initial version of textual countdown

This commit is contained in:
Olaf Leidinger 2014-02-18 23:29:48 +01:00
parent ac4f9ec30b
commit 46e6a7052e
7 changed files with 132 additions and 54 deletions

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-11-05 14:36+0100\n" "POT-Creation-Date: 2014-02-18 23:13+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -17,44 +17,48 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n" "Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
#: ../src/extension.js:85 ../src/extension.js:282 #: ../src/extension.js:86 ../src/extension.js:340
msgid "Your tea is ready!" msgid "Your tea is ready!"
msgstr "" msgstr ""
#: ../src/extension.js:180 #: ../src/extension.js:191
msgid "Show settings" msgid "Show settings"
msgstr "" msgstr ""
#: ../src/extension.js:189 #: ../src/extension.js:200
msgid "min:sec" msgid "min:sec"
msgstr "" msgstr ""
#: ../src/extension.js:244 #: ../src/extension.js:272 ../src/extension.js:273
msgid "TeaTime applet" msgid "TeaTime applet"
msgstr "" msgstr ""
#: ../src/extension.js:263 #: ../src/extension.js:313
msgid "Timer set!" msgid "Timer set!"
msgstr "" msgstr ""
#: ../src/extension.js:263 #: ../src/extension.js:313
#, javascript-format #, javascript-format
msgid "%ss to go" msgid "%ss to go"
msgstr "" msgstr ""
#: ../src/extension.js:283 #: ../src/extension.js:341
msgid "Drink it, while it is hot!" msgid "Drink it, while it is hot!"
msgstr "" msgstr ""
#: ../src/prefs.js:65 #: ../src/prefs.js:67
msgid "Fullscreen Notifications" msgid "Fullscreen Notifications"
msgstr "" msgstr ""
#: ../src/prefs.js:77 #: ../src/prefs.js:70
msgid "Graphical Countdown"
msgstr ""
#: ../src/prefs.js:96
msgid "Tea" msgid "Tea"
msgstr "" msgstr ""
#: ../src/prefs.js:92 #: ../src/prefs.js:111
msgid "Steep time" msgid "Steep time"
msgstr "" msgstr ""

View File

