static void panel_addto_prepend_entry (GSList **parent_list, MateMenuTreeEntry *entry, const char *filename) { PanelAddtoAppList *data; data = g_new0 (PanelAddtoAppList, 1); data->item_info.type = PANEL_ADDTO_LAUNCHER; data->item_info.name = g_strdup (matemenu_tree_entry_get_display_name (entry)); data->item_info.description = g_strdup (matemenu_tree_entry_get_comment (entry)); data->item_info.icon = g_strdup (matemenu_tree_entry_get_icon (entry)); data->item_info.launcher_path = g_strdup (matemenu_tree_entry_get_desktop_file_path (entry)); data->item_info.static_data = FALSE; *parent_list = g_slist_prepend (*parent_list, data); }
static void create_menuitem (GtkWidget *menu, MateMenuTreeEntry *entry, MateMenuTreeDirectory *alias_directory) { GtkWidget *menuitem; menuitem = panel_image_menu_item_new (); g_object_set_data_full (G_OBJECT (menuitem), "panel-menu-tree-entry", matemenu_tree_item_ref (entry), (GDestroyNotify) matemenu_tree_item_unref); if (alias_directory) //FIXME: we should probably use this data when we do dnd or //context menu for this menu item g_object_set_data_full (G_OBJECT (menuitem), "panel-menu-tree-alias-directory", matemenu_tree_item_ref (alias_directory), (GDestroyNotify) matemenu_tree_item_unref); panel_load_menu_image_deferred (menuitem, panel_menu_icon_get_size (), NULL, NULL, alias_directory ? matemenu_tree_directory_get_icon (alias_directory) : matemenu_tree_entry_get_icon (entry), PANEL_STOCK_DEFAULT_ICON); setup_menuitem (menuitem, panel_menu_icon_get_size (), NULL, alias_directory ? matemenu_tree_directory_get_name (alias_directory) : matemenu_tree_entry_get_display_name (entry)); if (alias_directory && matemenu_tree_directory_get_comment (alias_directory)) panel_util_set_tooltip_text (menuitem, matemenu_tree_directory_get_comment (alias_directory)); else if (!alias_directory && matemenu_tree_entry_get_comment (entry)) panel_util_set_tooltip_text (menuitem, matemenu_tree_entry_get_comment (entry)); else if (!alias_directory && matemenu_tree_entry_get_generic_name (entry)) panel_util_set_tooltip_text (menuitem, matemenu_tree_entry_get_generic_name (entry)); g_signal_connect_after (menuitem, "button_press_event", G_CALLBACK (menuitem_button_press_event), NULL); if (!panel_lockdown_get_locked_down ()) { static GtkTargetEntry menu_item_targets[] = { { "text/uri-list", 0, 0 } }; gtk_drag_source_set (menuitem, GDK_BUTTON1_MASK | GDK_BUTTON2_MASK, menu_item_targets, 1, GDK_ACTION_COPY); if (matemenu_tree_entry_get_icon (entry) != NULL) { const char *icon; char *icon_no_ext; icon = matemenu_tree_entry_get_icon (entry); if (!g_path_is_absolute (icon)) { icon_no_ext = panel_xdg_icon_remove_extension (icon); gtk_drag_source_set_icon_name (menuitem, icon_no_ext); g_free (icon_no_ext); } } g_signal_connect (G_OBJECT (menuitem), "drag_begin", G_CALLBACK (drag_begin_menu_cb), NULL); g_signal_connect (menuitem, "drag_data_get", G_CALLBACK (drag_data_get_menu_cb), entry); g_signal_connect (menuitem, "drag_end", G_CALLBACK (drag_end_menu_cb), NULL); } gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); g_signal_connect (menuitem, "activate", G_CALLBACK (activate_app_def), entry); gtk_widget_show (menuitem); }
static gboolean panel_run_dialog_add_items_idle (PanelRunDialog *dialog) { GtkCellRenderer *renderer; GtkTreeViewColumn *column; GtkTreeModel *model_filter; GSList *all_applications; GSList *l; GSList *next; const char *prev_name; /* create list store */ dialog->program_list_store = gtk_list_store_new (NUM_COLUMNS, G_TYPE_ICON, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN); all_applications = get_all_applications (); /* Strip duplicates */ prev_name = NULL; for (l = all_applications; l; l = next) { MateMenuTreeEntry *entry = l->data; const char *entry_name; next = l->next; entry_name = matemenu_tree_entry_get_display_name (entry); if (prev_name && entry_name && strcmp (entry_name, prev_name) == 0) { matemenu_tree_item_unref (entry); all_applications = g_slist_delete_link (all_applications, l); } else { prev_name = entry_name; } } for (l = all_applications; l; l = l->next) { MateMenuTreeEntry *entry = l->data; GtkTreeIter iter; const gchar *icon = matemenu_tree_entry_get_icon (entry); GIcon *gicon = panel_gicon_from_icon_name (icon); gtk_list_store_append (dialog->program_list_store, &iter); gtk_list_store_set (dialog->program_list_store, &iter, COLUMN_GICON, gicon, COLUMN_NAME, matemenu_tree_entry_get_display_name (entry), COLUMN_COMMENT, matemenu_tree_entry_get_comment (entry), COLUMN_EXEC, matemenu_tree_entry_get_exec (entry), COLUMN_PATH, matemenu_tree_entry_get_desktop_file_path (entry), COLUMN_VISIBLE, TRUE, -1); g_object_unref (gicon); matemenu_tree_item_unref (entry); } g_slist_free (all_applications); model_filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (dialog->program_list_store), NULL); gtk_tree_model_filter_set_visible_column (GTK_TREE_MODEL_FILTER (model_filter), COLUMN_VISIBLE); gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->program_list), model_filter); //FIXME use the same search than the fuzzy one? gtk_tree_view_set_search_column (GTK_TREE_VIEW (dialog->program_list), COLUMN_NAME); renderer = gtk_cell_renderer_pixbuf_new (); g_object_set (renderer, "stock-size", panel_menu_icon_get_size(), NULL); column = gtk_tree_view_column_new (); gtk_tree_view_column_pack_start (column, renderer, FALSE); gtk_tree_view_column_set_attributes (column, renderer, "gicon", COLUMN_GICON, NULL); renderer = gtk_cell_renderer_text_new (); gtk_tree_view_column_pack_start (column, renderer, TRUE); gtk_tree_view_column_set_attributes (column, renderer, "text", COLUMN_NAME, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (dialog->program_list), column); dialog->add_items_idle_id = 0; return G_SOURCE_REMOVE; }