[hamster-applet] dropped activity ordering as we are not using it anywhere anymore (results are sorted by recency and



commit 1c1c76d8f94b10af1c5947d2c320fc7a10d08655
Author: Toms Bauģis <toms baugis gmail com>
Date:   Thu Jul 15 11:50:47 2010 +0100

    dropped activity ordering as we are not using it anywhere anymore (results are sorted by recency and alphabetically instead)

 data/preferences.ui        |  123 ++++++++++++--------------------------------
 src/hamster/client.py      |    6 --
 src/hamster/db.py          |   57 ++++----------------
 src/hamster/preferences.py |  103 +++----------------------------------
 src/hamster/storage.py     |   22 +--------
 5 files changed, 52 insertions(+), 259 deletions(-)
---
diff --git a/data/preferences.ui b/data/preferences.ui
index fbe1a1c..4927b93 100644
--- a/data/preferences.ui
+++ b/data/preferences.ui
@@ -1,13 +1,8 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <requires lib="gtk+" version="2.16"/>
   <!-- interface-naming-policy project-wide -->
-  <object class="GtkAdjustment" id="adjustment1">
-    <property name="value">5</property>
-    <property name="lower">5</property>
-    <property name="upper">121</property>
-    <property name="step_increment">1</property>
-  </object>
+  <object class="GtkTextBuffer" id="autocomplete_tags"/>
   <object class="GtkWindow" id="preferences_window">
     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
     <property name="border_width">12</property>
@@ -17,13 +12,12 @@
     <property name="default_height">450</property>
     <property name="destroy_with_parent">True</property>
     <property name="icon_name">hamster-applet</property>
-    <signal name="destroy" handler="on_preferences_window_destroy"/>
-    <signal name="key_press_event" handler="on_preferences_window_key_press"/>
-    <signal name="delete_event" handler="on_close"/>
+    <signal name="destroy" handler="on_preferences_window_destroy" swapped="no"/>
+    <signal name="key-press-event" handler="on_preferences_window_key_press" swapped="no"/>
+    <signal name="delete-event" handler="on_close" swapped="no"/>
     <child>
       <object class="GtkVBox" id="big_box">
         <property name="visible">True</property>
-        <property name="orientation">vertical</property>
         <property name="spacing">8</property>
         <child>
           <object class="GtkNotebook" id="notebook1">
@@ -39,7 +33,6 @@
                 <child>
                   <object class="GtkVBox" id="vbox1">
                     <property name="visible">True</property>
-                    <property name="orientation">vertical</property>
                     <property name="spacing">20</property>
                     <child>
                       <object class="GtkAlignment" id="alignment4">
@@ -50,7 +43,6 @@
                         <child>
                           <object class="GtkVBox" id="vbox7">
                             <property name="visible">True</property>
-                            <property name="orientation">vertical</property>
                             <property name="spacing">4</property>
                             <child>
                               <object class="GtkCheckButton" id="shutdown_track">
@@ -60,7 +52,7 @@
                                 <property name="receives_default">False</property>
                                 <property name="use_underline">True</property>
                                 <property name="draw_indicator">True</property>
-                                <signal name="toggled" handler="on_shutdown_track_toggled"/>
+                                <signal name="toggled" handler="on_shutdown_track_toggled" swapped="no"/>
                               </object>
                               <packing>
                                 <property name="expand">False</property>
@@ -75,7 +67,7 @@
                                 <property name="receives_default">False</property>
                                 <property name="use_underline">True</property>
                                 <property name="draw_indicator">True</property>
-                                <signal name="toggled" handler="on_idle_track_toggled"/>
+                                <signal name="toggled" handler="on_idle_track_toggled" swapped="no"/>
                               </object>
                               <packing>
                                 <property name="position">1</property>
@@ -94,7 +86,6 @@
                                     <child>
                                       <object class="GtkVBox" id="vbox3">
                                         <property name="visible">True</property>
-                                        <property name="orientation">vertical</property>
                                         <child>
                                           <object class="GtkHScale" id="notify_interval">
                                             <property name="visible">True</property>
@@ -104,8 +95,8 @@
                                             <property name="restrict_to_fill_level">False</property>
                                             <property name="digits">0</property>
                                             <property name="value_pos">bottom</property>
-                                            <signal name="value_changed" handler="on_notify_interval_value_changed"/>
-                                            <signal name="format_value" handler="on_notify_interval_format_value"/>
+                                            <signal name="value-changed" handler="on_notify_interval_value_changed" swapped="no"/>
+                                            <signal name="format-value" handler="on_notify_interval_format_value" swapped="no"/>
                                           </object>
                                           <packing>
                                             <property name="position">0</property>
@@ -124,7 +115,7 @@
                                                 <property name="receives_default">False</property>
                                                 <property name="use_underline">True</property>
                                                 <property name="draw_indicator">True</property>
-                                                <signal name="toggled" handler="on_notify_on_idle_toggled"/>
+                                                <signal name="toggled" handler="on_notify_on_idle_toggled" swapped="no"/>
                                               </object>
                                             </child>
                                           </object>
@@ -270,7 +261,6 @@
                 <child>
                   <object class="GtkVBox" id="vbox2">
                     <property name="visible">True</property>
-                    <property name="orientation">vertical</property>
                     <property name="spacing">15</property>
                     <child>
                       <object class="GtkAlignment" id="alignment7">
@@ -285,7 +275,6 @@
                                 <property name="width_request">150</property>
                                 <property name="visible">True</property>
                                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="orientation">vertical</property>
                                 <property name="spacing">4</property>
                                 <child>
                                   <object class="GtkLabel" id="categories_label">
@@ -321,10 +310,10 @@
                                             <property name="AtkObject::accessible-name" translatable="yes">Category list</property>
                                           </object>
                                         </child>
-                                        <signal name="button_press_event" handler="on_category_list_button_pressed"/>
-                                        <signal name="drag_motion" handler="on_category_list_drag_motion"/>
-                                        <signal name="key_press_event" handler="on_category_list_key_pressed"/>
-                                        <signal name="button_release_event" handler="on_category_list_button_released"/>
+                                        <signal name="button-press-event" handler="on_category_list_button_pressed" swapped="no"/>
+                                        <signal name="drag-motion" handler="on_category_list_drag_motion" swapped="no"/>
+                                        <signal name="key-press-event" handler="on_category_list_key_pressed" swapped="no"/>
+                                        <signal name="button-release-event" handler="on_category_list_button_released" swapped="no"/>
                                       </object>
                                     </child>
                                   </object>
@@ -346,7 +335,7 @@
                                             <property name="AtkObject::accessible-name" translatable="yes">Add category</property>
                                           </object>
                                         </child>
-                                        <signal name="clicked" handler="on_category_add_clicked"/>
+                                        <signal name="clicked" handler="on_category_add_clicked" swapped="no"/>
                                         <child>
                                           <object class="GtkImage" id="image1">
                                             <property name="visible">True</property>
@@ -369,7 +358,7 @@
                                             <property name="AtkObject::accessible-name" translatable="yes">Remove category</property>
                                           </object>
                                         </child>
-                                        <signal name="clicked" handler="on_category_remove_clicked"/>
+                                        <signal name="clicked" handler="on_category_remove_clicked" swapped="no"/>
                                         <child>
                                           <object class="GtkImage" id="image2">
                                             <property name="visible">True</property>
@@ -392,7 +381,7 @@
                                             <property name="AtkObject::accessible-name" translatable="yes">Edit category</property>
                                           </object>
                                         </child>
-                                        <signal name="clicked" handler="on_category_edit_clicked"/>
+                                        <signal name="clicked" handler="on_category_edit_clicked" swapped="no"/>
                                         <child>
                                           <object class="GtkImage" id="image3">
                                             <property name="visible">True</property>
@@ -424,7 +413,6 @@
                               <object class="GtkVBox" id="vbox5">
                                 <property name="visible">True</property>
                                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                                <property name="orientation">vertical</property>
                                 <property name="spacing">4</property>
                                 <child>
                                   <object class="GtkLabel" id="activities_label">
@@ -465,10 +453,9 @@
                                                 <property name="AtkObject::accessible-name" translatable="yes">Activity list</property>
                                               </object>
                                             </child>
-                                            <signal name="button_press_event" handler="on_activity_list_button_pressed"/>
-                                            <signal name="drag_motion" handler="on_activity_list_drag_motion"/>
-                                            <signal name="key_press_event" handler="on_activity_list_key_pressed"/>
-                                            <signal name="button_release_event" handler="on_activity_list_button_released"/>
+                                            <signal name="button-press-event" handler="on_activity_list_button_pressed" swapped="no"/>
+                                            <signal name="key-press-event" handler="on_activity_list_key_pressed" swapped="no"/>
+                                            <signal name="button-release-event" handler="on_activity_list_button_released" swapped="no"/>
                                           </object>
                                         </child>
                                       </object>
@@ -492,7 +479,7 @@
                                             <property name="AtkObject::accessible-name" translatable="yes">Add activity</property>
                                           </object>
                                         </child>
-                                        <signal name="clicked" handler="on_activity_add_clicked"/>
+                                        <signal name="clicked" handler="on_activity_add_clicked" swapped="no"/>
                                         <child>
                                           <object class="GtkImage" id="image4">
                                             <property name="visible">True</property>
@@ -515,7 +502,7 @@
                                             <property name="AtkObject::accessible-name" translatable="yes">Remove activity</property>
                                           </object>
                                         </child>
-                                        <signal name="clicked" handler="on_activity_remove_clicked"/>
+                                        <signal name="clicked" handler="on_activity_remove_clicked" swapped="no"/>
                                         <child>
                                           <object class="GtkImage" id="image5">
                                             <property name="visible">True</property>
@@ -538,7 +525,7 @@
                                             <property name="AtkObject::accessible-name" translatable="yes">Edit activity</property>
                                           </object>
                                         </child>
-                                        <signal name="clicked" handler="on_activity_edit_clicked"/>
+                                        <signal name="clicked" handler="on_activity_edit_clicked" swapped="no"/>
                                         <child>
                                           <object class="GtkImage" id="image6">
                                             <property name="visible">True</property>
@@ -552,52 +539,6 @@
                                       </packing>
                                     </child>
                                     <child>
-                                      <object class="GtkButton" id="activity_up">
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">True</property>
-                                        <property name="receives_default">True</property>
-                                        <child internal-child="accessible">
-                                          <object class="AtkObject" id="activity_up-atkobject">
-                                            <property name="AtkObject::accessible-name" translatable="yes">Move activity up</property>
-                                          </object>
-                                        </child>
-                                        <signal name="clicked" handler="on_activity_up_clicked"/>
-                                        <child>
-                                          <object class="GtkImage" id="image7">
-                                            <property name="visible">True</property>
-                                            <property name="icon_name">up</property>
-                                          </object>
-                                        </child>
-                                      </object>
-                                      <packing>
-                                        <property name="expand">False</property>
-                                        <property name="position">3</property>
-                                      </packing>
-                                    </child>
-                                    <child>
-                                      <object class="GtkButton" id="activity_down">
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">True</property>
-                                        <property name="receives_default">True</property>
-                                        <child internal-child="accessible">
-                                          <object class="AtkObject" id="activity_down-atkobject">
-                                            <property name="AtkObject::accessible-name" translatable="yes">Move activity down</property>
-                                          </object>
-                                        </child>
-                                        <signal name="clicked" handler="on_activity_down_clicked"/>
-                                        <child>
-                                          <object class="GtkImage" id="image8">
-                                            <property name="visible">True</property>
-                                            <property name="icon_name">down</property>
-                                          </object>
-                                        </child>
-                                      </object>
-                                      <packing>
-                                        <property name="expand">False</property>
-                                        <property name="position">4</property>
-                                      </packing>
-                                    </child>
-                                    <child>
                                       <placeholder/>
                                     </child>
                                   </object>
@@ -645,7 +586,7 @@
                                     <property name="right_margin">4</property>
                                     <property name="buffer">autocomplete_tags</property>
                                     <property name="accepts_tab">False</property>
-                                    <signal name="focus_out_event" handler="on_autocomplete_tags_view_focus_out_event"/>
+                                    <signal name="focus-out-event" handler="on_autocomplete_tags_view_focus_out_event" swapped="no"/>
                                   </object>
                                 </child>
                               </object>
@@ -695,7 +636,6 @@
                 <child>
                   <object class="GtkVBox" id="vbox8">
                     <property name="visible">True</property>
-                    <property name="orientation">vertical</property>
                     <child>
                       <object class="GtkAlignment" id="alignment10">
                         <property name="visible">True</property>
@@ -703,7 +643,6 @@
                         <child>
                           <object class="GtkVBox" id="vbox6">
                             <property name="visible">True</property>
-                            <property name="orientation">vertical</property>
                             <property name="spacing">8</property>
                             <child>
                               <object class="GtkCheckButton" id="workspace_tracking_memory">
@@ -712,7 +651,7 @@
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">False</property>
                                 <property name="draw_indicator">True</property>
-                                <signal name="toggled" handler="on_workspace_tracking_toggled"/>
+                                <signal name="toggled" handler="on_workspace_tracking_toggled" swapped="no"/>
                               </object>
                               <packing>
                                 <property name="expand">False</property>
@@ -722,7 +661,6 @@
                             <child>
                               <object class="GtkVBox" id="vbox9">
                                 <property name="visible">True</property>
-                                <property name="orientation">vertical</property>
                                 <child>
                                   <object class="GtkCheckButton" id="workspace_tracking_name">
                                     <property name="label" translatable="yes">Start new activity when switching workspaces:</property>
@@ -730,7 +668,7 @@
                                     <property name="can_focus">True</property>
                                     <property name="receives_default">False</property>
                                     <property name="draw_indicator">True</property>
-                                    <signal name="toggled" handler="on_workspace_tracking_toggled"/>
+                                    <signal name="toggled" handler="on_workspace_tracking_toggled" swapped="no"/>
                                   </object>
                                   <packing>
                                     <property name="expand">False</property>
@@ -807,7 +745,7 @@
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
                 <property name="use_stock">True</property>
-                <signal name="clicked" handler="on_close_button_clicked"/>
+                <signal name="clicked" handler="on_close_button_clicked" swapped="no"/>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -824,5 +762,10 @@
       </object>
     </child>
   </object>
-  <object class="GtkTextBuffer" id="autocomplete_tags"/>
+  <object class="GtkAdjustment" id="adjustment1">
+    <property name="lower">5</property>
+    <property name="upper">121</property>
+    <property name="value">5</property>
+    <property name="step_increment">1</property>
+  </object>
 </interface>
diff --git a/src/hamster/client.py b/src/hamster/client.py
index f6f6280..7ace197 100644
--- a/src/hamster/client.py
+++ b/src/hamster/client.py
@@ -239,15 +239,9 @@ class Storage(gobject.GObject):
     def remove_category(self, id):
         self.conn.RemoveCategory(id)
 
-    def move_activity(self, source_id, target_order, insert_after = True):
-        self.conn.MoveActivity(source_id, target_order, insert_after)
-
     def change_category(self, id, category_id):
         return self.conn.ChangeCategory(id, category_id)
 
-    def swap_activities(self, id1, priority1, id2, priority2):
-        self.conn.SwapActivities(id1, priority1, id2, priority2)
-
     def update_activity(self, id, name, category_id):
         return self.conn.UpdateActivity(id, name, category_id)
 
diff --git a/src/hamster/db.py b/src/hamster/db.py
index 5991d61..27cf2ec 100644
--- a/src/hamster/db.py
+++ b/src/hamster/db.py
@@ -162,7 +162,7 @@ class Storage(storage.Storage):
         return changes or len(to_delete + to_uncomplete) > 0
 
     def __get_categories(self):
-        return self.fetchall("SELECT * FROM categories ORDER BY category_order")
+        return self.fetchall("SELECT id, name FROM categories ORDER BY lower(name)")
 
     def __change_category(self, id, category_id):
         # first check if we don't have an activity with same name before us
@@ -186,26 +186,22 @@ class Storage(storage.Storage):
             self.__remove_activity(id)
 
         else: #just moving
-            query = "SELECT max(activity_order) + 1 FROM activities WHERE category_id = ?"
-            max_order = self.fetchone(query, (category_id, ))[0] or 1
-
             statement = """
                        UPDATE activities
-                          SET category_id = ?, activity_order = ?
+                          SET category_id = ?
                         WHERE id = ?
             """
 
-            self.execute(statement, (category_id, max_order, id))
+            self.execute(statement, (category_id, id))
 
         return True
 
     def __add_category(self, name):
-        order = self.fetchone("select max(category_order) + 1  from categories")[0] or 1
         query = """
-                   INSERT INTO categories (name, category_order)
-                        VALUES (?, ?)
+                   INSERT INTO categories (name)
+                        VALUES (?)
         """
-        self.execute(query, (name, order))
+        self.execute(query, (name,))
         return self.__last_insert_rowid()
 
     def __update_category(self, id,  name):
@@ -217,24 +213,6 @@ class Storage(storage.Storage):
             """
             self.execute(update, (name, id))
 
-    def __move_activity(self, source_id, target_order, insert_after = True):
-        statement = "UPDATE activities SET activity_order = activity_order + 1"
-
-        if insert_after:
-            statement += " WHERE activity_order > ?"
-        else:
-            statement += " WHERE activity_order >= ?"
-
-        self.execute(statement, (target_order, ))
-
-        statement = "UPDATE activities SET activity_order = ? WHERE id = ?"
-
-        if insert_after:
-            self.execute(statement, (target_order + 1, source_id))
-        else:
-            self.execute(statement, (target_order, source_id))
-
-
 
     def __get_activity_by_name(self, name, category_id = None, resurrect = True):
         """get most recent, preferably not deleted activity by it's name"""
@@ -736,19 +714,14 @@ class Storage(storage.Storage):
         """returns list of activities, if category is specified, order by name
            otherwise - by activity_order"""
         query = """
-                   SELECT a.id, a.name, a.activity_order, a.category_id, b.name as category
+                   SELECT a.id, a.name, a.category_id, b.name as category
                      FROM activities a
                 LEFT JOIN categories b on coalesce(b.id, -1) = a.category_id
                     WHERE category_id = ?
                       AND deleted is null
+                 ORDER BY lower(a.name)
         """
 
-        # unsorted entries we sort by name - others by ID
-        if category_id == -1:
-            query += "ORDER BY lower(a.name)"
-        else:
-            query += "ORDER BY a.activity_order"
-
         return self.fetchall(query, (category_id, ))
 
 
@@ -794,13 +767,6 @@ class Storage(storage.Storage):
         self.execute("delete from categories where id = ?", (id, ))
 
 
-    def __swap_activities(self, id1, priority1, id2, priority2):
-        """ swaps nearby activities """
-        # TODO - 2 selects and 2 updates is wrong we could live without selects
-        self.execute(["update activities set activity_order = ? where id = ?",
-                      "update activities set activity_order = ? where id = ?"],
-                      [(priority1, id2), (priority2, id1)])
-
     def __add_activity(self, name, category_id = None, temporary = False):
         # first check that we don't have anything like that yet
         activity = self.__get_activity_by_name(name, category_id)
@@ -809,7 +775,6 @@ class Storage(storage.Storage):
 
         #now do the create bit
         category_id = category_id or -1
-        new_order = self.fetchone("select max(activity_order) + 1  from activities")[0] or 1
 
         deleted = None
         if temporary:
@@ -817,10 +782,10 @@ class Storage(storage.Storage):
 
 
         query = """
-                   INSERT INTO activities (name, category_id, activity_order, deleted)
-                        VALUES (?, ?, ?, ?)
+                   INSERT INTO activities (name, category_id, deleted)
+                        VALUES (?, ?, ?)
         """
-        self.execute(query, (name, category_id, new_order, deleted))
+        self.execute(query, (name, category_id, deleted))
         return self.__last_insert_rowid()
 
     def __update_activity(self, id, name, category_id):
diff --git a/src/hamster/preferences.py b/src/hamster/preferences.py
index 33e2977..cc71622 100755
--- a/src/hamster/preferences.py
+++ b/src/hamster/preferences.py
@@ -45,31 +45,23 @@ def get_prev(selection, model):
 class CategoryStore(gtk.ListStore):
     def __init__(self):
         #id, name, color_code, order
-        gtk.ListStore.__init__(self, int, str, int)
+        gtk.ListStore.__init__(self, int, str)
 
     def load(self):
-        """ Loads activity list from database, ordered by
-            activity_order """
-
         category_list = runtime.storage.get_categories()
 
         for category in category_list:
-            self.append([category['id'],
-                         category['name'],
-                         category['category_order']])
+            self.append([category['id'], category['name']])
 
-        self.unsorted_category = self.append([-1, _("Unsorted"), 999]) # all activities without category
+        self.unsorted_category = self.append([-1, _("Unsorted")]) # all activities without category
 
 
 class ActivityStore(gtk.ListStore):
     def __init__(self):
         #id, name, category_id, order
-        gtk.ListStore.__init__(self, int, str, int, int)
+        gtk.ListStore.__init__(self, int, str, int)
 
     def load(self, category_id):
-        """ Loads activity list from database, ordered by
-            activity_order """
-
         self.clear()
 
         if category_id is None:
@@ -80,8 +72,7 @@ class ActivityStore(gtk.ListStore):
         for activity in activity_list:
             self.append([activity['id'],
                          activity['name'],
-                         activity['category_id'],
-                         activity['activity_order']])
+                         activity['category_id']])
 
 
 class WorkspaceStore(gtk.ListStore):
