Opened 14 years ago

Closed 13 years ago

Last modified 12 years ago

#628 closed Enhancement (fixed)

Show thumbnails next to torrents

Reported by: frandavid100 Owned by: charles
Priority: Low Milestone: 1.60
Component: GTK+ Client Version: 1.06
Severity: Minor Keywords: patch glib-2.16
Cc: uws+transmission@…

Description

I have noticed that the Mac OS X version of Transmission shows a thumbnail next to each torrent. Could the GTK version do this, too? Either showing the Nautilus thumbnail for that file, or a generic icon for the file type.

Attachments (2)

mime_type_icons.patch (17.2 KB) - added by paobac 13 years ago.
added a cache to speed up the icon loading
Pantallazo.png (40.5 KB) - added by frandavid100 12 years ago.
mockup

Download all attachments as: .zip

Change History (27)

comment:1 Changed 14 years ago by frandavid100

  • Type changed from Bug to Enhancement

comment:2 Changed 14 years ago by charles

  • Milestone changed from None Set to Sometime
  • Priority changed from Normal to Low
  • Status changed from new to assigned

I tried to do this back around Christmas, but it's literally impossible to access those icons in the current gtk+ API. It apparently will be possible when GIO is included in an upcoming release of glib.

Ref: http://bugzilla.gnome.org/show_bug.cgi?id=144687

comment:3 Changed 14 years ago by charles

  • Summary changed from Show thumbnails next to torrents to Show thumbnails next to torrents in glib >= 2.16
  • Version changed from 1.01 to 1.06

comment:4 Changed 14 years ago by charles

  • Keywords glib-2.16 added

comment:5 Changed 14 years ago by charles

  • Milestone changed from Sometime to 1.10

comment:6 Changed 14 years ago by charles

  • Milestone changed from 1.10 to None Set

Well it's simple enough to get a GIcon from the given file type, but there's currently no way to convert that into a GtkIcon? or a GdkPixbuf?. So this needs to be bumped into the future for a new version of gtk+ to make this possible.

http://live.gnome.org/GioToDo says:

"GIcon is an abstract object representing an icon. Its in glib, so it has no UI in the API. We need a renderer API for this so that you can easily get a GdkPixbuf? for an icon. However, this needs to go into the Gtk+ level of the stack. See patches and discussion: http://mail.gnome.org/archives/gtk-devel-list/2008-January/msg00056.html"

comment:7 Changed 14 years ago by charles

  • Summary changed from Show thumbnails next to torrents in glib >= 2.16 to Show thumbnails next to torrents

comment:9 Changed 14 years ago by LucaFerretti

Not sure, but you should be able to get the "named" icon from GIcon with something like this:

GFileInfo *info;
GIcon *icon;
const char * const *names;

info = g_file_query_info (...);

if (info != NULL) {
  icon = g_file_info_get_icon (info);

  if (icon != NULL) {
    if (G_IS_THEMED_ICON (icon)) {
      names = g_themed_icon_get_names (G_THEMED_ICON (icon));
      ....
    }
  }
}

(see nautilus code and this commit for brasero)

Unfortunately g_themed_icon_get_names seems not available in glib 2.16. But check headers, maybe it's simply missed in API reference docs for 2.16, 'cause it's listed in glib/gio/ChangeLog starting from 2007-10-11 and glib 2.16.0 was released on 2008-03-10

comment:10 Changed 13 years ago by charles

Looks like the API for this was checked in to gtk+'s repo yesterday :)

comment:11 Changed 13 years ago by paobac

I did the work for you :)

More precisely I've added mime type icons to the file and torrent lists.

Some comments on the patch:

There are two new files icons.[ch] that contains the functions used to get the mime type icons. I had to add a private member to TrCore?, window, because the icon functions need the screen where the window is located. I didn't add a header to the new files, this is up to you.

attaching the patch now...

comment:12 follow-up: Changed 13 years ago by charles

paobac: wow, thanks! very nice indeed.

Just to be anal about this -- I know some distros are, as well -- is there any license restriction you want on the new source files? Is a dual MIT/GPL license okay?

comment:13 in reply to: ↑ 12 Changed 13 years ago by paobac

Replying to charles:

paobac: wow, thanks! very nice indeed.

Just to be anal about this -- I know some distros are, as well -- is there any license restriction you want on the new source files? Is a dual MIT/GPL license okay?

there is no problem for me, you can license my code under whatever licence you wish :)

comment:14 follow-up: Changed 13 years ago by charles

paobac: I just tried your patch, and am getting a crash in icons.c's call to gtk_icon_theme_choose_icon() because the `icon_names' argument being passed in is an unset pointer. I get this warning message:

(transmission:22203): GLib-GObject-WARNING : g_object_get_valist: object class GThemedIcon' has no property named names'

This is w/glib 2.15.7.

comment:15 Changed 13 years ago by paobac

Maybe the property has been added in a later version, because version 2.16.3 works good. The "names" property is ducumented here: http://library.gnome.org/devel/gio/2.16/GThemedIcon.html

comment:16 Changed 13 years ago by charles

  • Milestone changed from None Set to Sometime

comment:17 in reply to: ↑ 14 Changed 13 years ago by paobac

Replying to charles:

paobac: I just tried your patch, and am getting a crash in icons.c's call to gtk_icon_theme_choose_icon() because the `icon_names' argument being passed in is an unset pointer. I get this warning message:

(transmission:22203): GLib-GObject-WARNING : g_object_get_valist: object class GThemedIcon' has no property named names'

This is w/glib 2.15.7.

this is a bug in glib:

http://bugzilla.gnome.org/show_bug.cgi?id=537555

comment:18 Changed 13 years ago by paobac

There was a bug in the previous patch that could cause a segmentation fault. I'm going to attach a new patch that fixes the problem.

Changed 13 years ago by paobac

added a cache to speed up the icon loading

comment:19 Changed 13 years ago by WouterBolsterlee

  • Cc uws+transmission@… added

comment:20 Changed 13 years ago by charles

  • Keywords patch added

comment:21 Changed 13 years ago by charles

Added to trunk in r7996.

@paobac: thanks again for the patch. icons.c really is very clean. :)

The only change I made was to alter the way that the icon's handled in the main window. Part of the goal was to get separate icons for "full" and "minimal" mode, but in addition I'm planning on adding things under the icon when in "full" mode, so I moved the main window's icon handling into torrent-cell-renderer.c.

comment:22 Changed 13 years ago by charles

  • Resolution set to fixed
  • Status changed from assigned to closed

comment:23 Changed 12 years ago by frandavid100

Just installed 1.60, and found this a welcome addition.

However, the icons barely have any space to their sides which makes them look kind of "crammed" in there. Could you give them some free pixels to their left and right?

I'm attaching a quick mockup.

Changed 12 years ago by frandavid100

mockup

comment:24 Changed 12 years ago by frandavid100

Also, just to know: do you plan to use real thumbnails at some point, rather than mimetype icons, at some point? Maybe re-use the same ones nautilus uses?

comment:25 Changed 12 years ago by charles

  • Milestone changed from Sometime to 1.60
Note: See TracTickets for help on using tickets.