[gnome-panel] panel: Fix position re-shuffling on orientation change
- From: Vincent Untz <vuntz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel] panel: Fix position re-shuffling on orientation change
- Date: Mon, 5 Mar 2012 08:49:53 +0000 (UTC)
commit 1f7748b4b91ee45d4e3eb65e7cd177afdd39681d
Author: Peter Hurley <peter hurleysoftware com>
Date: Mon Mar 5 09:46:56 2012 +0100
panel: Fix position re-shuffling on orientation change
The ButtonWidget widgets of launchers were accidentally triggering
'EEEEK' code in panel_widget_update_positions.
This can happen when the parent (the PanelWidget) allocation is stale or
uninitialized. For example, when a panel's orientation is changed (eg,
via the Properties dialog) and the toplevel initiates a resize, the
children are queried for preferred height/width. At this point, the
allocations are stale and reflect the values from the previous
orientation.
Instead, use the toplevel's specified size as the size of the
ButtonWidget (accounting for padding in the major direction).
https://bugzilla.gnome.org/show_bug.cgi?id=671328
gnome-panel/button-widget.c | 20 ++++++++++++--------
1 files changed, 12 insertions(+), 8 deletions(-)
---
diff --git a/gnome-panel/button-widget.c b/gnome-panel/button-widget.c
index b21ccee..6c87441 100644
--- a/gnome-panel/button-widget.c
+++ b/gnome-panel/button-widget.c
@@ -440,7 +440,11 @@ button_widget_get_preferred_width (GtkWidget *widget,
GtkWidget *parent;
int size;
+ *minimal_width = *natural_width = 0;
+
parent = gtk_widget_get_parent (widget);
+ g_return_if_fail (PANEL_IS_WIDGET (parent));
+ size = panel_toplevel_get_size (PANEL_WIDGET (parent)->toplevel);
if (button_widget->priv->orientation & PANEL_HORIZONTAL_MASK) {
GtkStyleContext *context;
@@ -451,9 +455,8 @@ button_widget_get_preferred_width (GtkWidget *widget,
context = gtk_widget_get_style_context (widget);
gtk_style_context_get_padding (context, state, &padding);
- size = gtk_widget_get_allocated_height (parent) + padding.left + padding.right;
- } else
- size = gtk_widget_get_allocated_width (parent);
+ size += padding.left + padding.right;
+ }
*minimal_width = *natural_width = size;
}
@@ -467,11 +470,13 @@ button_widget_get_preferred_height (GtkWidget *widget,
GtkWidget *parent;
int size;
+ *minimal_height = *natural_height = 0;
+
parent = gtk_widget_get_parent (widget);
+ g_return_if_fail (PANEL_IS_WIDGET (parent));
+ size = panel_toplevel_get_size (PANEL_WIDGET (parent)->toplevel);
- if (button_widget->priv->orientation & PANEL_HORIZONTAL_MASK)
- size = gtk_widget_get_allocated_height (parent);
- else {
+ if (button_widget->priv->orientation & PANEL_VERTICAL_MASK) {
GtkStyleContext *context;
GtkStateFlags state;
GtkBorder padding;
@@ -480,10 +485,9 @@ button_widget_get_preferred_height (GtkWidget *widget,
context = gtk_widget_get_style_context (widget);
gtk_style_context_get_padding (context, state, &padding);
- size = gtk_widget_get_allocated_width (parent) + padding.top + padding.bottom;
+ size += padding.top + padding.bottom;
}
-
*minimal_height = *natural_height = size;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]