Make pylint happier.
authorJoel Rosdahl <joel@rosdahl.net>
Tue, 24 Jan 2006 20:52:58 +0000 (20:52 +0000)
committerJoel Rosdahl <joel@rosdahl.net>
Tue, 24 Jan 2006 20:52:58 +0000 (20:52 +0000)
src/packages/kofoto/gkofoto/fullscreenwindow.py
src/packages/kofoto/gkofoto/imageview.py
src/packages/kofoto/gkofoto/objectcollection.py
src/packages/kofoto/gkofoto/tableview.py
src/packages/kofoto/shelfupgrade.py

index 38d1e71..d714e5b 100644 (file)
@@ -1,11 +1,27 @@
+# pylint: disable-msg=F0203, E0201
+
+"""This module contains the FullScreenWindow class."""
+
+__all__ = ["FullScreenWindow"]
+
 import gtk
+import gobject
 from kofoto.gkofoto.imageview import ImageView
 from kofoto.gkofoto.environment import env
 
 class FullScreenWindow(gtk.Window):
+    """A fullscreen window widget."""
+
+    def __init__(self, image_versions, current_index=0):
+        """Constructor.
+
+        Arguments:
+
+        image_versions -- A list of ImageVersion instance to display.
+        current_index  -- Where to start in image_versions.
+        """
 
-    def __init__(self, image_versions, current_index = 0):
-        gtk.Window.__init__(self)
+        self.__gobject_init__() # TODO: Use gtk.Window.__init__ in PyGTK 2.8.
 
         self._image_versions = image_versions
         self._current_index = current_index
@@ -14,21 +30,35 @@ class FullScreenWindow(gtk.Window):
 
         self.connect("key_press_event", self._key_pressed_cb)
         self._image_view = ImageView()
-        bg_color = gtk.gdk.color_parse('#000000')
+        bg_color = gtk.gdk.color_parse("#000000")
         self._image_view.modify_bg(gtk.STATE_NORMAL, bg_color)
         self.add(self._image_view)
         self.set_modal(True)
         self.set_default_size(400, 400)
         self.fullscreen()
-        self.connect_after("map-event", self._hideCursor)
+        self.connect_after("map-event", self._hide_cursor)
         self._goto()
 
     def destroy(self):
+        """Destroy the widget."""
+
         if self._latest_handle is not None:
             env.pixbufLoader.cancel_load(self._latest_handle)
         gtk.Window.destroy(self)
 
-    def get_image_async_cb(self, size):
+    def next(self, *unused):
+        """Show next image."""
+
+        self._goto(1)
+
+    def previous(self, *unused):
+        """Show previous image."""
+
+        self._goto(-1)
+
+    # ----------------------------------------
+
+    def _get_image_async_cb(self, size):
         path = self._image_versions[self._current_index].getLocation()
         if self._latest_handle is not None:
             env.pixbufLoader.cancel_load(self._latest_handle)
@@ -41,38 +71,28 @@ class FullScreenWindow(gtk.Window):
             self._image_view.set_error)
         self._latest_key = (path, size)
 
-    def next(self, *unused):
-        self._goto(1)
-
-    def previous(self, *unused):
-        self._goto(-1)
-
     def _goto(self, direction = 0):
-        new_index =  self._current_index + direction
+        new_index = self._current_index + direction
         if self._is_valid_index(new_index):
             self._current_index = new_index
             self._preload()
-            self._image_view.set_image(self.get_image_async_cb)
+            self._image_view.set_image(self._get_image_async_cb)
 
