[Xfce4-commits] <midori:master> Further align bookmarks and history
Christian Dywan
noreply at xfce.org
Sun Nov 25 16:44:01 CET 2012
Updating branch refs/heads/master
to 6d3c1106f1c3507935e2317f6eae6c891372ad49 (commit)
from 4c10283dc9f1d0b73fb68668eb9189ceb0e122fe (commit)
commit 6d3c1106f1c3507935e2317f6eae6c891372ad49
Author: Christian Dywan <christian at twotoasts.de>
Date: Sun Nov 25 16:37:41 2012 +0100
Further align bookmarks and history
Streamline error messages, add quit for bookmarks.
katze/midori-paths.vala | 1 +
midori/main.c | 4 +-
midori/midori-bookmarks.c | 46 ++++++++++++++++++--------------------------
midori/midori-bookmarks.h | 3 ++
midori/midori-history.c | 7 ++---
tests/bookmarks.c | 1 +
6 files changed, 29 insertions(+), 33 deletions(-)
diff --git a/katze/midori-paths.vala b/katze/midori-paths.vala
index 887154f..9c539b0 100644
--- a/katze/midori-paths.vala
+++ b/katze/midori-paths.vala
@@ -153,6 +153,7 @@ namespace Midori {
public static string get_config_filename_for_writing (string filename) {
assert (mode != RuntimeMode.UNDEFINED);
assert (config_dir != null);
+ mkdir_with_parents (config_dir);
return Path.build_path (Path.DIR_SEPARATOR_S, config_dir, filename);
}
diff --git a/midori/main.c b/midori/main.c
index 70917ed..8b47099 100644
--- a/midori/main.c
+++ b/midori/main.c
@@ -1325,7 +1325,7 @@ main (int argc,
{
g_string_append_printf (error_messages,
_("Bookmarks couldn't be loaded: %s\n"), errmsg);
- errmsg = NULL;
+ katze_assign (errmsg, NULL);
}
midori_startup_timer ("Bookmarks read: \t%f");
@@ -1363,7 +1363,6 @@ main (int argc,
midori_startup_timer ("Trash read: \t%f");
- errmsg = NULL;
if (!(history = midori_history_new (&errmsg)))
{
g_string_append_printf (error_messages,
@@ -1476,6 +1475,7 @@ main (int argc,
gtk_main ();
settings_notify_cb (settings, NULL, app);
+ midori_bookmarks_on_quit (bookmarks);
midori_history_on_quit (history, settings);
midori_private_data_on_quit (settings);
/* Removing KatzeHttpCookies makes it save outstanding changes */
diff --git a/midori/midori-bookmarks.c b/midori/midori-bookmarks.c
index 69251ad..41c4d50 100644
--- a/midori/midori-bookmarks.c
+++ b/midori/midori-bookmarks.c
@@ -152,12 +152,8 @@ midori_bookmarks_new (char** errmsg)
/* sqlite3_open will create the file if it did not exists already */
if (sqlite3_open (newfile, &db) != SQLITE_OK)
{
- if (db)
- *errmsg = g_strdup_printf (_("failed to open database: %s\n"),
- sqlite3_errmsg (db));
- else
- *errmsg = g_strdup (_("failed to open database\n"));
-
+ *errmsg = g_strdup_printf (_("Failed to open database: %s\n"),
+ db ? sqlite3_errmsg (db) : "(db = NULL)");
goto init_failed;
}
@@ -260,17 +256,9 @@ midori_bookmarks_new (char** errmsg)
/* initial creation */
if (sqlite3_exec (db, create_stmt, NULL, NULL, &sql_errmsg) != SQLITE_OK)
{
-
- if (errmsg)
- {
- if (sql_errmsg)
- {
- *errmsg = g_strdup_printf (_("could not create bookmarks table: %s\n"), sql_errmsg);
- sqlite3_free (sql_errmsg);
- }
- else
- *errmsg = g_strdup (_("could not create bookmarks table"));
- }
+ *errmsg = g_strdup_printf (_("Couldn't create bookmarks table: %s\n"),
+ sql_errmsg ? sql_errmsg : "(err = NULL)");
+ sqlite3_free (sql_errmsg);
/* we can as well remove the new file */
g_unlink (newfile);
@@ -283,16 +271,9 @@ midori_bookmarks_new (char** errmsg)
/* import from old db */
if (!midori_bookmarks_import_from_old_db (db, oldfile, &import_errmsg))
{
- if (errmsg)
- {
- if (import_errmsg)
- {
- *errmsg = g_strdup_printf (_("could not import from old database: %s\n"), import_errmsg);
- g_free (import_errmsg);
- }
- else
- *errmsg = g_strdup_printf (_("could not import from old database"));
- }
+ *errmsg = g_strdup_printf (_("Couldn't import from old database: %s\n"),
+ import_errmsg ? import_errmsg : "(err = NULL)");
+ g_free (import_errmsg);
}
init_success:
@@ -333,3 +314,14 @@ midori_bookmarks_import (const gchar* filename,
}
midori_bookmarks_import_array_db (db, bookmarks, 0);
}
+
+void
+midori_bookmarks_on_quit (KatzeArray* array)
+{
+ g_return_if_fail (KATZE_IS_ARRAY (array));
+
+ sqlite3* db = g_object_get_data (G_OBJECT (array), "db");
+ g_return_if_fail (db != NULL);
+ sqlite3_close (db);
+}
+
diff --git a/midori/midori-bookmarks.h b/midori/midori-bookmarks.h
index bb1e416..63eb033 100644
--- a/midori/midori-bookmarks.h
+++ b/midori/midori-bookmarks.h
@@ -30,6 +30,9 @@ KatzeArray*
midori_bookmarks_new (char** errmsg);
void
+midori_bookmarks_on_quit (KatzeArray* array);
+
+void
midori_bookmarks_import (const gchar* filename,
sqlite3* db);
diff --git a/midori/midori-history.c b/midori/midori-history.c
index 8c283f2..56599d9 100644
--- a/midori/midori-history.c
+++ b/midori/midori-history.c
@@ -44,12 +44,11 @@ midori_history_new (char** errmsg)
filename = midori_paths_get_config_filename_for_writing ("history.db");
if (sqlite3_open (filename, &db) != SQLITE_OK)
{
- if (errmsg)
- *errmsg = g_strdup_printf (_("Failed to open database: %s\n"),
- sqlite3_errmsg (db));
+ *errmsg = g_strdup_printf (_("Failed to open database: %s\n"),
+ db ? sqlite3_errmsg (db) : "(db = NULL)");
g_free (filename);
sqlite3_close (db);
- return FALSE;
+ return NULL;
}
g_free (filename);
diff --git a/tests/bookmarks.c b/tests/bookmarks.c
index 0b3564c..9d216c6 100644
--- a/tests/bookmarks.c
+++ b/tests/bookmarks.c
@@ -84,6 +84,7 @@ static void
fixture_teardown (BookmarksFixture* fixture,
const TestParameters *params)
{
+ midori_bookmarks_on_quit (fixture->db_bookmarks);
g_object_unref (fixture->db_bookmarks);
g_object_unref (fixture->test_bookmarks);
}
More information about the Xfce4-commits
mailing list