[epiphany/wip/history-window] wip: use the new backend with the history window



commit 70df8413547c0d02168170ae8c10d49a7ab9330e
Author: Claudio Saavedra <csaavedra igalia com>
Date:   Fri Mar 2 21:47:54 2012 +0200

    wip: use the new backend with the history window
    
    This is still half-done and needs lots of cleaning, but it works.
    
    The TODO, as far as I can tell, is the following:
    
    * TODO Sort the elements in the hosts treeview.
    * TODO Sort the elements to the urls treeview.
    * TODO Fix the column widths.
    * TODO Selecting a host should filter the urls.
    * TODO History should be updated with new visits and changes
    * TODO Double click should open an url (?)
    * TODO remove traces of EphyNode from the code

 src/ephy-history-window.c |  525 ++++++++++++++++++++++++++++++++-------------
 1 files changed, 375 insertions(+), 150 deletions(-)
---
diff --git a/src/ephy-history-window.c b/src/ephy-history-window.c
index 52d0250..b4cdd21 100644
--- a/src/ephy-history-window.c
+++ b/src/ephy-history-window.c
@@ -27,6 +27,10 @@
 
 #include "ephy-window.h"
 #include "ephy-history-window.h"
+#include "ephy-history-view.h"
+#include "ephy-history-store.h"
+#include "ephy-hosts-view.h"
+#include "ephy-hosts-store.h"
 #include "ephy-shell.h"
 #include "ephy-dnd.h"
 #include "ephy-state.h"
@@ -91,6 +95,8 @@ static void cmd_help_contents		  (GtkAction *action,
 static void search_entry_search_cb 	  (GtkWidget *entry,
 					   char *search_text,
 					   EphyHistoryWindow *editor);
+static void
+filter_now (EphyHistoryWindow *editor, gboolean hosts, gboolean pages);
 
 #define EPHY_HISTORY_WINDOW_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_HISTORY_WINDOW, EphyHistoryWindowPrivate))
 
@@ -98,8 +104,10 @@ struct _EphyHistoryWindowPrivate
 {
 	EphyHistory *history;
 	EphyBrowseHistory *browse_history;
-	GtkWidget *sites_view;
+	GtkWidget *hosts_view;
 	GtkWidget *pages_view;
+	EphyHistoryStore *history_store;
+	EphyHostsStore *hosts_store;
 	EphyNodeFilter *pages_filter;
 	EphyNodeFilter *sites_filter;
 	GtkWidget *time_combo;
@@ -200,7 +208,9 @@ confirmation_dialog_response_cb (GtkWidget *dialog,
 
 	if (response == GTK_RESPONSE_ACCEPT)
 	{
-		ephy_history_clear (editor->priv->history);
+          ephy_browse_history_clear (editor->priv->browse_history,
+                                     NULL, NULL);
+	  filter_now (editor, TRUE, TRUE);
 	}
 }
 
@@ -295,21 +305,16 @@ cmd_open_bookmarks_in_tabs (GtkAction *action,
 	GList *l;
 
 	window = EPHY_WINDOW (get_target_window (editor));
-	selection = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->priv->pages_view));
+	selection = ephy_history_view_get_selection (EPHY_HISTORY_VIEW (editor->priv->pages_view));
 
 	for (l = selection; l; l = l->next)
 	{
-		EphyNode *node = l->data;
-		const char *location;
-
-		location = ephy_node_get_property_string (node,
-						EPHY_NODE_PAGE_PROP_LOCATION);
-
-		ephy_shell_new_tab (ephy_shell, window, NULL, location,
+		EphyHistoryURL *url = l->data;
+		ephy_shell_new_tab (ephy_shell, window, NULL, url->url,
 			EPHY_NEW_TAB_OPEN_PAGE | EPHY_NEW_TAB_IN_EXISTING_WINDOW);
 	}
 
-	g_list_free (selection);
+	g_list_free_full (selection, (GDestroyNotify) ephy_history_url_free);
 }
 
 static void
@@ -321,22 +326,17 @@ cmd_open_bookmarks_in_browser (GtkAction *action,
 	GList *l;
 
 	window = EPHY_WINDOW (get_target_window (editor));
-	selection = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->priv->pages_view));
+	selection = ephy_history_view_get_selection (EPHY_HISTORY_VIEW (editor->priv->pages_view));
 
 	for (l = selection; l; l = l->next)
 	{
-		EphyNode *node = l->data;
-		const char *location;
-
-		location = ephy_node_get_property_string (node,
-						EPHY_NODE_PAGE_PROP_LOCATION);
-
-		ephy_shell_new_tab (ephy_shell, window, NULL, location,
+		EphyHistoryURL *url = l->data;
+		ephy_shell_new_tab (ephy_shell, window, NULL, url->url,
 				    EPHY_NEW_TAB_OPEN_PAGE |
 				    EPHY_NEW_TAB_IN_NEW_WINDOW);
 	}
 
-	g_list_free (selection);
+	g_list_free_full (selection, (GDestroyNotify) ephy_history_url_free);
 }
 
 static void
