Implement Open new pages in: New window preference

This commit is contained in:
Christian Dywan 2009-05-17 20:29:31 +02:00
parent 964bcd0c1c
commit 907f7a72ce
3 changed files with 41 additions and 16 deletions

View file

@ -135,13 +135,18 @@ midori_browser_focus_in_event_cb (MidoriBrowser* browser,
static void static void
midori_browser_new_window_cb (MidoriBrowser* browser, midori_browser_new_window_cb (MidoriBrowser* browser,
const gchar* uri, MidoriBrowser* new_browser,
MidoriApp* app) MidoriApp* app)
{ {
MidoriBrowser* new_browser = midori_app_create_browser (app); g_object_set (new_browser,
midori_app_add_browser (app, new_browser); "settings", app->settings,
"bookmarks", app->bookmarks,
"trash", app->trash,
"search-engines", app->search_engines,
"history", app->history,
NULL);
midori_browser_add_uri (new_browser, uri); midori_app_add_browser (app, new_browser);
gtk_widget_show (GTK_WIDGET (new_browser)); gtk_widget_show (GTK_WIDGET (new_browser));
} }

View file

@ -1109,7 +1109,9 @@ midori_view_new_window_cb (GtkWidget* view,
const gchar* uri, const gchar* uri,
MidoriBrowser* browser) MidoriBrowser* browser)
{ {
g_signal_emit (browser, signals[NEW_WINDOW], 0, uri); MidoriBrowser* new_browser = g_object_new (MIDORI_TYPE_BROWSER, NULL);
midori_browser_add_uri (new_browser, uri);
g_signal_emit (browser, signals[NEW_WINDOW], 0, new_browser);
} }
static void static void
@ -1120,12 +1122,10 @@ midori_view_new_view_cb (GtkWidget* view,
{ {
if (where == MIDORI_NEW_VIEW_WINDOW) if (where == MIDORI_NEW_VIEW_WINDOW)
{ {
/* MidoriBrowser* new_browser = g_object_new (MIDORI_TYPE_BROWSER, MidoriBrowser* new_browser = g_object_new (MIDORI_TYPE_BROWSER, NULL);
NULL); midori_browser_add_tab (new_browser, new_view);
g_signal_emit (browser, signals[NEW_BROWSER], 0, new_browser); */ midori_browser_set_current_tab (new_browser, new_view);
g_debug ("Opening all pages in new windows not implemented"); g_signal_emit (browser, signals[NEW_WINDOW], 0, new_browser);
midori_browser_set_current_page (browser,
midori_browser_add_tab (browser, new_view));
} }
else else
{ {
@ -1525,6 +1525,15 @@ midori_browser_class_init (MidoriBrowserClass* class)
GObjectClass* gobject_class; GObjectClass* gobject_class;
GParamFlags flags; GParamFlags flags;
/**
* MidoriBrowser::new-window:
* @browser: the object on which the signal is emitted
* @window: a new browser window
*
* Emitted when a new browser window was created.
*
* Note: Before 0.1.7 the second argument was an URI string.
*/
signals[NEW_WINDOW] = g_signal_new ( signals[NEW_WINDOW] = g_signal_new (
"new-window", "new-window",
G_TYPE_FROM_CLASS (class), G_TYPE_FROM_CLASS (class),
@ -1532,9 +1541,9 @@ midori_browser_class_init (MidoriBrowserClass* class)
G_STRUCT_OFFSET (MidoriBrowserClass, new_window), G_STRUCT_OFFSET (MidoriBrowserClass, new_window),
0, 0,
NULL, NULL,
g_cclosure_marshal_VOID__STRING, g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1, G_TYPE_NONE, 1,
G_TYPE_STRING); MIDORI_TYPE_BROWSER);
signals[ADD_TAB] = g_signal_new ( signals[ADD_TAB] = g_signal_new (
"add-tab", "add-tab",
@ -1849,7 +1858,9 @@ static void
_action_window_new_activate (GtkAction* action, _action_window_new_activate (GtkAction* action,
MidoriBrowser* browser) MidoriBrowser* browser)
{ {
g_signal_emit (browser, signals[NEW_WINDOW], 0, ""); MidoriBrowser* new_browser = g_object_new (MIDORI_TYPE_BROWSER, NULL);
midori_browser_add_uri (new_browser, "");
g_signal_emit (browser, signals[NEW_WINDOW], 0, new_browser);
} }
static void static void
@ -3174,7 +3185,11 @@ midori_browser_bookmark_open_in_window_activate_cb (GtkWidget* menuitem,
uri = katze_item_get_uri (item); uri = katze_item_get_uri (item);
if (uri && *uri) if (uri && *uri)
g_signal_emit (browser, signals[NEW_WINDOW], 0, uri); {
MidoriBrowser* new_browser = g_object_new (MIDORI_TYPE_BROWSER, NULL);
midori_browser_add_uri (new_browser, uri);
g_signal_emit (browser, signals[NEW_WINDOW], 0, new_browser);
}
} }
static void static void

View file

@ -42,6 +42,9 @@ midori_search_action_get_icon (KatzeNet* net,
KatzeItem* item, KatzeItem* item,
GtkWidget* widget); GtkWidget* widget);
static void
midori_view_construct_web_view (MidoriView* view);
struct _MidoriView struct _MidoriView
{ {
GtkScrolledWindow parent_instance; GtkScrolledWindow parent_instance;
@ -1387,7 +1390,7 @@ webkit_web_view_create_web_view_cb (GtkWidget* web_view,
"net", view->net, "net", view->net,
"settings", view->settings, "settings", view->settings,
NULL); NULL);
midori_view_set_uri (MIDORI_VIEW (new_view), ""); midori_view_construct_web_view (MIDORI_VIEW (new_view));
g_signal_connect (MIDORI_VIEW (new_view)->web_view, "web-view-ready", g_signal_connect (MIDORI_VIEW (new_view)->web_view, "web-view-ready",
G_CALLBACK (webkit_web_view_web_view_ready_cb), view); G_CALLBACK (webkit_web_view_web_view_ready_cb), view);
return MIDORI_VIEW (new_view)->web_view; return MIDORI_VIEW (new_view)->web_view;
@ -1916,6 +1919,8 @@ midori_view_construct_web_view (MidoriView* view)
WebKitWebFrame* web_frame; WebKitWebFrame* web_frame;
gpointer inspector; gpointer inspector;
g_return_if_fail (!view->web_view);
view->web_view = webkit_web_view_new (); view->web_view = webkit_web_view_new ();
/* Load something to avoid a bug where WebKit might not set a main frame */ /* Load something to avoid a bug where WebKit might not set a main frame */