After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 580895 - Kill libgnomeui/gnome-thumbnail.h
Kill libgnomeui/gnome-thumbnail.h
Status: RESOLVED FIXED
Product: evolution
Classification: Applications
Component: general
2.26.x (obsolete)
Other Linux
: Normal normal
: ---
Assigned To: Evolution Shell Maintainers Team
Evolution QA team
evolution[cleanup]
Depends on: 488213
Blocks: 580887
 
 
Reported: 2009-04-30 15:24 UTC by André Klapper
Modified: 2009-08-03 18:44 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
proposed evo patch (6.91 KB, patch)
2009-07-22 13:25 UTC, Milan Crha
needs-work Details | Review
proposed evo patch ][ (7.21 KB, patch)
2009-07-23 09:34 UTC, Milan Crha
committed Details | Review

Description André Klapper 2009-04-30 15:24:42 UTC
http://live.gnome.org/LibgnomeMustDie

./e-util/e-icon-factory.c:#include <libgnomeui/gnome-thumbnail.h>
Comment 1 Matthew Barnes 2009-04-30 17:03:21 UTC
Open question is what to replace this with.  The attachment rewrite is very lazy about thumbnailing (reuses cached Nautilus thumbnails but doesn't generate any thumbnails itself), mainly because I didn't want to continue using deprecated code.

I see two options:

1) Grow a new dependency on GNOME Desktop Library and use 
   GnomeDesktopThumbnailFactory to write our own internal thumbnailing service
   like in Nautilus (dedicated thread processes thumbnail requests on a LIFO).

   Might have to do this for the short-term, though I don't like it.

2) Wait for a platform solution for requesting thumbnails.  I've weighed in
   on bug #498506 (D-Bus API for Nautilus), and have also suggested adding a
   g_file_request_thumbnail_async() to GIO that would return a path to the
   thumbnail file.

   Philip Van Hoof has proposed a desktop-wide thumbnailing daemon:
   http://live.gnome.org/ThumbnailerSpec

   But to my knowledge there's been no consensus.  Someone has to JFDI.
Comment 2 André Klapper 2009-05-01 09:57:46 UTC
Hmm. Worth bringing this up on d-d-l, ask if others have dropped gnome-thumbnail.h in their modules already, and/or document the potential solution(s) on the wikipage?
Comment 3 André Klapper 2009-06-20 16:04:25 UTC
Forwarding comment by mclasen on d-d-l today:

"Retrieving of thumbnails is covered in gio/gvfs with the file attributes
thumbnail::path
thumbnail::failed
preview::icon

What is not covered is creation of thumbnails, for which we probably
have to wait for the outcome of the 'thumbnailing service' ideas that
are being floated..."
Comment 4 Cosimo Cecchi 2009-06-21 13:32:57 UTC
This would be as simple as using gnome_desktop_thumbnail_scale_down_pixbuf() instead of gnome_thumbnail_scale_down_pixbuf().
As someone said on d-d-l, it should be fine to depend on gnome-desktop for this, as that doesn't depend on any other obsolete libraries.
Comment 5 André Klapper 2009-07-18 20:51:03 UTC
why does http://library.gnome.org/devel/gnome-desktop/stable/gnome-desktop-Miscellaneous-Thumbnail-Functions.html#gnome-desktop-thumbnail-scale-down-pixbuf propose
    #include <libgnomeui/gnome-thumbnail.h>
instead of
    #include <libgnomeui/gnome-desktop-thumbnail.h>
