diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2004-06-16 20:31:08 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2004-06-16 20:31:08 +0800 |
commit | e107b8c04820a45b8b4daca62e767cdfd8e62e23 (patch) | |
tree | 536c5f23466c16b391603b2634ca32f58fddbf6c | |
parent | a6c12b524b75382eb362e400df3b40c23bf24067 (diff) | |
download | gsoc2013-epiphany-e107b8c04820a45b8b4daca62e767cdfd8e62e23.tar gsoc2013-epiphany-e107b8c04820a45b8b4daca62e767cdfd8e62e23.tar.gz gsoc2013-epiphany-e107b8c04820a45b8b4daca62e767cdfd8e62e23.tar.bz2 gsoc2013-epiphany-e107b8c04820a45b8b4daca62e767cdfd8e62e23.tar.lz gsoc2013-epiphany-e107b8c04820a45b8b4daca62e767cdfd8e62e23.tar.xz gsoc2013-epiphany-e107b8c04820a45b8b4daca62e767cdfd8e62e23.tar.zst gsoc2013-epiphany-e107b8c04820a45b8b4daca62e767cdfd8e62e23.zip |
Go back to construction the toolbar when the model is set, fixes bug
2004-06-16 Christian Persch <chpe@cvs.gnome.org>
* lib/egg/egg-editable-toolbar.c:
(egg_editable_toolbar_disconnect_model),
(egg_editable_toolbar_deconstruct),
(egg_editable_toolbar_set_model),
(egg_editable_toolbar_class_init), (egg_editable_toolbar_finalize),
(egg_editable_toolbar_new), (egg_editable_toolbar_new_with_model),
(egg_editable_toolbar_set_fixed):
* lib/egg/egg-editable-toolbar.h:
* lib/egg/egg-toolbars-model.c: (egg_toolbars_model_get_flags),
(parse_toolbars):
* src/bookmarks/ephy-bookmarksbar.c:
(ephy_bookmarksbar_set_window), (ephy_bookmarksbar_class_init):
* src/ephy-window.c: (ephy_window_fullscreen),
(ephy_window_unfullscreen), (ephy_window_init):
* src/toolbar.c: (toolbar_style_changed_cb), (parent_set_cb),
(toolbar_init), (toolbar_finalize), (toolbar_new):
Go back to construction the toolbar when the model is set, fixes
bug #144191.
2004-06-15 Marco Pesenti Gritti <marco@gnome.org>
-rw-r--r-- | ChangeLog | 22 | ||||
-rwxr-xr-x | lib/egg/egg-editable-toolbar.c | 131 | ||||
-rwxr-xr-x | lib/egg/egg-editable-toolbar.h | 15 | ||||
-rw-r--r-- | src/bookmarks/ephy-bookmarksbar.c | 31 | ||||
-rw-r--r-- | src/ephy-window.c | 21 | ||||
-rwxr-xr-x | src/toolbar.c | 55 |
6 files changed, 159 insertions, 116 deletions
@@ -1,3 +1,25 @@ +2004-06-16 Christian Persch <chpe@cvs.gnome.org> + + * lib/egg/egg-editable-toolbar.c: + (egg_editable_toolbar_disconnect_model), + (egg_editable_toolbar_deconstruct), + (egg_editable_toolbar_set_model), + (egg_editable_toolbar_class_init), (egg_editable_toolbar_finalize), + (egg_editable_toolbar_new), (egg_editable_toolbar_new_with_model), + (egg_editable_toolbar_set_fixed): + * lib/egg/egg-editable-toolbar.h: + * lib/egg/egg-toolbars-model.c: (egg_toolbars_model_get_flags), + (parse_toolbars): + * src/bookmarks/ephy-bookmarksbar.c: + (ephy_bookmarksbar_set_window), (ephy_bookmarksbar_class_init): + * src/ephy-window.c: (ephy_window_fullscreen), + (ephy_window_unfullscreen), (ephy_window_init): + * src/toolbar.c: (toolbar_style_changed_cb), (parent_set_cb), + (toolbar_init), (toolbar_finalize), (toolbar_new): + + Go back to construction the toolbar when the model is set, fixes + bug #144191. + 2004-06-15 Marco Pesenti Gritti <marco@gnome.org> * data/bme.desktop.in: diff --git a/lib/egg/egg-editable-toolbar.c b/lib/egg/egg-editable-toolbar.c index 0b4ed7a45..1006a1e02 100755 --- a/lib/egg/egg-editable-toolbar.c +++ b/lib/egg/egg-editable-toolbar.c @@ -1,5 +1,6 @@ /* - * Copyright (C) 2003 Marco Pesenti Gritti + * Copyright (C) 2003-2004 Marco Pesenti Gritti + * Copyright (C) 2004 Christian Persch * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -78,6 +79,7 @@ struct EggEditableToolbarPrivate EggToolbarsModel *model; gboolean edit_mode; GtkWidget *selected_toolbar; + GtkToolItem *fixed; GtkWidget *fixed_toolbar; gboolean pending; @@ -949,38 +951,10 @@ egg_editable_toolbar_construct (EggEditableToolbar *t) } static void -egg_editable_toolbar_realize (GtkWidget *widget) +egg_editable_toolbar_disconnect_model (EggEditableToolbar *toolbar) { - EggEditableToolbar *toolbar = EGG_EDITABLE_TOOLBAR (widget); EggToolbarsModel *model = toolbar->priv->model; - GTK_WIDGET_CLASS (parent_class)->realize (widget); - - g_return_if_fail (model != NULL); - - egg_editable_toolbar_construct (toolbar); - - g_signal_connect (model, "item_added", - G_CALLBACK (item_added_cb), toolbar); - g_signal_connect (model, "item_removed", - G_CALLBACK (item_removed_cb), toolbar); - g_signal_connect (model, "toolbar_added", - G_CALLBACK (toolbar_added_cb), toolbar); - g_signal_connect (model, "toolbar_removed", - G_CALLBACK (toolbar_removed_cb), toolbar); - g_signal_connect (model, "toolbar_changed", - G_CALLBACK (toolbar_changed_cb), toolbar); -} - -static void -egg_editable_toolbar_unrealize (GtkWidget *widget) -{ - EggEditableToolbar *toolbar = EGG_EDITABLE_TOOLBAR (widget); - EggToolbarsModel *model = toolbar->priv->model; - GList *children, *l; - - g_return_if_fail (model != NULL); - g_signal_handlers_disconnect_by_func (model, G_CALLBACK (item_added_cb), toolbar); g_signal_handlers_disconnect_by_func @@ -991,6 +965,15 @@ egg_editable_toolbar_unrealize (GtkWidget *widget) (model, G_CALLBACK (toolbar_removed_cb), toolbar); g_signal_handlers_disconnect_by_func (model, G_CALLBACK (toolbar_changed_cb), toolbar); +} + +static void +egg_editable_toolbar_deconstruct (EggEditableToolbar *toolbar) +{ + EggToolbarsModel *model = toolbar->priv->model; + GList *children, *l; + + g_return_if_fail (model != NULL); if (toolbar->priv->fixed_toolbar) { @@ -1006,11 +989,9 @@ egg_editable_toolbar_unrealize (GtkWidget *widget) } g_list_free (children); - - GTK_WIDGET_CLASS (parent_class)->unrealize (widget); } -static void +void egg_editable_toolbar_set_model (EggEditableToolbar *toolbar, EggToolbarsModel *model) { @@ -1018,25 +999,32 @@ egg_editable_toolbar_set_model (EggEditableToolbar *toolbar, g_return_if_fail (EGG_IS_TOOLBARS_MODEL (model)); g_return_if_fail (EGG_IS_EDITABLE_TOOLBAR (toolbar)); + g_return_if_fail (toolbar->priv->merge); if (toolbar->priv->model == model) return; - if (GTK_WIDGET_VISIBLE (widget)) - { - gtk_widget_hide (widget); - } - - if(GTK_WIDGET_REALIZED (widget)) - { - gtk_widget_unrealize (widget); - } - if (toolbar->priv->model) { + egg_editable_toolbar_disconnect_model (toolbar); + egg_editable_toolbar_deconstruct (toolbar); + g_object_unref (toolbar->priv->model); } toolbar->priv->model = g_object_ref (model); + + egg_editable_toolbar_construct (toolbar); + + g_signal_connect (model, "item_added", + G_CALLBACK (item_added_cb), toolbar); + g_signal_connect (model, "item_removed", + G_CALLBACK (item_removed_cb), toolbar); + g_signal_connect (model, "toolbar_added", + G_CALLBACK (toolbar_added_cb), toolbar); + g_signal_connect (model, "toolbar_removed", + G_CALLBACK (toolbar_removed_cb), toolbar); + g_signal_connect (model, "toolbar_changed", + G_CALLBACK (toolbar_changed_cb), toolbar); } static void @@ -1097,7 +1085,6 @@ static void egg_editable_toolbar_class_init (EggEditableToolbarClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); parent_class = g_type_class_peek_parent (klass); @@ -1105,9 +1092,6 @@ egg_editable_toolbar_class_init (EggEditableToolbarClass *klass) object_class->set_property = egg_editable_toolbar_set_property; object_class->get_property = egg_editable_toolbar_get_property; - widget_class->realize = egg_editable_toolbar_realize; - widget_class->unrealize = egg_editable_toolbar_unrealize; - egg_editable_toolbar_signals[ACTION_REQUEST] = g_signal_new ("action_request", G_OBJECT_CLASS_TYPE (object_class), @@ -1157,6 +1141,7 @@ egg_editable_toolbar_finalize (GObject *object) if (t->priv->model) { + egg_editable_toolbar_disconnect_model (t); g_object_unref (t->priv->model); } @@ -1164,15 +1149,22 @@ egg_editable_toolbar_finalize (GObject *object) } GtkWidget * -egg_editable_toolbar_new (GtkUIManager *merge, - EggToolbarsModel *model) +egg_editable_toolbar_new (GtkUIManager *merge) { return GTK_WIDGET (g_object_new (EGG_TYPE_EDITABLE_TOOLBAR, - "ToolbarsModel", model, "MenuMerge", merge, NULL)); } +GtkWidget * +egg_editable_toolbar_new_with_model (GtkUIManager *merge, + EggToolbarsModel *model) +{ + return GTK_WIDGET (g_object_new (EGG_TYPE_EDITABLE_TOOLBAR, + "MenuMerge", merge, + "ToolbarsModel", model, + NULL)); +} gboolean egg_editable_toolbar_get_edit_mode (EggEditableToolbar *etoolbar) { @@ -1273,26 +1265,37 @@ egg_editable_toolbar_hide (EggEditableToolbar *etoolbar, } } -GtkToolbar * -egg_editable_toolbar_set_fixed (EggEditableToolbar *etoolbar, - GtkWidget *fixed) +void +egg_editable_toolbar_set_fixed (EggEditableToolbar *toolbar, + GtkToolItem *fixed) { - GtkWidget *fixed_item; + g_return_if_fail (EGG_IS_EDITABLE_TOOLBAR (toolbar)); + g_return_if_fail (!fixed || GTK_IS_TOOL_ITEM (fixed)); - 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); - gtk_object_sink (GTK_OBJECT (etoolbar->priv->fixed_toolbar)); + if (!toolbar->priv->fixed_toolbar) + { + toolbar->priv->fixed_toolbar = gtk_toolbar_new (); + gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar->priv->fixed_toolbar), FALSE); + g_object_ref (toolbar->priv->fixed_toolbar); + gtk_object_sink (GTK_OBJECT (toolbar->priv->fixed_toolbar)); + } - fixed_item = GTK_WIDGET (gtk_tool_item_new ()); - gtk_toolbar_insert (GTK_TOOLBAR (etoolbar->priv->fixed_toolbar), - GTK_TOOL_ITEM (fixed_item), 0); + if (toolbar->priv->fixed) + { + gtk_container_remove (GTK_CONTAINER (toolbar->priv->fixed_toolbar), + GTK_WIDGET (toolbar->priv->fixed)); + g_object_unref (toolbar->priv->fixed); + } - gtk_container_add (GTK_CONTAINER (fixed_item), fixed); + toolbar->priv->fixed = fixed; - update_fixed (etoolbar); + if (fixed) + { + g_object_ref (fixed); + gtk_object_sink (GTK_OBJECT (fixed)); - return GTK_TOOLBAR (etoolbar->priv->fixed_toolbar); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar->priv->fixed_toolbar), fixed, 0); + } } void diff --git a/lib/egg/egg-editable-toolbar.h b/lib/egg/egg-editable-toolbar.h index 0e5b72cd9..d0dfb9811 100755 --- a/lib/egg/egg-editable-toolbar.h +++ b/lib/egg/egg-editable-toolbar.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2003 Marco Pesenti Gritti + * Copyright (C) 2003-2004 Marco Pesenti Gritti + * Copyright (C) 2004 Christian Persch * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,6 +15,8 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ */ #ifndef EGG_EDITABLE_TOOLBAR_H @@ -24,6 +27,7 @@ #include <gtk/gtkuimanager.h> #include <gtk/gtkselection.h> #include <gtk/gtkvbox.h> +#include <gtk/gtktoolitem.h> #include <gtk/gtktoolbar.h> G_BEGIN_DECLS @@ -58,7 +62,10 @@ struct EggEditableToolbarClass }; GType egg_editable_toolbar_get_type (void); -GtkWidget *egg_editable_toolbar_new (GtkUIManager *merge, +GtkWidget *egg_editable_toolbar_new (GtkUIManager *merge); +GtkWidget *egg_editable_toolbar_new_with_model (GtkUIManager *merge, + EggToolbarsModel *model); +void egg_editable_toolbar_set_model (EggEditableToolbar *etoolbar, EggToolbarsModel *model); EggToolbarsModel *egg_editable_toolbar_get_model (EggEditableToolbar *etoolbar); void egg_editable_toolbar_set_edit_mode (EggEditableToolbar *etoolbar, @@ -72,8 +79,8 @@ void egg_editable_toolbar_set_drag_dest (EggEditableToolbar *etoolbar, const GtkTargetEntry *targets, gint n_targets, const char *toolbar_name); -GtkToolbar *egg_editable_toolbar_set_fixed (EggEditableToolbar *etoolbar, - GtkWidget *fixed); +void egg_editable_toolbar_set_fixed (EggEditableToolbar *etoolbar, + GtkToolItem *fixed); /* Private Functions */ diff --git a/src/bookmarks/ephy-bookmarksbar.c b/src/bookmarks/ephy-bookmarksbar.c index 511b635fa..1d666c0c4 100644 --- a/src/bookmarks/ephy-bookmarksbar.c +++ b/src/bookmarks/ephy-bookmarksbar.c @@ -274,10 +274,12 @@ toolbar_added_cb (EggToolbarsModel *model, static void ephy_bookmarksbar_set_window (EphyBookmarksBar *toolbar, - EphyWindow *window) + EphyWindow *window) { + EggEditableToolbar *eggtoolbar = EGG_EDITABLE_TOOLBAR (toolbar); EggToolbarsModel *model = toolbar->priv->toolbars_model; GtkUIManager *manager = GTK_UI_MANAGER (window->ui_merge); + int i, n_toolbars; g_return_if_fail (toolbar->priv->window == NULL); g_return_if_fail (model != NULL); @@ -294,17 +296,6 @@ ephy_bookmarksbar_set_window (EphyBookmarksBar *toolbar, "MenuMerge", manager, "ToolbarsModel", model, NULL); -} - -static void -ephy_bookmarksbar_realize (GtkWidget *widget) -{ - EggEditableToolbar *eggtoolbar = EGG_EDITABLE_TOOLBAR (widget); - EphyBookmarksBar *toolbar = EPHY_BOOKMARKSBAR (widget); - EggToolbarsModel *model = toolbar->priv->toolbars_model; - int i, n_toolbars; - - GTK_WIDGET_CLASS (parent_class)->realize (widget); g_signal_connect (model, "toolbar_added", G_CALLBACK (toolbar_added_cb), toolbar); @@ -324,18 +315,6 @@ ephy_bookmarksbar_realize (GtkWidget *widget) } static void -ephy_bookmarksbar_unrealize (GtkWidget *widget) -{ - EphyBookmarksBar *toolbar = EPHY_BOOKMARKSBAR (widget); - EggToolbarsModel *model = toolbar->priv->toolbars_model; - - g_signal_handlers_disconnect_by_func - (model, G_CALLBACK (toolbar_added_cb), toolbar); - - GTK_WIDGET_CLASS (parent_class)->unrealize (widget); -} - -static void ephy_bookmarksbar_init (EphyBookmarksBar *toolbar) { toolbar->priv = EPHY_BOOKMARKSBAR_GET_PRIVATE (toolbar); @@ -393,7 +372,6 @@ static void ephy_bookmarksbar_class_init (EphyBookmarksBarClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); EggEditableToolbarClass *eet_class = EGG_EDITABLE_TOOLBAR_CLASS (klass); parent_class = g_type_class_peek_parent (klass); @@ -402,9 +380,6 @@ ephy_bookmarksbar_class_init (EphyBookmarksBarClass *klass) object_class->set_property = ephy_bookmarksbar_set_property; object_class->get_property = ephy_bookmarksbar_get_property; - widget_class->realize = ephy_bookmarksbar_realize; - widget_class->unrealize = ephy_bookmarksbar_unrealize; - eet_class->action_request = ephy_bookmarksbar_action_request; g_object_class_install_property (object_class, diff --git a/src/ephy-window.c b/src/ephy-window.c index 9de3366ae..49c177f7a 100644 --- a/src/ephy-window.c +++ b/src/ephy-window.c @@ -547,8 +547,10 @@ ephy_window_fullscreen (EphyWindow *window) "size-changed", G_CALLBACK (size_changed_cb), window); - g_object_set (G_OBJECT (window->priv->toolbar), "ToolbarsModel", - ephy_shell_get_toolbars_model (ephy_shell, TRUE), NULL); + egg_editable_toolbar_set_model + (EGG_EDITABLE_TOOLBAR (window->priv->toolbar), + EGG_TOOLBARS_MODEL ( + ephy_shell_get_toolbars_model (ephy_shell, TRUE))); sync_chromes_visibility (window); } @@ -565,8 +567,10 @@ ephy_window_unfullscreen (EphyWindow *window) gtk_widget_destroy (window->priv->exit_fullscreen_popup); window->priv->exit_fullscreen_popup = NULL; - g_object_set (G_OBJECT (window->priv->toolbar), "ToolbarsModel", - ephy_shell_get_toolbars_model (ephy_shell, FALSE), NULL); + egg_editable_toolbar_set_model + (EGG_EDITABLE_TOOLBAR (window->priv->toolbar), + EGG_TOOLBARS_MODEL ( + ephy_shell_get_toolbars_model (ephy_shell, FALSE))); sync_chromes_visibility (window); } @@ -1988,6 +1992,15 @@ ephy_window_init (EphyWindow *window) manager = EPHY_EXTENSION (ephy_shell_get_extensions_manager (ephy_shell)); ephy_extension_attach_window (manager, window); + /* We only set the model now after attaching the extensions, so that + * extensions already have created their actions which may be on + * the toolbar + */ + egg_editable_toolbar_set_model + (EGG_EDITABLE_TOOLBAR (window->priv->toolbar), + EGG_TOOLBARS_MODEL + (ephy_shell_get_toolbars_model (ephy_shell, FALSE))); + g_signal_connect (window, "window-state-event", G_CALLBACK (ephy_window_state_event_cb), window); diff --git a/src/toolbar.c b/src/toolbar.c index d2a0d79e5..cf6596f32 100755 --- a/src/toolbar.c +++ b/src/toolbar.c @@ -399,9 +399,9 @@ toolbar_set_window (Toolbar *t, EphyWindow *window) } static void -toolbar_style_sync (GtkToolbar *toolbar, - GtkToolbarStyle style, - GtkWidget *spinner) +toolbar_style_changed_cb (GtkToolbar *toolbar, + GtkToolbarStyle style, + GtkWidget *spinner) { gboolean small; @@ -411,29 +411,51 @@ toolbar_style_sync (GtkToolbar *toolbar, } static void -create_spinner (Toolbar *t) +parent_set_cb (GtkWidget *item, + GtkObject *old_parent, + GtkWidget *spinner) { - GtkWidget *spinner; - GtkToolbar *toolbar; + if (old_parent != NULL) + { + g_return_if_fail (GTK_IS_TOOLBAR (old_parent)); - spinner = ephy_spinner_new (); - gtk_widget_show (spinner); - t->priv->spinner = spinner; + g_signal_handlers_disconnect_by_func + (old_parent, G_CALLBACK (toolbar_style_changed_cb), + spinner); + } - toolbar = egg_editable_toolbar_set_fixed - (EGG_EDITABLE_TOOLBAR (t), spinner); + if (item->parent) + { + g_return_if_fail (GTK_IS_TOOLBAR (item->parent)); - g_signal_connect (toolbar, "style_changed", - G_CALLBACK (toolbar_style_sync), - spinner); + g_signal_connect (item->parent, "style_changed", + G_CALLBACK (toolbar_style_changed_cb), + spinner); + } } static void toolbar_init (Toolbar *t) { + GtkWidget *spinner; + GtkToolItem *item; + t->priv = EPHY_TOOLBAR_GET_PRIVATE (t); - create_spinner (t); + spinner = ephy_spinner_new (); + t->priv->spinner = spinner; + g_object_ref (spinner); + gtk_object_sink (GTK_OBJECT (spinner)); + gtk_widget_show (spinner); + + item = gtk_tool_item_new (); + gtk_container_add (GTK_CONTAINER (item), spinner); + gtk_widget_show (GTK_WIDGET (item)); + + g_signal_connect (item, "parent_set", + G_CALLBACK (parent_set_cb), spinner); + + egg_editable_toolbar_set_fixed (EGG_EDITABLE_TOOLBAR (t), item); } static void @@ -449,6 +471,8 @@ toolbar_finalize (GObject *object) (egg_editable_toolbar_get_model (eggtoolbar), G_CALLBACK (toolbar_added_cb), t); + g_object_unref (t->priv->spinner); + g_object_unref (t->priv->action_group); G_OBJECT_CLASS (parent_class)->finalize (object); @@ -462,7 +486,6 @@ toolbar_new (EphyWindow *window) return EPHY_TOOLBAR (g_object_new (EPHY_TYPE_TOOLBAR, "window", window, "MenuMerge", window->ui_merge, - "ToolbarsModel", ephy_shell_get_toolbars_model (ephy_shell, FALSE), NULL)); } |