[Xfce4-commits] [xfce/xfce4-panel] 01/01: Applications menu icon sizing fixes

noreply at xfce.org noreply at xfce.org
Mon Mar 20 00:14:03 CET 2017


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

andrzejr pushed a commit to branch master
in repository xfce/xfce4-panel.

commit c04e40bcbf319b294f2e34f374fdb350571d6f72
Author: Andrzej <ndrwrdck at gmail.com>
Date:   Sun Mar 19 23:13:26 2017 +0000

    Applications menu icon sizing fixes
    
    Dropped support for stretching non-square icons to panel size and image files.
---
 plugins/applicationsmenu/applicationsmenu.c | 52 +++++------------------------
 1 file changed, 9 insertions(+), 43 deletions(-)

diff --git a/plugins/applicationsmenu/applicationsmenu.c b/plugins/applicationsmenu/applicationsmenu.c
index 29e0688..c717b59 100644
--- a/plugins/applicationsmenu/applicationsmenu.c
+++ b/plugins/applicationsmenu/applicationsmenu.c
@@ -349,7 +349,10 @@ 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;
 
@@ -450,19 +453,10 @@ 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                    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;
+  gint                    icon_size;
 
   gtk_box_set_child_packing (GTK_BOX (plugin->box), plugin->icon,
                              !plugin->show_button_title,
@@ -476,44 +470,16 @@ 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_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));
-    }
+  icon_size = xfce_panel_plugin_get_icon_size (panel_plugin);
+  gtk_image_set_pixel_size (GTK_IMAGE (plugin->icon), icon_size);
 
   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_width - 2 - border_thickness)
+      if (label_size.width <= size - icon_size - 4)
         orientation = GTK_ORIENTATION_HORIZONTAL;
     }
 
@@ -585,7 +551,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),
-                                    exo_str_is_empty (plugin->button_icon) ?
+                                    panel_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