Skip to content
This repository has been archived by the owner on Jun 4, 2022. It is now read-only.

Commit

Permalink
Build new WebInspector window which doesn't duplicate headerbar.
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Cochrane committed Mar 8, 2018
1 parent a0bd757 commit 4a34ca4
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 3 deletions.
42 changes: 42 additions & 0 deletions src/Widgets/Chromeless.vala
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/
/** 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;
});
}
}
8 changes: 6 additions & 2 deletions src/Widgets/WebTab.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
@@ -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']
Expand Down

0 comments on commit 4a34ca4

Please sign in to comment.