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