diff --git a/README.md b/README.md index 5fa1bfa..995b85a 100644 --- a/README.md +++ b/README.md @@ -346,29 +346,14 @@ date, time spent (hh:mm), type ('++' = project, '()' = task), task or project > **HINT:** > There is an option to pause the time tracker when the pomodoro stops! -The time tracker can also be controled via the command line using dbus: -```sh -# The id 'asdf' is created by using the 'tracker_id:string' todo.txt extension. -# When using the stop/start by id funcs, all tasks with the given id will -# stop/start tracking. -# -# There are 3 funcs: -# - stop_all_tracking -# - stop_tracking_by_id -# - start_tracking_by_id - -gdbus call --session --dest org.gnome.Shell \ - --object-path /timepp/zagortenay333/TimeTracker \ - --method timepp.zagortenay333.TimeTracker.stop_all_tracking - -gdbus call --session --dest org.gnome.Shell \ - --object-path /timepp/zagortenay333/TimeTracker \ - --method timepp.zagortenay333.TimeTracker.start_tracking_by_id 'asdf' - -gdbus call --session --dest org.gnome.Shell \ - --object-path /timepp/zagortenay333/TimeTracker \ - --method timepp.zagortenay333.TimeTracker.stop_tracking_by_id 'asdf' -``` +--- + +### DBus API + +This extension comes with a dbus api. Check out the [dbus](dbus) for info on +what you can do. + +There are also some example scripts that might come in handy. :smile: --- diff --git a/dbus/pomodoro_iface.xml b/dbus/pomodoro_iface.xml new file mode 100644 index 0000000..8abcafa --- /dev/null +++ b/dbus/pomodoro_iface.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dbus/scripts/examples b/dbus/scripts/examples new file mode 100755 index 0000000..465afc7 --- /dev/null +++ b/dbus/scripts/examples @@ -0,0 +1,37 @@ +#!/bin/bash +set -eu + + +# ===================================================================== +# Templates for monitoring a signal and calling a method +# ===================================================================== + + +pomodoro_monitor () { + local signal + local -a msg + + gdbus monitor --session \ + --dest org.gnome.Shell \ + --object-path /timepp/zagortenay333/Pomodoro | + while read -r -a msg; do + signal=${msg[1]} signal=${signal##*.} + + case "$signal" in + "POMO") echo "$signal";; + "STOPPED") echo "$signal";; + "LONG_BREAK") echo "$signal";; + "SHORT_BREAK") echo "$signal";; + esac + done +} + +timer_start () { + local time="$1" + + >/dev/null gdbus call \ + --session \ + --dest org.gnome.Shell \ + --object-path /timepp/zagortenay333/Timer \ + --method timepp.zagortenay333.Timer.start "$time" +} diff --git a/dbus/scripts/time_tracker_control b/dbus/scripts/time_tracker_control new file mode 100755 index 0000000..5fb6618 --- /dev/null +++ b/dbus/scripts/time_tracker_control @@ -0,0 +1,164 @@ +#!/bin/bash +set -eu + + +# ===================================================================== +# This script is used to control the time-tracker of the Time++ gnome +# shell extension: +# https://github.com/zagortenay333/timepp__gnome +# +# Once executed, the script will listen for when the workspace change +# and do something. +# +# The tracker is controled by supplying string arguments. +# An arg string is of the form: +# "["default" ]tracker_id n1[, n2, n3,...]" +# +# If the string starts with the "default" keyword then: +# - the given tracker_id is gonna be the default id +# - no workspace numbers need to provided +# +# The tracker_id is either: +# - the string "stop" +# - a tracker_id specified in Time++ using the the "tracker_id:string" +# todo.txt extension. (See README of Time++.) +# +# The n1, n2, ... numbers correspond to workspace numbers. They are +# 0-indexed. +# +# Examples: +# +# 1) tracker_control "stop 0" "default id1 2 3" "id2 1 4" +# Means: +# - If on workspace number 0 , stop the tracker. +# - If on workspace number 2 or 3, start tracking tasks with id "id1". +# - If on workspace number 1 or 4, start tracking tasks with id "id2". +# - If on any other workspace , start tracking tasks with id "id1". +# +# 2) tracker_control "id1 2 3" +# Means: +# - If on workspace number 2 or 3, start tracking tasks with id "id1". +# - If on any other workspace , stop tracking. +# +# 3) tracker_control "default id1" +# Means: +# - Always track tasks with id "id1". +# +# 4) tracker_control +# Means: +# - Stop tracking. +# ===================================================================== + + +# ===================================================================== +# @@@ Constants +# ===================================================================== +declare -A id_workspace_map + +current_workspace=0 + +current_id=0 + +default_id="stop" + + + +# ===================================================================== +# @@@ Funcs +# ===================================================================== +stop_tracking () { + >/dev/null gdbus call \ + --session \ + --dest org.gnome.Shell \ + --object-path /timepp/zagortenay333/TimeTracker \ + --method timepp.zagortenay333.TimeTracker.stop_all_tracking +} + +start_tracking () { + local id=$1 + + stop_tracking + + >/dev/null gdbus call \ + --session \ + --dest org.gnome.Shell \ + --object-path /timepp/zagortenay333/TimeTracker \ + --method timepp.zagortenay333.TimeTracker.start_tracking_by_id "$id" +} + +on_workspace_changed () { + local found_id=$default_id + local it + local workspace + + for it in "${!id_workspace_map[@]}"; do + for workspace in ${id_workspace_map[$it]}; do + [[ $workspace == "$current_workspace" ]] && found_id=$it && break 1 + done + done + + [[ $found_id == "$current_id" ]] && return + + if [[ $found_id == "stop" ]]; then + stop_tracking + else + start_tracking "$found_id" + fi + + current_id=$found_id +} + +check_workspace () { + local workspace + + read -r -a workspace <<< "$( + gdbus call \ + --session \ + --dest org.gnome.Shell \ + --object-path /org/gnome/Shell \ + --method org.gnome.Shell.Eval \ + "global.screen.get_active_workspace_index()" + )" + + # gdbus will return a string of the form "('bool', 'n')". + # We need to extract n only. + workspace=${workspace[1]} + workspace=${workspace:1: -2} + + if [[ $workspace != "$current_workspace" ]]; then + current_workspace=$workspace + on_workspace_changed + fi +} + + + +# ===================================================================== +# @@@ Parse args +# ===================================================================== +[[ $# == 0 ]] && stop_tracking && exit + +for it in "$@"; do + read -r -a it <<< "$it" + + case ${it[0]} in + "default") + default_id=${it[1]} + id_workspace_map[${it[1]}]="${it[*]:2}" + ;; + *) + id_workspace_map[${it[0]}]="${it[*]:1}" + esac +done + + + +# ===================================================================== +# @@@ Mainloop +# ===================================================================== +trap "stop_tracking" INT TERM EXIT + +while true; do + check_workspace + sleep 1 +done diff --git a/dbus/stopwatch_iface.xml b/dbus/stopwatch_iface.xml new file mode 100644 index 0000000..f55420a --- /dev/null +++ b/dbus/stopwatch_iface.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + diff --git a/dbus/time_tracker_iface.xml b/dbus/time_tracker_iface.xml new file mode 100644 index 0000000..99f8544 --- /dev/null +++ b/dbus/time_tracker_iface.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + diff --git a/dbus/timer_iface.xml b/dbus/timer_iface.xml new file mode 100644 index 0000000..7be1af8 --- /dev/null +++ b/dbus/timer_iface.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/num_picker.js b/lib/num_picker.js index 34d8e04..a4eea72 100644 --- a/lib/num_picker.js +++ b/lib/num_picker.js @@ -132,7 +132,7 @@ var NumPicker = new Lang.Class({ else return s; }, - _set_counter: function (num) { + set_counter: function (num) { this.counter_label.text = this._left_pad(num, 2); this.counter = num; }, diff --git a/lib/panel_item.js b/lib/panel_item.js index 514097c..1da87a8 100644 --- a/lib/panel_item.js +++ b/lib/panel_item.js @@ -41,18 +41,14 @@ var PanelItem = new Lang.Class({ // // listen // - this.actor.connect('button-press-event', (actor, event) => { - let btn = event.get_button(); - - switch (btn) { + this.actor.connect('button-press-event', (_, event) => { + switch (event.get_button()) { case Clutter.BUTTON_PRIMARY: this.emit('left-click'); return Clutter.EVENT_STOP; - case Clutter.BUTTON_MIDDLE: this.emit('middle-click'); return Clutter.EVENT_STOP; - case Clutter.BUTTON_SECONDARY: this.emit('right-click'); return Clutter.EVENT_STOP; @@ -61,9 +57,7 @@ var PanelItem = new Lang.Class({ return Clutter.EVENT_PROPAGATE; }); - this.actor.connect('key-press-event', (actor, event) => { - let symbol = event.get_key_symbol(); - + this.actor.connect('key-press-event', (_, event) => { if (event.get_key_symbol() === Clutter.KEY_Down) { this.menu.actor.navigate_focus(global.stage.get_key_focus(), Gtk.DirectionType.TAB_FORWARD, diff --git a/lib/signal_manager.js b/lib/signal_manager.js index 19b721e..30bdf9e 100644 --- a/lib/signal_manager.js +++ b/lib/signal_manager.js @@ -1,4 +1,5 @@ -const Lang = imports.lang; +const Clutter = imports.gi.Clutter; +const Lang = imports.lang; // ===================================================================== @@ -16,6 +17,41 @@ var SignalManager = new Lang.Class({ this.signals = []; }, + clear_obj: function (obj) { + this.disconnect_obj(obj); + + for (let i = 0, len = this.signals.length; i < len; i++) { + if (this.signals[i].obj === obj) { + this.signals.slice(i, 1); + len--; i--; + } + } + }, + + connect_press: function (obj, callback) { + let on_release = true; + + this.connect(obj, 'button-press-event', (_, event) => { + if (event.get_button() === Clutter.BUTTON_PRIMARY) { + on_release = false; + callback(); + } + }); + this.connect(obj, 'button-release-event', (_, event) => { + if (event.get_button() === Clutter.BUTTON_PRIMARY) { + if (on_release) callback(); + else on_release = true; + } + }); + this.connect(obj, 'key-release-event', (_, event) => { + if (event.get_key_symbol() === Clutter.Return) callback(); + }); + + obj.connect('destroy', () => { + this.clear_obj(obj); + }); + }, + connect: function (obj, sig_name, callback) { let id = obj.connect(sig_name, callback); @@ -29,37 +65,38 @@ var SignalManager = new Lang.Class({ return id; }, - disconnect: function (id) { - let i = this.signals.length; + disconnect_obj: function (obj) { + for (let it of this.signals) { + if (it.obj === obj) { + it.obj.disconnect(it.id); + it.id = null; + } + } + }, - while (i--) { - if (this.signals[i].id === id) { - this.signals[i].obj.disconnect(id); - this.signals[i].id = null; + disconnect: function (id) { + for (let it of this.signals) { + if (it.id === id) { + it.obj.disconnect(id); + it.id = null; break; } } }, connect_all: function () { - let i = this.signals.length; - - while (i--) { - if (! this.signals[i].id) { - this.signals[i].id = - this.signals[i].obj.connect(this.signals[i].sig_name, - this.signals[i].callback); + for (let it of this.signals) { + if (! it.id) { + it.id = it.obj.connect(it.sig_name, it.callback); } } }, disconnect_all: function () { - let i = this.signals.length; - - while (i--) { - if (this.signals[i].id) { - this.signals[i].obj.disconnect(this.signals[i].id); - this.signals[i].id = null; + for (let it of this.signals) { + if (it.id) { + it.obj.disconnect(it.id); + it.id = null; } } }, diff --git a/locale/de/LC_MESSAGES/timepp.mo b/locale/de/LC_MESSAGES/timepp.mo index d593d8b..ba0728d 100644 Binary files a/locale/de/LC_MESSAGES/timepp.mo and b/locale/de/LC_MESSAGES/timepp.mo differ diff --git a/locale/pl/LC_MESSAGES/timepp.mo b/locale/pl/LC_MESSAGES/timepp.mo index 4741e0e..fce71d4 100644 Binary files a/locale/pl/LC_MESSAGES/timepp.mo and b/locale/pl/LC_MESSAGES/timepp.mo differ diff --git a/locale/po/de.po b/locale/po/de.po index 199db47..7177a28 100644 --- a/locale/po/de.po +++ b/locale/po/de.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: timepp@zagortenay 333\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-09-04 13:55+0200\n" +"POT-Creation-Date: 2017-09-09 13:13+0200\n" "PO-Revision-Date: 2017-08-29 10:51+0200\n" "Last-Translator: Christian Mattes \n" "Language-Team: German\n" @@ -27,16 +27,16 @@ msgstr "Auf sekundären Bildschirm verschieben" #: ../prefs.js:133 ../sections/todo/view__clear_tasks.js:93 #: ../sections/todo/view__stats.js:219 -#: ../sections/todo/view__task_editor.js:127 ../sections/timer.js:646 -#: ../sections/pomodoro.js:771 ../sections/alarms.js:619 +#: ../sections/todo/view__task_editor.js:127 ../sections/timer.js:661 +#: ../sections/pomodoro.js:805 ../sections/alarms.js:622 msgid "Cancel" msgstr "Abbrechen" #: ../prefs.js:134 ../sections/todo/view__clear_tasks.js:96 #: ../sections/todo/view__sort.js:78 ../sections/todo/view__filters.js:165 #: ../sections/todo/view__stats.js:216 -#: ../sections/todo/view__task_editor.js:130 ../sections/timer.js:647 -#: ../sections/pomodoro.js:770 ../sections/alarms.js:620 +#: ../sections/todo/view__task_editor.js:130 ../sections/timer.js:662 +#: ../sections/pomodoro.js:804 ../sections/alarms.js:623 msgid "Ok" msgstr "Ok" @@ -45,9 +45,9 @@ msgid "Unique name" msgstr "Eindeutiger Name" #: ../prefs.ui:57 ../prefs.ui:1073 ../prefs.ui:1123 ../prefs.ui:1422 -#: ../prefs.ui:1472 ../prefs.ui:1979 ../prefs.ui:2029 ../prefs.ui:2389 -#: ../prefs.ui:2854 ../prefs.ui:2904 ../prefs.ui:2942 ../prefs.ui:2992 -#: ../prefs.ui:3048 +#: ../prefs.ui:1472 ../prefs.ui:1921 ../prefs.ui:1971 ../prefs.ui:2331 +#: ../prefs.ui:2796 ../prefs.ui:2846 ../prefs.ui:2884 ../prefs.ui:2934 +#: ../prefs.ui:2990 msgid "not set" msgstr "keine Angabe" @@ -87,22 +87,22 @@ msgstr "Rechts" msgid "Enabled Sections" msgstr "Aktivierte Bereiche" -#: ../prefs.ui:482 ../prefs.ui:1162 ../sections/timer.js:120 -#: ../sections/timer.js:333 +#: ../prefs.ui:482 ../prefs.ui:1162 ../sections/timer.js:132 +#: ../sections/timer.js:341 msgid "Timer" msgstr "Timer" -#: ../prefs.ui:526 ../prefs.ui:1511 ../sections/stopwatch.js:130 -#: ../sections/stopwatch.js:398 +#: ../prefs.ui:526 ../prefs.ui:1511 ../sections/stopwatch.js:142 +#: ../sections/stopwatch.js:411 msgid "Stopwatch" msgstr "Stoppuhr" -#: ../prefs.ui:570 ../prefs.ui:2068 ../sections/pomodoro.js:117 -#: ../sections/pomodoro.js:300 ../sections/pomodoro.js:406 +#: ../prefs.ui:570 ../prefs.ui:2010 ../sections/pomodoro.js:131 +#: ../sections/pomodoro.js:312 ../sections/pomodoro.js:406 msgid "Pomodoro" msgstr "Pomodoro" -#: ../prefs.ui:614 ../prefs.ui:2428 +#: ../prefs.ui:614 ../prefs.ui:2370 msgid "Alarms" msgstr "Wecker" @@ -114,8 +114,8 @@ msgstr "Aufgaben und Zeiterfassung" msgid "General" msgstr "Allgemein" -#: ../prefs.ui:767 ../prefs.ui:1222 ../prefs.ui:1571 ../prefs.ui:2128 -#: ../prefs.ui:2488 +#: ../prefs.ui:767 ../prefs.ui:1222 ../prefs.ui:1571 ../prefs.ui:2070 +#: ../prefs.ui:2430 msgid "Show in separate menu" msgstr "In eigenem Menü anzeigen" @@ -123,51 +123,51 @@ msgstr "In eigenem Menü anzeigen" msgid "Show seconds" msgstr "Sekunden anzeigen" -#: ../prefs.ui:855 ../prefs.ui:1316 ../prefs.ui:1659 ../prefs.ui:2532 +#: ../prefs.ui:855 ../prefs.ui:1316 ../prefs.ui:1659 ../prefs.ui:2474 msgid "Panel Item Mode" msgstr "Darstellung" -#: ../prefs.ui:869 ../prefs.ui:1330 ../prefs.ui:1673 ../prefs.ui:2546 +#: ../prefs.ui:869 ../prefs.ui:1330 ../prefs.ui:1673 ../prefs.ui:2488 msgid "Icon only" msgstr "nur Symbol" -#: ../prefs.ui:870 ../prefs.ui:1331 ../prefs.ui:1674 ../prefs.ui:2547 +#: ../prefs.ui:870 ../prefs.ui:1331 ../prefs.ui:1674 ../prefs.ui:2489 msgid "Text only" msgstr "nur Text" -#: ../prefs.ui:871 ../prefs.ui:1332 ../prefs.ui:1675 ../prefs.ui:2548 +#: ../prefs.ui:871 ../prefs.ui:1332 ../prefs.ui:1675 ../prefs.ui:2490 msgid "Icon and Text" msgstr "Symbol und Text" -#: ../prefs.ui:906 ../prefs.ui:1710 ../prefs.ui:2222 +#: ../prefs.ui:906 ../prefs.ui:1710 ../prefs.ui:2164 msgid "Notification sound" msgstr "Benachrichtigungston" -#: ../prefs.ui:968 ../prefs.ui:1772 ../prefs.ui:2284 +#: ../prefs.ui:968 ../prefs.ui:1772 ../prefs.ui:2226 msgid "Notification style" msgstr "Benachrichtigungsstil" -#: ../prefs.ui:982 ../prefs.ui:1786 ../prefs.ui:2298 +#: ../prefs.ui:982 ../prefs.ui:1786 ../prefs.ui:2240 msgid "Standard" msgstr "Standard" -#: ../prefs.ui:983 ../prefs.ui:1787 ../prefs.ui:2299 +#: ../prefs.ui:983 ../prefs.ui:1787 ../prefs.ui:2241 msgid "Fullscreen" msgstr "Vollbild" -#: ../prefs.ui:1015 ../prefs.ui:1364 ../prefs.ui:1921 ../prefs.ui:2331 -#: ../prefs.ui:2794 +#: ../prefs.ui:1015 ../prefs.ui:1364 ../prefs.ui:1863 ../prefs.ui:2273 +#: ../prefs.ui:2736 msgid "Keyboard shortcuts" msgstr "Tastaturkürzel" -#: ../prefs.ui:1056 ../prefs.ui:1405 ../prefs.ui:1962 ../prefs.ui:2372 -#: ../prefs.ui:2837 +#: ../prefs.ui:1056 ../prefs.ui:1405 ../prefs.ui:1904 ../prefs.ui:2314 +#: ../prefs.ui:2779 msgid "Open this section" msgstr "Diesen Bereich öffnen" #: ../prefs.ui:1068 ../prefs.ui:1118 ../prefs.ui:1417 ../prefs.ui:1467 -#: ../prefs.ui:1974 ../prefs.ui:2024 ../prefs.ui:2384 ../prefs.ui:2849 -#: ../prefs.ui:2899 ../prefs.ui:2937 ../prefs.ui:2987 ../prefs.ui:3043 +#: ../prefs.ui:1916 ../prefs.ui:1966 ../prefs.ui:2326 ../prefs.ui:2791 +#: ../prefs.ui:2841 ../prefs.ui:2879 ../prefs.ui:2929 ../prefs.ui:2985 msgid "" "Examples:\n" "t\n" @@ -179,7 +179,7 @@ msgstr "" "super\n" "F3" -#: ../prefs.ui:1106 ../prefs.ui:1455 ../prefs.ui:2012 +#: ../prefs.ui:1106 ../prefs.ui:1455 ../prefs.ui:1954 msgid "Open in fullscreen" msgstr "Im Vollbildmodus öffnen" @@ -204,63 +204,59 @@ msgstr "stunden:min:sek:millisek" msgid "Stop time tracking when pomo is paused" msgstr "Zeiterfassung anhalten, wenn Pomo pausiert wird" -#: ../prefs.ui:1866 -msgid "Execute custom script when pomo pauses/starts" -msgstr "Eigenes Skript ausführen, wenn Pomo startet/pausiert" - -#: ../prefs.ui:2172 +#: ../prefs.ui:2114 msgid "Snooze duration (sec)" msgstr "Schlummerdauer (sek)" -#: ../prefs.ui:2600 +#: ../prefs.ui:2542 msgid "Task width (px)" msgstr "Aufgabenbreite (px)" -#: ../prefs.ui:2630 +#: ../prefs.ui:2572 msgid "Todo files" msgstr "Aufgaben-Dateien" -#: ../prefs.ui:2887 +#: ../prefs.ui:2829 msgid "Open this section to add task" msgstr "Bereich zum Anlegen einer neuen Aufgabe öffnen" -#: ../prefs.ui:2955 +#: ../prefs.ui:2897 msgid "Open this section to search tasks" msgstr "Bereich zum Durchsuchen der Aufgaben öffnen" -#: ../prefs.ui:3005 +#: ../prefs.ui:2947 #, fuzzy msgid "Open the stats view" msgstr "Diesen Bereich öffnen" -#: ../prefs.ui:3061 +#: ../prefs.ui:3003 msgid "Open this section to switch todo files" msgstr "Bereich zum Wechseln der Aufgaben-Datei öffnen" -#: ../prefs.ui:3101 +#: ../prefs.ui:3043 msgid "Todo / Time Tracker" msgstr "Aufgaben / Zeiterfassung" -#: ../sections/todo/MAIN.js:255 ../sections/todo/MAIN.js:852 +#: ../sections/todo/MAIN.js:256 ../sections/todo/MAIN.js:853 msgid "Loading..." msgstr "Lade..." -#: ../sections/todo/MAIN.js:265 +#: ../sections/todo/MAIN.js:266 msgid "Select todo file in settings..." msgstr "Aufgaben-Datei in den Einstellungen auswählen..." -#: ../sections/todo/MAIN.js:290 +#: ../sections/todo/MAIN.js:291 msgid "Add New Task..." msgstr "Neue Aufgabe..." -#: ../sections/todo/MAIN.js:699 +#: ../sections/todo/MAIN.js:700 #, javascript-format msgid "%d task has recurred" msgid_plural "%d tasks have recurred" msgstr[0] "%d Aufgabe wurde wiederholt" msgstr[1] "%d Aufgaben wurden wiederholt" -#: ../sections/todo/MAIN.js:858 +#: ../sections/todo/MAIN.js:859 #, fuzzy msgid "Nothing found." msgstr "Nichts gefunden..." @@ -305,7 +301,7 @@ msgid_plural "in %d days" msgstr[0] "in %d Tag" msgstr[1] "in %d Tagen" -#: ../sections/todo/task_item.js:896 +#: ../sections/todo/task_item.js:877 msgid "File or dir not found." msgstr "Datei oder Verzeichnis nicht gefunden." @@ -383,8 +379,8 @@ msgstr[1] "%d wiederholte Aufgaben" msgid "Invert filters" msgstr "Filter invertieren" -#: ../sections/todo/view__filters.js:164 ../sections/stopwatch.js:156 -#: ../sections/stopwatch.js:610 +#: ../sections/todo/view__filters.js:164 ../sections/stopwatch.js:168 +#: ../sections/stopwatch.js:633 msgid "Reset" msgstr "Zurücksetzen" @@ -494,7 +490,7 @@ msgstr "Gesamtzeit pro Quartal: " msgid "Task..." msgstr "Aufgabe..." -#: ../sections/todo/view__task_editor.js:114 ../sections/alarms.js:611 +#: ../sections/todo/view__task_editor.js:114 ../sections/alarms.js:614 msgid "Delete" msgstr "Löschen" @@ -502,18 +498,19 @@ msgstr "Löschen" msgid "Archive" msgstr "Archiv" -#: ../sections/stopwatch.js:157 ../sections/stopwatch.js:611 +#: ../sections/stopwatch.js:169 ../sections/stopwatch.js:634 msgid "Lap" msgstr "Zwischenzeit" -#: ../sections/stopwatch.js:158 ../sections/stopwatch.js:613 -#: ../sections/pomodoro.js:162 ../sections/pomodoro.js:835 +#: ../sections/stopwatch.js:170 ../sections/stopwatch.js:636 +#: ../sections/pomodoro.js:176 ../sections/pomodoro.js:872 msgid "Start" msgstr "Starten" -#: ../sections/stopwatch.js:159 ../sections/stopwatch.js:612 -msgid "Pause" -msgstr "Pause" +#: ../sections/stopwatch.js:171 ../sections/stopwatch.js:635 +#: ../sections/pomodoro.js:177 ../sections/pomodoro.js:873 +msgid "Stop" +msgstr "Stoppen" #: ../sections/context_menu.js:38 msgid "Open settings" @@ -531,77 +528,78 @@ msgstr "Fehler melden" msgid "Help with translations" msgstr "Beim Übersetzen helfen" -#: ../sections/timer.js:39 +#: ../sections/timer.js:41 msgid "Timer Expired!" msgstr "Timer abgelaufen" -#: ../sections/timer.js:624 +#: ../sections/timer.js:639 msgid "Timer message..." msgstr "Timernachricht..." -#: ../sections/pomodoro.js:36 -msgid "Start working!" -msgstr "Beginne mit der Arbeit!" +#: ../sections/pomodoro.js:39 +msgid "Work!" +msgstr "" -#: ../sections/pomodoro.js:37 -msgid "Take long break!" +#: ../sections/pomodoro.js:40 +#, fuzzy +msgid "Long Break!" msgstr "Mache eine lange Pause!" -#: ../sections/pomodoro.js:38 -msgid "Take short break!" +#: ../sections/pomodoro.js:41 +#, fuzzy +msgid "Short break!" msgstr "Mache eine kurze Pause!" -#: ../sections/pomodoro.js:160 ../sections/pomodoro.js:833 +#: ../sections/pomodoro.js:174 ../sections/pomodoro.js:870 msgid "New Pomo" msgstr "Neuer Pomo" -#: ../sections/pomodoro.js:161 ../sections/pomodoro.js:834 +#: ../sections/pomodoro.js:175 ../sections/pomodoro.js:871 msgid "Take Break" msgstr "Pause machen" -#: ../sections/pomodoro.js:163 ../sections/pomodoro.js:836 -msgid "Stop" -msgstr "Stoppen" - -#: ../sections/pomodoro.js:694 +#: ../sections/pomodoro.js:715 msgid "Clear all pomodoros?" msgstr "Alle Pomodoros löschen?" -#: ../sections/pomodoro.js:710 -msgid "Pomodoro (min):" +#: ../sections/pomodoro.js:731 +#, fuzzy +msgid "Pomodoro (min:sec):" msgstr "Pomodoro (min):" -#: ../sections/pomodoro.js:725 -msgid "Short break (min):" +#: ../sections/pomodoro.js:750 +#, fuzzy +msgid "Short break (min:sec):" msgstr "Kurze Pause (min):" -#: ../sections/pomodoro.js:740 -msgid "Long break (min):" +#: ../sections/pomodoro.js:770 +#, fuzzy +msgid "Long break (min:sec):" msgstr "Lange Pause (min):" -#: ../sections/pomodoro.js:755 +#: ../sections/pomodoro.js:789 msgid "Num of pomos until long break:" msgstr "Anzahl Pomos bis zur langen Pause:" -#: ../sections/alarms.js:148 +#: ../sections/alarms.js:151 msgid "Add New Alarm..." msgstr "Neuer Wecker..." #. TRANSLATORS: %s is a time string in the format HH:MM (e.g., 13:44) -#: ../sections/alarms.js:472 ../sections/alarms.js:889 +#: ../sections/alarms.js:472 ../sections/alarms.js:892 #, javascript-format msgid "Alarm at %s" msgstr "Wecker für %s" -#: ../sections/alarms.js:486 ../sections/alarms.js:854 +#: ../sections/alarms.js:486 ../sections/alarms.js:857 msgid "Snooze" msgstr "Schlummern" -#: ../sections/alarms.js:583 +#: ../sections/alarms.js:586 msgid "Alarm Message..." msgstr "Weckmeldung..." -#: ../sections/alarms.js:912 +#: ../sections/alarms.js:915 #, javascript-format msgid "%d alarm went off!" msgid_plural "%d alarms went off!" diff --git a/locale/po/pl.po b/locale/po/pl.po index d8f7ad5..3a19b7a 100644 --- a/locale/po/pl.po +++ b/locale/po/pl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-09-04 13:55+0200\n" +"POT-Creation-Date: 2017-09-09 13:13+0200\n" "PO-Revision-Date: 2017-07-20 07:02+0200\n" "Last-Translator: Piotr Komur \n" "Language-Team: \n" @@ -29,16 +29,16 @@ msgstr "Przenieś na dodatkowy monitor" #: ../prefs.js:133 ../sections/todo/view__clear_tasks.js:93 #: ../sections/todo/view__stats.js:219 -#: ../sections/todo/view__task_editor.js:127 ../sections/timer.js:646 -#: ../sections/pomodoro.js:771 ../sections/alarms.js:619 +#: ../sections/todo/view__task_editor.js:127 ../sections/timer.js:661 +#: ../sections/pomodoro.js:805 ../sections/alarms.js:622 msgid "Cancel" msgstr "Anuluj" #: ../prefs.js:134 ../sections/todo/view__clear_tasks.js:96 #: ../sections/todo/view__sort.js:78 ../sections/todo/view__filters.js:165 #: ../sections/todo/view__stats.js:216 -#: ../sections/todo/view__task_editor.js:130 ../sections/timer.js:647 -#: ../sections/pomodoro.js:770 ../sections/alarms.js:620 +#: ../sections/todo/view__task_editor.js:130 ../sections/timer.js:662 +#: ../sections/pomodoro.js:804 ../sections/alarms.js:623 msgid "Ok" msgstr "OK" @@ -47,9 +47,9 @@ msgid "Unique name" msgstr "Unikatowa nazwa" #: ../prefs.ui:57 ../prefs.ui:1073 ../prefs.ui:1123 ../prefs.ui:1422 -#: ../prefs.ui:1472 ../prefs.ui:1979 ../prefs.ui:2029 ../prefs.ui:2389 -#: ../prefs.ui:2854 ../prefs.ui:2904 ../prefs.ui:2942 ../prefs.ui:2992 -#: ../prefs.ui:3048 +#: ../prefs.ui:1472 ../prefs.ui:1921 ../prefs.ui:1971 ../prefs.ui:2331 +#: ../prefs.ui:2796 ../prefs.ui:2846 ../prefs.ui:2884 ../prefs.ui:2934 +#: ../prefs.ui:2990 msgid "not set" msgstr "nie ustawiono" @@ -89,22 +89,22 @@ msgstr "Z prawej" msgid "Enabled Sections" msgstr "Dostępne sekcje" -#: ../prefs.ui:482 ../prefs.ui:1162 ../sections/timer.js:120 -#: ../sections/timer.js:333 +#: ../prefs.ui:482 ../prefs.ui:1162 ../sections/timer.js:132 +#: ../sections/timer.js:341 msgid "Timer" msgstr "Minutnik" -#: ../prefs.ui:526 ../prefs.ui:1511 ../sections/stopwatch.js:130 -#: ../sections/stopwatch.js:398 +#: ../prefs.ui:526 ../prefs.ui:1511 ../sections/stopwatch.js:142 +#: ../sections/stopwatch.js:411 msgid "Stopwatch" msgstr "Stoper" -#: ../prefs.ui:570 ../prefs.ui:2068 ../sections/pomodoro.js:117 -#: ../sections/pomodoro.js:300 ../sections/pomodoro.js:406 +#: ../prefs.ui:570 ../prefs.ui:2010 ../sections/pomodoro.js:131 +#: ../sections/pomodoro.js:312 ../sections/pomodoro.js:406 msgid "Pomodoro" msgstr "" -#: ../prefs.ui:614 ../prefs.ui:2428 +#: ../prefs.ui:614 ../prefs.ui:2370 msgid "Alarms" msgstr "Alarmy" @@ -116,8 +116,8 @@ msgstr "Zadania i śledzenie" msgid "General" msgstr "Ogólne" -#: ../prefs.ui:767 ../prefs.ui:1222 ../prefs.ui:1571 ../prefs.ui:2128 -#: ../prefs.ui:2488 +#: ../prefs.ui:767 ../prefs.ui:1222 ../prefs.ui:1571 ../prefs.ui:2070 +#: ../prefs.ui:2430 msgid "Show in separate menu" msgstr "Pokaż w oddzielnym menu" @@ -125,51 +125,51 @@ msgstr "Pokaż w oddzielnym menu" msgid "Show seconds" msgstr "Pokaż sekundy" -#: ../prefs.ui:855 ../prefs.ui:1316 ../prefs.ui:1659 ../prefs.ui:2532 +#: ../prefs.ui:855 ../prefs.ui:1316 ../prefs.ui:1659 ../prefs.ui:2474 msgid "Panel Item Mode" msgstr "Prezentacja na panelu" -#: ../prefs.ui:869 ../prefs.ui:1330 ../prefs.ui:1673 ../prefs.ui:2546 +#: ../prefs.ui:869 ../prefs.ui:1330 ../prefs.ui:1673 ../prefs.ui:2488 msgid "Icon only" msgstr "Tylko ikona" -#: ../prefs.ui:870 ../prefs.ui:1331 ../prefs.ui:1674 ../prefs.ui:2547 +#: ../prefs.ui:870 ../prefs.ui:1331 ../prefs.ui:1674 ../prefs.ui:2489 msgid "Text only" msgstr "Tylko tekst" -#: ../prefs.ui:871 ../prefs.ui:1332 ../prefs.ui:1675 ../prefs.ui:2548 +#: ../prefs.ui:871 ../prefs.ui:1332 ../prefs.ui:1675 ../prefs.ui:2490 msgid "Icon and Text" msgstr "Ikona i tekst" -#: ../prefs.ui:906 ../prefs.ui:1710 ../prefs.ui:2222 +#: ../prefs.ui:906 ../prefs.ui:1710 ../prefs.ui:2164 msgid "Notification sound" msgstr "Dźwięk powiadomienia" -#: ../prefs.ui:968 ../prefs.ui:1772 ../prefs.ui:2284 +#: ../prefs.ui:968 ../prefs.ui:1772 ../prefs.ui:2226 msgid "Notification style" msgstr "Styl powiadomienia" -#: ../prefs.ui:982 ../prefs.ui:1786 ../prefs.ui:2298 +#: ../prefs.ui:982 ../prefs.ui:1786 ../prefs.ui:2240 msgid "Standard" msgstr "Standardowy" -#: ../prefs.ui:983 ../prefs.ui:1787 ../prefs.ui:2299 +#: ../prefs.ui:983 ../prefs.ui:1787 ../prefs.ui:2241 msgid "Fullscreen" msgstr "Na pełnym ekranie" -#: ../prefs.ui:1015 ../prefs.ui:1364 ../prefs.ui:1921 ../prefs.ui:2331 -#: ../prefs.ui:2794 +#: ../prefs.ui:1015 ../prefs.ui:1364 ../prefs.ui:1863 ../prefs.ui:2273 +#: ../prefs.ui:2736 msgid "Keyboard shortcuts" msgstr "Skróty klawiaturowe" -#: ../prefs.ui:1056 ../prefs.ui:1405 ../prefs.ui:1962 ../prefs.ui:2372 -#: ../prefs.ui:2837 +#: ../prefs.ui:1056 ../prefs.ui:1405 ../prefs.ui:1904 ../prefs.ui:2314 +#: ../prefs.ui:2779 msgid "Open this section" msgstr "Otwórz sekcję" #: ../prefs.ui:1068 ../prefs.ui:1118 ../prefs.ui:1417 ../prefs.ui:1467 -#: ../prefs.ui:1974 ../prefs.ui:2024 ../prefs.ui:2384 ../prefs.ui:2849 -#: ../prefs.ui:2899 ../prefs.ui:2937 ../prefs.ui:2987 ../prefs.ui:3043 +#: ../prefs.ui:1916 ../prefs.ui:1966 ../prefs.ui:2326 ../prefs.ui:2791 +#: ../prefs.ui:2841 ../prefs.ui:2879 ../prefs.ui:2929 ../prefs.ui:2985 msgid "" "Examples:\n" "t\n" @@ -181,7 +181,7 @@ msgstr "" "super\n" "F3" -#: ../prefs.ui:1106 ../prefs.ui:1455 ../prefs.ui:2012 +#: ../prefs.ui:1106 ../prefs.ui:1455 ../prefs.ui:1954 msgid "Open in fullscreen" msgstr "Otwórz na pełnym ekranie" @@ -205,55 +205,51 @@ msgstr "" msgid "Stop time tracking when pomo is paused" msgstr "Zatrzymaj śledzenie, gdy pomodoro jest wstrzymane" -#: ../prefs.ui:1866 -msgid "Execute custom script when pomo pauses/starts" -msgstr "Wykonaj własny skrypt, gdy pomodoro jest zatrzymywane/uruchamiane" - -#: ../prefs.ui:2172 +#: ../prefs.ui:2114 msgid "Snooze duration (sec)" msgstr "Czas drzemki (sek.)" -#: ../prefs.ui:2600 +#: ../prefs.ui:2542 msgid "Task width (px)" msgstr "Szerokość zadania (px)" -#: ../prefs.ui:2630 +#: ../prefs.ui:2572 msgid "Todo files" msgstr "Pliki zadań" -#: ../prefs.ui:2887 +#: ../prefs.ui:2829 msgid "Open this section to add task" msgstr "Otwórz sekcję, aby dodać zadanie" -#: ../prefs.ui:2955 +#: ../prefs.ui:2897 msgid "Open this section to search tasks" msgstr "Otwórz sekcję, aby wyszukać zadanie" -#: ../prefs.ui:3005 +#: ../prefs.ui:2947 msgid "Open the stats view" msgstr "" -#: ../prefs.ui:3061 +#: ../prefs.ui:3003 msgid "Open this section to switch todo files" msgstr "Otwórz sekcję, aby wyszukać zadanie" -#: ../prefs.ui:3101 +#: ../prefs.ui:3043 msgid "Todo / Time Tracker" msgstr "Zadania / Śledzenie" -#: ../sections/todo/MAIN.js:255 ../sections/todo/MAIN.js:852 +#: ../sections/todo/MAIN.js:256 ../sections/todo/MAIN.js:853 msgid "Loading..." msgstr "Wczytuję..." -#: ../sections/todo/MAIN.js:265 +#: ../sections/todo/MAIN.js:266 msgid "Select todo file in settings..." msgstr "Wskaż w ustawieniach plik 'todo'..." -#: ../sections/todo/MAIN.js:290 +#: ../sections/todo/MAIN.js:291 msgid "Add New Task..." msgstr "Dodaj nowe zadanie..." -#: ../sections/todo/MAIN.js:699 +#: ../sections/todo/MAIN.js:700 #, javascript-format msgid "%d task has recurred" msgid_plural "%d tasks have recurred" @@ -261,7 +257,7 @@ msgstr[0] "%d powtórzyło się" msgstr[1] "%d powtórzyły się" msgstr[2] "%d powtórzyło się" -#: ../sections/todo/MAIN.js:858 +#: ../sections/todo/MAIN.js:859 msgid "Nothing found." msgstr "Nic nie znaleziono..." @@ -308,7 +304,7 @@ msgstr[0] "w ciągu %d dnia" msgstr[1] "w ciagu %d dni" msgstr[2] "w ciagu %d dni" -#: ../sections/todo/task_item.js:896 +#: ../sections/todo/task_item.js:877 msgid "File or dir not found." msgstr "" @@ -388,8 +384,8 @@ msgstr[2] "%d powtarzających się zadań" msgid "Invert filters" msgstr "Odwróć filtry" -#: ../sections/todo/view__filters.js:164 ../sections/stopwatch.js:156 -#: ../sections/stopwatch.js:610 +#: ../sections/todo/view__filters.js:164 ../sections/stopwatch.js:168 +#: ../sections/stopwatch.js:633 msgid "Reset" msgstr "Zeruj" @@ -493,7 +489,7 @@ msgstr "" msgid "Task..." msgstr "Zadanie..." -#: ../sections/todo/view__task_editor.js:114 ../sections/alarms.js:611 +#: ../sections/todo/view__task_editor.js:114 ../sections/alarms.js:614 msgid "Delete" msgstr "Usuń" @@ -501,18 +497,19 @@ msgstr "Usuń" msgid "Archive" msgstr "Archiwum" -#: ../sections/stopwatch.js:157 ../sections/stopwatch.js:611 +#: ../sections/stopwatch.js:169 ../sections/stopwatch.js:634 msgid "Lap" msgstr "Okrążenie" -#: ../sections/stopwatch.js:158 ../sections/stopwatch.js:613 -#: ../sections/pomodoro.js:162 ../sections/pomodoro.js:835 +#: ../sections/stopwatch.js:170 ../sections/stopwatch.js:636 +#: ../sections/pomodoro.js:176 ../sections/pomodoro.js:872 msgid "Start" msgstr "" -#: ../sections/stopwatch.js:159 ../sections/stopwatch.js:612 -msgid "Pause" -msgstr "Wstrzymaj" +#: ../sections/stopwatch.js:171 ../sections/stopwatch.js:635 +#: ../sections/pomodoro.js:177 ../sections/pomodoro.js:873 +msgid "Stop" +msgstr "" #: ../sections/context_menu.js:38 msgid "Open settings" @@ -530,77 +527,78 @@ msgstr "Zgłoś błąd" msgid "Help with translations" msgstr "" -#: ../sections/timer.js:39 +#: ../sections/timer.js:41 msgid "Timer Expired!" msgstr "Czas minął!" -#: ../sections/timer.js:624 +#: ../sections/timer.js:639 msgid "Timer message..." msgstr "Komunikat minutnika..." -#: ../sections/pomodoro.js:36 -msgid "Start working!" -msgstr "Rozpocznij pracę!" +#: ../sections/pomodoro.js:39 +msgid "Work!" +msgstr "" -#: ../sections/pomodoro.js:37 -msgid "Take long break!" +#: ../sections/pomodoro.js:40 +#, fuzzy +msgid "Long Break!" msgstr "Weź długą przerwę!" -#: ../sections/pomodoro.js:38 -msgid "Take short break!" +#: ../sections/pomodoro.js:41 +#, fuzzy +msgid "Short break!" msgstr "Weź krótką przerwę!" -#: ../sections/pomodoro.js:160 ../sections/pomodoro.js:833 +#: ../sections/pomodoro.js:174 ../sections/pomodoro.js:870 msgid "New Pomo" msgstr "Nowe Pomodoro" -#: ../sections/pomodoro.js:161 ../sections/pomodoro.js:834 +#: ../sections/pomodoro.js:175 ../sections/pomodoro.js:871 msgid "Take Break" msgstr "Weź przerwę!" -#: ../sections/pomodoro.js:163 ../sections/pomodoro.js:836 -msgid "Stop" -msgstr "" - -#: ../sections/pomodoro.js:694 +#: ../sections/pomodoro.js:715 msgid "Clear all pomodoros?" msgstr "Usunąć wszystkie pomodoro?" -#: ../sections/pomodoro.js:710 -msgid "Pomodoro (min):" +#: ../sections/pomodoro.js:731 +#, fuzzy +msgid "Pomodoro (min:sec):" msgstr "Pomodoro (min):" -#: ../sections/pomodoro.js:725 -msgid "Short break (min):" +#: ../sections/pomodoro.js:750 +#, fuzzy +msgid "Short break (min:sec):" msgstr "Krótka przerwa (min):" -#: ../sections/pomodoro.js:740 -msgid "Long break (min):" +#: ../sections/pomodoro.js:770 +#, fuzzy +msgid "Long break (min:sec):" msgstr "Długa przerwa (min):" -#: ../sections/pomodoro.js:755 +#: ../sections/pomodoro.js:789 msgid "Num of pomos until long break:" msgstr "Liczba pomodoro do długiej przerwy:" -#: ../sections/alarms.js:148 +#: ../sections/alarms.js:151 msgid "Add New Alarm..." msgstr "Dodaj nowy alarm..." #. TRANSLATORS: %s is a time string in the format HH:MM (e.g., 13:44) -#: ../sections/alarms.js:472 ../sections/alarms.js:889 +#: ../sections/alarms.js:472 ../sections/alarms.js:892 #, javascript-format msgid "Alarm at %s" msgstr "Alarm o %s" -#: ../sections/alarms.js:486 ../sections/alarms.js:854 +#: ../sections/alarms.js:486 ../sections/alarms.js:857 msgid "Snooze" msgstr "Drzemka" -#: ../sections/alarms.js:583 +#: ../sections/alarms.js:586 msgid "Alarm Message..." msgstr "Komunikat alarmu..." -#: ../sections/alarms.js:912 +#: ../sections/alarms.js:915 #, javascript-format msgid "%d alarm went off!" msgid_plural "%d alarms went off!" diff --git a/locale/po/template.pot b/locale/po/template.pot index 0f35c47..388c182 100644 --- a/locale/po/template.pot +++ b/locale/po/template.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-09-04 20:21+0200\n" +"POT-Creation-Date: 2017-09-09 13:13+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -28,16 +28,16 @@ msgstr "" #: ../prefs.js:133 ../sections/todo/view__clear_tasks.js:93 #: ../sections/todo/view__stats.js:219 -#: ../sections/todo/view__task_editor.js:127 ../sections/timer.js:646 -#: ../sections/pomodoro.js:771 ../sections/alarms.js:619 +#: ../sections/todo/view__task_editor.js:127 ../sections/timer.js:661 +#: ../sections/pomodoro.js:805 ../sections/alarms.js:622 msgid "Cancel" msgstr "" #: ../prefs.js:134 ../sections/todo/view__clear_tasks.js:96 #: ../sections/todo/view__sort.js:78 ../sections/todo/view__filters.js:165 #: ../sections/todo/view__stats.js:216 -#: ../sections/todo/view__task_editor.js:130 ../sections/timer.js:647 -#: ../sections/pomodoro.js:770 ../sections/alarms.js:620 +#: ../sections/todo/view__task_editor.js:130 ../sections/timer.js:662 +#: ../sections/pomodoro.js:804 ../sections/alarms.js:623 msgid "Ok" msgstr "" @@ -46,9 +46,9 @@ msgid "Unique name" msgstr "" #: ../prefs.ui:57 ../prefs.ui:1073 ../prefs.ui:1123 ../prefs.ui:1422 -#: ../prefs.ui:1472 ../prefs.ui:1979 ../prefs.ui:2029 ../prefs.ui:2389 -#: ../prefs.ui:2854 ../prefs.ui:2904 ../prefs.ui:2942 ../prefs.ui:2992 -#: ../prefs.ui:3048 +#: ../prefs.ui:1472 ../prefs.ui:1921 ../prefs.ui:1971 ../prefs.ui:2331 +#: ../prefs.ui:2796 ../prefs.ui:2846 ../prefs.ui:2884 ../prefs.ui:2934 +#: ../prefs.ui:2990 msgid "not set" msgstr "" @@ -88,22 +88,22 @@ msgstr "" msgid "Enabled Sections" msgstr "" -#: ../prefs.ui:482 ../prefs.ui:1162 ../sections/timer.js:120 -#: ../sections/timer.js:333 +#: ../prefs.ui:482 ../prefs.ui:1162 ../sections/timer.js:132 +#: ../sections/timer.js:341 msgid "Timer" msgstr "" -#: ../prefs.ui:526 ../prefs.ui:1511 ../sections/stopwatch.js:130 -#: ../sections/stopwatch.js:398 +#: ../prefs.ui:526 ../prefs.ui:1511 ../sections/stopwatch.js:142 +#: ../sections/stopwatch.js:411 msgid "Stopwatch" msgstr "" -#: ../prefs.ui:570 ../prefs.ui:2068 ../sections/pomodoro.js:117 -#: ../sections/pomodoro.js:300 ../sections/pomodoro.js:406 +#: ../prefs.ui:570 ../prefs.ui:2010 ../sections/pomodoro.js:131 +#: ../sections/pomodoro.js:312 ../sections/pomodoro.js:406 msgid "Pomodoro" msgstr "" -#: ../prefs.ui:614 ../prefs.ui:2428 +#: ../prefs.ui:614 ../prefs.ui:2370 msgid "Alarms" msgstr "" @@ -115,8 +115,8 @@ msgstr "" msgid "General" msgstr "" -#: ../prefs.ui:767 ../prefs.ui:1222 ../prefs.ui:1571 ../prefs.ui:2128 -#: ../prefs.ui:2488 +#: ../prefs.ui:767 ../prefs.ui:1222 ../prefs.ui:1571 ../prefs.ui:2070 +#: ../prefs.ui:2430 msgid "Show in separate menu" msgstr "" @@ -124,51 +124,51 @@ msgstr "" msgid "Show seconds" msgstr "" -#: ../prefs.ui:855 ../prefs.ui:1316 ../prefs.ui:1659 ../prefs.ui:2532 +#: ../prefs.ui:855 ../prefs.ui:1316 ../prefs.ui:1659 ../prefs.ui:2474 msgid "Panel Item Mode" msgstr "" -#: ../prefs.ui:869 ../prefs.ui:1330 ../prefs.ui:1673 ../prefs.ui:2546 +#: ../prefs.ui:869 ../prefs.ui:1330 ../prefs.ui:1673 ../prefs.ui:2488 msgid "Icon only" msgstr "" -#: ../prefs.ui:870 ../prefs.ui:1331 ../prefs.ui:1674 ../prefs.ui:2547 +#: ../prefs.ui:870 ../prefs.ui:1331 ../prefs.ui:1674 ../prefs.ui:2489 msgid "Text only" msgstr "" -#: ../prefs.ui:871 ../prefs.ui:1332 ../prefs.ui:1675 ../prefs.ui:2548 +#: ../prefs.ui:871 ../prefs.ui:1332 ../prefs.ui:1675 ../prefs.ui:2490 msgid "Icon and Text" msgstr "" -#: ../prefs.ui:906 ../prefs.ui:1710 ../prefs.ui:2222 +#: ../prefs.ui:906 ../prefs.ui:1710 ../prefs.ui:2164 msgid "Notification sound" msgstr "" -#: ../prefs.ui:968 ../prefs.ui:1772 ../prefs.ui:2284 +#: ../prefs.ui:968 ../prefs.ui:1772 ../prefs.ui:2226 msgid "Notification style" msgstr "" -#: ../prefs.ui:982 ../prefs.ui:1786 ../prefs.ui:2298 +#: ../prefs.ui:982 ../prefs.ui:1786 ../prefs.ui:2240 msgid "Standard" msgstr "" -#: ../prefs.ui:983 ../prefs.ui:1787 ../prefs.ui:2299 +#: ../prefs.ui:983 ../prefs.ui:1787 ../prefs.ui:2241 msgid "Fullscreen" msgstr "" -#: ../prefs.ui:1015 ../prefs.ui:1364 ../prefs.ui:1921 ../prefs.ui:2331 -#: ../prefs.ui:2794 +#: ../prefs.ui:1015 ../prefs.ui:1364 ../prefs.ui:1863 ../prefs.ui:2273 +#: ../prefs.ui:2736 msgid "Keyboard shortcuts" msgstr "" -#: ../prefs.ui:1056 ../prefs.ui:1405 ../prefs.ui:1962 ../prefs.ui:2372 -#: ../prefs.ui:2837 +#: ../prefs.ui:1056 ../prefs.ui:1405 ../prefs.ui:1904 ../prefs.ui:2314 +#: ../prefs.ui:2779 msgid "Open this section" msgstr "" #: ../prefs.ui:1068 ../prefs.ui:1118 ../prefs.ui:1417 ../prefs.ui:1467 -#: ../prefs.ui:1974 ../prefs.ui:2024 ../prefs.ui:2384 ../prefs.ui:2849 -#: ../prefs.ui:2899 ../prefs.ui:2937 ../prefs.ui:2987 ../prefs.ui:3043 +#: ../prefs.ui:1916 ../prefs.ui:1966 ../prefs.ui:2326 ../prefs.ui:2791 +#: ../prefs.ui:2841 ../prefs.ui:2879 ../prefs.ui:2929 ../prefs.ui:2985 msgid "" "Examples:\n" "t\n" @@ -176,7 +176,7 @@ msgid "" "F3" msgstr "" -#: ../prefs.ui:1106 ../prefs.ui:1455 ../prefs.ui:2012 +#: ../prefs.ui:1106 ../prefs.ui:1455 ../prefs.ui:1954 msgid "Open in fullscreen" msgstr "" @@ -200,62 +200,58 @@ msgstr "" msgid "Stop time tracking when pomo is paused" msgstr "" -#: ../prefs.ui:1866 -msgid "Execute custom script when pomo pauses/starts" -msgstr "" - -#: ../prefs.ui:2172 +#: ../prefs.ui:2114 msgid "Snooze duration (sec)" msgstr "" -#: ../prefs.ui:2600 +#: ../prefs.ui:2542 msgid "Task width (px)" msgstr "" -#: ../prefs.ui:2630 +#: ../prefs.ui:2572 msgid "Todo files" msgstr "" -#: ../prefs.ui:2887 +#: ../prefs.ui:2829 msgid "Open this section to add task" msgstr "" -#: ../prefs.ui:2955 +#: ../prefs.ui:2897 msgid "Open this section to search tasks" msgstr "" -#: ../prefs.ui:3005 +#: ../prefs.ui:2947 msgid "Open the stats view" msgstr "" -#: ../prefs.ui:3061 +#: ../prefs.ui:3003 msgid "Open this section to switch todo files" msgstr "" -#: ../prefs.ui:3101 +#: ../prefs.ui:3043 msgid "Todo / Time Tracker" msgstr "" -#: ../sections/todo/MAIN.js:255 ../sections/todo/MAIN.js:852 +#: ../sections/todo/MAIN.js:256 ../sections/todo/MAIN.js:853 msgid "Loading..." msgstr "" -#: ../sections/todo/MAIN.js:265 +#: ../sections/todo/MAIN.js:266 msgid "Select todo file in settings..." msgstr "" -#: ../sections/todo/MAIN.js:290 +#: ../sections/todo/MAIN.js:291 msgid "Add New Task..." msgstr "" -#: ../sections/todo/MAIN.js:699 +#: ../sections/todo/MAIN.js:700 #, javascript-format msgid "%d task has recurred" msgid_plural "%d tasks have recurred" msgstr[0] "" msgstr[1] "" -#: ../sections/todo/MAIN.js:858 +#: ../sections/todo/MAIN.js:859 msgid "Nothing found." msgstr "" @@ -299,7 +295,7 @@ msgid_plural "in %d days" msgstr[0] "" msgstr[1] "" -#: ../sections/todo/task_item.js:896 +#: ../sections/todo/task_item.js:877 msgid "File or dir not found." msgstr "" @@ -377,8 +373,8 @@ msgstr[1] "" msgid "Invert filters" msgstr "" -#: ../sections/todo/view__filters.js:164 ../sections/stopwatch.js:156 -#: ../sections/stopwatch.js:610 +#: ../sections/todo/view__filters.js:164 ../sections/stopwatch.js:168 +#: ../sections/stopwatch.js:633 msgid "Reset" msgstr "" @@ -481,7 +477,7 @@ msgstr "" msgid "Task..." msgstr "" -#: ../sections/todo/view__task_editor.js:114 ../sections/alarms.js:611 +#: ../sections/todo/view__task_editor.js:114 ../sections/alarms.js:614 msgid "Delete" msgstr "" @@ -489,17 +485,18 @@ msgstr "" msgid "Archive" msgstr "" -#: ../sections/stopwatch.js:157 ../sections/stopwatch.js:611 +#: ../sections/stopwatch.js:169 ../sections/stopwatch.js:634 msgid "Lap" msgstr "" -#: ../sections/stopwatch.js:158 ../sections/stopwatch.js:613 -#: ../sections/pomodoro.js:162 ../sections/pomodoro.js:835 +#: ../sections/stopwatch.js:170 ../sections/stopwatch.js:636 +#: ../sections/pomodoro.js:176 ../sections/pomodoro.js:872 msgid "Start" msgstr "" -#: ../sections/stopwatch.js:159 ../sections/stopwatch.js:612 -msgid "Pause" +#: ../sections/stopwatch.js:171 ../sections/stopwatch.js:635 +#: ../sections/pomodoro.js:177 ../sections/pomodoro.js:873 +msgid "Stop" msgstr "" #: ../sections/context_menu.js:38 @@ -518,77 +515,73 @@ msgstr "" msgid "Help with translations" msgstr "" -#: ../sections/timer.js:39 +#: ../sections/timer.js:41 msgid "Timer Expired!" msgstr "" -#: ../sections/timer.js:624 +#: ../sections/timer.js:639 msgid "Timer message..." msgstr "" -#: ../sections/pomodoro.js:36 -msgid "Start working!" +#: ../sections/pomodoro.js:39 +msgid "Work!" msgstr "" -#: ../sections/pomodoro.js:37 -msgid "Take long break!" +#: ../sections/pomodoro.js:40 +msgid "Long Break!" msgstr "" -#: ../sections/pomodoro.js:38 -msgid "Take short break!" +#: ../sections/pomodoro.js:41 +msgid "Short break!" msgstr "" -#: ../sections/pomodoro.js:160 ../sections/pomodoro.js:833 +#: ../sections/pomodoro.js:174 ../sections/pomodoro.js:870 msgid "New Pomo" msgstr "" -#: ../sections/pomodoro.js:161 ../sections/pomodoro.js:834 +#: ../sections/pomodoro.js:175 ../sections/pomodoro.js:871 msgid "Take Break" msgstr "" -#: ../sections/pomodoro.js:163 ../sections/pomodoro.js:836 -msgid "Stop" -msgstr "" - -#: ../sections/pomodoro.js:694 +#: ../sections/pomodoro.js:715 msgid "Clear all pomodoros?" msgstr "" -#: ../sections/pomodoro.js:710 -msgid "Pomodoro (min):" +#: ../sections/pomodoro.js:731 +msgid "Pomodoro (min:sec):" msgstr "" -#: ../sections/pomodoro.js:725 -msgid "Short break (min):" +#: ../sections/pomodoro.js:750 +msgid "Short break (min:sec):" msgstr "" -#: ../sections/pomodoro.js:740 -msgid "Long break (min):" +#: ../sections/pomodoro.js:770 +msgid "Long break (min:sec):" msgstr "" -#: ../sections/pomodoro.js:755 +#: ../sections/pomodoro.js:789 msgid "Num of pomos until long break:" msgstr "" -#: ../sections/alarms.js:148 +#: ../sections/alarms.js:151 msgid "Add New Alarm..." msgstr "" #. TRANSLATORS: %s is a time string in the format HH:MM (e.g., 13:44) -#: ../sections/alarms.js:472 ../sections/alarms.js:889 +#: ../sections/alarms.js:472 ../sections/alarms.js:892 #, javascript-format msgid "Alarm at %s" msgstr "" -#: ../sections/alarms.js:486 ../sections/alarms.js:854 +#: ../sections/alarms.js:486 ../sections/alarms.js:857 msgid "Snooze" msgstr "" -#: ../sections/alarms.js:583 +#: ../sections/alarms.js:586 msgid "Alarm Message..." msgstr "" -#: ../sections/alarms.js:912 +#: ../sections/alarms.js:915 #, javascript-format msgid "%d alarm went off!" msgid_plural "%d alarms went off!" diff --git a/metadata.json b/metadata.json index 7ace08f..be5df17 100644 --- a/metadata.json +++ b/metadata.json @@ -8,9 +8,9 @@ "version" : -1, "shell-version" : ["3.24"], "cache-file-format-version" : { - "timer" : 1, - "stopwatch" : 1, - "pomodoro" : 1, + "timer" : 2, + "stopwatch" : 2, + "pomodoro" : 2, "alarms" : 1, "todo" : 1 } diff --git a/prefs.js b/prefs.js index af7ea3b..77b13e7 100644 --- a/prefs.js +++ b/prefs.js @@ -525,19 +525,6 @@ const Settings = new Lang.Class({ 'active', Gio.SettingsBindFlags.DEFAULT); - this.settings.bind( - 'pomodoro-exec-script', - this.builder.get_object('pomodoro-exec-script-switch'), - 'active', - Gio.SettingsBindFlags.DEFAULT); - - this.builder.get_object('pomodoro-script-path-chooser') - .set_uri(this.settings.get_string('pomodoro-script-path')); - this.builder.get_object('pomodoro-script-path-chooser').connect('selection-changed', - (widget) => { - this.settings.set_string('pomodoro-script-path', widget.get_uri()); - }); - this.builder.get_object('pomodoro-keybinding-open') .set_text(this.settings.get_strv('pomodoro-keybinding-open')[0]); this.builder.get_object('pomodoro-keybinding-open').connect('changed', diff --git a/prefs.ui b/prefs.ui index 24cb006..2cb78e9 100644 --- a/prefs.ui +++ b/prefs.ui @@ -1842,64 +1842,6 @@ F3 - - - 100 - 40 - True - True - False - False - - - True - False - 10 - 10 - 10 - 10 - 16 - - - True - False - Execute custom script when pomo pauses/starts - - - False - True - 0 - - - - - True - True - - - False - True - end - 1 - - - - - True - False - - - - False - True - end - 2 - - - - - - diff --git a/schemas/gschemas.compiled b/schemas/gschemas.compiled index ce9f624..b10847f 100644 Binary files a/schemas/gschemas.compiled and b/schemas/gschemas.compiled differ diff --git a/schemas/org.gnome.shell.extensions.timepp.gschema.xml b/schemas/org.gnome.shell.extensions.timepp.gschema.xml index 082de2f..b23008e 100644 --- a/schemas/org.gnome.shell.extensions.timepp.gschema.xml +++ b/schemas/org.gnome.shell.extensions.timepp.gschema.xml @@ -190,16 +190,6 @@ Stop time tracking when pomo is paused - - false - Execute custom script when pomo pauses/starts - - - - "" - Path to custom script - - Open this section diff --git a/sections/alarms.js b/sections/alarms.js index 47cacfa..15a77aa 100644 --- a/sections/alarms.js +++ b/sections/alarms.js @@ -104,13 +104,16 @@ var Alarms = new Lang.Class({ this.ext = ext; this.settings = settings; + this.section_enabled = this.settings.get_boolean('alarms-enabled'); this.separate_menu = this.settings.get_boolean('alarms-separate-menu'); this.cache_file = null; this.cache = null; - this.fullscreen = new AlarmFullscreen( - this.ext, this, this.settings.get_int('alarms-fullscreen-monitor-pos')); + + this.fullscreen = new AlarmFullscreen(this.ext, this, + this.settings.get_int('alarms-fullscreen-monitor-pos')); + this.sigm = new SIG_MANAGER.SignalManager(); this.keym = new KEY_MANAGER.KeybindingManager(this.settings); @@ -241,7 +244,7 @@ var Alarms = new Lang.Class({ this.alarms_scroll_content.destroy_all_children(); this._store_cache(); - this.sigm.disconnect_all(); + this.sigm.clear(); this.keym.disable_all(); if (this.fullscreen) { @@ -301,7 +304,7 @@ var Alarms = new Lang.Class({ alarm_editor: function (alarm_item) { let alarm_obj = alarm_item ? alarm_item.alarm : null; - let editor = new AlarmEditor(this.ext, alarm_obj); + let editor = new AlarmEditor(this.ext, this, alarm_obj); this.actor.insert_child_at_index(editor.actor, 0); editor.button_cancel.grab_key_focus(); @@ -446,16 +449,13 @@ var Alarms = new Lang.Class({ }, _send_notif: function (alarm) { - let sound_file = this.settings.get_string('alarms-sound-file-path') - - if (sound_file) { - try { - [sound_file, ] = GLib.filename_from_uri(sound_file, null); - } catch (e) { logError(e); } - } + if (this.settings.get_boolean('alarms-play-sound')) { + let sound_file = this.settings.get_string('alarms-sound-file-path'); - if (this.settings.get_boolean('alarms-play-sound') && sound_file) { - global.play_sound_file(0, sound_file, 'alarms-notif', null); + if (sound_file) { + [sound_file,] = GLib.filename_from_uri(sound_file, null); + global.play_sound_file(0, sound_file, '', null); + } } if (this.settings.get_enum('alarms-notif-style') === NotifStyle.FULLSCREEN) { @@ -510,8 +510,9 @@ Signals.addSignalMethods(Alarms.prototype); // ===================================================================== // @@@ Alarm Editor // -// @ext : obj (main ext object) -// @alarm : obj (alarm object) +// @ext : obj (main ext object) +// @delegate : obj (main section object) +// @alarm : obj (alarm object) // // @signals: 'add-alarm', 'edited-alarm', 'delete-alarm', 'cancel' // @@ -522,13 +523,15 @@ Signals.addSignalMethods(Alarms.prototype); const AlarmEditor = new Lang.Class({ Name: 'Timepp.AlarmEditor', - _init: function(ext, alarm) { + _init: function(ext, delegate, alarm) { + this.ext = ext; + this.delegate = delegate; + this.alarm = alarm; + + // // container // - this.ext = ext; - this.alarm = alarm; - this.actor = new St.Bin({ x_fill: true, style_class: 'view-box' }); this.content_box = new St.BoxLayout({ x_expand: true, vertical: true, style_class: 'view-box-content'}); @@ -555,8 +558,8 @@ const AlarmEditor = new Lang.Class({ if (alarm) { let [hr_str, min_str] = alarm.time_str.split(':'); - this.hh._set_counter(parseInt(hr_str)); - this.mm._set_counter(parseInt(min_str)); + this.hh.set_counter(parseInt(hr_str)); + this.mm.set_counter(parseInt(min_str)); } @@ -611,9 +614,9 @@ const AlarmEditor = new Lang.Class({ this.button_delete = new St.Button({ can_focus: true, label: _('Delete'), style_class: 'btn-delete button', x_expand: true }); btn_box.add(this.button_delete, {expand: true}); - this.button_delete.connect('clicked', Lang.bind(this, function () { + this.button_delete.connect('clicked', () => { this.emit('delete-alarm'); - })); + }); }; this.button_cancel = new St.Button({ can_focus: true, label: _('Cancel'), style_class: 'btn-cancel button', x_expand: true }); @@ -747,8 +750,8 @@ const AlarmItem = new Lang.Class({ // // listen // - this.toggle_bin.connect('clicked', () => { this._on_toggle(); }); - this.edit_bin.connect('clicked', () => { this._on_edit(); }); + this.toggle_bin.connect('clicked', () => this._on_toggle()); + this.delegate.sigm.connect_press(this.edit_bin, () => this._on_edit()); this.actor.connect('queue-redraw', () => { resize_label(this.msg); }); this.actor.connect('enter-event', () => { this.edit_bin.show(); }); this.actor.connect('event', (actor, event) => { @@ -804,9 +807,9 @@ Signals.addSignalMethods(AlarmItem.prototype); // ===================================================================== // @@@ Alarm fullscreen interface // -// @ext : ext class -// @show_secs : bool -// @monitor : int +// @ext : obj (main extension object) +// @delegate : obj (main section object) +// @monitor : int // // signals: 'monitor-changed' // ===================================================================== diff --git a/sections/pomodoro.js b/sections/pomodoro.js index 8f15e1b..5476bd1 100644 --- a/sections/pomodoro.js +++ b/sections/pomodoro.js @@ -1,21 +1,20 @@ -const St = imports.gi.St; -const Gio = imports.gi.Gio -const GLib = imports.gi.GLib; -const Meta = imports.gi.Meta; -const Shell = imports.gi.Shell; -const Clutter = imports.gi.Clutter; -const MessageTray = imports.ui.messageTray; -const Main = imports.ui.main; -const CheckBox = imports.ui.checkBox; -const PopupMenu = imports.ui.popupMenu; -const Util = imports.misc.util; -const Lang = imports.lang; -const Signals = imports.signals; -const Mainloop = imports.mainloop; -const ExtensionUtils = imports.misc.extensionUtils; - - -const ME = ExtensionUtils.getCurrentExtension(); +const St = imports.gi.St; +const Gio = imports.gi.Gio +const GLib = imports.gi.GLib; +const Meta = imports.gi.Meta; +const Shell = imports.gi.Shell; +const Clutter = imports.gi.Clutter; +const MessageTray = imports.ui.messageTray; +const Main = imports.ui.main; +const CheckBox = imports.ui.checkBox; +const PopupMenu = imports.ui.popupMenu; +const Util = imports.misc.util; +const Lang = imports.lang; +const Signals = imports.signals; +const Mainloop = imports.mainloop; + + +const ME = imports.misc.extensionUtils.getCurrentExtension(); const Gettext = imports.gettext.domain(ME.metadata['gettext-domain']); @@ -30,21 +29,26 @@ const PANEL_ITEM = ME.imports.lib.panel_item; const NUM_PICKER = ME.imports.lib.num_picker; +const IFACE = `${ME.path}/dbus/pomodoro_iface.xml`; + + const CACHE_FILE = GLib.get_home_dir() + '/.cache/timepp_gnome_shell_extension/timepp_pomodoro.json'; -const START_MSG = _('Start working!'); -const LONG_BREAK_MSG = _('Take long break!') -const SHORT_BREAK_MSG = _('Take short break!') + +const START_MSG = _('Work!'); +const LONG_BREAK_MSG = _('Long Break!') +const SHORT_BREAK_MSG = _('Short break!') const PomoState = { + STOPPED : 'STOPPED', POMO : 'POMO', - SHORT_BREAK : 'SHORT_BREAK', LONG_BREAK : 'LONG_BREAK', - STOPPED : 'STOPPED', + SHORT_BREAK : 'SHORT_BREAK', }; + const NotifStyle = { STANDARD : 0, FULLSCREEN : 1, @@ -64,17 +68,27 @@ var Pomodoro = new Lang.Class({ this.ext = ext; this.settings = settings; + + { + let [,xml,] = Gio.file_new_for_path(IFACE).load_contents(null); + xml = '' + xml; + this.dbus_impl = Gio.DBusExportedObject.wrapJSObject(xml, this); + } + + this.section_enabled = this.settings.get_boolean('pomodoro-enabled'); this.separate_menu = this.settings.get_boolean('pomodoro-separate-menu'); this.pomo_state = PomoState.STOPPED; - this.timer_duration = 0; // in microseconds - this.end_time = 0; // used for computing elapsed time + this.clock = 0; // seconds + this.end_time = 0; // for computing elapsed time (microseconds) this.tic_mainloop_id = null; this.cache_file = null; this.cache = null; - this.fullscreen = new PomodoroFullscreen( - this.ext, this, this.settings.get_int('pomodoro-fullscreen-monitor-pos')); + + this.fullscreen = new PomodoroFullscreen(this.ext, this, + this.settings.get_int('pomodoro-fullscreen-monitor-pos')); + this.sigm = new SIG_MANAGER.SignalManager(); this.keym = new KEY_MANAGER.KeybindingManager(this.settings); @@ -87,7 +101,7 @@ var Pomodoro = new Lang.Class({ this.ext.open_menu(this); }); this.keym.register('pomodoro-keybinding-open-fullscreen', () => { - this._show_fullscreen(); + this.show_fullscreen(); }); @@ -126,9 +140,9 @@ var Pomodoro = new Lang.Class({ this.header.actor.add_child(this.phase_label); - // counter - this.pomo_counter_display = new St.Label({ y_align: Clutter.ActorAlign.CENTER, style_class: 'pomo-counter' }); - this.header.actor.add_child(this.pomo_counter_display); + // clock + this.clock_label = new St.Label({ y_align: Clutter.ActorAlign.CENTER, style_class: 'pomo-counter' }); + this.header.actor.add_child(this.clock_label); // icons @@ -198,15 +212,15 @@ var Pomodoro = new Lang.Class({ this.ext.open_menu(this); }); - this.sigm.connect(this.panel_item, 'left-click', () => { this.ext.toggle_menu(this); }); - this.sigm.connect(this.panel_item, 'right-click', () => { this.ext.toggle_context_menu(this); }); - this.sigm.connect(this.panel_item, 'middle-click', Lang.bind(this, this.timer_toggle)); - this.sigm.connect(this.settings_btn, 'clicked', Lang.bind(this, this._show_settings)); - this.sigm.connect(this.fullscreen_btn, 'clicked', Lang.bind(this, this._show_fullscreen)); - this.sigm.connect(this.button_start, 'clicked', Lang.bind(this, this.start)); - this.sigm.connect(this.button_stop, 'clicked', Lang.bind(this, this.stop)); - this.sigm.connect(this.button_new_pomo, 'clicked', Lang.bind(this, this.start_new_pomo)); - this.sigm.connect(this.button_take_break, 'clicked', Lang.bind(this, this.take_break)); + this.sigm.connect(this.panel_item, 'left-click', () => this.ext.toggle_menu(this)); + this.sigm.connect(this.panel_item, 'right-click', () => this.ext.toggle_context_menu(this)); + this.sigm.connect(this.panel_item, 'middle-click', () => this.timer_toggle()); + this.sigm.connect_press(this.settings_btn, () => this._show_settings()); + this.sigm.connect_press(this.fullscreen_btn, () => this.show_fullscreen()); + this.sigm.connect_press(this.button_start, () => this.start_pomo()); + this.sigm.connect_press(this.button_stop, () => this.stop()); + this.sigm.connect_press(this.button_new_pomo, () => this.start_new_pomo()); + this.sigm.connect_press(this.button_take_break, () => this.take_break()); if (this.section_enabled) this.enable_section(); @@ -240,14 +254,10 @@ var Pomodoro = new Lang.Class({ }, disable_section: function () { - if (this.tic_mainloop_id) { - Mainloop.source_remove(this.tic_mainloop_id); - this.tic_mainloop_id = null; - } - + this.dbus_impl.unexport(); this.stop(); this._store_cache(); - this.sigm.disconnect_all(); + this.sigm.clear(); this.keym.disable_all(); if (this.fullscreen) { @@ -275,9 +285,9 @@ var Pomodoro = new Lang.Class({ this.cache = { format_version : cache_format_version, pomo_counter : 0, - pomo_duration : 1500000000, // microseconds - short_break : 300000000, - long_break : 900000000, + pomo_duration : 150, // seconds + short_break : 300, // seconds + long_break : 900, // seconds long_break_rate : 4, }; } @@ -287,14 +297,16 @@ var Pomodoro = new Lang.Class({ return; } - let count_str = String(this.cache.pomo_counter); - this.pomo_counter_display.text = this.cache.pomo_counter ? count_str : ''; - this.timer_duration = this.cache.pomo_duration; + let count_str = String(this.cache.pomo_counter); + this.clock_label.text = this.cache.pomo_counter ? count_str : ''; + this.clock = this.cache.pomo_duration; - if (! this.fullscreen) - this.fullscreen = new PomodoroFullscreen( - this.ext, this, this.settings.get_int('pomodoro-fullscreen-monitor-pos')); + if (! this.fullscreen) { + this.fullscreen = new PomodoroFullscreen(this.ext, this, + this.settings.get_int('pomodoro-fullscreen-monitor-pos')); + } + this.dbus_impl.export(Gio.DBus.session, '/timepp/zagortenay333/Pomodoro'); this.keym.enable_all(); this._update_time_display(); this.header.label.text = _('Pomodoro'); @@ -309,24 +321,22 @@ var Pomodoro = new Lang.Class({ }, _show_settings: function () { - let settings = new PomodoroSettings(this.cache); + let settings = new PomodoroSettings(this, this.cache); this.settings_container.add_actor(settings.actor); settings.button_cancel.grab_key_focus(); this.header.actor.hide(); this.btn_box_wrapper.actor.hide(); - settings.connect('ok', (_, clear_pomo_counter) => { - this._store_cache(); + settings.connect('ok', (_, res) => { + this.set_phase_durations( + res.pomo, res.short_break, res.long_break, res.break_rate); if (this.pomo_state === PomoState.STOPPED) - this.timer_duration = this.cache.pomo_duration; + this.clock = this.cache.pomo_duration; - if (clear_pomo_counter) { - this.cache.pomo_counter = 0; - this._store_cache(); - this.pomo_counter_display.text = ''; - } + if (res.clear_counter) + this.clear_pomo_counter(); this.btn_box_wrapper.actor.show(); this.button_box.grab_key_focus(); @@ -344,76 +354,61 @@ var Pomodoro = new Lang.Class({ }); }, - _show_fullscreen: function () { + show_fullscreen: function () { this.ext.menu.close(); - if (! this.fullscreen) - this.fullscreen = new PomodoroFullscreen( - this.ext, this, this.settings.get_int('pomodoro-fullscreen-monitor-pos')); + + if (! this.fullscreen) { + this.fullscreen = new PomodoroFullscreen(this.ext, this, + this.settings.get_int('pomodoro-fullscreen-monitor-pos')); + } + this.fullscreen.open(); }, - _maybe_stop_tracking: function () { - if (! this.settings.get_boolean('pomodoro-stop-tracking')) - return; + clear_pomo_counter: function () { + this.cache.pomo_counter = 0; + this.clock_label.text = ''; - this.emit('stop-time-tracking'); + this._store_cache(); }, - _maybe_exec_custom_script: function () { - if (! this.settings.get_boolean('pomodoro-exec-script')) - return; + // @pomo : int (seconds) + // @short_break : int (seconds) + // @long_break : int (seconds) + // @break_rate : int (num of pomos until long break) + set_phase_durations: function (pomo, short_break, long_break, break_rate) { + this.cache.pomo_duration = Math.max(1, pomo); + this.cache.short_break = Math.max(1, short_break); + this.cache.long_break = Math.max(1, long_break); + this.cache.long_break_rate = Math.max(1, break_rate); - try { - let script_path = this.settings.get_string('pomodoro-script-path'); - - if (script_path) { - [script_path, ] = GLib.filename_from_uri(script_path, null); - Util.spawnCommandLine(script_path + " " + this.pomo_state); - } - } - catch (e) { logError(e); } + this._store_cache(); }, - start: function () { - if (this.pomo_state !== PomoState.STOPPED) return; + _maybe_stop_tracking: function () { + if (! this.settings.get_boolean('pomodoro-stop-tracking')) + return; + + this.emit('stop-time-tracking'); + }, + stop: function () { if (this.tic_mainloop_id) { Mainloop.source_remove(this.tic_mainloop_id); this.tic_mainloop_id = null; } - this.pomo_state = PomoState.POMO; - - this.end_time = GLib.get_monotonic_time() + this.timer_duration; - - if (! this.fullscreen.is_open) - this.button_stop.grab_key_focus(); - - this._update_phase_label(); - this._update_buttons(); - this._update_panel_item(); - this.fullscreen.on_start(); - this._tic(); - this._maybe_exec_custom_script(); - }, - - stop: function () { if (this.pomo_state === PomoState.STOPPED) return; if (this.pomo_state !== PomoState.POMO) { - this.timer_duration = this.cache.pomo_duration; + this.clock = this.cache.pomo_duration; this.header.label.text = _('Pomodoro'); } - if (this.tic_mainloop_id) { - Mainloop.source_remove(this.tic_mainloop_id); - this.tic_mainloop_id = null; - } - this.pomo_state = PomoState.STOPPED; - if (! this.fullscreen.is_open) + if (!this.fullscreen.is_open && this.actor.visible) this.button_stop.grab_key_focus(); this.fullscreen.on_stop(); @@ -424,26 +419,40 @@ var Pomodoro = new Lang.Class({ if (this.settings.get_boolean('pomodoro-stop-tracking')) this.emit('stop-time-tracking'); - this._maybe_exec_custom_script(); + this.dbus_impl.emit_signal( + 'pomo_state_changed', GLib.Variant.new('(s)', [this.pomo_state])); + this._maybe_stop_tracking(); }, start_new_pomo: function () { - this.pomo_state = PomoState.POMO; + this.start_pomo(this.cache.pomo_duration); + }, + // @time: int (seconds) + start_pomo: function (time = this.clock) { if (this.tic_mainloop_id) { Mainloop.source_remove(this.tic_mainloop_id); this.tic_mainloop_id = null; } - this.timer_duration = this.cache.pomo_duration; - this.end_time = GLib.get_monotonic_time() + this.timer_duration; - this.fullscreen.on_new_pomo(); - this._update_phase_label(); - this._update_buttons(); + this.pomo_state = PomoState.POMO; + this.end_time = GLib.get_monotonic_time() + (time * 1000000); + this.clock = time; + + this.dbus_impl.emit_signal( + 'pomo_state_changed', GLib.Variant.new('(s)', [this.pomo_state])); + + this.fullscreen.on_start(); + this._update_time_display(); this._update_panel_item(); + this._update_buttons(); + this._update_phase_label(); + + if (!this.fullscreen.is_open && this.actor.visible) + this.button_stop.grab_key_focus(); + this._tic(); - this._maybe_exec_custom_script(); }, take_break: function () { @@ -455,35 +464,41 @@ var Pomodoro = new Lang.Class({ if (this.cache.pomo_counter && ((this.cache.pomo_counter % this.cache.long_break_rate) === 0)) { - this.pomo_state = PomoState.LONG_BREAK; - this.timer_duration = this.cache.long_break; + this.pomo_state = PomoState.LONG_BREAK; + this.clock = this.cache.long_break; } else { - this.pomo_state = PomoState.SHORT_BREAK; - this.timer_duration = this.cache.short_break; + this.pomo_state = PomoState.SHORT_BREAK; + this.clock = this.cache.short_break; } + this.end_time = GLib.get_monotonic_time() + (this.clock * 1000000); + this.fullscreen.on_break(); - this.end_time = GLib.get_monotonic_time() + this.timer_duration; - this._maybe_exec_custom_script(); - this._maybe_stop_tracking(); + this._update_time_display(); this._update_phase_label(); this._update_buttons(); this._update_panel_item(); - this._tic(); + this._maybe_stop_tracking(); + if (this.settings.get_boolean('pomodoro-stop-tracking')) this.emit('stop-time-tracking'); + + this.dbus_impl.emit_signal( + 'pomo_state_changed', GLib.Variant.new('(s)', [this.pomo_state])); + + this._tic(); }, timer_toggle: function () { if (this.pomo_state === PomoState.STOPPED) - this.start(); + this.start_pomo(); else this.stop(); }, _update_time_display: function () { - let time = Math.floor(this.timer_duration / 1000000); + let time = this.clock; // If the seconds are not shown, we need to make the timer '1-indexed' // with respect to minutes. I.e., 00:00:34 becomes 00:01. @@ -495,9 +510,7 @@ var Pomodoro = new Lang.Class({ ); } else { - if (this.timer_duration > 0 && - this.timer_duration !== this.cache.pomo_duration) { - + if (this.clock > 0 && this.clock !== this.cache.pomo_duration) { time += 60; } @@ -544,31 +557,36 @@ var Pomodoro = new Lang.Class({ _update_buttons: function () { switch (this.pomo_state) { case PomoState.POMO: - this.button_start.visible = false; - this.button_stop.visible = true; - this.button_take_break.visible = true; - this.button_new_pomo.visible = true; + this.button_start.visible = false; + this.button_stop.visible = true; + this.button_take_break.visible = true; + this.button_new_pomo.visible = true; + this.fullscreen.button_start.visible = false; this.fullscreen.button_stop.visible = true; this.fullscreen.button_take_break.visible = true; this.fullscreen.button_new_pomo.visible = true; break; + case PomoState.SHORT_BREAK: case PomoState.LONG_BREAK: - this.button_start.visible = false; - this.button_stop.visible = true; - this.button_take_break.visible = false; - this.button_new_pomo.visible = true; + this.button_start.visible = false; + this.button_stop.visible = true; + this.button_take_break.visible = false; + this.button_new_pomo.visible = true; + this.fullscreen.button_start.visible = false; this.fullscreen.button_stop.visible = true; this.fullscreen.button_take_break.visible = false; this.fullscreen.button_new_pomo.visible = true; break; + case PomoState.STOPPED: - this.button_start.visible = true; - this.button_stop.visible = false; - this.button_take_break.visible = false; - this.button_new_pomo.visible = false; + this.button_start.visible = true; + this.button_stop.visible = false; + this.button_take_break.visible = false; + this.button_new_pomo.visible = false; + this.fullscreen.button_start.visible = true; this.fullscreen.button_stop.visible = false; this.fullscreen.button_take_break.visible = false; @@ -587,14 +605,14 @@ var Pomodoro = new Lang.Class({ this.cache.pomo_counter += 1; this._store_cache(); this.take_break(); - this.pomo_counter_display.text = '' + this.cache.pomo_counter; + this.clock_label.text = '' + this.cache.pomo_counter; } this._send_notif(); }, _tic: function () { - if (this.timer_duration < 1000000) { + if (this.clock < 1) { this.tic_mainloop_id = null; this._timer_expired(); return; @@ -602,7 +620,8 @@ var Pomodoro = new Lang.Class({ this._update_time_display(); - this.timer_duration = this.end_time - GLib.get_monotonic_time(); + this.clock = + Math.floor((this.end_time - GLib.get_monotonic_time()) / 1000000); this.tic_mainloop_id = Mainloop.timeout_add_seconds(1, () => { this._tic(); @@ -619,16 +638,13 @@ var Pomodoro = new Lang.Class({ default: return; } - let sound_file = this.settings.get_string('pomodoro-sound-file-path'); - - if (sound_file) { - try { - [sound_file, ] = GLib.filename_from_uri(sound_file, null); - } catch (e) { logError(e); } - } + if (this.settings.get_boolean('pomodoro-play-sound')) { + let sound_file = this.settings.get_string('pomodoro-sound-file-path'); - if (this.settings.get_boolean('pomodoro-play-sound') && sound_file) { - global.play_sound_file(0, sound_file, 'pomodoro-notif', null); + if (sound_file) { + [sound_file,] = GLib.filename_from_uri(sound_file, null); + global.play_sound_file(0, sound_file, '', null); + } } if (this.settings.get_enum('pomodoro-notif-style') === NotifStyle.FULLSCREEN) { @@ -673,12 +689,17 @@ Signals.addSignalMethods(Pomodoro.prototype); // ===================================================================== // @@@ Pomodoro settings // +// @delegate : obj (main section object) +// @pomo_cache : obj (section cache object) +// // @signals: 'ok', 'cancel' // ===================================================================== const PomodoroSettings = new Lang.Class({ Name: 'Timepp.PomodoroSettings', - _init: function(pomo_cache) { + _init: function(delegate, pomo_cache) { + this.delegate = delegate; + this.actor = new St.BoxLayout({style_class: 'view-box'}); this.content_box = new St.BoxLayout({vertical: true, style_class: 'view-box-content'}); @@ -707,13 +728,17 @@ const PomodoroSettings = new Lang.Class({ this.pomo_duration = new St.BoxLayout({style_class: 'row'}); this.content_box.add_actor(this.pomo_duration); - this.pomo_label = new St.Label({text: _('Pomodoro (min):'), y_align: Clutter.ActorAlign.CENTER}); + this.pomo_label = new St.Label({text: _('Pomodoro (min:sec):'), y_align: Clutter.ActorAlign.CENTER}); this.pomo_duration.add(this.pomo_label, {expand: true}); - this.pomo_dur_mm_picker = new NUM_PICKER.NumPicker(1, null); - this.pomo_duration.add_actor(this.pomo_dur_mm_picker.actor); + this.pomo_dur_min_picker = new NUM_PICKER.NumPicker(0, null); + this.pomo_duration.add_actor(this.pomo_dur_min_picker.actor); + this.pomo_dur_min_picker.set_counter( + Math.floor(pomo_cache.pomo_duration / 60)); - this.pomo_dur_mm_picker._set_counter(Math.floor(pomo_cache.pomo_duration / 60000000)); + this.pomo_dur_sec_picker = new NUM_PICKER.NumPicker(1, null); + this.pomo_duration.add_actor(this.pomo_dur_sec_picker.actor); + this.pomo_dur_sec_picker.set_counter(pomo_cache.pomo_duration % 60); // @@ -722,13 +747,18 @@ const PomodoroSettings = new Lang.Class({ this.short_break = new St.BoxLayout({style_class: 'row'}); this.content_box.add_actor(this.short_break); - this.short_break_label = new St.Label({text: _('Short break (min):'), y_align: Clutter.ActorAlign.CENTER}); + this.short_break_label = new St.Label({text: _('Short break (min:sec):'), y_align: Clutter.ActorAlign.CENTER}); this.short_break.add(this.short_break_label, {expand: true}); - this.short_break_mm_picker = new NUM_PICKER.NumPicker(1, null); - this.short_break.add_actor(this.short_break_mm_picker.actor); + this.short_break_min_picker = new NUM_PICKER.NumPicker(0, null); + this.short_break.add_actor(this.short_break_min_picker.actor); + this.short_break_min_picker.set_counter( + Math.floor(pomo_cache.short_break / 60)); + + this.short_break_sec_picker = new NUM_PICKER.NumPicker(1, null); + this.short_break.add_actor(this.short_break_sec_picker.actor); + this.short_break_sec_picker.set_counter(pomo_cache.short_break % 60); - this.short_break_mm_picker._set_counter(Math.floor(pomo_cache.short_break / 60000000)); // @@ -737,13 +767,17 @@ const PomodoroSettings = new Lang.Class({ this.long_break = new St.BoxLayout({style_class: 'row'}); this.content_box.add_actor(this.long_break); - this.long_break_label = new St.Label({text: _('Long break (min):'), y_align: Clutter.ActorAlign.CENTER}); + this.long_break_label = new St.Label({text: _('Long break (min:sec):'), y_align: Clutter.ActorAlign.CENTER}); this.long_break.add(this.long_break_label, {expand: true}); - this.long_break_mm_picker = new NUM_PICKER.NumPicker(1, null); - this.long_break.add_actor(this.long_break_mm_picker.actor); + this.long_break_min_picker = new NUM_PICKER.NumPicker(0, null); + this.long_break.add_actor(this.long_break_min_picker.actor); + this.long_break_min_picker.set_counter( + Math.floor(pomo_cache.long_break / 60)); - this.long_break_mm_picker._set_counter(Math.floor(pomo_cache.long_break / 60000000)); + this.long_break_sec_picker = new NUM_PICKER.NumPicker(1, null); + this.long_break.add_actor(this.long_break_sec_picker.actor); + this.long_break_sec_picker.set_counter(pomo_cache.long_break % 60); // @@ -758,7 +792,7 @@ const PomodoroSettings = new Lang.Class({ this.long_break_rate_picker = new NUM_PICKER.NumPicker(1, null); this.long_break_rate.add_actor(this.long_break_rate_picker.actor); - this.long_break_rate_picker._set_counter(pomo_cache.long_break_rate); + this.long_break_rate_picker.set_counter(pomo_cache.long_break_rate); // @@ -778,14 +812,17 @@ const PomodoroSettings = new Lang.Class({ // listen // this.button_ok.connect('clicked', () => { - pomo_cache.pomo_duration = this.pomo_dur_mm_picker.counter * 60000000; - pomo_cache.short_break = this.short_break_mm_picker.counter * 60000000; - pomo_cache.long_break = this.long_break_mm_picker.counter * 60000000; - pomo_cache.long_break_rate = this.long_break_rate_picker.counter; - - this.emit('ok', this.clear_item_checkbox.actor.checked); + this.emit('ok', { + clear_counter : this.clear_item_checkbox.actor.checked, + break_rate : this.long_break_rate_picker.counter, + pomo : this.pomo_dur_min_picker.counter * 60 + + this.pomo_dur_sec_picker.counter, + short_break : this.short_break_min_picker.counter * 60 + + this.short_break_sec_picker.counter, + long_break : this.long_break_min_picker.counter * 60 + + this.long_break_sec_picker.counter, + }); }); - this.button_cancel.connect('clicked', () => { this.emit('cancel'); }); @@ -798,9 +835,9 @@ Signals.addSignalMethods(PomodoroSettings.prototype); // ===================================================================== // @@@ Pomodoro fullscreen // -// @ext : ext class -// @show_secs : bool -// @monitor : int +// @ext : obj (main extension object) +// @delegate : obj (main section object) +// @monitor : int // // signals: 'monitor-changed' // ===================================================================== diff --git a/sections/stopwatch.js b/sections/stopwatch.js index 8dcca06..67a7063 100644 --- a/sections/stopwatch.js +++ b/sections/stopwatch.js @@ -27,13 +27,16 @@ const KEY_MANAGER = ME.imports.lib.keybinding_manager; const PANEL_ITEM = ME.imports.lib.panel_item; +const IFACE = `${ME.path}/dbus/stopwatch_iface.xml`; + + const CACHE_FILE = GLib.get_home_dir() + '/.cache/timepp_gnome_shell_extension/timepp_stopwatch.json'; const StopwatchState = { RUNNING : 'RUNNING', - PAUSED : 'PAUSED', + STOPPED : 'STOPPED', RESET : 'RESET', }; @@ -62,18 +65,27 @@ var Stopwatch = new Lang.Class({ this.ext = ext; this.settings = settings; + + { + let [,xml,] = Gio.file_new_for_path(IFACE).load_contents(null); + xml = '' + xml; + this.dbus_impl = Gio.DBusExportedObject.wrapJSObject(xml, this); + } + + this.section_enabled = this.settings.get_boolean('stopwatch-enabled'); this.separate_menu = this.settings.get_boolean('stopwatch-separate-menu'); this.clock_format = this.settings.get_enum('stopwatch-clock-format'); - this.start_time = 0; // used for computing elapsed time - this.lap_count = 0; + this.start_time = 0; // for computing elapsed time (microseconds) this.cache_file = null; this.cache = null; this.tic_mainloop_id = null; this.time_backup_mainloop_id = null; - this.fullscreen = new StopwatchFullscreen( - this.ext, this, this.settings.get_int('stopwatch-fullscreen-monitor-pos')); + + this.fullscreen = new StopwatchFullscreen(this.ext, this, + this.settings.get_int('stopwatch-fullscreen-monitor-pos')); + this.sigm = new SIG_MANAGER.SignalManager(); this.keym = new KEY_MANAGER.KeybindingManager(this.settings); @@ -86,7 +98,7 @@ var Stopwatch = new Lang.Class({ this.ext.open_menu(this); }); this.keym.register('stopwatch-keybinding-open-fullscreen', () => { - this._show_fullscreen(); + this.show_fullscreen(); }); @@ -112,8 +124,8 @@ var Stopwatch = new Lang.Class({ this.fullscreen.set_banner_text('00:00:00') break; case ClockFormat.H_M_S_CS: - this.panel_item.set_label('00:00:00:00'); - this.fullscreen.set_banner_text('00:00:00:00') + this.panel_item.set_label('00:00:00.00'); + this.fullscreen.set_banner_text('00:00:00.00') break; } @@ -156,11 +168,11 @@ var Stopwatch = new Lang.Class({ this.button_reset = new St.Button({ can_focus: true, label: _('Reset'), style_class: 'btn-reset button', x_expand: true, visible: false }); this.button_lap = new St.Button({ can_focus: true, label: _('Lap'), style_class: 'btn-lap button', x_expand: true, visible: false }); this.button_start = new St.Button({ can_focus: true, label: _('Start'), style_class: 'btn-start button', x_expand: true }); - this.button_pause = new St.Button({ can_focus: true, label: _('Pause'), style_class: 'btn-stop button', x_expand: true, visible: false }); + this.button_stop = new St.Button({ can_focus: true, label: _('Stop'), style_class: 'btn-stop button', x_expand: true, visible: false }); this.stopwatch_button_box.add(this.button_reset, {expand: true}); this.stopwatch_button_box.add(this.button_lap, {expand: true}); this.stopwatch_button_box.add(this.button_start, {expand: true}); - this.stopwatch_button_box.add(this.button_pause, {expand: true}); + this.stopwatch_button_box.add(this.button_stop, {expand: true}); // @@ -211,14 +223,14 @@ var Stopwatch = new Lang.Class({ this.ext.open_menu(this); }); - this.sigm.connect(this.panel_item, 'left-click', () => { this.ext.toggle_menu(this); }); - this.sigm.connect(this.panel_item, 'right-click', () => { this.ext.toggle_context_menu(this); }); - this.sigm.connect(this.panel_item, 'middle-click', Lang.bind(this, this.stopwatch_toggle)); - this.sigm.connect(this.fullscreen_bin, 'clicked', Lang.bind(this, this._show_fullscreen)); - this.sigm.connect(this.button_start, 'clicked', () => { this.start(); }); - this.sigm.connect(this.button_reset, 'clicked', () => { this.reset(); }); - this.sigm.connect(this.button_pause, 'clicked', () => { this.pause(); }); - this.sigm.connect(this.button_lap, 'clicked', () => { this.add_lap(); }); + this.sigm.connect(this.panel_item, 'left-click', () => this.ext.toggle_menu(this)); + this.sigm.connect(this.panel_item, 'right-click', () => this.ext.toggle_context_menu(this)); + this.sigm.connect(this.panel_item, 'middle-click', () => this.stopwatch_toggle()); + this.sigm.connect_press(this.fullscreen_bin, () => this.show_fullscreen()); + this.sigm.connect_press(this.button_start, () => this.start()); + this.sigm.connect_press(this.button_reset, () => this.reset()); + this.sigm.connect_press(this.button_stop, () => this.stop()); + this.sigm.connect_press(this.button_lap, () => this.lap()); this.sigm.connect(this.laps_string, 'queue-redraw', () => { this.laps_scroll.vscrollbar_policy = Gtk.PolicyType.NEVER; if (ext.needs_scrollbar()) @@ -262,9 +274,10 @@ var Stopwatch = new Lang.Class({ this.time_backup_mainloop_id = null; } - if (this.cache.state === StopwatchState.RUNNING) this.pause(); + if (this.cache.state === StopwatchState.RUNNING) this.stop(); + this.dbus_impl.unexport(); this._store_cache(); - this.sigm.disconnect_all(); + this.sigm.clear(); this.keym.disable_all(); if (this.fullscreen) { @@ -292,7 +305,7 @@ var Stopwatch = new Lang.Class({ this.cache = { format_version : cache_format_version, state : StopwatchState.RESET, - time : 0, // in microseconds + time : 0, // miliseconds laps : [], }; } @@ -307,6 +320,7 @@ var Stopwatch = new Lang.Class({ this.ext, this, this.settings.get_int('stopwatch-fullscreen-monitor-pos')); } + this.dbus_impl.export(Gio.DBus.session, '/timepp/zagortenay333/Stopwatch'); this.sigm.connect_all(); this.keym.enable_all(); @@ -314,7 +328,6 @@ var Stopwatch = new Lang.Class({ if (this.cache.state === StopwatchState.RESET) return; - this.lap_count = this.cache.laps.length; this._update_laps(); this._update_time_display(); @@ -322,7 +335,7 @@ var Stopwatch = new Lang.Class({ if (this.cache.state === StopwatchState.RUNNING) this.start(); else - this.pause(); + this.stop(); }, _store_cache: function () { @@ -333,22 +346,23 @@ var Stopwatch = new Lang.Class({ null, false, Gio.FileCreateFlags.REPLACE_DESTINATION, null); }, - start: function (actor, event) { + start: function () { this.start_time = GLib.get_monotonic_time() - this.cache.time; - if (!this.fullscreen.is_open) - this.button_pause.grab_key_focus(); + if (!this.fullscreen.is_open && this.actor.visible) + this.button_stop.grab_key_focus(); this.cache.state = StopwatchState.RUNNING; this._store_cache(); this._toggle_buttons(); this._panel_item_UI_update(); this.fullscreen.on_timer_started(); - if (! this.tic_mainloop_id) this._tic(); if (! this.time_backup_mainloop_id) this._periodic_time_backup(); + + if (! this.tic_mainloop_id) this._tic(); }, - pause: function (actor, event) { + stop: function () { if (this.tic_mainloop_id) { Mainloop.source_remove(this.tic_mainloop_id); this.tic_mainloop_id = null; @@ -361,16 +375,16 @@ var Stopwatch = new Lang.Class({ this.fullscreen.on_timer_stopped(); - if (!this.fullscreen.is_open) + if (!this.fullscreen.is_open && this.actor.visible) this.button_start.grab_key_focus(); - this.cache.state = StopwatchState.PAUSED; + this.cache.state = StopwatchState.STOPPED; this._store_cache(); this._panel_item_UI_update(); this._toggle_buttons(); }, - reset: function (actor, event) { + reset: function () { if (this.tic_mainloop_id) { Mainloop.source_remove(this.tic_mainloop_id); this.tic_mainloop_id = null; @@ -383,14 +397,13 @@ var Stopwatch = new Lang.Class({ this.fullscreen.on_timer_reset(); - if (!this.fullscreen.is_open) + if (!this.fullscreen.is_open && this.actor.visible) this.button_start.grab_key_focus(); this.cache.state = StopwatchState.RESET; this.cache.laps = []; this.cache.time = 0; this._store_cache(); - this.lap_count = 0; this._update_time_display(); this._toggle_buttons(); this._panel_item_UI_update(); @@ -400,13 +413,15 @@ var Stopwatch = new Lang.Class({ stopwatch_toggle: function () { if (this.cache.state === StopwatchState.RUNNING) - this.pause(); + this.stop(); else this.start(); }, _tic: function () { - this.cache.time = GLib.get_monotonic_time() - this.start_time; + this.cache.time = + Math.floor((GLib.get_monotonic_time() - this.start_time) / 1000); + this._update_time_display(); if (this.clock_format === ClockFormat.H_M_S_CS) { @@ -428,13 +443,14 @@ var Stopwatch = new Lang.Class({ }, _time_format_str: function () { - let t = Math.floor(this.cache.time / 10000); - let cs = t % 100; - t = Math.floor(t / 100); - let h = Math.floor(t / 3600); - t = t % 3600; - let m = Math.floor(t / 60); - let s = t % 60; + let t = Math.floor(this.cache.time / 10); // centiseconds + + let cs = t % 100; + t = Math.floor(t / 100); + let h = Math.floor(t / 3600); + t = t % 3600; + let m = Math.floor(t / 60); + let s = t % 60; switch (this.clock_format) { case ClockFormat.H_M: @@ -442,7 +458,7 @@ var Stopwatch = new Lang.Class({ case ClockFormat.H_M_S: return "%02d:%02d:%02d".format(h, m, s); case ClockFormat.H_M_S_CS: - return "%02d:%02d:%02d:%02d".format(h, m, s, cs); + return "%02d:%02d:%02d.%02d".format(h, m, s, cs); } }, @@ -453,33 +469,32 @@ var Stopwatch = new Lang.Class({ this.panel_item.actor.remove_style_class_name('on'); }, - add_lap: function () { + lap: function () { if (this.cache.state !== StopwatchState.RUNNING) return; - this.lap_count++; this.cache.laps.push(this._time_format_str()); this._store_cache(); this._update_laps(); }, _update_laps: function () { - if (this.cache.laps.length === 0) return; + let n = this.cache.laps.length; - let pad = String(this.lap_count).length + 1; + if (n === 0) return; - let markup = ''+ 1 +' ' + - Array(pad - 1).join(' ') + - '- '+ this.cache.laps[0]; + let pad = String(n).length + 1; + let markup = ''; - for (let i = 1, len = this.cache.laps.length; i < len; i++) { - markup += '\n' + (i + 1) + ' ' + - Array(pad - String(i + 1).length).join(' ') + - '- ' + this.cache.laps[i]; + while (n--) { + markup += `${n + 1} ` + + Array(pad - String(n + 1).length).join(' ') + + `- ${this.cache.laps[n]}\n`; } - this.laps_string.clutter_text.set_markup('' + markup + ''); - this.fullscreen.laps_string.clutter_text.set_markup('' + markup + ''); + markup = `${markup.slice(0, -1)}`; + this.laps_string.clutter_text.set_markup(markup); + this.fullscreen.laps_string.clutter_text.set_markup(markup); this.laps_wrapper.actor.show(); this.fullscreen.laps_scroll.show(); }, @@ -495,13 +510,13 @@ var Stopwatch = new Lang.Class({ this.button_reset.hide(); this.button_lap.hide(); this.button_start.show(); - this.button_pause.hide(); + this.button_stop.hide(); this.button_start.add_style_pseudo_class('first-child'); this.button_start.add_style_pseudo_class('last-child'); this.fullscreen.button_reset.hide(); this.fullscreen.button_lap.hide(); this.fullscreen.button_start.show(); - this.fullscreen.button_pause.hide(); + this.fullscreen.button_stop.hide(); this.fullscreen.button_start.add_style_pseudo_class('first-child'); this.fullscreen.button_start.add_style_pseudo_class('last-child'); break; @@ -509,34 +524,37 @@ var Stopwatch = new Lang.Class({ this.button_reset.show(); this.button_lap.show(); this.button_start.hide(); - this.button_pause.show(); + this.button_stop.show(); this.fullscreen.button_reset.show(); this.fullscreen.button_lap.show(); this.fullscreen.button_start.hide(); - this.fullscreen.button_pause.show(); + this.fullscreen.button_stop.show(); break; - case StopwatchState.PAUSED: + case StopwatchState.STOPPED: this.button_reset.show(); this.button_lap.hide(); this.button_start.show(); - this.button_pause.hide(); + this.button_stop.hide(); this.button_start.remove_style_pseudo_class('first-child'); this.button_start.add_style_pseudo_class('last-child'); this.fullscreen.button_reset.show(); this.fullscreen.button_lap.hide(); this.fullscreen.button_start.show(); - this.fullscreen.button_pause.hide(); + this.fullscreen.button_stop.hide(); this.fullscreen.button_start.remove_style_pseudo_class('first-child'); this.fullscreen.button_start.add_style_pseudo_class('last-child'); break; } }, - _show_fullscreen: function () { + show_fullscreen: function () { this.ext.menu.close(); - if (! this.fullscreen) - this.fullscreen = new StopwatchFullscreen( - this.ext, this, this.settings.get_int('stopwatch-fullscreen-monitor-pos')); + + if (! this.fullscreen) { + this.fullscreen = new StopwatchFullscreen(this.ext, this, + this.settings.get_int('stopwatch-fullscreen-monitor-pos')); + } + this.fullscreen.open(); }, @@ -557,6 +575,11 @@ var Stopwatch = new Lang.Class({ else this.panel_item.set_mode('icon_text'); }, + + // returns int (miliseconds) + get_time: function () { + return this.cache.time; + }, }); Signals.addSignalMethods(Stopwatch.prototype); @@ -565,9 +588,9 @@ Signals.addSignalMethods(Stopwatch.prototype); // ===================================================================== // @@@ Stopwatch fullscreen interface // -// @ext : ext class -// @show_secs : bool -// @monitor : int +// @ext : obj (main extension object) +// @delegate : obj (main section object) +// @monitor : int // // signals: 'monitor-changed' // ===================================================================== @@ -609,12 +632,12 @@ const StopwatchFullscreen = new Lang.Class({ this.button_reset = new St.Button({ can_focus: true, label: _('Reset'), style_class: 'btn-reset button', visible: false }); this.button_lap = new St.Button({ can_focus: true, label: _('Lap'), style_class: 'btn-lap button', visible: false }); - this.button_pause = new St.Button({ can_focus: true, label: _('Pause'), style_class: 'btn-stop button', visible: false }); + this.button_stop = new St.Button({ can_focus: true, label: _('Stop'), style_class: 'btn-stop button', visible: false }); this.button_start = new St.Button({ can_focus: true, label: _('Start'), style_class: 'btn-start button' }); this.stopwatch_button_box.add_child(this.button_reset); this.stopwatch_button_box.add_child(this.button_lap); this.stopwatch_button_box.add_child(this.button_start); - this.stopwatch_button_box.add_child(this.button_pause); + this.stopwatch_button_box.add_child(this.button_stop); // @@ -628,12 +651,12 @@ const StopwatchFullscreen = new Lang.Class({ this.delegate.reset(); return Clutter.EVENT_STOP; }); - this.button_pause.connect('clicked', () => { - this.delegate.pause(); + this.button_stop.connect('clicked', () => { + this.delegate.stop(); return Clutter.EVENT_STOP; }); this.button_lap.connect('clicked', () => { - this.delegate.add_lap(); + this.delegate.lap(); return Clutter.EVENT_STOP; }); this.actor.connect('key-release-event', (_, event) => { @@ -645,7 +668,7 @@ const StopwatchFullscreen = new Lang.Class({ case Clutter.KEY_KP_Enter: case Clutter.KEY_ISO_Enter: case Clutter.Return: - this.delegate.add_lap(); + this.delegate.lap(); return Clutter.EVENT_STOP; case Clutter.KEY_r: case Clutter.KEY_BackSpace: @@ -669,7 +692,7 @@ const StopwatchFullscreen = new Lang.Class({ this.set_banner_text('00:00:00') break; case ClockFormat.H_M_S_CS: - this.set_banner_text('00:00:00:00') + this.set_banner_text('00:00:00.00') break; } } diff --git a/sections/timer.js b/sections/timer.js index 8498a59..f0b93be 100644 --- a/sections/timer.js +++ b/sections/timer.js @@ -32,10 +32,12 @@ const NUM_PICKER = ME.imports.lib.num_picker; const MULTIL_ENTRY = ME.imports.lib.multiline_entry; +const IFACE = `${ME.path}/dbus/timer_iface.xml`; + const CACHE_FILE = GLib.get_home_dir() + '/.cache/timepp_gnome_shell_extension/timepp_timer.json'; -const TIMER_MAX_DURATION = 86400000000; // 24 hours in microseconds +const TIMER_MAX_DURATION = 86400; // 24 hours in seconds const TIMER_EXPIRED_MSG = _('Timer Expired!'); @@ -64,21 +66,31 @@ var Timer = new Lang.Class({ this.ext = ext; this.settings = settings; + + { + let [,xml,] = Gio.file_new_for_path(IFACE).load_contents(null); + xml = '' + xml; + this.dbus_impl = Gio.DBusExportedObject.wrapJSObject(xml, this); + } + + this.section_enabled = this.settings.get_boolean('timer-enabled'); this.separate_menu = this.settings.get_boolean('timer-separate-menu'); this.timer_state = TimerState.OFF; - this.timer_duration = 0; // in microseconds - this.end_time = 0; // used for computing elapsed time + this.clock = 0; // in seconds + this.end_time = 0; // for computing elapsed time (microseconds) this.tic_mainloop_id = null; this.cache_file = null; this.cache = null; - this.fullscreen = new TimerFullscreen( - this.ext, this, this.settings.get_int('timer-fullscreen-monitor-pos')); + + this.fullscreen = new TimerFullscreen(this.ext, this, + this.settings.get_int('timer-fullscreen-monitor-pos')); this.fullscreen.set_banner_text( this.settings.get_boolean('timer-show-seconds') ? '00:00:00' : '00:00'); + this.sigm = new SIG_MANAGER.SignalManager(); this.keym = new KEY_MANAGER.KeybindingManager(this.settings); @@ -90,7 +102,7 @@ var Timer = new Lang.Class({ this.ext.open_menu(this); }); this.keym.register('timer-keybinding-open-fullscreen', () => { - this._show_fullscreen(); + this.show_fullscreen(); }); @@ -184,17 +196,14 @@ var Timer = new Lang.Class({ }); this.sigm.connect(this.panel_item, 'left-click', () => { this.ext.toggle_menu(this); }); this.sigm.connect(this.panel_item, 'right-click', () => { this.ext.toggle_context_menu(this); }); - this.sigm.connect(this.panel_item, 'middle-click', Lang.bind(this, this.toggle_timer)); - this.sigm.connect(this.toggle_bin, 'clicked', Lang.bind(this, this.toggle_timer)); - this.sigm.connect(this.fullscreen_bin, 'clicked', Lang.bind(this, this._show_fullscreen)); - this.sigm.connect(this.settings_bin, 'clicked', Lang.bind(this, this._show_settings)); - this.sigm.connect(this.slider, 'value-changed', Lang.bind(this, this.slider_changed)); - this.sigm.connect(this.slider, 'drag-end', Lang.bind(this, this.slider_released)); - this.sigm.connect(this.slider.actor, 'scroll-event', Lang.bind(this, this.slider_released)); - this.sigm.connect(this.slider_item.actor, 'button-press-event', Lang.bind(this, function(actor, event) { - this.slider.startDragging(event); - })); - + this.sigm.connect(this.panel_item, 'middle-click', () => this.toggle_timer()); + this.sigm.connect_press(this.toggle_bin, () => this.toggle_timer()); + this.sigm.connect_press(this.fullscreen_bin, () => this.show_fullscreen()); + this.sigm.connect_press(this.settings_bin, () => this._show_settings()); + this.sigm.connect(this.slider, 'value-changed', (slider, value) => this.slider_changed(slider, value)); + this.sigm.connect(this.slider, 'drag-end', () => this.slider_released()); + this.sigm.connect(this.slider.actor, 'scroll-event', () => this.slider_released()); + this.sigm.connect(this.slider_item.actor, 'button-press-event', (_, event) => this.slider.startDragging(event)); if (this.section_enabled) this.enable_section(); else this.sigm.disconnect_all(); @@ -227,9 +236,10 @@ var Timer = new Lang.Class({ }, disable_section: function () { - this.stop_timer(); + this.dbus_impl.unexport(); + this.stop(); this._store_cache(); - this.sigm.disconnect_all(); + this.sigm.clear(); this.keym.disable_all(); if (this.fullscreen) { @@ -257,7 +267,7 @@ var Timer = new Lang.Class({ this.cache = { format_version : cache_format_version, notif_msg : '', - last_manually_set_time : 30000000, + last_manually_set_time : 30, // in seconds }; } } @@ -270,6 +280,7 @@ var Timer = new Lang.Class({ this.fullscreen = new TimerFullscreen( this.ext, this, this.settings.get_int('timer-fullscreen-monitor-pos')); + this.dbus_impl.export(Gio.DBus.session, '/timepp/zagortenay333/Timer'); this.keym.enable_all(); }, @@ -282,35 +293,31 @@ var Timer = new Lang.Class({ }, toggle_timer: function () { - if (this.timer_state === TimerState.STOPPED) - this.start_timer(); - else if (this.timer_state === TimerState.RUNNING) - this.stop_timer(); - else - return; + if (this.timer_state === TimerState.STOPPED) this.start(); + else if (this.timer_state === TimerState.RUNNING) this.stop(); }, - start_timer: function (time) { + // @time: int (seconds) + start: function (time = 0) { if (this.tic_mainloop_id) { Mainloop.source_remove(this.tic_mainloop_id); this.tic_mainloop_id = null; } - this.timer_duration = time || this.timer_duration; - this.end_time = GLib.get_monotonic_time() + this.timer_duration; - this.timer_state = TimerState.RUNNING; + this.clock = Math.min(time, TIMER_MAX_DURATION) || this.clock; + this.end_time = GLib.get_monotonic_time() + (this.clock * 1000000); this._update_time_display(); - this._tic(); - this.fullscreen.on_timer_started(); this.toggle.setToggleState('checked'); this.toggle_bin.show(); this.panel_item.actor.add_style_class_name('on'); + + this._tic(); }, - stop_timer: function () { + stop: function () { if (this.tic_mainloop_id) { Mainloop.source_remove(this.tic_mainloop_id); this.tic_mainloop_id = null; @@ -322,12 +329,13 @@ var Timer = new Lang.Class({ this.panel_item.actor.remove_style_class_name('on'); }, - off_timer: function () { + reset: function () { if (this.tic_mainloop_id) { Mainloop.source_remove(this.tic_mainloop_id); this.tic_mainloop_id = null; } + this.slider.setValue(0); this.fullscreen.on_timer_off(); this.timer_state = TimerState.OFF; this.header.label.text = _('Timer'); @@ -336,22 +344,24 @@ var Timer = new Lang.Class({ }, _on_timer_expired: function () { - this.off_timer(); + this.reset(); this.fullscreen.on_timer_expired(); this._send_notif(); + this.dbus_impl.emit_signal('timer_expired', null); }, _tic: function () { this._update_slider(); this._update_time_display(); - if (this.timer_duration < 1000000) { - this.timer_duration = 0; + if (this.clock < 1) { + this.clock = 0; this._on_timer_expired(); return; } - this.timer_duration = this.end_time - GLib.get_monotonic_time(); + this.clock = + Math.floor((this.end_time - GLib.get_monotonic_time()) / 1000000) this.tic_mainloop_id = Mainloop.timeout_add_seconds(1, () => { this._tic(); @@ -359,7 +369,7 @@ var Timer = new Lang.Class({ }, _update_time_display: function () { - let time = Math.floor(this.timer_duration / 1000000); + let time = this.clock; // If the seconds are not shown, we need to make the timer '1-indexed' // in respect to minutes. I.e., 00:00:34 becomes 00:01. @@ -384,18 +394,18 @@ var Timer = new Lang.Class({ }, _update_slider: function () { - // Update slider based on the timer_duration. - // Use this when the timer_duration changes without using the slider. + // Update slider based on the clock. + // Use this when the clock changes without using the slider. // This function is the inverse of the function that is used to calc the - // timer_duration based on the slider. - let x = this.timer_duration / TIMER_MAX_DURATION; + // clock based on the slider. + let x = this.clock / TIMER_MAX_DURATION; let y = (Math.log(x * (Math.pow(2, 10) - 1) +1)) / Math.log(2) / 10; this.slider.setValue(y); this.fullscreen.slider.setValue(y); }, _update_time_display: function () { - let time = Math.floor(this.timer_duration / 1000000); + let time = this.clock; // If the seconds are not shown, we need to make the timer '1-indexed' // in respect to minutes. I.e., 00:00:34 becomes 00:01. @@ -420,18 +430,18 @@ var Timer = new Lang.Class({ }, slider_released: function () { - if (this.timer_duration < 1000000) { - this.off_timer(); + if (this.clock < 1) { + this.reset(); } else { - this.start_timer(); - this.cache.last_manually_set_time = this.timer_duration; + this.start(); + this.cache.last_manually_set_time = this.clock; this._store_cache(); } }, slider_changed: function (slider, value) { - this.stop_timer(); + this.stop(); if (value < 1) { // Make rate of change of the timer duration an exponential curve. @@ -455,28 +465,24 @@ var Timer = new Lang.Class({ else step = 3600; } - this.timer_duration = - Math.floor(y * TIMER_MAX_DURATION / step) * step; + this.clock = Math.floor(y * TIMER_MAX_DURATION / step) * step; this._update_time_display(); } else { // slider has been dragged past the limit - this.timer_duration = TIMER_MAX_DURATION; + this.clock = TIMER_MAX_DURATION; this._update_time_display(); } }, _send_notif: function () { - let sound_file = this.settings.get_string('timer-sound-file-path'); - - if (sound_file) { - try { - [sound_file, ] = GLib.filename_from_uri(sound_file, null); - } catch (e) { logError(e); } - } + if (this.settings.get_boolean('timer-play-sound')) { + let sound_file = this.settings.get_string('timer-sound-file-path'); - if (this.settings.get_boolean('timer-play-sound') && sound_file) { - global.play_sound_file(0, sound_file, 'timer-notif', null); + if (sound_file) { + [sound_file,] = GLib.filename_from_uri(sound_file, null); + global.play_sound_file(0, sound_file, '', null); + } } if (this.settings.get_enum('timer-notif-style') === NotifStyle.FULLSCREEN) { @@ -512,6 +518,7 @@ var Timer = new Lang.Class({ _show_settings: function () { let settings = new TimerSettings( this.ext, + this, this.settings.get_boolean('timer-show-seconds'), this.cache.notif_msg ); @@ -528,12 +535,11 @@ var Timer = new Lang.Class({ this.header.actor.show(); this.slider_item.actor.show(); - this.cache.notif_msg = notif_msg; - this._store_cache(); + this.set_notif_msg(notif_msg); if (time) { - this.timer_duration = time; - this.start_timer(); + this.clock = time; + this.start(); this._update_slider(); this.cache.last_manually_set_time = time; this._store_cache(); @@ -548,7 +554,12 @@ var Timer = new Lang.Class({ }); }, - _show_fullscreen: function () { + set_notif_msg: function (msg) { + this.cache.notif_msg = msg; + this._store_cache(); + }, + + show_fullscreen: function () { this.ext.menu.close(); if (! this.fullscreen) { @@ -575,7 +586,8 @@ Signals.addSignalMethods(Timer.prototype); // ===================================================================== // @@@ Settings window // -// @ext : ext class +// @ext : obj (main extension object) +// @delegate : obj (main section object) // @show_secs : bool // @notif_msg : string // @@ -584,7 +596,10 @@ Signals.addSignalMethods(Timer.prototype); const TimerSettings = new Lang.Class({ Name: 'Timepp.TimerSettings', - _init: function(ext, show_secs, notif_msg) { + _init: function(ext, delegate, show_secs, notif_msg) { + this.ext = ext; + this.delegate = delegate; + this.actor = new St.Bin({ x_fill: true, style_class: 'view-box' }); this.content_box = new St.BoxLayout({ x_expand: true, vertical: true, style_class: 'view-box-content' }); @@ -667,11 +682,11 @@ const TimerSettings = new Lang.Class({ }, _get_time: function () { - let hr = this.hr.counter * 3600; + let h = this.hr.counter * 3600; let min = this.min.counter * 60; let sec = this.sec ? this.sec.counter : 0; - return (hr + min + sec) * 1000000; + return h + min + sec; }, }); Signals.addSignalMethods(TimerSettings.prototype); @@ -681,9 +696,9 @@ Signals.addSignalMethods(TimerSettings.prototype); // ===================================================================== // @@@ Timer fullscreen interface // -// @ext : ext class -// @show_secs : bool -// @monitor : int +// @ext : obj (main extension object) +// @delegate : obj (main section object) +// @monitor : int // // signals: 'monitor-changed' // ===================================================================== @@ -742,37 +757,37 @@ const TimerFullscreen = new Lang.Class({ return Clutter.EVENT_STOP; case Clutter.KEY_r: case Clutter.KEY_BackSpace: - this.delegate.start_timer(this.delegate.cache.last_manually_set_time); + this.delegate.start(this.delegate.cache.last_manually_set_time); return Clutter.EVENT_STOP; case Clutter.KEY_1: - this.delegate.start_timer(60000000); + this.delegate.start(60); return Clutter.EVENT_STOP; case Clutter.KEY_2: - this.delegate.start_timer(2 * 60000000); + this.delegate.start(2 * 60); return Clutter.EVENT_STOP; case Clutter.KEY_3: - this.delegate.start_timer(3 * 60000000); + this.delegate.start(3 * 60); return Clutter.EVENT_STOP; case Clutter.KEY_4: - this.delegate.start_timer(4 * 60000000); + this.delegate.start(4 * 60); return Clutter.EVENT_STOP; case Clutter.KEY_5: - this.delegate.start_timer(5 * 60000000); + this.delegate.start(5 * 60); return Clutter.EVENT_STOP; case Clutter.KEY_6: - this.delegate.start_timer(6 * 60000000); + this.delegate.start(6 * 60); return Clutter.EVENT_STOP; case Clutter.KEY_7: - this.delegate.start_timer(7 * 60000000); + this.delegate.start(7 * 60); return Clutter.EVENT_STOP; case Clutter.KEY_8: - this.delegate.start_timer(8 * 60000000); + this.delegate.start(8 * 60); return Clutter.EVENT_STOP; case Clutter.KEY_9: - this.delegate.start_timer(9 * 60000000); + this.delegate.start(9 * 60); return Clutter.EVENT_STOP; case Clutter.KEY_0: - this.delegate.start_timer(10 * 60000000); + this.delegate.start(10 * 60); return Clutter.EVENT_STOP; default: return Clutter.EVENT_PROPAGATE; diff --git a/sections/todo/MAIN.js b/sections/todo/MAIN.js index 5ec1910..498af39 100644 --- a/sections/todo/MAIN.js +++ b/sections/todo/MAIN.js @@ -61,6 +61,7 @@ var Todo = new Lang.Class({ this.section_enabled = this.settings.get_boolean('todo-enabled'); this.separate_menu = this.settings.get_boolean('todo-separate-menu'); + this.cache_file = null; this.cache = null; this.sigm = new SIG_MANAGER.SignalManager(); @@ -406,17 +407,17 @@ var Todo = new Lang.Class({ this.ext.open_menu(this); }); - this.sigm.connect(this.panel_item, 'left-click', () => { this.ext.toggle_menu(this); }); - this.sigm.connect(this.panel_item, 'right-click', () => { this.ext.toggle_context_menu(this); }); - this.sigm.connect(this.add_task_button, 'clicked', () => { this.show_view__task_editor(); }); - this.sigm.connect(this.filter_button, 'clicked', () => { this.show_view__filters(); }); - this.sigm.connect(this.sort_button, 'clicked', () => { this.show_view__sort(); }); - this.sigm.connect(this.file_switcher_button, 'clicked', () => { this.show_view__file_switcher(); }); - this.sigm.connect(this.search_button, 'clicked', () => { this.show_view__search(); }); - this.sigm.connect(this.stats_button, 'clicked', () => { this.show_view__time_tracker_stats(); }); - this.sigm.connect(this.clear_button, 'clicked', () => { this.show_view__clear_completed(); }); - this.sigm.connect(this.search_entry, 'secondary-icon-clicked', () => { this.show_view__default(); }); - this.sigm.connect(this.actor, 'style-changed', () => { this._update_markup_colors(); }); + this.sigm.connect(this.panel_item, 'left-click', () => this.ext.toggle_menu(this)); + this.sigm.connect(this.panel_item, 'right-click', () => this.ext.toggle_context_menu(this)); + this.sigm.connect_press(this.add_task_button, () => this.show_view__task_editor()); + this.sigm.connect_press(this.filter_button, () => this.show_view__filters()); + this.sigm.connect_press(this.sort_button, () => this.show_view__sort()); + this.sigm.connect_press(this.file_switcher_button, () => this.show_view__file_switcher()); + this.sigm.connect_press(this.search_button, () => this.show_view__search()); + this.sigm.connect_press(this.stats_button, () => this.show_view__time_tracker_stats()); + this.sigm.connect_press(this.clear_button, () => this.show_view__clear_completed()); + this.sigm.connect(this.search_entry, 'secondary-icon-clicked', () => this.show_view__default()); + this.sigm.connect(this.actor, 'style-changed', () => this._update_markup_colors()); this.sigm.connect(this.search_entry.clutter_text, 'text-changed', () => { Mainloop.idle_add(() => this._search()); }); @@ -511,7 +512,7 @@ var Todo = new Lang.Class({ }, disable_section: function () { - this.sigm.disconnect_all(); + this.sigm.clear(); this.keym.disable_all(); this.tasks = []; this.tasks_viewport = []; diff --git a/sections/todo/task_item.js b/sections/todo/task_item.js index f5f8c02..4928107 100644 --- a/sections/todo/task_item.js +++ b/sections/todo/task_item.js @@ -705,38 +705,19 @@ var TaskItem = new Lang.Class({ // listen - this.stat_icon_bin.connect('button-press-event', () => { + this.delegate.sigm.connect_press(this.stat_icon_bin, () => { this.delegate.show_view__time_tracker_stats(this); Mainloop.idle_add(() => { this._hide_header_icons(); }); return Clutter.EVENT_STOP; }); - this.stat_icon_bin.connect('key-press-event', (_, event) => { - if (event.get_key_symbol() === Clutter.Return) { - this.delegate.show_view__time_tracker_stats(this); - Mainloop.idle_add(() => { this._hide_header_icons(); }); - return Clutter.EVENT_STOP; - } - }); - this.edit_icon_bin.connect('button-press-event', () => { + this.delegate.sigm.connect_press(this.edit_icon_bin, () => { this.delegate.show_view__task_editor(this); Mainloop.idle_add(() => { this._hide_header_icons(); }); }); - this.edit_icon_bin.connect('key-press-event', (_, event) => { - if (event.get_key_symbol() === Clutter.Return) { - this.delegate.show_view__task_editor(this); - Mainloop.idle_add(() => { this._hide_header_icons(); }); - } - }); - this.tracker_icon_bin.connect('button-press-event', () => { + this.delegate.sigm.connect_press(this.tracker_icon_bin, () => { this.delegate.time_tracker.toggle_tracking(this); return Clutter.EVENT_STOP; }); - this.tracker_icon_bin.connect('key-press-event', (_, event) => { - if (event.get_key_symbol() === Clutter.Return) { - this.delegate.time_tracker.toggle_tracking(this); - return Clutter.EVENT_STOP; - } - }); } // diff --git a/sections/todo/time_tracker.js b/sections/todo/time_tracker.js index b016dc2..fe84dc3 100644 --- a/sections/todo/time_tracker.js +++ b/sections/todo/time_tracker.js @@ -16,24 +16,11 @@ const _ = Gettext.gettext; const ngettext = Gettext.ngettext; -const G = ME.imports.sections.todo.GLOBAL; +const IFACE = `${ME.path}/dbus/time_tracker_iface.xml`; + +const G = ME.imports.sections.todo.GLOBAL; -const TIME_TRACKER_DBUS_IFACE = - ' \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - '; // ===================================================================== @@ -49,24 +36,34 @@ var TimeTracker = new Lang.Class({ this.ext = ext; this.delegate = delegate; - this.dbus_impl = Gio.DBusExportedObject.wrapJSObject(TIME_TRACKER_DBUS_IFACE, this); - this.dbus_impl.export(Gio.DBus.session, '/timepp/zagortenay333/TimeTracker'); - this.csv_dir = delegate.settings.get_value('todo-current') - .deep_unpack().csv_dir; + { + let [,xml,] = Gio.file_new_for_path(IFACE).load_contents(null); + xml = '' + xml; + this.dbus_impl = Gio.DBusExportedObject.wrapJSObject(xml, this); + this.dbus_impl.export(Gio.DBus.session, '/timepp/zagortenay333/TimeTracker'); + } + + + + this.csv_dir = + delegate.settings.get_value('todo-current').deep_unpack().csv_dir; if (this.csv_dir) { [this.csv_dir, ] = GLib.filename_from_uri(this.csv_dir, null); } + this.number_of_tracked_tasks = 0; this.tracker_tic_id = null; + // GFiles this.yearly_csv_dir = null; this.yearly_csv_file = null; this.daily_csv_file = null; + // GFileMonitors this.yearly_csv_dir_monitor = null; this.yearly_csv_file_monitor = null; @@ -74,6 +71,7 @@ var TimeTracker = new Lang.Class({ this.daily_csv_file_monitor_handler_block = false; + // The stats data is cached with the exception of today's stats which // get appended. this.stats_data = new Map();