[epiphany/wip/sync: 8/13] bookmark-properties-grid: Don't manually check for changes, there are signals in manager just for th
- From: Gabriel Ivașcu <gabrielivascu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/wip/sync: 8/13] bookmark-properties-grid: Don't manually check for changes, there are signals in manager just for th
- Date: Wed, 29 Mar 2017 17:44:50 +0000 (UTC)
commit 83679fd74e89f8d49a69ee78b6304df3a0218627
Author: Gabriel Ivascu <ivascu gabriel59 gmail com>
Date: Tue Mar 28 14:31:29 2017 +0300
bookmark-properties-grid: Don't manually check for changes, there are signals in manager just for that
src/bookmarks/ephy-bookmark-properties-grid.c | 58 +------------------------
src/bookmarks/ephy-bookmarks-manager.c | 4 ++
2 files changed, 5 insertions(+), 57 deletions(-)
---
diff --git a/src/bookmarks/ephy-bookmark-properties-grid.c b/src/bookmarks/ephy-bookmark-properties-grid.c
index d99c582..081d3e7 100644
--- a/src/bookmarks/ephy-bookmark-properties-grid.c
+++ b/src/bookmarks/ephy-bookmark-properties-grid.c
@@ -53,10 +53,6 @@ struct _EphyBookmarkPropertiesGrid {
GtkWidget *add_tag_entry;
GtkWidget *add_tag_button;
GtkWidget *remove_bookmark_button;
-
- char *prev_name;
- char *prev_address;
- GSequence *prev_tags;
};
G_DEFINE_TYPE (EphyBookmarkPropertiesGrid, ephy_bookmark_properties_grid, GTK_TYPE_GRID)
@@ -329,7 +325,6 @@ ephy_bookmark_properties_grid_constructed (GObject *object)
/* Set text for name entry */
gtk_entry_set_text (GTK_ENTRY (self->name_entry),
ephy_bookmark_get_title (self->bookmark));
- self->prev_name = g_strdup (gtk_entry_get_text (GTK_ENTRY (self->name_entry)));
g_object_bind_property (GTK_ENTRY (self->name_entry), "text",
self->bookmark, "title",
@@ -342,7 +337,6 @@ ephy_bookmark_properties_grid_constructed (GObject *object)
decoded_address = ephy_uri_decode (address);
gtk_entry_set_text (GTK_ENTRY (self->address_entry), decoded_address);
g_free (decoded_address);
- self->prev_address = g_strdup (gtk_entry_get_text (GTK_ENTRY (self->address_entry)));
g_object_bind_property (GTK_ENTRY (self->address_entry), "text",
self->bookmark, "bmkUri",
@@ -350,7 +344,6 @@ ephy_bookmark_properties_grid_constructed (GObject *object)
}
/* Create tag widgets */
- self->prev_tags = g_sequence_new (g_free);
tags = ephy_bookmarks_manager_get_tags (self->manager);
bookmark_tags = ephy_bookmark_get_tags (self->bookmark);
for (iter = g_sequence_get_begin_iter (tags);
@@ -363,11 +356,8 @@ ephy_bookmark_properties_grid_constructed (GObject *object)
if (g_sequence_lookup (bookmark_tags,
(gpointer)tag,
(GCompareDataFunc)ephy_bookmark_tags_compare,
- NULL)) {
+ NULL))
selected = TRUE;
- g_sequence_insert_sorted (self->prev_tags, g_strdup (tag),
- (GCompareDataFunc)ephy_bookmark_tags_compare, NULL);
- }
widget = ephy_bookmark_properties_grid_create_tag_widget (self, tag, selected);
gtk_flow_box_insert (GTK_FLOW_BOX (self->tags_box), widget, -1);
@@ -381,56 +371,10 @@ ephy_bookmark_properties_grid_constructed (GObject *object)
}
static void
-ephy_bookmark_properties_grid_check_prev_values (EphyBookmarkPropertiesGrid *self)
-{
- if (ephy_bookmark_is_uploaded (self->bookmark) == FALSE)
- return;
-
- /* Check if any actual changes were made to the name, address or tags. If yes,
- * set the uploaded flag to FALSE. */
-
- if (g_strcmp0 (self->prev_name, ephy_bookmark_get_title (self->bookmark)) != 0) {
- ephy_bookmark_set_is_uploaded (self->bookmark, FALSE);
- return;
- }
-
- if (g_strcmp0 (self->prev_address, ephy_bookmark_get_url (self->bookmark)) != 0) {
- ephy_bookmark_set_is_uploaded (self->bookmark, FALSE);
- return;
- }
-
- if (self->prev_tags != NULL) {
- GSequence *tags = ephy_bookmark_get_tags (self->bookmark);
- GSequenceIter *iter;
-
- /* Check for added tags. */
- for (iter = g_sequence_get_begin_iter (tags);
- !g_sequence_iter_is_end (iter); iter = g_sequence_iter_next (iter)) {
- if (!g_sequence_lookup (self->prev_tags, g_sequence_get (iter),
- (GCompareDataFunc)ephy_bookmark_tags_compare, NULL)) {
- ephy_bookmark_set_is_uploaded (self->bookmark, FALSE);
- return;
- }
- }
-
- /* Check for deleted tags. */
- for (iter = g_sequence_get_begin_iter (self->prev_tags);
- !g_sequence_iter_is_end (iter); iter = g_sequence_iter_next (iter)) {
- if (!g_sequence_lookup (tags, g_sequence_get (iter),
- (GCompareDataFunc)ephy_bookmark_tags_compare, NULL)) {
- ephy_bookmark_set_is_uploaded (self->bookmark, FALSE);
- return;
- }
- }
- }
-}
-
-static void
ephy_bookmark_properties_grid_finalize (GObject *object)
{
EphyBookmarkPropertiesGrid *self = EPHY_BOOKMARK_PROPERTIES_GRID (object);
- ephy_bookmark_properties_grid_check_prev_values (self);
ephy_bookmarks_manager_save_to_file_async (self->manager, NULL,
ephy_bookmarks_manager_save_to_file_warn_on_error_cb,
NULL);
diff --git a/src/bookmarks/ephy-bookmarks-manager.c b/src/bookmarks/ephy-bookmarks-manager.c
index 7b565c5..359c8e3 100644
--- a/src/bookmarks/ephy-bookmarks-manager.c
+++ b/src/bookmarks/ephy-bookmarks-manager.c
@@ -396,6 +396,7 @@ bookmark_title_changed_cb (EphyBookmark *bookmark,
GParamSpec *pspec,
EphyBookmarksManager *self)
{
+ ephy_bookmark_set_is_uploaded (bookmark, FALSE);
g_signal_emit (self, signals[BOOKMARK_TITLE_CHANGED], 0, bookmark);
}
@@ -404,6 +405,7 @@ bookmark_url_changed_cb (EphyBookmark *bookmark,
GParamSpec *pspec,
EphyBookmarksManager *self)
{
+ ephy_bookmark_set_is_uploaded (bookmark, FALSE);
g_signal_emit (self, signals[BOOKMARK_URL_CHANGED], 0, bookmark);
}
@@ -412,6 +414,7 @@ bookmark_tag_added_cb (EphyBookmark *bookmark,
const char *tag,
EphyBookmarksManager *self)
{
+ ephy_bookmark_set_is_uploaded (bookmark, FALSE);
g_signal_emit (self, signals[BOOKMARK_TAG_ADDED], 0, bookmark, tag);
}
@@ -420,6 +423,7 @@ bookmark_tag_removed_cb (EphyBookmark *bookmark,
const char *tag,
EphyBookmarksManager *self)
{
+ ephy_bookmark_set_is_uploaded (bookmark, FALSE);
g_signal_emit (self, signals[BOOKMARK_TAG_REMOVED], 0, bookmark, tag);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]