]> Pileus Git - ~andy/gtk/blob - gtk/gtktoolitem.c
More action-related fixes
[~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 void gtk_tool_item_activatable_interface_init (GtkActivatableIface  *iface);
131 static void gtk_tool_item_activatable_update         (GtkActivatable       *activatable,
132                                                       GtkAction            *action,
133                                                       const gchar          *property_name);
134 static void gtk_tool_item_activatable_reset          (GtkActivatable       *activatable,
135                                                       GtkAction            *action);
136 static void gtk_tool_item_set_related_action         (GtkToolItem          *item, 
137                                                       GtkAction            *action);
138 static void gtk_tool_item_set_use_action_appearance  (GtkToolItem          *item, 
139                                                       gboolean              use_appearance);
140
141 static guint toolitem_signals[LAST_SIGNAL] = { 0 };
142
143 G_DEFINE_TYPE_WITH_CODE (GtkToolItem, gtk_tool_item, GTK_TYPE_BIN,
144                          G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIVATABLE,
145                                                 gtk_tool_item_activatable_interface_init))
146
147 static void
148 gtk_tool_item_class_init (GtkToolItemClass *klass)
149 {
150   GObjectClass *object_class;
151   GtkWidgetClass *widget_class;
152   
153   object_class = (GObjectClass *)klass;
154   widget_class = (GtkWidgetClass *)klass;
155   
156   object_class->set_property = gtk_tool_item_set_property;
157   object_class->get_property = gtk_tool_item_get_property;
158   object_class->finalize     = gtk_tool_item_finalize;
159   object_class->dispose      = gtk_tool_item_dispose;
160   object_class->notify       = gtk_tool_item_property_notify;
161
162   widget_class->realize       = gtk_tool_item_realize;
163   widget_class->unrealize     = gtk_tool_item_unrealize;
164   widget_class->map           = gtk_tool_item_map;
165   widget_class->unmap         = gtk_tool_item_unmap;
166   widget_class->size_request  = gtk_tool_item_size_request;
167   widget_class->size_allocate = gtk_tool_item_size_allocate;
168   widget_class->parent_set    = gtk_tool_item_parent_set;
169
170   klass->create_menu_proxy = _gtk_tool_item_create_menu_proxy;
171   klass->set_tooltip       = gtk_tool_item_real_set_tooltip;
172   
173   g_object_class_install_property (object_class,
174                                    PROP_VISIBLE_HORIZONTAL,
175                                    g_param_spec_boolean ("visible-horizontal",
176                                                          P_("Visible when horizontal"),
177                                                          P_("Whether the toolbar item is visible when the toolbar is in a horizontal orientation."),
178                                                          TRUE,
179                                                          GTK_PARAM_READWRITE));
180   g_object_class_install_property (object_class,
181                                    PROP_VISIBLE_VERTICAL,
182                                    g_param_spec_boolean ("visible-vertical",
183                                                          P_("Visible when vertical"),
184                                                          P_("Whether the toolbar item is visible when the toolbar is in a vertical orientation."),
185                                                          TRUE,
186                                                          GTK_PARAM_READWRITE));
187   g_object_class_install_property (object_class,
188                                    PROP_IS_IMPORTANT,
189                                    g_param_spec_boolean ("is-important",
190                                                          P_("Is important"),
191                                                          P_("Whether the toolbar item is considered important. When TRUE, toolbar buttons show text in GTK_TOOLBAR_BOTH_HORIZ mode"),
192                                                          FALSE,
193                                                          GTK_PARAM_READWRITE));
194
195   g_object_class_override_property (object_class, PROP_ACTIVATABLE_RELATED_ACTION, "related-action");
196   g_object_class_override_property (object_class, PROP_ACTIVATABLE_USE_ACTION_APPEARANCE, "use-action-appearance");
197
198
199 /**
200  * GtkToolItem::create-menu-proxy:
201  * @tool_item: the object the signal was emitted on
202  *
203  * This signal is emitted when the toolbar needs information from @tool_item
204  * about whether the item should appear in the toolbar overflow menu. In
205  * response the tool item should either
206  * <itemizedlist>
207  * <listitem>call gtk_tool_item_set_proxy_menu_item() with a %NULL
208  * pointer and return %TRUE to indicate that the item should not appear
209  * in the overflow menu
210  * </listitem>
211  * <listitem> call gtk_tool_item_set_proxy_menu_item() with a new menu
212  * item and return %TRUE, or 
213  * </listitem>
214  * <listitem> return %FALSE to indicate that the signal was not
215  * handled by the item. This means that
216  * the item will not appear in the overflow menu unless a later handler
217  * installs a menu item.
218  * </listitem>
219  * </itemizedlist>
220  *
221  * The toolbar may cache the result of this signal. When the tool item changes
222  * how it will respond to this signal it must call gtk_tool_item_rebuild_menu()
223  * to invalidate the cache and ensure that the toolbar rebuilds its overflow
224  * menu.
225  *
226  * Return value: %TRUE if the signal was handled, %FALSE if not
227  **/
228   toolitem_signals[CREATE_MENU_PROXY] =
229     g_signal_new (I_("create-menu-proxy"),
230                   G_OBJECT_CLASS_TYPE (klass),
231                   G_SIGNAL_RUN_LAST,
232                   G_STRUCT_OFFSET (GtkToolItemClass, create_menu_proxy),
233                   _gtk_boolean_handled_accumulator, NULL,
234                   _gtk_marshal_BOOLEAN__VOID,
235                   G_TYPE_BOOLEAN, 0);
236
237 /**
238  * GtkToolItem::toolbar-reconfigured:
239  * @tool_item: the object the signal was emitted on
240  *
241  * This signal is emitted when some property of the toolbar that the
242  * item is a child of changes. For custom subclasses of #GtkToolItem,
243  * the default handler of this signal use the functions
244  * <itemizedlist>
245  * <listitem>gtk_tool_shell_get_orientation()</listitem>
246  * <listitem>gtk_tool_shell_get_style()</listitem>
247  * <listitem>gtk_tool_shell_get_icon_size()</listitem>
248  * <listitem>gtk_tool_shell_get_relief_style()</listitem>
249  * </itemizedlist>
250  * to find out what the toolbar should look like and change
251  * themselves accordingly.
252  **/
253   toolitem_signals[TOOLBAR_RECONFIGURED] =
254     g_signal_new (I_("toolbar-reconfigured"),
255                   G_OBJECT_CLASS_TYPE (klass),
256                   G_SIGNAL_RUN_LAST,
257                   G_STRUCT_OFFSET (GtkToolItemClass, toolbar_reconfigured),
258                   NULL, NULL,
259                   _gtk_marshal_VOID__VOID,
260                   G_TYPE_NONE, 0);
261 /**
262  * GtkToolItem::set-tooltip:
263  * @tool_item: the object the signal was emitted on
264  * @tooltips: the #GtkTooltips
265  * @tip_text: the tooltip text
266  * @tip_private: the tooltip private text
267  *
268  * This signal is emitted when the toolitem's tooltip changes.
269  * Application developers can use gtk_tool_item_set_tooltip() to
270  * set the item's tooltip.
271  *
272  * Return value: %TRUE if the signal was handled, %FALSE if not
273  *
274  * Deprecated: 2.12: With the new tooltip API, there is no
275  *   need to use this signal anymore.
276  **/
277   toolitem_signals[SET_TOOLTIP] =
278     g_signal_new (I_("set-tooltip"),
279                   G_OBJECT_CLASS_TYPE (klass),
280                   G_SIGNAL_RUN_LAST,
281                   G_STRUCT_OFFSET (GtkToolItemClass, set_tooltip),
282                   _gtk_boolean_handled_accumulator, NULL,
283                   _gtk_marshal_BOOLEAN__OBJECT_STRING_STRING,
284                   G_TYPE_BOOLEAN, 3,
285                   GTK_TYPE_TOOLTIPS,
286                   G_TYPE_STRING,
287                   G_TYPE_STRING);                 
288
289   g_type_class_add_private (object_class, sizeof (GtkToolItemPrivate));
290 }
291
292 static void
293 gtk_tool_item_init (GtkToolItem *toolitem)
294 {
295   GTK_WIDGET_UNSET_FLAGS (toolitem, GTK_CAN_FOCUS);  
296
297   toolitem->priv = GTK_TOOL_ITEM_GET_PRIVATE (toolitem);
298
299   toolitem->priv->visible_horizontal = TRUE;
300   toolitem->priv->visible_vertical = TRUE;
301   toolitem->priv->homogeneous = FALSE;
302   toolitem->priv->expand = FALSE;
303
304   toolitem->priv->use_action_appearance = TRUE;
305 }
306
307 static void
308 gtk_tool_item_finalize (GObject *object)
309 {
310   GtkToolItem *item = GTK_TOOL_ITEM (object);
311
312   g_free (item->priv->menu_item_id);
313
314   if (item->priv->menu_item)
315     g_object_unref (item->priv->menu_item);
316
317   G_OBJECT_CLASS (gtk_tool_item_parent_class)->finalize (object);
318 }
319
320 static void
321 gtk_tool_item_dispose (GObject *object)
322 {
323   GtkToolItem *item = GTK_TOOL_ITEM (object);
324
325   if (item->priv->action)
326     {
327       gtk_activatable_do_set_related_action (GTK_ACTIVATABLE (item), NULL);      
328       item->priv->action = NULL;
329     }
330   G_OBJECT_CLASS (gtk_tool_item_parent_class)->dispose (object);
331 }
332
333
334 static void
335 gtk_tool_item_parent_set (GtkWidget   *toolitem,
336                           GtkWidget   *prev_parent)
337 {
338   if (GTK_WIDGET (toolitem)->parent != NULL)
339     gtk_tool_item_toolbar_reconfigured (GTK_TOOL_ITEM (toolitem));
340 }
341
342 static void
343 gtk_tool_item_set_property (GObject      *object,
344                             guint         prop_id,
345                             const GValue *value,
346                             GParamSpec   *pspec)
347 {
348   GtkToolItem *toolitem = GTK_TOOL_ITEM (object);
349
350   switch (prop_id)
351     {
352     case PROP_VISIBLE_HORIZONTAL:
353       gtk_tool_item_set_visible_horizontal (toolitem, g_value_get_boolean (value));
354       break;
355     case PROP_VISIBLE_VERTICAL:
356       gtk_tool_item_set_visible_vertical (toolitem, g_value_get_boolean (value));
357       break;
358     case PROP_IS_IMPORTANT:
359       gtk_tool_item_set_is_important (toolitem, g_value_get_boolean (value));
360       break;
361     case PROP_ACTIVATABLE_RELATED_ACTION:
362       gtk_tool_item_set_related_action (toolitem, g_value_get_object (value));
363       break;
364     case PROP_ACTIVATABLE_USE_ACTION_APPEARANCE:
365       gtk_tool_item_set_use_action_appearance (toolitem, g_value_get_boolean (value));
366       break;
367     default:
368       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
369       break;
370     }
371 }
372
373 static void
374 gtk_tool_item_get_property (GObject    *object,
375                             guint       prop_id,
376                             GValue     *value,
377                             GParamSpec *pspec)
378 {
379   GtkToolItem *toolitem = GTK_TOOL_ITEM (object);
380
381   switch (prop_id)
382     {
383     case PROP_VISIBLE_HORIZONTAL:
384       g_value_set_boolean (value, toolitem->priv->visible_horizontal);
385       break;
386     case PROP_VISIBLE_VERTICAL:
387       g_value_set_boolean (value, toolitem->priv->visible_vertical);
388       break;
389     case PROP_IS_IMPORTANT:
390       g_value_set_boolean (value, toolitem->priv->is_important);
391       break;
392     case PROP_ACTIVATABLE_RELATED_ACTION:
393       g_value_set_object (value, toolitem->priv->action);
394       break;
395     case PROP_ACTIVATABLE_USE_ACTION_APPEARANCE:
396       g_value_set_boolean (value, toolitem->priv->use_action_appearance);
397       break;
398     default:
399       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
400       break;
401     }
402 }
403
404 static void
405 gtk_tool_item_property_notify (GObject    *object,
406                                GParamSpec *pspec)
407 {
408   GtkToolItem *tool_item = GTK_TOOL_ITEM (object);
409
410   if (tool_item->priv->menu_item && strcmp (pspec->name, "sensitive") == 0)
411     gtk_widget_set_sensitive (tool_item->priv->menu_item,
412                               GTK_WIDGET_SENSITIVE (tool_item));
413 }
414
415 static void
416 create_drag_window (GtkToolItem *toolitem)
417 {
418   GtkWidget *widget;
419   GdkWindowAttr attributes;
420   gint attributes_mask, border_width;
421
422   g_return_if_fail (toolitem->priv->use_drag_window == TRUE);
423
424   widget = GTK_WIDGET (toolitem);
425   border_width = GTK_CONTAINER (toolitem)->border_width;
426
427   attributes.window_type = GDK_WINDOW_CHILD;
428   attributes.x = widget->allocation.x + border_width;
429   attributes.y = widget->allocation.y + border_width;
430   attributes.width = widget->allocation.width - border_width * 2;
431   attributes.height = widget->allocation.height - border_width * 2;
432   attributes.wclass = GDK_INPUT_ONLY;
433   attributes.event_mask = gtk_widget_get_events (widget);
434   attributes.event_mask |= (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
435
436   attributes_mask = GDK_WA_X | GDK_WA_Y;
437
438   toolitem->priv->drag_window = gdk_window_new (gtk_widget_get_parent_window (widget),
439                                           &attributes, attributes_mask);
440   gdk_window_set_user_data (toolitem->priv->drag_window, toolitem);
441 }
442
443 static void
444 gtk_tool_item_realize (GtkWidget *widget)
445 {
446   GtkToolItem *toolitem;
447
448   toolitem = GTK_TOOL_ITEM (widget);
449   GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
450
451   widget->window = gtk_widget_get_parent_window (widget);
452   g_object_ref (widget->window);
453
454   if (toolitem->priv->use_drag_window)
455     create_drag_window(toolitem);
456
457   widget->style = gtk_style_attach (widget->style, widget->window);
458 }
459
460 static void
461 destroy_drag_window (GtkToolItem *toolitem)
462 {
463   if (toolitem->priv->drag_window)
464     {
465       gdk_window_set_user_data (toolitem->priv->drag_window, NULL);
466       gdk_window_destroy (toolitem->priv->drag_window);
467       toolitem->priv->drag_window = NULL;
468     }
469 }
470
471 static void
472 gtk_tool_item_unrealize (GtkWidget *widget)
473 {
474   GtkToolItem *toolitem;
475
476   toolitem = GTK_TOOL_ITEM (widget);
477
478   destroy_drag_window (toolitem);
479   
480   GTK_WIDGET_CLASS (gtk_tool_item_parent_class)->unrealize (widget);
481 }
482
483 static void
484 gtk_tool_item_map (GtkWidget *widget)
485 {
486   GtkToolItem *toolitem;
487
488   toolitem = GTK_TOOL_ITEM (widget);
489   GTK_WIDGET_CLASS (gtk_tool_item_parent_class)->map (widget);
490   if (toolitem->priv->drag_window)
491     gdk_window_show (toolitem->priv->drag_window);
492 }
493
494 static void
495 gtk_tool_item_unmap (GtkWidget *widget)
496 {
497   GtkToolItem *toolitem;
498
499   toolitem = GTK_TOOL_ITEM (widget);
500   if (toolitem->priv->drag_window)
501     gdk_window_hide (toolitem->priv->drag_window);
502   GTK_WIDGET_CLASS (gtk_tool_item_parent_class)->unmap (widget);
503 }
504
505 static void
506 gtk_tool_item_size_request (GtkWidget      *widget,
507                             GtkRequisition *requisition)
508 {
509   GtkWidget *child = GTK_BIN (widget)->child;
510
511   if (child && GTK_WIDGET_VISIBLE (child))
512     {
513       gtk_widget_size_request (child, requisition);
514     }
515   else
516     {
517       requisition->height = 0;
518       requisition->width = 0;
519     }
520   
521   requisition->width += (GTK_CONTAINER (widget)->border_width) * 2;
522   requisition->height += (GTK_CONTAINER (widget)->border_width) * 2;
523 }
524
525 static void
526 gtk_tool_item_size_allocate (GtkWidget     *widget,
527                              GtkAllocation *allocation)
528 {
529   GtkToolItem *toolitem = GTK_TOOL_ITEM (widget);
530   GtkAllocation child_allocation;
531   gint border_width;
532   GtkWidget *child = GTK_BIN (widget)->child;
533
534   widget->allocation = *allocation;
535   border_width = GTK_CONTAINER (widget)->border_width;
536
537   if (toolitem->priv->drag_window)
538     gdk_window_move_resize (toolitem->priv->drag_window,
539                             widget->allocation.x + border_width,
540                             widget->allocation.y + border_width,
541                             widget->allocation.width - border_width * 2,
542                             widget->allocation.height - border_width * 2);
543   
544   if (child && GTK_WIDGET_VISIBLE (child))
545     {
546       child_allocation.x = allocation->x + border_width;
547       child_allocation.y = allocation->y + border_width;
548       child_allocation.width = allocation->width - 2 * border_width;
549       child_allocation.height = allocation->height - 2 * border_width;
550       
551       gtk_widget_size_allocate (child, &child_allocation);
552     }
553 }
554
555 gboolean
556 _gtk_tool_item_create_menu_proxy (GtkToolItem *item)
557 {
558   GtkWidget *menu_item;
559   gboolean visible_overflown;
560
561   if (item->priv->action)
562     {
563       g_object_get (item->priv->action, "visible-overflown", &visible_overflown, NULL);
564     
565       if (visible_overflown)
566         {
567           menu_item = gtk_action_create_menu_item (item->priv->action);
568
569           g_object_ref_sink (menu_item);
570           gtk_tool_item_set_proxy_menu_item (item, "gtk-action-menu-item", menu_item);
571           g_object_unref (menu_item);
572         }
573       else
574         gtk_tool_item_set_proxy_menu_item (item, "gtk-action-menu-item", NULL);
575
576       return TRUE;
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"