From 394fbd934dd421dd694a6b190780087f5a984d02 Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Fri, 17 Feb 2012 00:43:01 +0100 Subject: [PATCH] Update style --- bookmarks.c | 20 +++++++++++++------- zathura.c | 4 +--- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/bookmarks.c b/bookmarks.c index e0a90ed..5fc94d5 100644 --- a/bookmarks.c +++ b/bookmarks.c @@ -32,8 +32,9 @@ zathura_bookmark_add(zathura_t* zathura, const gchar* id, unsigned int page) bookmark->id = g_strdup(id); bookmark->page = page; girara_list_append(zathura->bookmarks.bookmarks, bookmark); - if (zathura->database) { - if (!zathura_db_add_bookmark(zathura->database, zathura->document->file_path, bookmark)) { + + if (zathura->database != NULL) { + if (zathura_db_add_bookmark(zathura->database, zathura->document->file_path, bookmark) == false) { girara_warning("Failed to add bookmark to database."); } } @@ -48,15 +49,16 @@ zathura_bookmark_remove(zathura_t* zathura, const gchar* id) g_return_val_if_fail(id, false); zathura_bookmark_t* bookmark = zathura_bookmark_get(zathura, id); - if (!bookmark) { + if (bookmark == NULL) { return false; } - if (zathura->database) { - if (!zathura_db_remove_bookmark(zathura->database, zathura->document->file_path, bookmark->id)) { + if (zathura->database != NULL) { + if (zathura_db_remove_bookmark(zathura->database, zathura->document->file_path, bookmark->id) == false) { girara_warning("Failed to remove bookmark from database."); } } + girara_list_remove(zathura->bookmarks.bookmarks, bookmark); return true; @@ -74,7 +76,7 @@ zathura_bookmark_get(zathura_t* zathura, const gchar* id) void zathura_bookmark_free(zathura_bookmark_t* bookmark) { - if (!bookmark) { + if (bookmark == NULL) { return; } @@ -86,17 +88,19 @@ bool zathura_bookmarks_load(zathura_t* zathura, const gchar* file) { g_return_val_if_fail(zathura, false); g_return_val_if_fail(file, false); + if (zathura->database == NULL) { return false; } girara_list_t* bookmarks = zathura_db_load_bookmarks(zathura->database, file); - if (!bookmarks) { + if (bookmarks == NULL) { return false; } girara_list_free(zathura->bookmarks.bookmarks); zathura->bookmarks.bookmarks = bookmarks; + return true; } @@ -106,9 +110,11 @@ zathura_bookmarks_compare(zathura_bookmark_t* lhs, zathura_bookmark_t* rhs) if (lhs == NULL && rhs == NULL) { return 0; } + if (lhs == NULL) { return -1; } + if (rhs == NULL) { return 1; } diff --git a/zathura.c b/zathura.c index 1aed38e..ee0fa24 100644 --- a/zathura.c +++ b/zathura.c @@ -431,9 +431,7 @@ document_open(zathura_t* zathura, const char* path, const char* password) } /* bookmarks */ - if (zathura_bookmarks_load(zathura, zathura->document->file_path) == false) { - girara_warning("Failed to load bookmarks for %s.\n", zathura->document->file_path); - } + zathura_bookmarks_load(zathura, zathura->document->file_path); page_set_delayed(zathura, document->current_page_number - 1); cb_view_vadjustment_value_changed(NULL, zathura);