Ejemplo n.º 1
0
    def create_hamster_window(self):
        if self.window is None:
            # load window of activity switcher and todays view
            self._gui = load_ui_file("today.ui")
            self.window = self._gui.get_object('hamster-window')
            self.window.connect("delete_event", self.on_delete_window)

            gtk.window_set_default_icon_name("hamster-time-tracker")

            self.new_name = widgets.ActivityEntry()
            self.new_name.connect("value-entered", self.on_switch_activity_clicked)
            widgets.add_hint(self.new_name, _("Activity"))
            self.get_widget("new_name_box").add(self.new_name)
            self.new_name.connect("changed", self.on_activity_text_changed)

            self.new_tags = widgets.TagsEntry()
            self.new_tags.connect("tags_selected", self.on_switch_activity_clicked)
            widgets.add_hint(self.new_tags, _("Tags"))
            self.get_widget("new_tags_box").add(self.new_tags)

            self.tag_box = widgets.TagBox(interactive = False)
            self.get_widget("tag_box").add(self.tag_box)

            self.treeview = widgets.FactTree()
            self.treeview.connect("key-press-event", self.on_todays_keys)
            self.treeview.connect("edit-clicked", self._open_edit_activity)
            self.treeview.connect("row-activated", self.on_today_row_activated)

            self.get_widget("today_box").add(self.treeview)

            # connect the accelerators
            self.accel_group = self.get_widget("accelgroup")
            self.window.add_accel_group(self.accel_group)

            self._gui.connect_signals(self)
Ejemplo n.º 2
0
    def create_hamster_window(self):
        if self.window is None:
            # load window of activity switcher and todays view
            self._gui = load_ui_file("today.ui")
            self.window = self._gui.get_object('hamster-window')
            self.window.connect("delete_event", self.on_delete_window)

            gtk.window_set_default_icon_name("hamster-time-tracker")

            self.new_name = widgets.ActivityEntry()
            self.new_name.connect("value-entered",
                                  self.on_switch_activity_clicked)
            widgets.add_hint(self.new_name, _("Activity"))
            self.get_widget("new_name_box").add(self.new_name)
            self.new_name.connect("changed", self.on_activity_text_changed)

            self.new_tags = widgets.TagsEntry()
            self.new_tags.connect("tags_selected",
                                  self.on_switch_activity_clicked)
            widgets.add_hint(self.new_tags, _("Tags"))
            self.get_widget("new_tags_box").add(self.new_tags)

            self.tag_box = widgets.TagBox(interactive=False)
            self.get_widget("tag_box").add(self.tag_box)

            self.treeview = widgets.FactTree()
            self.treeview.connect("key-press-event", self.on_todays_keys)
            self.treeview.connect("edit-clicked", self._open_edit_activity)
            self.treeview.connect("row-activated", self.on_today_row_activated)

            self.get_widget("today_box").add(self.treeview)

            # connect the accelerators
            self.accel_group = self.get_widget("accelgroup")
            self.window.add_accel_group(self.accel_group)

            self._gui.connect_signals(self)

            # Signal for Redmine issue combo
            self.get_widget("issue_combo").connect(
                "changed", self.on_redmine_issue_combo_change)

            # Signal for Redmine arbitrary issue id entry
            self.get_widget("arbitrary_issue_id_entry").connect(
                "changed", self.on_redmine_arbitrary_issue_id_entry_change)

            # Redmine combos additional setup
            cell = gtk.CellRendererText()
            self.get_widget("issue_combo").pack_start(cell, True)
            self.get_widget("issue_combo").add_attribute(cell, 'text', 0)
            cell = gtk.CellRendererText()
            self.get_widget("time_activity_combo").pack_start(cell, True)
            self.get_widget("time_activity_combo").add_attribute(
                cell, 'text', 0)
