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 typedef struct _GtkMenuBarPrivate GtkMenuBarPrivate;
52 struct _GtkMenuBarPrivate
54 GtkPackDirection pack_direction;
55 GtkPackDirection child_pack_direction;
58 #define GTK_MENU_BAR_GET_PRIVATE(o) \
59 (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_MENU_BAR, GtkMenuBarPrivate))
62 static void gtk_menu_bar_set_property (GObject *object,
66 static void gtk_menu_bar_get_property (GObject *object,
70 static void gtk_menu_bar_size_request (GtkWidget *widget,
71 GtkRequisition *requisition);
72 static void gtk_menu_bar_size_allocate (GtkWidget *widget,
73 GtkAllocation *allocation);
74 static void gtk_menu_bar_paint (GtkWidget *widget,
76 static gint gtk_menu_bar_expose (GtkWidget *widget,
77 GdkEventExpose *event);
78 static void gtk_menu_bar_hierarchy_changed (GtkWidget *widget,
79 GtkWidget *old_toplevel);
80 static gint gtk_menu_bar_get_popup_delay (GtkMenuShell *menu_shell);
81 static void gtk_menu_bar_move_current (GtkMenuShell *menu_shell,
82 GtkMenuDirectionType direction);
84 static GtkShadowType get_shadow_type (GtkMenuBar *menubar);
86 G_DEFINE_TYPE (GtkMenuBar, gtk_menu_bar, GTK_TYPE_MENU_SHELL)
89 gtk_menu_bar_class_init (GtkMenuBarClass *class)
91 GObjectClass *gobject_class;
92 GtkWidgetClass *widget_class;
93 GtkMenuShellClass *menu_shell_class;
95 GtkBindingSet *binding_set;
97 gobject_class = (GObjectClass*) class;
98 widget_class = (GtkWidgetClass*) class;
99 menu_shell_class = (GtkMenuShellClass*) class;
101 gobject_class->get_property = gtk_menu_bar_get_property;
102 gobject_class->set_property = gtk_menu_bar_set_property;
104 widget_class->size_request = gtk_menu_bar_size_request;
105 widget_class->size_allocate = gtk_menu_bar_size_allocate;
106 widget_class->expose_event = gtk_menu_bar_expose;
107 widget_class->hierarchy_changed = gtk_menu_bar_hierarchy_changed;
109 menu_shell_class->submenu_placement = GTK_TOP_BOTTOM;
110 menu_shell_class->get_popup_delay = gtk_menu_bar_get_popup_delay;
111 menu_shell_class->move_current = gtk_menu_bar_move_current;
113 binding_set = gtk_binding_set_by_class (class);
114 gtk_binding_entry_add_signal (binding_set,
117 GTK_TYPE_MENU_DIRECTION_TYPE,
119 gtk_binding_entry_add_signal (binding_set,
122 GTK_TYPE_MENU_DIRECTION_TYPE,
124 gtk_binding_entry_add_signal (binding_set,
127 GTK_TYPE_MENU_DIRECTION_TYPE,
129 gtk_binding_entry_add_signal (binding_set,
132 GTK_TYPE_MENU_DIRECTION_TYPE,
134 gtk_binding_entry_add_signal (binding_set,
137 GTK_TYPE_MENU_DIRECTION_TYPE,
138 GTK_MENU_DIR_PARENT);
139 gtk_binding_entry_add_signal (binding_set,
142 GTK_TYPE_MENU_DIRECTION_TYPE,
143 GTK_MENU_DIR_PARENT);
144 gtk_binding_entry_add_signal (binding_set,
147 GTK_TYPE_MENU_DIRECTION_TYPE,
149 gtk_binding_entry_add_signal (binding_set,
152 GTK_TYPE_MENU_DIRECTION_TYPE,
156 * GtkMenuBar:pack-direction:
158 * The pack direction of the menubar. It determines how
159 * menuitems are arranged in the menubar.
163 g_object_class_install_property (gobject_class,
165 g_param_spec_enum ("pack-direction",
166 P_("Pack direction"),
167 P_("The pack direction of the menubar"),
168 GTK_TYPE_PACK_DIRECTION,
169 GTK_PACK_DIRECTION_LTR,
170 GTK_PARAM_READWRITE));
173 * GtkMenuBar:child-pack-direction:
175 * The child pack direction of the menubar. It determines how
176 * the widgets contained in child menuitems are arranged.
180 g_object_class_install_property (gobject_class,
181 PROP_CHILD_PACK_DIRECTION,
182 g_param_spec_enum ("child-pack-direction",
183 P_("Child Pack direction"),
184 P_("The child pack direction of the menubar"),
185 GTK_TYPE_PACK_DIRECTION,
186 GTK_PACK_DIRECTION_LTR,
187 GTK_PARAM_READWRITE));
190 gtk_widget_class_install_style_property (widget_class,
191 g_param_spec_enum ("shadow-type",
193 P_("Style of bevel around the menubar"),
194 GTK_TYPE_SHADOW_TYPE,
196 GTK_PARAM_READABLE));
198 gtk_widget_class_install_style_property (widget_class,
199 g_param_spec_int ("internal-padding",
200 P_("Internal padding"),
201 P_("Amount of border space between the menubar shadow and the menu items"),
205 GTK_PARAM_READABLE));
207 gtk_settings_install_property (g_param_spec_int ("gtk-menu-bar-popup-delay",
208 P_("Delay before drop down menus appear"),
209 P_("Delay before the submenus of a menu bar appear"),
213 GTK_PARAM_READWRITE));
215 g_type_class_add_private (gobject_class, sizeof (GtkMenuBarPrivate));
219 gtk_menu_bar_init (GtkMenuBar *object)
224 gtk_menu_bar_new (void)
226 return g_object_new (GTK_TYPE_MENU_BAR, NULL);
230 gtk_menu_bar_set_property (GObject *object,
235 GtkMenuBar *menubar = GTK_MENU_BAR (object);
239 case PROP_PACK_DIRECTION:
240 gtk_menu_bar_set_pack_direction (menubar, g_value_get_enum (value));
242 case PROP_CHILD_PACK_DIRECTION:
243 gtk_menu_bar_set_child_pack_direction (menubar, g_value_get_enum (value));
246 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
252 gtk_menu_bar_get_property (GObject *object,
257 GtkMenuBar *menubar = GTK_MENU_BAR (object);
261 case PROP_PACK_DIRECTION:
262 g_value_set_enum (value, gtk_menu_bar_get_pack_direction (menubar));
264 case PROP_CHILD_PACK_DIRECTION:
265 g_value_set_enum (value, gtk_menu_bar_get_child_pack_direction (menubar));
268 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
274 gtk_menu_bar_size_request (GtkWidget *widget,
275 GtkRequisition *requisition)
277 GtkMenuBar *menu_bar;
278 GtkMenuBarPrivate *priv;
279 GtkMenuShell *menu_shell;
283 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 = GTK_MENU_BAR_GET_PRIVATE (menu_bar);
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 requisition->width += (GTK_CONTAINER (menu_bar)->border_width +
341 requisition->height += (GTK_CONTAINER (menu_bar)->border_width +
345 if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE)
347 requisition->width += widget->style->xthickness * 2;
348 requisition->height += widget->style->ythickness * 2;
354 gtk_menu_bar_size_allocate (GtkWidget *widget,
355 GtkAllocation *allocation)
357 GtkMenuBar *menu_bar;
358 GtkMenuShell *menu_shell;
359 GtkMenuBarPrivate *priv;
362 GtkAllocation child_allocation;
363 GtkRequisition child_requisition;
365 GtkTextDirection direction;
369 g_return_if_fail (GTK_IS_MENU_BAR (widget));
370 g_return_if_fail (allocation != NULL);
372 menu_bar = GTK_MENU_BAR (widget);
373 menu_shell = GTK_MENU_SHELL (widget);
374 priv = GTK_MENU_BAR_GET_PRIVATE (menu_bar);
376 direction = gtk_widget_get_direction (widget);
378 widget->allocation = *allocation;
379 if (gtk_widget_get_realized (widget))
380 gdk_window_move_resize (widget->window,
381 allocation->x, allocation->y,
382 allocation->width, allocation->height);
384 gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL);
386 if (menu_shell->children)
388 child_allocation.x = (GTK_CONTAINER (menu_bar)->border_width +
391 child_allocation.y = (GTK_CONTAINER (menu_bar)->border_width +
394 if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE)
396 child_allocation.x += widget->style->xthickness;
397 child_allocation.y += widget->style->ythickness;
400 if (priv->pack_direction == GTK_PACK_DIRECTION_LTR ||
401 priv->pack_direction == GTK_PACK_DIRECTION_RTL)
403 child_allocation.height = MAX (1, (gint)allocation->height - child_allocation.y * 2);
405 offset = child_allocation.x; /* Window edge to menubar start */
406 ltr_x = child_allocation.x;
408 children = menu_shell->children;
413 child = children->data;
414 children = children->next;
416 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
418 gtk_widget_get_child_requisition (child, &child_requisition);
420 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
421 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
422 child_requisition.width += toggle_size;
424 child_requisition.height += toggle_size;
426 /* Support for the right justified help menu */
427 if ((children == NULL) && (GTK_IS_MENU_ITEM(child))
428 && (GTK_MENU_ITEM(child)->right_justify))
430 ltr_x = allocation->width -
431 child_requisition.width - offset;
433 if (gtk_widget_get_visible (child))
435 if ((direction == GTK_TEXT_DIR_LTR) == (priv->pack_direction == GTK_PACK_DIRECTION_LTR))
436 child_allocation.x = ltr_x;
438 child_allocation.x = allocation->width -
439 child_requisition.width - ltr_x;
441 child_allocation.width = child_requisition.width;
443 gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (child),
445 gtk_widget_size_allocate (child, &child_allocation);
447 ltr_x += child_allocation.width;
453 child_allocation.width = MAX (1, (gint)allocation->width - child_allocation.x * 2);
455 offset = child_allocation.y; /* Window edge to menubar start */
456 ltr_y = child_allocation.y;
458 children = menu_shell->children;
463 child = children->data;
464 children = children->next;
466 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
468 gtk_widget_get_child_requisition (child, &child_requisition);
470 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
471 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
472 child_requisition.width += toggle_size;
474 child_requisition.height += toggle_size;
476 /* Support for the right justified help menu */
477 if ((children == NULL) && (GTK_IS_MENU_ITEM(child))
478 && (GTK_MENU_ITEM(child)->right_justify))
480 ltr_y = allocation->height -
481 child_requisition.height - offset;
483 if (gtk_widget_get_visible (child))
485 if ((direction == GTK_TEXT_DIR_LTR) ==
486 (priv->pack_direction == GTK_PACK_DIRECTION_TTB))
487 child_allocation.y = ltr_y;
489 child_allocation.y = allocation->height -
490 child_requisition.height - ltr_y;
491 child_allocation.height = child_requisition.height;
493 gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (child),
495 gtk_widget_size_allocate (child, &child_allocation);
497 ltr_y += child_allocation.height;
505 gtk_menu_bar_paint (GtkWidget *widget,
508 g_return_if_fail (GTK_IS_MENU_BAR (widget));
510 if (gtk_widget_is_drawable (widget))
514 border = GTK_CONTAINER (widget)->border_width;
516 gtk_paint_box (widget->style,
518 gtk_widget_get_state (widget),
519 get_shadow_type (GTK_MENU_BAR (widget)),
520 area, widget, "menubar",
522 widget->allocation.width - border * 2,
523 widget->allocation.height - border * 2);
528 gtk_menu_bar_expose (GtkWidget *widget,
529 GdkEventExpose *event)
531 g_return_val_if_fail (GTK_IS_MENU_BAR (widget), FALSE);
532 g_return_val_if_fail (event != NULL, FALSE);
534 if (gtk_widget_is_drawable (widget))
536 gtk_menu_bar_paint (widget, &event->area);
538 GTK_WIDGET_CLASS (gtk_menu_bar_parent_class)->expose_event (widget, event);
545 get_menu_bars (GtkWindow *window)
547 return g_object_get_data (G_OBJECT (window), "gtk-menu-bar-list");
551 get_viewable_menu_bars (GtkWindow *window)
554 GList *viewable_menu_bars = NULL;
556 for (menu_bars = get_menu_bars (window);
558 menu_bars = menu_bars->next)
560 GtkWidget *widget = menu_bars->data;
561 gboolean viewable = TRUE;
565 if (!gtk_widget_get_mapped (widget))
568 widget = widget->parent;
572 viewable_menu_bars = g_list_prepend (viewable_menu_bars, menu_bars->data);
575 return g_list_reverse (viewable_menu_bars);
579 set_menu_bars (GtkWindow *window,
582 g_object_set_data (G_OBJECT (window), I_("gtk-menu-bar-list"), menubars);
586 window_key_press_handler (GtkWidget *widget,
591 gboolean retval = FALSE;
593 g_object_get (gtk_widget_get_settings (widget),
594 "gtk-menu-bar-accel", &accel,
600 GdkModifierType mods = 0;
602 gtk_accelerator_parse (accel, &keyval, &mods);
605 g_warning ("Failed to parse menu bar accelerator '%s'\n", accel);
607 /* FIXME this is wrong, needs to be in the global accel resolution
608 * thing, to properly consider i18n etc., but that probably requires
609 * AccelGroup changes etc.
611 if (event->keyval == keyval &&
612 ((event->state & gtk_accelerator_get_default_mod_mask ()) ==
613 (mods & gtk_accelerator_get_default_mod_mask ())))
615 GList *tmp_menubars = get_viewable_menu_bars (GTK_WINDOW (widget));
618 menubars = _gtk_container_focus_sort (GTK_CONTAINER (widget), tmp_menubars,
619 GTK_DIR_TAB_FORWARD, NULL);
620 g_list_free (tmp_menubars);
624 GtkMenuShell *menu_shell = GTK_MENU_SHELL (menubars->data);
626 _gtk_menu_shell_set_keyboard_mode (menu_shell, TRUE);
627 _gtk_menu_shell_activate (menu_shell);
628 gtk_menu_shell_select_first (menu_shell, FALSE);
630 g_list_free (menubars);
643 add_to_window (GtkWindow *window,
646 GList *menubars = get_menu_bars (window);
650 g_signal_connect (window,
652 G_CALLBACK (window_key_press_handler),
656 set_menu_bars (window, g_list_prepend (menubars, menubar));
660 remove_from_window (GtkWindow *window,
663 GList *menubars = get_menu_bars (window);
665 menubars = g_list_remove (menubars, menubar);
669 g_signal_handlers_disconnect_by_func (window,
670 window_key_press_handler,
674 set_menu_bars (window, menubars);
678 gtk_menu_bar_hierarchy_changed (GtkWidget *widget,
679 GtkWidget *old_toplevel)
684 menubar = GTK_MENU_BAR (widget);
686 toplevel = gtk_widget_get_toplevel (widget);
689 remove_from_window (GTK_WINDOW (old_toplevel), menubar);
691 if (gtk_widget_is_toplevel (toplevel))
692 add_to_window (GTK_WINDOW (toplevel), menubar);
696 * _gtk_menu_bar_cycle_focus:
697 * @menubar: a #GtkMenuBar
698 * @dir: direction in which to cycle the focus
700 * Move the focus between menubars in the toplevel.
703 _gtk_menu_bar_cycle_focus (GtkMenuBar *menubar,
704 GtkDirectionType dir)
706 GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (menubar));
707 GtkMenuItem *to_activate = NULL;
709 if (gtk_widget_is_toplevel (toplevel))
711 GList *tmp_menubars = get_viewable_menu_bars (GTK_WINDOW (toplevel));
715 menubars = _gtk_container_focus_sort (GTK_CONTAINER (toplevel), tmp_menubars,
716 dir, GTK_WIDGET (menubar));
717 g_list_free (tmp_menubars);
721 current = g_list_find (menubars, menubar);
723 if (current && current->next)
725 GtkMenuShell *new_menushell = GTK_MENU_SHELL (current->next->data);
726 if (new_menushell->children)
727 to_activate = new_menushell->children->data;
731 g_list_free (menubars);
734 gtk_menu_shell_cancel (GTK_MENU_SHELL (menubar));
737 g_signal_emit_by_name (to_activate, "activate_item");
741 get_shadow_type (GtkMenuBar *menubar)
743 GtkShadowType shadow_type = GTK_SHADOW_OUT;
745 gtk_widget_style_get (GTK_WIDGET (menubar),
746 "shadow-type", &shadow_type,
753 gtk_menu_bar_get_popup_delay (GtkMenuShell *menu_shell)
757 g_object_get (gtk_widget_get_settings (GTK_WIDGET (menu_shell)),
758 "gtk-menu-bar-popup-delay", &popup_delay,
765 gtk_menu_bar_move_current (GtkMenuShell *menu_shell,
766 GtkMenuDirectionType direction)
768 GtkMenuBar *menubar = GTK_MENU_BAR (menu_shell);
769 GtkTextDirection text_dir;
770 GtkPackDirection pack_dir;
772 text_dir = gtk_widget_get_direction (GTK_WIDGET (menubar));
773 pack_dir = gtk_menu_bar_get_pack_direction (menubar);
775 if (pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL)
777 if ((text_dir == GTK_TEXT_DIR_RTL) == (pack_dir == GTK_PACK_DIRECTION_LTR))
781 case GTK_MENU_DIR_PREV:
782 direction = GTK_MENU_DIR_NEXT;
784 case GTK_MENU_DIR_NEXT:
785 direction = GTK_MENU_DIR_PREV;
795 case GTK_MENU_DIR_PARENT:
796 if ((text_dir == GTK_TEXT_DIR_LTR) == (pack_dir == GTK_PACK_DIRECTION_TTB))
797 direction = GTK_MENU_DIR_PREV;
799 direction = GTK_MENU_DIR_NEXT;
801 case GTK_MENU_DIR_CHILD:
802 if ((text_dir == GTK_TEXT_DIR_LTR) == (pack_dir == GTK_PACK_DIRECTION_TTB))
803 direction = GTK_MENU_DIR_NEXT;
805 direction = GTK_MENU_DIR_PREV;
807 case GTK_MENU_DIR_PREV:
808 if (text_dir == GTK_TEXT_DIR_RTL)
809 direction = GTK_MENU_DIR_CHILD;
811 direction = GTK_MENU_DIR_PARENT;
813 case GTK_MENU_DIR_NEXT:
814 if (text_dir == GTK_TEXT_DIR_RTL)
815 direction = GTK_MENU_DIR_PARENT;
817 direction = GTK_MENU_DIR_CHILD;
823 GTK_MENU_SHELL_CLASS (gtk_menu_bar_parent_class)->move_current (menu_shell, direction);
827 * gtk_menu_bar_get_pack_direction:
828 * @menubar: a #GtkMenuBar
830 * Retrieves the current pack direction of the menubar.
831 * See gtk_menu_bar_set_pack_direction().
833 * Return value: the pack direction
838 gtk_menu_bar_get_pack_direction (GtkMenuBar *menubar)
840 GtkMenuBarPrivate *priv;
842 g_return_val_if_fail (GTK_IS_MENU_BAR (menubar),
843 GTK_PACK_DIRECTION_LTR);
845 priv = GTK_MENU_BAR_GET_PRIVATE (menubar);
847 return priv->pack_direction;
851 * gtk_menu_bar_set_pack_direction:
852 * @menubar: a #GtkMenuBar
853 * @pack_dir: a new #GtkPackDirection
855 * Sets how items should be packed inside a menubar.
860 gtk_menu_bar_set_pack_direction (GtkMenuBar *menubar,
861 GtkPackDirection pack_dir)
863 GtkMenuBarPrivate *priv;
866 g_return_if_fail (GTK_IS_MENU_BAR (menubar));
868 priv = GTK_MENU_BAR_GET_PRIVATE (menubar);
870 if (priv->pack_direction != pack_dir)
872 priv->pack_direction = pack_dir;
874 gtk_widget_queue_resize (GTK_WIDGET (menubar));
876 for (l = GTK_MENU_SHELL (menubar)->children; l; l = l->next)
877 gtk_widget_queue_resize (GTK_WIDGET (l->data));
879 g_object_notify (G_OBJECT (menubar), "pack-direction");
884 * gtk_menu_bar_get_child_pack_direction:
885 * @menubar: a #GtkMenuBar
887 * Retrieves the current child pack direction of the menubar.
888 * See gtk_menu_bar_set_child_pack_direction().
890 * Return value: the child pack direction
895 gtk_menu_bar_get_child_pack_direction (GtkMenuBar *menubar)
897 GtkMenuBarPrivate *priv;
899 g_return_val_if_fail (GTK_IS_MENU_BAR (menubar),
900 GTK_PACK_DIRECTION_LTR);
902 priv = GTK_MENU_BAR_GET_PRIVATE (menubar);
904 return priv->child_pack_direction;
908 * gtk_menu_bar_set_child_pack_direction:
909 * @menubar: a #GtkMenuBar
910 * @child_pack_dir: a new #GtkPackDirection
912 * Sets how widgets should be packed inside the children of a menubar.
917 gtk_menu_bar_set_child_pack_direction (GtkMenuBar *menubar,
918 GtkPackDirection child_pack_dir)
920 GtkMenuBarPrivate *priv;
923 g_return_if_fail (GTK_IS_MENU_BAR (menubar));
925 priv = GTK_MENU_BAR_GET_PRIVATE (menubar);
927 if (priv->child_pack_direction != child_pack_dir)
929 priv->child_pack_direction = child_pack_dir;
931 gtk_widget_queue_resize (GTK_WIDGET (menubar));
933 for (l = GTK_MENU_SHELL (menubar)->children; l; l = l->next)
934 gtk_widget_queue_resize (GTK_WIDGET (l->data));
936 g_object_notify (G_OBJECT (menubar), "child-pack-direction");