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