aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2003-12-27 18:32:42 +0800
committerChristian Persch <chpe@src.gnome.org>2003-12-27 18:32:42 +0800
commita9863f3bfeb5d8852304d4c92e284e0653dc8ee6 (patch)
treefe4f9832b6d522a5c758cf2386c9e435168e436c
parentbde4c29f92204eafbe4f953353730946486dc474 (diff)
downloadgsoc2013-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.
-rw-r--r--ChangeLog37
-rwxr-xr-xlib/egg/egg-editable-toolbar.c80
-rwxr-xr-xlib/egg/egg-editable-toolbar.h12
-rwxr-xr-xlib/egg/egg-toolbar-editor.c55
-rwxr-xr-xlib/egg/egg-toolbar-editor.h14
-rwxr-xr-xlib/egg/egg-toolbars-model.c37
-rwxr-xr-xlib/egg/egg-toolbars-model.h12
-rwxr-xr-xsrc/ephy-toolbars-model.c97
-rwxr-xr-xsrc/ephy-toolbars-model.h6
-rwxr-xr-xsrc/toolbar.c43
10 files changed, 196 insertions, 197 deletions
diff --git a/ChangeLog b/ChangeLog
index 9de730030..39de3dc1a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,40 @@
+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.
+
2003-12-26 Christian Persch <chpe@cvs.gnome.org>
* src/prefs-dialog.c: (prefs_dialog_finalize),
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
diff --git a/lib/egg/egg-editable-toolbar.h b/lib/egg/egg-editable-toolbar.h
index 96c7935cd..3915878ff 100755
--- a/lib/egg/egg-editable-toolbar.h
+++ b/lib/egg/egg-editable-toolbar.h
@@ -30,12 +30,12 @@ G_BEGIN_DECLS
typedef struct EggEditableToolbarClass EggEditableToolbarClass;
-#define EGG_EDITABLE_TOOLBAR_TYPE (egg_editable_toolbar_get_type ())
-#define EGG_EDITABLE_TOOLBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_EDITABLE_TOOLBAR_TYPE, EggEditableToolbar))
-#define EGG_EDITABLE_TOOLBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_EDITABLE_TOOLBAR_TYPE, EggEditableToolbarClass))
-#define IS_EGG_EDITABLE_TOOLBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_EDITABLE_TOOLBAR_TYPE))
-#define IS_EGG_EDITABLE_TOOLBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EGG_EDITABLE_TOOLBAR_TYPE))
-#define EGG_EDITABLE_TOOLBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_EDITABLE_TOOLBAR_TYPE, EggEditableToolbarClass))
+#define EGG_TYPE_EDITABLE_TOOLBAR (egg_editable_toolbar_get_type ())
+#define EGG_EDITABLE_TOOLBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_EDITABLE_TOOLBAR, EggEditableToolbar))
+#define EGG_EDITABLE_TOOLBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_EDITABLE_TOOLBAR, EggEditableToolbarClass))
+#define EGG_IS_EDITABLE_TOOLBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_EDITABLE_TOOLBAR))
+#define EGG_IS_EDITABLE_TOOLBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EGG_TYPE_EDITABLE_TOOLBAR))
+#define EGG_EDITABLE_TOOLBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_TYPE_EDITABLE_TOOLBAR, EggEditableToolbarClass))
typedef struct EggEditableToolbar EggEditableToolbar;
diff --git a/lib/egg/egg-toolbar-editor.c b/lib/egg/egg-toolbar-editor.c
index 297251481..a317ff458 100755
--- a/lib/egg/egg-toolbar-editor.c
+++ b/lib/egg/egg-toolbar-editor.c
@@ -55,6 +55,8 @@ enum
static GObjectClass *parent_class = NULL;
+#define EGG_TOOLBAR_EDITOR_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EGG_TYPE_TOOLBAR_EDITOR, EggToolbarEditorPrivate))
+
struct EggToolbarEditorPrivate
{
GtkUIManager *merge;
@@ -133,7 +135,7 @@ find_action (EggToolbarEditor *t,
l = gtk_ui_manager_get_action_groups (t->priv->merge);
- g_return_val_if_fail (IS_EGG_TOOLBAR_EDITOR (t), NULL);
+ g_return_val_if_fail (EGG_IS_TOOLBAR_EDITOR (t), NULL);
g_return_val_if_fail (name != NULL, NULL);
for (; l != NULL; l = l->next)
@@ -153,18 +155,18 @@ egg_toolbar_editor_set_merge (EggToolbarEditor *t,
GtkUIManager *merge)
{
g_return_if_fail (GTK_IS_UI_MANAGER (merge));
- g_return_if_fail (IS_EGG_TOOLBAR_EDITOR (t));
+ g_return_if_fail (EGG_IS_TOOLBAR_EDITOR (t));
- t->priv->merge = merge;
+ t->priv->merge = g_object_ref (merge);
}
static void
egg_toolbar_editor_set_model (EggToolbarEditor *t,
EggToolbarsModel *model)
{
- g_return_if_fail (IS_EGG_TOOLBAR_EDITOR (t));
+ g_return_if_fail (EGG_IS_TOOLBAR_EDITOR (t));
- t->priv->model = model;
+ t->priv->model = g_object_ref (model);
}
static void
@@ -228,19 +230,26 @@ egg_toolbar_editor_class_init (EggToolbarEditorClass *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 (EggToolbarEditorPrivate));
}
static void
egg_toolbar_editor_finalize (GObject *object)
{
- EggToolbarEditor *t = EGG_TOOLBAR_EDITOR (object);
+ EggToolbarEditor *editor = EGG_TOOLBAR_EDITOR (object);
- g_return_if_fail (object != NULL);
- g_return_if_fail (IS_EGG_TOOLBAR_EDITOR (object));
+ if (editor->priv->merge)
+ {
+ g_object_unref (editor->priv->merge);
+ }
- g_free (t->priv);
+ if (editor->priv->model)
+ {
+ g_object_unref (editor->priv->model);
+ }
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@@ -249,16 +258,10 @@ GtkWidget *
egg_toolbar_editor_new (GtkUIManager *merge,
EggToolbarsModel *model)
{
- EggToolbarEditor *t;
-
- t = EGG_TOOLBAR_EDITOR (g_object_new (EGG_TOOLBAR_EDITOR_TYPE,
- "MenuMerge", merge,
- "ToolbarsModel", model,
- NULL));
-
- g_return_val_if_fail (t->priv != NULL, NULL);
-
- return GTK_WIDGET (t);
+ return GTK_WIDGET (g_object_new (EGG_TYPE_TOOLBAR_EDITOR,
+ "MenuMerge", merge,
+ "ToolbarsModel", model,
+ NULL));
}
static void
@@ -287,7 +290,7 @@ editor_drag_data_received_cb (GtkWidget *widget,
{
GtkAction *action;
- g_return_if_fail (IS_EGG_TOOLBAR_EDITOR (editor));
+ g_return_if_fail (EGG_IS_TOOLBAR_EDITOR (editor));
g_return_if_fail (selection_data != NULL);
action = find_action (editor, (const char *)selection_data->data);
@@ -309,7 +312,7 @@ editor_drag_data_delete_cb (GtkWidget *widget,
EggToolbarEditor *editor)
{
GtkAction *action;
- g_return_if_fail (IS_EGG_TOOLBAR_EDITOR (editor));
+ g_return_if_fail (EGG_IS_TOOLBAR_EDITOR (editor));
action = GTK_ACTION (g_object_get_data (G_OBJECT (widget), "egg-action"));
if (action)
@@ -470,7 +473,7 @@ update_editor_sheet (EggToolbarEditor *editor)
GtkWidget *item;
GtkWidget *icon;
- g_return_if_fail (IS_EGG_TOOLBAR_EDITOR (editor));
+ g_return_if_fail (EGG_IS_TOOLBAR_EDITOR (editor));
viewport = GTK_BIN (editor->priv->scrolled_window)->child;
if (viewport)
@@ -543,7 +546,7 @@ setup_editor (EggToolbarEditor *editor)
GtkWidget *image;
GtkWidget *label;
- g_return_if_fail (IS_EGG_TOOLBAR_EDITOR (editor));
+ g_return_if_fail (EGG_IS_TOOLBAR_EDITOR (editor));
gtk_container_set_border_width (GTK_CONTAINER (editor), 12);
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
@@ -569,7 +572,7 @@ setup_editor (EggToolbarEditor *editor)
static void
egg_toolbar_editor_init (EggToolbarEditor *t)
{
- t->priv = g_new0 (EggToolbarEditorPrivate, 1);
+ t->priv = EGG_TOOLBAR_EDITOR_GET_PRIVATE (t);
t->priv->merge = NULL;
t->priv->default_actions_list = NULL;
@@ -578,7 +581,7 @@ egg_toolbar_editor_init (EggToolbarEditor *t)
setup_editor (t);
}
-static void
+void
egg_toolbar_editor_add_action (EggToolbarEditor *editor,
const char *action_name)
{
diff --git a/lib/egg/egg-toolbar-editor.h b/lib/egg/egg-toolbar-editor.h
index 5999f45c8..671dfa26e 100755
--- a/lib/egg/egg-toolbar-editor.h
+++ b/lib/egg/egg-toolbar-editor.h
@@ -28,12 +28,12 @@ G_BEGIN_DECLS
typedef struct EggToolbarEditorClass EggToolbarEditorClass;
-#define EGG_TOOLBAR_EDITOR_TYPE (egg_toolbar_editor_get_type ())
-#define EGG_TOOLBAR_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TOOLBAR_EDITOR_TYPE, EggToolbarEditor))
-#define EGG_TOOLBAR_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TOOLBAR_EDITOR_TYPE, EggToolbarEditorClass))
-#define IS_EGG_TOOLBAR_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TOOLBAR_EDITOR_TYPE))
-#define IS_EGG_TOOLBAR_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EGG_TOOLBAR_EDITOR_TYPE))
-#define EGG_TOOLBAR_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_TOOLBAR_EDITOR_TYPE, EggToolbarEditorClass))
+#define EGG_TYPE_TOOLBAR_EDITOR (egg_toolbar_editor_get_type ())
+#define EGG_TOOLBAR_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_TOOLBAR_EDITOR, EggToolbarEditor))
+#define EGG_TOOLBAR_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_TOOLBAR_EDITOR, EggToolbarEditorClass))
+#define EGG_IS_TOOLBAR_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_TOOLBAR_EDITOR))
+#define EGG_IS_TOOLBAR_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EGG_TYPE_TOOLBAR_EDITOR))
+#define EGG_TOOLBAR_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_TYPE_TOOLBAR_EDITOR, EggToolbarEditorClass))
typedef struct EggToolbarEditor EggToolbarEditor;
@@ -56,6 +56,8 @@ struct EggToolbarEditorClass
GType egg_toolbar_editor_get_type (void);
GtkWidget *egg_toolbar_editor_new (GtkUIManager *merge,
EggToolbarsModel *model);
+void egg_toolbar_editor_add_action (EggToolbarEditor *editor,
+ const char *action_name);
void egg_toolbar_editor_load_actions (EggToolbarEditor *editor,
const char *xml_file);
diff --git a/lib/egg/egg-toolbars-model.c b/lib/egg/egg-toolbars-model.c
index ff0fa3315..8e44d9365 100755
--- a/lib/egg/egg-toolbars-model.c
+++ b/lib/egg/egg-toolbars-model.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2002 Marco Pesenti Gritti
+ * Copyright (C) 2002-2003 Marco Pesenti Gritti
*
* 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
@@ -55,6 +55,8 @@ static guint egg_toolbars_model_signals[LAST_SIGNAL] = { 0 };
static GObjectClass *parent_class = NULL;
+#define EGG_TOOLBARS_MODEL_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EGG_TYPE_TOOLBARS_MODEL, EggToolbarsModelPrivate))
+
struct EggToolbarsModelPrivate
{
GNode *toolbars;
@@ -94,7 +96,7 @@ egg_toolbars_model_to_xml (EggToolbarsModel *t)
GNode *l1, *l2, *tl;
xmlDocPtr doc;
- g_return_val_if_fail (IS_EGG_TOOLBARS_MODEL (t), NULL);
+ g_return_val_if_fail (EGG_IS_TOOLBARS_MODEL (t), NULL);
tl = t->priv->toolbars;
@@ -199,7 +201,7 @@ egg_toolbars_model_save (EggToolbarsModel *t,
xmlDocPtr doc;
xmlNodePtr root;
- g_return_if_fail (IS_EGG_TOOLBARS_MODEL (t));
+ g_return_if_fail (EGG_IS_TOOLBARS_MODEL (t));
doc = egg_toolbars_model_to_xml (t);
root = xmlDocGetRootElement (doc);
@@ -301,7 +303,7 @@ egg_toolbars_model_add_separator (EggToolbarsModel *t,
EggToolbarsItem *item;
int real_position;
- g_return_if_fail (IS_EGG_TOOLBARS_MODEL (t));
+ g_return_if_fail (EGG_IS_TOOLBARS_MODEL (t));
parent_node = g_node_nth_child (t->priv->toolbars, toolbar_position);
item = toolbars_item_new ("separator", "separator", TRUE);
@@ -326,7 +328,7 @@ impl_add_item (EggToolbarsModel *t,
EggToolbarsItem *item;
int real_position;
- g_return_val_if_fail (IS_EGG_TOOLBARS_MODEL (t), FALSE);
+ g_return_val_if_fail (EGG_IS_TOOLBARS_MODEL (t), FALSE);
g_return_val_if_fail (id != NULL, FALSE);
g_return_val_if_fail (type != NULL, FALSE);
@@ -388,7 +390,7 @@ egg_toolbars_model_add_toolbar (EggToolbarsModel *t,
GNode *node;
int real_position;
- g_return_val_if_fail (IS_EGG_TOOLBARS_MODEL (t), -1);
+ g_return_val_if_fail (EGG_IS_TOOLBARS_MODEL (t), -1);
node = g_node_new (toolbars_toolbar_new (name));
g_node_insert (t->priv->toolbars, position, node);
@@ -438,7 +440,7 @@ egg_toolbars_model_load (EggToolbarsModel *t,
xmlDocPtr doc;
xmlNodePtr root;
- g_return_val_if_fail (IS_EGG_TOOLBARS_MODEL (t), FALSE);
+ g_return_val_if_fail (EGG_IS_TOOLBARS_MODEL (t), FALSE);
doc = xmlParseFile (xml_file);
if (doc == NULL)
@@ -543,12 +545,14 @@ egg_toolbars_model_class_init (EggToolbarsModelClass *klass)
G_STRUCT_OFFSET (EggToolbarsModelClass, toolbar_changed),
NULL, NULL, g_cclosure_marshal_VOID__INT,
G_TYPE_NONE, 1, G_TYPE_INT);
+
+ g_type_class_add_private (object_class, sizeof (EggToolbarsModelPrivate));
}
static void
egg_toolbars_model_init (EggToolbarsModel *t)
{
- t->priv = g_new0 (EggToolbarsModelPrivate, 1);
+ t->priv =EGG_TOOLBARS_MODEL_GET_PRIVATE (t);
t->priv->toolbars = NULL;
}
@@ -558,27 +562,16 @@ egg_toolbars_model_finalize (GObject *object)
{
EggToolbarsModel *t = EGG_TOOLBARS_MODEL (object);
- g_return_if_fail (object != NULL);
- g_return_if_fail (IS_EGG_TOOLBARS_MODEL (object));
-
/* FIXME free nodes */
g_node_destroy (t->priv->toolbars);
- g_free (t->priv);
-
G_OBJECT_CLASS (parent_class)->finalize (object);
}
EggToolbarsModel *
egg_toolbars_model_new (void)
{
- EggToolbarsModel *t;
-
- t = EGG_TOOLBARS_MODEL (g_object_new (EGG_TOOLBARS_MODEL_TYPE, NULL));
-
- g_return_val_if_fail (t->priv != NULL, NULL);
-
- return t;
+ return EGG_TOOLBARS_MODEL (g_object_new (EGG_TYPE_TOOLBARS_MODEL, NULL));
}
void
@@ -588,7 +581,7 @@ egg_toolbars_model_remove_toolbar (EggToolbarsModel *t,
GNode *node;
EggTbModelFlags flags;
- g_return_if_fail (IS_EGG_TOOLBARS_MODEL (t));
+ g_return_if_fail (EGG_IS_TOOLBARS_MODEL (t));
flags = egg_toolbars_model_get_flags (t, position);
@@ -612,7 +605,7 @@ egg_toolbars_model_remove_item (EggToolbarsModel *t,
{
GNode *node, *toolbar;
- g_return_if_fail (IS_EGG_TOOLBARS_MODEL (t));
+ g_return_if_fail (EGG_IS_TOOLBARS_MODEL (t));
toolbar = g_node_nth_child (t->priv->toolbars, toolbar_position);
g_return_if_fail (toolbar != NULL);
diff --git a/lib/egg/egg-toolbars-model.h b/lib/egg/egg-toolbars-model.h
index 6ad28b9d7..9e1f01a50 100755
--- a/lib/egg/egg-toolbars-model.h
+++ b/lib/egg/egg-toolbars-model.h
@@ -27,12 +27,12 @@ G_BEGIN_DECLS
typedef struct EggToolbarsModelClass EggToolbarsModelClass;
-#define EGG_TOOLBARS_MODEL_TYPE (egg_toolbars_model_get_type ())
-#define EGG_TOOLBARS_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TOOLBARS_MODEL_TYPE, EggToolbarsModel))
-#define EGG_TOOLBARS_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TOOLBARS_MODEL_TYPE, EggToolbarsModelClass))
-#define IS_EGG_TOOLBARS_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TOOLBARS_MODEL_TYPE))
-#define IS_EGG_TOOLBARS_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EGG_TOOLBARS_MODEL_TYPE))
-#define EGG_TOOLBARS_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_TOOLBARS_MODEL_TYPE, EggToolbarsModelClass))
+#define EGG_TYPE_TOOLBARS_MODEL (egg_toolbars_model_get_type ())
+#define EGG_TOOLBARS_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_TOOLBARS_MODEL, EggToolbarsModel))
+#define EGG_TOOLBARS_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_TOOLBARS_MODEL, EggToolbarsModelClass))
+#define EGG_IS_TOOLBARS_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_TOOLBARS_MODEL))
+#define EGG_IS_TOOLBARS_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EGG_TYPE_TOOLBARS_MODEL))
+#define EGG_TOOLBARS_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_TYPE_TOOLBARS_MODEL, EggToolbarsModelClass))
typedef struct EggToolbarsModel EggToolbarsModel;
typedef struct EggToolbarsModelPrivate EggToolbarsModelPrivate;
diff --git a/src/ephy-toolbars-model.c b/src/ephy-toolbars-model.c
index f43acfb83..c022b9ba8 100755
--- a/src/ephy-toolbars-model.c
+++ b/src/ephy-toolbars-model.c
@@ -68,9 +68,9 @@ struct EphyToolbarsModelPrivate
GType
ephy_toolbars_model_get_type (void)
{
- static GType ephy_toolbars_model_type = 0;
+ static GType type = 0;
- if (ephy_toolbars_model_type == 0)
+ if (type == 0)
{
static const GTypeInfo our_info = {
sizeof (EphyToolbarsModelClass),
@@ -84,12 +84,12 @@ ephy_toolbars_model_get_type (void)
(GInstanceInitFunc) ephy_toolbars_model_init
};
- ephy_toolbars_model_type = g_type_register_static (EGG_TOOLBARS_MODEL_TYPE,
- "EphyToolbarsModel",
- &our_info, 0);
+ type = g_type_register_static (EGG_TYPE_TOOLBARS_MODEL,
+ "EphyToolbarsModel",
+ &our_info, 0);
}
- return ephy_toolbars_model_type;
+ return type;
}
char *
@@ -320,13 +320,40 @@ connect_item (EphyToolbarsModel *model,
}
static void
+update_toolbar_removeable_flag (EggToolbarsModel *model)
+{
+ int i, n_toolbars;
+ int flag = 0;
+
+ n_toolbars = egg_toolbars_model_n_toolbars (model);
+
+ /* If there is only one toolbar and the bookmarks bar */
+ if (n_toolbars <= 2)
+ {
+ flag = EGG_TB_MODEL_NOT_REMOVABLE;
+ }
+
+ for (i = 0; i < n_toolbars; i++)
+ {
+ const char *t_name;
+
+ t_name = egg_toolbars_model_toolbar_nth (model, i);
+ g_return_if_fail (t_name != NULL);
+
+ if (!(strcmp (t_name, "BookmarksBar") == 0))
+ {
+ egg_toolbars_model_set_flags (model, flag, i);
+ }
+ }
+}
+
+static void
ephy_toolbars_model_set_bookmarks (EphyToolbarsModel *model, EphyBookmarks *bookmarks)
{
EggToolbarsModel *egg_model = EGG_TOOLBARS_MODEL (model);
gboolean success = FALSE;
- model->priv->bookmarks = bookmarks;
- g_object_ref (model->priv->bookmarks);
+ model->priv->bookmarks = g_object_ref (bookmarks);
model->priv->loading = TRUE;
@@ -451,12 +478,14 @@ static void
toolbar_added (EphyToolbarsModel *model, int position)
{
save_changes (model);
+ update_toolbar_removeable_flag (EGG_TOOLBARS_MODEL (model));
}
static void
toolbar_removed (EphyToolbarsModel *model, int position)
{
save_changes (model);
+ update_toolbar_removeable_flag (EGG_TOOLBARS_MODEL (model));
}
static void
@@ -493,15 +522,9 @@ ephy_toolbars_model_finalize (GObject *object)
EphyToolbarsModel *
ephy_toolbars_model_new (EphyBookmarks *bookmarks)
{
- EphyToolbarsModel *t;
-
- t = EPHY_TOOLBARS_MODEL (g_object_new (EPHY_TYPE_TOOLBARS_MODEL,
- "bookmarks", bookmarks,
- NULL));
-
- g_return_val_if_fail (t->priv != NULL, NULL);
-
- return t;
+ return EPHY_TOOLBARS_MODEL (g_object_new (EPHY_TYPE_TOOLBARS_MODEL,
+ "bookmarks", bookmarks,
+ NULL));
}
static int
@@ -583,43 +606,3 @@ ephy_toolbars_model_has_bookmark (EphyToolbarsModel *model,
return found;
}
-
-void
-ephy_toolbars_model_set_flag (EphyToolbarsModel *model,
- EggTbModelFlags flags)
-{
- EggToolbarsModel *t = EGG_TOOLBARS_MODEL (model);
- int i, n_toolbars;
-
- n_toolbars = egg_toolbars_model_n_toolbars
- (EGG_TOOLBARS_MODEL (model));
-
- for (i = 0; i < n_toolbars; i++)
- {
- EggTbModelFlags old_flags;
-
- old_flags = egg_toolbars_model_get_flags (t, i);
-
- egg_toolbars_model_set_flags (t, old_flags | flags, i);
- }
-}
-
-void
-ephy_toolbars_model_unset_flag (EphyToolbarsModel *model,
- EggTbModelFlags flags)
-{
- EggToolbarsModel *t = EGG_TOOLBARS_MODEL (model);
- int i, n_toolbars;
-
- n_toolbars = egg_toolbars_model_n_toolbars
- (EGG_TOOLBARS_MODEL (model));
-
- for (i = 0; i < n_toolbars; i++)
- {
- EggTbModelFlags old_flags;
-
- old_flags = egg_toolbars_model_get_flags (t, i);
-
- egg_toolbars_model_set_flags (t, old_flags ^ flags, i);
- }
-}
diff --git a/src/ephy-toolbars-model.h b/src/ephy-toolbars-model.h
index bc20da6f6..dd0a412ae 100755
--- a/src/ephy-toolbars-model.h
+++ b/src/ephy-toolbars-model.h
@@ -68,12 +68,6 @@ char *ephy_toolbars_model_get_action_name (EphyToolbarsModel *model
EphyNode *ephy_toolbars_model_get_node (EphyToolbarsModel *model,
const char *action_name);
-void ephy_toolbars_model_set_flag (EphyToolbarsModel *model,
- EggTbModelFlags flags);
-
-void ephy_toolbars_model_unset_flag (EphyToolbarsModel *model,
- EggTbModelFlags flags);
-
G_END_DECLS
#endif
diff --git a/src/toolbar.c b/src/toolbar.c
index dae06f522..bf5596c24 100755
--- a/src/toolbar.c
+++ b/src/toolbar.c
@@ -20,7 +20,7 @@
*/
#ifdef HAVE_CONFIG_H
-#include <config.h>
+#include "config.h"
#endif
#include "toolbar.h"
@@ -116,7 +116,7 @@ toolbar_get_type (void)
(GInstanceInitFunc) toolbar_init
};
- toolbar_type = g_type_register_static (EGG_EDITABLE_TOOLBAR_TYPE,
+ toolbar_type = g_type_register_static (EGG_TYPE_EDITABLE_TOOLBAR,
"Toolbar",
&our_info, 0);
}
@@ -454,50 +454,13 @@ init_bookmarks_toolbar (Toolbar *t)
}
static void
-update_toolbar_remove_flag (EphyToolbarsModel *model, gpointer data)
-{
- int i, n_toolbars;
- int not_removable = 0;
-
- n_toolbars = egg_toolbars_model_n_toolbars
- (EGG_TOOLBARS_MODEL (model));
-
- /* If there is only one toolbar and the bookmarks bar */
- if (n_toolbars <= 2)
- {
- not_removable = EGG_TB_MODEL_NOT_REMOVABLE;
- }
-
- for (i = 0; i < n_toolbars; i++)
- {
- const char *t_name;
-
- t_name = egg_toolbars_model_toolbar_nth
- (EGG_TOOLBARS_MODEL (model), i);
- g_return_if_fail (t_name != NULL);
-
- if (!(strcmp (t_name, "BookmarksBar") == 0))
- {
- egg_toolbars_model_set_flags
- (EGG_TOOLBARS_MODEL (model),
- not_removable, i);
- }
- }
-}
-
-static void
init_normal_mode (Toolbar *t)
{
EphyToolbarsModel *model;
model = EPHY_TOOLBARS_MODEL
(ephy_shell_get_toolbars_model (ephy_shell, FALSE));
- g_signal_connect (EGG_TOOLBARS_MODEL (model), "toolbar_added",
- G_CALLBACK (update_toolbar_remove_flag),
- NULL);
- g_signal_connect (EGG_TOOLBARS_MODEL (model), "toolbar_removed",
- G_CALLBACK (update_toolbar_remove_flag),
- NULL);
+
g_object_set (G_OBJECT (t),
"ToolbarsModel", model,
NULL);