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/.
29 #include "gtkmenubar.h"
31 #include "gdk/gdkkeysyms.h"
32 #include "gtkbindings.h"
34 #include "gtkmarshalers.h"
35 #include "gtkmenuitem.h"
36 #include "gtkmenuprivate.h"
37 #include "gtksettings.h"
38 #include "gtksizerequest.h"
39 #include "gtkwindow.h"
42 #include "gtkprivate.h"
44 #define BORDER_SPACING 0
45 #define DEFAULT_IPADDING 1
51 PROP_CHILD_PACK_DIRECTION
54 struct _GtkMenuBarPrivate
56 GtkPackDirection pack_direction;
57 GtkPackDirection child_pack_direction;
61 static void gtk_menu_bar_set_property (GObject *object,
65 static void gtk_menu_bar_get_property (GObject *object,
69 static void gtk_menu_bar_size_request (GtkWidget *widget,
70 GtkRequisition *requisition);
71 static void gtk_menu_bar_size_allocate (GtkWidget *widget,
72 GtkAllocation *allocation);
73 static void gtk_menu_bar_paint (GtkWidget *widget,
75 static gint gtk_menu_bar_expose (GtkWidget *widget,
76 GdkEventExpose *event);
77 static void gtk_menu_bar_hierarchy_changed (GtkWidget *widget,
78 GtkWidget *old_toplevel);
79 static gint gtk_menu_bar_get_popup_delay (GtkMenuShell *menu_shell);
80 static void gtk_menu_bar_move_current (GtkMenuShell *menu_shell,
81 GtkMenuDirectionType direction);
83 static GtkShadowType get_shadow_type (GtkMenuBar *menubar);
85 G_DEFINE_TYPE (GtkMenuBar, gtk_menu_bar, GTK_TYPE_MENU_SHELL)
88 gtk_menu_bar_class_init (GtkMenuBarClass *class)
90 GObjectClass *gobject_class;
91 GtkWidgetClass *widget_class;
92 GtkMenuShellClass *menu_shell_class;
94 GtkBindingSet *binding_set;
96 gobject_class = (GObjectClass*) class;
97 widget_class = (GtkWidgetClass*) class;
98 menu_shell_class = (GtkMenuShellClass*) class;
100 gobject_class->get_property = gtk_menu_bar_get_property;
101 gobject_class->set_property = gtk_menu_bar_set_property;
103 widget_class->size_request = gtk_menu_bar_size_request;
104 widget_class->size_allocate = gtk_menu_bar_size_allocate;
105 widget_class->expose_event = gtk_menu_bar_expose;
106 widget_class->hierarchy_changed = gtk_menu_bar_hierarchy_changed;
108 menu_shell_class->submenu_placement = GTK_TOP_BOTTOM;
109 menu_shell_class->get_popup_delay = gtk_menu_bar_get_popup_delay;
110 menu_shell_class->move_current = gtk_menu_bar_move_current;
112 binding_set = gtk_binding_set_by_class (class);
113 gtk_binding_entry_add_signal (binding_set,
116 GTK_TYPE_MENU_DIRECTION_TYPE,
118 gtk_binding_entry_add_signal (binding_set,
121 GTK_TYPE_MENU_DIRECTION_TYPE,
123 gtk_binding_entry_add_signal (binding_set,
126 GTK_TYPE_MENU_DIRECTION_TYPE,
128 gtk_binding_entry_add_signal (binding_set,
131 GTK_TYPE_MENU_DIRECTION_TYPE,
133 gtk_binding_entry_add_signal (binding_set,
136 GTK_TYPE_MENU_DIRECTION_TYPE,
137 GTK_MENU_DIR_PARENT);
138 gtk_binding_entry_add_signal (binding_set,
141 GTK_TYPE_MENU_DIRECTION_TYPE,
142 GTK_MENU_DIR_PARENT);
143 gtk_binding_entry_add_signal (binding_set,
146 GTK_TYPE_MENU_DIRECTION_TYPE,
148 gtk_binding_entry_add_signal (binding_set,
151 GTK_TYPE_MENU_DIRECTION_TYPE,
155 * GtkMenuBar:pack-direction:
157 * The pack direction of the menubar. It determines how
158 * menuitems are arranged in the menubar.
162 g_object_class_install_property (gobject_class,
164 g_param_spec_enum ("pack-direction",
165 P_("Pack direction"),
166 P_("The pack direction of the menubar"),
167 GTK_TYPE_PACK_DIRECTION,
168 GTK_PACK_DIRECTION_LTR,
169 GTK_PARAM_READWRITE));
172 * GtkMenuBar:child-pack-direction:
174 * The child pack direction of the menubar. It determines how
175 * the widgets contained in child menuitems are arranged.
179 g_object_class_install_property (gobject_class,
180 PROP_CHILD_PACK_DIRECTION,
181 g_param_spec_enum ("child-pack-direction",
182 P_("Child Pack direction"),
183 P_("The child pack direction of the menubar"),
184 GTK_TYPE_PACK_DIRECTION,
185 GTK_PACK_DIRECTION_LTR,
186 GTK_PARAM_READWRITE));
189 gtk_widget_class_install_style_property (widget_class,
190 g_param_spec_enum ("shadow-type",
192 P_("Style of bevel around the menubar"),
193 GTK_TYPE_SHADOW_TYPE,
195 GTK_PARAM_READABLE));
197 gtk_widget_class_install_style_property (widget_class,
198 g_param_spec_int ("internal-padding",
199 P_("Internal padding"),
200 P_("Amount of border space between the menubar shadow and the menu items"),
204 GTK_PARAM_READABLE));
206 gtk_settings_install_property (g_param_spec_int ("gtk-menu-bar-popup-delay",
207 P_("Delay before drop down menus appear"),
208 P_("Delay before the submenus of a menu bar appear"),
212 GTK_PARAM_READWRITE));
214 g_type_class_add_private (gobject_class, sizeof (GtkMenuBarPrivate));
218 gtk_menu_bar_init (GtkMenuBar *menu_bar)
220 menu_bar->priv = G_TYPE_INSTANCE_GET_PRIVATE (menu_bar,
226 gtk_menu_bar_new (void)
228 return g_object_new (GTK_TYPE_MENU_BAR, NULL);
232 gtk_menu_bar_set_property (GObject *object,
237 GtkMenuBar *menubar = GTK_MENU_BAR (object);
241 case PROP_PACK_DIRECTION:
242 gtk_menu_bar_set_pack_direction (menubar, g_value_get_enum (value));
244 case PROP_CHILD_PACK_DIRECTION:
245 gtk_menu_bar_set_child_pack_direction (menubar, g_value_get_enum (value));
248 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
254 gtk_menu_bar_get_property (GObject *object,
259 GtkMenuBar *menubar = GTK_MENU_BAR (object);
263 case PROP_PACK_DIRECTION:
264 g_value_set_enum (value, gtk_menu_bar_get_pack_direction (menubar));
266 case PROP_CHILD_PACK_DIRECTION:
267 g_value_set_enum (value, gtk_menu_bar_get_child_pack_direction (menubar));
270 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
276 gtk_menu_bar_size_request (GtkWidget *widget,
277 GtkRequisition *requisition)
279 GtkMenuBar *menu_bar;
280 GtkMenuBarPrivate *priv;
281 GtkMenuShell *menu_shell;
285 GtkRequisition child_requisition;
289 g_return_if_fail (GTK_IS_MENU_BAR (widget));
290 g_return_if_fail (requisition != NULL);
292 requisition->width = 0;
293 requisition->height = 0;
295 if (gtk_widget_get_visible (widget))
297 menu_bar = GTK_MENU_BAR (widget);
298 menu_shell = GTK_MENU_SHELL (widget);
299 priv = menu_bar->priv;
302 children = menu_shell->children;
306 child = children->data;
307 children = children->next;
309 if (gtk_widget_get_visible (child))
313 GTK_MENU_ITEM (child)->show_submenu_indicator = FALSE;
314 gtk_size_request_get_size (GTK_SIZE_REQUEST (child),
315 &child_requisition, NULL);
316 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
319 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
320 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
321 child_requisition.width += toggle_size;
323 child_requisition.height += toggle_size;
325 if (priv->pack_direction == GTK_PACK_DIRECTION_LTR ||
326 priv->pack_direction == GTK_PACK_DIRECTION_RTL)
328 requisition->width += child_requisition.width;
329 requisition->height = MAX (requisition->height, child_requisition.height);
333 requisition->width = MAX (requisition->width, child_requisition.width);
334 requisition->height += child_requisition.height;
340 gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL);
342 border_width = gtk_container_get_border_width (GTK_CONTAINER (menu_bar));
343 requisition->width += (border_width +
346 requisition->height += (border_width +
350 if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE)
354 style = gtk_widget_get_style (widget);
355 requisition->width += style->xthickness * 2;
356 requisition->height += style->ythickness * 2;
362 gtk_menu_bar_size_allocate (GtkWidget *widget,
363 GtkAllocation *allocation)
365 GtkMenuBar *menu_bar;
366 GtkMenuShell *menu_shell;
367 GtkMenuBarPrivate *priv;
370 GtkAllocation child_allocation;
371 GtkRequisition child_requisition;
373 GtkTextDirection direction;
378 g_return_if_fail (GTK_IS_MENU_BAR (widget));
379 g_return_if_fail (allocation != NULL);
381 menu_bar = GTK_MENU_BAR (widget);
382 menu_shell = GTK_MENU_SHELL (widget);
383 priv = menu_bar->priv;
385 direction = gtk_widget_get_direction (widget);
387 gtk_widget_set_allocation (widget, allocation);
389 if (gtk_widget_get_realized (widget))
390 gdk_window_move_resize (gtk_widget_get_window (widget),
391 allocation->x, allocation->y,
392 allocation->width, allocation->height);
394 gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL);
396 if (menu_shell->children)
398 border_width = gtk_container_get_border_width (GTK_CONTAINER (menu_bar));
399 child_allocation.x = (border_width +
402 child_allocation.y = (border_width +
405 if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE)
409 style = gtk_widget_get_style (widget);
410 child_allocation.x += style->xthickness;
411 child_allocation.y += style->ythickness;
414 if (priv->pack_direction == GTK_PACK_DIRECTION_LTR ||
415 priv->pack_direction == GTK_PACK_DIRECTION_RTL)
417 child_allocation.height = MAX (1, (gint)allocation->height - child_allocation.y * 2);
419 offset = child_allocation.x; /* Window edge to menubar start */
420 ltr_x = child_allocation.x;
422 children = menu_shell->children;
427 child = children->data;
428 children = children->next;
430 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
432 gtk_size_request_get_size (GTK_SIZE_REQUEST (child),
433 &child_requisition, NULL);
435 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
436 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
437 child_requisition.width += toggle_size;
439 child_requisition.height += toggle_size;
441 /* Support for the right justified help menu */
442 if ((children == NULL) && (GTK_IS_MENU_ITEM(child))
443 && (GTK_MENU_ITEM(child)->right_justify))
445 ltr_x = allocation->width -
446 child_requisition.width - offset;
448 if (gtk_widget_get_visible (child))
450 if ((direction == GTK_TEXT_DIR_LTR) == (priv->pack_direction == GTK_PACK_DIRECTION_LTR))
451 child_allocation.x = ltr_x;
453 child_allocation.x = allocation->width -
454 child_requisition.width - ltr_x;
456 child_allocation.width = child_requisition.width;
458 gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (child),
460 gtk_widget_size_allocate (child, &child_allocation);
462 ltr_x += child_allocation.width;
468 child_allocation.width = MAX (1, (gint)allocation->width - child_allocation.x * 2);
470 offset = child_allocation.y; /* Window edge to menubar start */
471 ltr_y = child_allocation.y;
473 children = menu_shell->children;
478 child = children->data;
479 children = children->next;
481 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
483 gtk_size_request_get_size (GTK_SIZE_REQUEST (child),
484 &child_requisition, NULL);
486 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
487 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
488 child_requisition.width += toggle_size;
490 child_requisition.height += toggle_size;
492 /* Support for the right justified help menu */
493 if ((children == NULL) && (GTK_IS_MENU_ITEM(child))
494 && (GTK_MENU_ITEM(child)->right_justify))
496 ltr_y = allocation->height -
497 child_requisition.height - offset;
499 if (gtk_widget_get_visible (child))
501 if ((direction == GTK_TEXT_DIR_LTR) ==
502 (priv->pack_direction == GTK_PACK_DIRECTION_TTB))
503 child_allocation.y = ltr_y;
505 child_allocation.y = allocation->height -
506 child_requisition.height - ltr_y;
507 child_allocation.height = child_requisition.height;
509 gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (child),
511 gtk_widget_size_allocate (child, &child_allocation);
513 ltr_y += child_allocation.height;
521 gtk_menu_bar_paint (GtkWidget *widget,
524 g_return_if_fail (GTK_IS_MENU_BAR (widget));
526 if (gtk_widget_is_drawable (widget))
528 GtkAllocation allocation;
531 border = gtk_container_get_border_width (GTK_CONTAINER (widget));
532 gtk_widget_get_allocation (widget, &allocation);
534 gtk_paint_box (gtk_widget_get_style (widget),
535 gtk_widget_get_window (widget),
536 gtk_widget_get_state (widget),
537 get_shadow_type (GTK_MENU_BAR (widget)),
538 area, widget, "menubar",
540 allocation.width - border * 2,
541 allocation.height - border * 2);
546 gtk_menu_bar_expose (GtkWidget *widget,
547 GdkEventExpose *event)
549 g_return_val_if_fail (GTK_IS_MENU_BAR (widget), FALSE);
550 g_return_val_if_fail (event != NULL, FALSE);
552 if (gtk_widget_is_drawable (widget))
554 gtk_menu_bar_paint (widget, &event->area);
556 GTK_WIDGET_CLASS (gtk_menu_bar_parent_class)->expose_event (widget, event);
563 get_menu_bars (GtkWindow *window)
565 return g_object_get_data (G_OBJECT (window), "gtk-menu-bar-list");
569 get_viewable_menu_bars (GtkWindow *window)
572 GList *viewable_menu_bars = NULL;
574 for (menu_bars = get_menu_bars (window);
576 menu_bars = menu_bars->next)
578 GtkWidget *widget = menu_bars->data;
579 gboolean viewable = TRUE;
583 if (!gtk_widget_get_mapped (widget))
586 widget = gtk_widget_get_parent (widget);
590 viewable_menu_bars = g_list_prepend (viewable_menu_bars, menu_bars->data);
593 return g_list_reverse (viewable_menu_bars);
597 set_menu_bars (GtkWindow *window,
600 g_object_set_data (G_OBJECT (window), I_("gtk-menu-bar-list"), menubars);
604 window_key_press_handler (GtkWidget *widget,
609 gboolean retval = FALSE;
611 g_object_get (gtk_widget_get_settings (widget),
612 "gtk-menu-bar-accel", &accel,
618 GdkModifierType mods = 0;
620 gtk_accelerator_parse (accel, &keyval, &mods);
623 g_warning ("Failed to parse menu bar accelerator '%s'\n", accel);
625 /* FIXME this is wrong, needs to be in the global accel resolution
626 * thing, to properly consider i18n etc., but that probably requires
627 * AccelGroup changes etc.
629 if (event->keyval == keyval &&
630 ((event->state & gtk_accelerator_get_default_mod_mask ()) ==
631 (mods & gtk_accelerator_get_default_mod_mask ())))
633 GList *tmp_menubars = get_viewable_menu_bars (GTK_WINDOW (widget));
636 menubars = _gtk_container_focus_sort (GTK_CONTAINER (widget), tmp_menubars,
637 GTK_DIR_TAB_FORWARD, NULL);
638 g_list_free (tmp_menubars);
642 GtkMenuShell *menu_shell = GTK_MENU_SHELL (menubars->data);
644 _gtk_menu_shell_set_keyboard_mode (menu_shell, TRUE);
645 _gtk_menu_shell_activate (menu_shell);
646 gtk_menu_shell_select_first (menu_shell, FALSE);
648 g_list_free (menubars);
661 add_to_window (GtkWindow *window,
664 GList *menubars = get_menu_bars (window);
668 g_signal_connect (window,
670 G_CALLBACK (window_key_press_handler),
674 set_menu_bars (window, g_list_prepend (menubars, menubar));
678 remove_from_window (GtkWindow *window,
681 GList *menubars = get_menu_bars (window);
683 menubars = g_list_remove (menubars, menubar);
687 g_signal_handlers_disconnect_by_func (window,
688 window_key_press_handler,
692 set_menu_bars (window, menubars);
696 gtk_menu_bar_hierarchy_changed (GtkWidget *widget,
697 GtkWidget *old_toplevel)
702 menubar = GTK_MENU_BAR (widget);
704 toplevel = gtk_widget_get_toplevel (widget);
707 remove_from_window (GTK_WINDOW (old_toplevel), menubar);
709 if (gtk_widget_is_toplevel (toplevel))
710 add_to_window (GTK_WINDOW (toplevel), menubar);
714 * _gtk_menu_bar_cycle_focus:
715 * @menubar: a #GtkMenuBar
716 * @dir: direction in which to cycle the focus
718 * Move the focus between menubars in the toplevel.
721 _gtk_menu_bar_cycle_focus (GtkMenuBar *menubar,
722 GtkDirectionType dir)
724 GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (menubar));
725 GtkMenuItem *to_activate = NULL;
727 if (gtk_widget_is_toplevel (toplevel))
729 GList *tmp_menubars = get_viewable_menu_bars (GTK_WINDOW (toplevel));
733 menubars = _gtk_container_focus_sort (GTK_CONTAINER (toplevel), tmp_menubars,
734 dir, GTK_WIDGET (menubar));
735 g_list_free (tmp_menubars);
739 current = g_list_find (menubars, menubar);
741 if (current && current->next)
743 GtkMenuShell *new_menushell = GTK_MENU_SHELL (current->next->data);
744 if (new_menushell->children)
745 to_activate = new_menushell->children->data;
749 g_list_free (menubars);
752 gtk_menu_shell_cancel (GTK_MENU_SHELL (menubar));
755 g_signal_emit_by_name (to_activate, "activate_item");
759 get_shadow_type (GtkMenuBar *menubar)
761 GtkShadowType shadow_type = GTK_SHADOW_OUT;
763 gtk_widget_style_get (GTK_WIDGET (menubar),
764 "shadow-type", &shadow_type,
771 gtk_menu_bar_get_popup_delay (GtkMenuShell *menu_shell)
775 g_object_get (gtk_widget_get_settings (GTK_WIDGET (menu_shell)),
776 "gtk-menu-bar-popup-delay", &popup_delay,
783 gtk_menu_bar_move_current (GtkMenuShell *menu_shell,
784 GtkMenuDirectionType direction)
786 GtkMenuBar *menubar = GTK_MENU_BAR (menu_shell);
787 GtkTextDirection text_dir;
788 GtkPackDirection pack_dir;
790 text_dir = gtk_widget_get_direction (GTK_WIDGET (menubar));
791 pack_dir = gtk_menu_bar_get_pack_direction (menubar);
793 if (pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL)
795 if ((text_dir == GTK_TEXT_DIR_RTL) == (pack_dir == GTK_PACK_DIRECTION_LTR))
799 case GTK_MENU_DIR_PREV:
800 direction = GTK_MENU_DIR_NEXT;
802 case GTK_MENU_DIR_NEXT:
803 direction = GTK_MENU_DIR_PREV;
813 case GTK_MENU_DIR_PARENT:
814 if ((text_dir == GTK_TEXT_DIR_LTR) == (pack_dir == GTK_PACK_DIRECTION_TTB))
815 direction = GTK_MENU_DIR_PREV;
817 direction = GTK_MENU_DIR_NEXT;
819 case GTK_MENU_DIR_CHILD:
820 if ((text_dir == GTK_TEXT_DIR_LTR) == (pack_dir == GTK_PACK_DIRECTION_TTB))
821 direction = GTK_MENU_DIR_NEXT;
823 direction = GTK_MENU_DIR_PREV;
825 case GTK_MENU_DIR_PREV:
826 if (text_dir == GTK_TEXT_DIR_RTL)
827 direction = GTK_MENU_DIR_CHILD;
829 direction = GTK_MENU_DIR_PARENT;
831 case GTK_MENU_DIR_NEXT:
832 if (text_dir == GTK_TEXT_DIR_RTL)
833 direction = GTK_MENU_DIR_PARENT;
835 direction = GTK_MENU_DIR_CHILD;
841 GTK_MENU_SHELL_CLASS (gtk_menu_bar_parent_class)->move_current (menu_shell, direction);
845 * gtk_menu_bar_get_pack_direction:
846 * @menubar: a #GtkMenuBar
848 * Retrieves the current pack direction of the menubar.
849 * See gtk_menu_bar_set_pack_direction().
851 * Return value: the pack direction
856 gtk_menu_bar_get_pack_direction (GtkMenuBar *menubar)
858 g_return_val_if_fail (GTK_IS_MENU_BAR (menubar),
859 GTK_PACK_DIRECTION_LTR);
861 return menubar->priv->pack_direction;
865 * gtk_menu_bar_set_pack_direction:
866 * @menubar: a #GtkMenuBar
867 * @pack_dir: a new #GtkPackDirection
869 * Sets how items should be packed inside a menubar.
874 gtk_menu_bar_set_pack_direction (GtkMenuBar *menubar,
875 GtkPackDirection pack_dir)
877 GtkMenuBarPrivate *priv;
880 g_return_if_fail (GTK_IS_MENU_BAR (menubar));
882 priv = menubar->priv;
884 if (priv->pack_direction != pack_dir)
886 priv->pack_direction = pack_dir;
888 gtk_widget_queue_resize (GTK_WIDGET (menubar));
890 for (l = GTK_MENU_SHELL (menubar)->children; l; l = l->next)
891 gtk_widget_queue_resize (GTK_WIDGET (l->data));
893 g_object_notify (G_OBJECT (menubar), "pack-direction");
898 * gtk_menu_bar_get_child_pack_direction:
899 * @menubar: a #GtkMenuBar
901 * Retrieves the current child pack direction of the menubar.
902 * See gtk_menu_bar_set_child_pack_direction().
904 * Return value: the child pack direction
909 gtk_menu_bar_get_child_pack_direction (GtkMenuBar *menubar)
911 g_return_val_if_fail (GTK_IS_MENU_BAR (menubar),
912 GTK_PACK_DIRECTION_LTR);
914 return menubar->priv->child_pack_direction;
918 * gtk_menu_bar_set_child_pack_direction:
919 * @menubar: a #GtkMenuBar
920 * @child_pack_dir: a new #GtkPackDirection
922 * Sets how widgets should be packed inside the children of a menubar.
927 gtk_menu_bar_set_child_pack_direction (GtkMenuBar *menubar,
928 GtkPackDirection child_pack_dir)
930 GtkMenuBarPrivate *priv;
933 g_return_if_fail (GTK_IS_MENU_BAR (menubar));
935 priv = menubar->priv;
937 if (priv->child_pack_direction != child_pack_dir)
939 priv->child_pack_direction = child_pack_dir;
941 gtk_widget_queue_resize (GTK_WIDGET (menubar));
943 for (l = GTK_MENU_SHELL (menubar)->children; l; l = l->next)
944 gtk_widget_queue_resize (GTK_WIDGET (l->data));
946 g_object_notify (G_OBJECT (menubar), "child-pack-direction");