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/.
30 * @Short_description: A subclass of GtkMenuShell which holds GtkMenuItem widgets
31 * @See_also: #GtkMenuShell, #GtkMenu, #GtkMenuItem
33 * The #GtkMenuBar is a subclass of #GtkMenuShell which contains one or
34 * more #GtkMenuItems. The result is a standard menu bar which can hold
40 #include "gtkmenubar.h"
42 #include "gtkbindings.h"
44 #include "gtkmarshalers.h"
45 #include "gtkmenuitemprivate.h"
46 #include "gtkmenuprivate.h"
47 #include "gtkmenushellprivate.h"
48 #include "gtksettings.h"
49 #include "gtksizerequest.h"
50 #include "gtkwindow.h"
52 #include "gtkprivate.h"
53 #include "gtktypebuiltins.h"
55 #define BORDER_SPACING 0
56 #define DEFAULT_IPADDING 1
62 PROP_CHILD_PACK_DIRECTION
65 struct _GtkMenuBarPrivate
67 GtkPackDirection pack_direction;
68 GtkPackDirection child_pack_direction;
72 static void gtk_menu_bar_set_property (GObject *object,
76 static void gtk_menu_bar_get_property (GObject *object,
80 static void gtk_menu_bar_size_request (GtkWidget *widget,
81 GtkRequisition *requisition);
82 static void gtk_menu_bar_get_preferred_width (GtkWidget *widget,
85 static void gtk_menu_bar_get_preferred_height (GtkWidget *widget,
88 static void gtk_menu_bar_size_allocate (GtkWidget *widget,
89 GtkAllocation *allocation);
90 static gint gtk_menu_bar_draw (GtkWidget *widget,
92 static void gtk_menu_bar_hierarchy_changed (GtkWidget *widget,
93 GtkWidget *old_toplevel);
94 static gint gtk_menu_bar_get_popup_delay (GtkMenuShell *menu_shell);
95 static void gtk_menu_bar_move_current (GtkMenuShell *menu_shell,
96 GtkMenuDirectionType direction);
98 static GtkShadowType get_shadow_type (GtkMenuBar *menubar);
100 G_DEFINE_TYPE (GtkMenuBar, gtk_menu_bar, GTK_TYPE_MENU_SHELL)
103 gtk_menu_bar_class_init (GtkMenuBarClass *class)
105 GObjectClass *gobject_class;
106 GtkWidgetClass *widget_class;
107 GtkMenuShellClass *menu_shell_class;
109 GtkBindingSet *binding_set;
111 gobject_class = (GObjectClass*) class;
112 widget_class = (GtkWidgetClass*) class;
113 menu_shell_class = (GtkMenuShellClass*) class;
115 gobject_class->get_property = gtk_menu_bar_get_property;
116 gobject_class->set_property = gtk_menu_bar_set_property;
118 widget_class->get_preferred_width = gtk_menu_bar_get_preferred_width;
119 widget_class->get_preferred_height = gtk_menu_bar_get_preferred_height;
120 widget_class->size_allocate = gtk_menu_bar_size_allocate;
121 widget_class->draw = gtk_menu_bar_draw;
122 widget_class->hierarchy_changed = gtk_menu_bar_hierarchy_changed;
124 menu_shell_class->submenu_placement = GTK_TOP_BOTTOM;
125 menu_shell_class->get_popup_delay = gtk_menu_bar_get_popup_delay;
126 menu_shell_class->move_current = gtk_menu_bar_move_current;
128 binding_set = gtk_binding_set_by_class (class);
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,
139 gtk_binding_entry_add_signal (binding_set,
142 GTK_TYPE_MENU_DIRECTION_TYPE,
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,
153 GTK_MENU_DIR_PARENT);
154 gtk_binding_entry_add_signal (binding_set,
157 GTK_TYPE_MENU_DIRECTION_TYPE,
158 GTK_MENU_DIR_PARENT);
159 gtk_binding_entry_add_signal (binding_set,
162 GTK_TYPE_MENU_DIRECTION_TYPE,
164 gtk_binding_entry_add_signal (binding_set,
167 GTK_TYPE_MENU_DIRECTION_TYPE,
171 * GtkMenuBar:pack-direction:
173 * The pack direction of the menubar. It determines how
174 * menuitems are arranged in the menubar.
178 g_object_class_install_property (gobject_class,
180 g_param_spec_enum ("pack-direction",
181 P_("Pack direction"),
182 P_("The pack direction of the menubar"),
183 GTK_TYPE_PACK_DIRECTION,
184 GTK_PACK_DIRECTION_LTR,
185 GTK_PARAM_READWRITE));
188 * GtkMenuBar:child-pack-direction:
190 * The child pack direction of the menubar. It determines how
191 * the widgets contained in child menuitems are arranged.
195 g_object_class_install_property (gobject_class,
196 PROP_CHILD_PACK_DIRECTION,
197 g_param_spec_enum ("child-pack-direction",
198 P_("Child Pack direction"),
199 P_("The child pack direction of the menubar"),
200 GTK_TYPE_PACK_DIRECTION,
201 GTK_PACK_DIRECTION_LTR,
202 GTK_PARAM_READWRITE));
205 gtk_widget_class_install_style_property (widget_class,
206 g_param_spec_enum ("shadow-type",
208 P_("Style of bevel around the menubar"),
209 GTK_TYPE_SHADOW_TYPE,
211 GTK_PARAM_READABLE));
213 gtk_widget_class_install_style_property (widget_class,
214 g_param_spec_int ("internal-padding",
215 P_("Internal padding"),
216 P_("Amount of border space between the menubar shadow and the menu items"),
220 GTK_PARAM_READABLE));
222 g_type_class_add_private (gobject_class, sizeof (GtkMenuBarPrivate));
226 gtk_menu_bar_init (GtkMenuBar *menu_bar)
228 GtkStyleContext *context;
230 menu_bar->priv = G_TYPE_INSTANCE_GET_PRIVATE (menu_bar,
234 context = gtk_widget_get_style_context (GTK_WIDGET (menu_bar));
235 gtk_style_context_add_class (context, GTK_STYLE_CLASS_MENUBAR);
241 * Creates a new #GtkMenuBar
243 * Returns: the new menu bar, as a #GtkWidget
246 gtk_menu_bar_new (void)
248 return g_object_new (GTK_TYPE_MENU_BAR, NULL);
252 gtk_menu_bar_set_property (GObject *object,
257 GtkMenuBar *menubar = GTK_MENU_BAR (object);
261 case PROP_PACK_DIRECTION:
262 gtk_menu_bar_set_pack_direction (menubar, g_value_get_enum (value));
264 case PROP_CHILD_PACK_DIRECTION:
265 gtk_menu_bar_set_child_pack_direction (menubar, g_value_get_enum (value));
268 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
274 gtk_menu_bar_get_property (GObject *object,
279 GtkMenuBar *menubar = GTK_MENU_BAR (object);
283 case PROP_PACK_DIRECTION:
284 g_value_set_enum (value, gtk_menu_bar_get_pack_direction (menubar));
286 case PROP_CHILD_PACK_DIRECTION:
287 g_value_set_enum (value, gtk_menu_bar_get_child_pack_direction (menubar));
290 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
296 gtk_menu_bar_size_request (GtkWidget *widget,
297 GtkRequisition *requisition)
299 GtkMenuBar *menu_bar;
300 GtkMenuBarPrivate *priv;
301 GtkMenuShell *menu_shell;
304 GtkRequisition child_requisition;
308 g_return_if_fail (GTK_IS_MENU_BAR (widget));
309 g_return_if_fail (requisition != NULL);
311 requisition->width = 0;
312 requisition->height = 0;
314 menu_bar = GTK_MENU_BAR (widget);
315 menu_shell = GTK_MENU_SHELL (widget);
316 priv = menu_bar->priv;
318 children = menu_shell->priv->children;
322 child = children->data;
323 children = children->next;
325 if (gtk_widget_get_visible (child))
329 gtk_widget_get_preferred_size (child, &child_requisition, NULL);
330 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
333 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
334 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
335 child_requisition.width += toggle_size;
337 child_requisition.height += toggle_size;
339 if (priv->pack_direction == GTK_PACK_DIRECTION_LTR ||
340 priv->pack_direction == GTK_PACK_DIRECTION_RTL)
342 requisition->width += child_requisition.width;
343 requisition->height = MAX (requisition->height, child_requisition.height);
347 requisition->width = MAX (requisition->width, child_requisition.width);
348 requisition->height += child_requisition.height;
353 gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL);
355 border_width = gtk_container_get_border_width (GTK_CONTAINER (menu_bar));
356 requisition->width += (border_width +
359 requisition->height += (border_width +
363 if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE)
365 GtkStyleContext *context;
368 context = gtk_widget_get_style_context (widget);
370 gtk_style_context_get (context, 0,
371 "border-width", &border,
374 requisition->width += border->left + border->right;
375 requisition->height += border->top + border->bottom;
376 gtk_border_free (border);
381 gtk_menu_bar_get_preferred_width (GtkWidget *widget,
385 GtkRequisition requisition;
387 gtk_menu_bar_size_request (widget, &requisition);
389 *minimum = *natural = requisition.width;
393 gtk_menu_bar_get_preferred_height (GtkWidget *widget,
397 GtkRequisition requisition;
399 gtk_menu_bar_size_request (widget, &requisition);
401 *minimum = *natural = requisition.height;
405 gtk_menu_bar_size_allocate (GtkWidget *widget,
406 GtkAllocation *allocation)
408 GtkMenuBar *menu_bar;
409 GtkMenuShell *menu_shell;
410 GtkMenuBarPrivate *priv;
413 GtkAllocation child_allocation;
414 GtkRequisition child_requisition;
416 GtkTextDirection direction;
421 g_return_if_fail (GTK_IS_MENU_BAR (widget));
422 g_return_if_fail (allocation != NULL);
424 menu_bar = GTK_MENU_BAR (widget);
425 menu_shell = GTK_MENU_SHELL (widget);
426 priv = menu_bar->priv;
428 direction = gtk_widget_get_direction (widget);
430 gtk_widget_set_allocation (widget, allocation);
432 if (gtk_widget_get_realized (widget))
433 gdk_window_move_resize (gtk_widget_get_window (widget),
434 allocation->x, allocation->y,
435 allocation->width, allocation->height);
437 gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL);
439 if (menu_shell->priv->children)
441 border_width = gtk_container_get_border_width (GTK_CONTAINER (menu_bar));
442 child_allocation.x = (border_width +
445 child_allocation.y = (border_width +
448 if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE)
450 GtkStyleContext *context;
453 context = gtk_widget_get_style_context (widget);
454 gtk_style_context_get (context, 0,
455 "border-width", &border,
458 child_allocation.x += border->left;
459 child_allocation.y += border->top;
461 gtk_border_free (border);
464 if (priv->pack_direction == GTK_PACK_DIRECTION_LTR ||
465 priv->pack_direction == GTK_PACK_DIRECTION_RTL)
467 child_allocation.height = MAX (1, (gint)allocation->height - child_allocation.y * 2);
469 offset = child_allocation.x; /* Window edge to menubar start */
470 ltr_x = child_allocation.x;
472 children = menu_shell->priv->children;
477 child = children->data;
478 children = children->next;
480 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
482 gtk_widget_get_preferred_size (child, &child_requisition, NULL);
484 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
485 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
486 child_requisition.width += toggle_size;
488 child_requisition.height += toggle_size;
490 /* Support for the right justified help menu */
491 if (children == NULL &&
492 GTK_IS_MENU_ITEM (child) &&
493 GTK_MENU_ITEM (child)->priv->right_justify)
495 ltr_x = allocation->width -
496 child_requisition.width - offset;
498 if (gtk_widget_get_visible (child))
500 if ((direction == GTK_TEXT_DIR_LTR) == (priv->pack_direction == GTK_PACK_DIRECTION_LTR))
501 child_allocation.x = ltr_x;
503 child_allocation.x = allocation->width -
504 child_requisition.width - ltr_x;
506 child_allocation.width = child_requisition.width;
508 gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (child),
510 gtk_widget_size_allocate (child, &child_allocation);
512 ltr_x += child_allocation.width;
518 child_allocation.width = MAX (1, (gint)allocation->width - child_allocation.x * 2);
520 offset = child_allocation.y; /* Window edge to menubar start */
521 ltr_y = child_allocation.y;
523 children = menu_shell->priv->children;
528 child = children->data;
529 children = children->next;
531 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
533 gtk_widget_get_preferred_size (child, &child_requisition, NULL);
535 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
536 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
537 child_requisition.width += toggle_size;
539 child_requisition.height += toggle_size;
541 /* Support for the right justified help menu */
542 if (children == NULL &&
543 GTK_IS_MENU_ITEM (child) &&
544 GTK_MENU_ITEM (child)->priv->right_justify)
546 ltr_y = allocation->height -
547 child_requisition.height - offset;
549 if (gtk_widget_get_visible (child))
551 if ((direction == GTK_TEXT_DIR_LTR) ==
552 (priv->pack_direction == GTK_PACK_DIRECTION_TTB))
553 child_allocation.y = ltr_y;
555 child_allocation.y = allocation->height -
556 child_requisition.height - ltr_y;
557 child_allocation.height = child_requisition.height;
559 gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (child),
561 gtk_widget_size_allocate (child, &child_allocation);
563 ltr_y += child_allocation.height;
571 gtk_menu_bar_draw (GtkWidget *widget,
574 GtkStyleContext *context;
578 border = gtk_container_get_border_width (GTK_CONTAINER (widget));
579 context = gtk_widget_get_style_context (widget);
581 state = gtk_widget_get_state_flags (widget);
582 gtk_style_context_set_state (context, state);
584 if (get_shadow_type (GTK_MENU_BAR (widget)) != GTK_SHADOW_NONE)
585 gtk_render_background (context, cr,
587 gtk_widget_get_allocated_width (widget) - border * 2,
588 gtk_widget_get_allocated_height (widget) - border * 2);
590 gtk_render_frame (context, cr,
592 gtk_widget_get_allocated_width (widget) - border * 2,
593 gtk_widget_get_allocated_height (widget) - border * 2);
595 GTK_WIDGET_CLASS (gtk_menu_bar_parent_class)->draw (widget, cr);
601 get_menu_bars (GtkWindow *window)
603 return g_object_get_data (G_OBJECT (window), "gtk-menu-bar-list");
607 get_viewable_menu_bars (GtkWindow *window)
610 GList *viewable_menu_bars = NULL;
612 for (menu_bars = get_menu_bars (window);
614 menu_bars = menu_bars->next)
616 GtkWidget *widget = menu_bars->data;
617 gboolean viewable = TRUE;
621 if (!gtk_widget_get_mapped (widget))
624 widget = gtk_widget_get_parent (widget);
628 viewable_menu_bars = g_list_prepend (viewable_menu_bars, menu_bars->data);
631 return g_list_reverse (viewable_menu_bars);
635 set_menu_bars (GtkWindow *window,
638 g_object_set_data (G_OBJECT (window), I_("gtk-menu-bar-list"), menubars);
642 window_key_press_handler (GtkWidget *widget,
647 gboolean retval = FALSE;
649 g_object_get (gtk_widget_get_settings (widget),
650 "gtk-menu-bar-accel", &accel,
656 GdkModifierType mods = 0;
658 gtk_accelerator_parse (accel, &keyval, &mods);
661 g_warning ("Failed to parse menu bar accelerator '%s'\n", accel);
663 /* FIXME this is wrong, needs to be in the global accel resolution
664 * thing, to properly consider i18n etc., but that probably requires
665 * AccelGroup changes etc.
667 if (event->keyval == keyval &&
668 ((event->state & gtk_accelerator_get_default_mod_mask ()) ==
669 (mods & gtk_accelerator_get_default_mod_mask ())))
671 GList *tmp_menubars = get_viewable_menu_bars (GTK_WINDOW (widget));
674 menubars = _gtk_container_focus_sort (GTK_CONTAINER (widget), tmp_menubars,
675 GTK_DIR_TAB_FORWARD, NULL);
676 g_list_free (tmp_menubars);
680 GtkMenuShell *menu_shell = GTK_MENU_SHELL (menubars->data);
682 _gtk_menu_shell_set_keyboard_mode (menu_shell, TRUE);
683 gtk_menu_shell_select_first (menu_shell, FALSE);
685 g_list_free (menubars);
698 add_to_window (GtkWindow *window,
701 GList *menubars = get_menu_bars (window);
705 g_signal_connect (window,
707 G_CALLBACK (window_key_press_handler),
711 set_menu_bars (window, g_list_prepend (menubars, menubar));
715 remove_from_window (GtkWindow *window,
718 GList *menubars = get_menu_bars (window);
720 menubars = g_list_remove (menubars, menubar);
724 g_signal_handlers_disconnect_by_func (window,
725 window_key_press_handler,
729 set_menu_bars (window, menubars);
733 gtk_menu_bar_hierarchy_changed (GtkWidget *widget,
734 GtkWidget *old_toplevel)
739 menubar = GTK_MENU_BAR (widget);
741 toplevel = gtk_widget_get_toplevel (widget);
744 remove_from_window (GTK_WINDOW (old_toplevel), menubar);
746 if (gtk_widget_is_toplevel (toplevel))
747 add_to_window (GTK_WINDOW (toplevel), menubar);
751 * _gtk_menu_bar_cycle_focus:
752 * @menubar: a #GtkMenuBar
753 * @dir: direction in which to cycle the focus
755 * Move the focus between menubars in the toplevel.
758 _gtk_menu_bar_cycle_focus (GtkMenuBar *menubar,
759 GtkDirectionType dir)
761 GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (menubar));
762 GtkMenuItem *to_activate = NULL;
764 if (gtk_widget_is_toplevel (toplevel))
766 GList *tmp_menubars = get_viewable_menu_bars (GTK_WINDOW (toplevel));
770 menubars = _gtk_container_focus_sort (GTK_CONTAINER (toplevel), tmp_menubars,
771 dir, GTK_WIDGET (menubar));
772 g_list_free (tmp_menubars);
776 current = g_list_find (menubars, menubar);
778 if (current && current->next)
780 GtkMenuShell *new_menushell = GTK_MENU_SHELL (current->next->data);
781 if (new_menushell->priv->children)
782 to_activate = new_menushell->priv->children->data;
786 g_list_free (menubars);
789 gtk_menu_shell_cancel (GTK_MENU_SHELL (menubar));
792 g_signal_emit_by_name (to_activate, "activate_item");
796 get_shadow_type (GtkMenuBar *menubar)
798 GtkShadowType shadow_type = GTK_SHADOW_OUT;
800 gtk_widget_style_get (GTK_WIDGET (menubar),
801 "shadow-type", &shadow_type,
808 gtk_menu_bar_get_popup_delay (GtkMenuShell *menu_shell)
812 g_object_get (gtk_widget_get_settings (GTK_WIDGET (menu_shell)),
813 "gtk-menu-bar-popup-delay", &popup_delay,
820 gtk_menu_bar_move_current (GtkMenuShell *menu_shell,
821 GtkMenuDirectionType direction)
823 GtkMenuBar *menubar = GTK_MENU_BAR (menu_shell);
824 GtkTextDirection text_dir;
825 GtkPackDirection pack_dir;
827 text_dir = gtk_widget_get_direction (GTK_WIDGET (menubar));
828 pack_dir = gtk_menu_bar_get_pack_direction (menubar);
830 if (pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL)
832 if ((text_dir == GTK_TEXT_DIR_RTL) == (pack_dir == GTK_PACK_DIRECTION_LTR))
836 case GTK_MENU_DIR_PREV:
837 direction = GTK_MENU_DIR_NEXT;
839 case GTK_MENU_DIR_NEXT:
840 direction = GTK_MENU_DIR_PREV;
850 case GTK_MENU_DIR_PARENT:
851 if ((text_dir == GTK_TEXT_DIR_LTR) == (pack_dir == GTK_PACK_DIRECTION_TTB))
852 direction = GTK_MENU_DIR_PREV;
854 direction = GTK_MENU_DIR_NEXT;
856 case GTK_MENU_DIR_CHILD:
857 if ((text_dir == GTK_TEXT_DIR_LTR) == (pack_dir == GTK_PACK_DIRECTION_TTB))
858 direction = GTK_MENU_DIR_NEXT;
860 direction = GTK_MENU_DIR_PREV;
862 case GTK_MENU_DIR_PREV:
863 if (text_dir == GTK_TEXT_DIR_RTL)
864 direction = GTK_MENU_DIR_CHILD;
866 direction = GTK_MENU_DIR_PARENT;
868 case GTK_MENU_DIR_NEXT:
869 if (text_dir == GTK_TEXT_DIR_RTL)
870 direction = GTK_MENU_DIR_PARENT;
872 direction = GTK_MENU_DIR_CHILD;
878 GTK_MENU_SHELL_CLASS (gtk_menu_bar_parent_class)->move_current (menu_shell, direction);
882 * gtk_menu_bar_get_pack_direction:
883 * @menubar: a #GtkMenuBar
885 * Retrieves the current pack direction of the menubar.
886 * See gtk_menu_bar_set_pack_direction().
888 * Return value: the pack direction
893 gtk_menu_bar_get_pack_direction (GtkMenuBar *menubar)
895 g_return_val_if_fail (GTK_IS_MENU_BAR (menubar),
896 GTK_PACK_DIRECTION_LTR);
898 return menubar->priv->pack_direction;
902 * gtk_menu_bar_set_pack_direction:
903 * @menubar: a #GtkMenuBar
904 * @pack_dir: a new #GtkPackDirection
906 * Sets how items should be packed inside a menubar.
911 gtk_menu_bar_set_pack_direction (GtkMenuBar *menubar,
912 GtkPackDirection pack_dir)
914 GtkMenuBarPrivate *priv;
917 g_return_if_fail (GTK_IS_MENU_BAR (menubar));
919 priv = menubar->priv;
921 if (priv->pack_direction != pack_dir)
923 priv->pack_direction = pack_dir;
925 gtk_widget_queue_resize (GTK_WIDGET (menubar));
927 for (l = GTK_MENU_SHELL (menubar)->priv->children; l; l = l->next)
928 gtk_widget_queue_resize (GTK_WIDGET (l->data));
930 g_object_notify (G_OBJECT (menubar), "pack-direction");
935 * gtk_menu_bar_get_child_pack_direction:
936 * @menubar: a #GtkMenuBar
938 * Retrieves the current child pack direction of the menubar.
939 * See gtk_menu_bar_set_child_pack_direction().
941 * Return value: the child pack direction
946 gtk_menu_bar_get_child_pack_direction (GtkMenuBar *menubar)
948 g_return_val_if_fail (GTK_IS_MENU_BAR (menubar),
949 GTK_PACK_DIRECTION_LTR);
951 return menubar->priv->child_pack_direction;
955 * gtk_menu_bar_set_child_pack_direction:
956 * @menubar: a #GtkMenuBar
957 * @child_pack_dir: a new #GtkPackDirection
959 * Sets how widgets should be packed inside the children of a menubar.
964 gtk_menu_bar_set_child_pack_direction (GtkMenuBar *menubar,
965 GtkPackDirection child_pack_dir)
967 GtkMenuBarPrivate *priv;
970 g_return_if_fail (GTK_IS_MENU_BAR (menubar));
972 priv = menubar->priv;
974 if (priv->child_pack_direction != child_pack_dir)
976 priv->child_pack_direction = child_pack_dir;
978 gtk_widget_queue_resize (GTK_WIDGET (menubar));
980 for (l = GTK_MENU_SHELL (menubar)->priv->children; l; l = l->next)
981 gtk_widget_queue_resize (GTK_WIDGET (l->data));
983 g_object_notify (G_OBJECT (menubar), "child-pack-direction");