[Xfce4-commits] <exo:stephan/icon-bar-improvements> Set and un-set the auto_center flag at the right times.
Stephan Arts
noreply at xfce.org
Thu Feb 2 19:30:06 CET 2012
Updating branch refs/heads/stephan/icon-bar-improvements
to 33ff3d3b6c3418e3625a33545568307b4ea271ff (commit)
from 485dfd7bd609bcf7eb1e8fa20df651b62d9a4e6f (commit)
commit 33ff3d3b6c3418e3625a33545568307b4ea271ff
Author: Stephan Arts <stephan at xfce.org>
Date: Wed Feb 1 20:51:36 2012 +0100
Set and un-set the auto_center flag at the right times.
exo/exo-icon-bar.c | 41 ++++++++++++++++++++++++++++++++---------
1 files changed, 32 insertions(+), 9 deletions(-)
diff --git a/exo/exo-icon-bar.c b/exo/exo-icon-bar.c
index ccebc74..83d058f 100644
--- a/exo/exo-icon-bar.c
+++ b/exo/exo-icon-bar.c
@@ -223,7 +223,7 @@ struct _ExoIconBarPrivate
GtkAdjustment *hadjustment;
GtkAdjustment *vadjustment;
- gboolean auto_center; /* automatically center */
+ gboolean auto_center; /* automatically center the active item */
GtkOrientation orientation;
@@ -755,7 +755,6 @@ exo_icon_bar_size_allocate (GtkWidget *widget,
icon_bar->priv->width = allocation->width;
icon_bar->priv->item_width = icon_bar->priv->width;
icon_bar->priv->hadjustment->value = 0;
- gtk_adjustment_value_changed (icon_bar->priv->hadjustment);
/* If auto-center is true, center the selected item */
if (icon_bar->priv->auto_center == TRUE)
@@ -767,7 +766,13 @@ exo_icon_bar_size_allocate (GtkWidget *widget,
value = (gtk_adjustment_get_upper (icon_bar->priv->vadjustment)-page_size);
gtk_adjustment_set_value (icon_bar->priv->vadjustment, value);
- gtk_adjustment_changed (icon_bar->priv->vadjustment);
+ gtk_adjustment_value_changed (icon_bar->priv->vadjustment);
+ gtk_adjustment_value_changed (icon_bar->priv->hadjustment);
+ icon_bar->priv->auto_center = TRUE;
+ }
+ else
+ {
+ gtk_adjustment_value_changed (icon_bar->priv->hadjustment);
}
}
else
@@ -775,7 +780,6 @@ exo_icon_bar_size_allocate (GtkWidget *widget,
icon_bar->priv->height = allocation->height;
icon_bar->priv->item_height = icon_bar->priv->height;
icon_bar->priv->vadjustment->value = 0;
- gtk_adjustment_value_changed (icon_bar->priv->vadjustment);
/* If auto-center is true, center the selected item */
if (icon_bar->priv->auto_center == TRUE)
@@ -787,7 +791,13 @@ exo_icon_bar_size_allocate (GtkWidget *widget,
value = (gtk_adjustment_get_upper (icon_bar->priv->hadjustment)-page_size);
gtk_adjustment_set_value (icon_bar->priv->hadjustment, value);
- gtk_adjustment_changed (icon_bar->priv->hadjustment);
+ gtk_adjustment_value_changed (icon_bar->priv->hadjustment);
+ gtk_adjustment_value_changed (icon_bar->priv->vadjustment);
+ icon_bar->priv->auto_center = TRUE;
+ }
+ else
+ {
+ gtk_adjustment_value_changed (icon_bar->priv->vadjustment);
}
}
}
@@ -1021,6 +1031,15 @@ exo_icon_bar_adjustment_changed (GtkAdjustment *adjustment,
{
if (GTK_WIDGET_REALIZED (icon_bar))
{
+ /* Set auto_center to false, this should be the default behaviour
+ * in case a user changes the value of the adjustments.
+ *
+ * If the value is set internally, and auto-center was enabled
+ * the function calling gtk_adjustment_value_changed should set
+ * auto_center to TRUE afterwards.
+ */
+ icon_bar->priv->auto_center = FALSE;
+
gdk_window_move (icon_bar->priv->bin_window,
- icon_bar->priv->hadjustment->value,
- icon_bar->priv->vadjustment->value);
@@ -1914,10 +1933,10 @@ exo_icon_bar_set_orientation (ExoIconBar *icon_bar,
{
icon_bar->priv->orientation = orientation;
gtk_widget_queue_resize (GTK_WIDGET (icon_bar));
- if (icon_bar->priv->auto_center == TRUE)
- {
- exo_icon_bar_show_active (icon_bar);
- }
+
+ /* If the orientation changes, focus the active item */
+ exo_icon_bar_show_active (icon_bar);
+
g_object_notify (G_OBJECT (icon_bar), "orientation");
}
}
@@ -2104,6 +2123,8 @@ exo_icon_bar_show_active (ExoIconBar *icon_bar)
if (NULL == icon_bar->priv->active_item)
return FALSE;
+ icon_bar->priv->auto_center = TRUE;
+
if (icon_bar->priv->orientation == GTK_ORIENTATION_VERTICAL)
{
page_size = gtk_adjustment_get_page_size (icon_bar->priv->vadjustment);
@@ -2114,6 +2135,7 @@ exo_icon_bar_show_active (ExoIconBar *icon_bar)
gtk_adjustment_set_value (icon_bar->priv->vadjustment, value);
gtk_adjustment_changed (icon_bar->priv->vadjustment);
+ icon_bar->priv->auto_center = TRUE;
return TRUE;
}
else
@@ -2126,6 +2148,7 @@ exo_icon_bar_show_active (ExoIconBar *icon_bar)
gtk_adjustment_set_value (icon_bar->priv->hadjustment, value);
gtk_adjustment_changed (icon_bar->priv->hadjustment);
+ icon_bar->priv->auto_center = TRUE;
return TRUE;
}
return FALSE;
More information about the Xfce4-commits
mailing list