@@ -366,17 +366,15 @@ cmd_copy (GtkAction *action,
 	{
 		GList *selection;
 
-		selection = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->priv->pages_view));
+		selection = ephy_history_view_get_selection (EPHY_HISTORY_VIEW (editor->priv->pages_view));
 
 		if (g_list_length (selection) == 1)
 		{
-			const char *tmp;
-			EphyNode *node = selection->data;
-			tmp = ephy_node_get_property_string (node, EPHY_NODE_PAGE_PROP_LOCATION);
-			gtk_clipboard_set_text (gtk_clipboard_get (GDK_SELECTION_CLIPBOARD), tmp, -1);
+			EphyHistoryURL *url = selection->data;
+			gtk_clipboard_set_text (gtk_clipboard_get (GDK_SELECTION_CLIPBOARD), url->url, -1);
 		}
 
-		g_list_free (selection);
+		g_list_free_full (selection, (GDestroyNotify) ephy_history_url_free);
 	}
 }
 
@@ -413,20 +411,38 @@ cmd_select_all (GtkAction *action,
 }
 
 static void
+on_browse_history_deleted (gpointer service,
+			   gboolean success,
+			   gpointer result_data,
+			   gpointer user_data)
+{
+	EphyHistoryWindow *editor = EPHY_HISTORY_WINDOW (user_data);
+
+	if (success != TRUE)
+		return;
+
+	filter_now (editor, FALSE, TRUE);
+}
+
+static void
 cmd_delete (GtkAction *action,
             EphyHistoryWindow *editor)
 {
-	if (ephy_node_view_is_target (EPHY_NODE_VIEW (editor->priv->pages_view)))
+	GList *selected;
+
+	if (gtk_widget_is_focus (editor->priv->pages_view))
 	{
-		ephy_node_view_remove (EPHY_NODE_VIEW (editor->priv->pages_view));
+		selected = ephy_history_view_get_selection (EPHY_HISTORY_VIEW (editor->priv->pages_view));
+		ephy_browse_history_delete_urls (editor->priv->browse_history, selected,
+						 (EphyHistoryJobCallback)on_browse_history_deleted, editor);
 	}
-	else if (ephy_node_view_is_target (EPHY_NODE_VIEW (editor->priv->sites_view)))
+	else if (ephy_node_view_is_target (EPHY_NODE_VIEW (editor->priv->hosts_view)))
 	{
 		EphyNodePriority priority;
-		GList *selected;
+
 		EphyNode *node;
 
-		selected = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->priv->sites_view));
+		selected = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->priv->hosts_view));
 		node = selected->data;
 		priority = ephy_node_get_property_int (node, EPHY_NODE_KEYWORD_PROP_PRIORITY);
 
@@ -434,7 +450,7 @@ cmd_delete (GtkAction *action,
 
 		if (priority == EPHY_NODE_NORMAL_PRIORITY)
 		{
-			ephy_node_view_remove (EPHY_NODE_VIEW (editor->priv->sites_view));
+			ephy_node_view_remove (EPHY_NODE_VIEW (editor->priv->hosts_view));
 		}
 		
 		g_list_free (selected);
@@ -447,22 +463,18 @@ cmd_bookmark_link (GtkAction *action,
 {
         GList *selection;
 
-        selection = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->priv->pages_view));
+        selection = ephy_history_view_get_selection (EPHY_HISTORY_VIEW (editor->priv->pages_view));
 
 	if (g_list_length (selection) == 1)
 	{
-		const char *location;
-		const char *title;
-		EphyNode *node;
+		EphyHistoryURL *url;
 
-		node = selection->data;
-		location = ephy_node_get_property_string (node, EPHY_NODE_PAGE_PROP_LOCATION);
-		title = ephy_node_get_property_string (node, EPHY_NODE_PAGE_PROP_TITLE);
+		url = selection->data;
 
-		ephy_bookmarks_ui_add_bookmark (GTK_WINDOW (editor), location, title);
+		ephy_bookmarks_ui_add_bookmark (GTK_WINDOW (editor), url->url, url->title);
 	}
 
-	g_list_free (selection);
+	g_list_free_full (selection, (GDestroyNotify) ephy_history_url_free);
 }
 
 static void
