diff --git a/src/Widgets/Chromeless.vala b/src/Widgets/Chromeless.vala new file mode 100644 index 0000000..0a8bc5c --- /dev/null +++ b/src/Widgets/Chromeless.vala @@ -0,0 +1,42 @@ +/** +* This file is part of Odysseus Web Browser (Copyright Adrian Cochrane 2016-2018). +* +* Odysseus is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* Odysseus is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public License +* along with Odysseus. If not, see . +*/ +/** Improved window for WebInspector, which doesn't duplicate the headerbar. */ +public class Odysseus.Chromeless : Gtk.Window { + public Chromeless(WebKit.WebInspector inspector) { + var titlebar = new Gtk.HeaderBar(); + set_titlebar(titlebar); + titlebar.no_show_all = true; + + title = "Web Inspector — " + inspector.inspected_uri; + add(inspector.get_web_view()); + + inspector.closed.connect(() => this.destroy()); + inspector.attach.connect(() => { + remove(inspector.get_web_view()); + this.destroy(); + return false; + }); + + inspector.get_web_view().button_press_event.connect ((e) => { + if (e.type == Gdk.EventType.@2BUTTON_PRESS && e.button == Gdk.BUTTON_PRIMARY) { + begin_move_drag ((int) e.button, (int) e.x_root, (int) e.y_root, e.time); + return true; + } + return false; + }); + } +} diff --git a/src/Widgets/WebTab.vala b/src/Widgets/WebTab.vala index 95131cd..8d1d4f6 100644 --- a/src/Widgets/WebTab.vala +++ b/src/Widgets/WebTab.vala @@ -48,8 +48,12 @@ public class Odysseus.WebTab : Granite.Widgets.Tab { "web-context", get_web_context(), "user-content-manager", user_content); if (url != null) web.load_uri(url); - // Ugly WebKitGTK fix to ensure the inspector is properly initialized. - web.get_inspector(); + + var inspector = web.get_inspector(); + inspector.open_window.connect(() => { + new Chromeless(inspector).show_all(); + return true; + }); this.info = new Overlay.InfoContainer(); info.expand = true; diff --git a/src/meson.build b/src/meson.build index d74d366..f2b9f4a 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,5 +1,5 @@ sources = ['Odysseus', 'BrowserWindow', 'Persistance'] -widgets = ['WebTab','ProgressBin','WebNotebook','DownloadButton','DownloadBar'] +widgets = ['WebTab','ProgressBin','WebNotebook','DownloadButton','DownloadBar', 'Chromeless'] header_widgets = ['AddressBar', 'ButtonWithMenu', 'AutomaticScrollBox', 'HeaderBarWithMenus'] overlay_widgets = ['FindToolbar', 'InfoContainer']