1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
22 * file for a list of people on the GTK+ Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
27 #define GTK_MENU_INTERNALS
30 #include "gdk/gdkkeysyms.h"
31 #include "gtkbindings.h"
33 #include "gtkmarshalers.h"
34 #include "gtkmenubar.h"
35 #include "gtkmenuitem.h"
36 #include "gtksettings.h"
38 #include "gtkwindow.h"
39 #include "gtkprivate.h"
41 #define BORDER_SPACING 0
42 #define DEFAULT_IPADDING 1
48 PROP_CHILD_PACK_DIRECTION
51 struct _GtkMenuBarPrivate
53 GtkPackDirection pack_direction;
54 GtkPackDirection child_pack_direction;
58 static void gtk_menu_bar_set_property (GObject *object,
62 static void gtk_menu_bar_get_property (GObject *object,
66 static void gtk_menu_bar_size_request (GtkWidget *widget,
67 GtkRequisition *requisition);
68 static void gtk_menu_bar_size_allocate (GtkWidget *widget,
69 GtkAllocation *allocation);
70 static void gtk_menu_bar_paint (GtkWidget *widget,
72 static gint gtk_menu_bar_expose (GtkWidget *widget,
73 GdkEventExpose *event);
74 static void gtk_menu_bar_hierarchy_changed (GtkWidget *widget,
75 GtkWidget *old_toplevel);
76 static gint gtk_menu_bar_get_popup_delay (GtkMenuShell *menu_shell);
77 static void gtk_menu_bar_move_current (GtkMenuShell *menu_shell,
78 GtkMenuDirectionType direction);
80 static GtkShadowType get_shadow_type (GtkMenuBar *menubar);
82 G_DEFINE_TYPE (GtkMenuBar, gtk_menu_bar, GTK_TYPE_MENU_SHELL)
85 gtk_menu_bar_class_init (GtkMenuBarClass *class)
87 GObjectClass *gobject_class;
88 GtkWidgetClass *widget_class;
89 GtkMenuShellClass *menu_shell_class;
91 GtkBindingSet *binding_set;
93 gobject_class = (GObjectClass*) class;
94 widget_class = (GtkWidgetClass*) class;
95 menu_shell_class = (GtkMenuShellClass*) class;
97 gobject_class->get_property = gtk_menu_bar_get_property;
98 gobject_class->set_property = gtk_menu_bar_set_property;
100 widget_class->size_request = gtk_menu_bar_size_request;
101 widget_class->size_allocate = gtk_menu_bar_size_allocate;
102 widget_class->expose_event = gtk_menu_bar_expose;
103 widget_class->hierarchy_changed = gtk_menu_bar_hierarchy_changed;
105 menu_shell_class->submenu_placement = GTK_TOP_BOTTOM;
106 menu_shell_class->get_popup_delay = gtk_menu_bar_get_popup_delay;
107 menu_shell_class->move_current = gtk_menu_bar_move_current;
109 binding_set = gtk_binding_set_by_class (class);
110 gtk_binding_entry_add_signal (binding_set,
113 GTK_TYPE_MENU_DIRECTION_TYPE,
115 gtk_binding_entry_add_signal (binding_set,
118 GTK_TYPE_MENU_DIRECTION_TYPE,
120 gtk_binding_entry_add_signal (binding_set,
123 GTK_TYPE_MENU_DIRECTION_TYPE,
125 gtk_binding_entry_add_signal (binding_set,
128 GTK_TYPE_MENU_DIRECTION_TYPE,
130 gtk_binding_entry_add_signal (binding_set,
133 GTK_TYPE_MENU_DIRECTION_TYPE,
134 GTK_MENU_DIR_PARENT);
135 gtk_binding_entry_add_signal (binding_set,
138 GTK_TYPE_MENU_DIRECTION_TYPE,
139 GTK_MENU_DIR_PARENT);
140 gtk_binding_entry_add_signal (binding_set,
143 GTK_TYPE_MENU_DIRECTION_TYPE,
145 gtk_binding_entry_add_signal (binding_set,
148 GTK_TYPE_MENU_DIRECTION_TYPE,
152 * GtkMenuBar:pack-direction:
154 * The pack direction of the menubar. It determines how
155 * menuitems are arranged in the menubar.
159 g_object_class_install_property (gobject_class,
161 g_param_spec_enum ("pack-direction",
162 P_("Pack direction"),
163 P_("The pack direction of the menubar"),
164 GTK_TYPE_PACK_DIRECTION,
165 GTK_PACK_DIRECTION_LTR,
166 GTK_PARAM_READWRITE));
169 * GtkMenuBar:child-pack-direction:
171 * The child pack direction of the menubar. It determines how
172 * the widgets contained in child menuitems are arranged.
176 g_object_class_install_property (gobject_class,
177 PROP_CHILD_PACK_DIRECTION,
178 g_param_spec_enum ("child-pack-direction",
179 P_("Child Pack direction"),
180 P_("The child pack direction of the menubar"),
181 GTK_TYPE_PACK_DIRECTION,
182 GTK_PACK_DIRECTION_LTR,
183 GTK_PARAM_READWRITE));
186 gtk_widget_class_install_style_property (widget_class,
187 g_param_spec_enum ("shadow-type",
189 P_("Style of bevel around the menubar"),
190 GTK_TYPE_SHADOW_TYPE,
192 GTK_PARAM_READABLE));
194 gtk_widget_class_install_style_property (widget_class,
195 g_param_spec_int ("internal-padding",
196 P_("Internal padding"),
197 P_("Amount of border space between the menubar shadow and the menu items"),
201 GTK_PARAM_READABLE));
203 gtk_settings_install_property (g_param_spec_int ("gtk-menu-bar-popup-delay",
204 P_("Delay before drop down menus appear"),
205 P_("Delay before the submenus of a menu bar appear"),
209 GTK_PARAM_READWRITE));
211 g_type_class_add_private (gobject_class, sizeof (GtkMenuBarPrivate));
215 gtk_menu_bar_init (GtkMenuBar *menu_bar)
217 menu_bar->priv = G_TYPE_INSTANCE_GET_PRIVATE (menu_bar,
223 gtk_menu_bar_new (void)
225 return g_object_new (GTK_TYPE_MENU_BAR, NULL);
229 gtk_menu_bar_set_property (GObject *object,
234 GtkMenuBar *menubar = GTK_MENU_BAR (object);
238 case PROP_PACK_DIRECTION:
239 gtk_menu_bar_set_pack_direction (menubar, g_value_get_enum (value));
241 case PROP_CHILD_PACK_DIRECTION:
242 gtk_menu_bar_set_child_pack_direction (menubar, g_value_get_enum (value));
245 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
251 gtk_menu_bar_get_property (GObject *object,
256 GtkMenuBar *menubar = GTK_MENU_BAR (object);
260 case PROP_PACK_DIRECTION:
261 g_value_set_enum (value, gtk_menu_bar_get_pack_direction (menubar));
263 case PROP_CHILD_PACK_DIRECTION:
264 g_value_set_enum (value, gtk_menu_bar_get_child_pack_direction (menubar));
267 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
273 gtk_menu_bar_size_request (GtkWidget *widget,
274 GtkRequisition *requisition)
276 GtkMenuBar *menu_bar;
277 GtkMenuBarPrivate *priv;
278 GtkMenuShell *menu_shell;
282 GtkRequisition child_requisition;
286 g_return_if_fail (GTK_IS_MENU_BAR (widget));
287 g_return_if_fail (requisition != NULL);
289 requisition->width = 0;
290 requisition->height = 0;
292 if (gtk_widget_get_visible (widget))
294 menu_bar = GTK_MENU_BAR (widget);
295 menu_shell = GTK_MENU_SHELL (widget);
296 priv = menu_bar->priv;
299 children = menu_shell->children;
303 child = children->data;
304 children = children->next;
306 if (gtk_widget_get_visible (child))
310 GTK_MENU_ITEM (child)->show_submenu_indicator = FALSE;
311 gtk_widget_size_request (child, &child_requisition);
312 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
315 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
316 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
317 child_requisition.width += toggle_size;
319 child_requisition.height += toggle_size;
321 if (priv->pack_direction == GTK_PACK_DIRECTION_LTR ||
322 priv->pack_direction == GTK_PACK_DIRECTION_RTL)
324 requisition->width += child_requisition.width;
325 requisition->height = MAX (requisition->height, child_requisition.height);
329 requisition->width = MAX (requisition->width, child_requisition.width);
330 requisition->height += child_requisition.height;
336 gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL);
338 border_width = gtk_container_get_border_width (GTK_CONTAINER (menu_bar));
339 requisition->width += (border_width +
342 requisition->height += (border_width +
346 if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE)
348 requisition->width += widget->style->xthickness * 2;
349 requisition->height += widget->style->ythickness * 2;
355 gtk_menu_bar_size_allocate (GtkWidget *widget,
356 GtkAllocation *allocation)
358 GtkMenuBar *menu_bar;
359 GtkMenuShell *menu_shell;
360 GtkMenuBarPrivate *priv;
363 GtkAllocation child_allocation;
364 GtkRequisition child_requisition;
366 GtkTextDirection direction;
371 g_return_if_fail (GTK_IS_MENU_BAR (widget));
372 g_return_if_fail (allocation != NULL);
374 menu_bar = GTK_MENU_BAR (widget);
375 menu_shell = GTK_MENU_SHELL (widget);
376 priv = menu_bar->priv;
378 direction = gtk_widget_get_direction (widget);
380 widget->allocation = *allocation;
381 if (gtk_widget_get_realized (widget))
382 gdk_window_move_resize (widget->window,
383 allocation->x, allocation->y,
384 allocation->width, allocation->height);
386 gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL);
388 if (menu_shell->children)
390 border_width = gtk_container_get_border_width (GTK_CONTAINER (menu_bar));
391 child_allocation.x = (border_width +
394 child_allocation.y = (border_width +
397 if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE)
399 child_allocation.x += widget->style->xthickness;
400 child_allocation.y += widget->style->ythickness;
403 if (priv->pack_direction == GTK_PACK_DIRECTION_LTR ||
404 priv->pack_direction == GTK_PACK_DIRECTION_RTL)
406 child_allocation.height = MAX (1, (gint)allocation->height - child_allocation.y * 2);
408 offset = child_allocation.x; /* Window edge to menubar start */
409 ltr_x = child_allocation.x;
411 children = menu_shell->children;
416 child = children->data;
417 children = children->next;
419 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
421 gtk_widget_get_child_requisition (child, &child_requisition);
423 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
424 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
425 child_requisition.width += toggle_size;
427 child_requisition.height += toggle_size;
429 /* Support for the right justified help menu */
430 if ((children == NULL) && (GTK_IS_MENU_ITEM(child))
431 && (GTK_MENU_ITEM(child)->right_justify))
433 ltr_x = allocation->width -
434 child_requisition.width - offset;
436 if (gtk_widget_get_visible (child))
438 if ((direction == GTK_TEXT_DIR_LTR) == (priv->pack_direction == GTK_PACK_DIRECTION_LTR))
439 child_allocation.x = ltr_x;
441 child_allocation.x = allocation->width -
442 child_requisition.width - ltr_x;
444 child_allocation.width = child_requisition.width;
446 gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (child),
448 gtk_widget_size_allocate (child, &child_allocation);
450 ltr_x += child_allocation.width;
456 child_allocation.width = MAX (1, (gint)allocation->width - child_allocation.x * 2);
458 offset = child_allocation.y; /* Window edge to menubar start */
459 ltr_y = child_allocation.y;
461 children = menu_shell->children;
466 child = children->data;
467 children = children->next;
469 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
471 gtk_widget_get_child_requisition (child, &child_requisition);
473 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
474 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
475 child_requisition.width += toggle_size;
477 child_requisition.height += toggle_size;
479 /* Support for the right justified help menu */
480 if ((children == NULL) && (GTK_IS_MENU_ITEM(child))
481 && (GTK_MENU_ITEM(child)->right_justify))
483 ltr_y = allocation->height -
484 child_requisition.height - offset;
486 if (gtk_widget_get_visible (child))
488 if ((direction == GTK_TEXT_DIR_LTR) ==
489 (priv->pack_direction == GTK_PACK_DIRECTION_TTB))
490 child_allocation.y = ltr_y;
492 child_allocation.y = allocation->height -
493 child_requisition.height - ltr_y;
494 child_allocation.height = child_requisition.height;
496 gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (child),
498 gtk_widget_size_allocate (child, &child_allocation);
500 ltr_y += child_allocation.height;
508 gtk_menu_bar_paint (GtkWidget *widget,
511 g_return_if_fail (GTK_IS_MENU_BAR (widget));
513 if (gtk_widget_is_drawable (widget))
517 border = gtk_container_get_border_width (GTK_CONTAINER (widget));
519 gtk_paint_box (widget->style,
521 gtk_widget_get_state (widget),
522 get_shadow_type (GTK_MENU_BAR (widget)),
523 area, widget, "menubar",
525 widget->allocation.width - border * 2,
526 widget->allocation.height - border * 2);
531 gtk_menu_bar_expose (GtkWidget *widget,
532 GdkEventExpose *event)
534 g_return_val_if_fail (GTK_IS_MENU_BAR (widget), FALSE);
535 g_return_val_if_fail (event != NULL, FALSE);
537 if (gtk_widget_is_drawable (widget))
539 gtk_menu_bar_paint (widget, &event->area);
541 GTK_WIDGET_CLASS (gtk_menu_bar_parent_class)->expose_event (widget, event);
548 get_menu_bars (GtkWindow *window)
550 return g_object_get_data (G_OBJECT (window), "gtk-menu-bar-list");
554 get_viewable_menu_bars (GtkWindow *window)
557 GList *viewable_menu_bars = NULL;
559 for (menu_bars = get_menu_bars (window);
561 menu_bars = menu_bars->next)
563 GtkWidget *widget = menu_bars->data;
564 gboolean viewable = TRUE;
568 if (!gtk_widget_get_mapped (widget))
571 widget = widget->parent;
575 viewable_menu_bars = g_list_prepend (viewable_menu_bars, menu_bars->data);
578 return g_list_reverse (viewable_menu_bars);
582 set_menu_bars (GtkWindow *window,
585 g_object_set_data (G_OBJECT (window), I_("gtk-menu-bar-list"), menubars);
589 window_key_press_handler (GtkWidget *widget,
594 gboolean retval = FALSE;
596 g_object_get (gtk_widget_get_settings (widget),
597 "gtk-menu-bar-accel", &accel,
603 GdkModifierType mods = 0;
605 gtk_accelerator_parse (accel, &keyval, &mods);
608 g_warning ("Failed to parse menu bar accelerator '%s'\n", accel);
610 /* FIXME this is wrong, needs to be in the global accel resolution
611 * thing, to properly consider i18n etc., but that probably requires
612 * AccelGroup changes etc.
614 if (event->keyval == keyval &&
615 ((event->state & gtk_accelerator_get_default_mod_mask ()) ==
616 (mods & gtk_accelerator_get_default_mod_mask ())))
618 GList *tmp_menubars = get_viewable_menu_bars (GTK_WINDOW (widget));
621 menubars = _gtk_container_focus_sort (GTK_CONTAINER (widget), tmp_menubars,
622 GTK_DIR_TAB_FORWARD, NULL);
623 g_list_free (tmp_menubars);
627 GtkMenuShell *menu_shell = GTK_MENU_SHELL (menubars->data);
629 _gtk_menu_shell_set_keyboard_mode (menu_shell, TRUE);
630 _gtk_menu_shell_activate (menu_shell);
631 gtk_menu_shell_select_first (menu_shell, FALSE);
633 g_list_free (menubars);
646 add_to_window (GtkWindow *window,
649 GList *menubars = get_menu_bars (window);
653 g_signal_connect (window,
655 G_CALLBACK (window_key_press_handler),
659 set_menu_bars (window, g_list_prepend (menubars, menubar));
663 remove_from_window (GtkWindow *window,
666 GList *menubars = get_menu_bars (window);
668 menubars = g_list_remove (menubars, menubar);
672 g_signal_handlers_disconnect_by_func (window,
673 window_key_press_handler,
677 set_menu_bars (window, menubars);
681 gtk_menu_bar_hierarchy_changed (GtkWidget *widget,
682 GtkWidget *old_toplevel)
687 menubar = GTK_MENU_BAR (widget);
689 toplevel = gtk_widget_get_toplevel (widget);
692 remove_from_window (GTK_WINDOW (old_toplevel), menubar);
694 if (gtk_widget_is_toplevel (toplevel))
695 add_to_window (GTK_WINDOW (toplevel), menubar);
699 * _gtk_menu_bar_cycle_focus:
700 * @menubar: a #GtkMenuBar
701 * @dir: direction in which to cycle the focus
703 * Move the focus between menubars in the toplevel.
706 _gtk_menu_bar_cycle_focus (GtkMenuBar *menubar,
707 GtkDirectionType dir)
709 GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (menubar));
710 GtkMenuItem *to_activate = NULL;
712 if (gtk_widget_is_toplevel (toplevel))
714 GList *tmp_menubars = get_viewable_menu_bars (GTK_WINDOW (toplevel));
718 menubars = _gtk_container_focus_sort (GTK_CONTAINER (toplevel), tmp_menubars,
719 dir, GTK_WIDGET (menubar));
720 g_list_free (tmp_menubars);
724 current = g_list_find (menubars, menubar);
726 if (current && current->next)
728 GtkMenuShell *new_menushell = GTK_MENU_SHELL (current->next->data);
729 if (new_menushell->children)
730 to_activate = new_menushell->children->data;
734 g_list_free (menubars);
737 gtk_menu_shell_cancel (GTK_MENU_SHELL (menubar));
740 g_signal_emit_by_name (to_activate, "activate_item");
744 get_shadow_type (GtkMenuBar *menubar)
746 GtkShadowType shadow_type = GTK_SHADOW_OUT;
748 gtk_widget_style_get (GTK_WIDGET (menubar),
749 "shadow-type", &shadow_type,
756 gtk_menu_bar_get_popup_delay (GtkMenuShell *menu_shell)
760 g_object_get (gtk_widget_get_settings (GTK_WIDGET (menu_shell)),
761 "gtk-menu-bar-popup-delay", &popup_delay,
768 gtk_menu_bar_move_current (GtkMenuShell *menu_shell,
769 GtkMenuDirectionType direction)
771 GtkMenuBar *menubar = GTK_MENU_BAR (menu_shell);
772 GtkTextDirection text_dir;
773 GtkPackDirection pack_dir;
775 text_dir = gtk_widget_get_direction (GTK_WIDGET (menubar));
776 pack_dir = gtk_menu_bar_get_pack_direction (menubar);
778 if (pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL)
780 if ((text_dir == GTK_TEXT_DIR_RTL) == (pack_dir == GTK_PACK_DIRECTION_LTR))
784 case GTK_MENU_DIR_PREV:
785 direction = GTK_MENU_DIR_NEXT;
787 case GTK_MENU_DIR_NEXT:
788 direction = GTK_MENU_DIR_PREV;
798 case GTK_MENU_DIR_PARENT:
799 if ((text_dir == GTK_TEXT_DIR_LTR) == (pack_dir == GTK_PACK_DIRECTION_TTB))
800 direction = GTK_MENU_DIR_PREV;
802 direction = GTK_MENU_DIR_NEXT;
804 case GTK_MENU_DIR_CHILD:
805 if ((text_dir == GTK_TEXT_DIR_LTR) == (pack_dir == GTK_PACK_DIRECTION_TTB))
806 direction = GTK_MENU_DIR_NEXT;
808 direction = GTK_MENU_DIR_PREV;
810 case GTK_MENU_DIR_PREV:
811 if (text_dir == GTK_TEXT_DIR_RTL)
812 direction = GTK_MENU_DIR_CHILD;
814 direction = GTK_MENU_DIR_PARENT;
816 case GTK_MENU_DIR_NEXT:
817 if (text_dir == GTK_TEXT_DIR_RTL)
818 direction = GTK_MENU_DIR_PARENT;
820 direction = GTK_MENU_DIR_CHILD;
826 GTK_MENU_SHELL_CLASS (gtk_menu_bar_parent_class)->move_current (menu_shell, direction);
830 * gtk_menu_bar_get_pack_direction:
831 * @menubar: a #GtkMenuBar
833 * Retrieves the current pack direction of the menubar.
834 * See gtk_menu_bar_set_pack_direction().
836 * Return value: the pack direction
841 gtk_menu_bar_get_pack_direction (GtkMenuBar *menubar)
843 g_return_val_if_fail (GTK_IS_MENU_BAR (menubar),
844 GTK_PACK_DIRECTION_LTR);
846 return menubar->priv->pack_direction;
850 * gtk_menu_bar_set_pack_direction:
851 * @menubar: a #GtkMenuBar
852 * @pack_dir: a new #GtkPackDirection
854 * Sets how items should be packed inside a menubar.
859 gtk_menu_bar_set_pack_direction (GtkMenuBar *menubar,
860 GtkPackDirection pack_dir)
862 GtkMenuBarPrivate *priv;
865 g_return_if_fail (GTK_IS_MENU_BAR (menubar));
867 priv = menubar->priv;
869 if (priv->pack_direction != pack_dir)
871 priv->pack_direction = pack_dir;
873 gtk_widget_queue_resize (GTK_WIDGET (menubar));
875 for (l = GTK_MENU_SHELL (menubar)->children; l; l = l->next)
876 gtk_widget_queue_resize (GTK_WIDGET (l->data));
878 g_object_notify (G_OBJECT (menubar), "pack-direction");
883 * gtk_menu_bar_get_child_pack_direction:
884 * @menubar: a #GtkMenuBar
886 * Retrieves the current child pack direction of the menubar.
887 * See gtk_menu_bar_set_child_pack_direction().
889 * Return value: the child pack direction
894 gtk_menu_bar_get_child_pack_direction (GtkMenuBar *menubar)
896 g_return_val_if_fail (GTK_IS_MENU_BAR (menubar),
897 GTK_PACK_DIRECTION_LTR);
899 return menubar->priv->child_pack_direction;
903 * gtk_menu_bar_set_child_pack_direction:
904 * @menubar: a #GtkMenuBar
905 * @child_pack_dir: a new #GtkPackDirection
907 * Sets how widgets should be packed inside the children of a menubar.
912 gtk_menu_bar_set_child_pack_direction (GtkMenuBar *menubar,
913 GtkPackDirection child_pack_dir)
915 GtkMenuBarPrivate *priv;
918 g_return_if_fail (GTK_IS_MENU_BAR (menubar));
920 priv = menubar->priv;
922 if (priv->child_pack_direction != child_pack_dir)
924 priv->child_pack_direction = child_pack_dir;
926 gtk_widget_queue_resize (GTK_WIDGET (menubar));
928 for (l = GTK_MENU_SHELL (menubar)->children; l; l = l->next)
929 gtk_widget_queue_resize (GTK_WIDGET (l->data));
931 g_object_notify (G_OBJECT (menubar), "child-pack-direction");