peircej / jbrout

Automatically exported from code.google.com/p/jbrout
0 stars 0 forks source link

[Enhancement] use of wildcards when tagging pictures #149

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I suggest accepting the use of wildcards in the add tag dialog. 

Currently, the dialog suggests all tags which begin with the entered
characters. When only one tag matches, the "Enter" key adds it. 

I suggest allowing the use of wildcards (I've included "*" for any
character, and "$" for end of line). This will enable to select tags typing
letters in the middle or the end of line. 

For example, if you have 2 John in your tags, "John Smith" and "John Doe",
and no other "Jo... something" typing only "Jo" will leave two possible
tags where you have to select one using the mouse or the cursor, or
continue typing until you reach a differentiating character. 

With wildcards, you could type "Jo*i" or "Jo*h$" and clearly identify the tag. 

I've made a patch for commongtk.py which uses regular expressions and seems
to work fairly well. 

Original issue reported on code.google.com by chartier...@gmail.com on 4 Jun 2010 at 12:31

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Index: commongtk.py
===================================================================
--- commongtk.py    (révision 284)
+++ commongtk.py    (copie de travail)
@@ -17,6 +17,7 @@
 import gtk,os,gobject
 import common
 import sys
+import re
 #~ from __main__ import _
 from libs.gladeapp import GladeApp
 from subprocess import Popen, PIPE
@@ -69,12 +70,26 @@
         s=unicode(s).upper()
         s=unicodedata.normalize('NFD',s)
         s=s.encode('ascii','ignore')
+
+        use_regexp=0
+        if s.find("*") > -1 or s.endswith("$"):
+            # Convert s into a regexp
+            use_regexp=1
+            s=re.escape(s)
+            s=s.replace("\*",".*")
+            if s.endswith("\$"):
+                s=s[0:len(s)-2]+"$"
+
         for t,c in self.liste:
             u=unicode(t).upper()
             u=unicodedata.normalize('NFD',u)
             u=u.encode('ascii','ignore')
-            if u.upper().startswith(s):
-                l.append( (t,"(%s)"%c) )
+            if use_regexp:
+                if re.match(s, u.upper()):
+                    l.append( (t,"(%s)"%c) )
+            else:
+                if u.upper().startswith(s):
+                    l.append( (t,"(%s)"%c) )

     def on_text_changed(self,w):
         t=w.get_text().strip()

Original comment by chartier...@gmail.com on 4 Jun 2010 at 12:33

GoogleCodeExporter commented 8 years ago

Original comment by chartier...@gmail.com on 5 Jun 2010 at 7:47

Attachments:

GoogleCodeExporter commented 8 years ago

Original comment by chartier...@gmail.com on 5 Jun 2010 at 7:51

Attachments:

GoogleCodeExporter commented 8 years ago
done in r300

Original comment by manat...@gmail.com on 5 Jun 2010 at 12:42