Ejemplo n.º 3
0
    def __init__(self, action, fact_id=None):
        Controller.__init__(self)

        self._date = None  # for the date property

        self._gui = load_ui_file("edit_activity.ui")
        self.window = self.get_widget('custom_fact_window')
        self.window.set_size_request(600, 200)

        self.action = action
        self.fact_id = fact_id

        self.category_entry = widgets.CategoryEntry(
            widget=self.get_widget('category'))
        self.activity_entry = widgets.ActivityEntry(
            widget=self.get_widget('activity'),
            category_widget=self.category_entry)

        self.cmdline = widgets.CmdLineEntry(
            parent=self.get_widget("cmdline box"))
        self.cmdline.connect("focus_in_event", self.on_cmdline_focus_in_event)
        self.cmdline.connect("focus_out_event",
                             self.on_cmdline_focus_out_event)

        self.dayline = widgets.DayLine()
        self._gui.get_object("day_preview").add(self.dayline)

        self.description_box = self.get_widget('description')
        self.description_buffer = self.description_box.get_buffer()

        self.end_date = widgets.Calendar(
            widget=self.get_widget("end date"),
            expander=self.get_widget("end date expander"))

        self.end_time = widgets.TimeInput(
            parent=self.get_widget("end time box"))

        self.start_date = widgets.Calendar(
            widget=self.get_widget("start date"),
            expander=self.get_widget("start date expander"))

        self.start_time = widgets.TimeInput(
            parent=self.get_widget("start time box"))

        self.tags_entry = widgets.TagsEntry()
        self.get_widget("tags box").add(self.tags_entry)

        self.save_button = self.get_widget("save_button")

        # this will set self.master_is_cmdline
        self.cmdline.grab_focus()

        title = _("Update activity") if action == "edit" else _("Add activity")
        self.window.set_title(title)
        self.get_widget("delete_button").set_sensitive(action == "edit")
        if action == "edit":
            self.fact = runtime.storage.get_fact(fact_id)
        elif action == "clone":
            base_fact = runtime.storage.get_fact(fact_id)
            self.fact = base_fact.copy(start_time=dt.datetime.now(),
                                       end_time=None)
        else:
            self.fact = Fact(start_time=dt.datetime.now())

        original_fact = self.fact
        # TODO: should use hday, not date.
        self.date = self.fact.date

        self.update_fields()
        self.update_cmdline(select=True)

        self.cmdline.original_fact = original_fact

        # This signal should be emitted only after a manual modification,
        # not at init time when cmdline might not always be fully parsable.
        self.cmdline.connect("changed", self.on_cmdline_changed)
        self.description_buffer.connect("changed", self.on_description_changed)
        self.start_time.connect("changed", self.on_start_time_changed)
        self.start_date.connect("day-selected", self.on_start_date_changed)
        self.start_date.expander.connect("activate",
                                         self.on_start_date_expander_activated)
        self.end_time.connect("changed", self.on_end_time_changed)
        self.end_date.connect("day-selected", self.on_end_date_changed)
        self.end_date.expander.connect("activate",
                                       self.on_end_date_expander_activated)
        self.activity_entry.connect("changed", self.on_activity_changed)
        self.category_entry.connect("changed", self.on_category_changed)
        self.tags_entry.connect("changed", self.on_tags_changed)

        self._gui.connect_signals(self)
        self.validate_fields()
        self.window.show_all()
