More pylint-related changes.
authorJoel Rosdahl <joel@rosdahl.net>
Wed, 28 Sep 2005 19:47:02 +0000 (19:47 +0000)
committerJoel Rosdahl <joel@rosdahl.net>
Wed, 28 Sep 2005 19:47:02 +0000 (19:47 +0000)
21 files changed:
check.py
src/packages/kofoto/gkofoto/albums.py
src/packages/kofoto/gkofoto/categories.py
src/packages/kofoto/gkofoto/controller.py
src/packages/kofoto/gkofoto/crashdialog.py
src/packages/kofoto/gkofoto/duplicateandopenimagedialog.py
src/packages/kofoto/gkofoto/generatehtmldialog.py
src/packages/kofoto/gkofoto/handleimagesdialog.py
src/packages/kofoto/gkofoto/imagepreloader.py
src/packages/kofoto/gkofoto/imageversionsdialog.py
src/packages/kofoto/gkofoto/imageversionslist.py
src/packages/kofoto/gkofoto/imageview.py
src/packages/kofoto/gkofoto/mainwindow.py
src/packages/kofoto/gkofoto/mysortedmodel.py
src/packages/kofoto/gkofoto/objectcollectionview.py
src/packages/kofoto/gkofoto/registerimagesdialog.py
src/packages/kofoto/gkofoto/registerimageversionsdialog.py
src/packages/kofoto/gkofoto/singleobjectview.py
src/packages/kofoto/gkofoto/sortableobjectcollection.py
src/packages/kofoto/gkofoto/taganddescriptiondialog.py
src/packages/kofoto/gkofoto/thumbnailview.py

index 1777260..9b03632 100755 (executable)
--- a/check.py
+++ b/check.py
@@ -3,6 +3,7 @@
 import os
 import sys
 from optparse import OptionParser
+import warnings
 from pylint import lint
 
 def disable_message(arguments, message_id):
@@ -10,6 +11,8 @@ def disable_message(arguments, message_id):
 
 ######################################################################
 
