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,
82 /* reversed_1 */ NULL,
83 /* reversed_2 */ NULL,
84 (GtkClassInitFunc) NULL,
87 menu_type = gtk_type_unique (gtk_menu_shell_get_type (), &menu_info);
94 gtk_menu_class_init (GtkMenuClass *class)
96 GtkObjectClass *object_class;
97 GtkWidgetClass *widget_class;
98 GtkContainerClass *container_class;
99 GtkMenuShellClass *menu_shell_class;
101 object_class = (GtkObjectClass*) class;
102 widget_class = (GtkWidgetClass*) class;
103 container_class = (GtkContainerClass*) class;
104 menu_shell_class = (GtkMenuShellClass*) class;
105 parent_class = gtk_type_class (gtk_menu_shell_get_type ());
107 object_class->destroy = gtk_menu_destroy;
109 widget_class->show = gtk_menu_show;
110 widget_class->map = gtk_menu_map;
111 widget_class->unmap = gtk_menu_unmap;
112 widget_class->realize = gtk_menu_realize;
113 widget_class->draw = gtk_menu_draw;
114 widget_class->size_request = gtk_menu_size_request;
115 widget_class->size_allocate = gtk_menu_size_allocate;
116 widget_class->expose_event = gtk_menu_expose;
117 widget_class->configure_event = gtk_menu_configure;
118 widget_class->key_press_event = gtk_menu_key_press;
119 widget_class->show_all = gtk_menu_show_all;
120 widget_class->hide_all = gtk_menu_hide_all;
122 container_class->check_resize = gtk_menu_check_resize;
124 menu_shell_class->submenu_placement = GTK_LEFT_RIGHT;
125 menu_shell_class->deactivate = gtk_menu_deactivate;
129 gtk_menu_init (GtkMenu *menu)
131 GTK_WIDGET_SET_FLAGS (menu, GTK_TOPLEVEL);
133 gtk_container_set_resize_mode (GTK_CONTAINER (menu), GTK_RESIZE_QUEUE);
135 menu->parent_menu_item = NULL;
136 menu->old_active_menu_item = NULL;
137 menu->accel_group = NULL;
138 menu->position_func = NULL;
139 menu->position_func_data = NULL;
141 MENU_NEEDS_RESIZE (menu) = TRUE;
145 gtk_menu_destroy (GtkObject *object)
147 GtkMenuAttachData *data;
149 g_return_if_fail (object != NULL);
150 g_return_if_fail (GTK_IS_MENU (object));
152 gtk_widget_ref (GTK_WIDGET (object));
154 data = gtk_object_get_data (object, attach_data_key);
156 gtk_menu_detach (GTK_MENU (object));
158 gtk_menu_set_accel_group (GTK_MENU (object), NULL);
160 if (GTK_OBJECT_CLASS (parent_class)->destroy)
161 (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
163 gtk_widget_unref (GTK_WIDGET (object));
168 gtk_menu_attach_to_widget (GtkMenu *menu,
169 GtkWidget *attach_widget,
170 GtkMenuDetachFunc detacher)
172 GtkMenuAttachData *data;
174 g_return_if_fail (menu != NULL);
175 g_return_if_fail (GTK_IS_MENU (menu));
176 g_return_if_fail (attach_widget != NULL);
177 g_return_if_fail (GTK_IS_WIDGET (attach_widget));
178 g_return_if_fail (detacher != NULL);
180 /* keep this function in sync with gtk_widget_set_parent()
183 data = gtk_object_get_data (GTK_OBJECT (menu), attach_data_key);
186 g_warning ("gtk_menu_attach_to_widget(): menu already attached to %s",
187 gtk_type_name (GTK_OBJECT_TYPE (data->attach_widget)));
191 gtk_widget_ref (GTK_WIDGET (menu));
192 gtk_object_sink (GTK_OBJECT (menu));
194 data = g_new (GtkMenuAttachData, 1);
195 data->attach_widget = attach_widget;
196 data->detacher = detacher;
197 gtk_object_set_data (GTK_OBJECT (menu), attach_data_key, data);
199 if (GTK_WIDGET_STATE (menu) != GTK_STATE_NORMAL)
200 gtk_widget_set_state (GTK_WIDGET (menu), GTK_STATE_NORMAL);
202 /* we don't need to set the style here, since
203 * we are a toplevel widget.
208 gtk_menu_get_attach_widget (GtkMenu *menu)
210 GtkMenuAttachData *data;
212 g_return_val_if_fail (menu != NULL, NULL);
213 g_return_val_if_fail (GTK_IS_MENU (menu), NULL);
215 data = gtk_object_get_data (GTK_OBJECT (menu), attach_data_key);
217 return data->attach_widget;
222 gtk_menu_detach (GtkMenu *menu)
224 GtkMenuAttachData *data;
226 g_return_if_fail (menu != NULL);
227 g_return_if_fail (GTK_IS_MENU (menu));
229 /* keep this function in sync with gtk_widget_unparent()
231 data = gtk_object_get_data (GTK_OBJECT (menu), attach_data_key);
234 g_warning ("gtk_menu_detach(): menu is not attached");
237 gtk_object_remove_data (GTK_OBJECT (menu), attach_data_key);
239 data->detacher (data->attach_widget, menu);
241 if (GTK_WIDGET_REALIZED (menu))
242 gtk_widget_unrealize (GTK_WIDGET (menu));
246 gtk_widget_unref (GTK_WIDGET (menu));
252 return GTK_WIDGET (gtk_type_new (gtk_menu_get_type ()));
256 gtk_menu_append (GtkMenu *menu,
259 gtk_menu_shell_append (GTK_MENU_SHELL (menu), child);
263 gtk_menu_prepend (GtkMenu *menu,
266 gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), child);
270 gtk_menu_insert (GtkMenu *menu,
274 gtk_menu_shell_insert (GTK_MENU_SHELL (menu), child, position);
278 gtk_menu_popup (GtkMenu *menu,
279 GtkWidget *parent_menu_shell,
280 GtkWidget *parent_menu_item,
281 GtkMenuPositionFunc func,
284 guint32 activate_time)
286 GtkWidget *xgrab_shell;
289 g_return_if_fail (menu != NULL);
290 g_return_if_fail (GTK_IS_MENU (menu));
292 GTK_MENU_SHELL (menu)->parent_menu_shell = parent_menu_shell;
293 GTK_MENU_SHELL (menu)->active = TRUE;
294 GTK_MENU_SHELL (menu)->button = button;
296 menu->parent_menu_item = parent_menu_item;
297 menu->position_func = func;
298 menu->position_func_data = data;
299 GTK_MENU_SHELL (menu)->activate_time = activate_time;
301 gtk_widget_show (GTK_WIDGET (menu));
303 /* Find the last viewable ancestor, and make an X grab on it
305 parent = GTK_WIDGET (menu);
309 gboolean viewable = TRUE;
310 GtkWidget *tmp = parent;
314 if (!GTK_WIDGET_MAPPED (tmp))
323 xgrab_shell = parent;
325 parent = GTK_MENU_SHELL (parent)->parent_menu_shell;
328 if (xgrab_shell && (!GTK_MENU_SHELL (xgrab_shell)->have_xgrab))
330 GdkCursor *cursor = gdk_cursor_new (GDK_ARROW);
332 GTK_MENU_SHELL (xgrab_shell)->have_xgrab =
333 (gdk_pointer_grab (xgrab_shell->window, TRUE,
334 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
335 GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK,
336 NULL, cursor, activate_time) == 0);
337 gdk_cursor_destroy (cursor);
340 gtk_grab_add (GTK_WIDGET (menu));
344 gtk_menu_popdown (GtkMenu *menu)
346 GtkMenuShell *menu_shell;
348 g_return_if_fail (menu != NULL);
349 g_return_if_fail (GTK_IS_MENU (menu));
351 menu_shell = GTK_MENU_SHELL (menu);
353 menu_shell->parent_menu_shell = NULL;
354 menu_shell->active = FALSE;
356 if (menu_shell->active_menu_item)
358 menu->old_active_menu_item = menu_shell->active_menu_item;
359 gtk_menu_item_deselect (GTK_MENU_ITEM (menu_shell->active_menu_item));
360 menu_shell->active_menu_item = NULL;
363 /* The X Grab, if present, will automatically be removed when we hide
365 gtk_widget_hide (GTK_WIDGET (menu));
366 menu_shell->have_xgrab = FALSE;
368 gtk_grab_remove (GTK_WIDGET (menu));
372 gtk_menu_get_active (GtkMenu *menu)
377 g_return_val_if_fail (menu != NULL, NULL);
378 g_return_val_if_fail (GTK_IS_MENU (menu), NULL);
380 if (!menu->old_active_menu_item)
383 children = GTK_MENU_SHELL (menu)->children;
387 child = children->data;
388 children = children->next;
390 if (GTK_BIN (child)->child)
395 menu->old_active_menu_item = child;
398 return menu->old_active_menu_item;
402 gtk_menu_set_active (GtkMenu *menu,
408 g_return_if_fail (menu != NULL);
409 g_return_if_fail (GTK_IS_MENU (menu));
411 tmp_list = g_list_nth (GTK_MENU_SHELL (menu)->children, index);
414 child = tmp_list->data;
415 if (GTK_BIN (child)->child)
416 menu->old_active_menu_item = child;
421 gtk_menu_set_accel_group (GtkMenu *menu,
422 GtkAccelGroup *accel_group)
424 g_return_if_fail (menu != NULL);
425 g_return_if_fail (GTK_IS_MENU (menu));
427 if (menu->accel_group != accel_group)
429 if (menu->accel_group)
430 gtk_accel_group_unref (menu->accel_group);
431 menu->accel_group = accel_group;
432 if (menu->accel_group)
433 gtk_accel_group_ref (menu->accel_group);
439 gtk_menu_show (GtkWidget *widget)
441 g_return_if_fail (widget != NULL);
442 g_return_if_fail (GTK_IS_MENU (widget));
444 GTK_WIDGET_SET_FLAGS (widget, GTK_VISIBLE);
445 if (MENU_NEEDS_RESIZE (widget))
446 gtk_container_check_resize (GTK_CONTAINER (widget));
447 gtk_widget_map (widget);
451 gtk_menu_reposition (GtkMenu *menu)
455 g_return_if_fail (menu != NULL);
456 g_return_if_fail (GTK_IS_MENU (menu));
458 widget = GTK_WIDGET (menu);
460 if (GTK_WIDGET_DRAWABLE (menu))
464 gdk_window_get_pointer (NULL, &x, &y, NULL);
466 if (menu->position_func)
467 (* menu->position_func) (menu, &x, &y, menu->position_func_data);
473 screen_width = gdk_screen_width ();
474 screen_height = gdk_screen_height ();
479 if ((x + widget->requisition.width) > screen_width)
480 x -= ((x + widget->requisition.width) - screen_width);
483 if ((y + widget->requisition.height) > screen_height)
484 y -= ((y + widget->requisition.height) - screen_height);
489 gdk_window_move (widget->window, x, y);
494 gtk_menu_map (GtkWidget *widget)
497 GtkMenuShell *menu_shell;
501 g_return_if_fail (widget != NULL);
502 g_return_if_fail (GTK_IS_MENU (widget));
504 menu = GTK_MENU (widget);
505 menu_shell = GTK_MENU_SHELL (widget);
506 GTK_WIDGET_SET_FLAGS (menu_shell, GTK_MAPPED);
508 gtk_menu_reposition (menu);
510 children = menu_shell->children;
513 child = children->data;
514 children = children->next;
516 if (GTK_WIDGET_VISIBLE (child) && !GTK_WIDGET_MAPPED (child))
517 gtk_widget_map (child);
520 gdk_window_show (widget->window);
524 gtk_menu_unmap (GtkWidget *widget)
526 g_return_if_fail (widget != NULL);
527 g_return_if_fail (GTK_IS_MENU (widget));
529 GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
530 gdk_window_hide (widget->window);
534 gtk_menu_realize (GtkWidget *widget)
536 GdkWindowAttr attributes;
537 gint attributes_mask;
539 g_return_if_fail (widget != NULL);
540 g_return_if_fail (GTK_IS_MENU (widget));
542 GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
544 attributes.x = widget->allocation.x;
545 attributes.y = widget->allocation.y;
546 attributes.width = widget->allocation.width;
547 attributes.height = widget->allocation.height;
548 attributes.wclass = GDK_INPUT_OUTPUT;
549 attributes.visual = gtk_widget_get_visual (widget);
550 attributes.colormap = gtk_widget_get_colormap (widget);
551 attributes.window_type = GDK_WINDOW_TEMP;
552 attributes.event_mask = gtk_widget_get_events (widget);
553 attributes.event_mask |= (GDK_EXPOSURE_MASK |
557 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
558 widget->window = gdk_window_new (NULL, &attributes, attributes_mask);
559 gdk_window_set_user_data (widget->window, widget);
561 widget->style = gtk_style_attach (widget->style, widget->window);
562 gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
566 gtk_menu_size_request (GtkWidget *widget,
567 GtkRequisition *requisition)
570 GtkMenuShell *menu_shell;
573 guint max_toggle_size;
574 guint max_accel_width;
576 g_return_if_fail (widget != NULL);
577 g_return_if_fail (GTK_IS_MENU (widget));
578 g_return_if_fail (requisition != NULL);
580 menu = GTK_MENU (widget);
581 menu_shell = GTK_MENU_SHELL (widget);
583 requisition->width = 0;
584 requisition->height = 0;
589 children = menu_shell->children;
592 child = children->data;
593 children = children->next;
595 if (GTK_WIDGET_VISIBLE (child))
597 GTK_MENU_ITEM (child)->show_submenu_indicator = TRUE;
598 gtk_widget_size_request (child, &child->requisition);
600 requisition->width = MAX (requisition->width, child->requisition.width);
601 requisition->height += child->requisition.height;
603 max_toggle_size = MAX (max_toggle_size, MENU_ITEM_CLASS (child)->toggle_size);
604 max_accel_width = MAX (max_accel_width, GTK_MENU_ITEM (child)->accelerator_width);
608 requisition->width += max_toggle_size + max_accel_width;
609 requisition->width += (GTK_CONTAINER (menu)->border_width +
610 widget->style->klass->xthickness) * 2;
611 requisition->height += (GTK_CONTAINER (menu)->border_width +
612 widget->style->klass->ythickness) * 2;
614 children = menu_shell->children;
617 child = children->data;
618 children = children->next;
620 GTK_MENU_ITEM (child)->toggle_size = max_toggle_size;
625 gtk_menu_size_allocate (GtkWidget *widget,
626 GtkAllocation *allocation)
629 GtkMenuShell *menu_shell;
631 GtkAllocation child_allocation;
634 g_return_if_fail (widget != NULL);
635 g_return_if_fail (GTK_IS_MENU (widget));
636 g_return_if_fail (allocation != NULL);
638 menu = GTK_MENU (widget);
639 menu_shell = GTK_MENU_SHELL (widget);
641 widget->allocation = *allocation;
643 if (menu_shell->children)
645 child_allocation.x = (GTK_CONTAINER (menu)->border_width +
646 widget->style->klass->xthickness);
647 child_allocation.y = (GTK_CONTAINER (menu)->border_width +
648 widget->style->klass->ythickness);
649 child_allocation.width = MAX (1, allocation->width - child_allocation.x * 2);
651 children = menu_shell->children;
654 child = children->data;
655 children = children->next;
657 if (GTK_WIDGET_VISIBLE (child))
659 child_allocation.height = child->requisition.height;
661 gtk_widget_size_allocate (child, &child_allocation);
662 gtk_widget_queue_draw (child);
664 child_allocation.y += child_allocation.height;
669 if (GTK_WIDGET_REALIZED (widget))
671 gdk_window_resize (widget->window,
672 widget->requisition.width,
673 widget->requisition.height);
678 gtk_menu_paint (GtkWidget *widget)
680 g_return_if_fail (widget != NULL);
681 g_return_if_fail (GTK_IS_MENU (widget));
683 if (GTK_WIDGET_DRAWABLE (widget))
685 gtk_draw_shadow (widget->style,
690 widget->allocation.width,
691 widget->allocation.height);
696 gtk_menu_draw (GtkWidget *widget,
699 GtkMenuShell *menu_shell;
701 GdkRectangle child_area;
704 g_return_if_fail (widget != NULL);
705 g_return_if_fail (GTK_IS_MENU (widget));
706 g_return_if_fail (area != NULL);
708 if (GTK_WIDGET_DRAWABLE (widget))
710 gtk_menu_paint (widget);
712 menu_shell = GTK_MENU_SHELL (widget);
714 children = menu_shell->children;
717 child = children->data;
718 children = children->next;
720 if (gtk_widget_intersect (child, area, &child_area))
721 gtk_widget_draw (child, &child_area);
727 gtk_menu_expose (GtkWidget *widget,
728 GdkEventExpose *event)
730 GtkMenuShell *menu_shell;
732 GdkEventExpose child_event;
735 g_return_val_if_fail (widget != NULL, FALSE);
736 g_return_val_if_fail (GTK_IS_MENU (widget), FALSE);
737 g_return_val_if_fail (event != NULL, FALSE);
739 if (GTK_WIDGET_DRAWABLE (widget))
741 gtk_menu_paint (widget);
743 menu_shell = GTK_MENU_SHELL (widget);
744 child_event = *event;
746 children = menu_shell->children;
749 child = children->data;
750 children = children->next;
752 if (GTK_WIDGET_NO_WINDOW (child) &&
753 gtk_widget_intersect (child, &event->area, &child_event.area))
754 gtk_widget_event (child, (GdkEvent*) &child_event);
762 gtk_menu_configure (GtkWidget *widget,
763 GdkEventConfigure *event)
765 GtkAllocation allocation;
767 g_return_val_if_fail (widget != NULL, FALSE);
768 g_return_val_if_fail (GTK_IS_MENU (widget), FALSE);
769 g_return_val_if_fail (event != NULL, FALSE);
771 /* If the window was merely moved, do nothing */
772 if ((widget->allocation.width == event->width) &&
773 (widget->allocation.height == event->height))
776 if (MENU_NEEDS_RESIZE (widget))
778 MENU_NEEDS_RESIZE (widget) = FALSE;
782 allocation.width = event->width;
783 allocation.height = event->height;
785 gtk_widget_size_allocate (widget, &allocation);
792 gtk_menu_key_press (GtkWidget *widget,
797 g_return_val_if_fail (widget != NULL, FALSE);
798 g_return_val_if_fail (GTK_IS_MENU (widget), FALSE);
799 g_return_val_if_fail (event != NULL, FALSE);
801 delete = (event->keyval == GDK_Delete ||
802 event->keyval == GDK_KP_Delete ||
803 event->keyval == GDK_BackSpace);
805 if (delete || gtk_accelerator_valid (event->keyval, event->keyval))
807 GtkMenuShell *menu_shell;
809 menu_shell = GTK_MENU_SHELL (widget);
811 if (menu_shell->active_menu_item &&
812 GTK_BIN (menu_shell->active_menu_item)->child &&
813 GTK_MENU_ITEM (menu_shell->active_menu_item)->submenu == NULL)
815 GtkMenuItem *menu_item;
816 GtkAccelGroup *accel_group;
818 menu_item = GTK_MENU_ITEM (menu_shell->active_menu_item);
820 if (!GTK_MENU (widget)->accel_group)
821 accel_group = gtk_accel_group_get_default ();
823 accel_group = GTK_MENU (widget)->accel_group;
825 gtk_widget_remove_accelerators (GTK_WIDGET (menu_item),
826 gtk_signal_name (menu_item->accelerator_signal),
830 0 == gtk_widget_accelerator_signal (GTK_WIDGET (menu_item),
837 slist = gtk_accel_group_entries_from_object (GTK_OBJECT (menu_item));
840 GtkAccelEntry *ac_entry;
842 ac_entry = slist->data;
844 if (ac_entry->signal_id == menu_item->accelerator_signal)
851 gtk_widget_add_accelerator (GTK_WIDGET (menu_item),
852 gtk_signal_name (menu_item->accelerator_signal),
865 gtk_menu_check_resize (GtkContainer *container)
867 GtkAllocation allocation;
870 g_return_if_fail (container != NULL);
871 g_return_if_fail (GTK_IS_MENU (container));
873 widget = GTK_WIDGET (container);
875 if (GTK_WIDGET_VISIBLE (container))
877 MENU_NEEDS_RESIZE (container) = FALSE;
879 gtk_widget_size_request (widget, &widget->requisition);
881 allocation.x = widget->allocation.x;
882 allocation.y = widget->allocation.y;
883 allocation.width = widget->requisition.width;
884 allocation.height = widget->requisition.height;
886 gtk_widget_size_allocate (widget, &allocation);
889 MENU_NEEDS_RESIZE (container) = TRUE;
893 gtk_menu_deactivate (GtkMenuShell *menu_shell)
897 g_return_if_fail (menu_shell != NULL);
898 g_return_if_fail (GTK_IS_MENU (menu_shell));
900 parent = menu_shell->parent_menu_shell;
902 menu_shell->activate_time = 0;
903 gtk_menu_popdown (GTK_MENU (menu_shell));
906 gtk_menu_shell_deactivate (GTK_MENU_SHELL (parent));
911 gtk_menu_show_all (GtkWidget *widget)
913 GtkContainer *container;
915 g_return_if_fail (widget != NULL);
916 g_return_if_fail (GTK_IS_MENU (widget));
917 container = GTK_CONTAINER (widget);
919 /* Show children, but not self. */
920 gtk_container_foreach (container, (GtkCallback) gtk_widget_show_all, NULL);
925 gtk_menu_hide_all (GtkWidget *widget)
927 GtkContainer *container;
929 g_return_if_fail (widget != NULL);
930 g_return_if_fail (GTK_IS_MENU (widget));
931 container = GTK_CONTAINER (widget);
933 /* Hide children, but not self. */
934 gtk_container_foreach (container, (GtkCallback) gtk_widget_hide_all, NULL);