Permalink
Browse files

Merge pull request #35 from takuyozora/master

Fix crash on second notification + pie chart. Complete french translation. Add compat 3.26, 3.24, 3.22. Add sound notification with loop and panel settings
  • Loading branch information...
olebowle committed Oct 25, 2017
2 parents 6fb1678 + f03b839 commit acebb93eafe92991570516a51fd9166490aeaa5e
@@ -31,8 +31,9 @@
import os.path
import gettext
from gettext import gettext as _
-gettext.textdomain('timer-applet')
+gettext.textdomain('gnome-shell-timer')
+main_window = None
def color_to_hex(color):
return "#%02x%02x%02x%02x" % (
@@ -55,7 +56,7 @@ def hex_to_color(hexstr):
class ColorSelect:
def __init__(self, name):
- self.label = Gtk.Label("%s Chart Color: " % name)
+ self.label = Gtk.Label(_('{} Chart Color: '.format(name)))
self.picker = Gtk.ColorButton()
self.actor = Gtk.HBox()
self.actor.add(self.label)
@@ -149,13 +150,13 @@ def add(self, key):
treeView.set_rules_hint(True)
cellrenderer = Gtk.CellRendererText()
cellrenderer.set_property('editable', True)
- column = Gtk.TreeViewColumn("Name", cellrenderer, text=0)
+ column = Gtk.TreeViewColumn(_("Name"), cellrenderer, text=0)
cellrenderer.connect('edited', edited_name, treeView, store, self.schema)
column.set_sort_column_id(0)
treeView.append_column(column)
cellrenderer = Gtk.CellRendererText()
cellrenderer.set_property('editable', True)
- column = Gtk.TreeViewColumn("Duration in Seconds", cellrenderer, text=1)
+ column = Gtk.TreeViewColumn(_("Duration in Seconds"), cellrenderer, text=1)
cellrenderer.connect('edited', edited_duration, treeView, store, self.schema)
column.set_sort_column_id(1)
treeView.append_column(column)
@@ -218,16 +219,59 @@ def add(self, key):
item.set_value(self.schema.get_string(key))
self.hbox3.pack_end(item.actor, True, False, 0)
item.picker.connect('color-set', set_color, self.schema, key)
+ elif key == "sound-enable":
+ item = Gtk.CheckButton(label=_('Enable sound'))
+ item.set_active(self.schema.get_boolean(key))
+ self.hbox1.add(item)
+ item.connect('toggled', set_boolean, self.schema, key)
+ elif key == "sound-loop":
+ item = Gtk.CheckButton(label=_('Loop sound'))
+ item.set_active(self.schema.get_boolean(key))
+ self.hbox1.add(item)
+ item.connect('toggled', set_boolean, self.schema, key)
+ elif key == "sound-uri":
+ item = Gtk.Button(label=_('Select sound file'))
+ self.hbox2.add(item)
+ label = Gtk.Label(label=_("Current sound file : ")+str(os.path.basename(self.schema.get_string(key))))
+ self.hbox3.add(label)
+ item.connect('clicked', self.on_file_clicked, label)
+
+ def on_file_clicked(self, widget, label):
+ dialog = Gtk.FileChooserDialog(_("Please choose a file"), main_window,
+ Gtk.FileChooserAction.OPEN,
+ (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
+ Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
+
+ filter_sound = Gtk.FileFilter()
+ filter_sound.set_name(_("Audio file"))
+ filter_sound.add_mime_type("audio/*")
+ dialog.add_filter(filter_sound)
+
+ filter_any = Gtk.FileFilter()
+ filter_any.set_name(_("Any files"))
+ filter_any.add_pattern("*")
+ dialog.add_filter(filter_any)
+
+ response = dialog.run()
+ if response == Gtk.ResponseType.OK:
+ self.schema.set_string("sound-uri", dialog.get_uri())
+ label.set_text(_("Current sound file : ")+str(os.path.basename(self.schema.get_string("sound-uri"))))
+ elif response == Gtk.ResponseType.CANCEL:
+ pass
+
+ dialog.destroy()
class App:
- setting_items = ('manual', 'ui', 'presets')
+ setting_items = ('manual', 'ui', 'presets', 'sound')
def __init__(self):
self.schema = Gio.Settings('org.gnome.shell.extensions.timer')
keys = self.schema.keys()
self.window = Gtk.Window(title=_('Timer Applet Configurator'))
self.window.connect('destroy', Gtk.main_quit)
self.window.set_border_width(10)
+ global main_window
+ main_window = self.window
self.items = []
self.settings = {}
for setting in self.setting_items:
@@ -23,7 +23,7 @@
<key name="ui-persistent" type="b">
<default>true</default>
<summary>Show persistent notification messages (ModalDialog)</summary>
- <description>Set to true to show persistant notification messages (ModalDialog), when timer is finished</description>
+ <description>Set to true to show persistent notification messages (ModalDialog), when timer is finished</description>
</key>
<key name="ui-elapsed" type="b">
<default>false</default>
@@ -53,10 +53,20 @@
<summary>Timer presets</summary>
<description>Key-Value pairs of commonly used timer settings: key is the name of the preset, value the duration in seconds</description>
</key>
- <key name="sound-uri" type="s">
- <default>"file:///usr/share/gnome-shell/extensions/timer@olebowle.gmx.com/kitchen_timer.ogg"</default>
- <summary>Notification sound</summary>
- <description>Enter uri for notification sound</description>
+ <key name="sound-enable" type="b">
+ <default>true</default>
+ <summary>Enable a sound to be played on notification</summary>
+ <description>Enable a sound to be played on notification</description>
+ </key>
+ <key name="sound-loop" type="b">
+ <default>true</default>
+ <summary>Loop sound until end of notification</summary>
+ <description>Loop sound until end of notification</description>
</key>
+ <key name="sound-uri" type="s">
+ <default>"file:///usr/share/gnome-shell/extensions/timer@olebowle.gmx.com/kitchen_timer.ogg"</default>
+ <summary>Notification sound</summary>
+ <description>Enter uri for notification sound</description>
+ </key>
</schema>
</schemalist>
@@ -2,9 +2,10 @@ msgid ""
msgstr ""
"Project-Id-Version: gnome-shell-timer\n"
"POT-Creation-Date: 2011-08-24 20:05+0100\n"
-"PO-Revision-Date: 2014-01-28 04:34+0100\n"
-"Last-Translator: Ole Ernst <olebowle@gmx.com>\n"
-"Language-Team: \n"
+"PO-Revision-Date: 2016-05-22 17:28+0100\n"
+"Last-Translator: Olivier Radisson <o.radisson@laposte.net>\n"
+"Language: FRANÇAIS\n"
+"Language-Team: FRANÇAIS <o.radisson@laposte.net>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
@@ -44,3 +45,70 @@ msgstr "Secondes"
msgid "Preset \"%s\" finished!"
msgstr "Compte à rebours \"%s\" terminé !"
+
+msgid "Add"
+msgstr "Ajouter"
+
+msgid "Delete selected"
+msgstr "Supprimer"
+
+msgid "Set default timer values:"
+msgstr "Choisir les valeurs par défaut du timer:"
+
+msgid "Show Notification"
+msgstr "Afficher les notifications"
+
+msgid "Show Persistent Notification"
+msgstr "Afficher les notifications persistantes"
+
+msgid "Show Elapsed Time"
+msgstr "Afficher le temps passé"
+
+msgid "Show Time"
+msgstr "Afficher le temps"
+
+msgid "Timer Applet Configurator"
+msgstr "Configuration de l'applet Timer"
+
+msgid "Show Chart"
+msgstr "Afficher le graphique"
+
+msgid "Manual"
+msgstr "Manuel"
+
+msgid "Ui"
+msgstr "Interface"
+
+msgid "Presets"
+msgstr "Pré-réglages"
+
+msgid "Dark Chart Color: "
+msgstr "Temps passé: "
+
+msgid "Light Chart Color: "
+msgstr "Temps restant: "
+
+msgid "Enable sound"
+msgstr "Activer le son"
+
+msgid "Sound"
+msgstr "Son"
+
+msgid "Loop sound"
+msgstr "Boucler le son"
+
+msgid "Select sound file"
+msgstr "Choisir le fichier son"
+
+msgid "Current sound file : "
+msgstr "Fichier son actuel : "
+
+msgid "Please choose a file"
+msgstr "Selectionnez un fichier"
+
+msgid "Name"
+msgstr "Nom"
+
+msgid "Duration in Seconds"
+msgstr "Durée en secondes"
+
@@ -75,7 +75,9 @@ Indicator.prototype = {
this._darkColor = this._settings.get_string('ui-dark-color');
this._lightColor = this._settings.get_string('ui-light-color');
this._presets = this._settings.get_value('presets').deep_unpack();
- this._soundUri = this._settings.get_string('sound-uri');
+ this._soundUri = this._settings.get_string('sound-uri');
+ this._sound_enable = this._settings.get_boolean('sound-enable');
+ this._sound_loop = this._settings.get_boolean('sound-loop');
});
// Watch settings for changes
@@ -90,7 +92,9 @@ Indicator.prototype = {
this._settings.connect('changed::ui-dark-color', load_settings);
this._settings.connect('changed::ui-light-color', load_settings);
this._settings.connect('changed::presets', load_settings);
- this._settings.connect('changed::sound-uri', load_settings);
+ this._settings.connect('changed::sound-uri', load_settings);
+ this._settings.connect('changed::sound-enable', load_settings);
+ this._settings.connect('changed::sound-loop', load_settings);
//Set Box
this._box = new St.BoxLayout({ name: 'panelStatusMenu' });
@@ -263,8 +267,11 @@ Indicator.prototype = {
let pi = Math.PI;
function arc(r, value, max, angle, lightColor, darkColor) {
if(max == 0) return;
- let [res, light] = Clutter.Color.from_string(lightColor);
- let [res, dark] = Clutter.Color.from_string(darkColor);
+ let res;
+ let light;
+ let dark;
+ [res, light] = Clutter.Color.from_string(lightColor);
+ [res, dark] = Clutter.Color.from_string(darkColor);
Clutter.cairo_set_source_color(cr, light);
cr.arc(xc, yc, r, 0, 2*pi);
cr.fill();
@@ -281,7 +288,7 @@ Indicator.prototype = {
Clutter.cairo_set_source_color(cr, background);
cr.rectangle(0, 0, width, height);
cr.fill();*/
- arc(8,this._timeSpent,this._time,-pi/2, this._lightColor, this._darkColor);
+ arc(8,this._timeSpent,this._time,-pi/2, this._lightColor, this._darkColor);
},
//Reset all counters and timers
@@ -351,33 +358,53 @@ Indicator.prototype = {
source.notify(notification);
}
if(this._showPersistentNotifications) {
- this._persistentMessageLabel.set_text(text);
+ //Create persistent message modal dialog
+ this._persistentMessageDialog = new ModalDialog.ModalDialog();
+ this._persistentMessageLabel = new St.Label({ style_class: 'persistent-message-label',
+ text: _(text) });
+ this._persistentMessageDialog.contentLayout.add(this._persistentMessageLabel, { x_fill: true, y_fill: true });
+ this._persistentMessageDialog.setButtons([{ label: _("Close"),
+ action: Lang.bind(this, function(param) {
+ this._persistentMessageDialog.close();
+ if(this._sound_enable){
+ this.player.set_state(Gst.State.NULL);
+ }
+ }),
+ key: Clutter.Escape
+ }]);
this._persistentMessageDialog.open();
}
},
- // szm - from tea-time
- _playSound: function(uri) {
- if ( typeof this.player == 'undefined' ) {
- Gst.init(null, 0);
- this.player = Gst.ElementFactory.make("playbin","player");
- this.playBus = this.player.get_bus();
- this.playBus.add_signal_watch();
- this.playBus.connect("message", Lang.bind(this,
- function(playBus, message) {
- if (message != null) {
- // IMPORTANT: to reuse the player, set state to READY
- let t = message.type;
- if ( t == Gst.MessageType.EOS || t == Gst.MessageType.ERROR) {
- this.player.set_state(Gst.State.READY);
- }
- } // message handler
- }));
- } // if undefined
- //this._notifyUser("Playing uri="+uri);
- this.player.set_property('uri', uri);
- this.player.set_state(Gst.State.PLAYING);
- }
+ // szm - from tea-time
+ _playSound: function(uri) {
+ if (this._sound_enable) {
+ if ( typeof this.player == 'undefined' ) {
+ Gst.init(null, 0);
+ this.player = Gst.ElementFactory.make("playbin","player");
+ this.playBus = this.player.get_bus();
+ this.playBus.add_signal_watch();
+ this.playBus.connect("message", Lang.bind(this,
+ function(playBus, message) {
+ if (message != null) {
+ // IMPORTANT: to reuse the player, set state to READY
+ let t = message.type;
+ if ( t == Gst.MessageType.EOS || t == Gst.MessageType.ERROR) {
+ this.player.set_state(Gst.State.READY);
+ }
+ if ( t == Gst.MessageType.EOS && this._sound_loop ){
+ this.player.set_state(Gst.State.READY);
+ this.player.set_property('uri', uri);
+ this.player.set_state(Gst.State.PLAYING);
+ }
+ } // message handler
+ }));
+ } // if undefined
+ //this._notifyUser("Playing uri="+uri);
+ this.player.set_property('uri', uri);
+ this.player.set_state(Gst.State.PLAYING);
+ }
+ }
};
@@ -1,5 +1,5 @@
{
- "shell-version": ["3.14", "3.20", "3.22"],
+ "shell-version": ["3.26", "3.24", "3.22", "3.20", "3.16"],
"uuid": "timer@olebowle.gmx.com",
"name": "Timer",
"url": "https://github.com/olebowle/gnome-shell-timer",

0 comments on commit acebb93

Please sign in to comment.