diff options
author | Xan Lopez <xan@igalia.com> | 2012-02-29 23:35:32 +0800 |
---|---|---|
committer | Xan Lopez <xan@igalia.com> | 2012-03-07 04:49:44 +0800 |
commit | 92dec4e47d68bfb77be9ff256fcf44d1407d4ef4 (patch) | |
tree | ce2d1e7a37a200d7ca714761c4a44685d11f594f | |
parent | 8ad6302a3f9e1a867f3dd61605196d22e9bd2f86 (diff) | |
download | gsoc2013-epiphany-92dec4e47d68bfb77be9ff256fcf44d1407d4ef4.tar gsoc2013-epiphany-92dec4e47d68bfb77be9ff256fcf44d1407d4ef4.tar.gz gsoc2013-epiphany-92dec4e47d68bfb77be9ff256fcf44d1407d4ef4.tar.bz2 gsoc2013-epiphany-92dec4e47d68bfb77be9ff256fcf44d1407d4ef4.tar.lz gsoc2013-epiphany-92dec4e47d68bfb77be9ff256fcf44d1407d4ef4.tar.xz gsoc2013-epiphany-92dec4e47d68bfb77be9ff256fcf44d1407d4ef4.tar.zst gsoc2013-epiphany-92dec4e47d68bfb77be9ff256fcf44d1407d4ef4.zip |
Store zoom levels per host, not per URL
Zoom levels have always been stored per host in Epiphany, not per URL
(otherwise you'd have to re-apply the zoom level again and again when
visiting, say, every news entry in your favorite newspaper). Change
things to work like that.
Note: this changes the SQL table format for the history, so you'll
need to re-migrate your history.
-rw-r--r-- | embed/ephy-browse-history.c | 21 | ||||
-rw-r--r-- | embed/ephy-browse-history.h | 5 | ||||
-rw-r--r-- | embed/ephy-embed.c | 23 | ||||
-rw-r--r-- | lib/ephy-profile-migrator.c | 24 | ||||
-rw-r--r-- | lib/history/ephy-history-service-hosts-table.c | 35 | ||||
-rw-r--r-- | lib/history/ephy-history-service-urls-table.c | 28 | ||||
-rw-r--r-- | lib/history/ephy-history-service.c | 76 | ||||
-rw-r--r-- | lib/history/ephy-history-service.h | 1 | ||||
-rw-r--r-- | lib/history/ephy-history-types.c | 14 | ||||
-rw-r--r-- | lib/history/ephy-history-types.h | 7 | ||||
-rw-r--r-- | tests/ephy-history.c | 4 |
11 files changed, 148 insertions, 90 deletions
diff --git a/embed/ephy-browse-history.c b/embed/ephy-browse-history.c index c58eaeaf7..45d0d1c4e 100644 --- a/embed/ephy-browse-history.c +++ b/embed/ephy-browse-history.c @@ -158,11 +158,10 @@ ephy_browse_history_set_page_zoom_level (EphyBrowseHistory *history, g_return_if_fail (EPHY_IS_BROWSE_HISTORY (history)); g_return_if_fail (url != NULL); - ephy_history_service_set_url_property (history->priv->history_service, - url, - EPHY_HISTORY_URL_ZOOM_LEVEL, - g_variant_new_double (zoom_level), - NULL, NULL); + ephy_history_service_set_url_zoom_level (history->priv->history_service, + url, + zoom_level, + NULL, NULL); } void @@ -214,3 +213,15 @@ ephy_browse_history_delete_urls (EphyBrowseHistory *history, ephy_history_service_delete_urls (history->priv->history_service, urls, callback, user_data); } + +void +ephy_browse_history_get_host_for_url (EphyBrowseHistory *history, + const char *url, + EphyHistoryJobCallback callback, + gpointer user_data) +{ + g_return_if_fail (EPHY_IS_BROWSE_HISTORY (history)); + + ephy_history_service_get_host_for_url (history->priv->history_service, + url, callback, user_data); +} diff --git a/embed/ephy-browse-history.h b/embed/ephy-browse-history.h index 980134af5..1acc97b7e 100644 --- a/embed/ephy-browse-history.h +++ b/embed/ephy-browse-history.h @@ -103,6 +103,11 @@ void ephy_browse_history_delete_urls (EphyBrowseHistory *history, EphyHistoryJobCallback callback, gpointer user_data); +void ephy_browse_history_get_host_for_url (EphyBrowseHistory *history, + const char *url, + EphyHistoryJobCallback callback, + gpointer user_data); + G_END_DECLS #endif /* _EPHY_BROWSE_HISTORY_H */ diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c index 49a2e1568..b9f1f46d6 100644 --- a/embed/ephy-embed.c +++ b/embed/ephy-embed.c @@ -230,12 +230,12 @@ ephy_embed_statusbar_pop (EphyEmbed *embed, guint context_id) } static void -get_url_for_zoom_cb (gpointer service, +get_host_for_url_cb (gpointer service, gboolean success, gpointer result_data, gpointer user_data) { - EphyHistoryURL *url; + EphyHistoryHost *host; EphyEmbed *embed; WebKitWebView *web_view; double current_zoom; @@ -244,22 +244,21 @@ get_url_for_zoom_cb (gpointer service, return; embed = EPHY_EMBED (user_data); - url = (EphyHistoryURL *) result_data; - - g_assert (url != NULL); + host = (EphyHistoryHost *)result_data; web_view = embed->priv->web_view; - g_object_get (web_view, "zoom-level", ¤t_zoom, + g_object_get (web_view, + "zoom-level", ¤t_zoom, NULL); - if (url->zoom_level != current_zoom) { + if (host->zoom_level != current_zoom) { embed->priv->is_setting_zoom = TRUE; - g_object_set (web_view, "zoom-level", url->zoom_level, NULL); + g_object_set (web_view, "zoom-level", host->zoom_level, NULL); embed->priv->is_setting_zoom = FALSE; } - ephy_history_url_free (url); + ephy_history_host_free (host); } static void @@ -268,9 +267,9 @@ restore_zoom_level (EphyEmbed *embed, { /* restore zoom level */ if (ephy_embed_utils_address_has_web_scheme (address)) { - ephy_browse_history_get_url (embed->priv->browse_history, - address, - (EphyHistoryJobCallback)get_url_for_zoom_cb, embed); + ephy_browse_history_get_host_for_url (embed->priv->browse_history, + address, + (EphyHistoryJobCallback)get_host_for_url_cb, embed); } } diff --git a/lib/ephy-profile-migrator.c b/lib/ephy-profile-migrator.c index f660d9366..d4d4afbfd 100644 --- a/lib/ephy-profile-migrator.c +++ b/lib/ephy-profile-migrator.c @@ -467,21 +467,22 @@ history_parse_text (GMarkupParseContext *context, } else if (g_str_equal (parse_data->current, "4")) { /* Visit count */ GString *data = g_string_new_len (text, text_len); - sscanf(data->str, "%lld", &parse_data->visit_count); + sscanf (data->str, "%lld", &parse_data->visit_count); g_string_free (data, TRUE); } else if (g_str_equal (parse_data->current, "5")) { /* Last visit */ GString *data = g_string_new_len (text, text_len); - sscanf(data->str, "%lld", &parse_data->last_visit); + sscanf (data->str, "%lld", &parse_data->last_visit); g_string_free (data, TRUE); } else if (g_str_equal (parse_data->current, "6")) { /* First visit */ GString *data = g_string_new_len (text, text_len); - sscanf(data->str, "%lld", &parse_data->first_visit); + sscanf (data->str, "%lld", &parse_data->first_visit); g_string_free (data, TRUE); } else if (g_str_equal (parse_data->current, "10")) { + /* Zoom level. */ GString *data = g_string_new_len (text, text_len); - sscanf(data->str, "%lf", &parse_data->zoom_level); + sscanf (data->str, "%lf", &parse_data->zoom_level); g_string_free (data, TRUE); } @@ -505,10 +506,21 @@ history_parse_end_element (GMarkupParseContext *context, if (g_str_equal (element_name, "node") && parse_data) { /* Add one item to History */ - EphyHistoryPageVisit *visit = ephy_history_page_visit_new (parse_data->location ? parse_data->location : "", parse_data->last_visit, EPHY_PAGE_VISIT_TYPED); + EphyHistoryPageVisit *visit = ephy_history_page_visit_new (parse_data->location ? parse_data->location : "", + parse_data->last_visit, EPHY_PAGE_VISIT_TYPED); g_free (visit->url->title); visit->url->title = g_strdup (parse_data->title); - visit->url->zoom_level = parse_data->zoom_level; + + if (parse_data->zoom_level) { + /* Zoom levels are only stored per host in the old history, so + * creating a new host here is OK. */ + if (!visit->url->host) + visit->url->host = ephy_history_host_new (parse_data->location, parse_data->title, + parse_data->visit_count, parse_data->zoom_level); + else + visit->url->host->zoom_level = parse_data->zoom_level; + } + parse_data->visits = g_list_append (parse_data->visits, visit); } } diff --git a/lib/history/ephy-history-service-hosts-table.c b/lib/history/ephy-history-service-hosts-table.c index 8dcd3d7f4..df4ccf2ec 100644 --- a/lib/history/ephy-history-service-hosts-table.c +++ b/lib/history/ephy-history-service-hosts-table.c @@ -40,7 +40,8 @@ ephy_history_service_initialize_hosts_table (EphyHistoryService *self) "url LONGVARCAR," "title LONGVARCAR," "visit_count INTEGER DEFAULT 0 NOT NULL," - "favicon_id INTEGER DEFAULT 0 NOT NULL)", &error); + "favicon_id INTEGER DEFAULT 0 NOT NULL," + "zoom_level REAL DEFAULT 1.0)", &error); if (error) { g_error("Could not create hosts table: %s", error->message); @@ -62,8 +63,8 @@ ephy_history_service_add_host_row (EphyHistoryService *self, EphyHistoryHost *ho g_assert (priv->history_database != NULL); statement = ephy_sqlite_connection_create_statement (priv->history_database, - "INSERT INTO hosts (url, title, visit_count) " - "VALUES (?, ?, ?)", &error); + "INSERT INTO hosts (url, title, visit_count, zoom_level) " + "VALUES (?, ?, ?, ?)", &error); if (error) { g_error ("Could not build hosts table addition statement: %s", error->message); @@ -73,7 +74,8 @@ ephy_history_service_add_host_row (EphyHistoryService *self, EphyHistoryHost *ho if (ephy_sqlite_statement_bind_string (statement, 0, host->url, &error) == FALSE || ephy_sqlite_statement_bind_string (statement, 1, host->title, &error) == FALSE || - ephy_sqlite_statement_bind_int (statement, 2, host->visit_count, &error) == FALSE) { + ephy_sqlite_statement_bind_int (statement, 2, host->visit_count, &error) == FALSE || + ephy_sqlite_statement_bind_double (statement, 3, host->zoom_level, &error) == FALSE) { g_error ("Could not insert host into hosts table: %s", error->message); g_error_free (error); return; @@ -102,7 +104,7 @@ ephy_history_service_update_host_row (EphyHistoryService *self, EphyHistoryHost g_assert (priv->history_database != NULL); statement = ephy_sqlite_connection_create_statement (priv->history_database, - "UPDATE hosts SET url=?, title=?, visit_count=?" + "UPDATE hosts SET url=?, title=?, visit_count=?, zoom_level=?" "WHERE id=?", &error); if (error) { g_error ("Could not build hosts table modification statement: %s", error->message); @@ -113,7 +115,8 @@ ephy_history_service_update_host_row (EphyHistoryService *self, EphyHistoryHost if (ephy_sqlite_statement_bind_string (statement, 0, host->url, &error) == FALSE || ephy_sqlite_statement_bind_string (statement, 1, host->title, &error) == FALSE || ephy_sqlite_statement_bind_int (statement, 2, host->visit_count, &error) == FALSE || - ephy_sqlite_statement_bind_int (statement, 3, host->id, &error) == FALSE) { + ephy_sqlite_statement_bind_double (statement, 3, host->zoom_level, &error) == FALSE || + ephy_sqlite_statement_bind_int (statement, 4, host->id, &error) == FALSE) { g_error ("Could not modify host in hosts table: %s", error->message); g_error_free (error); return; @@ -144,11 +147,11 @@ ephy_history_service_get_host_row (EphyHistoryService *self, const gchar *host_s if (host != NULL && host->id != -1) { statement = ephy_sqlite_connection_create_statement (priv->history_database, - "SELECT id, url, title, visit_count FROM hosts " + "SELECT id, url, title, visit_count, zoom_level FROM hosts " "WHERE id=?", &error); } else { statement = ephy_sqlite_connection_create_statement (priv->history_database, - "SELECT id, url, title, visit_count FROM hosts " + "SELECT id, url, title, visit_count, zoom_level FROM hosts " "WHERE url=?", &error); } @@ -176,7 +179,7 @@ ephy_history_service_get_host_row (EphyHistoryService *self, const gchar *host_s } if (host == NULL) { - host = ephy_history_host_new (NULL, NULL, 0); + host = ephy_history_host_new (NULL, NULL, 0, 1.0); } else { if (host->url) g_free (host->url); @@ -185,9 +188,10 @@ ephy_history_service_get_host_row (EphyHistoryService *self, const gchar *host_s } host->id = ephy_sqlite_statement_get_column_as_int (statement, 0); - host->url = g_strdup (ephy_sqlite_statement_get_column_as_string (statement, 1)), - host->title = g_strdup (ephy_sqlite_statement_get_column_as_string (statement, 2)), - host->visit_count = ephy_sqlite_statement_get_column_as_int (statement, 3), + host->url = g_strdup (ephy_sqlite_statement_get_column_as_string (statement, 1)); + host->title = g_strdup (ephy_sqlite_statement_get_column_as_string (statement, 2)); + host->visit_count = ephy_sqlite_statement_get_column_as_int (statement, 3); + host->zoom_level = ephy_sqlite_statement_get_column_as_double (statement, 4); g_object_unref (statement); return host; @@ -199,7 +203,8 @@ create_host_from_statement (EphySQLiteStatement *statement) EphyHistoryHost *host = ephy_history_host_new (ephy_sqlite_statement_get_column_as_string (statement, 1), ephy_sqlite_statement_get_column_as_string (statement, 2), - ephy_sqlite_statement_get_column_as_int (statement, 3)); + ephy_sqlite_statement_get_column_as_int (statement, 3), + ephy_sqlite_statement_get_column_as_double (statement, 4)); host->id = ephy_sqlite_statement_get_column_as_int (statement, 0); return host; @@ -217,7 +222,7 @@ ephy_history_service_get_all_hosts (EphyHistoryService *self) g_assert (priv->history_database != NULL); statement = ephy_sqlite_connection_create_statement (priv->history_database, - "SELECT id, url, title, visit_count FROM hosts", &error); + "SELECT id, url, title, visit_count, zoom_level FROM hosts", &error); if (error) { g_error ("Could not build hosts query statement: %s", error->message); @@ -305,7 +310,7 @@ ephy_history_service_get_host_row_from_url (EphyHistoryService *self, } if (host == NULL) { - host = ephy_history_host_new (host_locations->data, hostname, 0); + host = ephy_history_host_new (host_locations->data, hostname, 0, 1.0); ephy_history_service_add_host_row (self, host); } diff --git a/lib/history/ephy-history-service-urls-table.c b/lib/history/ephy-history-service-urls-table.c index 0b72875a6..fe8d0d5e3 100644 --- a/lib/history/ephy-history-service-urls-table.c +++ b/lib/history/ephy-history-service-urls-table.c @@ -40,8 +40,7 @@ ephy_history_service_initialize_urls_table (EphyHistoryService *self) "title LONGVARCAR," "visit_count INTEGER DEFAULT 0 NOT NULL," "typed_count INTEGER DEFAULT 0 NOT NULL," - "last_visit_time INTEGER," - "zoom_level REAL DEFAULT 1.0)", &error); + "last_visit_time INTEGER)", &error); if (error) { g_error("Could not create urls table: %s", error->message); @@ -69,11 +68,11 @@ ephy_history_service_get_url_row (EphyHistoryService *self, const char *url_stri if (url != NULL && url->id != -1) { statement = ephy_sqlite_connection_create_statement (priv->history_database, - "SELECT id, url, title, visit_count, typed_count, last_visit_time, zoom_level FROM urls " + "SELECT id, url, title, visit_count, typed_count, last_visit_time FROM urls " "WHERE id=?", &error); } else { statement = ephy_sqlite_connection_create_statement (priv->history_database, - "SELECT id, url, title, visit_count, typed_count, last_visit_time, zoom_level FROM urls " + "SELECT id, url, title, visit_count, typed_count, last_visit_time FROM urls " "WHERE url=?", &error); } @@ -101,7 +100,7 @@ ephy_history_service_get_url_row (EphyHistoryService *self, const char *url_stri } if (url == NULL) { - url = ephy_history_url_new (NULL, NULL, 0, 0, 0, 1.0); + url = ephy_history_url_new (NULL, NULL, 0, 0, 0); } url->id = ephy_sqlite_statement_get_column_as_int (statement, 0); @@ -116,7 +115,6 @@ ephy_history_service_get_url_row (EphyHistoryService *self, const char *url_stri url->visit_count = ephy_sqlite_statement_get_column_as_int (statement, 3), url->typed_count = ephy_sqlite_statement_get_column_as_int (statement, 4), url->last_visit_time = ephy_sqlite_statement_get_column_as_int (statement, 5); - url->zoom_level = ephy_sqlite_statement_get_column_as_double (statement, 6); g_object_unref (statement); return url; @@ -133,8 +131,8 @@ ephy_history_service_add_url_row (EphyHistoryService *self, EphyHistoryURL *url) g_assert (priv->history_database != NULL); statement = ephy_sqlite_connection_create_statement (priv->history_database, - "INSERT INTO urls (url, title, visit_count, typed_count, last_visit_time, zoom_level, host) " - " VALUES (?, ?, ?, ?, ?, ?, ?)", &error); + "INSERT INTO urls (url, title, visit_count, typed_count, last_visit_time, host) " + " VALUES (?, ?, ?, ?, ?, ?)", &error); if (error) { g_error ("Could not build urls table addition statement: %s", error->message); g_error_free (error); @@ -146,8 +144,7 @@ ephy_history_service_add_url_row (EphyHistoryService *self, EphyHistoryURL *url) ephy_sqlite_statement_bind_int (statement, 2, url->visit_count, &error) == FALSE || ephy_sqlite_statement_bind_int (statement, 3, url->typed_count, &error) == FALSE || ephy_sqlite_statement_bind_int (statement, 4, url->last_visit_time, &error) == FALSE || - ephy_sqlite_statement_bind_double (statement, 5, url->zoom_level, &error) == FALSE || - ephy_sqlite_statement_bind_int (statement, 6, url->host->id, &error) == FALSE) { + ephy_sqlite_statement_bind_int (statement, 5, url->host->id, &error) == FALSE) { g_error ("Could not insert URL into urls table: %s", error->message); g_error_free (error); return; @@ -175,7 +172,7 @@ ephy_history_service_update_url_row (EphyHistoryService *self, EphyHistoryURL *u g_assert (priv->history_database != NULL); statement = ephy_sqlite_connection_create_statement (priv->history_database, - "UPDATE urls SET title=?, visit_count=?, typed_count=?, last_visit_time=?, zoom_level=? " + "UPDATE urls SET title=?, visit_count=?, typed_count=?, last_visit_time=? " "WHERE id=?", &error); if (error) { g_error ("Could not build urls table modification statement: %s", error->message); @@ -187,8 +184,7 @@ ephy_history_service_update_url_row (EphyHistoryService *self, EphyHistoryURL *u ephy_sqlite_statement_bind_int (statement, 1, url->visit_count, &error) == FALSE || ephy_sqlite_statement_bind_int (statement, 2, url->typed_count, &error) == FALSE || ephy_sqlite_statement_bind_int (statement, 3, url->last_visit_time, &error) == FALSE || - ephy_sqlite_statement_bind_double (statement, 4, url->zoom_level, &error) == FALSE || - ephy_sqlite_statement_bind_int (statement, 5, url->id, &error) == FALSE) { + ephy_sqlite_statement_bind_int (statement, 4, url->id, &error) == FALSE) { g_error ("Could not modify URL in urls table: %s", error->message); g_error_free (error); return; @@ -209,11 +205,10 @@ create_url_from_statement (EphySQLiteStatement *statement) ephy_sqlite_statement_get_column_as_string (statement, 2), ephy_sqlite_statement_get_column_as_int (statement, 3), ephy_sqlite_statement_get_column_as_int (statement, 4), - ephy_sqlite_statement_get_column_as_int (statement, 5), - ephy_sqlite_statement_get_column_as_int (statement, 6)); + ephy_sqlite_statement_get_column_as_int (statement, 5)); url->id = ephy_sqlite_statement_get_column_as_int (statement, 0); - url->host = ephy_history_host_new (NULL, NULL, 0); + url->host = ephy_history_host_new (NULL, NULL, 0, 1.0); url->host->id = ephy_sqlite_statement_get_column_as_int (statement, 7); return url; @@ -236,7 +231,6 @@ ephy_history_service_find_url_rows (EphyHistoryService *self, EphyHistoryQuery * "urls.visit_count, " "urls.typed_count, " "urls.last_visit_time, " - "urls.zoom_level, " "urls.host " "FROM " "urls "; diff --git a/lib/history/ephy-history-service.c b/lib/history/ephy-history-service.c index 61d7b2b05..0b3a2e198 100644 --- a/lib/history/ephy-history-service.c +++ b/lib/history/ephy-history-service.c @@ -37,6 +37,7 @@ typedef enum { QUIT, /* READ */ GET_URL, + GET_HOST_FOR_URL, QUERY_URLS, QUERY_VISITS, } EphyHistoryServiceMessageType; @@ -531,7 +532,7 @@ ephy_history_service_set_url_title (EphyHistoryService *self, EphyHistoryJobCallback callback, gpointer user_data) { - EphyHistoryURL *url = ephy_history_url_new (orig_url, title, 0, 0, 0, 1.0); + EphyHistoryURL *url = ephy_history_url_new (orig_url, title, 0, 0, 0); EphyHistoryServiceMessage *message = ephy_history_service_message_new (self, SET_URL_TITLE, @@ -542,35 +543,40 @@ ephy_history_service_set_url_title (EphyHistoryService *self, static gboolean ephy_history_service_execute_set_url_zoom_level (EphyHistoryService *self, - EphyHistoryURL *url, + GVariant *variant, gpointer *result) { - double zoom_level = url->zoom_level; + char *url_string; + double zoom_level; + EphyHistoryHost *host; - if (NULL == ephy_history_service_get_url_row (self, NULL, url)) { - /* The URL is not yet in the database, so we can't update it.. */ - return FALSE; - } else { - url->zoom_level = zoom_level; - ephy_history_service_update_url_row (self, url); - ephy_history_service_schedule_commit (self); - return TRUE; - } + g_variant_get (variant, "(sd)", &url_string, &zoom_level); + + host = ephy_history_service_get_host_row_from_url (self, url_string); + g_free (url_string); + + g_return_val_if_fail (host != NULL, FALSE); + + host->zoom_level = zoom_level; + ephy_history_service_update_host_row (self, host); + ephy_history_service_schedule_commit (self); + + return TRUE; } void ephy_history_service_set_url_zoom_level (EphyHistoryService *self, - const char *orig_url, + const char *url, const double zoom_level, EphyHistoryJobCallback callback, gpointer user_data) { - EphyHistoryURL *url = ephy_history_url_new (orig_url, NULL, 0, 0, 0, zoom_level); + EphyHistoryServiceMessage *message; + GVariant *variant = g_variant_new ("(sd)", url, zoom_level); - EphyHistoryServiceMessage *message = - ephy_history_service_message_new (self, SET_URL_ZOOM_LEVEL, - url, (GDestroyNotify) ephy_history_url_free, - callback, user_data); + message = ephy_history_service_message_new (self, SET_URL_ZOOM_LEVEL, + variant, (GDestroyNotify)g_variant_unref, + callback, user_data); ephy_history_service_send_message (self, message); } @@ -602,6 +608,34 @@ ephy_history_service_get_url (EphyHistoryService *self, } static gboolean +ephy_history_service_execute_get_host_for_url (EphyHistoryService *self, + const gchar *url, + gpointer *result) +{ + EphyHistoryHost *host; + + host = ephy_history_service_get_host_row_from_url (self, url); + g_return_val_if_fail (host != NULL, FALSE); + + *result = host; + + return host != NULL; +} + +void +ephy_history_service_get_host_for_url (EphyHistoryService *self, + const char *url, + EphyHistoryJobCallback callback, + gpointer user_data) +{ + EphyHistoryServiceMessage *message = + ephy_history_service_message_new (self, GET_HOST_FOR_URL, + g_strdup (url), g_free, + callback, user_data); + ephy_history_service_send_message (self, message); +} + +static gboolean ephy_history_service_execute_set_url_property (EphyHistoryService *self, GVariant *variant, gpointer *result) @@ -613,7 +647,7 @@ ephy_history_service_execute_set_url_property (EphyHistoryService *self, g_variant_get (variant, "(s(iv))", &url_string, &property, &value); - url = ephy_history_url_new (url_string, NULL, 0, 0, 0, 1.0); + url = ephy_history_url_new (url_string, NULL, 0, 0, 0); g_free (url_string); if (NULL == ephy_history_service_get_url_row (self, NULL, url)) { @@ -635,9 +669,6 @@ ephy_history_service_execute_set_url_property (EphyHistoryService *self, url->title = NULL; } break; - case EPHY_HISTORY_URL_ZOOM_LEVEL: - url->zoom_level = g_variant_get_double (value); - break; default: g_assert_not_reached(); } @@ -719,6 +750,7 @@ static EphyHistoryServiceMethod methods[] = { (EphyHistoryServiceMethod)ephy_history_service_execute_delete_urls, (EphyHistoryServiceMethod)ephy_history_service_execute_quit, (EphyHistoryServiceMethod)ephy_history_service_execute_get_url, + (EphyHistoryServiceMethod)ephy_history_service_execute_get_host_for_url, (EphyHistoryServiceMethod)ephy_history_service_execute_query_urls, (EphyHistoryServiceMethod)ephy_history_service_execute_find_visits }; diff --git a/lib/history/ephy-history-service.h b/lib/history/ephy-history-service.h index 601d13b07..98b48e275 100644 --- a/lib/history/ephy-history-service.h +++ b/lib/history/ephy-history-service.h @@ -61,6 +61,7 @@ void ephy_history_service_query_visits (EphyHisto void ephy_history_service_query_urls (EphyHistoryService *self, EphyHistoryQuery *query, EphyHistoryJobCallback callback, gpointer user_data); void ephy_history_service_set_url_title (EphyHistoryService *self, const char *url, const char *title, EphyHistoryJobCallback callback, gpointer user_data); void ephy_history_service_set_url_zoom_level (EphyHistoryService *self, const char *url, const double zoom_level, EphyHistoryJobCallback callback, gpointer user_data); +void ephy_history_service_get_host_for_url (EphyHistoryService *self, const char *url, EphyHistoryJobCallback callback, gpointer user_data); void ephy_history_service_set_url_property (EphyHistoryService *self, const char *url, EphyHistoryURLProperty property, GVariant *value, EphyHistoryJobCallback callback, gpointer user_data); void ephy_history_service_get_url (EphyHistoryService *self, const char *url, EphyHistoryJobCallback callback, gpointer user_data); void ephy_history_service_delete_urls (EphyHistoryService *self, GList *urls, EphyHistoryJobCallback callback, gpointer user_data); diff --git a/lib/history/ephy-history-types.c b/lib/history/ephy-history-types.c index bb8321653..84e83e72e 100644 --- a/lib/history/ephy-history-types.c +++ b/lib/history/ephy-history-types.c @@ -36,7 +36,7 @@ ephy_history_page_visit_new_with_url (EphyHistoryURL *url, gint64 visit_time, Ep EphyHistoryPageVisit * ephy_history_page_visit_new (const char *url, gint64 visit_time, EphyHistoryPageVisitType visit_type) { - return ephy_history_page_visit_new_with_url (ephy_history_url_new (url, "", 0, 0, 0, 1.0), + return ephy_history_page_visit_new_with_url (ephy_history_url_new (url, "", 0, 0, 0), visit_time, visit_type); } @@ -78,7 +78,7 @@ ephy_history_page_visit_list_free (GList *list) } EphyHistoryHost * -ephy_history_host_new (const char *url, const char *title, int visit_count) +ephy_history_host_new (const char *url, const char *title, int visit_count, double zoom_level) { EphyHistoryHost *host = g_slice_alloc0 (sizeof (EphyHistoryHost)); @@ -86,6 +86,7 @@ ephy_history_host_new (const char *url, const char *title, int visit_count) host->url = g_strdup (url); host->title = g_strdup (title); host->visit_count = visit_count; + host->zoom_level = zoom_level; return host; } @@ -100,7 +101,8 @@ ephy_history_host_copy (EphyHistoryHost *original) host = ephy_history_host_new (original->url, original->title, - original->visit_count); + original->visit_count, + original->zoom_level); host->id = original->id; return host; @@ -119,7 +121,7 @@ ephy_history_host_free (EphyHistoryHost *host) } EphyHistoryURL * -ephy_history_url_new (const char *url, const char *title, int visit_count, int typed_count, int last_visit_time, double zoom_level) +ephy_history_url_new (const char *url, const char *title, int visit_count, int typed_count, int last_visit_time) { EphyHistoryURL *history_url = g_slice_alloc0 (sizeof (EphyHistoryURL)); history_url->id = -1; @@ -128,7 +130,6 @@ ephy_history_url_new (const char *url, const char *title, int visit_count, int t history_url->visit_count = visit_count; history_url->typed_count = typed_count; history_url->last_visit_time = last_visit_time; - history_url->zoom_level = zoom_level; history_url->host = NULL; return history_url; } @@ -144,8 +145,7 @@ ephy_history_url_copy (EphyHistoryURL *url) url->title, url->visit_count, url->typed_count, - url->last_visit_time, - url->zoom_level); + url->last_visit_time); copy->id = url->id; copy->host = ephy_history_host_copy (url->host); return copy; diff --git a/lib/history/ephy-history-types.h b/lib/history/ephy-history-types.h index 8d32c5e6c..367e802e3 100644 --- a/lib/history/ephy-history-types.h +++ b/lib/history/ephy-history-types.h @@ -39,7 +39,6 @@ typedef enum { typedef enum { EPHY_HISTORY_URL_TITLE, - EPHY_HISTORY_URL_ZOOM_LEVEL } EphyHistoryURLProperty; typedef enum { @@ -56,6 +55,7 @@ typedef struct char* url; char* title; int visit_count; + double zoom_level; } EphyHistoryHost; typedef struct _EphyHistoryURL @@ -66,7 +66,6 @@ typedef struct _EphyHistoryURL int visit_count; int typed_count; int last_visit_time; - double zoom_level; EphyHistoryHost *host; } EphyHistoryURL; @@ -95,11 +94,11 @@ void ephy_history_page_visit_free (EphyHistoryPageVis GList * ephy_history_page_visit_list_copy (GList* original); void ephy_history_page_visit_list_free (GList* list); -EphyHistoryHost * ephy_history_host_new (const char *url, const char *title, int visit_count); +EphyHistoryHost * ephy_history_host_new (const char *url, const char *title, int visit_count, double zoom_level); EphyHistoryHost * ephy_history_host_copy (EphyHistoryHost *original); void ephy_history_host_free (EphyHistoryHost *host); -EphyHistoryURL * ephy_history_url_new (const char *url, const char* title, int visit_count, int typed_count, int last_visit_time, double zoom_level); +EphyHistoryURL * ephy_history_url_new (const char *url, const char* title, int visit_count, int typed_count, int last_visit_time); EphyHistoryURL * ephy_history_url_copy (EphyHistoryURL *url); void ephy_history_url_free (EphyHistoryURL *url); diff --git a/tests/ephy-history.c b/tests/ephy-history.c index 1ff376741..4abd1f064 100644 --- a/tests/ephy-history.c +++ b/tests/ephy-history.c @@ -368,7 +368,7 @@ perform_complex_url_query (EphyHistoryService *service, /* The expected result. */ url = ephy_history_url_new ("http://www.wikipedia.org", "Wikipedia", - 30, 30, 0, 1); + 30, 30, 0); ephy_history_service_query_urls (service, query, verify_complex_url_query, url); } @@ -408,7 +408,7 @@ perform_complex_url_query_with_time_range (EphyHistoryService *service, /* The expected result. */ url = ephy_history_url_new ("http://www.webkitgtk.org", "WebKitGTK+", - 2, 2, 0, 1); + 2, 2, 0); ephy_history_service_query_urls (service, query, verify_complex_url_query, url); } |