From 120c5bf40f09263d5578ba591c8aafa421af5608 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Sun, 10 Oct 2010 13:02:50 +0200 Subject: [PATCH] Move app spawning to sokoke_spawn_app and use in MidoriView --- midori/midori-browser.c | 24 ++---------------------- midori/midori-view.c | 2 +- midori/sokoke.c | 14 ++++++++++++++ midori/sokoke.h | 3 +++ 4 files changed, 20 insertions(+), 23 deletions(-) diff --git a/midori/midori-browser.c b/midori/midori-browser.c index 73cf903e..b9ed4304 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -2133,32 +2133,12 @@ _action_tab_new_activate (GtkAction* action, midori_browser_set_current_page (browser, n); } -static void -midori_browser_spawn_app (const gchar* uri) -{ - const gchar* executable = sokoke_get_argv (NULL)[0]; - /* "midori" - "/usr/bin/midori" - "c:/Program Files/Midori/bin/midori.exe" */ - gchar* quoted = g_shell_quote (executable); - gchar* command = g_strconcat (quoted, " -a", NULL); - g_free (quoted); - sokoke_spawn_program (command, uri, FALSE); - g_free (command); -} - static void _action_private_browsing_activate (GtkAction* action, MidoriBrowser* browser) { const gchar* uri = midori_browser_get_current_uri (browser); - if (uri != NULL) - { - if (*uri != '\0') - midori_browser_spawn_app (uri); - else - midori_browser_spawn_app ("about:blank"); - } + sokoke_spawn_app (uri && *uri ? uri : "about:blank"); } static void @@ -2761,7 +2741,7 @@ midori_browser_open_bookmark (MidoriBrowser* browser, uri_fixed = g_strdup (uri); if (katze_item_get_meta_boolean (item, "app")) - midori_browser_spawn_app (uri_fixed); + sokoke_spawn_app (uri_fixed); else { midori_browser_set_current_uri (browser, uri_fixed); diff --git a/midori/midori-view.c b/midori/midori-view.c index 4ab5344c..cd53bd35 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -1699,7 +1699,7 @@ static void midori_web_view_menu_web_app_activate_cb (GtkWidget* widget, MidoriView* view) { - sokoke_spawn_program ("midori -a", view->link_uri, FALSE); + sokoke_spawn_app (view->link_uri); } static void diff --git a/midori/sokoke.c b/midori/sokoke.c index caac7f1a..02a623ac 100644 --- a/midori/sokoke.c +++ b/midori/sokoke.c @@ -484,6 +484,20 @@ sokoke_spawn_program (const gchar* command, return TRUE; } +void +sokoke_spawn_app (const gchar* uri) +{ + const gchar* executable = sokoke_get_argv (NULL)[0]; + /* "midori" + "/usr/bin/midori" + "c:/Program Files/Midori/bin/midori.exe" */ + gchar* quoted = g_shell_quote (executable); + gchar* command = g_strconcat (quoted, " -a", NULL); + g_free (quoted); + sokoke_spawn_program (command, uri, FALSE); + g_free (command); +} + /** * sokoke_hostname_from_uri: * @uri: an URI string diff --git a/midori/sokoke.h b/midori/sokoke.h index 29a9cfb3..a5c94be1 100644 --- a/midori/sokoke.h +++ b/midori/sokoke.h @@ -102,6 +102,9 @@ sokoke_spawn_program (const gchar* command, const gchar* argument, gboolean quote); +void +sokoke_spawn_app (const gchar* uri); + gchar* sokoke_search_uri (const gchar* uri, const gchar* keywords);