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 509327 - Migrate from gnome-vfs to gio/gvfs
Migrate from gnome-vfs to gio/gvfs
Status: RESOLVED FIXED
Product: cheese
Classification: Applications
Component: general
git master
Other All
: Normal normal
: ---
Assigned To: Cheese Maintainer(s)
Cheese Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2008-01-14 10:37 UTC by Luca Ferretti
Modified: 2008-02-02 13:32 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Use GIO to trash files (7.90 KB, patch)
2008-01-16 14:28 UTC, Luca Ferretti
committed Details | Review
Patch using new gio function g_app_info_launch_default_for_uri for opening links (2.77 KB, patch)
2008-02-01 23:34 UTC, Jaap A. Haitsma
none Details | Review

Description Luca Ferretti 2008-01-14 10:37:17 UTC
GNOME-vfs is going to be deprecated, replaced by GIO/GVFS.

Note that, if I'm right, most of gnome-vfs usage in Cheese is relate to move grabbed stuff to the trash. Unfortunately, the gnome-vfs trash is located in (GNOME custom) ~/.Trash, while the gio/gvfs trash will use the freedesktop.org trash spec that place the trash in $XDG_DATA_HOME/Trash (that usually mean ~/.local/share/Trash). Nautilus is yet using GIO, so I suspect that if you move a grabbed item to trash from Cheese window, you can't see it in Nautilus trash://

Apart, move to GIO is Good Idea.
Comment 1 Luca Ferretti 2008-01-14 10:37:51 UTC
A simple `grep vfs  src/*c` in cheese sources.


