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 Library 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 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library 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.
20 #include "gdk/gdkkeysyms.h"
23 #include "gtkmenuitem.h"
24 #include "gtksignal.h"
27 #define MENU_ITEM_CLASS(w) GTK_MENU_ITEM_CLASS (GTK_OBJECT (w)->klass)
28 #define MENU_NEEDS_RESIZE(m) GTK_MENU_SHELL (m)->menu_flag
30 typedef struct _GtkMenuAttachData GtkMenuAttachData;
32 struct _GtkMenuAttachData
34 GtkWidget *attach_widget;
35 GtkMenuDetachFunc detacher;
39 static void gtk_menu_class_init (GtkMenuClass *klass);
40 static void gtk_menu_init (GtkMenu *menu);
41 static void gtk_menu_destroy (GtkObject *object);
42 static void gtk_menu_show (GtkWidget *widget);
43 static void gtk_menu_map (GtkWidget *widget);
44 static void gtk_menu_unmap (GtkWidget *widget);
45 static void gtk_menu_realize (GtkWidget *widget);
46 static void gtk_menu_size_request (GtkWidget *widget,
47 GtkRequisition *requisition);
48 static void gtk_menu_size_allocate (GtkWidget *widget,
49 GtkAllocation *allocation);
50 static void gtk_menu_paint (GtkWidget *widget);
51 static void gtk_menu_draw (GtkWidget *widget,
53 static gint gtk_menu_expose (GtkWidget *widget,
54 GdkEventExpose *event);
55 static gint gtk_menu_configure (GtkWidget *widget,
56 GdkEventConfigure *event);
57 static gint gtk_menu_key_press (GtkWidget *widget,
59 static void gtk_menu_check_resize (GtkContainer *container);
60 static void gtk_menu_deactivate (GtkMenuShell *menu_shell);
61 static void gtk_menu_show_all (GtkWidget *widget);
62 static void gtk_menu_hide_all (GtkWidget *widget);
64 static GtkMenuShellClass *parent_class = NULL;
65 static const gchar *attach_data_key = "gtk-menu-attach-data";
69 gtk_menu_get_type (void)
71 static GtkType menu_type = 0;
75 GtkTypeInfo menu_info =
79 sizeof (GtkMenuClass),
80 (GtkClassInitFunc) gtk_menu_class_init,
81 (GtkObjectInitFunc) gtk_menu_init,
86 menu_type = gtk_type_unique (gtk_menu_shell_get_type (), &menu_info);
93 gtk_menu_class_init (GtkMenuClass *class)
95 GtkObjectClass *object_class;
96 GtkWidgetClass *widget_class;
97 GtkContainerClass *container_class;
98 GtkMenuShellClass *menu_shell_class;
100 object_class = (GtkObjectClass*) class;
101 widget_class = (GtkWidgetClass*) class;
102 container_class = (GtkContainerClass*) class;
103 menu_shell_class = (GtkMenuShellClass*) class;
104 parent_class = gtk_type_class (gtk_menu_shell_get_type ());
106 object_class->destroy = gtk_menu_destroy;
108 widget_class->show = gtk_menu_show;
109 widget_class->map = gtk_menu_map;
110 widget_class->unmap = gtk_menu_unmap;
111 widget_class->realize = gtk_menu_realize;
112 widget_class->draw = gtk_menu_draw;
113 widget_class->size_request = gtk_menu_size_request;
114 widget_class->size_allocate = gtk_menu_size_allocate;
115 widget_class->expose_event = gtk_menu_expose;
116 widget_class->configure_event = gtk_menu_configure;
117 widget_class->key_press_event = gtk_menu_key_press;
118 widget_class->show_all = gtk_menu_show_all;
119 widget_class->hide_all = gtk_menu_hide_all;
121 container_class->check_resize = gtk_menu_check_resize;
123 menu_shell_class->submenu_placement = GTK_LEFT_RIGHT;
124 menu_shell_class->deactivate = gtk_menu_deactivate;
128 gtk_menu_init (GtkMenu *menu)
130 GTK_WIDGET_SET_FLAGS (menu, GTK_TOPLEVEL);
132 gtk_container_set_resize_mode (GTK_CONTAINER (menu), GTK_RESIZE_QUEUE);
134 menu->parent_menu_item = NULL;
135 menu->old_active_menu_item = NULL;
136 menu->accel_group = NULL;
137 menu->position_func = NULL;
138 menu->position_func_data = NULL;
140 MENU_NEEDS_RESIZE (menu) = TRUE;
144 gtk_menu_destroy (GtkObject *object)
146 GtkMenuAttachData *data;
148 g_return_if_fail (object != NULL);
149 g_return_if_fail (GTK_IS_MENU (object));
151 gtk_widget_ref (GTK_WIDGET (object));
153 data = gtk_object_get_data (object, attach_data_key);
155 gtk_menu_detach (GTK_MENU (object));
157 gtk_menu_set_accel_group (GTK_MENU (object), NULL);
159 if (GTK_OBJECT_CLASS (parent_class)->destroy)
160 (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
162 gtk_widget_unref (GTK_WIDGET (object));
167 gtk_menu_attach_to_widget (GtkMenu *menu,
168 GtkWidget *attach_widget,
169 GtkMenuDetachFunc detacher)
171 GtkMenuAttachData *data;
173 g_return_if_fail (menu != NULL);
174 g_return_if_fail (GTK_IS_MENU (menu));
175 g_return_if_fail (attach_widget != NULL);
176 g_return_if_fail (GTK_IS_WIDGET (attach_widget));
177 g_return_if_fail (detacher != NULL);
179 /* keep this function in sync with gtk_widget_set_parent()
182 data = gtk_object_get_data (GTK_OBJECT (menu), attach_data_key);
185 g_warning ("gtk_menu_attach_to_widget(): menu already attached to %s",
186 gtk_type_name (GTK_OBJECT_TYPE (data->attach_widget)));
190 gtk_widget_ref (GTK_WIDGET (menu));
191 gtk_object_sink (GTK_OBJECT (menu));
193 data = g_new (GtkMenuAttachData, 1);
194 data->attach_widget = attach_widget;
195 data->detacher = detacher;
196 gtk_object_set_data (GTK_OBJECT (menu), attach_data_key, data);
198 if (GTK_WIDGET_STATE (menu) != GTK_STATE_NORMAL)
199 gtk_widget_set_state (GTK_WIDGET (menu), GTK_STATE_NORMAL);
201 /* we don't need to set the style here, since
202 * we are a toplevel widget.
207 gtk_menu_get_attach_widget (GtkMenu *menu)
209 GtkMenuAttachData *data;
211 g_return_val_if_fail (menu != NULL, NULL);
212 g_return_val_if_fail (GTK_IS_MENU (menu), NULL);
214 data = gtk_object_get_data (GTK_OBJECT (menu), attach_data_key);
216 return data->attach_widget;
221 gtk_menu_detach (GtkMenu *menu)
223 GtkMenuAttachData *data;
225 g_return_if_fail (menu != NULL);
226 g_return_if_fail (GTK_IS_MENU (menu));
228 /* keep this function in sync with gtk_widget_unparent()
230 data = gtk_object_get_data (GTK_OBJECT (menu), attach_data_key);
233 g_warning ("gtk_menu_detach(): menu is not attached");
236 gtk_object_remove_data (GTK_OBJECT (menu), attach_data_key);
238 data->detacher (data->attach_widget, menu);
240 if (GTK_WIDGET_REALIZED (menu))
241 gtk_widget_unrealize (GTK_WIDGET (menu));
245 gtk_widget_unref (GTK_WIDGET (menu));
251 return GTK_WIDGET (gtk_type_new (gtk_menu_get_type ()));
255 gtk_menu_append (GtkMenu *menu,
258 gtk_menu_shell_append (GTK_MENU_SHELL (menu), child);
262 gtk_menu_prepend (GtkMenu *menu,
265 gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), child);
269 gtk_menu_insert (GtkMenu *menu,
273 gtk_menu_shell_insert (GTK_MENU_SHELL (menu), child, position);
277 gtk_menu_popup (GtkMenu *menu,
278 GtkWidget *parent_menu_shell,
279 GtkWidget *parent_menu_item,
280 GtkMenuPositionFunc func,
283 guint32 activate_time)
285 GtkWidget *xgrab_shell;
288 g_return_if_fail (menu != NULL);
289 g_return_if_fail (GTK_IS_MENU (menu));
291 GTK_MENU_SHELL (menu)->parent_menu_shell = parent_menu_shell;
292 GTK_MENU_SHELL (menu)->active = TRUE;
293 GTK_MENU_SHELL (menu)->button = button;
295 menu->parent_menu_item = parent_menu_item;
296 menu->position_func = func;
297 menu->position_func_data = data;
298 GTK_MENU_SHELL (menu)->activate_time = activate_time;
300 gtk_widget_show (GTK_WIDGET (menu));
302 /* Find the last viewable ancestor, and make an X grab on it
304 parent = GTK_WIDGET (menu);
308 gboolean viewable = TRUE;
309 GtkWidget *tmp = parent;
313 if (!GTK_WIDGET_MAPPED (tmp))
322 xgrab_shell = parent;
324 parent = GTK_MENU_SHELL (parent)->parent_menu_shell;
327 if (xgrab_shell && (!GTK_MENU_SHELL (xgrab_shell)->have_xgrab))
329 GdkCursor *cursor = gdk_cursor_new (GDK_ARROW);
331 GTK_MENU_SHELL (xgrab_shell)->have_xgrab =
332 (gdk_pointer_grab (xgrab_shell->window, TRUE,
333 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
334 GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK,
335 NULL, cursor, activate_time) == 0);
336 gdk_cursor_destroy (cursor);
339 gtk_grab_add (GTK_WIDGET (menu));
343 gtk_menu_popdown (GtkMenu *menu)
345 GtkMenuShell *menu_shell;
347 g_return_if_fail (menu != NULL);
348 g_return_if_fail (GTK_IS_MENU (menu));
350 menu_shell = GTK_MENU_SHELL (menu);
352 menu_shell->parent_menu_shell = NULL;
353 menu_shell->active = FALSE;
355 if (menu_shell->active_menu_item)
357 menu->old_active_menu_item = menu_shell->active_menu_item;
358 gtk_menu_item_deselect (GTK_MENU_ITEM (menu_shell->active_menu_item));
359 menu_shell->active_menu_item = NULL;
362 /* The X Grab, if present, will automatically be removed when we hide
364 gtk_widget_hide (GTK_WIDGET (menu));
365 menu_shell->have_xgrab = FALSE;
367 gtk_grab_remove (GTK_WIDGET (menu));
371 gtk_menu_get_active (GtkMenu *menu)
376 g_return_val_if_fail (menu != NULL, NULL);
377 g_return_val_if_fail (GTK_IS_MENU (menu), NULL);
379 if (!menu->old_active_menu_item)
382 children = GTK_MENU_SHELL (menu)->children;
386 child = children->data;
387 children = children->next;
389 if (GTK_BIN (child)->child)
394 menu->old_active_menu_item = child;
397 return menu->old_active_menu_item;
401 gtk_menu_set_active (GtkMenu *menu,
407 g_return_if_fail (menu != NULL);
408 g_return_if_fail (GTK_IS_MENU (menu));
410 tmp_list = g_list_nth (GTK_MENU_SHELL (menu)->children, index);
413 child = tmp_list->data;
414 if (GTK_BIN (child)->child)
415 menu->old_active_menu_item = child;
420 gtk_menu_set_accel_group (GtkMenu *menu,
421 GtkAccelGroup *accel_group)
423 g_return_if_fail (menu != NULL);
424 g_return_if_fail (GTK_IS_MENU (menu));
426 if (menu->accel_group != accel_group)
428 if (menu->accel_group)
429 gtk_accel_group_unref (menu->accel_group);
430 menu->accel_group = accel_group;
431 if (menu->accel_group)
432 gtk_accel_group_ref (menu->accel_group);
438 gtk_menu_show (GtkWidget *widget)
440 g_return_if_fail (widget != NULL);
441 g_return_if_fail (GTK_IS_MENU (widget));
443 GTK_WIDGET_SET_FLAGS (widget, GTK_VISIBLE);
444 if (MENU_NEEDS_RESIZE (widget))
445 gtk_container_check_resize (GTK_CONTAINER (widget));
446 gtk_widget_map (widget);
450 gtk_menu_reposition (GtkMenu *menu)
454 g_return_if_fail (menu != NULL);
455 g_return_if_fail (GTK_IS_MENU (menu));
457 widget = GTK_WIDGET (menu);
459 if (GTK_WIDGET_DRAWABLE (menu))
463 gdk_window_get_pointer (NULL, &x, &y, NULL);
465 if (menu->position_func)
466 (* menu->position_func) (menu, &x, &y, menu->position_func_data);
472 screen_width = gdk_screen_width ();
473 screen_height = gdk_screen_height ();
478 if ((x + widget->requisition.width) > screen_width)
479 x -= ((x + widget->requisition.width) - screen_width);
482 if ((y + widget->requisition.height) > screen_height)
483 y -= ((y + widget->requisition.height) - screen_height);
488 gdk_window_move (widget->window, x, y);
493 gtk_menu_map (GtkWidget *widget)
496 GtkMenuShell *menu_shell;
500 g_return_if_fail (widget != NULL);
501 g_return_if_fail (GTK_IS_MENU (widget));
503 menu = GTK_MENU (widget);
504 menu_shell = GTK_MENU_SHELL (widget);
505 GTK_WIDGET_SET_FLAGS (menu_shell, GTK_MAPPED);
507 gtk_menu_reposition (menu);
509 children = menu_shell->children;
512 child = children->data;
513 children = children->next;
515 if (GTK_WIDGET_VISIBLE (child) && !GTK_WIDGET_MAPPED (child))
516 gtk_widget_map (child);
519 gdk_window_show (widget->window);
523 gtk_menu_unmap (GtkWidget *widget)
525 g_return_if_fail (widget != NULL);
526 g_return_if_fail (GTK_IS_MENU (widget));
528 GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
529 gdk_window_hide (widget->window);
533 gtk_menu_realize (GtkWidget *widget)
535 GdkWindowAttr attributes;
536 gint attributes_mask;
538 g_return_if_fail (widget != NULL);
539 g_return_if_fail (GTK_IS_MENU (widget));
541 GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
543 attributes.x = widget->allocation.x;
544 attributes.y = widget->allocation.y;
545 attributes.width = widget->allocation.width;
546 attributes.height = widget->allocation.height;
547 attributes.wclass = GDK_INPUT_OUTPUT;
548 attributes.visual = gtk_widget_get_visual (widget);
549 attributes.colormap = gtk_widget_get_colormap (widget);
550 attributes.window_type = GDK_WINDOW_TEMP;
551 attributes.event_mask = gtk_widget_get_events (widget);
552 attributes.event_mask |= (GDK_EXPOSURE_MASK |
556 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
557 widget->window = gdk_window_new (NULL, &attributes, attributes_mask);
558 gdk_window_set_user_data (widget->window, widget);
560 widget->style = gtk_style_attach (widget->style, widget->window);
561 gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
565 gtk_menu_size_request (GtkWidget *widget,
566 GtkRequisition *requisition)
569 GtkMenuShell *menu_shell;
572 guint max_toggle_size;
573 guint max_accel_width;
575 g_return_if_fail (widget != NULL);
576 g_return_if_fail (GTK_IS_MENU (widget));
577 g_return_if_fail (requisition != NULL);
579 menu = GTK_MENU (widget);
580 menu_shell = GTK_MENU_SHELL (widget);
582 requisition->width = 0;
583 requisition->height = 0;
588 children = menu_shell->children;
591 child = children->data;
592 children = children->next;
594 if (GTK_WIDGET_VISIBLE (child))
596 GTK_MENU_ITEM (child)->show_submenu_indicator = TRUE;
597 gtk_widget_size_request (child, &child->requisition);
599 requisition->width = MAX (requisition->width, child->requisition.width);
600 requisition->height += child->requisition.height;
602 max_toggle_size = MAX (max_toggle_size, MENU_ITEM_CLASS (child)->toggle_size);
603 max_accel_width = MAX (max_accel_width, GTK_MENU_ITEM (child)->accelerator_width);
607 requisition->width += max_toggle_size + max_accel_width;
608 requisition->width += (GTK_CONTAINER (menu)->border_width +
609 widget->style->klass->xthickness) * 2;
610 requisition->height += (GTK_CONTAINER (menu)->border_width +
611 widget->style->klass->ythickness) * 2;
613 children = menu_shell->children;
616 child = children->data;
617 children = children->next;
619 GTK_MENU_ITEM (child)->toggle_size = max_toggle_size;
624 gtk_menu_size_allocate (GtkWidget *widget,
625 GtkAllocation *allocation)
628 GtkMenuShell *menu_shell;
630 GtkAllocation child_allocation;
633 g_return_if_fail (widget != NULL);
634 g_return_if_fail (GTK_IS_MENU (widget));
635 g_return_if_fail (allocation != NULL);
637 menu = GTK_MENU (widget);
638 menu_shell = GTK_MENU_SHELL (widget);
640 widget->allocation = *allocation;
642 if (menu_shell->children)
644 child_allocation.x = (GTK_CONTAINER (menu)->border_width +
645 widget->style->klass->xthickness);
646 child_allocation.y = (GTK_CONTAINER (menu)->border_width +
647 widget->style->klass->ythickness);
648 child_allocation.width = MAX (1, allocation->width - child_allocation.x * 2);
650 children = menu_shell->children;
653 child = children->data;
654 children = children->next;
656 if (GTK_WIDGET_VISIBLE (child))
658 child_allocation.height = child->requisition.height;
660 gtk_widget_size_allocate (child, &child_allocation);
661 gtk_widget_queue_draw (child);
663 child_allocation.y += child_allocation.height;
668 if (GTK_WIDGET_REALIZED (widget))
670 gdk_window_resize (widget->window,
671 widget->requisition.width,
672 widget->requisition.height);
677 gtk_menu_paint (GtkWidget *widget)
679 g_return_if_fail (widget != NULL);
680 g_return_if_fail (GTK_IS_MENU (widget));
682 if (GTK_WIDGET_DRAWABLE (widget))
684 gtk_draw_shadow (widget->style,
689 widget->allocation.width,
690 widget->allocation.height);
695 gtk_menu_draw (GtkWidget *widget,
698 GtkMenuShell *menu_shell;
700 GdkRectangle child_area;
703 g_return_if_fail (widget != NULL);
704 g_return_if_fail (GTK_IS_MENU (widget));
705 g_return_if_fail (area != NULL);
707 if (GTK_WIDGET_DRAWABLE (widget))
709 gtk_menu_paint (widget);
711 menu_shell = GTK_MENU_SHELL (widget);
713 children = menu_shell->children;
716 child = children->data;
717 children = children->next;
719 if (gtk_widget_intersect (child, area, &child_area))
720 gtk_widget_draw (child, &child_area);
726 gtk_menu_expose (GtkWidget *widget,
727 GdkEventExpose *event)
729 GtkMenuShell *menu_shell;
731 GdkEventExpose child_event;
734 g_return_val_if_fail (widget != NULL, FALSE);
735 g_return_val_if_fail (GTK_IS_MENU (widget), FALSE);
736 g_return_val_if_fail (event != NULL, FALSE);
738 if (GTK_WIDGET_DRAWABLE (widget))
740 gtk_menu_paint (widget);
742 menu_shell = GTK_MENU_SHELL (widget);
743 child_event = *event;
745 children = menu_shell->children;
748 child = children->data;
749 children = children->next;
751 if (GTK_WIDGET_NO_WINDOW (child) &&
752 gtk_widget_intersect (child, &event->area, &child_event.area))
753 gtk_widget_event (child, (GdkEvent*) &child_event);
761 gtk_menu_configure (GtkWidget *widget,
762 GdkEventConfigure *event)
764 GtkAllocation allocation;
766 g_return_val_if_fail (widget != NULL, FALSE);
767 g_return_val_if_fail (GTK_IS_MENU (widget), FALSE);
768 g_return_val_if_fail (event != NULL, FALSE);
770 /* If the window was merely moved, do nothing */
771 if ((widget->allocation.width == event->width) &&
772 (widget->allocation.height == event->height))
775 if (MENU_NEEDS_RESIZE (widget))
777 MENU_NEEDS_RESIZE (widget) = FALSE;
781 allocation.width = event->width;
782 allocation.height = event->height;
784 gtk_widget_size_allocate (widget, &allocation);
791 gtk_menu_key_press (GtkWidget *widget,
796 g_return_val_if_fail (widget != NULL, FALSE);
797 g_return_val_if_fail (GTK_IS_MENU (widget), FALSE);
798 g_return_val_if_fail (event != NULL, FALSE);
800 delete = (event->keyval == GDK_Delete ||
801 event->keyval == GDK_KP_Delete ||
802 event->keyval == GDK_BackSpace);
804 if (delete || gtk_accelerator_valid (event->keyval, event->keyval))
806 GtkMenuShell *menu_shell;
808 menu_shell = GTK_MENU_SHELL (widget);
810 if (menu_shell->active_menu_item &&
811 GTK_BIN (menu_shell->active_menu_item)->child &&
812 GTK_MENU_ITEM (menu_shell->active_menu_item)->submenu == NULL)
814 GtkMenuItem *menu_item;
815 GtkAccelGroup *accel_group;
817 menu_item = GTK_MENU_ITEM (menu_shell->active_menu_item);
819 if (!GTK_MENU (widget)->accel_group)
820 accel_group = gtk_accel_group_get_default ();
822 accel_group = GTK_MENU (widget)->accel_group;
824 gtk_widget_remove_accelerators (GTK_WIDGET (menu_item),
825 gtk_signal_name (menu_item->accelerator_signal),
829 0 == gtk_widget_accelerator_signal (GTK_WIDGET (menu_item),
836 slist = gtk_accel_group_entries_from_object (GTK_OBJECT (menu_item));
839 GtkAccelEntry *ac_entry;
841 ac_entry = slist->data;
843 if (ac_entry->signal_id == menu_item->accelerator_signal)
850 gtk_widget_add_accelerator (GTK_WIDGET (menu_item),
851 gtk_signal_name (menu_item->accelerator_signal),
864 gtk_menu_check_resize (GtkContainer *container)
866 GtkAllocation allocation;
869 g_return_if_fail (container != NULL);
870 g_return_if_fail (GTK_IS_MENU (container));
872 widget = GTK_WIDGET (container);
874 if (GTK_WIDGET_VISIBLE (container))
876 MENU_NEEDS_RESIZE (container) = FALSE;
878 gtk_widget_size_request (widget, &widget->requisition);
880 allocation.x = widget->allocation.x;
881 allocation.y = widget->allocation.y;
882 allocation.width = widget->requisition.width;
883 allocation.height = widget->requisition.height;
885 gtk_widget_size_allocate (widget, &allocation);
888 MENU_NEEDS_RESIZE (container) = TRUE;
892 gtk_menu_deactivate (GtkMenuShell *menu_shell)
896 g_return_if_fail (menu_shell != NULL);
897 g_return_if_fail (GTK_IS_MENU (menu_shell));
899 parent = menu_shell->parent_menu_shell;
901 menu_shell->activate_time = 0;
902 gtk_menu_popdown (GTK_MENU (menu_shell));
905 gtk_menu_shell_deactivate (GTK_MENU_SHELL (parent));
910 gtk_menu_show_all (GtkWidget *widget)
912 GtkContainer *container;
914 g_return_if_fail (widget != NULL);
915 g_return_if_fail (GTK_IS_MENU (widget));
916 container = GTK_CONTAINER (widget);
918 /* Show children, but not self. */
919 gtk_container_foreach (container, (GtkCallback) gtk_widget_show_all, NULL);
924 gtk_menu_hide_all (GtkWidget *widget)
926 GtkContainer *container;
928 g_return_if_fail (widget != NULL);
929 g_return_if_fail (GTK_IS_MENU (widget));
930 container = GTK_CONTAINER (widget);
932 /* Hide children, but not self. */
933 gtk_container_foreach (container, (GtkCallback) gtk_widget_hide_all, NULL);