epiphany r8702 - in branches/gnome-2-26: lib/widgets src
- From: diegoe svn gnome org
- To: svn-commits-list gnome org
- Subject: epiphany r8702 - in branches/gnome-2-26: lib/widgets src
- Date: Mon, 19 Jan 2009 23:17:42 +0000 (UTC)
Author: diegoe
Date: Mon Jan 19 23:17:41 2009
New Revision: 8702
URL: http://svn.gnome.org/viewvc/epiphany?rev=8702&view=rev
Log:
Turn the location bar into the woohoo bar
Enhance the completion popup by showing a two line cell containing the favicon,
the title of the page and the url.
Modified:
branches/gnome-2-26/lib/widgets/ephy-location-entry.c
branches/gnome-2-26/src/ephy-completion-model.c
Modified: branches/gnome-2-26/lib/widgets/ephy-location-entry.c
==============================================================================
--- branches/gnome-2-26/lib/widgets/ephy-location-entry.c (original)
+++ branches/gnome-2-26/lib/widgets/ephy-location-entry.c Mon Jan 19 23:17:41 2009
@@ -53,7 +53,6 @@
GdkColor secure_bg_colour;
GdkColor secure_fg_colour;
- GtkCellRenderer *extracell;
GRegex *regex;
char *before_completion;
@@ -92,11 +91,11 @@
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 void textcell_data_func (GtkCellLayout *cell_layout,
+ GtkCellRenderer *cell,
+ GtkTreeModel *tree_model,
+ GtkTreeIter *iter,
+ gpointer data);
static GObjectClass *parent_class = NULL;
@@ -160,10 +159,6 @@
}
title_fg_colour = widget->style->text[GTK_STATE_INSENSITIVE];
- g_object_set (entry->priv->extracell,
- "foreground-gdk", &title_fg_colour,
- "foreground-set", TRUE,
- NULL);
settings = gtk_settings_get_for_screen (gtk_widget_get_screen (widget));
g_object_get (settings, "gtk-theme-name", &theme, NULL);
@@ -949,8 +944,13 @@
&item, -1);
entry = gtk_entry_completion_get_entry (completion);
+ /* Prevent the update so we keep the highlight from our input.
+ * See textcell_data_func().
+ */
+ le->priv->block_update = TRUE;
gtk_entry_set_text (GTK_ENTRY (entry), item);
gtk_editable_set_position (GTK_EDITABLE (entry), -1);
+ le->priv->block_update = FALSE;
g_free (item);
@@ -958,32 +958,82 @@
}
static void
-extracell_data_func (GtkCellLayout *cell_layout,
+textcell_data_func (GtkCellLayout *cell_layout,
GtkCellRenderer *cell,
GtkTreeModel *tree_model,
GtkTreeIter *iter,
gpointer data)
{
- char *cdata;
- GValue visible = { 0, };
- GValue text = { 0, };
EphyLocationEntryPrivate *priv;
+ PangoAttrList *list;
+ PangoAttribute *att;
+ GMatchInfo *match;
+
+ int start, end;
+
+ char *ctext;
+ char *title;
+ char *url;
+
+ GtkStyle *style;
+ GdkColor color;
+
+ GValue text = { 0, };
priv = EPHY_LOCATION_ENTRY (data)->priv;
+ gtk_tree_model_get (tree_model, iter,
+ priv->text_col, &title,
+ priv->url_col, &url,
+ -1);
- gtk_tree_model_get (tree_model, iter, priv->extra_col, &cdata, -1);
+ list = pango_attr_list_new ();
- g_value_init (&text, G_TYPE_STRING);
- g_value_init (&visible, G_TYPE_BOOLEAN);
-
- g_value_take_string (&text, cdata);
- g_value_set_boolean (&visible, (cdata != NULL));
+ if (url)
+ {
+ ctext = g_strdup_printf ("%s\n%s", title, url);
+
+ style = gtk_widget_get_style (priv->icon);
+ color = style->text[GTK_STATE_INSENSITIVE];
+ att = pango_attr_foreground_new
+ (color.red, color.green, color.blue);
+ att->start_index = strlen (title)+1;
+
+ pango_attr_list_insert (list, att);
+ }
+ else
+ {
+ ctext = title;
+ }
+
+ g_regex_match (priv->regex, ctext, G_REGEX_MATCH_NOTEMPTY, &match);
+
+ while (g_match_info_matches (match))
+ {
+ g_match_info_fetch_pos (match, 0, &start, &end);
+
+ att = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
+ att->start_index = start;
+ att->end_index = end;
+
+ pango_attr_list_insert (list, att);
+ g_match_info_next (match, NULL);
+ }
+
+ g_object_set (G_OBJECT (cell),
+ "attributes", list,
+ NULL);
+
+ g_value_init (&text, G_TYPE_STRING);
+ g_value_take_string (&text, ctext);
g_object_set_property (G_OBJECT (cell), "text", &text);
- g_object_set_property (G_OBJECT (cell), "visible", &visible);
-
g_value_unset (&text);
- g_value_unset (&visible);
+
+ pango_attr_list_unref (list);
+ g_match_info_free (match);
+
+ g_free (title);
+ g_free (url);
}
void
@@ -1055,19 +1105,10 @@
cell, TRUE);
gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (completion),
cell, "text", text_col);
+ gtk_cell_renderer_text_set_fixed_height_from_font (GTK_CELL_RENDERER_TEXT (cell), 2);
- le->priv->extracell = gtk_cell_renderer_text_new ();
- g_object_set (le->priv->extracell,
- "ellipsize", PANGO_ELLIPSIZE_END,
- "ellipsize-set", TRUE,
- "alignment", PANGO_ALIGN_LEFT,
- NULL);
-
- gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (completion),
- le->priv->extracell, TRUE);
-
gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (completion),
- le->priv->extracell, extracell_data_func,
+ cell, textcell_data_func,
le,
NULL);
Modified: branches/gnome-2-26/src/ephy-completion-model.c
==============================================================================
--- branches/gnome-2-26/src/ephy-completion-model.c (original)
+++ branches/gnome-2-26/src/ephy-completion-model.c Mon Jan 19 23:17:41 2009
@@ -265,12 +265,9 @@
switch (group)
{
case BOOKMARKS_GROUP:
- text = ephy_node_get_property_string
- (node, EPHY_NODE_BMK_PROP_TITLE);
- break;
case HISTORY_GROUP:
text = ephy_node_get_property_string
- (node, EPHY_NODE_PAGE_PROP_LOCATION);
+ (node, EPHY_NODE_BMK_PROP_TITLE);
break;
default:
@@ -430,13 +427,10 @@
* history, since we assume that people know the url of
* their bookmarks
*/
- if (group == HISTORY_GROUP)
- {
- const char *text;
- text = ephy_node_get_property_string
- (node, EPHY_NODE_PAGE_PROP_TITLE);
- g_value_set_string (value, text);
- }
+ const char *text;
+ text = ephy_node_get_property_string
+ (node, EPHY_NODE_PAGE_PROP_LOCATION);
+ g_value_set_string (value, text);
break;
case EPHY_COMPLETION_TEXT_COL:
g_value_init (value, G_TYPE_STRING);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]