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 G_DEFINE_TYPE (GtkMenuBar, gtk_menu_bar, GTK_TYPE_MENU_SHELL)
93 gtk_menu_bar_init (GtkMenuBar *object)
98 gtk_menu_bar_class_init (GtkMenuBarClass *class)
100 GObjectClass *gobject_class;
101 GtkWidgetClass *widget_class;
102 GtkMenuShellClass *menu_shell_class;
104 GtkBindingSet *binding_set;
106 gobject_class = (GObjectClass*) class;
107 widget_class = (GtkWidgetClass*) class;
108 menu_shell_class = (GtkMenuShellClass*) class;
110 gobject_class->get_property = gtk_menu_bar_get_property;
111 gobject_class->set_property = gtk_menu_bar_set_property;
113 widget_class->size_request = gtk_menu_bar_size_request;
114 widget_class->size_allocate = gtk_menu_bar_size_allocate;
115 widget_class->expose_event = gtk_menu_bar_expose;
116 widget_class->hierarchy_changed = gtk_menu_bar_hierarchy_changed;
118 menu_shell_class->submenu_placement = GTK_TOP_BOTTOM;
119 menu_shell_class->get_popup_delay = gtk_menu_bar_get_popup_delay;
120 menu_shell_class->move_current = gtk_menu_bar_move_current;
122 binding_set = gtk_binding_set_by_class (class);
123 gtk_binding_entry_add_signal (binding_set,
126 GTK_TYPE_MENU_DIRECTION_TYPE,
128 gtk_binding_entry_add_signal (binding_set,
131 GTK_TYPE_MENU_DIRECTION_TYPE,
133 gtk_binding_entry_add_signal (binding_set,
136 GTK_TYPE_MENU_DIRECTION_TYPE,
138 gtk_binding_entry_add_signal (binding_set,
141 GTK_TYPE_MENU_DIRECTION_TYPE,
143 gtk_binding_entry_add_signal (binding_set,
146 GTK_TYPE_MENU_DIRECTION_TYPE,
147 GTK_MENU_DIR_PARENT);
148 gtk_binding_entry_add_signal (binding_set,
151 GTK_TYPE_MENU_DIRECTION_TYPE,
152 GTK_MENU_DIR_PARENT);
153 gtk_binding_entry_add_signal (binding_set,
156 GTK_TYPE_MENU_DIRECTION_TYPE,
158 gtk_binding_entry_add_signal (binding_set,
161 GTK_TYPE_MENU_DIRECTION_TYPE,
165 * GtkMenuBar:pack-direction:
167 * The pack direction of the menubar. It determines how
168 * menuitems are arranged in the menubar.
172 g_object_class_install_property (gobject_class,
174 g_param_spec_enum ("pack-direction",
175 P_("Pack direction"),
176 P_("The pack direction of the menubar"),
177 GTK_TYPE_PACK_DIRECTION,
178 GTK_PACK_DIRECTION_LTR,
179 GTK_PARAM_READWRITE));
182 * GtkMenuBar:child-pack-direction:
184 * The pack direction of the menubar. It determines how
185 * the widgets contained in child menuitems are arranged.
189 g_object_class_install_property (gobject_class,
190 PROP_CHILD_PACK_DIRECTION,
191 g_param_spec_enum ("child-pack-direction",
192 P_("Child Pack direction"),
193 P_("The child pack direction of the menubar"),
194 GTK_TYPE_PACK_DIRECTION,
195 GTK_PACK_DIRECTION_LTR,
196 GTK_PARAM_READWRITE));
199 gtk_widget_class_install_style_property (widget_class,
200 g_param_spec_enum ("shadow-type",
202 P_("Style of bevel around the menubar"),
203 GTK_TYPE_SHADOW_TYPE,
205 GTK_PARAM_READABLE));
207 gtk_widget_class_install_style_property (widget_class,
208 g_param_spec_int ("internal-padding",
209 P_("Internal padding"),
210 P_("Amount of border space between the menubar shadow and the menu items"),
214 GTK_PARAM_READABLE));
216 gtk_settings_install_property (g_param_spec_int ("gtk-menu-bar-popup-delay",
217 P_("Delay before drop down menus appear"),
218 P_("Delay before the submenus of a menu bar appear"),
222 GTK_PARAM_READWRITE));
224 g_type_class_add_private (gobject_class, sizeof (GtkMenuBarPrivate));
228 gtk_menu_bar_new (void)
230 return g_object_new (GTK_TYPE_MENU_BAR, NULL);
234 gtk_menu_bar_set_property (GObject *object,
239 GtkMenuBar *menubar = GTK_MENU_BAR (object);
243 case PROP_PACK_DIRECTION:
244 gtk_menu_bar_set_pack_direction (menubar, g_value_get_enum (value));
246 case PROP_CHILD_PACK_DIRECTION:
247 gtk_menu_bar_set_child_pack_direction (menubar, g_value_get_enum (value));
250 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
256 gtk_menu_bar_get_property (GObject *object,
261 GtkMenuBar *menubar = GTK_MENU_BAR (object);
265 case PROP_PACK_DIRECTION:
266 g_value_set_enum (value, gtk_menu_bar_get_pack_direction (menubar));
268 case PROP_CHILD_PACK_DIRECTION:
269 g_value_set_enum (value, gtk_menu_bar_get_child_pack_direction (menubar));
272 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
278 gtk_menu_bar_size_request (GtkWidget *widget,
279 GtkRequisition *requisition)
281 GtkMenuBar *menu_bar;
282 GtkMenuBarPrivate *priv;
283 GtkMenuShell *menu_shell;
287 GtkRequisition child_requisition;
290 g_return_if_fail (GTK_IS_MENU_BAR (widget));
291 g_return_if_fail (requisition != NULL);
293 requisition->width = 0;
294 requisition->height = 0;
296 if (GTK_WIDGET_VISIBLE (widget))
298 menu_bar = GTK_MENU_BAR (widget);
299 menu_shell = GTK_MENU_SHELL (widget);
300 priv = GTK_MENU_BAR_GET_PRIVATE (menu_bar);
303 children = menu_shell->children;
307 child = children->data;
308 children = children->next;
310 if (GTK_WIDGET_VISIBLE (child))
314 GTK_MENU_ITEM (child)->show_submenu_indicator = FALSE;
315 gtk_widget_size_request (child, &child_requisition);
316 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
319 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
320 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
321 child_requisition.width += toggle_size;
323 child_requisition.height += toggle_size;
325 if (priv->pack_direction == GTK_PACK_DIRECTION_LTR ||
326 priv->pack_direction == GTK_PACK_DIRECTION_RTL)
328 requisition->width += child_requisition.width;
329 requisition->height = MAX (requisition->height, child_requisition.height);
333 requisition->width = MAX (requisition->width, child_requisition.width);
334 requisition->height += child_requisition.height;
340 gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL);
342 requisition->width += (GTK_CONTAINER (menu_bar)->border_width +
345 requisition->height += (GTK_CONTAINER (menu_bar)->border_width +
349 if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE)
351 requisition->width += widget->style->xthickness * 2;
352 requisition->height += widget->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;
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 = GTK_MENU_BAR_GET_PRIVATE (menu_bar);
380 direction = gtk_widget_get_direction (widget);
382 widget->allocation = *allocation;
383 if (GTK_WIDGET_REALIZED (widget))
384 gdk_window_move_resize (widget->window,
385 allocation->x, allocation->y,
386 allocation->width, allocation->height);
388 gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL);
390 if (menu_shell->children)
392 child_allocation.x = (GTK_CONTAINER (menu_bar)->border_width +
395 child_allocation.y = (GTK_CONTAINER (menu_bar)->border_width +
398 if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE)
400 child_allocation.x += widget->style->xthickness;
401 child_allocation.y += widget->style->ythickness;
404 if (priv->pack_direction == GTK_PACK_DIRECTION_LTR ||
405 priv->pack_direction == GTK_PACK_DIRECTION_RTL)
407 child_allocation.height = MAX (1, (gint)allocation->height - child_allocation.y * 2);
409 offset = child_allocation.x; /* Window edge to menubar start */
410 ltr_x = child_allocation.x;
412 children = menu_shell->children;
417 child = children->data;
418 children = children->next;
420 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
422 gtk_widget_get_child_requisition (child, &child_requisition);
424 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
425 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
426 child_requisition.width += toggle_size;
428 child_requisition.height += toggle_size;
430 /* Support for the right justified help menu */
431 if ((children == NULL) && (GTK_IS_MENU_ITEM(child))
432 && (GTK_MENU_ITEM(child)->right_justify))
434 ltr_x = allocation->width -
435 child_requisition.width - offset;
437 if (GTK_WIDGET_VISIBLE (child))
439 if ((direction == GTK_TEXT_DIR_LTR) == (priv->pack_direction == GTK_PACK_DIRECTION_LTR))
440 child_allocation.x = ltr_x;
442 child_allocation.x = allocation->width -
443 child_requisition.width - ltr_x;
445 child_allocation.width = child_requisition.width;
447 gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (child),
449 gtk_widget_size_allocate (child, &child_allocation);
451 ltr_x += child_allocation.width;
457 child_allocation.width = MAX (1, (gint)allocation->width - child_allocation.x * 2);
459 offset = child_allocation.y; /* Window edge to menubar start */
460 ltr_y = child_allocation.y;
462 children = menu_shell->children;
467 child = children->data;
468 children = children->next;
470 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
472 gtk_widget_get_child_requisition (child, &child_requisition);
474 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
475 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
476 child_requisition.width += toggle_size;
478 child_requisition.height += toggle_size;
480 /* Support for the right justified help menu */
481 if ((children == NULL) && (GTK_IS_MENU_ITEM(child))
482 && (GTK_MENU_ITEM(child)->right_justify))
484 ltr_y = allocation->height -
485 child_requisition.height - offset;
487 if (GTK_WIDGET_VISIBLE (child))
489 if ((direction == GTK_TEXT_DIR_LTR) ==
490 (priv->pack_direction == GTK_PACK_DIRECTION_TTB))
491 child_allocation.y = ltr_y;
493 child_allocation.y = allocation->height -
494 child_requisition.height - ltr_y;
495 child_allocation.height = child_requisition.height;
497 gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (child),
499 gtk_widget_size_allocate (child, &child_allocation);
501 ltr_y += child_allocation.height;
509 gtk_menu_bar_paint (GtkWidget *widget, GdkRectangle *area)
511 g_return_if_fail (GTK_IS_MENU_BAR (widget));
513 if (GTK_WIDGET_DRAWABLE (widget))
517 border = GTK_CONTAINER (widget)->border_width;
519 gtk_paint_box (widget->style,
521 GTK_WIDGET_STATE (widget),
522 get_shadow_type (GTK_MENU_BAR (widget)),
523 area, widget, "menubar",
525 widget->allocation.width - border * 2,
526 widget->allocation.height - border * 2);
531 gtk_menu_bar_expose (GtkWidget *widget,
532 GdkEventExpose *event)
534 g_return_val_if_fail (GTK_IS_MENU_BAR (widget), FALSE);
535 g_return_val_if_fail (event != NULL, FALSE);
537 if (GTK_WIDGET_DRAWABLE (widget))
539 gtk_menu_bar_paint (widget, &event->area);
541 (* GTK_WIDGET_CLASS (gtk_menu_bar_parent_class)->expose_event) (widget, event);
548 get_menu_bars (GtkWindow *window)
550 return g_object_get_data (G_OBJECT (window), "gtk-menu-bar-list");
554 get_viewable_menu_bars (GtkWindow *window)
557 GList *viewable_menu_bars = NULL;
559 for (menu_bars = get_menu_bars (window);
561 menu_bars = menu_bars->next)
563 GtkWidget *widget = menu_bars->data;
564 gboolean viewable = TRUE;
568 if (!GTK_WIDGET_MAPPED (widget))
571 widget = widget->parent;
575 viewable_menu_bars = g_list_prepend (viewable_menu_bars, menu_bars->data);
578 return g_list_reverse (viewable_menu_bars);
582 set_menu_bars (GtkWindow *window,
585 g_object_set_data (G_OBJECT (window), I_("gtk-menu-bar-list"), menubars);
589 window_key_press_handler (GtkWidget *widget,
594 gboolean retval = FALSE;
596 g_object_get (gtk_widget_get_settings (widget),
597 "gtk-menu-bar-accel", &accel,
603 GdkModifierType mods = 0;
605 gtk_accelerator_parse (accel, &keyval, &mods);
608 g_warning ("Failed to parse menu bar accelerator '%s'\n", accel);
610 /* FIXME this is wrong, needs to be in the global accel resolution
611 * thing, to properly consider i18n etc., but that probably requires
612 * AccelGroup changes etc.
614 if (event->keyval == keyval &&
615 ((event->state & gtk_accelerator_get_default_mod_mask ()) ==
616 (mods & gtk_accelerator_get_default_mod_mask ())))
618 GList *tmp_menubars = get_viewable_menu_bars (GTK_WINDOW (widget));
621 menubars = _gtk_container_focus_sort (GTK_CONTAINER (widget), tmp_menubars,
622 GTK_DIR_TAB_FORWARD, NULL);
623 g_list_free (tmp_menubars);
627 GtkMenuShell *menu_shell = GTK_MENU_SHELL (menubars->data);
629 _gtk_menu_shell_activate (menu_shell);
630 gtk_menu_shell_select_first (menu_shell, FALSE);
632 g_list_free (menubars);
645 add_to_window (GtkWindow *window,
648 GList *menubars = get_menu_bars (window);
652 g_signal_connect (window,
654 G_CALLBACK (window_key_press_handler),
658 set_menu_bars (window, g_list_prepend (menubars, menubar));
662 remove_from_window (GtkWindow *window,
665 GList *menubars = get_menu_bars (window);
667 menubars = g_object_get_data (G_OBJECT (window),
668 "gtk-menu-bar-list");
670 menubars = g_list_remove (menubars, menubar);
674 g_signal_handlers_disconnect_by_func (window,
675 window_key_press_handler,
679 set_menu_bars (window, menubars);
683 gtk_menu_bar_hierarchy_changed (GtkWidget *widget,
684 GtkWidget *old_toplevel)
689 menubar = GTK_MENU_BAR (widget);
691 toplevel = gtk_widget_get_toplevel (widget);
694 remove_from_window (GTK_WINDOW (old_toplevel), menubar);
696 if (GTK_WIDGET_TOPLEVEL (toplevel))
697 add_to_window (GTK_WINDOW (toplevel), menubar);
701 * _gtk_menu_bar_cycle_focus:
702 * @menubar: a #GtkMenuBar
703 * @dir: direction in which to cycle the focus
705 * Move the focus between menubars in the toplevel.
708 _gtk_menu_bar_cycle_focus (GtkMenuBar *menubar,
709 GtkDirectionType dir)
711 GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (menubar));
712 GtkMenuItem *to_activate = NULL;
714 if (GTK_WIDGET_TOPLEVEL (toplevel))
716 GList *tmp_menubars = get_viewable_menu_bars (GTK_WINDOW (toplevel));
720 menubars = _gtk_container_focus_sort (GTK_CONTAINER (toplevel), tmp_menubars,
721 dir, GTK_WIDGET (menubar));
722 g_list_free (tmp_menubars);
726 current = g_list_find (menubars, menubar);
728 if (current && current->next)
730 GtkMenuShell *new_menushell = GTK_MENU_SHELL (current->next->data);
731 if (new_menushell->children)
732 to_activate = new_menushell->children->data;
736 g_list_free (menubars);
739 gtk_menu_shell_cancel (GTK_MENU_SHELL (menubar));
742 g_signal_emit_by_name (to_activate, "activate_item");
746 get_shadow_type (GtkMenuBar *menubar)
748 GtkShadowType shadow_type = GTK_SHADOW_OUT;
750 gtk_widget_style_get (GTK_WIDGET (menubar),
751 "shadow-type", &shadow_type,
758 gtk_menu_bar_get_popup_delay (GtkMenuShell *menu_shell)
762 g_object_get (gtk_widget_get_settings (GTK_WIDGET (menu_shell)),
763 "gtk-menu-bar-popup-delay", &popup_delay,
770 gtk_menu_bar_move_current (GtkMenuShell *menu_shell,
771 GtkMenuDirectionType direction)
773 GtkMenuBar *menubar = GTK_MENU_BAR (menu_shell);
774 GtkTextDirection text_dir;
775 GtkPackDirection pack_dir;
777 text_dir = gtk_widget_get_direction (GTK_WIDGET (menubar));
778 pack_dir = gtk_menu_bar_get_pack_direction (menubar);
780 if (pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL)
782 if ((text_dir == GTK_TEXT_DIR_RTL) == (pack_dir == GTK_PACK_DIRECTION_LTR))
786 case GTK_MENU_DIR_PREV:
787 direction = GTK_MENU_DIR_NEXT;
789 case GTK_MENU_DIR_NEXT:
790 direction = GTK_MENU_DIR_PREV;
800 case GTK_MENU_DIR_PARENT:
801 if ((text_dir == GTK_TEXT_DIR_LTR) == (pack_dir == GTK_PACK_DIRECTION_TTB))
802 direction = GTK_MENU_DIR_PREV;
804 direction = GTK_MENU_DIR_NEXT;
806 case GTK_MENU_DIR_CHILD:
807 if ((text_dir == GTK_TEXT_DIR_LTR) == (pack_dir == GTK_PACK_DIRECTION_TTB))
808 direction = GTK_MENU_DIR_NEXT;
810 direction = GTK_MENU_DIR_PREV;
812 case GTK_MENU_DIR_PREV:
813 if (text_dir == GTK_TEXT_DIR_RTL)
814 direction = GTK_MENU_DIR_CHILD;
816 direction = GTK_MENU_DIR_PARENT;
818 case GTK_MENU_DIR_NEXT:
819 if (text_dir == GTK_TEXT_DIR_RTL)
820 direction = GTK_MENU_DIR_PARENT;
822 direction = GTK_MENU_DIR_CHILD;
828 GTK_MENU_SHELL_CLASS (gtk_menu_bar_parent_class)->move_current (menu_shell, direction);
832 * gtk_menu_bar_get_pack_direction:
833 * @menubar: a #GtkMenuBar
835 * Retrieves the current pack direction of the menubar. See
836 * gtk_menu_bar_set_pack_direction().
838 * Return value: the pack direction
843 gtk_menu_bar_get_pack_direction (GtkMenuBar *menubar)
845 GtkMenuBarPrivate *priv;
847 g_return_val_if_fail (GTK_IS_MENU_BAR (menubar),
848 GTK_PACK_DIRECTION_LTR);
850 priv = GTK_MENU_BAR_GET_PRIVATE (menubar);
852 return priv->pack_direction;
856 * gtk_menu_bar_set_pack_direction:
857 * @menubar: a #GtkMenuBar.
858 * @pack_dir: a new #GtkPackDirection.
860 * Sets how items should be packed inside a menubar.
864 void gtk_menu_bar_set_pack_direction (GtkMenuBar *menubar,
865 GtkPackDirection pack_dir)
867 GtkMenuBarPrivate *priv;
870 g_return_if_fail (GTK_IS_MENU_BAR (menubar));
872 priv = GTK_MENU_BAR_GET_PRIVATE (menubar);
874 if (priv->pack_direction != pack_dir)
876 priv->pack_direction = pack_dir;
878 gtk_widget_queue_resize (GTK_WIDGET (menubar));
880 for (l = GTK_MENU_SHELL (menubar)->children; l; l = l->next)
881 gtk_widget_queue_resize (GTK_WIDGET (l->data));
883 g_object_notify (G_OBJECT (menubar), "pack-direction");
888 * gtk_menu_bar_get_child_pack_direction:
889 * @menubar: a #GtkMenuBar
891 * Retrieves the current child pack direction of the menubar. See
892 * gtk_menu_bar_set_child_pack_direction().
894 * Return value: the child pack direction
899 gtk_menu_bar_get_child_pack_direction (GtkMenuBar *menubar)
901 GtkMenuBarPrivate *priv;
903 g_return_val_if_fail (GTK_IS_MENU_BAR (menubar),
904 GTK_PACK_DIRECTION_LTR);
906 priv = GTK_MENU_BAR_GET_PRIVATE (menubar);
908 return 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.
920 void 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 = GTK_MENU_BAR_GET_PRIVATE (menubar);
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");
943 #define __GTK_MENU_BAR_C__
944 #include "gtkaliasdef.c"