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;
287 g_return_if_fail (GTK_IS_MENU_BAR (widget));
288 g_return_if_fail (requisition != NULL);
290 requisition->width = 0;
291 requisition->height = 0;
293 if (gtk_widget_get_visible (widget))
295 menu_bar = GTK_MENU_BAR (widget);
296 menu_shell = GTK_MENU_SHELL (widget);
297 priv = GTK_MENU_BAR_GET_PRIVATE (menu_bar);
300 children = menu_shell->children;
304 child = children->data;
305 children = children->next;
307 if (gtk_widget_get_visible (child))
311 GTK_MENU_ITEM (child)->show_submenu_indicator = FALSE;
312 gtk_widget_size_request (child, &child_requisition);
313 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
316 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
317 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
318 child_requisition.width += toggle_size;
320 child_requisition.height += toggle_size;
322 if (priv->pack_direction == GTK_PACK_DIRECTION_LTR ||
323 priv->pack_direction == GTK_PACK_DIRECTION_RTL)
325 requisition->width += child_requisition.width;
326 requisition->height = MAX (requisition->height, child_requisition.height);
330 requisition->width = MAX (requisition->width, child_requisition.width);
331 requisition->height += child_requisition.height;
337 gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL);
339 border_width = gtk_container_get_border_width (GTK_CONTAINER (menu_bar));
340 requisition->width += (border_width +
343 requisition->height += (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;
372 g_return_if_fail (GTK_IS_MENU_BAR (widget));
373 g_return_if_fail (allocation != NULL);
375 menu_bar = GTK_MENU_BAR (widget);
376 menu_shell = GTK_MENU_SHELL (widget);
377 priv = GTK_MENU_BAR_GET_PRIVATE (menu_bar);
379 direction = gtk_widget_get_direction (widget);
381 widget->allocation = *allocation;
382 if (gtk_widget_get_realized (widget))
383 gdk_window_move_resize (widget->window,
384 allocation->x, allocation->y,
385 allocation->width, allocation->height);
387 gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL);
389 if (menu_shell->children)
391 border_width = gtk_container_get_border_width (GTK_CONTAINER (menu_bar));
392 child_allocation.x = (border_width +
395 child_allocation.y = (border_width +
398 if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE)
400 child_allocation.x += widget->style->xthickness;
401 child_allocation.y += widget->style->ythickness;
404 if (priv->pack_direction == GTK_PACK_DIRECTION_LTR ||
405 priv->pack_direction == GTK_PACK_DIRECTION_RTL)
407 child_allocation.height = MAX (1, (gint)allocation->height - child_allocation.y * 2);
409 offset = child_allocation.x; /* Window edge to menubar start */
410 ltr_x = child_allocation.x;
412 children = menu_shell->children;
417 child = children->data;
418 children = children->next;
420 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
422 gtk_widget_get_child_requisition (child, &child_requisition);
424 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
425 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
426 child_requisition.width += toggle_size;
428 child_requisition.height += toggle_size;
430 /* Support for the right justified help menu */
431 if ((children == NULL) && (GTK_IS_MENU_ITEM(child))
432 && (GTK_MENU_ITEM(child)->right_justify))
434 ltr_x = allocation->width -
435 child_requisition.width - offset;
437 if (gtk_widget_get_visible (child))
439 if ((direction == GTK_TEXT_DIR_LTR) == (priv->pack_direction == GTK_PACK_DIRECTION_LTR))
440 child_allocation.x = ltr_x;
442 child_allocation.x = allocation->width -
443 child_requisition.width - ltr_x;
445 child_allocation.width = child_requisition.width;
447 gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (child),
449 gtk_widget_size_allocate (child, &child_allocation);
451 ltr_x += child_allocation.width;
457 child_allocation.width = MAX (1, (gint)allocation->width - child_allocation.x * 2);
459 offset = child_allocation.y; /* Window edge to menubar start */
460 ltr_y = child_allocation.y;
462 children = menu_shell->children;
467 child = children->data;
468 children = children->next;
470 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
472 gtk_widget_get_child_requisition (child, &child_requisition);
474 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
475 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
476 child_requisition.width += toggle_size;
478 child_requisition.height += toggle_size;
480 /* Support for the right justified help menu */
481 if ((children == NULL) && (GTK_IS_MENU_ITEM(child))
482 && (GTK_MENU_ITEM(child)->right_justify))
484 ltr_y = allocation->height -
485 child_requisition.height - offset;
487 if (gtk_widget_get_visible (child))
489 if ((direction == GTK_TEXT_DIR_LTR) ==
490 (priv->pack_direction == GTK_PACK_DIRECTION_TTB))
491 child_allocation.y = ltr_y;
493 child_allocation.y = allocation->height -
494 child_requisition.height - ltr_y;
495 child_allocation.height = child_requisition.height;
497 gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (child),
499 gtk_widget_size_allocate (child, &child_allocation);
501 ltr_y += child_allocation.height;
509 gtk_menu_bar_paint (GtkWidget *widget,
512 g_return_if_fail (GTK_IS_MENU_BAR (widget));
514 if (gtk_widget_is_drawable (widget))
518 border = gtk_container_get_border_width (GTK_CONTAINER (widget));
520 gtk_paint_box (widget->style,
522 gtk_widget_get_state (widget),
523 get_shadow_type (GTK_MENU_BAR (widget)),
524 area, widget, "menubar",
526 widget->allocation.width - border * 2,
527 widget->allocation.height - border * 2);
532 gtk_menu_bar_expose (GtkWidget *widget,
533 GdkEventExpose *event)
535 g_return_val_if_fail (GTK_IS_MENU_BAR (widget), FALSE);
536 g_return_val_if_fail (event != NULL, FALSE);
538 if (gtk_widget_is_drawable (widget))
540 gtk_menu_bar_paint (widget, &event->area);
542 GTK_WIDGET_CLASS (gtk_menu_bar_parent_class)->expose_event (widget, event);
549 get_menu_bars (GtkWindow *window)
551 return g_object_get_data (G_OBJECT (window), "gtk-menu-bar-list");
555 get_viewable_menu_bars (GtkWindow *window)
558 GList *viewable_menu_bars = NULL;
560 for (menu_bars = get_menu_bars (window);
562 menu_bars = menu_bars->next)
564 GtkWidget *widget = menu_bars->data;
565 gboolean viewable = TRUE;
569 if (!gtk_widget_get_mapped (widget))
572 widget = widget->parent;
576 viewable_menu_bars = g_list_prepend (viewable_menu_bars, menu_bars->data);
579 return g_list_reverse (viewable_menu_bars);
583 set_menu_bars (GtkWindow *window,
586 g_object_set_data (G_OBJECT (window), I_("gtk-menu-bar-list"), menubars);
590 window_key_press_handler (GtkWidget *widget,
595 gboolean retval = FALSE;
597 g_object_get (gtk_widget_get_settings (widget),
598 "gtk-menu-bar-accel", &accel,
604 GdkModifierType mods = 0;
606 gtk_accelerator_parse (accel, &keyval, &mods);
609 g_warning ("Failed to parse menu bar accelerator '%s'\n", accel);
611 /* FIXME this is wrong, needs to be in the global accel resolution
612 * thing, to properly consider i18n etc., but that probably requires
613 * AccelGroup changes etc.
615 if (event->keyval == keyval &&
616 ((event->state & gtk_accelerator_get_default_mod_mask ()) ==
617 (mods & gtk_accelerator_get_default_mod_mask ())))
619 GList *tmp_menubars = get_viewable_menu_bars (GTK_WINDOW (widget));
622 menubars = _gtk_container_focus_sort (GTK_CONTAINER (widget), tmp_menubars,
623 GTK_DIR_TAB_FORWARD, NULL);
624 g_list_free (tmp_menubars);
628 GtkMenuShell *menu_shell = GTK_MENU_SHELL (menubars->data);
630 _gtk_menu_shell_set_keyboard_mode (menu_shell, TRUE);
631 _gtk_menu_shell_activate (menu_shell);
632 gtk_menu_shell_select_first (menu_shell, FALSE);
634 g_list_free (menubars);
647 add_to_window (GtkWindow *window,
650 GList *menubars = get_menu_bars (window);
654 g_signal_connect (window,
656 G_CALLBACK (window_key_press_handler),
660 set_menu_bars (window, g_list_prepend (menubars, menubar));
664 remove_from_window (GtkWindow *window,
667 GList *menubars = get_menu_bars (window);
669 menubars = g_list_remove (menubars, menubar);
673 g_signal_handlers_disconnect_by_func (window,
674 window_key_press_handler,
678 set_menu_bars (window, menubars);
682 gtk_menu_bar_hierarchy_changed (GtkWidget *widget,
683 GtkWidget *old_toplevel)
688 menubar = GTK_MENU_BAR (widget);
690 toplevel = gtk_widget_get_toplevel (widget);
693 remove_from_window (GTK_WINDOW (old_toplevel), menubar);
695 if (gtk_widget_is_toplevel (toplevel))
696 add_to_window (GTK_WINDOW (toplevel), menubar);
700 * _gtk_menu_bar_cycle_focus:
701 * @menubar: a #GtkMenuBar
702 * @dir: direction in which to cycle the focus
704 * Move the focus between menubars in the toplevel.
707 _gtk_menu_bar_cycle_focus (GtkMenuBar *menubar,
708 GtkDirectionType dir)
710 GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (menubar));
711 GtkMenuItem *to_activate = NULL;
713 if (gtk_widget_is_toplevel (toplevel))
715 GList *tmp_menubars = get_viewable_menu_bars (GTK_WINDOW (toplevel));
719 menubars = _gtk_container_focus_sort (GTK_CONTAINER (toplevel), tmp_menubars,
720 dir, GTK_WIDGET (menubar));
721 g_list_free (tmp_menubars);
725 current = g_list_find (menubars, menubar);
727 if (current && current->next)
729 GtkMenuShell *new_menushell = GTK_MENU_SHELL (current->next->data);
730 if (new_menushell->children)
731 to_activate = new_menushell->children->data;
735 g_list_free (menubars);
738 gtk_menu_shell_cancel (GTK_MENU_SHELL (menubar));
741 g_signal_emit_by_name (to_activate, "activate_item");
745 get_shadow_type (GtkMenuBar *menubar)
747 GtkShadowType shadow_type = GTK_SHADOW_OUT;
749 gtk_widget_style_get (GTK_WIDGET (menubar),
750 "shadow-type", &shadow_type,
757 gtk_menu_bar_get_popup_delay (GtkMenuShell *menu_shell)
761 g_object_get (gtk_widget_get_settings (GTK_WIDGET (menu_shell)),
762 "gtk-menu-bar-popup-delay", &popup_delay,
769 gtk_menu_bar_move_current (GtkMenuShell *menu_shell,
770 GtkMenuDirectionType direction)
772 GtkMenuBar *menubar = GTK_MENU_BAR (menu_shell);
773 GtkTextDirection text_dir;
774 GtkPackDirection pack_dir;
776 text_dir = gtk_widget_get_direction (GTK_WIDGET (menubar));
777 pack_dir = gtk_menu_bar_get_pack_direction (menubar);
779 if (pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL)
781 if ((text_dir == GTK_TEXT_DIR_RTL) == (pack_dir == GTK_PACK_DIRECTION_LTR))
785 case GTK_MENU_DIR_PREV:
786 direction = GTK_MENU_DIR_NEXT;
788 case GTK_MENU_DIR_NEXT:
789 direction = GTK_MENU_DIR_PREV;
799 case GTK_MENU_DIR_PARENT:
800 if ((text_dir == GTK_TEXT_DIR_LTR) == (pack_dir == GTK_PACK_DIRECTION_TTB))
801 direction = GTK_MENU_DIR_PREV;
803 direction = GTK_MENU_DIR_NEXT;
805 case GTK_MENU_DIR_CHILD:
806 if ((text_dir == GTK_TEXT_DIR_LTR) == (pack_dir == GTK_PACK_DIRECTION_TTB))
807 direction = GTK_MENU_DIR_NEXT;
809 direction = GTK_MENU_DIR_PREV;
811 case GTK_MENU_DIR_PREV:
812 if (text_dir == GTK_TEXT_DIR_RTL)
813 direction = GTK_MENU_DIR_CHILD;
815 direction = GTK_MENU_DIR_PARENT;
817 case GTK_MENU_DIR_NEXT:
818 if (text_dir == GTK_TEXT_DIR_RTL)
819 direction = GTK_MENU_DIR_PARENT;
821 direction = GTK_MENU_DIR_CHILD;
827 GTK_MENU_SHELL_CLASS (gtk_menu_bar_parent_class)->move_current (menu_shell, direction);
831 * gtk_menu_bar_get_pack_direction:
832 * @menubar: a #GtkMenuBar
834 * Retrieves the current pack direction of the menubar.
835 * See gtk_menu_bar_set_pack_direction().
837 * Return value: the pack direction
842 gtk_menu_bar_get_pack_direction (GtkMenuBar *menubar)
844 GtkMenuBarPrivate *priv;
846 g_return_val_if_fail (GTK_IS_MENU_BAR (menubar),
847 GTK_PACK_DIRECTION_LTR);
849 priv = GTK_MENU_BAR_GET_PRIVATE (menubar);
851 return priv->pack_direction;
855 * gtk_menu_bar_set_pack_direction:
856 * @menubar: a #GtkMenuBar
857 * @pack_dir: a new #GtkPackDirection
859 * Sets how items should be packed inside a menubar.
864 gtk_menu_bar_set_pack_direction (GtkMenuBar *menubar,
865 GtkPackDirection pack_dir)
867 GtkMenuBarPrivate *priv;
870 g_return_if_fail (GTK_IS_MENU_BAR (menubar));
872 priv = GTK_MENU_BAR_GET_PRIVATE (menubar);
874 if (priv->pack_direction != pack_dir)
876 priv->pack_direction = pack_dir;
878 gtk_widget_queue_resize (GTK_WIDGET (menubar));
880 for (l = GTK_MENU_SHELL (menubar)->children; l; l = l->next)
881 gtk_widget_queue_resize (GTK_WIDGET (l->data));
883 g_object_notify (G_OBJECT (menubar), "pack-direction");
888 * gtk_menu_bar_get_child_pack_direction:
889 * @menubar: a #GtkMenuBar
891 * Retrieves the current child pack direction of the menubar.
892 * See gtk_menu_bar_set_child_pack_direction().
894 * Return value: the child pack direction
899 gtk_menu_bar_get_child_pack_direction (GtkMenuBar *menubar)
901 GtkMenuBarPrivate *priv;
903 g_return_val_if_fail (GTK_IS_MENU_BAR (menubar),
904 GTK_PACK_DIRECTION_LTR);
906 priv = GTK_MENU_BAR_GET_PRIVATE (menubar);
908 return priv->child_pack_direction;
912 * gtk_menu_bar_set_child_pack_direction:
913 * @menubar: a #GtkMenuBar
914 * @child_pack_dir: a new #GtkPackDirection
916 * Sets how widgets should be packed inside the children of a menubar.
921 gtk_menu_bar_set_child_pack_direction (GtkMenuBar *menubar,
922 GtkPackDirection child_pack_dir)
924 GtkMenuBarPrivate *priv;
927 g_return_if_fail (GTK_IS_MENU_BAR (menubar));
929 priv = GTK_MENU_BAR_GET_PRIVATE (menubar);
931 if (priv->child_pack_direction != child_pack_dir)
933 priv->child_pack_direction = child_pack_dir;
935 gtk_widget_queue_resize (GTK_WIDGET (menubar));
937 for (l = GTK_MENU_SHELL (menubar)->children; l; l = l->next)
938 gtk_widget_queue_resize (GTK_WIDGET (l->data));
940 g_object_notify (G_OBJECT (menubar), "child-pack-direction");