Ejemplo n.º 4
0
    def __init__(self, parent=None, fact_id=None, base_fact=None):
        gobject.GObject.__init__(self)

        self._gui = load_ui_file("edit_activity.ui")
        self.window = self.get_widget('custom_fact_window')
        self.window.set_size_request(600, 200)
        self.parent = parent
        # None if creating a new fact, instead of editing one
        self.fact_id = fact_id

        self.category_entry = widgets.CategoryEntry(
            widget=self.get_widget('category'))
        self.activity_entry = widgets.ActivityEntry(
            widget=self.get_widget('activity'),
            category_widget=self.category_entry)

        self.cmdline = widgets.CmdLineEntry()
        self.get_widget("command line box").add(self.cmdline)
        self.cmdline.connect("focus_in_event", self.on_cmdline_focus_in_event)
        self.cmdline.connect("focus_out_event",
                             self.on_cmdline_focus_out_event)

        self.dayline = widgets.DayLine()
        self._gui.get_object("day_preview").add(self.dayline)

        self.description_box = self.get_widget('description')
        self.description_buffer = self.description_box.get_buffer()

        self.end_date = widgets.Calendar(
            widget=self.get_widget("end date"),
            expander=self.get_widget("end date expander"))

        self.end_time = widgets.TimeInput()
        self.get_widget("end time box").add(self.end_time)

        self.start_date = widgets.Calendar(
            widget=self.get_widget("start date"),
            expander=self.get_widget("start date expander"))

        self.start_time = widgets.TimeInput()
        self.get_widget("start time box").add(self.start_time)

        self.tags_entry = widgets.TagsEntry()
        self.get_widget("tags box").add(self.tags_entry)

        self.save_button = self.get_widget("save_button")

        # this will set self.master_is_cmdline
        self.cmdline.grab_focus()

        if fact_id:
            # editing
            self.fact = runtime.storage.get_fact(fact_id)
            self.date = self.fact.date
            self.window.set_title(_("Update activity"))
        else:
            self.window.set_title(_("Add activity"))
            self.date = hamster_today()
            self.get_widget("delete_button").set_sensitive(False)
            if base_fact:
                # start a clone now.
                self.fact = base_fact.copy(start_time=hamster_now(),
                                           end_time=None)
            else:
                self.fact = Fact(start_time=hamster_now())

        original_fact = self.fact

        self.update_fields()
        self.update_cmdline(select=True)

        self.cmdline.original_fact = original_fact

        # This signal should be emitted only after a manual modification,
        # not at init time when cmdline might not always be fully parsable.
        self.cmdline.connect("changed", self.on_cmdline_changed)
        self.description_buffer.connect("changed", self.on_description_changed)
        self.start_time.connect("changed", self.on_start_time_changed)
        self.start_date.connect("day-selected", self.on_start_date_changed)
        self.start_date.expander.connect("activate",
                                         self.on_start_date_expander_activated)
        self.end_time.connect("changed", self.on_end_time_changed)
        self.end_date.connect("day-selected", self.on_end_date_changed)
        self.end_date.expander.connect("activate",
                                       self.on_end_date_expander_activated)
        self.activity_entry.connect("changed", self.on_activity_changed)
        self.category_entry.connect("changed", self.on_category_changed)
        self.tags_entry.connect("changed", self.on_tags_changed)

        self._gui.connect_signals(self)
        self.validate_fields()
        self.window.show_all()
Ejemplo n.º 5
0
    def __init__(self):
        window = gtk.Window()
        window.set_default_size(600, 500)
        window.connect("delete_event", lambda *args: gtk.main_quit())

        vbox = gtk.VBox(spacing=10)
        vbox.set_border_width(12)
        self.scene = Scene()

        self.fixed = gtk.Fixed()
        self.fixed.put(self.scene, 0, 0)

        self.scene.container = self

        self.edit_box = gtk.HBox()
        self.edit_box.set_border_width(6)
        self.fixed.put(self.edit_box, 100, 0)

        container = gtk.HBox(spacing=5)
        self.edit_box.add(container)

        start_entry = widgets.TimeInput()
        self.start_entry = start_entry
        box = gtk.VBox()
        box.add(start_entry)
        container.add(box)

        end_entry = widgets.TimeInput()
        self.end_entry = end_entry
        box = gtk.VBox()
        box.add(end_entry)
        container.add(box)

        entry_box = gtk.VBox(spacing=5)
        container.add(entry_box)

        activity_entry = widgets.ActivityEntry()
        activity_entry.set_width_chars(35)
        self.activity_entry = activity_entry
        entry_box.add(activity_entry)

        tags_entry = widgets.TagsEntry()
        self.tags_entry = tags_entry
        entry_box.add(tags_entry)

        description_entry = gtk.Entry()
        description_entry.set_width_chars(35)
        self.description_entry = description_entry
        entry_box.add(description_entry)

        save_button = gtk.Button("Save")
        entry_box.add(save_button)

        container.add(gtk.HBox())
        vbox.add(self.fixed)

        button_box = gtk.HBox(spacing=5)
        vbox.add(button_box)
        window.add(vbox)

        prev_day = gtk.Button("Previous day")
        next_day = gtk.Button("Next day")
        button_box.add(gtk.HBox())
        button_box.add(prev_day)
        button_box.add(next_day)

        prev_day.connect("clicked", self.on_prev_day_click)
        next_day.connect("clicked", self.on_next_day_click)

        self.scene.render_facts()

        window.show_all()
        self.edit_box.hide()