@@ -521,8 +533,8 @@ ephy_history_window_finalize (GObject *object)
 {
 	EphyHistoryWindow *editor = EPHY_HISTORY_WINDOW (object);
 
-	g_object_unref (G_OBJECT (editor->priv->pages_filter));
-	g_object_unref (G_OBJECT (editor->priv->sites_filter));
+	/* g_object_unref (G_OBJECT (editor->priv->pages_filter)); */
+	/* g_object_unref (G_OBJECT (editor->priv->sites_filter)); */
 
 	g_object_unref (editor->priv->action_group);
 	g_object_unref (editor->priv->ui_merge);
@@ -586,8 +598,7 @@ ephy_history_window_update_menu (EphyHistoryWindow *editor)
 	char *open_in_window_label, *open_in_tab_label, *copy_label;
 	GtkWidget *focus_widget;
 
-	pages_focus = ephy_node_view_is_target
-		(EPHY_NODE_VIEW (editor->priv->pages_view));
+	pages_focus = gtk_widget_is_focus (editor->priv->pages_view);
 	num_pages_selected = gtk_tree_selection_count_selected_rows
 		 (gtk_tree_view_get_selection (GTK_TREE_VIEW (editor->priv->pages_view)));
 	pages_selection = num_pages_selected > 0;
@@ -720,7 +731,7 @@ ephy_history_window_show_popup_cb (GtkWidget *view,
 
 	widget = gtk_ui_manager_get_widget (editor->priv->ui_merge,
 					    "/EphyHistoryWindowPopup");
-	ephy_node_view_popup (EPHY_NODE_VIEW (view), widget);
+	ephy_history_view_popup (EPHY_HISTORY_VIEW (view), widget);
 
 	return TRUE;
 }
@@ -890,7 +901,7 @@ site_node_selected_cb (EphyNodeView *view,
 	if (node == NULL)
 	{
 		pages = ephy_history_get_pages (editor->priv->history);
-		ephy_node_view_select_node (EPHY_NODE_VIEW (editor->priv->sites_view), pages);
+		ephy_node_view_select_node (EPHY_NODE_VIEW (editor->priv->hosts_view), pages);
 	}
 	else
 	{
@@ -908,28 +919,30 @@ site_node_selected_cb (EphyNodeView *view,
 static void
 search_entry_search_cb (GtkWidget *entry, char *search_text, EphyHistoryWindow *editor)
 {
-	EphyNode *all;
-
-	g_signal_handlers_block_by_func
-		(G_OBJECT (editor->priv->sites_view),
-		 G_CALLBACK (site_node_selected_cb),
-		 editor);
-	all = ephy_history_get_pages (editor->priv->history);
-	editor->priv->selected_site = all;
-	ephy_node_view_select_node (EPHY_NODE_VIEW (editor->priv->sites_view),
-				    all);
-	g_signal_handlers_unblock_by_func
-		(G_OBJECT (editor->priv->sites_view),
-		 G_CALLBACK (site_node_selected_cb),
-		 editor);
-
-	setup_filters (editor, TRUE, FALSE);
+	/* EphyNode *all; */
+
+	/* g_signal_handlers_block_by_func */
+	/* 	(G_OBJECT (editor->priv->sites_view), */
+	/* 	 G_CALLBACK (site_node_selected_cb), */
+	/* 	 editor); */
+	/* all = ephy_history_get_pages (editor->priv->history); */
+	/* editor->priv->selected_site = all; */
+	/* ephy_node_view_select_node (EPHY_NODE_VIEW (editor->priv->sites_view), */
+	/* 			    all); */
+	/* g_signal_handlers_unblock_by_func */
+	/* 	(G_OBJECT (editor->priv->sites_view), */
+	/* 	 G_CALLBACK (site_node_selected_cb), */
+	/* 	 editor); */
+
+	/* setup_filters (editor, TRUE, FALSE); */
+  filter_now (editor, FALSE, TRUE);
 }
 
 static void
 time_combo_changed_cb (GtkWidget *combo, EphyHistoryWindow *editor)
 {
-	setup_filters (editor, TRUE, TRUE);
+  filter_now (editor, FALSE, TRUE);
+	/* setup_filters (editor, TRUE, TRUE); */
 }
 
 static GtkWidget *
@@ -1086,14 +1099,210 @@ view_selection_changed_cb (GtkWidget *view, EphyHistoryWindow *editor)
 }
 
 static void
+setup_time_filters (EphyHistoryWindow *editor,
+		    gint64 *from, gint64 *to)
+{
+	time_t now, midnight, cmp_time = 0;
+	struct tm btime;
+	int time_range, days = 0;
+
+	time_range = gtk_combo_box_get_active
+		(GTK_COMBO_BOX (editor->priv->time_combo));
+
+	*from = *to = -1;
+
+	/* no need to setup a new filter */
+	if (time_range == EPHY_PREFS_STATE_HISTORY_DATE_FILTER_EVER) return;
+
+	now = time (NULL);
+	if (localtime_r (&now, &btime) == NULL) return;
+
+	/* get start of day */
+	btime.tm_sec = 0;
+	btime.tm_min = 0;
+	btime.tm_hour = 0;
+	midnight = mktime (&btime);
+
+	switch (time_range)
+	{
+		case EPHY_PREFS_STATE_HISTORY_DATE_FILTER_LAST_HALF_HOUR:
+			cmp_time = now - 30 * 60;
+			break;
+		case EPHY_PREFS_STATE_HISTORY_DATE_FILTER_TODAY:
+			cmp_time = midnight;
+			break;
+		case EPHY_PREFS_STATE_HISTORY_DATE_FILTER_LAST_TWO_DAYS:
+			days++;
+			cmp_time = midnight;
+			break;
+		case EPHY_PREFS_STATE_HISTORY_DATE_FILTER_LAST_THREE_DAYS:
+			days++;
+			cmp_time = midnight;
+			break;
+		default:
+			g_return_if_reached ();
+			break;
+	}
+
+	while (--days >= 0)
+	{
+		/* subtract 1 day */
+		cmp_time -= 43200;
+		localtime_r (&cmp_time, &btime);
+		btime.tm_sec = 0;
+		btime.tm_min = 0;
+		btime.tm_hour = 0;
+		cmp_time = mktime (&btime);
+	}
+
+	*from = cmp_time;
+}
+
+static GList *
+substrings_filter (EphyHistoryWindow *editor)
+{
+  const char *search_text;
+  char **tokens, **p;
+  GList *substrings = NULL;
+
+  search_text = gtk_entry_get_text (GTK_ENTRY (editor->priv->search_entry));
+  tokens = p = g_strsplit (search_text, " ", -1);
+
+  while (*p) {
+    substrings = g_list_prepend (substrings, *p++);
+  };
+  substrings = g_list_reverse (substrings);
+  g_free (tokens);
+
+  return substrings;
+}
+
+static gint
+get_selected_host (EphyHistoryWindow *editor)
+{
+  GtkTreeSelection *selection;
+  GtkTreeIter iter;
+  GtkTreePath *path;
+  GtkTreeModel *model;
+  EphyHistoryHost *host;
+  gint host_id = 0;
+
+  EphyHistoryWindowPrivate *priv = editor->priv;
+
+  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->hosts_view));
+  if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
+    path = gtk_tree_model_get_path (model, &iter);
+    host = ephy_hosts_store_get_host_from_path (priv->hosts_store,
+                                                path);
+    gtk_tree_path_free (path);
+    host_id = host->id;
+    ephy_history_host_free (host);
+  }
+  return host_id;
+}
+
+static GList*
+get_hosts_from_urls (GList *urls)
+{
+  GList *l, *hosts = NULL;
+  EphyHistoryURL *url;
+
+  /* We use a hash table to know which items are already in the list
+     of hosts without the need to traverse the list.*/
+
+  GHashTable * table = g_hash_table_new (g_int_hash,
+					 g_int_equal);
+  for (l = urls; l != NULL; l = l->next) {
+    url = l->data;
+    if (!g_hash_table_lookup (table, &url->host->id)) {
+      g_hash_table_insert (table, &url->host->id, GINT_TO_POINTER (TRUE));
+      hosts = g_list_prepend (hosts, ephy_history_host_copy (url->host));
+    }
+  }
+  g_hash_table_unref (table);
+
+  return g_list_reverse (hosts);
+}
+
+static void
+on_hosts_populated_cb (gpointer service,
+		       gboolean success,
+		       gpointer result_data,
+		       gpointer user_data)
+{
+  EphyHistoryWindow *window = EPHY_HISTORY_WINDOW (user_data);
+  GList *hosts;
+
+  if (success != TRUE)
+    goto out;
+
+  hosts = (GList *) result_data;
+  gtk_list_store_clear (GTK_LIST_STORE (window->priv->hosts_store));
+  ephy_hosts_store_add_hosts (window->priv->hosts_store, hosts);
+
+out:
+  g_list_free_full (hosts, (GDestroyNotify)ephy_history_host_free);
+}
+
+static void
+on_find_urls_cb (gpointer service,
+		 gboolean success,
+		 gpointer result_data,
+		 gpointer user_data)
+{
+  EphyHistoryWindow *window = EPHY_HISTORY_WINDOW (user_data);
+  GList *urls;
+  GList *hosts;
+
+  if (success != TRUE)
+    return;
+
+  urls = (GList *)result_data;
+  gtk_list_store_clear (GTK_LIST_STORE (window->priv->history_store));
+  ephy_history_store_add_urls (window->priv->history_store, urls);
+  hosts = get_hosts_from_urls (urls);
+  if (hosts)
+    ephy_browse_history_populate_hosts (window->priv->browse_history,
+                                        hosts,
+                                        (EphyHistoryJobCallback) on_hosts_populated_cb,
+                                        window);
+  else
+    gtk_list_store_clear (GTK_LIST_STORE (window->priv->hosts_store));
+
+  g_list_free_full (urls, (GDestroyNotify)ephy_history_url_free);
+}
+
+static void
+filter_now (EphyHistoryWindow *editor,
+            gboolean hosts,
+            gboolean pages)
+{
+	gint64 from, to;
+        gint host;
+	GList *substrings;
+
+	setup_time_filters (editor, &from, &to);
+	substrings = substrings_filter (editor);
+        host = get_selected_host (editor);
+
+        ephy_browse_history_find_urls (editor->priv->browse_history,
+				       from, to,
+				       0, 0,
+				       substrings,
+				       (EphyHistoryJobCallback)on_find_urls_cb, editor);
+}
+
+static void
 ephy_history_window_construct (EphyHistoryWindow *editor)
 {
 	GtkTreeViewColumn *col;
 	GtkTreeSelection *selection;
 	GtkWidget *vbox, *hpaned;
-	GtkWidget *pages_view, *sites_view;
+	GtkWidget *pages_view, *hosts_view;
 	GtkWidget *scrolled_window;
-	EphyNode *node;
+	EphyHistoryStore *history_store;
+	EphyHostsStore *hosts_store;
+	/* EphyNode *node; */
 	GtkUIManager *ui_merge;
 	GtkActionGroup *action_group;
 	GtkAction *action;
@@ -1142,7 +1351,7 @@ ephy_history_window_construct (EphyHistoryWindow *editor)
 	g_assert (editor->priv->history);
 
 	/* Sites View */
-	node = ephy_history_get_hosts (editor->priv->history);
+	/* node = ephy_history_get_hosts (editor->priv->history); */
 	scrolled_window = g_object_new (GTK_TYPE_SCROLLED_WINDOW,
 					"hadjustment", NULL,
 					"vadjustment", NULL,
@@ -1152,47 +1361,50 @@ ephy_history_window_construct (EphyHistoryWindow *editor)
 					NULL);
 	gtk_paned_pack1 (GTK_PANED (hpaned), scrolled_window, TRUE, FALSE);
 	gtk_widget_show (scrolled_window);
-	editor->priv->sites_filter = ephy_node_filter_new ();
-	sites_view = ephy_node_view_new (node, editor->priv->sites_filter);
-	add_focus_monitor (editor, sites_view);
-	url_col_id = ephy_node_view_add_data_column (EPHY_NODE_VIEW (sites_view),
-					             G_TYPE_STRING,
-					             EPHY_NODE_PAGE_PROP_LOCATION,
-						     NULL, NULL);
-	title_col_id = ephy_node_view_add_column (EPHY_NODE_VIEW (sites_view), _("Sites"),
-						  G_TYPE_STRING,
-						  EPHY_NODE_PAGE_PROP_TITLE,
-						  EPHY_NODE_VIEW_SEARCHABLE |
-						  EPHY_NODE_VIEW_SHOW_PRIORITY,
-						  provide_favicon,
-						  NULL);
-	ephy_node_view_enable_drag_source (EPHY_NODE_VIEW (sites_view),
-					   page_drag_types,
-				           G_N_ELEMENTS (page_drag_types),
-					   url_col_id,
-					   title_col_id);
-	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (sites_view));
+	/* editor->priv->sites_filter = ephy_node_filter_new (); */
+	hosts_store = ephy_hosts_store_new ();
+	hosts_view = ephy_hosts_view_new ();
+	gtk_tree_view_set_model (GTK_TREE_VIEW (hosts_view),
+				 GTK_TREE_MODEL (hosts_store));
+	add_focus_monitor (editor, hosts_view);
+	/* url_col_id = ephy_node_view_add_data_column (EPHY_NODE_VIEW (sites_view), */
+	/* 				             G_TYPE_STRING, */
+	/* 				             EPHY_NODE_PAGE_PROP_LOCATION, */
+	/* 					     NULL, NULL); */
+	/* title_col_id = ephy_node_view_add_column (EPHY_NODE_VIEW (sites_view), _("Sites"), */
+	/* 					  G_TYPE_STRING, */
+	/* 					  EPHY_NODE_PAGE_PROP_TITLE, */
+	/* 					  EPHY_NODE_VIEW_SEARCHABLE | */
+	/* 					  EPHY_NODE_VIEW_SHOW_PRIORITY, */
+	/* 					  provide_favicon, */
+	/* 					  NULL); */
+	/* ephy_node_view_enable_drag_source (EPHY_NODE_VIEW (sites_view), */
+	/* 				   page_drag_types, */
+	/* 			           G_N_ELEMENTS (page_drag_types), */
+	/* 				   url_col_id, */
+	/* 				   title_col_id); */
+	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (hosts_view));
 	gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
-	ephy_node_view_set_priority (EPHY_NODE_VIEW (sites_view),
-				     EPHY_NODE_PAGE_PROP_PRIORITY);
-	ephy_node_view_set_sort (EPHY_NODE_VIEW (sites_view), G_TYPE_STRING,
-				 EPHY_NODE_PAGE_PROP_TITLE,
-				 GTK_SORT_ASCENDING);
-	gtk_container_add (GTK_CONTAINER (scrolled_window), sites_view);
-	gtk_widget_show (sites_view);
-	editor->priv->sites_view = sites_view;
-	editor->priv->selected_site = ephy_history_get_pages (editor->priv->history);
-	ephy_node_view_select_node (EPHY_NODE_VIEW (sites_view),
-				    editor->priv->selected_site);
-
-	g_signal_connect (G_OBJECT (sites_view),
-			  "node_selected",
-			  G_CALLBACK (site_node_selected_cb),
-			  editor);
-	g_signal_connect (G_OBJECT (sites_view),
-			  "key_press_event",
-			  G_CALLBACK (key_pressed_cb),
-			  editor);
+	/* ephy_node_view_set_priority (EPHY_NODE_VIEW (sites_view), */
+	/* 			     EPHY_NODE_PAGE_PROP_PRIORITY); */
+	/* ephy_node_view_set_sort (EPHY_NODE_VIEW (sites_view), G_TYPE_STRING, */
+	/* 			 EPHY_NODE_PAGE_PROP_TITLE, */
+	/* 			 GTK_SORT_ASCENDING); */
+	gtk_container_add (GTK_CONTAINER (scrolled_window), hosts_view);
+	gtk_widget_show (hosts_view);
+	editor->priv->hosts_view = hosts_view;
+	/* editor->priv->selected_site = ephy_history_get_pages (editor->priv->history); */
+	/* ephy_node_view_select_node (EPHY_NODE_VIEW (sites_view), */
+	/* 			    editor->priv->selected_site); */
+
+	/* g_signal_connect (G_OBJECT (sites_view), */
+	/* 		  "node_selected", */
+	/* 		  G_CALLBACK (site_node_selected_cb), */
+	/* 		  editor); */
+	/* g_signal_connect (G_OBJECT (sites_view), */
+	/* 		  "key_press_event", */
+	/* 		  G_CALLBACK (key_pressed_cb), */
+	/* 		  editor); */
 	g_signal_connect (G_OBJECT (selection),
 			  "changed",
 			  G_CALLBACK (view_selection_changed_cb),
@@ -1216,45 +1428,57 @@ ephy_history_window_construct (EphyHistoryWindow *editor)
 					NULL);
 	gtk_box_pack_start (GTK_BOX (vbox), scrolled_window, TRUE, TRUE, 0);
 	gtk_widget_show (scrolled_window);
