From a763f51689dc7fb0c66e51bfa4c65b2a83ed45dc Mon Sep 17 00:00:00 2001 From: Imran Patel Date: Thu, 2 Aug 2007 17:53:29 -0700 Subject: [PATCH] Auto-completion GtkTreeView prototype shows url, topic and relvance columns now --- Makefile | 2 +- completion-test.c | 34 +++++++++++++++++++++++++++++----- ephy-completion-model.c | 10 ++++++---- 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index bab8a03..758adce 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -CC=gcc -Wall +CC=gcc -Wall CFLAGS=$(shell pkg-config --cflags glib-2.0) $(shell pkg-config --cflags gnome-vfs-2.0) $(shell pkg-config --cflags gtk+-2.0 sqlite) -g LDFLAGS = $(shell pkg-config --libs gobject-2.0 gnome-vfs-2.0 gtk+-2.0 sqlite3) diff --git a/completion-test.c b/completion-test.c index f67961f..e60f5b2 100644 --- a/completion-test.c +++ b/completion-test.c @@ -1,5 +1,6 @@ -#include "ephy-completion-model.h" #include +#include "ephy-completion-model.h" + int main (int argc, char **argv) @@ -10,7 +11,9 @@ main (int argc, char **argv) EphyCompletionModel *cModel; GtkTreeModel *model; GtkCellRenderer *renderer; + GtkTreeViewColumn *column; EphyHistory *eh; + int rc; gtk_init (&argc, &argv); @@ -19,7 +22,7 @@ main (int argc, char **argv) cModel = ephy_completion_model_new (eh); model = GTK_TREE_MODEL (cModel); - g_print ("n_children = %d\n", + g_print ("Number of entries = %d\n", gtk_tree_model_iter_n_children (model, NULL)); /* view */ @@ -36,16 +39,37 @@ main (int argc, char **argv) treeview = gtk_tree_view_new_with_model (model); g_object_unref (model); - gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE); renderer = gtk_cell_renderer_text_new (); g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview), - -1, "", + -1, "URL", renderer, "text", EPHY_COMPLETION_ACTION_COL, NULL); - + column = gtk_tree_view_get_column(GTK_TREE_VIEW (treeview), 0); + gtk_tree_view_column_set_expand(column, TRUE); + gtk_tree_view_column_set_resizable(column, TRUE); + + renderer = gtk_cell_renderer_text_new (); + g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL); + gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview), + -1, "Title", + renderer, + "text", + EPHY_COMPLETION_EXTRA_COL, + NULL); + column = gtk_tree_view_get_column(GTK_TREE_VIEW (treeview), 1); + gtk_tree_view_column_set_expand(column, TRUE); + gtk_tree_view_column_set_resizable(column, TRUE); + + renderer = gtk_cell_renderer_text_new (); + gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview), + -1, "Relevance", + renderer, + "text", + EPHY_COMPLETION_RELEVANCE_COL, + NULL); gtk_container_add (GTK_CONTAINER (scrwin), treeview); gtk_widget_show_all (window); diff --git a/ephy-completion-model.c b/ephy-completion-model.c index c7a8c8b..542c1d5 100644 --- a/ephy-completion-model.c +++ b/ephy-completion-model.c @@ -390,14 +390,15 @@ init_keywords_col (GValue * value, EphyHistoryPageNode * node, int group) static void init_favicon_col (GValue * value, EphyHistoryPageNode * page, int group) { + const char *icon_location; #ifdef EPHY_MERGE EphyFaviconCache *cache; - const char *icon_location; GdkPixbuf *pixbuf = NULL; cache = EPHY_FAVICON_CACHE (ephy_embed_shell_get_favicon_cache (EPHY_EMBED_SHELL (ephy_shell))); +#endif switch (group) { @@ -411,6 +412,7 @@ init_favicon_col (GValue * value, EphyHistoryPageNode * page, int group) icon_location = NULL; } +#ifdef EPHY_MERGE if (icon_location) { pixbuf = ephy_favicon_cache_get (cache, icon_location); @@ -420,6 +422,7 @@ init_favicon_col (GValue * value, EphyHistoryPageNode * page, int group) #else g_value_take_object (value, NULL); #endif + g_print("init_favicon_col: %s\n", icon_location); } static gboolean @@ -469,7 +472,7 @@ init_relevance_col (GValue * value, EphyHistoryPageNode * page, int group) guint visits; g_object_get (G_OBJECT (page), "url", &url, "visit-count", - visits, NULL); + &visits, NULL); visits = MIN (visits, (1 << 5) - 1); @@ -481,8 +484,8 @@ init_relevance_col (GValue * value, EphyHistoryPageNode * page, int group) { relevance = visits; } + //g_print("url: %s visits: %u rel: %d\n", url, visits, relevance); } - g_value_set_int (value, relevance); } @@ -503,7 +506,6 @@ init_url_col (GValue * value, EphyHistoryPageNode * page, int group) { url = ""; } - g_value_set_string (value, url); } -- 2.11.4.GIT