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_widget_size_request (child, &child_requisition);
315 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
318 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
319 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
320 child_requisition.width += toggle_size;
322 child_requisition.height += toggle_size;
324 if (priv->pack_direction == GTK_PACK_DIRECTION_LTR ||
325 priv->pack_direction == GTK_PACK_DIRECTION_RTL)
327 requisition->width += child_requisition.width;
328 requisition->height = MAX (requisition->height, child_requisition.height);
332 requisition->width = MAX (requisition->width, child_requisition.width);
333 requisition->height += child_requisition.height;
339 gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL);
341 border_width = gtk_container_get_border_width (GTK_CONTAINER (menu_bar));
342 requisition->width += (border_width +
345 requisition->height += (border_width +
349 if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE)
353 style = gtk_widget_get_style (widget);
354 requisition->width += style->xthickness * 2;
355 requisition->height += style->ythickness * 2;
361 gtk_menu_bar_size_allocate (GtkWidget *widget,
362 GtkAllocation *allocation)
364 GtkMenuBar *menu_bar;
365 GtkMenuShell *menu_shell;
366 GtkMenuBarPrivate *priv;
369 GtkAllocation child_allocation;
370 GtkRequisition child_requisition;
372 GtkTextDirection direction;
377 g_return_if_fail (GTK_IS_MENU_BAR (widget));
378 g_return_if_fail (allocation != NULL);
380 menu_bar = GTK_MENU_BAR (widget);
381 menu_shell = GTK_MENU_SHELL (widget);
382 priv = menu_bar->priv;
384 direction = gtk_widget_get_direction (widget);
386 gtk_widget_set_allocation (widget, allocation);
388 if (gtk_widget_get_realized (widget))
389 gdk_window_move_resize (gtk_widget_get_window (widget),
390 allocation->x, allocation->y,
391 allocation->width, allocation->height);
393 gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL);
395 if (menu_shell->children)
397 border_width = gtk_container_get_border_width (GTK_CONTAINER (menu_bar));
398 child_allocation.x = (border_width +
401 child_allocation.y = (border_width +
404 if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE)
408 style = gtk_widget_get_style (widget);
409 child_allocation.x += style->xthickness;
410 child_allocation.y += style->ythickness;
413 if (priv->pack_direction == GTK_PACK_DIRECTION_LTR ||
414 priv->pack_direction == GTK_PACK_DIRECTION_RTL)
416 child_allocation.height = MAX (1, (gint)allocation->height - child_allocation.y * 2);
418 offset = child_allocation.x; /* Window edge to menubar start */
419 ltr_x = child_allocation.x;
421 children = menu_shell->children;
426 child = children->data;
427 children = children->next;
429 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
431 gtk_size_request_get_size (GTK_SIZE_REQUEST (child),
432 &child_requisition, NULL);
434 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
435 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
436 child_requisition.width += toggle_size;
438 child_requisition.height += toggle_size;
440 /* Support for the right justified help menu */
441 if ((children == NULL) && (GTK_IS_MENU_ITEM(child))
442 && (GTK_MENU_ITEM(child)->right_justify))
444 ltr_x = allocation->width -
445 child_requisition.width - offset;
447 if (gtk_widget_get_visible (child))
449 if ((direction == GTK_TEXT_DIR_LTR) == (priv->pack_direction == GTK_PACK_DIRECTION_LTR))
450 child_allocation.x = ltr_x;
452 child_allocation.x = allocation->width -
453 child_requisition.width - ltr_x;
455 child_allocation.width = child_requisition.width;
457 gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (child),
459 gtk_widget_size_allocate (child, &child_allocation);
461 ltr_x += child_allocation.width;
467 child_allocation.width = MAX (1, (gint)allocation->width - child_allocation.x * 2);
469 offset = child_allocation.y; /* Window edge to menubar start */
470 ltr_y = child_allocation.y;
472 children = menu_shell->children;
477 child = children->data;
478 children = children->next;
480 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
482 gtk_size_request_get_size (GTK_SIZE_REQUEST (child),
483 &child_requisition, NULL);
485 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
486 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
487 child_requisition.width += toggle_size;
489 child_requisition.height += toggle_size;
491 /* Support for the right justified help menu */
492 if ((children == NULL) && (GTK_IS_MENU_ITEM(child))
493 && (GTK_MENU_ITEM(child)->right_justify))
495 ltr_y = allocation->height -
496 child_requisition.height - offset;
498 if (gtk_widget_get_visible (child))
500 if ((direction == GTK_TEXT_DIR_LTR) ==
501 (priv->pack_direction == GTK_PACK_DIRECTION_TTB))
502 child_allocation.y = ltr_y;
504 child_allocation.y = allocation->height -
505 child_requisition.height - ltr_y;
506 child_allocation.height = child_requisition.height;
508 gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (child),
510 gtk_widget_size_allocate (child, &child_allocation);
512 ltr_y += child_allocation.height;
520 gtk_menu_bar_paint (GtkWidget *widget,
523 g_return_if_fail (GTK_IS_MENU_BAR (widget));
525 if (gtk_widget_is_drawable (widget))
527 GtkAllocation allocation;
530 border = gtk_container_get_border_width (GTK_CONTAINER (widget));
531 gtk_widget_get_allocation (widget, &allocation);
533 gtk_paint_box (gtk_widget_get_style (widget),
534 gtk_widget_get_window (widget),
535 gtk_widget_get_state (widget),
536 get_shadow_type (GTK_MENU_BAR (widget)),
537 area, widget, "menubar",
539 allocation.width - border * 2,
540 allocation.height - border * 2);
545 gtk_menu_bar_expose (GtkWidget *widget,
546 GdkEventExpose *event)
548 g_return_val_if_fail (GTK_IS_MENU_BAR (widget), FALSE);
549 g_return_val_if_fail (event != NULL, FALSE);
551 if (gtk_widget_is_drawable (widget))
553 gtk_menu_bar_paint (widget, &event->area);
555 GTK_WIDGET_CLASS (gtk_menu_bar_parent_class)->expose_event (widget, event);
562 get_menu_bars (GtkWindow *window)
564 return g_object_get_data (G_OBJECT (window), "gtk-menu-bar-list");
568 get_viewable_menu_bars (GtkWindow *window)
571 GList *viewable_menu_bars = NULL;
573 for (menu_bars = get_menu_bars (window);
575 menu_bars = menu_bars->next)
577 GtkWidget *widget = menu_bars->data;
578 gboolean viewable = TRUE;
582 if (!gtk_widget_get_mapped (widget))
585 widget = gtk_widget_get_parent (widget);
589 viewable_menu_bars = g_list_prepend (viewable_menu_bars, menu_bars->data);
592 return g_list_reverse (viewable_menu_bars);
596 set_menu_bars (GtkWindow *window,
599 g_object_set_data (G_OBJECT (window), I_("gtk-menu-bar-list"), menubars);
603 window_key_press_handler (GtkWidget *widget,
608 gboolean retval = FALSE;
610 g_object_get (gtk_widget_get_settings (widget),
611 "gtk-menu-bar-accel", &accel,
617 GdkModifierType mods = 0;
619 gtk_accelerator_parse (accel, &keyval, &mods);
622 g_warning ("Failed to parse menu bar accelerator '%s'\n", accel);
624 /* FIXME this is wrong, needs to be in the global accel resolution
625 * thing, to properly consider i18n etc., but that probably requires
626 * AccelGroup changes etc.
628 if (event->keyval == keyval &&
629 ((event->state & gtk_accelerator_get_default_mod_mask ()) ==
630 (mods & gtk_accelerator_get_default_mod_mask ())))
632 GList *tmp_menubars = get_viewable_menu_bars (GTK_WINDOW (widget));
635 menubars = _gtk_container_focus_sort (GTK_CONTAINER (widget), tmp_menubars,
636 GTK_DIR_TAB_FORWARD, NULL);
637 g_list_free (tmp_menubars);
641 GtkMenuShell *menu_shell = GTK_MENU_SHELL (menubars->data);
643 _gtk_menu_shell_set_keyboard_mode (menu_shell, TRUE);
644 _gtk_menu_shell_activate (menu_shell);
645 gtk_menu_shell_select_first (menu_shell, FALSE);
647 g_list_free (menubars);
660 add_to_window (GtkWindow *window,
663 GList *menubars = get_menu_bars (window);
667 g_signal_connect (window,
669 G_CALLBACK (window_key_press_handler),
673 set_menu_bars (window, g_list_prepend (menubars, menubar));
677 remove_from_window (GtkWindow *window,
680 GList *menubars = get_menu_bars (window);
682 menubars = g_list_remove (menubars, menubar);
686 g_signal_handlers_disconnect_by_func (window,
687 window_key_press_handler,
691 set_menu_bars (window, menubars);
695 gtk_menu_bar_hierarchy_changed (GtkWidget *widget,
696 GtkWidget *old_toplevel)
701 menubar = GTK_MENU_BAR (widget);
703 toplevel = gtk_widget_get_toplevel (widget);
706 remove_from_window (GTK_WINDOW (old_toplevel), menubar);
708 if (gtk_widget_is_toplevel (toplevel))
709 add_to_window (GTK_WINDOW (toplevel), menubar);
713 * _gtk_menu_bar_cycle_focus:
714 * @menubar: a #GtkMenuBar
715 * @dir: direction in which to cycle the focus
717 * Move the focus between menubars in the toplevel.
720 _gtk_menu_bar_cycle_focus (GtkMenuBar *menubar,
721 GtkDirectionType dir)
723 GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (menubar));
724 GtkMenuItem *to_activate = NULL;
726 if (gtk_widget_is_toplevel (toplevel))
728 GList *tmp_menubars = get_viewable_menu_bars (GTK_WINDOW (toplevel));
732 menubars = _gtk_container_focus_sort (GTK_CONTAINER (toplevel), tmp_menubars,
733 dir, GTK_WIDGET (menubar));
734 g_list_free (tmp_menubars);
738 current = g_list_find (menubars, menubar);
740 if (current && current->next)
742 GtkMenuShell *new_menushell = GTK_MENU_SHELL (current->next->data);
743 if (new_menushell->children)
744 to_activate = new_menushell->children->data;
748 g_list_free (menubars);
751 gtk_menu_shell_cancel (GTK_MENU_SHELL (menubar));
754 g_signal_emit_by_name (to_activate, "activate_item");
758 get_shadow_type (GtkMenuBar *menubar)
760 GtkShadowType shadow_type = GTK_SHADOW_OUT;
762 gtk_widget_style_get (GTK_WIDGET (menubar),
763 "shadow-type", &shadow_type,
770 gtk_menu_bar_get_popup_delay (GtkMenuShell *menu_shell)
774 g_object_get (gtk_widget_get_settings (GTK_WIDGET (menu_shell)),
775 "gtk-menu-bar-popup-delay", &popup_delay,
782 gtk_menu_bar_move_current (GtkMenuShell *menu_shell,
783 GtkMenuDirectionType direction)
785 GtkMenuBar *menubar = GTK_MENU_BAR (menu_shell);
786 GtkTextDirection text_dir;
787 GtkPackDirection pack_dir;
789 text_dir = gtk_widget_get_direction (GTK_WIDGET (menubar));
790 pack_dir = gtk_menu_bar_get_pack_direction (menubar);
792 if (pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL)
794 if ((text_dir == GTK_TEXT_DIR_RTL) == (pack_dir == GTK_PACK_DIRECTION_LTR))
798 case GTK_MENU_DIR_PREV:
799 direction = GTK_MENU_DIR_NEXT;
801 case GTK_MENU_DIR_NEXT:
802 direction = GTK_MENU_DIR_PREV;
812 case GTK_MENU_DIR_PARENT:
813 if ((text_dir == GTK_TEXT_DIR_LTR) == (pack_dir == GTK_PACK_DIRECTION_TTB))
814 direction = GTK_MENU_DIR_PREV;
816 direction = GTK_MENU_DIR_NEXT;
818 case GTK_MENU_DIR_CHILD:
819 if ((text_dir == GTK_TEXT_DIR_LTR) == (pack_dir == GTK_PACK_DIRECTION_TTB))
820 direction = GTK_MENU_DIR_NEXT;
822 direction = GTK_MENU_DIR_PREV;
824 case GTK_MENU_DIR_PREV:
825 if (text_dir == GTK_TEXT_DIR_RTL)
826 direction = GTK_MENU_DIR_CHILD;
828 direction = GTK_MENU_DIR_PARENT;
830 case GTK_MENU_DIR_NEXT:
831 if (text_dir == GTK_TEXT_DIR_RTL)
832 direction = GTK_MENU_DIR_PARENT;
834 direction = GTK_MENU_DIR_CHILD;
840 GTK_MENU_SHELL_CLASS (gtk_menu_bar_parent_class)->move_current (menu_shell, direction);
844 * gtk_menu_bar_get_pack_direction:
845 * @menubar: a #GtkMenuBar
847 * Retrieves the current pack direction of the menubar.
848 * See gtk_menu_bar_set_pack_direction().
850 * Return value: the pack direction
855 gtk_menu_bar_get_pack_direction (GtkMenuBar *menubar)
857 g_return_val_if_fail (GTK_IS_MENU_BAR (menubar),
858 GTK_PACK_DIRECTION_LTR);
860 return menubar->priv->pack_direction;
864 * gtk_menu_bar_set_pack_direction:
865 * @menubar: a #GtkMenuBar
866 * @pack_dir: a new #GtkPackDirection
868 * Sets how items should be packed inside a menubar.
873 gtk_menu_bar_set_pack_direction (GtkMenuBar *menubar,
874 GtkPackDirection pack_dir)
876 GtkMenuBarPrivate *priv;
879 g_return_if_fail (GTK_IS_MENU_BAR (menubar));
881 priv = menubar->priv;
883 if (priv->pack_direction != pack_dir)
885 priv->pack_direction = pack_dir;
887 gtk_widget_queue_resize (GTK_WIDGET (menubar));
889 for (l = GTK_MENU_SHELL (menubar)->children; l; l = l->next)
890 gtk_widget_queue_resize (GTK_WIDGET (l->data));
892 g_object_notify (G_OBJECT (menubar), "pack-direction");
897 * gtk_menu_bar_get_child_pack_direction:
898 * @menubar: a #GtkMenuBar
900 * Retrieves the current child pack direction of the menubar.
901 * See gtk_menu_bar_set_child_pack_direction().
903 * Return value: the child pack direction
908 gtk_menu_bar_get_child_pack_direction (GtkMenuBar *menubar)
910 g_return_val_if_fail (GTK_IS_MENU_BAR (menubar),
911 GTK_PACK_DIRECTION_LTR);
913 return menubar->priv->child_pack_direction;
917 * gtk_menu_bar_set_child_pack_direction:
918 * @menubar: a #GtkMenuBar
919 * @child_pack_dir: a new #GtkPackDirection
921 * Sets how widgets should be packed inside the children of a menubar.
926 gtk_menu_bar_set_child_pack_direction (GtkMenuBar *menubar,
927 GtkPackDirection child_pack_dir)
929 GtkMenuBarPrivate *priv;
932 g_return_if_fail (GTK_IS_MENU_BAR (menubar));
934 priv = menubar->priv;
936 if (priv->child_pack_direction != child_pack_dir)
938 priv->child_pack_direction = child_pack_dir;
940 gtk_widget_queue_resize (GTK_WIDGET (menubar));
942 for (l = GTK_MENU_SHELL (menubar)->children; l; l = l->next)
943 gtk_widget_queue_resize (GTK_WIDGET (l->data));
945 g_object_notify (G_OBJECT (menubar), "child-pack-direction");