[Xfce4-commits] <midori:master> Tweak location match rendering by reducing conditions

Christian Dywan noreply at xfce.org
Sat Dec 26 15:24:04 CET 2009


Updating branch refs/heads/master
         to 0f988af44659304d4e2113ef2fe4ceeaf4d3e9e5 (commit)
       from 138e837457562c0041606e089c7e5510007828dc (commit)

commit 0f988af44659304d4e2113ef2fe4ceeaf4d3e9e5
Author: Christian Dywan <christian at twotoasts.de>
Date:   Sat Dec 26 14:22:25 2009 +0100

    Tweak location match rendering by reducing conditions

 midori/midori-locationaction.c |   81 +++++++++++++++++++++-------------------
 1 files changed, 43 insertions(+), 38 deletions(-)

diff --git a/midori/midori-locationaction.c b/midori/midori-locationaction.c
index f74d602..14ec6fd 100644
--- a/midori/midori-locationaction.c
+++ b/midori/midori-locationaction.c
@@ -643,76 +643,81 @@ midori_location_entry_render_text_cb (GtkCellLayout*   layout,
     gtk_tree_model_get (model, iter, URI_COL, &uri, TITLE_COL, &title,
                         FAVICON_COL, &icon, -1);
 
-    if (G_UNLIKELY (!icon) && uri)
+    if (G_UNLIKELY (!icon))
     {
-        #if !HAVE_HILDON
-        MidoriLocationAction* action
-            = g_object_get_data (G_OBJECT (renderer), "location-action");
-        if ((icon = katze_load_cached_icon (uri, NULL)))
+        if (uri)
         {
-            midori_location_action_set_icon_for_uri (action, icon, uri);
-            g_object_unref (icon);
+            #if !HAVE_HILDON
+            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);
 
     desc = desc_uri = desc_title = key = NULL;
-    key = title ? g_utf8_strdown (gtk_entry_get_text (GTK_ENTRY (entry)), -1)
-        : g_ascii_strdown (gtk_entry_get_text (GTK_ENTRY (entry)), -1);
+    key = g_ascii_strdown (gtk_entry_get_text (GTK_ENTRY (entry)), -1);
     len = 0;
 
-    /* g_uri_unescape_segment () sometimes produces garbage */
-    if (G_UNLIKELY (uri && !g_utf8_validate (uri, -1, (const gchar **)&temp)))
-        temp[0]='\0';
-    else if (G_LIKELY (uri))
+    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);
-        if (key && *key && (start = strstr (temp, key)))
+        if ((start = strstr (temp, key)) && (start - temp))
         {
             len = strlen (key);
-            skey = g_malloc0 (len + 1);
-            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);
-            }
+            skey = g_strndup (uri + (start - temp), len);
+            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]);
+            else
+                desc_uri = g_markup_escape_text (uri, -1);
+            g_strfreev (parts);
             g_free (skey);
         }
+        else
+            desc_uri = g_markup_escape_text (uri, -1);
         g_free (temp);
     }
-    if (uri && !desc_uri)
-        desc_uri = g_markup_escape_text (uri, -1);
 
-    /* g_uri_unescape_segment () sometimes produces garbage */
-    if (G_UNLIKELY (title && !g_utf8_validate (title, -1, (const gchar **)&temp)))
-        temp[0]='\0';
-    else if (G_LIKELY (title))
+    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);
-        if (key && *key && (start = strstr (temp, key)))
+        if ((start = strstr (temp, key)) && (start - temp))
         {
             if (!len)
                 len = strlen (key);
-            skey = g_malloc0 (len + 1);
-            strncpy (skey, title + (start - temp), len);
+            skey = g_strndup (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]);
+            else
+                desc_title = g_markup_escape_text (title, -1);
             g_strfreev (parts);
             g_free (skey);
         }
+        else
+            desc_title = g_markup_escape_text (title, -1);
         g_free (temp);
     }
-    if (title && !desc_title)
-        desc_title = g_markup_escape_text (title, -1);
 
     if (desc_title)
     {



More information about the Xfce4-commits mailing list