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"
32 #include "gtkbindings.h"
34 #include "gtkmarshalers.h"
35 #include "gtkmenubar.h"
36 #include "gtkmenuitem.h"
37 #include "gtksettings.h"
39 #include "gtkwindow.h"
42 #define BORDER_SPACING 0
43 #define DEFAULT_IPADDING 1
49 PROP_CHILD_PACK_DIRECTION
52 typedef struct _GtkMenuBarPrivate GtkMenuBarPrivate;
53 struct _GtkMenuBarPrivate
55 GtkPackDirection pack_direction;
56 GtkPackDirection child_pack_direction;
59 #define GTK_MENU_BAR_GET_PRIVATE(o) \
60 (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_MENU_BAR, GtkMenuBarPrivate))
63 static void gtk_menu_bar_class_init (GtkMenuBarClass *klass);
64 static void gtk_menu_bar_set_property (GObject *object,
68 static void gtk_menu_bar_get_property (GObject *object,
72 static void gtk_menu_bar_size_request (GtkWidget *widget,
73 GtkRequisition *requisition);
74 static void gtk_menu_bar_size_allocate (GtkWidget *widget,
75 GtkAllocation *allocation);
76 static void gtk_menu_bar_paint (GtkWidget *widget,
78 static gint gtk_menu_bar_expose (GtkWidget *widget,
79 GdkEventExpose *event);
80 static void gtk_menu_bar_hierarchy_changed (GtkWidget *widget,
81 GtkWidget *old_toplevel);
82 static gint gtk_menu_bar_get_popup_delay (GtkMenuShell *menu_shell);
83 static void gtk_menu_bar_move_current (GtkMenuShell *menu_shell,
84 GtkMenuDirectionType direction);
87 static GtkShadowType get_shadow_type (GtkMenuBar *menubar);
89 static GtkMenuShellClass *parent_class = NULL;
92 gtk_menu_bar_get_type (void)
94 static GType menu_bar_type = 0;
98 static const GTypeInfo menu_bar_info =
100 sizeof (GtkMenuBarClass),
101 NULL, /* base_init */
102 NULL, /* base_finalize */
103 (GClassInitFunc) gtk_menu_bar_class_init,
104 NULL, /* class_finalize */
105 NULL, /* class_data */
108 NULL, /* instance_init */
111 menu_bar_type = g_type_register_static (GTK_TYPE_MENU_SHELL, "GtkMenuBar",
115 return menu_bar_type;
119 gtk_menu_bar_class_init (GtkMenuBarClass *class)
121 GObjectClass *gobject_class;
122 GtkObjectClass *object_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 object_class = (GtkObjectClass*) class;
132 widget_class = (GtkWidgetClass*) class;
133 menu_shell_class = (GtkMenuShellClass*) class;
135 gobject_class->get_property = gtk_menu_bar_get_property;
136 gobject_class->set_property = gtk_menu_bar_set_property;
138 widget_class->size_request = gtk_menu_bar_size_request;
139 widget_class->size_allocate = gtk_menu_bar_size_allocate;
140 widget_class->expose_event = gtk_menu_bar_expose;
141 widget_class->hierarchy_changed = gtk_menu_bar_hierarchy_changed;
143 menu_shell_class->submenu_placement = GTK_TOP_BOTTOM;
144 menu_shell_class->get_popup_delay = gtk_menu_bar_get_popup_delay;
145 menu_shell_class->move_current = gtk_menu_bar_move_current;
147 binding_set = gtk_binding_set_by_class (class);
148 gtk_binding_entry_add_signal (binding_set,
151 GTK_TYPE_MENU_DIRECTION_TYPE,
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,
163 gtk_binding_entry_add_signal (binding_set,
166 GTK_TYPE_MENU_DIRECTION_TYPE,
168 gtk_binding_entry_add_signal (binding_set,
171 GTK_TYPE_MENU_DIRECTION_TYPE,
172 GTK_MENU_DIR_PARENT);
173 gtk_binding_entry_add_signal (binding_set,
176 GTK_TYPE_MENU_DIRECTION_TYPE,
177 GTK_MENU_DIR_PARENT);
178 gtk_binding_entry_add_signal (binding_set,
181 GTK_TYPE_MENU_DIRECTION_TYPE,
183 gtk_binding_entry_add_signal (binding_set,
186 GTK_TYPE_MENU_DIRECTION_TYPE,
190 * GtkMenuBar:pack-direction:
192 * The pack direction of the menubar. It determines how
193 * menuitems are arranged in the menubar.
197 g_object_class_install_property (gobject_class,
199 g_param_spec_enum ("pack_direction",
200 P_("Pack direction"),
201 P_("The pack direction of the menubar"),
202 GTK_TYPE_PACK_DIRECTION,
203 GTK_PACK_DIRECTION_LTR,
207 * GtkMenuBar:child-pack-direction:
209 * The pack direction of the menubar. It determines how
210 * the widgets contained in child menuitems are arranged.
214 g_object_class_install_property (gobject_class,
215 PROP_CHILD_PACK_DIRECTION,
216 g_param_spec_enum ("child_pack_direction",
217 P_("Child Pack direction"),
218 P_("The child pack direction of the menubar"),
219 GTK_TYPE_PACK_DIRECTION,
220 GTK_PACK_DIRECTION_LTR,
224 gtk_widget_class_install_style_property (widget_class,
225 g_param_spec_enum ("shadow_type",
227 P_("Style of bevel around the menubar"),
228 GTK_TYPE_SHADOW_TYPE,
232 gtk_widget_class_install_style_property (widget_class,
233 g_param_spec_int ("internal_padding",
234 P_("Internal padding"),
235 P_("Amount of border space between the menubar shadow and the menu items"),
241 gtk_settings_install_property (g_param_spec_int ("gtk-menu-bar-popup-delay",
242 P_("Delay before drop down menus appear"),
243 P_("Delay before the submenus of a menu bar appear"),
249 g_type_class_add_private (gobject_class, sizeof (GtkMenuBarPrivate));
253 gtk_menu_bar_new (void)
255 return g_object_new (GTK_TYPE_MENU_BAR, NULL);
259 gtk_menu_bar_set_property (GObject *object,
264 GtkMenuBar *menubar = GTK_MENU_BAR (object);
268 case PROP_PACK_DIRECTION:
269 gtk_menu_bar_set_pack_direction (menubar, g_value_get_enum (value));
271 case PROP_CHILD_PACK_DIRECTION:
272 gtk_menu_bar_set_child_pack_direction (menubar, g_value_get_enum (value));
275 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
281 gtk_menu_bar_get_property (GObject *object,
286 GtkMenuBar *menubar = GTK_MENU_BAR (object);
290 case PROP_PACK_DIRECTION:
291 g_value_set_enum (value, gtk_menu_bar_get_pack_direction (menubar));
293 case PROP_CHILD_PACK_DIRECTION:
294 g_value_set_enum (value, gtk_menu_bar_get_child_pack_direction (menubar));
297 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
303 gtk_menu_bar_size_request (GtkWidget *widget,
304 GtkRequisition *requisition)
306 GtkMenuBar *menu_bar;
307 GtkMenuBarPrivate *priv;
308 GtkMenuShell *menu_shell;
312 GtkRequisition child_requisition;
315 g_return_if_fail (GTK_IS_MENU_BAR (widget));
316 g_return_if_fail (requisition != NULL);
318 requisition->width = 0;
319 requisition->height = 0;
321 if (GTK_WIDGET_VISIBLE (widget))
323 menu_bar = GTK_MENU_BAR (widget);
324 menu_shell = GTK_MENU_SHELL (widget);
325 priv = GTK_MENU_BAR_GET_PRIVATE (menu_bar);
328 children = menu_shell->children;
332 child = children->data;
333 children = children->next;
335 if (GTK_WIDGET_VISIBLE (child))
339 GTK_MENU_ITEM (child)->show_submenu_indicator = FALSE;
340 gtk_widget_size_request (child, &child_requisition);
341 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
344 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
345 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
346 child_requisition.width += toggle_size;
348 child_requisition.height += toggle_size;
350 if (priv->pack_direction == GTK_PACK_DIRECTION_LTR ||
351 priv->pack_direction == GTK_PACK_DIRECTION_RTL)
353 requisition->width += child_requisition.width;
354 requisition->height = MAX (requisition->height, child_requisition.height);
358 requisition->width = MAX (requisition->width, child_requisition.width);
359 requisition->height += child_requisition.height;
365 gtk_widget_style_get (widget, "internal_padding", &ipadding, NULL);
367 requisition->width += (GTK_CONTAINER (menu_bar)->border_width +
370 requisition->height += (GTK_CONTAINER (menu_bar)->border_width +
374 if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE)
376 requisition->width += widget->style->xthickness * 2;
377 requisition->height += widget->style->ythickness * 2;
383 gtk_menu_bar_size_allocate (GtkWidget *widget,
384 GtkAllocation *allocation)
386 GtkMenuBar *menu_bar;
387 GtkMenuShell *menu_shell;
388 GtkMenuBarPrivate *priv;
391 GtkAllocation child_allocation;
392 GtkRequisition child_requisition;
394 GtkTextDirection direction;
398 g_return_if_fail (GTK_IS_MENU_BAR (widget));
399 g_return_if_fail (allocation != NULL);
401 menu_bar = GTK_MENU_BAR (widget);
402 menu_shell = GTK_MENU_SHELL (widget);
403 priv = GTK_MENU_BAR_GET_PRIVATE (menu_bar);
405 direction = gtk_widget_get_direction (widget);
407 widget->allocation = *allocation;
408 if (GTK_WIDGET_REALIZED (widget))
409 gdk_window_move_resize (widget->window,
410 allocation->x, allocation->y,
411 allocation->width, allocation->height);
413 gtk_widget_style_get (widget, "internal_padding", &ipadding, NULL);
415 if (menu_shell->children)
417 child_allocation.x = (GTK_CONTAINER (menu_bar)->border_width +
420 child_allocation.y = (GTK_CONTAINER (menu_bar)->border_width +
423 if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE)
425 child_allocation.x += widget->style->xthickness;
426 child_allocation.y += widget->style->ythickness;
429 if (priv->pack_direction == GTK_PACK_DIRECTION_LTR ||
430 priv->pack_direction == GTK_PACK_DIRECTION_RTL)
432 child_allocation.height = MAX (1, (gint)allocation->height - child_allocation.y * 2);
434 offset = child_allocation.x; /* Window edge to menubar start */
435 ltr_x = child_allocation.x;
437 children = menu_shell->children;
442 child = children->data;
443 children = children->next;
445 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
447 gtk_widget_get_child_requisition (child, &child_requisition);
449 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
450 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
451 child_requisition.width += toggle_size;
453 child_requisition.height += toggle_size;
455 /* Support for the right justified help menu */
456 if ((children == NULL) && (GTK_IS_MENU_ITEM(child))
457 && (GTK_MENU_ITEM(child)->right_justify))
459 ltr_x = allocation->width -
460 child_requisition.width - offset;
462 if (GTK_WIDGET_VISIBLE (child))
464 if ((direction == GTK_TEXT_DIR_LTR) == (priv->pack_direction == GTK_PACK_DIRECTION_LTR))
465 child_allocation.x = ltr_x;
467 child_allocation.x = allocation->width -
468 child_requisition.width - ltr_x;
470 child_allocation.width = child_requisition.width;
472 gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (child),
474 gtk_widget_size_allocate (child, &child_allocation);
476 ltr_x += child_allocation.width;
482 child_allocation.width = MAX (1, (gint)allocation->width - child_allocation.x * 2);
484 offset = child_allocation.y; /* Window edge to menubar start */
485 ltr_y = child_allocation.y;
487 children = menu_shell->children;
492 child = children->data;
493 children = children->next;
495 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
497 gtk_widget_get_child_requisition (child, &child_requisition);
499 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
500 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
501 child_requisition.width += toggle_size;
503 child_requisition.height += toggle_size;
505 /* Support for the right justified help menu */
506 if ((children == NULL) && (GTK_IS_MENU_ITEM(child))
507 && (GTK_MENU_ITEM(child)->right_justify))
509 ltr_y = allocation->height -
510 child_requisition.height - offset;
512 if (GTK_WIDGET_VISIBLE (child))
514 if ((direction == GTK_TEXT_DIR_LTR) ==
515 (priv->pack_direction == GTK_PACK_DIRECTION_TTB))
516 child_allocation.y = ltr_y;
518 child_allocation.y = allocation->height -
519 child_requisition.height - ltr_y;
520 child_allocation.height = child_requisition.height;
522 gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (child),
524 gtk_widget_size_allocate (child, &child_allocation);
526 ltr_y += child_allocation.height;
534 gtk_menu_bar_paint (GtkWidget *widget, GdkRectangle *area)
536 g_return_if_fail (GTK_IS_MENU_BAR (widget));
538 if (GTK_WIDGET_DRAWABLE (widget))
542 border = GTK_CONTAINER (widget)->border_width;
544 gtk_paint_box (widget->style,
546 GTK_WIDGET_STATE (widget),
547 get_shadow_type (GTK_MENU_BAR (widget)),
548 area, widget, "menubar",
550 widget->allocation.width - border * 2,
551 widget->allocation.height - border * 2);
556 gtk_menu_bar_expose (GtkWidget *widget,
557 GdkEventExpose *event)
559 g_return_val_if_fail (GTK_IS_MENU_BAR (widget), FALSE);
560 g_return_val_if_fail (event != NULL, FALSE);
562 if (GTK_WIDGET_DRAWABLE (widget))
564 gtk_menu_bar_paint (widget, &event->area);
566 (* GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event);
573 get_menu_bars (GtkWindow *window)
575 return g_object_get_data (G_OBJECT (window), "gtk-menu-bar-list");
579 get_viewable_menu_bars (GtkWindow *window)
582 GList *viewable_menu_bars = NULL;
584 for (menu_bars = get_menu_bars (window);
586 menu_bars = menu_bars->next)
588 GtkWidget *widget = menu_bars->data;
589 gboolean viewable = TRUE;
593 if (!GTK_WIDGET_MAPPED (widget))
596 widget = widget->parent;
600 viewable_menu_bars = g_list_prepend (viewable_menu_bars, menu_bars->data);
603 return g_list_reverse (viewable_menu_bars);
607 set_menu_bars (GtkWindow *window,
610 g_object_set_data (G_OBJECT (window), "gtk-menu-bar-list", menubars);
614 window_key_press_handler (GtkWidget *widget,
619 gboolean retval = FALSE;
621 g_object_get (gtk_widget_get_settings (widget),
622 "gtk-menu-bar-accel",
629 GdkModifierType mods = 0;
631 gtk_accelerator_parse (accel, &keyval, &mods);
634 g_warning ("Failed to parse menu bar accelerator '%s'\n", accel);
636 /* FIXME this is wrong, needs to be in the global accel resolution
637 * thing, to properly consider i18n etc., but that probably requires
638 * AccelGroup changes etc.
640 if (event->keyval == keyval &&
641 ((event->state & gtk_accelerator_get_default_mod_mask ()) ==
642 (mods & gtk_accelerator_get_default_mod_mask ())))
644 GList *tmp_menubars = get_viewable_menu_bars (GTK_WINDOW (widget));
647 menubars = _gtk_container_focus_sort (GTK_CONTAINER (widget), tmp_menubars,
648 GTK_DIR_TAB_FORWARD, NULL);
649 g_list_free (tmp_menubars);
653 GtkMenuShell *menu_shell = GTK_MENU_SHELL (menubars->data);
655 _gtk_menu_shell_activate (menu_shell);
656 gtk_menu_shell_select_first (menu_shell, FALSE);
658 g_list_free (menubars);
671 add_to_window (GtkWindow *window,
674 GList *menubars = get_menu_bars (window);
678 g_signal_connect (window,
680 G_CALLBACK (window_key_press_handler),
684 set_menu_bars (window, g_list_prepend (menubars, menubar));
688 remove_from_window (GtkWindow *window,
691 GList *menubars = get_menu_bars (window);
693 menubars = g_object_get_data (G_OBJECT (window),
694 "gtk-menu-bar-list");
696 menubars = g_list_remove (menubars, menubar);
700 g_signal_handlers_disconnect_by_func (window,
701 window_key_press_handler,
705 set_menu_bars (window, menubars);
709 gtk_menu_bar_hierarchy_changed (GtkWidget *widget,
710 GtkWidget *old_toplevel)
715 menubar = GTK_MENU_BAR (widget);
717 toplevel = gtk_widget_get_toplevel (widget);
720 remove_from_window (GTK_WINDOW (old_toplevel), menubar);
722 if (GTK_WIDGET_TOPLEVEL (toplevel))
723 add_to_window (GTK_WINDOW (toplevel), menubar);
727 * _gtk_menu_bar_cycle_focus:
728 * @menubar: a #GtkMenuBar
729 * @dir: direction in which to cycle the focus
731 * Move the focus between menubars in the toplevel.
734 _gtk_menu_bar_cycle_focus (GtkMenuBar *menubar,
735 GtkDirectionType dir)
737 GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (menubar));
738 GtkMenuItem *to_activate = NULL;
740 if (GTK_WIDGET_TOPLEVEL (toplevel))
742 GList *tmp_menubars = get_viewable_menu_bars (GTK_WINDOW (toplevel));
746 menubars = _gtk_container_focus_sort (GTK_CONTAINER (toplevel), tmp_menubars,
747 dir, GTK_WIDGET (menubar));
748 g_list_free (tmp_menubars);
752 current = g_list_find (menubars, menubar);
754 if (current && current->next)
756 GtkMenuShell *new_menushell = GTK_MENU_SHELL (current->next->data);
757 if (new_menushell->children)
758 to_activate = new_menushell->children->data;
762 g_list_free (menubars);
765 gtk_menu_shell_cancel (GTK_MENU_SHELL (menubar));
768 g_signal_emit_by_name (to_activate, "activate_item");
772 get_shadow_type (GtkMenuBar *menubar)
774 GtkShadowType shadow_type = GTK_SHADOW_OUT;
776 gtk_widget_style_get (GTK_WIDGET (menubar),
777 "shadow_type", &shadow_type,
784 gtk_menu_bar_get_popup_delay (GtkMenuShell *menu_shell)
788 g_object_get (gtk_widget_get_settings (GTK_WIDGET (menu_shell)),
789 "gtk-menu-bar-popup-delay", &popup_delay,
796 gtk_menu_bar_move_current (GtkMenuShell *menu_shell,
797 GtkMenuDirectionType direction)
799 GtkMenuBar *menubar = GTK_MENU_BAR (menu_shell);
800 GtkTextDirection text_dir;
801 GtkPackDirection pack_dir;
803 text_dir = gtk_widget_get_direction (GTK_WIDGET (menubar));
804 pack_dir = gtk_menu_bar_get_pack_direction (menubar);
806 if (pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL)
808 if ((text_dir == GTK_TEXT_DIR_RTL) == (pack_dir == GTK_PACK_DIRECTION_LTR))
812 case GTK_MENU_DIR_PREV:
813 direction = GTK_MENU_DIR_NEXT;
815 case GTK_MENU_DIR_NEXT:
816 direction = GTK_MENU_DIR_PREV;
826 case GTK_MENU_DIR_PARENT:
827 if ((text_dir == GTK_TEXT_DIR_LTR) == (pack_dir == GTK_PACK_DIRECTION_TTB))
828 direction = GTK_MENU_DIR_PREV;
830 direction = GTK_MENU_DIR_NEXT;
832 case GTK_MENU_DIR_CHILD:
833 if ((text_dir == GTK_TEXT_DIR_LTR) == (pack_dir == GTK_PACK_DIRECTION_TTB))
834 direction = GTK_MENU_DIR_NEXT;
836 direction = GTK_MENU_DIR_PREV;
838 case GTK_MENU_DIR_PREV:
839 if (text_dir == GTK_TEXT_DIR_RTL)
840 direction = GTK_MENU_DIR_CHILD;
842 direction = GTK_MENU_DIR_PARENT;
844 case GTK_MENU_DIR_NEXT:
845 if (text_dir == GTK_TEXT_DIR_RTL)
846 direction = GTK_MENU_DIR_PARENT;
848 direction = GTK_MENU_DIR_CHILD;
854 GTK_MENU_SHELL_CLASS (parent_class)->move_current (menu_shell, direction);
858 * gtk_menu_bar_get_pack_direction:
859 * @menubar: a #GtkMenuBar
861 * Retrieves the current pack direction of the menubar. See
862 * gtk_menu_bar_set_pack_direction().
864 * Return value: the pack direction
869 gtk_menu_bar_get_pack_direction (GtkMenuBar *menubar)
871 GtkMenuBarPrivate *priv;
873 g_return_val_if_fail (GTK_IS_MENU_BAR (menubar),
874 GTK_PACK_DIRECTION_LTR);
876 priv = GTK_MENU_BAR_GET_PRIVATE (menubar);
878 return priv->pack_direction;
882 * gtk_menu_bar_set_pack_direction:
883 * @menubar: a #GtkMenuBar.
884 * @pack_dir: a new #GtkPackDirection.
886 * Sets how items should be packed inside a menubar.
890 void gtk_menu_bar_set_pack_direction (GtkMenuBar *menubar,
891 GtkPackDirection pack_dir)
893 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));
904 g_object_notify (G_OBJECT (menubar), "pack-direction");
909 * gtk_menu_bar_get_child_pack_direction:
910 * @menubar: a #GtkMenuBar
912 * Retrieves the current child pack direction of the menubar. See
913 * gtk_menu_bar_set_child_pack_direction().
915 * Return value: the child pack direction
920 gtk_menu_bar_get_child_pack_direction (GtkMenuBar *menubar)
922 GtkMenuBarPrivate *priv;
924 g_return_val_if_fail (GTK_IS_MENU_BAR (menubar),
925 GTK_PACK_DIRECTION_LTR);
927 priv = GTK_MENU_BAR_GET_PRIVATE (menubar);
929 return priv->child_pack_direction;
933 * gtk_menu_bar_set_child_pack_direction:
934 * @menubar: a #GtkMenuBar.
935 * @child_pack_dir: a new #GtkPackDirection.
937 * Sets how widgets should be packed inside the children of a menubar.
941 void gtk_menu_bar_set_child_pack_direction (GtkMenuBar *menubar,
942 GtkPackDirection child_pack_dir)
944 GtkMenuBarPrivate *priv;
946 g_return_if_fail (GTK_IS_MENU_BAR (menubar));
948 priv = GTK_MENU_BAR_GET_PRIVATE (menubar);
950 if (priv->child_pack_direction != child_pack_dir)
952 priv->child_pack_direction = child_pack_dir;
954 gtk_widget_queue_resize (GTK_WIDGET (menubar));
955 g_object_notify (G_OBJECT (menubar), "child-pack-direction");