Add about dialog

This commit is contained in:
Rafostar
2020-10-15 16:21:46 +02:00
parent 34d39502b9
commit 57a8e6d933
7 changed files with 96 additions and 29 deletions

View File

@@ -1,8 +1,9 @@
const { Gdk, GLib, GObject, Gtk, GstPlayer } = imports.gi;
const { Gdk, Gio, GLib, GObject, Gtk, GstPlayer } = imports.gi;
const Debug = imports.clapper_src.debug;
const { HeaderBar } = imports.clapper_src.headerbar;
const { Interface } = imports.clapper_src.interface;
const { Player } = imports.clapper_src.player;
const Menu = imports.clapper_src.menu;
const { Window } = imports.clapper_src.window;
const APP_NAME = pkg.name.substring(
@@ -59,21 +60,26 @@ var App = GObject.registerClass({
'close-request', this._onWindowCloseRequest.bind(this)
);
this.interface = new Interface();
for(let action of Menu.actions) {
let simpleAction = new Gio.SimpleAction({
name: action.name
});
simpleAction.connect('activate', () => action(this.active_window, APP_NAME));
this.add_action(simpleAction);
}
let uiBuilder = Gtk.Builder.new_from_file(
`${pkg.datadir}/${pkg.name}/ui/clapper.ui`
);
let models = {
settingsMenu: uiBuilder.get_object('settingsMenu')
};
let headerBar = new HeaderBar(this.window, models);
let headerStart = [];
let headerEnd = [
this.interface.controls.openMenuButton,
this.interface.controls.fullscreenButton
];
let headerBar = new HeaderBar(this.window, headerStart, headerEnd);
this.interface = new Interface();
this.interface.addHeaderBar(headerBar, APP_NAME);
this.interface.controls.fullscreenButton.connect(
'clicked', () => this.activeWindow.fullscreen()
);
this.interface.controls.unfullscreenButton.connect(
'clicked', () => this.activeWindow.unfullscreen()
'clicked', () => this.active_window.unfullscreen()
);
this.window.set_titlebar(this.interface.headerBar);
@@ -358,7 +364,7 @@ var App = GObject.registerClass({
_onPlayerDragUpdate(gesture, offsetX, offsetY)
{
if(!this.dragAllowed || this.activeWindow.isFullscreen)
if(!this.dragAllowed || this.active_window.isFullscreen)
return;
let { gtk_double_click_distance } = this.player.widget.get_settings();
@@ -370,7 +376,7 @@ var App = GObject.registerClass({
let [isActive, startX, startY] = gesture.get_start_point();
if(!isActive) return;
this.activeWindow.get_surface().begin_move(
this.active_window.get_surface().begin_move(
gesture.get_device(),
gesture.get_current_button(),
startX,

View File

@@ -54,12 +54,6 @@ var Controls = GObject.registerClass({
'view-restore-symbolic',
);
this.unfullscreenButton.set_visible(false);
this.fullscreenButton = Gtk.Button.new_from_icon_name(
'view-fullscreen-symbolic',
);
this.openMenuButton = Gtk.Button.new_from_icon_name(
'open-menu-symbolic',
);
this.add_css_class('playercontrols');

View File

@@ -1,7 +1,5 @@
const { GLib, Gst } = imports.gi;
const GST_VERSION = Gst.version();
const REQ_GST_VER_MINOR = 16;
const REQ_GST_VERSION_MINOR = 16;
function debug(msg, levelName)
{
@@ -20,13 +18,13 @@ function debug(msg, levelName)
function gstVersionCheck()
{
if(GST_VERSION[1] >= REQ_GST_VER_MINOR)
if(Gst.VERSION_MINOR >= REQ_GST_VERSION_MINOR)
return;
debug(
'clapper interface was designed to' +
` work with GStreamer 1.${REQ_GST_VER_MINOR} or later.` +
` Your version is ${GST_VERSION[0]}.${GST_VERSION[1]}.` +
` work with GStreamer 1.${REQ_GST_VERSION_MINOR} or later.` +
` Your version is ${Gst.VERSION_MAJOR}.${Gst.VERSION_MINOR}.` +
' Please update GStreamer or expect some things to be broken.',
'LEVEL_WARNING'
);

View File

@@ -3,15 +3,25 @@ const { GLib, GObject, Gtk, Pango } = imports.gi;
var HeaderBar = GObject.registerClass(
class ClapperHeaderBar extends Gtk.HeaderBar
{
_init(window, startButtons, endButtons)
_init(window, models)
{
super._init({
can_focus: false,
});
this.set_title_widget(this._createWidgetForWindow(window));
startButtons.forEach(btn => this.pack_start(btn));
endButtons.forEach(btn => this.pack_end(btn));
let openMenuButton = new Gtk.MenuButton({
icon_name: 'open-menu-symbolic'
});
openMenuButton.set_menu_model(models.settingsMenu);
this.pack_end(openMenuButton);
let fullscreenButton = new Gtk.Button({
icon_name: 'view-fullscreen-symbolic'
});
fullscreenButton.connect('clicked', () => this.get_parent().fullscreen());
this.pack_end(fullscreenButton);
}
updateHeaderBar(mediaInfo)

41
clapper_src/menu.js Normal file
View File

@@ -0,0 +1,41 @@
const { GObject, Gst, Gtk } = imports.gi;
var actions = [
about
];
var accels = [
['app.quit', ['q']],
];
function about(window, appName)
{
let gstVer = [
Gst.VERSION_MAJOR, Gst.VERSION_MINOR, Gst.VERSION_MICRO
].join('.');
let gtkVer = [
Gtk.MAJOR_VERSION, Gtk.MINOR_VERSION, Gtk.MICRO_VERSION
].join('.');
let osInfo = [
'GTK version' + ': ' + gtkVer,
'GStreamer version' + ': ' + gstVer
].join('\n');
let aboutDialog = new Gtk.AboutDialog({
program_name: appName,
comments: 'A GNOME media player powered by GStreamer',
version: pkg.version,
authors: ['Rafał Dzięgiel'],
artists: ['Rafał Dzięgiel'],
license_type: Gtk.License.GPL_3_0,
logo_icon_name: pkg.name,
website: 'https://github.com/Rafostar/clapper',
modal: true,
system_information: osInfo,
transient_for: window
});
aboutDialog.present();
}