diff options
-rw-r--r-- | ChangeLog | 16 | ||||
-rwxr-xr-x | lib/egg/egg-editable-toolbar.c | 91 | ||||
-rwxr-xr-x | lib/egg/egg-editable-toolbar.h | 3 | ||||
-rwxr-xr-x | src/toolbar.c | 35 |
4 files changed, 114 insertions, 31 deletions
@@ -1,3 +1,19 @@ +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. + 2003-10-26 Christian Persch <chpe@cvs.gnome.org> * lib/ephy-file-chooser.c: (current_folder_changed_cb), 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); diff --git a/src/toolbar.c b/src/toolbar.c index 77ec674c9..5ef026f72 100755 --- a/src/toolbar.c +++ b/src/toolbar.c @@ -523,6 +523,36 @@ toolbar_set_window (Toolbar *t, EphyWindow *window) } static void +toolbar_style_sync (GtkToolbar *toolbar, + GtkToolbarStyle style, + GtkWidget *spinner) +{ + gboolean small; + + small = (style != GTK_TOOLBAR_BOTH); + + ephy_spinner_set_small_mode (EPHY_SPINNER (spinner), small); +} + +static void +create_spinner (Toolbar *t) +{ + GtkWidget *spinner; + GtkToolbar *toolbar; + + spinner = ephy_spinner_new (); + gtk_widget_show (spinner); + t->priv->spinner = spinner; + + toolbar = egg_editable_toolbar_set_fixed + (EGG_EDITABLE_TOOLBAR (t), spinner); + + g_signal_connect (toolbar, "style_changed", + G_CALLBACK (toolbar_style_sync), + spinner); +} + +static void toolbar_init (Toolbar *t) { t->priv = EPHY_TOOLBAR_GET_PRIVATE (t); @@ -532,10 +562,7 @@ toolbar_init (Toolbar *t) t->priv->visibility = TRUE; t->priv->updating_address = FALSE; - t->priv->spinner = ephy_spinner_new (); - gtk_widget_show (t->priv->spinner); - egg_editable_toolbar_set_fixed (EGG_EDITABLE_TOOLBAR (t), - t->priv->spinner); + create_spinner (t); } static void |