]> www.fi.muni.cz Git - evince.git/blob - cut-n-paste/toolbar-editor/egg-editable-toolbar.c
Fix gcc 4.0 warnings. Second part
[evince.git] / cut-n-paste / toolbar-editor / egg-editable-toolbar.c
1 /*
2  *  Copyright (C) 2003, 2004  Marco Pesenti Gritti
3  *  Copyright (C) 2003, 2004, 2005  Christian Persch
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2, or (at your option)
8  *  any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  *
19  *  $Id$
20  */
21
22 #include "config.h"
23
24 #include "egg-editable-toolbar.h"
25 #include "egg-toolbars-model.h"
26 #include "egg-toolbar-editor.h"
27
28 #include <gtk/gtkvseparator.h>
29 #include <gtk/gtkiconfactory.h>
30 #include <gtk/gtkwindow.h>
31 #include <gtk/gtkmain.h>
32 #include <gtk/gtkdnd.h>
33 #include <gtk/gtkhbox.h>
34 #include <gtk/gtkimage.h>
35 #include <gtk/gtkimagemenuitem.h>
36 #include <gtk/gtkmenu.h>
37 #include <gtk/gtkstock.h>
38 #include <gtk/gtktoolbar.h>
39 #include <gtk/gtktoolitem.h>
40 #include <gtk/gtkseparatortoolitem.h>
41 #include <glib/gi18n.h>
42 #include <string.h>
43
44 static void egg_editable_toolbar_class_init     (EggEditableToolbarClass *klass);
45 static void egg_editable_toolbar_init           (EggEditableToolbar *t);
46 static void egg_editable_toolbar_finalize       (GObject *object);
47
48 #define MIN_TOOLBAR_HEIGHT 20
49
50 static const GtkTargetEntry dest_drag_types[] = {
51   {EGG_TOOLBAR_ITEM_TYPE, GTK_TARGET_SAME_APP, 0},
52 };
53
54 enum
55 {
56   PROP_0,
57   PROP_TOOLBARS_MODEL,
58   PROP_UI_MANAGER
59 };
60
61 enum
62 {
63   ACTION_REQUEST,
64   LAST_SIGNAL
65 };
66
67 static guint egg_editable_toolbar_signals[LAST_SIGNAL] = { 0 };
68
69 static GObjectClass *parent_class = NULL;
70
71 #define EGG_EDITABLE_TOOLBAR_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EGG_TYPE_EDITABLE_TOOLBAR, EggEditableToolbarPrivate))
72
73 struct _EggEditableToolbarPrivate
74 {
75   GtkUIManager *manager;
76   EggToolbarsModel *model;
77   gboolean edit_mode;
78   GtkWidget *selected_toolbar;
79   GtkWidget *fixed_toolbar;
80
81   gboolean pending;
82   GtkToolbar *target_toolbar;
83   GtkWidget *dragged_item;
84 };
85
86 GType
87 egg_editable_toolbar_get_type (void)
88 {
89   static GType type = 0;
90
91   if (G_UNLIKELY (type == 0))
92     {
93       static const GTypeInfo our_info = {
94         sizeof (EggEditableToolbarClass),
95         NULL,                   /* base_init */
96         NULL,                   /* base_finalize */
97         (GClassInitFunc) egg_editable_toolbar_class_init,
98         NULL,
99         NULL,                   /* class_data */
100         sizeof (EggEditableToolbar),
101         0,                      /* n_preallocs */
102         (GInstanceInitFunc) egg_editable_toolbar_init
103       };
104
105       type = g_type_register_static (GTK_TYPE_VBOX,
106                                      "EggEditableToolbar",
107                                      &our_info, 0);
108     }
109
110   return type;
111 }
112
113 static int
114 get_toolbar_position (EggEditableToolbar *etoolbar, GtkWidget *toolbar)
115 {
116   GList *l;
117   int result;
118
119   l = gtk_container_get_children (GTK_CONTAINER (etoolbar));
120   result = g_list_index (l, toolbar->parent);
121   g_list_free (l);
122
123   return result;
124 }
125
126 static int
127 get_n_toolbars (EggEditableToolbar *etoolbar)
128 {
129   GList *l;
130   int result;
131
132   l = gtk_container_get_children (GTK_CONTAINER (etoolbar));
133   result = g_list_length (l);
134   g_list_free (l);
135
136   return result;
137 }
138
139 static GtkWidget *
140 get_dock_nth (EggEditableToolbar *etoolbar,
141               int                 position)
142 {
143   GList *l;
144   GtkWidget *result;
145
146   l = gtk_container_get_children (GTK_CONTAINER (etoolbar));
147   result = g_list_nth_data (l, position);
148   g_list_free (l);
149
150   return result;
151 }
152
153 static GtkWidget *
154 get_toolbar_nth (EggEditableToolbar *etoolbar,
155                  int                 position)
156 {
157   GList *l;
158   GtkWidget *dock;
159   GtkWidget *result;
160
161   dock = get_dock_nth (etoolbar, position);
162
163   l = gtk_container_get_children (GTK_CONTAINER (dock));
164   result = GTK_WIDGET (l->data);
165   g_list_free (l);
166
167   return result;
168 }
169
170 static GtkAction *
171 find_action (EggEditableToolbar *t,
172              const char         *name)
173 {
174   GList *l;
175   GtkAction *action = NULL;
176
177   l = gtk_ui_manager_get_action_groups (t->priv->manager);
178
179   g_return_val_if_fail (name != NULL, NULL);
180
181   for (; l != NULL; l = l->next)
182     {
183       GtkAction *tmp;
184
185       tmp = gtk_action_group_get_action (GTK_ACTION_GROUP (l->data), name);
186       if (tmp)
187         action = tmp;
188     }
189
190   return action;
191 }
192
193 static void
194 drag_data_delete_cb (GtkWidget          *widget,
195                      GdkDragContext     *context,
196                      EggEditableToolbar *etoolbar)
197 {
198   int pos, toolbar_pos;
199
200   g_return_if_fail (EGG_IS_EDITABLE_TOOLBAR (etoolbar));
201
202   pos = gtk_toolbar_get_item_index (GTK_TOOLBAR (widget->parent),
203                                     GTK_TOOL_ITEM (widget));
204   toolbar_pos = get_toolbar_position (etoolbar, widget->parent);
205
206   egg_toolbars_model_remove_item (etoolbar->priv->model,
207                                   toolbar_pos, pos);
208 }
209
210 static void
211 drag_begin_cb (GtkWidget          *widget,
212                GdkDragContext     *context,
213                EggEditableToolbar *etoolbar)
214 {
215         gtk_widget_hide (widget);
216 }
217
218 static void
219 drag_end_cb (GtkWidget          *widget,
220              GdkDragContext     *context,
221              EggEditableToolbar *etoolbar)
222 {
223         gtk_widget_show (widget);
224 }
225
226 static void
227 drag_data_get_cb (GtkWidget          *widget,
228                   GdkDragContext     *context,
229                   GtkSelectionData   *selection_data,
230                   guint               info,
231                   guint32             time,
232                   EggEditableToolbar *etoolbar)
233 {
234   const char *id, *type;
235   char *target;
236
237   g_return_if_fail (EGG_IS_EDITABLE_TOOLBAR (etoolbar));
238
239   type = g_object_get_data (G_OBJECT (widget), "type");
240   id = g_object_get_data (G_OBJECT (widget), "id");
241   if (strcmp (id, "separator") == 0)
242     {
243       target = g_strdup (id);
244     }
245   else
246     {
247       target = egg_toolbars_model_get_item_data (etoolbar->priv->model,
248                                                  type, id);
249     }
250
251   gtk_selection_data_set (selection_data,
252                           selection_data->target, 8,
253                           (const guchar *)target, strlen (target));
254
255   g_free (target);
256 }
257
258 static void
259 set_drag_cursor (GtkWidget *widget)
260 {
261   if (widget->window)
262     {
263       GdkCursor *cursor;
264       GdkPixbuf *pixbuf;
265
266       pixbuf = gdk_pixbuf_new_from_file (CURSOR_DIR "/hand-open.png", NULL);
267       cursor = gdk_cursor_new_from_pixbuf (gdk_display_get_default (),
268                                            pixbuf, 12, 12);
269       gdk_window_set_cursor (widget->window, cursor);
270       gdk_cursor_unref (cursor);
271       g_object_unref (pixbuf);
272     }
273 }
274
275 static void
276 unset_drag_cursor (GtkWidget *widget)
277 {
278   if (widget->window)
279     {
280       gdk_window_set_cursor (widget->window, NULL);
281     }
282 }
283
284 static void
285 set_item_drag_source (EggToolbarsModel *model,
286                       GtkWidget        *item,
287                       GtkAction        *action,
288                       gboolean          is_separator,
289                       const char       *type)
290 {
291   GtkTargetEntry target_entry;
292   const char *id;
293
294   target_entry.target = (char *)type;
295   target_entry.flags = GTK_TARGET_SAME_APP;
296   target_entry.info = 0;
297
298   gtk_drag_source_set (item, GDK_BUTTON1_MASK,
299                        &target_entry, 1,
300                        GDK_ACTION_MOVE);
301
302   if (is_separator)
303     {
304       GtkWidget *icon;
305       GdkPixbuf *pixbuf;
306
307       id = "separator";
308
309       icon = _egg_editable_toolbar_new_separator_image ();
310       pixbuf = gtk_image_get_pixbuf (GTK_IMAGE (icon));
311       gtk_drag_source_set_icon_pixbuf (item, pixbuf);
312     }
313   else
314     {
315       const char *stock_id;
316       GValue value = { 0, };
317       GdkPixbuf *pixbuf;
318
319       id = gtk_action_get_name (action);
320
321       g_value_init (&value, G_TYPE_STRING);
322       g_object_get_property (G_OBJECT (action), "stock_id", &value);
323       stock_id = g_value_get_string (&value);
324
325       if (stock_id != NULL)
326         {
327           pixbuf = gtk_widget_render_icon (item, stock_id,
328                                            GTK_ICON_SIZE_LARGE_TOOLBAR, NULL);
329         }
330       else
331         {
332           pixbuf = gtk_widget_render_icon (item, GTK_STOCK_DND,
333                                            GTK_ICON_SIZE_LARGE_TOOLBAR, NULL);
334         }
335
336       gtk_drag_source_set_icon_pixbuf (item, pixbuf);
337       g_object_unref (pixbuf);
338
339       g_value_unset (&value);
340     }
341
342     g_object_set_data_full (G_OBJECT (item), "id",
343                             g_strdup (id), g_free);
344     g_object_set_data_full (G_OBJECT (item), "type",
345                             g_strdup (type), g_free);
346 }
347
348 static GtkWidget *
349 create_item_from_action (EggEditableToolbar *t,
350                          const char *action_name,
351                          const char *type,
352                          gboolean is_separator,
353                          GtkAction **ret_action)
354 {
355   GtkWidget *item;
356   GtkAction *action;
357
358   if (is_separator)
359     {
360       item = GTK_WIDGET (gtk_separator_tool_item_new ());
361       action = NULL;
362     }
363   else
364     {
365       g_return_val_if_fail (action_name != NULL, NULL);
366
367       g_signal_emit (G_OBJECT (t), egg_editable_toolbar_signals[ACTION_REQUEST],
368                      0, action_name);
369
370       action = find_action (t, action_name);
371       if (action)
372         {
373           item = gtk_action_create_tool_item (action);
374         }
375       else
376         {
377           return NULL;
378         }  
379     }
380
381   gtk_widget_show (item);
382
383   g_signal_connect (item, "drag_begin",
384                     G_CALLBACK (drag_begin_cb), t);
385   g_signal_connect (item, "drag_end",
386                     G_CALLBACK (drag_end_cb), t);
387   g_signal_connect (item, "drag_data_get",
388                     G_CALLBACK (drag_data_get_cb), t);
389   g_signal_connect (item, "drag_data_delete",
390                     G_CALLBACK (drag_data_delete_cb), t);
391
392   if (t->priv->edit_mode)
393     {
394       set_drag_cursor (item);
395       gtk_widget_set_sensitive (item, TRUE);
396       set_item_drag_source (t->priv->model, item, action,
397                             is_separator, type);
398       gtk_tool_item_set_use_drag_window (GTK_TOOL_ITEM (item), TRUE);
399     }
400
401   if (ret_action)
402     {
403       *ret_action = action;
404     }
405
406   return item;
407 }
408
409 static GtkWidget *
410 create_item (EggEditableToolbar *t,
411              EggToolbarsModel   *model,
412              int                 toolbar_position,
413              int                 position,
414              GtkAction         **ret_action)
415 {
416   const char *action_name, *type;
417   gboolean is_separator;
418
419   egg_toolbars_model_item_nth (model, toolbar_position, position,
420                                &is_separator, &action_name, &type);
421   return create_item_from_action (t, action_name, type,
422                                   is_separator, ret_action);
423 }
424
425 static gboolean
426 data_is_separator (const char *data)
427 {
428   return strcmp (data, "separator") == 0;
429 }
430
431 static void
432 drag_data_received_cb (GtkWidget          *widget,
433                        GdkDragContext     *context,
434                        gint                x,
435                        gint                y,
436                        GtkSelectionData   *selection_data,
437                        guint               info,
438                        guint               time,
439                        EggEditableToolbar *etoolbar)
440 {
441   char *type;
442   char *id;
443
444   GdkAtom target;
445           
446   target = gtk_drag_dest_find_target (widget, context, NULL);
447   type = egg_toolbars_model_get_item_type (etoolbar->priv->model, target);
448   id = egg_toolbars_model_get_item_id (etoolbar->priv->model, type,
449                                        (const char*)selection_data->data);
450
451   /* This function can be called for two reasons
452    *
453    *  (1) drag_motion() needs an item to pass to
454    *      gtk_toolbar_set_drop_highlight_item(). We can
455    *      recognize this case by etoolbar->priv->pending being TRUE
456    *      We should just create an item and return.
457    *
458    *  (2) The drag has finished, and drag_drop() wants us to
459    *      actually add a new item to the toolbar.
460    */
461
462   if (id == NULL)
463     {
464       etoolbar->priv->pending = FALSE;
465       g_free (type);
466       return;
467     }
468
469   if (etoolbar->priv->pending)
470     {
471       etoolbar->priv->pending = FALSE;
472       etoolbar->priv->dragged_item =
473         create_item_from_action (etoolbar, id, type,
474                                  data_is_separator (id), NULL);
475       g_object_ref (etoolbar->priv->dragged_item);
476       gtk_object_sink (GTK_OBJECT (etoolbar->priv->dragged_item));
477     }
478   else
479     {
480       int pos, toolbar_pos;
481
482       pos = gtk_toolbar_get_drop_index (GTK_TOOLBAR (widget), x, y);
483       toolbar_pos = get_toolbar_position (etoolbar, widget);
484
485       if (data_is_separator ((const char*)selection_data->data))
486         {
487           egg_toolbars_model_add_separator (etoolbar->priv->model,
488                                             toolbar_pos, pos);
489         }
490       else
491         {
492           egg_toolbars_model_add_item (etoolbar->priv->model,
493                                        toolbar_pos, pos, id, type);
494         }
495       
496       gtk_drag_finish (context, TRUE, context->action == GDK_ACTION_MOVE,
497                        time);
498     }
499
500   g_free (type);
501   g_free (id);
502 }
503
504 static void
505 remove_toolbar_cb (GtkWidget          *menuitem,
506                    EggEditableToolbar *etoolbar)
507 {
508   int pos;
509
510   pos = get_toolbar_position (etoolbar, etoolbar->priv->selected_toolbar);
511   egg_toolbars_model_remove_toolbar (etoolbar->priv->model, pos);
512 }
513
514 static void
515 popup_toolbar_context_menu_cb (GtkWidget          *toolbar,
516                                gint                x,
517                                gint                y,
518                                gint                button_number,
519                                EggEditableToolbar *t)
520 {
521   GtkWidget *menu;
522   GtkWidget *item;
523   GtkWidget *image;
524
525   if (t->priv->edit_mode)
526     {
527       EggTbModelFlags flags;
528       int position;
529
530       t->priv->selected_toolbar = toolbar;
531
532       menu = gtk_menu_new ();
533
534       item = gtk_image_menu_item_new_with_mnemonic (_("_Remove Toolbar"));
535       gtk_widget_show (item);
536       image = gtk_image_new_from_stock (GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU);
537       gtk_widget_show (image);
538       gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
539       gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
540       g_signal_connect (item, "activate",
541                         G_CALLBACK (remove_toolbar_cb),
542                         t);
543
544       position = get_toolbar_position (t, toolbar);
545       flags = egg_toolbars_model_get_flags (t->priv->model, position);
546       if (flags & EGG_TB_MODEL_NOT_REMOVABLE)
547         {
548           gtk_widget_set_sensitive (GTK_WIDGET (item), FALSE);
549         }
550
551       gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, 2,
552                       gtk_get_current_event_time ());
553     }
554 }
555
556 static void
557 free_dragged_item (EggEditableToolbar *etoolbar)
558 {
559   if (etoolbar->priv->dragged_item)
560     {
561       gtk_widget_destroy (etoolbar->priv->dragged_item);
562       g_object_unref (etoolbar->priv->dragged_item);
563       etoolbar->priv->dragged_item = NULL;
564     }
565 }
566
567 static gboolean
568 toolbar_drag_drop_cb (GtkWidget          *widget,
569                       GdkDragContext     *context,
570                       gint                x,
571                       gint                y,
572                       guint               time,
573                       EggEditableToolbar *etoolbar)
574 {
575   GdkAtom target;
576
577   target = gtk_drag_dest_find_target (widget, context, NULL);
578   if (target != GDK_NONE)
579     {
580       gtk_drag_get_data (widget, context,
581                          target,
582                          time);
583       return TRUE;
584     }
585   
586   free_dragged_item (etoolbar);
587   
588   return FALSE;
589 }
590
591 static gboolean
592 toolbar_drag_motion_cb (GtkWidget          *widget,
593                         GdkDragContext     *context,
594                         gint                x,
595                         gint                y,
596                         guint               time,
597                         EggEditableToolbar *etoolbar)
598 {
599   GdkAtom target;
600   int index;
601   GtkToolbar *toolbar = GTK_TOOLBAR (widget);
602   GtkToolItem *item;
603   GtkWidget *source;
604
605   source = gtk_drag_get_source_widget (context);
606   if (source)
607     {
608       EggTbModelFlags flags;
609       int pos;
610       gboolean is_item;
611
612       pos = get_toolbar_position (etoolbar, widget);
613       flags = egg_toolbars_model_get_flags (etoolbar->priv->model, pos);
614
615       is_item = etoolbar->priv->edit_mode &&
616                 (gtk_widget_get_ancestor (source, EGG_TYPE_EDITABLE_TOOLBAR) ||
617                  gtk_widget_get_ancestor (source, EGG_TYPE_TOOLBAR_EDITOR));
618
619       if ((flags & EGG_TB_MODEL_ACCEPT_ITEMS_ONLY) && !is_item)
620         {
621           gdk_drag_status (context, 0, time);
622           return FALSE;
623         }
624
625       if (gtk_widget_is_ancestor (source, widget))
626         {
627           context->suggested_action = GDK_ACTION_MOVE;
628         }
629     }
630
631   target = gtk_drag_dest_find_target (widget, context, NULL);
632   if (target == GDK_NONE)
633     {
634       gdk_drag_status (context, 0, time);
635       return FALSE;
636     }
637
638   if (etoolbar->priv->target_toolbar != toolbar)
639     {
640       if (etoolbar->priv->target_toolbar)
641         gtk_toolbar_set_drop_highlight_item
642                 (etoolbar->priv->target_toolbar, NULL, 0);
643       
644       free_dragged_item (etoolbar);
645       etoolbar->priv->pending = TRUE;
646
647       etoolbar->priv->target_toolbar = toolbar;
648
649       gtk_drag_get_data (widget, context, target, time);
650     }
651
652   if (etoolbar->priv->dragged_item != NULL &&
653       etoolbar->priv->edit_mode)
654     {
655       item = GTK_TOOL_ITEM (etoolbar->priv->dragged_item);
656
657       index = gtk_toolbar_get_drop_index (toolbar, x, y);
658       gtk_toolbar_set_drop_highlight_item (toolbar, item, index);
659     }
660
661   gdk_drag_status (context, context->suggested_action, time);
662
663   return TRUE;
664 }
665
666 static void
667 toolbar_drag_leave_cb (GtkToolbar         *toolbar,
668                        GdkDragContext     *context,
669                        guint               time,
670                        EggEditableToolbar *etoolbar)
671 {
672   /* This is a workaround for bug 125557. Sometimes
673    * we seemingly enter another toolbar *before* leaving
674    * the current one.
675    *
676    * In that case etoolbar->priv->target_toolbar will
677    * have been set to something else and the highlighting
678    * will already have been turned off
679    */
680   
681   if (etoolbar->priv->target_toolbar == toolbar)
682     {
683       gtk_toolbar_set_drop_highlight_item (toolbar, NULL, 0);
684
685       etoolbar->priv->target_toolbar = NULL;
686       free_dragged_item (etoolbar);
687     }
688 }
689
690 static GtkWidget *
691 create_dock (EggEditableToolbar *t)
692 {
693   GtkWidget *toolbar, *hbox;
694
695   hbox = gtk_hbox_new (0, FALSE);
696   gtk_widget_show (hbox);
697
698   toolbar = gtk_toolbar_new ();
699   gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar), TRUE);
700   gtk_widget_show (toolbar);
701   gtk_box_pack_start (GTK_BOX (hbox), toolbar, TRUE, TRUE, 0);
702
703   gtk_drag_dest_set (toolbar, 0,
704                      dest_drag_types, G_N_ELEMENTS (dest_drag_types),
705                      GDK_ACTION_MOVE | GDK_ACTION_COPY);
706  
707   g_signal_connect (toolbar, "drag_drop",
708                     G_CALLBACK (toolbar_drag_drop_cb), t); 
709   g_signal_connect (toolbar, "drag_motion",
710                     G_CALLBACK (toolbar_drag_motion_cb), t);
711   g_signal_connect (toolbar, "drag_leave",
712                     G_CALLBACK (toolbar_drag_leave_cb), t);
713
714   g_signal_connect (toolbar, "drag_data_received",
715                     G_CALLBACK (drag_data_received_cb), t);
716   g_signal_connect (toolbar, "popup_context_menu",
717                     G_CALLBACK (popup_toolbar_context_menu_cb), t);
718
719   return hbox;
720 }
721
722 static void
723 set_fixed_style (EggEditableToolbar *t, GtkToolbarStyle style)
724 {
725   g_return_if_fail (GTK_IS_TOOLBAR (t->priv->fixed_toolbar));
726   gtk_toolbar_set_style (GTK_TOOLBAR (t->priv->fixed_toolbar),
727                          style == GTK_TOOLBAR_ICONS ? GTK_TOOLBAR_BOTH_HORIZ : style);
728 }
729
730 static void
731 unset_fixed_style (EggEditableToolbar *t)
732 {
733   g_return_if_fail (GTK_IS_TOOLBAR (t->priv->fixed_toolbar));
734   gtk_toolbar_unset_style (GTK_TOOLBAR (t->priv->fixed_toolbar));
735 }
736
737 static void
738 toolbar_changed_cb (EggToolbarsModel   *model,
739                     int                 position,
740                     EggEditableToolbar *t)
741 {
742   GtkWidget *toolbar;
743   EggTbModelFlags flags;
744   GtkToolbarStyle style;
745
746   flags = egg_toolbars_model_get_flags (model, position);
747   toolbar = get_toolbar_nth (t, position);
748
749   if (flags & EGG_TB_MODEL_ICONS)
750   {
751     style = GTK_TOOLBAR_ICONS;
752   }
753   else if (flags & EGG_TB_MODEL_TEXT)
754   {
755     style = GTK_TOOLBAR_TEXT;
756   }
757   else if (flags & EGG_TB_MODEL_BOTH)
758   {
759     style = GTK_TOOLBAR_BOTH;
760   }
761   else if (flags & EGG_TB_MODEL_BOTH_HORIZ)
762   {
763     style = GTK_TOOLBAR_BOTH_HORIZ;
764   }
765   else
766   {
767     gtk_toolbar_unset_style (GTK_TOOLBAR (toolbar));
768     if (position == 0 && t->priv->fixed_toolbar)
769       {
770         unset_fixed_style (t);
771       }
772     return;
773   }
774
775   gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), style);
776   if (position == 0 && t->priv->fixed_toolbar)
777     {
778       set_fixed_style (t, style);
779     }
780 }
781
782 static void
783 unparent_fixed (EggEditableToolbar *t)
784 {
785   GtkWidget *toolbar, *dock;
786   g_return_if_fail (GTK_IS_TOOLBAR (t->priv->fixed_toolbar));
787
788   toolbar = t->priv->fixed_toolbar;
789   dock = get_dock_nth (t, 0);
790
791   if (dock && toolbar->parent != NULL)
792     {
793       gtk_container_remove (GTK_CONTAINER (dock), toolbar);
794     }
795 }
796
797 static void
798 update_fixed (EggEditableToolbar *t)
799 {
800   GtkWidget *toolbar, *dock;
801   if (!t->priv->fixed_toolbar) return;
802
803   toolbar = t->priv->fixed_toolbar;
804   dock = get_dock_nth (t, 0);
805
806   if (dock && toolbar && toolbar->parent == NULL)
807     {
808       gtk_box_pack_end (GTK_BOX (dock), toolbar, FALSE, TRUE, 0);
809
810       gtk_widget_show (toolbar);
811   
812       gtk_widget_set_size_request (dock, -1, -1);
813       gtk_widget_queue_resize_no_redraw (dock);
814     }
815 }
816
817 static void
818 toolbar_added_cb (EggToolbarsModel   *model,
819                   int                 position,
820                   EggEditableToolbar *t)
821 {
822   GtkWidget *dock;
823
824   dock = create_dock (t);
825
826   gtk_widget_set_size_request (dock, -1, MIN_TOOLBAR_HEIGHT);
827
828   gtk_box_pack_start (GTK_BOX (t), dock, TRUE, TRUE, 0);
829
830   gtk_box_reorder_child (GTK_BOX (t), dock, position);
831
832   gtk_widget_show_all (dock);
833   
834   update_fixed (t);
835 }
836
837 static void
838 toolbar_removed_cb (EggToolbarsModel   *model,
839                     int                 position,
840                     EggEditableToolbar *t)
841 {
842   GtkWidget *toolbar;
843
844   if (position == 0 && t->priv->fixed_toolbar != NULL)
845     {
846       unparent_fixed (t);
847     }
848
849   toolbar = get_dock_nth (t, position);
850   gtk_widget_destroy (toolbar);
851
852   update_fixed (t);
853 }
854
855 static void
856 item_added_cb (EggToolbarsModel   *model,
857                int                 toolbar_position,
858                int                 position,
859                EggEditableToolbar *t)
860 {
861   GtkWidget *dock;
862   GtkWidget *toolbar;
863   GtkWidget *item;
864   GtkAction *action;
865
866   toolbar = get_toolbar_nth (t, toolbar_position);
867   item = create_item (t, model, toolbar_position, position, &action);
868   gtk_toolbar_insert (GTK_TOOLBAR (toolbar),
869                       GTK_TOOL_ITEM (item), position);
870
871   dock = get_dock_nth (t, toolbar_position);
872   gtk_widget_set_size_request (dock, -1, -1);
873   gtk_widget_queue_resize_no_redraw (dock);
874
875   /* FIXME Hack to make tooltip work from gtk */
876   if (action)
877     {
878       g_object_notify (G_OBJECT (action), "tooltip");
879     }
880 }
881
882 static void
883 item_removed_cb (EggToolbarsModel   *model,
884                  int                 toolbar_position,
885                  int                 position,
886                  EggEditableToolbar *t)
887 {
888   GtkWidget *toolbar;
889   GtkWidget *item;
890
891   toolbar = get_toolbar_nth (t, toolbar_position);
892   item = GTK_WIDGET (gtk_toolbar_get_nth_item
893         (GTK_TOOLBAR (toolbar), position));
894   g_return_if_fail (item != NULL);
895   gtk_container_remove (GTK_CONTAINER (toolbar), item);
896
897   if (egg_toolbars_model_n_items (model, toolbar_position) == 0)
898     {
899       egg_toolbars_model_remove_toolbar (model, toolbar_position);
900     }
901 }
902
903 static void
904 egg_editable_toolbar_construct (EggEditableToolbar *t)
905 {
906   int i, l, n_items, n_toolbars;
907   EggToolbarsModel *model = t->priv->model;
908
909   g_return_if_fail (model != NULL);
910   g_return_if_fail (t->priv->manager != NULL);
911
912   n_toolbars = egg_toolbars_model_n_toolbars (model);
913
914   for (i = 0; i < n_toolbars; i++)
915     {
916       GtkWidget *toolbar, *dock;
917
918       dock = create_dock (t);
919       gtk_box_pack_start (GTK_BOX (t), dock, TRUE, TRUE, 0);
920       toolbar = get_toolbar_nth (t, i);
921
922       n_items = egg_toolbars_model_n_items (model, i);
923       for (l = 0; l < n_items; l++)
924         {
925           GtkWidget *item;
926           GtkAction *action;
927
928           item = create_item (t, model, i, l, &action);
929           if (item)
930             {
931               gtk_toolbar_insert (GTK_TOOLBAR (toolbar),
932                                   GTK_TOOL_ITEM (item), l);
933               /* FIXME Hack to make tooltip work from gtk */
934               if (action)
935                 {
936                   g_object_notify (G_OBJECT (action), "tooltip");
937                 }
938             }
939           else
940             {
941               egg_toolbars_model_remove_item (model, i, l);
942               l--;
943               n_items--;
944             }
945         }
946
947       if (n_items == 0)
948         {
949             gtk_widget_set_size_request (dock, -1, MIN_TOOLBAR_HEIGHT);
950         }
951     }
952
953   update_fixed (t);
954
955   /* apply styles */
956   for (i = 0; i < n_toolbars; i ++)
957     {
958       toolbar_changed_cb (model, i, t);
959     }
960 }
961
962 static void
963 egg_editable_toolbar_disconnect_model (EggEditableToolbar *toolbar)
964 {
965   EggToolbarsModel *model = toolbar->priv->model;
966
967   g_signal_handlers_disconnect_by_func
968     (model, G_CALLBACK (item_added_cb), toolbar);
969   g_signal_handlers_disconnect_by_func
970     (model, G_CALLBACK (item_removed_cb), toolbar);
971   g_signal_handlers_disconnect_by_func
972     (model, G_CALLBACK (toolbar_added_cb), toolbar);
973   g_signal_handlers_disconnect_by_func
974     (model, G_CALLBACK (toolbar_removed_cb), toolbar);
975   g_signal_handlers_disconnect_by_func
976     (model, G_CALLBACK (toolbar_changed_cb), toolbar);
977 }
978
979 static void
980 egg_editable_toolbar_deconstruct (EggEditableToolbar *toolbar)
981 {
982   EggToolbarsModel *model = toolbar->priv->model;
983   GList *children;
984
985   g_return_if_fail (model != NULL);
986
987   if (toolbar->priv->fixed_toolbar)
988     {
989        unset_fixed_style (toolbar);
990        unparent_fixed (toolbar);
991     }
992
993   children = gtk_container_get_children (GTK_CONTAINER (toolbar));
994   g_list_foreach (children, (GFunc) gtk_widget_destroy, NULL);
995   g_list_free (children);
996 }
997
998 void
999 egg_editable_toolbar_set_model (EggEditableToolbar *toolbar,
1000                                 EggToolbarsModel   *model)
1001 {
1002   g_return_if_fail (EGG_IS_TOOLBARS_MODEL (model));
1003   g_return_if_fail (EGG_IS_EDITABLE_TOOLBAR (toolbar));
1004   g_return_if_fail (toolbar->priv->manager);
1005
1006   if (toolbar->priv->model == model) return;
1007
1008   if (toolbar->priv->model)
1009     {
1010       egg_editable_toolbar_disconnect_model (toolbar);
1011       egg_editable_toolbar_deconstruct (toolbar);
1012
1013       g_object_unref (toolbar->priv->model);
1014     }
1015
1016   toolbar->priv->model = g_object_ref (model);
1017
1018   egg_editable_toolbar_construct (toolbar);
1019
1020   g_signal_connect (model, "item_added",
1021                     G_CALLBACK (item_added_cb), toolbar);
1022   g_signal_connect (model, "item_removed",
1023                     G_CALLBACK (item_removed_cb), toolbar);
1024   g_signal_connect (model, "toolbar_added",
1025                     G_CALLBACK (toolbar_added_cb), toolbar);
1026   g_signal_connect (model, "toolbar_removed",
1027                     G_CALLBACK (toolbar_removed_cb), toolbar);
1028   g_signal_connect (model, "toolbar_changed",
1029                     G_CALLBACK (toolbar_changed_cb), toolbar);
1030 }
1031
1032 static void
1033 egg_editable_toolbar_set_ui_manager (EggEditableToolbar *t,
1034                                      GtkUIManager       *manager)
1035 {
1036   g_return_if_fail (GTK_IS_UI_MANAGER (manager));
1037
1038   t->priv->manager = g_object_ref (manager);
1039 }
1040
1041 static void
1042 egg_editable_toolbar_set_property (GObject      *object,
1043                                    guint         prop_id,
1044                                    const GValue *value,
1045                                    GParamSpec   *pspec)
1046 {
1047   EggEditableToolbar *t = EGG_EDITABLE_TOOLBAR (object);
1048
1049   switch (prop_id)
1050     {
1051     case PROP_UI_MANAGER:
1052       egg_editable_toolbar_set_ui_manager (t, g_value_get_object (value));
1053       break;
1054     case PROP_TOOLBARS_MODEL:
1055       egg_editable_toolbar_set_model (t, g_value_get_object (value));
1056       break;
1057     default:
1058       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1059       break;
1060     }
1061 }
1062
1063 static void
1064 egg_editable_toolbar_get_property (GObject    *object,
1065                                    guint       prop_id,
1066                                    GValue     *value,
1067                                    GParamSpec *pspec)
1068 {
1069   EggEditableToolbar *t = EGG_EDITABLE_TOOLBAR (object);
1070
1071   switch (prop_id)
1072     {
1073     case PROP_UI_MANAGER:
1074       g_value_set_object (value, t->priv->manager);
1075       break;
1076     case PROP_TOOLBARS_MODEL:
1077       g_value_set_object (value, t->priv->model);
1078       break;
1079     default:
1080       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1081       break;
1082     }
1083 }
1084
1085 static void
1086 egg_editable_toolbar_class_init (EggEditableToolbarClass *klass)
1087 {
1088   GObjectClass *object_class = G_OBJECT_CLASS (klass);
1089
1090   parent_class = g_type_class_peek_parent (klass);
1091
1092   object_class->finalize = egg_editable_toolbar_finalize;
1093   object_class->set_property = egg_editable_toolbar_set_property;
1094   object_class->get_property = egg_editable_toolbar_get_property;
1095
1096   egg_editable_toolbar_signals[ACTION_REQUEST] =
1097     g_signal_new ("action_request",
1098                   G_OBJECT_CLASS_TYPE (object_class),
1099                   G_SIGNAL_RUN_LAST,
1100                   G_STRUCT_OFFSET (EggEditableToolbarClass, action_request),
1101                   NULL, NULL, g_cclosure_marshal_VOID__STRING,
1102                   G_TYPE_NONE, 1, G_TYPE_STRING);
1103
1104   g_object_class_install_property (object_class,
1105                                    PROP_UI_MANAGER,
1106                                    g_param_spec_object ("ui-manager",
1107                                                         "UI-Mmanager",
1108                                                         "UI Manager",
1109                                                         GTK_TYPE_UI_MANAGER,
1110                                                         G_PARAM_READWRITE));
1111   g_object_class_install_property (object_class,
1112                                    PROP_TOOLBARS_MODEL,
1113                                    g_param_spec_object ("model",
1114                                                         "Model",
1115                                                         "Toolbars Model",
1116                                                         EGG_TYPE_TOOLBARS_MODEL,
1117                                                         G_PARAM_READWRITE));
1118
1119   g_type_class_add_private (object_class, sizeof (EggEditableToolbarPrivate));
1120 }
1121
1122 static void
1123 egg_editable_toolbar_init (EggEditableToolbar *t)
1124 {
1125   t->priv = EGG_EDITABLE_TOOLBAR_GET_PRIVATE (t);
1126 }
1127
1128 static void
1129 egg_editable_toolbar_finalize (GObject *object)
1130 {
1131   EggEditableToolbar *t = EGG_EDITABLE_TOOLBAR (object);
1132
1133   if (t->priv->fixed_toolbar)
1134     {
1135       g_object_unref (t->priv->fixed_toolbar);
1136     }
1137
1138   if (t->priv->manager)
1139     {
1140       g_object_unref (t->priv->manager);
1141     }
1142
1143   if (t->priv->model)
1144     {
1145       egg_editable_toolbar_disconnect_model (t);
1146       g_object_unref (t->priv->model);
1147     }
1148
1149   G_OBJECT_CLASS (parent_class)->finalize (object);
1150 }
1151
1152 GtkWidget *
1153 egg_editable_toolbar_new (GtkUIManager     *manager)
1154 {
1155   return GTK_WIDGET (g_object_new (EGG_TYPE_EDITABLE_TOOLBAR,
1156                                    "ui-manager", manager,
1157                                    NULL));
1158 }
1159
1160 GtkWidget *
1161 egg_editable_toolbar_new_with_model (GtkUIManager     *manager,
1162                                      EggToolbarsModel *model)
1163 {
1164   return GTK_WIDGET (g_object_new (EGG_TYPE_EDITABLE_TOOLBAR,
1165                                    "ui-manager", manager,
1166                                    "model", model,
1167                                    NULL));
1168 }
1169
1170 gboolean
1171 egg_editable_toolbar_get_edit_mode (EggEditableToolbar *etoolbar)
1172 {
1173         return etoolbar->priv->edit_mode;
1174 }
1175
1176 void
1177 egg_editable_toolbar_set_edit_mode (EggEditableToolbar *etoolbar,
1178                                     gboolean            mode)
1179 {
1180   int i, l, n_toolbars, n_items;
1181
1182   etoolbar->priv->edit_mode = mode;
1183
1184   n_toolbars = get_n_toolbars (etoolbar);
1185   for (i = 0; i < n_toolbars; i++)
1186     {
1187       GtkWidget *toolbar;
1188
1189       toolbar = get_toolbar_nth (etoolbar, i);
1190       n_items = gtk_toolbar_get_n_items (GTK_TOOLBAR (toolbar));
1191       for (l = 0; l < n_items; l++)
1192         {
1193           GtkToolItem *item;
1194           const char *action_name, *type;
1195           gboolean is_separator;
1196           GtkAction *action = NULL;
1197
1198           egg_toolbars_model_item_nth (etoolbar->priv->model, i, l,
1199                                        &is_separator, &action_name, &type);
1200           action = find_action (etoolbar, action_name);
1201
1202           item = gtk_toolbar_get_nth_item (GTK_TOOLBAR (toolbar), l);
1203           gtk_tool_item_set_use_drag_window (item, mode);
1204
1205           if (mode)
1206             {
1207               set_drag_cursor (GTK_WIDGET (item));
1208               gtk_widget_set_sensitive (GTK_WIDGET (item), TRUE);
1209               set_item_drag_source (etoolbar->priv->model, GTK_WIDGET (item),
1210                                     action, is_separator, type);
1211             }
1212           else
1213             {
1214               unset_drag_cursor (GTK_WIDGET (item));
1215               gtk_drag_source_unset (GTK_WIDGET (item));
1216
1217               if (!is_separator)
1218                 {
1219                   g_object_notify (G_OBJECT (action), "sensitive");
1220                 }
1221             }
1222         }
1223     }
1224 }
1225
1226 void
1227 egg_editable_toolbar_show (EggEditableToolbar *etoolbar,
1228                            const char         *name)
1229 {
1230   int i, n_toolbars;
1231   EggToolbarsModel *model = etoolbar->priv->model;
1232
1233   g_return_if_fail (model != NULL);
1234
1235   n_toolbars = egg_toolbars_model_n_toolbars (model);
1236   for (i = 0; i < n_toolbars; i++)
1237     {
1238       const char *toolbar_name;
1239
1240       toolbar_name = egg_toolbars_model_toolbar_nth (model, i);
1241       if (strcmp (toolbar_name, name) == 0)
1242       {
1243         gtk_widget_show (get_dock_nth (etoolbar, i));
1244       }
1245     }
1246 }
1247
1248 void
1249 egg_editable_toolbar_hide (EggEditableToolbar *etoolbar,
1250                            const char         *name)
1251 {
1252   int i, n_toolbars;
1253   EggToolbarsModel *model = etoolbar->priv->model;
1254
1255   g_return_if_fail (model != NULL);
1256
1257   n_toolbars = egg_toolbars_model_n_toolbars (model);
1258   for (i = 0; i < n_toolbars; i++)
1259     {
1260       const char *toolbar_name;
1261
1262       toolbar_name = egg_toolbars_model_toolbar_nth (model, i);
1263       if (strcmp (toolbar_name, name) == 0)
1264       {
1265         gtk_widget_hide (get_dock_nth (etoolbar, i));
1266       }
1267     }
1268 }
1269
1270 void
1271 egg_editable_toolbar_set_fixed (EggEditableToolbar *toolbar,
1272                                 GtkToolbar         *fixed_toolbar)
1273 {
1274   g_return_if_fail (EGG_IS_EDITABLE_TOOLBAR (toolbar));
1275   g_return_if_fail (!fixed_toolbar || GTK_IS_TOOLBAR (fixed_toolbar));
1276
1277   if (toolbar->priv->fixed_toolbar)
1278     {
1279       unparent_fixed (toolbar);
1280       g_object_unref (toolbar->priv->fixed_toolbar);
1281       toolbar->priv->fixed_toolbar = NULL;
1282     }
1283
1284   if (fixed_toolbar)
1285     {
1286       toolbar->priv->fixed_toolbar = GTK_WIDGET (fixed_toolbar);
1287       gtk_toolbar_set_show_arrow (fixed_toolbar, FALSE);
1288       g_object_ref (fixed_toolbar);
1289       gtk_object_sink (GTK_OBJECT (fixed_toolbar));
1290     }
1291
1292   update_fixed (toolbar);
1293 }
1294
1295 void
1296 egg_editable_toolbar_set_drag_dest (EggEditableToolbar   *etoolbar,
1297                                     const GtkTargetEntry *targets,
1298                                     gint                  n_targets,
1299                                     const char           *toolbar_name)
1300 {
1301   int i, n_toolbars;
1302   EggToolbarsModel *model = etoolbar->priv->model;
1303
1304   g_return_if_fail (model != NULL);
1305
1306   n_toolbars = egg_toolbars_model_n_toolbars (model);
1307   for (i = 0; i < n_toolbars; i++)
1308     {
1309       const char *name;
1310
1311       name = egg_toolbars_model_toolbar_nth (model, i);
1312       if (strcmp (toolbar_name, name) == 0)
1313       {
1314         GtkWidget *widget = get_toolbar_nth (etoolbar, i);
1315
1316         gtk_drag_dest_unset (widget);
1317         gtk_drag_dest_set (widget, 0,
1318                            targets, n_targets,
1319                            GDK_ACTION_MOVE | GDK_ACTION_COPY);
1320       }
1321     }
1322 }
1323
1324 #define DEFAULT_ICON_HEIGHT 20
1325 #define DEFAULT_ICON_WIDTH 0
1326
1327 static void
1328 fake_expose_widget (GtkWidget *widget,
1329                     GdkPixmap *pixmap)
1330 {
1331   GdkWindow *tmp_window;
1332   GdkEventExpose event;
1333
1334   event.type = GDK_EXPOSE;
1335   event.window = pixmap;
1336   event.send_event = FALSE;
1337   event.area = widget->allocation;
1338   event.region = NULL;
1339   event.count = 0;
1340
1341   tmp_window = widget->window;
1342   widget->window = pixmap;
1343   gtk_widget_send_expose (widget, (GdkEvent *) &event);
1344   widget->window = tmp_window;
1345 }
1346
1347 /* We should probably experiment some more with this.
1348  * Right now the rendered icon is pretty good for most
1349  * themes. However, the icon is slightly large for themes
1350  * with large toolbar icons.
1351  */
1352 static GdkPixbuf *
1353 new_pixbuf_from_widget (GtkWidget *widget)
1354 {
1355   GtkWidget *window;
1356   GdkPixbuf *pixbuf;
1357   GtkRequisition requisition;
1358   GtkAllocation allocation;
1359   GdkPixmap *pixmap;
1360   GdkVisual *visual;
1361   gint icon_width;
1362   gint icon_height;
1363
1364   icon_width = DEFAULT_ICON_WIDTH;
1365
1366   if (!gtk_icon_size_lookup_for_settings (gtk_settings_get_default (), 
1367                                           GTK_ICON_SIZE_LARGE_TOOLBAR,
1368                                           NULL, 
1369                                           &icon_height))
1370     {
1371       icon_height = DEFAULT_ICON_HEIGHT;
1372     }
1373
1374   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
1375   
1376   gtk_container_add (GTK_CONTAINER (window), widget);
1377   gtk_widget_realize (window);
1378   gtk_widget_show (widget);
1379   gtk_widget_realize (widget);
1380   gtk_widget_map (widget);
1381
1382   /* Gtk will never set the width or height of a window to 0. So setting the width to
1383    * 0 and than getting it will provide us with the minimum width needed to render
1384    * the icon correctly, without any additional window background noise.
1385    * This is needed mostly for pixmap based themes.
1386    */
1387   gtk_window_set_default_size (GTK_WINDOW (window), icon_width, icon_height);
1388   gtk_window_get_size (GTK_WINDOW (window),&icon_width, &icon_height);
1389
1390   gtk_widget_size_request (window, &requisition);
1391   allocation.x = 0;
1392   allocation.y = 0;
1393   allocation.width = icon_width;
1394   allocation.height = icon_height;
1395   gtk_widget_size_allocate (window, &allocation);
1396   gtk_widget_size_request (window, &requisition);
1397   
1398   /* Create a pixmap */
1399   visual = gtk_widget_get_visual (window);
1400   pixmap = gdk_pixmap_new (NULL, icon_width, icon_height, visual->depth);
1401   gdk_drawable_set_colormap (GDK_DRAWABLE (pixmap), gtk_widget_get_colormap (window));
1402
1403   /* Draw the window */
1404   gtk_widget_ensure_style (window);
1405   g_assert (window->style);
1406   g_assert (window->style->font_desc);
1407   
1408   fake_expose_widget (window, pixmap);
1409   fake_expose_widget (widget, pixmap);
1410   
1411   pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, icon_width, icon_height);
1412   gdk_pixbuf_get_from_drawable (pixbuf, pixmap, NULL, 0, 0, 0, 0, icon_width, icon_height);
1413
1414   return pixbuf;
1415 }
1416
1417 static GdkPixbuf *
1418 new_separator_pixbuf ()
1419 {
1420   GtkWidget *separator;
1421   GdkPixbuf *pixbuf;
1422
1423   separator = gtk_vseparator_new ();
1424   pixbuf = new_pixbuf_from_widget (separator);
1425   gtk_widget_destroy (separator);
1426   return pixbuf;
1427 }
1428
1429 static void
1430 update_separator_image (GtkImage *image)
1431 {
1432   GdkPixbuf *pixbuf = new_separator_pixbuf ();
1433   gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf);
1434   g_object_unref (pixbuf);
1435 }
1436
1437 static gboolean
1438 style_set_cb (GtkWidget *widget,
1439               GtkStyle *previous_style,
1440               GtkImage *image)
1441 {
1442
1443   update_separator_image (image);
1444   return FALSE;
1445 }
1446
1447 GtkWidget *
1448 _egg_editable_toolbar_new_separator_image (void)
1449 {
1450   GtkWidget *image = gtk_image_new ();
1451   update_separator_image (GTK_IMAGE (image));
1452   g_signal_connect (G_OBJECT (image), "style_set",
1453                     G_CALLBACK (style_set_cb), GTK_IMAGE (image));
1454
1455   return image;
1456 }
1457
1458 EggToolbarsModel *
1459 egg_editable_toolbar_get_model (EggEditableToolbar *etoolbar)
1460 {
1461   return etoolbar->priv->model;
1462 }