]> Pileus Git - ~andy/gtk/blob - gtk/gtktoolitem.c
ToolShell: Add ellipsize, text-orientation, text-alignment and size-group.
[~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_update                     (GtkActivatable       *activatable,
132                                                       GtkAction            *action,
133                                                       const gchar          *property_name);
134 static void gtk_tool_item_sync_action_properties     (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_update;
586   iface->sync_action_properties = gtk_tool_item_sync_action_properties;
587 }
588
589 static void
590 gtk_tool_item_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_sync_action_properties (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_sync_action_properties (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_ellipsize_mode:
692  * @tool_item: a #GtkToolItem: 
693  * 
694  * Returns the ellipsize mode used for @tool_item. Custom subclasses of
695  * #GtkToolItem should call this function to find out how text should
696  * be ellipsized.
697  * 
698  * Return value: a #PangoEllipsizeMode indicating how text in @tool_item
699  * should be ellipsized.
700  * 
701  * Since: 2.14
702  **/
703 PangoEllipsizeMode
704 gtk_tool_item_get_ellipsize_mode (GtkToolItem *tool_item)
705 {
706   GtkWidget *parent;
707   
708   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_ORIENTATION_HORIZONTAL);
709
710   parent = GTK_WIDGET (tool_item)->parent;
711   if (!parent || !GTK_IS_TOOL_SHELL (parent))
712     return PANGO_ELLIPSIZE_NONE;
713
714   return gtk_tool_shell_get_ellipsize_mode (GTK_TOOL_SHELL (parent));
715 }
716
717 /**
718  * gtk_tool_item_get_icon_size:
719  * @tool_item: a #GtkToolItem
720  * 
721  * Returns the icon size used for @tool_item. Custom subclasses of
722  * #GtkToolItem should call this function to find out what size icons
723  * they should use.
724  * 
725  * Return value: a #GtkIconSize indicating the icon size used for @tool_item
726  * 
727  * Since: 2.4
728  **/
729 GtkIconSize
730 gtk_tool_item_get_icon_size (GtkToolItem *tool_item)
731 {
732   GtkWidget *parent;
733
734   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_ICON_SIZE_LARGE_TOOLBAR);
735
736   parent = GTK_WIDGET (tool_item)->parent;
737   if (!parent || !GTK_IS_TOOL_SHELL (parent))
738     return GTK_ICON_SIZE_LARGE_TOOLBAR;
739
740   return gtk_tool_shell_get_icon_size (GTK_TOOL_SHELL (parent));
741 }
742
743 /**
744  * gtk_tool_item_get_orientation:
745  * @tool_item: a #GtkToolItem 
746  * 
747  * Returns the orientation used for @tool_item. Custom subclasses of
748  * #GtkToolItem should call this function to find out what size icons
749  * they should use.
750  * 
751  * Return value: a #GtkOrientation indicating the orientation
752  * used for @tool_item
753  * 
754  * Since: 2.4
755  **/
756 GtkOrientation
757 gtk_tool_item_get_orientation (GtkToolItem *tool_item)
758 {
759   GtkWidget *parent;
760   
761   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_ORIENTATION_HORIZONTAL);
762
763   parent = GTK_WIDGET (tool_item)->parent;
764   if (!parent || !GTK_IS_TOOL_SHELL (parent))
765     return GTK_ORIENTATION_HORIZONTAL;
766
767   return gtk_tool_shell_get_orientation (GTK_TOOL_SHELL (parent));
768 }
769
770 /**
771  * gtk_tool_item_get_toolbar_style:
772  * @tool_item: a #GtkToolItem 
773  * 
774  * Returns the toolbar style used for @tool_item. Custom subclasses of
775  * #GtkToolItem should call this function in the handler of the
776  * GtkToolItem::toolbar_reconfigured signal to find out in what style
777  * the toolbar is displayed and change themselves accordingly 
778  *
779  * Possibilities are:
780  * <itemizedlist>
781  * <listitem> GTK_TOOLBAR_BOTH, meaning the tool item should show
782  * both an icon and a label, stacked vertically </listitem>
783  * <listitem> GTK_TOOLBAR_ICONS, meaning the toolbar shows
784  * only icons </listitem>
785  * <listitem> GTK_TOOLBAR_TEXT, meaning the tool item should only
786  * show text</listitem>
787  * <listitem> GTK_TOOLBAR_BOTH_HORIZ, meaning the tool item should show
788  * both an icon and a label, arranged horizontally (however, note the 
789  * #GtkToolButton::has_text_horizontally that makes tool buttons not
790  * show labels when the toolbar style is GTK_TOOLBAR_BOTH_HORIZ.
791  * </listitem>
792  * </itemizedlist>
793  * 
794  * Return value: A #GtkToolbarStyle indicating the toolbar style used
795  * for @tool_item.
796  * 
797  * Since: 2.4
798  **/
799 GtkToolbarStyle
800 gtk_tool_item_get_toolbar_style (GtkToolItem *tool_item)
801 {
802   GtkWidget *parent;
803   
804   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_TOOLBAR_ICONS);
805
806   parent = GTK_WIDGET (tool_item)->parent;
807   if (!parent || !GTK_IS_TOOL_SHELL (parent))
808     return GTK_TOOLBAR_ICONS;
809
810   return gtk_tool_shell_get_style (GTK_TOOL_SHELL (parent));
811 }
812
813 /**
814  * gtk_tool_item_get_relief_style:
815  * @tool_item: a #GtkToolItem 
816  * 
817  * Returns the relief style of @tool_item. See gtk_button_set_relief_style().
818  * Custom subclasses of #GtkToolItem should call this function in the handler
819  * of the #GtkToolItem::toolbar_reconfigured signal to find out the
820  * relief style of buttons.
821  * 
822  * Return value: a #GtkReliefStyle indicating the relief style used
823  * for @tool_item.
824  * 
825  * Since: 2.4
826  **/
827 GtkReliefStyle 
828 gtk_tool_item_get_relief_style (GtkToolItem *tool_item)
829 {
830   GtkWidget *parent;
831   
832   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_RELIEF_NONE);
833
834   parent = GTK_WIDGET (tool_item)->parent;
835   if (!parent || !GTK_IS_TOOL_SHELL (parent))
836     return GTK_RELIEF_NONE;
837
838   return gtk_tool_shell_get_relief_style (GTK_TOOL_SHELL (parent));
839 }
840
841 /**
842  * gtk_tool_item_get_text_alignment:
843  * @tool_item: a #GtkToolItem: 
844  * 
845  * Returns the text alignment used for @tool_item. Custom subclasses of
846  * #GtkToolItem should call this function to find out how text should
847  * be aligned.
848  * 
849  * Return value: a #gfloat indicating the horizontal text alignment
850  * used for @tool_item
851  * 
852  * Since: 2.14
853  **/
854 gfloat
855 gtk_tool_item_get_text_alignment (GtkToolItem *tool_item)
856 {
857   GtkWidget *parent;
858   
859   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_ORIENTATION_HORIZONTAL);
860
861   parent = GTK_WIDGET (tool_item)->parent;
862   if (!parent || !GTK_IS_TOOL_SHELL (parent))
863     return 0.5;
864
865   return gtk_tool_shell_get_text_alignment (GTK_TOOL_SHELL (parent));
866 }
867
868 /**
869  * gtk_tool_item_get_text_orientation:
870  * @tool_item: a #GtkToolItem: 
871  * 
872  * Returns the text orientation used for @tool_item. Custom subclasses of
873  * #GtkToolItem should call this function to find out how text should
874  * be orientated.
875  * 
876  * Return value: a #GtkOrientation indicating the text orientation
877  * used for @tool_item
878  * 
879  * Since: 2.14
880  **/
881 GtkOrientation
882 gtk_tool_item_get_text_orientation (GtkToolItem *tool_item)
883 {
884   GtkWidget *parent;
885   
886   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_ORIENTATION_HORIZONTAL);
887
888   parent = GTK_WIDGET (tool_item)->parent;
889   if (!parent || !GTK_IS_TOOL_SHELL (parent))
890     return GTK_ORIENTATION_HORIZONTAL;
891
892   return gtk_tool_shell_get_text_orientation (GTK_TOOL_SHELL (parent));
893 }
894
895 /**
896  * gtk_tool_item_get_text_size_group:
897  * @tool_item: a #GtkToolItem: 
898  * 
899  * Returns the size group used for labels in @tool_item. Custom subclasses of
900  * #GtkToolItem should call this function and use the size group for labels.
901  * 
902  * Return value: a #GtkSizeGroup
903  * 
904  * Since: 2.14
905  **/
906 GtkSizeGroup *
907 gtk_tool_item_get_text_size_group (GtkToolItem *tool_item)
908 {
909   GtkWidget *parent;
910   
911   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_ORIENTATION_HORIZONTAL);
912
913   parent = GTK_WIDGET (tool_item)->parent;
914   if (!parent || !GTK_IS_TOOL_SHELL (parent))
915     return NULL;
916
917   return gtk_tool_shell_get_text_size_group (GTK_TOOL_SHELL (parent));
918 }
919
920 /**
921  * gtk_tool_item_set_expand:
922  * @tool_item: a #GtkToolItem 
923  * @expand: Whether @tool_item is allocated extra space
924  * 
925  * Sets whether @tool_item is allocated extra space when there
926  * is more room on the toolbar then needed for the items. The
927  * effect is that the item gets bigger when the toolbar gets bigger
928  * and smaller when the toolbar gets smaller.
929  * 
930  * Since: 2.4
931  **/
932 void
933 gtk_tool_item_set_expand (GtkToolItem *tool_item,
934                           gboolean     expand)
935 {
936   g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
937     
938   expand = expand != FALSE;
939
940   if (tool_item->priv->expand != expand)
941     {
942       tool_item->priv->expand = expand;
943       gtk_widget_child_notify (GTK_WIDGET (tool_item), "expand");
944       gtk_widget_queue_resize (GTK_WIDGET (tool_item));
945     }
946 }
947
948 /**
949  * gtk_tool_item_get_expand:
950  * @tool_item: a #GtkToolItem 
951  * 
952  * Returns whether @tool_item is allocated extra space.
953  * See gtk_tool_item_set_expand().
954  * 
955  * Return value: %TRUE if @tool_item is allocated extra space.
956  * 
957  * Since: 2.4
958  **/
959 gboolean
960 gtk_tool_item_get_expand (GtkToolItem *tool_item)
961 {
962   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), FALSE);
963
964   return tool_item->priv->expand;
965 }
966
967 /**
968  * gtk_tool_item_set_homogeneous:
969  * @tool_item: a #GtkToolItem 
970  * @homogeneous: whether @tool_item is the same size as other homogeneous items
971  * 
972  * Sets whether @tool_item is to be allocated the same size as other
973  * homogeneous items. The effect is that all homogeneous items will have
974  * the same width as the widest of the items.
975  * 
976  * Since: 2.4
977  **/
978 void
979 gtk_tool_item_set_homogeneous (GtkToolItem *tool_item,
980                                gboolean     homogeneous)
981 {
982   g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
983     
984   homogeneous = homogeneous != FALSE;
985
986   if (tool_item->priv->homogeneous != homogeneous)
987     {
988       tool_item->priv->homogeneous = homogeneous;
989       gtk_widget_child_notify (GTK_WIDGET (tool_item), "homogeneous");
990       gtk_widget_queue_resize (GTK_WIDGET (tool_item));
991     }
992 }
993
994 /**
995  * gtk_tool_item_get_homogeneous:
996  * @tool_item: a #GtkToolItem 
997  * 
998  * Returns whether @tool_item is the same size as other homogeneous
999  * items. See gtk_tool_item_set_homogeneous().
1000  * 
1001  * Return value: %TRUE if the item is the same size as other homogeneous
1002  * items.
1003  * 
1004  * Since: 2.4
1005  **/
1006 gboolean
1007 gtk_tool_item_get_homogeneous (GtkToolItem *tool_item)
1008 {
1009   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), FALSE);
1010
1011   return tool_item->priv->homogeneous;
1012 }
1013
1014 /**
1015  * gtk_tool_item_get_is_important:
1016  * @tool_item: a #GtkToolItem
1017  * 
1018  * Returns whether @tool_item is considered important. See
1019  * gtk_tool_item_set_is_important()
1020  * 
1021  * Return value: %TRUE if @tool_item is considered important.
1022  * 
1023  * Since: 2.4
1024  **/
1025 gboolean
1026 gtk_tool_item_get_is_important (GtkToolItem *tool_item)
1027 {
1028   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), FALSE);
1029
1030   return tool_item->priv->is_important;
1031 }
1032
1033 /**
1034  * gtk_tool_item_set_is_important:
1035  * @tool_item: a #GtkToolItem
1036  * @is_important: whether the tool item should be considered important
1037  * 
1038  * Sets whether @tool_item should be considered important. The #GtkToolButton
1039  * class uses this property to determine whether to show or hide its label
1040  * when the toolbar style is %GTK_TOOLBAR_BOTH_HORIZ. The result is that
1041  * only tool buttons with the "is_important" property set have labels, an
1042  * effect known as "priority text"
1043  * 
1044  * Since: 2.4
1045  **/
1046 void
1047 gtk_tool_item_set_is_important (GtkToolItem *tool_item, gboolean is_important)
1048 {
1049   g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
1050
1051   is_important = is_important != FALSE;
1052
1053   if (is_important != tool_item->priv->is_important)
1054     {
1055       tool_item->priv->is_important = is_important;
1056
1057       gtk_widget_queue_resize (GTK_WIDGET (tool_item));
1058
1059       g_object_notify (G_OBJECT (tool_item), "is-important");
1060     }
1061 }
1062
1063 static gboolean
1064 gtk_tool_item_real_set_tooltip (GtkToolItem *tool_item,
1065                                 GtkTooltips *tooltips,
1066                                 const gchar *tip_text,
1067                                 const gchar *tip_private)
1068 {
1069   GtkWidget *child = GTK_BIN (tool_item)->child;
1070
1071   if (!child)
1072     return FALSE;
1073
1074   gtk_widget_set_tooltip_text (child, tip_text);
1075
1076   return TRUE;
1077 }
1078
1079 /**
1080  * gtk_tool_item_set_tooltip:
1081  * @tool_item: a #GtkToolItem 
1082  * @tooltips: The #GtkTooltips object to be used
1083  * @tip_text: text to be used as tooltip text for @tool_item
1084  * @tip_private: text to be used as private tooltip text
1085  *
1086  * Sets the #GtkTooltips object to be used for @tool_item, the
1087  * text to be displayed as tooltip on the item and the private text
1088  * to be used. See gtk_tooltips_set_tip().
1089  * 
1090  * Since: 2.4
1091  *
1092  * Deprecated: 2.12: Use gtk_tool_item_set_tooltip_text() instead.
1093  **/
1094 void
1095 gtk_tool_item_set_tooltip (GtkToolItem *tool_item,
1096                            GtkTooltips *tooltips,
1097                            const gchar *tip_text,
1098                            const gchar *tip_private)
1099 {
1100   gboolean retval;
1101   
1102   g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
1103
1104   g_signal_emit (tool_item, toolitem_signals[SET_TOOLTIP], 0,
1105                  tooltips, tip_text, tip_private, &retval);
1106 }
1107
1108 /**
1109  * gtk_tool_item_set_tooltip_text:
1110  * @tool_item: a #GtkToolItem 
1111  * @text: text to be used as tooltip for @tool_item
1112  *
1113  * Sets the text to be displayed as tooltip on the item.
1114  * See gtk_widget_set_tooltip_text().
1115  *
1116  * Since: 2.12
1117  **/
1118 void
1119 gtk_tool_item_set_tooltip_text (GtkToolItem *tool_item,
1120                                 const gchar *text)
1121 {
1122   GtkWidget *child;
1123
1124   g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
1125
1126   child = GTK_BIN (tool_item)->child;
1127
1128   if (child)
1129     gtk_widget_set_tooltip_text (child, text);
1130 }
1131
1132 /**
1133  * gtk_tool_item_set_tooltip_markup:
1134  * @tool_item: a #GtkToolItem 
1135  * @markup: markup text to be used as tooltip for @tool_item
1136  *
1137  * Sets the markup text to be displayed as tooltip on the item.
1138  * See gtk_widget_set_tooltip_markup().
1139  *
1140  * Since: 2.12
1141  **/
1142 void
1143 gtk_tool_item_set_tooltip_markup (GtkToolItem *tool_item,
1144                                   const gchar *markup)
1145 {
1146   GtkWidget *child;
1147
1148   g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
1149
1150   child = GTK_BIN (tool_item)->child;
1151
1152   if (child)
1153     gtk_widget_set_tooltip_markup (child, markup);
1154 }
1155
1156 /**
1157  * gtk_tool_item_set_use_drag_window:
1158  * @tool_item: a #GtkToolItem 
1159  * @use_drag_window: Whether @tool_item has a drag window.
1160  * 
1161  * Sets whether @tool_item has a drag window. When %TRUE the
1162  * toolitem can be used as a drag source through gtk_drag_source_set().
1163  * When @tool_item has a drag window it will intercept all events,
1164  * even those that would otherwise be sent to a child of @tool_item.
1165  * 
1166  * Since: 2.4
1167  **/
1168 void
1169 gtk_tool_item_set_use_drag_window (GtkToolItem *toolitem,
1170                                    gboolean     use_drag_window)
1171 {
1172   g_return_if_fail (GTK_IS_TOOL_ITEM (toolitem));
1173
1174   use_drag_window = use_drag_window != FALSE;
1175
1176   if (toolitem->priv->use_drag_window != use_drag_window)
1177     {
1178       toolitem->priv->use_drag_window = use_drag_window;
1179       
1180       if (use_drag_window)
1181         {
1182           if (!toolitem->priv->drag_window && GTK_WIDGET_REALIZED (toolitem))
1183             {
1184               create_drag_window(toolitem);
1185               if (GTK_WIDGET_MAPPED (toolitem))
1186                 gdk_window_show (toolitem->priv->drag_window);
1187             }
1188         }
1189       else
1190         {
1191           destroy_drag_window (toolitem);
1192         }
1193     }
1194 }
1195
1196 /**
1197  * gtk_tool_item_get_use_drag_window:
1198  * @tool_item: a #GtkToolItem 
1199  * 
1200  * Returns whether @tool_item has a drag window. See
1201  * gtk_tool_item_set_use_drag_window().
1202  * 
1203  * Return value: %TRUE if @tool_item uses a drag window.
1204  * 
1205  * Since: 2.4
1206  **/
1207 gboolean
1208 gtk_tool_item_get_use_drag_window (GtkToolItem *toolitem)
1209 {
1210   g_return_val_if_fail (GTK_IS_TOOL_ITEM (toolitem), FALSE);
1211
1212   return toolitem->priv->use_drag_window;
1213 }
1214
1215 /**
1216  * gtk_tool_item_set_visible_horizontal:
1217  * @tool_item: a #GtkToolItem
1218  * @visible_horizontal: Whether @tool_item is visible when in horizontal mode
1219  * 
1220  * Sets whether @tool_item is visible when the toolbar is docked horizontally.
1221  * 
1222  * Since: 2.4
1223  **/
1224 void
1225 gtk_tool_item_set_visible_horizontal (GtkToolItem *toolitem,
1226                                       gboolean     visible_horizontal)
1227 {
1228   g_return_if_fail (GTK_IS_TOOL_ITEM (toolitem));
1229
1230   visible_horizontal = visible_horizontal != FALSE;
1231
1232   if (toolitem->priv->visible_horizontal != visible_horizontal)
1233     {
1234       toolitem->priv->visible_horizontal = visible_horizontal;
1235
1236       g_object_notify (G_OBJECT (toolitem), "visible-horizontal");
1237
1238       gtk_widget_queue_resize (GTK_WIDGET (toolitem));
1239     }
1240 }
1241
1242 /**
1243  * gtk_tool_item_get_visible_horizontal:
1244  * @tool_item: a #GtkToolItem 
1245  * 
1246  * Returns whether the @tool_item is visible on toolbars that are
1247  * docked horizontally.
1248  * 
1249  * Return value: %TRUE if @tool_item is visible on toolbars that are
1250  * docked horizontally.
1251  * 
1252  * Since: 2.4
1253  **/
1254 gboolean
1255 gtk_tool_item_get_visible_horizontal (GtkToolItem *toolitem)
1256 {
1257   g_return_val_if_fail (GTK_IS_TOOL_ITEM (toolitem), FALSE);
1258
1259   return toolitem->priv->visible_horizontal;
1260 }
1261
1262 /**
1263  * gtk_tool_item_set_visible_vertical:
1264  * @tool_item: a #GtkToolItem 
1265  * @visible_vertical: whether @tool_item is visible when the toolbar
1266  * is in vertical mode
1267  *
1268  * Sets whether @tool_item is visible when the toolbar is docked
1269  * vertically. Some tool items, such as text entries, are too wide to be
1270  * useful on a vertically docked toolbar. If @visible_vertical is %FALSE
1271  * @tool_item will not appear on toolbars that are docked vertically.
1272  * 
1273  * Since: 2.4
1274  **/
1275 void
1276 gtk_tool_item_set_visible_vertical (GtkToolItem *toolitem,
1277                                     gboolean     visible_vertical)
1278 {
1279   g_return_if_fail (GTK_IS_TOOL_ITEM (toolitem));
1280
1281   visible_vertical = visible_vertical != FALSE;
1282
1283   if (toolitem->priv->visible_vertical != visible_vertical)
1284     {
1285       toolitem->priv->visible_vertical = visible_vertical;
1286
1287       g_object_notify (G_OBJECT (toolitem), "visible-vertical");
1288
1289       gtk_widget_queue_resize (GTK_WIDGET (toolitem));
1290     }
1291 }
1292
1293 /**
1294  * gtk_tool_item_get_visible_vertical:
1295  * @tool_item: a #GtkToolItem 
1296  * 
1297  * Returns whether @tool_item is visible when the toolbar is docked vertically.
1298  * See gtk_tool_item_set_visible_vertical().
1299  * 
1300  * Return value: Whether @tool_item is visible when the toolbar is docked vertically
1301  * 
1302  * Since: 2.4
1303  **/
1304 gboolean
1305 gtk_tool_item_get_visible_vertical (GtkToolItem *toolitem)
1306 {
1307   g_return_val_if_fail (GTK_IS_TOOL_ITEM (toolitem), FALSE);
1308
1309   return toolitem->priv->visible_vertical;
1310 }
1311
1312 /**
1313  * gtk_tool_item_retrieve_proxy_menu_item:
1314  * @tool_item: a #GtkToolItem 
1315  * 
1316  * Returns the #GtkMenuItem that was last set by
1317  * gtk_tool_item_set_proxy_menu_item(), ie. the #GtkMenuItem
1318  * that is going to appear in the overflow menu.
1319  * 
1320  * Return value: The #GtkMenuItem that is going to appear in the
1321  * overflow menu for @tool_item.
1322  * 
1323  * Since: 2.4
1324  **/
1325 GtkWidget *
1326 gtk_tool_item_retrieve_proxy_menu_item (GtkToolItem *tool_item)
1327 {
1328   gboolean retval;
1329   
1330   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), NULL);
1331
1332   g_signal_emit (tool_item, toolitem_signals[CREATE_MENU_PROXY], 0,
1333                  &retval);
1334   
1335   return tool_item->priv->menu_item;
1336 }
1337
1338 /**
1339  * gtk_tool_item_get_proxy_menu_item:
1340  * @tool_item: a #GtkToolItem 
1341  * @menu_item_id: a string used to identify the menu item
1342  * 
1343  * If @menu_item_id matches the string passed to
1344  * gtk_tool_item_set_proxy_menu_item() return the corresponding #GtkMenuItem.
1345  *
1346  * Custom subclasses of #GtkToolItem should use this function to update
1347  * their menu item when the #GtkToolItem changes. That the
1348  * @menu_item_id<!-- -->s must match ensures that a #GtkToolItem will not
1349  * inadvertently change a menu item that they did not create.
1350  * 
1351  * Return value: The #GtkMenuItem passed to
1352  * gtk_tool_item_set_proxy_menu_item(), if the @menu_item_id<!-- -->s match.
1353  * 
1354  * Since: 2.4
1355  **/
1356 GtkWidget *
1357 gtk_tool_item_get_proxy_menu_item (GtkToolItem *tool_item,
1358                                    const gchar *menu_item_id)
1359 {
1360   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), NULL);
1361   g_return_val_if_fail (menu_item_id != NULL, NULL);
1362
1363   if (tool_item->priv->menu_item_id && strcmp (tool_item->priv->menu_item_id, menu_item_id) == 0)
1364     return tool_item->priv->menu_item;
1365
1366   return NULL;
1367 }
1368
1369 /**
1370  * gtk_tool_item_rebuild_menu()
1371  * @tool_item: a #GtkToolItem
1372  * 
1373  * Calling this function signals to the toolbar that the
1374  * overflow menu item for @tool_item has changed. If the
1375  * overflow menu is visible when this function it called,
1376  * the menu will be rebuilt.
1377  *
1378  * The function must be called when the tool item
1379  * changes what it will do in response to the "create_menu_proxy"
1380  * signal.
1381  * 
1382  * Since: 2.6
1383  **/
1384 void
1385 gtk_tool_item_rebuild_menu (GtkToolItem *tool_item)
1386 {
1387   GtkWidget *widget;
1388   
1389   g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
1390
1391   widget = GTK_WIDGET (tool_item);
1392
1393   if (GTK_IS_TOOL_SHELL (widget->parent))
1394     gtk_tool_shell_rebuild_menu (GTK_TOOL_SHELL (widget->parent));
1395 }
1396
1397 /**
1398  * gtk_tool_item_set_proxy_menu_item:
1399  * @tool_item: a #GtkToolItem
1400  * @menu_item_id: a string used to identify @menu_item
1401  * @menu_item: a #GtkMenuItem to be used in the overflow menu
1402  * 
1403  * Sets the #GtkMenuItem used in the toolbar overflow menu. The
1404  * @menu_item_id is used to identify the caller of this function and
1405  * should also be used with gtk_tool_item_get_proxy_menu_item().
1406  * 
1407  * Since: 2.4
1408  **/
1409 void
1410 gtk_tool_item_set_proxy_menu_item (GtkToolItem *tool_item,
1411                                    const gchar *menu_item_id,
1412                                    GtkWidget   *menu_item)
1413 {
1414   g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
1415   g_return_if_fail (menu_item == NULL || GTK_IS_MENU_ITEM (menu_item));
1416   g_return_if_fail (menu_item_id != NULL);
1417
1418   g_free (tool_item->priv->menu_item_id);
1419       
1420   tool_item->priv->menu_item_id = g_strdup (menu_item_id);
1421
1422   if (tool_item->priv->menu_item != menu_item)
1423     {
1424       if (tool_item->priv->menu_item)
1425         g_object_unref (tool_item->priv->menu_item);
1426       
1427       if (menu_item)
1428         {
1429           g_object_ref_sink (menu_item);
1430
1431           gtk_widget_set_sensitive (menu_item,
1432                                     GTK_WIDGET_SENSITIVE (tool_item));
1433         }
1434       
1435       tool_item->priv->menu_item = menu_item;
1436     }
1437 }
1438
1439 /**
1440  * gtk_tool_item_toolbar_reconfigured:
1441  * @tool_item: a #GtkToolItem
1442  *
1443  * Emits the signal #GtkToolItem::toolbar_reconfigured on @tool_item.
1444  * #GtkToolbar and other #GtkToolShell implementations use this function
1445  * to notify children, when some aspect of their configuration changes.
1446  *
1447  * Since: 2.14
1448  **/
1449 void
1450 gtk_tool_item_toolbar_reconfigured (GtkToolItem *tool_item)
1451 {
1452   /* The slightely inaccurate name "gtk_tool_item_toolbar_reconfigured" was
1453    * choosen over "gtk_tool_item_tool_shell_reconfigured", since the function
1454    * emits the "toolbar-reconfigured" signal, not "tool-shell-reconfigured".
1455    * Its not possible to rename the signal, and emitting another name than
1456    * indicated by the function name would be quite confusing. That's the
1457    * price of providing stable APIs.
1458    */
1459   g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
1460
1461   g_signal_emit (tool_item, toolitem_signals[TOOLBAR_RECONFIGURED], 0);
1462   
1463   if (tool_item->priv->drag_window)
1464     gdk_window_raise (tool_item->priv->drag_window);
1465
1466   gtk_widget_queue_resize (GTK_WIDGET (tool_item));
1467 }
1468
1469 #define __GTK_TOOL_ITEM_C__
1470 #include "gtkaliasdef.c"