GtkWidget* panel_place_menu_item_new(gboolean use_image) { PanelPlaceMenuItem* menuitem; GtkWidget* image; menuitem = g_object_new(PANEL_TYPE_PLACE_MENU_ITEM, NULL); if (use_image) { image = gtk_image_new_from_icon_name(PANEL_ICON_FOLDER, panel_menu_icon_get_size()); } else { image = NULL; } setup_menuitem(GTK_WIDGET(menuitem), image ? panel_menu_icon_get_size() : GTK_ICON_SIZE_INVALID, image, _("Places")); menuitem->priv->use_image = use_image; menuitem->priv->menu = panel_place_menu_item_create_menu(menuitem); gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menuitem->priv->menu); return GTK_WIDGET(menuitem); }
GtkWidget * panel_desktop_menu_item_new (gboolean use_image, gboolean append_lock_logout) { PanelDesktopMenuItem *menuitem; GtkWidget *image; menuitem = g_object_new (PANEL_TYPE_DESKTOP_MENU_ITEM, NULL); if (use_image) image = gtk_image_new_from_icon_name ("computer", panel_menu_icon_get_size ()); else image = NULL; setup_menuitem (GTK_WIDGET (menuitem), image ? panel_menu_icon_get_size () : GTK_ICON_SIZE_INVALID, image, _("System")); menuitem->priv->use_image = use_image; menuitem->priv->append_lock_logout = append_lock_logout; if (append_lock_logout) panel_lockdown_notify_add (G_CALLBACK (panel_desktop_menu_item_recreate_menu), menuitem); menuitem->priv->menu = panel_desktop_menu_item_create_menu (menuitem); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menuitem->priv->menu); return GTK_WIDGET (menuitem); }
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_menuitem_with_icon (GtkWidget *menuitem, GtkIconSize icon_size, GIcon *gicon, const char *image_filename, const char *title) { GtkWidget *image; GIcon *icon = NULL; image = gtk_image_new (); g_object_set (image, "icon-size", icon_size, NULL); if (gicon) icon = g_object_ref (gicon); else if (image_filename) icon = panel_gicon_from_icon_name (image_filename); gtk_image_set_from_gicon (GTK_IMAGE(image), icon, icon_size); g_object_unref (icon); gtk_widget_show (image); setup_menuitem (menuitem, icon_size, image, title); }
GtkWidget * panel_desktop_menu_item_new (gboolean use_image, gboolean append_lock_logout) { PanelDesktopMenuItem *menuitem; char *name; #ifdef HAVE_TELEPATHY_GLIB PanelSessionManager *manager; #endif menuitem = g_object_new (PANEL_TYPE_DESKTOP_MENU_ITEM, NULL); name = panel_util_get_user_name (); if (use_image) { #ifdef HAVE_TELEPATHY_GLIB setup_menu_item_with_icon (GTK_WIDGET (menuitem), panel_menu_icon_get_size (), PANEL_ICON_USER_AVAILABLE, NULL, NULL, name); gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menuitem), TRUE); #else setup_menu_item_with_icon (GTK_WIDGET (menuitem), panel_menu_icon_get_size (), PANEL_ICON_COMPUTER, NULL, NULL, name); #endif } else setup_menuitem (GTK_WIDGET (menuitem), GTK_ICON_SIZE_INVALID, NULL, name); g_free (name); menuitem->priv->menu = panel_desktop_menu_item_create_menu (menuitem, append_lock_logout); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menuitem->priv->menu); #ifdef HAVE_TELEPATHY_GLIB manager = panel_session_manager_get (); menuitem->priv->presence_changed_id = g_signal_connect (manager, "presence-changed", G_CALLBACK (panel_desktop_menu_item_on_presence_changed), menuitem); panel_desktop_menu_item_on_presence_changed (manager, panel_session_manager_get_presence (manager), menuitem); #endif return GTK_WIDGET (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 GtkWidget * panel_menu_item_presence_new (TpAccountManager *account_manager, PanelSessionManagerPresenceType presence_type, const char *name, const char *icon, gboolean use_icon) { GtkWidget *item; if (!account_manager) return NULL; item = gtk_check_menu_item_new (); setup_menuitem (item, GTK_ICON_SIZE_INVALID, NULL, name); gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (item), TRUE); /* TODO: we need to add an icon at the right of this CheckMenuItem */ #if 0 if (use_icon) { GtkWidget *image; image = gtk_image_new_from_icon_name (icon, panel_menu_icon_get_size ()); gtk_container_add (GTK_CONTAINER (item), image); } #endif g_object_set_data (G_OBJECT (item), "panel-menu-presence", GINT_TO_POINTER (presence_type)); g_signal_connect (item, "activate", G_CALLBACK (panel_menu_item_activate_presence), account_manager); g_signal_connect (G_OBJECT (item), "button_press_event", G_CALLBACK (menu_dummy_button_press_event), NULL); return item; }
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); }