1 /* GTK - The GIMP Toolkit
3 * Copyright (C) 2003 Ricardo Fernandez Pascual
4 * Copyright (C) 2004 Paolo Borelli
5 * Copyright (C) 2012 Bastien Nocera
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
22 * SECTION:gtkmenubutton
23 * @short_description: A widget that shows a menu when clicked on
24 * @title: GtkMenuButton
26 * The #GtkMenuButton widget is used to display a menu when clicked on.
27 * This menu can be provided either as a #GtkMenu, or an abstract #GMenuModel.
29 * The #GtkMenuButton widget can hold any valid child widget. That is, it
30 * can hold almost any other standard #GtkWidget. The most commonly used
31 * child is the provided #GtkArrow.
33 * The positioning of the menu is determined by the #GtkMenuButton:direction
34 * property of the menu button and the #GtkWidget:halign or #GtkWidget:valign
35 * properties of the menu. For example, when the direction is %GTK_ARROW_DOWN
36 * and the horizontal alignment is %GTK_ALIGN_START, the menu will be
37 * positioned below the button, with the starting edge (depending on the
38 * text direction) of the menu aligned with the starting edge of the button.
39 * If there is not enough space below the button, the menu is popped up above
40 * the button instead. If the alignment would move part of the menu offscreen,
48 * <entry>halign = start</entry>
49 * <entry>halign = center</entry>
50 * <entry>halign = end</entry>
53 * <entry>direction = down</entry>
56 * <imageobject><imagedata fileref="down-start.png" format="PNG"/></imageobject>
57 * </inlinemediaobject>
61 * <imageobject><imagedata fileref="down-center.png" format="PNG"/></imageobject>
62 * </inlinemediaobject>
66 * <imageobject><imagedata fileref="down-end.png" format="PNG"/></imageobject>
67 * </inlinemediaobject>
71 * <entry>direction = up</entry>
74 * <imageobject><imagedata fileref="up-start.png" format="PNG"/></imageobject>
75 * </inlinemediaobject>
79 * <imageobject><imagedata fileref="up-center.png" format="PNG"/></imageobject>
80 * </inlinemediaobject>
84 * <imageobject><imagedata fileref="up-end.png" format="PNG"/></imageobject>
85 * </inlinemediaobject>
96 * <entry>direction = left</entry>
97 * <entry>direction = right</entry>
100 * <entry>valign = start</entry>
102 * <inlinemediaobject>
103 * <imageobject><imagedata fileref="left-start.png" format="PNG"/></imageobject>
104 * </inlinemediaobject>
107 * <inlinemediaobject>
108 * <imageobject><imagedata fileref="right-start.png" format="PNG"/></imageobject>
109 * </inlinemediaobject>
113 * <entry>valign = center</entry>
115 * <inlinemediaobject>
116 * <imageobject><imagedata fileref="left-center.png" format="PNG"/></imageobject>
117 * </inlinemediaobject>
120 * <inlinemediaobject>
121 * <imageobject><imagedata fileref="right-center.png" format="PNG"/></imageobject>
122 * </inlinemediaobject>
126 * <entry>valign = end</entry>
128 * <inlinemediaobject>
129 * <imageobject><imagedata fileref="left-end.png" format="PNG"/></imageobject>
130 * </inlinemediaobject>
133 * <inlinemediaobject>
134 * <imageobject><imagedata fileref="right-end.png" format="PNG"/></imageobject>
135 * </inlinemediaobject>
145 #include "gtkmenubutton.h"
146 #include "gtkmenubuttonprivate.h"
147 #include "gtkarrow.h"
149 #include "gtkprivate.h"
152 struct _GtkMenuButtonPrivate
157 GtkMenuButtonShowMenuCallback func;
160 GtkArrowType arrow_type;
161 GtkWidget *align_widget;
162 gpointer arrow_widget;
174 G_DEFINE_TYPE(GtkMenuButton, gtk_menu_button, GTK_TYPE_TOGGLE_BUTTON)
176 static void gtk_menu_button_dispose (GObject *object);
179 gtk_menu_button_set_property (GObject *object,
184 GtkMenuButton *self = GTK_MENU_BUTTON (object);
189 gtk_menu_button_set_popup (self, g_value_get_object (value));
192 gtk_menu_button_set_menu_model (self, g_value_get_object (value));
194 case PROP_ALIGN_WIDGET:
195 gtk_menu_button_set_align_widget (self, g_value_get_object (value));
198 gtk_menu_button_set_direction (self, g_value_get_enum (value));
201 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
206 gtk_menu_button_get_property (GObject *object,
211 GtkMenuButtonPrivate *priv = GTK_MENU_BUTTON (object)->priv;
216 g_value_set_object (value, priv->popup);
219 g_value_set_object (value, priv->model);
221 case PROP_ALIGN_WIDGET:
222 g_value_set_object (value, priv->align_widget);
225 g_value_set_enum (value, priv->arrow_type);
228 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
233 gtk_menu_button_state_flags_changed (GtkWidget *widget,
234 GtkStateFlags previous_state_flags)
236 GtkMenuButton *button = GTK_MENU_BUTTON (widget);
237 GtkMenuButtonPrivate *priv = button->priv;
239 if (!gtk_widget_is_sensitive (widget) && priv->popup)
240 gtk_menu_shell_deactivate (GTK_MENU_SHELL (priv->popup));
244 menu_position_up_down_func (GtkMenu *menu,
248 GtkMenuButton *menu_button)
250 GtkMenuButtonPrivate *priv = menu_button->priv;
251 GtkWidget *widget = GTK_WIDGET (menu_button);
253 GtkRequisition menu_req;
254 GtkTextDirection direction;
255 GdkRectangle monitor;
259 GtkAllocation allocation, arrow_allocation;
262 /* In the common case the menu button is showing a dropdown menu, set the
263 * corresponding type hint on the toplevel, so the WM can omit the top side
266 if (priv->arrow_type == GTK_ARROW_DOWN)
268 toplevel = gtk_widget_get_toplevel (GTK_WIDGET (priv->popup));
269 gtk_window_set_type_hint (GTK_WINDOW (toplevel), GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU);
272 gtk_widget_get_preferred_size (GTK_WIDGET (priv->popup),
275 align = gtk_widget_get_halign (GTK_WIDGET (priv->popup));
276 direction = gtk_widget_get_direction (widget);
277 window = gtk_widget_get_window (priv->align_widget ? priv->align_widget : widget);
279 screen = gtk_widget_get_screen (GTK_WIDGET (menu));
280 monitor_num = gdk_screen_get_monitor_at_window (screen, window);
283 gdk_screen_get_monitor_workarea (screen, monitor_num, &monitor);
285 gtk_widget_get_allocation (priv->align_widget ? priv->align_widget : widget, &allocation);
286 gtk_widget_get_allocation (widget, &arrow_allocation);
288 gdk_window_get_origin (window, x, y);
292 /* treat the default align value like START */
293 if (align == GTK_ALIGN_FILL)
294 align = GTK_ALIGN_START;
296 if (align == GTK_ALIGN_CENTER)
297 *x -= (menu_req.width - allocation.width) / 2;
298 else if ((align == GTK_ALIGN_START && direction == GTK_TEXT_DIR_LTR) ||
299 (align == GTK_ALIGN_END && direction == GTK_TEXT_DIR_RTL))
300 *x += MAX (allocation.width - menu_req.width, 0);
301 else if (menu_req.width > allocation.width)
302 *x -= menu_req.width - allocation.width;
304 if (priv->arrow_type == GTK_ARROW_UP && *y - menu_req.height >= monitor.y)
306 *y -= menu_req.height;
310 if ((*y + arrow_allocation.height + menu_req.height) <= monitor.y + monitor.height)
311 *y += arrow_allocation.height;
312 else if ((*y - menu_req.height) >= monitor.y)
313 *y -= menu_req.height;
314 else if (monitor.y + monitor.height - (*y + arrow_allocation.height) > *y)
315 *y += arrow_allocation.height;
317 *y -= menu_req.height;
324 menu_position_side_func (GtkMenu *menu,
328 GtkMenuButton *menu_button)
330 GtkMenuButtonPrivate *priv = menu_button->priv;
331 GtkAllocation allocation;
332 GtkWidget *widget = GTK_WIDGET (menu_button);
333 GtkRequisition menu_req;
334 GdkRectangle monitor;
340 gtk_widget_get_preferred_size (GTK_WIDGET (priv->popup),
343 window = gtk_widget_get_window (widget);
345 align = gtk_widget_get_valign (GTK_WIDGET (menu));
346 screen = gtk_widget_get_screen (GTK_WIDGET (menu));
347 monitor_num = gdk_screen_get_monitor_at_window (screen, window);
350 gdk_screen_get_monitor_workarea (screen, monitor_num, &monitor);
352 gdk_window_get_origin (gtk_button_get_event_window (GTK_BUTTON (menu_button)), x, y);
354 gtk_widget_get_allocation (widget, &allocation);
356 if (priv->arrow_type == GTK_ARROW_RIGHT)
358 if (*x + allocation.width + menu_req.width <= monitor.x + monitor.width)
359 *x += allocation.width;
361 *x -= menu_req.width;
365 if (*x - menu_req.width >= monitor.x)
366 *x -= menu_req.width;
368 *x += allocation.width;
371 /* treat the default align value like START */
372 if (align == GTK_ALIGN_FILL)
373 align = GTK_ALIGN_START;
375 if (align == GTK_ALIGN_CENTER)
376 *y -= (menu_req.height - allocation.height) / 2;
377 else if (align == GTK_ALIGN_END)
378 *y -= menu_req.height - allocation.height;
384 popup_menu (GtkMenuButton *menu_button,
385 GdkEventButton *event)
387 GtkMenuButtonPrivate *priv = menu_button->priv;
388 GtkMenuPositionFunc func;
391 priv->func (priv->user_data);
396 switch (priv->arrow_type)
399 case GTK_ARROW_RIGHT:
400 func = (GtkMenuPositionFunc) menu_position_side_func;
403 func = (GtkMenuPositionFunc) menu_position_up_down_func;
407 gtk_menu_popup_for_device (GTK_MENU (priv->popup),
408 event ? event->device : NULL,
411 GTK_WIDGET (menu_button),
413 event ? event->button : 0,
414 event ? event->time : gtk_get_current_event_time ());
418 gtk_menu_button_toggled (GtkToggleButton *button)
420 GtkMenuButton *menu_button = GTK_MENU_BUTTON (button);
421 GtkMenuButtonPrivate *priv = menu_button->priv;
426 if (gtk_toggle_button_get_active (button) &&
427 !gtk_widget_get_visible (GTK_WIDGET (priv->popup)))
429 /* we get here only when the menu is activated by a key
430 * press, so that we can select the first menu item
432 popup_menu (menu_button, NULL);
433 gtk_menu_shell_select_first (GTK_MENU_SHELL (priv->popup), FALSE);
438 gtk_menu_button_button_press_event (GtkWidget *widget,
439 GdkEventButton *event)
441 if (event->button == GDK_BUTTON_PRIMARY)
443 popup_menu (GTK_MENU_BUTTON (widget), event);
444 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
449 return GTK_WIDGET_CLASS (gtk_menu_button_parent_class)->button_press_event (widget, event);
453 gtk_menu_button_add (GtkContainer *container,
456 GtkMenuButton *button = GTK_MENU_BUTTON (container);
458 if (button->priv->arrow_widget)
459 gtk_container_remove (container, button->priv->arrow_widget);
461 GTK_CONTAINER_CLASS (gtk_menu_button_parent_class)->add (container, child);
465 gtk_menu_button_remove (GtkContainer *container,
468 GtkMenuButton *button = GTK_MENU_BUTTON (container);
470 if (child == button->priv->arrow_widget)
471 button->priv->arrow_widget = NULL;
473 GTK_CONTAINER_CLASS (gtk_menu_button_parent_class)->remove (container, child);
477 gtk_menu_button_class_init (GtkMenuButtonClass *klass)
479 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
480 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
481 GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
482 GtkToggleButtonClass *toggle_button_class = GTK_TOGGLE_BUTTON_CLASS (klass);
484 g_type_class_add_private (klass, sizeof (GtkMenuButtonPrivate));
486 gobject_class->set_property = gtk_menu_button_set_property;
487 gobject_class->get_property = gtk_menu_button_get_property;
488 gobject_class->dispose = gtk_menu_button_dispose;
490 widget_class->state_flags_changed = gtk_menu_button_state_flags_changed;
491 widget_class->button_press_event = gtk_menu_button_button_press_event;
493 container_class->add = gtk_menu_button_add;
494 container_class->remove = gtk_menu_button_remove;
496 toggle_button_class->toggled = gtk_menu_button_toggled;
499 * GtkMenuButton:popup:
501 * The #GtkMenu that will be popped up when the button is clicked.
505 g_object_class_install_property (gobject_class,
507 g_param_spec_object ("popup",
509 P_("The dropdown menu."),
513 * GtkMenuButton:menu:
515 * The #GtkMenu that will be popped up when the button is clicked.
516 * This property has been renamed to "popup". "menu" will be
517 * removed before 3.6.0.
521 g_object_class_install_property (gobject_class,
522 PROP_POPUP, /* [sic] */
523 g_param_spec_object ("menu",
525 P_("The dropdown menu."),
527 G_PARAM_DEPRECATED | G_PARAM_READWRITE));
529 * GtkMenuButton:menu-model:
531 * The #GMenuModel from which the menu to pop up will be created.
532 * See gtk_menu_button_set_menu_model() for the interaction with the
533 * #GtkMenuButton:menu property.
537 g_object_class_install_property (gobject_class,
539 g_param_spec_object ("menu-model",
541 P_("The dropdown menu's model."),
545 * GtkMenuButton:align-widget:
547 * The #GtkWidget to use to align the popup menu with.
551 g_object_class_install_property (gobject_class,
553 g_param_spec_object ("align-widget",
555 P_("The parent widget which the menu should align with."),
559 * GtkMenuButton:direction:
561 * The #GtkArrowType representing the direction in which the
562 * menu will be popped out.
566 g_object_class_install_property (gobject_class,
568 g_param_spec_enum ("direction",
570 P_("The direction the arrow should point."),
577 add_arrow (GtkMenuButton *menu_button)
581 arrow = gtk_arrow_new (menu_button->priv->arrow_type, GTK_SHADOW_NONE);
582 gtk_container_add (GTK_CONTAINER (menu_button), arrow);
583 gtk_widget_show (arrow);
584 menu_button->priv->arrow_widget = arrow;
588 gtk_menu_button_init (GtkMenuButton *menu_button)
590 GtkMenuButtonPrivate *priv;
592 priv = G_TYPE_INSTANCE_GET_PRIVATE (menu_button, GTK_TYPE_MENU_BUTTON, GtkMenuButtonPrivate);
593 menu_button->priv = priv;
594 priv->arrow_type = GTK_ARROW_DOWN;
596 add_arrow (menu_button);
598 gtk_widget_set_sensitive (GTK_WIDGET (menu_button), FALSE);
602 * gtk_menu_button_new:
604 * Creates a new #GtkMenuButton widget with downwards-pointing
605 * arrow as the only child. You can replace the child widget
606 * with another #GtkWidget should you wish to.
608 * Returns: The newly created #GtkMenuButton widget.
613 gtk_menu_button_new (void)
615 return g_object_new (GTK_TYPE_MENU_BUTTON, NULL);
618 /* Callback for the "deactivate" signal on the pop-up menu.
619 * This is used so that we unset the state of the toggle button
620 * when the pop-up menu disappears.
623 menu_deactivate_cb (GtkMenuShell *menu_shell,
624 GtkMenuButton *menu_button)
626 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (menu_button), FALSE);
632 menu_detacher (GtkWidget *widget,
635 GtkMenuButtonPrivate *priv = GTK_MENU_BUTTON (widget)->priv;
637 g_return_if_fail (priv->popup == (GtkWidget *) menu);
642 /* This function is used in GtkMenuToolButton, the call back will
643 * be called when GtkMenuToolButton would have emitted the "show-menu"
647 _gtk_menu_button_set_popup_with_func (GtkMenuButton *menu_button,
649 GtkMenuButtonShowMenuCallback func,
652 GtkMenuButtonPrivate *priv;
654 g_return_if_fail (GTK_IS_MENU_BUTTON (menu_button));
655 g_return_if_fail (GTK_IS_MENU (menu) || menu == NULL);
657 priv = menu_button->priv;
659 priv->user_data = user_data;
661 if (priv->popup == GTK_WIDGET (menu))
666 if (gtk_widget_get_visible (GTK_WIDGET (priv->popup)))
667 gtk_menu_shell_deactivate (GTK_MENU_SHELL (priv->popup));
672 g_signal_handlers_disconnect_by_func (priv->popup,
675 gtk_menu_detach (GTK_MENU (priv->popup));
682 gtk_menu_attach_to_widget (GTK_MENU (priv->popup), GTK_WIDGET (menu_button),
685 gtk_widget_set_sensitive (GTK_WIDGET (menu_button), TRUE);
687 g_signal_connect (priv->popup, "deactivate",
688 G_CALLBACK (menu_deactivate_cb), menu_button);
692 gtk_widget_set_sensitive (GTK_WIDGET (menu_button), FALSE);
695 g_object_notify (G_OBJECT (menu_button), "menu");
696 g_object_notify (G_OBJECT (menu_button), "menu-model");
700 * gtk_menu_button_set_popup:
701 * @menu_button: a #GtkMenuButton
702 * @popup: (allow-none): a #GtkMenu
704 * Sets the #GtkMenu that will be popped up when the button is clicked,
705 * or %NULL to disable the button. If #GtkMenuButton:menu-model is set,
706 * it will be set to %NULL.
711 gtk_menu_button_set_popup (GtkMenuButton *menu_button,
714 GtkMenuButtonPrivate *priv;
716 g_return_if_fail (GTK_IS_MENU_BUTTON (menu_button));
717 g_return_if_fail (GTK_IS_MENU (popup) || popup == NULL);
719 priv = menu_button->priv;
720 g_clear_object (&priv->model);
722 _gtk_menu_button_set_popup_with_func (menu_button, popup, NULL, NULL);
726 * gtk_menu_button_get_popup:
727 * @menu_button: a #GtkMenuButton
729 * Returns the #GtkMenu that pops out of the button.
731 * Returns: (transfer none): a #GtkMenu or %NULL.
736 gtk_menu_button_get_popup (GtkMenuButton *menu_button)
738 g_return_val_if_fail (GTK_IS_MENU_BUTTON (menu_button), NULL);
740 return GTK_MENU (menu_button->priv->popup);
744 gtk_menu_button_set_menu (GtkMenuButton *menu_button,
747 gtk_menu_button_set_popup (menu_button, menu);
751 gtk_menu_button_get_menu (GtkMenuButton *menu_button)
753 return gtk_menu_button_get_popup (menu_button);
757 * gtk_menu_button_set_menu_model:
758 * @menu_button: a #GtkMenuButton
759 * @menu_model: (allow-none): a #GMenuModel
761 * Sets the #GMenuModel from which the #GtkMenuButton:menu property will be
762 * filled in, or %NULL to disable the button.
764 * The #GtkMenu will be created with gtk_menu_new_from_model(), so actions
765 * will be connected as documented there.
767 * If you #GtkMenuButton:menu * is already set, then its content will be lost
768 * and replaced by our newly created #GtkMenu.
773 gtk_menu_button_set_menu_model (GtkMenuButton *menu_button,
774 GMenuModel *menu_model)
776 GtkMenuButtonPrivate *priv;
779 g_return_if_fail (GTK_IS_MENU_BUTTON (menu_button));
780 g_return_if_fail (G_IS_MENU_MODEL (menu_model) || menu_model == NULL);
782 priv = menu_button->priv;
783 g_clear_object (&priv->model);
785 if (menu_model == NULL)
787 gtk_menu_button_set_popup (menu_button, NULL);
791 priv->model = g_object_ref (menu_model);
792 menu = gtk_menu_new_from_model (menu_model);
793 gtk_widget_show_all (menu);
794 gtk_menu_button_set_popup (menu_button, menu);
798 * gtk_menu_button_get_menu_model:
799 * @menu_button: a #GtkMenuButton
801 * Returns the #GMenuModel used to generate the menu.
803 * Returns: (transfer none): a #GMenuModel or %NULL.
808 gtk_menu_button_get_menu_model (GtkMenuButton *menu_button)
810 g_return_val_if_fail (GTK_IS_MENU_BUTTON (menu_button), NULL);
812 return menu_button->priv->model;
816 * gtk_menu_button_set_align_widget:
817 * @menu_button: a #GtkMenuButton
818 * @align_widget: (allow-none): a #GtkWidget
820 * Sets the #GtkWidget to use to line the menu with when popped up. Note that
821 * the @align_widget must contain the #GtkMenuButton itself.
823 * Setting it to %NULL means that the popup menu will be aligned with the
829 gtk_menu_button_set_align_widget (GtkMenuButton *menu_button,
830 GtkWidget *align_widget)
832 GtkMenuButtonPrivate *priv;
834 g_return_if_fail (GTK_IS_MENU_BUTTON (menu_button));
835 g_return_if_fail (align_widget == NULL || gtk_widget_is_ancestor (GTK_WIDGET (menu_button), align_widget));
837 priv = menu_button->priv;
838 if (priv->align_widget == align_widget)
841 priv->align_widget = align_widget;
843 if (priv->align_widget)
844 g_object_add_weak_pointer (G_OBJECT (priv->align_widget), (gpointer *) &priv->align_widget);
846 g_object_notify (G_OBJECT (menu_button), "align-widget");
850 * gtk_menu_button_get_align_widget:
851 * @menu_button: a #GtkMenuButton
853 * Returns the parent #GtkWidget to use to line up with menu.
855 * Returns: (transfer none): a #GtkWidget value or %NULL.
860 gtk_menu_button_get_align_widget (GtkMenuButton *menu_button)
862 g_return_val_if_fail (GTK_IS_MENU_BUTTON (menu_button), NULL);
864 return menu_button->priv->align_widget;
868 * gtk_menu_button_set_direction:
869 * @menu_button: a #GtkMenuButton
870 * @direction: a #GtkArrowType
872 * Sets the direction in which the menu will be popped up, as
873 * well as changing the arrow's direction. The child will not
874 * be changed to an arrow if it was customized.
876 * If the menu when popped out would have collided with screen edges,
877 * we will do our best to keep it inside the screen and fully visible.
879 * If you pass GTK_ARROW_NONE for a @direction, the menu will behave
880 * as if you passed GTK_ARROW_DOWN (although you won't see any arrows).
885 gtk_menu_button_set_direction (GtkMenuButton *menu_button,
886 GtkArrowType direction)
888 GtkMenuButtonPrivate *priv = menu_button->priv;
891 g_return_if_fail (GTK_IS_MENU_BUTTON (menu_button));
893 if (priv->arrow_type == direction)
896 priv->arrow_type = direction;
898 /* Is it custom content? We don't change that */
899 child = gtk_bin_get_child (GTK_BIN (menu_button));
900 if (priv->arrow_widget != child)
903 gtk_arrow_set (GTK_ARROW (child), priv->arrow_type, GTK_SHADOW_NONE);
907 * gtk_menu_button_get_direction:
908 * @menu_button: a #GtkMenuButton
910 * Returns the direction the menu will be pointing at when popped up.
912 * Returns: a #GtkArrowType value.
917 gtk_menu_button_get_direction (GtkMenuButton *menu_button)
919 g_return_val_if_fail (GTK_IS_MENU_BUTTON (menu_button), GTK_ARROW_DOWN);
921 return menu_button->priv->arrow_type;
925 gtk_menu_button_dispose (GObject *object)
927 GtkMenuButtonPrivate *priv = GTK_MENU_BUTTON (object)->priv;
931 g_signal_handlers_disconnect_by_func (priv->popup,
934 gtk_menu_detach (GTK_MENU (priv->popup));
937 g_clear_object (&priv->model);
939 G_OBJECT_CLASS (gtk_menu_button_parent_class)->dispose (object);