Replaced some error prints with proper error dialogs.
authorJoel Rosdahl <joel@rosdahl.net>
Tue, 3 Aug 2004 17:12:31 +0000 (17:12 +0000)
committerJoel Rosdahl <joel@rosdahl.net>
Tue, 3 Aug 2004 17:12:31 +0000 (17:12 +0000)
src/gkofoto/categories.py
src/gkofoto/imageview.py
src/gkofoto/objectcollection.py

index b84970d..e579e5e 100644 (file)
@@ -235,8 +235,7 @@ class Categories:
         env.clipboard.setCategories(cc)
 
     def _pasteCategory(self, item, data):
-        if not env.clipboard.hasCategories():
-            raise Exception("No categories in clipboard") # TODO
+        assert env.clipboard.hasCategories()
         clipboardCategories = env.clipboard[0]
         env.clipboard.clear()
         try:
@@ -260,8 +259,12 @@ class Categories:
                             else:
                                 self.__disconnectChild(categoryId, parentId)
         except CategoryLoopError:
-            print "Error: Category loop detected"
-            # TODO: Show dialog box with error message
+            dialog = gtk.MessageDialog(
+                type=gtk.MESSAGE_ERROR,
+                buttons=gtk.BUTTONS_OK,
+                message_format="Category loop detected.")
+            dialog.run()
+            dialog.destroy()
         self.__expandAndCollapseRows(False, False)
 
     def _createRootCategory(self, item, data):
@@ -486,8 +489,8 @@ class Categories:
                                                 childCategory,
                                                 self.__categoryModel)
         except CategoriesAlreadyConnectedError:
-            print "Error: Categories already connected"
-            # TODO: Show dialog box with error message
+            # This is okay.
+            pass
 
     def __connectChildToCategoryHelper(self, parentId, childCategory, categoryRows):
         for categoryRow in categoryRows:
index 52447d9..70ef8b3 100644 (file)
@@ -43,7 +43,12 @@ class ImageView(gtk.ScrolledWindow):
             self.__pixBuf = gtk.gdk.pixbuf_new_from_file(fileName)
             self.__loadedFileName = fileName
         except gobject.GError, e:
-            print "Error while loading image:", e # TODO show error dialog box.
+            dialog = gtk.MessageDialog(
+                type=gtk.MESSAGE_ERROR,
+                buttons=gtk.BUTTONS_OK,
+                message_format="Could not load image: %s" % fileName)
+            dialog.run()
+            dialog.destroy()
             self.__pixBuf = env.unknownImageIconPixbuf
             self.__loadedFileName = None
         self._newImageLoaded = True
index e00a4f1..35f6767 100644 (file)
@@ -306,24 +306,21 @@ class ObjectCollection(object):
 
     def _albumTagEdited(self, renderer, path, value, column, columnNumber):
         model = self.getModel()
+        assert model.get_value(iterator, self.COLUMN_IS_ALBUM)
         iterator = model.get_iter(path)
-        if model.get_value(iterator, self.COLUMN_IS_ALBUM):
-            oldValue = model.get_value(iterator, columnNumber)
-            if not oldValue:
-                oldValue = u""
-            value = unicode(value, "utf-8")
-            if oldValue != value:
-                # TODO Show dialog and ask for confirmation?
-                objectId = model.get_value(iterator, self.COLUMN_OBJECT_ID)
-                obj = env.shelf.getAlbum(objectId)
-                obj.setTag(value)
-                # TODO Handle invalid album tag?
-                model.set_value(iterator, columnNumber, value)
-                # TODO Update the album tree widget.
-                env.debug("Album tag edited")
-        else:
-            # TODO Show dialog error box?
-            print "Not allowed to set album tag on image"
+        oldValue = model.get_value(iterator, columnNumber)
+        if not oldValue:
+            oldValue = u""
+        value = unicode(value, "utf-8")
+        if oldValue != value:
+            # TODO Show dialog and ask for confirmation?
+            objectId = model.get_value(iterator, self.COLUMN_OBJECT_ID)
+            obj = env.shelf.getAlbum(objectId)
+            obj.setTag(value)
+            # TODO Handle invalid album tag?
+            model.set_value(iterator, columnNumber, value)
+            # TODO Update the album tree widget.
+            env.debug("Album tag edited")
 
     def createAlbumChild(self, *unused):
         dialog = AlbumDialog("Create album")
@@ -388,7 +385,12 @@ class ObjectCollection(object):
                     model = self.getUnsortedModel()
                     self.__loadThumbnail(model, model.get_iter(rowNr))
                 else:
-                    print "failed to execute:", command
+                    dialog = gtk.MessageDialog(
+                        type=gtk.MESSAGE_ERROR,
+                        buttons=gtk.BUTTONS_OK,
+                        message_format="Failed to execute command: \"%s\"" % command)
+                    dialog.run()
+                    dialog.destroy()
 
     def openImage(self, widget, data):
         locations = ""
@@ -402,7 +404,12 @@ class ObjectCollection(object):
             # characters. I tried latin-1 and utf-8 without success.
             result = os.system(command + " &")
             if result != 0:
-                print "failed to execute:", command
+                dialog = gtk.MessageDialog(
+                    type=gtk.MESSAGE_ERROR,
+                    buttons=gtk.BUTTONS_OK,
+                    message_format="Failed to execute command: \"%s\"" % command)
+                dialog.run()
+                dialog.destroy()
 
 ######################################################################
 ### Private