[Xfce4-commits] [xfce/thunar] 01/01: Right mouse click will not display icons for custom actions. (Bug #14685)

noreply at xfce.org noreply at xfce.org
Tue Sep 18 22:47:47 CEST 2018


This is an automated email from the git hooks/post-receive script.

a   l   e   x       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       x   f   c   e   -   4   .   1   4   
   in repository xfce/thunar.

commit 0f6cc96a1d43664325ae2133c48d5395a19bd1af
Author: Jehan <jehan at girinstud.io>
Date:   Tue Sep 18 22:43:35 2018 +0200

    Right mouse click will not display icons for custom actions.
    (Bug #14685)
    
    g_icon_to_string() is not meant to return an icon name, it returns a
    "textual representation of the icon", which is mostly "proprietary to
    GIcon" (in GIO documentation's own words).
    In particular the reverse function to get a GIcon back from this
    representation is g_icon_new_for_string().
    
    The reason why it used to work was because of a special casing (which
    happens to be the most common case: when you create an icon with a
    single name); yet even if the most common, relying on special cases is a
    bad idea. The special case is about to be reinstated in GLib so it will
    work again as expected, yet only until the next time a widget uses a not
    special-cased GIcon, for instance if using fallback icons. It is better
    to really fix the code.
    
    Now the menu properly recreates the icon using g_icon_new_for_string(),
    not assuming what type of icons it was (it could be an icon name, a
    path, a list of icon names, or whatever else proprietary representation
    any type of icon may use now or in the future).
    Also update the doc of thunarx_menu_item_new() to explicitly states that
    the icon parameter is a textual representation as returned by
    g_icon_to_string(). In particular this won't break any plug-ins as
    single icon names and icon paths are proper representations for icons
    too.
---
 thunar/thunar-menu-util.c   | 16 +++++++++++-----
 thunarx/thunarx-menu-item.c |  7 +++++--
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/thunar/thunar-menu-util.c b/thunar/thunar-menu-util.c
index b01f3d2..ca32ee4 100644
--- a/thunar/thunar-menu-util.c
+++ b/thunar/thunar-menu-util.c
@@ -36,7 +36,7 @@ extension_action_callback (GtkAction *action,
 static GtkAction *
 action_from_menu_item (GObject *item)
 {
-  gchar *name, *label, *tooltip, *icon_name;
+  gchar *name, *label, *tooltip, *icon_str;
   gboolean  sensitive, priority;
   GtkAction *action;
 
@@ -46,7 +46,7 @@ action_from_menu_item (GObject *item)
                 "name", &name,
                 "label", &label,
                 "tooltip", &tooltip,
-                "icon", &icon_name,
+                "icon", &icon_str,
                 "sensitive", &sensitive,
                 "priority", &priority,
                 NULL);
@@ -54,9 +54,15 @@ action_from_menu_item (GObject *item)
 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
   action = gtk_action_new (name, label, tooltip, NULL);
 
-  if (icon_name != NULL)
+  if (icon_str != NULL)
     {
-      gtk_action_set_icon_name (action, icon_name);
+      GIcon *icon = g_icon_new_for_string (icon_str, NULL);
+
+      if (icon)
+        {
+          gtk_action_set_gicon (action, icon);
+          g_object_unref (icon);
+        }
     }
 
   gtk_action_set_sensitive (action, sensitive);
@@ -71,7 +77,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
   g_free (name);
   g_free (label);
   g_free (tooltip);
-  g_free (icon_name);
+  g_free (icon_str);
 
   return action;
 }
diff --git a/thunarx/thunarx-menu-item.c b/thunarx/thunarx-menu-item.c
index 9f4f608..d9a518c 100644
--- a/thunarx/thunarx-menu-item.c
+++ b/thunarx/thunarx-menu-item.c
@@ -145,7 +145,8 @@ thunarx_menu_item_class_init (ThunarxMenuItemClass *klass)
                                    PROP_ICON,
                                    g_param_spec_string ("icon",
                                                         "Icon",
-                                                        "Name of the icon to display in the menu item",
+                                                        "Textual representation of the icon (as returned "
+                                                        "by g_icon_to_string()) to display in the menu item",
                                                         NULL,
                                                         G_PARAM_READWRITE));
   g_object_class_install_property (gobject_class,
@@ -312,7 +313,9 @@ thunarx_menu_item_finalize (GObject *object)
  * @name: identifier for the menu item
  * @label: user-visible label of the menu item
  * @tooltip: tooltip of the menu item
- * @icon: path or name of the icon to display in the menu item
+ * @icon: textual representation of the icon to display in the menu
+ *        item, as returned by g_icon_to_string(). A path or icon name
+ *        are valid representations too.
  *
  * Creates a new menu item that can be added to the toolbar or to a contextual menu.
  *

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list