sound-juicer r2205 - in trunk: . libjuicer src
- From: rburton svn gnome org
- To: svn-commits-list gnome org
- Subject: sound-juicer r2205 - in trunk: . libjuicer src
- Date: Thu, 5 Jun 2008 10:28:01 +0000 (UTC)
Author: rburton
Date: Thu Jun 5 10:28:01 2008
New Revision: 2205
URL: http://svn.gnome.org/viewvc/sound-juicer?rev=2205&view=rev
Log:
2008-06-05 Ross Burton <ross burtonini com>
* configure.in:
* src/sj-main.c:
* src/sound-juicer.h:
* src/sj-play.c:
* src/sj-extracting.c:
* src/sj-prefs.c:
* libjuicer/sj-extractor.c:
* libjuicer/sj-util.c:
* libjuicer/sj-extractor.h:
* libjuicer/sj-util.h:
Port to GIO. Thanks to Michael Terry for the bulk of this
work! (#514673).
Modified:
trunk/ChangeLog
trunk/configure.in
trunk/libjuicer/sj-extractor.c
trunk/libjuicer/sj-extractor.h
trunk/libjuicer/sj-util.c
trunk/libjuicer/sj-util.h
trunk/src/sj-extracting.c
trunk/src/sj-main.c
trunk/src/sj-play.c
trunk/src/sj-prefs.c
trunk/src/sound-juicer.h
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Thu Jun 5 10:28:01 2008
@@ -50,7 +50,7 @@
LIBS="$oldlibs"
# Find the UI libraries
-PKG_CHECK_MODULES(UI, gtk+-2.0 >= 2.12 libglade-2.0 gconf-2.0 libgnomeui-2.0 >= 2.13.0 gnome-vfs-2.0 >= 2.9 gnome-vfs-module-2.0 > 2.9 gmodule-export-2.0 dbus-glib-1)
+PKG_CHECK_MODULES(UI, gtk+-2.0 >= 2.12 libglade-2.0 gconf-2.0 libgnomeui-2.0 >= 2.13.0 gio-2.0 gmodule-export-2.0 dbus-glib-1)
AC_SUBST(UI_CFLAGS)
AC_SUBST(UI_LIBS)
@@ -62,7 +62,7 @@
AM_GST_ELEMENT_CHECK(vorbisenc,,AC_MSG_WARN([The 'vorbisenc' element was not found. This will cause encoding to Ogg Vorbis to fail.]))
AM_GST_ELEMENT_CHECK(flacenc,,AC_MSG_WARN([The 'flacenc' element was not found. This will cause encoding to FLAC to fail.]))
AM_GST_ELEMENT_CHECK(wavenc,,AC_MSG_WARN([The 'wavenc' element was not found. This will cause encoding to Wave to fail.]))
-AM_GST_ELEMENT_CHECK(gnomevfssink,,AC_MSG_WARN([The 'gnomevfssink' element was not found. This will cause Sound Juicer to fail at runtime.]))
+AM_GST_ELEMENT_CHECK(giosink,,AC_MSG_WARN([The 'giosink' element was not found. This will cause Sound Juicer to fail at runtime.]))
# Find GNOME Media Profiles
PKG_CHECK_MODULES(MEDIA_PROFILES, gnome-media-profiles >= 2.11.91)
Modified: trunk/libjuicer/sj-extractor.c
==============================================================================
--- trunk/libjuicer/sj-extractor.c (original)
+++ trunk/libjuicer/sj-extractor.c Thu Jun 5 10:28:01 2008
@@ -60,7 +60,7 @@
#define DEFAULT_AUDIO_PROFILE_NAME "cdlossy"
/* Element names */
-#define FILE_SINK "gnomevfssink"
+#define FILE_SINK "giosink"
struct SjExtractorPrivate {
/** The current audio profile */
@@ -308,8 +308,9 @@
g_error_free (error);
}
+#if 0
/**
- * Callback from the gnomevfssink to say that its about to overwrite a file.
+ * Callback from the giosink to say that its about to overwrite a file.
* For now, Just Say Yes. If this API will stay in 0.9, then rewrite
* SjExtractor.
*/
@@ -318,6 +319,7 @@
{
return TRUE;
}
+#endif
static void
build_pipeline (SjExtractor *extractor)
@@ -379,7 +381,9 @@
_("Could not create GStreamer file output"));
return;
}
+#if 0
g_signal_connect (G_OBJECT (priv->filesink), "allow-overwrite", G_CALLBACK (just_say_yes), extractor);
+#endif
/* Add the elements to the pipeline */
gst_bin_add_many (GST_BIN (priv->pipeline), priv->cdsrc, priv->queue, priv->encoder, priv->filesink, NULL);
@@ -465,7 +469,7 @@
}
void
-sj_extractor_extract_track (SjExtractor *extractor, const TrackDetails *track, const char* url, GError **error)
+sj_extractor_extract_track (SjExtractor *extractor, const TrackDetails *track, GFile *file, GError **error)
{
GParamSpec *spec;
GstStateChangeReturn state_ret;
@@ -473,10 +477,11 @@
GstIterator *iter;
GstTagSetter *tagger;
gboolean done;
+ char *uri;
g_return_if_fail (SJ_IS_EXTRACTOR (extractor));
- g_return_if_fail (url != NULL);
+ g_return_if_fail (file != NULL);
g_return_if_fail (track != NULL);
priv = extractor->priv;
@@ -499,7 +504,9 @@
/* Set the output filename */
gst_element_set_state (priv->filesink, GST_STATE_NULL);
- g_object_set (G_OBJECT (priv->filesink), "location", url, NULL);
+ uri = g_file_get_uri (file);
+ g_object_set (G_OBJECT (priv->filesink), "location", uri, NULL);
+ g_free (uri);
/* Set the metadata */
iter = gst_bin_iterate_all_by_interface (GST_BIN (priv->pipeline), GST_TYPE_TAG_SETTER);
Modified: trunk/libjuicer/sj-extractor.h
==============================================================================
--- trunk/libjuicer/sj-extractor.h (original)
+++ trunk/libjuicer/sj-extractor.h Thu Jun 5 10:28:01 2008
@@ -25,6 +25,7 @@
#include <glib/gmacros.h>
#include <glib-object.h>
+#include <gio/gio.h>
#include <profiles/audio-profile.h>
#include "sj-structures.h"
@@ -66,7 +67,7 @@
void sj_extractor_set_paranoia (SjExtractor *extractor, const int paranoia_mode);
-void sj_extractor_extract_track (SjExtractor *extractor, const TrackDetails *track, const char* url, GError **error);
+void sj_extractor_extract_track (SjExtractor *extractor, const TrackDetails *track, GFile *file, GError **error);
void sj_extractor_cancel_extract (SjExtractor *extractor);
Modified: trunk/libjuicer/sj-util.c
==============================================================================
--- trunk/libjuicer/sj-util.c (original)
+++ trunk/libjuicer/sj-util.c Thu Jun 5 10:28:01 2008
@@ -25,66 +25,57 @@
#endif /* HAVE_CONFIG_H */
#include "sj-util.h"
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
-
/**
* Stolen from gnome-vfs/programs/gnomevfs-mkdir.c (v1.3)
*/
-GnomeVFSResult
-make_directory_with_parents_for_uri (GnomeVFSURI * uri, guint perm)
+gboolean
+make_directory_with_parents (GFile * uri, GError **error_out)
{
- GnomeVFSResult result;
- GnomeVFSURI *parent, *work_uri;
+ gboolean result;
+ GFile *parent, *work_uri;
GList *list = NULL;
+ GError *error = NULL;
- result = gnome_vfs_make_directory_for_uri (uri, perm);
- if (result == GNOME_VFS_OK || result != GNOME_VFS_ERROR_NOT_FOUND)
+ result = g_file_make_directory (uri, NULL, &error);
+ if (result || error->code != G_IO_ERROR_NOT_FOUND) {
+ if (error_out)
+ *error_out = error;
return result;
+ }
work_uri = uri;
- while (result == GNOME_VFS_ERROR_NOT_FOUND) {
- parent = gnome_vfs_uri_get_parent (work_uri);
- result = gnome_vfs_make_directory_for_uri (parent, perm);
+ while (!result && error->code == G_IO_ERROR_NOT_FOUND) {
+ g_clear_error (&error);
+
+ parent = g_file_get_parent (work_uri);
+ result = g_file_make_directory (parent, NULL, &error);
- if (result == GNOME_VFS_ERROR_NOT_FOUND)
+ if (!result && error->code == G_IO_ERROR_NOT_FOUND)
list = g_list_prepend (list, parent);
work_uri = parent;
}
- if (result != GNOME_VFS_OK) {
+ if (!result) {
/* Clean up */
while (list != NULL) {
- gnome_vfs_uri_unref ((GnomeVFSURI *) list->data);
+ g_object_unref ((GFile *) list->data);
list = g_list_remove (list, list->data);
}
+ if (error_out)
+ *error_out = error;
return result;
}
- while (result == GNOME_VFS_OK && list != NULL) {
- result = gnome_vfs_make_directory_for_uri
- ((GnomeVFSURI *) list->data, perm);
+ while (result && list != NULL) {
+ result = g_file_make_directory ((GFile *) list->data, NULL, NULL);
- gnome_vfs_uri_unref ((GnomeVFSURI *) list->data);
+ g_object_unref ((GFile *) list->data);
list = g_list_remove (list, list->data);
}
- result = gnome_vfs_make_directory_for_uri (uri, perm);
- return result;
-}
-
-GnomeVFSResult
-make_directory_with_parents (const gchar * text_uri, guint perm)
-{
- GnomeVFSURI *uri;
- GnomeVFSResult result;
-
- uri = gnome_vfs_uri_new (text_uri);
- result = make_directory_with_parents_for_uri (uri, perm);
- gnome_vfs_uri_unref (uri);
-
+ result = g_file_make_directory (uri, NULL, error_out);
return result;
}
@@ -98,152 +89,28 @@
g_list_free (l);
}
-/* Copied from xdg-user-dir-lookup.c */
-#include <stdlib.h>
-#include <string.h>
-
-static char *
-xdg_user_dir_lookup (const char *type)
-{
- FILE *file;
- char *home_dir, *config_home, *config_file;
- char buffer[512];
- char *user_dir;
- char *p, *d;
- int len;
- int relative;
-
- home_dir = getenv ("HOME");
-
- if (home_dir == NULL)
- return strdup ("/tmp");
-
- config_home = getenv ("XDG_CONFIG_HOME");
- if (config_home == NULL || config_home[0] == 0)
- {
- config_file = malloc (strlen (home_dir) + strlen ("/.config/user-dirs.dirs") + 1);
- strcpy (config_file, home_dir);
- strcat (config_file, "/.config/user-dirs.dirs");
- }
- else
- {
- config_file = malloc (strlen (config_home) + strlen ("/user-dirs.dirs") + 1);
- strcpy (config_file, config_home);
- strcat (config_file, "/user-dirs.dirs");
- }
-
- file = fopen (config_file, "r");
- free (config_file);
- if (file == NULL)
- goto error;
-
- user_dir = NULL;
- while (fgets (buffer, sizeof (buffer), file))
- {
- /* Remove newline at end */
- len = strlen (buffer);
- if (len > 0 && buffer[len-1] == '\n')
- buffer[len-1] = 0;
-
- p = buffer;
- while (*p == ' ' || *p == '\t')
- p++;
-
- if (strncmp (p, "XDG_", 4) != 0)
- continue;
- p += 4;
- if (strncmp (p, type, strlen (type)) != 0)
- continue;
- p += strlen (type);
- if (strncmp (p, "_DIR", 4) != 0)
- continue;
- p += 4;
-
- while (*p == ' ' || *p == '\t')
- p++;
-
- if (*p != '=')
- continue;
- p++;
-
- while (*p == ' ' || *p == '\t')
- p++;
-
- if (*p != '"')
- continue;
- p++;
-
- relative = 0;
- if (strncmp (p, "$HOME/", 6) == 0)
- {
- p += 6;
- relative = 1;
- }
- else if (*p != '/')
- continue;
-
- if (relative)
- {
- user_dir = malloc (strlen (home_dir) + 1 + strlen (p) + 1);
- strcpy (user_dir, home_dir);
- strcat (user_dir, "/");
- }
- else
- {
- user_dir = malloc (strlen (p) + 1);
- *user_dir = 0;
- }
-
- d = user_dir + strlen (user_dir);
- while (*p && *p != '"')
- {
- if ((*p == '\\') && (*(p+1) != 0))
- p++;
- *d++ = *p++;
- }
- *d = 0;
- }
- fclose (file);
-
- if (user_dir)
- return user_dir;
-
- error:
- /* Special case desktop for historical compatibility */
- if (strcmp (type, "DESKTOP") == 0)
- {
- user_dir = malloc (strlen (home_dir) + strlen ("/Desktop") + 1);
- strcpy (user_dir, home_dir);
- strcat (user_dir, "/Desktop");
- return user_dir;
- }
- else
- return strdup (home_dir);
-}
-
-char *
+GFile *
sj_get_default_music_directory (void)
{
- char *uri, *dir;
+ const char *dir;
+ GFile *file;
- dir = xdg_user_dir_lookup ("MUSIC");
+ dir = g_get_user_special_dir (G_USER_DIRECTORY_MUSIC);
if (dir == NULL) {
- return gnome_vfs_get_uri_from_local_path (g_get_home_dir ());
+ dir = g_get_home_dir ();
}
- uri = gnome_vfs_get_uri_from_local_path (dir);
- g_free (dir);
- return uri;
+ file = g_file_new_for_path (dir);
+ return file;
}
void
sj_add_default_dirs (GtkFileChooser *dialog)
{
- char *dir;
+ const char *dir;
- dir = xdg_user_dir_lookup ("MUSIC");
- if (dir == NULL)
- return;
- gtk_file_chooser_add_shortcut_folder (dialog, dir, NULL);
- g_free (dir);
+ dir = g_get_user_special_dir (G_USER_DIRECTORY_MUSIC);
+ if (dir) {
+ gtk_file_chooser_add_shortcut_folder (dialog, dir, NULL);
+ }
}
Modified: trunk/libjuicer/sj-util.h
==============================================================================
--- trunk/libjuicer/sj-util.h (original)
+++ trunk/libjuicer/sj-util.h Thu Jun 5 10:28:01 2008
@@ -24,16 +24,14 @@
#define SJ_UTIL_H
#include <sys/types.h>
+#include <gio/gio.h>
#include <gtk/gtkfilechooser.h>
-#include <libgnomevfs/gnome-vfs-uri.h>
-#include <libgnomevfs/gnome-vfs-result.h>
-GnomeVFSResult make_directory_with_parents_for_uri (GnomeVFSURI * uri, guint perm);
-GnomeVFSResult make_directory_with_parents (const gchar * text_uri, guint perm);
+gboolean make_directory_with_parents (GFile *uri, GError **error);
void g_list_deep_free (GList *l, GFunc free_func);
void sj_add_default_dirs (GtkFileChooser *dialog);
-char *sj_get_default_music_directory (void);
+GFile *sj_get_default_music_directory (void);
#endif /* SJ_UTIL_H */
Modified: trunk/src/sj-extracting.c
==============================================================================
--- trunk/src/sj-extracting.c (original)
+++ trunk/src/sj-extracting.c Thu Jun 5 10:28:01 2008
@@ -28,10 +28,7 @@
#include <limits.h>
#include <glib/glist.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs-volume.h>
-#include <libgnomevfs/gnome-vfs-volume-monitor.h>
+#include <gio/gio.h>
#include <gtk/gtk.h>
#include "sj-error.h"
@@ -122,11 +119,11 @@
* extern variables 'path_pattern' and 'file_pattern'. Free the result when you
* have finished with it.
*/
-static char*
+static GFile *
build_filename (const TrackDetails *track, gboolean temp_filename, GError **error)
{
- GnomeVFSURI *uri, *new;
- gchar *realfile, *realpath, *filename, *string;
+ GFile *uri, *new;
+ gchar *realfile, *realpath, *filename, *scheme;
const gchar *extension;
size_t len_extension;
int max_realfile = INT_MAX;
@@ -134,11 +131,9 @@
g_object_get (extractor, "profile", &profile, NULL);
- uri = gnome_vfs_uri_new (base_uri);
-
realpath = filepath_parse_pattern (path_pattern, track);
- new = gnome_vfs_uri_append_path (uri, realpath);
- gnome_vfs_uri_unref (uri); uri = new;
+ new = g_file_get_child (base_uri, realpath);
+ uri = new;
g_free (realpath);
if (profile == NULL) {
@@ -153,13 +148,17 @@
max_realfile = NAME_MAX - len_extension;
#endif /* NAME_MAX */
#if defined(PATH_MAX) && PATH_MAX > 0
- if (!strcmp (gnome_vfs_uri_get_scheme (uri), "file")) {
- size_t len_path = strlen (gnome_vfs_uri_get_path (uri)) + 1;
+ scheme = g_file_get_uri_scheme (uri);
+ if (scheme && !strcmp (scheme, "file")) {
+ gchar *path = g_file_get_path (uri);
+ size_t len_path = strlen (path) + 1;
max_realfile = MIN (max_realfile, PATH_MAX - len_path - len_extension);
+ g_free (path);
}
+ g_free (scheme);
#endif /* PATH_MAX */
if (max_realfile <= 0) {
- g_set_error (error, SJ_ERROR, SJ_ERROR_INTERNAL_ERROR, g_strdup (gnome_vfs_result_to_string (GNOME_VFS_ERROR_NAME_TOO_LONG)));
+ g_set_error (error, SJ_ERROR, SJ_ERROR_INTERNAL_ERROR, g_strdup (_("Name too long")));
return NULL;
}
realfile = filepath_parse_pattern (file_pattern, track);
@@ -168,13 +167,11 @@
} else {
filename = g_strdup_printf ("%.*s.%s", max_realfile, realfile, extension);
}
- new = gnome_vfs_uri_append_file_name (uri, filename);
- gnome_vfs_uri_unref (uri); uri = new;
+ new = g_file_get_child (uri, filename);
+ g_object_unref (uri); uri = new;
g_free (filename); g_free (realfile);
- string = gnome_vfs_uri_to_string (uri, 0);
- gnome_vfs_uri_unref (uri);
- return string;
+ return uri;
}
static gboolean
@@ -254,52 +251,60 @@
* Check if a file exists, can be written to, etc.
* Return true on continue, false on skip.
*/
-static GnomeVFSFileSize
-check_file_size (const char* uri)
+static goffset
+check_file_size (GFile *uri)
{
- GnomeVFSFileInfo info;
- GnomeVFSResult res;
+ GFileInfo *gfile_info;
+ GError *error = NULL;
+ goffset size;
- res = gnome_vfs_get_file_info (uri, &info, GNOME_VFS_FILE_INFO_DEFAULT);
+ gfile_info = g_file_query_info (uri, G_FILE_ATTRIBUTE_STANDARD_SIZE, 0,
+ NULL, &error);
/* No existing file */
- if (res == GNOME_VFS_ERROR_NOT_FOUND)
+ if (!gfile_info && error->code == G_IO_ERROR_NOT_FOUND) {
+ g_error_free (error);
return 0;
+ }
/* unexpected error condition - bad news */
- if (res != GNOME_VFS_OK) {
+ if (!gfile_info) {
/* TODO: display an error dialog */
- g_warning ("Cannot get file info: %s", gnome_vfs_result_to_string (res));
+ g_warning ("Cannot get file info: %s", error->message);
+ g_error_free (error);
return -1;
}
/* A file with that name does exist. Report the size. */
- return info.size;
+ size = g_file_info_get_size (gfile_info);
+ g_object_unref (gfile_info);
+ return size;
}
-
static gboolean
-confirm_overwrite_existing_file (const char* uri, int *overwrite_mode, GnomeVFSFileSize info_size)
+confirm_overwrite_existing_file (GFile *uri, int *overwrite_mode, goffset info_size)
{
OverwriteDialogResponse ret;
GtkWidget *dialog;
GtkWidget *play_preview;
- char *filename, *size;
+ char *display_name, *filename, *size;
- filename = gnome_vfs_format_uri_for_display (uri);
- size = gnome_vfs_format_file_size_for_display (info_size);
+ display_name = g_file_get_parse_name (uri);
+ size = g_format_size_for_display (info_size);
dialog = gtk_message_dialog_new (GTK_WINDOW (main_window), GTK_DIALOG_MODAL,
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_NONE,
_("A file with the same name exists"));
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
_("A file called '%s' exists, size %s.\nDo you want to skip this track or overwrite it?"),
- filename, size);
- g_free (filename);
+ display_name, size);
+ g_free (display_name);
g_free (size);
- play_preview = egg_play_preview_new_with_uri (uri);
+ filename = g_file_get_uri (uri);
+ play_preview = egg_play_preview_new_with_uri (filename);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), play_preview);
+ g_free (filename);
gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Skip"), BUTTON_SKIP);
gtk_dialog_add_button (GTK_DIALOG (dialog), _("S_kip All"), BUTTON_SKIP_ALL);
@@ -338,28 +343,31 @@
* directory.
*/
static char*
-create_directory_for (const char* url, GError **error)
+create_directory_for (GFile *uri, GError **error)
{
- GnomeVFSResult res;
- GnomeVFSURI *uri, *parent;
+ gboolean res;
+ GFile *parent;
char *string;
+ GError *io_error = NULL;
- g_return_val_if_fail (url != NULL, NULL);
+ g_return_val_if_fail (uri != NULL, NULL);
- uri = gnome_vfs_uri_new (url);
- parent = gnome_vfs_uri_get_parent (uri);
- gnome_vfs_uri_unref (uri);
-
- res = make_directory_with_parents_for_uri (parent, 0777);
- if (res != GNOME_VFS_OK && res != GNOME_VFS_ERROR_FILE_EXISTS) {
- g_set_error (error, SJ_ERROR, SJ_ERROR_CD_PERMISSION_ERROR,
- _("Failed to create output directory: %s"),
- gnome_vfs_result_to_string (res));
- return NULL;
+ parent = g_file_get_parent (uri);
+
+ res = make_directory_with_parents (parent, &io_error);
+ if (!res) {
+ if (io_error->code != G_IO_ERROR_EXISTS) {
+ g_set_error (error, SJ_ERROR, SJ_ERROR_CD_PERMISSION_ERROR,
+ _("Failed to create output directory: %s"),
+ io_error->message);
+ g_error_free (io_error);
+ return NULL;
+ }
+ g_error_free (io_error);
}
- string = gnome_vfs_uri_to_string (parent, 0);
- gnome_vfs_uri_unref (parent);
+ string = g_file_get_uri (parent);
+ g_object_unref (parent);
return string;
}
@@ -379,22 +387,26 @@
g_assert_not_reached ();
} else {
TrackDetails *track = NULL;
- char *file_path = NULL, *temp_file_path = NULL, *directory;
+ char *directory;
+ GFile *file = NULL, *temp_file = NULL;
GError *error = NULL;
/* Pop the next track to extract */
gtk_tree_model_get (GTK_TREE_MODEL (track_store), ¤t, COLUMN_DETAILS, &track, -1);
/* Build the filename for this track */
- file_path = build_filename (track, FALSE, &error);
+ file = build_filename (track, FALSE, &error);
if (error) {
goto error;
}
- temp_file_path = build_filename (track, TRUE, &error);
+ temp_file = build_filename (track, TRUE, &error);
if (error) {
goto error;
}
- /* And create the directory it lives in */
- directory = create_directory_for (file_path, &error);
+ /* Delete the temporary file as giosink won't overwrite existing files */
+ g_file_delete (temp_file, NULL, NULL);
+
+ /* Create the directory it lives in */
+ directory = create_directory_for (file, &error);
if (error) {
goto error;
}
@@ -402,8 +414,8 @@
paths = g_list_append (paths, directory);
- GnomeVFSFileSize file_size;
- file_size = check_file_size (file_path);
+ goffset file_size;
+ file_size = check_file_size (file);
/* Skip if destination file can't be accessed (unexpected error). */
/* Skip existing files if "skip all" is selected. */
@@ -416,7 +428,7 @@
/* What if the file already exists? */
if ((file_size > MIN_FILE_SIZE) &&
(*overwrite_mode != OVERWRITE_ALL) &&
- (confirm_overwrite_existing_file (file_path, overwrite_mode, file_size) == FALSE)) {
+ (confirm_overwrite_existing_file (file, overwrite_mode, file_size) == FALSE)) {
on_completion_cb (NULL, overwrite_mode);
return;
}
@@ -438,7 +450,7 @@
gtk_tree_path_free(path);
/* Now actually do the extraction */
- sj_extractor_extract_track (extractor, track, temp_file_path, &error);
+ sj_extractor_extract_track (extractor, track, temp_file, &error);
if (error) {
goto error;
}
@@ -447,8 +459,8 @@
on_error_cb (NULL, error, NULL);
g_error_free (error);
local_cleanup:
- g_free (file_path);
- g_free (temp_file_path);
+ g_object_unref (file);
+ g_object_unref (temp_file);
}
}
@@ -604,7 +616,8 @@
on_completion_cb (SjExtractor *extractor, gpointer data)
{
TrackDetails *track = NULL;
- char *temp_file_path, *new_file_path;
+ GFile *temp_file, *new_file;
+ GError *error = NULL;
/* Only manipulate the track state if we have an album, as we might be here if
the disk was ejected mid-rip. */
@@ -620,14 +633,17 @@
- temp_file_path = build_filename (track, TRUE, NULL);
- new_file_path = build_filename (track, FALSE, NULL);
- gnome_vfs_move (temp_file_path, new_file_path, TRUE);
-
- g_free (temp_file_path);
- g_free (new_file_path);
+ temp_file = build_filename (track, TRUE, NULL);
+ new_file = build_filename (track, FALSE, NULL);
+ g_file_move (temp_file, new_file, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, &error);
- if (find_next ()) {
+ g_object_unref (temp_file);
+ g_object_unref (new_file);
+
+ if (error) {
+ on_error_cb (NULL, error, NULL);
+ g_error_free (error);
+ } else if (find_next ()) {
/* Increment the duration */
current_duration += track->duration;
/* And go and do it all again */
@@ -676,18 +692,24 @@
on_progress_cancel_clicked (GtkWidget *button, gpointer user_data)
{
TrackDetails *track = NULL;
- char *file_path;
+ GFile *file;
+ GError *error = NULL;
sj_extractor_cancel_extract (extractor);
gtk_tree_model_get (GTK_TREE_MODEL (track_store), ¤t,
COLUMN_DETAILS, &track, -1);
- file_path = build_filename (track, TRUE, NULL);
- gnome_vfs_unlink (file_path);
- g_free (file_path);
+ file = build_filename (track, TRUE, NULL);
+ g_file_delete (file, NULL, &error);
+ g_object_unref (file);
- cleanup ();
+ if (error) {
+ on_error_cb (NULL, error, NULL);
+ g_error_free (error);
+ } else {
+ cleanup ();
+ }
}
/**
@@ -873,22 +895,18 @@
{
/* p is the pattern iterator, i is a general purpose iterator */
const char *p;
- char *tmp, *str, *base_path, *filesystem_type = NULL;
+ char *tmp, *str, *filesystem_type = NULL;
GString *s;
- GnomeVFSVolumeMonitor *monitor;
- GnomeVFSVolume *volume;
+ GFileInfo *fs_info;
if (pattern == NULL || pattern[0] == 0)
return g_strdup (" ");
-
- if ((base_path = gnome_vfs_get_local_path_from_uri (base_uri))) {
- monitor = gnome_vfs_get_volume_monitor ();
-
- if ((volume = gnome_vfs_volume_monitor_get_volume_for_path (monitor, base_path))) {
- filesystem_type = gnome_vfs_volume_get_filesystem_type (volume);
- gnome_vfs_volume_unref (volume);
- }
- g_free (base_path);
+
+ fs_info = g_file_query_filesystem_info (base_uri, G_FILE_ATTRIBUTE_FILESYSTEM_TYPE,
+ NULL, NULL);
+ if (fs_info) {
+ filesystem_type = g_file_info_get_attribute_as_string (fs_info, G_FILE_ATTRIBUTE_FILESYSTEM_TYPE);
+ g_object_unref (fs_info);
}
s = g_string_new (NULL);
Modified: trunk/src/sj-main.c
==============================================================================
--- trunk/src/sj-main.c (original)
+++ trunk/src/sj-main.c Thu Jun 5 10:28:01 2008
@@ -28,6 +28,7 @@
#include <glib/gi18n.h>
#include <gdk/gdkkeysyms.h>
+#include <gio/gio.h>
#include <gtk/gtk.h>
#include <glade/glade.h>
#include <gconf/gconf-client.h>
@@ -36,7 +37,6 @@
#include <libgnome/gnome-url.h>
#include <libgnomeui/gnome-ui-init.h>
#include <libgnomeui/gnome-authentication-manager.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
#include <profiles/gnome-media-profiles.h>
#include <gst/gst.h>
@@ -89,7 +89,7 @@
GtkWidget *current_message_area;
const char *path_pattern, *file_pattern;
-char *base_uri;
+GFile *base_uri;
NautilusBurnDrive *drive = NULL;
gboolean strip_chars;
gboolean eject_finished;
@@ -685,11 +685,13 @@
static void baseuri_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data)
{
g_assert (strcmp (entry->key, GCONF_BASEURI) == 0);
- g_free (base_uri);
+ if (base_uri) {
+ g_object_unref (base_uri);
+ }
if (entry->value == NULL) {
base_uri = sj_get_default_music_directory ();
} else {
- base_uri = g_strdup (gconf_value_get_string (entry->value));
+ base_uri = g_file_new_for_uri (gconf_value_get_string (entry->value));
}
/* TODO: sanity check the URI somewhat */
}
@@ -1473,12 +1475,15 @@
if (s != NULL) {
g_free (s);
} else {
+ GFile *gfile;
char *uri;
s = gconf_client_get_string (gconf_client, GCONF_BASEPATH, NULL);
if (s == NULL)
return;
- uri = gnome_vfs_get_uri_from_local_path (s);
+ gfile = g_file_new_for_path (s);
+ uri = g_file_get_uri (gfile);
g_free (s);
+ g_object_unref (gfile);
gconf_client_set_string (gconf_client, GCONF_BASEURI, uri, NULL);
g_free (uri);
}
@@ -1839,7 +1844,7 @@
nautilus_burn_shutdown ();
- g_free (base_uri);
+ g_object_unref (base_uri);
g_object_unref (metadata);
g_object_unref (extractor);
g_object_unref (gconf_client);
Modified: trunk/src/sj-play.c
==============================================================================
--- trunk/src/sj-play.c (original)
+++ trunk/src/sj-play.c Thu Jun 5 10:28:01 2008
@@ -565,11 +565,7 @@
gint track;
GtkTreeSelection *selection = gtk_tree_view_get_selection (treeview);
- if (is_paused ())
- gtk_list_store_set (track_store, ¤t_iter,
- COLUMN_STATE, STATE_IDLE, -1);
-
- if (is_playing ())
+ if (is_playing () || is_paused ())
return;
if (gtk_tree_selection_get_selected (selection, NULL, ¤t_iter)) {
Modified: trunk/src/sj-prefs.c
==============================================================================
--- trunk/src/sj-prefs.c (original)
+++ trunk/src/sj-prefs.c Thu Jun 5 10:28:01 2008
@@ -196,11 +196,14 @@
base_uri = gconf_value_get_string (entry->value);
if (base_uri == NULL || base_uri[0] == '\0') {
- char *dir;
+ GFile *dir;
+ char *dir_uri;
dir = sj_get_default_music_directory ();
- gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (basepath_fcb), dir);
- g_free (dir);
+ dir_uri = g_file_get_uri (dir);
+ gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (basepath_fcb), dir_uri);
+ g_free (dir_uri);
+ g_object_unref (dir);
} else {
g_return_if_fail (entry->value->type == GCONF_VALUE_STRING);
current_uri = gtk_file_chooser_get_current_folder_uri (GTK_FILE_CHOOSER (basepath_fcb));
Modified: trunk/src/sound-juicer.h
==============================================================================
--- trunk/src/sound-juicer.h (original)
+++ trunk/src/sound-juicer.h Thu Jun 5 10:28:01 2008
@@ -31,6 +31,7 @@
#include <nautilus-burn-drive.h>
#include <gconf/gconf-client.h>
#include <glade/glade-xml.h>
+#include <gio/gio.h>
#include <gtk/gtkwidget.h>
#include <gtk/gtk.h>
#include <gtk/gtkliststore.h>
@@ -102,7 +103,7 @@
/**
* The root path to write files too
*/
-extern char *base_uri;
+extern GFile *base_uri;
/**
* The pattern to expand when naming folders
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]