+warnings.filterwarnings("ignore", "logilab.common.compat.Set is deprecated")
+
 option_parser = OptionParser()
 option_parser.add_option(
     "--all",
@@ -34,6 +37,7 @@ else:
 normally_disabled_tests = [
     "C0101", # "Too short variable name."
     "I0011", # "Locally disabling ..."
+    "R0801", # "Similar lines ..."
     "W0131", # "Missing docstring."
     "W0142", # "Used * or ** magic."
     "W0511", # "TODO ..."
index f893f3a..f2853ab 100644 (file)
@@ -1,10 +1,9 @@
 import gtk
 import gobject
-import gtk
-from environment import env
-from albumdialog import AlbumDialog
-from menuhandler import *
-from registerimagesdialog import RegisterImagesDialog
+from kofoto.gkofoto.environment import env
+from kofoto.gkofoto.albumdialog import AlbumDialog
+from kofoto.gkofoto.menuhandler import MenuGroup
+from kofoto.gkofoto.registerimagesdialog import RegisterImagesDialog
 
 class Albums:
 
@@ -21,6 +20,7 @@ class Albums:
     #      a multiple windows feature is introduced.
 
     def __init__(self, mainWindow):
+        self.__menuGroup = None
         self._connectedOids = []
         self.__albumModel = gtk.TreeStore(gobject.TYPE_INT,      # ALBUM_ID
                                           gobject.TYPE_STRING,   # TAG
@@ -30,17 +30,17 @@ class Albums:
         self.__mainWindow = mainWindow
         self.__albumView = env.widgets["albumView"]
         self.__albumView.set_model(self.__albumModel)
-        self.__albumView.connect("focus-in-event", self._treeViewFocusInEvent)
-        self.__albumView.connect("focus-out-event", self._treeViewFocusOutEvent)
+        self.__albumView.connect("focus-in-event", self._treeViewFocusInEvent_cb)
+        self.__albumView.connect("focus-out-event", self._treeViewFocusOutEvent_cb)
         renderer = gtk.CellRendererText()
         column = gtk.TreeViewColumn("Albums", renderer, text=self.__COLUMN_TEXT)
         column.set_clickable(True)
         self.__albumView.append_column(column)
         albumSelection = self.__albumView.get_selection()
-        albumSelection.connect("changed", self._albumSelectionUpdated)
+        albumSelection.connect("changed", self._albumSelectionUpdated_cb)
         albumSelection.set_select_function(self._isSelectable, self.__albumModel)
         self.__contextMenu = self.__createContextMenu()
-        self.__albumView.connect("button_press_event", self._button_pressed)
+        self.__albumView.connect("button_press_event", self._button_pressed_cb)
         self.loadAlbumTree()
         iterator = self.__albumModel.get_iter_first()
         albumSelection.select_iter(iterator)
@@ -60,7 +60,7 @@ class Albums:
     def _isSelectable(self, path, model):
         return model[path][self.__COLUMN_SELECTABLE]
 
-    def _albumSelectionUpdated(self, selection=None, load=True):
+    def _albumSelectionUpdated_cb(self, selection=None, load=True):
         # The focus grab below is made to compensate for what could be
         # some GTK bug. Without the call, the focus-out-event signal
         # sometimes isn't emitted for the view widget in the table
@@ -103,11 +103,11 @@ class Albums:
             env.widgets["menubarDestroy"].set_sensitive(False)
             env.widgets["menubarProperties"].set_sensitive(False)
 
-    def _createChildAlbum(self, *dummies):
+    def _createChildAlbum(self, *unused):
         dialog = AlbumDialog("Create album")
         dialog.run(self._createAlbumHelper)
 
-    def _registerImages(self, *dummies):
+    def _registerImages(self, *unused):
         albumModel, iterator =  self.__albumView.get_selection().get_selected()
         selectedAlbumId = albumModel.get_value(iterator, self.__COLUMN_ALBUM_ID)
         selectedAlbum = env.shelf.getAlbum(selectedAlbumId)
@@ -116,7 +116,7 @@ class Albums:
             self.__mainWindow.reload() # TODO: don't reload everything.
         dialog.destroy()
 
-    def _generateHtml(self, *dummies):
+    def _generateHtml(self, *unused):
         albumModel, iterator =  self.__albumView.get_selection().get_selected()
         selectedAlbumId = albumModel.get_value(iterator, self.__COLUMN_ALBUM_ID)
         selectedAlbum = env.shelf.getAlbum(selectedAlbumId)
@@ -139,7 +139,7 @@ class Albums:
         self.loadAlbumTree()
         # TODO update objectCollection?
 
-    def _destroyAlbum(self, *dummies):
+    def _destroyAlbum(self, *unused):
         dialogId = "destroyAlbumsDialog"
         widgets = gtk.glade.XML(env.gladeFile, dialogId)
         dialog = widgets.get_widget(dialogId)
@@ -153,7 +153,7 @@ class Albums:
             # TODO update objectCollection?
         dialog.destroy()
 
-    def _editAlbum(self, *dummies):
+    def _editAlbum(self, *unused):
         albumModel, iterator =  self.__albumView.get_selection().get_selected()
         selectedAlbumId = albumModel.get_value(iterator, self.__COLUMN_ALBUM_ID)
         dialog = AlbumDialog("Edit album", selectedAlbumId)
@@ -172,15 +172,15 @@ class Albums:
         self.loadAlbumTree()
         # TODO update objectCollection?
 
-    def _button_pressed(self, treeView, event):
+    def _button_pressed_cb(self, treeView, event):
         if event.button == 3:
-            self.__contextMenu.popup(None,None,None,event.button,event.time)
+            self.__contextMenu.popup(None, None, None, event.button, event.time)
             return True
         else:
             return False
 
-    def _treeViewFocusInEvent(self, widget, event):
-        self._albumSelectionUpdated(None, load=False)
+    def _treeViewFocusInEvent_cb(self, widget, event):
+        self._albumSelectionUpdated_cb(None, load=False)
         for widgetName, function in [
                 ("menubarCreateAlbumChild", self._createChildAlbum),
                 ("menubarRegisterAndAddImages", self._registerImages),
@@ -192,7 +192,7 @@ class Albums:
             oid = w.connect("activate", function, None)
             self._connectedOids.append((w, oid))
 
-    def _treeViewFocusOutEvent(self, widget, event):
+    def _treeViewFocusOutEvent_cb(self, widget, event):
         for (widget, oid) in self._connectedOids:
             widget.disconnect(oid)
         self._connectedOids = []
@@ -214,7 +214,9 @@ class Albums:
     __COLUMN_TYPE       = 3
     __COLUMN_SELECTABLE = 4
 
-    def __loadAlbumTreeHelper(self, parentAlbum=None, album=None, visited=[]):
+    def __loadAlbumTreeHelper(self, parentAlbum=None, album=None, visited=None):
+        if visited is None:
+            visited = []
         if not album:
             album = env.shelf.getRootAlbum()
         iterator = self.__albumModel.append(parentAlbum)
index 18891c9..6ee6500 100644 (file)
@@ -2,11 +2,13 @@ import gobject
 import gtk
 import re
 
-from environment import env
-from categorydialog import CategoryDialog
-from menuhandler import *
-from kofoto.search import *
-from kofoto.shelf import *
+from kofoto.gkofoto.environment import env
+from kofoto.gkofoto.categorydialog import CategoryDialog
+from kofoto.gkofoto.menuhandler import MenuGroup
+from kofoto.shelf import \
+    CategoriesAlreadyConnectedError, CategoryLoopError, CategoryPresentError
+from kofoto.alternative import Alternative
+from kofoto.structclass import makeStructClass
 
 class Categories:
 
@@ -18,6 +20,8 @@ class Categories:
         self.__toggleColumn = None
         self.__objectCollection = None
         self.__ignoreSelectEvent = False
+        self.__qsSelectedPath = None
+        self._menubarOids = None
         self.__selectedCategoriesIds  = {}
         self.__categoryModel = gtk.TreeStore(gobject.TYPE_INT,      # CATEGORY_ID
                                              gobject.TYPE_STRING,   # DESCRIPTION
@@ -30,12 +34,12 @@ class Categories:
         self.__categoryView = env.widgets["categoryView"]
         self.__categoryView.realize()
         self.__categoryView.set_model(self.__categoryModel)
-        self.__categoryView.connect("focus-in-event", self._categoryViewFocusInEvent)
-        self.__categoryView.connect("focus-out-event", self._categoryViewFocusOutEvent)
+        self.__categoryView.connect("focus-in-event", self._categoryViewFocusInEvent_cb)
+        self.__categoryView.connect("focus-out-event", self._categoryViewFocusOutEvent_cb)
 
         # Create toggle column
         toggleRenderer = gtk.CellRendererToggle()
-        toggleRenderer.connect("toggled", self._connectionToggled)
+        toggleRenderer.connect("toggled", self._connectionToggled_cb)
         self.__toggleColumn = gtk.TreeViewColumn("",
                                                  toggleRenderer,
                                                  active=self.__COLUMN_CONNECTED,
@@ -58,22 +62,22 @@ class Categories:
             gobject.TYPE_BOOLEAN)  # INCONSISTENT
         self.__categoryQSView = env.widgets["categoryQuickSelectView"]
         self.__categoryQSView.connect(
-            "focus-in-event", self._categoryQSViewFocusInEvent)
+            "focus-in-event", self._categoryQSViewFocusInEvent_cb)
         self.__categoryQSEntry = env.widgets["categoryQuickSelectEntry"]
         self.__categoryQSEntry.connect(
-            "activate", self._categoryQSEntryActivateEvent)
+            "activate", self._categoryQSEntryActivateEvent_cb)
         self.__categoryQSEntry.connect(
-            "changed", self._categoryQSEntryChangedEvent)
+            "changed", self._categoryQSEntryChangedEvent_cb)
         self.__categoryQSButton = env.widgets["categoryQuickSelectButton"]
         self.__categoryQSButton.connect(
-            "clicked", self._categoryQSEntryActivateEvent)
+            "clicked", self._categoryQSEntryActivateEvent_cb)
         self.__categoryQSView.realize()
         self.__categoryQSView.set_model(self.__categoryQSModel)
         self.__categoryQSFreeze = False
 
         # Create toggle column
         toggleRenderer = gtk.CellRendererToggle()
-        toggleRenderer.connect("toggled", self._qsConnectionToggled)
+        toggleRenderer.connect("toggled", self._qsConnectionToggled_cb)
         self.__toggleQSColumn = gtk.TreeViewColumn(
             "",
             toggleRenderer,
@@ -102,32 +106,32 @@ class Categories:
         self._contextMenuGroup.addStockImageMenuItem(
             self.__cutCategoryLabel,
             gtk.STOCK_CUT,
-            self._cutCategory)
+            self._cutCategory_cb)
         self._contextMenuGroup.addStockImageMenuItem(
             self.__copyCategoryLabel,
             gtk.STOCK_COPY,
-            self._copyCategory)
+            self._copyCategory_cb)
         self._contextMenuGroup.addStockImageMenuItem(
             self.__pasteCategoryLabel,
             gtk.STOCK_PASTE,
-            self._pasteCategory)
+            self._pasteCategory_cb)
         self._contextMenuGroup.addStockImageMenuItem(
             self.__destroyCategoryLabel,
             gtk.STOCK_DELETE,
-            self._deleteCategories)
+            self._deleteCategories_cb)
         self._contextMenuGroup.addMenuItem(
             self.__disconnectCategoryLabel,
-            self._disconnectCategory)
+            self._disconnectCategory_cb)
         self._contextMenuGroup.addMenuItem(
             self.__createChildCategoryLabel,
-            self._createChildCategory)
+            self._createChildCategory_cb)
         self._contextMenuGroup.addMenuItem(
             self.__createRootCategoryLabel,
-            self._createRootCategory)
+            self._createRootCategory_cb)
         self._contextMenuGroup.addStockImageMenuItem(
             self.__propertiesLabel,
             gtk.STOCK_PROPERTIES,
-            self._editProperties)
+            self._editProperties_cb)
 
         for item in self._contextMenuGroup:
             self._contextMenu.append(item)
@@ -136,25 +140,25 @@ class Categories:
 
         # Init menubar items.
         env.widgets["menubarDisconnectFromParent"].connect(
-            "activate", self._disconnectCategory, None)
+            "activate", self._disconnectCategory_cb, None)
         env.widgets["menubarCreateChild"].connect(
-            "activate", self._createChildCategory, None)
+            "activate", self._createChildCategory_cb, None)
         env.widgets["menubarCreateRoot"].connect(
-            "activate", self._createRootCategory, None)
+            "activate", self._createRootCategory_cb, None)
 
         # Init selection functions
         categorySelection = self.__categoryView.get_selection()
         categorySelection.set_mode(gtk.SELECTION_MULTIPLE)
-        categorySelection.set_select_function(self._selectionFunction, None)
-        categorySelection.connect("changed", self._categorySelectionChanged)
+        categorySelection.set_select_function(self._selectionFunction_cb, None)
+        categorySelection.connect("changed", self._categorySelectionChanged_cb)
         categoryQSSelection = self.__categoryQSView.get_selection()
         categoryQSSelection.set_mode(gtk.SELECTION_NONE)
 
         # Connect the rest of the UI events
-        self.__categoryView.connect("button_press_event", self._button_pressed)
-        self.__categoryView.connect("button_release_event", self._button_released)
-        self.__categoryView.connect("row-activated", self._rowActivated)
-        env.widgets["categorySearchButton"].connect('clicked', self._executeQuery)
+        self.__categoryView.connect("button_press_event", self._button_pressed_cb)
+        self.__categoryView.connect("button_release_event", self._button_released_cb)
+        self.__categoryView.connect("row-activated", self._rowActivated_cb)
+        env.widgets["categorySearchButton"].connect('clicked', self._executeQuery_cb)
 
         self.loadCategoryTree()
 
@@ -174,7 +178,7 @@ class Categories:
         self.__objectCollection.getObjectSelection().addChangedCallback(self.objectSelectionChanged)
         self.objectSelectionChanged()
 
