Since there is work going on the combobox now, I thought this might go in
(or something like it)

This patch introduces two functions:
etk_combobox_item_fields_nth_set and etk_combobox_item_fields_nth_get
to get/set a specific column's widget of the combobox.
This is needed for perl bindings.

Regards,

--
Chady 'Leviathan' Kassouf
http://chady.net/
Index: etk_combobox.c
===================================================================
RCS file: /cvs/e/e17/libs/etk/src/lib/etk_combobox.c,v
retrieving revision 1.39
diff -u -r1.39 etk_combobox.c
--- etk_combobox.c	9 Mar 2007 02:53:05 -0000	1.39
+++ etk_combobox.c	9 Mar 2007 14:12:47 -0000
@@ -493,6 +493,50 @@
 }
 
 /**
+ * @brief Sets the value of the nth cell of the combobox item. The current widget of item will be destroyed
+ * @param item a combobox item
+ * @param index the index of the column to set
+ * @param field the widget to attach to the column of the item:
+ * @note The new widgets of the item will be automatically shown
+ */
+void etk_combobox_item_fields_nth_set(Etk_Combobox_Item *item, int index, void *field)
+{
+   Etk_Combobox *combobox;
+   
+   if (!item || !(combobox = item->combobox))
+      return;
+
+   if (index >= combobox->num_cols)
+      return;
+   
+  switch (combobox->cols[index]->type)
+  {
+     if (item->widgets[index])
+        etk_object_destroy(ETK_OBJECT(item->widgets[index]));
+      
+     case ETK_COMBOBOX_LABEL:
+        item->widgets[index] = etk_label_new((char *)field);
+        etk_widget_pass_mouse_events_set(item->widgets[index], ETK_TRUE);
+        break;
+     case ETK_COMBOBOX_IMAGE:
+        item->widgets[index] = (Etk_Widget *)field;
+        etk_widget_pass_mouse_events_set(item->widgets[index], ETK_TRUE);
+        break;
+     case ETK_COMBOBOX_OTHER:
+        item->widgets[index] = (Etk_Widget *)field;
+        break;
+     default:
+        item->widgets[index] = NULL;
+        break;
+  }
+  etk_widget_parent_set(item->widgets[index], ETK_WIDGET(item));
+  etk_widget_show(item->widgets[index]);
+   
+   if (combobox->active_item == item)
+      etk_combobox_active_item_set(combobox, item);
+}
+
+/**
  * @brief Gets the values of the cells of the combobox item
  * @param item a combobox item
  * @param ... the location where to store the different values of the cells of the item:
@@ -557,6 +601,49 @@
       etk_widget_parent_set(item->widgets[i], ETK_WIDGET(item));
       etk_widget_show(item->widgets[i]);
    }
+}
+
+/**
+ * @brief Gets the value of the nth cell of the combobox item
+ * @param item a combobox item
+ * @param index the index of the column to set
+ * @param field the widget to get from the column of the item:
+ */
+void etk_combobox_item_fields_nth_get(Etk_Combobox_Item *item, int index, void **field)
+{
+   Etk_Combobox *combobox;
+   
+   if (!item || !(combobox = item->combobox))
+      return;
+
+   if (index >= combobox->num_cols)
+      return;
+   
+   switch (combobox->cols[index]->type)
+   {
+      case ETK_COMBOBOX_LABEL:
+      {
+         const char **label;
+         if ((label = (const char **)field))
+            *label = etk_label_get(ETK_LABEL(item->widgets[index]));
+         break;
+      }
+      case ETK_COMBOBOX_IMAGE:
+      case ETK_COMBOBOX_OTHER:
+      {
+         Etk_Widget **widget;
+         if ((widget = (Etk_Widget **)field))
+            *widget = item->widgets[index];
+         break;
+      }
+      default:
+      {
+         *field = NULL;
+         break;
+      }
+   }
+   etk_widget_parent_set(item->widgets[index], ETK_WIDGET(item));
+   etk_widget_show(item->widgets[index]);
 }
 
 /**
Index: etk_combobox.h
===================================================================
RCS file: /cvs/e/e17/libs/etk/src/lib/etk_combobox.h,v
retrieving revision 1.17
diff -u -r1.17 etk_combobox.h
--- etk_combobox.h	9 Mar 2007 02:53:05 -0000	1.17
+++ etk_combobox.h	9 Mar 2007 14:12:47 -0000
@@ -143,6 +143,9 @@
 void etk_combobox_item_fields_get(Etk_Combobox_Item *item, ...);
 void etk_combobox_item_fields_get_valist(Etk_Combobox_Item *item, va_list args);
 
+void etk_combobox_item_fields_nth_set(Etk_Combobox_Item *item, int index, void *field);
+void etk_combobox_item_fields_nth_get(Etk_Combobox_Item *item, int index, void **field);
+
 void               etk_combobox_active_item_set(Etk_Combobox *combobox, Etk_Combobox_Item *item);
 Etk_Combobox_Item *etk_combobox_active_item_get(Etk_Combobox *combobox);
 int                etk_combobox_active_item_num_get(Etk_Combobox *combobox);
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to