totem r5302 - in trunk: . src src/plugins/publish
- From: pwithnall svn gnome org
- To: svn-commits-list gnome org
- Subject: totem r5302 - in trunk: . src src/plugins/publish
- Date: Fri, 14 Mar 2008 23:06:43 +0000 (GMT)
Author: pwithnall
Date: Fri Mar 14 23:06:43 2008
New Revision: 5302
URL: http://svn.gnome.org/viewvc/totem?rev=5302&view=rev
Log:
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)
Modified:
trunk/ChangeLog
trunk/configure.in
trunk/src/plugins/publish/totem-publish.c
trunk/src/totem-menu.c
trunk/src/totem-playlist.c
trunk/src/totem-playlist.h
trunk/src/totem-private.h
trunk/src/totem-uri.c
trunk/src/totem-uri.h
trunk/src/totem.c
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Fri Mar 14 23:06:43 2008
@@ -234,11 +234,11 @@
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
Modified: trunk/src/plugins/publish/totem-publish.c
==============================================================================
--- trunk/src/plugins/publish/totem-publish.c (original)
+++ trunk/src/plugins/publish/totem-publish.c Fri Mar 14 23:06:43 2008
@@ -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"
Modified: trunk/src/totem-menu.c
==============================================================================
--- trunk/src/totem-menu.c (original)
+++ trunk/src/totem-menu.c Fri Mar 14 23:06:43 2008
@@ -686,13 +686,24 @@
{
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 @@
}
/* Play DVB menu items */
-
static void
on_play_dvb_activate (GtkAction *action, Totem *totem)
{
@@ -756,145 +766,103 @@
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);
- /* 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) {
+ if (mount == NULL)
+ continue;
+
+ root = g_mount_get_root (mount);
+ g_object_unref (mount);
+
+ 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 @@
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 @@
}
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 @@
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;
}
Modified: trunk/src/totem-playlist.c
==============================================================================
--- trunk/src/totem-playlist.c (original)
+++ trunk/src/totem-playlist.c Fri Mar 14 23:06:43 2008
@@ -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 @@
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 @@
}
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 *
Modified: trunk/src/totem-playlist.h
==============================================================================
--- trunk/src/totem-playlist.h (original)
+++ trunk/src/totem-playlist.h Fri Mar 14 23:06:43 2008
@@ -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 @@
/* 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,
Modified: trunk/src/totem-private.h
==============================================================================
--- trunk/src/totem-private.h (original)
+++ trunk/src/totem-private.h Fri Mar 14 23:06:43 2008
@@ -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 @@
guint recent_ui_id;
/* Monitor for playlist unmounts and drives/volumes monitoring */
- GnomeVFSVolumeMonitor *monitor;
+ GVolumeMonitor *monitor;
gboolean drives_changed;
/* session */
Modified: trunk/src/totem-uri.c
==============================================================================
--- trunk/src/totem-uri.c (original)
+++ trunk/src/totem-uri.c Fri Mar 14 23:06:43 2008
@@ -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 @@
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 @@
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 @@
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 @@
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 @@
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 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 @@
}
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 @@
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);
+ if (g_file_query_exists (file, NULL) != TRUE) {
+ g_object_unref (file);
return NULL;
+ }
/* Try in the current directory */
subtitle = totem_uri_get_subtitle_for_uri (uri);
if (subtitle != NULL) {
- gnome_vfs_uri_unref (vfsuri);
+ g_object_unref (file);
return subtitle;
}
- subtitle = totem_uri_get_subtitle_in_subdir (vfsuri, "subtitles");
- gnome_vfs_uri_unref (vfsuri);
+ subtitle = totem_uri_get_subtitle_in_subdir (file, "subtitles");
+ g_object_unref (file);
return subtitle;
}
@@ -384,29 +367,14 @@
char *
totem_uri_escape_for_display (const char *uri)
{
- char *disp, *tmp;
-
- disp = gnome_vfs_unescape_string_for_display (uri);
- /* If we don't have UTF-8, try to convert */
- if (g_utf8_validate (disp, -1, NULL) != FALSE)
- return disp;
+ GFile *file;
+ char *disp;
- /* If we don't have UTF-8, try to convert */
- tmp = g_locale_to_utf8 (disp, -1, NULL, NULL, NULL);
- /* If we couldn't convert using the current codeset, try
- * another one */
- if (tmp != NULL) {
- g_free (disp);
- return tmp;
- }
-
- tmp = g_convert (disp, -1, "UTF-8", "ISO8859-1", NULL, NULL, NULL);
- if (tmp != NULL) {
- g_free (disp);
- return tmp;
- }
+ file = g_file_new_for_uri (uri);
+ disp = g_file_get_parse_name (file);
+ g_object_unref (file);
- return g_strdup (uri);
+ return disp;
}
void
Modified: trunk/src/totem-uri.h
==============================================================================
--- trunk/src/totem-uri.h (original)
+++ trunk/src/totem-uri.h Fri Mar 14 23:06:43 2008
@@ -25,24 +25,24 @@
#include "totem.h"
#include <gtk/gtkwindow.h>
-#include <libgnomevfs/gnome-vfs-volume.h>
+#include <gio/gio.h>
G_BEGIN_DECLS
const char * totem_dot_dir (void);
char * totem_pictures_dir (void);
-char* totem_create_full_path (const char *path);
-GnomeVFSVolume* totem_get_volume_for_media (const char *uri);
+char * totem_create_full_path (const char *path);
+GMount * totem_get_mount_for_media (const char *uri);
gboolean totem_playing_dvd (const char *uri);
gboolean totem_is_block_device (const char *uri);
void totem_setup_file_monitoring (Totem *totem);
void totem_setup_file_filters (void);
void totem_destroy_file_filters (void);
-char* totem_uri_get_subtitle_uri (const char *uri);
-char* totem_uri_escape_for_display (const char *uri);
-GSList* totem_add_files (GtkWindow *parent,
+char * totem_uri_get_subtitle_uri (const char *uri);
+char * totem_uri_escape_for_display (const char *uri);
+GSList * totem_add_files (GtkWindow *parent,
const char *path);
-char* totem_add_subtitle (GtkWindow *parent,
+char * totem_add_subtitle (GtkWindow *parent,
const char *path);
void totem_add_pictures_dir (GtkWidget *chooser);
Modified: trunk/src/totem.c
==============================================================================
--- trunk/src/totem.c (original)
+++ trunk/src/totem.c Fri Mar 14 23:06:43 2008
@@ -34,6 +34,7 @@
#include <totem-disc.h>
#include <stdlib.h>
#include <math.h>
+#include <gio/gio.h>
#ifndef HAVE_GTK_ONLY
#include <gnome.h>
@@ -261,8 +262,6 @@
g_object_unref (totem);
- gnome_vfs_shutdown ();
-
exit (0);
}
@@ -345,10 +344,10 @@
void
totem_action_eject (Totem *totem)
{
- GnomeVFSVolume *volume;
+ GMount *mount;
- volume = totem_get_volume_for_media (totem->mrl);
- if (volume == NULL)
+ mount = totem_get_mount_for_media (totem->mrl);
+ if (mount == NULL)
return;
g_free (totem->mrl);
@@ -356,9 +355,9 @@
bacon_video_widget_close (totem->bvw);
totem_file_closed (totem);
- /* the volume monitoring will take care of removing the items */
- gnome_vfs_volume_eject (volume, NULL, NULL);
- gnome_vfs_volume_unref (volume);
+ /* The volume monitoring will take care of removing the items */
+ g_mount_eject (mount, G_MOUNT_UNMOUNT_NONE, NULL, NULL, NULL);
+ g_object_unref (mount);
}
void
@@ -1366,33 +1365,33 @@
static void
drag_video_cb (GtkWidget *widget,
- GdkDragContext *context,
- GtkSelectionData *selection_data,
- guint info,
- guint32 time,
- gpointer callback_data)
+ GdkDragContext *context,
+ GtkSelectionData *selection_data,
+ guint info,
+ guint32 time,
+ gpointer callback_data)
{
Totem *totem = (Totem *) callback_data;
char *text;
int len;
+ GFile *file;
g_assert (selection_data != NULL);
if (totem->mrl == NULL)
return;
- if (totem->mrl[0] == '/')
- text = gnome_vfs_get_uri_from_local_path (totem->mrl);
- else
- text = g_strdup (totem->mrl);
+ /* Canonicalise the MRL as a proper URI */
+ file = g_file_new_for_commandline_arg (totem->mrl);
+ text = g_file_get_uri (file);
+ g_object_unref (file);
g_return_if_fail (text != NULL);
len = strlen (text);
- gtk_selection_data_set (selection_data,
- selection_data->target,
- 8, (guchar *) text, len);
+ gtk_selection_data_set (selection_data, selection_data->target,
+ 8, (guchar *) text, len);
g_free (text);
}
@@ -2650,7 +2649,7 @@
static void
update_media_menu_items (Totem *totem)
{
- GnomeVFSVolume *volume;
+ GMount *mount;
gboolean playing;
playing = totem_playing_dvd (totem->mrl);
@@ -2663,10 +2662,10 @@
/* FIXME we should only show that if we have multiple angles */
totem_action_set_sensitivity ("next-angle", playing);
- volume = totem_get_volume_for_media (totem->mrl);
- totem_action_set_sensitivity ("eject", volume != NULL);
- if (volume != NULL)
- gnome_vfs_volume_unref (volume);
+ mount = totem_get_mount_for_media (totem->mrl);
+ totem_action_set_sensitivity ("eject", mount != NULL);
+ if (mount != NULL)
+ g_object_unref (mount);
}
static void
@@ -3129,8 +3128,6 @@
g_set_application_name (_("Totem Movie Player"));
gtk_window_set_default_icon_name ("totem");
- gnome_vfs_init ();
-
gc = gconf_client_get_default ();
if (gc == NULL)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]