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.
This commit is contained in:
André Stösel 2011-04-04 21:56:21 +02:00 committed by Christian Dywan
parent f97d82c559
commit 2ffd780bb6
2 changed files with 35 additions and 1 deletions

View file

@ -1248,6 +1248,17 @@ midori_view_attach_inspector_cb (GtkWidget* view,
gtk_widget_destroy (toplevel); 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 static void
midori_browser_view_copy_history (GtkWidget* view_to, midori_browser_view_copy_history (GtkWidget* view_to,
GtkWidget* view_from, GtkWidget* view_from,
@ -1546,6 +1557,8 @@ _midori_browser_add_tab (MidoriBrowser* browser,
midori_view_activate_action_cb, browser, midori_view_activate_action_cb, browser,
"signal::attach-inspector", "signal::attach-inspector",
midori_view_attach_inspector_cb, browser, midori_view_attach_inspector_cb, browser,
"signal::detach-inspector",
midori_view_detach_inspector_cb, browser,
"signal::new-tab", "signal::new-tab",
midori_view_new_tab_cb, browser, midori_view_new_tab_cb, browser,
"signal::new-window", "signal::new-window",

View file

@ -194,6 +194,7 @@ enum {
CONSOLE_MESSAGE, CONSOLE_MESSAGE,
CONTEXT_READY, CONTEXT_READY,
ATTACH_INSPECTOR, ATTACH_INSPECTOR,
DETACH_INSPECTOR,
NEW_TAB, NEW_TAB,
NEW_WINDOW, NEW_WINDOW,
NEW_VIEW, NEW_VIEW,
@ -289,6 +290,26 @@ midori_view_class_init (MidoriViewClass* class)
G_TYPE_NONE, 1, G_TYPE_NONE, 1,
GTK_TYPE_WIDGET); 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 ( signals[NEW_TAB] = g_signal_new (
"new-tab", "new-tab",
G_TYPE_FROM_CLASS (class), G_TYPE_FROM_CLASS (class),
@ -3638,7 +3659,7 @@ midori_view_web_inspector_detach_window_cb (gpointer inspector,
return FALSE; return FALSE;
gtk_widget_hide (parent); 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, midori_view_web_inspector_construct_window (inspector,
WEBKIT_WEB_VIEW (view->web_view), GTK_WIDGET (inspector_view), view); WEBKIT_WEB_VIEW (view->web_view), GTK_WIDGET (inspector_view), view);
return TRUE; return TRUE;