[epiphany/wip/bookmarks: 71/76] Add a convenience GAsyncReadyCallback to pass to ephy_bookmarks_manager_save_to_file_async
- From: Iulian Radu <iulianradu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/wip/bookmarks: 71/76] Add a convenience GAsyncReadyCallback to pass to ephy_bookmarks_manager_save_to_file_async
- Date: Wed, 28 Sep 2016 13:22:46 +0000 (UTC)
commit 57909f3888eccbd9a2629330677f9017d7f257b6
Author: Iulian Radu <iulian radu67 gmail com>
Date: Tue Sep 27 19:51:31 2016 +0300
Add a convenience GAsyncReadyCallback to pass to ephy_bookmarks_manager_save_to_file_async
src/ephy-add-bookmark-popover.c | 4 +-
src/ephy-bookmark-properties-grid.c | 4 +-
src/ephy-bookmarks-manager.c | 35 ++++++++-------
src/ephy-bookmarks-manager.h | 62 ++++++++++++++------------
src/profile-migrator/ephy-profile-migrator.c | 4 +-
5 files changed, 61 insertions(+), 48 deletions(-)
---
diff --git a/src/ephy-add-bookmark-popover.c b/src/ephy-add-bookmark-popover.c
index c01b644..881e747 100644
--- a/src/ephy-add-bookmark-popover.c
+++ b/src/ephy-add-bookmark-popover.c
@@ -156,7 +156,9 @@ ephy_add_bookmark_popover_update_bookmarked_status_cb (EphyAddBookmarkPopover *s
FALSE);
}
- ephy_bookmarks_manager_save_to_file_async (manager, NULL, NULL, NULL);
+ ephy_bookmarks_manager_save_to_file_async (manager, NULL,
+ ephy_bookmarks_manager_save_to_file_warn_on_error_cb,
+ NULL);
gtk_widget_hide (GTK_WIDGET (self));
diff --git a/src/ephy-bookmark-properties-grid.c b/src/ephy-bookmark-properties-grid.c
index adae3b2..fb87078 100644
--- a/src/ephy-bookmark-properties-grid.c
+++ b/src/ephy-bookmark-properties-grid.c
@@ -359,7 +359,9 @@ ephy_bookmark_properties_grid_finalize (GObject *object)
{
EphyBookmarkPropertiesGrid *self = EPHY_BOOKMARK_PROPERTIES_GRID (object);
- ephy_bookmarks_manager_save_to_file_async (self->manager, NULL, NULL, NULL);
+ ephy_bookmarks_manager_save_to_file_async (self->manager, NULL,
+ ephy_bookmarks_manager_save_to_file_warn_on_error_cb,
+ NULL);
G_OBJECT_CLASS (ephy_bookmark_properties_grid_parent_class)->finalize (object);
}
diff --git a/src/ephy-bookmarks-manager.c b/src/ephy-bookmarks-manager.c
index 6415440..ef9207a 100644
--- a/src/ephy-bookmarks-manager.c
+++ b/src/ephy-bookmarks-manager.c
@@ -87,19 +87,6 @@ build_variant (EphyBookmark *bookmark)
}
static void
-data_saved_cb (GObject *object,
- GAsyncResult *result,
- gpointer user_data)
-{
- EphyBookmarksManager *self = EPHY_BOOKMARKS_MANAGER (object);
- gboolean ret;
-
- ret = ephy_bookmarks_manager_save_to_file_finish (self, result, NULL);
- if (ret)
- LOG ("Bookmarks data saved");
-}
-
-static void
add_bookmark_to_table (EphyBookmark *bookmark, GHashTable *table)
{
gvdb_hash_table_insert_variant (table,
@@ -277,7 +264,7 @@ ephy_bookmarks_manager_add_bookmark (EphyBookmarksManager *self,
g_signal_emit (self, signals[BOOKMARK_ADDED], 0, bookmark);
ephy_bookmarks_manager_save_to_file_async (self, NULL,
- (GAsyncReadyCallback)data_saved_cb,
+
(GAsyncReadyCallback)ephy_bookmarks_manager_save_to_file_warn_on_error_cb,
NULL);
}
}
@@ -308,7 +295,7 @@ ephy_bookmarks_manager_add_bookmarks (EphyBookmarksManager *self,
NULL);
ephy_bookmarks_manager_save_to_file_async (self, NULL,
- (GAsyncReadyCallback)data_saved_cb,
+
(GAsyncReadyCallback)ephy_bookmarks_manager_save_to_file_warn_on_error_cb,
NULL);
}
@@ -337,7 +324,7 @@ ephy_bookmarks_manager_remove_bookmark (EphyBookmarksManager *self,
g_list_model_items_changed (G_LIST_MODEL (self), position, 1, 0);
ephy_bookmarks_manager_save_to_file_async (self, NULL,
- (GAsyncReadyCallback)data_saved_cb,
+
(GAsyncReadyCallback)ephy_bookmarks_manager_save_to_file_warn_on_error_cb,
NULL);
}
@@ -574,3 +561,19 @@ ephy_bookmarks_manager_load_from_file (EphyBookmarksManager *self)
g_sequence_free (bookmarks);
gvdb_table_free (root_table);
}
+
+void
+ephy_bookmarks_manager_save_to_file_warn_on_error_cb (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ EphyBookmarksManager *self = EPHY_BOOKMARKS_MANAGER (object);
+ gboolean ret;
+ GError *error;
+
+ ret = ephy_bookmarks_manager_save_to_file_finish (self, result, &error);
+ if (ret == FALSE) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
+}
diff --git a/src/ephy-bookmarks-manager.h b/src/ephy-bookmarks-manager.h
index 9d65184..9817260 100644
--- a/src/ephy-bookmarks-manager.h
+++ b/src/ephy-bookmarks-manager.h
@@ -28,34 +28,38 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (EphyBookmarksManager, ephy_bookmarks_manager, EPHY, BOOKMARKS_MANAGER, GObject)
-void ephy_bookmarks_manager_add_bookmark (EphyBookmarksManager *self,
- EphyBookmark *bookmark);
-void ephy_bookmarks_manager_add_bookmarks (EphyBookmarksManager *self,
- GSequence *bookmarks);
-void ephy_bookmarks_manager_remove_bookmark (EphyBookmarksManager *self,
- EphyBookmark *bookmark);
-EphyBookmark *ephy_bookmarks_manager_get_bookmark_by_url (EphyBookmarksManager *self,
- const char *url);
-
-void ephy_bookmarks_manager_add_tag (EphyBookmarksManager *self,
- const char *tag);
-void ephy_bookmarks_manager_remove_tag (EphyBookmarksManager *self,
- const char *tag);
-gboolean ephy_bookmarks_manager_tag_exists (EphyBookmarksManager *self,
- const char *tag);
-
-GSequence *ephy_bookmarks_manager_get_bookmarks (EphyBookmarksManager *self);
-GSequence *ephy_bookmarks_manager_get_bookmarks_with_tag (EphyBookmarksManager *self,
- const char *tag);
-GSequence *ephy_bookmarks_manager_get_tags (EphyBookmarksManager *self);
-
-void ephy_bookmarks_manager_save_to_file_async (EphyBookmarksManager *self,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean ephy_bookmarks_manager_save_to_file_finish (EphyBookmarksManager *self,
- GAsyncResult *result,
- GError **error);
-void ephy_bookmarks_manager_load_from_file (EphyBookmarksManager *self);
+void ephy_bookmarks_manager_add_bookmark (EphyBookmarksManager *self,
+ EphyBookmark *bookmark);
+void ephy_bookmarks_manager_add_bookmarks (EphyBookmarksManager *self,
+ GSequence *bookmarks);
+void ephy_bookmarks_manager_remove_bookmark (EphyBookmarksManager *self,
+ EphyBookmark *bookmark);
+EphyBookmark *ephy_bookmarks_manager_get_bookmark_by_url (EphyBookmarksManager *self,
+ const char *url);
+
+void ephy_bookmarks_manager_add_tag (EphyBookmarksManager *self,
+ const char *tag);
+void ephy_bookmarks_manager_remove_tag (EphyBookmarksManager *self,
+ const char *tag);
+gboolean ephy_bookmarks_manager_tag_exists (EphyBookmarksManager *self,
+ const char *tag);
+
+GSequence *ephy_bookmarks_manager_get_bookmarks (EphyBookmarksManager *self);
+GSequence *ephy_bookmarks_manager_get_bookmarks_with_tag (EphyBookmarksManager *self,
+ const char *tag);
+GSequence *ephy_bookmarks_manager_get_tags (EphyBookmarksManager *self);
+
+void ephy_bookmarks_manager_save_to_file_async (EphyBookmarksManager *self,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean ephy_bookmarks_manager_save_to_file_finish (EphyBookmarksManager *self,
+ GAsyncResult *result,
+ GError **error);
+void ephy_bookmarks_manager_load_from_file (EphyBookmarksManager *self);
+
+void ephy_bookmarks_manager_save_to_file_warn_on_error_cb (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data);
G_END_DECLS
diff --git a/src/profile-migrator/ephy-profile-migrator.c b/src/profile-migrator/ephy-profile-migrator.c
index c9f2b2b..f2e39b0 100644
--- a/src/profile-migrator/ephy-profile-migrator.c
+++ b/src/profile-migrator/ephy-profile-migrator.c
@@ -855,7 +855,9 @@ migrate_bookmarks (void)
child = child->next;
}
- ephy_bookmarks_manager_save_to_file_async (manager, NULL, NULL, NULL);
+ ephy_bookmarks_manager_save_to_file_async (manager, NULL,
+ ephy_bookmarks_manager_save_to_file_warn_on_error_cb,
+ NULL);
xmlFreeDoc (doc);
g_clear_object (&manager);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]