[epiphany/history-rewrite: 12/26] Add API to set the URL title in the history



commit 8661e73583f1d0874ce1ccac410e0b814d0b7d35
Author: Claudio Saavedra <csaavedra igalia com>
Date:   Sun Jul 3 21:49:53 2011 +0300

    Add API to set the URL title in the history

 lib/history/ephy-history-service.c |   38 ++++++++++++++++++++++++++++++++++++
 lib/history/ephy-history-service.h |    1 +
 2 files changed, 39 insertions(+), 0 deletions(-)
---
diff --git a/lib/history/ephy-history-service.c b/lib/history/ephy-history-service.c
index c0f39a7..edc44a8 100644
--- a/lib/history/ephy-history-service.c
+++ b/lib/history/ephy-history-service.c
@@ -501,3 +501,41 @@ ephy_history_service_find_visits_in_time (EphyHistoryService *self, gint64 from,
                                       details);
 
 }
+
+static gboolean
+ephy_history_service_execute_set_url_title (EphyHistoryService *self,
+                                            EphyHistoryURL *url,
+                                            gpointer *result)
+{
+  char *title = url->title;
+
+  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 {
+    g_free (url->title);
+    url->title = title;
+    ephy_history_service_update_url_row (self, url);
+    ephy_history_service_schedule_commit (self);
+    return TRUE;
+  }
+}
+
+void
+ephy_history_service_set_url_title (EphyHistoryService *self,
+                                    const char *orig_url,
+                                    const char *title,
+                                    EphyHistoryJobCallback callback,
+                                    gpointer user_data)
+{
+  EphyHistoryURL *url = ephy_history_url_new (orig_url, title, 0, 0, 0);
+
+  EphyHistoryThreadJobDetails *details =
+    ephy_history_thread_job_details_new (self,
+                                         (EphyHistoryJobMethod) ephy_history_service_execute_set_url_title,
+                                         url, (GDestroyNotify) ephy_history_url_free,
+                                         callback, user_data);
+  ephy_history_service_schedule_idle (self, G_PRIORITY_DEFAULT,
+                                      ephy_history_service_execute_job_on_history_thread,
+                                      details);
+}
diff --git a/lib/history/ephy-history-service.h b/lib/history/ephy-history-service.h
index 8911745..862f7f6 100644
--- a/lib/history/ephy-history-service.h
+++ b/lib/history/ephy-history-service.h
@@ -55,6 +55,7 @@ EphyHistoryService *     ephy_history_service_new                     (const cha
 void                     ephy_history_service_add_visit               (EphyHistoryService *self, EphyHistoryPageVisit *visit, EphyHistoryJobCallback callback, gpointer user_data);
 void                     ephy_history_service_add_visits              (EphyHistoryService *self, GList *visits, EphyHistoryJobCallback callback, gpointer user_data);
 void                     ephy_history_service_find_visits_in_time     (EphyHistoryService *self, gint64 from, gint64 to, 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);
 
 G_END_DECLS
 



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