-	node = ephy_history_get_pages (editor->priv->history);
-	editor->priv->pages_filter = ephy_node_filter_new ();
-	pages_view = ephy_node_view_new (node, editor->priv->pages_filter);
+	/* node = ephy_history_get_pages (editor->priv->history); */
+	/* editor->priv->pages_filter = ephy_node_filter_new (); */
+	/* pages_view = ephy_node_view_new (node, editor->priv->pages_filter); */
+	editor->priv->pages_view = pages_view = ephy_history_view_new ();
+        history_store = ephy_history_store_new ();
+        gtk_tree_view_set_model (GTK_TREE_VIEW (pages_view), GTK_TREE_MODEL (history_store));
 	add_focus_monitor (editor, pages_view);
 	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (pages_view));
 	gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (pages_view), TRUE);
-	title_col_id = ephy_node_view_add_column (EPHY_NODE_VIEW (pages_view), _("Title"),
-				                  G_TYPE_STRING, EPHY_NODE_PAGE_PROP_TITLE,
-				                  EPHY_NODE_VIEW_SORTABLE |
-					          EPHY_NODE_VIEW_SEARCHABLE |
-						  EPHY_NODE_VIEW_ELLIPSIZED, NULL, &col);
+	/* title_col_id = ephy_node_view_add_column (EPHY_NODE_VIEW (pages_view), _("Title"), */
+	/* 			                  G_TYPE_STRING, EPHY_NODE_PAGE_PROP_TITLE, */
+	/* 			                  EPHY_NODE_VIEW_SORTABLE | */
+	/* 				          EPHY_NODE_VIEW_SEARCHABLE | */
+	/* 					  EPHY_NODE_VIEW_ELLIPSIZED, NULL, &col); */
+	title_col_id = 0;
+	col = gtk_tree_view_get_column (GTK_TREE_VIEW (pages_view), title_col_id);
+
 	gtk_tree_view_column_set_min_width (col, 300);
 	gtk_tree_view_column_set_resizable (col, TRUE);
 	editor->priv->title_col = col;
