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:
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):
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:
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
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")
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 = ""
# 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