diff --git a/clapper_src/app.js b/clapper_src/app.js index 2bde0bb0..5a729c90 100644 --- a/clapper_src/app.js +++ b/clapper_src/app.js @@ -101,10 +101,15 @@ var App = GObject.registerClass({ ); this.interface = new Interface(); + let headerBar = new Gtk.HeaderBar({ + show_close_button: true + }); + this.interface.addHeaderBar(headerBar); this.interface.controls.toggleFullscreenButton.connect( 'clicked', this._onInterfaceToggleFullscreenClicked.bind(this) ); + this.window.set_titlebar(this.interface.headerBar); this.window.add(this.interface); } diff --git a/clapper_src/interface.js b/clapper_src/interface.js index e1736b86..0a0cf0f0 100644 --- a/clapper_src/interface.js +++ b/clapper_src/interface.js @@ -1,7 +1,8 @@ -const { GObject, Gtk, Gst, GstPlayer } = imports.gi; +const { GLib, GObject, Gtk, Gst, GstPlayer } = imports.gi; const { Controls } = imports.clapper_src.controls; const Debug = imports.clapper_src.debug; +const HOME_DIR = GLib.get_home_dir(); let { debug } = Debug; var Interface = GObject.registerClass( @@ -23,6 +24,7 @@ class ClapperInterface extends Gtk.Grid this.lastPositionValue = 0; this.needsTracksUpdate = true; this.revealTime = 800; + this.headerBar = null; this.overlay = new Gtk.Overlay(); this.controls = new Controls(); @@ -69,6 +71,11 @@ class ClapperInterface extends Gtk.Grid this.overlay.add(this._player.widget); } + addHeaderBar(headerBar) + { + this.headerBar = headerBar; + } + revealControls(isReveal) { this.revealer.set_transition_duration(this.revealTime); @@ -107,8 +114,8 @@ class ClapperInterface extends Gtk.Grid { let mediaInfo = this._player.get_media_info(); - // titlebar from video title should be set from this (not implemented yet) - //let title = mediaInfo.get_title(); + // set titlebar media title and path + this.updateHeaderBar(mediaInfo); // we can also check if video is "live" or "seekable" (right now unused) // it might be a good idea to hide position seek bar and disable seeking @@ -185,6 +192,25 @@ class ClapperInterface extends Gtk.Grid } } + updateHeaderBar(mediaInfo) + { + if(!this.headerBar) + return; + + let title = mediaInfo.get_title(); + let subtitle = mediaInfo.get_uri(); + + if(HOME_DIR && subtitle.startsWith('file://')) { + subtitle = GLib.filename_from_uri(subtitle)[0]; + + if(subtitle.startsWith(HOME_DIR)) + subtitle = '~' + subtitle.substring(HOME_DIR.length); + } + + this.headerBar.set_title(title || 'Clapper'); + this.headerBar.set_subtitle(subtitle || null); + } + _onTrackChangeRequested(self, trackType, trackId) { // reenabling audio is slow (as expected),