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/.
28 #include "gdk/gdkkeysyms.h"
29 #include "gtkbindings.h"
31 #include "gtkmarshalers.h"
32 #include "gtkmenubar.h"
33 #include "gtkmenuitem.h"
34 #include "gtkmenuprivate.h"
35 #include "gtksettings.h"
37 #include "gtkwindow.h"
38 #include "gtkprivate.h"
40 #define BORDER_SPACING 0
41 #define DEFAULT_IPADDING 1
47 PROP_CHILD_PACK_DIRECTION
50 struct _GtkMenuBarPrivate
52 GtkPackDirection pack_direction;
53 GtkPackDirection child_pack_direction;
57 static void gtk_menu_bar_set_property (GObject *object,
61 static void gtk_menu_bar_get_property (GObject *object,
65 static void gtk_menu_bar_size_request (GtkWidget *widget,
66 GtkRequisition *requisition);
67 static void gtk_menu_bar_size_allocate (GtkWidget *widget,
68 GtkAllocation *allocation);
69 static void gtk_menu_bar_paint (GtkWidget *widget,
71 static gint gtk_menu_bar_expose (GtkWidget *widget,
72 GdkEventExpose *event);
73 static void gtk_menu_bar_hierarchy_changed (GtkWidget *widget,
74 GtkWidget *old_toplevel);
75 static gint gtk_menu_bar_get_popup_delay (GtkMenuShell *menu_shell);
76 static void gtk_menu_bar_move_current (GtkMenuShell *menu_shell,
77 GtkMenuDirectionType direction);
79 static GtkShadowType get_shadow_type (GtkMenuBar *menubar);
81 G_DEFINE_TYPE (GtkMenuBar, gtk_menu_bar, GTK_TYPE_MENU_SHELL)
84 gtk_menu_bar_class_init (GtkMenuBarClass *class)
86 GObjectClass *gobject_class;
87 GtkWidgetClass *widget_class;
88 GtkMenuShellClass *menu_shell_class;
90 GtkBindingSet *binding_set;
92 gobject_class = (GObjectClass*) class;
93 widget_class = (GtkWidgetClass*) class;
94 menu_shell_class = (GtkMenuShellClass*) class;
96 gobject_class->get_property = gtk_menu_bar_get_property;
97 gobject_class->set_property = gtk_menu_bar_set_property;
99 widget_class->size_request = gtk_menu_bar_size_request;
100 widget_class->size_allocate = gtk_menu_bar_size_allocate;
101 widget_class->expose_event = gtk_menu_bar_expose;
102 widget_class->hierarchy_changed = gtk_menu_bar_hierarchy_changed;
104 menu_shell_class->submenu_placement = GTK_TOP_BOTTOM;
105 menu_shell_class->get_popup_delay = gtk_menu_bar_get_popup_delay;
106 menu_shell_class->move_current = gtk_menu_bar_move_current;
108 binding_set = gtk_binding_set_by_class (class);
109 gtk_binding_entry_add_signal (binding_set,
112 GTK_TYPE_MENU_DIRECTION_TYPE,
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,
133 GTK_MENU_DIR_PARENT);
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,
144 gtk_binding_entry_add_signal (binding_set,
147 GTK_TYPE_MENU_DIRECTION_TYPE,
151 * GtkMenuBar:pack-direction:
153 * The pack direction of the menubar. It determines how
154 * menuitems are arranged in the menubar.
158 g_object_class_install_property (gobject_class,
160 g_param_spec_enum ("pack-direction",
161 P_("Pack direction"),
162 P_("The pack direction of the menubar"),
163 GTK_TYPE_PACK_DIRECTION,
164 GTK_PACK_DIRECTION_LTR,
165 GTK_PARAM_READWRITE));
168 * GtkMenuBar:child-pack-direction:
170 * The child pack direction of the menubar. It determines how
171 * the widgets contained in child menuitems are arranged.
175 g_object_class_install_property (gobject_class,
176 PROP_CHILD_PACK_DIRECTION,
177 g_param_spec_enum ("child-pack-direction",
178 P_("Child Pack direction"),
179 P_("The child pack direction of the menubar"),
180 GTK_TYPE_PACK_DIRECTION,
181 GTK_PACK_DIRECTION_LTR,
182 GTK_PARAM_READWRITE));
185 gtk_widget_class_install_style_property (widget_class,
186 g_param_spec_enum ("shadow-type",
188 P_("Style of bevel around the menubar"),
189 GTK_TYPE_SHADOW_TYPE,
191 GTK_PARAM_READABLE));
193 gtk_widget_class_install_style_property (widget_class,
194 g_param_spec_int ("internal-padding",
195 P_("Internal padding"),
196 P_("Amount of border space between the menubar shadow and the menu items"),
200 GTK_PARAM_READABLE));
202 gtk_settings_install_property (g_param_spec_int ("gtk-menu-bar-popup-delay",
203 P_("Delay before drop down menus appear"),
204 P_("Delay before the submenus of a menu bar appear"),
208 GTK_PARAM_READWRITE));
210 g_type_class_add_private (gobject_class, sizeof (GtkMenuBarPrivate));
214 gtk_menu_bar_init (GtkMenuBar *menu_bar)
216 menu_bar->priv = G_TYPE_INSTANCE_GET_PRIVATE (menu_bar,
222 gtk_menu_bar_new (void)
224 return g_object_new (GTK_TYPE_MENU_BAR, NULL);
228 gtk_menu_bar_set_property (GObject *object,
233 GtkMenuBar *menubar = GTK_MENU_BAR (object);
237 case PROP_PACK_DIRECTION:
238 gtk_menu_bar_set_pack_direction (menubar, g_value_get_enum (value));
240 case PROP_CHILD_PACK_DIRECTION:
241 gtk_menu_bar_set_child_pack_direction (menubar, g_value_get_enum (value));
244 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
250 gtk_menu_bar_get_property (GObject *object,
255 GtkMenuBar *menubar = GTK_MENU_BAR (object);
259 case PROP_PACK_DIRECTION:
260 g_value_set_enum (value, gtk_menu_bar_get_pack_direction (menubar));
262 case PROP_CHILD_PACK_DIRECTION:
263 g_value_set_enum (value, gtk_menu_bar_get_child_pack_direction (menubar));
266 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
272 gtk_menu_bar_size_request (GtkWidget *widget,
273 GtkRequisition *requisition)
275 GtkMenuBar *menu_bar;
276 GtkMenuBarPrivate *priv;
277 GtkMenuShell *menu_shell;
281 GtkRequisition child_requisition;
285 g_return_if_fail (GTK_IS_MENU_BAR (widget));
286 g_return_if_fail (requisition != NULL);
288 requisition->width = 0;
289 requisition->height = 0;
291 if (gtk_widget_get_visible (widget))
293 menu_bar = GTK_MENU_BAR (widget);
294 menu_shell = GTK_MENU_SHELL (widget);
295 priv = menu_bar->priv;
298 children = menu_shell->children;
302 child = children->data;
303 children = children->next;
305 if (gtk_widget_get_visible (child))
309 GTK_MENU_ITEM (child)->show_submenu_indicator = FALSE;
310 gtk_widget_size_request (child, &child_requisition);
311 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
314 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
315 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
316 child_requisition.width += toggle_size;
318 child_requisition.height += toggle_size;
320 if (priv->pack_direction == GTK_PACK_DIRECTION_LTR ||
321 priv->pack_direction == GTK_PACK_DIRECTION_RTL)
323 requisition->width += child_requisition.width;
324 requisition->height = MAX (requisition->height, child_requisition.height);
328 requisition->width = MAX (requisition->width, child_requisition.width);
329 requisition->height += child_requisition.height;
335 gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL);
337 border_width = gtk_container_get_border_width (GTK_CONTAINER (menu_bar));
338 requisition->width += (border_width +
341 requisition->height += (border_width +
345 if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE)
349 style = gtk_widget_get_style (widget);
350 requisition->width += style->xthickness * 2;
351 requisition->height += style->ythickness * 2;
357 gtk_menu_bar_size_allocate (GtkWidget *widget,
358 GtkAllocation *allocation)
360 GtkMenuBar *menu_bar;
361 GtkMenuShell *menu_shell;
362 GtkMenuBarPrivate *priv;
365 GtkAllocation child_allocation;
366 GtkRequisition child_requisition;
368 GtkTextDirection direction;
373 g_return_if_fail (GTK_IS_MENU_BAR (widget));
374 g_return_if_fail (allocation != NULL);
376 menu_bar = GTK_MENU_BAR (widget);
377 menu_shell = GTK_MENU_SHELL (widget);
378 priv = menu_bar->priv;
380 direction = gtk_widget_get_direction (widget);
382 gtk_widget_set_allocation (widget, allocation);
384 if (gtk_widget_get_realized (widget))
385 gdk_window_move_resize (gtk_widget_get_window (widget),
386 allocation->x, allocation->y,
387 allocation->width, allocation->height);
389 gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL);
391 if (menu_shell->children)
393 border_width = gtk_container_get_border_width (GTK_CONTAINER (menu_bar));
394 child_allocation.x = (border_width +
397 child_allocation.y = (border_width +
400 if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE)
404 style = gtk_widget_get_style (widget);
405 child_allocation.x += style->xthickness;
406 child_allocation.y += style->ythickness;
409 if (priv->pack_direction == GTK_PACK_DIRECTION_LTR ||
410 priv->pack_direction == GTK_PACK_DIRECTION_RTL)
412 child_allocation.height = MAX (1, (gint)allocation->height - child_allocation.y * 2);
414 offset = child_allocation.x; /* Window edge to menubar start */
415 ltr_x = child_allocation.x;
417 children = menu_shell->children;
422 child = children->data;
423 children = children->next;
425 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
427 gtk_widget_get_child_requisition (child, &child_requisition);
429 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
430 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
431 child_requisition.width += toggle_size;
433 child_requisition.height += toggle_size;
435 /* Support for the right justified help menu */
436 if ((children == NULL) && (GTK_IS_MENU_ITEM(child))
437 && (GTK_MENU_ITEM(child)->right_justify))
439 ltr_x = allocation->width -
440 child_requisition.width - offset;
442 if (gtk_widget_get_visible (child))
444 if ((direction == GTK_TEXT_DIR_LTR) == (priv->pack_direction == GTK_PACK_DIRECTION_LTR))
445 child_allocation.x = ltr_x;
447 child_allocation.x = allocation->width -
448 child_requisition.width - ltr_x;
450 child_allocation.width = child_requisition.width;
452 gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (child),
454 gtk_widget_size_allocate (child, &child_allocation);
456 ltr_x += child_allocation.width;
462 child_allocation.width = MAX (1, (gint)allocation->width - child_allocation.x * 2);
464 offset = child_allocation.y; /* Window edge to menubar start */
465 ltr_y = child_allocation.y;
467 children = menu_shell->children;
472 child = children->data;
473 children = children->next;
475 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
477 gtk_widget_get_child_requisition (child, &child_requisition);
479 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
480 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
481 child_requisition.width += toggle_size;
483 child_requisition.height += toggle_size;
485 /* Support for the right justified help menu */
486 if ((children == NULL) && (GTK_IS_MENU_ITEM(child))
487 && (GTK_MENU_ITEM(child)->right_justify))
489 ltr_y = allocation->height -
490 child_requisition.height - offset;
492 if (gtk_widget_get_visible (child))
494 if ((direction == GTK_TEXT_DIR_LTR) ==
495 (priv->pack_direction == GTK_PACK_DIRECTION_TTB))
496 child_allocation.y = ltr_y;
498 child_allocation.y = allocation->height -
499 child_requisition.height - ltr_y;
500 child_allocation.height = child_requisition.height;
502 gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (child),
504 gtk_widget_size_allocate (child, &child_allocation);
506 ltr_y += child_allocation.height;
514 gtk_menu_bar_paint (GtkWidget *widget,
517 g_return_if_fail (GTK_IS_MENU_BAR (widget));
519 if (gtk_widget_is_drawable (widget))
521 GtkAllocation allocation;
524 border = gtk_container_get_border_width (GTK_CONTAINER (widget));
525 gtk_widget_get_allocation (widget, &allocation);
527 gtk_paint_box (gtk_widget_get_style (widget),
528 gtk_widget_get_window (widget),
529 gtk_widget_get_state (widget),
530 get_shadow_type (GTK_MENU_BAR (widget)),
531 area, widget, "menubar",
533 allocation.width - border * 2,
534 allocation.height - border * 2);
539 gtk_menu_bar_expose (GtkWidget *widget,
540 GdkEventExpose *event)
542 g_return_val_if_fail (GTK_IS_MENU_BAR (widget), FALSE);
543 g_return_val_if_fail (event != NULL, FALSE);
545 if (gtk_widget_is_drawable (widget))
547 gtk_menu_bar_paint (widget, &event->area);
549 GTK_WIDGET_CLASS (gtk_menu_bar_parent_class)->expose_event (widget, event);
556 get_menu_bars (GtkWindow *window)
558 return g_object_get_data (G_OBJECT (window), "gtk-menu-bar-list");
562 get_viewable_menu_bars (GtkWindow *window)
565 GList *viewable_menu_bars = NULL;
567 for (menu_bars = get_menu_bars (window);
569 menu_bars = menu_bars->next)
571 GtkWidget *widget = menu_bars->data;
572 gboolean viewable = TRUE;
576 if (!gtk_widget_get_mapped (widget))
579 widget = gtk_widget_get_parent (widget);
583 viewable_menu_bars = g_list_prepend (viewable_menu_bars, menu_bars->data);
586 return g_list_reverse (viewable_menu_bars);
590 set_menu_bars (GtkWindow *window,
593 g_object_set_data (G_OBJECT (window), I_("gtk-menu-bar-list"), menubars);
597 window_key_press_handler (GtkWidget *widget,
602 gboolean retval = FALSE;
604 g_object_get (gtk_widget_get_settings (widget),
605 "gtk-menu-bar-accel", &accel,
611 GdkModifierType mods = 0;
613 gtk_accelerator_parse (accel, &keyval, &mods);
616 g_warning ("Failed to parse menu bar accelerator '%s'\n", accel);
618 /* FIXME this is wrong, needs to be in the global accel resolution
619 * thing, to properly consider i18n etc., but that probably requires
620 * AccelGroup changes etc.
622 if (event->keyval == keyval &&
623 ((event->state & gtk_accelerator_get_default_mod_mask ()) ==
624 (mods & gtk_accelerator_get_default_mod_mask ())))
626 GList *tmp_menubars = get_viewable_menu_bars (GTK_WINDOW (widget));
629 menubars = _gtk_container_focus_sort (GTK_CONTAINER (widget), tmp_menubars,
630 GTK_DIR_TAB_FORWARD, NULL);
631 g_list_free (tmp_menubars);
635 GtkMenuShell *menu_shell = GTK_MENU_SHELL (menubars->data);
637 _gtk_menu_shell_set_keyboard_mode (menu_shell, TRUE);
638 _gtk_menu_shell_activate (menu_shell);
639 gtk_menu_shell_select_first (menu_shell, FALSE);
641 g_list_free (menubars);
654 add_to_window (GtkWindow *window,
657 GList *menubars = get_menu_bars (window);
661 g_signal_connect (window,
663 G_CALLBACK (window_key_press_handler),
667 set_menu_bars (window, g_list_prepend (menubars, menubar));
671 remove_from_window (GtkWindow *window,
674 GList *menubars = get_menu_bars (window);
676 menubars = g_list_remove (menubars, menubar);
680 g_signal_handlers_disconnect_by_func (window,
681 window_key_press_handler,
685 set_menu_bars (window, menubars);
689 gtk_menu_bar_hierarchy_changed (GtkWidget *widget,
690 GtkWidget *old_toplevel)
695 menubar = GTK_MENU_BAR (widget);
697 toplevel = gtk_widget_get_toplevel (widget);
700 remove_from_window (GTK_WINDOW (old_toplevel), menubar);
702 if (gtk_widget_is_toplevel (toplevel))
703 add_to_window (GTK_WINDOW (toplevel), menubar);
707 * _gtk_menu_bar_cycle_focus:
708 * @menubar: a #GtkMenuBar
709 * @dir: direction in which to cycle the focus
711 * Move the focus between menubars in the toplevel.
714 _gtk_menu_bar_cycle_focus (GtkMenuBar *menubar,
715 GtkDirectionType dir)
717 GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (menubar));
718 GtkMenuItem *to_activate = NULL;
720 if (gtk_widget_is_toplevel (toplevel))
722 GList *tmp_menubars = get_viewable_menu_bars (GTK_WINDOW (toplevel));
726 menubars = _gtk_container_focus_sort (GTK_CONTAINER (toplevel), tmp_menubars,
727 dir, GTK_WIDGET (menubar));
728 g_list_free (tmp_menubars);
732 current = g_list_find (menubars, menubar);
734 if (current && current->next)
736 GtkMenuShell *new_menushell = GTK_MENU_SHELL (current->next->data);
737 if (new_menushell->children)
738 to_activate = new_menushell->children->data;
742 g_list_free (menubars);
745 gtk_menu_shell_cancel (GTK_MENU_SHELL (menubar));
748 g_signal_emit_by_name (to_activate, "activate_item");
752 get_shadow_type (GtkMenuBar *menubar)
754 GtkShadowType shadow_type = GTK_SHADOW_OUT;
756 gtk_widget_style_get (GTK_WIDGET (menubar),
757 "shadow-type", &shadow_type,
764 gtk_menu_bar_get_popup_delay (GtkMenuShell *menu_shell)
768 g_object_get (gtk_widget_get_settings (GTK_WIDGET (menu_shell)),
769 "gtk-menu-bar-popup-delay", &popup_delay,
776 gtk_menu_bar_move_current (GtkMenuShell *menu_shell,
777 GtkMenuDirectionType direction)
779 GtkMenuBar *menubar = GTK_MENU_BAR (menu_shell);
780 GtkTextDirection text_dir;
781 GtkPackDirection pack_dir;
783 text_dir = gtk_widget_get_direction (GTK_WIDGET (menubar));
784 pack_dir = gtk_menu_bar_get_pack_direction (menubar);
786 if (pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL)
788 if ((text_dir == GTK_TEXT_DIR_RTL) == (pack_dir == GTK_PACK_DIRECTION_LTR))
792 case GTK_MENU_DIR_PREV:
793 direction = GTK_MENU_DIR_NEXT;
795 case GTK_MENU_DIR_NEXT:
796 direction = GTK_MENU_DIR_PREV;
806 case GTK_MENU_DIR_PARENT:
807 if ((text_dir == GTK_TEXT_DIR_LTR) == (pack_dir == GTK_PACK_DIRECTION_TTB))
808 direction = GTK_MENU_DIR_PREV;
810 direction = GTK_MENU_DIR_NEXT;
812 case GTK_MENU_DIR_CHILD:
813 if ((text_dir == GTK_TEXT_DIR_LTR) == (pack_dir == GTK_PACK_DIRECTION_TTB))
814 direction = GTK_MENU_DIR_NEXT;
816 direction = GTK_MENU_DIR_PREV;
818 case GTK_MENU_DIR_PREV:
819 if (text_dir == GTK_TEXT_DIR_RTL)
820 direction = GTK_MENU_DIR_CHILD;
822 direction = GTK_MENU_DIR_PARENT;
824 case GTK_MENU_DIR_NEXT:
825 if (text_dir == GTK_TEXT_DIR_RTL)
826 direction = GTK_MENU_DIR_PARENT;
828 direction = GTK_MENU_DIR_CHILD;
834 GTK_MENU_SHELL_CLASS (gtk_menu_bar_parent_class)->move_current (menu_shell, direction);
838 * gtk_menu_bar_get_pack_direction:
839 * @menubar: a #GtkMenuBar
841 * Retrieves the current pack direction of the menubar.
842 * See gtk_menu_bar_set_pack_direction().
844 * Return value: the pack direction
849 gtk_menu_bar_get_pack_direction (GtkMenuBar *menubar)
851 g_return_val_if_fail (GTK_IS_MENU_BAR (menubar),
852 GTK_PACK_DIRECTION_LTR);
854 return menubar->priv->pack_direction;
858 * gtk_menu_bar_set_pack_direction:
859 * @menubar: a #GtkMenuBar
860 * @pack_dir: a new #GtkPackDirection
862 * Sets how items should be packed inside a menubar.
867 gtk_menu_bar_set_pack_direction (GtkMenuBar *menubar,
868 GtkPackDirection pack_dir)
870 GtkMenuBarPrivate *priv;
873 g_return_if_fail (GTK_IS_MENU_BAR (menubar));
875 priv = menubar->priv;
877 if (priv->pack_direction != pack_dir)
879 priv->pack_direction = pack_dir;
881 gtk_widget_queue_resize (GTK_WIDGET (menubar));
883 for (l = GTK_MENU_SHELL (menubar)->children; l; l = l->next)
884 gtk_widget_queue_resize (GTK_WIDGET (l->data));
886 g_object_notify (G_OBJECT (menubar), "pack-direction");
891 * gtk_menu_bar_get_child_pack_direction:
892 * @menubar: a #GtkMenuBar
894 * Retrieves the current child pack direction of the menubar.
895 * See gtk_menu_bar_set_child_pack_direction().
897 * Return value: the child pack direction
902 gtk_menu_bar_get_child_pack_direction (GtkMenuBar *menubar)
904 g_return_val_if_fail (GTK_IS_MENU_BAR (menubar),
905 GTK_PACK_DIRECTION_LTR);
907 return menubar->priv->child_pack_direction;
911 * gtk_menu_bar_set_child_pack_direction:
912 * @menubar: a #GtkMenuBar
913 * @child_pack_dir: a new #GtkPackDirection
915 * Sets how widgets should be packed inside the children of a menubar.
920 gtk_menu_bar_set_child_pack_direction (GtkMenuBar *menubar,
921 GtkPackDirection child_pack_dir)
923 GtkMenuBarPrivate *priv;
926 g_return_if_fail (GTK_IS_MENU_BAR (menubar));
928 priv = menubar->priv;
930 if (priv->child_pack_direction != child_pack_dir)
932 priv->child_pack_direction = child_pack_dir;
934 gtk_widget_queue_resize (GTK_WIDGET (menubar));
936 for (l = GTK_MENU_SHELL (menubar)->children; l; l = l->next)
937 gtk_widget_queue_resize (GTK_WIDGET (l->data));
939 g_object_notify (G_OBJECT (menubar), "child-pack-direction");