|
Packit |
1470ea |
#!/usr/bin/gjs
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
imports.gi.versions.Gtk = '3.0';
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
const GLib = imports.gi.GLib;
|
|
Packit |
1470ea |
const Gtk = imports.gi.Gtk;
|
|
Packit |
1470ea |
const Webkit = imports.gi.WebKit;
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
class HelloGNOME {
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Create the application itself
|
|
Packit |
1470ea |
constructor() {
|
|
Packit |
1470ea |
this.application = new Gtk.Application ();
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Connect 'activate' and 'startup' signals to the callback functions
|
|
Packit |
1470ea |
this.application.connect('activate', this._onActivate.bind(this));
|
|
Packit |
1470ea |
this.application.connect('startup', this._onStartup.bind(this));
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Callback function for 'activate' signal presents windows when active
|
|
Packit |
1470ea |
_onActivate() {
|
|
Packit |
1470ea |
this._window.present();
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Callback function for 'startup' signal builds the UI
|
|
Packit |
1470ea |
_onStartup() {
|
|
Packit |
1470ea |
this._buildUI();
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Build the application's UI
|
|
Packit |
1470ea |
_buildUI() {
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Create the application window
|
|
Packit |
1470ea |
this._window = new Gtk.ApplicationWindow ({
|
|
Packit |
1470ea |
application: this.application,
|
|
Packit |
1470ea |
title: "Welcome to GNOME",
|
|
Packit |
1470ea |
default_height: 200,
|
|
Packit |
1470ea |
default_width: 400,
|
|
Packit |
1470ea |
window_position: Gtk.WindowPosition.CENTER });
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Create a webview to show the web app
|
|
Packit |
1470ea |
this._webView = new Webkit.WebView ();
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Put the web app into the webview
|
|
Packit |
1470ea |
this._webView.load_uri (GLib.filename_to_uri (GLib.get_current_dir() +
|
|
Packit |
1470ea |
"/hellognome.html", null));
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Put the webview into the window
|
|
Packit |
1470ea |
this._window.add (this._webView);
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Show the window and all child widgets
|
|
Packit |
1470ea |
this._window.show_all();
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
};
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Run the application
|
|
Packit |
1470ea |
let app = new HelloGNOME ();
|
|
Packit |
1470ea |
app.application.run (ARGV);
|