diff options
author | Sorokin Alexei <[email protected]> | 2016-02-16 02:09:29 +0300 |
---|---|---|
committer | Wolfgang Ulbrich <[email protected]> | 2016-02-21 11:51:49 +0100 |
commit | 44a6c2f7e478fce00cc987bb76ac519704c13da2 (patch) | |
tree | bc14dec92c73292752b2133b697ba8572c2d70cf | |
parent | 25e25157410ff41965dd38f426538fed6c934913 (diff) | |
download | mate-panel-44a6c2f7e478fce00cc987bb76ac519704c13da2.tar.bz2 mate-panel-44a6c2f7e478fce00cc987bb76ac519704c13da2.tar.xz |
merge panel_load_menu_image_deferred() into setup_menuitem_with_icon()
also rename setup_menu_item_with_icon() to setup_menuitem_with_icon(),
and drop GtkStock support from it
-rw-r--r-- | mate-panel/menu.c | 123 | ||||
-rw-r--r-- | mate-panel/menu.h | 11 | ||||
-rw-r--r-- | mate-panel/panel-menu-items.c | 58 | ||||
-rw-r--r-- | mate-panel/panel-recent.c | 14 |
4 files changed, 83 insertions, 123 deletions
diff --git a/mate-panel/menu.c b/mate-panel/menu.c index fd713d53..1a80fb02 100644 --- a/mate-panel/menu.c +++ b/mate-panel/menu.c @@ -55,13 +55,6 @@ static GtkWidget *populate_menu_from_directory (GtkWidget *menu, MateMenuTreeDirectory *directory); -static void panel_load_menu_image_deferred (GtkWidget *image_menu_item, - GtkIconSize icon_size, - const char *stock_id, - GIcon *gicon, - const char *image_filename, - const char *fallback_image_filename); - static gboolean panel_menu_key_press_handler (GtkWidget *widget, GdkEventKey *event); @@ -818,6 +811,32 @@ menu_escape_underscores_and_prepend (const char *text) } 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); +} + +void setup_menuitem (GtkWidget *menuitem, GtkIconSize icon_size, GtkWidget *image, @@ -848,9 +867,13 @@ setup_menuitem (GtkWidget *menuitem, gtk_container_add (GTK_CONTAINER (menuitem), label); if (image) { + gint icon_height = PANEL_DEFAULT_MENU_ICON_SIZE; + + gtk_icon_size_lookup (icon_size, NULL, &icon_height); gtk_widget_show (image); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image); + gtk_image_set_pixel_size (GTK_IMAGE(image), icon_height); } gtk_widget_show (menuitem); @@ -1063,16 +1086,11 @@ create_submenu_entry (GtkWidget *menu, 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)); + setup_menuitem_with_icon (menuitem, + panel_menu_icon_get_size (), + NULL, + matemenu_tree_directory_get_icon (directory), + matemenu_tree_directory_get_name (directory)); gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); @@ -1149,18 +1167,13 @@ create_menuitem (GtkWidget *menu, 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)); + setup_menuitem_with_icon (menuitem, + panel_menu_icon_get_size (), + NULL, + alias_directory ? matemenu_tree_directory_get_icon (alias_directory) : + matemenu_tree_entry_get_icon (entry), + 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)) @@ -1412,22 +1425,6 @@ populate_menu_from_directory (GtkWidget *menu, return menu; } -void -setup_menu_item_with_icon (GtkWidget *item, - GtkIconSize icon_size, - const char *icon_name, - const char *stock_id, - GIcon *gicon, - const char *title) -{ - if (icon_name || gicon || stock_id) - panel_load_menu_image_deferred (item, icon_size, - stock_id, gicon, - icon_name, NULL); - - setup_menuitem (item, icon_size, NULL, title); -} - static void main_menu_append (GtkWidget *main_menu, gpointer data) @@ -1479,42 +1476,6 @@ GtkWidget* create_main_menu(PanelWidget* panel) return main_menu; } -static void -panel_load_menu_image_deferred (GtkWidget *image_menu_item, - GtkIconSize icon_size, - const char *stock_id, - GIcon *gicon, - const char *image_filename, - const char *fallback_image_filename) -{ - GtkWidget *image; - int icon_height = PANEL_DEFAULT_MENU_ICON_SIZE; - - gtk_icon_size_lookup (icon_size, NULL, &icon_height); - - image = gtk_image_new (); - g_object_set (image, "icon-size", icon_size, NULL); - gtk_image_set_pixel_size (GTK_IMAGE(image), icon_height); - - GIcon *icon = NULL; - - if (gicon != NULL) { - icon = g_object_ref (gicon); - } else if (stock_id != NULL ) { - icon = g_themed_icon_new (stock_id); - } else if (image_filename != NULL) { - 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); - - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (image_menu_item), - image); -} - static gboolean panel_menu_key_press_handler (GtkWidget *widget, GdkEventKey *event) diff --git a/mate-panel/menu.h b/mate-panel/menu.h index e82760d5..0c6d3495 100644 --- a/mate-panel/menu.h +++ b/mate-panel/menu.h @@ -36,12 +36,11 @@ void setup_menuitem (GtkWidget *menuitem, GtkIconSize icon_size, GtkWidget *pixmap, const char *title); -void setup_menu_item_with_icon (GtkWidget *item, - GtkIconSize icon_size, - const char *icon_name, - const char *stock_id, - GIcon *gicon, - const char *title); +void setup_menuitem_with_icon (GtkWidget *menuitem, + GtkIconSize icon_size, + GIcon *gicon, + const char *image_filename, + const char *title); GtkWidget *create_empty_menu (void); GtkWidget *create_applications_menu (const char *menu_file, diff --git a/mate-panel/panel-menu-items.c b/mate-panel/panel-menu-items.c index 76289ff6..6d9be2e1 100644 --- a/mate-panel/panel-menu-items.c +++ b/mate-panel/panel-menu-items.c @@ -246,8 +246,8 @@ panel_menu_items_append_from_desktop (GtkWidget *menu, item = gtk_image_menu_item_new (); } - setup_menu_item_with_icon (item, panel_menu_icon_get_size (), - icon, NULL, NULL, name); + setup_menuitem_with_icon (item, panel_menu_icon_get_size (), + NULL, icon, name); panel_util_set_tooltip_text (item, comment); @@ -292,10 +292,10 @@ panel_menu_items_append_place_item (const char *icon_name, char *user_data; item = panel_image_menu_item_new (); - setup_menu_item_with_icon (item, - panel_menu_icon_get_size (), - icon_name, NULL, gicon, - title); + setup_menuitem_with_icon (item, + panel_menu_icon_get_size (), + gicon, icon_name, + title); panel_util_set_tooltip_text (item, tooltip); @@ -323,11 +323,11 @@ panel_menu_items_create_action_item_full (PanelActionButtonType action_type, return NULL; item = gtk_image_menu_item_new (); - setup_menu_item_with_icon (item, - panel_menu_icon_get_size (), - panel_action_get_icon_name (action_type), - NULL, NULL, - label ? label : panel_action_get_text (action_type)); + setup_menuitem_with_icon (item, + panel_menu_icon_get_size (), + NULL, + panel_action_get_icon_name (action_type), + label ? label : panel_action_get_text (action_type)); panel_util_set_tooltip_text (item, tooltip ? @@ -468,9 +468,9 @@ panel_place_menu_item_append_gtk_bookmarks (GtkWidget *menu) GtkWidget *item; item = gtk_image_menu_item_new (); - setup_menu_item_with_icon (item, panel_menu_icon_get_size (), - PANEL_ICON_BOOKMARKS, NULL, NULL, - _("Bookmarks")); + setup_menuitem_with_icon (item, panel_menu_icon_get_size (), + NULL, PANEL_ICON_BOOKMARKS, + _("Bookmarks")); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); @@ -601,10 +601,10 @@ panel_menu_item_append_drive (GtkWidget *menu, title = g_drive_get_name (drive); item = panel_image_menu_item_new (); - setup_menu_item_with_icon (item, - panel_menu_icon_get_size (), - NULL, NULL, icon, - title); + setup_menuitem_with_icon (item, + panel_menu_icon_get_size (), + icon, NULL, + title); g_object_unref (icon); tooltip = g_strdup_printf (_("Rescan %s"), title); @@ -701,10 +701,10 @@ panel_menu_item_append_volume (GtkWidget *menu, title = g_volume_get_name (volume); item = panel_image_menu_item_new (); - setup_menu_item_with_icon (item, - panel_menu_icon_get_size (), - NULL, NULL, icon, - title); + setup_menuitem_with_icon (item, + panel_menu_icon_get_size (), + icon, NULL, + title); g_object_unref (icon); tooltip = g_strdup_printf (_("Mount %s"), title); @@ -912,9 +912,9 @@ panel_place_menu_item_append_local_gio (PanelPlaceMenuItem *place_item, GtkWidget *item; item = gtk_image_menu_item_new (); - setup_menu_item_with_icon (item, panel_menu_icon_get_size (), - PANEL_ICON_REMOVABLE_MEDIA, - NULL, NULL, + setup_menuitem_with_icon (item, panel_menu_icon_get_size (), + NULL, + PANEL_ICON_REMOVABLE_MEDIA, _("Removable Media")); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); @@ -999,10 +999,10 @@ panel_place_menu_item_append_remote_gio (PanelPlaceMenuItem *place_item, GtkWidget *item; item = panel_image_menu_item_new (); - setup_menu_item_with_icon (item, panel_menu_icon_get_size (), - PANEL_ICON_NETWORK_SERVER, - NULL, NULL, - _("Network Places")); + setup_menuitem_with_icon (item, panel_menu_icon_get_size (), + NULL, + PANEL_ICON_NETWORK_SERVER, + _("Network Places")); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); diff --git a/mate-panel/panel-recent.c b/mate-panel/panel-recent.c index bfc7d523..b3d5beb6 100644 --- a/mate-panel/panel-recent.c +++ b/mate-panel/panel-recent.c @@ -189,11 +189,11 @@ panel_recent_append_documents_menu (GtkWidget *top_menu, int size; menu_item = gtk_image_menu_item_new (); - setup_menu_item_with_icon (menu_item, - panel_menu_icon_get_size (), - PANEL_ICON_RECENT, - NULL, NULL, - _("Recent Documents")); + setup_menuitem_with_icon (menu_item, + panel_menu_icon_get_size (), + NULL, + PANEL_ICON_RECENT, + _("Recent Documents")); recent_menu = gtk_recent_chooser_menu_new_for_manager (manager); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), recent_menu); @@ -228,10 +228,10 @@ panel_recent_append_documents_menu (GtkWidget *top_menu, add_menu_separator (recent_menu); menu_item = gtk_image_menu_item_new (); - setup_menu_item_with_icon (menu_item, + setup_menuitem_with_icon (menu_item, panel_menu_icon_get_size (), NULL, - GTK_STOCK_CLEAR, NULL, + "edit-clear", _("Clear Recent Documents...")); panel_util_set_tooltip_text (menu_item, _("Clear all items from the recent documents list")); |