Skip to content

Commit

Permalink
add description field fix #3
Browse files Browse the repository at this point in the history
  • Loading branch information
gsobczyk committed May 14, 2013
1 parent 3117e83 commit 7612f8b
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 44 deletions.
126 changes: 83 additions & 43 deletions data/today.ui
Original file line number Diff line number Diff line change
Expand Up @@ -346,85 +346,125 @@
<property name="top_padding">5</property>
<property name="left_padding">12</property>
<child>
<object class="GtkHBox" id="bleh1">
<object class="GtkVBox" id="vbox3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">4</property>
<child>
<object class="GtkAlignment" id="new_name_box">
<property name="width_request">280</property>
<object class="GtkHBox" id="bleh1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">4</property>
<child>
<placeholder/>
<object class="GtkAlignment" id="new_name_box">
<property name="width_request">280</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkAlignment" id="new_tags_box">
<property name="width_request">220</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
<object class="GtkAlignment" id="new_tags_box">
<property name="width_request">220</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkHButtonBox" id="hbuttonbox2">
<object class="GtkHBox" id="hbox2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">5</property>
<child>
<object class="GtkButton" id="switch_activity">
<property name="label" translatable="yes">S_witch</property>
<property name="width_request">80</property>
<object class="GtkEntry" id="description">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="no_show_all">True</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<signal name="clicked" handler="on_switch_activity_clicked" swapped="no"/>
<property name="invisible_char">•</property>
<property name="invisible_char_set">True</property>
<property name="primary_icon_activatable">False</property>
<property name="secondary_icon_activatable">False</property>
<property name="primary_icon_sensitive">True</property>
<property name="secondary_icon_sensitive">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="start_tracking">
<property name="label" translatable="yes">Start _Tracking</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="no_show_all">True</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<signal name="clicked" handler="on_switch_activity_clicked" swapped="no"/>
<object class="GtkHButtonBox" id="hbuttonbox2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">5</property>
<child>
<object class="GtkButton" id="switch_activity">
<property name="label" translatable="yes">S_witch</property>
<property name="width_request">80</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="no_show_all">True</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<signal name="clicked" handler="on_switch_activity_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="start_tracking">
<property name="label" translatable="yes">Start _Tracking</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="no_show_all">True</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<signal name="clicked" handler="on_switch_activity_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="position">1</property>
</packing>
</child>
</object>
Expand Down
11 changes: 10 additions & 1 deletion src/hamster/today.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ def create_hamster_window(self):
self.get_widget("new_name_box").add(self.new_name)
self.new_name.connect("changed", self.on_activity_text_changed)

self.new_description = self.get_widget("description")
self.new_description.connect("key-release-event", self._description_on_key_release_event)

self.new_tags = widgets.TagsEntry()
self.new_tags.connect("tags_selected", self.on_switch_activity_clicked)
widgets.add_hint(self.new_tags, _("Tags"))
Expand Down Expand Up @@ -260,6 +263,10 @@ def delete_selected(self):


"""events"""
def _description_on_key_release_event(self, entry, event):
if (event.keyval in (gtk.keysyms.Return, gtk.keysyms.KP_Enter)):
self.on_switch_activity_clicked(entry)

def on_todays_keys(self, tree, event):
if (event.keyval == gtk.keysyms.Delete):
self.delete_selected()
Expand Down Expand Up @@ -404,13 +411,15 @@ def on_switch_activity_clicked(self, widget):
activity, temporary = self.new_name.get_value()

fact = Fact(activity,
tags = self.new_tags.get_text().decode("utf8", "replace"))
tags = self.new_tags.get_text().decode("utf8", "replace"),
description=self.new_description.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("")
self.new_description.set_text("")

def on_stop_tracking_clicked(self, widget):
runtime.storage.stop_tracking()
Expand Down

0 comments on commit 7612f8b

Please sign in to comment.