mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-31 16:31:58 +02:00
Add header bar with media title and path
This commit is contained in:
@@ -101,10 +101,15 @@ var App = GObject.registerClass({
|
|||||||
);
|
);
|
||||||
|
|
||||||
this.interface = new Interface();
|
this.interface = new Interface();
|
||||||
|
let headerBar = new Gtk.HeaderBar({
|
||||||
|
show_close_button: true
|
||||||
|
});
|
||||||
|
this.interface.addHeaderBar(headerBar);
|
||||||
this.interface.controls.toggleFullscreenButton.connect(
|
this.interface.controls.toggleFullscreenButton.connect(
|
||||||
'clicked', this._onInterfaceToggleFullscreenClicked.bind(this)
|
'clicked', this._onInterfaceToggleFullscreenClicked.bind(this)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.window.set_titlebar(this.interface.headerBar);
|
||||||
this.window.add(this.interface);
|
this.window.add(this.interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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 { Controls } = imports.clapper_src.controls;
|
||||||
const Debug = imports.clapper_src.debug;
|
const Debug = imports.clapper_src.debug;
|
||||||
|
|
||||||
|
const HOME_DIR = GLib.get_home_dir();
|
||||||
let { debug } = Debug;
|
let { debug } = Debug;
|
||||||
|
|
||||||
var Interface = GObject.registerClass(
|
var Interface = GObject.registerClass(
|
||||||
@@ -23,6 +24,7 @@ class ClapperInterface extends Gtk.Grid
|
|||||||
this.lastPositionValue = 0;
|
this.lastPositionValue = 0;
|
||||||
this.needsTracksUpdate = true;
|
this.needsTracksUpdate = true;
|
||||||
this.revealTime = 800;
|
this.revealTime = 800;
|
||||||
|
this.headerBar = null;
|
||||||
|
|
||||||
this.overlay = new Gtk.Overlay();
|
this.overlay = new Gtk.Overlay();
|
||||||
this.controls = new Controls();
|
this.controls = new Controls();
|
||||||
@@ -69,6 +71,11 @@ class ClapperInterface extends Gtk.Grid
|
|||||||
this.overlay.add(this._player.widget);
|
this.overlay.add(this._player.widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addHeaderBar(headerBar)
|
||||||
|
{
|
||||||
|
this.headerBar = headerBar;
|
||||||
|
}
|
||||||
|
|
||||||
revealControls(isReveal)
|
revealControls(isReveal)
|
||||||
{
|
{
|
||||||
this.revealer.set_transition_duration(this.revealTime);
|
this.revealer.set_transition_duration(this.revealTime);
|
||||||
@@ -107,8 +114,8 @@ class ClapperInterface extends Gtk.Grid
|
|||||||
{
|
{
|
||||||
let mediaInfo = this._player.get_media_info();
|
let mediaInfo = this._player.get_media_info();
|
||||||
|
|
||||||
// titlebar from video title should be set from this (not implemented yet)
|
// set titlebar media title and path
|
||||||
//let title = mediaInfo.get_title();
|
this.updateHeaderBar(mediaInfo);
|
||||||
|
|
||||||
// we can also check if video is "live" or "seekable" (right now unused)
|
// 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
|
// 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)
|
_onTrackChangeRequested(self, trackType, trackId)
|
||||||
{
|
{
|
||||||
// reenabling audio is slow (as expected),
|
// reenabling audio is slow (as expected),
|
||||||
|
Reference in New Issue
Block a user