diff --git a/clapper_src/menu.js b/clapper_src/menu.js index f52fbb67..d774b421 100644 --- a/clapper_src/menu.js +++ b/clapper_src/menu.js @@ -1,10 +1,10 @@ const { GObject, Gst, Gtk } = imports.gi; const Misc = imports.clapper_src.misc; -const { Prefs } = imports.clapper_src.prefs; +const Prefs = imports.clapper_src.prefs; var actions = [ prefs, - about + about, ]; var accels = [ @@ -13,14 +13,14 @@ var accels = [ function prefs(window, appName) { - let prefs = new Prefs(); + let prefsWidget = Prefs.buildPrefsWidget(); let prefsDialog = new Gtk.Dialog({ title: 'Preferences', modal: true, transient_for: window, - child: prefs, - default_width: 400, - default_height: 320, + child: prefsWidget, + default_width: 460, + default_height: 400, }); prefsDialog.connect('close-request', () => prefsDialog.run_dispose()); prefsDialog.present(); diff --git a/clapper_src/player.js b/clapper_src/player.js index b6cf22b8..a5e8085d 100644 --- a/clapper_src/player.js +++ b/clapper_src/player.js @@ -17,6 +17,7 @@ class ClapperPlayer extends PlayerBase this.is_local_file = false; this.seek_done = true; this.dragAllowed = false; + this.doneStartup = false; this.posX = 0; this.posY = 0; @@ -342,18 +343,32 @@ class ClapperPlayer extends PlayerBase this.stop(); } - _onUriLoaded(self, uri) + _onUriLoaded(player, uri) { + if(!this.doneStartup) { + if(this.settings.get_boolean('fullscreen-auto')) { + let root = player.widget.get_root(); + if(root) { + let clapperWidget = root.get_child(); + if(!clapperWidget.fullscreenMode) + root.fullscreen(); + } + } + if(this.settings.get_string('volume-initial') === 'custom') + this.set_volume(this.settings.get_int('volume-value') / 100); + } + this.doneStartup = true; + this.play(); debug(`URI loaded: ${uri}`); } - _onPlayerWarning(self, error) + _onPlayerWarning(player, error) { debug(error.message, 'LEVEL_WARNING'); } - _onPlayerError(self, error) + _onPlayerError(player, error) { debug(error); } diff --git a/clapper_src/prefs.js b/clapper_src/prefs.js index 367a3eb1..c8421612 100644 --- a/clapper_src/prefs.js +++ b/clapper_src/prefs.js @@ -8,32 +8,46 @@ class ClapperGeneralPage extends PrefsBase.Grid { super._init(); - let label; - let widget; + this.addTitle('Startup'); + this.addCheckButton('Auto enter fullscreen', 'fullscreen-auto'); - label = this.getLabel('Seeking', true); - this.addToGrid(label); + this.addTitle('Volume'); + let comboBox = this.addComboBoxText('Initial value', [ + ['restore', "Restore"], + ['custom', "Custom"], + ], 'volume-initial'); + let spinButton = this.addSpinButton('Value (percentage)', 0, 200, 'volume-value'); + this._onVolumeInitialChanged(spinButton, comboBox); + comboBox.connect('changed', this._onVolumeInitialChanged.bind(this, spinButton)); + } - label = this.getLabel('Mode:'); - widget = this.getComboBoxText([ + _onVolumeInitialChanged(spinButton, comboBox) + { + let value = comboBox.get_active_id(); + spinButton.set_visible(value === 'custom'); + } +}); + +let BehaviourPage = GObject.registerClass( +class ClapperBehaviourPage extends PrefsBase.Grid +{ + _init() + { + super._init(); + + this.addTitle('Seeking'); + this.addComboBoxText('Mode', [ ['normal', "Normal"], ['accurate', "Accurate"], /* Needs gstplayer pipeline ref count fix */ //['fast', "Fast"], ], 'seeking-mode'); - this.addToGrid(label, widget); - - label = this.getLabel('Value:'); - widget = this.getSpinButton(1, 99, 'seeking-value'); - this.addToGrid(label, widget); - - label = this.getLabel('Unit:'); - widget = this.getComboBoxText([ + this.addComboBoxText('Unit', [ ['second', "Second"], ['minute', "Minute"], ['percentage', "Percentage"], ], 'seeking-unit'); - this.addToGrid(label, widget); + this.addSpinButton('Value', 1, 99, 'seeking-value'); } }); @@ -52,38 +66,37 @@ class ClapperGStreamerPage extends PrefsBase.Grid } }); -var Prefs = GObject.registerClass( -class ClapperPrefs extends Gtk.Box +function buildPrefsWidget() { - _init() - { - super._init({ - orientation: Gtk.Orientation.VERTICAL, - }); - - this.add_css_class('prefsbox'); - - let pages = [ - { - title: 'General', - widget: GeneralPage, - }, + let pages = [ + { + title: 'Player', + pages: [ + { + title: 'General', + widget: GeneralPage, + }, + { + title: 'Behaviour', + widget: BehaviourPage, + } + ] + }, /* - { - title: 'Advanced', - pages: [ - { - title: 'GStreamer', - widget: GStreamerPage, - } - ] - } + { + title: 'Advanced', + pages: [ + { + title: 'GStreamer', + widget: GStreamerPage, + } + ] + } */ - ]; + ]; - let prefsNotebook = new PrefsBase.Notebook(pages); - prefsNotebook.add_css_class('prefsnotebook'); + let prefsNotebook = new PrefsBase.Notebook(pages); + prefsNotebook.add_css_class('prefsnotebook'); - this.append(prefsNotebook); - } -}); + return prefsNotebook; +} diff --git a/clapper_src/prefsBase.js b/clapper_src/prefsBase.js index 7e289501..53354cce 100644 --- a/clapper_src/prefsBase.js +++ b/clapper_src/prefsBase.js @@ -3,13 +3,19 @@ const { Gio, GObject, Gtk } = imports.gi; var Notebook = GObject.registerClass( class ClapperPrefsNotebook extends Gtk.Notebook { - _init(pages) + _init(pages, isSubpage) { super._init({ + show_border: false, vexpand: true, hexpand: true, }); + if(isSubpage) { + this.set_tab_pos(Gtk.PositionType.LEFT); + this.add_css_class('prefssubpage'); + } + this.addArrayPages(pages); } @@ -22,7 +28,7 @@ class ClapperPrefsNotebook extends Gtk.Notebook addObjectPages(item) { let widget = (item.pages) - ? new Notebook(item.pages) + ? new Notebook(item.pages, true) : new item.widget(); this.addToNotebook(widget, item.title); @@ -66,16 +72,52 @@ class ClapperPrefsGrid extends Gtk.Grid if(rightWidget) { spanWidth = 1; + rightWidget.bind_property('visible', leftWidget, 'visible', + GObject.BindingFlags.SYNC_CREATE + ); this.attach(rightWidget, 1, this.gridIndex, 1, 1); } this.attach(leftWidget, 0, this.gridIndex, spanWidth, 1); this.gridIndex++; + + return rightWidget || leftWidget; + } + + addTitle(text) + { + let label = this.getLabel(text, true); + + return this.addToGrid(label); + } + + addComboBoxText(text, entries, setting) + { + let label = this.getLabel(text + ':'); + let widget = this.getComboBoxText(entries, setting); + + return this.addToGrid(label, widget); + } + + addSpinButton(text, min, max, setting) + { + let label = this.getLabel(text + ':'); + let widget = this.getSpinButton(min, max, setting); + + return this.addToGrid(label, widget); + } + + addCheckButton(text, setting) + { + let widget = this.getCheckButton(text, setting); + + return this.addToGrid(widget); } getLabel(text, isTitle) { let marginLR = 0; + let marginTop = (isTitle && this.gridIndex > 0) ? 16 : 0; let marginBottom = (isTitle) ? 2 : 0; if(isTitle) @@ -88,6 +130,7 @@ class ClapperPrefsGrid extends Gtk.Grid use_markup: true, hexpand: true, halign: Gtk.Align.START, + margin_top: marginTop, margin_bottom: marginBottom, margin_start: marginLR, margin_end: marginLR, @@ -115,4 +158,14 @@ class ClapperPrefsGrid extends Gtk.Grid return spinButton; } + + getCheckButton(text, setting) + { + let checkButton = new Gtk.CheckButton({ + label: text || null, + }); + this.settings.bind(setting, checkButton, 'active', this.flag); + + return checkButton; + } }); diff --git a/css/styles.css b/css/styles.css index 5e77adf0..14f6492f 100644 --- a/css/styles.css +++ b/css/styles.css @@ -99,10 +99,9 @@ scale marks { } /* Preferences */ -.prefsbox { - margin: 5px; -} - .prefsnotebook grid { margin: 10px; } +.prefssubpage header { + background: transparent; +} diff --git a/data/com.github.rafostar.Clapper.gschema.xml b/data/com.github.rafostar.Clapper.gschema.xml index 7c0a5efa..84b3e2c6 100644 --- a/data/com.github.rafostar.Clapper.gschema.xml +++ b/data/com.github.rafostar.Clapper.gschema.xml @@ -1,6 +1,21 @@ + + + false + Automatically enter fullscreen when first file is loaded + + + "restore" + Mode used for startup volume value + + + 100 + Custom initial volume value after startup + + + "normal" Mode used for seeking @@ -13,6 +28,8 @@ "second" Unit to use with seeking value + + "{}" Custom values for GStreamer plugin ranking