@@ -173,15 +164,11 @@ class PreferencesEditor:
                                                 self.TARGETS,
                                                 gtk.gdk.ACTION_DEFAULT|
                                                 gtk.gdk.ACTION_MOVE)
-        self.activity_tree.enable_model_drag_dest(self.TARGETS,
-                                                  gtk.gdk.ACTION_MOVE)
 
         self.category_tree.enable_model_drag_dest(self.TARGETS,
                                                   gtk.gdk.ACTION_MOVE)
 
         self.activity_tree.connect("drag_data_get", self.drag_data_get_data)
-        self.activity_tree.connect("drag_data_received",
-                                   self.drag_data_received_data)
 
         self.category_tree.connect("drag_data_received",
                                    self.on_category_drop)
@@ -341,23 +328,6 @@ class PreferencesEditor:
                 self.category_tree.set_cursor((i, ))
             i += 1
 
-    def on_activity_list_drag_motion(self, treeview, drag_context, x, y, eventtime):
-        self.prev_selected_activity = None
-        try:
-            target_path, drop_position = treeview.get_dest_row_at_pos(x, y)
-            model, source = treeview.get_selection().get_selected()
-
-        except:
-            return
-
-        drop_yes = ("drop_yes", gtk.TARGET_SAME_APP, 0)
-        drop_no = ("drop_no", gtk.TARGET_SAME_APP, 0)
-
-        if drop_position == gtk.TREE_VIEW_DROP_AFTER or \
-           drop_position == gtk.TREE_VIEW_DROP_BEFORE:
-            treeview.enable_model_drag_dest(self.TARGETS, gtk.gdk.ACTION_MOVE)
-        else:
-            treeview.enable_model_drag_dest([drop_no], gtk.gdk.ACTION_MOVE)
 
 
     def on_category_list_drag_motion(self, treeview, drag_context, x, y, eventtime):