-    def objectSelectionChanged(self, objectSelection=None):
+    def objectSelectionChanged(self, unused=None):
         self.__updateToggleColumn()
         self.__updateQSToggleColumn()
         self.__updateContextMenu()
@@ -185,32 +189,32 @@ class Categories:
 ###############################################################################
 ### Callback functions registered by this class but invoked from other classes.
 
-    def _executeQuery(self, *foo):
+    def _executeQuery_cb(self, *unused):
         query = self.__buildQueryFromSelection()
         if query:
             self.__mainWindow.loadQuery(query)
 
-    def _categoryViewFocusInEvent(self, widget, event):
+    def _categoryViewFocusInEvent_cb(self, widget, event):
         self._menubarOids = []
         for widgetName, function in [
-                ("menubarCut", lambda *x: self._cutCategory(None, None)),
-                ("menubarCopy", lambda *x: self._copyCategory(None, None)),
-                ("menubarPaste", lambda *x: self._pasteCategory(None, None)),
-                ("menubarDestroy", lambda *x: self._deleteCategories(None, None)),
+                ("menubarCut", lambda *x: self._cutCategory_cb(None, None)),
+                ("menubarCopy", lambda *x: self._copyCategory_cb(None, None)),
+                ("menubarPaste", lambda *x: self._pasteCategory_cb(None, None)),
+                ("menubarDestroy", lambda *x: self._deleteCategories_cb(None, None)),
                 ("menubarClear", lambda *x: widget.get_selection().unselect_all()),
                 ("menubarSelectAll", lambda *x: widget.get_selection().select_all()),
-                ("menubarProperties", lambda *x: self._editProperties(None, None)),
+                ("menubarProperties", lambda *x: self._editProperties_cb(None, None)),
                 ]:
             w = env.widgets[widgetName]
             oid = w.connect("activate", function)
             self._menubarOids.append((w, oid))
         self.__updateContextMenu()
 
-    def _categoryViewFocusOutEvent(self, widget, event):
+    def _categoryViewFocusOutEvent_cb(self, widget, event):
         for (widget, oid) in self._menubarOids:
             widget.disconnect(oid)
 
-    def _categorySelectionChanged(self, selection):
+    def _categorySelectionChanged_cb(self, selection):
         selectedCategoryRows = []
         selection = self.__categoryView.get_selection()
         # TODO replace with "get_selected_rows()" when it is introduced in Pygtk 2.2 API
@@ -229,14 +233,14 @@ class Categories:
             else:
                 parentId = None
             try:
-                 self.__selectedCategoriesIds[cid].append(parentId)
+                self.__selectedCategoriesIds[cid].append(parentId)
             except KeyError:
-                 self.__selectedCategoriesIds[cid] = [parentId]
+                self.__selectedCategoriesIds[cid] = [parentId]
         self.__updateContextMenu()
         env.widgets["categorySearchButton"].set_sensitive(
             len(selectedCategoryRows) > 0)
 
-    def _connectionToggled(self, renderer, path):
+    def _connectionToggled_cb(self, renderer, path):
         categoryRow = self.__categoryModel[path]
         category = env.shelf.getCategory(categoryRow[self.__COLUMN_CATEGORY_ID])
         if categoryRow[self.__COLUMN_INCONSISTENT] \
@@ -257,9 +261,9 @@ class Categories:
         self.__updateToggleColumn()
         self.__updateQSToggleColumn()
 
-    def _button_pressed(self, treeView, event):
+    def _button_pressed_cb(self, treeView, event):
         if event.button == 3:
-            self._contextMenu.popup(None,None,None,event.button,event.time)
+            self._contextMenu.popup(None, None, None, event.button, event.time)
             return True
         rec = self.__categoryView.get_cell_area(0, self.__toggleColumn)
         if event.x <= (rec.x + rec.width):
@@ -267,34 +271,34 @@ class Categories:
             self.__ignoreSelectEvent = True
         return False
 
-    def _button_released(self, treeView, event):
+    def _button_released_cb(self, treeView, event):
         self.__ignoreSelectEvent = False
         return False
 
-    def _rowActivated(self, a, b, c):
+    def _rowActivated_cb(self, a, b, c):
         # TODO What should happen if the user dubble-click on a category?
         pass
 
-    def _copyCategory(self, item, data):
+    def _copyCategory_cb(self, item, data):
         cc = ClipboardCategories()
-        cc.type = cc.COPY
+        cc.type = ClipboardCategoriesType.Copy
         cc.categories = self.__selectedCategoriesIds
         env.clipboard.setCategories(cc)
 
-    def _cutCategory(self, item, data):
+    def _cutCategory_cb(self, item, data):
         cc = ClipboardCategories()
-        cc.type = cc.CUT
+        cc.type = ClipboardCategoriesType.Cut
         cc.categories = self.__selectedCategoriesIds
         env.clipboard.setCategories(cc)
 
-    def _pasteCategory(self, item, data):
+    def _pasteCategory_cb(self, item, data):
         assert env.clipboard.hasCategories()
         clipboardCategories = env.clipboard[0]
         env.clipboard.clear()
         try:
             for (categoryId, previousParentIds) in clipboardCategories.categories.items():
                 for newParentId in self.__selectedCategoriesIds:
-                    if clipboardCategories.type == ClipboardCategories.COPY:
+                    if clipboardCategories.type == ClipboardCategoriesType.Copy:
                         self.__connectChildToCategory(categoryId, newParentId)
                         for parentId in previousParentIds:
                             if parentId is None:
@@ -321,7 +325,7 @@ class Categories:
         self.__updateToggleColumn()
         self.__expandAndCollapseRows(False, False)
 
-    def _createRootCategory(self, item, data):
+    def _createRootCategory_cb(self, item, data):
         dialog = CategoryDialog("Create top-level category")
         dialog.run(self._createRootCategoryHelper)
 
@@ -329,7 +333,7 @@ class Categories:
         category = env.shelf.createCategory(tag, desc)
         self.__loadCategorySubTree(None, category)
 
-    def _createChildCategory(self, item, data):
+    def _createChildCategory_cb(self, item, data):
         dialog = CategoryDialog("Create subcategory")
         dialog.run(self._createChildCategoryHelper)
 
@@ -339,7 +343,7 @@ class Categories:
             self.__connectChildToCategory(newCategory.getId(), selectedCategoryId)
         self.__expandAndCollapseRows(False, False)
 
-    def _deleteCategories(self, item, data):
+    def _deleteCategories_cb(self, item, data):
         dialogId = "destroyCategoriesDialog"
         widgets = gtk.glade.XML(env.gladeFile, dialogId)
         dialog = widgets.get_widget(dialogId)
@@ -363,40 +367,40 @@ class Categories:
         if categoryRow[self.__COLUMN_CATEGORY_ID] == categoryIdToDelete:
             self.__categoryModel.remove(categoryRow.iter)
 
-    def _disconnectCategory(self, item, data):
+    def _disconnectCategory_cb(self, item, data):
         for (categoryId, parentIds) in self.__selectedCategoriesIds.items():
             for parentId in parentIds:
                 if not parentId == None: # Not possible to disconnect root categories
                     self.__disconnectChild(categoryId, parentId)
 
-    def _editProperties(self, item, data):
+    def _editProperties_cb(self, item, data):
         for categoryId in self.__selectedCategoriesIds:
             dialog = CategoryDialog("Change properties", categoryId)
             dialog.run(self._editPropertiesHelper, data=categoryId)
 
     def _editPropertiesHelper(self, tag, desc, categoryId):
-         category = env.shelf.getCategory(categoryId)
-         category.setTag(tag)
-         category.setDescription(desc)
-         env.shelf.flushCategoryCache()
-         self.__forEachCategoryRow(self.__updatePropertiesFromShelf, categoryId)
+        category = env.shelf.getCategory(categoryId)
+        category.setTag(tag)
+        category.setDescription(desc)
+        env.shelf.flushCategoryCache()
+        self.__forEachCategoryRow(self.__updatePropertiesFromShelf, categoryId)
 
