From 84232f3c120ed8e00271ded38f718ce9f1bded6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Mon, 8 Feb 2021 19:22:27 +0100 Subject: [PATCH] Prepare resume playback dialog --- src/dialogs.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/dialogs.js b/src/dialogs.js index 4c153d70..10ce82da 100644 --- a/src/dialogs.js +++ b/src/dialogs.js @@ -162,6 +162,45 @@ class ClapperUriDialog extends Gtk.Dialog } }); +var ResumeDialog = GObject.registerClass( +class ClapperResumeDialog extends Gtk.MessageDialog +{ + _init(window, resumeInfo) + { + const percentage = Math.round((resumeInfo.time / resumeInfo.duration) * 100); + + const msg = [ + `Title: ${resumeInfo.title}`, + `Completed: ${percentage}%` + ].join('\n'); + + super._init({ + transient_for: window, + modal: true, + message_type: Gtk.MessageType.QUESTION, + buttons: Gtk.ButtonsType.YES_NO, + text: 'Resume playback?', + secondary_use_markup: true, + secondary_text: msg, + }); + + this.resumeInfo = resumeInfo; + this.connect('response', this._onResponse.bind(this)); + + this.show(); + } + + _onResponse(dialog, respId) + { + const { player } = this.transient_for.child; + + if(respId === Gtk.ResponseType.YES) + player.seek_seconds(this.resumeInfo.time); + + this.destroy(); + } +}); + var PrefsDialog = GObject.registerClass( class ClapperPrefsDialog extends Gtk.Dialog {