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"
148 #include "gtktypebuiltins.h"
149 #include "gtkwindow.h"
152 #include "gtkprivate.h"
155 struct _GtkMenuButtonPrivate
160 GtkMenuButtonShowMenuCallback func;
163 GtkArrowType arrow_type;
164 GtkWidget *align_widget;
165 gpointer arrow_widget;
177 G_DEFINE_TYPE(GtkMenuButton, gtk_menu_button, GTK_TYPE_TOGGLE_BUTTON)
179 static void gtk_menu_button_dispose (GObject *object);
182 gtk_menu_button_set_property (GObject *object,
187 GtkMenuButton *self = GTK_MENU_BUTTON (object);
192 gtk_menu_button_set_popup (self, g_value_get_object (value));
195 gtk_menu_button_set_menu_model (self, g_value_get_object (value));
197 case PROP_ALIGN_WIDGET:
198 gtk_menu_button_set_align_widget (self, g_value_get_object (value));
201 gtk_menu_button_set_direction (self, g_value_get_enum (value));
204 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
209 gtk_menu_button_get_property (GObject *object,
214 GtkMenuButtonPrivate *priv = GTK_MENU_BUTTON (object)->priv;
219 g_value_set_object (value, priv->popup);
222 g_value_set_object (value, priv->model);
224 case PROP_ALIGN_WIDGET:
225 g_value_set_object (value, priv->align_widget);
228 g_value_set_enum (value, priv->arrow_type);
231 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
236 gtk_menu_button_state_flags_changed (GtkWidget *widget,
237 GtkStateFlags previous_state_flags)
239 GtkMenuButton *button = GTK_MENU_BUTTON (widget);
240 GtkMenuButtonPrivate *priv = button->priv;
242 if (!gtk_widget_is_sensitive (widget) && priv->popup)
243 gtk_menu_shell_deactivate (GTK_MENU_SHELL (priv->popup));
247 menu_position_up_down_func (GtkMenu *menu,
251 GtkMenuButton *menu_button)
253 GtkMenuButtonPrivate *priv = menu_button->priv;
254 GtkWidget *widget = GTK_WIDGET (menu_button);
256 GtkRequisition menu_req;
257 GtkTextDirection direction;
258 GdkRectangle monitor;
262 GtkAllocation allocation, arrow_allocation;
265 /* In the common case the menu button is showing a dropdown menu, set the
266 * corresponding type hint on the toplevel, so the WM can omit the top side
269 if (priv->arrow_type == GTK_ARROW_DOWN)
271 toplevel = gtk_widget_get_toplevel (GTK_WIDGET (priv->popup));
272 gtk_window_set_type_hint (GTK_WINDOW (toplevel), GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU);
275 gtk_widget_get_preferred_size (GTK_WIDGET (priv->popup),
278 align = gtk_widget_get_halign (GTK_WIDGET (priv->popup));
279 direction = gtk_widget_get_direction (widget);
280 window = gtk_widget_get_window (priv->align_widget ? priv->align_widget : widget);
282 screen = gtk_widget_get_screen (GTK_WIDGET (menu));
283 monitor_num = gdk_screen_get_monitor_at_window (screen, window);
286 gdk_screen_get_monitor_workarea (screen, monitor_num, &monitor);
288 gtk_widget_get_allocation (priv->align_widget ? priv->align_widget : widget, &allocation);
289 gtk_widget_get_allocation (widget, &arrow_allocation);
291 gdk_window_get_origin (window, x, y);
295 /* treat the default align value like START */
296 if (align == GTK_ALIGN_FILL)
297 align = GTK_ALIGN_START;
299 if (align == GTK_ALIGN_CENTER)
300 *x -= (menu_req.width - allocation.width) / 2;
301 else if ((align == GTK_ALIGN_START && direction == GTK_TEXT_DIR_LTR) ||
302 (align == GTK_ALIGN_END && direction == GTK_TEXT_DIR_RTL))
303 *x += MAX (allocation.width - menu_req.width, 0);
304 else if (menu_req.width > allocation.width)
305 *x -= menu_req.width - allocation.width;
307 if (priv->arrow_type == GTK_ARROW_UP && *y - menu_req.height >= monitor.y)
309 *y -= menu_req.height;
313 if ((*y + arrow_allocation.height + menu_req.height) <= monitor.y + monitor.height)
314 *y += arrow_allocation.height;
315 else if ((*y - menu_req.height) >= monitor.y)
316 *y -= menu_req.height;
317 else if (monitor.y + monitor.height - (*y + arrow_allocation.height) > *y)
318 *y += arrow_allocation.height;
320 *y -= menu_req.height;
327 menu_position_side_func (GtkMenu *menu,
331 GtkMenuButton *menu_button)
333 GtkMenuButtonPrivate *priv = menu_button->priv;
334 GtkAllocation allocation;
335 GtkWidget *widget = GTK_WIDGET (menu_button);
336 GtkRequisition menu_req;
337 GdkRectangle monitor;
342 GtkTextDirection direction;
344 gtk_widget_get_preferred_size (GTK_WIDGET (priv->popup),
347 window = gtk_widget_get_window (widget);
349 direction = gtk_widget_get_direction (widget);
350 align = gtk_widget_get_valign (GTK_WIDGET (menu));
351 screen = gtk_widget_get_screen (GTK_WIDGET (menu));
352 monitor_num = gdk_screen_get_monitor_at_window (screen, window);
355 gdk_screen_get_monitor_workarea (screen, monitor_num, &monitor);
357 gdk_window_get_origin (gtk_button_get_event_window (GTK_BUTTON (menu_button)), x, y);
359 gtk_widget_get_allocation (widget, &allocation);
361 if ((priv->arrow_type == GTK_ARROW_RIGHT && direction == GTK_TEXT_DIR_LTR) ||
362 (priv->arrow_type == GTK_ARROW_LEFT && direction == GTK_TEXT_DIR_RTL))
365 if (*x + allocation.width + menu_req.width <= monitor.x + monitor.width)
366 *x += allocation.width;
368 *x -= menu_req.width;
372 if (*x - menu_req.width >= monitor.x)
373 *x -= menu_req.width;
375 *x += allocation.width;
378 /* treat the default align value like START */
379 if (align == GTK_ALIGN_FILL)
380 align = GTK_ALIGN_START;
382 if (align == GTK_ALIGN_CENTER)
383 *y -= (menu_req.height - allocation.height) / 2;
384 else if (align == GTK_ALIGN_END)
385 *y -= menu_req.height - allocation.height;
391 popup_menu (GtkMenuButton *menu_button,
392 GdkEventButton *event)
394 GtkMenuButtonPrivate *priv = menu_button->priv;
395 GtkMenuPositionFunc func;
398 priv->func (priv->user_data);
403 switch (priv->arrow_type)
406 case GTK_ARROW_RIGHT:
407 func = (GtkMenuPositionFunc) menu_position_side_func;
410 func = (GtkMenuPositionFunc) menu_position_up_down_func;
414 gtk_menu_popup_for_device (GTK_MENU (priv->popup),
415 event ? event->device : NULL,
418 GTK_WIDGET (menu_button),
420 event ? event->button : 0,
421 event ? event->time : gtk_get_current_event_time ());
425 gtk_menu_button_toggled (GtkToggleButton *button)
427 GtkMenuButton *menu_button = GTK_MENU_BUTTON (button);
428 GtkMenuButtonPrivate *priv = menu_button->priv;
433 if (gtk_toggle_button_get_active (button) &&
434 !gtk_widget_get_visible (GTK_WIDGET (priv->popup)))
436 /* we get here only when the menu is activated by a key
437 * press, so that we can select the first menu item
439 popup_menu (menu_button, NULL);
440 gtk_menu_shell_select_first (GTK_MENU_SHELL (priv->popup), FALSE);
445 gtk_menu_button_button_press_event (GtkWidget *widget,
446 GdkEventButton *event)
448 if (event->button == GDK_BUTTON_PRIMARY)
450 popup_menu (GTK_MENU_BUTTON (widget), event);
451 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
456 return GTK_WIDGET_CLASS (gtk_menu_button_parent_class)->button_press_event (widget, event);
460 gtk_menu_button_add (GtkContainer *container,
463 GtkMenuButton *button = GTK_MENU_BUTTON (container);
465 if (button->priv->arrow_widget)
466 gtk_container_remove (container, button->priv->arrow_widget);
468 GTK_CONTAINER_CLASS (gtk_menu_button_parent_class)->add (container, child);
472 gtk_menu_button_remove (GtkContainer *container,
475 GtkMenuButton *button = GTK_MENU_BUTTON (container);
477 if (child == button->priv->arrow_widget)
478 button->priv->arrow_widget = NULL;
480 GTK_CONTAINER_CLASS (gtk_menu_button_parent_class)->remove (container, child);
484 gtk_menu_button_class_init (GtkMenuButtonClass *klass)
486 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
487 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
488 GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
489 GtkToggleButtonClass *toggle_button_class = GTK_TOGGLE_BUTTON_CLASS (klass);
491 g_type_class_add_private (klass, sizeof (GtkMenuButtonPrivate));
493 gobject_class->set_property = gtk_menu_button_set_property;
494 gobject_class->get_property = gtk_menu_button_get_property;
495 gobject_class->dispose = gtk_menu_button_dispose;
497 widget_class->state_flags_changed = gtk_menu_button_state_flags_changed;
498 widget_class->button_press_event = gtk_menu_button_button_press_event;
500 container_class->add = gtk_menu_button_add;
501 container_class->remove = gtk_menu_button_remove;
503 toggle_button_class->toggled = gtk_menu_button_toggled;
506 * GtkMenuButton:popup:
508 * The #GtkMenu that will be popped up when the button is clicked.
512 g_object_class_install_property (gobject_class,
514 g_param_spec_object ("popup",
516 P_("The dropdown menu."),
521 * GtkMenuButton:menu-model:
523 * The #GMenuModel from which the menu to pop up will be created.
524 * See gtk_menu_button_set_menu_model() for the interaction with the
525 * #GtkMenuButton:popup property.
529 g_object_class_install_property (gobject_class,
531 g_param_spec_object ("menu-model",
533 P_("The dropdown menu's model."),
537 * GtkMenuButton:align-widget:
539 * The #GtkWidget to use to align the popup menu with.
543 g_object_class_install_property (gobject_class,
545 g_param_spec_object ("align-widget",
547 P_("The parent widget which the menu should align with."),
551 * GtkMenuButton:direction:
553 * The #GtkArrowType representing the direction in which the
554 * menu will be popped out.
558 g_object_class_install_property (gobject_class,
560 g_param_spec_enum ("direction",
562 P_("The direction the arrow should point."),
569 add_arrow (GtkMenuButton *menu_button)
573 arrow = gtk_arrow_new (menu_button->priv->arrow_type, GTK_SHADOW_NONE);
574 gtk_container_add (GTK_CONTAINER (menu_button), arrow);
575 gtk_widget_show (arrow);
576 menu_button->priv->arrow_widget = arrow;
580 gtk_menu_button_init (GtkMenuButton *menu_button)
582 GtkMenuButtonPrivate *priv;
584 priv = G_TYPE_INSTANCE_GET_PRIVATE (menu_button, GTK_TYPE_MENU_BUTTON, GtkMenuButtonPrivate);
585 menu_button->priv = priv;
586 priv->arrow_type = GTK_ARROW_DOWN;
588 add_arrow (menu_button);
590 gtk_widget_set_sensitive (GTK_WIDGET (menu_button), FALSE);
594 * gtk_menu_button_new:
596 * Creates a new #GtkMenuButton widget with downwards-pointing
597 * arrow as the only child. You can replace the child widget
598 * with another #GtkWidget should you wish to.
600 * Returns: The newly created #GtkMenuButton widget.
605 gtk_menu_button_new (void)
607 return g_object_new (GTK_TYPE_MENU_BUTTON, NULL);
610 /* Callback for the "deactivate" signal on the pop-up menu.
611 * This is used so that we unset the state of the toggle button
612 * when the pop-up menu disappears.
615 menu_deactivate_cb (GtkMenuShell *menu_shell,
616 GtkMenuButton *menu_button)
618 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (menu_button), FALSE);
624 menu_detacher (GtkWidget *widget,
627 GtkMenuButtonPrivate *priv = GTK_MENU_BUTTON (widget)->priv;
629 g_return_if_fail (priv->popup == (GtkWidget *) menu);
634 /* This function is used in GtkMenuToolButton, the call back will
635 * be called when GtkMenuToolButton would have emitted the "show-menu"
639 _gtk_menu_button_set_popup_with_func (GtkMenuButton *menu_button,
641 GtkMenuButtonShowMenuCallback func,
644 GtkMenuButtonPrivate *priv;
646 g_return_if_fail (GTK_IS_MENU_BUTTON (menu_button));
647 g_return_if_fail (GTK_IS_MENU (menu) || menu == NULL);
649 priv = menu_button->priv;
651 priv->user_data = user_data;
653 if (priv->popup == GTK_WIDGET (menu))
658 if (gtk_widget_get_visible (GTK_WIDGET (priv->popup)))
659 gtk_menu_shell_deactivate (GTK_MENU_SHELL (priv->popup));
664 g_signal_handlers_disconnect_by_func (priv->popup,
667 gtk_menu_detach (GTK_MENU (priv->popup));
674 gtk_menu_attach_to_widget (GTK_MENU (priv->popup), GTK_WIDGET (menu_button),
677 gtk_widget_set_sensitive (GTK_WIDGET (menu_button), TRUE);
679 g_signal_connect (priv->popup, "deactivate",
680 G_CALLBACK (menu_deactivate_cb), menu_button);
684 gtk_widget_set_sensitive (GTK_WIDGET (menu_button), FALSE);
687 g_object_notify (G_OBJECT (menu_button), "popup");
688 g_object_notify (G_OBJECT (menu_button), "menu-model");
692 * gtk_menu_button_set_popup:
693 * @menu_button: a #GtkMenuButton
694 * @popup: (allow-none): a #GtkMenu
696 * Sets the #GtkMenu that will be popped up when the button is clicked,
697 * or %NULL to disable the button. If #GtkMenuButton:menu-model is set,
698 * it will be set to %NULL.
703 gtk_menu_button_set_popup (GtkMenuButton *menu_button,
706 GtkMenuButtonPrivate *priv;
708 g_return_if_fail (GTK_IS_MENU_BUTTON (menu_button));
709 g_return_if_fail (GTK_IS_MENU (popup) || popup == NULL);
711 priv = menu_button->priv;
712 g_clear_object (&priv->model);
714 _gtk_menu_button_set_popup_with_func (menu_button, popup, NULL, NULL);
718 * gtk_menu_button_get_popup:
719 * @menu_button: a #GtkMenuButton
721 * Returns the #GtkMenu that pops out of the button.
723 * Returns: (transfer none): a #GtkMenu or %NULL.
728 gtk_menu_button_get_popup (GtkMenuButton *menu_button)
730 g_return_val_if_fail (GTK_IS_MENU_BUTTON (menu_button), NULL);
732 return GTK_MENU (menu_button->priv->popup);
736 * gtk_menu_button_set_menu_model:
737 * @menu_button: a #GtkMenuButton
738 * @menu_model: (allow-none): a #GMenuModel
740 * Sets the #GMenuModel from which the #GtkMenuButton:popup property will be
741 * filled in, or %NULL to disable the button.
743 * The #GtkMenu will be created with gtk_menu_new_from_model(), so actions
744 * will be connected as documented there.
746 * If #GtkMenuButton:popup is already set, then its content will be lost
747 * and replaced by our newly created #GtkMenu.
752 gtk_menu_button_set_menu_model (GtkMenuButton *menu_button,
753 GMenuModel *menu_model)
755 GtkMenuButtonPrivate *priv;
758 g_return_if_fail (GTK_IS_MENU_BUTTON (menu_button));
759 g_return_if_fail (G_IS_MENU_MODEL (menu_model) || menu_model == NULL);
761 priv = menu_button->priv;
762 g_clear_object (&priv->model);
764 if (menu_model == NULL)
766 gtk_menu_button_set_popup (menu_button, NULL);
770 priv->model = g_object_ref (menu_model);
771 menu = gtk_menu_new_from_model (menu_model);
772 gtk_widget_show_all (menu);
773 gtk_menu_button_set_popup (menu_button, menu);
777 * gtk_menu_button_get_menu_model:
778 * @menu_button: a #GtkMenuButton
780 * Returns the #GMenuModel used to generate the menu.
782 * Returns: (transfer none): a #GMenuModel or %NULL.
787 gtk_menu_button_get_menu_model (GtkMenuButton *menu_button)
789 g_return_val_if_fail (GTK_IS_MENU_BUTTON (menu_button), NULL);
791 return menu_button->priv->model;
795 set_align_widget_pointer (GtkMenuButton *menu_button,
796 GtkWidget *align_widget)
798 GtkMenuButtonPrivate *priv;
800 priv = menu_button->priv;
802 if (priv->align_widget)
803 g_object_remove_weak_pointer (G_OBJECT (priv->align_widget), (gpointer *) &priv->align_widget);
805 priv->align_widget = align_widget;
808 g_object_add_weak_pointer (G_OBJECT (priv->align_widget), (gpointer *) &priv->align_widget);
812 * gtk_menu_button_set_align_widget:
813 * @menu_button: a #GtkMenuButton
814 * @align_widget: (allow-none): a #GtkWidget
816 * Sets the #GtkWidget to use to line the menu with when popped up. Note that
817 * the @align_widget must contain the #GtkMenuButton itself.
819 * Setting it to %NULL means that the popup menu will be aligned with the
825 gtk_menu_button_set_align_widget (GtkMenuButton *menu_button,
826 GtkWidget *align_widget)
828 GtkMenuButtonPrivate *priv;
830 g_return_if_fail (GTK_IS_MENU_BUTTON (menu_button));
831 g_return_if_fail (align_widget == NULL || gtk_widget_is_ancestor (GTK_WIDGET (menu_button), align_widget));
833 priv = menu_button->priv;
834 if (priv->align_widget == align_widget)
837 set_align_widget_pointer (menu_button, align_widget);
839 g_object_notify (G_OBJECT (menu_button), "align-widget");
843 * gtk_menu_button_get_align_widget:
844 * @menu_button: a #GtkMenuButton
846 * Returns the parent #GtkWidget to use to line up with menu.
848 * Returns: (transfer none): a #GtkWidget value or %NULL.
853 gtk_menu_button_get_align_widget (GtkMenuButton *menu_button)
855 g_return_val_if_fail (GTK_IS_MENU_BUTTON (menu_button), NULL);
857 return menu_button->priv->align_widget;
861 * gtk_menu_button_set_direction:
862 * @menu_button: a #GtkMenuButton
863 * @direction: a #GtkArrowType
865 * Sets the direction in which the menu will be popped up, as
866 * well as changing the arrow's direction. The child will not
867 * be changed to an arrow if it was customized.
869 * If the menu when popped out would have collided with screen edges,
870 * we will do our best to keep it inside the screen and fully visible.
872 * If you pass %GTK_ARROW_NONE for a @direction, the menu will behave
873 * as if you passed %GTK_ARROW_DOWN (although you won't see any arrows).
878 gtk_menu_button_set_direction (GtkMenuButton *menu_button,
879 GtkArrowType direction)
881 GtkMenuButtonPrivate *priv = menu_button->priv;
884 g_return_if_fail (GTK_IS_MENU_BUTTON (menu_button));
886 if (priv->arrow_type == direction)
889 priv->arrow_type = direction;
891 /* Is it custom content? We don't change that */
892 child = gtk_bin_get_child (GTK_BIN (menu_button));
893 if (priv->arrow_widget != child)
896 gtk_arrow_set (GTK_ARROW (child), priv->arrow_type, GTK_SHADOW_NONE);
900 * gtk_menu_button_get_direction:
901 * @menu_button: a #GtkMenuButton
903 * Returns the direction the menu will be pointing at when popped up.
905 * Returns: a #GtkArrowType value.
910 gtk_menu_button_get_direction (GtkMenuButton *menu_button)
912 g_return_val_if_fail (GTK_IS_MENU_BUTTON (menu_button), GTK_ARROW_DOWN);
914 return menu_button->priv->arrow_type;
918 gtk_menu_button_dispose (GObject *object)
920 GtkMenuButtonPrivate *priv = GTK_MENU_BUTTON (object)->priv;
924 g_signal_handlers_disconnect_by_func (priv->popup,
927 gtk_menu_detach (GTK_MENU (priv->popup));
931 set_align_widget_pointer (GTK_MENU_BUTTON (object), NULL);
933 g_clear_object (&priv->model);
935 G_OBJECT_CLASS (gtk_menu_button_parent_class)->dispose (object);