-    def _selectionFunction(self, path, b):
+    def _selectionFunction_cb(self, path, b):
         return not self.__ignoreSelectEvent
 
-    def _categoryQSViewFocusInEvent(self, widget, event):
+    def _categoryQSViewFocusInEvent_cb(self, widget, event):
         self.__categoryQSEntry.grab_focus()
 
-    def _categoryQSEntryActivateEvent(self, entry):
+    def _categoryQSEntryActivateEvent_cb(self, entry):
         if not self.__qsSelectedPath:
             return
-        self._qsConnectionToggled(None, self.__qsSelectedPath)
+        self._qsConnectionToggled_cb(None, self.__qsSelectedPath)
         self.__categoryQSFreeze = True
         self.__categoryQSEntry.set_text("")
         self.__categoryQSFreeze = False
         self.__qsSelectedPath = None
 
-    def _categoryQSEntryChangedEvent(self, entry):
+    def _categoryQSEntryChangedEvent_cb(self, entry):
         if self.__categoryQSFreeze:
             return
         self.__categoryQSModel.clear()
@@ -429,7 +433,7 @@ class Categories:
             self.__categoryQSButton.set_sensitive(True)
         self.__updateQSToggleColumn()
 
-    def _qsConnectionToggled(self, renderer, path):
+    def _qsConnectionToggled_cb(self, renderer, path):
         categoryRow = self.__categoryQSModel[path]
         category = env.shelf.getCategory(
             categoryRow[self.__COLUMN_CATEGORY_ID])
@@ -537,7 +541,7 @@ class Categories:
                 try:
                     nrSelectedObjectsInCategory[categoryId] += 1
                 except KeyError:
-                        nrSelectedObjectsInCategory[categoryId] = 1
+                    nrSelectedObjectsInCategory[categoryId] = 1
         self.__forEachCategoryRow(self.__updateToggleColumnHelper,
                                   (nrSelectedObjects, nrSelectedObjectsInCategory))
 
@@ -579,14 +583,14 @@ class Categories:
         # We can't use gtk.TreeModel.foreach() since it does not pass a row
         # to the callback function.
         if not categoryRows:
-            categoryRows=self.__categoryModel
+            categoryRows = self.__categoryModel
         for categoryRow in categoryRows:
             function(categoryRow, data)
             self.__forEachCategoryRow(function, data, categoryRow.iterchildren())
 
     def __expandAndCollapseRows(self, autoExpand, autoCollapse, categoryRows=None):
         if categoryRows is None:
-            categoryRows=self.__categoryModel
+            categoryRows = self.__categoryModel
         someRowsExpanded = False
         for categoryRow in categoryRows:
             expandThisRow = False
@@ -685,8 +689,5 @@ class Categories:
             (x.getDescription(), x.getTag()),
             (y.getDescription(), y.getTag()))
 
-class ClipboardCategories:
-    COPY = 1
-    CUT = 2
-    categories = None
-    type = None
+ClipboardCategoriesType = Alternative("Copy", "Cut")
+ClipboardCategories = makeStructClass("categories", "type")
index 51b4a3a..c15325c 100644 (file)
@@ -1,4 +1,3 @@
-import sys
 import gtk
 from kofoto.shelf import ShelfLockedError, UnsupportedShelfError
 from kofoto.gkofoto.mainwindow import MainWindow
@@ -7,6 +6,7 @@ from kofoto.gkofoto.environment import env
 class Controller:
     def __init__(self):
         self.__clipboard = None
+        self.__mainWindow = None
 
     def start(self, setupOk):
         if setupOk:
@@ -66,11 +66,11 @@ class Controller:
             dialog.run()
         if setupOk:
             self.__mainWindow = MainWindow()
-            env.widgets["mainWindow"].connect("destroy", self.quit, False)
+            env.widgets["mainWindow"].connect("destroy", self.quit_cb, False)
             env.widgets["mainWindow"].show()
             gtk.main()
 
-    def quit(self, app, cancelButton=True):
+    def quit_cb(self, app, cancelButton=True):
         if env.shelf.isModified():
             widgets = gtk.glade.XML(env.gladeFile, "quitDialog")
             quitDialog = widgets.get_widget("quitDialog")
@@ -90,11 +90,11 @@ class Controller:
             env.shelf.rollback()
             self._doQuit()
 
-    def save(self, app):
+    def save_cb(self, app):
         env.shelf.commit()
         env.shelf.begin()
 
