]> Pileus Git - ~andy/gtk/blob - gtk/gtktoolbutton.c
Add new toolbar headers
[~andy/gtk] / gtk / gtktoolbutton.c
1 /* gtktoolbutton.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 "gtktoolbutton.h"
24 #include "gtkbutton.h"
25 #include "gtkhbox.h"
26 #include "gtkiconfactory.h"
27 #include "gtkimage.h"
28 #include "gtkimagemenuitem.h"
29 #include "gtklabel.h"
30 #include "gtkstock.h"
31 #include "gtkvbox.h"
32 #include "gtkintl.h"
33 #include "gtktoolbar.h"
34
35 #include <string.h>
36
37 #define MENU_ID "gtk-tool-button-menu-id"
38
39 enum {
40   CLICKED,
41   LAST_SIGNAL
42 };
43
44 enum {
45   PROP_0,
46   PROP_LABEL,
47   PROP_USE_UNDERLINE,
48   PROP_LABEL_WIDGET,
49   PROP_STOCK_ID,
50   PROP_ICON_WIDGET,
51 };
52
53 static void gtk_tool_button_init          (GtkToolButton      *button,
54                                            GtkToolButtonClass *klass);
55 static void gtk_tool_button_class_init    (GtkToolButtonClass *klass);
56 static void gtk_tool_button_size_request  (GtkWidget          *widget,
57                                            GtkRequisition     *requisition);
58 static void gtk_tool_button_size_allocate (GtkWidget          *widget,
59                                            GtkAllocation      *allocation);
60 static void gtk_tool_button_set_property  (GObject            *object,
61                                            guint               prop_id,
62                                            const GValue       *value,
63                                            GParamSpec         *pspec);
64 static void gtk_tool_button_get_property  (GObject            *object,
65                                            guint               prop_id,
66                                            GValue             *value,
67                                            GParamSpec         *pspec);
68 static void gtk_tool_button_finalize      (GObject            *object);
69
70 static void gtk_tool_button_toolbar_reconfigured (GtkToolItem *tool_item);
71 static gboolean   gtk_tool_button_create_menu_proxy (GtkToolItem     *item);
72 static void       button_clicked                    (GtkWidget       *widget,
73                                                      GtkToolButton   *button);
74
75 static void gtk_tool_button_construct_contents (GtkToolItem *tool_item);
76       
77 static GObjectClass *parent_class = NULL;
78 static guint         toolbutton_signals[LAST_SIGNAL] = { 0 };
79
80 GType
81 gtk_tool_button_get_type (void)
82 {
83   static GtkType type = 0;
84
85   if (!type)
86     {
87       static const GTypeInfo type_info =
88         {
89           sizeof (GtkToolButtonClass),
90           (GBaseInitFunc) NULL,
91           (GBaseFinalizeFunc) NULL,
92           (GClassInitFunc) gtk_tool_button_class_init,
93           (GClassFinalizeFunc) NULL,
94           NULL,
95           sizeof (GtkToolButton),
96           0, /* n_preallocs */
97           (GInstanceInitFunc) gtk_tool_button_init,
98         };
99
100       type = g_type_register_static (GTK_TYPE_TOOL_ITEM,
101                                      "GtkToolButton",
102                                      &type_info, 0);
103     }
104   return type;
105 }
106
107 static void
108 gtk_tool_button_class_init (GtkToolButtonClass *klass)
109 {
110   GObjectClass *object_class;
111   GtkWidgetClass *widget_class;
112   GtkToolItemClass *tool_item_class;
113   
114   parent_class = g_type_class_peek_parent (klass);
115   
116   object_class = (GObjectClass *)klass;
117   widget_class = (GtkWidgetClass *)klass;
118   tool_item_class = (GtkToolItemClass *)klass;
119   
120   object_class->set_property = gtk_tool_button_set_property;
121   object_class->get_property = gtk_tool_button_get_property;
122   object_class->finalize = gtk_tool_button_finalize;
123
124   widget_class->size_request = gtk_tool_button_size_request;
125   widget_class->size_allocate = gtk_tool_button_size_allocate;
126
127   tool_item_class->create_menu_proxy = gtk_tool_button_create_menu_proxy;
128   tool_item_class->toolbar_reconfigured = gtk_tool_button_toolbar_reconfigured;
129   
130   klass->button_type = GTK_TYPE_BUTTON;
131
132   g_object_class_install_property (object_class,
133                                    PROP_LABEL,
134                                    g_param_spec_string ("label",
135                                                         _("Label"),
136                                                         _("Text to show in the item."),
137                                                         NULL,
138                                                         G_PARAM_READWRITE));
139   g_object_class_install_property (object_class,
140                                    PROP_USE_UNDERLINE,
141                                    g_param_spec_boolean ("use_underline",
142                                                          _("Use underline"),
143                                                          _("Interpret underlines in the item label"),
144                                                          FALSE,
145                                                          G_PARAM_READWRITE));
146   g_object_class_install_property (object_class,
147                                    PROP_LABEL_WIDGET,
148                                    g_param_spec_object ("label_widget",
149                                                         _("Label widget"),
150                                                         _("Widget to use as the item label"),
151                                                         GTK_TYPE_WIDGET,
152                                                         G_PARAM_READWRITE));
153   g_object_class_install_property (object_class,
154                                    PROP_STOCK_ID,
155                                    g_param_spec_string ("stock_id",
156                                                         _("Stock Id"),
157                                                         _("The stock icon displayed on the item"),
158                                                         NULL,
159                                                         G_PARAM_READWRITE));
160   g_object_class_install_property (object_class,
161                                    PROP_ICON_WIDGET,
162                                    g_param_spec_object ("icon_widget",
163                                                         _("Icon widget"),
164                                                         _("Icon widget to display in the item"),
165                                                         GTK_TYPE_WIDGET,
166                                                         G_PARAM_READWRITE));
167
168   toolbutton_signals[CLICKED] =
169     g_signal_new ("clicked",
170                   G_OBJECT_CLASS_TYPE (klass),
171                   G_SIGNAL_RUN_FIRST,
172                   G_STRUCT_OFFSET (GtkToolButtonClass, clicked),
173                   NULL, NULL,
174                   g_cclosure_marshal_VOID__VOID,
175                   G_TYPE_NONE, 0);
176 }
177
178 static void
179 gtk_tool_button_init (GtkToolButton      *button,
180                       GtkToolButtonClass *klass)
181 {
182   GtkToolItem *toolitem = GTK_TOOL_ITEM (button);
183   
184   toolitem->homogeneous = TRUE;
185
186   /* create button */
187   button->button = g_object_new (klass->button_type, NULL);
188   gtk_button_set_focus_on_click (GTK_BUTTON (button->button), FALSE);
189   g_signal_connect_object (button->button, "clicked",
190                            G_CALLBACK (button_clicked), button, 0);
191
192   gtk_container_add (GTK_CONTAINER (button), button->button);
193   gtk_widget_show (button->button);
194 }
195
196 static void
197 gtk_tool_button_size_request (GtkWidget      *widget,
198                               GtkRequisition *requisition)
199 {
200   GtkWidget *child = GTK_BIN (widget)->child;
201
202   if (child && GTK_WIDGET_VISIBLE (child))
203     {
204       gtk_widget_size_request (child, requisition);
205     }
206   else
207     {
208       requisition->width = 0;
209       requisition->height = 0;
210     }
211   
212   requisition->width += GTK_CONTAINER (widget)->border_width * 2;
213   requisition->height += GTK_CONTAINER (widget)->border_width * 2;  
214 }
215
216 static void
217 gtk_tool_button_size_allocate (GtkWidget     *widget,
218                                GtkAllocation *allocation)
219 {
220   GtkToolItem *toolitem = GTK_TOOL_ITEM (widget);
221   GtkAllocation child_allocation;
222   gint border_width;
223   GtkWidget *child = GTK_BIN (widget)->child;
224
225   widget->allocation = *allocation;
226   border_width = GTK_CONTAINER (widget)->border_width;
227
228   if (toolitem->drag_window && GTK_WIDGET_REALIZED (widget))
229     gdk_window_move_resize (toolitem->drag_window,
230                             widget->allocation.x + border_width,
231                             widget->allocation.y + border_width,
232                             widget->allocation.width - border_width * 2,
233                             widget->allocation.height - border_width * 2);
234   
235   if (child && GTK_WIDGET_VISIBLE (child))
236     {
237       child_allocation.x = allocation->x + border_width;
238       child_allocation.y = allocation->y + border_width;
239       child_allocation.width = allocation->width - 2 * border_width;
240       child_allocation.height = allocation->height - 2 * border_width;
241       
242       gtk_widget_size_allocate (child, &child_allocation);
243     }
244 }
245
246 static void
247 gtk_tool_button_construct_contents (GtkToolItem *tool_item)
248 {
249   GtkToolButton *button = GTK_TOOL_BUTTON (tool_item);
250   GtkWidget *label = NULL;
251   GtkWidget *icon = NULL;
252   GtkToolbarStyle style;
253   gboolean need_label = FALSE;
254   gboolean need_icon = FALSE;
255   GtkIconSize icon_size;
256   GtkWidget *box = NULL;
257
258   if (gtk_tool_item_get_proxy_menu_item (tool_item, MENU_ID))
259     {
260       /* Remove item, so it will be recreated on the next
261        * create_proxy_menu_item()
262        */
263       gtk_tool_item_set_proxy_menu_item (tool_item, MENU_ID, NULL);
264     }
265   
266   if (button->icon_widget && button->icon_widget->parent)
267     {
268       gtk_container_remove (GTK_CONTAINER (button->icon_widget->parent),
269                             button->icon_widget);
270     }
271
272   if (button->label_widget && button->label_widget->parent)
273     {
274       gtk_container_remove (GTK_CONTAINER (button->label_widget->parent),
275                             button->label_widget);
276     }
277
278   if (GTK_BIN (button->button)->child)
279     {
280       gtk_container_remove (GTK_CONTAINER (button->button),
281                             GTK_BIN (button->button)->child);
282     }
283
284   style = gtk_tool_item_get_toolbar_style (GTK_TOOL_ITEM (button));
285   
286   if (style != GTK_TOOLBAR_TEXT)
287     need_icon = TRUE;
288
289   if (style != GTK_TOOLBAR_ICONS)
290     need_label = TRUE;
291
292   if (need_label)
293     {
294       if (button->label_widget)
295         {
296           label = button->label_widget;
297         }
298       else
299         {
300           GtkStockItem stock_item;
301           gboolean elide = TRUE;
302           gchar *label_text;
303
304           if (button->label_text)
305             {
306               label_text = button->label_text;
307               elide = button->use_underline;
308             }
309           else if (button->stock_id && gtk_stock_lookup (button->stock_id, &stock_item))
310             label_text = stock_item.label;
311           else
312             label_text = "";
313
314           if (elide)
315             label_text = _gtk_toolbar_elide_underscores (label_text);
316           else
317             label_text = g_strdup (label_text);
318
319           label = gtk_label_new (label_text);
320
321           g_free (label_text);
322           
323           gtk_widget_show (label);
324         }
325     }
326
327   icon_size = gtk_tool_item_get_icon_size (GTK_TOOL_ITEM (button));
328   if (need_icon)
329     {
330       if (button->icon_widget)
331         {
332           icon = button->icon_widget;
333           
334           if (GTK_IS_IMAGE (icon))
335             {
336               GtkImage *image = GTK_IMAGE (icon);
337               GtkImageType storage_type = gtk_image_get_storage_type (image);
338               
339               if (storage_type == GTK_IMAGE_STOCK)
340                 {
341                   gchar *stock_id;
342                   gtk_image_get_stock (image, &stock_id, NULL);
343
344                   icon = gtk_image_new_from_stock (stock_id, icon_size);
345                   gtk_widget_show (icon);
346                 }
347               else if (storage_type == GTK_IMAGE_ICON_SET)
348                 {
349                   GtkIconSet *icon_set;
350                   gtk_image_get_icon_set (image, &icon_set, NULL);
351                   
352                   icon = gtk_image_new_from_icon_set (icon_set, icon_size);
353                   gtk_widget_show (icon);
354                 }
355             }
356         }
357       else if (button->stock_id)
358         {
359           icon = gtk_image_new_from_stock (button->stock_id, icon_size);
360           gtk_widget_show (icon);
361         }
362     }
363
364   switch (style)
365     {
366     case GTK_TOOLBAR_ICONS:
367       if (icon)
368         gtk_container_add (GTK_CONTAINER (button->button), icon);
369       break;
370
371     case GTK_TOOLBAR_BOTH:
372       box = gtk_vbox_new (FALSE, 0);
373       gtk_box_pack_start (GTK_BOX (box), icon, TRUE, TRUE, 0);
374       gtk_box_pack_start (GTK_BOX (box), label, FALSE, TRUE, 0);
375       gtk_container_add (GTK_CONTAINER (button->button), box);
376       break;
377
378     case GTK_TOOLBAR_BOTH_HORIZ:
379       box = gtk_hbox_new (FALSE, 0);
380       gtk_box_pack_start (GTK_BOX (box), icon, FALSE, TRUE, 0);
381       gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
382       gtk_container_add (GTK_CONTAINER (button->button), box);
383       break;
384
385     case GTK_TOOLBAR_TEXT:
386       gtk_container_add (GTK_CONTAINER (button->button), label);
387       break;
388     }
389
390   if (box)
391     gtk_widget_show (box);
392
393   gtk_button_set_relief (GTK_BUTTON (button->button),
394                          gtk_tool_item_get_relief_style (GTK_TOOL_ITEM (button)));
395
396   gtk_widget_queue_resize (GTK_WIDGET (button));
397 }
398
399 static void
400 gtk_tool_button_set_property (GObject         *object,
401                               guint            prop_id,
402                               const GValue    *value,
403                               GParamSpec      *pspec)
404 {
405   GtkToolButton *button = GTK_TOOL_BUTTON (object);
406   
407   switch (prop_id)
408     {
409     case PROP_LABEL:
410       gtk_tool_button_set_label (button, g_value_get_string (value));
411       break;
412     case PROP_USE_UNDERLINE:
413       gtk_tool_button_set_use_underline (button, g_value_get_boolean (value));
414       break;
415     case PROP_LABEL_WIDGET:
416       gtk_tool_button_set_label_widget (button, g_value_get_object (value));
417       break;
418     case PROP_STOCK_ID:
419       gtk_tool_button_set_stock_id (button, g_value_get_string (value));
420       break;
421     case PROP_ICON_WIDGET:
422       gtk_tool_button_set_icon_widget (button, g_value_get_object (value));
423       break;
424     default:
425       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
426     }
427 }
428
429 static void
430 gtk_tool_button_get_property (GObject         *object,
431                               guint            prop_id,
432                               GValue          *value,
433                               GParamSpec      *pspec)
434 {
435   GtkToolButton *button = GTK_TOOL_BUTTON (object);
436
437   switch (prop_id)
438     {
439     case PROP_LABEL:
440       g_value_set_string (value, gtk_tool_button_get_label (button));
441       break;
442     case PROP_LABEL_WIDGET:
443       g_value_set_object (value, gtk_tool_button_get_label_widget (button));
444       break;
445     case PROP_USE_UNDERLINE:
446       g_value_set_boolean (value, gtk_tool_button_get_use_underline (button));
447       break;
448     case PROP_STOCK_ID:
449       g_value_set_string (value, button->stock_id);
450       break;
451     case PROP_ICON_WIDGET:
452       g_value_set_object (value, button->icon_widget);
453       break;
454     default:
455       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
456     }
457 }
458
459 static void
460 gtk_tool_button_finalize (GObject *object)
461 {
462   GtkToolButton *button = GTK_TOOL_BUTTON (object);
463
464   g_free (button->stock_id);
465   button->stock_id = NULL;
466
467   parent_class->finalize (object);
468 }
469
470 static gboolean
471 gtk_tool_button_create_menu_proxy (GtkToolItem *item)
472 {
473   GtkToolButton *button = GTK_TOOL_BUTTON (item);
474   GtkWidget *menu_item;
475   GtkWidget *menu_image = NULL;
476   GtkStockItem stock_item;
477   gboolean use_mnemonic = TRUE;
478   const char *label = "";
479
480   if (button->label_widget && GTK_IS_LABEL (button->label_widget))
481     label = gtk_label_get_label (GTK_LABEL (button->label_widget));
482   else if (button->label_text)
483     {
484       label = button->label_text;
485       use_mnemonic = button->use_underline;
486     }
487   else if (button->stock_id && gtk_stock_lookup (button->stock_id, &stock_item))
488     label = stock_item.label;
489   
490   if (use_mnemonic)
491     menu_item = gtk_image_menu_item_new_with_mnemonic (label);
492   else
493     menu_item = gtk_image_menu_item_new_with_label (label);
494
495   if (button->icon_widget && GTK_IS_IMAGE (button->icon_widget))
496     {
497       GtkImage *image = GTK_IMAGE (button->icon_widget);
498       GtkImageType storage_type = gtk_image_get_storage_type (image);
499       
500       if (storage_type == GTK_IMAGE_STOCK)
501         {
502           gchar *stock_id;
503           gtk_image_get_stock (image, &stock_id, NULL);
504           menu_image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_MENU);
505         }
506       else if (storage_type == GTK_IMAGE_ICON_SET)
507         {
508           GtkIconSet *icon_set;
509           gtk_image_get_icon_set (image, &icon_set, NULL);
510           menu_image = gtk_image_new_from_icon_set (icon_set, GTK_ICON_SIZE_MENU);
511         }
512     }
513   else if (button->stock_id)
514     {
515       menu_image = gtk_image_new_from_stock (button->stock_id, GTK_ICON_SIZE_MENU);
516     }
517
518   if (menu_image)
519     gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), menu_image);
520
521   g_signal_connect_closure_by_id (menu_item,
522                                   g_signal_lookup ("activate", G_OBJECT_TYPE (menu_item)), 0,
523                                   g_cclosure_new_object_swap (G_CALLBACK (gtk_button_clicked),
524                                                               G_OBJECT (GTK_TOOL_BUTTON (button)->button)),
525                                   FALSE);
526
527   gtk_tool_item_set_proxy_menu_item (GTK_TOOL_ITEM (button), MENU_ID, menu_item);
528   
529   return TRUE;
530 }
531
532 static void
533 button_clicked (GtkWidget     *widget,
534                 GtkToolButton *button)
535 {
536   g_signal_emit_by_name (button, "clicked");
537 }
538
539 static void
540 gtk_tool_button_toolbar_reconfigured (GtkToolItem *tool_item)
541 {
542   gtk_tool_button_construct_contents (tool_item);
543 }
544
545 GtkToolItem *
546 gtk_tool_button_new_from_stock (const gchar *stock_id)
547 {
548   GtkToolButton *button;
549
550   g_return_val_if_fail (stock_id != NULL, NULL);
551     
552   button = g_object_new (GTK_TYPE_TOOL_BUTTON,
553                          "stock_id", stock_id,
554                          NULL);
555
556   return GTK_TOOL_ITEM (button);
557 }
558
559 GtkToolItem *
560 gtk_tool_button_new (const gchar *label,
561                      GtkWidget   *icon_widget)
562 {
563   GtkToolButton *button;
564
565   button = g_object_new (GTK_TYPE_TOOL_BUTTON,
566                          NULL);
567   
568   if (label)
569     gtk_tool_button_set_label (button, label);
570
571   if (icon_widget)
572     gtk_tool_button_set_icon_widget (button, icon_widget);
573
574   return GTK_TOOL_ITEM (button);  
575 }
576
577 void
578 gtk_tool_button_set_label (GtkToolButton *button,
579                            const gchar   *label)
580 {
581   gchar *old_label;
582   
583   g_return_if_fail (GTK_IS_TOOL_BUTTON (button));
584
585   old_label = button->label_text;
586
587   button->label_text = g_strdup (label);
588   gtk_tool_button_construct_contents (GTK_TOOL_ITEM (button));
589       
590   g_object_notify (G_OBJECT (button), "label");
591
592   if (old_label)
593     g_free (old_label);
594 }
595
596 G_CONST_RETURN gchar *
597 gtk_tool_button_get_label (GtkToolButton *button)
598 {
599   g_return_val_if_fail (GTK_IS_TOOL_BUTTON (button), NULL);
600
601   return button->label_text;
602 }
603
604 void
605 gtk_tool_button_set_use_underline (GtkToolButton *button,
606                                    gboolean       use_underline)
607 {
608   g_return_if_fail (GTK_IS_TOOL_BUTTON (button));
609
610   use_underline = use_underline != FALSE;
611
612   if (use_underline != button->use_underline)
613     {
614       button->use_underline = use_underline;
615
616       gtk_tool_button_construct_contents (GTK_TOOL_ITEM (button));
617
618       g_object_notify (G_OBJECT (button), "use_underline");
619     }
620 }
621
622 gboolean
623 gtk_tool_button_get_use_underline (GtkToolButton *button)
624 {
625   g_return_val_if_fail (GTK_IS_TOOL_BUTTON (button), FALSE);
626
627   return button->use_underline;
628 }
629
630 void
631 gtk_tool_button_set_stock_id (GtkToolButton *button,
632                               const gchar   *stock_id)
633 {
634   gchar *old_stock_id;
635   
636   g_return_if_fail (GTK_IS_TOOL_BUTTON (button));
637
638   old_stock_id = button->stock_id;
639
640   button->stock_id = g_strdup (stock_id);
641   gtk_tool_button_construct_contents (GTK_TOOL_ITEM (button));
642   
643   g_object_notify (G_OBJECT (button), "stock_id");
644
645   g_free (old_stock_id);
646 }
647
648 G_CONST_RETURN gchar *
649 gtk_tool_button_get_stock_id (GtkToolButton *button)
650 {
651   g_return_val_if_fail (GTK_IS_TOOL_BUTTON (button), NULL);
652
653   return button->stock_id;
654 }
655
656 void
657 gtk_tool_button_set_icon_widget (GtkToolButton *button,
658                                  GtkWidget     *icon)
659 {
660   g_return_if_fail (GTK_IS_TOOL_BUTTON (button));
661   g_return_if_fail (icon == NULL || GTK_IS_WIDGET (icon));
662
663   if (icon != button->icon_widget)
664     {
665       if (button->icon_widget)
666         g_object_unref (G_OBJECT (button->icon_widget));
667
668       if (icon)
669         {
670           g_object_ref (icon);
671           gtk_object_sink (GTK_OBJECT (icon));
672         }
673
674       button->icon_widget = icon;
675
676       gtk_tool_button_construct_contents (GTK_TOOL_ITEM (button));
677       
678       g_object_notify (G_OBJECT (button), "icon_widget");
679     }
680 }
681
682 void
683 gtk_tool_button_set_label_widget (GtkToolButton *button,
684                                   GtkWidget     *label_widget)
685 {
686   g_return_if_fail (GTK_IS_TOOL_BUTTON (button));
687   g_return_if_fail (label_widget == NULL || GTK_IS_WIDGET (label_widget));
688
689   if (label_widget != button->label_widget)
690     {
691       if (button->label_widget)
692         g_object_unref (button->label_widget);
693
694       if (label_widget)
695         {
696           g_object_ref (label_widget);
697           gtk_object_sink (GTK_OBJECT (label_widget));
698         }
699
700       button->label_widget = label_widget;
701
702       gtk_tool_button_construct_contents (GTK_TOOL_ITEM (button));
703       
704       g_object_notify (G_OBJECT (button), "label_widget");
705     }
706 }
707
708 GtkWidget *
709 gtk_tool_button_get_label_widget (GtkToolButton *button)
710 {
711   g_return_val_if_fail (GTK_IS_TOOL_BUTTON (button), NULL);
712
713   return button->label_widget;
714 }
715
716 GtkWidget *
717 gtk_tool_button_get_icon_widget (GtkToolButton *button)
718 {
719   g_return_val_if_fail (GTK_IS_BUTTON (button), NULL);
720
721   return button->icon_widget;
722 }