[hamster-applet] do not suggest non-autocomplete tags. fixes bug 617820



commit 074a523c8d851625a8603f01185405d7c553fcb2
Author: Toms Bauģis <toms baugis gmail com>
Date:   Thu May 6 01:08:51 2010 +0100

    do not suggest non-autocomplete tags. fixes bug 617820

 src/hamster/client.py       |    4 ++--
 src/hamster/db.py           |    7 +++++--
 src/hamster/preferences.py  |    2 +-
 src/hamster/storage.py      |    8 ++++----
 src/hamster/widgets/tags.py |    4 ++--
 5 files changed, 14 insertions(+), 11 deletions(-)
---
diff --git a/src/hamster/client.py b/src/hamster/client.py
index 576d9c1..8f3ade1 100644
--- a/src/hamster/client.py
+++ b/src/hamster/client.py
@@ -120,9 +120,9 @@ class Storage(gobject.GObject):
         """returns list of categories"""
         return self.conn.GetCategories()
 
-    def get_tags(self):
+    def get_tags(self, only_autocomplete = False):
         """returns list of all tags. by default only those that have been set for autocomplete"""
-        return self.conn.GetTags()
+        return self.conn.GetTags(only_autocomplete)
 
 
     def get_tag_ids(self, tags):
diff --git a/src/hamster/db.py b/src/hamster/db.py
index 249e67e..a1594ee 100644
--- a/src/hamster/db.py
+++ b/src/hamster/db.py
@@ -113,8 +113,11 @@ class Storage(storage.Storage):
         self.__last_etag = self.__database_file.query_info(gio.FILE_ATTRIBUTE_ETAG_VALUE).get_etag()
 
     #tags, here we come!
-    def __get_tags(self):
-        return self.fetchall("select * from tags order by name")
+    def __get_tags(self, only_autocomplete = False):
+        if only_autocomplete:
+            return self.fetchall("select * from tags where autocomplete != 'false' order by name")
+        else:
+            return self.fetchall("select * from tags order by name")
 
     def __get_tag_ids(self, tags):
         """look up tags by their name. create if not found"""
diff --git a/src/hamster/preferences.py b/src/hamster/preferences.py
index 0ecec77..7d8fc2c 100755
--- a/src/hamster/preferences.py
+++ b/src/hamster/preferences.py
@@ -277,7 +277,7 @@ class PreferencesEditor:
         day_start = dt.time(day_start / 60, day_start % 60)
         self.day_start.set_time(day_start)
 
-        self.tags = [tag["name"] for tag in runtime.storage.get_tags()]
+        self.tags = [tag["name"] for tag in runtime.storage.get_tags(only_autocomplete=True)]
         self.get_widget("autocomplete_tags").set_text(", ".join(self.tags))
 
         self.workspace_mapping = conf.get("workspace_mapping")
diff --git a/src/hamster/storage.py b/src/hamster/storage.py
index f342085..74290d0 100644
--- a/src/hamster/storage.py
+++ b/src/hamster/storage.py
@@ -313,9 +313,9 @@ class Storage(dbus.service.Object):
             return {}
 
     # tags
-    @dbus.service.method("org.gnome.Hamster", out_signature='aa{sv}')
-    def GetTags(self):
-        return [dict(tag) for tag in self.__get_tags()]
+    @dbus.service.method("org.gnome.Hamster", in_signature='b', out_signature='aa{sv}')
+    def GetTags(self, only_autocomplete):
+        return [dict(tag) for tag in self.__get_tags(only_autocomplete)]
 
 
     @dbus.service.method("org.gnome.Hamster", in_signature='as', out_signature='aa{sv}')
@@ -326,7 +326,7 @@ class Storage(dbus.service.Object):
         return [dict(tag) for tag in tags]
 
 
-    @dbus.service.method("org.gnome.Hamster", in_signature='as')
+    @dbus.service.method("org.gnome.Hamster", in_signature='s')
     def SetTagsAutocomplete(self, tags):
         changes = self.__update_autocomplete_tags(tags)
         if changes:
diff --git a/src/hamster/widgets/tags.py b/src/hamster/widgets/tags.py
index d8d9ced..6eda0a2 100644
--- a/src/hamster/widgets/tags.py
+++ b/src/hamster/widgets/tags.py
@@ -130,7 +130,7 @@ class TagsEntry(gtk.Entry):
         self.categories = None
 
     def populate_suggestions(self):
-        self.tags = self.tags or [tag["name"] for tag in runtime.storage.get_tags()]
+        self.tags = self.tags or [tag["name"] for tag in runtime.storage.get_tags(only_autocomplete=True)]
 
         cursor_tag = self.get_cursor_tag()
 
@@ -255,7 +255,7 @@ class TagBox(graphics.Scene):
     def on_tag_click(self, area, event, targets):
         if not targets:
             return
-        
+
         tag = targets[0]
         if tag.text in self.selected_tags:
             self.emit("tag-unselected", tag.text)



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