From 8c8b026fc6c22677eb05255eb4e1bbf1bda7dae3 Mon Sep 17 00:00:00 2001 From: Diego Escalante Urrelo Date: Sun, 30 Sep 2007 12:58:24 +0000 Subject: Make the location entry completion cells smarter, now bookmarks take the full width of the popup. Also make the extracell (titles of history entries) align to the left so it's less messy and easier to browse a lot of entries with similar titles. Almost-fixes bug #419475. svn path=/trunk/; revision=7508 --- lib/widgets/ephy-location-entry.c | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/widgets/ephy-location-entry.c b/lib/widgets/ephy-location-entry.c index a7f670add..08843166e 100644 --- a/lib/widgets/ephy-location-entry.c +++ b/lib/widgets/ephy-location-entry.c @@ -122,6 +122,12 @@ static void ephy_location_entry_class_init (EphyLocationEntryClass *klass); static void ephy_location_entry_init (EphyLocationEntry *le); static gboolean ephy_location_entry_reset_internal (EphyLocationEntry *, gboolean); +static void extracell_data_func (GtkCellLayout *cell_layout, + GtkCellRenderer *cell, + GtkTreeModel *tree_model, + GtkTreeIter *iter, + gpointer data); + static GObjectClass *parent_class = NULL; enum signalsEnum @@ -1006,6 +1012,29 @@ cursor_on_match_cb (GtkEntryCompletion *completion, return TRUE; } +static void +extracell_data_func (GtkCellLayout *cell_layout, + GtkCellRenderer *cell, + GtkTreeModel *tree_model, + GtkTreeIter *iter, + gpointer data) +{ + char *cdata; + GValue visible = { 0, }; + GValue text = { 0, }; + + gtk_tree_model_get (tree_model, iter, GPOINTER_TO_UINT(data), &cdata, -1); + + g_value_init (&text, G_TYPE_STRING); + g_value_init (&visible, G_TYPE_BOOLEAN); + + g_value_set_string (&text, cdata); + g_value_set_boolean (&visible, (cdata != NULL)); + + g_object_set_property (G_OBJECT (cell), "text", &text); + g_object_set_property (G_OBJECT (cell), "visible", &visible); +} + void ephy_location_entry_set_completion (EphyLocationEntry *le, GtkTreeModel *model, @@ -1066,13 +1095,16 @@ ephy_location_entry_set_completion (EphyLocationEntry *le, g_object_set (le->priv->extracell, "ellipsize", PANGO_ELLIPSIZE_END, "ellipsize-set", TRUE, - "alignment", PANGO_ALIGN_RIGHT, + "alignment", PANGO_ALIGN_LEFT, NULL); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (completion), le->priv->extracell, TRUE); - gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (completion), - le->priv->extracell, "text", extra_col); + + gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (completion), + le->priv->extracell, extracell_data_func, + GUINT_TO_POINTER (extra_col), + NULL); g_object_set (completion, "inline-selection", TRUE, NULL); g_signal_connect (completion, "cursor-on-match", -- cgit