Skip to content

Commit

Permalink
Merge e840a33 into 5cde1f4
Browse files Browse the repository at this point in the history
  • Loading branch information
StephaneMangin committed Sep 8, 2023
2 parents 5cde1f4 + e840a33 commit 52b8673
Show file tree
Hide file tree
Showing 16 changed files with 339 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ Changelog
- Grouped task entries can now be sorted by start date, name, duration or
according to tasks.txt order (GH: #228).

- Grouped task entries can now be sorted by start date, name, duration or
according to tasks.txt order (GH: #228).

- Add time rounding option in minutes (GH: #237)
(max: 240 minutes, except for start entries `***`).


0.11.3 (2019-04-23)
~~~~~~~~~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def parse_and_sort_unicode_piecemeal():

@mark
def full():
return TimeLog(Settings().get_timelog_file(), Settings().virtual_midnight).items
return TimeLog(Settings().get_timelog_file(), Settings().virtual_midnight, Settings().rounding_time).items


def main():
Expand Down
3 changes: 2 additions & 1 deletion scripts/export-my-calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
if os.path.exists(settings_file):
settings.load(settings_file)
timelog = gtimelog.TimeLog(settings.get_timelog_file(),
settings.virtual_midnight)
settings.virtual_midnight,
settings.rounding_time)
window = timelog.window_for(d1, d2)
window.icalendar(open(outputfile, 'w'))
Binary file modified src/gtimelog/data/gschemas.compiled
Binary file not shown.
13 changes: 13 additions & 0 deletions src/gtimelog/data/org.gtimelog.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,19 @@
<description>Hour and minute that say when a work day ends and another begins.</description>
</key>

<key name="rounding-time" type="i">
<default>0</default>
<summary>Rounding Time</summary>
<description>Rounding time in minutes to round the time recorded.</description>
<range min="0" max="65535" />
</key>

<key name="rounding-time-force-above" type="b">
<default>false</default>
<summary>Rounding Time Force Above</summary>
<description>Force the rounding up if rounding is less than current time.</description>
</key>

<key name="name" type="s">
<default>"Anonymous"</default>
<summary>Name</summary>
Expand Down
32 changes: 31 additions & 1 deletion src/gtimelog/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,8 @@ def load_settings(self):
self.gsettings.connect('changed::task-list-edit-url', self.update_edit_tasks_availability)
self.gsettings.connect('changed::virtual-midnight', self.virtual_midnight_changed)
self.update_edit_tasks_availability()
self.gsettings.bind('rounding-time', self.log_view, 'rounding-time', Gio.SettingsBindFlags.DEFAULT)
self.gsettings.bind('rounding-time-force-above', self.log_view, 'rounding-time-force-above', Gio.SettingsBindFlags.DEFAULT)

x, y = self.gsettings.get_value('window-position')
w, h = self.gsettings.get_value('window-size')
Expand Down Expand Up @@ -682,6 +684,8 @@ def load_settings(self):
self.gsettings.set_string('task-list-edit-url', arg)
vm = old_settings.virtual_midnight
self.gsettings.set_value('virtual-midnight', GLib.Variant('(ii)', (vm.hour, vm.minute)))
self.gsettings.set_int('rounding-time', old_settings.rounding_time)
self.gsettings.set_boolean('rounding-time-force-above', old_settings.rounding_time_force_above)
self.gsettings.set_boolean('gtk-completion', bool(old_settings.enable_gtk_completion))
self.gsettings.set_boolean('settings-migrated', True)
if loaded_files:
Expand All @@ -691,7 +695,7 @@ def load_settings(self):

def load_log(self):
mark_time("loading timelog")
timelog = TimeLog(Settings().get_timelog_file(), self.get_virtual_midnight())
timelog = TimeLog(Settings().get_timelog_file(), self.get_virtual_midnight(), self.get_rounding_time(), self.get_rounding_time_force_above())
mark_time("timelog loaded")
self.timelog = timelog
self.tick(True)
Expand Down Expand Up @@ -886,6 +890,14 @@ def get_virtual_midnight(self):
h, m = self.gsettings.get_value('virtual-midnight')
return datetime.time(h, m)

def get_rounding_time(self):
value = self.gsettings.get_int('rounding-time')
return value

def get_rounding_time_force_above(self):
value = self.gsettings.get_boolean('rounding-time-force-above')
return value

def get_today(self):
return virtual_day(datetime.datetime.now(), self.get_virtual_midnight())

Expand Down Expand Up @@ -1354,6 +1366,14 @@ class LogView(Gtk.TextView):
type=float, default=0, nick='Office Hours',
blurb='Target number of office hours per day')

rounding_time = GObject.Property(
type=int, default=0, nick='Rounding Time',
blurb='Round time using this value')

rounding_time_force_above = GObject.Property(
type=bool, default=False, nick='Rounding Time Force Above',
blurb='Force rounding up')

current_task = GObject.Property(
type=str, nick='Current task',
blurb='Current task in progress')
Expand Down Expand Up @@ -1386,6 +1406,8 @@ def __init__(self):
self.connect('notify::log-order', self.queue_update)
self.connect('notify::hours', self.queue_footer_update)
self.connect('notify::office-hours', self.queue_footer_update)
self.connect('notify::rounding-time', self.queue_footer_update)
self.connect('notify::rounding-time-force-above', self.queue_footer_update)
self.connect('notify::current-task', self.queue_footer_update)
self.connect('notify::now', self.queue_footer_update)
self.connect('notify::filter-text', self.queue_update)
Expand Down Expand Up @@ -1899,6 +1921,12 @@ def __init__(self, transient_for, page=None):
virtual_midnight_entry = builder.get_object('virtual_midnight_entry')
self.virtual_midnight_entry = virtual_midnight_entry

rounding_time_entry = builder.get_object('rounding_time_entry')
self.rounding_time_entry = rounding_time_entry

rounding_time_force_above_entry = builder.get_object('rounding_time_force_above_entry')
self.rounding_time_force_above_entry = rounding_time_force_above_entry

hours_entry = builder.get_object('hours_entry')
office_hours_entry = builder.get_object('office_hours_entry')
name_entry = builder.get_object('name_entry')
Expand All @@ -1921,6 +1949,8 @@ def __init__(self, transient_for, page=None):
self.gsettings.connect('changed::virtual-midnight', self.virtual_midnight_changed)
self.virtual_midnight_changed()
self.virtual_midnight_entry.connect('focus-out-event', self.virtual_midnight_set)
self.gsettings.bind('rounding-time', rounding_time_entry, 'value', Gio.SettingsBindFlags.DEFAULT)
self.gsettings.bind('rounding-time-force-above', rounding_time_force_above_entry, 'active', Gio.SettingsBindFlags.DEFAULT)
self.gsettings.bind('mail-protocol', protocol_combo, 'active-id', Gio.SettingsBindFlags.DEFAULT)
self.gsettings.bind('smtp-server', server_entry, 'text', Gio.SettingsBindFlags.DEFAULT)
self.gsettings.connect('changed::smtp-port', self.smtp_port_changed)
Expand Down
6 changes: 6 additions & 0 deletions src/gtimelog/po/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,12 @@ msgstr ""
msgid "Virtual midnight"
msgstr ""

msgid "Rounding Time (minutes)"
msgstr ""

msgid "(Force rounding up)"
msgstr ""

msgid "Goals"
msgstr ""

Expand Down
6 changes: 6 additions & 0 deletions src/gtimelog/po/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,12 @@ msgstr "Entrée des données"
msgid "Virtual midnight"
msgstr "Minuit virtuel"

msgid "Rounding Time (minutes)"
msgstr "Arrondir le temps (minutes)"

msgid "(Force rounding up)"
msgstr "(au supérieur)"

msgid "Goals"
msgstr "Objectifs"

Expand Down
6 changes: 6 additions & 0 deletions src/gtimelog/po/gtimelog.pot
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,12 @@ msgstr ""
msgid "Virtual midnight"
msgstr ""

msgid "Rounding Time (minutes)"
msgstr ""

msgid "(Force rounding up)"
msgstr ""

msgid "Goals"
msgstr ""

Expand Down
6 changes: 6 additions & 0 deletions src/gtimelog/po/lt.po
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,12 @@ msgstr "Duomenų įvedimas"
msgid "Virtual midnight"
msgstr "Virtualus vidurnaktis"

msgid "Rounding Time (minutes)"
msgstr ""

msgid "(Force rounding up)"
msgstr ""

msgid "Goals"
msgstr "Tikslai"

Expand Down
6 changes: 6 additions & 0 deletions src/gtimelog/po/nb.po
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,12 @@ msgstr "Data oppføring"
msgid "Virtual midnight"
msgstr "Virtuell midnatt"

msgid "Rounding Time (minutes)"
msgstr ""

msgid "(Force rounding up)"
msgstr ""

msgid "Goals"
msgstr "Mål"

Expand Down
6 changes: 6 additions & 0 deletions src/gtimelog/po/nl.po
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,12 @@ msgstr "Gegevensinvoer"
msgid "Virtual midnight"
msgstr "Virtuele middernacht"

msgid "Rounding Time (minutes)"
msgstr ""

msgid "(Force rounding up)"
msgstr ""

msgid "Goals"
msgstr "Doelen"

Expand Down
48 changes: 48 additions & 0 deletions src/gtimelog/preferences.ui
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
<property name="step_increment">0.5</property>
<property name="page_increment">1</property>
</object>
<object class="GtkAdjustment" id="rounding_time_adjustment">
<property name="upper">240</property>
<property name="step_increment">5</property>
<property name="page_increment">0</property>
</object>
<object class="GtkStack" id="dialog_stack">
<property name="visible">True</property>
<property name="can_focus">False</property>
Expand Down Expand Up @@ -82,6 +87,48 @@
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="rounding_time_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Rounding Time (minutes)</property>
<property name="xalign">1</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="rounding_time_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="numeric">1</property>
<property name="width_chars">5</property>
<property name="max_width_chars">5</property>
<property name="text">0</property>
<property name="xalign">1</property>
<property name="adjustment">rounding_time_adjustment</property>
<property name="activates_default">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="rounding_time_force_above_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">(Force rounding up)</property>
<property name="xalign">1</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">1</property>
</packing>
</child>
</object>
<packing>
Expand Down Expand Up @@ -547,6 +594,7 @@
<property name="mode">GTK_SIZE_GROUP_HORIZONTAL</property>
<widgets>
<widget name="virtual_midnight_label"/>
<widget name="rounding_time_label"/>
<widget name="hours_label"/>
<widget name="office_hours_label"/>
</widgets>
Expand Down
6 changes: 6 additions & 0 deletions src/gtimelog/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class Settings(object):
hours = 8
office_hours = 9
virtual_midnight = datetime.time(2, 0)
rounding_time = 0
rounding_time_force_above = False

task_list_url = ''
edit_task_list_cmd = ''
Expand Down Expand Up @@ -106,6 +108,8 @@ def _config(self):
config.set('gtimelog', 'office-hours', str(self.office_hours))
config.set('gtimelog', 'virtual_midnight',
self.virtual_midnight.strftime('%H:%M'))
config.set('gtimelog', 'rounding_time', str(self.rounding_time))
config.set('gtimelog', 'rounding_time_force_above', str(self.rounding_time_force_above))
config.set('gtimelog', 'task_list_url', self.task_list_url)
config.set('gtimelog', 'edit_task_list_cmd', self.edit_task_list_cmd)
config.set('gtimelog', 'show_office_hours',
Expand Down Expand Up @@ -137,6 +141,8 @@ def load(self, filename=None):
self.office_hours = config.getfloat('gtimelog', 'office-hours')
self.virtual_midnight = parse_time(config.get('gtimelog',
'virtual_midnight'))
self.rounding_time = config.getint('gtimelog', 'rounding_time')
self.rounding_time_force_above = config.getboolean('gtimelog', 'rounding_time_force_above')
self.task_list_url = config.get('gtimelog', 'task_list_url')
self.edit_task_list_cmd = config.get('gtimelog', 'edit_task_list_cmd')
self.show_office_hours = config.getboolean('gtimelog',
Expand Down

0 comments on commit 52b8673

Please sign in to comment.