[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[E-devel] [PATCH] add data set/get of specific columns of an Etk_Combobox_Item



Hi,

This is to allow people to get/set the widgets on specific columns of the combobox item.

--
Chady 'Leviathan' Kassouf
http://chady.net/
Index: etk_combobox.c
===================================================================
RCS file: /cvs/e/e17/proto/etk/src/lib/etk_combobox.c,v
retrieving revision 1.18
diff -u -r1.18 etk_combobox.c
--- etk_combobox.c	30 Jul 2006 21:09:32 -0000	1.18
+++ etk_combobox.c	4 Aug 2006 18:54:47 -0000
@@ -552,6 +552,61 @@
 }
 
 /**
+ * @brief Set the contents of a column in the combobox item
+ * @param item a combobox item
+ * @param col the column number
+ * @param data the data to set
+ * See etk_combobox_item_prepend()'s "..." argument for more information
+ */
+void etk_combobox_item_col_set(Etk_Combobox_Item *item, int col, void *data)
+{
+   Etk_Combobox * combobox;
+   int cols;
+   
+   if (!item)
+      return;
+   
+   combobox = item->combobox;
+   cols = combobox->num_cols;
+   if (col >= cols)
+      return;
+
+   if (item->widgets[col])
+      etk_object_destroy(ETK_OBJECT(item->widgets[col]));
+
+   switch(combobox->cols[col]->type)
+   {
+      case ETK_COMBOBOX_LABEL:
+         item->widgets[col] = etk_label_new((char *) data);
+         break;
+      case ETK_COMBOBOX_IMAGE:
+      case ETK_COMBOBOX_OTHER:
+         item->widgets[col] = (Etk_Widget *)data;
+      default:
+         break;
+   }
+        
+   etk_widget_parent_set(item->widgets[col], ETK_WIDGET(item));
+   etk_widget_pass_mouse_events_set(item->widgets[col], ETK_TRUE);
+   etk_widget_show(item->widgets[col]);
+}
+
+/**
+ * @brief Gets the contents of a column in the combobox item
+ * @param item a combobox item
+ * @param col the column number
+ * @return the data of the column
+ * See etk_combobox_item_prepend()'s "..." argument for more information
+ */
+void *etk_combobox_item_col_get(Etk_Combobox_Item *item, int col)
+{
+   if (!item || col >= item->combobox->num_cols)
+      return NULL;
+
+   return item->widgets[col];
+}
+
+/**
  * @brief Removes an item from the combobox
  * @param combobox a combobox
  * @param item the item to remove
Index: etk_combobox.h
===================================================================
RCS file: /cvs/e/e17/proto/etk/src/lib/etk_combobox.h,v
retrieving revision 1.10
diff -u -r1.10 etk_combobox.h
--- etk_combobox.h	16 May 2006 22:03:00 -0000	1.10
+++ etk_combobox.h	4 Aug 2006 18:54:47 -0000
@@ -127,6 +127,9 @@
 Etk_Combobox_Item *etk_combobox_item_append_relative(Etk_Combobox *combobox, Etk_Combobox_Item *relative, ...);
 Etk_Combobox_Item *etk_combobox_item_append_relative_valist(Etk_Combobox *combobox, Etk_Combobox_Item *relative, va_list args);
 
+void etk_combobox_item_col_set(Etk_Combobox_Item *item, int col, void *data);
+void *etk_combobox_item_col_get(Etk_Combobox_Item *item, int col);
+
 void etk_combobox_item_remove(Etk_Combobox *combobox, Etk_Combobox_Item *item);
 void etk_combobox_clear(Etk_Combobox *combobox);