[gnome-disk-utility/udisks2-port] Unify how file chooser is configured
- From: David Zeuthen <davidz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-disk-utility/udisks2-port] Unify how file chooser is configured
- Date: Fri, 2 Dec 2011 19:57:57 +0000 (UTC)
commit dcd7512bfd0e85412c55f3232dfb220fcd4432ac
Author: David Zeuthen <davidz redhat com>
Date: Fri Dec 2 14:57:38 2011 -0500
Unify how file chooser is configured
Signed-off-by: David Zeuthen <davidz redhat com>
src/palimpsest/gducreatediskimagedialog.c | 8 +-------
src/palimpsest/gduutils.c | 24 ++++++++++++++++++++++++
src/palimpsest/gduutils.h | 3 +++
src/palimpsest/gduwindow.c | 21 +--------------------
4 files changed, 29 insertions(+), 27 deletions(-)
---
diff --git a/src/palimpsest/gducreatediskimagedialog.c b/src/palimpsest/gducreatediskimagedialog.c
index b1d5cf4..b0e2295 100644
--- a/src/palimpsest/gducreatediskimagedialog.c
+++ b/src/palimpsest/gducreatediskimagedialog.c
@@ -130,7 +130,6 @@ create_disk_image_populate (CreateDiskImageData *data)
guint n;
GTimeZone *tz;
GDateTime *now;
- const gchar *folder;
device_name = udisks_block_dup_preferred_device (data->block);
if (g_str_has_prefix (device_name, "/dev/"))
@@ -159,12 +158,7 @@ create_disk_image_populate (CreateDiskImageData *data)
g_time_zone_unref (tz);
g_free (now_string);
- /* Defaults to the "Documents" folder */
- folder = g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS);
- if (folder != NULL)
- {
- gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (data->destination_name_fcbutton), folder);
- }
+ gdu_utils_configure_file_chooser_for_disk_images (GTK_FILE_CHOOSER (data->destination_name_fcbutton));
}
/* ---------------------------------------------------------------------------------------------------- */
diff --git a/src/palimpsest/gduutils.c b/src/palimpsest/gduutils.c
index 622371e..c27e9f0 100644
--- a/src/palimpsest/gduutils.c
+++ b/src/palimpsest/gduutils.c
@@ -64,3 +64,27 @@ gdu_utils_has_configuration (UDisksBlock *block,
*out_has_passphrase = has_passphrase;
return ret;
}
+
+void
+gdu_utils_configure_file_chooser_for_disk_images (GtkFileChooser *file_chooser)
+{
+ GtkFileFilter *filter;
+ const gchar *folder;
+
+ /* Default to the "Documents" folder since that's where we save such images */
+ folder = g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS);
+ if (folder != NULL)
+ gtk_file_chooser_set_current_folder (file_chooser, folder);
+
+ /* TODO: define proper mime-types */
+ filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter, _("All Files"));
+ gtk_file_filter_add_pattern (filter, "*");
+ gtk_file_chooser_add_filter (file_chooser, filter); /* adopts filter */
+ filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter, _("Disk Images (*.img, *.iso)"));
+ gtk_file_filter_add_pattern (filter, "*.img");
+ gtk_file_filter_add_pattern (filter, "*.iso");
+ gtk_file_chooser_add_filter (file_chooser, filter); /* adopts filter */
+ gtk_file_chooser_set_filter (file_chooser, filter);
+}
diff --git a/src/palimpsest/gduutils.h b/src/palimpsest/gduutils.h
index f44435e..4f1c9c1 100644
--- a/src/palimpsest/gduutils.h
+++ b/src/palimpsest/gduutils.h
@@ -32,6 +32,9 @@ gboolean gdu_utils_has_configuration (UDisksBlock *block,
const gchar *type,
gboolean *out_has_passphrase);
+void gdu_utils_configure_file_chooser_for_disk_images (GtkFileChooser *file_chooser);
+
+
G_END_DECLS
#endif /* __GDU_UTILS_H__ */
diff --git a/src/palimpsest/gduwindow.c b/src/palimpsest/gduwindow.c
index bfb9e19..be06576 100644
--- a/src/palimpsest/gduwindow.c
+++ b/src/palimpsest/gduwindow.c
@@ -603,13 +603,11 @@ on_device_tree_attach_disk_image_button_clicked (GtkToolButton *button,
{
GduWindow *window = GDU_WINDOW (user_data);
GtkWidget *dialog;
- GtkFileFilter *filter;
gchar *filename;
gint fd;
GUnixFDList *fd_list;
GVariantBuilder options_builder;
GtkWidget *ro_checkbutton;
- const gchar *folder;
filename = NULL;
fd = -1;
@@ -620,24 +618,7 @@ on_device_tree_attach_disk_image_button_clicked (GtkToolButton *button,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
_("_Attach"), GTK_RESPONSE_ACCEPT,
NULL);
- gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), g_get_home_dir ());
-
- /* TODO: define proper mime-types */
- filter = gtk_file_filter_new ();
- gtk_file_filter_set_name (filter, _("All Files"));
- gtk_file_filter_add_pattern (filter, "*");
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter); /* adopts filter */
- filter = gtk_file_filter_new ();
- gtk_file_filter_set_name (filter, _("Disk Images (*.img, *.iso)"));
- gtk_file_filter_add_pattern (filter, "*.img");
- gtk_file_filter_add_pattern (filter, "*.iso");
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter); /* adopts filter */
- gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), filter);
-
- /* Default to the "Documents" folder since that's where we save such images */
- folder = g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS);
- if (folder != NULL)
- gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), folder);
+ gdu_utils_configure_file_chooser_for_disk_images (GTK_FILE_CHOOSER (dialog));
/* Can't support non-local files because uid gets EPERM when doing fstat(2)
* an FD from the FUSE mount... it would be nice to support this, though
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]