Title: [174425] releases/WebKitGTK/webkit-2.6/Source/WebKit2
Revision
174425
Author
[email protected]
Date
2014-10-08 03:19:47 -0700 (Wed, 08 Oct 2014)

Log Message

Merge r174327 - [GTK] The new web inspector can't be docked again once undocked
https://bugs.webkit.org/show_bug.cgi?id=121544

Reviewed by Martin Robinson.

Use a GtkHeaderBar for the inspector window to add dock buttons
when building with GTK+ >= 3.10.

* UIProcess/WebInspectorProxy.cpp:
(WebKit::WebInspectorProxy::WebInspectorProxy):
* UIProcess/WebInspectorProxy.h:
* UIProcess/gtk/WebInspectorProxyGtk.cpp:
(WebKit::WebInspectorProxy::dockButtonClicked):
(WebKit::WebInspectorProxy::createInspectorWindow):
(WebKit::WebInspectorProxy::updateInspectorWindowTitle):
(WebKit::WebInspectorProxy::platformInspectedURLChanged):
(WebKit::WebInspectorProxy::platformAttachAvailabilityChanged):

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.6/Source/WebKit2/ChangeLog (174424 => 174425)


--- releases/WebKitGTK/webkit-2.6/Source/WebKit2/ChangeLog	2014-10-08 10:01:55 UTC (rev 174424)
+++ releases/WebKitGTK/webkit-2.6/Source/WebKit2/ChangeLog	2014-10-08 10:19:47 UTC (rev 174425)
@@ -1,3 +1,23 @@
+2014-10-05  Carlos Garcia Campos  <[email protected]>
+
+        [GTK] The new web inspector can't be docked again once undocked
+        https://bugs.webkit.org/show_bug.cgi?id=121544
+
+        Reviewed by Martin Robinson.
+
+        Use a GtkHeaderBar for the inspector window to add dock buttons
+        when building with GTK+ >= 3.10.
+
+        * UIProcess/WebInspectorProxy.cpp:
+        (WebKit::WebInspectorProxy::WebInspectorProxy):
+        * UIProcess/WebInspectorProxy.h:
+        * UIProcess/gtk/WebInspectorProxyGtk.cpp:
+        (WebKit::WebInspectorProxy::dockButtonClicked):
+        (WebKit::WebInspectorProxy::createInspectorWindow):
+        (WebKit::WebInspectorProxy::updateInspectorWindowTitle):
+        (WebKit::WebInspectorProxy::platformInspectedURLChanged):
+        (WebKit::WebInspectorProxy::platformAttachAvailabilityChanged):
+
 2014-10-04  Carlos Garcia Campos  <[email protected]>
 
         Unreviewed. Add missing inspector files to compilation.

Modified: releases/WebKitGTK/webkit-2.6/Source/WebKit2/UIProcess/WebInspectorProxy.cpp (174424 => 174425)


--- releases/WebKitGTK/webkit-2.6/Source/WebKit2/UIProcess/WebInspectorProxy.cpp	2014-10-08 10:01:55 UTC (rev 174424)
+++ releases/WebKitGTK/webkit-2.6/Source/WebKit2/UIProcess/WebInspectorProxy.cpp	2014-10-08 10:19:47 UTC (rev 174425)
@@ -134,9 +134,14 @@
     , m_ignoreFirstBringToFront(false)
     , m_attachmentSide(AttachmentSideBottom)
 #if PLATFORM(GTK) || PLATFORM(EFL)
-    , m_inspectorView(0)
-    , m_inspectorWindow(0)
+    , m_inspectorView(nullptr)
+    , m_inspectorWindow(nullptr)
+#if PLATFORM(GTK)
+    , m_headerBar(nullptr)
+    , m_dockBottomButton(nullptr)
+    , m_dockRightButton(nullptr)
 #endif
+#endif
 #if ENABLE(INSPECTOR_SERVER)
     , m_remoteInspectionPageId(0)
 #endif

Modified: releases/WebKitGTK/webkit-2.6/Source/WebKit2/UIProcess/WebInspectorProxy.h (174424 => 174425)


--- releases/WebKitGTK/webkit-2.6/Source/WebKit2/UIProcess/WebInspectorProxy.h	2014-10-08 10:01:55 UTC (rev 174424)
+++ releases/WebKitGTK/webkit-2.6/Source/WebKit2/UIProcess/WebInspectorProxy.h	2014-10-08 10:19:47 UTC (rev 174425)
@@ -198,6 +198,11 @@
     void createInspectorWindow();
 #endif
 
+#if PLATFORM(GTK)
+    void updateInspectorWindowTitle() const;
+    static void dockButtonClicked(GtkWidget*, WebInspectorProxy*);
+#endif
+
     static const unsigned minimumWindowWidth;
     static const unsigned minimumWindowHeight;
 
@@ -238,6 +243,10 @@
     WebInspectorClientGtk m_client;
     GtkWidget* m_inspectorView;
     GtkWidget* m_inspectorWindow;
+    GtkWidget* m_headerBar;
+    GtkWidget* m_dockBottomButton;
+    GtkWidget* m_dockRightButton;
+    String m_inspectedURLString;
 #elif PLATFORM(EFL)
     Evas_Object* m_inspectorView;
     Ecore_Evas* m_inspectorWindow;

Modified: releases/WebKitGTK/webkit-2.6/Source/WebKit2/UIProcess/gtk/WebInspectorProxyGtk.cpp (174424 => 174425)


--- releases/WebKitGTK/webkit-2.6/Source/WebKit2/UIProcess/gtk/WebInspectorProxyGtk.cpp	2014-10-08 10:01:55 UTC (rev 174424)
+++ releases/WebKitGTK/webkit-2.6/Source/WebKit2/UIProcess/gtk/WebInspectorProxyGtk.cpp	2014-10-08 10:19:47 UTC (rev 174425)
@@ -67,6 +67,16 @@
     return webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(m_inspectorView));
 }
 
