Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to GSettings #470

Merged
merged 21 commits into from
Dec 24, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pgrep -af hamster
###### Ubuntu (tested in 19.04 and 18.04)

```bash
sudo apt install gettext intltool gconf2 gir1.2-gconf-2.0 python3-gi-cairo python3-distutils python3-dbus python3-xdg
sudo apt install gettext intltool python3-gi-cairo python3-distutils python3-dbus python3-xdg
# and for documentation
sudo apt install gnome-doc-utils yelp
```
Expand All @@ -70,7 +70,7 @@ sudo zypper install gnome-doc-utils xml2po yelp

*RPM-based instructions below should be updated for python3 (issue [#369](https://github.com/projecthamster/hamster/issues/369)).*

`yum install gettext intltool gnome-python2-gconf dbus-python`
`yum install gettext intltool dbus-python`

If the hamster help pages are not accessible ("unable to open `help:hamster-time-tracker`"),
then a [Mallard](https://en.wikipedia.org/wiki/Mallard_(documentation))-capable help reader is required,
Expand Down
104 changes: 104 additions & 0 deletions data/apps.hamster-time-tracker.gschema.xml.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<schemalist>
<schema path="/apps/hamster-time-tracker/" id="apps.HamsterTimeTracker">
<key type="b" name="enable-timeout">
<default>true</default>
<summary>Stop tracking on idle</summary>
<description>
Stop tracking current activity when computer becomes idle
</description>
</key>

<key type="b" name="stop-on-shutdown">
<default>false</default>
<summary>Stop tracking on shutdown</summary>
<description>
Stop tracking current activity on shutdown
</description>
</key>

<key type="u" name="notify-interval">
<default>27</default>
<summary>Remind of current task every x minutes</summary>
<description>
Remind of current task every specified amount of minutes.
Set to 0 or greater than 120 to disable reminder.
</description>
</key>

<key type="b" name="notify-on-idle">
<default>false</default>
<summary>Also remind when no activity is set</summary>
<description>
Also remind every notify_interval minutes if no activity
has been started.
</description>
</key>

<key type="s" name="last-report-folder">
<default>""</default>
<summary>The folder the last report was saved to</summary>
<description>
The folder the last report was saved to
</description>
</key>

<key type="s" name="activities-source">
<default>""</default>
<summary>Source for external activity information</summary>
<description>
Which external program activity information should be taken from.
</description>
</key>

<key type="u" name="day-start-minutes">
<default>330</default>
<summary>At what time does the day start (defaults to 5:30AM)</summary>
<description>
Activities will be counted as to bedescription to yesterday if
the current time is less than the specified day start; and
today, if it is over the time.
Activities that span two days, will tip over to the side
where the largest part of the activity is.
</description>
</key>

<key type="as" name="workspace-tracking">
<default>[]</default>
<summary>Should workspace switch trigger activity switch</summary>
<description>
List of enabled tracking methods. "name" will enable
switching activities by name defined in workspace_mapping.
"memory" will enable switching to the last activity when
returning to a previous workspace.
</description>
</key>

<key type="as" name="workspace-mapping">
<default>[]</default>
<summary>Switch activity on workspace change</summary>
<description>
If switching by name is enabled, this list sets the activity
names that should be switched to, workspaces represented by
the index of item.
</description>
</key>

<key type="s" name="active-hamster-window">
<default>""</default>
<summary>Show / hide Time Tracker Window</summary>
<description>Keyboard summarycut for showing / hiding the Time Tracker window.</description>
</key>

<key type="s" name="action">
<default>"hamster-time-tracker toggle"</default>
<summary>Toggle hamster application window action</summary>
<description>Command for toggling visibility of the hamster application window.</description>
</key>

<key type="s" name="name">
<default>"Toggle hamster application window"</default>
<summary>Toggle hamster application window</summary>
<description>Toggle visibility of the hamster application window.</description>
</key>
</schema>
</schemalist>
143 changes: 0 additions & 143 deletions data/hamster-time-tracker.schemas.in

This file was deleted.

12 changes: 6 additions & 6 deletions data/preferences.ui
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.16.1 -->
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.0"/>
<object class="GtkAdjustment" id="adjustment1">
Expand All @@ -20,6 +20,9 @@
<property name="destroy_with_parent">True</property>
<property name="icon_name">hamster-time-tracker</property>
<signal name="key-press-event" handler="on_preferences_window_key_press" swapped="no"/>
<child>
<placeholder/>
</child>
<child>
<object class="GtkVBox" id="big_box">
<property name="visible">True</property>
Expand Down Expand Up @@ -63,7 +66,6 @@
<property name="use_underline">True</property>
<property name="xalign">0.5</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_shutdown_track_toggled" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
Expand All @@ -80,7 +82,6 @@
<property name="use_underline">True</property>
<property name="xalign">0.5</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_idle_track_toggled" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
Expand Down Expand Up @@ -137,7 +138,6 @@
<property name="use_underline">True</property>
<property name="xalign">0.5</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_notify_on_idle_toggled" swapped="no"/>
</object>
</child>
</object>
Expand Down Expand Up @@ -332,10 +332,10 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Categories</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">category_list</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
Expand Down Expand Up @@ -484,10 +484,10 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Activities</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">activity_list</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
Expand Down
4 changes: 2 additions & 2 deletions data/wscript_build
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ bld.add_group()

# process .in files with intl_tool
bld(features = 'intltool_in',
source = 'hamster-time-tracker.schemas.in',
target = 'hamster-time-tracker.schemas',
source = 'apps.hamster-time-tracker.gschema.xml.in',
target = 'apps.hamster-time-tracker.gschema.xml',
install_path = bld.env.schemas_destination,
podir = '../po',
flags = ['-s', '-u'])
Expand Down
2 changes: 1 addition & 1 deletion src/hamster/external.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
class ActivitiesSource(gobject.GObject):
def __init__(self):
gobject.GObject.__init__(self)
self.source = conf.get("activities_source")
self.source = conf.get("activities-source")
self.__gtg_connection = None

if self.source == "evo" and not evolution:
Expand Down
18 changes: 4 additions & 14 deletions src/hamster/idle.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@

from dbus.lowlevel import Message

gi.require_version('GConf', '2.0')
from gi.repository import GConf as gconf
from gi.repository import Gio as gio
from gi.repository import GObject as gobject

class DbusIdleListener(gobject.GObject):
Expand All @@ -37,7 +36,7 @@ class DbusIdleListener(gobject.GObject):
Monitors org.gnome.ScreenSaver for idleness. There are two types,
implicit (due to inactivity) and explicit (lock screen), that need to be
handled differently. An implicit idle state should subtract the
time-to-become-idle (as specified in the gconf) from the last activity,
time-to-become-idle (as specified in GSettings) from the last activity,
but an explicit idle state should not.

The signals are inspected for the "ActiveChanged" and "Lock"
Expand Down Expand Up @@ -93,17 +92,8 @@ def bus_inspector(self, bus, message):
idle_state = message.get_args_list()[0]
if idle_state:
self.idle_from = dt.datetime.now()

# from gnome screensaver 2.24 to 2.28 they have switched
# configuration keys and signal types.
# luckily we can determine key by signal type
if member == "SessionIdleChanged":
delay_key = "/apps/gnome-screensaver/idle_delay"
else:
delay_key = "/desktop/gnome/session/idle_delay"

client = gconf.Client.get_default()
self.timeout_minutes = client.get_int(delay_key)
settings = gio.Settings("org.gnome.desktop.session")
self.timeout_minutes = settings.get_value("idle-delay")

else:
self.screen_locked = False
Expand Down
Loading