]> Pileus Git - ~andy/gtk/blob - gtk/gtkmenutoolbutton.c
Revert "gtkmenutoolbutton: Use GtkMenuButton"
[~andy/gtk] / gtk / gtkmenutoolbutton.c
1 /* GTK - The GIMP Toolkit
2  *
3  * Copyright (C) 2003 Ricardo Fernandez Pascual
4  * Copyright (C) 2004 Paolo Borelli
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 #include "config.h"
21
22 #include "gtkmenutoolbutton.h"
23
24 #include "gtktogglebutton.h"
25 #include "gtkarrow.h"
26 #include "gtkbox.h"
27 #include "gtkmenu.h"
28 #include "gtkmain.h"
29 #include "gtksizerequest.h"
30 #include "gtkbuildable.h"
31
32 #include "gtkprivate.h"
33 #include "gtkintl.h"
34
35
36 /**
37  * SECTION:gtkmenutoolbutton
38  * @Short_description: A GtkToolItem containing a button with an additional dropdown menu
39  * @Title: GtkMenuToolButton
40  * @See_also: #GtkToolbar, #GtkToolButton
41  *
42  * A #GtkMenuToolButton is a #GtkToolItem that contains a button and
43  * a small additional button with an arrow. When clicked, the arrow
44  * button pops up a dropdown menu.
45  *
46  * Use gtk_menu_tool_button_new() to create a new
47  * #GtkMenuToolButton. Use gtk_menu_tool_button_new_from_stock() to
48  * create a new #GtkMenuToolButton containing a stock item.
49  *
50  * <refsect2 id="GtkMenuToolButton-BUILDER-UI">
51  * <title>GtkMenuToolButton as GtkBuildable</title>
52  * <para>
53  * The GtkMenuToolButton implementation of the GtkBuildable interface
54  * supports adding a menu by specifying "menu" as the "type"
55  * attribute of a &lt;child&gt; element.
56  *
57  * <example>
58  * <title>A UI definition fragment with menus</title>
59  * <programlisting><![CDATA[
60  * <object class="GtkMenuToolButton">
61  *   <child type="menu">
62  *     <object class="GtkMenu"/>
63  *   </child>
64  * </object>
65  * ]]></programlisting>
66  * </example>
67  * </para>
68  * </refsect2>
69  */
70
71
72 struct _GtkMenuToolButtonPrivate
73 {
74   GtkWidget *button;
75   GtkWidget *arrow;
76   GtkWidget *arrow_button;
77   GtkWidget *box;
78   GtkMenu   *menu;
79 };
80
81 static void gtk_menu_tool_button_destroy    (GtkWidget              *widget);
82
83 static int  menu_deactivate_cb              (GtkMenuShell           *menu_shell,
84                                              GtkMenuToolButton      *button);
85
86 static void gtk_menu_tool_button_buildable_interface_init (GtkBuildableIface   *iface);
87 static void gtk_menu_tool_button_buildable_add_child      (GtkBuildable        *buildable,
88                                                            GtkBuilder          *builder,
89                                                            GObject             *child,
90                                                            const gchar         *type);
91
92 enum
93 {
94   SHOW_MENU,
95   LAST_SIGNAL
96 };
97
98 enum
99 {
100   PROP_0,
101   PROP_MENU
102 };
103
104 static gint signals[LAST_SIGNAL];
105
106 static GtkBuildableIface *parent_buildable_iface;
107
108 G_DEFINE_TYPE_WITH_CODE (GtkMenuToolButton, gtk_menu_tool_button, GTK_TYPE_TOOL_BUTTON,
109                          G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
110                                                 gtk_menu_tool_button_buildable_interface_init))
111
112 static void
113 gtk_menu_tool_button_construct_contents (GtkMenuToolButton *button)
114 {
115   GtkMenuToolButtonPrivate *priv = button->priv;
116   GtkWidget *box;
117   GtkWidget *parent;
118   GtkOrientation orientation;
119
120   orientation = gtk_tool_item_get_orientation (GTK_TOOL_ITEM (button));
121
122   if (orientation == GTK_ORIENTATION_HORIZONTAL)
123     {
124       box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
125       gtk_arrow_set (GTK_ARROW (priv->arrow), GTK_ARROW_DOWN, GTK_SHADOW_NONE);
126     }
127   else
128     {
129       box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
130       gtk_arrow_set (GTK_ARROW (priv->arrow), GTK_ARROW_RIGHT, GTK_SHADOW_NONE);
131     }
132
133   parent = gtk_widget_get_parent (priv->button);
134   if (priv->button && parent)
135     {
136       g_object_ref (priv->button);
137       gtk_container_remove (GTK_CONTAINER (parent),
138                             priv->button);
139       gtk_container_add (GTK_CONTAINER (box), priv->button);
140       g_object_unref (priv->button);
141     }
142
143   parent = gtk_widget_get_parent (priv->arrow_button);
144   if (priv->arrow_button && parent)
145     {
146       g_object_ref (priv->arrow_button);
147       gtk_container_remove (GTK_CONTAINER (parent),
148                             priv->arrow_button);
149       gtk_box_pack_end (GTK_BOX (box), priv->arrow_button,
150                         FALSE, FALSE, 0);
151       g_object_unref (priv->arrow_button);
152     }
153
154   if (priv->box)
155     {
156       gchar *tmp;
157
158       /* Transfer a possible tooltip to the new box */
159       g_object_get (priv->box, "tooltip-markup", &tmp, NULL);
160
161       if (tmp)
162         {
163           g_object_set (box, "tooltip-markup", tmp, NULL);
164           g_free (tmp);
165         }
166
167       /* Note: we are not destroying the button and the arrow_button
168        * here because they were removed from their container above
169        */
170       gtk_widget_destroy (priv->box);
171     }
172
173   priv->box = box;
174
175   gtk_container_add (GTK_CONTAINER (button), priv->box);
176   gtk_widget_show_all (priv->box);
177
178   gtk_button_set_relief (GTK_BUTTON (priv->arrow_button),
179                          gtk_tool_item_get_relief_style (GTK_TOOL_ITEM (button)));
180   
181   gtk_widget_queue_resize (GTK_WIDGET (button));
182 }
183
184 static void
185 gtk_menu_tool_button_toolbar_reconfigured (GtkToolItem *toolitem)
186 {
187   gtk_menu_tool_button_construct_contents (GTK_MENU_TOOL_BUTTON (toolitem));
188
189   /* chain up */
190   GTK_TOOL_ITEM_CLASS (gtk_menu_tool_button_parent_class)->toolbar_reconfigured (toolitem);
191 }
192
193 static void
194 gtk_menu_tool_button_state_changed (GtkWidget    *widget,
195                                     GtkStateType  previous_state)
196 {
197   GtkMenuToolButton *button = GTK_MENU_TOOL_BUTTON (widget);
198   GtkMenuToolButtonPrivate *priv = button->priv;
199
200   if (!gtk_widget_is_sensitive (widget) && priv->menu)
201     {
202       gtk_menu_shell_deactivate (GTK_MENU_SHELL (priv->menu));
203     }
204 }
205
206 static void
207 gtk_menu_tool_button_set_property (GObject      *object,
208                                    guint         prop_id,
209                                    const GValue *value,
210                                    GParamSpec   *pspec)
211 {
212   GtkMenuToolButton *button = GTK_MENU_TOOL_BUTTON (object);
213
214   switch (prop_id)
215     {
216     case PROP_MENU:
217       gtk_menu_tool_button_set_menu (button, g_value_get_object (value));
218       break;
219
220     default:
221       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
222       break;
223     }
224 }
225
226 static void
227 gtk_menu_tool_button_get_property (GObject    *object,
228                                    guint       prop_id,
229                                    GValue     *value,
230                                    GParamSpec *pspec)
231 {
232   GtkMenuToolButton *button = GTK_MENU_TOOL_BUTTON (object);
233
234   switch (prop_id)
235     {
236     case PROP_MENU:
237       g_value_set_object (value, button->priv->menu);
238       break;
239
240     default:
241       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
242       break;
243     }
244 }
245
246 static void
247 gtk_menu_tool_button_class_init (GtkMenuToolButtonClass *klass)
248 {
249   GObjectClass *object_class;
250   GtkWidgetClass *widget_class;
251   GtkToolItemClass *toolitem_class;
252
253   object_class = (GObjectClass *)klass;
254   widget_class = (GtkWidgetClass *)klass;
255   toolitem_class = (GtkToolItemClass *)klass;
256
257   object_class->set_property = gtk_menu_tool_button_set_property;
258   object_class->get_property = gtk_menu_tool_button_get_property;
259
260   widget_class->destroy = gtk_menu_tool_button_destroy;
261   widget_class->state_changed = gtk_menu_tool_button_state_changed;
262
263   toolitem_class->toolbar_reconfigured = gtk_menu_tool_button_toolbar_reconfigured;
264
265   /**
266    * GtkMenuToolButton::show-menu:
267    * @button: the object on which the signal is emitted
268    *
269    * The ::show-menu signal is emitted before the menu is shown.
270    *
271    * It can be used to populate the menu on demand, using 
272    * gtk_menu_tool_button_set_menu().
273
274    * Note that even if you populate the menu dynamically in this way, 
275    * you must set an empty menu on the #GtkMenuToolButton beforehand,
276    * since the arrow is made insensitive if the menu is not set.
277    */
278   signals[SHOW_MENU] =
279     g_signal_new (I_("show-menu"),
280                   G_OBJECT_CLASS_TYPE (klass),
281                   G_SIGNAL_RUN_FIRST,
282                   G_STRUCT_OFFSET (GtkMenuToolButtonClass, show_menu),
283                   NULL, NULL,
284                   g_cclosure_marshal_VOID__VOID,
285                   G_TYPE_NONE, 0);
286
287   g_object_class_install_property (object_class,
288                                    PROP_MENU,
289                                    g_param_spec_object ("menu",
290                                                         P_("Menu"),
291                                                         P_("The dropdown menu"),
292                                                         GTK_TYPE_MENU,
293                                                         GTK_PARAM_READWRITE));
294
295   g_type_class_add_private (object_class, sizeof (GtkMenuToolButtonPrivate));
296 }
297
298 static void
299 menu_position_func (GtkMenu           *menu,
300                     int               *x,
301                     int               *y,
302                     gboolean          *push_in,
303                     GtkMenuToolButton *button)
304 {
305   GtkMenuToolButtonPrivate *priv = button->priv;
306   GtkAllocation arrow_allocation;
307   GtkWidget *widget = GTK_WIDGET (button);
308   GtkRequisition menu_req;
309   GtkOrientation orientation;
310   GtkTextDirection direction;
311   GdkRectangle monitor;
312   gint monitor_num;
313   GdkScreen *screen;
314   GdkWindow *window;
315
316   gtk_widget_get_preferred_size (GTK_WIDGET (priv->menu),
317                                  &menu_req, NULL);
318
319   orientation = gtk_tool_item_get_orientation (GTK_TOOL_ITEM (button));
320   direction = gtk_widget_get_direction (widget);
321   window = gtk_widget_get_window (widget);
322
323   screen = gtk_widget_get_screen (GTK_WIDGET (menu));
324   monitor_num = gdk_screen_get_monitor_at_window (screen, window);
325   if (monitor_num < 0)
326     monitor_num = 0;
327   gdk_screen_get_monitor_workarea (screen, monitor_num, &monitor);
328
329   if (orientation == GTK_ORIENTATION_HORIZONTAL)
330     {
331       GtkAllocation allocation;
332
333       gtk_widget_get_allocation (widget, &allocation);
334       gtk_widget_get_allocation (priv->arrow_button, &arrow_allocation);
335
336       gdk_window_get_origin (window, x, y);
337       *x += allocation.x;
338       *y += allocation.y;
339
340       if (direction == GTK_TEXT_DIR_LTR)
341         *x += MAX (allocation.width - menu_req.width, 0);
342       else if (menu_req.width > allocation.width)
343         *x -= menu_req.width - allocation.width;
344
345       if ((*y + arrow_allocation.height + menu_req.height) <= monitor.y + monitor.height)
346         *y += arrow_allocation.height;
347       else if ((*y - menu_req.height) >= monitor.y)
348         *y -= menu_req.height;
349       else if (monitor.y + monitor.height - (*y + arrow_allocation.height) > *y)
350         *y += arrow_allocation.height;
351       else
352         *y -= menu_req.height;
353     }
354   else 
355     {
356       gdk_window_get_origin (gtk_button_get_event_window (GTK_BUTTON (priv->arrow_button)), x, y);
357
358       gtk_widget_get_allocation (priv->arrow_button, &arrow_allocation);
359
360       if (direction == GTK_TEXT_DIR_LTR)
361         *x += arrow_allocation.width;
362       else 
363         *x -= menu_req.width;
364
365       if (*y + menu_req.height > monitor.y + monitor.height &&
366           *y + arrow_allocation.height - monitor.y > monitor.y + monitor.height - *y)
367         *y += arrow_allocation.height - menu_req.height;
368     }
369
370   *push_in = FALSE;
371 }
372
373 static void
374 popup_menu_under_arrow (GtkMenuToolButton *button,
375                         GdkEventButton    *event)
376 {
377   GtkMenuToolButtonPrivate *priv = button->priv;
378
379   g_signal_emit (button, signals[SHOW_MENU], 0);
380
381   if (!priv->menu)
382     return;
383
384   gtk_menu_popup (priv->menu, NULL, NULL,
385                   (GtkMenuPositionFunc) menu_position_func,
386                   button,
387                   event ? event->button : 0,
388                   event ? event->time : gtk_get_current_event_time ());
389 }
390
391 static void
392 arrow_button_toggled_cb (GtkToggleButton   *togglebutton,
393                          GtkMenuToolButton *button)
394 {
395   GtkMenuToolButtonPrivate *priv = button->priv;
396
397   if (!priv->menu)
398     return;
399
400   if (gtk_toggle_button_get_active (togglebutton) &&
401       !gtk_widget_get_visible (GTK_WIDGET (priv->menu)))
402     {
403       /* we get here only when the menu is activated by a key
404        * press, so that we can select the first menu item */
405       popup_menu_under_arrow (button, NULL);
406       gtk_menu_shell_select_first (GTK_MENU_SHELL (priv->menu), FALSE);
407     }
408 }
409
410 static gboolean
411 arrow_button_button_press_event_cb (GtkWidget         *widget,
412                                     GdkEventButton    *event,
413                                     GtkMenuToolButton *button)
414 {
415   if (event->button == GDK_BUTTON_PRIMARY)
416     {
417       popup_menu_under_arrow (button, event);
418       gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
419
420       return TRUE;
421     }
422   else
423     {
424       return FALSE;
425     }
426 }
427
428 static void
429 gtk_menu_tool_button_init (GtkMenuToolButton *button)
430 {
431   GtkWidget *box;
432   GtkWidget *arrow;
433   GtkWidget *arrow_button;
434   GtkWidget *real_button;
435
436   button->priv = G_TYPE_INSTANCE_GET_PRIVATE (button,
437                                               GTK_TYPE_MENU_TOOL_BUTTON,
438                                               GtkMenuToolButtonPrivate);
439
440   gtk_tool_item_set_homogeneous (GTK_TOOL_ITEM (button), FALSE);
441
442   box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
443
444   real_button = gtk_bin_get_child (GTK_BIN (button));
445   g_object_ref (real_button);
446   gtk_container_remove (GTK_CONTAINER (button), real_button);
447   gtk_container_add (GTK_CONTAINER (box), real_button);
448   g_object_unref (real_button);
449
450   arrow_button = gtk_toggle_button_new ();
451   arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
452   gtk_container_add (GTK_CONTAINER (arrow_button), arrow);
453   gtk_box_pack_end (GTK_BOX (box), arrow_button,
454                     FALSE, FALSE, 0);
455
456   /* the arrow button is insentive until we set a menu */
457   gtk_widget_set_sensitive (arrow_button, FALSE);
458
459   gtk_widget_show_all (box);
460
461   gtk_container_add (GTK_CONTAINER (button), box);
462
463   button->priv->button = real_button;
464   button->priv->arrow = arrow;
465   button->priv->arrow_button = arrow_button;
466   button->priv->box = box;
467
468   g_signal_connect (arrow_button, "toggled",
469                     G_CALLBACK (arrow_button_toggled_cb), button);
470   g_signal_connect (arrow_button, "button-press-event",
471                     G_CALLBACK (arrow_button_button_press_event_cb), button);
472 }
473
474 static void
475 gtk_menu_tool_button_destroy (GtkWidget *widget)
476 {
477   GtkMenuToolButton *button = GTK_MENU_TOOL_BUTTON (widget);
478
479   if (button->priv->menu)
480     {
481       g_signal_handlers_disconnect_by_func (button->priv->menu, 
482                                             menu_deactivate_cb, 
483                                             button);
484       gtk_menu_detach (button->priv->menu);
485
486       g_signal_handlers_disconnect_by_func (button->priv->arrow_button,
487                                             arrow_button_toggled_cb, 
488                                             button);
489       g_signal_handlers_disconnect_by_func (button->priv->arrow_button, 
490                                             arrow_button_button_press_event_cb, 
491                                             button);
492     }
493
494   GTK_WIDGET_CLASS (gtk_menu_tool_button_parent_class)->destroy (widget);
495 }
496
497 static void
498 gtk_menu_tool_button_buildable_add_child (GtkBuildable *buildable,
499                                           GtkBuilder   *builder,
500                                           GObject      *child,
501                                           const gchar  *type)
502 {
503   if (type && strcmp (type, "menu") == 0)
504     gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (buildable),
505                                    GTK_WIDGET (child));
506   else
507     parent_buildable_iface->add_child (buildable, builder, child, type);
508 }
509
510 static void
511 gtk_menu_tool_button_buildable_interface_init (GtkBuildableIface *iface)
512 {
513   parent_buildable_iface = g_type_interface_peek_parent (iface);
514   iface->add_child = gtk_menu_tool_button_buildable_add_child;
515 }
516
517 /**
518  * gtk_menu_tool_button_new:
519  * @icon_widget: (allow-none): a widget that will be used as icon widget, or %NULL
520  * @label: (allow-none): a string that will be used as label, or %NULL
521  *
522  * Creates a new #GtkMenuToolButton using @icon_widget as icon and
523  * @label as label.
524  *
525  * Return value: the new #GtkMenuToolButton
526  *
527  * Since: 2.6
528  **/
529 GtkToolItem *
530 gtk_menu_tool_button_new (GtkWidget   *icon_widget,
531                           const gchar *label)
532 {
533   GtkMenuToolButton *button;
534
535   button = g_object_new (GTK_TYPE_MENU_TOOL_BUTTON, NULL);
536
537   if (label)
538     gtk_tool_button_set_label (GTK_TOOL_BUTTON (button), label);
539
540   if (icon_widget)
541     gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (button), icon_widget);
542
543   return GTK_TOOL_ITEM (button);
544 }
545
546 /**
547  * gtk_menu_tool_button_new_from_stock:
548  * @stock_id: the name of a stock item
549  *
550  * Creates a new #GtkMenuToolButton.
551  * The new #GtkMenuToolButton will contain an icon and label from
552  * the stock item indicated by @stock_id.
553  *
554  * Return value: the new #GtkMenuToolButton
555  *
556  * Since: 2.6
557  **/
558 GtkToolItem *
559 gtk_menu_tool_button_new_from_stock (const gchar *stock_id)
560 {
561   GtkMenuToolButton *button;
562
563   g_return_val_if_fail (stock_id != NULL, NULL);
564
565   button = g_object_new (GTK_TYPE_MENU_TOOL_BUTTON,
566                          "stock-id", stock_id,
567                          NULL);
568
569   return GTK_TOOL_ITEM (button);
570 }
571
572 /* Callback for the "deactivate" signal on the pop-up menu.
573  * This is used so that we unset the state of the toggle button
574  * when the pop-up menu disappears. 
575  */
576 static int
577 menu_deactivate_cb (GtkMenuShell      *menu_shell,
578                     GtkMenuToolButton *button)
579 {
580   GtkMenuToolButtonPrivate *priv = button->priv;
581
582   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->arrow_button), FALSE);
583
584   return TRUE;
585 }
586
587 static void
588 menu_detacher (GtkWidget *widget,
589                GtkMenu   *menu)
590 {
591   GtkMenuToolButtonPrivate *priv = GTK_MENU_TOOL_BUTTON (widget)->priv;
592
593   g_return_if_fail (priv->menu == menu);
594
595   priv->menu = NULL;
596 }
597
598 /**
599  * gtk_menu_tool_button_set_menu:
600  * @button: a #GtkMenuToolButton
601  * @menu: the #GtkMenu associated with #GtkMenuToolButton
602  *
603  * Sets the #GtkMenu that is popped up when the user clicks on the arrow.
604  * If @menu is NULL, the arrow button becomes insensitive.
605  *
606  * Since: 2.6
607  **/
608 void
609 gtk_menu_tool_button_set_menu (GtkMenuToolButton *button,
610                                GtkWidget         *menu)
611 {
612   GtkMenuToolButtonPrivate *priv;
613
614   g_return_if_fail (GTK_IS_MENU_TOOL_BUTTON (button));
615   g_return_if_fail (GTK_IS_MENU (menu) || menu == NULL);
616
617   priv = button->priv;
618
619   if (priv->menu != GTK_MENU (menu))
620     {
621       if (priv->menu && gtk_widget_get_visible (GTK_WIDGET (priv->menu)))
622         gtk_menu_shell_deactivate (GTK_MENU_SHELL (priv->menu));
623
624       if (priv->menu)
625         {
626           g_signal_handlers_disconnect_by_func (priv->menu, 
627                                                 menu_deactivate_cb, 
628                                                 button);
629           gtk_menu_detach (priv->menu);
630         }
631
632       priv->menu = GTK_MENU (menu);
633
634       if (priv->menu)
635         {
636           gtk_menu_attach_to_widget (priv->menu, GTK_WIDGET (button),
637                                      menu_detacher);
638
639           gtk_widget_set_sensitive (priv->arrow_button, TRUE);
640
641           g_signal_connect (priv->menu, "deactivate",
642                             G_CALLBACK (menu_deactivate_cb), button);
643         }
644       else
645        gtk_widget_set_sensitive (priv->arrow_button, FALSE);
646     }
647
648   g_object_notify (G_OBJECT (button), "menu");
649 }
650
651 /**
652  * gtk_menu_tool_button_get_menu:
653  * @button: a #GtkMenuToolButton
654  *
655  * Gets the #GtkMenu associated with #GtkMenuToolButton.
656  *
657  * Return value: (transfer none): the #GtkMenu associated
658  *     with #GtkMenuToolButton
659  *
660  * Since: 2.6
661  **/
662 GtkWidget *
663 gtk_menu_tool_button_get_menu (GtkMenuToolButton *button)
664 {
665   g_return_val_if_fail (GTK_IS_MENU_TOOL_BUTTON (button), NULL);
666
667   return GTK_WIDGET (button->priv->menu);
668 }
669
670 /**
671  * gtk_menu_tool_button_set_arrow_tooltip_text:
672  * @button: a #GtkMenuToolButton
673  * @text: text to be used as tooltip text for button's arrow button
674  *
675  * Sets the tooltip text to be used as tooltip for the arrow button which
676  * pops up the menu.  See gtk_tool_item_set_tooltip_text() for setting a tooltip
677  * on the whole #GtkMenuToolButton.
678  *
679  * Since: 2.12
680  **/
681 void
682 gtk_menu_tool_button_set_arrow_tooltip_text (GtkMenuToolButton *button,
683                                              const gchar       *text)
684 {
685   g_return_if_fail (GTK_IS_MENU_TOOL_BUTTON (button));
686
687   gtk_widget_set_tooltip_text (button->priv->arrow_button, text);
688 }
689
690 /**
691  * gtk_menu_tool_button_set_arrow_tooltip_markup:
692  * @button: a #GtkMenuToolButton
693  * @markup: markup text to be used as tooltip text for button's arrow button
694  *
695  * Sets the tooltip markup text to be used as tooltip for the arrow button
696  * which pops up the menu.  See gtk_tool_item_set_tooltip_text() for setting a
697  * tooltip on the whole #GtkMenuToolButton.
698  *
699  * Since: 2.12
700  **/
701 void
702 gtk_menu_tool_button_set_arrow_tooltip_markup (GtkMenuToolButton *button,
703                                                const gchar       *markup)
704 {
705   g_return_if_fail (GTK_IS_MENU_TOOL_BUTTON (button));
706
707   gtk_widget_set_tooltip_markup (button->priv->arrow_button, markup);
708 }