]> Pileus Git - ~andy/gtk/blob - gtk/gtktoolitem.c
make _gtk_tool_item_toolbar_reconfigured() an internal function
[~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   g_type_class_add_private (object_class, sizeof (GtkToolItemPrivate));
194 }
195
196 static void
197 gtk_tool_item_init (GtkToolItem *toolitem)
198 {
199   GTK_WIDGET_UNSET_FLAGS (toolitem, GTK_CAN_FOCUS);  
200
201   toolitem->priv = GTK_TOOL_ITEM_GET_PRIVATE (toolitem);
202
203   toolitem->priv->visible_horizontal = TRUE;
204   toolitem->priv->visible_vertical = TRUE;
205   toolitem->priv->homogeneous = FALSE;
206   toolitem->priv->expand = FALSE;
207 }
208
209 static void
210 gtk_tool_item_finalize (GObject *object)
211 {
212   GtkToolItem *item = GTK_TOOL_ITEM (object);
213
214   if (item->priv->menu_item)
215     g_object_unref (item->priv->menu_item);
216   
217   if (G_OBJECT_CLASS (parent_class)->finalize)
218     G_OBJECT_CLASS (parent_class)->finalize (object);
219 }
220
221 static void
222 gtk_tool_item_parent_set   (GtkWidget   *toolitem,
223                             GtkWidget   *prev_parent)
224 {
225   _gtk_tool_item_toolbar_reconfigured (GTK_TOOL_ITEM (toolitem));
226 }
227
228 static void
229 gtk_tool_item_set_property (GObject      *object,
230                             guint         prop_id,
231                             const GValue *value,
232                             GParamSpec   *pspec)
233 {
234   GtkToolItem *toolitem = GTK_TOOL_ITEM (object);
235
236   switch (prop_id)
237     {
238     case PROP_VISIBLE_HORIZONTAL:
239       gtk_tool_item_set_visible_horizontal (toolitem, g_value_get_boolean (value));
240       break;
241     case PROP_VISIBLE_VERTICAL:
242       gtk_tool_item_set_visible_horizontal (toolitem, g_value_get_boolean (value));
243       break;
244     default:
245       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
246     }
247 }
248
249 static void
250 gtk_tool_item_get_property (GObject    *object,
251                             guint       prop_id,
252                             GValue     *value,
253                             GParamSpec *pspec)
254 {
255   GtkToolItem *toolitem = GTK_TOOL_ITEM (object);
256
257   switch (prop_id)
258     {
259     case PROP_VISIBLE_HORIZONTAL:
260       g_value_set_boolean (value, toolitem->priv->visible_horizontal);
261       break;
262     case PROP_VISIBLE_VERTICAL:
263       g_value_set_boolean (value, toolitem->priv->visible_vertical);
264       break;
265     default:
266       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
267     }
268 }
269
270 static void
271 create_drag_window (GtkToolItem *toolitem)
272 {
273   GtkWidget *widget;
274   GdkWindowAttr attributes;
275   gint attributes_mask, border_width;
276
277   g_return_if_fail (toolitem->priv->use_drag_window == TRUE);
278
279   widget = GTK_WIDGET (toolitem);
280   border_width = GTK_CONTAINER (toolitem)->border_width;
281
282   attributes.window_type = GDK_WINDOW_CHILD;
283   attributes.x = widget->allocation.x + border_width;
284   attributes.y = widget->allocation.y + border_width;
285   attributes.width = widget->allocation.width - border_width * 2;
286   attributes.height = widget->allocation.height - border_width * 2;
287   attributes.wclass = GDK_INPUT_ONLY;
288   attributes.event_mask = gtk_widget_get_events (widget);
289   attributes.event_mask |= (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
290
291   attributes_mask = GDK_WA_X | GDK_WA_Y;
292
293   toolitem->priv->drag_window = gdk_window_new (gtk_widget_get_parent_window (widget),
294                                           &attributes, attributes_mask);
295   gdk_window_set_user_data (toolitem->priv->drag_window, toolitem);
296 }
297
298 static void
299 gtk_tool_item_realize (GtkWidget *widget)
300 {
301   GtkToolItem *toolitem;
302
303   toolitem = GTK_TOOL_ITEM (widget);
304   GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
305
306   widget->window = gtk_widget_get_parent_window (widget);
307   g_object_ref (widget->window);
308
309   if (toolitem->priv->use_drag_window)
310     create_drag_window(toolitem);
311
312   widget->style = gtk_style_attach (widget->style, widget->window);
313 }
314
315 static void
316 destroy_drag_window (GtkToolItem *toolitem)
317 {
318   if (toolitem->priv->drag_window)
319     {
320       gdk_window_set_user_data (toolitem->priv->drag_window, NULL);
321       gdk_window_destroy (toolitem->priv->drag_window);
322       toolitem->priv->drag_window = NULL;
323     }
324 }
325
326 static void
327 gtk_tool_item_unrealize (GtkWidget *widget)
328 {
329   GtkToolItem *toolitem;
330
331   toolitem = GTK_TOOL_ITEM (widget);
332
333   destroy_drag_window (toolitem);
334   
335   GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
336 }
337
338 static void
339 gtk_tool_item_map (GtkWidget *widget)
340 {
341   GtkToolItem *toolitem;
342
343   toolitem = GTK_TOOL_ITEM (widget);
344   GTK_WIDGET_CLASS (parent_class)->map (widget);
345   if (toolitem->priv->drag_window)
346     gdk_window_show (toolitem->priv->drag_window);
347 }
348
349 static void
350 gtk_tool_item_unmap (GtkWidget *widget)
351 {
352   GtkToolItem *toolitem;
353
354   toolitem = GTK_TOOL_ITEM (widget);
355   if (toolitem->priv->drag_window)
356     gdk_window_hide (toolitem->priv->drag_window);
357   GTK_WIDGET_CLASS (parent_class)->unmap (widget);
358 }
359
360 static void
361 gtk_tool_item_size_request (GtkWidget      *widget,
362                             GtkRequisition *requisition)
363 {
364   GtkWidget *child = GTK_BIN (widget)->child;
365
366   if (child && GTK_WIDGET_VISIBLE (child))
367     {
368       gtk_widget_size_request (child, requisition);
369     }
370   else
371     {
372       requisition->height = 0;
373       requisition->width = 0;
374     }
375   
376   requisition->width += (GTK_CONTAINER (widget)->border_width) * 2;
377   requisition->height += (GTK_CONTAINER (widget)->border_width) * 2;
378 }
379
380 static void
381 gtk_tool_item_size_allocate (GtkWidget     *widget,
382                              GtkAllocation *allocation)
383 {
384   GtkToolItem *toolitem = GTK_TOOL_ITEM (widget);
385   GtkAllocation child_allocation;
386   gint border_width;
387   GtkWidget *child = GTK_BIN (widget)->child;
388
389   widget->allocation = *allocation;
390   border_width = GTK_CONTAINER (widget)->border_width;
391
392   if (toolitem->priv->drag_window)
393     gdk_window_move_resize (toolitem->priv->drag_window,
394                             widget->allocation.x + border_width,
395                             widget->allocation.y + border_width,
396                             widget->allocation.width - border_width * 2,
397                             widget->allocation.height - border_width * 2);
398   
399   if (child && GTK_WIDGET_VISIBLE (child))
400     {
401       child_allocation.x = allocation->x + border_width;
402       child_allocation.y = allocation->y + border_width;
403       child_allocation.width = allocation->width - 2 * border_width;
404       child_allocation.height = allocation->height - 2 * border_width;
405       
406       gtk_widget_size_allocate (child, &child_allocation);
407     }
408 }
409
410 static gboolean
411 gtk_tool_item_create_menu_proxy (GtkToolItem *item)
412 {
413   if (!GTK_BIN (item)->child)
414     {
415       GtkWidget *menu_item = NULL;
416
417       menu_item = gtk_separator_menu_item_new();
418
419       gtk_tool_item_set_proxy_menu_item (item, MENU_ID, menu_item);
420
421       return TRUE;
422     }
423   
424   return FALSE;
425 }
426
427 GtkToolItem *
428 gtk_tool_item_new (void)
429 {
430   GtkToolItem *item;
431
432   item = g_object_new (GTK_TYPE_TOOL_ITEM, NULL);
433
434   return item;
435 }
436
437 GtkIconSize
438 gtk_tool_item_get_icon_size (GtkToolItem *tool_item)
439 {
440   GtkWidget *parent;
441
442   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_ICON_SIZE_LARGE_TOOLBAR);
443
444   parent = GTK_WIDGET (tool_item)->parent;
445   if (!parent || !GTK_IS_TOOLBAR (parent))
446     return GTK_ICON_SIZE_LARGE_TOOLBAR;
447
448   return gtk_toolbar_get_icon_size (GTK_TOOLBAR (parent));
449 }
450
451 GtkOrientation
452 gtk_tool_item_get_orientation (GtkToolItem *tool_item)
453 {
454   GtkWidget *parent;
455   
456   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_ORIENTATION_HORIZONTAL);
457
458   parent = GTK_WIDGET (tool_item)->parent;
459   if (!parent || !GTK_IS_TOOLBAR (parent))
460     return GTK_ORIENTATION_HORIZONTAL;
461
462   return gtk_toolbar_get_orientation (GTK_TOOLBAR (parent));
463 }
464
465 GtkToolbarStyle
466 gtk_tool_item_get_toolbar_style (GtkToolItem *tool_item)
467 {
468   GtkWidget *parent;
469   
470   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_TOOLBAR_ICONS);
471
472   parent = GTK_WIDGET (tool_item)->parent;
473   if (!parent || !GTK_IS_TOOLBAR (parent))
474     return GTK_TOOLBAR_ICONS;
475
476   return gtk_toolbar_get_style (GTK_TOOLBAR (parent));
477 }
478
479 GtkReliefStyle 
480 gtk_tool_item_get_relief_style (GtkToolItem *tool_item)
481 {
482   GtkWidget *parent;
483   
484   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_RELIEF_NONE);
485
486   parent = GTK_WIDGET (tool_item)->parent;
487   if (!parent || !GTK_IS_TOOLBAR (parent))
488     return GTK_RELIEF_NONE;
489
490   return gtk_toolbar_get_relief_style (GTK_TOOLBAR (parent));
491 }
492
493 void
494 gtk_tool_item_set_expand (GtkToolItem *tool_item,
495                           gboolean     expand)
496 {
497   g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
498     
499   expand = expand != FALSE;
500
501   if (tool_item->priv->expand != expand)
502     {
503       tool_item->priv->expand = expand;
504       gtk_widget_child_notify (GTK_WIDGET (tool_item), "expand");
505       gtk_widget_queue_resize (GTK_WIDGET (tool_item));
506     }
507 }
508
509 gboolean
510 gtk_tool_item_get_expand (GtkToolItem *tool_item)
511 {
512   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), FALSE);
513
514   return tool_item->priv->expand;
515 }
516
517 void
518 gtk_tool_item_set_pack_end (GtkToolItem *tool_item,
519                             gboolean     pack_end)
520 {
521   g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
522     
523   pack_end = pack_end != FALSE;
524
525   if (tool_item->priv->pack_end != pack_end)
526     {
527       tool_item->priv->pack_end = pack_end;
528       gtk_widget_child_notify (GTK_WIDGET (tool_item), "pack_end");
529       gtk_widget_queue_resize (GTK_WIDGET (tool_item));
530     }
531 }
532
533 gboolean
534 gtk_tool_item_get_pack_end (GtkToolItem *tool_item)
535 {
536   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), FALSE);
537
538   return tool_item->priv->pack_end;
539 }
540
541 void
542 gtk_tool_item_set_homogeneous (GtkToolItem *tool_item,
543                                gboolean     homogeneous)
544 {
545   g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
546     
547   homogeneous = homogeneous != FALSE;
548
549   if (tool_item->priv->homogeneous != homogeneous)
550     {
551       tool_item->priv->homogeneous = homogeneous;
552       gtk_widget_child_notify (GTK_WIDGET (tool_item), "homogeneous");
553       gtk_widget_queue_resize (GTK_WIDGET (tool_item));
554     }
555 }
556
557 gboolean
558 gtk_tool_item_get_homogeneous (GtkToolItem *tool_item)
559 {
560   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), FALSE);
561
562   return tool_item->priv->homogeneous;
563 }
564
565 static gboolean
566 gtk_tool_item_real_set_tooltip (GtkToolItem *tool_item,
567                                 GtkTooltips *tooltips,
568                                 const gchar *tip_text,
569                                 const gchar *tip_private)
570 {
571   GtkWidget *child = GTK_BIN (tool_item)->child;
572
573   if (!child)
574     return FALSE;
575
576   gtk_tooltips_set_tip (tooltips, child, tip_text, tip_private);
577
578   return TRUE;
579 }
580
581 void
582 gtk_tool_item_set_tooltip (GtkToolItem *tool_item,
583                            GtkTooltips *tooltips,
584                            const gchar *tip_text,
585                            const gchar *tip_private)
586 {
587   gboolean retval;
588   
589   g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
590
591   g_signal_emit (tool_item, toolitem_signals[SET_TOOLTIP], 0,
592                  tooltips, tip_text, tip_private, &retval);
593 }
594
595 void
596 gtk_tool_item_set_use_drag_window (GtkToolItem *toolitem,
597                                    gboolean     use_drag_window)
598 {
599   g_return_if_fail (GTK_IS_TOOL_ITEM (toolitem));
600
601   use_drag_window = use_drag_window != FALSE;
602
603   if (toolitem->priv->use_drag_window != use_drag_window)
604     {
605       toolitem->priv->use_drag_window = use_drag_window;
606       
607       if (use_drag_window)
608         {
609           if (!toolitem->priv->drag_window && GTK_WIDGET_REALIZED (toolitem))
610             {
611               create_drag_window(toolitem);
612               if (GTK_WIDGET_MAPPED (toolitem))
613                 gdk_window_show (toolitem->priv->drag_window);
614             }
615         }
616       else
617         {
618           destroy_drag_window (toolitem);
619         }
620     }
621 }
622
623 gboolean
624 gtk_tool_item_get_use_drag_window (GtkToolItem *toolitem)
625 {
626   g_return_val_if_fail (GTK_IS_TOOL_ITEM (toolitem), FALSE);
627
628   return toolitem->priv->use_drag_window;
629 }
630
631 void
632 gtk_tool_item_set_visible_horizontal (GtkToolItem *toolitem,
633                                       gboolean     visible_horizontal)
634 {
635   g_return_if_fail (GTK_IS_TOOL_ITEM (toolitem));
636
637   visible_horizontal = visible_horizontal != FALSE;
638
639   if (toolitem->priv->visible_horizontal != visible_horizontal)
640     {
641       toolitem->priv->visible_horizontal = visible_horizontal;
642
643       g_object_notify (G_OBJECT (toolitem), "visible_horizontal");
644
645       gtk_widget_queue_resize (GTK_WIDGET (toolitem));
646     }
647 }
648
649 gboolean
650 gtk_tool_item_get_visible_horizontal (GtkToolItem *toolitem)
651 {
652   g_return_val_if_fail (GTK_IS_TOOL_ITEM (toolitem), FALSE);
653
654   return toolitem->priv->visible_horizontal;
655 }
656
657 void
658 gtk_tool_item_set_visible_vertical (GtkToolItem *toolitem,
659                                     gboolean     visible_vertical)
660 {
661   g_return_if_fail (GTK_IS_TOOL_ITEM (toolitem));
662
663   visible_vertical = visible_vertical != FALSE;
664
665   if (toolitem->priv->visible_vertical != visible_vertical)
666     {
667       toolitem->priv->visible_vertical = visible_vertical;
668
669       g_object_notify (G_OBJECT (toolitem), "visible_vertical");
670
671       gtk_widget_queue_resize (GTK_WIDGET (toolitem));
672     }
673 }
674
675 gboolean
676 gtk_tool_item_get_visible_vertical (GtkToolItem *toolitem)
677 {
678   g_return_val_if_fail (GTK_IS_TOOL_ITEM (toolitem), FALSE);
679
680   return toolitem->priv->visible_vertical;
681 }
682
683 GtkWidget *
684 gtk_tool_item_retrieve_proxy_menu_item (GtkToolItem *tool_item)
685 {
686   gboolean retval;
687   
688   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), NULL);
689
690   g_signal_emit (tool_item, toolitem_signals[CREATE_MENU_PROXY], 0, &retval);
691   
692   return tool_item->priv->menu_item;
693 }
694
695 GtkWidget *
696 gtk_tool_item_get_proxy_menu_item (GtkToolItem *tool_item,
697                                    const gchar *menu_item_id)
698 {
699   g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), NULL);
700   g_return_val_if_fail (menu_item_id != NULL, NULL);
701
702   if (tool_item->priv->menu_item_id && strcmp (tool_item->priv->menu_item_id, menu_item_id) == 0)
703     return tool_item->priv->menu_item;
704
705   return NULL;
706 }
707
708 void
709 gtk_tool_item_set_proxy_menu_item (GtkToolItem *tool_item,
710                                    const gchar *menu_item_id,
711                                    GtkWidget   *menu_item)
712 {
713   g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
714   g_return_if_fail (menu_item == NULL || GTK_IS_MENU_ITEM (menu_item));
715   g_return_if_fail (menu_item_id != NULL);
716
717   if (tool_item->priv->menu_item_id)
718     g_free (tool_item->priv->menu_item_id);
719       
720   tool_item->priv->menu_item_id = g_strdup (menu_item_id);
721
722   if (tool_item->priv->menu_item != menu_item)
723     {
724       if (tool_item->priv->menu_item)
725         g_object_unref (G_OBJECT (tool_item->priv->menu_item));
726       
727       if (menu_item)
728         {
729           g_object_ref (menu_item);
730           gtk_object_sink (GTK_OBJECT (menu_item));
731         }
732       
733       tool_item->priv->menu_item = menu_item;
734     }
735 }
736
737 void
738 _gtk_tool_item_toolbar_reconfigured (GtkToolItem *tool_item)
739 {
740   g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
741
742   g_signal_emit (tool_item, toolitem_signals[TOOLBAR_RECONFIGURED], 0);
743   
744   gtk_widget_queue_resize (GTK_WIDGET (tool_item));
745 }
746