コード例 #1
0
ファイル: edit.py プロジェクト: BackupTheBerlios/griffith-svn
def change_poster(self):
	"""
	changes movie poster image to a custom one 
	showing a file chooser dialog to select it
	"""
	import shutil
	picture = self.e_picture
	m_id = self.get_maintree_selection()
	filename = gutils.file_chooser(_("Select image"), action=gtk.FILE_CHOOSER_ACTION_OPEN, buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK), name="", folder=self.locations['desktop'], picture=True)
	if filename[0]:
		try:
			picture.set_from_pixbuf(gtk.gdk.pixbuf_new_from_file(filename[0]).scale_simple(100, 140, gtk.gdk.INTERP_BILINEAR))
			file_to_copy = os.path.basename(filename[0])
			shutil.copyfile(filename[0],'%s/posters/%s.jpg' % (self.griffith_dir,  os.path.splitext(file_to_copy)[0]))
			gutils.make_thumbnail(self, '%s.jpg' % os.path.splitext(file_to_copy)[0])
			gutils.make_medium_image(self, '%s.jpg' % os.path.splitext(file_to_copy)[0])
			update.update_image(self, os.path.splitext(file_to_copy)[0], m_id[0])
			update_tree_thumbnail(self, '%s/posters/t_%s.jpg' % (self.griffith_dir,  os.path.splitext(file_to_copy)[0]))
		except:
			gutils.error(self, _("Image not valid."), self.main_window)
コード例 #2
0
ファイル: edit.py プロジェクト: BackupTheBerlios/griffith-svn
def get_poster(self, f, result, current_poster):
	if f == None:
		treeselection = self.results_treeview.get_selection()
		(tmp_model, tmp_iter) = treeselection.get_selected()
		f = int(tmp_model.get_value(tmp_iter, 0))
		self.w_results.hide()

	file_to_copy = tempfile.mktemp(suffix=self.e_number.get_text(), prefix='poster_', \
		dir=os.path.join(self.griffith_dir, "posters"))
	file_to_copy += ".jpg"
	try:
		progress = movie.Progress(self.main_window,_("Fetching poster"),_("Wait a moment"))
		retriever = movie.Retriever(result[f].ImageUrlLarge, self.main_window, progress, file_to_copy)
		retriever.start()
		while retriever.isAlive():
			progress.pulse()
			if progress.status:
				retriever.suspend()
			while gtk.events_pending():
				gtk.main_iteration()
		progress.close()
		urlcleanup()
	except:
		gutils.warning(self, _("Sorry. A connection error was occurred."))

	self.debug.show(file_to_copy)

	if  os.path.isfile(file_to_copy):
		handler = self.big_poster.set_from_file(file_to_copy)
		gutils.garbage(handler)

		try:
		    im = Image.open(file_to_copy)
		except IOError:
		    self.debug.show("failed to identify %s"%file_to_copy)
		else:
		    if im.format == "GIF":
				gutils.warning(self, _("Sorry. This poster image format is not supported."))
				os.remove(file_to_copy)
				return
		self.poster_window.show()
		self.poster_window.move(0,0)
		response = \
				gutils.question(self, \
				_("Do you want to use this poster instead?"), \
				1, self.main_window)
		if response == -8:
			self.debug.show("Using new fetched poster, updating and removing old one from disk.")
			update.update_image(self, os.path.basename(file_to_copy), self.e_number.get_text())
			gutils.make_thumbnail(self, '%s' % os.path.basename(file_to_copy))
			gutils.make_medium_image(self, '%s' % os.path.basename(file_to_copy))
			update_tree_thumbnail(self, '%s/posters/t_%s' % (self.griffith_dir, \
				os.path.basename(file_to_copy)))
			self.e_picture.set_from_pixbuf(gtk.gdk.pixbuf_new_from_file(os.path.join(self.griffith_dir, "posters/m_%s"%os.path.basename(file_to_copy))))
			delete.delete_poster(self, current_poster)

		else:
			self.debug.show("Reverting to previous poster and deleting new one from disk.")
			try:
                            os.remove(file_to_copy)
                        except:
                            self.debug.show("no permission for %s"%file_to_copy)

		self.poster_window.hide()
	else:
		gutils.warning(self, _("Sorry. This movie is listed but have no poster available at Amazon.com."))