]> spindle.queued.net Git - midori/commitdiff
Fix detaching and reattaching the inspector to browser
authorAndré Stösel <andre@stoesel.de>
Mon, 4 Apr 2011 19:56:21 +0000 (21:56 +0200)
committerChristian Dywan <christian@twotoasts.de>
Mon, 4 Apr 2011 19:56:21 +0000 (21:56 +0200)
Probably related to https://bugs.launchpad.net/midori/+bug/746540

Special thanks to Andy Kittner, who helped me with debugging.

midori/midori-browser.c
midori/midori-view.c

index 790b35a50e66457d0dca435a9b79e5badfb084c0..ca2b5a5819c29bd6e75e8d41ed67c8d98d53ac7a 100644 (file)
@@ -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",
index 1a73b7e6e0e9bd3c66b44b0d29b3ab11c61a6253..3a309a6a29bf383e86084857e9e901395a3b58cb 100644 (file)
@@ -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;