@ -8,8 +8,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: TeaTime 7\n" "Project-Id-Version: TeaTime 7\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-11-05 14:36+0100\n" "POT-Creation-Date: 2014-02-18 23:13+0100\n"
"PO-Revision-Date: 2013-10-31 09:38+0100\n" "PO-Revision-Date: 2014-02-18 23:25+0100\n"
"Last-Translator: Olaf Leidinger <oleid@mescharet.de>\n" "Last-Translator: Olaf Leidinger <oleid@mescharet.de>\n"
"Language-Team: German\n" "Language-Team: German\n"
"Language: de\n" "Language: de\n"
@ -17,46 +17,50 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 1.5.7\n" "X-Generator: Poedit 1.6.4\n"
#: ../src/extension.js:85 ../src/extension.js:282 #: ../src/extension.js:86 ../src/extension.js:340
msgid "Your tea is ready!" msgid "Your tea is ready!"
msgstr "Dein Tee ist fertig!" msgstr "Dein Tee ist fertig!"
#: ../src/extension.js:180 #: ../src/extension.js:191
msgid "Show settings" msgid "Show settings"
msgstr "Einstellungen" msgstr "Einstellungen"
#: ../src/extension.js:189 #: ../src/extension.js:200
msgid "min:sec" msgid "min:sec"
msgstr "min:sec" msgstr "min:sec"
#: ../src/extension.js:244 #: ../src/extension.js:272 ../src/extension.js:273
msgid "TeaTime applet" msgid "TeaTime applet"
msgstr "TeaTime applet" msgstr "TeaTime applet"
#: ../src/extension.js:263 #: ../src/extension.js:313
msgid "Timer set!" msgid "Timer set!"
msgstr "Die Zeit läuft!" msgstr "Die Zeit läuft!"
#: ../src/extension.js:263 #: ../src/extension.js:313
#, javascript-format #, javascript-format
msgid "%ss to go" msgid "%ss to go"
msgstr "%ss verbleiben" msgstr "%ss verbleiben"
#: ../src/extension.js:283 #: ../src/extension.js:341
msgid "Drink it, while it is hot!" msgid "Drink it, while it is hot!"
msgstr "Trink ihn, solange er noch heiß ist!" msgstr "Trink ihn, solange er noch heiß ist!"
#: ../src/prefs.js:65 #: ../src/prefs.js:67
msgid "Fullscreen Notifications" msgid "Fullscreen Notifications"
msgstr "Vollbild-Benachrichtigungen" msgstr "Vollbild-Benachrichtigungen"
#: ../src/prefs.js:77 #: ../src/prefs.js:70
msgid "Graphical Countdown"
msgstr "Grafisches Herunterzählen"
#: ../src/prefs.js:96
msgid "Tea" msgid "Tea"
msgstr "Tee" msgstr "Tee"
#: ../src/prefs.js:92 #: ../src/prefs.js:111
msgid "Steep time" msgid "Steep time"
msgstr "Ziehzeit" msgstr "Ziehzeit"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-11-05 14:36+0100\n" "POT-Creation-Date: 2014-02-18 23:13+0100\n"
"PO-Revision-Date: 2013-11-05 14:22+0100\n" "PO-Revision-Date: 2013-11-05 14:22+0100\n"
"Last-Translator: Solveig <teatime@solveig.org>\n" "Last-Translator: Solveig <teatime@solveig.org>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -16,44 +16,48 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
#: ../src/extension.js:85 ../src/extension.js:282 #: ../src/extension.js:86 ../src/extension.js:340
msgid "Your tea is ready!" msgid "Your tea is ready!"
msgstr "Votre thé est prêt !" msgstr "Votre thé est prêt !"
#: ../src/extension.js:180 #: ../src/extension.js:191
msgid "Show settings" msgid "Show settings"
msgstr "Préférences" msgstr "Préférences"
#: ../src/extension.js:189 #: ../src/extension.js:200
msgid "min:sec" msgid "min:sec"
msgstr "min:sec" msgstr "min:sec"
#: ../src/extension.js:244 #: ../src/extension.js:272 ../src/extension.js:273
msgid "TeaTime applet" msgid "TeaTime applet"
msgstr "Application TeaTime" msgstr "Application TeaTime"
#: ../src/extension.js:263 #: ../src/extension.js:313
msgid "Timer set!" msgid "Timer set!"
msgstr "Minuteur réglé !" msgstr "Minuteur réglé !"
#: ../src/extension.js:263 #: ../src/extension.js:313
#, javascript-format #, javascript-format
msgid "%ss to go" msgid "%ss to go"
msgstr "encore %ss" msgstr "encore %ss"
#: ../src/extension.js:283 #: ../src/extension.js:341
msgid "Drink it, while it is hot!" msgid "Drink it, while it is hot!"
msgstr "Buvez tant que c'est chaud !" msgstr "Buvez tant que c'est chaud !"
#: ../src/prefs.js:65 #: ../src/prefs.js:67
msgid "Fullscreen Notifications" msgid "Fullscreen Notifications"
msgstr "Notifications en plein écran" msgstr "Notifications en plein écran"
#: ../src/prefs.js:77 #: ../src/prefs.js:70
msgid "Graphical Countdown"
msgstr ""
#: ../src/prefs.js:96
msgid "Tea" msgid "Tea"
msgstr "Thé" msgstr "Thé"
#: ../src/prefs.js:92 #: ../src/prefs.js:111
msgid "Steep time" msgid "Steep time"
msgstr "Temps d'infusion" msgstr "Temps d'infusion"

View File