src/cheese.c:#include <libgnomevfs/gnome-vfs.h>
src/cheese.c:  gnome_vfs_init ();
src/cheese-thumb-view.c:#include <libgnomevfs/gnome-vfs.h>
src/cheese-thumb-view.c:  file_info = gnome_vfs_file_info_new ();
src/cheese-thumb-view.c:  if (!uri || (gnome_vfs_get_file_info (uri, file_info,
src/cheese-thumb-view.c:  char *filename = gnome_vfs_get_local_path_from_uri (info_uri);
src/cheese-thumb-view.c:  gnome_vfs_monitor_cancel (priv->monitor_handle);
src/cheese-thumb-view.c:  uri = gnome_vfs_uri_new (path);
src/cheese-thumb-view.c:  if (!gnome_vfs_uri_exists (uri))
src/cheese-thumb-view.c:    gnome_vfs_make_directory_for_uri (uri, 0775);
src/cheese-thumb-view.c:  gnome_vfs_monitor_add (&(priv->monitor_handle), path, GNOME_VFS_MONITOR_DIRECTORY,
src/cheese-thumb-view.c:  gnome_vfs_uri_unref (uri);
src/cheese-window.c:#include <libgnomevfs/gnome-vfs.h>
src/cheese-window.c:  gnome_vfs_url_show (link);
src/cheese-window.c:  gnome_vfs_url_show (address);
src/cheese-window.c:  uri = gnome_vfs_get_uri_from_local_path (filename);
src/cheese-window.c:  gnome_vfs_url_show (uri);
src/cheese-window.c:    GnomeVFSURI *source = gnome_vfs_uri_new (source_uri);
src/cheese-window.c:    GnomeVFSURI *target = gnome_vfs_uri_new (target_uri);
src/cheese-window.c:    response = gnome_vfs_xfer_uri (source, target,
src/cheese-window.c:    gnome_vfs_uri_unref (source);
src/cheese-window.c:    gnome_vfs_uri_unref (target);
src/cheese-window.c:  uri = gnome_vfs_uri_new (g_filename_to_uri (filename, NULL, NULL));
src/cheese-window.c:  result = gnome_vfs_find_directory (uri, GNOME_VFS_DIRECTORY_KIND_TRASH,
src/cheese-window.c:    gnome_vfs_uri_unref (uri);
src/cheese-window.c:    gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dlg), gnome_vfs_result_to_string (result));
src/cheese-window.c:  name = gnome_vfs_uri_extract_short_name (uri);
src/cheese-window.c:  trash_uri = gnome_vfs_uri_append_file_name (trash_dir, name);
src/cheese-window.c:  result = gnome_vfs_move_uri (uri, trash_uri, TRUE);
src/cheese-window.c:  gnome_vfs_uri_unref (uri);
src/cheese-window.c:  gnome_vfs_uri_unref (trash_uri);
src/cheese-window.c:  gnome_vfs_uri_unref (trash_dir);
src/cheese-window.c:    gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dlg), gnome_vfs_result_to_string (result));
src/eog-thumbnail.c:set_vfs_error (GError **error, GnomeVFSResult result)
src/eog-thumbnail.c:                 gnome_vfs_result_to_string (result));
src/eog-thumbnail.c:    data->uri_str    = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE);
src/eog-thumbnail.c:    info    = gnome_vfs_file_info_new ();
src/eog-thumbnail.c:    result  = gnome_vfs_get_file_info_uri (uri, info, 
src/eog-thumbnail.c:            set_vfs_error (error, result);
src/eog-thumbnail.c:    gnome_vfs_file_info_unref (info);
Comment 2 Jaap A. Haitsma 2008-01-14 12:16:05 UTC
Confirming. Are you planning on providing the patch?
Comment 3 Luca Ferretti 2008-01-16 14:28:58 UTC
Created attachment 102996 [details] [review]
Use GIO to trash files

Here is a patch to use GIO to trash files (and only to trash files, any other GnomeVFS usage is still here).

Changes:
 * check for gio-2.0 in configure
 * change cheese_window_cmd_move_file_to_trash() to use the
   trivial g_file_trash(). Note that I also changed the arguments for this
   function s/char *filename/GList *files//  GList *files is the list of
   GFiles to trash. The new function is + or - a copyandpaste from Nautilus.
 * change cheese_window_move_all_media_to_trash() and 
   cheese_window_move_media_to_trash() to pass GList instead char. Moreover,
   removed the confiration dialog for just one item, use WARNING, not QUESTION,
   add accelerator and other (note you should not split with \n message text)
 * use g_strjoin + G_DIR_SEPARATOR_S in cheese_fileutil_get_media_path()
 
Missing stuff: 
 * what should we do when we can't trash files?
 * review visible text and check if there are all needed g_free()
Comment 4 Luca Ferretti 2008-01-16 14:36:30 UTC
By now I'm not planning to add more GIO/GVFS to Cheese then trash...
Comment 5 daniel g. siegel 2008-01-16 17:06:04 UTC
seems ok to me. please commit, if jaap is ok with that too!
Comment 6 Jaap A. Haitsma 2008-01-16 17:47:50 UTC
Luca,

Please commit and leave the bug open until we removed all gnome-vfs stuff
Comment 7 Luca Ferretti 2008-01-17 12:37:34 UTC
Committed (please change the status of attachment, I've no permission to do...)
Comment 8 Luca Ferretti 2008-01-17 12:48:42 UTC
The next VFS feature to implement should be the save trough D'n'D: it seems that you are able to save shots using the file chooser dialog (using the new gio backend available in libgnomeui svn, only on local filesystem), but Nautilus fails to accept dragged items.

Tip: didn't checked, but the Nautilus error dialog says that can't get info on "/home/user/.gnome2/cheese/media/0001.jpg". Try converting filename to URI file://home/user/[..]
Comment 9 Luca Ferretti 2008-01-17 21:01:26 UTC
Just for reference: EoG is migrating to GIO too.

Look the patch attached to bug #509239 - here are some checks before (G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH) trash the file and after.

I'll investigate in next days...
Comment 10 daniel g. siegel 2008-01-17 21:15:36 UTC
sorry, but what do you mean by "save trough D'n'D"?

cheese has dnd support, but do you mean dragging the media out of cheese and
inside another application?

i think GIO _is_ the right way, no need to convince us ;) of course you are very welcome to submit those patches to us
Comment 11 Jaap A. Haitsma 2008-01-30 23:18:05 UTC
Replaced all gnome-vfs calls by gio calls now in cheese. Unfortunately we still link with gnome-vfs because libgnomeui (which we use for thumbnails) depends on gnome-vfs
Comment 12 Luca Ferretti 2008-02-01 21:40:10 UTC
Reopenign the bug, sorry...

First: I've warnings starting cheese (and UI freeze, but maybe could be unrelated...) relatd to gnome-vfs: do cheese still need to initialize gnomevfs??

Second: the gvf-open program from gvfs shows us a better and glib/gio only way to open files and locations: the brave Alexander Larsson provided us g_app_info_launc() and g_app_info_launch_uri() functions, I'll provide a patch to use them instead unuseful xdg-open... but I've to unfreeze my UI before...


############### Warnings ###############

(cheese:3355): GLib-CRITICAL **: g_hash_table_lookup: assertion `hash_table != NULL' failed

(cheese:3355): libgnomevfs-WARNING **: Internal error: the configuration system was not initialized. Did you call _gnome_vfs_configuration_init?

(cheese:3355): GLib-CRITICAL **: g_hash_table_lookup: assertion `hash_table != NULL' failed

(cheese:3355): libgnomevfs-WARNING **: Internal error: the configuration system was not initialized. Did you call _gnome_vfs_configuration_init?

** (cheese:3355): WARNING **: could not load /home/luca/.gnome2/cheese/media/0001.jpg (image/jpeg)


(cheese:3355): GLib-CRITICAL **: g_hash_table_lookup: assertion `hash_table != NULL' failed

(cheese:3355): libgnomevfs-WARNING **: Internal error: the configuration system was not initialized. Did you call _gnome_vfs_configuration_init?

(cheese:3355): GLib-CRITICAL **: g_hash_table_lookup: assertion `hash_table != NULL' failed

(cheese:3355): libgnomevfs-WARNING **: Internal error: the configuration system was not initialized. Did you call _gnome_vfs_configuration_init?

** (cheese:3355): WARNING **: could not load /home/luca/.gnome2/cheese/media/0002.jpg (image/jpeg)
Comment 13 Jaap A. Haitsma 2008-02-01 23:32:18 UTC
I'm getting the same errors when closing cheese. I've now added a gnome_vfs_init again to cheese.c and don't get the errors anymore. I'm pretty sure it's caused by gnome-thumbnail because it's using gnome-vfs functions. It's committed in SVN 

Comment 14 Jaap A. Haitsma 2008-02-01 23:34:17 UTC
Created attachment 104229 [details] [review]
Patch using new gio function g_app_info_launch_default_for_uri for opening links

It only doesn't work. I get Operation not supported as an error message for http and email links. Any idea what's wrong. Videos and Images are opened correctly
Comment 15 daniel g. siegel 2008-02-02 00:12:46 UTC
i think librsvg still has to be linked to gnome-vfs because of this http://bugzilla.gnome.org/show_bug.cgi?id=513778 (?)
Comment 16 Luca Ferretti 2008-02-02 11:18:18 UTC
My ui freeze is still here (see bug #513863), so by now I can't test the patch, but Jaap, do you have the latest gvfs? The default handlers for http: and mail: are stored in GConf and gvfs was update to read then in the last week.

However,
 * could be better use different labels for messages
   ("failed to show url", "failed to send email", "failed to open file")
 * s/GTK_MESSAGE_INFO/GTK_MESSAGE_ERROR
Comment 17 Jaap A. Haitsma 2008-02-02 13:32:21 UTC
Thanks for the suggestions I incorporated them into the patch. Indeed my gvfs was not up to date. I commited the changes to SVN.

Setting this bug now to fixed