Implement web inspector attaching/ detaching properly
This commit is contained in:
parent
407e4dd5d3
commit
112966fe67
2 changed files with 75 additions and 31 deletions
|
@ -1205,10 +1205,17 @@ midori_view_attach_inspector_cb (GtkWidget* view,
|
|||
GtkWidget* inspector_view,
|
||||
MidoriBrowser* browser)
|
||||
{
|
||||
GtkWidget* scrolled = gtk_widget_get_parent (browser->inspector_view);
|
||||
gtk_container_remove (GTK_CONTAINER (scrolled), browser->inspector_view);
|
||||
gtk_container_add (GTK_CONTAINER (scrolled), inspector_view);
|
||||
GtkWidget* toplevel;
|
||||
GtkWidget* scrolled;
|
||||
|
||||
toplevel = gtk_widget_get_toplevel (inspector_view);
|
||||
gtk_widget_hide (toplevel);
|
||||
scrolled = gtk_widget_get_parent (browser->inspector_view);
|
||||
gtk_widget_destroy (browser->inspector_view);
|
||||
gtk_widget_reparent (inspector_view, scrolled);
|
||||
gtk_widget_show_all (browser->inspector);
|
||||
browser->inspector_view = inspector_view;
|
||||
gtk_widget_destroy (toplevel);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -5991,7 +5998,7 @@ midori_browser_init (MidoriBrowser* browser)
|
|||
gtk_widget_modify_style (browser->notebook, rcstyle);
|
||||
g_object_unref (rcstyle);
|
||||
gtk_notebook_set_scrollable (GTK_NOTEBOOK (browser->notebook), TRUE);
|
||||
gtk_paned_pack2 (GTK_PANED (vpaned), browser->notebook, FALSE, FALSE);
|
||||
gtk_paned_pack1 (GTK_PANED (vpaned), browser->notebook, FALSE, FALSE);
|
||||
g_signal_connect (browser->notebook, "switch-page",
|
||||
G_CALLBACK (gtk_notebook_switch_page_cb),
|
||||
browser);
|
||||
|
@ -6008,19 +6015,16 @@ midori_browser_init (MidoriBrowser* browser)
|
|||
|
||||
/* Inspector container */
|
||||
browser->inspector = gtk_vbox_new (FALSE, 0);
|
||||
gtk_paned_pack2 (GTK_PANED (vpaned), browser->inspector, TRUE, TRUE);
|
||||
gtk_paned_pack2 (GTK_PANED (vpaned), browser->inspector, FALSE, FALSE);
|
||||
scrolled = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||
GTK_WIDGET_SET_FLAGS (scrolled, GTK_CAN_FOCUS);
|
||||
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
|
||||
GTK_SHADOW_ETCHED_IN);
|
||||
gtk_box_pack_start (GTK_BOX (browser->inspector),
|
||||
scrolled, TRUE, TRUE, 0);
|
||||
browser->inspector_view = webkit_web_view_new ();
|
||||
gtk_box_pack_start (GTK_BOX (browser->inspector), scrolled, TRUE, TRUE, 0);
|
||||
browser->inspector_view = gtk_viewport_new (NULL, NULL);
|
||||
gtk_container_add (GTK_CONTAINER (scrolled), browser->inspector_view);
|
||||
gtk_widget_show_all (browser->inspector);
|
||||
|
||||
/* Incremental findbar */
|
||||
browser->find = gtk_toolbar_new ();
|
||||
|
|
|
@ -2080,7 +2080,7 @@ webkit_web_view_populate_popup_cb (WebKitWebView* web_view,
|
|||
#if HAVE_HILDON
|
||||
static void
|
||||
midori_view_web_view_tap_and_hold_cb (GtkWidget* web_view,
|
||||
MidoriView* view)
|
||||
gpointer data)
|
||||
{
|
||||
gint x, y;
|
||||
GdkEvent event;
|
||||
|
@ -2722,9 +2722,10 @@ midori_view_get_progress (MidoriView* view)
|
|||
return view->progress;
|
||||
}
|
||||
|
||||
static WebKitWebView*
|
||||
webkit_web_inspector_inspect_web_view_cb (gpointer inspector,
|
||||
static void
|
||||
midori_view_web_inspector_construct_window (gpointer inspector,
|
||||
WebKitWebView* web_view,
|
||||
GtkWidget* inspector_view,
|
||||
MidoriView* view)
|
||||
{
|
||||
gchar* title;
|
||||
|
@ -2735,7 +2736,6 @@ webkit_web_inspector_inspect_web_view_cb (gpointer inspector,
|
|||
GtkIconTheme* icon_theme;
|
||||
GdkPixbuf* icon;
|
||||
GdkPixbuf* gray_icon;
|
||||
GtkWidget* inspector_view;
|
||||
|
||||
title = g_strdup_printf (_("Inspect page - %s"), "");
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
|
@ -2769,19 +2769,54 @@ webkit_web_inspector_inspect_web_view_cb (gpointer inspector,
|
|||
}
|
||||
else
|
||||
gtk_window_set_icon_name (GTK_WINDOW (window), "midori");
|
||||
inspector_view = webkit_web_view_new ();
|
||||
gtk_container_add (GTK_CONTAINER (window), inspector_view);
|
||||
|
||||
/* FIXME: Implement web inspector signals properly
|
||||
FIXME: Save and restore window size
|
||||
FIXME: Update window title with URI */
|
||||
gtk_widget_show_all (window);
|
||||
/* inspector_view = webkit_web_view_new ();
|
||||
gtk_widget_show (inspector_view);
|
||||
g_signal_emit (view, signals[ATTACH_INSPECTOR], 0, inspector_view); */
|
||||
|
||||
/* FIXME: Update window title with URI */
|
||||
}
|
||||
|
||||
static WebKitWebView*
|
||||
midori_view_web_inspector_inspect_web_view_cb (gpointer inspector,
|
||||
WebKitWebView* web_view,
|
||||
MidoriView* view)
|
||||
{
|
||||
GtkWidget* inspector_view = webkit_web_view_new ();
|
||||
#if HAVE_HILDON
|
||||
gtk_widget_tap_and_hold_setup (view->web_view, NULL, NULL, 0);
|
||||
g_signal_connect (view->web_view, "tap-and-hold",
|
||||
G_CALLBACK (midori_view_web_view_tap_and_hold_cb), NULL);
|
||||
#endif
|
||||
midori_view_web_inspector_construct_window (inspector,
|
||||
web_view, inspector_view, view);
|
||||
return WEBKIT_WEB_VIEW (inspector_view);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
midori_view_web_inspector_attach_window_cb (gpointer inspector,
|
||||
MidoriView* view)
|
||||
{
|
||||
GtkWidget* inspector_view = katze_object_get_object (inspector, "web-view");
|
||||
g_signal_emit (view, signals[ATTACH_INSPECTOR], 0, inspector_view);
|
||||
g_object_unref (inspector_view);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
midori_view_web_inspector_detach_window_cb (gpointer inspector,
|
||||
MidoriView* view)
|
||||
{
|
||||
GtkWidget* inspector_view = katze_object_get_object (inspector, "web-view");
|
||||
GtkWidget* parent = gtk_widget_get_parent (inspector_view);
|
||||
if (GTK_IS_WINDOW (parent))
|
||||
return FALSE;
|
||||
gtk_widget_hide (parent);
|
||||
gtk_container_remove (GTK_CONTAINER (parent), inspector_view);
|
||||
midori_view_web_inspector_construct_window (inspector,
|
||||
WEBKIT_WEB_VIEW (view->web_view), inspector_view, view);
|
||||
g_object_unref (inspector_view);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
midori_view_construct_web_view (MidoriView* view)
|
||||
{
|
||||
|
@ -2798,6 +2833,8 @@ midori_view_construct_web_view (MidoriView* view)
|
|||
|
||||
#if HAVE_HILDON
|
||||
gtk_widget_tap_and_hold_setup (view->web_view, NULL, NULL, 0);
|
||||
g_signal_connect (view->web_view, "tap-and-hold",
|
||||
G_CALLBACK (midori_view_web_view_tap_and_hold_cb), NULL);
|
||||
#endif
|
||||
|
||||
g_object_connect (view->web_view,
|
||||
|
@ -2838,10 +2875,6 @@ midori_view_construct_web_view (MidoriView* view)
|
|||
gtk_widget_scroll_event_cb, view,
|
||||
"signal::populate-popup",
|
||||
webkit_web_view_populate_popup_cb, view,
|
||||
#if HAVE_HILDON
|
||||
"signal::tap-and-hold",
|
||||
midori_view_web_view_tap_and_hold_cb, view,
|
||||
#endif
|
||||
"signal::console-message",
|
||||
webkit_web_view_console_message_cb, view,
|
||||
"signal::window-object-cleared",
|
||||
|
@ -2882,8 +2915,15 @@ midori_view_construct_web_view (MidoriView* view)
|
|||
gtk_container_add (GTK_CONTAINER (view), view->web_view);
|
||||
|
||||
inspector = katze_object_get_object (view->web_view, "web-inspector");
|
||||
g_object_connect (inspector, "signal::inspect-web-view",
|
||||
webkit_web_inspector_inspect_web_view_cb, view, NULL);
|
||||
g_object_connect (inspector,
|
||||
"signal::inspect-web-view",
|
||||
midori_view_web_inspector_inspect_web_view_cb, view,
|
||||
"signal::attach-window",
|
||||
midori_view_web_inspector_attach_window_cb, view,
|
||||
"signal::detach-window",
|
||||
midori_view_web_inspector_detach_window_cb, view,
|
||||
NULL);
|
||||
g_object_unref (inspector);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue