[epiphany/gnome-3-22] Move some duplicate code into ephy_history_query_new_for_overview
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/gnome-3-22] Move some duplicate code into ephy_history_query_new_for_overview
- Date: Sat, 17 Dec 2016 03:54:50 +0000 (UTC)
commit 39a1c7fb4e866241855b7cbfdfd68a654ef72b94
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Sun Dec 4 14:04:12 2016 -0600
Move some duplicate code into ephy_history_query_new_for_overview
https://bugzilla.gnome.org/show_bug.cgi?id=775612
embed/ephy-about-handler.c | 27 ++++++++++++++++++++-------
embed/ephy-about-handler.h | 6 +++++-
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 dffce40..e9bf4c9 100644
--- a/embed/ephy-about-handler.c
+++ b/embed/ephy-about-handler.c
@@ -40,10 +40,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 d75be82..468583c 100644
--- a/embed/ephy-about-handler.h
+++ b/embed/ephy-about-handler.h
@@ -19,6 +19,8 @@
#ifndef EPHY_ABOUT_HANDLER_H
#define EPHY_ABOUT_HANDLER_H
+#include "ephy-history-service.h"
+
#include <webkit2/webkit2.h>
G_BEGIN_DECLS
@@ -29,11 +31,13 @@ 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 10
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
#endif /* EPHY_ABOUT_HANDLER_H */
diff --git a/embed/ephy-embed-shell.c b/embed/ephy-embed-shell.c
index 4c85ff2..218e134 100644
--- a/embed/ephy-embed-shell.c
+++ b/embed/ephy-embed-shell.c
@@ -157,12 +157,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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]