[hamster-applet] unbroke



commit 8fda833088da38e57cc63678203f1f6c87b7c76d
Author: Toms Bauģis <toms baugis gmail com>
Date:   Wed Nov 25 01:12:47 2009 +0000

    unbroke

 data/edit_activity.ui    |   68 +++++++++++++++++++++-------------------------
 hamster/edit_activity.py |   43 +++++++++--------------------
 2 files changed, 44 insertions(+), 67 deletions(-)
---
diff --git a/data/edit_activity.ui b/data/edit_activity.ui
index cd7faf6..792c1f3 100644
--- a/data/edit_activity.ui
+++ b/data/edit_activity.ui
@@ -133,32 +133,9 @@
               <packing>
                 <property name="left_attach">1</property>
                 <property name="right_attach">2</property>
-                <property name="top_attach">1</property>
-                <property name="bottom_attach">2</property>
-                <property name="y_options">GTK_FILL</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkScrolledWindow" id="scrolledwindow2">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="hscrollbar_policy">never</property>
-                <property name="vscrollbar_policy">automatic</property>
-                <property name="shadow_type">in</property>
-                <child>
-                  <object class="GtkTextView" id="description">
-                    <property name="height_request">50</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="wrap_mode">word-char</property>
-                  </object>
-                </child>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="right_attach">2</property>
                 <property name="top_attach">2</property>
                 <property name="bottom_attach">3</property>
+                <property name="y_options">GTK_FILL</property>
               </packing>
             </child>
             <child>
@@ -174,13 +151,10 @@
               </packing>
             </child>
             <child>
-              <object class="GtkLabel" id="Description:">
+              <object class="GtkLabel" id="label2">
                 <property name="visible">True</property>
                 <property name="xalign">0</property>
-                <property name="yalign">0</property>
-                <property name="label" translatable="yes">Description:</property>
-                <property name="use_underline">True</property>
-                <property name="mnemonic_widget">description</property>
+                <property name="label" translatable="yes">Time:</property>
               </object>
               <packing>
                 <property name="top_attach">2</property>
@@ -188,27 +162,41 @@
               </packing>
             </child>
             <child>
-              <object class="GtkLabel" id="label2">
+              <object class="GtkLabel" id="label1">
                 <property name="visible">True</property>
                 <property name="xalign">0</property>
-                <property name="label" translatable="yes">Time:</property>
+                <property name="label" translatable="yes">Activity:</property>
+                <property name="use_underline">True</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkAlignment" id="activity_box">
+                <property name="width_request">300</property>
+                <property name="visible">True</property>
+                <child>
+                  <placeholder/>
+                </child>
               </object>
               <packing>
-                <property name="top_attach">1</property>
-                <property name="bottom_attach">2</property>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
               </packing>
             </child>
             <child>
-              <object class="GtkLabel" id="label1">
+              <object class="GtkLabel" id="tags_label">
                 <property name="visible">True</property>
                 <property name="xalign">0</property>
-                <property name="label" translatable="yes">Activity:</property>
+                <property name="yalign">0</property>
+                <property name="label" translatable="yes">Tags:</property>
                 <property name="use_underline">True</property>
               </object>
+              <packing>
+                <property name="top_attach">1</property>
+                <property name="bottom_attach">2</property>
+              </packing>
             </child>
             <child>
-              <object class="GtkAlignment" id="activity_box">
-                <property name="width_request">300</property>
+              <object class="GtkAlignment" id="tags_box">
                 <property name="visible">True</property>
                 <child>
                   <placeholder/>
@@ -217,6 +205,8 @@
               <packing>
                 <property name="left_attach">1</property>
                 <property name="right_attach">2</property>
+                <property name="top_attach">1</property>
+                <property name="bottom_attach">2</property>
               </packing>
             </child>
           </object>
@@ -240,6 +230,8 @@
                 <signal name="clicked" handler="on_cancel_clicked"/>
               </object>
               <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
                 <property name="position">0</property>
               </packing>
             </child>
@@ -253,6 +245,8 @@
                 <signal name="clicked" handler="on_save_button_clicked"/>
               </object>
               <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
                 <property name="position">1</property>
               </packing>
             </child>
diff --git a/hamster/edit_activity.py b/hamster/edit_activity.py
index 83e1d7e..8602d29 100644
--- a/hamster/edit_activity.py
+++ b/hamster/edit_activity.py
@@ -41,6 +41,9 @@ class CustomFactController:
         self.new_name = widgets.ActivityEntry()
         self.get_widget("activity_box").add(self.new_name)
         
+        self.new_tags = widgets.TagsEntry()
+        self.get_widget("tags_box").add(self.new_tags)
+        
         if fact_id:
             fact = runtime.storage.get_fact(fact_id)
 
@@ -50,13 +53,14 @@ class CustomFactController:
                 
             self.new_name.set_text(label)
             
+            if fact['description']:
+                fact['tags'].append(fact['description'])  #same edit field
+            self.new_tags.set_text(", ".join(fact['tags']))
+            
+            
             start_date = fact["start_time"]
             end_date = fact["end_time"]
             
-            buf = gtk.TextBuffer()
-            buf.set_text(fact["description"] or "")
-            self.get_widget('description').set_buffer(buf)
-
             self.get_widget("save_button").set_label("gtk-save")
             self.window.set_title(_("Update activity"))
 
@@ -153,36 +157,13 @@ class CustomFactController:
         else:
             return None
     
-    def figure_description(self):
-        activity = self.new_name.get_text().decode("utf-8")
-
-        # juggle with description - break into parts and then put together
-        buf = self.get_widget('description').get_buffer()
-        description = buf.get_text(buf.get_start_iter(), buf.get_end_iter(), 0)\
-                         .decode("utf-8")
-        description = description.strip()
-        
-        # user might also type description in the activity name - strip it here
-        # and remember value
-        inline_description = None
-        if activity.find(",") != -1:
-            activity, inline_description  = activity.split(",", 1)
-            inline_description = inline_description.strip()
-        
-        # description field is prior to inline description
-        return description or inline_description
-        
     def on_save_button_clicked(self, button):
         activity = self.new_name.get_text().decode("utf-8")
         
         if not activity:
             return False
 
-        description = self.figure_description()
-
-        if description:
-            activity = "%s, %s" % (activity, description)
-
+        tags = self.new_tags.get_text()
         
         start_time = self._get_datetime("start")
 
@@ -195,7 +176,7 @@ class CustomFactController:
         if self.fact_id:
             runtime.storage.remove_fact(self.fact_id)
 
-        runtime.storage.add_fact(activity, start_time, end_time)
+        runtime.storage.add_fact(activity, tags, start_time, end_time)
 
 
         # hide panel only on add - on update user will want to see changes
@@ -283,7 +264,9 @@ class CustomFactController:
             
             if self.start_date.popup.get_property("visible") or \
                self.start_time.popup.get_property("visible") or \
-               self.end_time.popup.get_property("visible"):
+               self.end_time.popup.get_property("visible") or \
+               self.new_name.popup.get_property("visible") or \
+               self.new_tags.popup.get_property("visible"):
                 return False
 
             self.close_window()            



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]