mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-31 08:21:59 +02:00
Add Clapper usage as GTK widget
This commit is contained in:
40
examples/widget-example.js
Normal file
40
examples/widget-example.js
Normal file
@@ -0,0 +1,40 @@
|
||||
imports.gi.versions.Gtk = '4.0';
|
||||
|
||||
const Gtk = imports.gi.Gtk;
|
||||
const Clapper = imports.clapper;
|
||||
|
||||
let app = new Gtk.Application({
|
||||
application_id: 'com.clapper.WidgetExample'
|
||||
});
|
||||
|
||||
app.connect('activate', () => {
|
||||
let window = new Gtk.ApplicationWindow({
|
||||
application: app,
|
||||
title: 'Clapper Widget Example',
|
||||
});
|
||||
let box = new Gtk.Box({
|
||||
orientation: Gtk.Orientation.VERTICAL,
|
||||
});
|
||||
let label = new Gtk.Label({
|
||||
label: [
|
||||
'Clapper is used as a widget and placed below.',
|
||||
'Double click it to enter fullscreen!',
|
||||
].join('\n')
|
||||
});
|
||||
let widget = new Clapper.Widget();
|
||||
|
||||
widget.connect('fullscreen-changed', (widget, isFullscreen) => {
|
||||
label.set_visible(!isFullscreen);
|
||||
});
|
||||
window.connect('show', () => {
|
||||
let media = 'http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_30fps_normal.mp4';
|
||||
widget.player.set_media(media);
|
||||
});
|
||||
|
||||
box.append(label);
|
||||
box.append(widget);
|
||||
|
||||
window.set_child(box);
|
||||
window.present();
|
||||
});
|
||||
app.run([]);
|
Reference in New Issue
Block a user