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