From a33c20cfdededb04f58bb157ac26953dc8eb55cf Mon Sep 17 00:00:00 2001 From: Olaf Leidinger Date: Tue, 21 Oct 2014 23:21:46 +0200 Subject: [PATCH 1/3] merge drawing into abstract class --- src/extension.js | 41 ++++----------------------- src/icon.js | 73 +++++++++++++++++++++++++++++++++++++----------- 2 files changed, 63 insertions(+), 51 deletions(-) diff --git a/src/extension.js b/src/extension.js index c59f8cf..ce85cdc 100644 --- a/src/extension.js +++ b/src/extension.js @@ -24,6 +24,7 @@ const Gettext = imports.gettext; const ExtensionUtils = imports.misc.extensionUtils; const Me = ExtensionUtils.getCurrentExtension(); const Utils = Me.imports.utils; +const Icon = Me.imports.icon; const bUseGnome34Workarounds = imports.misc.extensionUtils.versionCheck( ["3.4"], imports.misc.config.PACKAGE_VERSION); @@ -148,18 +149,13 @@ const TeaTime = new Lang.Class({ this._settings = Utils.getSettings(); - this._logo = new Me.imports.icon.TeaPot(24); + this._logo = new Icon.TwoColorIcon(24, Icon.TeaPot); // set timer widget this._textualTimer = new St.Label({ text: "", x_align: Clutter.ActorAlign.END, y_align: Clutter.ActorAlign.CENTER }); - this._graphicalTimer = new St.DrawingArea({ - reactive : true - }); - this._graphicalTimer.set_width(20); - this._graphicalTimer.set_height(20); - this._graphicalTimer.connect('repaint', Lang.bind(this, this._drawTimer)); + this._graphicalTimer = new Icon.TwoColorIcon(24, Icon.Pie); this.actor.add_actor(this._logo); this.actor.connect('style-changed', Lang.bind(this, this._onStyleChanged)); @@ -285,7 +281,6 @@ const TeaTime = new Lang.Class({ this._startTime = new Date(); this._stopTime = new Date(); this._cntdownStart = time; - this._progress = 0; this._bGraphicalCountdown = this._settings.get_boolean(Utils.TEATIME_GRAPHICAL_COUNTDOWN_KEY); @@ -310,8 +305,7 @@ const TeaTime = new Lang.Class({ }, _updateTimerDisplay: function(remainingTime) { if ( this._bGraphicalCountdown ) { - this._progress = (this._cntdownStart - remainingTime) / this._cntdownStart; - this._graphicalTimer.queue_repaint(); + this._graphicalTimer.setStatus((this._cntdownStart - remainingTime) / this._cntdownStart); } else { this._textualTimer.text = Utils.formatTime(remainingTime); } @@ -341,30 +335,6 @@ const TeaTime = new Lang.Class({ return true; // continue timer } }, - _drawTimer : function() { - let[width, height] = this._graphicalTimer.get_surface_size(); - let cr = this._graphicalTimer.get_context(); - let pi = Math.PI; - let r = Math.min(width, height) * 0.5;; - - cr.setSourceRGBA(0, 0, 0, 0); - cr.rectangle(0, 0, width, height); - cr.fill(); - - cr.translate(Math.floor(width / 2), Math.floor(height / 2)); - cr.save(); - - Utils.setCairoColorFromClutter(cr, this._secondaryColor); - cr.moveTo(0, 0); - cr.arc(0, 0, r, 3 / 2 * pi + 2 * pi * this._progress, 3 / 2 * pi + 2 - * pi); - cr.fill(); - - Utils.setCairoColorFromClutter(cr, this._primaryColor); - cr.moveTo(0, 0); - cr.arc(0, 0, r, 3 / 2 * pi, 3 / 2 * pi + 2 * pi * this._progress); - cr.fill(); - }, _playSound : function() { let bPlayAlarmSound = this._settings.get_boolean(Utils.TEATIME_USE_ALARM_SOUND_KEY); if (bPlayAlarmSound) { @@ -385,7 +355,8 @@ const TeaTime = new Lang.Class({ blue: color.blue, alpha: color.alpha*0.3 }); - this._logo.setColor(this._primaryColor); + this._logo.setColor(this._primaryColor, this._secondaryColor); + this._graphicalTimer.setColor(this._primaryColor, this._secondaryColor); } }); diff --git a/src/icon.js b/src/icon.js index 6953006..edf52be 100644 --- a/src/icon.js +++ b/src/icon.js @@ -17,14 +17,16 @@ const ExUt = imports.misc.extensionUtils; const Me = ExUt.getCurrentExtension(); const Utils = Me.imports.utils; -const TeaPot = new Lang.Class({ - Name: 'TeaPot', +const TwoColorIcon = new Lang.Class({ + Name: 'TwoColorIcon', Extends: St.DrawingArea, - _init : function(size) { + _init : function(size, drawingObject) { this.parent({ reactive : true }); this.set_width(size); this.set_height(size); + this._drawingObject = drawingObject; + this.connect('repaint', Lang.bind(this, this._drawIcon)); // some fallback color @@ -34,19 +36,24 @@ const TeaPot = new Lang.Class({ blue: 150, alpha: 255 }); + this._secundaryColor = this._primaryColor; + this._currentStatus = null; }, - setColor: function(col) { - this._primaryColor = col; + setColor: function(primary, secundary) { + this._primaryColor = primary; + this._secundaryColor = secundary; this.queue_repaint(); }, + setStatus: function(newStatus) { + this._customStatus = newStatus; + this.queue_repaint(); + }, _drawIcon: function() { let cr = this.get_context(); - let orWdt = 484; // from the svg file - let orHgt = 295; + let orWdt = this._drawingObject.width; + let orHgt = this._drawingObject.height; let[width, height] = this.get_surface_size(); - Utils.setCairoColorFromClutter(cr, this._primaryColor); - cr.save(); // layout object in box @@ -58,12 +65,24 @@ const TeaPot = new Lang.Class({ cr.scale(height/orHgt, height/orHgt) cr.translate(-(orWdt-orHgt)*0.5, 0);; } - - - // draw TeaPot + + this._drawingObject.draw(cr, this._customStatus, this._primaryColor, this._secundaryColor); + + cr.restore(); + } + +}); + +const TeaPot = { + width : 484, + height : 295, + draw : function(cr, stat, primary, secundary) { + // draw TeaPot // cairo commands generated from svg2cairo // https://github.com/akrinke/svg2cairo + Utils.setCairoColorFromClutter(cr, primary); + cr.moveTo(127.894531, 276.472656); cr.curveTo(98.457031, 244.316406, 76.527344, 238.09375, 47.953125, 210.996094); cr.curveTo(17.957031, 186.902344, -7.5625, 148.257812, 2.066406, 108.261719); @@ -94,9 +113,31 @@ const TeaPot = new Lang.Class({ cr.fillPreserve(); // end of image - cr.restore(); - } - -}); + } // draw +}; // TeaPot +const Pie = { + width : 1, + height: 1, + draw : function(cr, stat, primary, secundary) { + const pi = Math.PI; + const r = 0.5; + + if(stat == null) stat = 0; + + cr.translate(0.5, 0.5); + cr.save(); + + Utils.setCairoColorFromClutter(cr, secundary); + cr.moveTo(0, 0); + cr.arc(0, 0, r, 3 / 2 * pi + 2 * pi * stat, 3 / 2 * pi + 2 + * pi); + cr.fill(); + + Utils.setCairoColorFromClutter(cr, primary); + cr.moveTo(0, 0); + cr.arc(0, 0, r, 3 / 2 * pi, 3 / 2 * pi + 2 * pi * stat); + cr.fill(); + } // draw +}; // Pie From 3e33279a6e90926dcfe3e57b9dd56b2dab408013 Mon Sep 17 00:00:00 2001 From: Olaf Leidinger Date: Tue, 21 Oct 2014 23:28:30 +0200 Subject: [PATCH 2/3] whitespace --- src/icon.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/icon.js b/src/icon.js index edf52be..0149a0d 100644 --- a/src/icon.js +++ b/src/icon.js @@ -122,9 +122,9 @@ const Pie = { height: 1, draw : function(cr, stat, primary, secundary) { const pi = Math.PI; - const r = 0.5; + const r = 0.5; - if(stat == null) stat = 0; + if(stat == null) stat = 0; cr.translate(0.5, 0.5); cr.save(); From 7b2de6c92e5b5d056f5cfc6ed9b066ae20703958 Mon Sep 17 00:00:00 2001 From: Olaf Leidinger Date: Tue, 30 Dec 2014 10:54:24 +0100 Subject: [PATCH 3/3] added spanish translation --- po/LINGUAS | 1 + po/es.po | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 po/es.po diff --git a/po/LINGUAS b/po/LINGUAS index 78dd0c5..fcedbfa 100644 --- a/po/LINGUAS +++ b/po/LINGUAS @@ -1,4 +1,5 @@ # keep this file sorted alphabetically, one language code per line de +es fr diff --git a/po/es.po b/po/es.po new file mode 100644 index 0000000..aacae25 --- /dev/null +++ b/po/es.po @@ -0,0 +1,64 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# Rockyiii , 2014. +# +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-02-18 23:13+0100\n" +"PO-Revision-Date: 2013-11-05 14:22+0100\n" +"Last-Translator: Solveig \n" +"Language-Team: LANGUAGE \n" +"Language: spanish\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +#: ../src/extension.js:86 ../src/extension.js:340 +msgid "Your tea is ready!" +msgstr "Su té está listo!" +#: ../src/extension.js:191 +msgid "Show settings" +msgstr "Preferencias" +#: ../src/extension.js:200 +msgid "min:sec" +msgstr "min:sec" +#: ../src/extension.js:272 ../src/extension.js:273 +msgid "TeaTime applet" +msgstr "Applicación TeaTime" +#: ../src/extension.js:313 +msgid "Timer set!" +msgstr "Definir el tiempo!" +#: ../src/extension.js:313 +#, javascript-format +msgid "%ss to go" +msgstr "para ir %ss" +#: ../src/extension.js:341 +msgid "Drink it, while it is hot!" +msgstr "Beba mientras está caliente!" +#: ../src/prefs.js:67 +msgid "Fullscreen Notifications" +msgstr "Notificaciones en pantalla completa" +#: ../src/prefs.js:70 +msgid "Graphical Countdown" +msgstr "Cuenta atrás gráfica" +#: ../src/prefs.js:96 +msgid "Tea" +msgstr "Té" +#: ../src/prefs.js:111 +msgid "Steep time" +msgstr "Tiempo de infusión" +#: ../src/schemas/org.gnome.shell.extensions.teatime.gschema.xml.in.h:1 +msgid "" +"{ \"Green tea\": 180, \"Black tea\": 210, \"Fruit tea\": 420, \"White tea\": " +"120 }" +msgstr "" +"{ \"Té verde\": 180, \"Té negro\": 210, \"Té de frutas\": 420, \"Té blanco" +"\": 120 }" +#: ../src/schemas/org.gnome.shell.extensions.teatime.gschema.xml.in.h:2 +msgid "Tea drawing times list" +msgstr "Tiempo de infusión de diferentes tés" +#: ../src/schemas/org.gnome.shell.extensions.teatime.gschema.xml.in.h:3 +msgid "A mapping of a teas to their corresponding drawing time in seconds." +msgstr "Correspondencias entre cada té y el tiempo de infusión en segundos."