Commit 6f86a70b authored by Philip Withnall's avatar Philip Withnall Committed by Philip Withnall

Convert the bulk of Totem to GIO, leaving the plugins and backends still

2008-03-14  Philip Withnall  <pwithnall@svn.gnome.org>

	* configure.in:
	* src/plugins/publish/totem-publish.c:
	* src/totem-menu.c: (totem_action_add_recent),
	(on_play_dvb_activate), (add_drive_to_menu),
	(update_drive_menu_items), (on_movie_menu_select),
	(on_g_volume_monitor_event), (totem_setup_play_disc):
	* src/totem-playlist.c: (totem_playlist_mrl_to_title),
	(totem_playlist_compare_with_mount),
	(totem_playlist_clear_with_g_mount):
	* src/totem-playlist.h:
	* src/totem-private.h:
	* src/totem-uri.c: (totem_get_mount_for_uri),
	(totem_get_mount_for_media), (totem_is_special_mrl),
	(totem_create_full_path), (totem_action_on_unmount),
	(totem_setup_file_monitoring), (totem_uri_exists),
	(totem_uri_get_subtitle_in_subdir), (totem_uri_get_subtitle_uri),
	(totem_uri_escape_for_display):
	* src/totem-uri.h:
	* src/totem.c: (totem_action_exit), (totem_action_eject),
	(drag_video_cb), (update_media_menu_items), (main): Convert the bulk
	of Totem to GIO, leaving the plugins and backends still to convert.
	(Closes: #512594, helps: #512602)


svn path=/trunk/; revision=5302
parent 9f833008
2008-03-14 Philip Withnall <pwithnall@svn.gnome.org>
* configure.in:
* src/plugins/publish/totem-publish.c:
* src/totem-menu.c: (totem_action_add_recent),
(on_play_dvb_activate), (add_drive_to_menu),
(update_drive_menu_items), (on_movie_menu_select),
(on_g_volume_monitor_event), (totem_setup_play_disc):
* src/totem-playlist.c: (totem_playlist_mrl_to_title),
(totem_playlist_compare_with_mount),
(totem_playlist_clear_with_g_mount):
* src/totem-playlist.h:
* src/totem-private.h:
* src/totem-uri.c: (totem_get_mount_for_uri),
(totem_get_mount_for_media), (totem_is_special_mrl),
(totem_create_full_path), (totem_action_on_unmount),
(totem_setup_file_monitoring), (totem_uri_exists),
(totem_uri_get_subtitle_in_subdir), (totem_uri_get_subtitle_uri),
(totem_uri_escape_for_display):
* src/totem-uri.h:
* src/totem.c: (totem_action_exit), (totem_action_eject),
(drag_video_cb), (update_media_menu_items), (main): Convert the bulk
of Totem to GIO, leaving the plugins and backends still to convert.
(Closes: #512594, helps: #512602)
2008-03-14 Philip Withnall <pwithnall@svn.gnome.org>
* src/plugins/sample-vala/totem-sample-vala-plugin.vala: Update the
......
......@@ -234,11 +234,11 @@ dnl Seems that the order matters because libtool blows
dnl Also check if we're going to be using GTK+ only
if test x$ENABLE_GTK = "xno" ; then
# FIXME: use gmodule-no-export instead!
PKG_CHECK_MODULES(EXTRA_GNOME, glib-2.0 >= $GLIB_REQS gtk+-2.0 >= $GTK_REQS libgnomeui-2.0 >= $GNOMEUI_REQS gnome-vfs-2.0 >= $GNOMEVFS_REQS gnome-vfs-module-2.0 >= $GNOMEVFS_REQS libgnome-2.0 >= $LIBGNOME_REQS gnome-icon-theme >= $GNOMEICON_REQS gmodule-2.0 totem-plparser >= $TOTEM_PLPARSER_REQS $ISO_CODES)
PKG_CHECK_MODULES(EXTRA_GNOME, glib-2.0 >= $GLIB_REQS gtk+-2.0 >= $GTK_REQS libgnomeui-2.0 >= $GNOMEUI_REQS gio-2.0 libgnome-2.0 >= $LIBGNOME_REQS gnome-icon-theme >= $GNOMEICON_REQS gmodule-2.0 totem-plparser >= $TOTEM_PLPARSER_REQS $ISO_CODES)
HAVE_GNOME=yes
else
# FIXME: use gmodule-no-export instead!
PKG_CHECK_MODULES(EXTRA_GNOME, glib-2.0 >= $GLIB_REQS gtk+-2.0 >= $GTK_REQS gnome-vfs-2.0 >= $GNOMEVFS_REQS gnome-vfs-module-2.0 >= $GNOMEVFS_REQS gnome-icon-theme >= $GNOMEICON_REQS gmodule-2.0 totem-plparser >= $TOTEM_PLPARSER_REQS $ISO_CODES)
PKG_CHECK_MODULES(EXTRA_GNOME, glib-2.0 >= $GLIB_REQS gtk+-2.0 >= $GTK_REQS gio-2.0 gnome-icon-theme >= $GNOMEICON_REQS gmodule-2.0 totem-plparser >= $TOTEM_PLPARSER_REQS $ISO_CODES)
AC_DEFINE(USE_STABLE_LIBGNOMEUI, 1, [defined if we don't have GNOME])
AC_DEFINE(HAVE_GTK_ONLY, 1, [defined if GNOME isn't used])
HAVE_GNOME=no
......
......@@ -39,6 +39,7 @@
#include <libepc/service-monitor.h>
#include <libepc-ui/progress-window.h>
#include <libgnomevfs/gnome-vfs.h>
#include "ev-sidebar.h"
#include "totem-plugin.h"
......
......@@ -686,13 +686,24 @@ totem_action_add_recent (Totem *totem, const char *filename)
{
GtkRecentData data;
char *groups[] = { NULL, NULL };
GFile *file;
GFileInfo *file_info;
memset (&data, 0, sizeof (data));
data.mime_type = gnome_vfs_get_mime_type (filename);
file = g_file_new_for_uri (filename);
file_info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE, G_FILE_QUERY_INFO_NONE, NULL, NULL);
/* Probably an unsupported URI scheme */
if (file_info == NULL)
return;
data.mime_type = g_strdup (g_file_info_get_content_type (file_info));
g_object_unref (file_info);
if (data.mime_type == NULL) {
/* No mime-type means warnings, and it breaks when adding
* non-gnome-vfs supported URI schemes */
* unsupported URI schemes */
return;
}
data.display_name = NULL;
......@@ -744,7 +755,6 @@ on_play_disc_activate (GtkAction *action, Totem *totem)
}
/* Play DVB menu items */
static void
on_play_dvb_activate (GtkAction *action, Totem *totem)
{
......@@ -756,145 +766,103 @@ on_play_dvb_activate (GtkAction *action, Totem *totem)
totem_action_play_media (totem, MEDIA_TYPE_DVB, str);
g_free (str);
}
/* A GnomeVFSDrive and GnomeVFSVolume share many similar methods, but do not
share a base class other than GObject. */
static char *
fake_gnome_vfs_device_get_something (GObject *device,
char *(*volume_function) (GnomeVFSVolume *),
char *(*drive_function) (GnomeVFSDrive *)) {
if (GNOME_IS_VFS_VOLUME (device)) {
return (*volume_function) (GNOME_VFS_VOLUME (device));
} else if (GNOME_IS_VFS_DRIVE (device)) {
return (*drive_function) (GNOME_VFS_DRIVE (device));
} else {
g_warning ("neither a GnomeVFSVolume or a GnomeVFSDrive");
return NULL;
}
}
static char *
my_gnome_vfs_volume_get_mount_path (GnomeVFSVolume *volume)
{
char *uri, *path;
uri = gnome_vfs_volume_get_activation_uri (volume);
path = g_filename_from_uri (uri, NULL, NULL);
g_free (uri);
if (path == NULL)
return gnome_vfs_volume_get_device_path (volume);
return path;
}
static void
add_device_to_menu (GObject *device, guint position, Totem *totem)
add_drive_to_menu (GDrive *drive, guint position, Totem *totem)
{
char *name, *escaped_name, *icon_name, *device_path;
char *label, *activation_uri;
char *name, *escaped_name, *device_path, *label;
GtkAction *action;
gboolean disabled = FALSE;
GList *volumes, *i;
GMount *mount;
GFile *root;
GIcon *icon;
const char * const *icon_names;
/* Repeat for all the drive's volumes */
volumes = g_drive_get_volumes (drive);
for (i = volumes; i != NULL; i = i->next) {
/* Add devices with blank CDs and audio CDs in them, but disable them */
mount = g_volume_get_mount (i->data);
if (mount == NULL)
continue;
root = g_mount_get_root (mount);
g_object_unref (mount);
/* Add devices with blank CDs and audio CDs in them, but disable them */
activation_uri = fake_gnome_vfs_device_get_something (device,
&gnome_vfs_volume_get_activation_uri,
&gnome_vfs_drive_get_activation_uri);
if (activation_uri != NULL) {
if (g_str_has_prefix (activation_uri, "burn://") != FALSE || g_str_has_prefix (activation_uri, "cdda://") != FALSE) {
device_path = g_file_get_path (root);
if (g_file_has_uri_scheme (root, "burn") != FALSE || g_file_has_uri_scheme (root, "cdda") != FALSE)
disabled = TRUE;
}
g_free (activation_uri);
} else {
if (GNOME_IS_VFS_DRIVE (device)) {
device_path = gnome_vfs_drive_get_device_path
(GNOME_VFS_DRIVE (device));
if (root == NULL)
disabled = !totem_cd_has_medium (device_path);
/* Work out an icon to display */
icon = g_volume_get_icon (i->data);
icon_names = g_themed_icon_get_names (G_THEMED_ICON (icon));
/* Get the volume's pretty name for the menu label */
name = g_volume_get_name (i->data);
g_strstrip (name);
escaped_name = escape_label_for_menu (name);
g_free (name);
label = g_strdup_printf (_("Play Disc '%s'"), escaped_name);
g_free (escaped_name);
name = g_strdup_printf (_("device%d"), position);
action = gtk_action_new (name, label, NULL, NULL);
g_object_set (G_OBJECT (action),
"icon-name", icon_names[0],
"sensitive", !disabled, NULL);
gtk_action_group_add_action (totem->devices_action_group, action);
g_object_unref (action);
gtk_ui_manager_add_ui (totem->ui_manager, totem->devices_ui_id,
"/tmw-menubar/movie/devices-placeholder", name, name,
GTK_UI_MANAGER_MENUITEM, FALSE);
g_free (name);
g_free (label);
g_object_unref (icon);
if (disabled != FALSE) {
g_free (device_path);
return;
}
}
name = fake_gnome_vfs_device_get_something (device,
&gnome_vfs_volume_get_display_name,
&gnome_vfs_drive_get_display_name);
icon_name = fake_gnome_vfs_device_get_something (device,
&gnome_vfs_volume_get_icon, &gnome_vfs_drive_get_icon);
device_path = fake_gnome_vfs_device_get_something (device,
&my_gnome_vfs_volume_get_mount_path,
&gnome_vfs_drive_get_device_path);
g_strstrip (name);
escaped_name = escape_label_for_menu (name);
g_free (name);
label = g_strdup_printf (_("Play Disc '%s'"), escaped_name);
g_free (escaped_name);
name = g_strdup_printf (_("device%d"), position);
action = gtk_action_new (name, label, NULL, NULL);
g_object_set (G_OBJECT (action), "icon-name", icon_name,
"sensitive", !disabled, NULL);
gtk_action_group_add_action (totem->devices_action_group, action);
g_object_unref (action);
gtk_ui_manager_add_ui (totem->ui_manager, totem->devices_ui_id,
"/tmw-menubar/movie/devices-placeholder", name, name,
GTK_UI_MANAGER_MENUITEM, FALSE);
g_free (name);
g_free (label);
g_free (icon_name);
g_object_set_data_full (G_OBJECT (action),
"device_path", device_path,
(GDestroyNotify) g_free);
if (disabled != FALSE) {
g_free (device_path);
return;
g_signal_connect (G_OBJECT (action), "activate",
G_CALLBACK (on_play_disc_activate), totem);
}
g_object_set_data_full (G_OBJECT (action),
"device_path", device_path,
(GDestroyNotify) g_free);
g_signal_connect (G_OBJECT (action), "activate",
G_CALLBACK (on_play_disc_activate), totem);
g_list_free (volumes);
}
static void
update_drives_menu_items (GtkMenuItem *movie_menuitem, Totem *totem)
update_drive_menu_items (GtkMenuItem *movie_menuitem, Totem *totem)
{
GList *devices, *volumes, *drives, *i;
GList *drives, *i;
guint position;
/* Create a list of suitable devices */
devices = NULL;
volumes = gnome_vfs_volume_monitor_get_mounted_volumes
(totem->monitor);
for (i = volumes; i != NULL; i = i->next) {
if (gnome_vfs_volume_get_device_type (i->data) != GNOME_VFS_DEVICE_TYPE_CDROM)
continue;
gnome_vfs_volume_ref (i->data);
devices = g_list_append (devices, i->data);
}
gnome_vfs_drive_volume_list_free (volumes);
/* Add any suitable devices to the menu */
position = 0;
drives = gnome_vfs_volume_monitor_get_connected_drives (totem->monitor);
drives = g_volume_monitor_get_connected_drives (totem->monitor);
for (i = drives; i != NULL; i = i->next) {
if (gnome_vfs_drive_get_device_type (i->data) != GNOME_VFS_DEVICE_TYPE_CDROM)
continue;
else if (gnome_vfs_drive_is_mounted (i->data))
/* FIXME: We used to explicitly check whether it was a CD/DVD drive */
if (g_drive_can_eject (i->data) == FALSE)
continue;
gnome_vfs_volume_ref (i->data);
devices = g_list_append (devices, i->data);
}
gnome_vfs_drive_volume_list_free (drives);
/* Add the devices to the menu */
position = 0;
for (i = devices; i != NULL; i = i->next) {
position++;
add_device_to_menu (i->data, position, totem);
add_drive_to_menu (i->data, position, totem);
}
g_list_foreach (devices, (GFunc) g_object_unref, NULL);
g_list_free (devices);
g_list_free (drives);
totem->drives_changed = FALSE;
}
......@@ -961,11 +929,9 @@ on_movie_menu_select (GtkMenuItem *movie_menuitem, Totem *totem)
gtk_ui_manager_insert_action_group (totem->ui_manager,
totem->devices_action_group, -1);
update_drive_menu_items (movie_menuitem, totem);
if (totem->drives_changed != FALSE)
update_drives_menu_items (movie_menuitem, totem);
/* check for DVB */
/* Check for DVB */
/* FIXME we should only update if we have an updated as per HAL */
update_dvb_menu_items (movie_menuitem, totem);
......@@ -973,9 +939,9 @@ on_movie_menu_select (GtkMenuItem *movie_menuitem, Totem *totem)
}
static void
on_gnome_vfs_monitor_event (GnomeVFSVolumeMonitor *monitor,
GnomeVFSDrive *drive,
Totem *totem)
on_g_volume_monitor_event (GVolumeMonitor *monitor,
gpointer *device,
Totem *totem)
{
totem->drives_changed = TRUE;
}
......@@ -990,17 +956,17 @@ totem_setup_play_disc (Totem *totem)
G_CALLBACK (on_movie_menu_select), totem);
g_signal_connect (G_OBJECT (totem->monitor),
"drive-connected",
G_CALLBACK (on_gnome_vfs_monitor_event), totem);
"volume-added",
G_CALLBACK (on_g_volume_monitor_event), totem);
g_signal_connect (G_OBJECT (totem->monitor),
"drive-disconnected",
G_CALLBACK (on_gnome_vfs_monitor_event), totem);
"volume-removed",
G_CALLBACK (on_g_volume_monitor_event), totem);
g_signal_connect (G_OBJECT (totem->monitor),
"volume-mounted",
G_CALLBACK (on_gnome_vfs_monitor_event), totem);
"mount-added",
G_CALLBACK (on_g_volume_monitor_event), totem);
g_signal_connect (G_OBJECT (totem->monitor),
"volume-unmounted",
G_CALLBACK (on_gnome_vfs_monitor_event), totem);
"mount-removed",
G_CALLBACK (on_g_volume_monitor_event), totem);
totem->drives_changed = TRUE;
}
......
......@@ -29,8 +29,7 @@
#include <glib/gi18n.h>
#include <gdk/gdkkeysyms.h>
#include <gconf/gconf-client.h>
#include <libgnomevfs/gnome-vfs.h>
#include <libgnomevfs/gnome-vfs-mime-utils.h>
#include <gio/gio.h>
#include <string.h>
#include "totem-uri.h"
......@@ -259,17 +258,18 @@ totem_playlist_error (char *title, char *reason, TotemPlaylist *playlist)
gtk_widget_show (error_dialog);
}
/* This one returns a new string, in UTF8 even if the mrl is encoded
/* This one returns a new string, in UTF8 even if the MRL is encoded
* in the locale's encoding
*/
static char *
totem_playlist_mrl_to_title (const gchar *mrl)
{
char *filename_for_display, *filename, *unescaped;
GFile *file;
char *filename_for_display, *unescaped;
filename = g_path_get_basename (mrl);
unescaped = gnome_vfs_unescape_string_for_display (filename);
g_free (filename);
file = g_file_new_for_uri (mrl);
unescaped = g_file_get_basename (file);
g_object_unref (file);
filename_for_display = g_filename_to_utf8 (unescaped,
-1, /* length */
......@@ -1840,35 +1840,32 @@ totem_playlist_clear_with_compare (TotemPlaylist *playlist, GCompareFunc func,
}
static int
totem_playlist_compare_with_volume (gpointer a, gpointer b)
totem_playlist_compare_with_mount (gpointer a, gpointer b)
{
GnomeVFSVolume *clear_volume = (GnomeVFSVolume *) b;
GMount *clear_mount = (GMount *) b;
const char *mrl = (const char *) a;
GnomeVFSVolume *volume;
GnomeVFSVolumeMonitor *monitor;
GMount *mount;
gboolean retval = FALSE;
monitor = gnome_vfs_get_volume_monitor ();
volume = totem_get_volume_for_media (mrl);
mount = totem_get_mount_for_media (mrl);
if (volume == clear_volume)
if (mount == clear_mount)
retval = TRUE;
if (volume != NULL)
gnome_vfs_volume_unref (volume);
if (mount != NULL)
g_object_unref (mount);
return retval;
}
void
totem_playlist_clear_with_gnome_vfs_volume (TotemPlaylist *playlist,
GnomeVFSVolume *volume)
totem_playlist_clear_with_g_mount (TotemPlaylist *playlist,
GMount *mount)
{
totem_playlist_clear_with_compare (playlist,
(GCompareFunc) totem_playlist_compare_with_volume,
volume);
(GCompareFunc) totem_playlist_compare_with_mount,
mount);
}
char *
......
......@@ -24,8 +24,8 @@
#define TOTEM_PLAYLIST_H
#include <gtk/gtkvbox.h>
#include <libgnomevfs/gnome-vfs-volume.h>
#include <totem-pl-parser.h>
#include <gio/gio.h>
G_BEGIN_DECLS
......@@ -96,8 +96,8 @@ void totem_playlist_save_current_playlist_ext (TotemPlaylist *playlist,
/* totem_playlist_clear doesn't emit the current_removed signal, even if it does
* because the caller should know what to do after it's done with clearing */
gboolean totem_playlist_clear (TotemPlaylist *playlist);
void totem_playlist_clear_with_gnome_vfs_volume (TotemPlaylist *playlist,
GnomeVFSVolume *volume);
void totem_playlist_clear_with_g_mount (TotemPlaylist *playlist,
GMount *mount);
char *totem_playlist_get_current_mrl (TotemPlaylist *playlist,
char **subtitle);
char *totem_playlist_get_current_title (TotemPlaylist *playlist,
......
......@@ -30,7 +30,7 @@
#include <gconf/gconf-client.h>
#include <gtk/gtk.h>
#include <libgnomevfs/gnome-vfs.h>
#include <gio/gio.h>
#include "totem-playlist.h"
#include "bacon-message-connection.h"
......@@ -138,7 +138,7 @@ struct TotemObject {
guint recent_ui_id;
/* Monitor for playlist unmounts and drives/volumes monitoring */
GnomeVFSVolumeMonitor *monitor;
GVolumeMonitor *monitor;
gboolean drives_changed;
/* session */
......
......@@ -25,10 +25,10 @@
#include <glib.h>
#include <glib/gi18n.h>
#include <string.h>
#include <libgnomevfs/gnome-vfs-utils.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <gio/gio.h>
#include "totem-mime-types.h"
#include "totem-uri.h"
......@@ -88,25 +88,26 @@ totem_pictures_dir (void)
return g_strdup (dir);
}
static GnomeVFSVolume *
totem_get_volume_for_uri (GnomeVFSVolumeMonitor *monitor, const char *path)
static GMount *
totem_get_mount_for_uri (const char *path)
{
GnomeVFSVolume *vol;
GnomeVFSDeviceType type;
GMount *mount;
GFile *file;
vol = gnome_vfs_volume_monitor_get_volume_for_path (monitor, path);
if (vol == NULL)
file = g_file_new_for_path (path);
mount = g_file_find_enclosing_mount (file, NULL, NULL);
g_object_unref (file);
if (mount == NULL)
return NULL;
type = gnome_vfs_volume_get_device_type (vol);
if (type != GNOME_VFS_DEVICE_TYPE_AUDIO_CD
&& type != GNOME_VFS_DEVICE_TYPE_VIDEO_DVD
&& type != GNOME_VFS_DEVICE_TYPE_CDROM) {
gnome_vfs_volume_unref (vol);
vol = NULL;
/* FIXME: We used to explicitly check whether it was a CD/DVD */
if (g_mount_can_eject (mount) == TRUE) {
g_object_unref (mount);
return NULL;
}
return vol;
return mount;
}
static char *
......@@ -123,32 +124,29 @@ totem_get_mountpoint_for_vcd (const char *uri)
return NULL;
}
GnomeVFSVolume *
totem_get_volume_for_media (const char *uri)
GMount *
totem_get_mount_for_media (const char *uri)
{
GnomeVFSVolumeMonitor *monitor;
GnomeVFSVolume *ret;
char *mount;
GMount *ret;
char *mount_path;
if (uri == NULL)
return NULL;
mount = NULL;
ret = NULL;
mount_path = NULL;
if (g_str_has_prefix (uri, "dvd://") != FALSE)
mount = totem_get_mountpoint_for_dvd (uri);
mount_path = totem_get_mountpoint_for_dvd (uri);
else if (g_str_has_prefix (uri, "vcd:") != FALSE)
mount = totem_get_mountpoint_for_vcd (uri);
mount_path = totem_get_mountpoint_for_vcd (uri);
else if (g_str_has_prefix (uri, "file:") != FALSE)
mount = g_filename_from_uri (uri, NULL, NULL);
mount_path = g_filename_from_uri (uri, NULL, NULL);
if (mount == NULL)
if (mount_path == NULL)
return NULL;
monitor = gnome_vfs_get_volume_monitor ();
ret = totem_get_volume_for_uri (monitor, mount);
g_free (mount);
ret = totem_get_mount_for_uri (mount_path);
g_free (mount_path);
return ret;
}
......@@ -156,20 +154,18 @@ totem_get_volume_for_media (const char *uri)
static gboolean
totem_is_special_mrl (const char *uri)
{
GnomeVFSVolume *vol;
gboolean retval;
GMount *mount;
if (uri == NULL || g_str_has_prefix (uri, "file:") != FALSE)
return FALSE;
if (g_str_has_prefix (uri, "dvb:") != FALSE)
return TRUE;
vol = totem_get_volume_for_media (uri);
retval = (vol != NULL);
if (vol != NULL)
gnome_vfs_volume_unref (vol);
mount = totem_get_mount_for_media (uri);
if (mount != NULL)
g_object_unref (mount);
return retval;
return (mount != NULL);
}
gboolean
......@@ -198,7 +194,8 @@ totem_is_block_device (const char *uri)
char *
totem_create_full_path (const char *path)
{
char *retval, *curdir, *curdir_withslash, *escaped;
GFile *file;
char *retval;
g_return_val_if_fail (path != NULL, NULL);
......@@ -207,45 +204,28 @@ totem_create_full_path (const char *path)
if (totem_is_special_mrl (path) != FALSE)
return NULL;
if (path[0] == G_DIR_SEPARATOR) {
escaped = gnome_vfs_escape_path_string (path);
retval = g_strdup_printf ("file://%s", escaped);
g_free (escaped);
return retval;
}
curdir = g_get_current_dir ();
escaped = gnome_vfs_escape_path_string (curdir);
curdir_withslash = g_strdup_printf ("file://%s%c",
escaped, G_DIR_SEPARATOR);
g_free (escaped);
g_free (curdir);
escaped = gnome_vfs_escape_path_string (path);
retval = gnome_vfs_uri_make_full_from_relative
(curdir_withslash, escaped);
g_free (curdir_withslash);
g_free (escaped);
file = g_file_new_for_commandline_arg (path);
retval = g_file_get_uri (file);
g_object_unref (file);
return retval;
}
static void
totem_action_on_unmount (GnomeVFSVolumeMonitor *vfsvolumemonitor,
GnomeVFSVolume *volume,
totem_action_on_unmount (GVolumeMonitor *volume_monitor,
GMount *mount,
Totem *totem)
{
totem_playlist_clear_with_gnome_vfs_volume (totem->playlist, volume);
totem_playlist_clear_with_g_mount (totem->playlist, mount);
}
void
totem_setup_file_monitoring (Totem *totem)
{
totem->monitor = gnome_vfs_get_volume_monitor ();
totem->monitor = g_volume_monitor_get ();
g_signal_connect (G_OBJECT (totem->monitor),
"volume_pre_unmount",
"mount-pre-unmount",
G_CALLBACK (totem_action_on_unmount),
totem);
}
......@@ -264,13 +244,13 @@ static const char subtitle_ext[][4] = {
static inline gboolean
totem_uri_exists (const char *uri)
{
GnomeVFSURI *vfsuri = gnome_vfs_uri_new (uri);
if (vfsuri != NULL) {
if (gnome_vfs_uri_exists (vfsuri)) {
gnome_vfs_uri_unref (vfsuri);
GFile *file = g_file_new_for_uri (uri);
if (file != NULL) {
if (g_file_query_exists (file, NULL)) {
g_object_unref (file);
return TRUE;
}
gnome_vfs_uri_unref (vfsuri);
g_object_unref (file);
}
return FALSE;
}
......@@ -326,24 +306,27 @@ totem_uri_get_subtitle_for_uri (const char *uri)
}
static char *
totem_uri_get_subtitle_in_subdir (GnomeVFSURI *vfsuri, const char *subdir)
totem_uri_get_subtitle_in_subdir (GFile *file, const char *subdir)
{
char *filename, *subtitle, *fullpath_str;
GnomeVFSURI *parent, *fullpath, *directory;
parent = gnome_vfs_uri_get_parent (vfsuri);
directory = gnome_vfs_uri_append_path (parent, subdir);
gnome_vfs_uri_unref (parent);
filename = g_path_get_basename (gnome_vfs_uri_get_path (vfsuri));
fullpath = gnome_vfs_uri_append_string (directory, filename);
gnome_vfs_uri_unref (directory);
g_free (filename);
fullpath_str = gnome_vfs_uri_to_string (fullpath, 0);
gnome_vfs_uri_unref (fullpath);
subtitle = totem_uri_get_subtitle_for_uri (fullpath_str);
g_free (fullpath_str);
char *filename, *subtitle, *full_path_str;
GFile *parent, *full_path, *directory;
/* Get the sibling directory @subdir of the file @file */
parent = g_file_get_parent (file);
directory = g_file_get_child (parent, subdir);
g_object_unref (parent);
/* Get the file of the same name as @file in the @subdir directory */
filename = g_file_get_basename (file);
full_path = g_file_get_child (directory, filename);
g_object_unref (directory);
g_free (filename);
/* Get the subtitles from that URI */
full_path_str = g_file_get_uri (full_path);
g_object_unref (full_path);
subtitle = totem_uri_get_subtitle_for_uri (full_path_str);
g_free (full_path_str);
return subtitle;
}
......@@ -351,32 +334,32 @@ totem_uri_get_subtitle_in_subdir (GnomeVFSURI *vfsuri, const char *subdir)
char *
totem_uri_get_subtitle_uri (const char *uri)
{
GnomeVFSURI *vfsuri;
GFile *file;
char *subtitle;
if (g_str_has_prefix (uri, "http") != FALSE) {
if (g_str_has_prefix (uri, "http") != FALSE)
return NULL;
}
/* Has the user specified a subtitle file manually? */
if (strstr (uri, "#subtitle:") != NULL) {
if (strstr (uri, "#subtitle:") != NULL)
return NULL;
}
/* Does gnome-vfs support that scheme? */
vfsuri = gnome_vfs_uri_new (uri);
if (vfsuri == NULL)
/* Does the file exist? */
file = g_file_new_for_uri (uri);