[Xfce4-commits] [xfce/xfce4-panel] 01/01: Add icon-size property per panel

noreply at xfce.org noreply at xfce.org
Wed Nov 28 15:06:08 CET 2018


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 4d1b17980b43d4cba0edaa84fc3edced62193596
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date:   Wed Jul 4 23:28:30 2018 +0200

    Add icon-size property per panel
    
    Plugins using the xfce_panel_plugin_get_icon_size method returns either the
    fixed icon-size that users can now define per panel or a calculated icon-size.
    This way combinations of sizes that were previously impossible are do-able,
    e.g. a 32px panel with 16px icons. This should help with consistency of icons.
    
    Setting 'icon-size' to 0 results in "auto sizing" (i.e. icon-size
    calculated based on the size of the panel).
---
 libxfce4panel/libxfce4panel.symbols        |   1 +
 libxfce4panel/xfce-panel-plugin-provider.c |  11 +++
 libxfce4panel/xfce-panel-plugin-provider.h |   6 ++
 libxfce4panel/xfce-panel-plugin.c          |  82 +++++++++++++++++----
 panel/panel-application.c                  |   3 +-
 panel/panel-plugin-external.c              |  23 ++++++
 panel/panel-preferences-dialog.c           |  88 ++++++++++++++++++++++-
 panel/panel-preferences-dialog.glade       | 110 ++++++++++++++++++++++++++++-
 panel/panel-window.c                       |  49 ++++++++++++-
 wrapper/main.c                             |   4 ++
 10 files changed, 360 insertions(+), 17 deletions(-)

diff --git a/libxfce4panel/libxfce4panel.symbols b/libxfce4panel/libxfce4panel.symbols
index e3def53..92e7a81 100644
--- a/libxfce4panel/libxfce4panel.symbols
+++ b/libxfce4panel/libxfce4panel.symbols
@@ -147,6 +147,7 @@ xfce_panel_plugin_provider_get_type G_GNUC_CONST
 xfce_panel_plugin_provider_get_name
 xfce_panel_plugin_provider_get_unique_id
 xfce_panel_plugin_provider_set_size
+xfce_panel_plugin_provider_set_icon_size
 xfce_panel_plugin_provider_set_mode
 xfce_panel_plugin_provider_set_nrows
 xfce_panel_plugin_provider_set_screen_position