-    def _hideCursor(self, *unused):
+    def _hide_cursor(self, *unused):
         pix_data = """/* XPM */
-        static char * invisible_xpm[] = {
-        "1 1 1 1",
-        "       c None",
-        " "};"""
+            static char * invisible_xpm[] = {
+            "1 1 1 1",
+            "       c None",
+            " "};
+            """
         color = gtk.gdk.Color()
-        pix = gtk.gdk.pixmap_create_from_data(None,
-                                              pix_data,
-                                              1,
-                                              1,
-                                              1,
-                                              color,
-                                              color)
+        pix = gtk.gdk.pixmap_create_from_data(
+            None, pix_data, 1, 1, 1, color, color)
         invisible_cursor = gtk.gdk.Cursor(pix, pix, color, color, 0, 0)
         self.window.set_cursor(invisible_cursor)
 
     def _is_valid_index(self, index):
-        return index >= 0 and index < len(self._image_versions)
+        return 0 <= index < len(self._image_versions)
 
     def _key_pressed_cb(self, unused, event):
         if event.keyval == gtk.gdk.keyval_from_name("space"):
@@ -105,3 +125,5 @@ class FullScreenWindow(gtk.Window):
             if self._is_valid_index(x):
                 filename = self._image_versions[x].getLocation()
                 env.pixbufLoader.preload(filename, size)
+
+gobject.type_register(FullScreenWindow) # TODO: Not needed in PyGTK 2.8.
index 26dd1a2..c85a8b9 100644 (file)
@@ -163,7 +163,11 @@ class ImageView(gtk.ScrolledWindow):
                 self._available_size.width)
 
     def modify_bg(self, state, color):
-        """ Sets the background color. See gtk.Widget.modify_bg"""
+        """Set the background color.
+
+        See gtk.Widget.modify_bg.
+        """
+
         gtk.ScrolledWindow.modify_bg(self, state, color)
         self._image_widget.modify_bg(state, color)
         self.get_child().modify_bg(state, color)
@@ -475,7 +479,7 @@ if __name__ == "__main__":
     def toggle_prescale_mode(widget):
         imageview.set_prescale_mode(widget.get_active())
 
-    state = State()
+    appstate = State()
 
     window = gtk.Window()
     window.set_default_size(300, 200)
@@ -511,7 +515,7 @@ if __name__ == "__main__":
 
     next_button = gtk.Button(stock=gtk.STOCK_GO_FORWARD)
     control_box.add(next_button)
-    next_button.connect("clicked", state.next_image)
+    next_button.connect("clicked", appstate.next_image)
 
     prescale_checkbutton = gtk.CheckButton("Prescale mode")
     prescale_checkbutton.set_active(True)
@@ -523,5 +527,5 @@ if __name__ == "__main__":
 
     control_window.show_all()
 
-    state.next_image()
+    appstate.next_image()
     gtk.main()
index b3114c5..dcc03fd 100644 (file)
@@ -575,9 +575,9 @@ class ObjectCollection(object):
     def fullScreen(self):
         imageVersions = []
         if len(self.__objectSelection) > 1:
-            for object in self.__objectSelection.getSelectedObjects():
-                if not object.isAlbum():
-                    imageVersions.append(object.getPrimaryVersion())
+            for obj in self.__objectSelection.getSelectedObjects():
+                if not obj.isAlbum():
+                    imageVersions.append(obj.getPrimaryVersion())
             window = FullScreenWindow(imageVersions)
         else:
             index = self.__objectSelection.getLowestSelectedRowNr()
@@ -587,9 +587,9 @@ class ObjectCollection(object):
             nr_of_albums_before_index = 0
             for row in self.getModel():
                 objectId = row[self.COLUMN_OBJECT_ID]
-                object = env.getShelf().getObject(objectId)
-                if not object.isAlbum():
-                    imageVersions.append(object.getPrimaryVersion())
+                obj = env.getShelf().getObject(objectId)
+                if not obj.isAlbum():
+                    imageVersions.append(obj.getPrimaryVersion())
                 elif index > current_row:
                     nr_of_albums_before_index += 1
                 current_row += 1
index 2729978..656cf47 100644 (file)
@@ -19,7 +19,7 @@ class TableView(ObjectCollectionView):
         self.__selectionLocked = False
         self._viewWidget.connect("drag_data_received", self._onDragDataReceived)
         self._viewWidget.connect("drag-data-get", self._onDragDataGet)
-        self._viewWidget.connect("row-activated", self._onRowActivated)
+        self._viewWidget.connect("row-activated", self._onRowActivated_cb)
         self.__userChosenColumns = {}
         self.__createdColumns = {}
         self.__editedCallbacks = {}
@@ -302,7 +302,7 @@ class TableView(ObjectCollectionView):
                 removeSourceRowAutomatically = False
                 dragContext.finish(True, removeSourceRowAutomatically, eventtime)
 
-    def _onRowActivated(self, widget, path, view_column):
+    def _onRowActivated_cb(self, widget, path, view_column):
         model = self._objectCollection.getModel()
         row = model[path]
         if not row[ObjectCollection.COLUMN_IS_ALBUM]:
index 46ef0ef..f02c1ad 100644 (file)
@@ -6,8 +6,7 @@ import os
 import sqlite as sql
 import time
 import kofoto.shelfschema
-from kofoto.shelfexceptions import \
-    ShelfNotFoundError, ShelfLockedError, ShelfNotFoundError
+from kofoto.shelfexceptions import ShelfLockedError, ShelfNotFoundError
 
 def isUpgradable(location):
     """Check whether a shelf is upgradable, i.e. not the latest version."""