?
Because I have also seen some #include <libgnomeui/gnome-desktop-thumbnail.h> around, e.g. in g-c-c.
Also, is that "since 2.2" really true on that page?
Wondering about what to add in Evolution's configure.ac...
Comment 6 Milan Crha 2009-07-21 17:12:49 UTC
(In reply to comment #4)
> This would be as simple as using gnome_desktop_thumbnail_scale_down_pixbuf()
> instead of gnome_thumbnail_scale_down_pixbuf().
> As someone said on d-d-l, it should be fine to depend on gnome-desktop for
> this, as that doesn't depend on any other obsolete libraries.

I do not know why the gdk_pixbuf_scale_simple cannot be extended that way, as it's very slow (as stated in the depending bug). That might make things very simple and add a benefit for all the applications, or not?
Comment 7 Matthew Barnes 2009-07-21 17:35:54 UTC
Worth filing a GTK+ bug about that.
Comment 8 Milan Crha 2009-07-21 18:03:19 UTC
(In reply to comment #7)
> Worth filing a GTK+ bug about that.

Sure, we've one already, it's the bug 488213
Comment 9 Milan Crha 2009-07-22 13:25:51 UTC
Created attachment 138998 [details] [review]
proposed evo patch

for evolution;

This should do the trick. I saw two crashers with this applied, but maybe not related. One is below, and the other was in time when I kept there also thumbnailing of the mime part, it crashed in time of saving to stream in the main thread and in some other thread simultaneously, if I recall correctly. Note that the thumbnail is created in the proper folder, just for some reason nautilus doesn't pick it, but creates its own. I didn't get why. Note also that the function can be called up to 4 times, as my tests showed. It was there when attaching a file.

Thread 1:
...
  • #7 <signal handler called>
  • #8 g_type_check_instance_is_a
    from /lib/libgobject-2.0.so.0
  • #9 g_file_info_get_icon
    from /lib/libgio-2.0.so.0
  • #10 attachment_update_icon_column
    at e-attachment.c line 325
  • #11 g_cclosure_marshal_VOID__PARAM
    from /lib/libgobject-2.0.so.0
  • #12 g_closure_invoke
    from /lib/libgobject-2.0.so.0
  • #13 ??
    from /lib/libgobject-2.0.so.0
  • #14 g_signal_emit_valist
    from /lib/libgobject-2.0.so.0
  • #15 g_signal_emit
    from /lib/libgobject-2.0.so.0
  • #16 ??
    from /lib/libgobject-2.0.so.0
  • #17 ??
    from /lib/libgobject-2.0.so.0
  • #18 g_object_thaw_notify
    from /lib/libgobject-2.0.so.0
  • #19 attachment_set_loading
    at e-attachment.c line 505
  • #20 e_attachment_load_finish
    at e-attachment.c line 1933
  • #21 e_attachment_load_handle_error
    at e-attachment.c line 1954
  • #22 g_simple_async_result_complete
    from /lib/libgio-2.0.so.0
  • #23 attachment_load_finish
    at e-attachment.c line 1624
  • #24 attachment_load_stream_read_cb
    at e-attachment.c line 1696
  • #25 ??
    from /lib/libgio-2.0.so.0
  • #26 g_simple_async_result_complete
    from /lib/libgio-2.0.so.0
  • #27 ??
    from /lib/libgio-2.0.so.0
  • #28 ??
    from /lib/libglib-2.0.so.0
  • #29 g_main_context_dispatch
    from /lib/libglib-2.0.so.0
  • #30 ??
    from /lib/libglib-2.0.so.0
  • #31 g_main_loop_run
    from /lib/libglib-2.0.so.0
  • #32 bonobo_main
    from /usr/lib/libbonobo-2.so.0
  • #33 main
    at main.c line 732

Comment 10 André Klapper 2009-07-22 13:41:17 UTC
Are parts of the patch worth to get mentioned in the gtk+ bug 488213?
Comment 11 Milan Crha 2009-07-22 14:31:31 UTC
I do not know, do you meant the part where we might use as a workaround the gnome_desktop_thumbnail function instead of gnome_thumbnail function? I believe it doesn't change anything on the slowness of gdk scale simple function.
Comment 12 Matthew Barnes 2009-07-22 14:42:56 UTC
You might need to set the GFile's "thumbnail::path" attribute for Nautilus to pick it up.  Not sure, maybe ask alexl.  That should also avoid thumbnailing the same (unchanged) file multiple times, as your patch correctly generates the thumbnail only after checking for "thumbnail::path".

  g_file_info_set_attribute_byte_string (file, "thumbnail::path", thumbnail);

Also, I think the function would be better placed in e-util as there's nothing really attachment-specific about it.  We may find other uses for thumbnailing in the future.  Dave Richard's "image gallery" composer feature, for example.
Comment 13 Milan Crha 2009-07-23 09:34:33 UTC
Created attachment 139055 [details] [review]
proposed evo patch ][

for evolution;

I didn't find any better place than e-icon-factory, thus moved the working part there.

With respect of Nautilus, I will try to catch Alex some time soon. The thing is that nautilus creates and loads a different thumbnail, it generates different checksum for some reason. Maybe because of the mtime parameter. I will see.
Comment 14 Matthew Barnes 2009-08-03 16:41:41 UTC
Patch looks pretty good.  One hand-wavy comment and a few nit-picky things.

  - Using gnome-desktop is a stop-gap until GNOME grows a better approach to
    generating thumbnails -- either a thumbnailing daemon or a D-Bus API for
    Nautilus.  So I think the patch is good enough for now, but I'm a little
    concerned about blocking the main thread while generating a thumbnail.

    In lieu of an asynchronous API in GnomeDesktopThumbnailFactory, we really
    should run the factory in a dedicated thread and write our own GIO-style
    asynchronous API around it.  But let's wait and see if it becomes a real
    issue first.

  - In configure.ac, it looks like maybe we can also remove the test for
    <libgnomeui/gnome-icon-lookup.h>.  Would be good to knock that off too.

  - In create_system_thumbnail(), g_file_new_for_path() always succeeds.
    There's no need to test for NULL there.

  - In e_icon_factory_create_thumbnail(), instead of g_stat() use
    "g_file_test (filename, G_FILE_TEST_IS_REGULAR)".

  - In the same function, the "g_strconcat ("file://", filename, NULL)" is
    not portable.  Use g_filename_to_uri() instead.

Apart from that it should be good to go.
Comment 15 Milan Crha 2009-08-03 16:56:39 UTC
(In reply to comment #14)
> Patch looks pretty good.  One hand-wavy comment and a few nit-picky things.
> 
>   - Using gnome-desktop is a stop-gap until GNOME grows a better approach to
>     generating thumbnails -- either a thumbnailing daemon or a D-Bus API for
>     Nautilus.  So I think the patch is good enough for now, but I'm a little
>     concerned about blocking the main thread while generating a thumbnail.
> 
>     In lieu of an asynchronous API in GnomeDesktopThumbnailFactory, we really
>     should run the factory in a dedicated thread and ...

No no no, the factory can be only created in the main thread. Though no such thing had been said about the rest of functions from there. Which one you mean?

>   - In configure.ac, it looks like maybe we can also remove the test for
>     <libgnomeui/gnome-icon-lookup.h>.  Would be good to knock that off too.

Sure, shouldn't be an issue at all.

>   - In create_system_thumbnail(), g_file_new_for_path() always succeeds.
>     There's no need to test for NULL there.

How do you know? It returns pointer, and any pointer can be NULL :)

>   - In e_icon_factory_create_thumbnail(), instead of g_stat() use
>     "g_file_test (filename, G_FILE_TEST_IS_REGULAR)".

Seems you overlooked, slightly later in that function is used file_stat.st_mtime

>   - In the same function, the "g_strconcat ("file://", filename, NULL)" is
>     not portable.  Use g_filename_to_uri() instead.

Oh, yup, will do.
Comment 16 Matthew Barnes 2009-08-03 17:40:21 UTC
(In reply to comment #15)
> No no no, the factory can be only created in the main thread. Though no
> such thing had been said about the rest of functions from there. Which one 
> you mean?

I'm not sure of the details, but I'm pretty sure Nautilus runs (if not creates) the factory in a dedicated thread.  The saving to disk part could be an issue, but moreso the actual thumbnail creation function, which could take a long time to process if handed a sufficiently large file.

> 
> >   - In create_system_thumbnail(), g_file_new_for_path() always succeeds.
> >     There's no need to test for NULL there.
> 
> How do you know? It returns pointer, and any pointer can be NULL :)

The docs guarantee it.  If it ever returns NULL it's a GIO bug.
http://library.gnome.org/devel/gio/unstable/GFile.html#g-file-new-for-path

How about "g_return_val_if_fail (gf != NULL, FALSE)" as a compromise?


> >   - In e_icon_factory_create_thumbnail(), instead of g_stat() use
> >     "g_file_test (filename, G_FILE_TEST_IS_REGULAR)".
> 
> Seems you overlooked, slightly later in that function is used
> file_stat.st_mtime

You're right, I missed that.  Okay, disregard.
Comment 17 Matthew Barnes 2009-08-03 17:52:00 UTC
Go ahead and commit your next patch revision.  No need to post a new one.
Comment 18 Milan Crha 2009-08-03 18:44:20 UTC
Created commit 290cd2b in evo master (2.27.6+, slightly modified above patch)