void nld_search_context_picker_set_context (NldSearchContextPicker * picker, int context_id) { NldSearchContextPickerPrivate *priv = NLD_SEARCH_CONTEXT_PICKER_GET_PRIVATE (picker); GList *children; children = gtk_container_get_children (GTK_CONTAINER (priv->menu)); while (children) { GtkMenuItem *item = children->data; int item_id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "NldSearchContextPicker:content_id")); if (item_id == context_id) { item_activated (item, picker); return; } children = children->next; } g_list_free (children); priv->cur_context = -1; g_signal_emit (picker, signals[CONTEXT_CHANGED], 0); }
void nld_search_context_picker_add_context (NldSearchContextPicker * picker, const char *label, const char *icon_name, int context_id) { NldSearchContextPickerPrivate *priv = NLD_SEARCH_CONTEXT_PICKER_GET_PRIVATE (picker); GtkWidget *item = gtk_image_menu_item_new_with_label (label); GtkWidget *image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU); GList *children = gtk_container_get_children (GTK_CONTAINER (priv->menu)); gboolean first = children == NULL; gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); g_object_set_data (G_OBJECT (item), "NldSearchContextPicker:context_id", GINT_TO_POINTER (context_id)); g_signal_connect (item, "activate", G_CALLBACK (item_activated), picker); gtk_widget_show_all (item); gtk_container_add (GTK_CONTAINER (priv->menu), item); if (first) { item_activated (GTK_MENU_ITEM (item), picker); g_list_free (children); } }
static void item_cb (GtkWidget *menuitem, ItemData *data) { item_activated (data->icon_list, data->path); }
void itemActivated_(QTreeWidgetItem* item, int col) { item_activated(item, col); }