diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2003-12-27 18:32:42 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2003-12-27 18:32:42 +0800 |
commit | a9863f3bfeb5d8852304d4c92e284e0653dc8ee6 (patch) | |
tree | fe4f9832b6d522a5c758cf2386c9e435168e436c /lib/egg/egg-editable-toolbar.c | |
parent | bde4c29f92204eafbe4f953353730946486dc474 (diff) | |
download | gsoc2013-epiphany-a9863f3bfeb5d8852304d4c92e284e0653dc8ee6.tar gsoc2013-epiphany-a9863f3bfeb5d8852304d4c92e284e0653dc8ee6.tar.gz gsoc2013-epiphany-a9863f3bfeb5d8852304d4c92e284e0653dc8ee6.tar.bz2 gsoc2013-epiphany-a9863f3bfeb5d8852304d4c92e284e0653dc8ee6.tar.lz gsoc2013-epiphany-a9863f3bfeb5d8852304d4c92e284e0653dc8ee6.tar.xz gsoc2013-epiphany-a9863f3bfeb5d8852304d4c92e284e0653dc8ee6.tar.zst gsoc2013-epiphany-a9863f3bfeb5d8852304d4c92e284e0653dc8ee6.zip |
Brought type macros in line with the rest of libegg; and use gobject
2003-12-27 Christian Persch <chpe@cvs.gnome.org>
* lib/egg/egg-editable-toolbar.c: (find_action),
(drag_data_delete_cb), (drag_data_get_cb),
(egg_editable_toolbar_set_model), (egg_editable_toolbar_set_merge),
(egg_editable_toolbar_class_init), (egg_editable_toolbar_init),
(egg_editable_toolbar_finalize), (egg_editable_toolbar_new):
* lib/egg/egg-editable-toolbar.h:
* lib/egg/egg-toolbar-editor.c: (find_action),
(egg_toolbar_editor_set_merge), (egg_toolbar_editor_set_model),
(egg_toolbar_editor_class_init), (egg_toolbar_editor_finalize),
(egg_toolbar_editor_new), (editor_drag_data_received_cb),
(editor_drag_data_delete_cb), (update_editor_sheet),
(setup_editor), (egg_toolbar_editor_init):
* lib/egg/egg-toolbar-editor.h:
* lib/egg/egg-toolbars-model.c: (egg_toolbars_model_to_xml),
(egg_toolbars_model_save), (egg_toolbars_model_add_separator),
(impl_add_item), (egg_toolbars_model_add_toolbar),
(egg_toolbars_model_load), (egg_toolbars_model_class_init),
(egg_toolbars_model_init), (egg_toolbars_model_finalize),
(egg_toolbars_model_new), (egg_toolbars_model_remove_toolbar),
(egg_toolbars_model_remove_item):
* lib/egg/egg-toolbars-model.h:
Brought type macros in line with the rest of libegg; and use
gobject instance private data.
* src/ephy-toolbars-model.c: (ephy_toolbars_model_get_type),
(update_toolbar_removeable_flag),
(ephy_toolbars_model_set_bookmarks), (toolbar_added),
(toolbar_removed), (ephy_toolbars_model_new),
(ephy_toolbars_model_has_bookmark):
* src/ephy-toolbars-model.h:
* src/toolbar.c: (toolbar_get_type), (init_normal_mode):
Fix crasher bug #129991.
Diffstat (limited to 'lib/egg/egg-editable-toolbar.c')
-rwxr-xr-x | lib/egg/egg-editable-toolbar.c | 80 |
1 files changed, 52 insertions, 28 deletions
diff --git a/lib/egg/egg-editable-toolbar.c b/lib/egg/egg-editable-toolbar.c index aef7aac60..746affc42 100755 --- a/lib/egg/egg-editable-toolbar.c +++ b/lib/egg/egg-editable-toolbar.c @@ -68,6 +68,8 @@ static guint egg_editable_toolbar_signals[LAST_SIGNAL] = { 0 }; static GObjectClass *parent_class = NULL; +#define EGG_EDITABLE_TOOLBAR_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EGG_TYPE_EDITABLE_TOOLBAR, EggEditableToolbarPrivate)) + struct EggEditableToolbarPrivate { GtkUIManager *merge; @@ -174,7 +176,7 @@ find_action (EggEditableToolbar *t, l = gtk_ui_manager_get_action_groups (t->priv->merge); - g_return_val_if_fail (IS_EGG_EDITABLE_TOOLBAR (t), NULL); + g_return_val_if_fail (EGG_IS_EDITABLE_TOOLBAR (t), NULL); g_return_val_if_fail (name != NULL, NULL); for (; l != NULL; l = l->next) @@ -196,7 +198,7 @@ drag_data_delete_cb (GtkWidget *widget, { int pos, toolbar_pos; - g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (etoolbar)); + g_return_if_fail (EGG_IS_EDITABLE_TOOLBAR (etoolbar)); pos = gtk_toolbar_get_item_index (GTK_TOOLBAR (widget->parent), GTK_TOOL_ITEM (widget)); @@ -233,7 +235,7 @@ drag_data_get_cb (GtkWidget *widget, GtkAction *action; const char *target; - g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (etoolbar)); + g_return_if_fail (EGG_IS_EDITABLE_TOOLBAR (etoolbar)); action = GTK_ACTION (g_object_get_data (G_OBJECT (widget), "gtk-action")); @@ -896,12 +898,28 @@ static void egg_editable_toolbar_set_model (EggEditableToolbar *t, EggToolbarsModel *model) { - g_return_if_fail (IS_EGG_TOOLBARS_MODEL (model)); - g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (t)); + g_return_if_fail (EGG_IS_TOOLBARS_MODEL (model)); + g_return_if_fail (EGG_IS_EDITABLE_TOOLBAR (t)); if (t->priv->model == model) return; - t->priv->model = model; + if (t->priv->model) + { + g_signal_handlers_disconnect_by_func + (t->priv->model, G_CALLBACK (item_added_cb), t); + g_signal_handlers_disconnect_by_func + (t->priv->model, G_CALLBACK (item_removed_cb), t); + g_signal_handlers_disconnect_by_func + (t->priv->model, G_CALLBACK (toolbar_added_cb), t); + g_signal_handlers_disconnect_by_func + (t->priv->model, G_CALLBACK (toolbar_removed_cb), t); + g_signal_handlers_disconnect_by_func + (t->priv->model, G_CALLBACK (toolbar_changed_cb), t); + + g_object_unref (t->priv->model); + } + + t->priv->model = g_object_ref (model); toolbars_clean (t); egg_editable_toolbar_construct (t); @@ -923,16 +941,20 @@ egg_editable_toolbar_set_merge (EggEditableToolbar *t, GtkUIManager *merge) { g_return_if_fail (GTK_IS_UI_MANAGER (merge)); - g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (t)); + g_return_if_fail (EGG_IS_EDITABLE_TOOLBAR (t)); + + if (t->priv->merge == merge) return; - if (t->priv->merge != merge) + if (t->priv->merge) { - t->priv->merge = merge; + g_object_unref (t->priv->merge); + } - if (t->priv->model != NULL) - { - egg_editable_toolbar_construct (t); - } + t->priv->merge = g_object_ref (merge); + + if (t->priv->model != NULL) + { + egg_editable_toolbar_construct (t); } } @@ -1005,14 +1027,16 @@ egg_editable_toolbar_class_init (EggEditableToolbarClass *klass) g_param_spec_object ("ToolbarsModel", "ToolbarsModel", "Toolbars Model", - EGG_TOOLBARS_MODEL_TYPE, + EGG_TYPE_TOOLBARS_MODEL, G_PARAM_READWRITE)); + + g_type_class_add_private (object_class, sizeof (EggEditableToolbarPrivate)); } static void egg_editable_toolbar_init (EggEditableToolbar *t) { - t->priv = g_new0 (EggEditableToolbarPrivate, 1); + t->priv = EGG_EDITABLE_TOOLBAR_GET_PRIVATE (t); t->priv->merge = NULL; t->priv->edit_mode = FALSE; @@ -1023,15 +1047,20 @@ egg_editable_toolbar_finalize (GObject *object) { EggEditableToolbar *t = EGG_EDITABLE_TOOLBAR (object); - g_return_if_fail (object != NULL); - g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (object)); - if (t->priv->fixed_toolbar) { g_object_unref (t->priv->fixed_toolbar); } - g_free (t->priv); + if (t->priv->merge) + { + g_object_unref (t->priv->merge); + } + + if (t->priv->model) + { + g_object_unref (t->priv->model); + } G_OBJECT_CLASS (parent_class)->finalize (object); } @@ -1040,15 +1069,10 @@ GtkWidget * egg_editable_toolbar_new (GtkUIManager *merge, EggToolbarsModel *model) { - EggEditableToolbar *t; - - t = EGG_EDITABLE_TOOLBAR (g_object_new (EGG_EDITABLE_TOOLBAR_TYPE, - "ToolbarsModel", model, - "MenuMerge", merge, NULL)); - - g_return_val_if_fail (t->priv != NULL, NULL); - - return GTK_WIDGET (t); + return GTK_WIDGET (g_object_new (EGG_TYPE_EDITABLE_TOOLBAR, + "ToolbarsModel", model, + "MenuMerge", merge, + NULL)); } void |