Move app spawning to sokoke_spawn_app and use in MidoriView

This commit is contained in:
Christian Dywan 2010-10-10 13:02:50 +02:00
parent 0344792c2f
commit 120c5bf40f
4 changed files with 20 additions and 23 deletions

View file

@ -2133,32 +2133,12 @@ _action_tab_new_activate (GtkAction* action,
midori_browser_set_current_page (browser, n); 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 static void
_action_private_browsing_activate (GtkAction* action, _action_private_browsing_activate (GtkAction* action,
MidoriBrowser* browser) MidoriBrowser* browser)
{ {
const gchar* uri = midori_browser_get_current_uri (browser); const gchar* uri = midori_browser_get_current_uri (browser);
if (uri != NULL) sokoke_spawn_app (uri && *uri ? uri : "about:blank");
{
if (*uri != '\0')
midori_browser_spawn_app (uri);
else
midori_browser_spawn_app ("about:blank");
}
} }
static void static void
@ -2761,7 +2741,7 @@ midori_browser_open_bookmark (MidoriBrowser* browser,
uri_fixed = g_strdup (uri); uri_fixed = g_strdup (uri);
if (katze_item_get_meta_boolean (item, "app")) if (katze_item_get_meta_boolean (item, "app"))
midori_browser_spawn_app (uri_fixed); sokoke_spawn_app (uri_fixed);
else else
{ {
midori_browser_set_current_uri (browser, uri_fixed); midori_browser_set_current_uri (browser, uri_fixed);

View file

@ -1699,7 +1699,7 @@ static void
midori_web_view_menu_web_app_activate_cb (GtkWidget* widget, midori_web_view_menu_web_app_activate_cb (GtkWidget* widget,
MidoriView* view) MidoriView* view)
{ {
sokoke_spawn_program ("midori -a", view->link_uri, FALSE); sokoke_spawn_app (view->link_uri);
} }
static void static void

View file

@ -484,6 +484,20 @@ sokoke_spawn_program (const gchar* command,
return TRUE; 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: * sokoke_hostname_from_uri:
* @uri: an URI string * @uri: an URI string

View file

@ -102,6 +102,9 @@ sokoke_spawn_program (const gchar* command,
const gchar* argument, const gchar* argument,
gboolean quote); gboolean quote);
void
sokoke_spawn_app (const gchar* uri);
gchar* sokoke_search_uri (const gchar* uri, gchar* sokoke_search_uri (const gchar* uri,
const gchar* keywords); const gchar* keywords);