[Xfce4-commits] <xfce4-panel:andrzejr/deskbar-github> pager: fixed aspect ratio of the wnck applet in deskbar mode.
Andrzej
noreply at xfce.org
Mon Dec 12 11:40:26 CET 2011
Updating branch refs/heads/andrzejr/deskbar-github
to a13e5d342d24c20b305a675af99e419eaecc5a0c (commit)
from 460dac040e62ddbd2f345ada96fd6b7686045ea5 (commit)
commit a13e5d342d24c20b305a675af99e419eaecc5a0c
Author: Andrzej <ndrwrdck at gmail.com>
Date: Mon Nov 21 23:24:53 2011 +0900
pager: fixed aspect ratio of the wnck applet in deskbar mode.
wnck assumes that a horizontal applet is always used in a horizontal panel, which is not the case in the deskbar mode. Added a workaround for it.
plugins/pager/pager.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 65 insertions(+), 0 deletions(-)
diff --git a/plugins/pager/pager.c b/plugins/pager/pager.c
index c92d91d..91fa2b2 100644
--- a/plugins/pager/pager.c
+++ b/plugins/pager/pager.c
@@ -64,6 +64,10 @@ static void pager_plugin_deskbar_mode_changed (XfcePanelPlugin *pa
static void pager_plugin_configure_workspace_settings (GtkWidget *button);
static void pager_plugin_configure_plugin (XfcePanelPlugin *panel_plugin);
static void pager_plugin_screen_layout_changed (PagerPlugin *plugin);
+static void pager_plugin_size_request (GtkWidget *widget,
+ GtkRequisition *requisition);
+static void pager_plugin_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation);
@@ -84,6 +88,8 @@ struct _PagerPlugin
guint scrolling : 1;
guint miniature_view : 1;
gint rows;
+
+ double aspect;
};
enum
@@ -115,6 +121,8 @@ pager_plugin_class_init (PagerPluginClass *klass)
widget_class = GTK_WIDGET_CLASS (klass);
widget_class->scroll_event = pager_plugin_scroll_event;
+ widget_class->size_request = pager_plugin_size_request;
+ widget_class->size_allocate = pager_plugin_size_allocate;
plugin_class = XFCE_PANEL_PLUGIN_CLASS (klass);
plugin_class->construct = pager_plugin_construct;
@@ -156,6 +164,7 @@ pager_plugin_init (PagerPlugin *plugin)
plugin->miniature_view = TRUE;
plugin->rows = 1;
plugin->pager = NULL;
+ plugin->aspect = 1.0;
}
@@ -387,6 +396,62 @@ pager_plugin_free_data (XfcePanelPlugin *panel_plugin)
+static void
+pager_plugin_size_request (GtkWidget *widget,
+ GtkRequisition *requisition)
+{
+ PagerPlugin *plugin;
+ XfcePanelPlugin *panel_plugin;
+ gboolean deskbar_mode;
+ GtkOrientation orientation;
+ gint size;
+
+ plugin = XFCE_PAGER_PLUGIN (widget);
+ panel_plugin = XFCE_PANEL_PLUGIN (widget);
+ deskbar_mode = xfce_panel_plugin_get_deskbar_mode (panel_plugin);
+ orientation = xfce_panel_plugin_get_orientation (panel_plugin);
+ size = xfce_panel_plugin_get_size (panel_plugin);
+
+ gtk_widget_size_request (plugin->pager, requisition);
+ if (plugin->miniature_view && deskbar_mode && orientation == GTK_ORIENTATION_VERTICAL)
+ {
+ /* Working around limitations of the wnck applet. */
+ /* Wnck assumes that a horizontal applet is always used in a horizontal panel. */
+ if (requisition->width && requisition->width > size)
+ plugin->aspect = (double) requisition->height / (double) requisition->width;
+ }
+}
+
+
+
+static void
+pager_plugin_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation)
+{
+ PagerPlugin *plugin;
+ XfcePanelPlugin *panel_plugin;
+ gboolean deskbar_mode;
+ GtkOrientation orientation;
+ gint size;
+
+ plugin = XFCE_PAGER_PLUGIN (widget);
+ panel_plugin = XFCE_PANEL_PLUGIN (widget);
+ deskbar_mode = xfce_panel_plugin_get_deskbar_mode (panel_plugin);
+ orientation = xfce_panel_plugin_get_orientation (panel_plugin);
+ size = xfce_panel_plugin_get_size (panel_plugin);
+
+ if (plugin->miniature_view && deskbar_mode && orientation == GTK_ORIENTATION_VERTICAL)
+ {
+ /* Working around limitations of the wnck applet. */
+ /* Wnck assumes that a horizontal applet is always used in a horizontal panel. */
+ allocation->height = size * plugin->aspect;
+ allocation->width = size;
+ }
+ gtk_widget_size_allocate (plugin->pager, allocation);
+}
+
+
+
static gboolean
pager_plugin_size_changed (XfcePanelPlugin *panel_plugin,
gint size)
More information about the Xfce4-commits
mailing list