Enlightenment CVS committal Author : andrunko Project : e17 Module : libs/etk
Dir : e17/libs/etk/src/lib Modified Files: etk_combobox.c etk_combobox.h Log Message: Added method to set combobox fields. Added signal item-activated to combobox. =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_combobox.c,v retrieving revision 1.48 retrieving revision 1.49 diff -u -3 -r1.48 -r1.49 --- etk_combobox.c 6 Aug 2007 12:02:40 -0000 1.48 +++ etk_combobox.c 15 Aug 2007 00:12:38 -0000 1.49 @@ -22,6 +22,7 @@ enum Etk_Combobox_Signal_Id { + ETK_COMBOBOX_ITEM_ACTIVATED_SIGNAL, ETK_COMBOBOX_ACTIVE_ITEM_CHANGED_SIGNAL, ETK_COMBOBOX_NUM_SIGNALS }; @@ -89,6 +90,8 @@ combobox_type = etk_type_new("Etk_Combobox", ETK_WIDGET_TYPE, sizeof(Etk_Combobox), ETK_CONSTRUCTOR(_etk_combobox_constructor), ETK_DESTRUCTOR(_etk_combobox_destructor)); + _etk_combobox_signals[ETK_COMBOBOX_ITEM_ACTIVATED_SIGNAL] = etk_signal_new("item-activated", + combobox_type, -1, etk_marshaller_VOID__POINTER, NULL, NULL); _etk_combobox_signals[ETK_COMBOBOX_ACTIVE_ITEM_CHANGED_SIGNAL] = etk_signal_new("active-item-changed", combobox_type, -1, etk_marshaller_VOID__VOID, NULL, NULL); @@ -434,6 +437,73 @@ } /** + * @brief Sets the values of the cells of the combobox + * @param combobox a combobox + * @param ... the different widgets to attach to the columns of the item: + * there must be as many arguments as the number of columns in the combobox, one for each column. @n + * - If the type of the corresponding column is ETK_COMBOBOX_LABEL, the argument must be a "const char *" @n + * - If the type of the corresponding column is ETK_COMBOBOX_IMAGE, the argument must be an "Etk_Image *" @n + * - If the type of the corresponding column is ETK_COMBOBOX_OTHER, the argument must be an "Etk_Widget *" + */ +void etk_combobox_fields_set(Etk_Combobox *combobox, ...) +{ + va_list args; + + if (!combobox) + return; + + va_start(args, combobox); + etk_combobox_fields_set_valist(combobox, args); + va_end(args); +} + +/** + * @brief Sets the values of the cells of the combobox + * @param combobox a combobox + * @param args the different widgets to attach to the columns of the item: + * there must be as many arguments as the number of columns in the combobox, one for each column. @n + * - If the type of the corresponding column is ETK_COMBOBOX_LABEL, the argument must be a "const char *" @n + * - If the type of the corresponding column is ETK_COMBOBOX_IMAGE, the argument must be an "Etk_Image *" @n + * - If the type of the corresponding column is ETK_COMBOBOX_OTHER, the argument must be an "Etk_Widget *" + */ +void etk_combobox_fields_set_valist(Etk_Combobox *combobox, va_list args) +{ + int i; + Etk_Widget *widget; + + if (!combobox) + return; + + if (!combobox->built) + { + ETK_WARNING("Unable to set the specified fields. The combobox is not built yet."); + return; + } + + for (i = 0; i < combobox->num_cols; i++) + { + switch (combobox->cols[i]->type) + { + case ETK_COMBOBOX_LABEL: + etk_label_set(ETK_LABEL(combobox->active_item_children[i]), va_arg(args, char *)); + break; + case ETK_COMBOBOX_IMAGE: + widget = ETK_WIDGET(va_arg(args, Etk_Widget *)); + if (widget) + etk_image_copy(ETK_IMAGE(combobox->active_item_children[i]), ETK_IMAGE(widget)); + else + etk_image_set_from_file(ETK_IMAGE(combobox->active_item_children[i]), NULL, NULL); + break; + case ETK_COMBOBOX_OTHER: + widget = va_arg(args, Etk_Widget *); + break; + default: + break; + } + } +} + +/** * @brief Sets the values of the cells of the combobox item * @param item a combobox item * @param ... the different widgets to attach to the columns of the item: @@ -734,7 +804,10 @@ break; } } - + + if (item) + etk_signal_emit(_etk_combobox_signals[ETK_COMBOBOX_ITEM_ACTIVATED_SIGNAL], ETK_OBJECT(combobox), NULL, item); + if (combobox->active_item != item) { combobox->active_item = item; @@ -1506,6 +1579,12 @@ * - Etk_Combobox * * \par Signals: + * @signal_name "item-activated": Emitted when an item is activated + * @signal_cb void callback(Etk_Combobox *combobox, Etk_Combobox_Item *item, void *data) + * @signal_arg combobox: the combobox whose item has been activated + * @signal_arg item: the activated item + * @signal_data + * \par * @signal_name "active-item-changed": Emitted when the active item is changed (when the user selects another items) * @signal_cb void callback(Etk_Combobox *combobox, void *data) * @signal_arg combobox: the combobox whose active item has been changed =================================================================== RCS file: /cvs/e/e17/libs/etk/src/lib/etk_combobox.h,v retrieving revision 1.22 retrieving revision 1.23 diff -u -3 -r1.22 -r1.23 --- etk_combobox.h 6 Aug 2007 12:02:40 -0000 1.22 +++ etk_combobox.h 15 Aug 2007 00:12:38 -0000 1.23 @@ -138,6 +138,9 @@ void etk_combobox_item_remove(Etk_Combobox_Item *item); void etk_combobox_clear(Etk_Combobox *combobox); +void etk_combobox_fields_set(Etk_Combobox *combobox, ...); +void etk_combobox_fields_set_valist(Etk_Combobox *combobox, va_list args); + void etk_combobox_item_fields_set(Etk_Combobox_Item *item, ...); void etk_combobox_item_fields_set_valist(Etk_Combobox_Item *item, va_list args); void etk_combobox_item_field_set(Etk_Combobox_Item *item, int column, void *value); ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs