Running "midori" should open a new window

This commit is contained in:
Christian Dywan 2008-09-10 19:48:45 +02:00
parent b62869a49b
commit 2c1cdb0573
3 changed files with 49 additions and 3 deletions

View file

@ -546,10 +546,10 @@ main (int argc,
if (midori_app_instance_is_running (app)) if (midori_app_instance_is_running (app))
{ {
/* TODO: Open as many tabs as we have uris, seperated by pipes */ /* TODO: Open as many tabs as we have uris, seperated by pipes */
if (argc > 1) if (uris)
result = midori_app_instance_send_uris (app, argv+1); result = midori_app_instance_send_uris (app, uris);
else else
result = midori_app_instance_send_activate (app); result = midori_app_instance_send_new_browser (app);
if (result) if (result)
return 0; return 0;

View file

@ -195,6 +195,7 @@ midori_browser_message_received_cb (UniqueApp* instance,
MidoriApp* app) MidoriApp* app)
{ {
UniqueResponse response; UniqueResponse response;
MidoriBrowser* browser;
gchar** uris; gchar** uris;
switch (command) switch (command)
@ -205,6 +206,21 @@ midori_browser_message_received_cb (UniqueApp* instance,
gtk_window_present (GTK_WINDOW (app->browser)); gtk_window_present (GTK_WINDOW (app->browser));
response = UNIQUE_RESPONSE_OK; response = UNIQUE_RESPONSE_OK;
break; break;
case UNIQUE_NEW:
browser = g_object_new (MIDORI_TYPE_BROWSER,
"settings", app->settings,
"bookmarks", app->bookmarks,
"trash", app->trash,
"search-engines", app->search_engines,
NULL);
/* FIXME: Should open the homepage according to settings */
midori_browser_add_uri (browser, "about:blank");
midori_app_add_browser (app, browser);
gtk_window_set_screen (GTK_WINDOW (app->browser),
unique_message_data_get_screen (message));
gtk_widget_show (GTK_WIDGET (browser));
response = UNIQUE_RESPONSE_OK;
break;
case UNIQUE_OPEN: case UNIQUE_OPEN:
uris = unique_message_data_get_uris (message); uris = unique_message_data_get_uris (message);
if (!uris) if (!uris)
@ -483,6 +499,33 @@ midori_app_instance_send_activate (MidoriApp* app)
return FALSE; return FALSE;
} }
/**
* midori_app_instance_send_new_browser:
* @app: a #MidoriApp
*
* Sends a message to an instance of Midori already
* running on the default display, asking to open a new browser.
*
* Return value: %TRUE if the message was sent successfully
**/
gboolean
midori_app_instance_send_new_browser (MidoriApp* app)
{
#if HAVE_UNIQUE
UniqueResponse response;
#endif
g_return_val_if_fail (MIDORI_IS_APP (app), FALSE);
g_return_val_if_fail (midori_app_instance_is_running (app), FALSE);
#if HAVE_UNIQUE
response = unique_app_send_message (app->instance, UNIQUE_NEW, NULL);
if (response == UNIQUE_RESPONSE_OK)
return TRUE;
#endif
return FALSE;
}
/** /**
* midori_app_instance_send_uris: * midori_app_instance_send_uris:
* @app: a #MidoriApp * @app: a #MidoriApp

View file

@ -59,6 +59,9 @@ midori_app_instance_is_running (MidoriApp* app);
gboolean gboolean
midori_app_instance_send_activate (MidoriApp* app); midori_app_instance_send_activate (MidoriApp* app);
gboolean
midori_app_instance_send_new_browser (MidoriApp* app);
gboolean gboolean
midori_app_instance_send_uris (MidoriApp* app, midori_app_instance_send_uris (MidoriApp* app,
gchar** uris); gchar** uris);