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_class_init (GtkMenuBarClass *klass);
65 static void gtk_menu_bar_set_property (GObject *object,
69 static void gtk_menu_bar_get_property (GObject *object,
73 static void gtk_menu_bar_size_request (GtkWidget *widget,
74 GtkRequisition *requisition);
75 static void gtk_menu_bar_size_allocate (GtkWidget *widget,
76 GtkAllocation *allocation);
77 static void gtk_menu_bar_paint (GtkWidget *widget,
79 static gint gtk_menu_bar_expose (GtkWidget *widget,
80 GdkEventExpose *event);
81 static void gtk_menu_bar_hierarchy_changed (GtkWidget *widget,
82 GtkWidget *old_toplevel);
83 static gint gtk_menu_bar_get_popup_delay (GtkMenuShell *menu_shell);
84 static void gtk_menu_bar_move_current (GtkMenuShell *menu_shell,
85 GtkMenuDirectionType direction);
88 static GtkShadowType get_shadow_type (GtkMenuBar *menubar);
90 static GtkMenuShellClass *parent_class = NULL;
93 gtk_menu_bar_get_type (void)
95 static GType menu_bar_type = 0;
99 static const GTypeInfo menu_bar_info =
101 sizeof (GtkMenuBarClass),
102 NULL, /* base_init */
103 NULL, /* base_finalize */
104 (GClassInitFunc) gtk_menu_bar_class_init,
105 NULL, /* class_finalize */
106 NULL, /* class_data */
109 NULL, /* instance_init */
112 menu_bar_type = g_type_register_static (GTK_TYPE_MENU_SHELL, I_("GtkMenuBar"),
116 return menu_bar_type;
120 gtk_menu_bar_class_init (GtkMenuBarClass *class)
122 GObjectClass *gobject_class;
123 GtkWidgetClass *widget_class;
124 GtkMenuShellClass *menu_shell_class;
126 GtkBindingSet *binding_set;
128 parent_class = g_type_class_peek_parent (class);
130 gobject_class = (GObjectClass*) class;
131 widget_class = (GtkWidgetClass*) class;
132 menu_shell_class = (GtkMenuShellClass*) class;
134 gobject_class->get_property = gtk_menu_bar_get_property;
135 gobject_class->set_property = gtk_menu_bar_set_property;
137 widget_class->size_request = gtk_menu_bar_size_request;
138 widget_class->size_allocate = gtk_menu_bar_size_allocate;
139 widget_class->expose_event = gtk_menu_bar_expose;
140 widget_class->hierarchy_changed = gtk_menu_bar_hierarchy_changed;
142 menu_shell_class->submenu_placement = GTK_TOP_BOTTOM;
143 menu_shell_class->get_popup_delay = gtk_menu_bar_get_popup_delay;
144 menu_shell_class->move_current = gtk_menu_bar_move_current;
146 binding_set = gtk_binding_set_by_class (class);
147 gtk_binding_entry_add_signal (binding_set,
150 GTK_TYPE_MENU_DIRECTION_TYPE,
152 gtk_binding_entry_add_signal (binding_set,
155 GTK_TYPE_MENU_DIRECTION_TYPE,
157 gtk_binding_entry_add_signal (binding_set,
160 GTK_TYPE_MENU_DIRECTION_TYPE,
162 gtk_binding_entry_add_signal (binding_set,
165 GTK_TYPE_MENU_DIRECTION_TYPE,
167 gtk_binding_entry_add_signal (binding_set,
170 GTK_TYPE_MENU_DIRECTION_TYPE,
171 GTK_MENU_DIR_PARENT);
172 gtk_binding_entry_add_signal (binding_set,
175 GTK_TYPE_MENU_DIRECTION_TYPE,
176 GTK_MENU_DIR_PARENT);
177 gtk_binding_entry_add_signal (binding_set,
180 GTK_TYPE_MENU_DIRECTION_TYPE,
182 gtk_binding_entry_add_signal (binding_set,
185 GTK_TYPE_MENU_DIRECTION_TYPE,
189 * GtkMenuBar:pack-direction:
191 * The pack direction of the menubar. It determines how
192 * menuitems are arranged in the menubar.
196 g_object_class_install_property (gobject_class,
198 g_param_spec_enum ("pack-direction",
199 P_("Pack direction"),
200 P_("The pack direction of the menubar"),
201 GTK_TYPE_PACK_DIRECTION,
202 GTK_PACK_DIRECTION_LTR,
203 GTK_PARAM_READWRITE));
206 * GtkMenuBar:child-pack-direction:
208 * The pack direction of the menubar. It determines how
209 * the widgets contained in child menuitems are arranged.
213 g_object_class_install_property (gobject_class,
214 PROP_CHILD_PACK_DIRECTION,
215 g_param_spec_enum ("child-pack-direction",
216 P_("Child Pack direction"),
217 P_("The child pack direction of the menubar"),
218 GTK_TYPE_PACK_DIRECTION,
219 GTK_PACK_DIRECTION_LTR,
220 GTK_PARAM_READWRITE));
223 gtk_widget_class_install_style_property (widget_class,
224 g_param_spec_enum ("shadow-type",
226 P_("Style of bevel around the menubar"),
227 GTK_TYPE_SHADOW_TYPE,
229 GTK_PARAM_READABLE));
231 gtk_widget_class_install_style_property (widget_class,
232 g_param_spec_int ("internal-padding",
233 P_("Internal padding"),
234 P_("Amount of border space between the menubar shadow and the menu items"),
238 GTK_PARAM_READABLE));
240 gtk_settings_install_property (g_param_spec_int ("gtk-menu-bar-popup-delay",
241 P_("Delay before drop down menus appear"),
242 P_("Delay before the submenus of a menu bar appear"),
246 GTK_PARAM_READWRITE));
248 g_type_class_add_private (gobject_class, sizeof (GtkMenuBarPrivate));
252 gtk_menu_bar_new (void)
254 return g_object_new (GTK_TYPE_MENU_BAR, NULL);
258 gtk_menu_bar_set_property (GObject *object,
263 GtkMenuBar *menubar = GTK_MENU_BAR (object);
267 case PROP_PACK_DIRECTION:
268 gtk_menu_bar_set_pack_direction (menubar, g_value_get_enum (value));
270 case PROP_CHILD_PACK_DIRECTION:
271 gtk_menu_bar_set_child_pack_direction (menubar, g_value_get_enum (value));
274 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
280 gtk_menu_bar_get_property (GObject *object,
285 GtkMenuBar *menubar = GTK_MENU_BAR (object);
289 case PROP_PACK_DIRECTION:
290 g_value_set_enum (value, gtk_menu_bar_get_pack_direction (menubar));
292 case PROP_CHILD_PACK_DIRECTION:
293 g_value_set_enum (value, gtk_menu_bar_get_child_pack_direction (menubar));
296 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
302 gtk_menu_bar_size_request (GtkWidget *widget,
303 GtkRequisition *requisition)
305 GtkMenuBar *menu_bar;
306 GtkMenuBarPrivate *priv;
307 GtkMenuShell *menu_shell;
311 GtkRequisition child_requisition;
314 g_return_if_fail (GTK_IS_MENU_BAR (widget));
315 g_return_if_fail (requisition != NULL);
317 requisition->width = 0;
318 requisition->height = 0;
320 if (GTK_WIDGET_VISIBLE (widget))
322 menu_bar = GTK_MENU_BAR (widget);
323 menu_shell = GTK_MENU_SHELL (widget);
324 priv = GTK_MENU_BAR_GET_PRIVATE (menu_bar);
327 children = menu_shell->children;
331 child = children->data;
332 children = children->next;
334 if (GTK_WIDGET_VISIBLE (child))
338 GTK_MENU_ITEM (child)->show_submenu_indicator = FALSE;
339 gtk_widget_size_request (child, &child_requisition);
340 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
343 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
344 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
345 child_requisition.width += toggle_size;
347 child_requisition.height += toggle_size;
349 if (priv->pack_direction == GTK_PACK_DIRECTION_LTR ||
350 priv->pack_direction == GTK_PACK_DIRECTION_RTL)
352 requisition->width += child_requisition.width;
353 requisition->height = MAX (requisition->height, child_requisition.height);
357 requisition->width = MAX (requisition->width, child_requisition.width);
358 requisition->height += child_requisition.height;
364 gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL);
366 requisition->width += (GTK_CONTAINER (menu_bar)->border_width +
369 requisition->height += (GTK_CONTAINER (menu_bar)->border_width +
373 if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE)
375 requisition->width += widget->style->xthickness * 2;
376 requisition->height += widget->style->ythickness * 2;
382 gtk_menu_bar_size_allocate (GtkWidget *widget,
383 GtkAllocation *allocation)
385 GtkMenuBar *menu_bar;
386 GtkMenuShell *menu_shell;
387 GtkMenuBarPrivate *priv;
390 GtkAllocation child_allocation;
391 GtkRequisition child_requisition;
393 GtkTextDirection direction;
397 g_return_if_fail (GTK_IS_MENU_BAR (widget));
398 g_return_if_fail (allocation != NULL);
400 menu_bar = GTK_MENU_BAR (widget);
401 menu_shell = GTK_MENU_SHELL (widget);
402 priv = GTK_MENU_BAR_GET_PRIVATE (menu_bar);
404 direction = gtk_widget_get_direction (widget);
406 widget->allocation = *allocation;
407 if (GTK_WIDGET_REALIZED (widget))
408 gdk_window_move_resize (widget->window,
409 allocation->x, allocation->y,
410 allocation->width, allocation->height);
412 gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL);
414 if (menu_shell->children)
416 child_allocation.x = (GTK_CONTAINER (menu_bar)->border_width +
419 child_allocation.y = (GTK_CONTAINER (menu_bar)->border_width +
422 if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE)
424 child_allocation.x += widget->style->xthickness;
425 child_allocation.y += widget->style->ythickness;
428 if (priv->pack_direction == GTK_PACK_DIRECTION_LTR ||
429 priv->pack_direction == GTK_PACK_DIRECTION_RTL)
431 child_allocation.height = MAX (1, (gint)allocation->height - child_allocation.y * 2);
433 offset = child_allocation.x; /* Window edge to menubar start */
434 ltr_x = child_allocation.x;
436 children = menu_shell->children;
441 child = children->data;
442 children = children->next;
444 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
446 gtk_widget_get_child_requisition (child, &child_requisition);
448 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
449 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
450 child_requisition.width += toggle_size;
452 child_requisition.height += toggle_size;
454 /* Support for the right justified help menu */
455 if ((children == NULL) && (GTK_IS_MENU_ITEM(child))
456 && (GTK_MENU_ITEM(child)->right_justify))
458 ltr_x = allocation->width -
459 child_requisition.width - offset;
461 if (GTK_WIDGET_VISIBLE (child))
463 if ((direction == GTK_TEXT_DIR_LTR) == (priv->pack_direction == GTK_PACK_DIRECTION_LTR))
464 child_allocation.x = ltr_x;
466 child_allocation.x = allocation->width -
467 child_requisition.width - ltr_x;
469 child_allocation.width = child_requisition.width;
471 gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (child),
473 gtk_widget_size_allocate (child, &child_allocation);
475 ltr_x += child_allocation.width;
481 child_allocation.width = MAX (1, (gint)allocation->width - child_allocation.x * 2);
483 offset = child_allocation.y; /* Window edge to menubar start */
484 ltr_y = child_allocation.y;
486 children = menu_shell->children;
491 child = children->data;
492 children = children->next;
494 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
496 gtk_widget_get_child_requisition (child, &child_requisition);
498 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
499 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
500 child_requisition.width += toggle_size;
502 child_requisition.height += toggle_size;
504 /* Support for the right justified help menu */
505 if ((children == NULL) && (GTK_IS_MENU_ITEM(child))
506 && (GTK_MENU_ITEM(child)->right_justify))
508 ltr_y = allocation->height -
509 child_requisition.height - offset;
511 if (GTK_WIDGET_VISIBLE (child))
513 if ((direction == GTK_TEXT_DIR_LTR) ==
514 (priv->pack_direction == GTK_PACK_DIRECTION_TTB))
515 child_allocation.y = ltr_y;
517 child_allocation.y = allocation->height -
518 child_requisition.height - ltr_y;
519 child_allocation.height = child_requisition.height;
521 gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (child),
523 gtk_widget_size_allocate (child, &child_allocation);
525 ltr_y += child_allocation.height;
533 gtk_menu_bar_paint (GtkWidget *widget, GdkRectangle *area)
535 g_return_if_fail (GTK_IS_MENU_BAR (widget));
537 if (GTK_WIDGET_DRAWABLE (widget))
541 border = GTK_CONTAINER (widget)->border_width;
543 gtk_paint_box (widget->style,
545 GTK_WIDGET_STATE (widget),
546 get_shadow_type (GTK_MENU_BAR (widget)),
547 area, widget, "menubar",
549 widget->allocation.width - border * 2,
550 widget->allocation.height - border * 2);
555 gtk_menu_bar_expose (GtkWidget *widget,
556 GdkEventExpose *event)
558 g_return_val_if_fail (GTK_IS_MENU_BAR (widget), FALSE);
559 g_return_val_if_fail (event != NULL, FALSE);
561 if (GTK_WIDGET_DRAWABLE (widget))
563 gtk_menu_bar_paint (widget, &event->area);
565 (* GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event);
572 get_menu_bars (GtkWindow *window)
574 return g_object_get_data (G_OBJECT (window), "gtk-menu-bar-list");
578 get_viewable_menu_bars (GtkWindow *window)
581 GList *viewable_menu_bars = NULL;
583 for (menu_bars = get_menu_bars (window);
585 menu_bars = menu_bars->next)
587 GtkWidget *widget = menu_bars->data;
588 gboolean viewable = TRUE;
592 if (!GTK_WIDGET_MAPPED (widget))
595 widget = widget->parent;
599 viewable_menu_bars = g_list_prepend (viewable_menu_bars, menu_bars->data);
602 return g_list_reverse (viewable_menu_bars);
606 set_menu_bars (GtkWindow *window,
609 g_object_set_data (G_OBJECT (window), I_("gtk-menu-bar-list"), menubars);
613 window_key_press_handler (GtkWidget *widget,
618 gboolean retval = FALSE;
620 g_object_get (gtk_widget_get_settings (widget),
621 "gtk-menu-bar-accel",
628 GdkModifierType mods = 0;
630 gtk_accelerator_parse (accel, &keyval, &mods);
633 g_warning ("Failed to parse menu bar accelerator '%s'\n", accel);
635 /* FIXME this is wrong, needs to be in the global accel resolution
636 * thing, to properly consider i18n etc., but that probably requires
637 * AccelGroup changes etc.
639 if (event->keyval == keyval &&
640 ((event->state & gtk_accelerator_get_default_mod_mask ()) ==
641 (mods & gtk_accelerator_get_default_mod_mask ())))
643 GList *tmp_menubars = get_viewable_menu_bars (GTK_WINDOW (widget));
646 menubars = _gtk_container_focus_sort (GTK_CONTAINER (widget), tmp_menubars,
647 GTK_DIR_TAB_FORWARD, NULL);
648 g_list_free (tmp_menubars);
652 GtkMenuShell *menu_shell = GTK_MENU_SHELL (menubars->data);
654 _gtk_menu_shell_activate (menu_shell);
655 gtk_menu_shell_select_first (menu_shell, FALSE);
657 g_list_free (menubars);
670 add_to_window (GtkWindow *window,
673 GList *menubars = get_menu_bars (window);
677 g_signal_connect (window,
679 G_CALLBACK (window_key_press_handler),
683 set_menu_bars (window, g_list_prepend (menubars, menubar));
687 remove_from_window (GtkWindow *window,
690 GList *menubars = get_menu_bars (window);
692 menubars = g_object_get_data (G_OBJECT (window),
693 "gtk-menu-bar-list");
695 menubars = g_list_remove (menubars, menubar);
699 g_signal_handlers_disconnect_by_func (window,
700 window_key_press_handler,
704 set_menu_bars (window, menubars);
708 gtk_menu_bar_hierarchy_changed (GtkWidget *widget,
709 GtkWidget *old_toplevel)
714 menubar = GTK_MENU_BAR (widget);
716 toplevel = gtk_widget_get_toplevel (widget);
719 remove_from_window (GTK_WINDOW (old_toplevel), menubar);
721 if (GTK_WIDGET_TOPLEVEL (toplevel))
722 add_to_window (GTK_WINDOW (toplevel), menubar);
726 * _gtk_menu_bar_cycle_focus:
727 * @menubar: a #GtkMenuBar
728 * @dir: direction in which to cycle the focus
730 * Move the focus between menubars in the toplevel.
733 _gtk_menu_bar_cycle_focus (GtkMenuBar *menubar,
734 GtkDirectionType dir)
736 GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (menubar));
737 GtkMenuItem *to_activate = NULL;
739 if (GTK_WIDGET_TOPLEVEL (toplevel))
741 GList *tmp_menubars = get_viewable_menu_bars (GTK_WINDOW (toplevel));
745 menubars = _gtk_container_focus_sort (GTK_CONTAINER (toplevel), tmp_menubars,
746 dir, GTK_WIDGET (menubar));
747 g_list_free (tmp_menubars);
751 current = g_list_find (menubars, menubar);
753 if (current && current->next)
755 GtkMenuShell *new_menushell = GTK_MENU_SHELL (current->next->data);
756 if (new_menushell->children)
757 to_activate = new_menushell->children->data;
761 g_list_free (menubars);
764 gtk_menu_shell_cancel (GTK_MENU_SHELL (menubar));
767 g_signal_emit_by_name (to_activate, "activate_item");
771 get_shadow_type (GtkMenuBar *menubar)
773 GtkShadowType shadow_type = GTK_SHADOW_OUT;
775 gtk_widget_style_get (GTK_WIDGET (menubar),
776 "shadow-type", &shadow_type,
783 gtk_menu_bar_get_popup_delay (GtkMenuShell *menu_shell)
787 g_object_get (gtk_widget_get_settings (GTK_WIDGET (menu_shell)),
788 "gtk-menu-bar-popup-delay", &popup_delay,
795 gtk_menu_bar_move_current (GtkMenuShell *menu_shell,
796 GtkMenuDirectionType direction)
798 GtkMenuBar *menubar = GTK_MENU_BAR (menu_shell);
799 GtkTextDirection text_dir;
800 GtkPackDirection pack_dir;
802 text_dir = gtk_widget_get_direction (GTK_WIDGET (menubar));
803 pack_dir = gtk_menu_bar_get_pack_direction (menubar);
805 if (pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL)
807 if ((text_dir == GTK_TEXT_DIR_RTL) == (pack_dir == GTK_PACK_DIRECTION_LTR))
811 case GTK_MENU_DIR_PREV:
812 direction = GTK_MENU_DIR_NEXT;
814 case GTK_MENU_DIR_NEXT:
815 direction = GTK_MENU_DIR_PREV;
825 case GTK_MENU_DIR_PARENT:
826 if ((text_dir == GTK_TEXT_DIR_LTR) == (pack_dir == GTK_PACK_DIRECTION_TTB))
827 direction = GTK_MENU_DIR_PREV;
829 direction = GTK_MENU_DIR_NEXT;
831 case GTK_MENU_DIR_CHILD:
832 if ((text_dir == GTK_TEXT_DIR_LTR) == (pack_dir == GTK_PACK_DIRECTION_TTB))
833 direction = GTK_MENU_DIR_NEXT;
835 direction = GTK_MENU_DIR_PREV;
837 case GTK_MENU_DIR_PREV:
838 if (text_dir == GTK_TEXT_DIR_RTL)
839 direction = GTK_MENU_DIR_CHILD;
841 direction = GTK_MENU_DIR_PARENT;
843 case GTK_MENU_DIR_NEXT:
844 if (text_dir == GTK_TEXT_DIR_RTL)
845 direction = GTK_MENU_DIR_PARENT;
847 direction = GTK_MENU_DIR_CHILD;
853 GTK_MENU_SHELL_CLASS (parent_class)->move_current (menu_shell, direction);
857 * gtk_menu_bar_get_pack_direction:
858 * @menubar: a #GtkMenuBar
860 * Retrieves the current pack direction of the menubar. See
861 * gtk_menu_bar_set_pack_direction().
863 * Return value: the pack direction
868 gtk_menu_bar_get_pack_direction (GtkMenuBar *menubar)
870 GtkMenuBarPrivate *priv;
872 g_return_val_if_fail (GTK_IS_MENU_BAR (menubar),
873 GTK_PACK_DIRECTION_LTR);
875 priv = GTK_MENU_BAR_GET_PRIVATE (menubar);
877 return priv->pack_direction;
881 * gtk_menu_bar_set_pack_direction:
882 * @menubar: a #GtkMenuBar.
883 * @pack_dir: a new #GtkPackDirection.
885 * Sets how items should be packed inside a menubar.
889 void gtk_menu_bar_set_pack_direction (GtkMenuBar *menubar,
890 GtkPackDirection pack_dir)
892 GtkMenuBarPrivate *priv;
895 g_return_if_fail (GTK_IS_MENU_BAR (menubar));
897 priv = GTK_MENU_BAR_GET_PRIVATE (menubar);
899 if (priv->pack_direction != pack_dir)
901 priv->pack_direction = pack_dir;
903 gtk_widget_queue_resize (GTK_WIDGET (menubar));
905 for (l = GTK_MENU_SHELL (menubar)->children; l; l = l->next)
906 gtk_widget_queue_resize (GTK_WIDGET (l->data));
908 g_object_notify (G_OBJECT (menubar), "pack-direction");
913 * gtk_menu_bar_get_child_pack_direction:
914 * @menubar: a #GtkMenuBar
916 * Retrieves the current child pack direction of the menubar. See
917 * gtk_menu_bar_set_child_pack_direction().
919 * Return value: the child pack direction
924 gtk_menu_bar_get_child_pack_direction (GtkMenuBar *menubar)
926 GtkMenuBarPrivate *priv;
928 g_return_val_if_fail (GTK_IS_MENU_BAR (menubar),
929 GTK_PACK_DIRECTION_LTR);
931 priv = GTK_MENU_BAR_GET_PRIVATE (menubar);
933 return priv->child_pack_direction;
937 * gtk_menu_bar_set_child_pack_direction:
938 * @menubar: a #GtkMenuBar.
939 * @child_pack_dir: a new #GtkPackDirection.
941 * Sets how widgets should be packed inside the children of a menubar.
945 void gtk_menu_bar_set_child_pack_direction (GtkMenuBar *menubar,
946 GtkPackDirection child_pack_dir)
948 GtkMenuBarPrivate *priv;
951 g_return_if_fail (GTK_IS_MENU_BAR (menubar));
953 priv = GTK_MENU_BAR_GET_PRIVATE (menubar);
955 if (priv->child_pack_direction != child_pack_dir)
957 priv->child_pack_direction = child_pack_dir;
959 gtk_widget_queue_resize (GTK_WIDGET (menubar));
961 for (l = GTK_MENU_SHELL (menubar)->children; l; l = l->next)
962 gtk_widget_queue_resize (GTK_WIDGET (l->data));
964 g_object_notify (G_OBJECT (menubar), "child-pack-direction");
968 #define __GTK_MENU_BAR_C__
969 #include "gtkaliasdef.c"