@@ -379,34 +349,6 @@ class PreferencesEditor:
             treeview.enable_model_drag_dest([drop_no], gtk.gdk.ACTION_MOVE)
 
 
-    def drag_data_received_data(self, treeview, context, x, y, selection,
-                                info, etime):
-        model = treeview.get_model()
-        data = selection.data
-        drop_info = treeview.get_dest_row_at_pos(x, y)
-
-        if drop_info:
-            path, position = drop_info
-            iter = model.get_iter(path)
-            if (position == gtk.TREE_VIEW_DROP_BEFORE
-                or position == gtk.TREE_VIEW_DROP_INTO_OR_BEFORE):
-                logging.debug("insert '%s' before '%s'" % (data, model[iter][3]))
-                runtime.storage.move_activity(int(data), model[iter][3], insert_after = False)
-            else:
-                logging.debug("insert '%s' after '%s'" % (data, model[iter][3]))
-                runtime.storage.move_activity(int(data), model[iter][3], insert_after = True)
-        else:
-            logging.debug("append '%s'" % data)
-
-        if context.action == gtk.gdk.ACTION_MOVE:
-            context.finish(True, True, etime)
-
-
-        self.activity_store.load(self._get_selected_category())
-
-        self.select_activity(int(data))
-
-        return
 
     def on_category_drop(self, treeview, context, x, y, selection,
                                 info, etime):
