aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@it.gnome.org>2003-07-06 19:10:31 +0800
committerMarco Pesenti Gritti <mpeseng@src.gnome.org>2003-07-06 19:10:31 +0800
commit5f244c99e6fefb6f56ba468b442e0aab000cff34 (patch)
treed1a6b98c0774b11bd579ba760b3c4387b6c22e88 /src
parent2ed547c52d8c9bde77dd0d95ddd6e32a9149b6d6 (diff)
downloadgsoc2013-epiphany-5f244c99e6fefb6f56ba468b442e0aab000cff34.tar
gsoc2013-epiphany-5f244c99e6fefb6f56ba468b442e0aab000cff34.tar.gz
gsoc2013-epiphany-5f244c99e6fefb6f56ba468b442e0aab000cff34.tar.bz2
gsoc2013-epiphany-5f244c99e6fefb6f56ba468b442e0aab000cff34.tar.lz
gsoc2013-epiphany-5f244c99e6fefb6f56ba468b442e0aab000cff34.tar.xz
gsoc2013-epiphany-5f244c99e6fefb6f56ba468b442e0aab000cff34.tar.zst
gsoc2013-epiphany-5f244c99e6fefb6f56ba468b442e0aab000cff34.zip
Make sure we ever save bookmarks after changes, so they dont get lost on
2003-07-06 Marco Pesenti Gritti <marco@it.gnome.org> * src/bookmarks/ephy-bookmarks-import.c: (ephy_bookmarks_import_mozilla), (ephy_bookmarks_import_xbel): * src/bookmarks/ephy-bookmarks.c: (ephy_bookmarks_init_defaults), (save_bookmarks_delayed), (ephy_bookmarks_set_dirty), (bookmarks_changed_cb), (bookmarks_removed_cb), (ephy_bookmarks_init), (ephy_bookmarks_finalize), (ephy_bookmarks_add): * src/bookmarks/ephy-bookmarks.h: * src/bookmarks/ephy-new-bookmark.c: (ephy_new_bookmark_add): * src/ephy-shell.c: (ephy_shell_finalize), (ephy_shell_get_toolbars_model): * src/ephy-toolbars-model.c: (item_added), (item_removed), (toolbar_added), (toolbar_removed), (ephy_toolbars_model_init), (ephy_toolbars_model_finalize): Make sure we ever save bookmarks after changes, so they dont get lost on crashes.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/ephy-toolbars-model.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/ephy-toolbars-model.c b/src/ephy-toolbars-model.c
index ca2109c90..11223e95b 100755
--- a/src/ephy-toolbars-model.c
+++ b/src/ephy-toolbars-model.c
@@ -19,6 +19,7 @@
#include "ephy-toolbars-model.h"
#include "ephy-dnd.h"
#include "ephy-new-bookmark.h"
+#include "ephy-file-helpers.h"
#include "ephy-shell.h"
#include "ephy-debug.h"
@@ -45,6 +46,7 @@ static GObjectClass *parent_class = NULL;
struct EphyToolbarsModelPrivate
{
EphyBookmarks *bookmarks;
+ char *xml_file;
};
GType
@@ -193,10 +195,62 @@ ephy_toolbars_model_class_init (EphyToolbarsModelClass *klass)
}
static void
+item_added (EphyToolbarsModel *model, int toolbar_position, int position)
+{
+ egg_toolbars_model_save (EGG_TOOLBARS_MODEL (model),
+ model->priv->xml_file);
+}
+
+static void
+item_removed (EphyToolbarsModel *model, int toolbar_position, int position)
+{
+ egg_toolbars_model_save (EGG_TOOLBARS_MODEL (model),
+ model->priv->xml_file);
+}
+
+static void
+toolbar_added (EphyToolbarsModel *model, int position)
+{
+ egg_toolbars_model_save (EGG_TOOLBARS_MODEL (model),
+ model->priv->xml_file);
+}
+
+static void
+toolbar_removed (EphyToolbarsModel *model, int position)
+{
+ egg_toolbars_model_save (EGG_TOOLBARS_MODEL (model),
+ model->priv->xml_file);
+}
+
+static void
ephy_toolbars_model_init (EphyToolbarsModel *t)
{
+ EggToolbarsModel *egg_model = EGG_TOOLBARS_MODEL (t);
+
t->priv = g_new0 (EphyToolbarsModelPrivate, 1);
t->priv->bookmarks = NULL;
+
+ t->priv->xml_file = g_build_filename (ephy_dot_dir (),
+ "ephy-toolbar.xml",
+ NULL);
+
+ if (g_file_test (t->priv->xml_file, G_FILE_TEST_EXISTS))
+ {
+ egg_toolbars_model_load (egg_model,
+ t->priv->xml_file);
+ }
+ else
+ {
+ const char *default_xml;
+
+ default_xml = ephy_file ("epiphany-toolbar.xml");
+ egg_toolbars_model_load (egg_model, default_xml);
+ }
+
+ g_signal_connect (t, "item_added", G_CALLBACK (item_added), NULL);
+ g_signal_connect (t, "item_removed", G_CALLBACK (item_removed), NULL);
+ g_signal_connect (t, "toolbar_added", G_CALLBACK (toolbar_added), NULL);
+ g_signal_connect (t, "toolbar_removed", G_CALLBACK (toolbar_removed), NULL);
}
static void
@@ -209,6 +263,8 @@ ephy_toolbars_model_finalize (GObject *object)
g_object_unref (t->priv->bookmarks);
+ g_free (t->priv->xml_file);
+
g_free (t->priv);
G_OBJECT_CLASS (parent_class)->finalize (object);