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/.
29 #include "gtkmenubar.h"
31 #include "gtkbindings.h"
33 #include "gtkmarshalers.h"
34 #include "gtkmenuitemprivate.h"
35 #include "gtkmenuprivate.h"
36 #include "gtkmenushellprivate.h"
37 #include "gtksettings.h"
38 #include "gtksizerequest.h"
39 #include "gtkwindow.h"
42 #include "gtkprivate.h"
44 #define BORDER_SPACING 0
45 #define DEFAULT_IPADDING 1
51 PROP_CHILD_PACK_DIRECTION
54 struct _GtkMenuBarPrivate
56 GtkPackDirection pack_direction;
57 GtkPackDirection child_pack_direction;
61 static void gtk_menu_bar_set_property (GObject *object,
65 static void gtk_menu_bar_get_property (GObject *object,
69 static void gtk_menu_bar_size_request (GtkWidget *widget,
70 GtkRequisition *requisition);
71 static void gtk_menu_bar_get_preferred_width (GtkWidget *widget,
74 static void gtk_menu_bar_get_preferred_height (GtkWidget *widget,
77 static void gtk_menu_bar_size_allocate (GtkWidget *widget,
78 GtkAllocation *allocation);
79 static gint gtk_menu_bar_draw (GtkWidget *widget,
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);
87 static GtkShadowType get_shadow_type (GtkMenuBar *menubar);
89 G_DEFINE_TYPE (GtkMenuBar, gtk_menu_bar, GTK_TYPE_MENU_SHELL)
92 gtk_menu_bar_class_init (GtkMenuBarClass *class)
94 GObjectClass *gobject_class;
95 GtkWidgetClass *widget_class;
96 GtkMenuShellClass *menu_shell_class;
98 GtkBindingSet *binding_set;
100 gobject_class = (GObjectClass*) class;
101 widget_class = (GtkWidgetClass*) class;
102 menu_shell_class = (GtkMenuShellClass*) class;
104 gobject_class->get_property = gtk_menu_bar_get_property;
105 gobject_class->set_property = gtk_menu_bar_set_property;
107 widget_class->get_preferred_width = gtk_menu_bar_get_preferred_width;
108 widget_class->get_preferred_height = gtk_menu_bar_get_preferred_height;
109 widget_class->size_allocate = gtk_menu_bar_size_allocate;
110 widget_class->draw = gtk_menu_bar_draw;
111 widget_class->hierarchy_changed = gtk_menu_bar_hierarchy_changed;
113 menu_shell_class->submenu_placement = GTK_TOP_BOTTOM;
114 menu_shell_class->get_popup_delay = gtk_menu_bar_get_popup_delay;
115 menu_shell_class->move_current = gtk_menu_bar_move_current;
117 binding_set = gtk_binding_set_by_class (class);
118 gtk_binding_entry_add_signal (binding_set,
121 GTK_TYPE_MENU_DIRECTION_TYPE,
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,
142 GTK_MENU_DIR_PARENT);
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,
153 gtk_binding_entry_add_signal (binding_set,
156 GTK_TYPE_MENU_DIRECTION_TYPE,
160 * GtkMenuBar:pack-direction:
162 * The pack direction of the menubar. It determines how
163 * menuitems are arranged in the menubar.
167 g_object_class_install_property (gobject_class,
169 g_param_spec_enum ("pack-direction",
170 P_("Pack direction"),
171 P_("The pack direction of the menubar"),
172 GTK_TYPE_PACK_DIRECTION,
173 GTK_PACK_DIRECTION_LTR,
174 GTK_PARAM_READWRITE));
177 * GtkMenuBar:child-pack-direction:
179 * The child pack direction of the menubar. It determines how
180 * the widgets contained in child menuitems are arranged.
184 g_object_class_install_property (gobject_class,
185 PROP_CHILD_PACK_DIRECTION,
186 g_param_spec_enum ("child-pack-direction",
187 P_("Child Pack direction"),
188 P_("The child pack direction of the menubar"),
189 GTK_TYPE_PACK_DIRECTION,
190 GTK_PACK_DIRECTION_LTR,
191 GTK_PARAM_READWRITE));
194 gtk_widget_class_install_style_property (widget_class,
195 g_param_spec_enum ("shadow-type",
197 P_("Style of bevel around the menubar"),
198 GTK_TYPE_SHADOW_TYPE,
200 GTK_PARAM_READABLE));
202 gtk_widget_class_install_style_property (widget_class,
203 g_param_spec_int ("internal-padding",
204 P_("Internal padding"),
205 P_("Amount of border space between the menubar shadow and the menu items"),
209 GTK_PARAM_READABLE));
211 g_type_class_add_private (gobject_class, sizeof (GtkMenuBarPrivate));
215 gtk_menu_bar_init (GtkMenuBar *menu_bar)
217 GtkStyleContext *context;
219 menu_bar->priv = G_TYPE_INSTANCE_GET_PRIVATE (menu_bar,
223 context = gtk_widget_get_style_context (GTK_WIDGET (menu_bar));
224 gtk_style_context_add_class (context, GTK_STYLE_CLASS_MENUBAR);
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;
291 g_return_if_fail (GTK_IS_MENU_BAR (widget));
292 g_return_if_fail (requisition != NULL);
294 requisition->width = 0;
295 requisition->height = 0;
297 if (gtk_widget_get_visible (widget))
299 menu_bar = GTK_MENU_BAR (widget);
300 menu_shell = GTK_MENU_SHELL (widget);
301 priv = menu_bar->priv;
304 children = menu_shell->priv->children;
308 child = children->data;
309 children = children->next;
311 if (gtk_widget_get_visible (child))
315 gtk_widget_get_preferred_size (child, &child_requisition, NULL);
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 border_width = gtk_container_get_border_width (GTK_CONTAINER (menu_bar));
343 requisition->width += (border_width +
346 requisition->height += (border_width +
350 if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE)
352 GtkStyleContext *context;
355 context = gtk_widget_get_style_context (widget);
357 gtk_style_context_get (context, 0,
358 "border-width", &border,
361 requisition->width += border->left + border->right;
362 requisition->height += border->top + border->bottom;
363 gtk_border_free (border);
369 gtk_menu_bar_get_preferred_width (GtkWidget *widget,
373 GtkRequisition requisition;
375 gtk_menu_bar_size_request (widget, &requisition);
377 *minimum = *natural = requisition.width;
381 gtk_menu_bar_get_preferred_height (GtkWidget *widget,
385 GtkRequisition requisition;
387 gtk_menu_bar_size_request (widget, &requisition);
389 *minimum = *natural = requisition.height;
393 gtk_menu_bar_size_allocate (GtkWidget *widget,
394 GtkAllocation *allocation)
396 GtkMenuBar *menu_bar;
397 GtkMenuShell *menu_shell;
398 GtkMenuBarPrivate *priv;
401 GtkAllocation child_allocation;
402 GtkRequisition child_requisition;
404 GtkTextDirection direction;
409 g_return_if_fail (GTK_IS_MENU_BAR (widget));
410 g_return_if_fail (allocation != NULL);
412 menu_bar = GTK_MENU_BAR (widget);
413 menu_shell = GTK_MENU_SHELL (widget);
414 priv = menu_bar->priv;
416 direction = gtk_widget_get_direction (widget);
418 gtk_widget_set_allocation (widget, allocation);
420 if (gtk_widget_get_realized (widget))
421 gdk_window_move_resize (gtk_widget_get_window (widget),
422 allocation->x, allocation->y,
423 allocation->width, allocation->height);
425 gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL);
427 if (menu_shell->priv->children)
429 border_width = gtk_container_get_border_width (GTK_CONTAINER (menu_bar));
430 child_allocation.x = (border_width +
433 child_allocation.y = (border_width +
436 if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE)
438 GtkStyleContext *context;
441 context = gtk_widget_get_style_context (widget);
442 gtk_style_context_get (context, 0,
443 "border-width", &border,
446 child_allocation.x += border->left;
447 child_allocation.y += border->top;
449 gtk_border_free (border);
452 if (priv->pack_direction == GTK_PACK_DIRECTION_LTR ||
453 priv->pack_direction == GTK_PACK_DIRECTION_RTL)
455 child_allocation.height = MAX (1, (gint)allocation->height - child_allocation.y * 2);
457 offset = child_allocation.x; /* Window edge to menubar start */
458 ltr_x = child_allocation.x;
460 children = menu_shell->priv->children;
465 child = children->data;
466 children = children->next;
468 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
470 gtk_widget_get_preferred_size (child, &child_requisition, NULL);
472 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
473 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
474 child_requisition.width += toggle_size;
476 child_requisition.height += toggle_size;
478 /* Support for the right justified help menu */
479 if (children == NULL &&
480 GTK_IS_MENU_ITEM (child) &&
481 GTK_MENU_ITEM (child)->priv->right_justify)
483 ltr_x = allocation->width -
484 child_requisition.width - offset;
486 if (gtk_widget_get_visible (child))
488 if ((direction == GTK_TEXT_DIR_LTR) == (priv->pack_direction == GTK_PACK_DIRECTION_LTR))
489 child_allocation.x = ltr_x;
491 child_allocation.x = allocation->width -
492 child_requisition.width - ltr_x;
494 child_allocation.width = child_requisition.width;
496 gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (child),
498 gtk_widget_size_allocate (child, &child_allocation);
500 ltr_x += child_allocation.width;
506 child_allocation.width = MAX (1, (gint)allocation->width - child_allocation.x * 2);
508 offset = child_allocation.y; /* Window edge to menubar start */
509 ltr_y = child_allocation.y;
511 children = menu_shell->priv->children;
516 child = children->data;
517 children = children->next;
519 gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
521 gtk_widget_get_preferred_size (child, &child_requisition, NULL);
523 if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
524 priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
525 child_requisition.width += toggle_size;
527 child_requisition.height += toggle_size;
529 /* Support for the right justified help menu */
530 if (children == NULL &&
531 GTK_IS_MENU_ITEM (child) &&
532 GTK_MENU_ITEM (child)->priv->right_justify)
534 ltr_y = allocation->height -
535 child_requisition.height - offset;
537 if (gtk_widget_get_visible (child))
539 if ((direction == GTK_TEXT_DIR_LTR) ==
540 (priv->pack_direction == GTK_PACK_DIRECTION_TTB))
541 child_allocation.y = ltr_y;
543 child_allocation.y = allocation->height -
544 child_requisition.height - ltr_y;
545 child_allocation.height = child_requisition.height;
547 gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (child),
549 gtk_widget_size_allocate (child, &child_allocation);
551 ltr_y += child_allocation.height;
559 gtk_menu_bar_draw (GtkWidget *widget,
562 GtkStyleContext *context;
566 border = gtk_container_get_border_width (GTK_CONTAINER (widget));
567 context = gtk_widget_get_style_context (widget);
569 state = gtk_widget_get_state_flags (widget);
570 gtk_style_context_set_state (context, state);
572 if (get_shadow_type (GTK_MENU_BAR (widget)) != GTK_SHADOW_NONE)
573 gtk_render_background (context, cr,
575 gtk_widget_get_allocated_width (widget) - border * 2,
576 gtk_widget_get_allocated_height (widget) - border * 2);
578 gtk_render_frame (context, cr,
580 gtk_widget_get_allocated_width (widget) - border * 2,
581 gtk_widget_get_allocated_height (widget) - border * 2);
583 GTK_WIDGET_CLASS (gtk_menu_bar_parent_class)->draw (widget, cr);
589 get_menu_bars (GtkWindow *window)
591 return g_object_get_data (G_OBJECT (window), "gtk-menu-bar-list");
595 get_viewable_menu_bars (GtkWindow *window)
598 GList *viewable_menu_bars = NULL;
600 for (menu_bars = get_menu_bars (window);
602 menu_bars = menu_bars->next)
604 GtkWidget *widget = menu_bars->data;
605 gboolean viewable = TRUE;
609 if (!gtk_widget_get_mapped (widget))
612 widget = gtk_widget_get_parent (widget);
616 viewable_menu_bars = g_list_prepend (viewable_menu_bars, menu_bars->data);
619 return g_list_reverse (viewable_menu_bars);
623 set_menu_bars (GtkWindow *window,
626 g_object_set_data (G_OBJECT (window), I_("gtk-menu-bar-list"), menubars);
630 window_key_press_handler (GtkWidget *widget,
635 gboolean retval = FALSE;
637 g_object_get (gtk_widget_get_settings (widget),
638 "gtk-menu-bar-accel", &accel,
644 GdkModifierType mods = 0;
646 gtk_accelerator_parse (accel, &keyval, &mods);
649 g_warning ("Failed to parse menu bar accelerator '%s'\n", accel);
651 /* FIXME this is wrong, needs to be in the global accel resolution
652 * thing, to properly consider i18n etc., but that probably requires
653 * AccelGroup changes etc.
655 if (event->keyval == keyval &&
656 ((event->state & gtk_accelerator_get_default_mod_mask ()) ==
657 (mods & gtk_accelerator_get_default_mod_mask ())))
659 GList *tmp_menubars = get_viewable_menu_bars (GTK_WINDOW (widget));
662 menubars = _gtk_container_focus_sort (GTK_CONTAINER (widget), tmp_menubars,
663 GTK_DIR_TAB_FORWARD, NULL);
664 g_list_free (tmp_menubars);
668 GtkMenuShell *menu_shell = GTK_MENU_SHELL (menubars->data);
670 _gtk_menu_shell_set_keyboard_mode (menu_shell, TRUE);
671 _gtk_menu_shell_activate (menu_shell);
672 gtk_menu_shell_select_first (menu_shell, FALSE);
674 g_list_free (menubars);
687 add_to_window (GtkWindow *window,
690 GList *menubars = get_menu_bars (window);
694 g_signal_connect (window,
696 G_CALLBACK (window_key_press_handler),
700 set_menu_bars (window, g_list_prepend (menubars, menubar));
704 remove_from_window (GtkWindow *window,
707 GList *menubars = get_menu_bars (window);
709 menubars = g_list_remove (menubars, menubar);
713 g_signal_handlers_disconnect_by_func (window,
714 window_key_press_handler,
718 set_menu_bars (window, menubars);
722 gtk_menu_bar_hierarchy_changed (GtkWidget *widget,
723 GtkWidget *old_toplevel)
728 menubar = GTK_MENU_BAR (widget);
730 toplevel = gtk_widget_get_toplevel (widget);
733 remove_from_window (GTK_WINDOW (old_toplevel), menubar);
735 if (gtk_widget_is_toplevel (toplevel))
736 add_to_window (GTK_WINDOW (toplevel), menubar);
740 * _gtk_menu_bar_cycle_focus:
741 * @menubar: a #GtkMenuBar
742 * @dir: direction in which to cycle the focus
744 * Move the focus between menubars in the toplevel.
747 _gtk_menu_bar_cycle_focus (GtkMenuBar *menubar,
748 GtkDirectionType dir)
750 GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (menubar));
751 GtkMenuItem *to_activate = NULL;
753 if (gtk_widget_is_toplevel (toplevel))
755 GList *tmp_menubars = get_viewable_menu_bars (GTK_WINDOW (toplevel));
759 menubars = _gtk_container_focus_sort (GTK_CONTAINER (toplevel), tmp_menubars,
760 dir, GTK_WIDGET (menubar));
761 g_list_free (tmp_menubars);
765 current = g_list_find (menubars, menubar);
767 if (current && current->next)
769 GtkMenuShell *new_menushell = GTK_MENU_SHELL (current->next->data);
770 if (new_menushell->priv->children)
771 to_activate = new_menushell->priv->children->data;
775 g_list_free (menubars);
778 gtk_menu_shell_cancel (GTK_MENU_SHELL (menubar));
781 g_signal_emit_by_name (to_activate, "activate_item");
785 get_shadow_type (GtkMenuBar *menubar)
787 GtkShadowType shadow_type = GTK_SHADOW_OUT;
789 gtk_widget_style_get (GTK_WIDGET (menubar),
790 "shadow-type", &shadow_type,
797 gtk_menu_bar_get_popup_delay (GtkMenuShell *menu_shell)
801 g_object_get (gtk_widget_get_settings (GTK_WIDGET (menu_shell)),
802 "gtk-menu-bar-popup-delay", &popup_delay,
809 gtk_menu_bar_move_current (GtkMenuShell *menu_shell,
810 GtkMenuDirectionType direction)
812 GtkMenuBar *menubar = GTK_MENU_BAR (menu_shell);
813 GtkTextDirection text_dir;
814 GtkPackDirection pack_dir;
816 text_dir = gtk_widget_get_direction (GTK_WIDGET (menubar));
817 pack_dir = gtk_menu_bar_get_pack_direction (menubar);
819 if (pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL)
821 if ((text_dir == GTK_TEXT_DIR_RTL) == (pack_dir == GTK_PACK_DIRECTION_LTR))
825 case GTK_MENU_DIR_PREV:
826 direction = GTK_MENU_DIR_NEXT;
828 case GTK_MENU_DIR_NEXT:
829 direction = GTK_MENU_DIR_PREV;
839 case GTK_MENU_DIR_PARENT:
840 if ((text_dir == GTK_TEXT_DIR_LTR) == (pack_dir == GTK_PACK_DIRECTION_TTB))
841 direction = GTK_MENU_DIR_PREV;
843 direction = GTK_MENU_DIR_NEXT;
845 case GTK_MENU_DIR_CHILD:
846 if ((text_dir == GTK_TEXT_DIR_LTR) == (pack_dir == GTK_PACK_DIRECTION_TTB))
847 direction = GTK_MENU_DIR_NEXT;
849 direction = GTK_MENU_DIR_PREV;
851 case GTK_MENU_DIR_PREV:
852 if (text_dir == GTK_TEXT_DIR_RTL)
853 direction = GTK_MENU_DIR_CHILD;
855 direction = GTK_MENU_DIR_PARENT;
857 case GTK_MENU_DIR_NEXT:
858 if (text_dir == GTK_TEXT_DIR_RTL)
859 direction = GTK_MENU_DIR_PARENT;
861 direction = GTK_MENU_DIR_CHILD;
867 GTK_MENU_SHELL_CLASS (gtk_menu_bar_parent_class)->move_current (menu_shell, direction);
871 * gtk_menu_bar_get_pack_direction:
872 * @menubar: a #GtkMenuBar
874 * Retrieves the current pack direction of the menubar.
875 * See gtk_menu_bar_set_pack_direction().
877 * Return value: the pack direction
882 gtk_menu_bar_get_pack_direction (GtkMenuBar *menubar)
884 g_return_val_if_fail (GTK_IS_MENU_BAR (menubar),
885 GTK_PACK_DIRECTION_LTR);
887 return menubar->priv->pack_direction;
891 * gtk_menu_bar_set_pack_direction:
892 * @menubar: a #GtkMenuBar
893 * @pack_dir: a new #GtkPackDirection
895 * Sets how items should be packed inside a menubar.
900 gtk_menu_bar_set_pack_direction (GtkMenuBar *menubar,
901 GtkPackDirection pack_dir)
903 GtkMenuBarPrivate *priv;
906 g_return_if_fail (GTK_IS_MENU_BAR (menubar));
908 priv = menubar->priv;
910 if (priv->pack_direction != pack_dir)
912 priv->pack_direction = pack_dir;
914 gtk_widget_queue_resize (GTK_WIDGET (menubar));
916 for (l = GTK_MENU_SHELL (menubar)->priv->children; l; l = l->next)
917 gtk_widget_queue_resize (GTK_WIDGET (l->data));
919 g_object_notify (G_OBJECT (menubar), "pack-direction");
924 * gtk_menu_bar_get_child_pack_direction:
925 * @menubar: a #GtkMenuBar
927 * Retrieves the current child pack direction of the menubar.
928 * See gtk_menu_bar_set_child_pack_direction().
930 * Return value: the child pack direction
935 gtk_menu_bar_get_child_pack_direction (GtkMenuBar *menubar)
937 g_return_val_if_fail (GTK_IS_MENU_BAR (menubar),
938 GTK_PACK_DIRECTION_LTR);
940 return menubar->priv->child_pack_direction;
944 * gtk_menu_bar_set_child_pack_direction:
945 * @menubar: a #GtkMenuBar
946 * @child_pack_dir: a new #GtkPackDirection
948 * Sets how widgets should be packed inside the children of a menubar.
953 gtk_menu_bar_set_child_pack_direction (GtkMenuBar *menubar,
954 GtkPackDirection child_pack_dir)
956 GtkMenuBarPrivate *priv;
959 g_return_if_fail (GTK_IS_MENU_BAR (menubar));
961 priv = menubar->priv;
963 if (priv->child_pack_direction != child_pack_dir)
965 priv->child_pack_direction = child_pack_dir;
967 gtk_widget_queue_resize (GTK_WIDGET (menubar));
969 for (l = GTK_MENU_SHELL (menubar)->priv->children; l; l = l->next)
970 gtk_widget_queue_resize (GTK_WIDGET (l->data));
972 g_object_notify (G_OBJECT (menubar), "child-pack-direction");