Ensure that we have something to complete and set the actual model
This commit is contained in:
parent
0da785e94c
commit
7124e6f0bf
1 changed files with 56 additions and 54 deletions
|
@ -630,7 +630,7 @@ midori_location_entry_render_text_cb (GtkCellLayout* layout,
|
||||||
|
|
||||||
gtk_tree_model_get (model, iter, URI_COL, &uri, TITLE_COL, &title, -1);
|
gtk_tree_model_get (model, iter, URI_COL, &uri, TITLE_COL, &title, -1);
|
||||||
|
|
||||||
desc_uri = desc_title = key = NULL;
|
desc = desc_uri = desc_title = key = NULL;
|
||||||
if (G_LIKELY (data))
|
if (G_LIKELY (data))
|
||||||
{
|
{
|
||||||
entry = gtk_entry_completion_get_entry (GTK_ENTRY_COMPLETION (data));
|
entry = gtk_entry_completion_get_entry (GTK_ENTRY_COMPLETION (data));
|
||||||
|
@ -638,63 +638,65 @@ midori_location_entry_render_text_cb (GtkCellLayout* layout,
|
||||||
: g_ascii_strdown (gtk_entry_get_text (GTK_ENTRY (entry)), -1);
|
: g_ascii_strdown (gtk_entry_get_text (GTK_ENTRY (entry)), -1);
|
||||||
len = 0;
|
len = 0;
|
||||||
}
|
}
|
||||||
if (G_LIKELY (data && uri))
|
if (key && *key)
|
||||||
{
|
{
|
||||||
temp = g_ascii_strdown (uri, -1);
|
if (G_LIKELY (data && uri))
|
||||||
if ((start = strstr (temp, key)))
|
|
||||||
{
|
{
|
||||||
len = strlen (key);
|
temp = g_ascii_strdown (uri, -1);
|
||||||
skey = g_malloc0 (len + 1);
|
if ((start = strstr (temp, key)))
|
||||||
strncpy (skey, uri + (start - temp), len);
|
|
||||||
if (skey && *skey && (parts = g_strsplit (uri, skey, 2)))
|
|
||||||
{
|
{
|
||||||
if (parts[0] && parts[1])
|
|
||||||
{
|
|
||||||
desc_uri = g_markup_printf_escaped ("%s<b>%s</b>%s",
|
|
||||||
parts[0], skey, parts[1]);
|
|
||||||
g_strfreev (parts);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
g_free (skey);
|
|
||||||
}
|
|
||||||
g_free (temp);
|
|
||||||
}
|
|
||||||
if (uri && !desc_uri)
|
|
||||||
desc_uri = g_markup_escape_text (uri, -1);
|
|
||||||
if (G_LIKELY (data && title))
|
|
||||||
{
|
|
||||||
temp = g_utf8_strdown (title, -1);
|
|
||||||
if ((start = strstr (temp, key)))
|
|
||||||
{
|
|
||||||
if (!len)
|
|
||||||
len = strlen (key);
|
len = strlen (key);
|
||||||
skey = g_malloc0 (len + 1);
|
skey = g_malloc0 (len + 1);
|
||||||
strncpy (skey, title + (start - temp), len);
|
strncpy (skey, uri + (start - temp), len);
|
||||||
parts = g_strsplit (title, skey, 2);
|
if (skey && *skey && (parts = g_strsplit (uri, skey, 2)))
|
||||||
if (parts && parts[0] && parts[1])
|
{
|
||||||
desc_title = g_markup_printf_escaped ("%s<b>%s</b>%s",
|
if (parts[0] && parts[1])
|
||||||
parts[0], skey, parts[1]);
|
{
|
||||||
g_strfreev (parts);
|
desc_uri = g_markup_printf_escaped ("%s<b>%s</b>%s",
|
||||||
g_free (skey);
|
parts[0], skey, parts[1]);
|
||||||
|
g_strfreev (parts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g_free (skey);
|
||||||
|
}
|
||||||
|
g_free (temp);
|
||||||
}
|
}
|
||||||
g_free (temp);
|
if (uri && !desc_uri)
|
||||||
|
desc_uri = g_markup_escape_text (uri, -1);
|
||||||
|
if (G_LIKELY (data && title))
|
||||||
|
{
|
||||||
|
temp = g_utf8_strdown (title, -1);
|
||||||
|
if ((start = strstr (temp, key)))
|
||||||
|
{
|
||||||
|
if (!len)
|
||||||
|
len = strlen (key);
|
||||||
|
skey = g_malloc0 (len + 1);
|
||||||
|
strncpy (skey, title + (start - temp), len);
|
||||||
|
parts = g_strsplit (title, skey, 2);
|
||||||
|
if (parts && parts[0] && parts[1])
|
||||||
|
desc_title = g_markup_printf_escaped ("%s<b>%s</b>%s",
|
||||||
|
parts[0], skey, parts[1]);
|
||||||
|
g_strfreev (parts);
|
||||||
|
g_free (skey);
|
||||||
|
}
|
||||||
|
g_free (temp);
|
||||||
|
}
|
||||||
|
if (title && !desc_title)
|
||||||
|
desc_title = g_markup_escape_text (title, -1);
|
||||||
|
|
||||||
|
if (desc_title)
|
||||||
|
{
|
||||||
|
desc = g_strdup_printf ("%s\n<span color='gray45'>%s</span>",
|
||||||
|
desc_title, desc_uri);
|
||||||
|
g_free (desc_uri);
|
||||||
|
g_free (desc_title);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
desc = desc_uri;
|
||||||
|
|
||||||
|
g_object_set (renderer, "markup", desc,
|
||||||
|
"ellipsize-set", TRUE, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
|
||||||
}
|
}
|
||||||
if (title && !desc_title)
|
|
||||||
desc_title = g_markup_escape_text (title, -1);
|
|
||||||
|
|
||||||
if (desc_title)
|
|
||||||
{
|
|
||||||
desc = g_strdup_printf ("%s\n<span color='gray45'>%s</span>",
|
|
||||||
desc_title, desc_uri);
|
|
||||||
g_free (desc_uri);
|
|
||||||
g_free (desc_title);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
desc = desc_uri;
|
|
||||||
|
|
||||||
g_object_set (renderer, "markup", desc,
|
|
||||||
"ellipsize-set", TRUE, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
|
|
||||||
|
|
||||||
g_free (uri);
|
g_free (uri);
|
||||||
g_free (title);
|
g_free (title);
|
||||||
g_free (key);
|
g_free (key);
|
||||||
|
@ -952,7 +954,7 @@ midori_location_action_completion_init (MidoriLocationAction* location_action,
|
||||||
{
|
{
|
||||||
gtk_entry_completion_set_model (completion,
|
gtk_entry_completion_set_model (completion,
|
||||||
midori_location_action_is_frozen (location_action)
|
midori_location_action_is_frozen (location_action)
|
||||||
? NULL : location_action->filter_model);
|
? NULL : location_action->model);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -961,7 +963,7 @@ midori_location_action_completion_init (MidoriLocationAction* location_action,
|
||||||
g_object_unref (completion);
|
g_object_unref (completion);
|
||||||
gtk_entry_completion_set_model (completion,
|
gtk_entry_completion_set_model (completion,
|
||||||
midori_location_action_is_frozen (location_action)
|
midori_location_action_is_frozen (location_action)
|
||||||
? NULL : location_action->filter_model);
|
? NULL : location_action->model);
|
||||||
|
|
||||||
gtk_entry_completion_set_text_column (completion, URI_COL);
|
gtk_entry_completion_set_text_column (completion, URI_COL);
|
||||||
#if GTK_CHECK_VERSION (2, 12, 0)
|
#if GTK_CHECK_VERSION (2, 12, 0)
|
||||||
|
|
Loading…
Reference in a new issue