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