-    def revert(self, app):
+    def revert_cb(self, app):
         dialog = gtk.MessageDialog(
             type=gtk.MESSAGE_QUESTION,
             buttons=gtk.BUTTONS_YES_NO,
index 4995c4b..280bfc5 100644 (file)
@@ -1,4 +1,5 @@
-import pygtk
+# pylint: disable-msg=F0203, E0201
+
 import gtk
 import pango
 import linecache
@@ -25,7 +26,7 @@ class CrashDialog(gtk.Dialog):
 
         button = gtk.Button(stock=gtk.STOCK_SAVE)
         button.show()
-        button.connect("clicked", self._save)
+        button.connect("clicked", self._save_cb)
         self.action_area.pack_start(button)
         self.action_area.reorder_child(button, 0)
 
@@ -65,7 +66,7 @@ class CrashDialog(gtk.Dialog):
         sw.add(textview)
         textview.show()
 
-    def _save(self, widget):
+    def _save_cb(self, widget):
         filechooser = gtk.FileChooserDialog(
             "Save crash log",
             self,
index 2957c9b..88200e7 100644 (file)
@@ -1,13 +1,12 @@
-import glob
+import gtk
 import os
 import shutil
 
-import gtk
-
-from environment import env
+from kofoto.gkofoto.environment import env
 
 class DuplicateAndOpenImageDialog:
     def __init__(self):
+        self._imageversion = None
         self._widgets = gtk.glade.XML(
             env.gladeFile, "duplicateAndOpenImageDialog")
         self._dialog = self._widgets.get_widget("duplicateAndOpenImageDialog")
index 8fd5c64..99ddf50 100644 (file)
@@ -2,7 +2,7 @@ import gtk
 import os
 import re
 from sets import Set
-from environment import env
+from kofoto.gkofoto.environment import env
 import kofoto.generate
 
 class GenerateHTMLDialog:
@@ -33,7 +33,6 @@ class GenerateHTMLDialog:
             os.path.isdir(self.directoryTextEntry.get_text()))
 
     def _onBrowse(self, *unused):
-        directorySelectedInDirList = False
         dirDialog = gtk.FileChooserDialog(
             title="Choose directory",
             action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
index d499d06..b5fd72a 100644 (file)
@@ -1,3 +1,5 @@
+# pylint: disable-msg=F0203, E0201
+
 import gobject
 import gtk
 from kofoto.timer import Timer
@@ -86,8 +88,6 @@ class ImagePreloader(object):
 
         The pixbuf may be None if the image was unloadable.
         """
-        pixbuf = None
-
         if not self.__preloadStates.has_key(filename):
             self.__preloadStates[filename] = _PreloadState(
                 filename, self._fileSystemCodeset)
@@ -131,7 +131,6 @@ class ImagePreloader(object):
         # Discard old preloaded images.
         for filename in self.__preloadStates.keys():
             if not filename in filenames:
-                pixbufLoader = self.__preloadStates[filename].pixbufLoader
                 del self.__preloadStates[filename]
 
         # Preload the new images.
index 776ee79..cfbaaa5 100644 (file)
@@ -1,10 +1,7 @@
 import gtk
-import os
-import re
-from environment import env
+from kofoto.gkofoto.environment import env
 from kofoto.structclass import makeStructClass
 from kofoto.shelf import CategoryPresentError, ImageVersionType
-from sets import Set
 
 RowDataStruct = makeStructClass(
     "imageVersion",
@@ -18,6 +15,8 @@ class ImageVersionsDialog:
     tableWidth = 3
 
     def __init__(self, model):
+        self._mergeImages = []
+        self._isMerge = False
         self._model = model
         self._versionDataList = []
         self._widgets = gtk.glade.XML(
@@ -53,7 +52,7 @@ class ImageVersionsDialog:
                 self._addRow(imageVersion)
         self._table.show_all()
         x, y = self._dialog.get_position()
-        width, height = self._dialog.get_size()
+        _, height = self._dialog.get_size()
         hackyConstant = 89 # TODO: How to calculate this properly?
         newheight = min(800, self._table.size_request()[1] + hackyConstant)
         self._dialog.move(x, max(0, y - ((newheight - height) / 2)))
@@ -64,7 +63,6 @@ class ImageVersionsDialog:
         self._dialog.destroy()
 
     def _onOk(self, *unused):
-        t = self._table
         for data in self._versionDataList:
             tb = data.commentTextBuffer
             comment = tb.get_text(tb.get_start_iter(), tb.get_end_iter())
@@ -80,7 +78,6 @@ class ImageVersionsDialog:
             else:
                 assert False
 
-        proceed = True
         if self._isMerge:
             #
             # The mother image below is the image of the primary
@@ -161,7 +158,7 @@ class ImageVersionsDialog:
         #
         image = gtk.Image()
         try:
-            thumbnailLocation, w, h = env.imageCache.get(
+            thumbnailLocation, _, _ = env.imageCache.get(
                 imageVersion.getLocation().encode(env.codeset), 128, 128)
             image.set_from_file(thumbnailLocation.decode(env.codeset))
         except OSError:
index 4a5fc92..13fe9b0 100644 (file)
@@ -1,13 +1,14 @@
+# pylint: disable-msg=F0203, E0201
+
 import os
 import gtk
-
-from environment import env
-from kofoto.shelf import ImageVersionType
-from kofoto.gkofoto.menuhandler import MenuGroup
-from imageversionsdialog import ImageVersionsDialog
 from sets import Set as set
 from kofoto.alternative import Alternative
-from duplicateandopenimagedialog import DuplicateAndOpenImageDialog
+from kofoto.shelf import ImageVersionType
+from kofoto.gkofoto.environment import env
+from kofoto.gkofoto.menuhandler import MenuGroup
+from kofoto.gkofoto.imageversionsdialog import ImageVersionsDialog
+from kofoto.gkofoto.duplicateandopenimagedialog import DuplicateAndOpenImageDialog
 
 _imageVersionTypeToStringMap = {
     ImageVersionType.Important: "Important",
@@ -20,6 +21,10 @@ _rotationDirection = Alternative("Left", "Right")
 class ImageVersionsList(gtk.ScrolledWindow):
     def __init__(self, singleObjectView, imageView):
         gtk.ScrolledWindow.__init__(self)
+        self.__menuGroup = None
+        self.__imageWidgetToImageVersion = None
+        self.__imageWidgetList = None
+        self.__selectedImageWidgets = None
         self.__singleObjectView = singleObjectView
         self.__imageView = imageView
         self.__vbox = gtk.VBox()
@@ -31,21 +36,21 @@ class ImageVersionsList(gtk.ScrolledWindow):
         self.__image = None
         self.__tooltips = gtk.Tooltips()
         self.__recentlySelectedImageWidget = None
-        self.connect("focus-in-event", self.__focusInEventHandler)
-        self.connect("focus-out-event", self.__focusOutEventHandler)
+        self.connect("focus-in-event", self.__focusInEventHandler_cb)
+        self.connect("focus-out-event", self.__focusOutEventHandler_cb)
         self.__contextMenu = self.__createContextMenu()
         self.clear()
 
         callbacks = [
-            ("menubarViewImageVersion", self.__view),
-            ("menubarCopyImageVersionLocations", self.__copyImageLocation),
-            ("menubarOpenImageVersions", self.__open),
-            ("menubarDuplicateAndOpenImageVersion", self.__duplicateAndOpen),
-            ("menubarRotateImageVersionLeft", self.__rotateLeft),
-            ("menubarRotateImageVersionRight", self.__rotateRight),
-            ("menubarSplitToIndependentImages", self.__split),
-            ("menubarDestroyImageVersion", self.__destroy),
-            ("menubarEditImageVersionProperties", self.__editProperties),
+            ("menubarViewImageVersion", self.__view_cb),
+            ("menubarCopyImageVersionLocations", self.__copyImageLocation_cb),
+            ("menubarOpenImageVersions", self.__open_cb),
+            ("menubarDuplicateAndOpenImageVersion", self.__duplicateAndOpen_cb),
+            ("menubarRotateImageVersionLeft", self.__rotateLeft_cb),
+            ("menubarRotateImageVersionRight", self.__rotateRight_cb),
+            ("menubarSplitToIndependentImages", self.__split_cb),
+            ("menubarDestroyImageVersion", self.__destroy_cb),
+            ("menubarEditImageVersionProperties", self.__editProperties_cb),
             ]
         for widgetName, callback in callbacks:
             env.widgets[widgetName].connect("activate", callback)
@@ -78,9 +83,9 @@ class ImageVersionsList(gtk.ScrolledWindow):
             eventbox = gtk.EventBox()
             eventbox.add(alignment)
             eventbox.connect(
-                "button-press-event", self.__mouseButtonPressed)
+                "button-press-event", self.__mouseButtonPressed_cb)
             eventbox.connect_after(
-                "expose-event", self.__imageWidgetExposed)
+                "expose-event", self.__imageWidgetExposed_cb)
             tooltipText = "Location: " + iv.getLocation()
             if iv.getComment():
                 tooltipText += "\nComment: " + iv.getComment()
@@ -101,39 +106,39 @@ class ImageVersionsList(gtk.ScrolledWindow):
         menugroup = MenuGroup()
         menugroup.addMenuItem(
             "View",
-            self.__view)
+            self.__view_cb)
         menugroup.addMenuItem(
             "Copy image version location(s)",
-            self.__copyImageLocation)
+            self.__copyImageLocation_cb)
         menugroup.addStockImageMenuItem(
             "Open image version(s) in external program...",
             gtk.STOCK_OPEN,
-            self.__open)
+            self.__open_cb)
         menugroup.addStockImageMenuItem(
             "Duplicate and open image version(s) in external program...",
             gtk.STOCK_OPEN,
-            self.__duplicateAndOpen)
+            self.__duplicateAndOpen_cb)
         menugroup.addImageMenuItem(
             "Rotate left",
             os.path.join(env.iconDir, "rotateleft.png"),
-            self.__rotateLeft)
+            self.__rotateLeft_cb)
         menugroup.addImageMenuItem(
             "Rotate right",
             os.path.join(env.iconDir, "rotateright.png"),
-            self.__rotateRight)
+            self.__rotateRight_cb)
         menugroup.addSeparator()
         menugroup.addMenuItem(
             "Split to independent image(s)",
-            self.__split)
+            self.__split_cb)
         menugroup.addSeparator()
         menugroup.addStockImageMenuItem(
             "Destroy...",
             gtk.STOCK_DELETE,
-            self.__destroy)
+            self.__destroy_cb)
         menugroup.addStockImageMenuItem(
             "Edit properties...",
             gtk.STOCK_PROPERTIES,
-            self.__editProperties)
+            self.__editProperties_cb)
         for item in menugroup:
             menu.add(item)
         self.__menuGroup = menugroup
@@ -177,7 +182,7 @@ class ImageVersionsList(gtk.ScrolledWindow):
             if allSelected:
                 self.__menuGroup["Split to independent image(s)"].set_sensitive(False)
 
-    def __mouseButtonPressed(self, widget, event):
+    def __mouseButtonPressed_cb(self, widget, event):
         def selectWidget(widget):
             widget.set_state(gtk.STATE_SELECTED)
             self.__selectedImageWidgets.add(widget)
@@ -215,7 +220,7 @@ class ImageVersionsList(gtk.ScrolledWindow):
             elif event.type == gtk.gdk._2BUTTON_PRESS:
                 if (event.state & (
                         gtk.gdk.CONTROL_MASK | gtk.gdk.SHIFT_MASK) == 0):
-                    self.__view()
+                    self.__view_cb()
         elif event.button == 3:
             if widget in self.__selectedImageWidgets:
                 selectThisToo()
@@ -228,7 +233,7 @@ class ImageVersionsList(gtk.ScrolledWindow):
         self.__recentlySelectedImageWidget = widget
         self.__updateMenus()
 
-    def __imageWidgetExposed(self, widget, event):
+    def __imageWidgetExposed_cb(self, widget, event):
         if widget == self.__recentlySelectedImageWidget:
             state = gtk.STATE_SELECTED
             allocation = widget.get_allocation()
@@ -238,13 +243,13 @@ class ImageVersionsList(gtk.ScrolledWindow):
         else:
             state = gtk.STATE_NORMAL
 
-    def __view(self, *args):
+    def __view_cb(self, *args):
         assert len(self.__selectedImageWidgets) == 1
         widget = list(self.__selectedImageWidgets)[0]
         imageVersion = self.__imageWidgetToImageVersion[widget]
         self.__imageView.loadFile(imageVersion.getLocation())
 
-    def __copyImageLocation(self, widget, param):
+    def __copyImageLocation_cb(self, widget, param):
         assert len(self.__selectedImageWidgets) > 0
         clipboard = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD)
         primary = gtk.clipboard_get(gtk.gdk.SELECTION_PRIMARY)
@@ -254,7 +259,7 @@ class ImageVersionsList(gtk.ScrolledWindow):
         clipboard.set_text(location)
         primary.set_text(location)
 
-    def __open(self, *args):
+    def __open_cb(self, *args):
         assert len(self.__selectedImageWidgets) > 0
         locations = [
             self.__imageWidgetToImageVersion[x].getLocation()
@@ -269,14 +274,14 @@ class ImageVersionsList(gtk.ScrolledWindow):
             dialog.run()
             dialog.destroy()
 
-    def __duplicateAndOpen(self, *args):
+    def __duplicateAndOpen_cb(self, *args):
         assert len(self.__selectedImageWidgets) == 1
         imageWidget = list(self.__selectedImageWidgets)[0]
         imageVersion = self.__imageWidgetToImageVersion[imageWidget]
         dialog = DuplicateAndOpenImageDialog()
         dialog.run(imageVersion)
 
-    def __split(self, *args):
+    def __split_cb(self, *args):
         assert len(self.__selectedImageWidgets) > 0
         assert len(self.__selectedImageWidgets) < len(self.__imageWidgetList)
         for widget in self.__selectedImageWidgets:
@@ -289,15 +294,15 @@ class ImageVersionsList(gtk.ScrolledWindow):
                 image.addCategory(category)
         self.__singleObjectView.reload()
 
-    def __rotateLeft(self, *args):
+    def __rotateLeft_cb(self, *args):
         assert len(self.__selectedImageWidgets) > 0
         self.__rotate(_rotationDirection.Left)
 
-    def __rotateRight(self, *args):
+    def __rotateRight_cb(self, *args):
         assert len(self.__selectedImageWidgets) > 0
         self.__rotate(_rotationDirection.Right)
 
-    def __destroy(self, *args):
+    def __destroy_cb(self, *args):
         assert len(self.__selectedImageWidgets) > 0
         widgets = gtk.glade.XML(env.gladeFile, "destroyImageVersionsDialog")
         dialog = widgets.get_widget("destroyImageVersionsDialog")
@@ -318,17 +323,17 @@ class ImageVersionsList(gtk.ScrolledWindow):
             self.__singleObjectView.reload()
         dialog.destroy()
 
-    def __editProperties(self, *args):
+    def __editProperties_cb(self, *args):
         assert len(self.__selectedImageWidgets) > 0
         dialog = ImageVersionsDialog(self.__singleObjectView._objectCollection)
         dialog.runViewImageVersions(self.__image)
         self.__singleObjectView.reload()
 
-    def __focusInEventHandler(self, widget, event):
+    def __focusInEventHandler_cb(self, widget, event):
         for x in self.__selectedImageWidgets:
             x.set_state(gtk.STATE_SELECTED)
 
-    def __focusOutEventHandler(self, widget, event):
+    def __focusOutEventHandler_cb(self, widget, event):
         for x in self.__selectedImageWidgets:
             x.set_state(gtk.STATE_ACTIVE)
 
index e481541..2ae3510 100644 (file)
@@ -1,9 +1,10 @@
+# pylint: disable-msg=F0203, E0201
+
 import gtk
 import gtk.gdk
 import math
-import gobject
 import gc
-from environment import env
+from kofoto.gkofoto.environment import env
 from kofoto.common import calculateDownscaledDimensions
 
 class ImageView(gtk.ScrolledWindow):
@@ -19,6 +20,7 @@ class ImageView(gtk.ScrolledWindow):
     def __init__(self):
         self._image = gtk.Image()
         gtk.ScrolledWindow.__init__(self)
+        self._newImageLoaded = False
         self.__loadedFileName = None
         self.__pixBuf = None
         self.__currentZoom = None
@@ -36,19 +38,19 @@ class ImageView(gtk.ScrolledWindow):
 
         self.add_with_viewport(eventBox)
         self.add_events(gtk.gdk.ALL_EVENTS_MASK)
-        self.connect_after("size-allocate", self.resizeEventHandler)
-        self.connect("scroll-event", self.scrollEventHandler)
-        self.connect("focus-in-event", self.focusInEventHandler)
-        self.connect("focus-out-event", self.focusOutEventHandler)
+        self.connect_after("size-allocate", self.resizeEventHandler_cb)
+        self.connect("scroll-event", self.scrollEventHandler_cb)
+        self.connect("focus-in-event", self.focusInEventHandler_cb)
+        self.connect("focus-out-event", self.focusOutEventHandler_cb)
 
-    def focusInEventHandler(self, widget, event):
+    def focusInEventHandler_cb(self, widget, event):
         pass
 
-    def focusOutEventHandler(self, widget, event):
+    def focusOutEventHandler_cb(self, widget, event):
         pass
 
-    def loadFile(self, fileName, reload=True):
-        if (not reload) and self.__loadedFileName == fileName:
+    def loadFile(self, fileName, reloadFile=True):
+        if (not reloadFile) and self.__loadedFileName == fileName:
             return
         self.clear()
         env.debug("ImageView is loading image from file: " + fileName)
@@ -66,7 +68,7 @@ class ImageView(gtk.ScrolledWindow):
             self.__loadedFileName = None
         self._newImageLoaded = True
         self._image.show()
-        self.fitToWindow()
+        self.fitToWindow_cb()
 
     def clear(self):
         self._image.hide()
@@ -119,17 +121,17 @@ class ImageView(gtk.ScrolledWindow):
         self.__currentZoom = self.__wantedZoom
         gc.collect()
 
-    def resizeEventHandler(self, widget, gdkEvent):
+    def resizeEventHandler_cb(self, widget, gdkEvent):
         if self.__fitToWindowMode:
-            x, y, width, height = self.get_allocation()
+            _, _, width, height = self.get_allocation()
             if height != self.__previousWidgetHeight or width != self.__previousWidgetWidth:
-                self.fitToWindow()
+                self.fitToWindow_cb()
         return False
 
-    def fitToWindow(self, *foo):
+    def fitToWindow_cb(self, *unused):
         self.__fitToWindowMode = True
         self.set_policy(gtk.POLICY_NEVER, gtk.POLICY_NEVER)
-        y, x, widgetWidth, widgetHeight = self.get_allocation()
+        _, _, widgetWidth, widgetHeight = self.get_allocation()
         if self.__pixBuf != None:
             self.__previousWidgetWidth = widgetWidth
             self.__previousWidgetHeight = widgetHeight
@@ -146,32 +148,32 @@ class ImageView(gtk.ScrolledWindow):
     def _log(self, base, value):
         return math.log(value) / math.log(base)
 
-    def zoomIn(self, *foo):
+    def zoomIn_cb(self, *unused):
         self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
         self.__fitToWindowMode = False
         if self.__wantedZoom <= self._MAX_ZOOM:
             self.__wantedZoom = math.floor(self.__wantedZoom + 1)
             self.renderImage()
 
-    def zoomOut(self, *foo):
+    def zoomOut_cb(self, *unused):
         self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
         self.__fitToWindowMode = False
         if self.__wantedZoom >= self._MIN_ZOOM:
             self.__wantedZoom = math.ceil(self.__wantedZoom - 1)
             self.renderImage()
 
-    def zoom100(self, *foo):
+    def zoom100_cb(self, *unused):
         self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
         self.__fitToWindowMode = False
         self.__wantedZoom = 0
         self.renderImage()
 
-    def scrollEventHandler(self, widget, gdkEvent):
+    def scrollEventHandler_cb(self, widget, gdkEvent):
         if gdkEvent.type == gtk.gdk.SCROLL:
             if gdkEvent.direction == gtk.gdk.SCROLL_UP:
-                self.zoomOut()
+                self.zoomOut_cb()
             elif gdkEvent.direction == gtk.gdk.SCROLL_DOWN:
-                self.zoomIn()
+                self.zoomIn_cb()
             return True
         else:
             return False
index bcf9a64..bfb4320 100644 (file)
@@ -1,3 +1,5 @@
+# pylint: disable-msg=F0203, E0201
+
 import gtk
 import gtk.gdk
 import os
@@ -48,11 +50,11 @@ class MainWindow(gtk.Window):
         env.widgets["zoomIn"].set_sensitive(False)
         env.widgets["zoomOut"].set_sensitive(False)
 
-        env.widgets["menubarSave"].connect("activate", env.controller.save)
+        env.widgets["menubarSave"].connect("activate", env.controller.save_cb)
         env.widgets["menubarSave"].set_sensitive(False)
-        env.widgets["menubarRevert"].connect("activate", env.controller.revert)
+        env.widgets["menubarRevert"].connect("activate", env.controller.revert_cb)
         env.widgets["menubarRevert"].set_sensitive(False)
-        env.widgets["menubarQuit"].connect("activate", env.controller.quit)
+        env.widgets["menubarQuit"].connect("activate", env.controller.quit_cb)
 
         env.widgets["menubarThumbnailsView"].hide()
 
index 8a6585d..1c20ce8 100644 (file)
@@ -1,3 +1,5 @@
+# pylint: disable-msg=F0203, E0201
+
 import gtk
 
 class MySortedModel(gtk.TreeModelSort):
@@ -20,9 +22,9 @@ class MySortedModel(gtk.TreeModelSort):
         else:
             raise IndexError
 
-    def set_value(self, iter, column, value):
+    def set_value(self, iterator, column, value):
         childIter = self._model.get_iter_first()
-        self.convert_iter_to_child_iter(childIter, iter)
+        self.convert_iter_to_child_iter(childIter, iterator)
         self._model.set_value(childIter, column, value)
 
     # Workaround until http://bugzilla.gnome.org/show_bug.cgi?id=121633 is solved.
index f87d9eb..ea21fdc 100644 (file)
@@ -1,7 +1,9 @@
 import gtk
-from environment import env
-from menuhandler import *
-from objectcollection import *
+import os
+from kofoto.gkofoto.environment import env
+from kofoto.gkofoto.menuhandler import MenuGroup
+from kofoto.gkofoto.objectcollection import ObjectCollection
+from kofoto.common import UnimplementedError
 
 class ObjectCollectionView:
 
@@ -15,6 +17,13 @@ class ObjectCollectionView:
         self.__objectCollectionLoaded = False
         self.__hidden = True
         self.__connections = []
+        self.__singleImageMenuGroup = None
+        self.__objectMenuGroup = None
+        self.__multipleImagesMenuGroup = None
+        self.__sortMenuGroup = None
+        self.__albumMenuGroup = None
+        self.__clipboardMenuGroup = None
+        self.__imageMenuGroup = None
 
     def show(self, objectCollection):
         if self.__hidden:
@@ -117,7 +126,31 @@ class ObjectCollectionView:
             return False
 
 ##############################################################################
-### Methods used by and overloaded by subbclasses
+### Methods used by and overloaded by subclasses
+
+    def _hasFocus(self):
+        raise UnimplementedError
+
+    def _showHelper(self):
+        raise UnimplementedError
+
+    def _hideHelper(self):
+        raise UnimplementedError
+
+    def _freezeHelper(self):
+        raise UnimplementedError
+
+    def _thawHelper(self):
+        raise UnimplementedError
+
+    def _connectObjectCollectionHelper(self):
+        raise UnimplementedError
+
+    def _disconnectObjectCollectionHelper(self):
+        raise UnimplementedError
+
+    def importSelection(self, objectCollection):
+        raise UnimplementedError
 
     def _connect(self, obj, signal, function, data=None):
         oid = obj.connect(signal, function, data)
@@ -168,7 +201,7 @@ class ObjectCollectionView:
         self.__multipleImagesMenuGroup = None
         self.__sortMenuGroup = None
 
-    def _updateContextMenu(self, *foo):
+    def _updateContextMenu(self, *unused):
         if not self._hasFocus():
             return
         env.debug("Updating context menu")
@@ -196,7 +229,6 @@ class ObjectCollectionView:
                 else:
                     imagesSelected += 1
 
-            modifiable = mutable and not loading
             self.__clipboardMenuGroup[self._objectCollection.getCutLabel()].set_sensitive(mutable and not loading)
             env.widgets["menubarCut"].set_sensitive(mutable and not loading)
             self.__clipboardMenuGroup[self._objectCollection.getCopyLabel()].set_sensitive(True)
index 753e86c..7f82e10 100644 (file)
@@ -4,7 +4,7 @@ import sets
 
 import gtk
 
-from environment import env
+from kofoto.gkofoto.environment import env
 from kofoto.shelf import \
     ImageVersionDoesNotExistError, \
     ImageVersionExistsError, \
@@ -13,6 +13,7 @@ from kofoto.shelf import \
 
 class RegisterImageVersionsDialog:
     def __init__(self, model):
+        self._image = None
         self._model = model
         self._widgets = gtk.glade.XML(
             env.gladeFile, "registerImageVersionsDialog")
@@ -39,7 +40,7 @@ class RegisterImageVersionsDialog:
         files = sets.Set()
         for imageversion in image.getImageVersions():
             base, filename = os.path.split(imageversion.getLocation())
-            prefix, suffix = os.path.splitext(filename)
+            prefix, _ = os.path.splitext(filename)
             for candidateFilename in os.listdir(base):
                 if (re.match("%s[^a-zA-Z0-9].*" % prefix, candidateFilename)):
                     candidatePath = os.path.join(base, candidateFilename)
@@ -56,7 +57,7 @@ class RegisterImageVersionsDialog:
 
     def _onOk(self, *unused):
         selection = self._fileListView.get_selection()
-        model, selectedRows = selection.get_selected_rows()
+        _, selectedRows = selection.get_selected_rows()
         changed = False
         for path in selectedRows:
             treeiter = self._fileListStore.get_iter(path)
index cd4d514..a3a5cd7 100644 (file)
@@ -1,3 +1,5 @@
+# pylint: disable-msg=F0203, E0201
+
 import gtk
 from kofoto.gkofoto.environment import env
 from kofoto.gkofoto.imageview import ImageView
@@ -28,15 +30,15 @@ class SingleObjectView(ObjectCollectionView, gtk.HPaned):
         env.widgets["menubarNextImage"].connect("activate", self._goto, 1)
         env.widgets["previousButton"].connect("clicked", self._goto, -1)
         env.widgets["menubarPreviousImage"].connect("activate", self._goto, -1)
-        env.widgets["zoomToFit"].connect("clicked", self.__imageView.fitToWindow)
-        env.widgets["menubarZoomToFit"].connect("activate", self.__imageView.fitToWindow)
-        env.widgets["zoom100"].connect("clicked", self.__imageView.zoom100)
-        env.widgets["menubarActualSize"].connect("activate", self.__imageView.zoom100)
-        env.widgets["zoomIn"].connect("clicked", self.__imageView.zoomIn)
-        env.widgets["menubarZoomIn"].connect("activate", self.__imageView.zoomIn)
-        env.widgets["zoomOut"].connect("clicked", self.__imageView.zoomOut)
-        env.widgets["menubarZoomOut"].connect("activate", self.__imageView.zoomOut)
-        env.widgets["mainWindow"].connect("key_press_event", self._key_pressed)
+        env.widgets["zoomToFit"].connect("clicked", self.__imageView.fitToWindow_cb)
+        env.widgets["menubarZoomToFit"].connect("activate", self.__imageView.fitToWindow_cb)
+        env.widgets["zoom100"].connect("clicked", self.__imageView.zoom100_cb)
+        env.widgets["menubarActualSize"].connect("activate", self.__imageView.zoom100_cb)
+        env.widgets["zoomIn"].connect("clicked", self.__imageView.zoomIn_cb)
+        env.widgets["menubarZoomIn"].connect("activate", self.__imageView.zoomIn_cb)
+        env.widgets["zoomOut"].connect("clicked", self.__imageView.zoomOut_cb)
+        env.widgets["menubarZoomOut"].connect("activate", self.__imageView.zoomOut_cb)
+        env.widgets["mainWindow"].connect("key_press_event", self._key_pressed_cb)
         env.widgets["menubarViewDetailsPane"].set_sensitive(True)
         self.__loadedObject = False
         self.__selectionLocked = False
@@ -194,7 +196,7 @@ class SingleObjectView(ObjectCollectionView, gtk.HPaned):
         env.mainwindow.getImagePreloader().preloadImages(
             filenames, maxWidth, maxHeight)
 
-    def _key_pressed(self, unused, event):
+    def _key_pressed_cb(self, unused, event):
         # TODO use UiManager instead of this...
         if event.state & gtk.gdk.CONTROL_MASK:
             if (event.keyval == gtk.gdk.keyval_from_name("space") and
index 18bf3e3..48b3b28 100644 (file)
@@ -1,7 +1,7 @@
 import gtk
-from environment import env
-from mysortedmodel import *
-from objectcollection import *
+from kofoto.gkofoto.environment import env
+from kofoto.gkofoto.mysortedmodel import MySortedModel
+from kofoto.gkofoto.objectcollection import ObjectCollection
 
 def attributeSortFunc(model, iterA, iterB, column):
     valueA = model.get_value(iterA, column)
index 6b69cdd..07eabf9 100644 (file)
@@ -1,8 +1,7 @@
 import gtk
-import string
 import re
-from environment import env
-from kofoto.shelf import *
+from kofoto.gkofoto.environment import env
+from kofoto.common import UnimplementedError
 
 class TagAndDescriptionDialog:
     def __init__(self, title, tagText=u"", descText=u""):
@@ -37,32 +36,17 @@ class TagAndDescriptionDialog:
         else:
             return None
 
+    def _isTagOkay(self, tag):
+        raise UnimplementedError
+
     def __generateTagName(self, descText):
         env.assertUnicode(descText)
         return re.sub(r"(?u)\W", "", descText).lower()
 
-    def __generateTagNameDeprecated1(self, descText):
-        # An algoritm for generating tag names used in previous gkofoto
-        # versions (2004-04-26 -- 2004-05-15). This algoritm
-        # must always remove all swedish characters, regardles of LOCAL
-        # or UNICODE setting, to be backward compatible with the old version.
-        env.assertUnicode(descText)
-        return re.sub("\W", "", descText)
-
-    def __generateTagNameDeprecated2(self, descText):
-        # An algoritm for generating tag names used in previous gkofoto
-        # versions (< 2004-04-26)
-        env.assertUnicode(descText)
-        return string.translate(descText.encode(env.codeset),
-                                string.maketrans("", ""),
-                                string.whitespace)
-
     def _descriptionChanged(self, description, tag):
         newDescText = description.get_text().decode("utf-8")
         currentTagText = self._tagWidget.get_text()
-        if (currentTagText == self.__generateTagName(self.__descText) or
-            currentTagText == self.__generateTagNameDeprecated1(self.__descText) or
-            currentTagText == self.__generateTagNameDeprecated2(self.__descText)):
+        if currentTagText == self.__generateTagName(self.__descText):
             tag.set_text(self.__generateTagName(newDescText))
         self.__descText = newDescText
 
index 70dd17f..db5b0f2 100644 (file)
@@ -1,7 +1,7 @@
 import gtk
-from kofoto.gkofoto.objectcollectionview import *
-from kofoto.gkofoto.objectcollection import *
-from environment import env
+from kofoto.gkofoto.objectcollectionview import ObjectCollectionView
+from kofoto.gkofoto.objectcollection import ObjectCollection
+from kofoto.gkofoto.environment import env
 
 class ThumbnailView(ObjectCollectionView):
 
@@ -16,9 +16,8 @@ class ThumbnailView(ObjectCollectionView):
                                       env.widgets["thumbnailView"])
         self.__currentMaxWidth = env.thumbnailSize[0]
         self.__selectionLocked = False
-        return
-        self._viewWidget.connect("select_icon", self._widgetIconSelected)
-        self._viewWidget.connect("unselect_icon", self._widgetIconUnselected)
+##        self._viewWidget.connect("select_icon", self._widgetIconSelected)
+##        self._viewWidget.connect("unselect_icon", self._widgetIconUnselected)
 
     def importSelection(self, objectSelection):
         if not self.__selectionLocked:
@@ -63,16 +62,16 @@ class ThumbnailView(ObjectCollectionView):
         model = self._objectCollection.getModel()
         for row in model:
             self.__loadRow(row)
-        self._connect(model, "row_inserted",   self._rowInserted)
-        self._connect(model, "row_deleted",    self._rowDeleted)
-        self._connect(model, "rows_reordered", self._rowsReordered)
-        self._connect(model, "row_changed",    self._rowChanged)
+        self._connect(model, "row_inserted",   self._rowInserted_cb)
+        self._connect(model, "row_deleted",    self._rowDeleted_cb)
+        self._connect(model, "rows_reordered", self._rowsReordered_cb)
+        self._connect(model, "row_changed",    self._rowChanged_cb)
         env.exit("ThumbnailView.thawHelper()")
 
 ###############################################################################
 ### Callback functions registered by this class but invoked from other classes.
 
-    def _rowChanged(self, model, path, iterator):
+    def _rowChanged_cb(self, model, path, iterator):
         env.debug("ThumbnailView row changed.")
         self.__selectionLocked = True
         self._viewWidget.remove(path[0])
@@ -84,11 +83,11 @@ class ThumbnailView(ObjectCollectionView):
             self._viewWidget.select_icon(path[0])
         self.__selectionLocked = False
 
-    def _rowInserted(self, model, path, iterator):
+    def _rowInserted_cb(self, model, path, iterator):
         env.debug("ThumbnailView row inserted.")
         self.__loadRow(model[path])
 
-    def _rowsReordered(self, model, b, c, d):
+    def _rowsReordered_cb(self, model, b, c, d):
         env.debug("ThumbnailView rows reordered.")
         # TODO I Don't know how to parse which rows that has
         #      been reordered. Hence I must reload all rows.
@@ -97,18 +96,18 @@ class ThumbnailView(ObjectCollectionView):
             self.__loadRow(row)
         self.importSelection(self._objectCollection.getObjectSelection())
 
-    def _rowDeleted(self, model, path):
+    def _rowDeleted_cb(self, model, path):
         env.debug("ThumbnailView row deleted.")
         self._viewWidget.remove(path[0])
 
-    def _widgetIconSelected(self, widget, index, event):
+    def _widgetIconSelected_cb(self, widget, index, event):
         if not self.__selectionLocked:
             env.enter("ThumbnailView selection changed")
             self.__selectionLocked = True
             self._objectCollection.getObjectSelection().addSelection(index)
             self.__selectionLocked = False
 
-    def _widgetIconUnselected(self, widget, index, event):
+    def _widgetIconUnselected_cb(self, widget, index, event):
         if not self.__selectionLocked:
             env.enter("ThumbnailView selection changed")
             self.__selectionLocked = True