@@ -499,8 +441,6 @@ class PreferencesEditor:
             self.activity_store.load(model[iter][0])
 
         #start with nothing
-        self.get_widget('activity_up').set_sensitive(False)
-        self.get_widget('activity_down').set_sensitive(False)
         self.get_widget('activity_edit').set_sensitive(False)
         self.get_widget('activity_remove').set_sensitive(False)
 
@@ -522,18 +462,9 @@ class PreferencesEditor:
 
         # treat any selected case
         unsorted_selected = self._get_selected_category() == -1
-        self.get_widget('activity_up').set_sensitive(False)
-        self.get_widget('activity_down').set_sensitive(False)
-
         self.get_widget('activity_edit').set_sensitive(iter != None)
         self.get_widget('activity_remove').set_sensitive(iter != None)
 
-        if iter != None and not unsorted_selected:
-            first_item = model.get_path(iter) == (0,)
-            self.get_widget('activity_up').set_sensitive(not first_item)
-
-            last_item = model.iter_next(iter) is None
-            self.get_widget('activity_down').set_sensitive(not last_item)
 
     def _del_selected_row(self, tree):
         selection = tree.get_selection()
@@ -693,7 +624,7 @@ class PreferencesEditor:
         """ appends row, jumps to it and allows user to input name """
 
         new_category = self.category_store.insert_before(self.category_store.unsorted_category,
-                                                         [-2, _(u"New category"), -1])
+                                                         [-2, _(u"New category")])
 
         self.categoryCell.set_property("editable", True)
         self.category_tree.set_cursor_on_cell((len(self.category_tree.get_model()) - 2, ),
@@ -706,7 +637,7 @@ class PreferencesEditor:
         """ appends row, jumps to it and allows user to input name """
         category_id = self._get_selected_category()
 
-        new_activity = self.activity_store.append([-1, _(u"New activity"), category_id, -1])
+        new_activity = self.activity_store.append([-1, _(u"New activity"), category_id])
 
         (model, iter) = self.selection.get_selected()
 
@@ -720,26 +651,6 @@ class PreferencesEditor:
         removable_id = self._del_selected_row(self.activity_tree)
         runtime.storage.remove_activity(removable_id)
 
-    def on_activity_up_clicked(self, button):
-        (model, iter) = self.selection.get_selected()
-
-        #previous item
-        prev_iter = get_prev(self.selection, model)
-        runtime.storage.swap_activities(model[iter][0], model[iter][3],
-                                model[prev_iter][0], model[prev_iter][3])
-        model.move_before(iter, prev_iter)
-
-        self.activity_changed(self.selection, model)
-
-    def on_activity_down_clicked(self, button):
-        (model, iter) = self.selection.get_selected()
-
-        next_iter = model.iter_next(iter)
-        runtime.storage.swap_activities(model[iter][0], model[iter][3],
-                                model[next_iter][0], model[next_iter][3])
-        self.activity_store.move_after(iter, next_iter)
-
-        self.activity_changed(self.selection, model)
 
     def on_close_button_clicked(self, button):
         self.close_window()
diff --git a/src/hamster/storage.py b/src/hamster/storage.py
index f7bf879..53e26fb 100644
--- a/src/hamster/storage.py
+++ b/src/hamster/storage.py
@@ -237,14 +237,7 @@ class Storage(dbus.service.Object):
 
     @dbus.service.method("org.gnome.Hamster", out_signature='aa{sv}')
     def GetCategories(self):
-        res = []
-        for category in self.__get_categories():
-            category = dict(category)
-            category['color_code'] = category['color_code'] or ''
-            res.append(category)
-
-
-        return res
+        return [dict(category) for category in self.__get_categories()]
 
 
     # activities
@@ -292,13 +285,6 @@ class Storage(dbus.service.Object):
         return res
 
 
-
-    @dbus.service.method("org.gnome.Hamster", in_signature='iib')
-    def MoveActivity(self, source_id, target_order, insert_after = True):
-        self.__move_activity(source_id, target_order, insert_after)
-        self.ActivitiesChanged()
-
-
     @dbus.service.method("org.gnome.Hamster", in_signature='ii', out_signature = 'b')
     def ChangeCategory(self, id, category_id):
         changed = self.__change_category(id, category_id)
@@ -307,12 +293,6 @@ class Storage(dbus.service.Object):
         return changed
 
 
-    @dbus.service.method("org.gnome.Hamster", in_signature='iiii')
-    def SwapActivities(self, id1, priority1, id2, priority2):
-        self.__swap_activities(id1, priority1, id2, priority2)
-        self.ActivitiesChanged()
-
-
     @dbus.service.method("org.gnome.Hamster", in_signature='sib', out_signature='a{sv}')
     def GetActivityByName(self, activity, category_id, resurrect = True):
         category_id = category_id or None



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