]> Pileus Git - ~andy/gtk/blob - gtk/gtktoolitem.c
remove unused overflow_item field.
[~andy/gtk] / gtk / gtktoolitem.c
1 /* gtktoolitem.c
2  *
3  * Copyright (C) 2002 Anders Carlsson <andersca@codefactory.se>
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 "gtktoolitem.h"
24 #include "gtkmarshalers.h"
25 #include "gtktoolbar.h"
26 #include "gtkseparatormenuitem.h"
27 #include "gtkintl.h"
28 #include "gtkmain.h"
29
30 #include <string.h>
31
32 #define MENU_ID "gtk-tool-item-menu-id"
33
34 enum {
35   CREATE_MENU_PROXY,
36   TOOLBAR_RECONFIGURED,
37   SET_TOOLTIP,
38   LAST_SIGNAL
39 };
40
41 enum {
42   PROP_0,
43   PROP_VISIBLE_HORIZONTAL,
44   PROP_VISIBLE_VERTICAL,
45 };
46
47 struct _GtkToolItemPrivate
48 {
49   gchar *tip_text;
50   gchar *tip_private;
51
52   guint visible_horizontal : 1;
53   guint visible_vertical : 1;
54   guint homogeneous : 1;
55   guint expand : 1;
56   guint pack_end : 1;
57   guint use_drag_window : 1;
58
59   GdkWindow *drag_window;
60   
61   gchar *menu_item_id;
62   GtkWidget *menu_item;
63 };
64   
65 static void gtk_tool_item_init       (GtkToolItem *toolitem);
66 static void gtk_tool_item_class_init (GtkToolItemClass *class);
67 static void gtk_tool_item_finalize    (GObject *object);
68 static void gtk_tool_item_parent_set   (GtkWidget   *toolitem,
69                                         GtkWidget   *parent);
70 static void gtk_tool_item_set_property (GObject         *object,
71                                         guint            prop_id,
72                                         const GValue    *value,
73                                         GParamSpec      *pspec);
74 static void gtk_tool_item_get_property (GObject         *object,
75                                         guint            prop_id,
76                                         GValue          *value,
77                                         GParamSpec      *pspec);
78 static void gtk_tool_item_realize       (GtkWidget      *widget);
79 static void gtk_tool_item_unrealize     (GtkWidget      *widget);
80 static void gtk_tool_item_map           (GtkWidget      *widget);
81 static void gtk_tool_item_unmap         (GtkWidget      *widget);
82 static void gtk_tool_item_size_request  (GtkWidget      *widget,
83                                          GtkRequisition *requisition);
84 static void gtk_tool_item_size_allocate (GtkWidget      *widget,
85                                          GtkAllocation  *allocation);
86 static gboolean gtk_tool_item_real_set_tooltip (GtkToolItem *tool_item,
87                                                 GtkTooltips *tooltips,
88                                                 const gchar *tip_text,
89                                                 const gchar *tip_private);
90
91 static gboolean gtk_tool_item_create_menu_proxy (GtkToolItem *item);
92
93
94 static GObjectClass *parent_class = NULL;
95 static guint         toolitem_signals[LAST_SIGNAL] = { 0 };
96
97 GType
98 gtk_tool_item_get_type (void)
99 {
100   static GtkType type = 0;
101
102   if (!type)
103     {
104       static const GTypeInfo type_info =
105         {
106           sizeof (GtkToolItemClass),
107           (GBaseInitFunc) NULL,
108           (GBaseFinalizeFunc) NULL,
109           (GClassInitFunc) gtk_tool_item_class_init,
110           (GClassFinalizeFunc) NULL,
111           NULL,
112         
113           sizeof (GtkToolItem),
114           0, /* n_preallocs */
115           (GInstanceInitFunc) gtk_tool_item_init,
116         };
117
118       type = g_type_register_static (GTK_TYPE_BIN,
119                                      "GtkToolItem",
120                                      &type_info, 0);
121     }
122   return type;
123 }
124
125 static void
126 gtk_tool_item_class_init (GtkToolItemClass *klass)
127 {
128   GObjectClass *object_class;
129   GtkWidgetClass *widget_class;
130   
131   parent_class = g_type_class_peek_parent (klass);
132   object_class = (GObjectClass *)klass;
133   widget_class = (GtkWidgetClass *)klass;
134   
135   object_class->set_property = gtk_tool_item_set_property;
136   object_class->get_property = gtk_tool_item_get_property;
137   object_class->finalize = gtk_tool_item_finalize;
138
139   widget_class->realize       = gtk_tool_item_realize;
140   widget_class->unrealize     = gtk_tool_item_unrealize;
141   widget_class->map           = gtk_tool_item_map;
142   widget_class->unmap         = gtk_tool_item_unmap;
143   widget_class->size_request  = gtk_tool_item_size_request;
144   widget_class->size_allocate = gtk_tool_item_size_allocate;
145   widget_class->parent_set    = gtk_tool_item_parent_set;
146
147   klass->create_menu_proxy = gtk_tool_item_create_menu_proxy;
148   klass->set_tooltip       = gtk_tool_item_real_set_tooltip;
149   
150   g_object_class_install_property (object_class,
151                                    PROP_VISIBLE_HORIZONTAL,
152                                    g_param_spec_boolean ("visible_horizontal",
153                                                          _("Visible when horizontal"),
154                                                          _("Whether the toolbar item is visible when the toolbar is in a horizontal orientation."),
155                                                          TRUE,
156                                                          G_PARAM_READWRITE));
157   g_object_class_install_property (object_class,
158                                    PROP_VISIBLE_VERTICAL,
159                                    g_param_spec_boolean ("visible_vertical",
160                                                          _("Visible when vertical"),
161                                                          _("Whether the toolbar item is visible when the toolbar is in a vertical orientation."),
162                                                          TRUE,
163                                                          G_PARAM_READWRITE));
164   toolitem_signals[CREATE_MENU_PROXY] =
165     g_signal_new ("create_menu_proxy",
166                   G_OBJECT_CLASS_TYPE (klass),
167                   G_SIGNAL_RUN_LAST,
168                   G_STRUCT_OFFSET (GtkToolItemClass, create_menu_proxy),
169                   _gtk_boolean_handled_accumulator, NULL,
170                   _gtk_marshal_BOOLEAN__VOID,
171                   G_TYPE_BOOLEAN, 0);
172   toolitem_signals[TOOLBAR_RECONFIGURED] =
173     g_signal_new ("toolbar_reconfigured",
174                   G_OBJECT_CLASS_TYPE (klass),
175                   G_SIGNAL_RUN_LAST,
176                   G_STRUCT_OFFSET (GtkToolItemClass, toolbar_reconfigured),
177                   NULL, NULL,
178                   _gtk_marshal_VOID__VOID,
179                   G_TYPE_NONE, 0);
180   toolitem_signals[SET_TOOLTIP] =
181     g_signal_new ("set_tooltip",
182                   G_OBJECT_CLASS_TYPE (klass),
183                   G_SIGNAL_RUN_LAST,
184                   G_STRUCT_OFFSET (GtkToolItemClass, set_tooltip),
185                   _gtk_boolean_handled_accumulator, NULL,
186                   _gtk_marshal_BOOLEAN__OBJECT_STRING_STRING,
187                   G_TYPE_BOOLEAN, 3,
188                   GTK_TYPE_TOOLTIPS,
189                   G_TYPE_STRING,
190                   G_TYPE_STRING);                 
191
192   g_type_class_add_private (object_class, sizeof (GtkToolItemPrivate));
193 }
194
195 static void
196 gtk_tool_item_init (GtkToolItem *toolitem)
197 {
198   GTK_WIDGET_UNSET_FLAGS (toolitem, GTK_CAN_FOCUS);  
199
200   toolitem->priv = GTK_TOOL_ITEM_GET_PRIVATE (toolitem);
201
202   toolitem->priv->visible_horizontal = TRUE;
203   toolitem->priv->visible_vertical = TRUE;
204   toolitem->priv->homogeneous = FALSE;
205   toolitem->priv->expand = FALSE;
206 }
207
208 static void
209 gtk_tool_item_finalize (GObject *object)
210 {
211   GtkToolItem *item = GTK_TOOL_ITEM (object);
212
213   if (item->priv->menu_item)
214     g_object_unref (item->priv->menu_item);
215   
216   if (G_OBJECT_CLASS (parent_class)->finalize)
217     G_OBJECT_CLASS (parent_class)->finalize (object);
218 }
219
220 static void
221 gtk_tool_item_parent_set   (GtkWidget   *toolitem,
222                             GtkWidget   *prev_parent)
223 {
224   _gtk_tool_item_toolbar_reconfigured (GTK_TOOL_ITEM (toolitem));
225 }
226
227 static void
228 gtk_tool_item_set_property (GObject      *object,
229                             guint         prop_id,
230                             const GValue *value,
231                             GParamSpec   *pspec)
232 {
233   GtkToolItem *toolitem = GTK_TOOL_ITEM (object);
234
235   switch (prop_id)
236     {
237     case PROP_VISIBLE_HORIZONTAL:
238       gtk_tool_item_set_visible_horizontal (toolitem, g_value_get_boolean (value));
239       break;
240     case PROP_VISIBLE_VERTICAL:
241       gtk_tool_item_set_visible_horizontal (toolitem, g_value_get_boolean (value));
242       break;
243     default:
244       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
245     }
246 }
247
248 static void
249 gtk_tool_item_get_property (GObject    *object,
250                             guint       prop_id,
251                             GValue     *value,
252                             GParamSpec *pspec)
253 {
254   GtkToolItem *toolitem = GTK_TOOL_ITEM (object);
255
256   switch (prop_id)
257     {
258     case PROP_VISIBLE_HORIZONTAL:
259       g_value_set_boolean (value, toolitem->priv->visible_horizontal);
260       break;
261     case PROP_VISIBLE_VERTICAL:
262       g_value_set_boolean (value, toolitem->priv->visible_vertical);
263       break;
264     default:
265       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
266     }
267 }
268
269 static void
270 create_drag_window (GtkToolItem *toolitem)
271 {
272   GtkWidget *widget;
273   GdkWindowAttr attributes;
274   gint attributes_mask, border_width;
275
276   g_return_if_fail (toolitem->priv->use_drag_window == TRUE);
277
278   widget = GTK_WIDGET (toolitem);
279   border_width = GTK_CONTAINER (toolitem)->border_width;
280
281   attributes.window_type = GDK_WINDOW_CHILD;
282   attributes.x = widget->allocation.x + border_width;
283   attributes.y = widget->allocation.y + border_width;
284   attributes.width = widget->allocation.width - border_width * 2;
285   attributes.height = widget->allocation.height - border_width * 2;
286   attributes.wclass = GDK_INPUT_ONLY;
287   attributes.event_mask = gtk_widget_get_events (widget);
288   attributes.event_mask |= (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
289
290   attributes_mask = GDK_WA_X | GDK_WA_Y;
291
292   toolitem->priv->drag_window = gdk_window_new (gtk_widget_get_parent_window (widget),
293                                           &attributes, attributes_mask);
294   gdk_window_set_user_data (toolitem->priv->drag_window, toolitem);
295 }
296
297 static void
298 gtk_tool_item_realize (GtkWidget *widget)
299 {
300   GtkToolItem *toolitem;
301
302   toolitem = GTK_TOOL_ITEM (widget);
303   GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
304
305   widget->window = gtk_widget_get_parent_window (widget);
306   g_object_ref (widget->window);
307
308   if (toolitem->priv->use_drag_window)
309     create_drag_window(toolitem);
310
311   widget->style = gtk_style_attach (widget->style, widget->window);
312 }
313
314 static void
315 destroy_drag_window (GtkToolItem *toolitem)
316 {
317   if (toolitem->priv->drag_window)
318     {
319       gdk_window_set_user_data (toolitem->priv->drag_window, NULL);
320       gdk_window_destroy (toolitem->priv->drag_window);
321       toolitem->priv->drag_window = NULL;
322     }
323 }
324
325 static void
326 gtk_tool_item_unrealize (GtkWidget *widget)
327 {
328   GtkToolItem *toolitem;
329
330   toolitem = GTK_TOOL_ITEM (widget);
331
332   destroy_drag_window (toolitem);
333   
334   GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
335 }
336
337 static void
338 gtk_tool_item_map (GtkWidget *widget)
339 {
340   GtkToolItem *toolitem;
341
342   toolitem = GTK_TOOL_ITEM (widget);
343   GTK_WIDGET_CLASS (parent_class)->map (widget);
344   if (toolitem->priv->drag_window)
345     gdk_window_show (toolitem->priv->drag_window);
346 }
347
348 static void
349 gtk_tool_item_unmap (GtkWidget *widget)
350 {
351   GtkToolItem *toolitem;
352
353   toolitem = GTK_TOOL_ITEM (widget);
354   if (toolitem->priv->drag_window)
355     gdk_window_hide (toolitem->priv->drag_window);
356   GTK_WIDGET_CLASS (parent_class)->unmap (widget);
357 }
358
359 static void
360 gtk_tool_item_size_request (GtkWidget      *widget,
361                             GtkRequisition *requisition)
362 {
363   GtkWidget *child = GTK_BIN (widget)->child;
364
365   if (child && GTK_WIDGET_VISIBLE (child))
366     {
367       gtk_widget_size_request (child, requisition);
368     }
369   else
370     {
371       requisition->height = 0;
372       requisition->width = 0;
373     }
374   
375   requisition->width += (GTK_CONTAINER (widget)->border_width) * 2;
376   requisition->height += (GTK_CONTAINER (widget)->border_width) * 2;
377 }
378
379 static void
380 gtk_tool_item_size_allocate (GtkWidget     *widget,
381                              GtkAllocation *allocation)
382 {
383   GtkToolItem *toolitem = GTK_TOOL_ITEM (widget);
384   GtkAllocation child_allocation;
385   gint border_width;
386   GtkWidget *child = GTK_BIN (widget)->child;
387
388   widget->allocation = *allocation;
389   border_width = GTK_CONTAINER (widget)->border_width;
390
391   if (toolitem->priv->drag_window)
392     gdk_window_move_resize (toolitem->priv->drag_window,
393                             widget->allocation.x + border_width,
394                             widget->allocation.y + border_width,
395                             widget->allocation.width - border_width * 2,
396                             widget->allocation.height - border_width * 2);
397   
398   if (child && GTK_WIDGET_VISIBLE (child))
399     {
400       child_allocation.x = allocation->x + border_width;
401       child_allocation.y = allocation->y + border_width;
402       child_allocation.width = allocation->width - 2 * border_width;
403       child_allocation.height = allocation->height - 2 * border_width;
404       
405       gtk_widget_size_allocate (child, &child_allocation);
406     }
407 }
408
409 static gboolean
410 gtk_tool_item_create_menu_proxy (GtkToolItem *item)
411 {
412   if (!GTK_BIN (item)->child)
413     {
414       GtkWidget *menu_item = NULL;
415
416       menu_item = gtk_separator_menu_item_new();
417
418       gtk_tool_item_set_proxy_menu_item (item, MENU_ID, menu_item);
419
420       return TRUE;
421     }
422   
423   return FALSE;
424 }
425
426 GtkToolItem *
427 gtk_tool_item_new (void)
428 {
429   GtkToolItem *item;
430
431   item = g_object_new (GTK_TYPE_TOOL_ITEM, NULL);
432
433   return item;
434 }
435
436 GtkIconSize
437 gtk_tool_item_get_icon_size (GtkToolItem *tool_item)
438 {
439   GtkWidget *parent;
440
441   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_ICON_SIZE_LARGE_TOOLBAR);
442
443   parent = GTK_WIDGET (tool_item)->parent;
444   if (!parent || !GTK_IS_TOOLBAR (parent))
445     return GTK_ICON_SIZE_LARGE_TOOLBAR;
446
447   return gtk_toolbar_get_icon_size (GTK_TOOLBAR (parent));
448 }
449
450 GtkOrientation
451 gtk_tool_item_get_orientation (GtkToolItem *tool_item)
452 {
453   GtkWidget *parent;
454   
455   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_ORIENTATION_HORIZONTAL);
456
457   parent = GTK_WIDGET (tool_item)->parent;
458   if (!parent || !GTK_IS_TOOLBAR (parent))
459     return GTK_ORIENTATION_HORIZONTAL;
460
461   return gtk_toolbar_get_orientation (GTK_TOOLBAR (parent));
462 }
463
464 GtkToolbarStyle
465 gtk_tool_item_get_toolbar_style (GtkToolItem *tool_item)
466 {
467   GtkWidget *parent;
468   
469   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_TOOLBAR_ICONS);
470
471   parent = GTK_WIDGET (tool_item)->parent;
472   if (!parent || !GTK_IS_TOOLBAR (parent))
473     return GTK_TOOLBAR_ICONS;
474
475   return gtk_toolbar_get_style (GTK_TOOLBAR (parent));
476 }
477
478 GtkReliefStyle 
479 gtk_tool_item_get_relief_style (GtkToolItem *tool_item)
480 {
481   GtkWidget *parent;
482   
483   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_RELIEF_NONE);
484
485   parent = GTK_WIDGET (tool_item)->parent;
486   if (!parent || !GTK_IS_TOOLBAR (parent))
487     return GTK_RELIEF_NONE;
488
489   return gtk_toolbar_get_relief_style (GTK_TOOLBAR (parent));
490 }
491
492 void
493 gtk_tool_item_set_expand (GtkToolItem *tool_item,
494                           gboolean     expand)
495 {
496   g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
497     
498   expand = expand != FALSE;
499
500   if (tool_item->priv->expand != expand)
501     {
502       tool_item->priv->expand = expand;
503       gtk_widget_child_notify (GTK_WIDGET (tool_item), "expand");
504       gtk_widget_queue_resize (GTK_WIDGET (tool_item));
505     }
506 }
507
508 gboolean
509 gtk_tool_item_get_expand (GtkToolItem *tool_item)
510 {
511   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), FALSE);
512
513   return tool_item->priv->expand;
514 }
515
516 void
517 gtk_tool_item_set_pack_end (GtkToolItem *tool_item,
518                             gboolean     pack_end)
519 {
520   g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
521     
522   pack_end = pack_end != FALSE;
523
524   if (tool_item->priv->pack_end != pack_end)
525     {
526       tool_item->priv->pack_end = pack_end;
527       gtk_widget_child_notify (GTK_WIDGET (tool_item), "pack_end");
528       gtk_widget_queue_resize (GTK_WIDGET (tool_item));
529     }
530 }
531
532 gboolean
533 gtk_tool_item_get_pack_end (GtkToolItem *tool_item)
534 {
535   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), FALSE);
536
537   return tool_item->priv->pack_end;
538 }
539
540 void
541 gtk_tool_item_set_homogeneous (GtkToolItem *tool_item,
542                                gboolean     homogeneous)
543 {
544   g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
545     
546   homogeneous = homogeneous != FALSE;
547
548   if (tool_item->priv->homogeneous != homogeneous)
549     {
550       tool_item->priv->homogeneous = homogeneous;
551       gtk_widget_child_notify (GTK_WIDGET (tool_item), "homogeneous");
552       gtk_widget_queue_resize (GTK_WIDGET (tool_item));
553     }
554 }
555
556 gboolean
557 gtk_tool_item_get_homogeneous (GtkToolItem *tool_item)
558 {
559   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), FALSE);
560
561   return tool_item->priv->homogeneous;
562 }
563
564 static gboolean
565 gtk_tool_item_real_set_tooltip (GtkToolItem *tool_item,
566                                 GtkTooltips *tooltips,
567                                 const gchar *tip_text,
568                                 const gchar *tip_private)
569 {
570   GtkWidget *child = GTK_BIN (tool_item)->child;
571
572   if (!child)
573     return FALSE;
574
575   gtk_tooltips_set_tip (tooltips, child, tip_text, tip_private);
576
577   return TRUE;
578 }
579
580 void
581 gtk_tool_item_set_tooltip (GtkToolItem *tool_item,
582                            GtkTooltips *tooltips,
583                            const gchar *tip_text,
584                            const gchar *tip_private)
585 {
586   gboolean retval;
587   
588   g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
589
590   g_signal_emit (tool_item, toolitem_signals[SET_TOOLTIP], 0,
591                  tooltips, tip_text, tip_private, &retval);
592 }
593
594 void
595 gtk_tool_item_set_use_drag_window (GtkToolItem *toolitem,
596                                    gboolean     use_drag_window)
597 {
598   g_return_if_fail (GTK_IS_TOOL_ITEM (toolitem));
599
600   use_drag_window = use_drag_window != FALSE;
601
602   if (toolitem->priv->use_drag_window != use_drag_window)
603     {
604       toolitem->priv->use_drag_window = use_drag_window;
605       
606       if (use_drag_window)
607         {
608           if (!toolitem->priv->drag_window && GTK_WIDGET_REALIZED (toolitem))
609             {
610               create_drag_window(toolitem);
611               if (GTK_WIDGET_MAPPED (toolitem))
612                 gdk_window_show (toolitem->priv->drag_window);
613             }
614         }
615       else
616         {
617           destroy_drag_window (toolitem);
618         }
619     }
620 }
621
622 gboolean
623 gtk_tool_item_get_use_drag_window (GtkToolItem *toolitem)
624 {
625   g_return_val_if_fail (GTK_IS_TOOL_ITEM (toolitem), FALSE);
626
627   return toolitem->priv->use_drag_window;
628 }
629
630 void
631 gtk_tool_item_set_visible_horizontal (GtkToolItem *toolitem,
632                                       gboolean     visible_horizontal)
633 {
634   g_return_if_fail (GTK_IS_TOOL_ITEM (toolitem));
635
636   visible_horizontal = visible_horizontal != FALSE;
637
638   if (toolitem->priv->visible_horizontal != visible_horizontal)
639     {
640       toolitem->priv->visible_horizontal = visible_horizontal;
641
642       g_object_notify (G_OBJECT (toolitem), "visible_horizontal");
643
644       gtk_widget_queue_resize (GTK_WIDGET (toolitem));
645     }
646 }
647
648 gboolean
649 gtk_tool_item_get_visible_horizontal (GtkToolItem *toolitem)
650 {
651   g_return_val_if_fail (GTK_IS_TOOL_ITEM (toolitem), FALSE);
652
653   return toolitem->priv->visible_horizontal;
654 }
655
656 void
657 gtk_tool_item_set_visible_vertical (GtkToolItem *toolitem,
658                                     gboolean     visible_vertical)
659 {
660   g_return_if_fail (GTK_IS_TOOL_ITEM (toolitem));
661
662   visible_vertical = visible_vertical != FALSE;
663
664   if (toolitem->priv->visible_vertical != visible_vertical)
665     {
666       toolitem->priv->visible_vertical = visible_vertical;
667
668       g_object_notify (G_OBJECT (toolitem), "visible_vertical");
669
670       gtk_widget_queue_resize (GTK_WIDGET (toolitem));
671     }
672 }
673
674 gboolean
675 gtk_tool_item_get_visible_vertical (GtkToolItem *toolitem)
676 {
677   g_return_val_if_fail (GTK_IS_TOOL_ITEM (toolitem), FALSE);
678
679   return toolitem->priv->visible_vertical;
680 }
681
682 GtkWidget *
683 gtk_tool_item_retrieve_proxy_menu_item (GtkToolItem *tool_item)
684 {
685   gboolean retval;
686   
687   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), NULL);
688
689   g_signal_emit (tool_item, toolitem_signals[CREATE_MENU_PROXY], 0, &retval);
690   
691   return tool_item->priv->menu_item;
692 }
693
694 GtkWidget *
695 gtk_tool_item_get_proxy_menu_item (GtkToolItem *tool_item,
696                                    const gchar *menu_item_id)
697 {
698   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), NULL);
699   g_return_val_if_fail (menu_item_id != NULL, NULL);
700
701   if (tool_item->priv->menu_item_id && strcmp (tool_item->priv->menu_item_id, menu_item_id) == 0)
702     return tool_item->priv->menu_item;
703
704   return NULL;
705 }
706
707 void
708 gtk_tool_item_set_proxy_menu_item (GtkToolItem *tool_item,
709                                    const gchar *menu_item_id,
710                                    GtkWidget   *menu_item)
711 {
712   g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
713   g_return_if_fail (menu_item == NULL || GTK_IS_MENU_ITEM (menu_item));
714   g_return_if_fail (menu_item_id != NULL);
715
716   if (tool_item->priv->menu_item_id)
717     g_free (tool_item->priv->menu_item_id);
718       
719   tool_item->priv->menu_item_id = g_strdup (menu_item_id);
720
721   if (tool_item->priv->menu_item != menu_item)
722     {
723       if (tool_item->priv->menu_item)
724         g_object_unref (G_OBJECT (tool_item->priv->menu_item));
725       
726       if (menu_item)
727         {
728           g_object_ref (menu_item);
729           gtk_object_sink (GTK_OBJECT (menu_item));
730         }
731       
732       tool_item->priv->menu_item = menu_item;
733     }
734 }
735
736 void
737 _gtk_tool_item_toolbar_reconfigured (GtkToolItem *tool_item)
738 {
739   g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
740
741   g_signal_emit (tool_item, toolitem_signals[TOOLBAR_RECONFIGURED], 0);
742   
743   gtk_widget_queue_resize (GTK_WIDGET (tool_item));
744 }
745