]> Pileus Git - ~andy/gtk/blob - gtk/gtktoolitem.c
Merge branch 'gtk-2-90'
[~andy/gtk] / gtk / gtktoolitem.c
1 /* gtktoolitem.c
2  *
3  * Copyright (C) 2002 Anders Carlsson <andersca@gnome.org>
4  * Copyright (C) 2002 James Henstridge <james@daa.com.au>
5  * Copyright (C) 2003 Soeren Sandmann <sandmann@daimi.au.dk>
6  *
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.
11  *
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.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23 #include "config.h"
24
25 #include <string.h>
26
27 #include "gtktoolitem.h"
28 #include "gtkmarshalers.h"
29 #include "gtktoolshell.h"
30 #include "gtkseparatormenuitem.h"
31 #include "gtkactivatable.h"
32 #include "gtkintl.h"
33 #include "gtkmain.h"
34 #include "gtkprivate.h"
35 #include "gtkalias.h"
36
37 /**
38  * SECTION:gtktoolitem
39  * @short_description: The base class of widgets that can be added to GtkToolShell
40  * @see_also: <variablelist>
41  *   <varlistentry>
42  *     <term>#GtkToolbar</term>
43  *     <listitem><para>The toolbar widget</para></listitem>
44  *   </varlistentry>
45  *   <varlistentry>
46  *     <term>#GtkToolButton</term>
47  *     <listitem><para>A subclass of #GtkToolItem that displays buttons on
48  *         the toolbar</para></listitem>
49  *   </varlistentry>
50  *   <varlistentry>
51  *     <term>#GtkSeparatorToolItem</term>
52  *     <listitem><para>A subclass of #GtkToolItem that separates groups of
53  *         items on a toolbar</para></listitem>
54  *   </varlistentry>
55  * </variablelist>
56  *
57  * #GtkToolItem<!-- -->s are widgets that can appear on a toolbar. To
58  * create a toolbar item that contain something else than a button, use
59  * gtk_tool_item_new(). Use gtk_container_add() to add a child
60  * widget to the tool item.
61  *
62  * For toolbar items that contain buttons, see the #GtkToolButton,
63  * #GtkToggleToolButton and #GtkRadioToolButton classes.
64  *
65  * See the #GtkToolbar class for a description of the toolbar widget, and
66  * #GtkToolShell for a description of the tool shell interface.
67  */
68
69 /**
70  * GtkToolItem:
71  *
72  * The GtkToolItem struct contains only private data.
73  * It should only be accessed through the functions described below.
74  */
75
76 enum {
77   CREATE_MENU_PROXY,
78   TOOLBAR_RECONFIGURED,
79   LAST_SIGNAL
80 };
81
82 enum {
83   PROP_0,
84   PROP_VISIBLE_HORIZONTAL,
85   PROP_VISIBLE_VERTICAL,
86   PROP_IS_IMPORTANT,
87
88   /* activatable properties */
89   PROP_ACTIVATABLE_RELATED_ACTION,
90   PROP_ACTIVATABLE_USE_ACTION_APPEARANCE
91 };
92
93 #define GTK_TOOL_ITEM_GET_PRIVATE(o)  (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_TOOL_ITEM, GtkToolItemPrivate))
94
95 struct _GtkToolItemPrivate
96 {
97   gchar *tip_text;
98   gchar *tip_private;
99
100   guint visible_horizontal : 1;
101   guint visible_vertical : 1;
102   guint homogeneous : 1;
103   guint expand : 1;
104   guint use_drag_window : 1;
105   guint is_important : 1;
106
107   GdkWindow *drag_window;
108   
109   gchar *menu_item_id;
110   GtkWidget *menu_item;
111
112   GtkAction *action;
113   gboolean   use_action_appearance;
114 };
115   
116 static void gtk_tool_item_finalize     (GObject         *object);
117 static void gtk_tool_item_dispose      (GObject         *object);
118 static void gtk_tool_item_parent_set   (GtkWidget       *toolitem,
119                                         GtkWidget       *parent);
120 static void gtk_tool_item_set_property (GObject         *object,
121                                         guint            prop_id,
122                                         const GValue    *value,
123                                         GParamSpec      *pspec);
124 static void gtk_tool_item_get_property (GObject         *object,
125                                         guint            prop_id,
126                                         GValue          *value,
127                                         GParamSpec      *pspec);
128 static void gtk_tool_item_property_notify (GObject      *object,
129                                            GParamSpec   *pspec);
130 static void gtk_tool_item_realize       (GtkWidget      *widget);
131 static void gtk_tool_item_unrealize     (GtkWidget      *widget);
132 static void gtk_tool_item_map           (GtkWidget      *widget);
133 static void gtk_tool_item_unmap         (GtkWidget      *widget);
134 static void gtk_tool_item_size_request  (GtkWidget      *widget,
135                                          GtkRequisition *requisition);
136 static void gtk_tool_item_size_allocate (GtkWidget      *widget,
137                                          GtkAllocation  *allocation);
138
139 static void gtk_tool_item_activatable_interface_init (GtkActivatableIface  *iface);
140 static void gtk_tool_item_update                     (GtkActivatable       *activatable,
141                                                       GtkAction            *action,
142                                                       const gchar          *property_name);
143 static void gtk_tool_item_sync_action_properties     (GtkActivatable       *activatable,
144                                                       GtkAction            *action);
145 static void gtk_tool_item_set_related_action         (GtkToolItem          *item, 
146                                                       GtkAction            *action);
147 static void gtk_tool_item_set_use_action_appearance  (GtkToolItem          *item, 
148                                                       gboolean              use_appearance);
149
150 static guint toolitem_signals[LAST_SIGNAL] = { 0 };
151
152 G_DEFINE_TYPE_WITH_CODE (GtkToolItem, gtk_tool_item, GTK_TYPE_BIN,
153                          G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIVATABLE,
154                                                 gtk_tool_item_activatable_interface_init))
155
156 static void
157 gtk_tool_item_class_init (GtkToolItemClass *klass)
158 {
159   GObjectClass *object_class;
160   GtkWidgetClass *widget_class;
161   
162   object_class = (GObjectClass *)klass;
163   widget_class = (GtkWidgetClass *)klass;
164   
165   object_class->set_property = gtk_tool_item_set_property;
166   object_class->get_property = gtk_tool_item_get_property;
167   object_class->finalize     = gtk_tool_item_finalize;
168   object_class->dispose      = gtk_tool_item_dispose;
169   object_class->notify       = gtk_tool_item_property_notify;
170
171   widget_class->realize       = gtk_tool_item_realize;
172   widget_class->unrealize     = gtk_tool_item_unrealize;
173   widget_class->map           = gtk_tool_item_map;
174   widget_class->unmap         = gtk_tool_item_unmap;
175   widget_class->size_request  = gtk_tool_item_size_request;
176   widget_class->size_allocate = gtk_tool_item_size_allocate;
177   widget_class->parent_set    = gtk_tool_item_parent_set;
178
179   klass->create_menu_proxy = _gtk_tool_item_create_menu_proxy;
180   
181   g_object_class_install_property (object_class,
182                                    PROP_VISIBLE_HORIZONTAL,
183                                    g_param_spec_boolean ("visible-horizontal",
184                                                          P_("Visible when horizontal"),
185                                                          P_("Whether the toolbar item is visible when the toolbar is in a horizontal orientation."),
186                                                          TRUE,
187                                                          GTK_PARAM_READWRITE));
188   g_object_class_install_property (object_class,
189                                    PROP_VISIBLE_VERTICAL,
190                                    g_param_spec_boolean ("visible-vertical",
191                                                          P_("Visible when vertical"),
192                                                          P_("Whether the toolbar item is visible when the toolbar is in a vertical orientation."),
193                                                          TRUE,
194                                                          GTK_PARAM_READWRITE));
195   g_object_class_install_property (object_class,
196                                    PROP_IS_IMPORTANT,
197                                    g_param_spec_boolean ("is-important",
198                                                          P_("Is important"),
199                                                          P_("Whether the toolbar item is considered important. When TRUE, toolbar buttons show text in GTK_TOOLBAR_BOTH_HORIZ mode"),
200                                                          FALSE,
201                                                          GTK_PARAM_READWRITE));
202
203   g_object_class_override_property (object_class, PROP_ACTIVATABLE_RELATED_ACTION, "related-action");
204   g_object_class_override_property (object_class, PROP_ACTIVATABLE_USE_ACTION_APPEARANCE, "use-action-appearance");
205
206
207 /**
208  * GtkToolItem::create-menu-proxy:
209  * @tool_item: the object the signal was emitted on
210  *
211  * This signal is emitted when the toolbar needs information from @tool_item
212  * about whether the item should appear in the toolbar overflow menu. In
213  * response the tool item should either
214  * <itemizedlist>
215  * <listitem>call gtk_tool_item_set_proxy_menu_item() with a %NULL
216  * pointer and return %TRUE to indicate that the item should not appear
217  * in the overflow menu
218  * </listitem>
219  * <listitem> call gtk_tool_item_set_proxy_menu_item() with a new menu
220  * item and return %TRUE, or 
221  * </listitem>
222  * <listitem> return %FALSE to indicate that the signal was not
223  * handled by the item. This means that
224  * the item will not appear in the overflow menu unless a later handler
225  * installs a menu item.
226  * </listitem>
227  * </itemizedlist>
228  *
229  * The toolbar may cache the result of this signal. When the tool item changes
230  * how it will respond to this signal it must call gtk_tool_item_rebuild_menu()
231  * to invalidate the cache and ensure that the toolbar rebuilds its overflow
232  * menu.
233  *
234  * Return value: %TRUE if the signal was handled, %FALSE if not
235  **/
236   toolitem_signals[CREATE_MENU_PROXY] =
237     g_signal_new (I_("create-menu-proxy"),
238                   G_OBJECT_CLASS_TYPE (klass),
239                   G_SIGNAL_RUN_LAST,
240                   G_STRUCT_OFFSET (GtkToolItemClass, create_menu_proxy),
241                   _gtk_boolean_handled_accumulator, NULL,
242                   _gtk_marshal_BOOLEAN__VOID,
243                   G_TYPE_BOOLEAN, 0);
244
245 /**
246  * GtkToolItem::toolbar-reconfigured:
247  * @tool_item: the object the signal was emitted on
248  *
249  * This signal is emitted when some property of the toolbar that the
250  * item is a child of changes. For custom subclasses of #GtkToolItem,
251  * the default handler of this signal use the functions
252  * <itemizedlist>
253  * <listitem>gtk_tool_shell_get_orientation()</listitem>
254  * <listitem>gtk_tool_shell_get_style()</listitem>
255  * <listitem>gtk_tool_shell_get_icon_size()</listitem>
256  * <listitem>gtk_tool_shell_get_relief_style()</listitem>
257  * </itemizedlist>
258  * to find out what the toolbar should look like and change
259  * themselves accordingly.
260  **/
261   toolitem_signals[TOOLBAR_RECONFIGURED] =
262     g_signal_new (I_("toolbar-reconfigured"),
263                   G_OBJECT_CLASS_TYPE (klass),
264                   G_SIGNAL_RUN_LAST,
265                   G_STRUCT_OFFSET (GtkToolItemClass, toolbar_reconfigured),
266                   NULL, NULL,
267                   _gtk_marshal_VOID__VOID,
268                   G_TYPE_NONE, 0);
269
270   g_type_class_add_private (object_class, sizeof (GtkToolItemPrivate));
271 }
272
273 static void
274 gtk_tool_item_init (GtkToolItem *toolitem)
275 {
276   gtk_widget_set_can_focus (GTK_WIDGET (toolitem), FALSE);
277
278   toolitem->priv = GTK_TOOL_ITEM_GET_PRIVATE (toolitem);
279
280   toolitem->priv->visible_horizontal = TRUE;
281   toolitem->priv->visible_vertical = TRUE;
282   toolitem->priv->homogeneous = FALSE;
283   toolitem->priv->expand = FALSE;
284
285   toolitem->priv->use_action_appearance = TRUE;
286 }
287
288 static void
289 gtk_tool_item_finalize (GObject *object)
290 {
291   GtkToolItem *item = GTK_TOOL_ITEM (object);
292
293   g_free (item->priv->menu_item_id);
294
295   if (item->priv->menu_item)
296     g_object_unref (item->priv->menu_item);
297
298   G_OBJECT_CLASS (gtk_tool_item_parent_class)->finalize (object);
299 }
300
301 static void
302 gtk_tool_item_dispose (GObject *object)
303 {
304   GtkToolItem *item = GTK_TOOL_ITEM (object);
305
306   if (item->priv->action)
307     {
308       gtk_activatable_do_set_related_action (GTK_ACTIVATABLE (item), NULL);      
309       item->priv->action = NULL;
310     }
311   G_OBJECT_CLASS (gtk_tool_item_parent_class)->dispose (object);
312 }
313
314
315 static void
316 gtk_tool_item_parent_set (GtkWidget   *toolitem,
317                           GtkWidget   *prev_parent)
318 {
319   if (GTK_WIDGET (toolitem)->parent != NULL)
320     gtk_tool_item_toolbar_reconfigured (GTK_TOOL_ITEM (toolitem));
321 }
322
323 static void
324 gtk_tool_item_set_property (GObject      *object,
325                             guint         prop_id,
326                             const GValue *value,
327                             GParamSpec   *pspec)
328 {
329   GtkToolItem *toolitem = GTK_TOOL_ITEM (object);
330
331   switch (prop_id)
332     {
333     case PROP_VISIBLE_HORIZONTAL:
334       gtk_tool_item_set_visible_horizontal (toolitem, g_value_get_boolean (value));
335       break;
336     case PROP_VISIBLE_VERTICAL:
337       gtk_tool_item_set_visible_vertical (toolitem, g_value_get_boolean (value));
338       break;
339     case PROP_IS_IMPORTANT:
340       gtk_tool_item_set_is_important (toolitem, g_value_get_boolean (value));
341       break;
342     case PROP_ACTIVATABLE_RELATED_ACTION:
343       gtk_tool_item_set_related_action (toolitem, g_value_get_object (value));
344       break;
345     case PROP_ACTIVATABLE_USE_ACTION_APPEARANCE:
346       gtk_tool_item_set_use_action_appearance (toolitem, g_value_get_boolean (value));
347       break;
348     default:
349       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
350       break;
351     }
352 }
353
354 static void
355 gtk_tool_item_get_property (GObject    *object,
356                             guint       prop_id,
357                             GValue     *value,
358                             GParamSpec *pspec)
359 {
360   GtkToolItem *toolitem = GTK_TOOL_ITEM (object);
361
362   switch (prop_id)
363     {
364     case PROP_VISIBLE_HORIZONTAL:
365       g_value_set_boolean (value, toolitem->priv->visible_horizontal);
366       break;
367     case PROP_VISIBLE_VERTICAL:
368       g_value_set_boolean (value, toolitem->priv->visible_vertical);
369       break;
370     case PROP_IS_IMPORTANT:
371       g_value_set_boolean (value, toolitem->priv->is_important);
372       break;
373     case PROP_ACTIVATABLE_RELATED_ACTION:
374       g_value_set_object (value, toolitem->priv->action);
375       break;
376     case PROP_ACTIVATABLE_USE_ACTION_APPEARANCE:
377       g_value_set_boolean (value, toolitem->priv->use_action_appearance);
378       break;
379     default:
380       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
381       break;
382     }
383 }
384
385 static void
386 gtk_tool_item_property_notify (GObject    *object,
387                                GParamSpec *pspec)
388 {
389   GtkToolItem *tool_item = GTK_TOOL_ITEM (object);
390
391   if (tool_item->priv->menu_item && strcmp (pspec->name, "sensitive") == 0)
392     gtk_widget_set_sensitive (tool_item->priv->menu_item,
393                               gtk_widget_get_sensitive (GTK_WIDGET (tool_item)));
394 }
395
396 static void
397 create_drag_window (GtkToolItem *toolitem)
398 {
399   GtkWidget *widget;
400   GdkWindowAttr attributes;
401   gint attributes_mask, border_width;
402
403   g_return_if_fail (toolitem->priv->use_drag_window == TRUE);
404
405   widget = GTK_WIDGET (toolitem);
406   border_width = GTK_CONTAINER (toolitem)->border_width;
407
408   attributes.window_type = GDK_WINDOW_CHILD;
409   attributes.x = widget->allocation.x + border_width;
410   attributes.y = widget->allocation.y + border_width;
411   attributes.width = widget->allocation.width - border_width * 2;
412   attributes.height = widget->allocation.height - border_width * 2;
413   attributes.wclass = GDK_INPUT_ONLY;
414   attributes.event_mask = gtk_widget_get_events (widget);
415   attributes.event_mask |= (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
416
417   attributes_mask = GDK_WA_X | GDK_WA_Y;
418
419   toolitem->priv->drag_window = gdk_window_new (gtk_widget_get_parent_window (widget),
420                                           &attributes, attributes_mask);
421   gdk_window_set_user_data (toolitem->priv->drag_window, toolitem);
422 }
423
424 static void
425 gtk_tool_item_realize (GtkWidget *widget)
426 {
427   GtkToolItem *toolitem;
428
429   toolitem = GTK_TOOL_ITEM (widget);
430   gtk_widget_set_realized (widget, TRUE);
431
432   widget->window = gtk_widget_get_parent_window (widget);
433   g_object_ref (widget->window);
434
435   if (toolitem->priv->use_drag_window)
436     create_drag_window(toolitem);
437
438   widget->style = gtk_style_attach (widget->style, widget->window);
439 }
440
441 static void
442 destroy_drag_window (GtkToolItem *toolitem)
443 {
444   if (toolitem->priv->drag_window)
445     {
446       gdk_window_set_user_data (toolitem->priv->drag_window, NULL);
447       gdk_window_destroy (toolitem->priv->drag_window);
448       toolitem->priv->drag_window = NULL;
449     }
450 }
451
452 static void
453 gtk_tool_item_unrealize (GtkWidget *widget)
454 {
455   GtkToolItem *toolitem;
456
457   toolitem = GTK_TOOL_ITEM (widget);
458
459   destroy_drag_window (toolitem);
460   
461   GTK_WIDGET_CLASS (gtk_tool_item_parent_class)->unrealize (widget);
462 }
463
464 static void
465 gtk_tool_item_map (GtkWidget *widget)
466 {
467   GtkToolItem *toolitem;
468
469   toolitem = GTK_TOOL_ITEM (widget);
470   GTK_WIDGET_CLASS (gtk_tool_item_parent_class)->map (widget);
471   if (toolitem->priv->drag_window)
472     gdk_window_show (toolitem->priv->drag_window);
473 }
474
475 static void
476 gtk_tool_item_unmap (GtkWidget *widget)
477 {
478   GtkToolItem *toolitem;
479
480   toolitem = GTK_TOOL_ITEM (widget);
481   if (toolitem->priv->drag_window)
482     gdk_window_hide (toolitem->priv->drag_window);
483   GTK_WIDGET_CLASS (gtk_tool_item_parent_class)->unmap (widget);
484 }
485
486 static void
487 gtk_tool_item_size_request (GtkWidget      *widget,
488                             GtkRequisition *requisition)
489 {
490   GtkWidget *child = GTK_BIN (widget)->child;
491
492   if (child && gtk_widget_get_visible (child))
493     {
494       gtk_widget_size_request (child, requisition);
495     }
496   else
497     {
498       requisition->height = 0;
499       requisition->width = 0;
500     }
501   
502   requisition->width += (GTK_CONTAINER (widget)->border_width) * 2;
503   requisition->height += (GTK_CONTAINER (widget)->border_width) * 2;
504 }
505
506 static void
507 gtk_tool_item_size_allocate (GtkWidget     *widget,
508                              GtkAllocation *allocation)
509 {
510   GtkToolItem *toolitem = GTK_TOOL_ITEM (widget);
511   GtkAllocation child_allocation;
512   gint border_width;
513   GtkWidget *child = GTK_BIN (widget)->child;
514
515   widget->allocation = *allocation;
516   border_width = GTK_CONTAINER (widget)->border_width;
517
518   if (toolitem->priv->drag_window)
519     gdk_window_move_resize (toolitem->priv->drag_window,
520                             widget->allocation.x + border_width,
521                             widget->allocation.y + border_width,
522                             widget->allocation.width - border_width * 2,
523                             widget->allocation.height - border_width * 2);
524   
525   if (child && gtk_widget_get_visible (child))
526     {
527       child_allocation.x = allocation->x + border_width;
528       child_allocation.y = allocation->y + border_width;
529       child_allocation.width = allocation->width - 2 * border_width;
530       child_allocation.height = allocation->height - 2 * border_width;
531       
532       gtk_widget_size_allocate (child, &child_allocation);
533     }
534 }
535
536 gboolean
537 _gtk_tool_item_create_menu_proxy (GtkToolItem *item)
538 {
539   GtkWidget *menu_item;
540   gboolean visible_overflown;
541
542   if (item->priv->action)
543     {
544       g_object_get (item->priv->action, "visible-overflown", &visible_overflown, NULL);
545     
546       if (visible_overflown)
547         {
548           menu_item = gtk_action_create_menu_item (item->priv->action);
549
550           g_object_ref_sink (menu_item);
551           gtk_tool_item_set_proxy_menu_item (item, "gtk-action-menu-item", menu_item);
552           g_object_unref (menu_item);
553         }
554       else
555         gtk_tool_item_set_proxy_menu_item (item, "gtk-action-menu-item", NULL);
556
557       return TRUE;
558     }
559
560   return FALSE;
561 }
562
563 static void
564 gtk_tool_item_activatable_interface_init (GtkActivatableIface *iface)
565 {
566   iface->update = gtk_tool_item_update;
567   iface->sync_action_properties = gtk_tool_item_sync_action_properties;
568 }
569
570 static void
571 gtk_tool_item_update (GtkActivatable *activatable,
572                       GtkAction      *action,
573                       const gchar    *property_name)
574 {
575   if (strcmp (property_name, "visible") == 0)
576     {
577       if (gtk_action_is_visible (action))
578         gtk_widget_show (GTK_WIDGET (activatable));
579       else
580         gtk_widget_hide (GTK_WIDGET (activatable));
581     }
582   else if (strcmp (property_name, "sensitive") == 0)
583     gtk_widget_set_sensitive (GTK_WIDGET (activatable), gtk_action_is_sensitive (action));
584   else if (strcmp (property_name, "tooltip") == 0)
585     gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (activatable),
586                                     gtk_action_get_tooltip (action));
587   else if (strcmp (property_name, "visible-horizontal") == 0)
588     gtk_tool_item_set_visible_horizontal (GTK_TOOL_ITEM (activatable),
589                                           gtk_action_get_visible_horizontal (action));
590   else if (strcmp (property_name, "visible-vertical") == 0)
591     gtk_tool_item_set_visible_vertical (GTK_TOOL_ITEM (activatable),
592                                         gtk_action_get_visible_vertical (action));
593   else if (strcmp (property_name, "is-important") == 0)
594     gtk_tool_item_set_is_important (GTK_TOOL_ITEM (activatable),
595                                     gtk_action_get_is_important (action));
596 }
597
598 static void
599 gtk_tool_item_sync_action_properties (GtkActivatable *activatable,
600                                       GtkAction      *action)
601 {
602   if (!action)
603     return;
604
605   if (gtk_action_is_visible (action))
606     gtk_widget_show (GTK_WIDGET (activatable));
607   else
608     gtk_widget_hide (GTK_WIDGET (activatable));
609   
610   gtk_widget_set_sensitive (GTK_WIDGET (activatable), gtk_action_is_sensitive (action));
611   
612   gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (activatable),
613                                   gtk_action_get_tooltip (action));
614   gtk_tool_item_set_visible_horizontal (GTK_TOOL_ITEM (activatable),
615                                         gtk_action_get_visible_horizontal (action));
616   gtk_tool_item_set_visible_vertical (GTK_TOOL_ITEM (activatable),
617                                       gtk_action_get_visible_vertical (action));
618   gtk_tool_item_set_is_important (GTK_TOOL_ITEM (activatable),
619                                   gtk_action_get_is_important (action));
620 }
621
622 static void
623 gtk_tool_item_set_related_action (GtkToolItem *item, 
624                                   GtkAction   *action)
625 {
626   if (item->priv->action == action)
627     return;
628
629   gtk_activatable_do_set_related_action (GTK_ACTIVATABLE (item), action);
630
631   item->priv->action = action;
632
633   if (action)
634     {
635       gtk_tool_item_rebuild_menu (item);
636     }
637 }
638
639 static void
640 gtk_tool_item_set_use_action_appearance (GtkToolItem *item,
641                                          gboolean     use_appearance)
642 {
643   if (item->priv->use_action_appearance != use_appearance)
644     {
645       item->priv->use_action_appearance = use_appearance;
646
647       gtk_activatable_sync_action_properties (GTK_ACTIVATABLE (item), item->priv->action);
648     }
649 }
650
651
652 /**
653  * gtk_tool_item_new:
654  * 
655  * Creates a new #GtkToolItem
656  * 
657  * Return value: the new #GtkToolItem
658  * 
659  * Since: 2.4
660  **/
661 GtkToolItem *
662 gtk_tool_item_new (void)
663 {
664   GtkToolItem *item;
665
666   item = g_object_new (GTK_TYPE_TOOL_ITEM, NULL);
667
668   return item;
669 }
670
671 /**
672  * gtk_tool_item_get_ellipsize_mode:
673  * @tool_item: a #GtkToolItem
674  *
675  * Returns the ellipsize mode used for @tool_item. Custom subclasses of
676  * #GtkToolItem should call this function to find out how text should
677  * be ellipsized.
678  *
679  * Return value: a #PangoEllipsizeMode indicating how text in @tool_item
680  * should be ellipsized.
681  *
682  * Since: 2.20
683  **/
684 PangoEllipsizeMode
685 gtk_tool_item_get_ellipsize_mode (GtkToolItem *tool_item)
686 {
687   GtkWidget *parent;
688   
689   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_ORIENTATION_HORIZONTAL);
690
691   parent = GTK_WIDGET (tool_item)->parent;
692   if (!parent || !GTK_IS_TOOL_SHELL (parent))
693     return PANGO_ELLIPSIZE_NONE;
694
695   return gtk_tool_shell_get_ellipsize_mode (GTK_TOOL_SHELL (parent));
696 }
697
698 /**
699  * gtk_tool_item_get_icon_size:
700  * @tool_item: a #GtkToolItem
701  * 
702  * Returns the icon size used for @tool_item. Custom subclasses of
703  * #GtkToolItem should call this function to find out what size icons
704  * they should use.
705  * 
706  * Return value: (type int): a #GtkIconSize indicating the icon size
707  * used for @tool_item
708  * 
709  * Since: 2.4
710  **/
711 GtkIconSize
712 gtk_tool_item_get_icon_size (GtkToolItem *tool_item)
713 {
714   GtkWidget *parent;
715
716   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_ICON_SIZE_LARGE_TOOLBAR);
717
718   parent = GTK_WIDGET (tool_item)->parent;
719   if (!parent || !GTK_IS_TOOL_SHELL (parent))
720     return GTK_ICON_SIZE_LARGE_TOOLBAR;
721
722   return gtk_tool_shell_get_icon_size (GTK_TOOL_SHELL (parent));
723 }
724
725 /**
726  * gtk_tool_item_get_orientation:
727  * @tool_item: a #GtkToolItem 
728  * 
729  * Returns the orientation used for @tool_item. Custom subclasses of
730  * #GtkToolItem should call this function to find out what size icons
731  * they should use.
732  * 
733  * Return value: a #GtkOrientation indicating the orientation
734  * used for @tool_item
735  * 
736  * Since: 2.4
737  **/
738 GtkOrientation
739 gtk_tool_item_get_orientation (GtkToolItem *tool_item)
740 {
741   GtkWidget *parent;
742   
743   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_ORIENTATION_HORIZONTAL);
744
745   parent = GTK_WIDGET (tool_item)->parent;
746   if (!parent || !GTK_IS_TOOL_SHELL (parent))
747     return GTK_ORIENTATION_HORIZONTAL;
748
749   return gtk_tool_shell_get_orientation (GTK_TOOL_SHELL (parent));
750 }
751
752 /**
753  * gtk_tool_item_get_toolbar_style:
754  * @tool_item: a #GtkToolItem 
755  * 
756  * Returns the toolbar style used for @tool_item. Custom subclasses of
757  * #GtkToolItem should call this function in the handler of the
758  * GtkToolItem::toolbar_reconfigured signal to find out in what style
759  * the toolbar is displayed and change themselves accordingly 
760  *
761  * Possibilities are:
762  * <itemizedlist>
763  * <listitem> GTK_TOOLBAR_BOTH, meaning the tool item should show
764  * both an icon and a label, stacked vertically </listitem>
765  * <listitem> GTK_TOOLBAR_ICONS, meaning the toolbar shows
766  * only icons </listitem>
767  * <listitem> GTK_TOOLBAR_TEXT, meaning the tool item should only
768  * show text</listitem>
769  * <listitem> GTK_TOOLBAR_BOTH_HORIZ, meaning the tool item should show
770  * both an icon and a label, arranged horizontally (however, note the 
771  * #GtkToolButton::has_text_horizontally that makes tool buttons not
772  * show labels when the toolbar style is GTK_TOOLBAR_BOTH_HORIZ.
773  * </listitem>
774  * </itemizedlist>
775  * 
776  * Return value: A #GtkToolbarStyle indicating the toolbar style used
777  * for @tool_item.
778  * 
779  * Since: 2.4
780  **/
781 GtkToolbarStyle
782 gtk_tool_item_get_toolbar_style (GtkToolItem *tool_item)
783 {
784   GtkWidget *parent;
785   
786   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_TOOLBAR_ICONS);
787
788   parent = GTK_WIDGET (tool_item)->parent;
789   if (!parent || !GTK_IS_TOOL_SHELL (parent))
790     return GTK_TOOLBAR_ICONS;
791
792   return gtk_tool_shell_get_style (GTK_TOOL_SHELL (parent));
793 }
794
795 /**
796  * gtk_tool_item_get_relief_style:
797  * @tool_item: a #GtkToolItem 
798  * 
799  * Returns the relief style of @tool_item. See gtk_button_set_relief_style().
800  * Custom subclasses of #GtkToolItem should call this function in the handler
801  * of the #GtkToolItem::toolbar_reconfigured signal to find out the
802  * relief style of buttons.
803  * 
804  * Return value: a #GtkReliefStyle indicating the relief style used
805  * for @tool_item.
806  * 
807  * Since: 2.4
808  **/
809 GtkReliefStyle 
810 gtk_tool_item_get_relief_style (GtkToolItem *tool_item)
811 {
812   GtkWidget *parent;
813   
814   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_RELIEF_NONE);
815
816   parent = GTK_WIDGET (tool_item)->parent;
817   if (!parent || !GTK_IS_TOOL_SHELL (parent))
818     return GTK_RELIEF_NONE;
819
820   return gtk_tool_shell_get_relief_style (GTK_TOOL_SHELL (parent));
821 }
822
823 /**
824  * gtk_tool_item_get_text_alignment:
825  * @tool_item: a #GtkToolItem: 
826  * 
827  * Returns the text alignment used for @tool_item. Custom subclasses of
828  * #GtkToolItem should call this function to find out how text should
829  * be aligned.
830  * 
831  * Return value: a #gfloat indicating the horizontal text alignment
832  * used for @tool_item
833  * 
834  * Since: 2.20
835  **/
836 gfloat
837 gtk_tool_item_get_text_alignment (GtkToolItem *tool_item)
838 {
839   GtkWidget *parent;
840   
841   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_ORIENTATION_HORIZONTAL);
842
843   parent = GTK_WIDGET (tool_item)->parent;
844   if (!parent || !GTK_IS_TOOL_SHELL (parent))
845     return 0.5;
846
847   return gtk_tool_shell_get_text_alignment (GTK_TOOL_SHELL (parent));
848 }
849
850 /**
851  * gtk_tool_item_get_text_orientation:
852  * @tool_item: a #GtkToolItem
853  *
854  * Returns the text orientation used for @tool_item. Custom subclasses of
855  * #GtkToolItem should call this function to find out how text should
856  * be orientated.
857  *
858  * Return value: a #GtkOrientation indicating the text orientation
859  * used for @tool_item
860  *
861  * Since: 2.20
862  */
863 GtkOrientation
864 gtk_tool_item_get_text_orientation (GtkToolItem *tool_item)
865 {
866   GtkWidget *parent;
867   
868   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_ORIENTATION_HORIZONTAL);
869
870   parent = GTK_WIDGET (tool_item)->parent;
871   if (!parent || !GTK_IS_TOOL_SHELL (parent))
872     return GTK_ORIENTATION_HORIZONTAL;
873
874   return gtk_tool_shell_get_text_orientation (GTK_TOOL_SHELL (parent));
875 }
876
877 /**
878  * gtk_tool_item_get_text_size_group:
879  * @tool_item: a #GtkToolItem
880  *
881  * Returns the size group used for labels in @tool_item. Custom subclasses of
882  * #GtkToolItem should call this function and use the size group for labels.
883  *
884  * Return value: a #GtkSizeGroup
885  *
886  * Since: 2.20
887  */
888 GtkSizeGroup *
889 gtk_tool_item_get_text_size_group (GtkToolItem *tool_item)
890 {
891   GtkWidget *parent;
892   
893   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), NULL);
894
895   parent = GTK_WIDGET (tool_item)->parent;
896   if (!parent || !GTK_IS_TOOL_SHELL (parent))
897     return NULL;
898
899   return gtk_tool_shell_get_text_size_group (GTK_TOOL_SHELL (parent));
900 }
901
902 /**
903  * gtk_tool_item_set_expand:
904  * @tool_item: a #GtkToolItem
905  * @expand: Whether @tool_item is allocated extra space
906  *
907  * Sets whether @tool_item is allocated extra space when there
908  * is more room on the toolbar then needed for the items. The
909  * effect is that the item gets bigger when the toolbar gets bigger
910  * and smaller when the toolbar gets smaller.
911  *
912  * Since: 2.4
913  */
914 void
915 gtk_tool_item_set_expand (GtkToolItem *tool_item,
916                           gboolean     expand)
917 {
918   g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
919     
920   expand = expand != FALSE;
921
922   if (tool_item->priv->expand != expand)
923     {
924       tool_item->priv->expand = expand;
925       gtk_widget_child_notify (GTK_WIDGET (tool_item), "expand");
926       gtk_widget_queue_resize (GTK_WIDGET (tool_item));
927     }
928 }
929
930 /**
931  * gtk_tool_item_get_expand:
932  * @tool_item: a #GtkToolItem 
933  * 
934  * Returns whether @tool_item is allocated extra space.
935  * See gtk_tool_item_set_expand().
936  * 
937  * Return value: %TRUE if @tool_item is allocated extra space.
938  * 
939  * Since: 2.4
940  **/
941 gboolean
942 gtk_tool_item_get_expand (GtkToolItem *tool_item)
943 {
944   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), FALSE);
945
946   return tool_item->priv->expand;
947 }
948
949 /**
950  * gtk_tool_item_set_homogeneous:
951  * @tool_item: a #GtkToolItem 
952  * @homogeneous: whether @tool_item is the same size as other homogeneous items
953  * 
954  * Sets whether @tool_item is to be allocated the same size as other
955  * homogeneous items. The effect is that all homogeneous items will have
956  * the same width as the widest of the items.
957  * 
958  * Since: 2.4
959  **/
960 void
961 gtk_tool_item_set_homogeneous (GtkToolItem *tool_item,
962                                gboolean     homogeneous)
963 {
964   g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
965     
966   homogeneous = homogeneous != FALSE;
967
968   if (tool_item->priv->homogeneous != homogeneous)
969     {
970       tool_item->priv->homogeneous = homogeneous;
971       gtk_widget_child_notify (GTK_WIDGET (tool_item), "homogeneous");
972       gtk_widget_queue_resize (GTK_WIDGET (tool_item));
973     }
974 }
975
976 /**
977  * gtk_tool_item_get_homogeneous:
978  * @tool_item: a #GtkToolItem 
979  * 
980  * Returns whether @tool_item is the same size as other homogeneous
981  * items. See gtk_tool_item_set_homogeneous().
982  * 
983  * Return value: %TRUE if the item is the same size as other homogeneous
984  * items.
985  * 
986  * Since: 2.4
987  **/
988 gboolean
989 gtk_tool_item_get_homogeneous (GtkToolItem *tool_item)
990 {
991   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), FALSE);
992
993   return tool_item->priv->homogeneous;
994 }
995
996 /**
997  * gtk_tool_item_get_is_important:
998  * @tool_item: a #GtkToolItem
999  * 
1000  * Returns whether @tool_item is considered important. See
1001  * gtk_tool_item_set_is_important()
1002  * 
1003  * Return value: %TRUE if @tool_item is considered important.
1004  * 
1005  * Since: 2.4
1006  **/
1007 gboolean
1008 gtk_tool_item_get_is_important (GtkToolItem *tool_item)
1009 {
1010   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), FALSE);
1011
1012   return tool_item->priv->is_important;
1013 }
1014
1015 /**
1016  * gtk_tool_item_set_is_important:
1017  * @tool_item: a #GtkToolItem
1018  * @is_important: whether the tool item should be considered important
1019  * 
1020  * Sets whether @tool_item should be considered important. The #GtkToolButton
1021  * class uses this property to determine whether to show or hide its label
1022  * when the toolbar style is %GTK_TOOLBAR_BOTH_HORIZ. The result is that
1023  * only tool buttons with the "is_important" property set have labels, an
1024  * effect known as "priority text"
1025  * 
1026  * Since: 2.4
1027  **/
1028 void
1029 gtk_tool_item_set_is_important (GtkToolItem *tool_item, gboolean is_important)
1030 {
1031   g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
1032
1033   is_important = is_important != FALSE;
1034
1035   if (is_important != tool_item->priv->is_important)
1036     {
1037       tool_item->priv->is_important = is_important;
1038
1039       gtk_widget_queue_resize (GTK_WIDGET (tool_item));
1040
1041       g_object_notify (G_OBJECT (tool_item), "is-important");
1042     }
1043 }
1044
1045 /**
1046  * gtk_tool_item_set_tooltip_text:
1047  * @tool_item: a #GtkToolItem 
1048  * @text: text to be used as tooltip for @tool_item
1049  *
1050  * Sets the text to be displayed as tooltip on the item.
1051  * See gtk_widget_set_tooltip_text().
1052  *
1053  * Since: 2.12
1054  **/
1055 void
1056 gtk_tool_item_set_tooltip_text (GtkToolItem *tool_item,
1057                                 const gchar *text)
1058 {
1059   GtkWidget *child;
1060
1061   g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
1062
1063   child = GTK_BIN (tool_item)->child;
1064
1065   if (child)
1066     gtk_widget_set_tooltip_text (child, text);
1067 }
1068
1069 /**
1070  * gtk_tool_item_set_tooltip_markup:
1071  * @tool_item: a #GtkToolItem 
1072  * @markup: markup text to be used as tooltip for @tool_item
1073  *
1074  * Sets the markup text to be displayed as tooltip on the item.
1075  * See gtk_widget_set_tooltip_markup().
1076  *
1077  * Since: 2.12
1078  **/
1079 void
1080 gtk_tool_item_set_tooltip_markup (GtkToolItem *tool_item,
1081                                   const gchar *markup)
1082 {
1083   GtkWidget *child;
1084
1085   g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
1086
1087   child = GTK_BIN (tool_item)->child;
1088
1089   if (child)
1090     gtk_widget_set_tooltip_markup (child, markup);
1091 }
1092
1093 /**
1094  * gtk_tool_item_set_use_drag_window:
1095  * @tool_item: a #GtkToolItem 
1096  * @use_drag_window: Whether @tool_item has a drag window.
1097  * 
1098  * Sets whether @tool_item has a drag window. When %TRUE the
1099  * toolitem can be used as a drag source through gtk_drag_source_set().
1100  * When @tool_item has a drag window it will intercept all events,
1101  * even those that would otherwise be sent to a child of @tool_item.
1102  * 
1103  * Since: 2.4
1104  **/
1105 void
1106 gtk_tool_item_set_use_drag_window (GtkToolItem *toolitem,
1107                                    gboolean     use_drag_window)
1108 {
1109   g_return_if_fail (GTK_IS_TOOL_ITEM (toolitem));
1110
1111   use_drag_window = use_drag_window != FALSE;
1112
1113   if (toolitem->priv->use_drag_window != use_drag_window)
1114     {
1115       toolitem->priv->use_drag_window = use_drag_window;
1116       
1117       if (use_drag_window)
1118         {
1119           if (!toolitem->priv->drag_window &&
1120               gtk_widget_get_realized (GTK_WIDGET (toolitem)))
1121             {
1122               create_drag_window(toolitem);
1123               if (gtk_widget_get_mapped (GTK_WIDGET (toolitem)))
1124                 gdk_window_show (toolitem->priv->drag_window);
1125             }
1126         }
1127       else
1128         {
1129           destroy_drag_window (toolitem);
1130         }
1131     }
1132 }
1133
1134 /**
1135  * gtk_tool_item_get_use_drag_window:
1136  * @tool_item: a #GtkToolItem 
1137  * 
1138  * Returns whether @tool_item has a drag window. See
1139  * gtk_tool_item_set_use_drag_window().
1140  * 
1141  * Return value: %TRUE if @tool_item uses a drag window.
1142  * 
1143  * Since: 2.4
1144  **/
1145 gboolean
1146 gtk_tool_item_get_use_drag_window (GtkToolItem *toolitem)
1147 {
1148   g_return_val_if_fail (GTK_IS_TOOL_ITEM (toolitem), FALSE);
1149
1150   return toolitem->priv->use_drag_window;
1151 }
1152
1153 /**
1154  * gtk_tool_item_set_visible_horizontal:
1155  * @tool_item: a #GtkToolItem
1156  * @visible_horizontal: Whether @tool_item is visible when in horizontal mode
1157  * 
1158  * Sets whether @tool_item is visible when the toolbar is docked horizontally.
1159  * 
1160  * Since: 2.4
1161  **/
1162 void
1163 gtk_tool_item_set_visible_horizontal (GtkToolItem *toolitem,
1164                                       gboolean     visible_horizontal)
1165 {
1166   g_return_if_fail (GTK_IS_TOOL_ITEM (toolitem));
1167
1168   visible_horizontal = visible_horizontal != FALSE;
1169
1170   if (toolitem->priv->visible_horizontal != visible_horizontal)
1171     {
1172       toolitem->priv->visible_horizontal = visible_horizontal;
1173
1174       g_object_notify (G_OBJECT (toolitem), "visible-horizontal");
1175
1176       gtk_widget_queue_resize (GTK_WIDGET (toolitem));
1177     }
1178 }
1179
1180 /**
1181  * gtk_tool_item_get_visible_horizontal:
1182  * @tool_item: a #GtkToolItem 
1183  * 
1184  * Returns whether the @tool_item is visible on toolbars that are
1185  * docked horizontally.
1186  * 
1187  * Return value: %TRUE if @tool_item is visible on toolbars that are
1188  * docked horizontally.
1189  * 
1190  * Since: 2.4
1191  **/
1192 gboolean
1193 gtk_tool_item_get_visible_horizontal (GtkToolItem *toolitem)
1194 {
1195   g_return_val_if_fail (GTK_IS_TOOL_ITEM (toolitem), FALSE);
1196
1197   return toolitem->priv->visible_horizontal;
1198 }
1199
1200 /**
1201  * gtk_tool_item_set_visible_vertical:
1202  * @tool_item: a #GtkToolItem 
1203  * @visible_vertical: whether @tool_item is visible when the toolbar
1204  * is in vertical mode
1205  *
1206  * Sets whether @tool_item is visible when the toolbar is docked
1207  * vertically. Some tool items, such as text entries, are too wide to be
1208  * useful on a vertically docked toolbar. If @visible_vertical is %FALSE
1209  * @tool_item will not appear on toolbars that are docked vertically.
1210  * 
1211  * Since: 2.4
1212  **/
1213 void
1214 gtk_tool_item_set_visible_vertical (GtkToolItem *toolitem,
1215                                     gboolean     visible_vertical)
1216 {
1217   g_return_if_fail (GTK_IS_TOOL_ITEM (toolitem));
1218
1219   visible_vertical = visible_vertical != FALSE;
1220
1221   if (toolitem->priv->visible_vertical != visible_vertical)
1222     {
1223       toolitem->priv->visible_vertical = visible_vertical;
1224
1225       g_object_notify (G_OBJECT (toolitem), "visible-vertical");
1226
1227       gtk_widget_queue_resize (GTK_WIDGET (toolitem));
1228     }
1229 }
1230
1231 /**
1232  * gtk_tool_item_get_visible_vertical:
1233  * @tool_item: a #GtkToolItem 
1234  * 
1235  * Returns whether @tool_item is visible when the toolbar is docked vertically.
1236  * See gtk_tool_item_set_visible_vertical().
1237  * 
1238  * Return value: Whether @tool_item is visible when the toolbar is docked vertically
1239  * 
1240  * Since: 2.4
1241  **/
1242 gboolean
1243 gtk_tool_item_get_visible_vertical (GtkToolItem *toolitem)
1244 {
1245   g_return_val_if_fail (GTK_IS_TOOL_ITEM (toolitem), FALSE);
1246
1247   return toolitem->priv->visible_vertical;
1248 }
1249
1250 /**
1251  * gtk_tool_item_retrieve_proxy_menu_item:
1252  * @tool_item: a #GtkToolItem 
1253  * 
1254  * Returns the #GtkMenuItem that was last set by
1255  * gtk_tool_item_set_proxy_menu_item(), ie. the #GtkMenuItem
1256  * that is going to appear in the overflow menu.
1257  *
1258  * Return value: (transfer none): The #GtkMenuItem that is going to appear in the
1259  * overflow menu for @tool_item.
1260  *
1261  * Since: 2.4
1262  **/
1263 GtkWidget *
1264 gtk_tool_item_retrieve_proxy_menu_item (GtkToolItem *tool_item)
1265 {
1266   gboolean retval;
1267   
1268   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), NULL);
1269
1270   g_signal_emit (tool_item, toolitem_signals[CREATE_MENU_PROXY], 0,
1271                  &retval);
1272   
1273   return tool_item->priv->menu_item;
1274 }
1275
1276 /**
1277  * gtk_tool_item_get_proxy_menu_item:
1278  * @tool_item: a #GtkToolItem 
1279  * @menu_item_id: a string used to identify the menu item
1280  * 
1281  * If @menu_item_id matches the string passed to
1282  * gtk_tool_item_set_proxy_menu_item() return the corresponding #GtkMenuItem.
1283  *
1284  * Custom subclasses of #GtkToolItem should use this function to update
1285  * their menu item when the #GtkToolItem changes. That the
1286  * @menu_item_id<!-- -->s must match ensures that a #GtkToolItem will not
1287  * inadvertently change a menu item that they did not create.
1288  * 
1289  * Return value: The #GtkMenuItem passed to
1290  * gtk_tool_item_set_proxy_menu_item(), if the @menu_item_id<!-- -->s match.
1291  * 
1292  * Since: 2.4
1293  **/
1294 GtkWidget *
1295 gtk_tool_item_get_proxy_menu_item (GtkToolItem *tool_item,
1296                                    const gchar *menu_item_id)
1297 {
1298   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), NULL);
1299   g_return_val_if_fail (menu_item_id != NULL, NULL);
1300
1301   if (tool_item->priv->menu_item_id && strcmp (tool_item->priv->menu_item_id, menu_item_id) == 0)
1302     return tool_item->priv->menu_item;
1303
1304   return NULL;
1305 }
1306
1307 /**
1308  * gtk_tool_item_rebuild_menu:
1309  * @tool_item: a #GtkToolItem
1310  *
1311  * Calling this function signals to the toolbar that the
1312  * overflow menu item for @tool_item has changed. If the
1313  * overflow menu is visible when this function it called,
1314  * the menu will be rebuilt.
1315  *
1316  * The function must be called when the tool item changes what it
1317  * will do in response to the #GtkToolItem::create-menu-proxy signal.
1318  *
1319  * Since: 2.6
1320  */
1321 void
1322 gtk_tool_item_rebuild_menu (GtkToolItem *tool_item)
1323 {
1324   GtkWidget *widget;
1325   
1326   g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
1327
1328   widget = GTK_WIDGET (tool_item);
1329
1330   if (GTK_IS_TOOL_SHELL (widget->parent))
1331     gtk_tool_shell_rebuild_menu (GTK_TOOL_SHELL (widget->parent));
1332 }
1333
1334 /**
1335  * gtk_tool_item_set_proxy_menu_item:
1336  * @tool_item: a #GtkToolItem
1337  * @menu_item_id: a string used to identify @menu_item
1338  * @menu_item: a #GtkMenuItem to be used in the overflow menu
1339  * 
1340  * Sets the #GtkMenuItem used in the toolbar overflow menu. The
1341  * @menu_item_id is used to identify the caller of this function and
1342  * should also be used with gtk_tool_item_get_proxy_menu_item().
1343  * 
1344  * Since: 2.4
1345  **/
1346 void
1347 gtk_tool_item_set_proxy_menu_item (GtkToolItem *tool_item,
1348                                    const gchar *menu_item_id,
1349                                    GtkWidget   *menu_item)
1350 {
1351   g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
1352   g_return_if_fail (menu_item == NULL || GTK_IS_MENU_ITEM (menu_item));
1353   g_return_if_fail (menu_item_id != NULL);
1354
1355   g_free (tool_item->priv->menu_item_id);
1356       
1357   tool_item->priv->menu_item_id = g_strdup (menu_item_id);
1358
1359   if (tool_item->priv->menu_item != menu_item)
1360     {
1361       if (tool_item->priv->menu_item)
1362         g_object_unref (tool_item->priv->menu_item);
1363       
1364       if (menu_item)
1365         {
1366           g_object_ref_sink (menu_item);
1367
1368           gtk_widget_set_sensitive (menu_item,
1369                                     gtk_widget_get_sensitive (GTK_WIDGET (tool_item)));
1370         }
1371       
1372       tool_item->priv->menu_item = menu_item;
1373     }
1374 }
1375
1376 /**
1377  * gtk_tool_item_toolbar_reconfigured:
1378  * @tool_item: a #GtkToolItem
1379  *
1380  * Emits the signal #GtkToolItem::toolbar_reconfigured on @tool_item.
1381  * #GtkToolbar and other #GtkToolShell implementations use this function
1382  * to notify children, when some aspect of their configuration changes.
1383  *
1384  * Since: 2.14
1385  **/
1386 void
1387 gtk_tool_item_toolbar_reconfigured (GtkToolItem *tool_item)
1388 {
1389   /* The slightely inaccurate name "gtk_tool_item_toolbar_reconfigured" was
1390    * choosen over "gtk_tool_item_tool_shell_reconfigured", since the function
1391    * emits the "toolbar-reconfigured" signal, not "tool-shell-reconfigured".
1392    * Its not possible to rename the signal, and emitting another name than
1393    * indicated by the function name would be quite confusing. That's the
1394    * price of providing stable APIs.
1395    */
1396   g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
1397
1398   g_signal_emit (tool_item, toolitem_signals[TOOLBAR_RECONFIGURED], 0);
1399   
1400   if (tool_item->priv->drag_window)
1401     gdk_window_raise (tool_item->priv->drag_window);
1402
1403   gtk_widget_queue_resize (GTK_WIDGET (tool_item));
1404 }
1405
1406 #define __GTK_TOOL_ITEM_C__
1407 #include "gtkaliasdef.c"