Merge branch 'master' of https://git.maemo.org/projects/findit into mosfet/master
authorEugene Gagarin <mosfet07@ya.ru>
Sat, 28 Feb 2009 16:22:37 +0000 (19:22 +0300)
committerEugene Gagarin <mosfet07@ya.ru>
Sat, 28 Feb 2009 16:22:37 +0000 (19:22 +0300)
src/findit.py

index 9204f65..a286fca 100755 (executable)
@@ -36,6 +36,7 @@ except IOError:
 
 # Функция которая возвращает строку из числа и единиц для столбца "Размер"("Size")
 def size_convert(size):
+    """Return string with file size in b or Kb or Mb or Gb or Tb."""
     for i, unit in enumerate(['%d b', '%.1f Kb', '%.2f Mb', '%.3f Gb', '%.4f Tb']):
         if size < 1024**(i+1):
             return unit % (size/1024.**i)
@@ -43,6 +44,7 @@ def size_convert(size):
 
 # Функция поставляющая размер файла и путь к нему
 def filegetter(startdir, obj):
+    """Generator of file sizes and paths based on os.walk."""
     # Список игнорируемых каталогов:
     ignore_dirs = ['/dev', '/proc', '/sys', '/mnt']
     # Проходим по всем папкам вглубь от заданного пути
@@ -73,6 +75,7 @@ def filegetter(startdir, obj):
 
 # Fullscreen
 def toggle_fullscreen(obj):
+    """Switch fullscreen on/off."""
     if obj.fullscreen:
         obj.window.unfullscreen()
     else: 
@@ -81,13 +84,18 @@ def toggle_fullscreen(obj):
 
 # Нажатие на кнопку клавиатуры
 def on_key_press(obj, event):
+    """Key press callback."""
+    # Toggle fullscreen on Maemo when hw key is pressed
     if hildonFound and event.keyval == gtk.keysyms.F6:
         toggle_fullscreen(obj)
 
 ### Properties dialog ##########################################################
 
 class PropertiesDialog(gtk.Dialog):
+    """File property dialog window."""
+
     def __init__(self, path, size, bytesize):
+        """Create&show file properties dialog."""
         gtk.Dialog.__init__(self)
         self.set_title( _('File properties') )
         self.set_transient_for(app)
@@ -140,9 +148,11 @@ class PropertiesDialog(gtk.Dialog):
 ### Main window ################################################################
 
 class MainWindow(gtk.Window):
+    """Main window class."""
 
     # Окно сообщения заданного типа с заданным текстом
     def mess_window(self, mestype, content):
+        """Show popup message window."""
         dialog = gtk.MessageDialog(parent=self, flags=gtk.DIALOG_MODAL,
                                    type=mestype, buttons=gtk.BUTTONS_OK,
                                    message_format=content)
@@ -153,6 +163,7 @@ class MainWindow(gtk.Window):
 
     # Функция выполняющаяся при нажатии на кнопку "Показать"
     def start_print(self, widget):
+        """Start file search. Button "Go" activate callback."""         
         self.start_path = self.srch_p_entr.get_text()
         # Проверяем правильное ли значение введено
         if isdir(self.start_path):
@@ -187,10 +198,12 @@ class MainWindow(gtk.Window):
 
     # Функция выполняющаяся при нажатии на кнопку "Стоп"
     def stop_print(self, widget):
+        """Stop search. "Stop" button clicked callback."""
         self.stopit = True
 
     # Функция выполняющаяся при нажатии на кнопку "Свойства файла"
     def show_properties_dialog(self, *args):
+        """Show property dialog window."""
         selection = self.treeview.get_selection()
         (model, it) = selection.get_selected()
         try:
@@ -205,6 +218,7 @@ class MainWindow(gtk.Window):
     ### Window initialization ##################################################
 
     def __init__(self, win_width, win_height, st_path):
+        """Create MainWindow."""
         # Создаем новое окно
         gtk.Window.__init__(self)
         self.set_default_size(win_width, win_height)
@@ -353,6 +367,7 @@ class MainWindow(gtk.Window):
         self.add(main_Vbox)
 
     def run(self):
+        """Show all widgets and run gtk.main()."""
         self.show_all()
         gtk.main()