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"
41 #define BORDER_SPACING 0
42 #define DEFAULT_IPADDING 1
48 PROP_CHILD_PACK_DIRECTION
51 struct _GtkMenuBarPrivate
53 GtkPackDirection pack_direction;
54 GtkPackDirection child_pack_direction;
58 static void gtk_menu_bar_set_property (GObject *object,
62 static void gtk_menu_bar_get_property (GObject *object,
66 static void gtk_menu_bar_size_request (GtkWidget *widget,
67 GtkRequisition *requisition);
68 static void gtk_menu_bar_size_allocate (GtkWidget *widget,
69 GtkAllocation *allocation);
70 static void gtk_menu_bar_paint (GtkWidget *widget,
72 static gint gtk_menu_bar_expose (GtkWidget *widget,
73 GdkEventExpose *event);
74 static void gtk_menu_bar_hierarchy_changed (GtkWidget *widget,
75 GtkWidget *old_toplevel);
76 static gint gtk_menu_bar_get_popup_delay (GtkMenuShell *menu_shell);
77 static void gtk_menu_bar_move_current (GtkMenuShell *menu_shell,
78 GtkMenuDirectionType direction);
80 static GtkShadowType get_shadow_type (GtkMenuBar *menubar);
82 G_DEFINE_TYPE (GtkMenuBar, gtk_menu_bar, GTK_TYPE_MENU_SHELL)
85 gtk_menu_bar_class_init (GtkMenuBarClass *class)
87 GObjectClass *gobject_class;
88 GtkWidgetClass *widget_class;
89 GtkMenuShellClass *menu_shell_class;
91 GtkBindingSet *binding_set;
93 gobject_class = (GObjectClass*) class;
94 widget_class = (GtkWidgetClass*) class;
95 menu_shell_class = (GtkMenuShellClass*) class;
97 gobject_class->get_property = gtk_menu_bar_get_property;
98 gobject_class->set_property = gtk_menu_bar_set_property;
100 widget_class->size_request = gtk_menu_bar_size_request;
101 widget_class->size_allocate = gtk_menu_bar_size_allocate;
102 widget_class->expose_event = gtk_menu_bar_expose;
103 widget_class->hierarchy_changed = gtk_menu_bar_hierarchy_changed;
105 menu_shell_class->submenu_placement = GTK_TOP_BOTTOM;
106 menu_shell_class->get_popup_delay = gtk_menu_bar_get_popup_delay;
107 menu_shell_class->move_current = gtk_menu_bar_move_current;
109 binding_set = gtk_binding_set_by_class (class);
110 gtk_binding_entry_add_signal (binding_set,
113 GTK_TYPE_MENU_DIRECTION_TYPE,
115 gtk_binding_entry_add_signal (binding_set,
118 GTK_TYPE_MENU_DIRECTION_TYPE,
120 gtk_binding_entry_add_signal (binding_set,
123 GTK_TYPE_MENU_DIRECTION_TYPE,
125 gtk_binding_entry_add_signal (binding_set,
128 GTK_TYPE_MENU_DIRECTION_TYPE,
130 gtk_binding_entry_add_signal (binding_set,
133 GTK_TYPE_MENU_DIRECTION_TYPE,
134 GTK_MENU_DIR_PARENT);
135 gtk_binding_entry_add_signal (binding_set,
138 GTK_TYPE_MENU_DIRECTION_TYPE,
139 GTK_MENU_DIR_PARENT);
140 gtk_binding_entry_add_signal (binding_set,
143 GTK_TYPE_MENU_DIRECTION_TYPE,
145 gtk_binding_entry_add_signal (binding_set,
148 GTK_TYPE_MENU_DIRECTION_TYPE,
152 * GtkMenuBar:pack-direction:
154 * The pack direction of the menubar. It determines how
155 * menuitems are arranged in the menubar.
159 g_object_class_install_property (gobject_class,
161 g_param_spec_enum ("pack-direction",
162 P_("Pack direction"),
163 P_("The pack direction of the menubar"),
164 GTK_TYPE_PACK_DIRECTION,
165 GTK_PACK_DIRECTION_LTR,
166 GTK_PARAM_READWRITE));
169 * GtkMenuBar:child-pack-direction:
171 * The child pack direction of the menubar. It determines how
172 * the widgets contained in child menuitems are arranged.
176 g_object_class_install_property (gobject_class,
177 PROP_CHILD_PACK_DIRECTION,
178 g_param_spec_enum ("child-pack-direction",
179 P_("Child Pack direction"),
180 P_("The child pack direction of the menubar"),
181 GTK_TYPE_PACK_DIRECTION,
182 GTK_PACK_DIRECTION_LTR,
183 GTK_PARAM_READWRITE));
186 gtk_widget_class_install_style_property (widget_class,
187 g_param_spec_enum ("shadow-type",
189 P_("Style of bevel around the menubar"),
190 GTK_TYPE_SHADOW_TYPE,
192 GTK_PARAM_READABLE));
194 gtk_widget_class_install_style_property (widget_class,
195 g_param_spec_int ("internal-padding",
196 P_("Internal padding"),
197 P_("Amount of border space between the menubar shadow and the menu items"),
201 GTK_PARAM_READABLE));
203 gtk_settings_install_property (g_param_spec_int ("gtk-menu-bar-popup-delay",
204 P_("Delay before drop down menus appear"),
205 P_("Delay before the submenus of a menu bar appear"),
209 GTK_PARAM_READWRITE));
211 g_type_class_add_private (gobject_class, sizeof (GtkMenuBarPrivate));
215 gtk_menu_bar_init (GtkMenuBar *menu_bar)
217 menu_bar->priv = G_TYPE_INSTANCE_GET_PRIVATE (menu_bar,
223 gtk_menu_bar_new (void)
225 return g_object_new (GTK_TYPE_MENU_BAR, NULL);
229 gtk_menu_bar_set_property (GObject *object,
234 GtkMenuBar *menubar = GTK_MENU_BAR (object);
238 case PROP_PACK_DIRECTION:
239 gtk_menu_bar_set_pack_direction (menubar, g_value_get_enum (value));
241 case PROP_CHILD_PACK_DIRECTION:
242 gtk_menu_bar_set_child_pack_direction (menubar, g_value_get_enum (value));
245 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
251 gtk_menu_bar_get_property (GObject *object,
256 GtkMenuBar *menubar = GTK_MENU_BAR (object);
260 case PROP_PACK_DIRECTION:
261 g_value_set_enum (value, gtk_menu_bar_get_pack_direction (menubar));
263 case PROP_CHILD_PACK_DIRECTION:
264 g_value_set_enum (value, gtk_menu_bar_get_child_pack_direction (menubar));
267 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
273 gtk_menu_bar_size_request (GtkWidget *widget,
274 GtkRequisition *requisition)
276 GtkMenuBar *menu_bar;
277 GtkMenuBarPrivate *priv;
278 GtkMenuShell *menu_shell;
282 GtkRequisition child_requisition;
286 g_return_if_fail (GTK_IS_MENU_BAR (widget));
287 g_return_if_fail (requisition != NULL);
289 requisition->width = 0;
290 requisition->height = 0;
292 if (gtk_widget_get_visible (widget))
294 menu_bar = GTK_MENU_BAR (widget);
295 menu_shell = GTK_MENU_SHELL (widget);
296 priv = menu_bar->priv;
299 children = menu_shell->children;
303 child = children->data;
304 children = children->next;
306 if (gtk_widget_get_visible (child))
310 GTK_MENU_ITEM (child)->show_submenu_indicator = FALSE;
311 gtk_widget_size_request (child, &child_requisition);
312 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
315 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
316 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
317 child_requisition.width += toggle_size;
319 child_requisition.height += toggle_size;
321 if (priv->pack_direction == GTK_PACK_DIRECTION_LTR ||
322 priv->pack_direction == GTK_PACK_DIRECTION_RTL)
324 requisition->width += child_requisition.width;
325 requisition->height = MAX (requisition->height, child_requisition.height);
329 requisition->width = MAX (requisition->width, child_requisition.width);
330 requisition->height += child_requisition.height;
336 gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL);
338 border_width = gtk_container_get_border_width (GTK_CONTAINER (menu_bar));
339 requisition->width += (border_width +
342 requisition->height += (border_width +
346 if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE)
350 style = gtk_widget_get_style (widget);
351 requisition->width += style->xthickness * 2;
352 requisition->height += style->ythickness * 2;
358 gtk_menu_bar_size_allocate (GtkWidget *widget,
359 GtkAllocation *allocation)
361 GtkMenuBar *menu_bar;
362 GtkMenuShell *menu_shell;
363 GtkMenuBarPrivate *priv;
366 GtkAllocation child_allocation;
367 GtkRequisition child_requisition;
369 GtkTextDirection direction;
374 g_return_if_fail (GTK_IS_MENU_BAR (widget));
375 g_return_if_fail (allocation != NULL);
377 menu_bar = GTK_MENU_BAR (widget);
378 menu_shell = GTK_MENU_SHELL (widget);
379 priv = menu_bar->priv;
381 direction = gtk_widget_get_direction (widget);
383 gtk_widget_set_allocation (widget, allocation);
385 if (gtk_widget_get_realized (widget))
386 gdk_window_move_resize (gtk_widget_get_window (widget),
387 allocation->x, allocation->y,
388 allocation->width, allocation->height);
390 gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL);
392 if (menu_shell->children)
394 border_width = gtk_container_get_border_width (GTK_CONTAINER (menu_bar));
395 child_allocation.x = (border_width +
398 child_allocation.y = (border_width +
401 if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE)
405 style = gtk_widget_get_style (widget);
406 child_allocation.x += style->xthickness;
407 child_allocation.y += style->ythickness;
410 if (priv->pack_direction == GTK_PACK_DIRECTION_LTR ||
411 priv->pack_direction == GTK_PACK_DIRECTION_RTL)
413 child_allocation.height = MAX (1, (gint)allocation->height - child_allocation.y * 2);
415 offset = child_allocation.x; /* Window edge to menubar start */
416 ltr_x = child_allocation.x;
418 children = menu_shell->children;
423 child = children->data;
424 children = children->next;
426 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
428 gtk_widget_get_child_requisition (child, &child_requisition);
430 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
431 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
432 child_requisition.width += toggle_size;
434 child_requisition.height += toggle_size;
436 /* Support for the right justified help menu */
437 if ((children == NULL) && (GTK_IS_MENU_ITEM(child))
438 && (GTK_MENU_ITEM(child)->right_justify))
440 ltr_x = allocation->width -
441 child_requisition.width - offset;
443 if (gtk_widget_get_visible (child))
445 if ((direction == GTK_TEXT_DIR_LTR) == (priv->pack_direction == GTK_PACK_DIRECTION_LTR))
446 child_allocation.x = ltr_x;
448 child_allocation.x = allocation->width -
449 child_requisition.width - ltr_x;
451 child_allocation.width = child_requisition.width;
453 gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (child),
455 gtk_widget_size_allocate (child, &child_allocation);
457 ltr_x += child_allocation.width;
463 child_allocation.width = MAX (1, (gint)allocation->width - child_allocation.x * 2);
465 offset = child_allocation.y; /* Window edge to menubar start */
466 ltr_y = child_allocation.y;
468 children = menu_shell->children;
473 child = children->data;
474 children = children->next;
476 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
478 gtk_widget_get_child_requisition (child, &child_requisition);
480 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
481 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
482 child_requisition.width += toggle_size;
484 child_requisition.height += toggle_size;
486 /* Support for the right justified help menu */
487 if ((children == NULL) && (GTK_IS_MENU_ITEM(child))
488 && (GTK_MENU_ITEM(child)->right_justify))
490 ltr_y = allocation->height -
491 child_requisition.height - offset;
493 if (gtk_widget_get_visible (child))
495 if ((direction == GTK_TEXT_DIR_LTR) ==
496 (priv->pack_direction == GTK_PACK_DIRECTION_TTB))
497 child_allocation.y = ltr_y;
499 child_allocation.y = allocation->height -
500 child_requisition.height - ltr_y;
501 child_allocation.height = child_requisition.height;
503 gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (child),
505 gtk_widget_size_allocate (child, &child_allocation);
507 ltr_y += child_allocation.height;
515 gtk_menu_bar_paint (GtkWidget *widget,
518 g_return_if_fail (GTK_IS_MENU_BAR (widget));
520 if (gtk_widget_is_drawable (widget))
522 GtkAllocation allocation;
525 border = gtk_container_get_border_width (GTK_CONTAINER (widget));
526 gtk_widget_get_allocation (widget, &allocation);
528 gtk_paint_box (gtk_widget_get_style (widget),
529 gtk_widget_get_window (widget),
530 gtk_widget_get_state (widget),
531 get_shadow_type (GTK_MENU_BAR (widget)),
532 area, widget, "menubar",
534 allocation.width - border * 2,
535 allocation.height - border * 2);
540 gtk_menu_bar_expose (GtkWidget *widget,
541 GdkEventExpose *event)
543 g_return_val_if_fail (GTK_IS_MENU_BAR (widget), FALSE);
544 g_return_val_if_fail (event != NULL, FALSE);
546 if (gtk_widget_is_drawable (widget))
548 gtk_menu_bar_paint (widget, &event->area);
550 GTK_WIDGET_CLASS (gtk_menu_bar_parent_class)->expose_event (widget, event);
557 get_menu_bars (GtkWindow *window)
559 return g_object_get_data (G_OBJECT (window), "gtk-menu-bar-list");
563 get_viewable_menu_bars (GtkWindow *window)
566 GList *viewable_menu_bars = NULL;
568 for (menu_bars = get_menu_bars (window);
570 menu_bars = menu_bars->next)
572 GtkWidget *widget = menu_bars->data;
573 gboolean viewable = TRUE;
577 if (!gtk_widget_get_mapped (widget))
580 widget = gtk_widget_get_parent (widget);
584 viewable_menu_bars = g_list_prepend (viewable_menu_bars, menu_bars->data);
587 return g_list_reverse (viewable_menu_bars);
591 set_menu_bars (GtkWindow *window,
594 g_object_set_data (G_OBJECT (window), I_("gtk-menu-bar-list"), menubars);
598 window_key_press_handler (GtkWidget *widget,
603 gboolean retval = FALSE;
605 g_object_get (gtk_widget_get_settings (widget),
606 "gtk-menu-bar-accel", &accel,
612 GdkModifierType mods = 0;
614 gtk_accelerator_parse (accel, &keyval, &mods);
617 g_warning ("Failed to parse menu bar accelerator '%s'\n", accel);
619 /* FIXME this is wrong, needs to be in the global accel resolution
620 * thing, to properly consider i18n etc., but that probably requires
621 * AccelGroup changes etc.
623 if (event->keyval == keyval &&
624 ((event->state & gtk_accelerator_get_default_mod_mask ()) ==
625 (mods & gtk_accelerator_get_default_mod_mask ())))
627 GList *tmp_menubars = get_viewable_menu_bars (GTK_WINDOW (widget));
630 menubars = _gtk_container_focus_sort (GTK_CONTAINER (widget), tmp_menubars,
631 GTK_DIR_TAB_FORWARD, NULL);
632 g_list_free (tmp_menubars);
636 GtkMenuShell *menu_shell = GTK_MENU_SHELL (menubars->data);
638 _gtk_menu_shell_set_keyboard_mode (menu_shell, TRUE);
639 _gtk_menu_shell_activate (menu_shell);
640 gtk_menu_shell_select_first (menu_shell, FALSE);
642 g_list_free (menubars);
655 add_to_window (GtkWindow *window,
658 GList *menubars = get_menu_bars (window);
662 g_signal_connect (window,
664 G_CALLBACK (window_key_press_handler),
668 set_menu_bars (window, g_list_prepend (menubars, menubar));
672 remove_from_window (GtkWindow *window,
675 GList *menubars = get_menu_bars (window);
677 menubars = g_list_remove (menubars, menubar);
681 g_signal_handlers_disconnect_by_func (window,
682 window_key_press_handler,
686 set_menu_bars (window, menubars);
690 gtk_menu_bar_hierarchy_changed (GtkWidget *widget,
691 GtkWidget *old_toplevel)
696 menubar = GTK_MENU_BAR (widget);
698 toplevel = gtk_widget_get_toplevel (widget);
701 remove_from_window (GTK_WINDOW (old_toplevel), menubar);
703 if (gtk_widget_is_toplevel (toplevel))
704 add_to_window (GTK_WINDOW (toplevel), menubar);
708 * _gtk_menu_bar_cycle_focus:
709 * @menubar: a #GtkMenuBar
710 * @dir: direction in which to cycle the focus
712 * Move the focus between menubars in the toplevel.
715 _gtk_menu_bar_cycle_focus (GtkMenuBar *menubar,
716 GtkDirectionType dir)
718 GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (menubar));
719 GtkMenuItem *to_activate = NULL;
721 if (gtk_widget_is_toplevel (toplevel))
723 GList *tmp_menubars = get_viewable_menu_bars (GTK_WINDOW (toplevel));
727 menubars = _gtk_container_focus_sort (GTK_CONTAINER (toplevel), tmp_menubars,
728 dir, GTK_WIDGET (menubar));
729 g_list_free (tmp_menubars);
733 current = g_list_find (menubars, menubar);
735 if (current && current->next)
737 GtkMenuShell *new_menushell = GTK_MENU_SHELL (current->next->data);
738 if (new_menushell->children)
739 to_activate = new_menushell->children->data;
743 g_list_free (menubars);
746 gtk_menu_shell_cancel (GTK_MENU_SHELL (menubar));
749 g_signal_emit_by_name (to_activate, "activate_item");
753 get_shadow_type (GtkMenuBar *menubar)
755 GtkShadowType shadow_type = GTK_SHADOW_OUT;
757 gtk_widget_style_get (GTK_WIDGET (menubar),
758 "shadow-type", &shadow_type,
765 gtk_menu_bar_get_popup_delay (GtkMenuShell *menu_shell)
769 g_object_get (gtk_widget_get_settings (GTK_WIDGET (menu_shell)),
770 "gtk-menu-bar-popup-delay", &popup_delay,
777 gtk_menu_bar_move_current (GtkMenuShell *menu_shell,
778 GtkMenuDirectionType direction)
780 GtkMenuBar *menubar = GTK_MENU_BAR (menu_shell);
781 GtkTextDirection text_dir;
782 GtkPackDirection pack_dir;
784 text_dir = gtk_widget_get_direction (GTK_WIDGET (menubar));
785 pack_dir = gtk_menu_bar_get_pack_direction (menubar);
787 if (pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL)
789 if ((text_dir == GTK_TEXT_DIR_RTL) == (pack_dir == GTK_PACK_DIRECTION_LTR))
793 case GTK_MENU_DIR_PREV:
794 direction = GTK_MENU_DIR_NEXT;
796 case GTK_MENU_DIR_NEXT:
797 direction = GTK_MENU_DIR_PREV;
807 case GTK_MENU_DIR_PARENT:
808 if ((text_dir == GTK_TEXT_DIR_LTR) == (pack_dir == GTK_PACK_DIRECTION_TTB))
809 direction = GTK_MENU_DIR_PREV;
811 direction = GTK_MENU_DIR_NEXT;
813 case GTK_MENU_DIR_CHILD:
814 if ((text_dir == GTK_TEXT_DIR_LTR) == (pack_dir == GTK_PACK_DIRECTION_TTB))
815 direction = GTK_MENU_DIR_NEXT;
817 direction = GTK_MENU_DIR_PREV;
819 case GTK_MENU_DIR_PREV:
820 if (text_dir == GTK_TEXT_DIR_RTL)
821 direction = GTK_MENU_DIR_CHILD;
823 direction = GTK_MENU_DIR_PARENT;
825 case GTK_MENU_DIR_NEXT:
826 if (text_dir == GTK_TEXT_DIR_RTL)
827 direction = GTK_MENU_DIR_PARENT;
829 direction = GTK_MENU_DIR_CHILD;
835 GTK_MENU_SHELL_CLASS (gtk_menu_bar_parent_class)->move_current (menu_shell, direction);
839 * gtk_menu_bar_get_pack_direction:
840 * @menubar: a #GtkMenuBar
842 * Retrieves the current pack direction of the menubar.
843 * See gtk_menu_bar_set_pack_direction().
845 * Return value: the pack direction
850 gtk_menu_bar_get_pack_direction (GtkMenuBar *menubar)
852 g_return_val_if_fail (GTK_IS_MENU_BAR (menubar),
853 GTK_PACK_DIRECTION_LTR);
855 return menubar->priv->pack_direction;
859 * gtk_menu_bar_set_pack_direction:
860 * @menubar: a #GtkMenuBar
861 * @pack_dir: a new #GtkPackDirection
863 * Sets how items should be packed inside a menubar.
868 gtk_menu_bar_set_pack_direction (GtkMenuBar *menubar,
869 GtkPackDirection pack_dir)
871 GtkMenuBarPrivate *priv;
874 g_return_if_fail (GTK_IS_MENU_BAR (menubar));
876 priv = menubar->priv;
878 if (priv->pack_direction != pack_dir)
880 priv->pack_direction = pack_dir;
882 gtk_widget_queue_resize (GTK_WIDGET (menubar));
884 for (l = GTK_MENU_SHELL (menubar)->children; l; l = l->next)
885 gtk_widget_queue_resize (GTK_WIDGET (l->data));
887 g_object_notify (G_OBJECT (menubar), "pack-direction");
892 * gtk_menu_bar_get_child_pack_direction:
893 * @menubar: a #GtkMenuBar
895 * Retrieves the current child pack direction of the menubar.
896 * See gtk_menu_bar_set_child_pack_direction().
898 * Return value: the child pack direction
903 gtk_menu_bar_get_child_pack_direction (GtkMenuBar *menubar)
905 g_return_val_if_fail (GTK_IS_MENU_BAR (menubar),
906 GTK_PACK_DIRECTION_LTR);
908 return menubar->priv->child_pack_direction;
912 * gtk_menu_bar_set_child_pack_direction:
913 * @menubar: a #GtkMenuBar
914 * @child_pack_dir: a new #GtkPackDirection
916 * Sets how widgets should be packed inside the children of a menubar.
921 gtk_menu_bar_set_child_pack_direction (GtkMenuBar *menubar,
922 GtkPackDirection child_pack_dir)
924 GtkMenuBarPrivate *priv;
927 g_return_if_fail (GTK_IS_MENU_BAR (menubar));
929 priv = menubar->priv;
931 if (priv->child_pack_direction != child_pack_dir)
933 priv->child_pack_direction = child_pack_dir;
935 gtk_widget_queue_resize (GTK_WIDGET (menubar));
937 for (l = GTK_MENU_SHELL (menubar)->children; l; l = l->next)
938 gtk_widget_queue_resize (GTK_WIDGET (l->data));
940 g_object_notify (G_OBJECT (menubar), "child-pack-direction");