static GtkWidget * create_submenu_entry (GtkWidget *menu, MateMenuTreeDirectory *directory) { GtkWidget *menuitem; gboolean force_categories_icon; force_categories_icon = g_object_get_data (G_OBJECT (menu), "panel-menu-force-icon-for-categories") != NULL; if (force_categories_icon) menuitem = panel_image_menu_item_new (); else menuitem = gtk_image_menu_item_new (); panel_load_menu_image_deferred (menuitem, panel_menu_icon_get_size (), NULL, NULL, matemenu_tree_directory_get_icon (directory), PANEL_ICON_FOLDER); setup_menuitem (menuitem, panel_menu_icon_get_size (), NULL, matemenu_tree_directory_get_name (directory)); gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); gtk_widget_show (menuitem); return menuitem; }
void setup_menu_item_with_icon (GtkWidget *item, GtkIconSize icon_size, const char *icon_name, GIcon *gicon, const char *title) { if (icon_name || gicon) panel_load_menu_image_deferred (item, icon_size, gicon, icon_name, NULL); setup_menuitem (item, icon_size, NULL, title); }
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 void create_menuitem (GtkWidget *menu, GMenuTreeEntry *entry, GMenuTreeDirectory *alias_directory) { GtkWidget *menuitem; menuitem = panel_image_menu_item_new2 (); if (alias_directory) panel_load_menu_image_deferred (menuitem, panel_menu_icon_get_size (), gmenu_tree_directory_get_icon (alias_directory), NULL, NULL); else panel_load_menu_image_deferred (menuitem, panel_menu_icon_get_size (), g_app_info_get_icon (G_APP_INFO (gmenu_tree_entry_get_app_info (entry))), NULL, NULL); setup_menuitem (menuitem, panel_menu_icon_get_size (), NULL, alias_directory ? gmenu_tree_directory_get_name (alias_directory) : g_app_info_get_display_name (G_APP_INFO (gmenu_tree_entry_get_app_info (entry)))); if (alias_directory && gmenu_tree_directory_get_comment (alias_directory)) panel_util_set_tooltip_text (menuitem, gmenu_tree_directory_get_comment (alias_directory)); else if (!alias_directory) { const char *description = g_app_info_get_description (G_APP_INFO (gmenu_tree_entry_get_app_info (entry))); if (!description) description = g_desktop_app_info_get_generic_name (gmenu_tree_entry_get_app_info (entry)); if (description) panel_util_set_tooltip_text (menuitem, description); } g_signal_connect_after (menuitem, "button_press_event", G_CALLBACK (menu_dummy_button_press_event), NULL); if (!panel_lockdown_get_panels_locked_down_s ()) { GIcon *icon; 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); icon = g_app_info_get_icon (G_APP_INFO (gmenu_tree_entry_get_app_info (entry))); if (icon != NULL) gtk_drag_source_set_icon_gicon (menuitem, icon); 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); }