diff --git a/libxfce4panel/xfce-panel-plugin-provider.c b/libxfce4panel/xfce-panel-plugin-provider.c
index b4ec7fc..bb6326a 100644
--- a/libxfce4panel/xfce-panel-plugin-provider.c
+++ b/libxfce4panel/xfce-panel-plugin-provider.c
@@ -115,6 +115,17 @@ xfce_panel_plugin_provider_set_size (XfcePanelPluginProvider *provider,
 
 
 void
+xfce_panel_plugin_provider_set_icon_size (XfcePanelPluginProvider *provider,
+                                          gint                     icon_size)
+{
+  panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
+
+  (*XFCE_PANEL_PLUGIN_PROVIDER_GET_INTERFACE (provider)->set_icon_size) (provider, icon_size);
+}
+
+
+
+void
 xfce_panel_plugin_provider_set_mode (XfcePanelPluginProvider *provider,
                                      XfcePanelPluginMode      mode)
 {
diff --git a/libxfce4panel/xfce-panel-plugin-provider.h b/libxfce4panel/xfce-panel-plugin-provider.h
index 8d173c9..de2a547 100644
--- a/libxfce4panel/xfce-panel-plugin-provider.h
+++ b/libxfce4panel/xfce-panel-plugin-provider.h
@@ -52,6 +52,8 @@ struct _XfcePanelPluginProviderInterface
   gint         (*get_unique_id)       (XfcePanelPluginProvider       *provider);
   void         (*set_size)            (XfcePanelPluginProvider       *provider,
                                        gint                           size);
+  void         (*set_icon_size)       (XfcePanelPluginProvider       *provider,
+                                       gint                           icon_size);
   void         (*set_mode)            (XfcePanelPluginProvider       *provider,
                                        XfcePanelPluginMode            mode);
   void         (*set_nrows)           (XfcePanelPluginProvider       *provider,
@@ -101,6 +103,7 @@ XfcePanelPluginProviderSignal;
 typedef enum /*< skip >*/
 {
   PROVIDER_PROP_TYPE_SET_SIZE,                /* gint */
+  PROVIDER_PROP_TYPE_SET_ICON_SIZE,           /* gint */
   PROVIDER_PROP_TYPE_SET_MODE,                /* XfcePanelPluginMode (as gint) */
   PROVIDER_PROP_TYPE_SET_SCREEN_POSITION,     /* XfceScreenPosition (as gint) */
   PROVIDER_PROP_TYPE_SET_BACKGROUND_ALPHA,    /* gdouble */
@@ -158,6 +161,9 @@ gint                  xfce_panel_plugin_provider_get_unique_id       (XfcePanelP
 void                  xfce_panel_plugin_provider_set_size            (XfcePanelPluginProvider       *provider,
                                                                       gint                           size);
 
+void                  xfce_panel_plugin_provider_set_icon_size       (XfcePanelPluginProvider       *provider,
+                                                                      gint                           icon_size);
+
 void                  xfce_panel_plugin_provider_set_mode            (XfcePanelPluginProvider       *provider,
                                                                       XfcePanelPluginMode            mode);
 
diff --git a/libxfce4panel/xfce-panel-plugin.c b/libxfce4panel/xfce-panel-plugin.c
index d75d362..b831e66 100644
--- a/libxfce4panel/xfce-panel-plugin.c
+++ b/libxfce4panel/xfce-panel-plugin.c
@@ -93,6 +93,8 @@ static void          xfce_panel_plugin_unregister_menu        (GtkMenu
                                                                XfcePanelPlugin                  *plugin);
 static void          xfce_panel_plugin_set_size               (XfcePanelPluginProvider          *provider,
                                                                gint                              size);
+static void          xfce_panel_plugin_set_icon_size          (XfcePanelPluginProvider          *provider,
+                                                               gint                              icon_size);
 static void          xfce_panel_plugin_set_mode               (XfcePanelPluginProvider          *provider,
                                                                XfcePanelPluginMode               mode);
 static void          xfce_panel_plugin_set_nrows              (XfcePanelPluginProvider          *provider,
@@ -129,6 +131,7 @@ enum
   PROP_UNIQUE_ID,
   PROP_ORIENTATION,
   PROP_SIZE,
+  PROP_ICON_SIZE,
   PROP_SMALL,
   PROP_SCREEN_POSITION,
   PROP_EXPAND,
@@ -175,6 +178,7 @@ struct _XfcePanelPluginPrivate
   gchar               *property_base;
   gchar              **arguments;
   gint                 size; /* single row size */
+  gint                 icon_size;
   guint                expand : 1;
   guint                shrink : 1;
   guint                nrows;
@@ -574,6 +578,22 @@ xfce_panel_plugin_class_init (XfcePanelPluginClass *klass)
                         | G_PARAM_STATIC_STRINGS);
 
   /**
+   * XfcePanelPlugin:icon-size:
+   *
+   * The icon-size in pixels of the #XfcePanelPlugin. Plugin writers can use it to read the
+   * plugin's icon size, but xfce_panel_plugin_get_icon_size() is recommended.
+   *
+   * Since: 4.14
+   **/
+  plugin_props[PROP_ICON_SIZE] =
+      g_param_spec_int ("icon-size",
+                        "Icon Size",
+                        "Size of the plugin's icon",
+                        0, (128 * 6), 0,
+                        G_PARAM_READABLE
+                        | G_PARAM_STATIC_STRINGS);
+
+  /**
    * XfcePanelPlugin:screen-position:
    *
    * The #XfceScreenPosition of the #XfcePanelPlugin. Plugin writer can use it
@@ -690,6 +710,7 @@ xfce_panel_plugin_init (XfcePanelPlugin *plugin)
   plugin->priv->property_base = NULL;
   plugin->priv->arguments = NULL;
   plugin->priv->size = 0;
+  plugin->priv->icon_size = 0;
   plugin->priv->small = FALSE;
   plugin->priv->expand = FALSE;
   plugin->priv->shrink = FALSE;
@@ -722,6 +743,7 @@ xfce_panel_plugin_provider_init (XfcePanelPluginProviderInterface *iface)
   iface->get_name = (ProviderToPluginChar) xfce_panel_plugin_get_name;
   iface->get_unique_id = (ProviderToPluginInt) xfce_panel_plugin_get_unique_id;
   iface->set_size = xfce_panel_plugin_set_size;
+  iface->set_icon_size = xfce_panel_plugin_set_icon_size;
   iface->set_mode = xfce_panel_plugin_set_mode;
   iface->set_nrows = xfce_panel_plugin_set_nrows;
   iface->set_screen_position = xfce_panel_plugin_set_screen_position;
@@ -793,6 +815,10 @@ xfce_panel_plugin_get_property (GObject    *object,
       g_value_set_int (value, private->size * private->nrows);
       break;
 
+    case PROP_ICON_SIZE:
+      g_value_set_uint (value, private->icon_size);
+      break;
+
     case PROP_NROWS:
       g_value_set_uint (value, private->nrows);
       break;
@@ -1425,6 +1451,7 @@ xfce_panel_plugin_set_size (XfcePanelPluginProvider *provider,
   XfcePanelPlugin *plugin = XFCE_PANEL_PLUGIN (provider);
   gboolean         handled = FALSE;
   gint             real_size;
+  gint             icon_size;
 
   panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (provider));
 
@@ -1451,6 +1478,24 @@ xfce_panel_plugin_set_size (XfcePanelPluginProvider *provider,
 
 
 static void
+xfce_panel_plugin_set_icon_size (XfcePanelPluginProvider *provider,
+                                 gint                     icon_size)
+{
+  XfcePanelPlugin *plugin = XFCE_PANEL_PLUGIN (provider);
+
+  if (G_LIKELY (plugin->priv->icon_size != icon_size))
+    {
+      plugin->priv->icon_size = icon_size;
+      g_object_notify_by_pspec (G_OBJECT (plugin), plugin_props[PROP_ICON_SIZE]);
+
+      /* also update the size so the icon gets re-rendered */
+      xfce_panel_plugin_set_size (provider, -1);
+    }
+}
+
+
+
+static void
 xfce_panel_plugin_set_mode (XfcePanelPluginProvider *provider,
                             XfcePanelPluginMode      mode)
 {
@@ -2036,7 +2081,8 @@ xfce_panel_plugin_set_small (XfcePanelPlugin *plugin,
  * xfce_panel_plugin_get_icon_size:
  * @plugin : an #XfcePanelPlugin,
  *
- * Returns a preferred icon size.
+ * Returns either the icon size defined in the panel's settings or
+ * a preferred icon size.
  *
  * Since: 4.14
  **/
@@ -2044,18 +2090,30 @@ gint
 xfce_panel_plugin_get_icon_size (XfcePanelPlugin *plugin)
 {
   gint width;
-  width = xfce_panel_plugin_get_size (plugin) / xfce_panel_plugin_get_nrows (plugin);
-
-  /* Since symbolic icons are usually only provided in 16px we
-   * try to be clever and use size steps */
-  if (width <= 27)
-    return 16;
-  else if (width < 34)
-    return 24;
-  else if (width < 40)
-    return 32;
+
+  g_return_val_if_fail (XFCE_IS_PANEL_PLUGIN (plugin), FALSE);
+  g_return_val_if_fail (XFCE_PANEL_PLUGIN_CONSTRUCTED (plugin), FALSE);
+
+  /* 0 is handled as 'automatic sizing' */
+  if (plugin->priv->icon_size == 0)
+    {
+      width = xfce_panel_plugin_get_size (plugin) / xfce_panel_plugin_get_nrows (plugin);
+
+      /* Since symbolic icons are usually only provided in 16px we
+      * try to be clever and use size steps */
+      if (width <= 27)
+        return 16;
+      else if (width < 34)
+        return 24;
+      else if (width < 40)
+        return 32;
+      else
+        return width;
+    }
   else
-    return width;
+    {
+      return plugin->priv->icon_size;
+    }
 }
 
 
diff --git a/panel/panel-application.c b/panel/panel-application.c
index 43ecf1b..01e389a 100644
--- a/panel/panel-application.c
+++ b/panel/panel-application.c
@@ -300,6 +300,7 @@ panel_application_xfconf_window_bindings (PanelApplication *application,
     { "background-style", G_TYPE_UINT },
     { "background-rgba", GDK_TYPE_RGBA },
     { "background-image", G_TYPE_STRING },
+    { "icon-size", G_TYPE_UINT },
     { "output-name", G_TYPE_STRING },
     { "position", G_TYPE_STRING },
     { "disable-struts", G_TYPE_BOOLEAN },
@@ -1479,7 +1480,7 @@ panel_application_new_window (PanelApplication *application,
   GtkWidget          *itembar;
   gchar              *property;
   gint                idx;
-  static const gchar *props[] = { "mode", "size", "nrows" };
+  static const gchar *props[] = { "mode", "size", "nrows", "icon-size" };
   guint               i;
   gchar              *position;
   static gint         unqiue_id_counter = 1;
diff --git a/panel/panel-plugin-external.c b/panel/panel-plugin-external.c
index 4958206..6c3b6dc 100644
--- a/panel/panel-plugin-external.c
+++ b/panel/panel-plugin-external.c
@@ -84,6 +84,8 @@ static const gchar *panel_plugin_external_get_name                (XfcePanelPlug
 static gint         panel_plugin_external_get_unique_id           (XfcePanelPluginProvider          *provider);
 static void         panel_plugin_external_set_size                (XfcePanelPluginProvider          *provider,
                                                                    gint                              size);
+static void         panel_plugin_external_set_icon_size           (XfcePanelPluginProvider          *provider,
+                                                                   gint                              icon_size);
 static void         panel_plugin_external_set_mode                (XfcePanelPluginProvider          *provider,
                                                                    XfcePanelPluginMode               mode);
 static void         panel_plugin_external_set_nrows               (XfcePanelPluginProvider          *provider,
@@ -222,6 +224,7 @@ panel_plugin_external_provider_init (XfcePanelPluginProviderInterface *iface)
   iface->get_name = panel_plugin_external_get_name;
   iface->get_unique_id = panel_plugin_external_get_unique_id;
   iface->set_size = panel_plugin_external_set_size;
+  iface->set_icon_size = panel_plugin_external_set_icon_size;
   iface->set_mode = panel_plugin_external_set_mode;
   iface->set_nrows = panel_plugin_external_set_nrows;
   iface->set_screen_position = panel_plugin_external_set_screen_position;
@@ -900,6 +903,26 @@ panel_plugin_external_set_size (XfcePanelPluginProvider *provider,
 
 
 static void
+panel_plugin_external_set_icon_size (XfcePanelPluginProvider *provider,
+                                     gint                     icon_size)
+{
+  GValue value = { 0, };
+
+  panel_return_if_fail (PANEL_IS_PLUGIN_EXTERNAL (provider));
+  panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
+
+  g_value_init (&value, G_TYPE_INT);
+  g_value_set_int (&value, icon_size);
+
+  panel_plugin_external_queue_add (PANEL_PLUGIN_EXTERNAL (provider),
+                                   PROVIDER_PROP_TYPE_SET_ICON_SIZE, &value);
+
+  g_value_unset (&value);
+}
+
+
+
+static void
 panel_plugin_external_set_mode (XfcePanelPluginProvider *provider,
                                 XfcePanelPluginMode      mode)
 {
diff --git a/panel/panel-preferences-dialog.c b/panel/panel-preferences-dialog.c
index b286938..456a536 100644
--- a/panel/panel-preferences-dialog.c
+++ b/panel/panel-preferences-dialog.c
@@ -73,6 +73,11 @@ static void                     panel_preferences_dialog_panel_add
                                                                                  PanelPreferencesDialog *dialog);
 static void                     panel_preferences_dialog_panel_remove           (GtkWidget              *widget,
                                                                                  PanelPreferencesDialog *dialog);
+static gboolean                 panel_preferences_dialog_icon_size_state_set    (GtkSwitch              *widget,
+                                                                                 gboolean                state,
+                                                                                 PanelPreferencesDialog *dialog);
+static void                     panel_preferences_dialog_icon_size_changed      (GtkSpinButton          *button,
+                                                                                 PanelPreferencesDialog *dialog);
 static void                     panel_preferences_dialog_compositing_clicked    (GtkButton              *button,
                                                                                  gpointer                user_data);
 static void                     panel_preferences_dialog_panel_switch           (GtkWidget              *widget,
@@ -226,6 +231,16 @@ panel_preferences_dialog_init (PanelPreferencesDialog *dialog)
   g_signal_connect_swapped (G_OBJECT (object), "changed",
       G_CALLBACK (panel_preferences_dialog_bg_style_changed), dialog);
 
+  /* icon size switch, handling enabling/disabling of custom icon sizes */
+  object = gtk_builder_get_object (GTK_BUILDER (dialog), "icon-size-spinbutton");
+  panel_return_if_fail (G_IS_OBJECT (object));
+  g_signal_connect (G_OBJECT (object), "value-changed",
+                    G_CALLBACK (panel_preferences_dialog_icon_size_changed), dialog);
+  object = gtk_builder_get_object (GTK_BUILDER (dialog), "icon-size-switch");
+  panel_return_if_fail (G_IS_OBJECT (object));
+  g_signal_connect (G_OBJECT (object), "state-set",
+                    G_CALLBACK (panel_preferences_dialog_icon_size_state_set), dialog);
+
   object = gtk_builder_get_object (GTK_BUILDER (dialog), "composited");
   panel_return_if_fail (G_IS_OBJECT (object));
   g_signal_connect_swapped (G_OBJECT (object), "notify::visible",
@@ -289,7 +304,7 @@ panel_preferences_dialog_init (PanelPreferencesDialog *dialog)
   renderer = gtk_cell_renderer_pixbuf_new ();
   column = gtk_tree_view_column_new_with_attributes ("", renderer, "icon-name",
                                                      ITEM_COLUMN_ICON_NAME, NULL);
-  g_object_set (G_OBJECT (renderer), "stock-size", GTK_ICON_SIZE_BUTTON, NULL);
+  g_object_set (G_OBJECT (renderer), "stock-size", GTK_ICON_SIZE_LARGE_TOOLBAR, NULL);
   gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
 
   /* text renderer */
@@ -449,6 +464,7 @@ panel_preferences_dialog_bindings_update (PanelPreferencesDialog *dialog)
   gint         n = 0, i;
   gchar       *name, *title;
   gboolean     span_monitors_sensitive = FALSE;
+  gboolean     icon_size_set;
 
   /* leave when there is no active panel */
   panel_return_if_fail (G_IS_OBJECT (dialog->active));
@@ -470,6 +486,7 @@ panel_preferences_dialog_bindings_update (PanelPreferencesDialog *dialog)
   panel_preferences_dialog_bindings_add (dialog, "composited", "sensitive", G_BINDING_SYNC_CREATE);
   panel_preferences_dialog_bindings_add (dialog, "background-style", "active", 0);
   panel_preferences_dialog_bindings_add (dialog, "background-rgba", "rgba", 0);
+  panel_preferences_dialog_bindings_add (dialog, "icon-size", "value", 0);
 
   /* watch image changes from the panel */
   dialog->bg_image_notify_handler_id = g_signal_connect_swapped (G_OBJECT (dialog->active),
@@ -589,6 +606,23 @@ panel_preferences_dialog_bindings_update (PanelPreferencesDialog *dialog)
   object = gtk_builder_get_object (GTK_BUILDER (dialog), "autohide-behavior");
   panel_return_if_fail (GTK_IS_COMBO_BOX (object));
   panel_preferences_dialog_autohide_changed (GTK_COMBO_BOX (object), dialog);
+
+  /* update visibility of the "icon-size" widgets */
+  object = gtk_builder_get_object (GTK_BUILDER (dialog), "icon-size-spinbutton");
+  panel_return_if_fail (G_IS_OBJECT (object));
+
+  if (gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (object)) == 0)
+    icon_size_set = FALSE;
+  else
+    icon_size_set = TRUE;
+
+  object = gtk_builder_get_object (GTK_BUILDER (dialog), "icon-size-revealer");
+  panel_return_if_fail (G_IS_OBJECT (object));
+  gtk_revealer_set_reveal_child (GTK_REVEALER (object), icon_size_set);
+
+  object = gtk_builder_get_object (GTK_BUILDER (dialog), "icon-size-switch");
+  panel_return_if_fail (G_IS_OBJECT (object));
+  gtk_switch_set_state (GTK_SWITCH (object), !icon_size_set);
 }
 
 
@@ -944,6 +978,58 @@ panel_preferences_dialog_panel_remove (GtkWidget              *widget,
 
 
 
+static gboolean
+panel_preferences_dialog_icon_size_state_set (GtkSwitch              *widget,
+                                              gboolean                state,
+                                              PanelPreferencesDialog *dialog)
+{
+  GObject   *spinbutton, *revealer;
+
+  panel_return_val_if_fail (PANEL_IS_PREFERENCES_DIALOG (dialog), FALSE);
+  spinbutton = gtk_builder_get_object (GTK_BUILDER (dialog), "icon-size-spinbutton");
+  panel_return_val_if_fail (G_IS_OBJECT (spinbutton), FALSE);
+  revealer = gtk_builder_get_object (GTK_BUILDER (dialog), "icon-size-revealer");
+  panel_return_val_if_fail (G_IS_OBJECT (revealer), FALSE);
+
+  /* we set the icon-size to 0 for auto-handling */
+  if (state)
+    {
+      gtk_spin_button_set_value (GTK_SPIN_BUTTON (spinbutton), 0.0);
+    }
+  else
+    {
+      /* if the setting is initially enabled we start at the low default of 16px */
+      if (gtk_spin_button_get_value (GTK_SPIN_BUTTON (spinbutton)) == 0)
+        gtk_spin_button_set_value (GTK_SPIN_BUTTON (spinbutton), 16.0);
+    }
+
+  gtk_revealer_set_reveal_child (GTK_REVEALER (revealer), !state);
+  gtk_switch_set_state (GTK_SWITCH (widget), state);
+
+  return TRUE;
+}
+
+
+
+static void
+panel_preferences_dialog_icon_size_changed (GtkSpinButton          *button,
+                                            PanelPreferencesDialog *dialog)
+{
+  GObject   *object;
+
+  panel_return_if_fail (PANEL_IS_PREFERENCES_DIALOG (dialog));
+  object = gtk_builder_get_object (GTK_BUILDER (dialog), "icon-size-switch");
+  panel_return_if_fail (G_IS_OBJECT (object));
+
+  /* 0 means the setting is disabled (icon-size-switch's state == true) so the lower value
+     of the spinbutton has to be 0. however, we want to set 16px as the reasonable lower limit for icons. */
+  if (gtk_spin_button_get_value_as_int (button) < 16
+      && gtk_switch_get_state (GTK_SWITCH (object)))
+      gtk_spin_button_set_value (button, 16.0);
+}
+
+
+
 static void
 panel_preferences_dialog_compositing_clicked (GtkButton *button, gpointer user_data)
 {
diff --git a/panel/panel-preferences-dialog.glade b/panel/panel-preferences-dialog.glade
index 50e0e6a..ba47c3b 100644
--- a/panel/panel-preferences-dialog.glade
+++ b/panel/panel-preferences-dialog.glade
@@ -28,6 +28,11 @@
     <property name="step_increment">1</property>
     <property name="page_increment">10</property>
   </object>
+  <object class="GtkAdjustment" id="icon-size">
+    <property name="upper">100</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
+  </object>
   <object class="GtkImage" id="image10">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
@@ -639,7 +644,7 @@
                     <property name="orientation">vertical</property>
                     <property name="spacing">6</property>
                     <child>
-                      <object class="GtkGrid">
+                      <object class="GtkGrid" id="background-grid">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="margin_bottom">18</property>
@@ -749,6 +754,109 @@
                       <packing>
                         <property name="expand">False</property>
                         <property name="fill">True</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkGrid">
+                        <property name="name">icons-grid</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="margin_bottom">18</property>
+                        <property name="row_spacing">6</property>
+                        <property name="column_spacing">12</property>
+                        <child>
+                          <object class="GtkLabel">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="label" translatable="yes"><b>Icons</b></property>
+                            <property name="use_markup">True</property>
+                            <property name="xalign">0</property>
+                          </object>
+                          <packing>
+                            <property name="left_attach">0</property>
+                            <property name="top_attach">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkLabel">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="margin_left">12</property>
+                            <property name="label" translatable="yes">Adjust size automatically</property>
+                            <property name="xalign">0</property>
+                          </object>
+                          <packing>
+                            <property name="left_attach">0</property>
+                            <property name="top_attach">1</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkSwitch" id="icon-size-switch">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="halign">end</property>
+                            <property name="valign">center</property>
+                          </object>
+                          <packing>
+                            <property name="left_attach">1</property>
+                            <property name="top_attach">1</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkRevealer" id="icon-size-revealer">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="reveal_child">True</property>
+                            <child>
+                              <object class="GtkBox">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="hexpand">True</property>
+                                <property name="spacing">6</property>
+                                <child>
+                                  <object class="GtkLabel">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="margin_left">12</property>
+                                    <property name="label" translatable="yes">Fixed Icon Size (pixels):</property>
+                                    <property name="xalign">0</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkSpinButton" id="icon-size-spinbutton">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="adjustment">icon-size</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="pack_type">end</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="left_attach">0</property>
+                            <property name="top_attach">2</property>
+                            <property name="width">2</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
                         <property name="position">1</property>
                       </packing>
                     </child>
diff --git a/panel/panel-window.c b/panel/panel-window.c
index 6c892db..5b2f26e 100644
--- a/panel/panel-window.c
+++ b/panel/panel-window.c
@@ -172,6 +172,8 @@ static void         panel_window_plugin_set_mode                      (GtkWidget
                                                                        gpointer          user_data);
 static void         panel_window_plugin_set_size                      (GtkWidget        *widget,
                                                                        gpointer          user_data);
+static void         panel_window_plugin_set_icon_size                 (GtkWidget        *widget,
+                                                                       gpointer          user_data);
 static void         panel_window_plugin_set_nrows                     (GtkWidget        *widget,
                                                                        gpointer          user_data);
 static void         panel_window_plugin_set_screen_position           (GtkWidget        *widget,
@@ -193,7 +195,8 @@ enum
   PROP_SPAN_MONITORS,
   PROP_OUTPUT_NAME,
   PROP_POSITION,
-  PROP_DISABLE_STRUTS
+  PROP_DISABLE_STRUTS,
+  PROP_ICON_SIZE
 };
 
 enum _PluginProp
@@ -201,7 +204,8 @@ enum _PluginProp
   PLUGIN_PROP_MODE,
   PLUGIN_PROP_SCREEN_POSITION,
   PLUGIN_PROP_NROWS,
-  PLUGIN_PROP_SIZE
+  PLUGIN_PROP_SIZE,
+  PLUGIN_PROP_ICON_SIZE
 };
 
 enum _AutohideBehavior
@@ -308,6 +312,7 @@ struct _PanelWindow
 
   /* window positioning */
   guint                size;
+  guint                icon_size;
   gdouble              length;
   guint                length_adjust : 1;
   XfcePanelPluginMode  mode;
@@ -417,6 +422,12 @@ panel_window_class_init (PanelWindowClass *klass)
                                                       G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
   g_object_class_install_property (gobject_class,
+                                   PROP_ICON_SIZE,
+                                   g_param_spec_uint ("icon-size", NULL, NULL,
+                                                      0, 256, 0,
+                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_property (gobject_class,
                                    PROP_NROWS,
                                    g_param_spec_uint ("nrows", NULL, NULL,
                                                       1, 6, 1,
@@ -519,6 +530,7 @@ panel_window_init (PanelWindow *window)
   window->struts_disabled = FALSE;
   window->mode = XFCE_PANEL_PLUGIN_MODE_HORIZONTAL;
   window->size = 48;
+  window->icon_size = 0;
   window->nrows = 1;
   window->length = 0.10;
   window->length_adjust = TRUE;
@@ -577,6 +589,10 @@ panel_window_get_property (GObject    *object,
       g_value_set_uint (value, window->size);
       break;
 
+    case PROP_ICON_SIZE:
+      g_value_set_uint (value, window->icon_size);
+      break;
+
     case PROP_NROWS:
       g_value_set_uint (value, window->nrows);
       break;
@@ -671,6 +687,17 @@ panel_window_set_property (GObject      *object,
       panel_window_plugins_update (window, PLUGIN_PROP_SIZE);
       break;
 
+    case PROP_ICON_SIZE:
+      val_uint = g_value_get_uint (value);
+      if (window->icon_size != val_uint)
+        {
+          window->icon_size = val_uint;
+        }
+
+      /* send the new icon size to the panel plugins */
+      panel_window_plugins_update (window, PLUGIN_PROP_ICON_SIZE);
+      break;
+
     case PROP_NROWS:
       val_uint = g_value_get_uint (value);
       if (window->nrows != val_uint)
@@ -2800,6 +2827,10 @@ panel_window_plugins_update (PanelWindow *window,
       func = panel_window_plugin_set_size;
       break;
 
+    case PLUGIN_PROP_ICON_SIZE:
+      func = panel_window_plugin_set_icon_size;
+      break;
+
     default:
       panel_assert_not_reached ();
       return;
@@ -2842,6 +2873,19 @@ panel_window_plugin_set_size (GtkWidget *widget,
 
 
 static void
+panel_window_plugin_set_icon_size (GtkWidget *widget,
+                                   gpointer   user_data)
+{
+  panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (widget));
+  panel_return_if_fail (PANEL_IS_WINDOW (user_data));
+
+  xfce_panel_plugin_provider_set_icon_size (XFCE_PANEL_PLUGIN_PROVIDER (widget),
+                                            PANEL_WINDOW (user_data)->icon_size);
+}
+
+
+
+static void
 panel_window_plugin_set_nrows (GtkWidget *widget,
                                gpointer   user_data)
 {
@@ -3007,6 +3051,7 @@ panel_window_set_povider_info (PanelWindow *window,
   panel_window_plugin_set_mode (provider, window);
   panel_window_plugin_set_screen_position (provider, window);
   panel_window_plugin_set_size (provider, window);
+  panel_window_plugin_set_icon_size (provider, window);
   panel_window_plugin_set_nrows (provider, window);
 }
 
diff --git a/wrapper/main.c b/wrapper/main.c
index c9b5219..903c503 100644
--- a/wrapper/main.c
+++ b/wrapper/main.c
@@ -75,6 +75,10 @@ wrapper_gproxy_set (XfcePanelPluginProvider *provider,
           xfce_panel_plugin_provider_set_size (provider, g_variant_get_int32 (variant));
           break;
 
+        case PROVIDER_PROP_TYPE_SET_ICON_SIZE:
+          xfce_panel_plugin_provider_set_icon_size (provider, g_variant_get_int32 (variant));
+          break;
+
         case PROVIDER_PROP_TYPE_SET_MODE:
           xfce_panel_plugin_provider_set_mode (provider, g_variant_get_int32 (variant));
           break;

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


More information about the Xfce4-commits mailing list