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"
43 #define BORDER_SPACING 0
44 #define DEFAULT_IPADDING 1
50 PROP_CHILD_PACK_DIRECTION
53 typedef struct _GtkMenuBarPrivate GtkMenuBarPrivate;
54 struct _GtkMenuBarPrivate
56 GtkPackDirection pack_direction;
57 GtkPackDirection child_pack_direction;
60 #define GTK_MENU_BAR_GET_PRIVATE(o) \
61 (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_MENU_BAR, GtkMenuBarPrivate))
64 static void gtk_menu_bar_set_property (GObject *object,
68 static void gtk_menu_bar_get_property (GObject *object,
72 static void gtk_menu_bar_size_request (GtkWidget *widget,
73 GtkRequisition *requisition);
74 static void gtk_menu_bar_size_allocate (GtkWidget *widget,
75 GtkAllocation *allocation);
76 static void gtk_menu_bar_paint (GtkWidget *widget,
78 static gint gtk_menu_bar_expose (GtkWidget *widget,
79 GdkEventExpose *event);
80 static void gtk_menu_bar_hierarchy_changed (GtkWidget *widget,
81 GtkWidget *old_toplevel);
82 static gint gtk_menu_bar_get_popup_delay (GtkMenuShell *menu_shell);
83 static void gtk_menu_bar_move_current (GtkMenuShell *menu_shell,
84 GtkMenuDirectionType direction);
86 static GtkShadowType get_shadow_type (GtkMenuBar *menubar);
88 G_DEFINE_TYPE (GtkMenuBar, gtk_menu_bar, GTK_TYPE_MENU_SHELL)
91 gtk_menu_bar_class_init (GtkMenuBarClass *class)
93 GObjectClass *gobject_class;
94 GtkWidgetClass *widget_class;
95 GtkMenuShellClass *menu_shell_class;
97 GtkBindingSet *binding_set;
99 gobject_class = (GObjectClass*) class;
100 widget_class = (GtkWidgetClass*) class;
101 menu_shell_class = (GtkMenuShellClass*) class;
103 gobject_class->get_property = gtk_menu_bar_get_property;
104 gobject_class->set_property = gtk_menu_bar_set_property;
106 widget_class->size_request = gtk_menu_bar_size_request;
107 widget_class->size_allocate = gtk_menu_bar_size_allocate;
108 widget_class->expose_event = gtk_menu_bar_expose;
109 widget_class->hierarchy_changed = gtk_menu_bar_hierarchy_changed;
111 menu_shell_class->submenu_placement = GTK_TOP_BOTTOM;
112 menu_shell_class->get_popup_delay = gtk_menu_bar_get_popup_delay;
113 menu_shell_class->move_current = gtk_menu_bar_move_current;
115 binding_set = gtk_binding_set_by_class (class);
116 gtk_binding_entry_add_signal (binding_set,
119 GTK_TYPE_MENU_DIRECTION_TYPE,
121 gtk_binding_entry_add_signal (binding_set,
124 GTK_TYPE_MENU_DIRECTION_TYPE,
126 gtk_binding_entry_add_signal (binding_set,
129 GTK_TYPE_MENU_DIRECTION_TYPE,
131 gtk_binding_entry_add_signal (binding_set,
134 GTK_TYPE_MENU_DIRECTION_TYPE,
136 gtk_binding_entry_add_signal (binding_set,
139 GTK_TYPE_MENU_DIRECTION_TYPE,
140 GTK_MENU_DIR_PARENT);
141 gtk_binding_entry_add_signal (binding_set,
144 GTK_TYPE_MENU_DIRECTION_TYPE,
145 GTK_MENU_DIR_PARENT);
146 gtk_binding_entry_add_signal (binding_set,
149 GTK_TYPE_MENU_DIRECTION_TYPE,
151 gtk_binding_entry_add_signal (binding_set,
154 GTK_TYPE_MENU_DIRECTION_TYPE,
158 * GtkMenuBar:pack-direction:
160 * The pack direction of the menubar. It determines how
161 * menuitems are arranged in the menubar.
165 g_object_class_install_property (gobject_class,
167 g_param_spec_enum ("pack-direction",
168 P_("Pack direction"),
169 P_("The pack direction of the menubar"),
170 GTK_TYPE_PACK_DIRECTION,
171 GTK_PACK_DIRECTION_LTR,
172 GTK_PARAM_READWRITE));
175 * GtkMenuBar:child-pack-direction:
177 * The child pack direction of the menubar. It determines how
178 * the widgets contained in child menuitems are arranged.
182 g_object_class_install_property (gobject_class,
183 PROP_CHILD_PACK_DIRECTION,
184 g_param_spec_enum ("child-pack-direction",
185 P_("Child Pack direction"),
186 P_("The child pack direction of the menubar"),
187 GTK_TYPE_PACK_DIRECTION,
188 GTK_PACK_DIRECTION_LTR,
189 GTK_PARAM_READWRITE));
192 gtk_widget_class_install_style_property (widget_class,
193 g_param_spec_enum ("shadow-type",
195 P_("Style of bevel around the menubar"),
196 GTK_TYPE_SHADOW_TYPE,
198 GTK_PARAM_READABLE));
200 gtk_widget_class_install_style_property (widget_class,
201 g_param_spec_int ("internal-padding",
202 P_("Internal padding"),
203 P_("Amount of border space between the menubar shadow and the menu items"),
207 GTK_PARAM_READABLE));
209 gtk_settings_install_property (g_param_spec_int ("gtk-menu-bar-popup-delay",
210 P_("Delay before drop down menus appear"),
211 P_("Delay before the submenus of a menu bar appear"),
215 GTK_PARAM_READWRITE));
217 g_type_class_add_private (gobject_class, sizeof (GtkMenuBarPrivate));
221 gtk_menu_bar_init (GtkMenuBar *object)
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;
288 g_return_if_fail (GTK_IS_MENU_BAR (widget));
289 g_return_if_fail (requisition != NULL);
291 requisition->width = 0;
292 requisition->height = 0;
294 if (gtk_widget_get_visible (widget))
296 menu_bar = GTK_MENU_BAR (widget);
297 menu_shell = GTK_MENU_SHELL (widget);
298 priv = GTK_MENU_BAR_GET_PRIVATE (menu_bar);
301 children = menu_shell->children;
305 child = children->data;
306 children = children->next;
308 if (gtk_widget_get_visible (child))
312 GTK_MENU_ITEM (child)->show_submenu_indicator = FALSE;
313 gtk_widget_size_request (child, &child_requisition);
314 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
317 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
318 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
319 child_requisition.width += toggle_size;
321 child_requisition.height += toggle_size;
323 if (priv->pack_direction == GTK_PACK_DIRECTION_LTR ||
324 priv->pack_direction == GTK_PACK_DIRECTION_RTL)
326 requisition->width += child_requisition.width;
327 requisition->height = MAX (requisition->height, child_requisition.height);
331 requisition->width = MAX (requisition->width, child_requisition.width);
332 requisition->height += child_requisition.height;
338 gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL);
340 requisition->width += (GTK_CONTAINER (menu_bar)->border_width +
343 requisition->height += (GTK_CONTAINER (menu_bar)->border_width +
347 if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE)
349 requisition->width += widget->style->xthickness * 2;
350 requisition->height += widget->style->ythickness * 2;
356 gtk_menu_bar_size_allocate (GtkWidget *widget,
357 GtkAllocation *allocation)
359 GtkMenuBar *menu_bar;
360 GtkMenuShell *menu_shell;
361 GtkMenuBarPrivate *priv;
364 GtkAllocation child_allocation;
365 GtkRequisition child_requisition;
367 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 = GTK_MENU_BAR_GET_PRIVATE (menu_bar);
378 direction = gtk_widget_get_direction (widget);
380 widget->allocation = *allocation;
381 if (GTK_WIDGET_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 child_allocation.x = (GTK_CONTAINER (menu_bar)->border_width +
393 child_allocation.y = (GTK_CONTAINER (menu_bar)->border_width +
396 if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE)
398 child_allocation.x += widget->style->xthickness;
399 child_allocation.y += widget->style->ythickness;
402 if (priv->pack_direction == GTK_PACK_DIRECTION_LTR ||
403 priv->pack_direction == GTK_PACK_DIRECTION_RTL)
405 child_allocation.height = MAX (1, (gint)allocation->height - child_allocation.y * 2);
407 offset = child_allocation.x; /* Window edge to menubar start */
408 ltr_x = child_allocation.x;
410 children = menu_shell->children;
415 child = children->data;
416 children = children->next;
418 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
420 gtk_widget_get_child_requisition (child, &child_requisition);
422 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
423 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
424 child_requisition.width += toggle_size;
426 child_requisition.height += toggle_size;
428 /* Support for the right justified help menu */
429 if ((children == NULL) && (GTK_IS_MENU_ITEM(child))
430 && (GTK_MENU_ITEM(child)->right_justify))
432 ltr_x = allocation->width -
433 child_requisition.width - offset;
435 if (gtk_widget_get_visible (child))
437 if ((direction == GTK_TEXT_DIR_LTR) == (priv->pack_direction == GTK_PACK_DIRECTION_LTR))
438 child_allocation.x = ltr_x;
440 child_allocation.x = allocation->width -
441 child_requisition.width - ltr_x;
443 child_allocation.width = child_requisition.width;
445 gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (child),
447 gtk_widget_size_allocate (child, &child_allocation);
449 ltr_x += child_allocation.width;
455 child_allocation.width = MAX (1, (gint)allocation->width - child_allocation.x * 2);
457 offset = child_allocation.y; /* Window edge to menubar start */
458 ltr_y = child_allocation.y;
460 children = menu_shell->children;
465 child = children->data;
466 children = children->next;
468 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
470 gtk_widget_get_child_requisition (child, &child_requisition);
472 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
473 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
474 child_requisition.width += toggle_size;
476 child_requisition.height += toggle_size;
478 /* Support for the right justified help menu */
479 if ((children == NULL) && (GTK_IS_MENU_ITEM(child))
480 && (GTK_MENU_ITEM(child)->right_justify))
482 ltr_y = allocation->height -
483 child_requisition.height - offset;
485 if (gtk_widget_get_visible (child))
487 if ((direction == GTK_TEXT_DIR_LTR) ==
488 (priv->pack_direction == GTK_PACK_DIRECTION_TTB))
489 child_allocation.y = ltr_y;
491 child_allocation.y = allocation->height -
492 child_requisition.height - ltr_y;
493 child_allocation.height = child_requisition.height;
495 gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (child),
497 gtk_widget_size_allocate (child, &child_allocation);
499 ltr_y += child_allocation.height;
507 gtk_menu_bar_paint (GtkWidget *widget,
510 g_return_if_fail (GTK_IS_MENU_BAR (widget));
512 if (gtk_widget_is_drawable (widget))
516 border = GTK_CONTAINER (widget)->border_width;
518 gtk_paint_box (widget->style,
520 GTK_WIDGET_STATE (widget),
521 get_shadow_type (GTK_MENU_BAR (widget)),
522 area, widget, "menubar",
524 widget->allocation.width - border * 2,
525 widget->allocation.height - border * 2);
530 gtk_menu_bar_expose (GtkWidget *widget,
531 GdkEventExpose *event)
533 g_return_val_if_fail (GTK_IS_MENU_BAR (widget), FALSE);
534 g_return_val_if_fail (event != NULL, FALSE);
536 if (gtk_widget_is_drawable (widget))
538 gtk_menu_bar_paint (widget, &event->area);
540 GTK_WIDGET_CLASS (gtk_menu_bar_parent_class)->expose_event (widget, event);
547 get_menu_bars (GtkWindow *window)
549 return g_object_get_data (G_OBJECT (window), "gtk-menu-bar-list");
553 get_viewable_menu_bars (GtkWindow *window)
556 GList *viewable_menu_bars = NULL;
558 for (menu_bars = get_menu_bars (window);
560 menu_bars = menu_bars->next)
562 GtkWidget *widget = menu_bars->data;
563 gboolean viewable = TRUE;
567 if (!GTK_WIDGET_MAPPED (widget))
570 widget = widget->parent;
574 viewable_menu_bars = g_list_prepend (viewable_menu_bars, menu_bars->data);
577 return g_list_reverse (viewable_menu_bars);
581 set_menu_bars (GtkWindow *window,
584 g_object_set_data (G_OBJECT (window), I_("gtk-menu-bar-list"), menubars);
588 window_key_press_handler (GtkWidget *widget,
593 gboolean retval = FALSE;
595 g_object_get (gtk_widget_get_settings (widget),
596 "gtk-menu-bar-accel", &accel,
602 GdkModifierType mods = 0;
604 gtk_accelerator_parse (accel, &keyval, &mods);
607 g_warning ("Failed to parse menu bar accelerator '%s'\n", accel);
609 /* FIXME this is wrong, needs to be in the global accel resolution
610 * thing, to properly consider i18n etc., but that probably requires
611 * AccelGroup changes etc.
613 if (event->keyval == keyval &&
614 ((event->state & gtk_accelerator_get_default_mod_mask ()) ==
615 (mods & gtk_accelerator_get_default_mod_mask ())))
617 GList *tmp_menubars = get_viewable_menu_bars (GTK_WINDOW (widget));
620 menubars = _gtk_container_focus_sort (GTK_CONTAINER (widget), tmp_menubars,
621 GTK_DIR_TAB_FORWARD, NULL);
622 g_list_free (tmp_menubars);
626 GtkMenuShell *menu_shell = GTK_MENU_SHELL (menubars->data);
628 _gtk_menu_shell_set_keyboard_mode (menu_shell, TRUE);
629 _gtk_menu_shell_activate (menu_shell);
630 gtk_menu_shell_select_first (menu_shell, FALSE);
632 g_list_free (menubars);
645 add_to_window (GtkWindow *window,
648 GList *menubars = get_menu_bars (window);
652 g_signal_connect (window,
654 G_CALLBACK (window_key_press_handler),
658 set_menu_bars (window, g_list_prepend (menubars, menubar));
662 remove_from_window (GtkWindow *window,
665 GList *menubars = get_menu_bars (window);
667 menubars = g_list_remove (menubars, menubar);
671 g_signal_handlers_disconnect_by_func (window,
672 window_key_press_handler,
676 set_menu_bars (window, menubars);
680 gtk_menu_bar_hierarchy_changed (GtkWidget *widget,
681 GtkWidget *old_toplevel)
686 menubar = GTK_MENU_BAR (widget);
688 toplevel = gtk_widget_get_toplevel (widget);
691 remove_from_window (GTK_WINDOW (old_toplevel), menubar);
693 if (gtk_widget_is_toplevel (toplevel))
694 add_to_window (GTK_WINDOW (toplevel), menubar);
698 * _gtk_menu_bar_cycle_focus:
699 * @menubar: a #GtkMenuBar
700 * @dir: direction in which to cycle the focus
702 * Move the focus between menubars in the toplevel.
705 _gtk_menu_bar_cycle_focus (GtkMenuBar *menubar,
706 GtkDirectionType dir)
708 GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (menubar));
709 GtkMenuItem *to_activate = NULL;
711 if (gtk_widget_is_toplevel (toplevel))
713 GList *tmp_menubars = get_viewable_menu_bars (GTK_WINDOW (toplevel));
717 menubars = _gtk_container_focus_sort (GTK_CONTAINER (toplevel), tmp_menubars,
718 dir, GTK_WIDGET (menubar));
719 g_list_free (tmp_menubars);
723 current = g_list_find (menubars, menubar);
725 if (current && current->next)
727 GtkMenuShell *new_menushell = GTK_MENU_SHELL (current->next->data);
728 if (new_menushell->children)
729 to_activate = new_menushell->children->data;
733 g_list_free (menubars);
736 gtk_menu_shell_cancel (GTK_MENU_SHELL (menubar));
739 g_signal_emit_by_name (to_activate, "activate_item");
743 get_shadow_type (GtkMenuBar *menubar)
745 GtkShadowType shadow_type = GTK_SHADOW_OUT;
747 gtk_widget_style_get (GTK_WIDGET (menubar),
748 "shadow-type", &shadow_type,
755 gtk_menu_bar_get_popup_delay (GtkMenuShell *menu_shell)
759 g_object_get (gtk_widget_get_settings (GTK_WIDGET (menu_shell)),
760 "gtk-menu-bar-popup-delay", &popup_delay,
767 gtk_menu_bar_move_current (GtkMenuShell *menu_shell,
768 GtkMenuDirectionType direction)
770 GtkMenuBar *menubar = GTK_MENU_BAR (menu_shell);
771 GtkTextDirection text_dir;
772 GtkPackDirection pack_dir;
774 text_dir = gtk_widget_get_direction (GTK_WIDGET (menubar));
775 pack_dir = gtk_menu_bar_get_pack_direction (menubar);
777 if (pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL)
779 if ((text_dir == GTK_TEXT_DIR_RTL) == (pack_dir == GTK_PACK_DIRECTION_LTR))
783 case GTK_MENU_DIR_PREV:
784 direction = GTK_MENU_DIR_NEXT;
786 case GTK_MENU_DIR_NEXT:
787 direction = GTK_MENU_DIR_PREV;
797 case GTK_MENU_DIR_PARENT:
798 if ((text_dir == GTK_TEXT_DIR_LTR) == (pack_dir == GTK_PACK_DIRECTION_TTB))
799 direction = GTK_MENU_DIR_PREV;
801 direction = GTK_MENU_DIR_NEXT;
803 case GTK_MENU_DIR_CHILD:
804 if ((text_dir == GTK_TEXT_DIR_LTR) == (pack_dir == GTK_PACK_DIRECTION_TTB))
805 direction = GTK_MENU_DIR_NEXT;
807 direction = GTK_MENU_DIR_PREV;
809 case GTK_MENU_DIR_PREV:
810 if (text_dir == GTK_TEXT_DIR_RTL)
811 direction = GTK_MENU_DIR_CHILD;
813 direction = GTK_MENU_DIR_PARENT;
815 case GTK_MENU_DIR_NEXT:
816 if (text_dir == GTK_TEXT_DIR_RTL)
817 direction = GTK_MENU_DIR_PARENT;
819 direction = GTK_MENU_DIR_CHILD;
825 GTK_MENU_SHELL_CLASS (gtk_menu_bar_parent_class)->move_current (menu_shell, direction);
829 * gtk_menu_bar_get_pack_direction:
830 * @menubar: a #GtkMenuBar
832 * Retrieves the current pack direction of the menubar.
833 * See gtk_menu_bar_set_pack_direction().
835 * Return value: the pack direction
840 gtk_menu_bar_get_pack_direction (GtkMenuBar *menubar)
842 GtkMenuBarPrivate *priv;
844 g_return_val_if_fail (GTK_IS_MENU_BAR (menubar),
845 GTK_PACK_DIRECTION_LTR);
847 priv = GTK_MENU_BAR_GET_PRIVATE (menubar);
849 return priv->pack_direction;
853 * gtk_menu_bar_set_pack_direction:
854 * @menubar: a #GtkMenuBar
855 * @pack_dir: a new #GtkPackDirection
857 * Sets how items should be packed inside a menubar.
862 gtk_menu_bar_set_pack_direction (GtkMenuBar *menubar,
863 GtkPackDirection pack_dir)
865 GtkMenuBarPrivate *priv;
868 g_return_if_fail (GTK_IS_MENU_BAR (menubar));
870 priv = GTK_MENU_BAR_GET_PRIVATE (menubar);
872 if (priv->pack_direction != pack_dir)
874 priv->pack_direction = pack_dir;
876 gtk_widget_queue_resize (GTK_WIDGET (menubar));
878 for (l = GTK_MENU_SHELL (menubar)->children; l; l = l->next)
879 gtk_widget_queue_resize (GTK_WIDGET (l->data));
881 g_object_notify (G_OBJECT (menubar), "pack-direction");
886 * gtk_menu_bar_get_child_pack_direction:
887 * @menubar: a #GtkMenuBar
889 * Retrieves the current child pack direction of the menubar.
890 * See gtk_menu_bar_set_child_pack_direction().
892 * Return value: the child pack direction
897 gtk_menu_bar_get_child_pack_direction (GtkMenuBar *menubar)
899 GtkMenuBarPrivate *priv;
901 g_return_val_if_fail (GTK_IS_MENU_BAR (menubar),
902 GTK_PACK_DIRECTION_LTR);
904 priv = GTK_MENU_BAR_GET_PRIVATE (menubar);
906 return priv->child_pack_direction;
910 * gtk_menu_bar_set_child_pack_direction:
911 * @menubar: a #GtkMenuBar
912 * @child_pack_dir: a new #GtkPackDirection
914 * Sets how widgets should be packed inside the children of a menubar.
919 gtk_menu_bar_set_child_pack_direction (GtkMenuBar *menubar,
920 GtkPackDirection child_pack_dir)
922 GtkMenuBarPrivate *priv;
925 g_return_if_fail (GTK_IS_MENU_BAR (menubar));
927 priv = GTK_MENU_BAR_GET_PRIVATE (menubar);
929 if (priv->child_pack_direction != child_pack_dir)
931 priv->child_pack_direction = child_pack_dir;
933 gtk_widget_queue_resize (GTK_WIDGET (menubar));
935 for (l = GTK_MENU_SHELL (menubar)->children; l; l = l->next)
936 gtk_widget_queue_resize (GTK_WIDGET (l->data));
938 g_object_notify (G_OBJECT (menubar), "child-pack-direction");
942 #define __GTK_MENU_BAR_C__
943 #include "gtkaliasdef.c"