diff options
author | Michael Catanzaro <mcatanzaro@gnome.org> | 2016-12-04 14:04:12 -0600 |
---|---|---|
committer | Michael Catanzaro <mcatanzaro@gnome.org> | 2016-12-06 09:14:04 -0600 |
commit | 02fdbf1ff21e33dbd5270f95e28f35521ebd8753 (patch) | |
tree | a7e9bbe69ca3693125ac4aa46f84092b924fa51c /embed | |
parent | dc0c5cf67e5fa15fadf894b7d555ad48b967fbea (diff) | |
download | epiphany-02fdbf1ff21e33dbd5270f95e28f35521ebd8753.tar.gz |
Move some duplicate code into ephy_history_query_new_for_overview
https://bugzilla.gnome.org/show_bug.cgi?id=775612
Diffstat (limited to 'embed')
-rw-r--r-- | embed/ephy-about-handler.c | 27 | ||||
-rw-r--r-- | embed/ephy-about-handler.h | 6 | ||||
-rw-r--r-- | embed/ephy-embed-shell.c | 7 |
3 files changed, 26 insertions, 14 deletions
diff --git a/embed/ephy-about-handler.c b/embed/ephy-about-handler.c index f1e715fa6..12b4b5e54 100644 --- a/embed/ephy-about-handler.c +++ b/embed/ephy-about-handler.c @@ -41,10 +41,13 @@ struct _EphyAboutHandler { EphySMaps *smaps; }; -#define EPHY_PAGE_TEMPLATE_ABOUT_CSS "ephy-resource:///org/gnome/epiphany/page-templates/about.css" - G_DEFINE_TYPE (EphyAboutHandler, ephy_about_handler, G_TYPE_OBJECT) + +#define EPHY_ABOUT_OVERVIEW_MAX_ITEMS 9 + +#define EPHY_PAGE_TEMPLATE_ABOUT_CSS "ephy-resource:///org/gnome/epiphany/page-templates/about.css" + static void ephy_about_handler_finalize (GObject *object) { @@ -541,19 +544,29 @@ history_service_query_urls_cb (EphyHistoryService *history, g_object_unref (request); } -static gboolean -ephy_about_handler_handle_html_overview (EphyAboutHandler *handler, - WebKitURISchemeRequest *request) +EphyHistoryQuery * +ephy_history_query_new_for_overview (void) { - EphyHistoryService *history; EphyHistoryQuery *query; - history = EPHY_HISTORY_SERVICE (ephy_embed_shell_get_global_history_service (ephy_embed_shell_get_default ())); query = ephy_history_query_new (); query->sort_type = EPHY_HISTORY_SORT_MOST_VISITED; query->limit = EPHY_ABOUT_OVERVIEW_MAX_ITEMS; query->ignore_hidden = TRUE; query->ignore_local = TRUE; + + return query; +} + +static gboolean +ephy_about_handler_handle_html_overview (EphyAboutHandler *handler, + WebKitURISchemeRequest *request) +{ + EphyHistoryService *history; + EphyHistoryQuery *query; + + history = EPHY_HISTORY_SERVICE (ephy_embed_shell_get_global_history_service (ephy_embed_shell_get_default ())); + query = ephy_history_query_new_for_overview (); ephy_history_service_query_urls (history, query, NULL, (EphyHistoryJobCallback)history_service_query_urls_cb, g_object_ref (request)); diff --git a/embed/ephy-about-handler.h b/embed/ephy-about-handler.h index 01e1273f6..c6bf357c5 100644 --- a/embed/ephy-about-handler.h +++ b/embed/ephy-about-handler.h @@ -20,6 +20,8 @@ #pragma once +#include "ephy-history-service.h" + #include <webkit2/webkit2.h> G_BEGIN_DECLS @@ -30,9 +32,11 @@ G_DECLARE_FINAL_TYPE (EphyAboutHandler, ephy_about_handler, EPHY, ABOUT_HANDLER, #define EPHY_ABOUT_SCHEME "ephy-about" #define EPHY_ABOUT_SCHEME_LEN 10 -#define EPHY_ABOUT_OVERVIEW_MAX_ITEMS 9 EphyAboutHandler *ephy_about_handler_new (void); void ephy_about_handler_handle_request (EphyAboutHandler *handler, WebKitURISchemeRequest *request); + +EphyHistoryQuery *ephy_history_query_new_for_overview (void); + G_END_DECLS diff --git a/embed/ephy-embed-shell.c b/embed/ephy-embed-shell.c index 10d74fa0c..2de56037d 100644 --- a/embed/ephy-embed-shell.c +++ b/embed/ephy-embed-shell.c @@ -206,12 +206,7 @@ ephy_embed_shell_update_overview_urls (EphyEmbedShell *shell) EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell); EphyHistoryQuery *query; - query = ephy_history_query_new (); - query->sort_type = EPHY_HISTORY_SORT_MOST_VISITED; - query->limit = EPHY_ABOUT_OVERVIEW_MAX_ITEMS; - query->ignore_hidden = TRUE; - query->ignore_local = TRUE; - + query = ephy_history_query_new_for_overview (); ephy_history_service_query_urls (priv->global_history_service, query, NULL, (EphyHistoryJobCallback)history_service_query_urls_cb, shell); |