diff options
-rw-r--r-- | plugins/filebrowser/pluma-file-browser-widget.c | 48 | ||||
-rw-r--r-- | pluma/pluma-utils.c | 30 | ||||
-rw-r--r-- | pluma/pluma-utils.h | 4 |
3 files changed, 33 insertions, 49 deletions
diff --git a/plugins/filebrowser/pluma-file-browser-widget.c b/plugins/filebrowser/pluma-file-browser-widget.c index 5056999b..f7f8b0db 100644 --- a/plugins/filebrowser/pluma-file-browser-widget.c +++ b/plugins/filebrowser/pluma-file-browser-widget.c @@ -1514,39 +1514,57 @@ get_topmost_file (GFile * file) } static GtkWidget * -create_goto_menu_item (PlumaFileBrowserWidget * obj, GList * item, - GdkPixbuf * icon) +create_goto_menu_item (PlumaFileBrowserWidget *obj, + GList *item, + GdkPixbuf *icon) { - GtkWidget *result; - gchar *unescape; + GtkWidget *menu_item; + gchar *label_text; GdkPixbuf *pixbuf = NULL; - Location *loc; + Location *loc; loc = (Location *) (item->data); - if (!get_from_bookmark_file (obj, loc->virtual_root, &unescape, &pixbuf)) { - unescape = pluma_file_browser_utils_file_basename (loc->virtual_root); + if (!get_from_bookmark_file (obj, loc->virtual_root, &label_text, &pixbuf)) { + label_text = pluma_file_browser_utils_file_basename (loc->virtual_root); if (icon) pixbuf = g_object_ref (icon); } if (pixbuf) { - result = pluma_image_menu_item_new_from_pixbuf (pixbuf, unescape); + /* code based on https://developer.gnome.org/gtk3/stable/GtkImageMenuItem.html */ + GtkWidget *box; + GtkWidget *icon; + GtkWidget *label; + + box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); + + icon = gtk_image_new_from_pixbuf (pixbuf); + + label = gtk_label_new (NULL); + gtk_label_set_text (GTK_LABEL (label), label_text); + gtk_label_set_xalign (GTK_LABEL (label), 0.0); + + menu_item = gtk_menu_item_new (); + gtk_container_add (GTK_CONTAINER (box), icon); + gtk_container_add (GTK_CONTAINER (box), label); + gtk_container_add (GTK_CONTAINER (menu_item), box); + g_object_unref (pixbuf); } else { - result = gtk_menu_item_new_with_label (unescape); + menu_item = gtk_menu_item_new_with_label (label_text); } - g_object_set_data (G_OBJECT (result), LOCATION_DATA_KEY, item); - g_signal_connect (result, "activate", - G_CALLBACK (on_location_jump_activate), obj); + g_object_set_data (G_OBJECT (menu_item), LOCATION_DATA_KEY, item); + g_signal_connect (menu_item, "activate", + G_CALLBACK (on_location_jump_activate), obj); - gtk_widget_show (result); + gtk_widget_show_all (menu_item); - g_free (unescape); + g_free (label_text); - return result; + return menu_item; } static GList * diff --git a/pluma/pluma-utils.c b/pluma/pluma-utils.c index 6dee2224..b398ad05 100644 --- a/pluma/pluma-utils.c +++ b/pluma/pluma-utils.c @@ -1669,33 +1669,3 @@ free_resources: g_regex_unref (regex); return found; } - -GtkWidget * -pluma_image_menu_item_new_from_pixbuf (GdkPixbuf *icon_pixbuf, - const gchar *label_name) -{ - gchar *concat; - GtkWidget *icon; - GtkWidget *box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); - - if (icon_pixbuf) - icon = gtk_image_new_from_pixbuf (icon_pixbuf); - else - icon = gtk_image_new (); - - concat = g_strconcat (label_name, " ", NULL); - - GtkWidget *label_menu = gtk_label_new (concat); - GtkWidget *menuitem = gtk_menu_item_new (); - - gtk_container_add (GTK_CONTAINER (box), icon); - gtk_container_add (GTK_CONTAINER (box), label_menu); - - gtk_container_add (GTK_CONTAINER (menuitem), box); - gtk_widget_show_all (menuitem); - - g_free (concat); - - return menuitem; -} - diff --git a/pluma/pluma-utils.h b/pluma/pluma-utils.h index 68b77737..1e0c8288 100644 --- a/pluma/pluma-utils.h +++ b/pluma/pluma-utils.h @@ -157,10 +157,6 @@ pluma_gtk_text_iter_regex_search (const GtkTextIter *iter, gboolean forward_search, gchar **replace_text); -GtkWidget * -pluma_image_menu_item_new_from_pixbuf (GdkPixbuf *icon_pixbuf, - const gchar *label_name); - G_END_DECLS #endif /* __PLUMA_UTILS_H__ */ |