[epiphany/in-tab-overview: 15/56] ephy-history-service: add a method to set/unset a row hidden



commit 41d20f79bae3b235941a3eeb8e0c9ca52f4576c9
Author: Claudio Saavedra <csaavedra igalia com>
Date:   Sun Aug 12 19:41:21 2012 +0300

    ephy-history-service: add a method to set/unset a row hidden

 lib/history/ephy-history-service.c |   45 ++++++++++++++++++++++++++++++++++++
 lib/history/ephy-history-service.h |    1 +
 2 files changed, 46 insertions(+), 0 deletions(-)
---
diff --git a/lib/history/ephy-history-service.c b/lib/history/ephy-history-service.c
index b7aab16..ef58fb3 100644
--- a/lib/history/ephy-history-service.c
+++ b/lib/history/ephy-history-service.c
@@ -30,6 +30,7 @@ typedef enum {
   /* WRITE */
   SET_URL_TITLE,
   SET_URL_ZOOM_LEVEL,
+  SET_URL_HIDDEN,
   ADD_VISIT,
   ADD_VISITS,
   DELETE_URLS,
@@ -794,6 +795,49 @@ ephy_history_service_set_url_zoom_level (EphyHistoryService *self,
 }
 
 static gboolean
+ephy_history_service_execute_set_url_hidden (EphyHistoryService *self,
+                                             EphyHistoryURL *url,
+                                             gpointer *result)
+{
+  gboolean hidden;
+
+  hidden = url->hidden;
+
+  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->hidden = hidden;
+    ephy_history_service_update_url_row (self, url);
+    ephy_history_service_schedule_commit (self);
+    return TRUE;
+  }
+}
+
+void
+ephy_history_service_set_url_hidden (EphyHistoryService *self,
+                                     const char *orig_url,
+                                     gboolean hidden,
+                                     GCancellable *cancellable,
+                                     EphyHistoryJobCallback callback,
+                                     gpointer user_data)
+{
+  EphyHistoryServiceMessage *message;
+  EphyHistoryURL *url;
+
+  g_return_if_fail (EPHY_IS_HISTORY_SERVICE (self));
+  g_return_if_fail (orig_url != NULL);
+
+  url = ephy_history_url_new (orig_url, NULL, 0, 0, 0);
+  url->hidden = hidden;
+
+  message = ephy_history_service_message_new (self, SET_URL_HIDDEN,
+                                              url, (GDestroyNotify)ephy_history_url_free,
+                                              cancellable, callback, user_data);
+  ephy_history_service_send_message (self, message);
+}
+
+static gboolean
 ephy_history_service_execute_get_url (EphyHistoryService *self,
                                       const gchar *orig_url,
                                       gpointer *result)
@@ -966,6 +1010,7 @@ ephy_history_service_quit (EphyHistoryService *self,
 static EphyHistoryServiceMethod methods[] = {
   (EphyHistoryServiceMethod)ephy_history_service_execute_set_url_title,
   (EphyHistoryServiceMethod)ephy_history_service_execute_set_url_zoom_level,
+  (EphyHistoryServiceMethod)ephy_history_service_execute_set_url_hidden,
   (EphyHistoryServiceMethod)ephy_history_service_execute_add_visit,
   (EphyHistoryServiceMethod)ephy_history_service_execute_add_visits,
   (EphyHistoryServiceMethod)ephy_history_service_execute_delete_urls,
diff --git a/lib/history/ephy-history-service.h b/lib/history/ephy-history-service.h
index 233f443..f8d64d8 100644
--- a/lib/history/ephy-history-service.h
+++ b/lib/history/ephy-history-service.h
@@ -66,6 +66,7 @@ void                     ephy_history_service_find_visits_in_time     (EphyHisto
 void                     ephy_history_service_query_visits            (EphyHistoryService *self, EphyHistoryQuery *query, GCancellable *cancellable, EphyHistoryJobCallback callback, gpointer user_data);
 void                     ephy_history_service_query_urls              (EphyHistoryService *self, EphyHistoryQuery *query, GCancellable *cancellable, EphyHistoryJobCallback callback, gpointer user_data);
 void                     ephy_history_service_set_url_title           (EphyHistoryService *self, const char *url, const char *title, GCancellable *cancellable, EphyHistoryJobCallback callback, gpointer user_data);
+void                     ephy_history_service_set_url_hidden          (EphyHistoryService *self, const char *url, gboolean hidden, GCancellable *cancellable, EphyHistoryJobCallback callback, gpointer user_data);
 void                     ephy_history_service_set_url_zoom_level      (EphyHistoryService *self, const char *url, const double zoom_level, GCancellable *cancellable, EphyHistoryJobCallback callback, gpointer user_data);
 void                     ephy_history_service_get_host_for_url        (EphyHistoryService *self, const char *url, GCancellable *cancellable, EphyHistoryJobCallback callback, gpointer user_data);
 void                     ephy_history_service_get_hosts               (EphyHistoryService *self, GCancellable *cancellable, EphyHistoryJobCallback callback, gpointer user_data);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]