[gnac/devel] Code refactoring
- From: BenoÃt Dupasquier <bdupasqu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnac/devel] Code refactoring
- Date: Sat, 10 Dec 2011 15:22:49 +0000 (UTC)
commit 82f84a72a39ad8e7ef821ce3e05b98b5fe046d77
Author: BenoÃt Dupasquier <bdupasqu src gnome org>
Date: Sat Dec 10 14:23:26 2011 +0000
Code refactoring
src/gnac-main.c | 8 +++-----
src/gnac-utils.c | 17 +++++++++++++----
src/gnac-utils.h | 6 +++++-
3 files changed, 21 insertions(+), 10 deletions(-)
---
diff --git a/src/gnac-main.c b/src/gnac-main.c
index 297e53b..2c6228e 100644
--- a/src/gnac-main.c
+++ b/src/gnac-main.c
@@ -428,15 +428,14 @@ gnac_on_converter_overwrite_cb(LibgnacConverter *converter,
if (remember_overwrite) return overwrite;
GError *error = NULL;
- GFileInfo *info = g_file_query_info(file,
- G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
- G_FILE_QUERY_INFO_NONE, NULL, &error);
+ gchar *display_name = gnac_utils_get_display_name_from_file(file, &error);
GtkWidget *dialog = gtk_message_dialog_new(
GTK_WINDOW(gnac_ui_get_widget("main_window")),
GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_YES_NO,
_("File %s already exists...\nOverwrite?"),
- g_file_info_get_display_name(info));
+ display_name);
+ g_free(display_name);
gtk_window_set_title(GTK_WINDOW(dialog), PACKAGE_NAME);
GtkWidget *checkbox = gtk_check_button_new_with_label(
@@ -453,7 +452,6 @@ gnac_on_converter_overwrite_cb(LibgnacConverter *converter,
remember_overwrite = gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(checkbox));
- g_object_unref(info);
gtk_widget_destroy(dialog);
overwrite = (response == GTK_RESPONSE_YES);
diff --git a/src/gnac-utils.c b/src/gnac-utils.c
index d3bdabb..ced7ca0 100644
--- a/src/gnac-utils.c
+++ b/src/gnac-utils.c
@@ -38,13 +38,12 @@ static guint64 total_samples = 0;
gchar *
-gnac_utils_get_display_name(const gchar *uri,
- GError **error)
+gnac_utils_get_display_name_from_file(GFile *file,
+ GError **error)
{
g_return_val_if_fail(!error || !*error, NULL);
GError *err = NULL;
- GFile *file = g_file_new_for_uri(uri);
GFileInfo *info = g_file_query_info(file,
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
G_FILE_QUERY_INFO_NONE, NULL, &err);
@@ -57,13 +56,23 @@ gnac_utils_get_display_name(const gchar *uri,
gchar *display_name = g_strdup(g_file_info_get_display_name(info));
g_object_unref(info);
- g_object_unref(file);
return display_name;
}
gchar *
+gnac_utils_get_display_name(const gchar *uri,
+ GError **error)
+{
+ GFile *file = g_file_new_for_uri(uri);
+ gchar *display_name = gnac_utils_get_display_name_from_file(file, error);
+ g_object_unref(file);
+ return display_name;
+}
+
+
+gchar *
gnac_utils_format_duration_for_display(guint64 duration)
{
gint minutes = (gint) ((duration / 60) % 60);
diff --git a/src/gnac-utils.h b/src/gnac-utils.h
index bf5f9aa..be4f463 100644
--- a/src/gnac-utils.h
+++ b/src/gnac-utils.h
@@ -31,7 +31,11 @@
G_BEGIN_DECLS
gchar *
-gnac_utils_get_display_name(const gchar *uri,
+gnac_utils_get_display_name_from_file(GFile *uri,
+ GError **error);
+
+gchar *
+gnac_utils_get_display_name(const gchar *uri,
GError **error);
gchar *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]