diff options
author | Marco Pesenti Gritti <marco@gnome.org> | 2003-10-27 16:13:36 +0800 |
---|---|---|
committer | Marco Pesenti Gritti <marco@src.gnome.org> | 2003-10-27 16:13:36 +0800 |
commit | 32ccc668ac8e87ec9dd67b9d594a7fcf89381776 (patch) | |
tree | f8a4d9cd11393f1a3589f04c2363e4cd6b9d4093 /lib | |
parent | 36dc5ffa3ccd419fa87677829f7e49556528ccb1 (diff) | |
download | gsoc2013-epiphany-32ccc668ac8e87ec9dd67b9d594a7fcf89381776.tar.gz gsoc2013-epiphany-32ccc668ac8e87ec9dd67b9d594a7fcf89381776.tar.zst gsoc2013-epiphany-32ccc668ac8e87ec9dd67b9d594a7fcf89381776.zip |
Fixup spinner when resetting the toolbar model. Update spinner on toolbar
2003-10-27 Marco Pesenti Gritti <marco@gnome.org>
* lib/egg/egg-editable-toolbar.c: (create_dock), (set_fixed_style),
(unset_fixed_style), (toolbar_changed_cb), (unparent_fixed),
(update_fixed), (toolbar_removed_cb), (toolbars_clean),
(egg_editable_toolbar_construct), (egg_editable_toolbar_init),
(egg_editable_toolbar_finalize), (egg_editable_toolbar_set_fixed):
* lib/egg/egg-editable-toolbar.h:
* src/toolbar.c: (toolbar_style_sync), (create_spinner),
(toolbar_init):
Fixup spinner when resetting the toolbar model.
Update spinner on toolbar style change.
Fix a typo in toolbars creation that wa causing fs toolbar
to be hidden.
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/egg/egg-editable-toolbar.c | 91 | ||||
-rwxr-xr-x | lib/egg/egg-editable-toolbar.h | 3 |
2 files changed, 67 insertions, 27 deletions
diff --git a/lib/egg/egg-editable-toolbar.c b/lib/egg/egg-editable-toolbar.c index ec1b1ede9..2e473fee0 100755 --- a/lib/egg/egg-editable-toolbar.c +++ b/lib/egg/egg-editable-toolbar.c @@ -75,7 +75,7 @@ struct EggEditableToolbarPrivate gboolean edit_mode; GtkWidget *selected_toolbar; GtkWidget *dragged_item; - GtkWidget *fixed; + GtkWidget *fixed_toolbar; }; GType @@ -578,14 +578,13 @@ create_dock (EggEditableToolbar *t) GtkWidget *toolbar, *hbox; hbox = gtk_hbox_new (0, FALSE); + gtk_widget_show (hbox); toolbar = gtk_toolbar_new (); gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar), TRUE); gtk_widget_show (toolbar); - gtk_box_pack_start (GTK_BOX (hbox), toolbar, TRUE, TRUE, 0); - gtk_widget_show (toolbar); gtk_drag_dest_set (toolbar, 0, dest_drag_types, n_dest_drag_types, GDK_ACTION_MOVE | GDK_ACTION_COPY); @@ -606,6 +605,18 @@ create_dock (EggEditableToolbar *t) } static void +set_fixed_style (EggEditableToolbar *t, GtkToolbarStyle style) +{ + gtk_toolbar_set_style (GTK_TOOLBAR (t->priv->fixed_toolbar), style); +} + +static void +unset_fixed_style (EggEditableToolbar *t) +{ + gtk_toolbar_unset_style (GTK_TOOLBAR (t->priv->fixed_toolbar)); +} + +static void toolbar_changed_cb (EggToolbarsModel *model, int position, EggEditableToolbar *t) @@ -619,26 +630,48 @@ toolbar_changed_cb (EggToolbarsModel *model, if (flags & EGG_TB_MODEL_ICONS_ONLY) { gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS); + if (position == 0) + { + set_fixed_style (t, GTK_TOOLBAR_ICONS); + } } else { gtk_toolbar_unset_style (GTK_TOOLBAR (toolbar)); + if (position == 0) + { + unset_fixed_style (t); + } } } static void -update_fixed (EggEditableToolbar *t) +unparent_fixed (EggEditableToolbar *t) { - GtkWidget *fixed, *dock; + GtkWidget *toolbar, *dock; - g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (t)); + toolbar = t->priv->fixed_toolbar; + dock = get_dock_nth (t, 0); - fixed = t->priv->fixed; + if (dock && toolbar->parent != NULL) + { + gtk_container_remove (GTK_CONTAINER (dock), toolbar); + } +} + +static void +update_fixed (EggEditableToolbar *t) +{ + GtkWidget *toolbar, *dock; + + toolbar = t->priv->fixed_toolbar; dock = get_dock_nth (t, 0); - if (dock && fixed && fixed->parent == NULL) + if (dock && toolbar && toolbar->parent == NULL) { - gtk_box_pack_end (GTK_BOX (dock), fixed, FALSE, TRUE, 0); + gtk_box_pack_end (GTK_BOX (dock), toolbar, FALSE, TRUE, 0); + + gtk_widget_show_all (toolbar); } } @@ -667,8 +700,8 @@ toolbar_removed_cb (EggToolbarsModel *model, { GtkWidget *toolbar; - toolbar = get_toolbar_nth (t, position); - gtk_widget_destroy (toolbar->parent); + toolbar = get_dock_nth (t, position); + gtk_widget_destroy (toolbar); update_fixed (t); } @@ -716,6 +749,9 @@ toolbars_clean (EggEditableToolbar *t) { GList *children, *l; + unset_fixed_style (t); + unparent_fixed (t); + children = gtk_container_get_children (GTK_CONTAINER (t)); for (l = children; l != NULL; l = l->next) @@ -749,6 +785,10 @@ egg_editable_toolbar_construct (EggEditableToolbar *t) if (flags & EGG_TB_MODEL_ICONS_ONLY) { gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS); + if (i == 0) + { + set_fixed_style (t, GTK_TOOLBAR_ICONS); + } } n_items = egg_toolbars_model_n_items (model, i); @@ -776,7 +816,7 @@ egg_editable_toolbar_construct (EggEditableToolbar *t) } } - update_fixed (t); + update_fixed (t); } static void @@ -903,7 +943,6 @@ egg_editable_toolbar_init (EggEditableToolbar *t) t->priv->merge = NULL; t->priv->edit_mode = FALSE; - t->priv->fixed = NULL; } static void @@ -914,9 +953,9 @@ egg_editable_toolbar_finalize (GObject *object) g_return_if_fail (object != NULL); g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (object)); - if (t->priv->fixed) + if (t->priv->fixed_toolbar) { - g_object_unref (t->priv->fixed); + g_object_unref (t->priv->fixed_toolbar); } g_free (t->priv); @@ -1033,25 +1072,25 @@ egg_editable_toolbar_hide (EggEditableToolbar *etoolbar, } } -void +GtkToolbar * egg_editable_toolbar_set_fixed (EggEditableToolbar *etoolbar, GtkWidget *fixed) { - GtkWidget *toolbar; - GtkToolItem *item; + GtkWidget *fixed_item; - toolbar = gtk_toolbar_new (); - gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar), FALSE); - gtk_widget_show (toolbar); + etoolbar->priv->fixed_toolbar = gtk_toolbar_new (); + gtk_toolbar_set_show_arrow (GTK_TOOLBAR (etoolbar->priv->fixed_toolbar), FALSE); + g_object_ref (etoolbar->priv->fixed_toolbar); - item = gtk_tool_item_new (); - gtk_widget_show (GTK_WIDGET (item)); - gtk_container_add (GTK_CONTAINER (item), fixed); + fixed_item = GTK_WIDGET (gtk_tool_item_new ()); + gtk_toolbar_insert (GTK_TOOLBAR (etoolbar->priv->fixed_toolbar), + GTK_TOOL_ITEM (fixed_item), 0); - gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, 0); - etoolbar->priv->fixed = g_object_ref (toolbar); + gtk_container_add (GTK_CONTAINER (fixed_item), fixed); update_fixed (etoolbar); + + return GTK_TOOLBAR (etoolbar->priv->fixed_toolbar); } void diff --git a/lib/egg/egg-editable-toolbar.h b/lib/egg/egg-editable-toolbar.h index e361b83c5..d332f482c 100755 --- a/lib/egg/egg-editable-toolbar.h +++ b/lib/egg/egg-editable-toolbar.h @@ -24,6 +24,7 @@ #include <gtk/gtkuimanager.h> #include <gtk/gtkselection.h> #include <gtk/gtkvbox.h> +#include <gtk/gtktoolbar.h> G_BEGIN_DECLS @@ -67,7 +68,7 @@ void egg_editable_toolbar_set_drag_dest (EggEditableToolbar *etoolbar, const GtkTargetEntry *targets, gint n_targets, const char *toolbar_name); -void egg_editable_toolbar_set_fixed (EggEditableToolbar *etoolbar, +GtkToolbar *egg_editable_toolbar_set_fixed (EggEditableToolbar *etoolbar, GtkWidget *fixed); |