Last active
July 7, 2023 12:52
-
-
Save WebReflection/993cfdaeccd49cb58849117a4c9b13cc to your computer and use it in GitHub Desktop.
Full Screen WebKitGTK via GJS Browser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env gjs | |
// (c) Andrea Giammarchi - ISC | |
// define the Gtk version to use (July 2023) | |
imports.gi.versions.Gtk = '3.0'; | |
imports.gi.versions.WebKit2 = '4.1'; | |
const GLib = imports.gi.GLib; | |
GLib.setenv('JSC_useSharedArrayBuffer', 'true', true); | |
((Gtk, Gdk, WebKit2) => { | |
Gtk.init(null); | |
const screen = Gdk.Screen.get_default(); | |
const view = new WebKit2.WebView(); | |
const window = new Gtk.Window({ | |
decorated: false, | |
type : Gtk.WindowType.TOPLEVEL | |
}); | |
// view setup (avoid right click) | |
view.connect('context-menu', () => true); | |
view.load_uri(ARGV[0]); | |
// window setup | |
window.set_default_size( | |
screen.get_width(), | |
screen.get_height() | |
); | |
window.connect('show', () => { | |
window.fullscreen(); | |
Gtk.main(); | |
}); | |
window.connect('destroy', () => Gtk.main_quit()); | |
window.connect('delete_event', () => false); | |
window.add(view); | |
window.show_all(); | |
})( | |
imports.gi.Gtk, | |
imports.gi.Gdk, | |
imports.gi.WebKit2 | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment