Tweak location match rendering by reducing conditions
This commit is contained in:
parent
138e837457
commit
0f988af446
1 changed files with 43 additions and 38 deletions
|
@ -643,76 +643,81 @@ midori_location_entry_render_text_cb (GtkCellLayout* layout,
|
||||||
gtk_tree_model_get (model, iter, URI_COL, &uri, TITLE_COL, &title,
|
gtk_tree_model_get (model, iter, URI_COL, &uri, TITLE_COL, &title,
|
||||||
FAVICON_COL, &icon, -1);
|
FAVICON_COL, &icon, -1);
|
||||||
|
|
||||||
if (G_UNLIKELY (!icon) && uri)
|
if (G_UNLIKELY (!icon))
|
||||||
{
|
{
|
||||||
#if !HAVE_HILDON
|
if (uri)
|
||||||
MidoriLocationAction* action
|
|
||||||
= g_object_get_data (G_OBJECT (renderer), "location-action");
|
|
||||||
if ((icon = katze_load_cached_icon (uri, NULL)))
|
|
||||||
{
|
{
|
||||||
midori_location_action_set_icon_for_uri (action, icon, uri);
|
#if !HAVE_HILDON
|
||||||
g_object_unref (icon);
|
MidoriLocationAction* action;
|
||||||
|
|
||||||
|
action = g_object_get_data (G_OBJECT (renderer), "location-action");
|
||||||
|
if ((icon = katze_load_cached_icon (uri, NULL)))
|
||||||
|
{
|
||||||
|
midori_location_action_set_icon_for_uri (action, icon, uri);
|
||||||
|
g_object_unref (icon);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
midori_location_action_set_icon_for_uri (action, action->default_icon, uri);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
|
||||||
midori_location_action_set_icon_for_uri (action, action->default_icon, uri);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else if (icon)
|
else
|
||||||
g_object_unref (icon);
|
g_object_unref (icon);
|
||||||
|
|
||||||
desc = desc_uri = desc_title = key = NULL;
|
desc = desc_uri = desc_title = key = NULL;
|
||||||
key = title ? g_utf8_strdown (gtk_entry_get_text (GTK_ENTRY (entry)), -1)
|
key = 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;
|
||||||
|
|
||||||
/* g_uri_unescape_segment () sometimes produces garbage */
|
if (G_LIKELY (uri))
|
||||||
if (G_UNLIKELY (uri && !g_utf8_validate (uri, -1, (const gchar **)&temp)))
|
|
||||||
temp[0]='\0';
|
|
||||||
else if (G_LIKELY (uri))
|
|
||||||
{
|
{
|
||||||
|
/* g_uri_unescape_segment () sometimes produces garbage */
|
||||||
|
if (!g_utf8_validate (uri, -1, (const gchar **)&temp))
|
||||||
|
temp[0] = '\0';
|
||||||
|
|
||||||
temp = g_utf8_strdown (uri, -1);
|
temp = g_utf8_strdown (uri, -1);
|
||||||
if (key && *key && (start = strstr (temp, key)))
|
if ((start = strstr (temp, key)) && (start - temp))
|
||||||
{
|
{
|
||||||
len = strlen (key);
|
len = strlen (key);
|
||||||
skey = g_malloc0 (len + 1);
|
skey = g_strndup (uri + (start - temp), len);
|
||||||
strncpy (skey, uri + (start - temp), len);
|
parts = g_strsplit (uri, skey, 2);
|
||||||
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",
|
||||||
if (parts[0] && parts[1])
|
parts[0], skey, parts[1]);
|
||||||
desc_uri = g_markup_printf_escaped ("%s<b>%s</b>%s",
|
else
|
||||||
parts[0], skey, parts[1]);
|
desc_uri = g_markup_escape_text (uri, -1);
|
||||||
g_strfreev (parts);
|
g_strfreev (parts);
|
||||||
}
|
|
||||||
g_free (skey);
|
g_free (skey);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
desc_uri = g_markup_escape_text (uri, -1);
|
||||||
g_free (temp);
|
g_free (temp);
|
||||||
}
|
}
|
||||||
if (uri && !desc_uri)
|
|
||||||
desc_uri = g_markup_escape_text (uri, -1);
|
|
||||||
|
|
||||||
/* g_uri_unescape_segment () sometimes produces garbage */
|
if (G_LIKELY (title))
|
||||||
if (G_UNLIKELY (title && !g_utf8_validate (title, -1, (const gchar **)&temp)))
|
|
||||||
temp[0]='\0';
|
|
||||||
else if (G_LIKELY (title))
|
|
||||||
{
|
{
|
||||||
|
/* g_uri_unescape_segment () sometimes produces garbage */
|
||||||
|
if (!g_utf8_validate (title, -1, (const gchar **)&temp))
|
||||||
|
temp[0] = '\0';
|
||||||
|
|
||||||
temp = g_utf8_strdown (title, -1);
|
temp = g_utf8_strdown (title, -1);
|
||||||
if (key && *key && (start = strstr (temp, key)))
|
if ((start = strstr (temp, key)) && (start - temp))
|
||||||
{
|
{
|
||||||
if (!len)
|
if (!len)
|
||||||
len = strlen (key);
|
len = strlen (key);
|
||||||
skey = g_malloc0 (len + 1);
|
skey = g_strndup (title + (start - temp), len);
|
||||||
strncpy (skey, title + (start - temp), len);
|
|
||||||
parts = g_strsplit (title, skey, 2);
|
parts = g_strsplit (title, skey, 2);
|
||||||
if (parts && parts[0] && parts[1])
|
if (parts && parts[0] && parts[1])
|
||||||
desc_title = g_markup_printf_escaped ("%s<b>%s</b>%s",
|
desc_title = g_markup_printf_escaped ("%s<b>%s</b>%s",
|
||||||
parts[0], skey, parts[1]);
|
parts[0], skey, parts[1]);
|
||||||
|
else
|
||||||
|
desc_title = g_markup_escape_text (title, -1);
|
||||||
g_strfreev (parts);
|
g_strfreev (parts);
|
||||||
g_free (skey);
|
g_free (skey);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
desc_title = g_markup_escape_text (title, -1);
|
||||||
g_free (temp);
|
g_free (temp);
|
||||||
}
|
}
|
||||||
if (title && !desc_title)
|
|
||||||
desc_title = g_markup_escape_text (title, -1);
|
|
||||||
|
|
||||||
if (desc_title)
|
if (desc_title)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue