Commit f6d3f9b4 authored by Cosimo Cecchi's avatar Cosimo Cecchi Committed by Cosimo Cecchi

Port to GIO and drop gnome-vfs dependency (#527903).

2008-08-22  Cosimo Cecchi  <cosimoc@gnome.org>

	* configure.in:
	* main-menu/src/main-menu-ui.c: (main_menu_ui_new),
	(main_menu_ui_finalize), (create_rct_docs_section),
	(recently_used_store_monitor_changed_cb),
	(setup_recently_used_store_monitor), (item_to_recent_doc_tile),
	(doc_uri_to_item), (update_recently_used_sections),
	(volume_monitor_mount_cb):
	Port to GIO and drop gnome-vfs dependency (#527903).

svn path=/trunk/; revision=489
parent 1f3b3012
2008-08-22 Cosimo Cecchi <cosimoc@gnome.org>
* configure.in:
* main-menu/src/main-menu-ui.c: (main_menu_ui_new),
(main_menu_ui_finalize), (create_rct_docs_section),
(recently_used_store_monitor_changed_cb),
(setup_recently_used_store_monitor), (item_to_recent_doc_tile),
(doc_uri_to_item), (update_recently_used_sections),
(volume_monitor_mount_cb):
Port to GIO and drop gnome-vfs dependency (#527903).
2008-08-11 A. Walton <awalton@gnome.org>
reviewed by: Federico Mena Quintero
......
......@@ -42,7 +42,10 @@ dnl Check that we meet the dependencies
dnl ==============================================
AM_PATH_GLIB_2_0(2.8.0,,,gobject)
COMMON_MODULES="glib-2.0 gobject-2.0 gtk+-2.0 gdk-2.0"
COMMON_MODULES="glib-2.0 >= 2.12.0 \
gobject-2.0 \
gtk+-2.0 >= 2.13.3 \
gdk-2.0 gio-2.0"
PKG_CHECK_MODULES(GLADE, libglade-2.0)
AC_SUBST(GLADE_CFLAGS)
......@@ -152,9 +155,8 @@ AC_ARG_ENABLE(nautilus-extension,
if test "x$ENABLE_NAUTILUS_EXTENSION" = "x1"
then
NAUTILUS_REQUIRED=2.6.0
GNOME_VFS_REQUIRED=2.12.0
PKG_CHECK_MODULES(NAUTILUS, [libnautilus-extension >= $NAUTILUS_REQUIRED glib-2.0 gobject-2.0 gconf-2.0 gnome-vfs-2.0 >= $GNOME_VFS_REQUIRED])
PKG_CHECK_MODULES(NAUTILUS, [libnautilus-extension >= $NAUTILUS_REQUIRED glib-2.0 gobject-2.0 gconf-2.0])
AC_SUBST(NAUTILUS_CFLAGS)
AC_SUBST(NAUTILUS_LIBS)
......
2008-08-22 Cosimo Cecchi <cosimoc@gnome.org>
* Makefile.am:
* app-shell.c: (generate_new_apps):
* bookmark-agent.c: (bookmark_agent_move_item),
(bookmark_agent_remove_item), (bookmark_agent_new), (finalize),
(update_user_spec_path), (store_monitor_cb),
(recent_item_mru_comp_func):
* directory-tile.c: (directory_tile_new),
(directory_tile_private_setup), (directory_tile_finalize),
(rename_entry_activate_cb), (move_to_trash_trigger),
(delete_trigger), (open_with_default_trigger):
* document-tile.c: (document_tile_new),
(document_tile_private_setup), (document_tile_finalize),
(rename_entry_activate_cb), (open_with_default_trigger),
(move_to_trash_trigger), (delete_trigger), (user_docs_trigger):
* recent-files.c: (main_menu_recent_monitor_init),
(main_menu_recent_file_init), (main_menu_recent_monitor_finalize),
(main_menu_recent_file_finalize), (main_menu_recent_monitor_new),
(get_files), (main_menu_recent_file_get_uri),
(main_menu_recent_file_get_mime_type),
(main_menu_recent_file_get_modified),
(main_menu_rename_recent_file), (main_menu_remove_recent_file),
(recent_file_store_monitor_cb), (recent_item_mru_comp_func):
* slab-gnome-util.c: (copy_file):
Port to GIO and drop gnome-vfs dependency (#527903).
2008-08-11 A. Walton <awalton@gnome.org>
reviewed by: Federico Mena Quintero
......
......@@ -37,18 +37,11 @@ libslab_la_SOURCES = \
app-shell-startup.c \
application-tile.c \
bookmark-agent.h \
bookmark-agent-libslab.h \
bookmark-agent.c \
directory-tile.c \
document-tile.c \
double-click-detector.c \
double-click-detector.h \
libslab-bookmarkfile.c \
libslab-bookmarkfile.h \
egg-recent-item.c \
egg-recent-item.h \
egg-recent-model.c \
egg-recent-model.h \
gnome-utils.c \
libslab-utils.c \
libslab-utils.h \
......
......@@ -24,7 +24,7 @@
#include <libgnome/gnome-desktop-item.h>
#include <libgnomeui/libgnomeui.h>
#include <libgnomevfs/gnome-vfs-ops.h>
#include <gio/gio.h>
#include <sys/types.h>
#include <sys/stat.h>
......@@ -1137,7 +1137,8 @@ generate_new_apps (AppShellData * app_data)
const gchar *uri = gnome_desktop_item_get_location (item);
if (!g_hash_table_lookup (all_apps_cache, uri))
{
GnomeVFSFileInfo *info;
GFile *file;
GFileInfo *info;
long filetime;
if (g_hash_table_lookup (new_apps_dups, uri))
......@@ -1163,17 +1164,21 @@ generate_new_apps (AppShellData * app_data)
got_new_apps = TRUE;
}
info = gnome_vfs_file_info_new ();
if (gnome_vfs_get_file_info (uri, info,
GNOME_VFS_FILE_INFO_DEFAULT) != GNOME_VFS_OK
|| !(info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_MTIME))
file = g_file_new_for_uri (uri);
info = g_file_query_info (file,
G_FILE_ATTRIBUTE_TIME_MODIFIED,
0, NULL, NULL);
if (!info)
{
gnome_vfs_file_info_unref (info);
g_object_unref (file);
g_warning ("Cant get vfs info for %s\n", uri);
return;
}
filetime = info->mtime;
gnome_vfs_file_info_unref (info);
filetime = (long) g_file_info_get_attribute_uint64 (info,
G_FILE_ATTRIBUTE_TIME_MODIFIED);
g_object_unref (info);
g_object_unref (file);
for (x = 0; x < app_data->new_apps->max_items; x++)
{
......
......@@ -26,24 +26,13 @@
# define PACKAGE "gnome-main-menu"
#endif
#if ! GLIB_CHECK_VERSION (2, 12, 0)
# include "bookmark-agent-libslab.h"
#endif
#include <gtk/gtkversion.h>
#if GTK_CHECK_VERSION (2, 10, 0)
# define USE_GTK_RECENT_MANAGER
# include <gtk/gtkrecentmanager.h>
#else
# define EGG_ENABLE_RECENT_FILES
# include "egg-recent-model.h"
#endif
#include <gtk/gtk.h>
#include <string.h>
#include <stdlib.h>
#include <glib/gi18n.h>
#include <glib/gstdio.h>
#include <libgnomevfs/gnome-vfs.h>
#include <gio/gio.h>
#include "libslab-utils.h"
......@@ -80,8 +69,8 @@ typedef struct {
const gchar *store_filename;
const gchar *lockdown_key;
GnomeVFSMonitorHandle *store_monitor;
GnomeVFSMonitorHandle *user_store_monitor;
GFileMonitor *store_monitor;
GFileMonitor *user_store_monitor;
guint gconf_monitor;
void (* update_path) (BookmarkAgent *);
......@@ -90,7 +79,7 @@ typedef struct {
void (* create_item) (BookmarkAgent *, const gchar *);
gchar *gtk_store_path;
GnomeVFSMonitorHandle *gtk_store_monitor;
GFileMonitor *gtk_store_monitor;
} BookmarkAgentPrivate;
#define PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), BOOKMARK_AGENT_TYPE, BookmarkAgentPrivate))
......@@ -128,14 +117,12 @@ static void create_app_item (BookmarkAgent *, const gchar *);
static void create_doc_item (BookmarkAgent *, const gchar *);
static void create_dir_item (BookmarkAgent *, const gchar *);
static void store_monitor_cb (GnomeVFSMonitorHandle *, const gchar *, const gchar *,
GnomeVFSMonitorEventType, gpointer);
static void store_monitor_cb (GFileMonitor *, GFile *, GFile *,
GFileMonitorEvent, gpointer);
static void gconf_notify_cb (GConfClient *, guint, GConfEntry *, gpointer);
static void weak_destroy_cb (gpointer, GObject *);
#ifdef USE_GTK_RECENT_MANAGER
static gint recent_item_mru_comp_func (gconstpointer a, gconstpointer b);
#endif
static gchar *find_package_data_file (const gchar *filename);
......@@ -218,17 +205,11 @@ bookmark_agent_move_item (BookmarkAgent *this, const gchar *uri, const gchar *ur
{
BookmarkAgentPrivate *priv = PRIVATE (this);
#ifdef USE_GTK_RECENT_MANAGER
GError *error = NULL;
#else
EggRecentModel *model;
#endif
if (! TYPE_IS_RECENT (priv->type))
return;
#ifdef USE_GTK_RECENT_MANAGER
gtk_recent_manager_move_item (
gtk_recent_manager_get_default (), uri, uri_new, & error);
......@@ -236,14 +217,6 @@ bookmark_agent_move_item (BookmarkAgent *this, const gchar *uri, const gchar *ur
libslab_handle_g_error (
& error, "%s: unable to update %s with renamed file, [%s] -> [%s].",
G_STRFUNC, priv->store_path, uri, uri_new);
#else
model = egg_recent_model_new (EGG_RECENT_MODEL_SORT_NONE);
egg_recent_model_delete (model, uri);
egg_recent_model_add (model, uri_new);
g_object_unref (model);
#endif
}
void
......@@ -253,11 +226,7 @@ bookmark_agent_remove_item (BookmarkAgent *this, const gchar *uri)
gint rank;
#ifdef USE_GTK_RECENT_MANAGER
GError *error = NULL;
#else
EggRecentModel *model;
#endif
gchar **uris = NULL;
gint rank_i;
......@@ -270,7 +239,6 @@ bookmark_agent_remove_item (BookmarkAgent *this, const gchar *uri)
return;
if (TYPE_IS_RECENT (priv->type)) {
#ifdef USE_GTK_RECENT_MANAGER
gtk_recent_manager_remove_item (
gtk_recent_manager_get_default (), uri, & error);
......@@ -278,11 +246,6 @@ bookmark_agent_remove_item (BookmarkAgent *this, const gchar *uri)
libslab_handle_g_error (
& error, "%s: unable to remove [%s] from %s.",
G_STRFUNC, priv->store_path, uri);
#else
model = egg_recent_model_new (EGG_RECENT_MODEL_SORT_NONE);
egg_recent_model_delete (model, uri);
g_object_unref (model);
#endif
}
else {
rank = get_rank (this, uri);
......@@ -495,6 +458,7 @@ bookmark_agent_new (BookmarkStoreType type)
{
BookmarkAgent *this;
BookmarkAgentPrivate *priv;
GFile *gtk_store_file;
this = g_object_new (BOOKMARK_AGENT_TYPE, NULL);
priv = PRIVATE (this);
......@@ -528,9 +492,15 @@ bookmark_agent_new (BookmarkStoreType type)
priv->load_store = load_places_store;
priv->gtk_store_path = g_build_filename (g_get_home_dir (), GTK_BOOKMARKS_FILE, NULL);
gnome_vfs_monitor_add (
& priv->gtk_store_monitor, priv->gtk_store_path,
GNOME_VFS_MONITOR_FILE, store_monitor_cb, this);
gtk_store_file = g_file_new_for_path (priv->gtk_store_path);
priv->gtk_store_monitor = g_file_monitor_file (gtk_store_file,
0, NULL, NULL);
if (priv->gtk_store_monitor) {
g_signal_connect (priv->gtk_store_monitor, "changed",
G_CALLBACK (store_monitor_cb), this);
}
g_object_unref (gtk_store_file);
break;
......@@ -539,11 +509,7 @@ bookmark_agent_new (BookmarkStoreType type)
priv->user_modifiable = TRUE;
priv->reorderable = FALSE;
#ifdef USE_GTK_RECENT_MANAGER
priv->store_path = g_build_filename (g_get_home_dir (), ".recently-used.xbel", NULL);
#else
priv->store_path = g_build_filename (g_get_home_dir (), ".recently-used", NULL);
#endif
break;
......@@ -611,6 +577,7 @@ set_property (GObject *g_obj, guint prop_id, const GValue *value, GParamSpec *ps
static void
finalize (GObject *g_obj)
{
BookmarkAgent *this = BOOKMARK_AGENT (g_obj);
BookmarkAgentPrivate *priv = PRIVATE (g_obj);
gint i;
......@@ -624,14 +591,23 @@ finalize (GObject *g_obj)
g_free (priv->user_store_path);
g_free (priv->gtk_store_path);
if (priv->store_monitor)
gnome_vfs_monitor_cancel (priv->store_monitor);
if (priv->store_monitor) {
g_signal_handlers_disconnect_by_func (priv->store_monitor, store_monitor_cb, this);
g_file_monitor_cancel (priv->store_monitor);
g_object_unref (priv->store_monitor);
}
if (priv->user_store_monitor)
gnome_vfs_monitor_cancel (priv->user_store_monitor);
if (priv->user_store_monitor) {
g_signal_handlers_disconnect_by_func (priv->user_store_monitor, store_monitor_cb, this);
g_file_monitor_cancel (priv->user_store_monitor);
g_object_unref (priv->user_store_monitor);
}
if (priv->gtk_store_monitor)
gnome_vfs_monitor_cancel (priv->gtk_store_monitor);
if (priv->gtk_store_monitor) {
g_signal_handlers_disconnect_by_func (priv->gtk_store_monitor, store_monitor_cb, this);
g_file_monitor_cancel (priv->gtk_store_monitor);
g_object_unref (priv->gtk_store_monitor);
}
libslab_gconf_notify_remove (priv->gconf_monitor);
......@@ -995,27 +971,48 @@ update_user_spec_path (BookmarkAgent *this)
g_object_notify (G_OBJECT (this), BOOKMARK_AGENT_STORE_STATUS_PROP);
if (priv->user_store_monitor) {
gnome_vfs_monitor_cancel (priv->user_store_monitor);
g_file_monitor_cancel (priv->user_store_monitor);
g_object_unref (priv->user_store_monitor);
priv->user_store_monitor = NULL;
}
if (priv->status == BOOKMARK_STORE_DEFAULT)
gnome_vfs_monitor_add (
& priv->user_store_monitor, priv->user_store_path,
GNOME_VFS_MONITOR_FILE, store_monitor_cb, this);
if (priv->status == BOOKMARK_STORE_DEFAULT) {
GFile *user_store_file;
user_store_file = g_file_new_for_path (priv->user_store_path);
priv->user_store_monitor = g_file_monitor_file (user_store_file,
0, NULL, NULL);
if (priv->user_store_monitor) {
g_signal_connect (priv->user_store_monitor, "changed",
G_CALLBACK (store_monitor_cb), this);
}
g_object_unref (user_store_file);
}
}
if (libslab_strcmp (priv->store_path, path)) {
g_free (priv->store_path);
priv->store_path = path;
if (priv->store_monitor)
gnome_vfs_monitor_cancel (priv->store_monitor);
if (priv->store_monitor) {
g_file_monitor_cancel (priv->store_monitor);
g_object_unref (priv->store_monitor);
}
if (priv->store_path) {
GFile *store_file;
if (priv->store_path)
gnome_vfs_monitor_add (
& priv->store_monitor, priv->store_path,
GNOME_VFS_MONITOR_FILE, store_monitor_cb, this);
store_file = g_file_new_for_path (priv->store_path);
priv->store_monitor = g_file_monitor_file (store_file,
0, NULL, NULL);
if (priv->store_monitor) {
g_signal_connect (priv->store_monitor, "changed",
G_CALLBACK (store_monitor_cb), this);
}
g_object_unref (store_file);
}
}
else
g_free (path);
......@@ -1210,8 +1207,8 @@ create_dir_item (BookmarkAgent *this, const gchar *uri)
}
static void
store_monitor_cb (GnomeVFSMonitorHandle *handle, const gchar *monitor_uri,
const gchar *info_uri, GnomeVFSMonitorEventType type, gpointer user_data)
store_monitor_cb (GFileMonitor *mon, GFile *f1, GFile *f2,
GFileMonitorEvent event_type, gpointer user_data)
{
update_agent (BOOKMARK_AGENT (user_data));
}
......@@ -1240,10 +1237,8 @@ weak_destroy_cb (gpointer data, GObject *g_obj)
instances [GPOINTER_TO_INT (data)] = NULL;
}
#ifdef USE_GTK_RECENT_MANAGER
static gint
recent_item_mru_comp_func (gconstpointer a, gconstpointer b)
{
return ((BookmarkItem *) b)->mtime - ((BookmarkItem *) a)->mtime;
}
#endif
......@@ -23,8 +23,8 @@
#include <glib/gi18n.h>
#include <string.h>
#include <libgnomeui/gnome-icon-lookup.h>
#include <libgnomevfs/gnome-vfs-mime-handlers.h>
#include <libgnomevfs/gnome-vfs.h>
#include <gio/gio.h>
#include <gdk/gdk.h>
#include <unistd.h>
#include "slab-gnome-util.h"
......@@ -67,7 +67,7 @@ typedef struct
gchar *icon_name;
GtkBin *header_bin;
GnomeVFSMimeApplication *default_app;
GAppInfo *default_app;
gboolean image_is_broken;
......@@ -121,7 +121,7 @@ directory_tile_new (const gchar *in_uri, const gchar *title, const gchar *icon_n
if (! title) {
markup = g_path_get_basename (uri);
basename = gnome_vfs_unescape_string (markup, NULL);
basename = g_uri_unescape_string (markup, NULL);
g_free (markup);
}
else
......@@ -262,7 +262,7 @@ directory_tile_private_setup (DirectoryTile *tile)
GConfClient *client;
if (priv->mime_type)
priv->default_app = gnome_vfs_mime_get_default_application (priv->mime_type);
priv->default_app = g_app_info_get_default_for_type (priv->mime_type, TRUE);
else
priv->default_app = NULL;
......@@ -304,7 +304,7 @@ directory_tile_finalize (GObject *g_object)
g_free (priv->icon_name);
g_free (priv->mime_type);
gnome_vfs_mime_application_free (priv->default_app);
g_object_unref (priv->default_app);
client = gconf_client_get_default ();
......@@ -368,41 +368,48 @@ rename_entry_activate_cb (GtkEntry *entry, gpointer user_data)
DirectoryTile *tile = DIRECTORY_TILE (user_data);
DirectoryTilePrivate *priv = DIRECTORY_TILE_GET_PRIVATE (tile);
GnomeVFSURI *src_uri;
GnomeVFSURI *dst_uri;
GFile *src_file;
GFile *dst_file;
gchar *dirname;
gchar *dst_path;
gchar *dst_uri_str;
gchar *dst_uri;
gchar *src_path;
GtkWidget *child;
GtkWidget *header;
GnomeVFSResult retval;
gboolean res;
GError *error = NULL;
if (strlen (gtk_entry_get_text (entry)) < 1)
return;
src_uri = gnome_vfs_uri_new (TILE (tile)->uri);
dirname = gnome_vfs_uri_extract_dirname (src_uri);
src_file = g_file_new_for_uri (TILE (tile)->uri);
dst_path = g_build_filename (dirname, gtk_entry_get_text (entry), NULL);
src_path = g_filename_from_uri (TILE (tile)->uri, NULL, NULL);
dirname = g_path_get_dirname (src_path);
dst_uri = g_build_filename (dirname, gtk_entry_get_text (entry), NULL);
dst_file = g_file_new_for_uri (dst_uri);
dst_uri = gnome_vfs_uri_new (dst_path);
retval = gnome_vfs_xfer_uri (src_uri, dst_uri, GNOME_VFS_XFER_REMOVESOURCE,
GNOME_VFS_XFER_ERROR_MODE_ABORT, GNOME_VFS_XFER_OVERWRITE_MODE_SKIP, NULL, NULL);
g_free (dirname);
g_free (src_path);
dst_uri_str = gnome_vfs_uri_to_string (dst_uri, GNOME_VFS_URI_HIDE_NONE);
res = g_file_move (src_file, dst_file,
G_FILE_COPY_NONE, NULL, NULL, NULL, &error);
if (retval == GNOME_VFS_OK) {
if (res) {
g_free (priv->basename);
priv->basename = g_strdup (gtk_entry_get_text (entry));
}
else
g_warning ("unable to move [%s] to [%s]\n", TILE (tile)->uri, dst_uri_str);
else {
g_warning ("unable to move [%s] to [%s]: %s\n", TILE (tile)->uri, dst_uri,
error->message);
g_error_free (error);
}
g_free (dst_uri);
g_object_unref (src_file);
g_object_unref (dst_file);
header = gtk_label_new (priv->basename);
gtk_misc_set_alignment (GTK_MISC (header), 0.0, 0.5);
......@@ -415,13 +422,6 @@ rename_entry_activate_cb (GtkEntry *entry, gpointer user_data)
gtk_container_add (GTK_CONTAINER (priv->header_bin), header);
gtk_widget_show (header);
gnome_vfs_uri_unref (src_uri);
gnome_vfs_uri_unref (dst_uri);
g_free (dirname);
g_free (dst_path);
g_free (dst_uri_str);
}
static gboolean
......@@ -501,53 +501,20 @@ rename_trigger (Tile *tile, TileEvent *event, TileAction *action)
static void
move_to_trash_trigger (Tile *tile, TileEvent *event, TileAction *action)
{
GnomeVFSURI *src_uri;
GnomeVFSURI *trash_uri;
gchar *file_name;
gchar *trash_uri_str;
GnomeVFSResult retval;
src_uri = gnome_vfs_uri_new (TILE (tile)->uri);
gnome_vfs_find_directory (src_uri, GNOME_VFS_DIRECTORY_KIND_TRASH, &trash_uri,
FALSE, FALSE, 0777);
if (!trash_uri) {
g_warning ("unable to find trash location\n");
return;
}
file_name = gnome_vfs_uri_extract_short_name (src_uri);
if (!file_name) {
g_warning ("unable to extract short name from [%s]\n",
gnome_vfs_uri_to_string (src_uri, GNOME_VFS_URI_HIDE_NONE));
return;
}
trash_uri = gnome_vfs_uri_append_file_name (trash_uri, file_name);
retval = gnome_vfs_xfer_uri (src_uri, trash_uri, GNOME_VFS_XFER_REMOVESOURCE,
GNOME_VFS_XFER_ERROR_MODE_ABORT, GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE, NULL, NULL);
if (retval != GNOME_VFS_OK) {
trash_uri_str = gnome_vfs_uri_to_string (trash_uri, GNOME_VFS_URI_HIDE_NONE);
GFile *src_file;
gboolean res;
GError *error = NULL;
g_warning ("unable to move [%s] to the trash [%s]\n", TILE (tile)->uri,
trash_uri_str);
src_file = g_file_new_for_uri (TILE (tile)->uri);
g_free (trash_uri_str);
res = g_file_trash (src_file, NULL, &error);
if (!res) {
g_warning ("unable to move [%s] to the trash: %s\n", TILE (tile)->uri,
error->message);
g_error_free (error);
}
gnome_vfs_uri_unref (src_uri);
gnome_vfs_uri_unref (trash_uri);
g_free (file_name);
g_object_unref (src_file);
}
static void
......@@ -556,11 +523,9 @@ delete_trigger (Tile *tile, TileEvent *event, TileAction *action)
GtkDialog *confirm_dialog;
gint result;
GnomeVFSURI *src_uri;
GList *list = NULL;
GnomeVFSResult retval;
GFile *src_file;
gboolean res;
GError *error = NULL;
if (GPOINTER_TO_INT (libslab_get_gconf_value (GCONF_CONFIRM_DELETE_KEY))) {
confirm_dialog = GTK_DIALOG(gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_WARNING,
......@@ -579,18 +544,17 @@ delete_trigger (Tile *tile, TileEvent *event, TileAction *action)
return;
}
src_uri = gnome_vfs_uri_new (TILE (tile)->uri);
list = g_list_append (list, src_uri);
src_file = g_file_new_for_uri (TILE (tile)->uri);
retval = gnome_vfs_xfer_delete_list (list, GNOME_VFS_XFER_ERROR_MODE_ABORT,
GNOME_VFS_XFER_REMOVESOURCE, NULL, NULL);
res = g_file_delete (src_file, NULL, &error);
if (retval != GNOME_VFS_OK)
g_warning ("unable to delete [%s]\n", TILE (tile)->uri);
if (!res) {
g_warning ("unable to delete [%s]: %s\n", TILE (tile)->uri,
error->message);
g_error_free (error);
}
gnome_vfs_uri_unref (src_uri);
g_list_free (list);
g_object_unref (src_file);
}
static void
......@@ -667,20 +631,33 @@ open_with_default_trigger (Tile *tile, TileEvent *event, TileAction *action)
{
DirectoryTilePrivate *priv = DIRECTORY_TILE_GET_PRIVATE (tile);
GList *uris = NULL;
GnomeVFSResult retval;
gboolean res;
GdkAppLaunchContext *launch_context;
GError *error = NULL;
if (priv->default_app)
{
uris = g_list_append (uris, TILE (tile)->uri);
retval = gnome_vfs_mime_application_launch (priv->default_app, uris);
if (retval != GNOME_VFS_OK)
launch_context = gdk_app_launch_context_new ();
gdk_app_launch_context_set_screen (launch_context,
gtk_widget_get_screen (GTK_WIDGET (tile)));
gdk_app_launch_context_set_timestamp (launch_context,
event->time);
res = g_app_info_launch_uris (priv->default_app, uris,
G_APP_LAUNCH_CONTEXT (launch_context),
&error);
if (!res) {
g_warning
("error: could not launch application with [%s]. GnomeVFSResult = %d\n",
TILE (tile)->uri, retval);
("error: could not launch application with [%s]: %s\n",
TILE (tile)->uri, error->message);
g_error_free (error);
}
g_list_free (uris);
g_object_unref (launch_context);
} else {
gchar *cmd;
cmd = string_replace_once (
......
......@@ -23,12 +23,7 @@
#include <glib/gi18n.h>
#include <string.h>
#include <libgnomeui/gnome-icon-lookup.h>
#include <libgnomevfs/gnome-vfs-ops.h>
#include <libgnomevfs/gnome-vfs-uri.h>
#include <libgnomevfs/gnome-vfs-xfer.h>
#include <libgnomevfs/gnome-vfs-utils.h>
#include <libgnomevfs/gnome-vfs-mime-handlers.h>
#include <libgnomevfs/gnome-vfs-find-directory.h>
#include <gio/gio.h>
#include "slab-gnome-util.h"
#include "gnome-utils.h"
......@@ -77,7 +72,7 @@ typedef struct
gchar *mime_type;
time_t modified;
GnomeVFSMimeApplication *default_app;
GAppInfo *default_app;
GtkBin *header_bin;
......@@ -155,7 +150,7 @@ document_tile_new (const gchar *in_uri, const gchar *mime_type, time_t modified)
image = gtk_image_new ();
markup = g_path_get_basename (uri);
basename = gnome_vfs_unescape_string (markup, NULL);
basename = g_uri_unescape_string (markup, NULL);
g_free (markup);
header = create_header (basename);
......@@ -199,7 +194,7 @@ document_tile_new (const gchar *in_uri, const gchar *mime_type, time_t modified)
if (priv->default_app) {
markup = g_markup_printf_escaped (_("<b>Open with \"%s\"</b>"),
priv->default_app->name);
g_app_info_get_name (priv->default_app));
action = tile_action_new (TILE (this), open_with_default_trigger, markup,
TILE_ACTION_OPENS_NEW_WINDOW);
g_free (markup);
......@@ -324,23 +319,16 @@ document_tile_private_setup (DocumentTile *this)
{
DocumentTilePrivate *priv = DOCUMENT_TILE_GET_PRIVATE (this);
GnomeVFSResult result;
GnomeVFSFileInfo *info;
GFile *file;
GAppInfo *app;
GConfClient *client;
file = g_file_new_for_uri (TILE (this)->uri);
app = g_file_query_default_handler (file, NULL, NULL);
priv->default_app = app;
info = gnome_vfs_file_info_new ();
result = gnome_vfs_get_file_info (TILE (this)->uri, info,
GNOME_VFS_FILE_INFO_GET_MIME_TYPE | GNOME_VFS_FILE_INFO_FORCE_FAST_MIME_TYPE);
if (result == GNOME_VFS_OK)
priv->default_app = gnome_vfs_mime_get_default_application (priv->mime_type);
else
priv->default_app = NULL;