From 2ffd780bb6079e4cdfee50fd5912a20e533a6903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20St=C3=B6sel?= Date: Mon, 4 Apr 2011 21:56:21 +0200 Subject: [PATCH] Fix detaching and reattaching the inspector to browser Probably related to https://bugs.launchpad.net/midori/+bug/746540 Special thanks to Andy Kittner, who helped me with debugging. --- midori/midori-browser.c | 13 +++++++++++++ midori/midori-view.c | 23 ++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/midori/midori-browser.c b/midori/midori-browser.c index 790b35a5..ca2b5a58 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -1248,6 +1248,17 @@ midori_view_attach_inspector_cb (GtkWidget* view, gtk_widget_destroy (toplevel); } +static void +midori_view_detach_inspector_cb (GtkWidget* view, + GtkWidget* inspector_view, + MidoriBrowser* browser) +{ + GtkWidget* scrolled = gtk_widget_get_parent (GTK_WIDGET (inspector_view)); + browser->inspector_view = gtk_viewport_new (NULL, NULL); + gtk_container_remove (GTK_CONTAINER (scrolled), GTK_WIDGET (inspector_view)); + gtk_container_add (GTK_CONTAINER (scrolled), browser->inspector_view); +} + static void midori_browser_view_copy_history (GtkWidget* view_to, GtkWidget* view_from, @@ -1546,6 +1557,8 @@ _midori_browser_add_tab (MidoriBrowser* browser, midori_view_activate_action_cb, browser, "signal::attach-inspector", midori_view_attach_inspector_cb, browser, + "signal::detach-inspector", + midori_view_detach_inspector_cb, browser, "signal::new-tab", midori_view_new_tab_cb, browser, "signal::new-window", diff --git a/midori/midori-view.c b/midori/midori-view.c index 1a73b7e6..3a309a6a 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -194,6 +194,7 @@ enum { CONSOLE_MESSAGE, CONTEXT_READY, ATTACH_INSPECTOR, + DETACH_INSPECTOR, NEW_TAB, NEW_WINDOW, NEW_VIEW, @@ -289,6 +290,26 @@ midori_view_class_init (MidoriViewClass* class) G_TYPE_NONE, 1, GTK_TYPE_WIDGET); + /** + * MidoriView::detach-inspector: + * @view: the object on which the signal is emitted + * + * Emitted when an open inspector that was previously + * attached to the window is now detached again. + * + * Since: 0.3.4 + */ + signals[DETACH_INSPECTOR] = g_signal_new ( + "detach-inspector", + G_TYPE_FROM_CLASS (class), + (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), + 0, + 0, + NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, + GTK_TYPE_WIDGET); + signals[NEW_TAB] = g_signal_new ( "new-tab", G_TYPE_FROM_CLASS (class), @@ -3638,7 +3659,7 @@ midori_view_web_inspector_detach_window_cb (gpointer inspector, return FALSE; gtk_widget_hide (parent); - gtk_container_remove (GTK_CONTAINER (parent), GTK_WIDGET (inspector_view)); + g_signal_emit (view, signals[DETACH_INSPECTOR], 0, inspector_view); midori_view_web_inspector_construct_window (inspector, WEBKIT_WEB_VIEW (view->web_view), GTK_WIDGET (inspector_view), view); return TRUE;