[Xfce4-commits] [xfce/xfce4-panel] 01/01: Revert "Applications menu icon sizing fixes" (Bug #14976)

noreply at xfce.org noreply at xfce.org
Thu Jan 3 15:09:06 CET 2019


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

o   c   h   o   s   i       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository xfce/xfce4-panel.

commit dc1f684d600884583d93cfbdae6b78a6b2b9ee9f
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date:   Thu Jan 3 15:07:32 2019 +0100

    Revert "Applications menu icon sizing fixes" (Bug #14976)
    
    This reverts commit c04e40bcbf319b294f2e34f374fdb350571d6f72.
    Without the GdkPixbuf logic in this commit the image file option of the
    applications menu doesn't work anymore. Allowing non-square icons is a
    feature of the panel, but it can much more easily be reverted, if
    needed.
---
 plugins/applicationsmenu/applicationsmenu.c | 52 ++++++++++++++++++++++++-----
 1 file changed, 43 insertions(+), 9 deletions(-)

diff --git a/plugins/applicationsmenu/applicationsmenu.c b/plugins/applicationsmenu/applicationsmenu.c
index b05128b..ce51d03 100644
--- a/plugins/applicationsmenu/applicationsmenu.c
+++ b/plugins/applicationsmenu/applicationsmenu.c
@@ -362,10 +362,7 @@ applications_menu_plugin_set_property (GObject      *object,
     case PROP_BUTTON_ICON:
       g_free (plugin->button_icon);
       plugin->button_icon = g_value_dup_string (value);
-      gtk_image_set_from_icon_name (GTK_IMAGE (plugin->icon),
-                                    panel_str_is_empty (plugin->button_icon) ?
-                                    DEFAULT_ICON_NAME : plugin->button_icon,
-                                    GTK_ICON_SIZE_BUTTON);
+
       force_a_resize = TRUE;
       break;
 
@@ -474,10 +471,19 @@ applications_menu_plugin_size_changed (XfcePanelPlugin *panel_plugin,
                                        gint             size)
 {
   ApplicationsMenuPlugin *plugin = XFCE_APPLICATIONS_MENU_PLUGIN (panel_plugin);
+  gint                    row_size;
   XfcePanelPluginMode     mode;
   GtkRequisition          label_size;
   GtkOrientation          orientation;
-  gint                    icon_size;
+  gint                    border_thickness;
+  GdkPixbuf              *icon;
+  gint                    icon_width_max, icon_height_max;
+  gint                    icon_width = 0;
+  GdkScreen              *screen;
+  GtkIconTheme           *icon_theme = NULL;
+  gchar                  *icon_name;
+  GtkStyleContext        *ctx;
+  GtkBorder               padding, border;
 
   gtk_box_set_child_packing (GTK_BOX (plugin->box), plugin->icon,
                              !plugin->show_button_title,
@@ -491,16 +497,44 @@ applications_menu_plugin_size_changed (XfcePanelPlugin *panel_plugin,
   else
     orientation = GTK_ORIENTATION_VERTICAL;
 
+  row_size = size / xfce_panel_plugin_get_nrows (panel_plugin);
+  /* style thickness */
+  ctx = gtk_widget_get_style_context (plugin->button);
+  gtk_style_context_get_padding (ctx, gtk_widget_get_state_flags (plugin->button), &padding);
+  gtk_style_context_get_border (ctx, gtk_widget_get_state_flags (plugin->button), &border);
+  border_thickness = MAX (padding.left + padding.right + border.left + border.right,
+                          padding.top + padding.bottom + border.top + border.bottom);
+
+  /* arbitrary limit on non-square icon width in horizontal panel */
+  icon_width_max = (mode == XFCE_PANEL_PLUGIN_MODE_HORIZONTAL) ?
+    6 * row_size - border_thickness : size - border_thickness;
+  icon_height_max = row_size - border_thickness;
+
+  screen = gtk_widget_get_screen (GTK_WIDGET (plugin));
+  if (G_LIKELY (screen != NULL))
+    icon_theme = gtk_icon_theme_get_for_screen (screen);
 
-  icon_size = xfce_panel_plugin_get_icon_size (panel_plugin);
-  gtk_image_set_pixel_size (GTK_IMAGE (plugin->icon), icon_size);
+  icon_name = panel_str_is_empty (plugin->button_icon) ?
+    DEFAULT_ICON_NAME : plugin->button_icon;
+
+  icon = xfce_panel_pixbuf_from_source_at_size (icon_name,
+                                                icon_theme,
+                                                icon_width_max,
+                                                icon_height_max);
+
+  if (G_LIKELY (icon != NULL))
+    {
+      gtk_image_set_from_pixbuf (GTK_IMAGE (plugin->icon), icon);
+      icon_width = gdk_pixbuf_get_width (icon);
+      g_object_unref (G_OBJECT (icon));
+    }
 
   if (plugin->show_button_title &&
       mode == XFCE_PANEL_PLUGIN_MODE_DESKBAR)
     {
       /* check if the label (minimum size) fits next to the icon */
       gtk_widget_get_preferred_size (GTK_WIDGET (plugin->label), &label_size, NULL);
-      if (label_size.width <= size - icon_size - 4)
+      if (label_size.width <= size - icon_width - 2 - border_thickness)
         orientation = GTK_ORIENTATION_HORIZONTAL;
     }
 
@@ -569,7 +603,7 @@ applications_menu_plugin_configure_plugin_icon_chooser (GtkWidget              *
       icon = exo_icon_chooser_dialog_get_icon (EXO_ICON_CHOOSER_DIALOG (chooser));
       g_object_set (G_OBJECT (plugin), "button-icon", icon, NULL);
       gtk_image_set_from_icon_name (GTK_IMAGE (plugin->dialog_icon),
-                                    panel_str_is_empty (plugin->button_icon) ?
+                                    exo_str_is_empty (plugin->button_icon) ?
                                     DEFAULT_ICON_NAME : plugin->button_icon,
                                     GTK_ICON_SIZE_DIALOG);
       g_free (icon);

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


More information about the Xfce4-commits mailing list