예제 #1
0
def delete_poster(self):
	movie = self.db.Movie.get_by(movie_id=self._movie_id)
	if not movie:
		self.debug.show("Can't delete unknown movie's poster!")
		return False
	response = gutils.question(self, _("Are you sure you want to delete this poster?"), 1, self.widgets['window'])
	if response==-8:
		image_path = os.path.join(self.locations['images'], 'default.png')
		handler = self.widgets['movie']['picture'].set_from_pixbuf(gtk.gdk.pixbuf_new_from_file(image_path))
		gutils.garbage(handler)
		update_tree_thumbnail(self, os.path.join(self.locations['images'], 'default_thumbnail.png'))
		# update in database
		old_image = movie.image
		movie.image = None
		movie.update()
		movie.flush()
		self.update_statusbar(_("Image has been updated"))

		self.widgets['add']['delete_poster'].set_sensitive(False)
		self.widgets['menu']['delete_poster'].set_sensitive(False)
		self.widgets['movie']['picture_button'].set_sensitive(False)
		if old_image:
			delete.delete_poster(self, old_image)
	else:
		pass
예제 #2
0
	filename = os.path.basename(file_path)
	new_image = os.path.splitext(filename)[0]
	if self.db.Movie.get_by(image=new_image) is not None:
		i = 0
		while True:
			i += 1
			if self.db.Movie.get_by(image="%s_%s" % (new_image, i)) is None:
				new_image = "%s_%s" % (new_image, i)
				break

	movie = self.db.Movie.get_by(number=number)
	old_image = os.path.join(self.locations['posters'], "%s.jpg" % movie.image)
	delete.delete_poster(self, old_image)
	movie.image = new_image
	movie.update()
	movie.flush()

	shutil.copyfile(file_path, os.path.join(self.locations['posters'], "%s.jpg" % new_image))

	gutils.make_thumbnail(self, '%s.jpg' % new_image)
	gutils.make_medium_image(self, '%s.jpg' % new_image)
	update_tree_thumbnail(self, os.path.join(self.locations['posters'], 't_%s.jpg' % new_image))

	self.widgets['movie']['picture_button'].set_sensitive(True)
	self.widgets['add']['delete_poster'].set_sensitive(True)
	self.widgets['menu']['delete_poster'].set_sensitive(True)

	self.update_statusbar(_("Image has been updated"))

def delete_poster(self):