-	
-	url_col_id = ephy_node_view_add_column (EPHY_NODE_VIEW (pages_view), _("Address"),
-				                G_TYPE_STRING, EPHY_NODE_PAGE_PROP_LOCATION,
-				                EPHY_NODE_VIEW_SORTABLE |
-						EPHY_NODE_VIEW_ELLIPSIZED, NULL, &col);
+
+	/* url_col_id = ephy_node_view_add_column (EPHY_NODE_VIEW (pages_view), _("Address"), */
+	/* 			                G_TYPE_STRING, EPHY_NODE_PAGE_PROP_LOCATION, */
+	/* 			                EPHY_NODE_VIEW_SORTABLE | */
+	/* 					EPHY_NODE_VIEW_ELLIPSIZED, NULL, &col); */
+	url_col_id = 1;
+	col = gtk_tree_view_get_column (GTK_TREE_VIEW (pages_view), url_col_id);
 	gtk_tree_view_column_set_min_width (col, 300);
 	gtk_tree_view_column_set_resizable (col, TRUE);
 	editor->priv->address_col = col;
 
-	datetime_col_id = ephy_node_view_add_column (EPHY_NODE_VIEW (pages_view), _("Date"),
-						     G_TYPE_INT, EPHY_NODE_PAGE_PROP_LAST_VISIT,
-						     EPHY_NODE_VIEW_SORTABLE, NULL, &col);
+	/* datetime_col_id = ephy_node_view_add_column (EPHY_NODE_VIEW (pages_view), _("Date"), */
+	/* 					     G_TYPE_INT, EPHY_NODE_PAGE_PROP_LAST_VISIT, */
+	/* 					     EPHY_NODE_VIEW_SORTABLE, NULL, &col); */
+	datetime_col_id = 2;
+	col = gtk_tree_view_get_column (GTK_TREE_VIEW (pages_view), datetime_col_id);
 	editor->priv->datetime_col = col;
 	parse_time_into_date (editor->priv->datetime_col, datetime_col_id);
 
