Skip to content

Commit

Permalink
Enable hamster plugin to new plugin api #114
Browse files Browse the repository at this point in the history
update to new plugin api and update the description we send to dbus-hamster version 3.0.
  • Loading branch information
flavin authored and diegogangl committed Oct 8, 2020
1 parent b62b108 commit f4d8cd6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
4 changes: 2 additions & 2 deletions GTG/plugins/unmaintained/hamster.gtg-plugin
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module=hamster
name=Hamster Time Tracker Integration
short-description=Track time of GTG task with Hamster applet.
description=Adds the ability to send a task to
the Hamster time tracking applet
the Hamster time tracking app.
authors=Kevin Mehall <km@kevinmehall.net>
version=0.3
version=0.4
dbus-dependencies=org.gnome.Hamster:/org/gnome/Hamster
enabled=False
34 changes: 21 additions & 13 deletions GTG/plugins/unmaintained/hamster/hamster.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def sendTask(self, task):
fact = activity
if category:
fact += f"@{category}"
fact += f",{description}{tag_str}"
fact += f",, {description}{tag_str}"
start_time = timegm(datetime.datetime.now().timetuple())
hamster_id = self.hamster.AddFact(fact, start_time, 0, False)

Expand Down Expand Up @@ -240,7 +240,8 @@ def activate(self, plugin_api):
self.button.set_sensitive(False)
self.button.connect('clicked', self.browser_cb, plugin_api)
self.button.show()
plugin_api.add_toolbar_item(self.button)
header_bar = plugin_api.get_gtk_builder().get_object('browser_headerbar')
header_bar.add(self.button)
plugin_api.set_active_selection_changed_callback(
self.selection_changed)

Expand All @@ -249,6 +250,13 @@ def activate(self, plugin_api):
("node-deleted-inview", self.on_task_deleted),
])

#TODO(flavin): SET ACTIVE TASK AT START
# we need something like get_active_id
# to setup the current hamster task running and
# and check if is the gtg task list
# with the title we can match.


# set up preferences
self.preference_dialog_init()
self.preferences_load()
Expand All @@ -271,7 +279,7 @@ def onTaskOpened(self, plugin_api):
self.decide_button_mode(self.taskbutton, task)
self.taskbutton.connect('clicked', self.task_cb, plugin_api)
self.taskbutton.show()
plugin_api.add_toolbar_item(self.taskbutton)
plugin_api.add_widget_to_taskeditor(self.taskbutton)

records = self.get_records(task)

Expand Down Expand Up @@ -304,15 +312,15 @@ def add(w, a, b, offset, active=False):

dateLabel = Gtk.Label(label=a)
dateLabel.set_use_markup(True)
dateLabel.set_alignment(halign=Gtk.Align.START,
valign=Gtk.Align.CENTER)
dateLabel.set_alignment(xalign=Gtk.Align.START,
yalign=Gtk.Align.CENTER)
dateLabel.set_size_request(200, -1)
w.attach(dateLabel, 0, offset, 1, 1)

durLabel = Gtk.Label(label=b)
durLabel.set_use_markup(True)
durLabel.set_alignment(halign=Gtk.Align.START,
valign=Gtk.Align.CENTER)
durLabel.set_alignment(xalign=Gtk.Align.START,
yalign=Gtk.Align.CENTER)
w.attach(durLabel, 1, offset, 1, 1)

active_id = self.get_active_id()
Expand Down Expand Up @@ -376,14 +384,14 @@ def decide_button_mode(self, button, task):
self.change_button_to_start_activity(button)

def change_button_to_start_activity(self, button):
self.menu_item.set_label(self.START_ACTIVITY_LABEL)
self.button.set_icon_widget(self.get_icon_widget(self.IMG_START_PATH))
self.button.set_tooltip_text(self.TOOLTIP_TEXT_START_ACTIVITY)
self.menu_item.set_label(self.START_ACTIVITY_LABEL) #TODO flavin not used
button.set_icon_widget(self.get_icon_widget(self.IMG_START_PATH))
button.set_tooltip_text(self.TOOLTIP_TEXT_START_ACTIVITY)

def change_button_to_stop_activity(self, button):
self.menu_item.set_label(self.STOP_ACTIVITY_LABEL)
self.button.set_icon_widget(self.get_icon_widget(self.IMG_STOP_PATH))
self.button.set_tooltip_text(self.TOOLTIP_TEXT_STOP_ACTIVITY)
self.menu_item.set_label(self.STOP_ACTIVITY_LABEL) #TODO flavin not used menu
button.set_icon_widget(self.get_icon_widget(self.IMG_STOP_PATH))
button.set_tooltip_text(self.TOOLTIP_TEXT_STOP_ACTIVITY)

# Preference Handling ###
def is_configurable(self):
Expand Down

0 comments on commit f4d8cd6

Please sign in to comment.