Ejemplo n.º 1
0
    def on_switch_activity_clicked(self, widget):
        activity, temporary = self.new_name.get_value()
        
        # Redmine integration - if activity is connected with Redmine, it must use new data structures to save additional data
        fact = None
        if conf.get("redmine_integration_enabled"):
            redmine_issue_subject = self.get_widget("issue_combo").get_active_text()
            if redmine_issue_subject == None or redmine_issue_subject == "None":
              arbitrary_issue_id = self.get_widget("arbitrary_issue_id_entry").get_text()
              if arbitrary_issue_id == "" or arbitrary_issue_id == None:
                fact = Fact(activity, tags = self.new_tags.get_text().decode("utf8", "replace"))
              else:
                redcon = redmine.RedmineConnector(conf.get("redmine_url"), conf.get("redmine_api_key"))
                try:
                  redcon.get_arbitrary_issue_data(arbitrary_issue_id)
                  arbitrary_issue_id = int(arbitrary_issue_id)
                  redmine_time_activity_name = self.get_widget("time_activity_combo").get_active_text()
                  if redmine_time_activity_name == None:
                    dialog = gtk.Dialog("Failed to start tracking", self.window, gtk.DIALOG_MODAL, (gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
                    label = gtk.Label("Redmine activity cannot be empty!")
                    dialog.vbox.pack_start(label)
                    label.show()
                    dialog.run()
                    dialog.destroy()
                    return
                  redmine_activity_id = redcon.get_redmine_activity_id(redmine_time_activity_name)
                  fact = RedmineFact(activity, arbitrary_issue_id, redmine_activity_id, tags = self.new_tags.get_text().decode("utf8", "replace"))
                except redmine.RedmineConnectionException:
                  dialog = gtk.Dialog("Failed to start tracking", self.window, gtk.DIALOG_MODAL, (gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
                  label = gtk.Label("Invalid arbitrary issue number!")
                  dialog.vbox.pack_start(label)
                  label.show()
                  dialog.run()
                  dialog.destroy()
                  return
            else:
                redmine_time_activity_name = self.get_widget("time_activity_combo").get_active_text()
                if redmine_time_activity_name == None:
                    dialog = gtk.Dialog("Failed to start tracking", self.window, gtk.DIALOG_MODAL, (gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
                    label = gtk.Label("Redmine activity cannot be empty!")
                    dialog.vbox.pack_start(label)
                    label.show()
                    dialog.run()
                    dialog.destroy()
                    return
                redcon = redmine.RedmineConnector(conf.get("redmine_url"), conf.get("redmine_api_key"))
                redmine_issue_id = redcon.get_redmine_issue_id(redmine_issue_subject)
                redmine_activity_id = redcon.get_redmine_activity_id(redmine_time_activity_name)
                fact = RedmineFact(activity, redmine_issue_id, redmine_activity_id, tags = self.new_tags.get_text().decode("utf8", "replace"))
        else:
            fact = Fact(activity, tags = self.new_tags.get_text().decode("utf8", "replace"))
            
        if not fact.activity:
            return

        runtime.storage.add_fact(fact, temporary)
        self.new_name.set_text("")
        self.new_tags.set_text("")
Ejemplo n.º 2
0
 def on_redmine_issue_combo_change(self, combobox):
   redmine_url = conf.get("redmine_url")
   redmine_api_key = conf.get("redmine_api_key")
   redcon = redmine.RedmineConnector(redmine_url, redmine_api_key)
   if combobox.get_active() == 0:
     self.get_widget("time_activity_combo").set_sensitive(False)
     self.get_widget("time_activity_combo").set_active(-1)
     self.get_widget("arbitrary_issue_id_entry").set_sensitive(True)
     self.get_widget("arbitrary_issue_id_entry").set_text("")
   else:
     self.get_widget("time_activity_combo").set_sensitive(True)
     self.get_widget("arbitrary_issue_id_entry").set_sensitive(False)
Ejemplo n.º 3
0
 def on_redmine_issue_combo_change(self, combobox):
     redmine_url = conf.get("redmine_url")
     redmine_api_key = conf.get("redmine_api_key")
     redcon = redmine.RedmineConnector(redmine_url, redmine_api_key)
     if combobox.get_active() == 0:
         self.get_widget("time_activity_combo").set_sensitive(False)
         self.get_widget("time_activity_combo").set_active(-1)
         self.get_widget("arbitrary_issue_id_entry").set_sensitive(True)
         self.get_widget("arbitrary_issue_id_entry").set_text("")
     else:
         self.get_widget("time_activity_combo").set_sensitive(True)
         self.get_widget("arbitrary_issue_id_entry").set_sensitive(False)
Ejemplo n.º 4
0
 def on_stop_tracking_clicked(self, widget):
     facts = runtime.storage.get_todays_facts()
     fact = facts[-1]
     runtime.storage.stop_tracking()
     self.last_activity = None
     if fact != None and conf.get("redmine_integration_enabled") and (fact.delta.days * 24 + fact.delta.seconds / 3600) >= 0.016 and not fact.redmine_issue_id == -1:
         redmine_url = conf.get("redmine_url")
         redmine_api_key = conf.get("redmine_api_key")
         redcon = redmine.RedmineConnector(redmine_url, redmine_api_key)
         redcon.add_time_entry(fact.redmine_issue_id, round((fact.delta.days * 24 + fact.delta.seconds / 3600), 2), fact.redmine_time_activity_id, fact.activity)
     self.fill_issues_combo()
     self.fill_time_activities_combo()
Ejemplo n.º 5
0
    def __init__(self, storage):
        self.storage = storage  # can't use client as then we get in a dbus loop

        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
        self.bus = dbus.SessionBus()

        self.conf_enable_timeout = conf.get("enable_timeout")
        self.conf_notify_on_idle = conf.get("notify_on_idle")
        self.conf_notify_interval = conf.get("notify_interval")
        conf.connect('conf-changed', self.on_conf_changed)

        self.idle_listener = idle.DbusIdleListener()
        self.idle_listener.connect('idle-changed', self.on_idle_changed)

        gobject.timeout_add_seconds(60, self.check_hamster)
Ejemplo n.º 6
0
    def __init__(self, storage):
        self.storage = storage # can't use client as then we get in a dbus loop

        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
        self.bus = dbus.SessionBus()

        self.conf_enable_timeout = conf.get("enable_timeout")
        self.conf_notify_on_idle = conf.get("notify_on_idle")
        self.conf_notify_interval = conf.get("notify_interval")
        conf.connect('conf-changed', self.on_conf_changed)

        self.idle_listener = idle.DbusIdleListener()
        self.idle_listener.connect('idle-changed', self.on_idle_changed)

        gobject.timeout_add_seconds(60, self.check_hamster)
Ejemplo n.º 7
0
    def reposition_hamster_window(self):
        if not self.window:
            self.create_hamster_window()

        if conf.get("standalone_window_maximized"):
            self.window.maximize()
        else:
            window_box = conf.get("standalone_window_box")
            if window_box:
                x,y,w,h = (int(i) for i in window_box)
                self.window.move(x, y)
                self.window.move(x, y)
                self.window.resize(w, h)
            else:
                self.window.set_position(gtk.WIN_POS_CENTER)
Ejemplo n.º 8
0
 def _on_show_label_changed(self):
     '''Hide or show the indicator's label'''
     self._show_label = conf.get("show_label")
     if self._show_label:
         self.update_label()
     else:
         self.indicator.set_label("")
Ejemplo n.º 9
0
 def fill_time_activities_combo(self):
   combomodel = self.get_widget("time_activity_combo").get_model()
   if combomodel == None:
     combomodel = gtk.ListStore(gobject.TYPE_STRING)
   combomodel.clear()
   self.get_widget("time_activity_combo").set_model(None) # Optimizes operations
   if conf.get("redmine_integration_enabled"):
     redmine_url = conf.get("redmine_url")
     redmine_api_key = conf.get("redmine_api_key")
     redcon = redmine.RedmineConnector(redmine_url, redmine_api_key)
     activities = redcon.get_activities()
     for activity in activities['time_entry_activities']:
       combomodel.append([activity["name"]])
   else:
     combomodel = None
   self.get_widget("time_activity_combo").set_model(combomodel)
Ejemplo n.º 10
0
 def _on_show_label_changed(self):
     '''Hide or show the indicator's label'''
     self._show_label = conf.get("show_label")
     if self._show_label:
         self.update_label()
     else:
         self.indicator.set_label("")
Ejemplo n.º 11
0
 def on_stop_tracking_clicked(self, widget):
     facts = runtime.storage.get_todays_facts()
     fact = facts[-1]
     runtime.storage.stop_tracking()
     self.last_activity = None
     if fact != None and conf.get("redmine_integration_enabled") and (
             fact.delta.days * 24 + fact.delta.seconds /
             3600) >= 0.016 and not fact.redmine_issue_id == -1:
         redmine_url = conf.get("redmine_url")
         redmine_api_key = conf.get("redmine_api_key")
         redcon = redmine.RedmineConnector(redmine_url, redmine_api_key)
         redcon.add_time_entry(
             fact.redmine_issue_id,
             round((fact.delta.days * 24 + fact.delta.seconds / 3600), 2),
             fact.redmine_time_activity_id, fact.activity)
     self.fill_issues_combo()
     self.fill_time_activities_combo()
Ejemplo n.º 12
0
 def fill_time_activities_combo(self):
     combomodel = self.get_widget("time_activity_combo").get_model()
     if combomodel == None:
         combomodel = gtk.ListStore(gobject.TYPE_STRING)
     combomodel.clear()
     self.get_widget("time_activity_combo").set_model(
         None)  # Optimizes operations
     if conf.get("redmine_integration_enabled"):
         redmine_url = conf.get("redmine_url")
         redmine_api_key = conf.get("redmine_api_key")
         redcon = redmine.RedmineConnector(redmine_url, redmine_api_key)
         activities = redcon.get_activities()
         for activity in activities['time_entry_activities']:
             combomodel.append([activity["name"]])
     else:
         combomodel = None
     self.get_widget("time_activity_combo").set_model(combomodel)
Ejemplo n.º 13
0
 def fill_issues_combo(self):
     combomodel = self.get_widget("issue_combo").get_model()
     if combomodel == None:
         combomodel = gtk.ListStore(gobject.TYPE_STRING)
     combomodel.clear()
     self.get_widget("issue_combo").set_model(None)  # Optimizes operations
     if conf.get("redmine_integration_enabled"):
         redmine_url = conf.get("redmine_url")
         redmine_api_key = conf.get("redmine_api_key")
         redcon = redmine.RedmineConnector(redmine_url, redmine_api_key)
         issues = redcon.get_issues()
         combomodel.append(["None"])
         for issue in issues['issues']:
             combomodel.append([issue["subject"]])
     else:
         combomodel = None
     self.get_widget("issue_combo").set_model(combomodel)
     self.get_widget("issue_combo").set_active(0)
Ejemplo n.º 14
0
 def fill_issues_combo(self):
   combomodel = self.get_widget("issue_combo").get_model()
   if combomodel == None:
     combomodel = gtk.ListStore(gobject.TYPE_STRING)
   combomodel.clear()
   self.get_widget("issue_combo").set_model(None) # Optimizes operations
   if conf.get("redmine_integration_enabled"):
     redmine_url = conf.get("redmine_url")
     redmine_api_key = conf.get("redmine_api_key")
     redcon = redmine.RedmineConnector(redmine_url, redmine_api_key)
     issues = redcon.get_issues()
     combomodel.append(["None"])
     for issue in issues['issues']:
       combomodel.append([issue["subject"]])
   else:
     combomodel = None
   self.get_widget("issue_combo").set_model(combomodel)
   self.get_widget("issue_combo").set_active(0)
Ejemplo n.º 15
0
    def __init__(self):
        # initialize the window.  explicitly set it to None first, so that the
        # creator knows it doesn't yet exist.
        self.window = None
        self.create_hamster_window()

        self.new_name.grab_focus()

        # configuration
        self.workspace_tracking = conf.get("workspace_tracking")

        conf.connect('conf-changed', self.on_conf_changed)

        # Load today's data, activities and set label
        self.last_activity = None
        self.todays_facts = None

        runtime.storage.connect('activities-changed',
                                self.after_activity_update)
        runtime.storage.connect('facts-changed', self.after_fact_update)
        runtime.storage.connect('toggle-called', self.on_toggle_called)

        self.screen = None
        if self.workspace_tracking:
            self.init_workspace_tracking()

        # refresh hamster every 60 seconds
        gobject.timeout_add_seconds(60, self.refresh_hamster)

        self.prev_size = None

        # bindings
        self.accel_group = self.get_widget("accelgroup")
        self.window.add_accel_group(self.accel_group)

        gtk.accel_map_add_entry("<hamster-time-tracker>/tracking/add",
                                gtk.keysyms.n, gtk.gdk.CONTROL_MASK)
        gtk.accel_map_add_entry("<hamster-time-tracker>/tracking/overview",
                                gtk.keysyms.o, gtk.gdk.CONTROL_MASK)
        gtk.accel_map_add_entry("<hamster-time-tracker>/tracking/stats",
                                gtk.keysyms.i, gtk.gdk.CONTROL_MASK)
        gtk.accel_map_add_entry("<hamster-time-tracker>/tracking/close",
                                gtk.keysyms.Escape, 0)
        gtk.accel_map_add_entry("<hamster-time-tracker>/tracking/quit",
                                gtk.keysyms.q, gtk.gdk.CONTROL_MASK)
        gtk.accel_map_add_entry("<hamster-time-tracker>/edit/prefs",
                                gtk.keysyms.p, gtk.gdk.CONTROL_MASK)
        gtk.accel_map_add_entry("<hamster-time-tracker>/help/contents",
                                gtk.keysyms.F1, 0)

        # create the status icon
        self.statusicon = ProjectHamsterStatusIcon(self)

        self.reposition_hamster_window()
        self.show_hamster_window()
        self.show_in_tray()
Ejemplo n.º 16
0
    def __init__(self):
        # initialize the window.  explicitly set it to None first, so that the
        # creator knows it doesn't yet exist.
        self.window = None
        self.create_hamster_window()

        self.new_name.grab_focus()

        # configuration
        self.workspace_tracking = conf.get("workspace_tracking")

        conf.connect('conf-changed', self.on_conf_changed)

        # Load today's data, activities and set label
        self.last_activity = None
        self.todays_facts = None

        runtime.storage.connect('activities-changed',self.after_activity_update)
        runtime.storage.connect('facts-changed',self.after_fact_update)
        runtime.storage.connect('toggle-called', self.on_toggle_called)

        self.screen = None
        if self.workspace_tracking:
            self.init_workspace_tracking()


        # refresh hamster every 60 seconds
        gobject.timeout_add_seconds(60, self.refresh_hamster)

        self.prev_size = None

        # bindings
        self.accel_group = self.get_widget("accelgroup")
        self.window.add_accel_group(self.accel_group)

        gtk.accel_map_add_entry("<hamster-time-tracker>/tracking/add", gtk.keysyms.n, gtk.gdk.CONTROL_MASK)
        gtk.accel_map_add_entry("<hamster-time-tracker>/tracking/overview", gtk.keysyms.o, gtk.gdk.CONTROL_MASK)
        gtk.accel_map_add_entry("<hamster-time-tracker>/tracking/stats", gtk.keysyms.i, gtk.gdk.CONTROL_MASK)
        gtk.accel_map_add_entry("<hamster-time-tracker>/tracking/close", gtk.keysyms.Escape, 0)
        gtk.accel_map_add_entry("<hamster-time-tracker>/tracking/quit", gtk.keysyms.q, gtk.gdk.CONTROL_MASK)
        gtk.accel_map_add_entry("<hamster-time-tracker>/edit/prefs", gtk.keysyms.p, gtk.gdk.CONTROL_MASK)
        gtk.accel_map_add_entry("<hamster-time-tracker>/help/contents", gtk.keysyms.F1, 0)



        # create the status icon
        self.statusicon = ProjectHamsterStatusIcon(self)


        self.reposition_hamster_window()
        self.show_hamster_window()
        self.show_in_tray()
Ejemplo n.º 17
0
 def _on_last_activities_days_changed(self):
     self._last_activities_days = conf.get("last_activities_days")
     self.update_last_activities()
Ejemplo n.º 18
0
 def _on_icon_glow_changed(self):
     self._use_icon_glow = conf.get("icon_glow")
     self._set_attention_icon()
Ejemplo n.º 19
0
class DailyView(object):
    def __init__(self):
        # initialize the window.  explicitly set it to None first, so that the
        # creator knows it doesn't yet exist.
        self.window = None
        self.create_hamster_window()

        self.new_name.grab_focus()

        # DBus Setup
        try:
            dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
            # Set up connection to the screensaver
            self.dbusIdleListener = idle.DbusIdleListener()
            self.dbusIdleListener.connect('idle-changed', self.on_idle_changed)

        except dbus.DBusException, e:
            logging.error("Can't init dbus: %s" % e)

        # configuration
        self.timeout_enabled = conf.get("enable_timeout")
        self.notify_on_idle = conf.get("notify_on_idle")
        self.notify_interval = conf.get("notify_interval")
        self.workspace_tracking = conf.get("workspace_tracking")

        conf.connect('conf-changed', self.on_conf_changed)

        # Load today's data, activities and set label
        self.last_activity = None
        self.todays_facts = None

        runtime.storage.connect('activities-changed',self.after_activity_update)
        runtime.storage.connect('facts-changed',self.after_fact_update)
        runtime.storage.connect('toggle-called', self.on_toggle_called)

        self.screen = None
        if self.workspace_tracking:
            self.init_workspace_tracking()

        self.notification = None
        if pynotify:
            self.notification = pynotify.Notification("Oh hi",
                                                      "Greetings from hamster!")
            self.notification.set_urgency(pynotify.URGENCY_LOW) # lower than grass

        # refresh hamster every 60 seconds
        gobject.timeout_add_seconds(60, self.refresh_hamster)

        self.prev_size = None

        # bindings
        self.accel_group = self.get_widget("accelgroup")
        self.window.add_accel_group(self.accel_group)

        gtk.accel_map_add_entry("<hamster-applet>/tracking/add", gtk.keysyms.n, gtk.gdk.CONTROL_MASK)
        gtk.accel_map_add_entry("<hamster-applet>/tracking/overview", gtk.keysyms.o, gtk.gdk.CONTROL_MASK)
        gtk.accel_map_add_entry("<hamster-applet>/tracking/stats", gtk.keysyms.i, gtk.gdk.CONTROL_MASK)
        gtk.accel_map_add_entry("<hamster-applet>/tracking/close", gtk.keysyms.Escape, 0)
        gtk.accel_map_add_entry("<hamster-applet>/tracking/quit", gtk.keysyms.q, gtk.gdk.CONTROL_MASK)
        gtk.accel_map_add_entry("<hamster-applet>/edit/prefs", gtk.keysyms.p, gtk.gdk.CONTROL_MASK)
        gtk.accel_map_add_entry("<hamster-applet>/help/contents", gtk.keysyms.F1, 0)



        # create the status icon
        self.statusicon = ProjectHamsterStatusIcon(self)


        self.reposition_hamster_window()
        self.show_hamster_window()
        self.show_in_tray()
Ejemplo n.º 20
0
 def _on_last_activities_days_changed(self):
     self._last_activities_days = conf.get("last_activities_days")
     self.update_last_activities()
Ejemplo n.º 21
0
    def on_workspace_changed(self, screen, previous_workspace):
        if not previous_workspace:
            # wnck has a slight hiccup on init and after that calls
            # workspace changed event with blank previous state that should be
            # ignored
            return

        if not self.workspace_tracking:
            return # default to not doing anything

        current_workspace = screen.get_active_workspace()

        # rely on workspace numbers as names change
        prev = previous_workspace.get_number()
        new = current_workspace.get_number()

        # on switch, update our mapping between spaces and activities
        self.workspace_activities[prev] = self.last_activity


        activity = None
        if "name" in self.workspace_tracking:
            # first try to look up activity by desktop name
            mapping = conf.get("workspace_mapping")

            fact = None
            if new < len(mapping):
                fact = Fact(mapping[new])

                if fact.activity:
                    category_id = None
                    if fact.category:
                        category_id = runtime.storage.get_category_id(fact.category)

                    activity = runtime.storage.get_activity_by_name(fact.activity,
                                                                    category_id,
                                                                    resurrect = False)
                    if activity:
                        # we need dict below
                        activity = dict(name = activity.name,
                                        category = activity.category,
                                        description = fact.description,
                                        tags = fact.tags)


        if not activity and "memory" in self.workspace_tracking:
            # now see if maybe we have any memory of the new workspace
            # (as in - user was here and tracking Y)
            # if the new workspace is in our dict, switch to the specified activity
            if new in self.workspace_activities and self.workspace_activities[new]:
                activity = self.workspace_activities[new]

        if not activity:
            return

        # check if maybe there is no need to switch, as field match:
        if self.last_activity and \
           self.last_activity.name.lower() == activity.name.lower() and \
           (self.last_activity.category or "").lower() == (activity.category or "").lower() and \
           ", ".join(self.last_activity.tags).lower() == ", ".join(activity.tags).lower():
            return

        # ok, switch
        fact = Fact(activity.name,
                          tags = ", ".join(activity.tags),
                          category = activity.category,
                          description = activity.description);
        runtime.storage.add_fact(fact)
Ejemplo n.º 22
0
 def _on_label_length_changed(self):
     '''Resize the indicator's label'''
     self._label_length = conf.get("label_length")
     if self._show_label:
         self.update_label()
Ejemplo n.º 23
0
    def on_switch_activity_clicked(self, widget):
        activity, temporary = self.new_name.get_value()

        # Redmine integration - if activity is connected with Redmine, it must use new data structures to save additional data
        fact = None
        if conf.get("redmine_integration_enabled"):
            redmine_issue_subject = self.get_widget(
                "issue_combo").get_active_text()
            if redmine_issue_subject == None or redmine_issue_subject == "None":
                arbitrary_issue_id = self.get_widget(
                    "arbitrary_issue_id_entry").get_text()
                if arbitrary_issue_id == "" or arbitrary_issue_id == None:
                    fact = Fact(activity,
                                tags=self.new_tags.get_text().decode(
                                    "utf8", "replace"))
                else:
                    redcon = redmine.RedmineConnector(
                        conf.get("redmine_url"), conf.get("redmine_api_key"))
                    try:
                        redcon.get_arbitrary_issue_data(arbitrary_issue_id)
                        arbitrary_issue_id = int(arbitrary_issue_id)
                        redmine_time_activity_name = self.get_widget(
                            "time_activity_combo").get_active_text()
                        if redmine_time_activity_name == None:
                            dialog = gtk.Dialog(
                                "Failed to start tracking", self.window,
                                gtk.DIALOG_MODAL,
                                (gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
                            label = gtk.Label(
                                "Redmine activity cannot be empty!")
                            dialog.vbox.pack_start(label)
                            label.show()
                            dialog.run()
                            dialog.destroy()
                            return
                        redmine_activity_id = redcon.get_redmine_activity_id(
                            redmine_time_activity_name)
                        fact = RedmineFact(
                            activity,
                            arbitrary_issue_id,
                            redmine_activity_id,
                            tags=self.new_tags.get_text().decode(
                                "utf8", "replace"))
                    except redmine.RedmineConnectionException:
                        dialog = gtk.Dialog(
                            "Failed to start tracking", self.window,
                            gtk.DIALOG_MODAL,
                            (gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
                        label = gtk.Label("Invalid arbitrary issue number!")
                        dialog.vbox.pack_start(label)
                        label.show()
                        dialog.run()
                        dialog.destroy()
                        return
            else:
                redmine_time_activity_name = self.get_widget(
                    "time_activity_combo").get_active_text()
                if redmine_time_activity_name == None:
                    dialog = gtk.Dialog("Failed to start tracking",
                                        self.window, gtk.DIALOG_MODAL,
                                        (gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
                    label = gtk.Label("Redmine activity cannot be empty!")
                    dialog.vbox.pack_start(label)
                    label.show()
                    dialog.run()
                    dialog.destroy()
                    return
                redcon = redmine.RedmineConnector(conf.get("redmine_url"),
                                                  conf.get("redmine_api_key"))
                redmine_issue_id = redcon.get_redmine_issue_id(
                    redmine_issue_subject)
                redmine_activity_id = redcon.get_redmine_activity_id(
                    redmine_time_activity_name)
                fact = RedmineFact(activity,
                                   redmine_issue_id,
                                   redmine_activity_id,
                                   tags=self.new_tags.get_text().decode(
                                       "utf8", "replace"))
        else:
            fact = Fact(activity,
                        tags=self.new_tags.get_text().decode(
                            "utf8", "replace"))

        if not fact.activity:
            return

        runtime.storage.add_fact(fact, temporary)
        self.new_name.set_text("")
        self.new_tags.set_text("")
Ejemplo n.º 24
0
    def set_last_activity(self):
        activity = self.last_activity
        #sets all the labels and everything as necessary
        self.get_widget("stop_tracking").set_sensitive(activity != None)
        arbitrary_issue_id = self.get_widget(
            "arbitrary_issue_id_entry").get_text()
        active_activity = self.get_widget("time_activity_combo").get_active()

        if activity:
            self.get_widget("switch_activity").show()
            self.get_widget("start_tracking").hide()

            # If the Redmine integration is enabled, show the Redmine frame and set insensitivity of combos
            if conf.get("redmine_integration_enabled"):
                self.get_widget("redmine_frame").show()
                self.get_widget("issue_combo").set_sensitive(False)
                self.get_widget("time_activity_combo").set_sensitive(False)
                self.get_widget("arbitrary_issue_id_entry").set_sensitive(
                    False)
                if arbitrary_issue_id != None:
                    self.get_widget("arbitrary_issue_id_entry").set_text(
                        arbitrary_issue_id)
                    self.get_widget("time_activity_combo").set_active(
                        active_activity)

            delta = dt.datetime.now() - activity.start_time
            duration = delta.seconds // 60

            if activity.category != _("Unsorted"):
                if isinstance(activity, RedmineFact):
                    self.get_widget("last_activity_name").set_text(
                        "%s %s - %s" %
                        (activity.activity, activity.redmine_tag(),
                         activity.category))
                else:
                    self.get_widget("last_activity_name").set_text(
                        "%s - %s" % (activity.activity, activity.category))
            else:
                if isinstance(activity, RedmineFact):
                    self.get_widget("last_activity_name").set_text(
                        "%s %s" % (activity.activity, activity.redmine_tag()))
                else:
                    self.get_widget("last_activity_name").set_text(
                        activity.activity)

            self.get_widget("last_activity_duration").set_text(
                stuff.format_duration(duration) or _("Just started"))
            self.get_widget("last_activity_description").set_text(
                activity.description or "")
            self.get_widget("activity_info_box").show()

            self.tag_box.draw(activity.tags)
        else:
            self.get_widget("switch_activity").hide()
            self.get_widget("start_tracking").show()

            self.get_widget("last_activity_name").set_text(_("No activity"))

            self.get_widget("activity_info_box").hide()

            self.tag_box.draw([])

            # If the Redmine integration is enabled, show the Redmine frame and set up the combos (if there is no selection), making sure they are sensitive
            if conf.get("redmine_integration_enabled"):
                self.get_widget("redmine_frame").show()
                self.get_widget("issue_combo").set_sensitive(True)
                self.get_widget("time_activity_combo").set_sensitive(True)
                if self.get_widget("issue_combo").get_active(
                ) == -1 or self.get_widget("issue_combo").get_active() == 0:
                    self.fill_issues_combo()
                    self.get_widget("arbitrary_issue_id_entry").set_sensitive(
                        True)
                if self.get_widget("time_activity_combo").get_active(
                ) == -1 or self.get_widget(
                        "time_activity_combo").get_active() == 0:
                    self.fill_time_activities_combo()
                if arbitrary_issue_id != None:
                    self.get_widget("arbitrary_issue_id_entry").set_text(
                        arbitrary_issue_id)
                    self.get_widget("time_activity_combo").set_active(
                        active_activity)
Ejemplo n.º 25
0
    def __init__(self, project):
        self.project = project

        # Gconf settings
#        self._settings = gconf.client_get_default()
#        self._settings.add_dir(self.BASE_KEY, gconf.CLIENT_PRELOAD_NONE)
        # Key to enable/disable icon glow
        self._use_icon_glow = conf.get("icon_glow")
        self._show_label = conf.get("show_label")
        self._label_length = conf.get("label_length")
        conf.connect('conf-changed', self.on_conf_changed)

        self._activity_as_attribute = None
        # Create a fake applet since HamsterApplet requires one
#        applet = FakeApplet()

        self.indicator = appindicator.Indicator ("hamster-applet",
                                  "hamster-applet-inactive",
                                  appindicator.CATEGORY_SYSTEM_SERVICES)

        self.indicator.set_status(appindicator.STATUS_ACTIVE)
        # Set the attention icon as per the icon_glow gconf key
        self._set_attention_icon()

        # Initialise the activity label with "No Activity"
        self.indicator.set_label(self._get_no_activity_label())

        self.activity, self.duration = None, None

        self.menu = gtk.Menu()
        self.activity_item = gtk.MenuItem("")
        self.menu.append(self.activity_item)
        # this is where you would connect your menu item up with a function:
        self.activity_item.connect("activate", self.on_activate)
        self.activity_label = self.activity_item.get_child()
        self.activity_label.connect('style-set', self.on_label_style_set)

        # show the items
        self.activity_item.show()

        self.stop_activity_item = gtk.MenuItem(_(u"Sto_p tracking"))
        self.menu.append(self.stop_activity_item)
        # this is where you would connect your menu item up with a function:
        self.stop_activity_item.connect("activate", self.on_stop_activity_activated, None)
        # show the items
        self.stop_activity_item.show()

        self.append_separator(self.menu)

        self.earlier_activity_item = gtk.MenuItem(_(u"Add earlier activity"))
        self.menu.append(self.earlier_activity_item)
        # this is where you would connect your menu item up with a function:
        self.earlier_activity_item.connect("activate", self.on_earlier_activity_activated, None)
        # show the items
        self.earlier_activity_item.show()

        self.overview_show_item = gtk.MenuItem(_(u"Show Overview"))
        self.menu.append(self.overview_show_item)
        # this is where you would connect your menu item up with a function:
        self.overview_show_item.connect("activate", self.on_overview_show_activated, None)
        # show the items
        self.overview_show_item.show()

        self.append_separator(self.menu)

        self.preferences_show_item = gtk.MenuItem(_(u"_Preferences"))
        self.menu.append(self.preferences_show_item)
        # this is where you would connect your menu item up with a function:
        self.preferences_show_item.connect("activate", self.on_show_preferences_activated, None)
        # show the items
        self.preferences_show_item.show()

        self.append_separator(self.menu)

        self.quit_item = gtk.ImageMenuItem(gtk.STOCK_QUIT)
        self.menu.append(self.quit_item)
        # this is where you would connect your menu item up with a function:
        self.quit_item.connect("activate", gtk.main_quit, None)
        # show the items
        self.quit_item.show()
        
        self.project.last_activity = None
        runtime.storage.connect('activities-changed', self.after_activity_update)
        runtime.storage.connect('facts-changed', self.after_fact_update)
        runtime.storage.connect('toggle-called', self.on_toggle_called)
        
        gobject.timeout_add_seconds(20, self.refresh_tray) # refresh hamster every 20 seconds to update duration
Ejemplo n.º 26
0
 def _on_icon_glow_changed(self):
     self._use_icon_glow = conf.get("icon_glow")
     self._set_attention_icon()
Ejemplo n.º 27
0
 def _on_label_length_changed(self):
     '''Resize the indicator's label'''
     self._label_length = conf.get("label_length")
     if self._show_label:
         self.update_label()
Ejemplo n.º 28
0
    def __init__(self, project):
        self.project = project

        # Gconf settings
        #        self._settings = gconf.client_get_default()
        #        self._settings.add_dir(self.BASE_KEY, gconf.CLIENT_PRELOAD_NONE)
        # Key to enable/disable icon glow
        self._use_icon_glow = conf.get("icon_glow")
        self._show_label = conf.get("show_label")
        self._label_length = conf.get("label_length")
        conf.connect('conf-changed', self.on_conf_changed)

        self._activity_as_attribute = None
        # Create a fake applet since HamsterApplet requires one
        #        applet = FakeApplet()

        self.indicator = appindicator.Indicator(
            "hamster-applet", "hamster-applet-inactive",
            appindicator.CATEGORY_SYSTEM_SERVICES)

        self.indicator.set_status(appindicator.STATUS_ACTIVE)
        # Set the attention icon as per the icon_glow gconf key
        self._set_attention_icon()

        # Initialise the activity label with "No Activity"
        self.indicator.set_label(self._get_no_activity_label())

        self.activity, self.duration = None, None

        self.menu = gtk.Menu()
        self.activity_item = gtk.MenuItem("")
        self.menu.append(self.activity_item)
        # this is where you would connect your menu item up with a function:
        self.activity_item.connect("activate", self.on_activate)
        self.activity_label = self.activity_item.get_child()
        self.activity_label.connect('style-set', self.on_label_style_set)

        # show the items
        self.activity_item.show()

        self.stop_activity_item = gtk.MenuItem(_(u"Sto_p tracking"))
        self.menu.append(self.stop_activity_item)
        # this is where you would connect your menu item up with a function:
        self.stop_activity_item.connect("activate",
                                        self.on_stop_activity_activated, None)
        # show the items
        self.stop_activity_item.show()

        self.append_separator(self.menu)

        self.earlier_activity_item = gtk.MenuItem(_(u"Add earlier activity"))
        self.menu.append(self.earlier_activity_item)
        # this is where you would connect your menu item up with a function:
        self.earlier_activity_item.connect("activate",
                                           self.on_earlier_activity_activated,
                                           None)
        # show the items
        self.earlier_activity_item.show()

        self.overview_show_item = gtk.MenuItem(_(u"Show Overview"))
        self.menu.append(self.overview_show_item)
        # this is where you would connect your menu item up with a function:
        self.overview_show_item.connect("activate",
                                        self.on_overview_show_activated, None)
        # show the items
        self.overview_show_item.show()

        self.append_separator(self.menu)

        self.preferences_show_item = gtk.MenuItem(_(u"_Preferences"))
        self.menu.append(self.preferences_show_item)
        # this is where you would connect your menu item up with a function:
        self.preferences_show_item.connect("activate",
                                           self.on_show_preferences_activated,
                                           None)
        # show the items
        self.preferences_show_item.show()

        self.append_separator(self.menu)

        self.quit_item = gtk.ImageMenuItem(gtk.STOCK_QUIT)
        self.menu.append(self.quit_item)
        # this is where you would connect your menu item up with a function:
        self.quit_item.connect("activate", gtk.main_quit, None)
        # show the items
        self.quit_item.show()

        self.project.last_activity = None
        runtime.storage.connect('activities-changed',
                                self.after_activity_update)
        runtime.storage.connect('facts-changed', self.after_fact_update)
        runtime.storage.connect('toggle-called', self.on_toggle_called)

        gobject.timeout_add_seconds(
            20, self.refresh_tray
        )  # refresh hamster every 20 seconds to update duration
Ejemplo n.º 29
0
    def set_last_activity(self):
        activity = self.last_activity
        #sets all the labels and everything as necessary
        self.get_widget("stop_tracking").set_sensitive(activity != None)
        arbitrary_issue_id = self.get_widget("arbitrary_issue_id_entry").get_text()
        active_activity = self.get_widget("time_activity_combo").get_active()


        if activity:
            self.get_widget("switch_activity").show()
            self.get_widget("start_tracking").hide()
            
            # If the Redmine integration is enabled, show the Redmine frame and set insensitivity of combos
            if conf.get("redmine_integration_enabled"):
              self.get_widget("redmine_frame").show()
              self.get_widget("issue_combo").set_sensitive(False)
              self.get_widget("time_activity_combo").set_sensitive(False)
              self.get_widget("arbitrary_issue_id_entry").set_sensitive(False)
              if arbitrary_issue_id != None:
                self.get_widget("arbitrary_issue_id_entry").set_text(arbitrary_issue_id)
                self.get_widget("time_activity_combo").set_active(active_activity)

            delta = dt.datetime.now() - activity.start_time
            duration = delta.seconds //  60

            if activity.category != _("Unsorted"):
                if isinstance(activity, RedmineFact):
                    self.get_widget("last_activity_name").set_text("%s %s - %s" %(activity.activity, activity.redmine_tag(), activity.category))
                else:
                    self.get_widget("last_activity_name").set_text("%s - %s" %(activity.activity, activity.category))
            else:
                if isinstance(activity, RedmineFact):
                    self.get_widget("last_activity_name").set_text("%s %s"%(activity.activity, activity.redmine_tag()))
                else:
                    self.get_widget("last_activity_name").set_text(activity.activity)

            self.get_widget("last_activity_duration").set_text(stuff.format_duration(duration) or _("Just started"))
            self.get_widget("last_activity_description").set_text(activity.description or "")
            self.get_widget("activity_info_box").show()

            self.tag_box.draw(activity.tags)
        else:
            self.get_widget("switch_activity").hide()
            self.get_widget("start_tracking").show()

            self.get_widget("last_activity_name").set_text(_("No activity"))

            self.get_widget("activity_info_box").hide()

            self.tag_box.draw([])
            
            # If the Redmine integration is enabled, show the Redmine frame and set up the combos (if there is no selection), making sure they are sensitive
            if conf.get("redmine_integration_enabled"):
              self.get_widget("redmine_frame").show()
              self.get_widget("issue_combo").set_sensitive(True)
              self.get_widget("time_activity_combo").set_sensitive(True)
              if self.get_widget("issue_combo").get_active() == -1 or self.get_widget("issue_combo").get_active() == 0:
                self.fill_issues_combo()
                self.get_widget("arbitrary_issue_id_entry").set_sensitive(True)
              if self.get_widget("time_activity_combo").get_active() == -1 or self.get_widget("time_activity_combo").get_active() == 0:
                self.fill_time_activities_combo()
              if arbitrary_issue_id != None:
                self.get_widget("arbitrary_issue_id_entry").set_text(arbitrary_issue_id)
                self.get_widget("time_activity_combo").set_active(active_activity)