Implement and make use of midori_app_create_browser

This commit is contained in:
Christian Dywan 2008-12-25 00:39:35 +01:00
parent 770b6d9e11
commit be9c907c7e
2 changed files with 35 additions and 25 deletions

View file

@ -108,17 +108,11 @@ midori_browser_new_window_cb (MidoriBrowser* browser,
const gchar* uri, const gchar* uri,
MidoriApp* app) MidoriApp* app)
{ {
MidoriBrowser* new_browser = g_object_new (MIDORI_TYPE_BROWSER, MidoriBrowser* new_browser = midori_app_create_browser (app);
"settings", app->settings, midori_app_add_browser (app, new_browser);
"bookmarks", app->bookmarks,
"trash", app->trash,
"search-engines", app->search_engines,
"history", app->history,
NULL);
midori_browser_add_uri (new_browser, uri); midori_browser_add_uri (new_browser, uri);
gtk_widget_show (GTK_WIDGET (new_browser)); gtk_widget_show (GTK_WIDGET (new_browser));
g_signal_emit (app, signals[ADD_BROWSER], 0, new_browser);
} }
static gboolean static gboolean
@ -307,17 +301,11 @@ midori_browser_message_received_cb (UniqueApp* instance,
response = UNIQUE_RESPONSE_OK; response = UNIQUE_RESPONSE_OK;
break; break;
case UNIQUE_NEW: case UNIQUE_NEW:
browser = g_object_new (MIDORI_TYPE_BROWSER, browser = midori_app_create_browser (app);
"settings", app->settings, midori_app_add_browser (app, browser);
"bookmarks", app->bookmarks,
"trash", app->trash,
"search-engines", app->search_engines,
"history", app->history,
NULL);
/* FIXME: Should open the homepage according to settings */ /* FIXME: Should open the homepage according to settings */
midori_browser_add_uri (browser, ""); midori_browser_add_uri (browser, "");
midori_browser_activate_action (browser, "Location"); midori_browser_activate_action (browser, "Location");
midori_app_add_browser (app, browser);
gtk_window_set_screen (GTK_WINDOW (app->browser), gtk_window_set_screen (GTK_WINDOW (app->browser),
unique_message_data_get_screen (message)); unique_message_data_get_screen (message));
gtk_widget_show (GTK_WIDGET (browser)); gtk_widget_show (GTK_WIDGET (browser));
@ -336,13 +324,7 @@ midori_browser_message_received_cb (UniqueApp* instance,
&open_external_pages_in, NULL); &open_external_pages_in, NULL);
if (open_external_pages_in == MIDORI_NEW_PAGE_WINDOW) if (open_external_pages_in == MIDORI_NEW_PAGE_WINDOW)
{ {
browser = g_object_new (MIDORI_TYPE_BROWSER, browser = midori_app_create_browser (app);
"settings", app->settings,
"bookmarks", app->bookmarks,
"trash", app->trash,
"search-engines", app->search_engines,
"history", app->history,
NULL);
midori_app_add_browser (app, browser); midori_app_add_browser (app, browser);
gtk_window_set_screen (GTK_WINDOW (app->browser), gtk_window_set_screen (GTK_WINDOW (app->browser),
unique_message_data_get_screen (message)); unique_message_data_get_screen (message));
@ -649,7 +631,7 @@ midori_app_instance_send_uris (MidoriApp* app,
* @app: a #MidoriApp * @app: a #MidoriApp
* @browser: a #MidoriBrowser * @browser: a #MidoriBrowser
* *
* Adds a #MidoriBrowser to the #MidoriApp singleton. * Adds a #MidoriBrowser to the #MidoriApp.
* *
* The app will take care of the browser's new-window and quit signals, as well * The app will take care of the browser's new-window and quit signals, as well
* as watch window closing so that the last closed window quits the app. * as watch window closing so that the last closed window quits the app.
@ -667,6 +649,31 @@ midori_app_add_browser (MidoriApp* app,
g_signal_emit (app, signals[ADD_BROWSER], 0, browser); g_signal_emit (app, signals[ADD_BROWSER], 0, browser);
} }
/**
* midori_app_create_browser:
* @app: a #MidoriApp
*
* Creates a #MidoriBrowser which inherits its settings,
* bookmarks, trash, search engines and history from @app.
*
* Return value: a new #MidoriBrowser
*
* Since: 1.0.2
**/
MidoriBrowser*
midori_app_create_browser (MidoriApp* app)
{
g_return_val_if_fail (MIDORI_IS_APP (app), NULL);
return g_object_new (MIDORI_TYPE_BROWSER,
"settings", app->settings,
"bookmarks", app->bookmarks,
"trash", app->trash,
"search-engines", app->search_engines,
"history", app->history,
NULL);
}
/** /**
* midori_app_quit: * midori_app_quit:
* @app: a #MidoriApp * @app: a #MidoriApp

View file

@ -58,6 +58,9 @@ void
midori_app_add_browser (MidoriApp* app, midori_app_add_browser (MidoriApp* app,
MidoriBrowser* browser); MidoriBrowser* browser);
MidoriBrowser*
midori_app_create_browser (MidoriApp* app);
void void
midori_app_quit (MidoriApp* app); midori_app_quit (MidoriApp* app);