[Xfce4-commits] <midori:master> Prefill description when adding search engine

Christian Dywan noreply at xfce.org
Tue Jul 24 23:12:03 CEST 2012


Updating branch refs/heads/master
         to d95513226d265448abc7d12ec1431e9c9d7c0a54 (commit)
       from dce8096593f661f263294b353dc1486ed64c9449 (commit)

commit d95513226d265448abc7d12ec1431e9c9d7c0a54
Author: Paweł Forysiuk <tuxator at o2.pl>
Date:   Tue Jul 24 23:03:17 2012 +0200

    Prefill description when adding search engine

 midori/midori-searchaction.c |    3 +--
 midori/midori-view.c         |   41 ++++++++++++++++++++++++++++++++++++-----
 2 files changed, 37 insertions(+), 7 deletions(-)

diff --git a/midori/midori-searchaction.c b/midori/midori-searchaction.c
index a60271f..9568573 100644
--- a/midori/midori-searchaction.c
+++ b/midori/midori-searchaction.c
@@ -946,8 +946,7 @@ midori_search_action_get_editor (MidoriSearchAction* search_action,
     gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
     entry_description = gtk_entry_new ();
     gtk_entry_set_activates_default (GTK_ENTRY (entry_description), TRUE);
-    if (!new_engine)
-        gtk_entry_set_text (GTK_ENTRY (entry_description)
+    gtk_entry_set_text (GTK_ENTRY (entry_description)
          , katze_str_non_null (katze_item_get_text (item)));
     gtk_box_pack_start (GTK_BOX (hbox), entry_description, TRUE, TRUE, 0);
     gtk_container_add (GTK_CONTAINER (content_area), hbox);
diff --git a/midori/midori-view.c b/midori/midori-view.c
index b37c8cf..12137fa 100644
--- a/midori/midori-view.c
+++ b/midori/midori-view.c
@@ -2442,7 +2442,8 @@ midori_view_menu_add_search_engine_cb (GtkWidget*  widget,
 }
 
 static KatzeItem*
-midori_view_search_engine_for_form (WebKitWebView* web_view)
+midori_view_search_engine_for_form (MidoriView*    view,
+                                    WebKitWebView* web_view)
 {
 
     WebKitDOMDocument* doc;
@@ -2450,9 +2451,12 @@ midori_view_search_engine_for_form (WebKitWebView* web_view)
     WebKitDOMHTMLCollection* form_nodes;
     WebKitDOMElement* active_element;
     gchar* token_element;
+    const gchar* title;
     GString* uri_str;
     gulong form_len;
     guint i;
+    KatzeItem* item;
+    gchar** parts;
 
     #if WEBKIT_CHECK_VERSION (1, 9, 5)
     doc = webkit_web_frame_get_dom_document (web_view);
@@ -2504,10 +2508,37 @@ midori_view_search_engine_for_form (WebKitWebView* web_view)
         }
     }
 
+    title = webkit_web_view_get_title (web_view);
+
+    item = katze_item_new ();
+    katze_item_set_uri (item, g_string_free (uri_str, FALSE));
+
+    if (strstr (title, " - "))
+        parts = g_strsplit (title, " - ", 2);
+    else if (strstr (title, ": "))
+        parts = g_strsplit (title, ": ", 2);
+    else
+        parts = NULL;
+    if (parts != NULL)
+    {
+        /* See midori_view_set_title: title can be first or last */
+        if (view->ellipsize == PANGO_ELLIPSIZE_END)
+        {
+            katze_item_set_name (item, g_strdup (parts[0]));
+            katze_item_set_text (item, g_strdup (parts[1]));
+        }
+        else
+        {
+            katze_item_set_name (item, g_strdup (parts[1]));
+            katze_item_set_text (item, g_strdup (parts[2]));
+        }
+        g_strfreev (parts);
+    }
+    else
+        katze_item_set_name (item, title);
+
     g_free (token_element);
-    return g_object_new (KATZE_TYPE_ITEM,
-        "uri", g_string_free (uri_str, FALSE),
-        "name", webkit_web_view_get_title (web_view), NULL);
+    return item;
 }
 #endif
 
@@ -2619,7 +2650,7 @@ midori_view_populate_popup (MidoriView* view,
 
         #if WEBKIT_CHECK_VERSION (1, 5, 0)
         {
-            KatzeItem* item = midori_view_search_engine_for_form (web_view);
+            KatzeItem* item = midori_view_search_engine_for_form (view, web_view);
             if (item != NULL)
             {
                 menuitem = midori_view_insert_menu_item (menu_shell, -1,


More information about the Xfce4-commits mailing list