]> spindle.queued.net Git - midori/commitdiff
Re-implement search engines in the completion
authorChristian Dywan <christian@twotoasts.de>
Thu, 28 Jan 2010 21:19:00 +0000 (22:19 +0100)
committerChristian Dywan <christian@twotoasts.de>
Thu, 28 Jan 2010 21:19:00 +0000 (22:19 +0100)
midori/midori-browser.c
midori/midori-locationaction.c
midori/midori-preferences.c
midori/midori-websettings.c

index 44e94c708d747ab0bd44b7a0074d2a3990a1d185..27f9b2eeb26d1d3963ed4ff05459e9450b3c3d23 100644 (file)
@@ -6640,7 +6640,12 @@ midori_browser_settings_notify (MidoriWebSettings* web_settings,
             g_value_get_string (&value) && *g_value_get_string (&value));
     else if (name == g_intern_string ("search-engines-in-completion"))
     {
-        /* Do nothing */
+        if (g_value_get_boolean (&value))
+            midori_location_action_set_search_engines (MIDORI_LOCATION_ACTION (
+                _action_by_name (browser, "Location")), browser->search_engines);
+        else
+            midori_location_action_set_search_engines (MIDORI_LOCATION_ACTION (
+                _action_by_name (browser, "Location")), NULL);
     }
     else if (name == g_intern_string ("location-entry-search"))
     {
@@ -6854,6 +6859,13 @@ midori_browser_set_property (GObject*      object,
 
         /* FIXME: Disconnect handlers */
         katze_object_assign (browser->search_engines, g_value_dup_object (value));
+        if (katze_object_get_boolean (browser->settings,
+                                      "search-engines-in-completion"))
+            midori_location_action_set_search_engines (MIDORI_LOCATION_ACTION (
+                _action_by_name (browser, "Location")), browser->search_engines);
+        else
+            midori_location_action_set_search_engines (MIDORI_LOCATION_ACTION (
+                _action_by_name (browser, "Location")), NULL);
         midori_search_action_set_search_engines (MIDORI_SEARCH_ACTION (
             _action_by_name (browser, "Search")), browser->search_engines);
         /* FIXME: Connect to updates */
index 5098794d70e63b92b4324ee120ea9938b60cfea9..a0593643f279d29974c7fde554aea38e3abcffd1 100644 (file)
@@ -34,6 +34,7 @@ struct _MidoriLocationAction
 
     gchar* text;
     gchar* uri;
+    KatzeArray* search_engines;
     gdouble progress;
     gchar* secondary_icon;
 
@@ -373,7 +374,7 @@ midori_location_action_popup_timeout_cb (gpointer data)
     }
 
     result = sqlite3_step (statement);
-    if (result != SQLITE_ROW)
+    if (result != SQLITE_ROW && !action->search_engines)
     {
         sqlite3_finalize (statement);
         midori_location_action_popdown_completion (action);
@@ -432,7 +433,7 @@ midori_location_action_popup_timeout_cb (gpointer data)
     gtk_list_store_clear (store);
 
     matches = 0;
-    do
+    while (result == SQLITE_ROW)
     {
         const unsigned char* uri = sqlite3_column_text (statement, 0);
         const unsigned char* title = sqlite3_column_text (statement, 1);
@@ -445,8 +446,27 @@ midori_location_action_popup_timeout_cb (gpointer data)
         matches++;
         result = sqlite3_step (statement);
     }
-    while (result == SQLITE_ROW);
-    /* TODO: Suggest _("Search with %s") or opening hostname as actions */
+
+    if (action->search_engines)
+    {
+        gint i = 0;
+        KatzeItem* item;
+        while ((item = katze_array_get_nth_item (action->search_engines, i)))
+        {
+            gchar* uri;
+            gchar* title;
+
+            uri = sokoke_search_uri (katze_item_get_uri (item), action->key);
+            title = g_strdup_printf (_("Search with %s"), katze_item_get_name (item));
+            gtk_list_store_insert_with_values (store, NULL, matches,
+                URI_COL, uri, TITLE_COL, title, YALIGN_COL, 0.25,
+                FAVICON_COL, NULL, -1);
+            g_free (uri);
+            g_free (title);
+            i++;
+        }
+        matches += i;
+    }
 
     if (!GTK_WIDGET_VISIBLE (action->popup))
     {
@@ -547,6 +567,7 @@ static void
 midori_location_action_init (MidoriLocationAction* location_action)
 {
     location_action->text = location_action->uri = NULL;
+    location_action->search_engines = NULL;
     location_action->progress = 0.0;
     location_action->secondary_icon = NULL;
     location_action->default_icon = NULL;
@@ -565,6 +586,7 @@ midori_location_action_finalize (GObject* object)
 
     katze_assign (location_action->text, NULL);
     katze_assign (location_action->uri, NULL);
+    katze_assign (location_action->search_engines, NULL);
 
     katze_assign (location_action->key, NULL);
     if (location_action->popup)
@@ -1455,15 +1477,21 @@ midori_location_action_set_title_for_uri (MidoriLocationAction* location_action,
  * @location_action: a #MidoriLocationAction
  * @search_engines: a #KatzeArray
  *
- * This function is obsolete and has no effect.
+ * Assigns the specified search engines to the location action.
+ * Search engines will appear as actions in the completion.
  *
- * Deprecated: 0.2.3
+ * Since: 0.1.6
  **/
 void
 midori_location_action_set_search_engines (MidoriLocationAction* location_action,
                                            KatzeArray*           search_engines)
 {
-    /* Do nothing */
+    g_return_if_fail (MIDORI_IS_LOCATION_ACTION (location_action));
+
+    if (search_engines)
+        g_object_ref (search_engines);
+
+    katze_object_assign (location_action->search_engines, search_engines);
 }
 
 gdouble
index df1234982ee0576dfc5d2495e328ba4c987bbaa4..fe71743ef4aed7602db444a316350472031c6ef6 100644 (file)
@@ -435,6 +435,8 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
     SPANNED_ADD (button);
     button = katze_property_proxy (settings, "progress-in-location", NULL);
     INDENTED_ADD (button);
+    button = katze_property_proxy (settings, "search-engines-in-completion", NULL);
+    SPANNED_ADD (button);
     #endif
     FRAME_NEW (_("Browsing"));
     label = katze_property_label (settings, "open-new-pages-in");
index 4305a413a43755321499109a518174d5b849c730..10e40e890ec0dcafc29de6a29a6011bf456ff51e 100644 (file)
@@ -512,7 +512,7 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
     *
     * Whether to show search engines in the location completion.
     *
-    * Deprecated: 0.2.3: This setting is obsolete.
+    * Since: 0.1.6
     */
     g_object_class_install_property (gobject_class,
                                      PROP_SEARCH_ENGINES_IN_COMPLETION,