[Xfce4-commits] <midori:master> Fix detaching and reattaching the inspector to browser

Christian Dywan noreply at xfce.org
Mon Apr 4 21:58:01 CEST 2011


Updating branch refs/heads/master
         to 2ffd780bb6079e4cdfee50fd5912a20e533a6903 (commit)
       from f97d82c5597ce0f6b19f47f91d35f75f29c892de (commit)

commit 2ffd780bb6079e4cdfee50fd5912a20e533a6903
Author: André Stösel <andre at stoesel.de>
Date:   Mon Apr 4 21:56:21 2011 +0200

    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 deletions(-)

diff --git a/midori/midori-browser.c b/midori/midori-browser.c
index 790b35a..ca2b5a5 100644
--- a/midori/midori-browser.c
+++ b/midori/midori-browser.c
@@ -1249,6 +1249,17 @@ midori_view_attach_inspector_cb (GtkWidget*     view,
 }
 
 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,
                                   gboolean   omit_last)
@@ -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 1a73b7e..3a309a6 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;



More information about the Xfce4-commits mailing list