mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-30 07:42:23 +02:00
Add about dialog
This commit is contained in:
@@ -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,
|
||||
|
6
clapper_src/controls.js
vendored
6
clapper_src/controls.js
vendored
@@ -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');
|
||||
|
||||
|
@@ -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'
|
||||
);
|
||||
|
@@ -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
41
clapper_src/menu.js
Normal 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();
|
||||
}
|
@@ -22,6 +22,7 @@ subdir('data')
|
||||
installdir = join_paths(get_option('prefix'), 'share', meson.project_name())
|
||||
install_subdir('clapper_src', install_dir : installdir)
|
||||
install_subdir('css', install_dir : installdir)
|
||||
install_subdir('ui', install_dir : installdir)
|
||||
install_data('main.js', install_dir : installdir)
|
||||
|
||||
meson.add_install_script('build-aux/meson/postinstall.py')
|
||||
|
17
ui/clapper.ui
Normal file
17
ui/clapper.ui
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<menu id="settingsMenu">
|
||||
<section>
|
||||
<!--
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">Keyboard Shortcuts</attribute>
|
||||
<attribute name="action">app.shortcuts</attribute>
|
||||
</item>
|
||||
-->
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">About Clapper</attribute>
|
||||
<attribute name="action">app.about</attribute>
|
||||
</item>
|
||||
</section>
|
||||
</menu>
|
||||
</interface>
|
Reference in New Issue
Block a user