-	ephy_node_view_enable_drag_source (EPHY_NODE_VIEW (pages_view),
-					   page_drag_types,
-				           G_N_ELEMENTS (page_drag_types),
-					   url_col_id, title_col_id);
-	ephy_node_view_set_sort (EPHY_NODE_VIEW (pages_view), G_TYPE_INT,
-				 EPHY_NODE_PAGE_PROP_LAST_VISIT,
-				 GTK_SORT_DESCENDING);
+	/* ephy_node_view_enable_drag_source (EPHY_NODE_VIEW (pages_view), */
+	/* 				   page_drag_types, */
+	/* 			           G_N_ELEMENTS (page_drag_types), */
+	/* 				   url_col_id, title_col_id); */
+	/* ephy_node_view_set_sort (EPHY_NODE_VIEW (pages_view), G_TYPE_INT, */
+	/* 			 EPHY_NODE_PAGE_PROP_LAST_VISIT, */
+	/* 			 GTK_SORT_DESCENDING); */
 	gtk_container_add (GTK_CONTAINER (scrolled_window), pages_view);
 	gtk_widget_show (pages_view);
 	editor->priv->pages_view = pages_view;
+        editor->priv->history_store = history_store;
+        editor->priv->hosts_store = hosts_store;
 
 	action = gtk_action_group_get_action (action_group, "ViewTitle");
 	g_settings_bind (EPHY_SETTINGS_STATE,
@@ -1286,26 +1510,26 @@ ephy_history_window_construct (EphyHistoryWindow *editor)
 			 editor->priv->datetime_col, "visible",
 			 G_SETTINGS_BIND_DEFAULT);
 
