aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanielle Madeley <danielle.madeley@collabora.co.uk>2011-03-07 08:21:43 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-03-07 16:54:05 +0800
commitb6e030fc577477fb6bf87d8833f2404ab8c6fc48 (patch)
treee03c46d48b1be8be53b669cb031011a24eed2339
parent2eb9099ce3e60b8c60039b7947e249c294b02167 (diff)
downloadgsoc2013-empathy-b6e030fc577477fb6bf87d8833f2404ab8c6fc48.tar
gsoc2013-empathy-b6e030fc577477fb6bf87d8833f2404ab8c6fc48.tar.gz
gsoc2013-empathy-b6e030fc577477fb6bf87d8833f2404ab8c6fc48.tar.bz2
gsoc2013-empathy-b6e030fc577477fb6bf87d8833f2404ab8c6fc48.tar.lz
gsoc2013-empathy-b6e030fc577477fb6bf87d8833f2404ab8c6fc48.tar.xz
gsoc2013-empathy-b6e030fc577477fb6bf87d8833f2404ab8c6fc48.tar.zst
gsoc2013-empathy-b6e030fc577477fb6bf87d8833f2404ab8c6fc48.zip
Warn the user if she has insufficient disk space to receive a file
Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=644062
-rw-r--r--libempathy-gtk/empathy-ui-utils.c61
1 files changed, 58 insertions, 3 deletions
diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c
index 4d9f4d4c7..90bafb1e4 100644
--- a/libempathy-gtk/empathy-ui-utils.c
+++ b/libempathy-gtk/empathy-ui-utils.c
@@ -1839,11 +1839,66 @@ file_manager_receive_file_response_cb (GtkDialog *dialog,
GFile *file;
if (response == GTK_RESPONSE_OK) {
- factory = empathy_ft_factory_dup_singleton ();
+ GFile *parent;
+ GFileInfo *info;
+ guint64 free_space, file_size;
+ GError *error = NULL;
+
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
+ parent = g_file_get_parent (file);
+ info = g_file_query_filesystem_info (parent,
+ G_FILE_ATTRIBUTE_FILESYSTEM_FREE,
+ NULL, &error);
+
+ g_object_unref (parent);
+
+ if (error != NULL) {
+ g_warning ("Error: %s", error->message);
+
+ g_object_unref (file);
+ return;
+ }
+
+ free_space = g_file_info_get_attribute_uint64 (info,
+ G_FILE_ATTRIBUTE_FILESYSTEM_FREE);
+ file_size = empathy_ft_handler_get_total_bytes (handler);
+
+ g_object_unref (info);
+
+ if (file_size > free_space) {
+ GtkWidget *message = gtk_message_dialog_new (
+ GTK_WINDOW (dialog),
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ _("Insufficient free space to save file"));
+ char *file_size_str, *free_space_str;
+
+ file_size_str = g_format_size_for_display (file_size);
+ free_space_str = g_format_size_for_display (free_space);
+
+ gtk_message_dialog_format_secondary_text (
+ GTK_MESSAGE_DIALOG (message),
+ _("%s of free space are required to save this "
+ "file, but only %s is available. Please "
+ "choose another location."),
+ file_size_str, free_space_str);
+
+ gtk_dialog_run (GTK_DIALOG (message));
+
+ g_free (file_size_str);
+ g_free (free_space_str);
+ gtk_widget_destroy (message);
+
+ g_object_unref (file);
+
+ return;
+ }
+
+ factory = empathy_ft_factory_dup_singleton ();
- empathy_ft_factory_set_destination_for_incoming_handler
- (factory, handler, file);
+ empathy_ft_factory_set_destination_for_incoming_handler (
+ factory, handler, file);
g_object_unref (factory);
g_object_unref (file);