+void WebInspectorProxy::dockButtonClicked(GtkWidget* button, WebInspectorProxy* inspector)
+{
+    if (button == inspector->m_dockBottomButton)
+        inspector->attach(AttachmentSideBottom);
+    else if (button == inspector->m_dockRightButton)
+        inspector->attach(AttachmentSideRight);
+    else
+        ASSERT_NOT_REACHED();
+}
+
 void WebInspectorProxy::createInspectorWindow()
 {
     if (m_client.openWindow(this))
@@ -79,7 +89,33 @@
     if (WebCore::widgetIsOnscreenToplevelWindow(inspectedViewParent))
         gtk_window_set_transient_for(GTK_WINDOW(m_inspectorWindow), GTK_WINDOW(inspectedViewParent));
 
-    gtk_window_set_title(GTK_WINDOW(m_inspectorWindow), _("Web Inspector"));
+#if GTK_CHECK_VERSION(3, 10, 0)
+    m_headerBar = gtk_header_bar_new();
+    gtk_header_bar_set_show_close_button(GTK_HEADER_BAR(m_headerBar), TRUE);
+
+    m_dockBottomButton = gtk_button_new();
+    g_object_add_weak_pointer(G_OBJECT(m_dockBottomButton), reinterpret_cast<void**>(&m_dockBottomButton));
+    g_signal_connect(m_dockBottomButton, "clicked", G_CALLBACK(dockButtonClicked), this);
+    gtk_widget_set_sensitive(m_dockBottomButton, canAttach());
+    gtk_button_set_relief(GTK_BUTTON(m_dockBottomButton), GTK_RELIEF_NONE);
+    gtk_button_set_image(GTK_BUTTON(m_dockBottomButton), gtk_image_new_from_resource("/org/webkitgtk/inspector/UserInterface/Images/DockBottom.svg"));
+    gtk_header_bar_pack_start(GTK_HEADER_BAR(m_headerBar), m_dockBottomButton);
+    gtk_widget_show(m_dockBottomButton);
+
+    m_dockRightButton = gtk_button_new();
+    g_object_add_weak_pointer(G_OBJECT(m_dockRightButton), reinterpret_cast<void**>(&m_dockRightButton));
+    g_signal_connect(m_dockRightButton, "clicked", G_CALLBACK(dockButtonClicked), this);
+    gtk_widget_set_sensitive(m_dockRightButton, canAttach());
+    gtk_button_set_relief(GTK_BUTTON(m_dockRightButton), GTK_RELIEF_NONE);
+    gtk_button_set_image(GTK_BUTTON(m_dockRightButton), gtk_image_new_from_resource("/org/webkitgtk/inspector/UserInterface/Images/DockRight.svg"));
+    gtk_header_bar_pack_start(GTK_HEADER_BAR(m_headerBar), m_dockRightButton);
+    gtk_widget_show(m_dockRightButton);
+
+    gtk_window_set_titlebar(GTK_WINDOW(m_inspectorWindow), m_headerBar);
+    gtk_widget_show(m_headerBar);
+#endif
+
+    updateInspectorWindowTitle();
     gtk_window_set_default_size(GTK_WINDOW(m_inspectorWindow), initialWindowWidth, initialWindowHeight);
 
     gtk_container_add(GTK_CONTAINER(m_inspectorWindow), m_inspectorView);
@@ -89,6 +125,23 @@
     gtk_window_present(GTK_WINDOW(m_inspectorWindow));
 }
 
+void WebInspectorProxy::updateInspectorWindowTitle() const
+{
+    ASSERT(m_inspectorWindow);
+    if (m_inspectedURLString.isEmpty()) {
+        gtk_window_set_title(GTK_WINDOW(m_inspectorWindow), _("Web Inspector"));
+        return;
+    }
+
+#if GTK_CHECK_VERSION(3, 10, 0)
+    gtk_header_bar_set_title(GTK_HEADER_BAR(m_headerBar), _("Web Inspector"));
+    gtk_header_bar_set_subtitle(GTK_HEADER_BAR(m_headerBar), m_inspectedURLString.utf8().data());
+#else
+    GUniquePtr<gchar> title(g_strdup_printf("%s - %s", _("Web Inspector"), m_inspectedURLString.utf8().data()));
+    gtk_window_set_title(GTK_WINDOW(m_inspectorWindow), title.get());
+#endif
+}
+
 void WebInspectorProxy::platformOpen()
 {
     ASSERT(!m_inspectorWindow);
@@ -140,12 +193,11 @@
 
 void WebInspectorProxy::platformInspectedURLChanged(const String& url)
 {
+    m_inspectedURLString = url;
     m_client.inspectedURLChanged(this, url);
 
-    if (!m_inspectorWindow)
-        return;
-    GUniquePtr<gchar> title(g_strdup_printf("%s - %s", _("Web Inspector"), url.utf8().data()));
-    gtk_window_set_title(GTK_WINDOW(m_inspectorWindow), title.get());
+    if (m_inspectorWindow)
+        updateInspectorWindowTitle();
 }
 
 String WebInspectorProxy::inspectorPageURL() const
@@ -250,9 +302,12 @@
     notImplemented();
 }
 
-void WebInspectorProxy::platformAttachAvailabilityChanged(bool)
+void WebInspectorProxy::platformAttachAvailabilityChanged(bool available)
 {
-    notImplemented();
+    if (m_dockBottomButton && m_dockRightButton) {
+        gtk_widget_set_sensitive(m_dockBottomButton, available);
+        gtk_widget_set_sensitive(m_dockRightButton, available);
+    }
 }
 
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to