[gtk+/gtk-3-2] toolbar: Fix widget path creation code
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-3-2] toolbar: Fix widget path creation code
- Date: Mon, 7 Nov 2011 22:19:07 +0000 (UTC)
commit a8b315f41ff64da6ad4412410524d07a164c27f0
Author: Benjamin Otte <otte redhat com>
Date: Tue Sep 27 04:29:55 2011 +0200
toolbar: Fix widget path creation code
- Ensure arrow button is always included
- Invalidate list when direction changes
gtk/gtkcontainer.c | 6 +++---
gtk/gtkcontainerprivate.h | 1 +
gtk/gtktoolbar.c | 25 +++++++++++++++++++------
3 files changed, 23 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c
index ac9bcf9..bfccc1d 100644
--- a/gtk/gtkcontainer.c
+++ b/gtk/gtkcontainer.c
@@ -2302,8 +2302,8 @@ get_focus_chain (GtkContainer *container)
/* same as gtk_container_get_children, except it includes internals
*/
-static GList *
-gtk_container_get_all_children (GtkContainer *container)
+GList *
+_gtk_container_get_all_children (GtkContainer *container)
{
GList *children = NULL;
@@ -2377,7 +2377,7 @@ gtk_container_focus (GtkWidget *widget,
if (priv->has_focus_chain)
children = g_list_copy (get_focus_chain (container));
else
- children = gtk_container_get_all_children (container);
+ children = _gtk_container_get_all_children (container);
if (priv->has_focus_chain &&
(direction == GTK_DIR_TAB_FORWARD ||
diff --git a/gtk/gtkcontainerprivate.h b/gtk/gtkcontainerprivate.h
index 4d77979..d5a7e9f 100644
--- a/gtk/gtkcontainerprivate.h
+++ b/gtk/gtkcontainerprivate.h
@@ -23,6 +23,7 @@
G_BEGIN_DECLS
+GList * _gtk_container_get_all_children (GtkContainer *container);
void _gtk_container_queue_resize (GtkContainer *container);
void _gtk_container_resize_invalidate (GtkContainer *container);
void _gtk_container_clear_resize_widgets (GtkContainer *container);
diff --git a/gtk/gtktoolbar.c b/gtk/gtktoolbar.c
index a8cb86d..dd3d05e 100644
--- a/gtk/gtktoolbar.c
+++ b/gtk/gtktoolbar.c
@@ -39,6 +39,7 @@
#include "gtkarrow.h"
#include "gtkbindings.h"
+#include "gtkcontainerprivate.h"
#include "gtkimage.h"
#include "gtklabel.h"
#include "gtkmainprivate.h"
@@ -233,6 +234,8 @@ static GtkWidgetPath * gtk_toolbar_get_path_for_child
GtkWidget *child);
static void gtk_toolbar_invalidate_order (GtkToolbar *toolbar);
+static void gtk_toolbar_direction_changed (GtkWidget *widget,
+ GtkTextDirection previous_direction);
static void gtk_toolbar_orientation_changed (GtkToolbar *toolbar,
GtkOrientation orientation);
static void gtk_toolbar_real_style_changed (GtkToolbar *toolbar,
@@ -398,6 +401,7 @@ gtk_toolbar_class_init (GtkToolbarClass *klass)
widget_class->unmap = gtk_toolbar_unmap;
widget_class->popup_menu = gtk_toolbar_popup_menu;
widget_class->show_all = gtk_toolbar_show_all;
+ widget_class->direction_changed = gtk_toolbar_direction_changed;
container_class->add = gtk_toolbar_add;
container_class->remove = gtk_toolbar_remove;
@@ -3947,10 +3951,10 @@ gtk_toolbar_get_path_for_child (GtkContainer *container,
* get_children works in visible order
*/
priv->sibling_path = gtk_widget_path_new ();
- children = gtk_container_get_children (container);
+ children = _gtk_container_get_all_children (container);
- if (priv->orientation == GTK_ORIENTATION_HORIZONTAL &&
- gtk_widget_get_direction (GTK_WIDGET (toolbar)) == GTK_TEXT_DIR_RTL)
+ if (priv->orientation != GTK_ORIENTATION_HORIZONTAL ||
+ gtk_widget_get_direction (GTK_WIDGET (toolbar)) != GTK_TEXT_DIR_RTL)
children = g_list_reverse (children);
g_list_foreach (children, add_widget_to_path, priv->sibling_path);
@@ -3985,9 +3989,18 @@ gtk_toolbar_invalidate_order (GtkToolbar *toolbar)
gtk_widget_path_unref (priv->sibling_path);
priv->sibling_path = NULL;
- gtk_container_foreach (GTK_CONTAINER (toolbar),
- (GtkCallback) gtk_widget_reset_style,
- NULL);
+ gtk_container_forall (GTK_CONTAINER (toolbar),
+ (GtkCallback) gtk_widget_reset_style,
+ NULL);
}
}
+static void
+gtk_toolbar_direction_changed (GtkWidget *widget,
+ GtkTextDirection previous_direction)
+{
+ GTK_WIDGET_CLASS (gtk_toolbar_parent_class)->direction_changed (widget, previous_direction);
+
+ gtk_toolbar_invalidate_order (GTK_TOOLBAR (widget));
+}
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]