-	g_signal_connect (G_OBJECT (pages_view),
-			  "node_activated",
-			  G_CALLBACK (ephy_history_window_node_activated_cb),
-			  editor);
-	g_signal_connect (G_OBJECT (pages_view),
-			  "node-middle-clicked",
-			  G_CALLBACK (ephy_history_window_node_middle_clicked_cb),
-			  editor);
+	/* g_signal_connect (G_OBJECT (pages_view), */
+	/* 		  "node_activated", */
+	/* 		  G_CALLBACK (ephy_history_window_node_activated_cb), */
+	/* 		  editor); */
+	/* g_signal_connect (G_OBJECT (pages_view), */
+	/* 		  "node-middle-clicked", */
+	/* 		  G_CALLBACK (ephy_history_window_node_middle_clicked_cb), */
+	/* 		  editor); */
 	g_signal_connect (G_OBJECT (pages_view),
 			  "popup_menu",
 			  G_CALLBACK (ephy_history_window_show_popup_cb),
 			  editor);
-	g_signal_connect (G_OBJECT (pages_view),
-			  "key_press_event",
-			  G_CALLBACK (key_pressed_cb),
-			  editor);
-	g_signal_connect (G_OBJECT (selection),
-			  "changed",
-			  G_CALLBACK (view_selection_changed_cb),
-			  editor);
+	/* g_signal_connect (G_OBJECT (pages_view), */
+	/* 		  "key_press_event", */
+	/* 		  G_CALLBACK (key_pressed_cb), */
+	/* 		  editor); */
+	/* g_signal_connect (G_OBJECT (selection), */
+	/* 		  "changed", */
+	/* 		  G_CALLBACK (view_selection_changed_cb), */
+	/* 		  editor); */
 
 	ephy_state_add_window (GTK_WIDGET (editor),
 			       "history_window",
@@ -1315,7 +1539,8 @@ ephy_history_window_construct (EphyHistoryWindow *editor)
 			       "history_paned",
 		               130);
 
-	setup_filters (editor, TRUE, TRUE);
+	/* setup_filters (editor, TRUE, TRUE); */
+	filter_now (editor, TRUE, TRUE);
 }
 
 void
@@ -1419,13 +1644,13 @@ ephy_history_window_dispose (GObject *object)
 
 	editor = EPHY_HISTORY_WINDOW (object);
 
-	if (editor->priv->sites_view != NULL)
+	if (editor->priv->hosts_view != NULL)
 	{
 		remove_focus_monitor (editor, editor->priv->pages_view);
-		remove_focus_monitor (editor, editor->priv->sites_view);
+		remove_focus_monitor (editor, editor->priv->hosts_view);
 		remove_focus_monitor (editor, editor->priv->search_entry);
 
-		editor->priv->sites_view = NULL;
+		editor->priv->hosts_view = NULL;
 	}
 
 	G_OBJECT_CLASS (ephy_history_window_parent_class)->dispose (object);



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