[epiphany/wip/ephy-sync] bookmarks: Save changes to file on edit
- From: Gabriel - Cristian Ivascu <gabrielivascu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/wip/ephy-sync] bookmarks: Save changes to file on edit
- Date: Mon, 8 Aug 2016 18:22:32 +0000 (UTC)
commit 62aa902115ac05c0b5d6c027810b716ccf6abf25
Author: Iulian Radu <iulian radu67 gmail com>
Date: Tue Aug 2 00:37:40 2016 +0300
bookmarks: Save changes to file on edit
src/ephy-bookmark-properties-grid.c | 32 +++++++++++++++++++++++++++-----
src/ephy-bookmark-row.c | 2 +-
src/ephy-bookmark.c | 20 +++++++++++++++++++-
src/ephy-bookmark.h | 5 +++++
4 files changed, 52 insertions(+), 7 deletions(-)
---
diff --git a/src/ephy-bookmark-properties-grid.c b/src/ephy-bookmark-properties-grid.c
index 62c5ee3..f202bff 100644
--- a/src/ephy-bookmark-properties-grid.c
+++ b/src/ephy-bookmark-properties-grid.c
@@ -266,9 +266,15 @@ get_address (const char *url)
{
SoupURI *uri;
char *address;
- int len;
uri = soup_uri_new (url);
+ if (!uri) {
+ url = g_strconcat (SOUP_URI_SCHEME_HTTP,
+ "://",
+ url,
+ NULL);
+ uri = soup_uri_new (url);
+ }
address = g_strconcat (soup_uri_get_host (uri),
soup_uri_get_path (uri),
soup_uri_get_query (uri),
@@ -276,10 +282,6 @@ get_address (const char *url)
NULL);
soup_uri_free (uri);
- len = strlen (address);
- if (address[len - 1] == '/')
- address[len - 1] = '\0';
-
return address;
}
@@ -297,11 +299,19 @@ ephy_bookmark_properties_grid_constructed (GObject *object)
gtk_entry_set_text (GTK_ENTRY (self->name_entry),
ephy_bookmark_get_title (self->bookmark));
+ g_object_bind_property (GTK_ENTRY (self->name_entry), "text",
+ self->bookmark, "title",
+ G_BINDING_DEFAULT);
+
/* Set text for address entry */
address = get_address (ephy_bookmark_get_url (self->bookmark));
gtk_entry_set_text (GTK_ENTRY (self->address_entry), address);
g_free (address);
+ g_object_bind_property (GTK_ENTRY (self->address_entry), "text",
+ self->bookmark, "url",
+ G_BINDING_DEFAULT);
+
/* Create tag widgets */
tags = ephy_bookmarks_manager_get_tags (manager);
bookmark_tags = ephy_bookmark_get_tags (self->bookmark);
@@ -330,6 +340,16 @@ ephy_bookmark_properties_grid_constructed (GObject *object)
}
static void
+ephy_bookmark_properties_grid_destroy (GtkWidget *widget)
+{
+ EphyBookmarksManager *manager = ephy_shell_get_bookmarks_manager (ephy_shell_get_default ());
+
+ ephy_bookmarks_manager_save_to_file_async (manager, NULL, NULL, NULL);
+
+ GTK_WIDGET_CLASS (ephy_bookmark_properties_grid_parent_class)->destroy (widget);
+}
+
+static void
ephy_bookmark_properties_grid_class_init (EphyBookmarkPropertiesGridClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -338,6 +358,8 @@ ephy_bookmark_properties_grid_class_init (EphyBookmarkPropertiesGridClass *klass
object_class->set_property = ephy_bookmark_properties_grid_set_property;
object_class->constructed = ephy_bookmark_properties_grid_constructed;
+ widget_class->destroy = ephy_bookmark_properties_grid_destroy;
+
obj_properties[PROP_BOOKMARK] =
g_param_spec_object ("bookmark",
"An EphyBookmark object",
diff --git a/src/ephy-bookmark-row.c b/src/ephy-bookmark-row.c
index 11de228..bffe2b3 100644
--- a/src/ephy-bookmark-row.c
+++ b/src/ephy-bookmark-row.c
@@ -78,7 +78,7 @@ ephy_bookmark_row_favicon_loaded_cb (GObject *source,
gpointer user_data)
{
EphyBookmarkRow *self = user_data;
- WebKitFaviconDatabase *database = (WebKitFaviconDatabase *)source;
+ WebKitFaviconDatabase *database = WEBKIT_FAVICON_DATABASE (source);
cairo_surface_t *icon_surface;
GdkPixbuf *favicon = NULL;
diff --git a/src/ephy-bookmark.c b/src/ephy-bookmark.c
index b49800b..2c73717 100644
--- a/src/ephy-bookmark.c
+++ b/src/ephy-bookmark.c
@@ -249,13 +249,31 @@ ephy_bookmark_new (char *url, char *title, GSequence *tags)
NULL);
}
+void
+ephy_bookmark_set_url (EphyBookmark *self, const char *url)
+{
+ g_return_if_fail (EPHY_IS_BOOKMARK (self));
+
+ self->url = g_strdup (url);
+}
+
const char *
-ephy_bookmark_get_url (EphyBookmark *self) {
+ephy_bookmark_get_url (EphyBookmark *self)
+{
g_return_val_if_fail (EPHY_IS_BOOKMARK (self), NULL);
return self->url;
}
+void
+ephy_bookmark_set_title (EphyBookmark *self, const char *title)
+{
+ g_return_if_fail (EPHY_IS_BOOKMARK (self));
+
+ self->title = g_strdup (title);
+ g_object_notify_by_pspec (G_OBJECT (self), obj_properties[PROP_TITLE]);
+}
+
const char *
ephy_bookmark_get_title (EphyBookmark *bookmark)
{
diff --git a/src/ephy-bookmark.h b/src/ephy-bookmark.h
index 14c2c23..3d89c14 100644
--- a/src/ephy-bookmark.h
+++ b/src/ephy-bookmark.h
@@ -30,7 +30,12 @@ EphyBookmark *ephy_bookmark_new (char *url,
char *title,
GSequence *tags);
+void ephy_bookmark_set_url (EphyBookmark *self,
+ const char *url);
const char *ephy_bookmark_get_url (EphyBookmark *self);
+
+void ephy_bookmark_set_title (EphyBookmark *self,
+ const char *title);
const char *ephy_bookmark_get_title (EphyBookmark *self);
const char *ephy_bookmark_get_id (EphyBookmark *self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]