[Xfce4-commits] <midori:master> Store searches with tokens in the completion as a distinct item
Christian Dywan
noreply at xfce.org
Fri Jan 1 22:50:02 CET 2010
Updating branch refs/heads/master
to 311a5a8a1b767c36274e44819fd3a9f3ec69ce41 (commit)
from 3aff0a34d0cadb99cb5db1e2912041bd5e672376 (commit)
commit 311a5a8a1b767c36274e44819fd3a9f3ec69ce41
Author: Christian Dywan <christian at twotoasts.de>
Date: Fri Jan 1 22:47:24 2010 +0100
Store searches with tokens in the completion as a distinct item
Currently searches won't be stored persistently in the database.
midori/main.c | 2 +-
midori/midori-app.c | 2 +-
midori/midori-browser.c | 34 ++++++++++++++++++++++++++++++++--
midori/midori-view.c | 4 ++--
midori/sokoke.c | 8 +++++++-
midori/sokoke.h | 3 ++-
tests/magic-uri.c | 2 +-
7 files changed, 46 insertions(+), 9 deletions(-)
diff --git a/midori/main.c b/midori/main.c
index d747282..077bc6a 100644
--- a/midori/main.c
+++ b/midori/main.c
@@ -2035,7 +2035,7 @@ main (int argc,
g_free (current_dir);
}
else
- uri_ready = sokoke_magic_uri (uri, NULL);
+ uri_ready = sokoke_magic_uri (uri, NULL, NULL);
katze_item_set_uri (item, uri_ready);
g_free (uri_ready);
katze_array_add_item (_session, item);
diff --git a/midori/midori-app.c b/midori/midori-app.c
index 0574259..c1df59e 100644
--- a/midori/midori-app.c
+++ b/midori/midori-app.c
@@ -454,7 +454,7 @@ midori_app_command_received (MidoriApp* app,
first = (open_external_pages_in == MIDORI_NEW_PAGE_CURRENT);
while (*uris)
{
- gchar* fixed_uri = sokoke_magic_uri (*uris, NULL);
+ gchar* fixed_uri = sokoke_magic_uri (*uris, NULL, NULL);
if (first)
{
midori_browser_set_current_uri (browser, fixed_uri);
diff --git a/midori/midori-browser.c b/midori/midori-browser.c
index 13f0696..62667db 100644
--- a/midori/midori-browser.c
+++ b/midori/midori-browser.c
@@ -198,6 +198,11 @@ static void
midori_browser_add_download_item (MidoriBrowser* browser,
WebKitDownload* download);
+GdkPixbuf*
+midori_search_action_get_icon (KatzeItem* item,
+ GtkWidget* widget,
+ const gchar** icon_name);
+
static GtkAction*
_action_by_name (MidoriBrowser* browser,
const gchar* name)
@@ -2918,7 +2923,7 @@ midori_browser_open_bookmark (MidoriBrowser* browser,
return;
/* Imported bookmarks may lack a protocol */
- uri_fixed = sokoke_magic_uri (uri, NULL);
+ uri_fixed = sokoke_magic_uri (uri, NULL, NULL);
/* FIXME: Use the same binary that is running right now */
if (katze_item_get_meta_integer (item, "app") != -1)
@@ -3707,6 +3712,8 @@ _action_location_reset_uri (GtkAction* action,
midori_location_action_set_uri (MIDORI_LOCATION_ACTION (action), uri);
}
+
+
static void
_action_location_submit_uri (GtkAction* action,
const gchar* uri,
@@ -3715,15 +3722,38 @@ _action_location_submit_uri (GtkAction* action,
{
gchar* stripped_uri;
gchar* new_uri;
+ KatzeItem* item;
gint n;
stripped_uri = g_strdup (uri);
g_strstrip (stripped_uri);
- new_uri = sokoke_magic_uri (stripped_uri, browser->search_engines);
+ item = NULL;
+ new_uri = sokoke_magic_uri (stripped_uri, browser->search_engines, &item);
if (!new_uri)
new_uri = sokoke_search_uri (browser->location_entry_search, stripped_uri);
g_free (stripped_uri);
+ if (item)
+ {
+ gchar* title;
+ GdkPixbuf* icon;
+ const gchar* icon_name;
+
+ title = g_strdup_printf (_("Search with %s"), katze_item_get_name (item));
+ icon = midori_search_action_get_icon (item, GTK_WIDGET (browser), &icon_name);
+ if (!icon)
+ {
+ GdkScreen* screen = gtk_widget_get_screen (GTK_WIDGET (browser));
+ GtkIconTheme* icon_theme = gtk_icon_theme_get_for_screen (screen);
+ icon = gtk_icon_theme_load_icon (icon_theme, icon_name, 16, 0, NULL);
+ }
+ midori_location_action_add_item (MIDORI_LOCATION_ACTION (action),
+ uri, icon, title);
+ if (icon)
+ g_object_unref (icon);
+ g_free (title);
+ }
+
if (new_tab)
{
n = midori_browser_add_uri (browser, new_uri);
diff --git a/midori/midori-view.c b/midori/midori-view.c
index 4abd75c..5a2e43d 100644
--- a/midori/midori-view.c
+++ b/midori/midori-view.c
@@ -1303,7 +1303,7 @@ gtk_widget_button_press_event_cb (WebKitWebView* web_view,
while (uri[i++] != '\0')
if (uri[i] == '\n' || uri[i] == '\r')
uri[i] = ' ';
- new_uri = sokoke_magic_uri (g_strstrip (uri), empty_array);
+ new_uri = sokoke_magic_uri (g_strstrip (uri), empty_array, NULL);
g_object_unref (empty_array);
if (!new_uri)
{
@@ -1554,7 +1554,7 @@ midori_web_view_menu_new_tab_activate_cb (GtkWidget* widget,
}
else
{
- gchar* uri = sokoke_magic_uri (data, NULL);
+ gchar* uri = sokoke_magic_uri (data, NULL, NULL);
g_signal_emit (view, signals[NEW_TAB], 0, uri,
view->open_tabs_in_the_background);
g_free (uri);
diff --git a/midori/sokoke.c b/midori/sokoke.c
index 89dd0b3..15e5504 100644
--- a/midori/sokoke.c
+++ b/midori/sokoke.c
@@ -526,15 +526,19 @@ gchar* sokoke_search_uri (const gchar* uri,
* sokoke_magic_uri:
* @uri: a string typed by a user
* @search_engines: search engines
+ * @item: the location to store a #KatzeItem
*
* Takes a string that was typed by a user,
* guesses what it is, and returns an URI.
*
+ * If it was a search, @item will contain the engine.
+ *
* Return value: a newly allocated URI
**/
gchar*
sokoke_magic_uri (const gchar* uri,
- KatzeArray* search_engines)
+ KatzeArray* search_engines,
+ KatzeItem** found_item)
{
gchar** parts;
gchar* search;
@@ -593,6 +597,8 @@ sokoke_magic_uri (const gchar* uri,
{
search_uri = katze_item_get_uri (item);
search = sokoke_search_uri (search_uri, parts[1] ? parts[1] : "");
+ if (found_item)
+ *found_item = item;
}
g_strfreev (parts);
return search;
diff --git a/midori/sokoke.h b/midori/sokoke.h
index acf91ef..85c11ff 100644
--- a/midori/sokoke.h
+++ b/midori/sokoke.h
@@ -61,7 +61,8 @@ sokoke_uri_to_ascii (const gchar* uri);
gchar*
sokoke_magic_uri (const gchar* uri,
- KatzeArray* search_engines);
+ KatzeArray* search_engines,
+ KatzeItem** found_item);
gchar*
sokoke_format_uri_for_display (const gchar* uri);
diff --git a/tests/magic-uri.c b/tests/magic-uri.c
index 5733927..35c6fdb 100644
--- a/tests/magic-uri.c
+++ b/tests/magic-uri.c
@@ -55,7 +55,7 @@ test_input (const gchar* input,
g_object_unref (item);
}
- gchar* uri = sokoke_magic_uri (input, search_engines);
+ gchar* uri = sokoke_magic_uri (input, search_engines, NULL);
sokoke_assert_str_equal (input, uri, expected);
g_free (uri);
}
More information about the Xfce4-commits
mailing list