Auto-completion GtkTreeView prototype shows url, topic and relvance columns now
[ephy-history.git] / completion-test.c
blobe60f5b2958d7fb18e81609f7e3ac0a8b7304f7db
1 #include <gtk/gtk.h>
2 #include "ephy-completion-model.h"
5 int
6 main (int argc, char **argv)
8 GtkWidget *window;
9 GtkWidget *scrwin;
10 GtkWidget *treeview;
11 EphyCompletionModel *cModel;
12 GtkTreeModel *model;
13 GtkCellRenderer *renderer;
14 GtkTreeViewColumn *column;
15 EphyHistory *eh;
16 int rc;
18 gtk_init (&argc, &argv);
20 /* model */
21 eh = ephy_history_new ();
22 cModel = ephy_completion_model_new (eh);
23 model = GTK_TREE_MODEL (cModel);
25 g_print ("Number of entries = %d\n",
26 gtk_tree_model_iter_n_children (model, NULL));
28 /* view */
29 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
30 gtk_window_set_default_size (GTK_WINDOW (window), 800, 600);
31 g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit),
32 NULL);
34 scrwin = gtk_scrolled_window_new (NULL, NULL);
35 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrwin),
36 GTK_POLICY_NEVER,
37 GTK_POLICY_AUTOMATIC);
38 gtk_container_add (GTK_CONTAINER (window), scrwin);
40 treeview = gtk_tree_view_new_with_model (model);
41 g_object_unref (model);
42 renderer = gtk_cell_renderer_text_new ();
43 g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
44 gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
45 -1, "URL",
46 renderer,
47 "text",
48 EPHY_COMPLETION_ACTION_COL,
49 NULL);
50 column = gtk_tree_view_get_column(GTK_TREE_VIEW (treeview), 0);
51 gtk_tree_view_column_set_expand(column, TRUE);
52 gtk_tree_view_column_set_resizable(column, TRUE);
54 renderer = gtk_cell_renderer_text_new ();
55 g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
56 gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
57 -1, "Title",
58 renderer,
59 "text",
60 EPHY_COMPLETION_EXTRA_COL,
61 NULL);
62 column = gtk_tree_view_get_column(GTK_TREE_VIEW (treeview), 1);
63 gtk_tree_view_column_set_expand(column, TRUE);
64 gtk_tree_view_column_set_resizable(column, TRUE);
66 renderer = gtk_cell_renderer_text_new ();
67 gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
68 -1, "Relevance",
69 renderer,
70 "text",
71 EPHY_COMPLETION_RELEVANCE_COL,
72 NULL);
73 gtk_container_add (GTK_CONTAINER (scrwin), treeview);
75 gtk_widget_show_all (window);
76 gtk_main ();
78 return 0;