[eog] Make newly saved images user writable



commit 00075ab25d5bd3656a2f5f89773bd56e091d5b47
Author: Javier Sánchez <jsanchez deskblue com>
Date:   Sat Oct 23 23:22:19 2010 +0200

    Make newly saved images user writable
    
    Doesn't occur for existing files only when saving creates a new file.
    Fixes bug #589921.

 src/eog-jobs.c |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/src/eog-jobs.c b/src/eog-jobs.c
index 22e4b33..5cf8127 100644
--- a/src/eog-jobs.c
+++ b/src/eog-jobs.c
@@ -707,6 +707,9 @@ eog_job_save_as_run (EogJob *ejob)
 	EogJobSaveAs *saveas_job;
 	GList *it;
 	guint n_images;
+	guint file_permissions = 00000;
+	guint permissions_mask = 00600;
+	GFileInfo *info;
 
 	g_return_if_fail (EOG_IS_JOB_SAVE_AS (ejob));
 
@@ -778,6 +781,27 @@ eog_job_save_as_run (EogJob *ejob)
 						     dest_info,
 						     &ejob->error);
 
+		/* get file permissions */
+		info = g_file_query_info (saveas_job->file,
+					  G_FILE_ATTRIBUTE_UNIX_MODE,
+					  G_FILE_QUERY_INFO_NONE,
+					  NULL,
+					  NULL);
+
+		file_permissions = g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_MODE);
+
+		/* apply permission mask to file permissions */
+		file_permissions |= permissions_mask;
+
+		g_file_set_attribute_uint32 (saveas_job->file,
+					     G_FILE_ATTRIBUTE_UNIX_MODE,
+					     file_permissions,
+					     G_FILE_QUERY_INFO_NONE,
+					     NULL,
+					     NULL);
+
+		g_object_unref (info);
+
 		if (src_info)
 			g_object_unref (src_info);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]