implemented draft of config globalization
[findit] / src / files / search.py
index 6b15c4b..b4feac9 100755 (executable)
@@ -7,22 +7,23 @@ from os.path import join, abspath, normcase, basename, isdir, getsize
 from heapq import nlargest
 
 from misc import size_hum_read, _
+from config import config
 
 #==============================================================================
 
 class Control(object):
 
-    def __init__(self, ui, config):
+    def __init__(self, ui):
 
         if ui == 'cli':
-            self.present = Cli_Presentation(config)
+            self.present = Cli_Presentation()
         elif ui == 'gtk':
-            self.present = Gtk_Presentation(config, self.start_search)
+            self.present = Gtk_Presentation(self.start_search)
         elif ui == 'hildon':
-            self.present = Hildon_Presentation(config, self.start_search)
+            self.present = Hildon_Presentation(self.start_search)
 
         # self.present - for updating windows in interactive presentations
-        self.abstrac = Abstraction(config, self.present)
+        self.abstrac = Abstraction(self.present)
 
         # Used only in non-interactive presentations
         self.present.start_search(self.start_search)
@@ -42,8 +43,8 @@ class Control(object):
 
 class Abstraction(object):
 
-    def __init__(self, config, presentation):
-        self.ignore_dirs = config['ignore_dirs']
+    def __init__(self, presentation):
+        self.ignore_dirs = config['files']['ignore_dirs']
         self.presentation = presentation
 
     def filegetter(self, startdir, get_stopit):
@@ -79,10 +80,10 @@ class Abstraction(object):
 #==============================================================================
 
 class Cli_Presentation(object):
-    def __init__(self, config):
-        self.outtype = config['outtype']
-        self.start_path = config['start_path']
-        self.count = config['count']
+    def __init__(self):
+        self.outtype = config['files']['outtype']
+        self.start_path = config['files']['start_path']
+        self.count = config['files']['count']
         self.stopit = False
 
         self.toplevel = None
@@ -108,14 +109,12 @@ class Cli_Presentation(object):
 
 class Gtk_Presentation(object):
 
-    def __init__(self, config, start_func):
+    def __init__(self, start_func):
         import gtk
 
-        self.config = config
-
         # "Start path" entry
         self.path_entry = gtk.Entry()
-        self.path_entry.set_text(self.config['start_path'])
+        self.path_entry.set_text(config['files']['start_path'])
 
         # "Files quantity" label
         qty_label = gtk.Label(_('Files quantity'))
@@ -125,7 +124,7 @@ class Gtk_Presentation(object):
         self.qty_spin.set_numeric(True)
         self.qty_spin.set_range(0, 65536)
         self.qty_spin.set_increments(1, 10)
-        self.qty_spin.set_value(self.config['count'])
+        self.qty_spin.set_value(config['files']['count'])
 
         # "Start" button
         self.start_btn = gtk.Button(_('Start'))
@@ -153,7 +152,7 @@ class Gtk_Presentation(object):
         for btn in reversed(self.out_rbtns):
             hbox.pack_end(btn, False, False, 0)
             # Activate radio button
-            if btn.get_name() == self.config['outtype']:
+            if btn.get_name() == config['outtype']:
                 btn.set_active(True)
 
         self.statusbar = gtk.Statusbar()
@@ -172,7 +171,7 @@ class Gtk_Presentation(object):
             gtk.main_iteration()
         self.show_current_status = show_current_status
 
-        self.show_out_toplevel(None, self.config['outtype'], [(1, 'path', 'bytesize')])
+        self.show_out_toplevel(None, config['outtype'], [(1, 'path', 'bytesize')])
 
     #=== Functions ============================================================
     def start_btn_released(self, btn, start_func):
@@ -220,11 +219,9 @@ class Gtk_Presentation(object):
 
 class Hildon_Presentation(object):
 
-    def __init__(self, config, start_func):
+    def __init__(self, start_func):
         import gtk
         import hildon
 
-        self.config = config
-
     def start_search(self, start_func):
         pass