Add Python and Javascript examples
This commit is contained in:
parent
9e65ef6f0f
commit
5e212efa82
2 changed files with 86 additions and 0 deletions
46
examples/compositor.js
Executable file
46
examples/compositor.js
Executable file
|
|
@ -0,0 +1,46 @@
|
|||
#!/usr/bin/gjs -m
|
||||
|
||||
import System from 'system';
|
||||
import GLib from 'gi://GLib';
|
||||
import GObject from 'gi://GObject';
|
||||
import Gtk from 'gi://Gtk?version=4.0';
|
||||
import Casilda from 'gi://Casilda?version=1.0';
|
||||
|
||||
|
||||
let CasildaApplication = GObject.registerClass({},
|
||||
class CasildaApplication extends Gtk.Application {
|
||||
constructor() {
|
||||
super({
|
||||
application_id: 'ar.xjuan.casilda.Gjs.Example'
|
||||
});
|
||||
}
|
||||
|
||||
vfunc_activate() {
|
||||
let compositor = new Casilda.Compositor();
|
||||
|
||||
let window = new Gtk.ApplicationWindow({
|
||||
application: this,
|
||||
title: 'Casilda Compositor',
|
||||
default_width: 800,
|
||||
default_height: 600,
|
||||
child: compositor
|
||||
});
|
||||
|
||||
window.connect('close-request', () => {
|
||||
this.quit();
|
||||
});
|
||||
|
||||
compositor.spawn_async (
|
||||
null,
|
||||
["/usr/bin/gtk4-demo"],
|
||||
null,
|
||||
GLib.SpawnFlags.DEFAULT,
|
||||
null
|
||||
);
|
||||
|
||||
window.present();
|
||||
}
|
||||
});
|
||||
|
||||
let app = new CasildaApplication();
|
||||
app.run([System.programInvocationName].concat(ARGV));
|
||||
40
examples/compositor.py
Executable file
40
examples/compositor.py
Executable file
|
|
@ -0,0 +1,40 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import gi
|
||||
import sys
|
||||
|
||||
gi.require_version("Gtk", "4.0")
|
||||
gi.require_version("Casilda", "1.0")
|
||||
from gi.repository import GLib, Gtk, Casilda
|
||||
|
||||
|
||||
class CasildaApplication(Gtk.Application):
|
||||
def __init__(self):
|
||||
super().__init__(
|
||||
application_id="ar.xjuan.casilda.PyGObject.Example"
|
||||
)
|
||||
|
||||
def do_activate(self):
|
||||
compositor = Casilda.Compositor()
|
||||
|
||||
window = Gtk.ApplicationWindow(
|
||||
application=self,
|
||||
title="Casilda Compositor",
|
||||
default_width=800,
|
||||
default_height=600,
|
||||
child=compositor
|
||||
)
|
||||
|
||||
compositor.spawn_async (
|
||||
None,
|
||||
["/usr/bin/gtk4-demo"],
|
||||
None,
|
||||
GLib.SpawnFlags.DEFAULT
|
||||
)
|
||||
|
||||
window.present()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = CasildaApplication()
|
||||
sys.exit(app.run(sys.argv))
|
||||
Loading…
Add table
Add a link
Reference in a new issue