$OpenBSD: patch-catfish_py,v 1.2 2012/09/10 20:54:40 landry Exp $
- strip heading spaces
- expand ~ to /home/user as default search path
- fix find/locate args
- add a hack for non-iso chars to be converted to utf before being
  passed to gtk
--- catfish.py.orig	Wed Aug 22 15:49:53 2012
+++ catfish.py	Mon Sep 10 22:37:13 2012
@@ -36,13 +36,6 @@ try:
 except ImportError, msg:
     print 'Warning: The optional module %s is missing.' % str(msg).split()[-1]
     
-try:
-    from zeitgeist.client import ZeitgeistDBusInterface
-    from zeitgeist.datamodel import Event, TimeRange
-    from zeitgeist import datamodel
-    iface = ZeitgeistDBusInterface()
-except ImportError, msg:
-    print 'Warning: The optional module %s is missing.' % str(msg).split()[-1]
 
 app_name = 'catfish'
 app_version = '0.4.0.1'
@@ -282,7 +275,7 @@ class suggestions(list):
         """Perform a query using locate.
         
         Return the number of found results."""
-        query = "locate -i %s --existing -n 20" % os.path.join(folder, "*%s*" % keywords)
+        query = "locate -i %s -l 20" % os.path.join(folder, "*%s*" % keywords)
         self.process = subprocess.Popen(query, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
         result_count = 0
         for filepath in self.process.communicate()[0].split('\n'):
@@ -304,7 +297,6 @@ class suggestions(list):
         if len(keywords) > 1:
             self.clear()
             result_count = 0
-            result_count += self.zeitgeist_query(keywords, folder)
             result_count += self.locate_query(keywords, folder)
             return result_count
         else:
@@ -398,7 +390,7 @@ class shell_query:
             , file_manual, path_manual, exact_manual, errors_ignore, use_regex
             ) = self.options
         if 'locate' in binary and '*' not in keywords:
-            command = default % binary + ' --regex'
+            command = default % binary
         else:
             command = default % binary
         if exact:
@@ -415,6 +407,7 @@ class shell_query:
             command += ' "*%s*"' % keywords
         else:
             command += ' "%s"' % keywords
+        print command
         self.process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
         return self.process.stdout
     def status(self): return self.err or self.process.poll()
@@ -456,7 +449,7 @@ class catfish:
         parser.add_option('', '--debug', action='store_true'
             , help='Show debugging messages.')
         parser.set_defaults(icons_large=0, thumbnails=0, time_iso=0, method='find'
-            , limit_results=0, path='~', fileman=self.open_wrapper, exact=0
+            , limit_results=0, path=os.path.expanduser('~'), fileman=self.open_wrapper, exact=0
             , hidden=0, fulltext=0, file_action='open', debug=0, open_wrapper=self.open_wrapper)
         self.options, args = parser.parse_args()
         keywords = ' '.join(args)
@@ -474,7 +467,6 @@ class catfish:
         # Prepare i18n using gettext
         try:
             locale.setlocale(locale.LC_ALL, '')
-            locale.bindtextdomain(app_name, 'locale')
             gettext.bindtextdomain(app_name, 'locale')
             gettext.textdomain(app_name)
         except Exception, msg:
@@ -871,8 +863,8 @@ class catfish:
         folder = os.path.expanduser(folder)
         method_name = [method, 'locate'][method=='slocate']
         methods = {
-            'find': (method, '', '%s "' + folder + '" -ignore_readdir_race -noleaf',
-                '-wholename', '-iwholename', '', 1, 1, 0, 0, 0, 0),
+            'find': (method, '', '%s "' + folder + '"',
+                '-name', '-iname', '', 1, 1, 0, 0, 0, 0),
             'locate': (method, '', '%s', '', '-i', '',
                 1, 0, 1, 0, 0, 1),
             'tracker': ('tracker-search', 'trackerd', '%s', '', '', '-l %i' % limit,
@@ -1349,7 +1341,7 @@ class catfish:
             self.updatedb_in_progress = True
             self.updatedb_button_cancel.set_sensitive(False)
             self.updatedb_button_ok.set_sensitive(False)
-            self.updatedb_process = subprocess.Popen(['gksudo', 'updatedb'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
+            self.updatedb_process = subprocess.Popen(['sudo', '/usr/libexec/locate.updatedb'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
             GObject.timeout_add(1000, updatedb_subprocess)
 
             