@ -162,12 +162,13 @@ const TeaTime = new Lang.Class({
icon_size: 20 }); icon_size: 20 });
} }
// set timer widget // set timer widget
this._timer = new St.DrawingArea({ this._textualTimer = new St.Label({ text: "" });
this._graphicalTimer = new St.DrawingArea({
reactive : true reactive : true
}); });
this._timer.set_width(20); this._graphicalTimer.set_width(20);
this._timer.set_height(20); this._graphicalTimer.set_height(20);
this._timer.connect('repaint', Lang.bind(this, this._drawTimer)); this._graphicalTimer.connect('repaint', Lang.bind(this, this._drawTimer));
this.actor.add_actor(this._logo); this.actor.add_actor(this._logo);
@ -179,6 +180,8 @@ const TeaTime = new Lang.Class({
this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
this._settings.connect("changed::" + Utils.TEATIME_STEEP_TIMES_KEY, this._settings.connect("changed::" + Utils.TEATIME_STEEP_TIMES_KEY,
Lang.bind(this, this._updateTeaList)); Lang.bind(this, this._updateTeaList));
this._settings.connect("changed::" + Utils.TEATIME_GRAPHICAL_COUNTDOWN_KEY,
Lang.bind(this, this._updateCountdownType));
this.teaItemCont = new PopupMenu.PopupMenuSection(); this.teaItemCont = new PopupMenu.PopupMenuSection();
@ -226,6 +229,22 @@ const TeaTime = new Lang.Class({
this.teaItemCont.addMenuItem(menuItem); this.teaItemCont.addMenuItem(menuItem);
} }
}, },
_updateCountdownType : function(config, output) {
let bWantGraphicalCountdown = this._settings.get_boolean(Utils.TEATIME_GRAPHICAL_COUNTDOWN_KEY);
if ( bWantGraphicalCountdown != this._bGraphicalCountdown) {
if (this._idleTimeout != null) {
// we have a running countdown, replace the display
this.actor.remove_actor( this._bGraphicalCountdown
? this._graphicalTimer : this._textualTimer);
this._bGraphicalCountdown = bWantGraphicalCountdown;
this.actor.add_actor( this._bGraphicalCountdown
? this._graphicalTimer : this._textualTimer);
this._updateTimerDisplay( this._getRemainingSec() );
} // if timeout active
} // value changed
},
_createCustomTimer: function(text, event) { _createCustomTimer: function(text, event) {
if (event.get_key_symbol() == Clutter.KEY_Enter || if (event.get_key_symbol() == Clutter.KEY_Enter ||
event.get_key_symbol() == Clutter.KEY_Return) { event.get_key_symbol() == Clutter.KEY_Return) {
@ -275,12 +294,21 @@ const TeaTime = new Lang.Class({
this._stopTime = new Date(); this._stopTime = new Date();
this._cntdownStart = time; this._cntdownStart = time;
this._progress = 0; this._progress = 0;
let dt = Math.max(0.1, time / 180); // change time step to fit animation
this._bGraphicalCountdown = this._settings.get_boolean(Utils.TEATIME_GRAPHICAL_COUNTDOWN_KEY);
let dt = this._bGraphicalCountdown
? Math.max(0.1, time / 180) // set time step to fit animation
: 1.0; // show every second for the textual countdown
this._stopTime.setTime(this._startTime.getTime() + time*1000); // in msec this._stopTime.setTime(this._startTime.getTime() + time*1000); // in msec
this.actor.remove_actor(this._logo); // show timer instead of default icon this.actor.remove_actor(this._logo); // show timer instead of default icon
this.actor.add_actor(this._timer);
this._updateTimerDisplay(time);
this.actor.add_actor( this._bGraphicalCountdown
? this._graphicalTimer : this._textualTimer);
this._showNotification(_("Timer set!"), _("%ss to go").format(time)); this._showNotification(_("Timer set!"), _("%ss to go").format(time));
this._idleTimeout = Mainloop.timeout_add_seconds(dt, Lang.bind(this, this._doCountdown)); this._idleTimeout = Mainloop.timeout_add_seconds(dt, Lang.bind(this, this._doCountdown));
@ -289,13 +317,21 @@ const TeaTime = new Lang.Class({
let a = new Date(); let a = new Date();
return (this._stopTime.getTime() - a.getTime()) * 1e-3; return (this._stopTime.getTime() - a.getTime()) * 1e-3;
}, },
_updateTimerDisplay: function(remainingTime) {
if ( this._bGraphicalCountdown ) {
this._progress = (this._cntdownStart - remainingTime) / this._cntdownStart;
this._graphicalTimer.queue_repaint();
} else {
this._textualTimer.text = Utils.formatTime(remainingTime);
}
},
_doCountdown : function() { _doCountdown : function() {
let remainingTime = this._getRemainingSec(); let remainingTime = this._getRemainingSec();
this._progress = (this._cntdownStart - remainingTime) / this._cntdownStart;
if (remainingTime <= 0) { if (remainingTime <= 0) {
// count down finished, switch display again // count down finished, switch display again
this.actor.remove_actor(this._timer); this.actor.remove_actor( this._bGraphicalCountdown
? this._graphicalTimer : this._textualTimer);
this.actor.add_actor(this._logo); this.actor.add_actor(this._logo);
if ( !bUseGnome34Workarounds && this._settings.get_boolean(Utils.TEATIME_FULLSCREEN_NOTIFICATION_KEY)) { if ( !bUseGnome34Workarounds && this._settings.get_boolean(Utils.TEATIME_FULLSCREEN_NOTIFICATION_KEY)) {
this.dialog = new TeaTimeFullscreenNotification(); this.dialog = new TeaTimeFullscreenNotification();
@ -308,13 +344,13 @@ const TeaTime = new Lang.Class({
this._idleTimeout = null; this._idleTimeout = null;
return false; return false;
} else { } else {
this._timer.queue_repaint(); this._updateTimerDisplay(remainingTime);
return true; // continue timer return true; // continue timer
} }
}, },
_drawTimer : function() { _drawTimer : function() {
let[width, height] = this._timer.get_surface_size(); let[width, height] = this._graphicalTimer.get_surface_size();
let cr = this._timer.get_context(); let cr = this._graphicalTimer.get_context();
let pi = Math.PI; let pi = Math.PI;
let r = Math.min(width, height) * 0.5;; let r = Math.min(width, height) * 0.5;;

View File

@ -63,21 +63,35 @@ const TeaTimePrefsWidget = new Lang.Class({
this._tealist.connect("row-deleted", Lang.bind(this, this._save)); this._tealist.connect("row-deleted", Lang.bind(this, this._save));
}, },
_initWindow: function() { _initWindow: function() {
let label = new Gtk.Label({ label: _("Fullscreen Notifications"), let curRow = 0;
let labelFN = new Gtk.Label({ label: _("Fullscreen Notifications"),
hexpand: true, hexpand: true,
halign: Gtk.Align.START }); halign: Gtk.Align.START });
let labelGC = new Gtk.Label({ label: _("Graphical Countdown"),
hexpand: true,
halign: Gtk.Align.START });
this.fullscreenNotificationSwitch = new Gtk.Switch(); this.fullscreenNotificationSwitch = new Gtk.Switch();
this.fullscreenNotificationSwitch.connect("notify::active", Lang.bind(this, this._saveFullscreenNotifications)); this.fullscreenNotificationSwitch.connect("notify::active", Lang.bind(this, this._saveFullscreenNotifications));
this.graphicalCountdownSwitch = new Gtk.Switch();
this.graphicalCountdownSwitch.connect("notify::active", Lang.bind(this, this._saveGraphicalCountdown));
if ( !bUseGnome34Workarounds) { if ( !bUseGnome34Workarounds) {
// Full screen notifications currently not working on GNOME 3.4, thus don't show the switch // Full screen notifications currently not working on GNOME 3.4, thus don't show the switch
this.attach(label, 0 /*col*/, 0 /*row*/, 1 /*col span*/, 1 /*row span*/); this.attach(labelFN, 0 /*col*/, curRow /*row*/, 1 /*col span*/, 1 /*row span*/);
this.attach(this.fullscreenNotificationSwitch, 1, 0, 1, 1); this.attach(this.fullscreenNotificationSwitch, 1, curRow, 1, 1);
curRow += 1;
} }
this.attach(labelGC, 0 /*col*/, curRow /*row*/, 1 /*col span*/, 1 /*row span*/);
this.attach(this.graphicalCountdownSwitch, 1, curRow, 1, 1);
curRow += 1;
this.treeview = new Gtk.TreeView({model: this._tealist, expand: true}); this.treeview = new Gtk.TreeView({model: this._tealist, expand: true});
this.treeview.get_selection().set_mode(Gtk.SelectionMode.MULTIPLE); this.treeview.get_selection().set_mode(Gtk.SelectionMode.MULTIPLE);
this.attach(this.treeview, 0, 1, 2, 1); this.attach(this.treeview, 0, curRow, 2, 1);
curRow += 1;
let teaname = new Gtk.TreeViewColumn({ title: _("Tea"), expand: true }); let teaname = new Gtk.TreeViewColumn({ title: _("Tea"), expand: true });
let renderer = new Gtk.CellRendererText({ editable: true }); let renderer = new Gtk.CellRendererText({ editable: true });
@ -110,7 +124,7 @@ const TeaTimePrefsWidget = new Lang.Class({
this.toolbar = new Gtk.Toolbar({ icon_size: 1 }); this.toolbar = new Gtk.Toolbar({ icon_size: 1 });
this.toolbar.get_style_context().add_class("inline-toolbar"); this.toolbar.get_style_context().add_class("inline-toolbar");
this.add(this.toolbar); this.attach(this.toolbar, 0 /*col*/, curRow /*row*/, 2 /*col span*/, 1 /*row span*/);
this.addButton = new Gtk.ToolButton({ icon_name: "list-add-symbolic", use_action_appearance: false }); this.addButton = new Gtk.ToolButton({ icon_name: "list-add-symbolic", use_action_appearance: false });
this.addButton.connect("clicked", Lang.bind(this, this._addTea)); this.addButton.connect("clicked", Lang.bind(this, this._addTea));
this.toolbar.insert(this.addButton, -1); this.toolbar.insert(this.addButton, -1);
@ -125,6 +139,7 @@ const TeaTimePrefsWidget = new Lang.Class({
this.fullscreenNotificationSwitch.active = this._settings.get_boolean(Utils.TEATIME_FULLSCREEN_NOTIFICATION_KEY) this.fullscreenNotificationSwitch.active = this._settings.get_boolean(Utils.TEATIME_FULLSCREEN_NOTIFICATION_KEY)
this.graphicalCountdownSwitch.active = this._settings.get_boolean(Utils.TEATIME_GRAPHICAL_COUNTDOWN_KEY)
let list = this._settings.get_value(Utils.TEATIME_STEEP_TIMES_KEY).unpack(); let list = this._settings.get_value(Utils.TEATIME_STEEP_TIMES_KEY).unpack();
// stop everyone from reacting to the changes we are about to produce // stop everyone from reacting to the changes we are about to produce
@ -178,6 +193,15 @@ const TeaTimePrefsWidget = new Lang.Class({
sw.active); sw.active);
this._inhibitUpdate = false; this._inhibitUpdate = false;
}, },
_saveGraphicalCountdown: function(sw, data) {
// don't update the backend if someone else is messing with the model
if (this._inhibitUpdate)
return;
this._inhibitUpdate = true;
this._settings.set_boolean(Utils.TEATIME_GRAPHICAL_COUNTDOWN_KEY,
sw.active);
this._inhibitUpdate = false;
},
_save: function(store, path_, iter_) { _save: function(store, path_, iter_) {
// don't update the backend if someone else is messing with the model // don't update the backend if someone else is messing with the model
if (this._inhibitUpdate) if (this._inhibitUpdate)

View File

@ -11,6 +11,11 @@
<summary>Show fullscreen notifications.</summary> <summary>Show fullscreen notifications.</summary>
<description>Displays a more disrupting, modal fullscreen notification when the timer has elapsed.</description> <description>Displays a more disrupting, modal fullscreen notification when the timer has elapsed.</description>
</key> </key>
<key name="graphical-countdown" type="b">
<default>true</default>
<summary>Show an animated graphical countdown.</summary>
<description>Displays a small, yet nice animation instead of an textual countdown.</description>
</key>
</schema> </schema>
</schemalist> </schemalist>

View File

@ -12,6 +12,7 @@ const Config = imports.misc.config;
const TEATIME_STEEP_TIMES_KEY = 'steep-times'; const TEATIME_STEEP_TIMES_KEY = 'steep-times';
const TEATIME_FULLSCREEN_NOTIFICATION_KEY = 'fullscreen-notification'; const TEATIME_FULLSCREEN_NOTIFICATION_KEY = 'fullscreen-notification';
const TEATIME_GRAPHICAL_COUNTDOWN_KEY = 'graphical-countdown';
function initTranslations(domain) { function initTranslations(domain) {
let extension = ExtensionUtils.getCurrentExtension(); let extension = ExtensionUtils.getCurrentExtension();