[gnac/devel] Fixed a bug
- From: BenoÃt Dupasquier <bdupasqu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnac/devel] Fixed a bug
- Date: Thu, 29 Dec 2011 10:57:01 +0000 (UTC)
commit 445557b4be5fc91a7c34d5b7d587056b15a0a684
Author: BenoÃt Dupasquier <bdupasqu src gnome org>
Date: Wed Dec 14 11:49:07 2011 +0000
Fixed a bug
libgnac/libgnac-converter.c | 4 +--
libgnac/libgnac-error.c | 24 ++++++++---------
src/gnac-main.c | 59 +++++++++++++++++++++++-------------------
3 files changed, 44 insertions(+), 43 deletions(-)
---
diff --git a/libgnac/libgnac-converter.c b/libgnac/libgnac-converter.c
index e68dca6..101e3af 100644
--- a/libgnac/libgnac-converter.c
+++ b/libgnac/libgnac-converter.c
@@ -825,9 +825,7 @@ libgnac_converter_error_sink(LibgnacMediaItem *item,
g_clear_error(&err);
- if (!libgnac_error_handle_dest_file_already_exists(item, message, uri)) {
- g_signal_emit(item->parent, signals[ERROR], 0, uri,
- _("Unable to access destination file"), error);
+ if (libgnac_error_handle_dest_file_already_exists(item, message, uri)) {
return FALSE;
}
diff --git a/libgnac/libgnac-error.c b/libgnac/libgnac-error.c
index 6adf328..554f024 100644
--- a/libgnac/libgnac-error.c
+++ b/libgnac/libgnac-error.c
@@ -84,16 +84,14 @@ libgnac_error_handle_overwrite(LibgnacMediaItem *item,
static void
libgnac_error_emit_dest_file_exists_error(LibgnacMediaItem *item,
+ const gchar *msg,
const gchar *uri)
{
GError *err = NULL;
- gchar *msg = g_strdup_printf(_("Destination file %s already exists"), uri);
- libgnac_debug("%s", msg);
- g_set_error_literal(&err, LIBGNAC_ERROR,
- LIBGNAC_ERROR_FILE_EXISTS, msg);
+ libgnac_debug(msg);
+ g_set_error_literal(&err, LIBGNAC_ERROR, LIBGNAC_ERROR_FILE_EXISTS, msg);
g_signal_emit(item->parent, signals[ERROR], 0, uri, msg, err);
g_clear_error(&err);
- g_free(msg);
}
@@ -105,28 +103,28 @@ libgnac_error_handle_dest_file_already_exists(LibgnacMediaItem *item,
gchar *dst_path = g_file_get_path(item->destination);
if (!g_file_test(dst_path, G_FILE_TEST_EXISTS)) {
g_free(dst_path);
- return FALSE;
+ return TRUE;
}
gchar *src_path = g_file_get_path(item->source);
- if (g_str_equal(dst_path, src_path)) {
+ if (g_strcmp0(dst_path, src_path) == 0) {
const gchar *msg = _("Source and destination files are identical");
- libgnac_debug(msg);
- g_signal_emit(item->parent, signals[ERROR], 0, uri, msg, NULL);
+ libgnac_error_emit_dest_file_exists_error(item, msg, uri);
g_free(dst_path);
g_free(src_path);
- return FALSE;
+ return TRUE;
}
g_free(src_path);
if (!libgnac_error_handle_overwrite(item, uri)) {
- libgnac_error_emit_dest_file_exists_error(item, uri);
+ const gchar *msg = _("Destination file already exists");
+ libgnac_error_emit_dest_file_exists_error(item, msg, uri);
g_free(dst_path);
- return FALSE;
+ return TRUE;
}
g_free(dst_path);
- return TRUE;
+ return FALSE;
}
diff --git a/src/gnac-main.c b/src/gnac-main.c
index 7287ecd..fb2d210 100644
--- a/src/gnac-main.c
+++ b/src/gnac-main.c
@@ -607,6 +607,33 @@ gnac_on_ui_pause_cb(GtkWidget *widget,
}
+static void
+gnac_start_conversion(GError **error)
+{
+ gchar *folder_hierarchy = gnac_settings_get_string(
+ GNAC_KEY_FOLDER_HIERARCHY_PATTERN);
+ gchar *folder_path = gnac_settings_get_string(
+ GNAC_KEY_DESTINATION_DIRECTORY);
+ gchar *rename_pattern = gnac_settings_get_string(
+ GNAC_KEY_RENAME_PATTERN_PATTERN);
+ g_object_set(G_OBJECT(converter),
+ "extension", gnac_profiles_get_extension(),
+ "folder-hierarchy", folder_hierarchy,
+ "folder-path", folder_path,
+ "folder-type", gnac_settings_get_int(GNAC_KEY_FOLDER_TYPE),
+ "audio-description", gnac_profiles_get_pipeline(),
+ "rename-pattern", rename_pattern,
+ "strip-special", gnac_settings_get_boolean(GNAC_KEY_STRIP_SPECIAL),
+ NULL);
+
+ libgnac_converter_start(converter, error);
+
+ g_free(folder_path);
+ g_free(folder_hierarchy);
+ g_free(rename_pattern);
+}
+
+
void
gnac_on_ui_convert_cb(GtkWidget *widget,
gpointer data)
@@ -617,42 +644,20 @@ gnac_on_ui_convert_cb(GtkWidget *widget,
case GNAC_AUDIO_CONVERT_STATE:
case GNAC_AUDIO_PAUSED_STATE:
libgnac_converter_stop(converter, &error);
- break;
-
- case GNAC_AUDIO_READY_STATE: {
- gchar *folder_hierarchy = gnac_settings_get_string(
- GNAC_KEY_FOLDER_HIERARCHY_PATTERN);
- gchar *folder_path = gnac_settings_get_string(
- GNAC_KEY_DESTINATION_DIRECTORY);
- gchar *rename_pattern = gnac_settings_get_string(
- GNAC_KEY_RENAME_PATTERN_PATTERN);
- g_object_set(G_OBJECT(converter),
- "extension", gnac_profiles_get_extension(),
- "folder-hierarchy", folder_hierarchy,
- "folder-path", folder_path,
- "folder-type", gnac_settings_get_int(GNAC_KEY_FOLDER_TYPE),
- "audio-description", gnac_profiles_get_pipeline(),
- "rename-pattern", rename_pattern,
- "strip-special", gnac_settings_get_boolean(GNAC_KEY_STRIP_SPECIAL),
- NULL);
-
- libgnac_converter_start(converter, &error);
-
- g_free(folder_path);
- g_free(folder_hierarchy);
- g_free(rename_pattern);
+ break;
+ case GNAC_AUDIO_READY_STATE:
+ gnac_start_conversion(&error);
break;
- }
case GNAC_AUDIO_FILE_ACTION_STATE:
continue_files_action = FALSE;
- break;
+ break;
default:
// uha we have a problem
g_return_if_reached();
- break;
+ break;
}
if (error) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]