[Xfce4-commits] <xfce4-panel:master> Only use orientation in systray box.
Nick Schermer
noreply at xfce.org
Tue Dec 28 20:50:04 CET 2010
Updating branch refs/heads/master
to cf7bf8d019247388488fbe442624f75dd1bdcc51 (commit)
from 4ea533ef90968e58a0aafd76a9055ac974a92e12 (commit)
commit cf7bf8d019247388488fbe442624f75dd1bdcc51
Author: Nick Schermer <nick at xfce.org>
Date: Fri Dec 24 20:32:20 2010 +0100
Only use orientation in systray box.
Swapping the tray order if it is positioned on the
other side of the screen is hardly of any use, so
ditch is to make the allocation code simpler.
plugins/systray/systray-box.c | 37 ++++++++------------
plugins/systray/systray-box.h | 4 +-
plugins/systray/systray.c | 76 ++---------------------------------------
3 files changed, 20 insertions(+), 97 deletions(-)
diff --git a/plugins/systray/systray-box.c b/plugins/systray/systray-box.c
index 9362044..f1d1874 100644
--- a/plugins/systray/systray-box.c
+++ b/plugins/systray/systray-box.c
@@ -35,8 +35,6 @@
#define SPACING (2)
#define OFFSCREEN (-9999)
-#define IS_HORIZONTAL(box) ((box)->arrow_type == GTK_ARROW_LEFT \
- || (box)->arrow_type == GTK_ARROW_RIGHT)
@@ -91,8 +89,8 @@ struct _SystrayBox
* that represents the hidden bool */
GHashTable *names;
- /* position of the arrow button */
- GtkArrowType arrow_type;
+ /* orientation of the box */
+ guint horizontal : 1;
/* hidden childeren counter */
gint n_hidden_childeren;
@@ -167,7 +165,7 @@ systray_box_init (SystrayBox *box)
box->childeren = NULL;
box->rows = 1;
box->n_hidden_childeren = 0;
- box->arrow_type = GTK_ARROW_LEFT;
+ box->horizontal = TRUE;
box->show_hidden = FALSE;
box->guess_size = 128;
}
@@ -330,7 +328,7 @@ systray_box_size_request (GtkWidget *widget,
}
/* swap the sizes if the orientation is vertical */
- if (!IS_HORIZONTAL (box))
+ if (!box->horizontal)
{
swap = requisition->width;
requisition->width = requisition->height;
@@ -381,20 +379,20 @@ systray_box_size_allocate (GtkWidget *widget,
/* child size */
if (box->rows == 1)
{
- child_size = IS_HORIZONTAL (box) ? width : height;
+ child_size = box->horizontal ? width : height;
n = n_children - (box->show_hidden ? 0 : box->n_hidden_childeren);
child_size -= SPACING * MAX (n - 1, 0);
if (n > 1)
child_size /= n;
- if (IS_HORIZONTAL (box))
+ if (box->horizontal)
y += MAX (height - child_size, 0) / 2;
else
x += MAX (width - child_size, 0) / 2;
}
else
{
- child_size = IS_HORIZONTAL (box) ? height : width;
+ child_size = box->horizontal ? height : width;
child_size -= SPACING * (box->rows - 1);
child_size /= box->rows;
}
@@ -424,19 +422,13 @@ systray_box_size_allocate (GtkWidget *widget,
n++;
/* swap coordinates on a vertical panel */
- if (!IS_HORIZONTAL (box))
+ if (!box->horizontal)
{
swap = child_allocation.x;
child_allocation.x = child_allocation.y;
child_allocation.y = swap;
}
- /* invert the icon order if the arrow button position is right or down */
- if (box->arrow_type == GTK_ARROW_RIGHT)
- child_allocation.x = width - child_allocation.x - child_size;
- else if (box->arrow_type == GTK_ARROW_DOWN)
- child_allocation.y = height - child_allocation.y - child_size;
-
/* add root */
child_allocation.x += x;
child_allocation.y += y;
@@ -661,17 +653,18 @@ systray_box_set_guess_size (SystrayBox *box,
void
-systray_box_set_arrow_type (SystrayBox *box,
- GtkArrowType arrow_type)
+systray_box_set_orientation (SystrayBox *box,
+ GtkOrientation orientation)
{
+ gboolean horizontal;
+
panel_return_if_fail (XFCE_IS_SYSTRAY_BOX (box));
- if (G_LIKELY (arrow_type != box->arrow_type))
+ horizontal = !!(orientation == GTK_ORIENTATION_HORIZONTAL);
+ if (G_LIKELY (box->horizontal != horizontal))
{
- /* set new setting */
- box->arrow_type = arrow_type;
+ box->horizontal = horizontal;
- /* queue a resize */
if (box->childeren != NULL)
gtk_widget_queue_resize (GTK_WIDGET (box));
}
diff --git a/plugins/systray/systray-box.h b/plugins/systray/systray-box.h
index 57af888..cb5cf3d 100644
--- a/plugins/systray/systray-box.h
+++ b/plugins/systray/systray-box.h
@@ -38,8 +38,8 @@ GtkWidget *systray_box_new (void) G_GNUC_MALLOC;
void systray_box_set_guess_size (SystrayBox *box,
gint guess_size);
-void systray_box_set_arrow_type (SystrayBox *box,
- GtkArrowType arrow_type);
+void systray_box_set_orientation (SystrayBox *box,
+ GtkOrientation orientation);
void systray_box_set_rows (SystrayBox *box,
gint rows);
diff --git a/plugins/systray/systray.c b/plugins/systray/systray.c
index c31916e..16f2018 100644
--- a/plugins/systray/systray.c
+++ b/plugins/systray/systray.c
@@ -49,8 +49,6 @@ static void systray_plugin_set_property (GObject
GParamSpec *pspec);
static void systray_plugin_construct (XfcePanelPlugin *panel_plugin);
static void systray_plugin_free_data (XfcePanelPlugin *panel_plugin);
-static void systray_plugin_screen_position_changed (XfcePanelPlugin *panel_plugin,
- XfceScreenPosition screen_position);
static void systray_plugin_orientation_changed (XfcePanelPlugin *panel_plugin,
GtkOrientation orientation);
static gboolean systray_plugin_size_changed (XfcePanelPlugin *panel_plugin,
@@ -166,7 +164,6 @@ systray_plugin_class_init (SystrayPluginClass *klass)
plugin_class->construct = systray_plugin_construct;
plugin_class->free_data = systray_plugin_free_data;
plugin_class->size_changed = systray_plugin_size_changed;
- plugin_class->screen_position_changed = systray_plugin_screen_position_changed;
plugin_class->configure_plugin = systray_plugin_configure_plugin;
plugin_class->orientation_changed = systray_plugin_orientation_changed;
@@ -459,83 +456,16 @@ systray_plugin_free_data (XfcePanelPlugin *panel_plugin)
static void
-systray_plugin_screen_position_changed (XfcePanelPlugin *panel_plugin,
- XfceScreenPosition screen_position)
-{
- SystrayPlugin *plugin = XFCE_SYSTRAY_PLUGIN (panel_plugin);
- GdkScreen *screen;
- GdkRectangle geom;
- gint mon, x, y;
- GtkArrowType arrow_type;
-
- panel_return_if_fail (GTK_WIDGET_REALIZED (panel_plugin));
-
- /* get the button position */
- switch (screen_position)
- {
- /* horizontal west */
- case XFCE_SCREEN_POSITION_NW_H:
- case XFCE_SCREEN_POSITION_SW_H:
- arrow_type = GTK_ARROW_RIGHT;
- break;
-
- /* horizontal east */
- case XFCE_SCREEN_POSITION_N:
- case XFCE_SCREEN_POSITION_NE_H:
- case XFCE_SCREEN_POSITION_S:
- case XFCE_SCREEN_POSITION_SE_H:
- arrow_type = GTK_ARROW_LEFT;
- break;
-
- /* vertical north */
- case XFCE_SCREEN_POSITION_NW_V:
- case XFCE_SCREEN_POSITION_NE_V:
- arrow_type = GTK_ARROW_DOWN;
- break;
-
- /* vertical south */
- case XFCE_SCREEN_POSITION_W:
- case XFCE_SCREEN_POSITION_SW_V:
- case XFCE_SCREEN_POSITION_E:
- case XFCE_SCREEN_POSITION_SE_V:
- arrow_type = GTK_ARROW_UP;
- break;
-
- /* floating */
- default:
- /* get the screen information */
- screen = gtk_widget_get_screen (GTK_WIDGET (panel_plugin));
- mon = gdk_screen_get_monitor_at_window (screen, GTK_WIDGET (panel_plugin)->window);
- gdk_screen_get_monitor_geometry (screen, mon, &geom);
- gdk_window_get_root_origin (GTK_WIDGET (panel_plugin)->window, &x, &y);
-
- /* get the position based on the screen position */
- if (screen_position == XFCE_SCREEN_POSITION_FLOATING_H)
- arrow_type = ((x < (geom.x + geom.width / 2)) ? GTK_ARROW_RIGHT : GTK_ARROW_LEFT);
- else
- arrow_type = ((y < (geom.y + geom.height / 2)) ? GTK_ARROW_DOWN : GTK_ARROW_UP);
- break;
- }
-
- /* set the arrow type of the tray widget */
- systray_box_set_arrow_type (XFCE_SYSTRAY_BOX (plugin->box), arrow_type);
-
- /* update the manager orientation */
- systray_plugin_orientation_changed (panel_plugin,
- xfce_panel_plugin_get_orientation (panel_plugin));
-}
-
-
-
-static void
systray_plugin_orientation_changed (XfcePanelPlugin *panel_plugin,
GtkOrientation orientation)
{
SystrayPlugin *plugin = XFCE_SYSTRAY_PLUGIN (panel_plugin);
+ xfce_hvbox_set_orientation (XFCE_HVBOX (plugin->hvbox), orientation);
+ systray_box_set_orientation (XFCE_SYSTRAY_BOX (plugin->box), orientation);
+
if (G_LIKELY (plugin->manager != NULL))
systray_manager_set_orientation (plugin->manager, orientation);
- xfce_hvbox_set_orientation (XFCE_HVBOX (plugin->hvbox), orientation);
if (orientation == GTK_ORIENTATION_HORIZONTAL)
gtk_widget_set_size_request (plugin->button, BUTTON_SIZE, -1);
More information about the Xfce4-commits
mailing list