[Xfce4-commits] <xfce4-panel:andrzejr/deskbar-applicationsmenu> applicationsmenu: accumulated changes from andrzejr/deskbar-github branch.

Andrzej noreply at xfce.org
Mon Dec 12 16:00:08 CET 2011


Updating branch refs/heads/andrzejr/deskbar-applicationsmenu
         to 2370ecfba014032408dfb237c81dcb7bf113d32e (commit)
       from f9af320ee3f50582039e8f596c87948a37029770 (commit)

commit 2370ecfba014032408dfb237c81dcb7bf113d32e
Author: Andrzej <ndrwrdck at gmail.com>
Date:   Mon Dec 12 22:34:45 2011 +0900

    applicationsmenu: accumulated changes from andrzejr/deskbar-github branch.

 plugins/applicationsmenu/applicationsmenu.c |   84 ++++++++++++++++++++-------
 1 files changed, 63 insertions(+), 21 deletions(-)

diff --git a/plugins/applicationsmenu/applicationsmenu.c b/plugins/applicationsmenu/applicationsmenu.c
index 5b2045d..ca4eac1 100644
--- a/plugins/applicationsmenu/applicationsmenu.c
+++ b/plugins/applicationsmenu/applicationsmenu.c
@@ -101,8 +101,10 @@ static void      applications_menu_plugin_construct            (XfcePanelPlugin
 static void      applications_menu_plugin_free_data            (XfcePanelPlugin        *panel_plugin);
 static gboolean  applications_menu_plugin_size_changed         (XfcePanelPlugin        *panel_plugin,
                                                                 gint                    size);
-static void      applications_menu_plugin_orientation_changed  (XfcePanelPlugin        *panel_plugin,
-                                                                GtkOrientation          orientation);
+static void      applications_menu_plugin_mode_changed         (XfcePanelPlugin        *panel_plugin,
+                                                                XfcePanelPluginMode     mode);
+static void      applications_menu_plugin_nrows_changed        (XfcePanelPlugin        *panel_plugin,
+                                                                guint                   nrows);
 static void      applications_menu_plugin_configure_plugin     (XfcePanelPlugin        *panel_plugin);
 static gboolean  applications_menu_plugin_remote_event         (XfcePanelPlugin        *panel_plugin,
                                                                 const gchar            *name,
@@ -137,7 +139,8 @@ applications_menu_plugin_class_init (ApplicationsMenuPluginClass *klass)
   plugin_class->construct = applications_menu_plugin_construct;
   plugin_class->free_data = applications_menu_plugin_free_data;
   plugin_class->size_changed = applications_menu_plugin_size_changed;
-  plugin_class->orientation_changed = applications_menu_plugin_orientation_changed;
+  plugin_class->mode_changed = applications_menu_plugin_mode_changed;
+  plugin_class->nrows_changed = applications_menu_plugin_nrows_changed;
   plugin_class->configure_plugin = applications_menu_plugin_configure_plugin;
   plugin_class->remote_event = applications_menu_plugin_remote_event;
 
@@ -343,6 +346,8 @@ applications_menu_plugin_set_property (GObject      *object,
           plugin->button_title != NULL ? plugin->button_title : "");
       gtk_widget_set_tooltip_text (plugin->button,
           exo_str_is_empty (plugin->button_title) ? NULL : plugin->button_title);
+      applications_menu_plugin_size_changed (XFCE_PANEL_PLUGIN (plugin),
+          xfce_panel_plugin_get_size (XFCE_PANEL_PLUGIN (plugin)));
       return;
 
     case PROP_BUTTON_ICON:
@@ -422,40 +427,77 @@ applications_menu_plugin_size_changed (XfcePanelPlugin *panel_plugin,
   ApplicationsMenuPlugin *plugin = XFCE_APPLICATIONS_MENU_PLUGIN (panel_plugin);
   gint                    icon_size;
   GtkStyle               *style;
+  gint                    plugin_size;
+  gint                    plugin_nrows;
+  XfcePanelPluginMode     mode;
+  GtkOrientation          orientation;
+  GtkRequisition          label_size;
 
-  gtk_box_set_child_packing (GTK_BOX (plugin->box), plugin->icon,
-                             !plugin->show_button_title, !plugin->show_button_title,
-                             0, GTK_PACK_START);
+  plugin_size = xfce_panel_plugin_get_size (panel_plugin);
+  plugin_nrows = (gint) xfce_panel_plugin_get_nrows (panel_plugin);
 
-  if (!plugin->show_button_title)
-    {
-      xfce_panel_image_set_size (XFCE_PANEL_IMAGE (plugin->icon), -1);
-      gtk_widget_set_size_request (GTK_WIDGET (panel_plugin), size, size);
-    }
-  else
+  if (size > 2 * plugin_size / plugin_nrows)
+    size = 2 * plugin_size / plugin_nrows;
+
+  style = gtk_widget_get_style (plugin->button);
+  icon_size = size - 2 * MAX (style->xthickness, style->ythickness);
+
+  xfce_panel_image_set_size (XFCE_PANEL_IMAGE (plugin->icon), icon_size);
+
+  mode = xfce_panel_plugin_get_mode (panel_plugin);
+  orientation = (mode == XFCE_PANEL_PLUGIN_MODE_HORIZONTAL) ?
+    GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL;
+
+  /* deskbar mode & button title */
+  if (plugin->show_button_title &&
+      mode == XFCE_PANEL_PLUGIN_MODE_DESKBAR)
     {
-      style = gtk_widget_get_style (plugin->button);
-      icon_size = size - 2 * MAX (style->xthickness, style->ythickness);
-      xfce_panel_image_set_size (XFCE_PANEL_IMAGE (plugin->icon), icon_size);
-      gtk_widget_set_size_request (GTK_WIDGET (panel_plugin), -1, -1);
-    }
+      gtk_widget_size_request(GTK_WIDGET (plugin->label), &label_size);
 
+      /* the title fits next to the icon */
+      if (label_size.width <= plugin_size - size - MAX (style->xthickness, style->ythickness))
+        {
+          orientation = GTK_ORIENTATION_HORIZONTAL;
+        }
+    }
+  gtk_orientable_set_orientation (GTK_ORIENTABLE (plugin->box),
+                                  orientation);
   return TRUE;
 }
 
 
 
 static void
-applications_menu_plugin_orientation_changed (XfcePanelPlugin *panel_plugin,
-                                              GtkOrientation   orientation)
+applications_menu_plugin_mode_changed (XfcePanelPlugin      *panel_plugin,
+                                       XfcePanelPluginMode   mode)
 {
   ApplicationsMenuPlugin *plugin = XFCE_APPLICATIONS_MENU_PLUGIN (panel_plugin);
 
-  xfce_hvbox_set_orientation (XFCE_HVBOX (plugin->box), orientation);
-  gtk_label_set_angle (GTK_LABEL (plugin->label), orientation == GTK_ORIENTATION_HORIZONTAL ? 0 : 270);
+  if (mode != XFCE_PANEL_PLUGIN_MODE_VERTICAL)
+    {
+      gtk_orientable_set_orientation (GTK_ORIENTABLE (plugin->box), GTK_ORIENTATION_HORIZONTAL);
+      /* gtk_box_reorder_child (GTK_BOX (plugin->box), plugin->icon, 0); */
+      gtk_label_set_angle (GTK_LABEL (plugin->label), 0);
+    }
+  else
+    {
+      gtk_orientable_set_orientation (GTK_ORIENTABLE (plugin->box), GTK_ORIENTATION_VERTICAL);
+      /* gtk_box_reorder_child (GTK_BOX (plugin->box), plugin->icon, -1); */
+      gtk_label_set_angle (GTK_LABEL (plugin->label), 270);
+    }
+  applications_menu_plugin_size_changed (panel_plugin,
+                                         xfce_panel_plugin_get_size (panel_plugin));
 }
 
 
+static void
+applications_menu_plugin_nrows_changed (XfcePanelPlugin        *panel_plugin,
+                                       guint                   nrows)
+{
+  applications_menu_plugin_size_changed (panel_plugin,
+                                         xfce_panel_plugin_get_size (panel_plugin));
+}
+
 
 static void
 applications_menu_plugin_configure_plugin_file_set (GtkFileChooserButton   *button,


More information about the Xfce4-commits mailing list