[Deskbar] Thumbnail support... and some comments



Hello!

I've been using deskbar-applet since some weeks/months, at first using
it with the trackerd handler, but later with many useful handlers too
(gajim, calculator and many of the main handlers).
Some day I wanted to see thumbnails when searching movies. I modified
deskbar so now it uses gnome thumbnails when available (see attached
patch). (If I wrote this email is mainly because I've seen
http://live.gnome.org/DeskbarApplet/Design )

I think this is good, but tracker has thumbnails support, so I think
that it should be possible for handlers to add thumbnails to files.

Another thing is the size of thumbnails. Currently thumbnails (or icons)
are not scaled, I think it's a little problematic, for example handlers
don't have the size allowed for the thumbnail.

The last one is handlers loading, as it's written in the above webpage,
I think that it's bad to have synchronized loading too. The main reason
being loading time. I think it'd be nice to have a small list in the
bottom of the replies, with handlers status : handler is loading,
handler loading failed...

I think that python is a good language, I don't want to do a C++ or D
version of deskbar-applet, but I think that some points may be improved.

Anyway, deskbar-applet is still a good tool, thank you, devs!

-- 
Damien Thebault

Key C15AB8AF
Fingerprint 8FB9 8576 7033 4B45 3DF5  88E8 5471 1A44 C15A B8AF
--- /usr/lib/python2.4/site-packages/deskbar/Utils.py	2007-07-05 22:41:40.000000000 +0200
+++ ./usr/lib/python2.4/site-packages/deskbar/Utils.py	2007-07-05 22:53:27.717838510 +0200
@@ -55,6 +55,29 @@
 	return [dir for dir in dirs.split(":") if dir.strip() != "" and exists(dir)]
 
 def load_icon_for_file(f):
+	# get (gnomevfs) uri of the file and get the path of the thumbnail
+	uri = gnomevfs.get_uri_from_local_path(os.path.abspath(f))
+	thumb_path = gnome.ui.thumbnail_path_for_uri(uri, 'normal')
+	# if the user browsed the folder with nautilus, the thumbnail was created
+	# if not, we load an icon for the file, but we may try to do a thumbnail
+	# too
+	if os.path.exists(thumb_path):
+		# size : should be the height of file name + comments
+		# currently, deskbar doesn't resize thumbnails
+		size = deskbar.ICON_HEIGHT*2
+		pix = gtk.gdk.pixbuf_new_from_file(thumb_path)
+		# if the thumbnail is too big, we have to scale it
+		if pix.get_height() > size:
+			height = size
+			width = int(1.0*height*pix.get_width()/pix.get_height())
+			return pix.scale_simple(width, height, gtk.gdk.INTERP_BILINEAR)
+		else:
+			return pix
+	else:
+		return load_std_icon_for_file(f)
+		
+
+def load_std_icon_for_file(f):
 	icon_name, flags = gnome.ui.icon_lookup(ICON_THEME, factory,
 				f, "",
 				gnome.ui.ICON_LOOKUP_FLAGS_SHOW_SMALL_IMAGES_AS_THEMSELVES)

Attachment: signature.asc
Description: Ceci est une partie de message =?ISO-8859-1?Q?num=E9riquement?= =?ISO-8859-1?Q?_sign=E9e?=



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]