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, g_intern_static_string ("GtkMenuBar"),
116 return menu_bar_type;
120 gtk_menu_bar_class_init (GtkMenuBarClass *class)
122 GObjectClass *gobject_class;
123 GtkObjectClass *object_class;
124 GtkWidgetClass *widget_class;
125 GtkMenuShellClass *menu_shell_class;
127 GtkBindingSet *binding_set;
129 parent_class = g_type_class_peek_parent (class);
131 gobject_class = (GObjectClass*) class;
132 object_class = (GtkObjectClass*) class;
133 widget_class = (GtkWidgetClass*) class;
134 menu_shell_class = (GtkMenuShellClass*) class;
136 gobject_class->get_property = gtk_menu_bar_get_property;
137 gobject_class->set_property = gtk_menu_bar_set_property;
139 widget_class->size_request = gtk_menu_bar_size_request;
140 widget_class->size_allocate = gtk_menu_bar_size_allocate;
141 widget_class->expose_event = gtk_menu_bar_expose;
142 widget_class->hierarchy_changed = gtk_menu_bar_hierarchy_changed;
144 menu_shell_class->submenu_placement = GTK_TOP_BOTTOM;
145 menu_shell_class->get_popup_delay = gtk_menu_bar_get_popup_delay;
146 menu_shell_class->move_current = gtk_menu_bar_move_current;
148 binding_set = gtk_binding_set_by_class (class);
149 gtk_binding_entry_add_signal (binding_set,
152 GTK_TYPE_MENU_DIRECTION_TYPE,
154 gtk_binding_entry_add_signal (binding_set,
157 GTK_TYPE_MENU_DIRECTION_TYPE,
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,
169 gtk_binding_entry_add_signal (binding_set,
172 GTK_TYPE_MENU_DIRECTION_TYPE,
173 GTK_MENU_DIR_PARENT);
174 gtk_binding_entry_add_signal (binding_set,
177 GTK_TYPE_MENU_DIRECTION_TYPE,
178 GTK_MENU_DIR_PARENT);
179 gtk_binding_entry_add_signal (binding_set,
182 GTK_TYPE_MENU_DIRECTION_TYPE,
184 gtk_binding_entry_add_signal (binding_set,
187 GTK_TYPE_MENU_DIRECTION_TYPE,
191 * GtkMenuBar:pack-direction:
193 * The pack direction of the menubar. It determines how
194 * menuitems are arranged in the menubar.
198 g_object_class_install_property (gobject_class,
200 g_param_spec_enum ("pack-direction",
201 P_("Pack direction"),
202 P_("The pack direction of the menubar"),
203 GTK_TYPE_PACK_DIRECTION,
204 GTK_PACK_DIRECTION_LTR,
205 GTK_PARAM_READWRITE));
208 * GtkMenuBar:child-pack-direction:
210 * The pack direction of the menubar. It determines how
211 * the widgets contained in child menuitems are arranged.
215 g_object_class_install_property (gobject_class,
216 PROP_CHILD_PACK_DIRECTION,
217 g_param_spec_enum ("child-pack-direction",
218 P_("Child Pack direction"),
219 P_("The child pack direction of the menubar"),
220 GTK_TYPE_PACK_DIRECTION,
221 GTK_PACK_DIRECTION_LTR,
222 GTK_PARAM_READWRITE));
225 gtk_widget_class_install_style_property (widget_class,
226 g_param_spec_enum ("shadow-type",
228 P_("Style of bevel around the menubar"),
229 GTK_TYPE_SHADOW_TYPE,
231 GTK_PARAM_READABLE));
233 gtk_widget_class_install_style_property (widget_class,
234 g_param_spec_int ("internal-padding",
235 P_("Internal padding"),
236 P_("Amount of border space between the menubar shadow and the menu items"),
240 GTK_PARAM_READABLE));
242 gtk_settings_install_property (g_param_spec_int ("gtk-menu-bar-popup-delay",
243 P_("Delay before drop down menus appear"),
244 P_("Delay before the submenus of a menu bar appear"),
248 GTK_PARAM_READWRITE));
250 g_type_class_add_private (gobject_class, sizeof (GtkMenuBarPrivate));
254 gtk_menu_bar_new (void)
256 return g_object_new (GTK_TYPE_MENU_BAR, NULL);
260 gtk_menu_bar_set_property (GObject *object,
265 GtkMenuBar *menubar = GTK_MENU_BAR (object);
269 case PROP_PACK_DIRECTION:
270 gtk_menu_bar_set_pack_direction (menubar, g_value_get_enum (value));
272 case PROP_CHILD_PACK_DIRECTION:
273 gtk_menu_bar_set_child_pack_direction (menubar, g_value_get_enum (value));
276 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
282 gtk_menu_bar_get_property (GObject *object,
287 GtkMenuBar *menubar = GTK_MENU_BAR (object);
291 case PROP_PACK_DIRECTION:
292 g_value_set_enum (value, gtk_menu_bar_get_pack_direction (menubar));
294 case PROP_CHILD_PACK_DIRECTION:
295 g_value_set_enum (value, gtk_menu_bar_get_child_pack_direction (menubar));
298 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
304 gtk_menu_bar_size_request (GtkWidget *widget,
305 GtkRequisition *requisition)
307 GtkMenuBar *menu_bar;
308 GtkMenuBarPrivate *priv;
309 GtkMenuShell *menu_shell;
313 GtkRequisition child_requisition;
316 g_return_if_fail (GTK_IS_MENU_BAR (widget));
317 g_return_if_fail (requisition != NULL);
319 requisition->width = 0;
320 requisition->height = 0;
322 if (GTK_WIDGET_VISIBLE (widget))
324 menu_bar = GTK_MENU_BAR (widget);
325 menu_shell = GTK_MENU_SHELL (widget);
326 priv = GTK_MENU_BAR_GET_PRIVATE (menu_bar);
329 children = menu_shell->children;
333 child = children->data;
334 children = children->next;
336 if (GTK_WIDGET_VISIBLE (child))
340 GTK_MENU_ITEM (child)->show_submenu_indicator = FALSE;
341 gtk_widget_size_request (child, &child_requisition);
342 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
345 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
346 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
347 child_requisition.width += toggle_size;
349 child_requisition.height += toggle_size;
351 if (priv->pack_direction == GTK_PACK_DIRECTION_LTR ||
352 priv->pack_direction == GTK_PACK_DIRECTION_RTL)
354 requisition->width += child_requisition.width;
355 requisition->height = MAX (requisition->height, child_requisition.height);
359 requisition->width = MAX (requisition->width, child_requisition.width);
360 requisition->height += child_requisition.height;
366 gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL);
368 requisition->width += (GTK_CONTAINER (menu_bar)->border_width +
371 requisition->height += (GTK_CONTAINER (menu_bar)->border_width +
375 if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE)
377 requisition->width += widget->style->xthickness * 2;
378 requisition->height += widget->style->ythickness * 2;
384 gtk_menu_bar_size_allocate (GtkWidget *widget,
385 GtkAllocation *allocation)
387 GtkMenuBar *menu_bar;
388 GtkMenuShell *menu_shell;
389 GtkMenuBarPrivate *priv;
392 GtkAllocation child_allocation;
393 GtkRequisition child_requisition;
395 GtkTextDirection direction;
399 g_return_if_fail (GTK_IS_MENU_BAR (widget));
400 g_return_if_fail (allocation != NULL);
402 menu_bar = GTK_MENU_BAR (widget);
403 menu_shell = GTK_MENU_SHELL (widget);
404 priv = GTK_MENU_BAR_GET_PRIVATE (menu_bar);
406 direction = gtk_widget_get_direction (widget);
408 widget->allocation = *allocation;
409 if (GTK_WIDGET_REALIZED (widget))
410 gdk_window_move_resize (widget->window,
411 allocation->x, allocation->y,
412 allocation->width, allocation->height);
414 gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL);
416 if (menu_shell->children)
418 child_allocation.x = (GTK_CONTAINER (menu_bar)->border_width +
421 child_allocation.y = (GTK_CONTAINER (menu_bar)->border_width +
424 if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE)
426 child_allocation.x += widget->style->xthickness;
427 child_allocation.y += widget->style->ythickness;
430 if (priv->pack_direction == GTK_PACK_DIRECTION_LTR ||
431 priv->pack_direction == GTK_PACK_DIRECTION_RTL)
433 child_allocation.height = MAX (1, (gint)allocation->height - child_allocation.y * 2);
435 offset = child_allocation.x; /* Window edge to menubar start */
436 ltr_x = child_allocation.x;
438 children = menu_shell->children;
443 child = children->data;
444 children = children->next;
446 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
448 gtk_widget_get_child_requisition (child, &child_requisition);
450 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
451 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
452 child_requisition.width += toggle_size;
454 child_requisition.height += toggle_size;
456 /* Support for the right justified help menu */
457 if ((children == NULL) && (GTK_IS_MENU_ITEM(child))
458 && (GTK_MENU_ITEM(child)->right_justify))
460 ltr_x = allocation->width -
461 child_requisition.width - offset;
463 if (GTK_WIDGET_VISIBLE (child))
465 if ((direction == GTK_TEXT_DIR_LTR) == (priv->pack_direction == GTK_PACK_DIRECTION_LTR))
466 child_allocation.x = ltr_x;
468 child_allocation.x = allocation->width -
469 child_requisition.width - ltr_x;
471 child_allocation.width = child_requisition.width;
473 gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (child),
475 gtk_widget_size_allocate (child, &child_allocation);
477 ltr_x += child_allocation.width;
483 child_allocation.width = MAX (1, (gint)allocation->width - child_allocation.x * 2);
485 offset = child_allocation.y; /* Window edge to menubar start */
486 ltr_y = child_allocation.y;
488 children = menu_shell->children;
493 child = children->data;
494 children = children->next;
496 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
498 gtk_widget_get_child_requisition (child, &child_requisition);
500 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
501 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
502 child_requisition.width += toggle_size;
504 child_requisition.height += toggle_size;
506 /* Support for the right justified help menu */
507 if ((children == NULL) && (GTK_IS_MENU_ITEM(child))
508 && (GTK_MENU_ITEM(child)->right_justify))
510 ltr_y = allocation->height -
511 child_requisition.height - offset;
513 if (GTK_WIDGET_VISIBLE (child))
515 if ((direction == GTK_TEXT_DIR_LTR) ==
516 (priv->pack_direction == GTK_PACK_DIRECTION_TTB))
517 child_allocation.y = ltr_y;
519 child_allocation.y = allocation->height -
520 child_requisition.height - ltr_y;
521 child_allocation.height = child_requisition.height;
523 gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (child),
525 gtk_widget_size_allocate (child, &child_allocation);
527 ltr_y += child_allocation.height;
535 gtk_menu_bar_paint (GtkWidget *widget, GdkRectangle *area)
537 g_return_if_fail (GTK_IS_MENU_BAR (widget));
539 if (GTK_WIDGET_DRAWABLE (widget))
543 border = GTK_CONTAINER (widget)->border_width;
545 gtk_paint_box (widget->style,
547 GTK_WIDGET_STATE (widget),
548 get_shadow_type (GTK_MENU_BAR (widget)),
549 area, widget, "menubar",
551 widget->allocation.width - border * 2,
552 widget->allocation.height - border * 2);
557 gtk_menu_bar_expose (GtkWidget *widget,
558 GdkEventExpose *event)
560 g_return_val_if_fail (GTK_IS_MENU_BAR (widget), FALSE);
561 g_return_val_if_fail (event != NULL, FALSE);
563 if (GTK_WIDGET_DRAWABLE (widget))
565 gtk_menu_bar_paint (widget, &event->area);
567 (* GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event);
574 get_menu_bars (GtkWindow *window)
576 return g_object_get_data (G_OBJECT (window), "gtk-menu-bar-list");
580 get_viewable_menu_bars (GtkWindow *window)
583 GList *viewable_menu_bars = NULL;
585 for (menu_bars = get_menu_bars (window);
587 menu_bars = menu_bars->next)
589 GtkWidget *widget = menu_bars->data;
590 gboolean viewable = TRUE;
594 if (!GTK_WIDGET_MAPPED (widget))
597 widget = widget->parent;
601 viewable_menu_bars = g_list_prepend (viewable_menu_bars, menu_bars->data);
604 return g_list_reverse (viewable_menu_bars);
608 set_menu_bars (GtkWindow *window,
611 g_object_set_data (G_OBJECT (window), g_intern_static_string ("gtk-menu-bar-list"), menubars);
615 window_key_press_handler (GtkWidget *widget,
620 gboolean retval = FALSE;
622 g_object_get (gtk_widget_get_settings (widget),
623 "gtk-menu-bar-accel",
630 GdkModifierType mods = 0;
632 gtk_accelerator_parse (accel, &keyval, &mods);
635 g_warning ("Failed to parse menu bar accelerator '%s'\n", accel);
637 /* FIXME this is wrong, needs to be in the global accel resolution
638 * thing, to properly consider i18n etc., but that probably requires
639 * AccelGroup changes etc.
641 if (event->keyval == keyval &&
642 ((event->state & gtk_accelerator_get_default_mod_mask ()) ==
643 (mods & gtk_accelerator_get_default_mod_mask ())))
645 GList *tmp_menubars = get_viewable_menu_bars (GTK_WINDOW (widget));
648 menubars = _gtk_container_focus_sort (GTK_CONTAINER (widget), tmp_menubars,
649 GTK_DIR_TAB_FORWARD, NULL);
650 g_list_free (tmp_menubars);
654 GtkMenuShell *menu_shell = GTK_MENU_SHELL (menubars->data);
656 _gtk_menu_shell_activate (menu_shell);
657 gtk_menu_shell_select_first (menu_shell, FALSE);
659 g_list_free (menubars);
672 add_to_window (GtkWindow *window,
675 GList *menubars = get_menu_bars (window);
679 g_signal_connect (window,
681 G_CALLBACK (window_key_press_handler),
685 set_menu_bars (window, g_list_prepend (menubars, menubar));
689 remove_from_window (GtkWindow *window,
692 GList *menubars = get_menu_bars (window);
694 menubars = g_object_get_data (G_OBJECT (window),
695 "gtk-menu-bar-list");
697 menubars = g_list_remove (menubars, menubar);
701 g_signal_handlers_disconnect_by_func (window,
702 window_key_press_handler,
706 set_menu_bars (window, menubars);
710 gtk_menu_bar_hierarchy_changed (GtkWidget *widget,
711 GtkWidget *old_toplevel)
716 menubar = GTK_MENU_BAR (widget);
718 toplevel = gtk_widget_get_toplevel (widget);
721 remove_from_window (GTK_WINDOW (old_toplevel), menubar);
723 if (GTK_WIDGET_TOPLEVEL (toplevel))
724 add_to_window (GTK_WINDOW (toplevel), menubar);
728 * _gtk_menu_bar_cycle_focus:
729 * @menubar: a #GtkMenuBar
730 * @dir: direction in which to cycle the focus
732 * Move the focus between menubars in the toplevel.
735 _gtk_menu_bar_cycle_focus (GtkMenuBar *menubar,
736 GtkDirectionType dir)
738 GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (menubar));
739 GtkMenuItem *to_activate = NULL;
741 if (GTK_WIDGET_TOPLEVEL (toplevel))
743 GList *tmp_menubars = get_viewable_menu_bars (GTK_WINDOW (toplevel));
747 menubars = _gtk_container_focus_sort (GTK_CONTAINER (toplevel), tmp_menubars,
748 dir, GTK_WIDGET (menubar));
749 g_list_free (tmp_menubars);
753 current = g_list_find (menubars, menubar);
755 if (current && current->next)
757 GtkMenuShell *new_menushell = GTK_MENU_SHELL (current->next->data);
758 if (new_menushell->children)
759 to_activate = new_menushell->children->data;
763 g_list_free (menubars);
766 gtk_menu_shell_cancel (GTK_MENU_SHELL (menubar));
769 g_signal_emit_by_name (to_activate, "activate_item");
773 get_shadow_type (GtkMenuBar *menubar)
775 GtkShadowType shadow_type = GTK_SHADOW_OUT;
777 gtk_widget_style_get (GTK_WIDGET (menubar),
778 "shadow-type", &shadow_type,
785 gtk_menu_bar_get_popup_delay (GtkMenuShell *menu_shell)
789 g_object_get (gtk_widget_get_settings (GTK_WIDGET (menu_shell)),
790 "gtk-menu-bar-popup-delay", &popup_delay,
797 gtk_menu_bar_move_current (GtkMenuShell *menu_shell,
798 GtkMenuDirectionType direction)
800 GtkMenuBar *menubar = GTK_MENU_BAR (menu_shell);
801 GtkTextDirection text_dir;
802 GtkPackDirection pack_dir;
804 text_dir = gtk_widget_get_direction (GTK_WIDGET (menubar));
805 pack_dir = gtk_menu_bar_get_pack_direction (menubar);
807 if (pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL)
809 if ((text_dir == GTK_TEXT_DIR_RTL) == (pack_dir == GTK_PACK_DIRECTION_LTR))
813 case GTK_MENU_DIR_PREV:
814 direction = GTK_MENU_DIR_NEXT;
816 case GTK_MENU_DIR_NEXT:
817 direction = GTK_MENU_DIR_PREV;
827 case GTK_MENU_DIR_PARENT:
828 if ((text_dir == GTK_TEXT_DIR_LTR) == (pack_dir == GTK_PACK_DIRECTION_TTB))
829 direction = GTK_MENU_DIR_PREV;
831 direction = GTK_MENU_DIR_NEXT;
833 case GTK_MENU_DIR_CHILD:
834 if ((text_dir == GTK_TEXT_DIR_LTR) == (pack_dir == GTK_PACK_DIRECTION_TTB))
835 direction = GTK_MENU_DIR_NEXT;
837 direction = GTK_MENU_DIR_PREV;
839 case GTK_MENU_DIR_PREV:
840 if (text_dir == GTK_TEXT_DIR_RTL)
841 direction = GTK_MENU_DIR_CHILD;
843 direction = GTK_MENU_DIR_PARENT;
845 case GTK_MENU_DIR_NEXT:
846 if (text_dir == GTK_TEXT_DIR_RTL)
847 direction = GTK_MENU_DIR_PARENT;
849 direction = GTK_MENU_DIR_CHILD;
855 GTK_MENU_SHELL_CLASS (parent_class)->move_current (menu_shell, direction);
859 * gtk_menu_bar_get_pack_direction:
860 * @menubar: a #GtkMenuBar
862 * Retrieves the current pack direction of the menubar. See
863 * gtk_menu_bar_set_pack_direction().
865 * Return value: the pack direction
870 gtk_menu_bar_get_pack_direction (GtkMenuBar *menubar)
872 GtkMenuBarPrivate *priv;
874 g_return_val_if_fail (GTK_IS_MENU_BAR (menubar),
875 GTK_PACK_DIRECTION_LTR);
877 priv = GTK_MENU_BAR_GET_PRIVATE (menubar);
879 return priv->pack_direction;
883 * gtk_menu_bar_set_pack_direction:
884 * @menubar: a #GtkMenuBar.
885 * @pack_dir: a new #GtkPackDirection.
887 * Sets how items should be packed inside a menubar.
891 void gtk_menu_bar_set_pack_direction (GtkMenuBar *menubar,
892 GtkPackDirection pack_dir)
894 GtkMenuBarPrivate *priv;
897 g_return_if_fail (GTK_IS_MENU_BAR (menubar));
899 priv = GTK_MENU_BAR_GET_PRIVATE (menubar);
901 if (priv->pack_direction != pack_dir)
903 priv->pack_direction = pack_dir;
905 gtk_widget_queue_resize (GTK_WIDGET (menubar));
907 for (l = GTK_MENU_SHELL (menubar)->children; l; l = l->next)
908 gtk_widget_queue_resize (GTK_WIDGET (l->data));
910 g_object_notify (G_OBJECT (menubar), "pack-direction");
915 * gtk_menu_bar_get_child_pack_direction:
916 * @menubar: a #GtkMenuBar
918 * Retrieves the current child pack direction of the menubar. See
919 * gtk_menu_bar_set_child_pack_direction().
921 * Return value: the child pack direction
926 gtk_menu_bar_get_child_pack_direction (GtkMenuBar *menubar)
928 GtkMenuBarPrivate *priv;
930 g_return_val_if_fail (GTK_IS_MENU_BAR (menubar),
931 GTK_PACK_DIRECTION_LTR);
933 priv = GTK_MENU_BAR_GET_PRIVATE (menubar);
935 return priv->child_pack_direction;
939 * gtk_menu_bar_set_child_pack_direction:
940 * @menubar: a #GtkMenuBar.
941 * @child_pack_dir: a new #GtkPackDirection.
943 * Sets how widgets should be packed inside the children of a menubar.
947 void gtk_menu_bar_set_child_pack_direction (GtkMenuBar *menubar,
948 GtkPackDirection child_pack_dir)
950 GtkMenuBarPrivate *priv;
953 g_return_if_fail (GTK_IS_MENU_BAR (menubar));
955 priv = GTK_MENU_BAR_GET_PRIVATE (menubar);
957 if (priv->child_pack_direction != child_pack_dir)
959 priv->child_pack_direction = child_pack_dir;
961 gtk_widget_queue_resize (GTK_WIDGET (menubar));
963 for (l = GTK_MENU_SHELL (menubar)->children; l; l = l->next)
964 gtk_widget_queue_resize (GTK_WIDGET (l->data));
966 g_object_notify (G_OBJECT (menubar), "child-pack-direction");
970 #define __GTK_MENU_BAR_C__
971 #include "gtkaliasdef.c"