[Patch] fix bug #8487: read-only status not shown in title bar

joe joe <[email protected]> Sat, 6 Apr 2013 23:43:52 +0800
Newsgroups gmane.editors.abiword.devel
Message-ID <CAKBgNKrpDvstER4VCX8WQPy-SOVr4fzgxE3VDMr6-ev_YXfFnw@mail.gmail.com>
Hi,

I have fixed bug #8487: read-only status not shown in title bar
http://bugzilla.abisource.com/show_bug.cgi?id=8487

Patch and fix screenshot are attached on that bug. Can someone help me
to have a review? thanks

Investigation:
  Only Windows don't show read-only status  in title bar. the reason
is that in Window, there is not function to read user-permission.

Solution:
  I add some code to read user-permission and fix it.

Index: af/util/xp/ut_go_file.cpp
===================================================================
--- af/util/xp/ut_go_file.cpp	(revision 32831)
+++ af/util/xp/ut_go_file.cpp	(working copy)
@@ -1478,6 +1478,19 @@
 		file_permissions->others_write   = ((file_stat.st_mode & S_IWOTH) != 0);
 		file_permissions->others_execute = ((file_stat.st_mode & S_IXOTH) != 0);
 	}
+#elif defined (G_OS_WIN32)
+	//fix bug #8487: read-only status not shown in title bar
+	GStatBuf file_stat;
+	char *filename = UT_go_filename_from_uri (uri);
+	int result = filename ? g_stat (filename, &file_stat) : -1;
+	g_free (filename);
+	if (result == 0) {
+		file_permissions = g_new0 (UT_GOFilePermissions, 1);
+		/* Owner  Permissions */
+		file_permissions->owner_read    = ((file_stat.st_mode & S_IREAD) != 0);
+		file_permissions->owner_write   = ((file_stat.st_mode & S_IWRITE) != 0);
+		file_permissions->owner_execute = ((file_stat.st_mode & S_IEXEC) != 0);
+	}
 #endif
 	return file_permissions;
 }




Joe
[bug 8487]fix readonly status not shown in title bar.patch (application/octet-stream, 992 B)
Index: af/util/xp/ut_go_file.cpp
===================================================================
--- af/util/xp/ut_go_file.cpp	(revision 32831)
+++ af/util/xp/ut_go_file.cpp	(working copy)
@@ -1478,6 +1478,19 @@
 		file_permissions->others_write   = ((file_stat.st_mode & S_IWOTH) != 0);
 		file_permissions->others_execute = ((file_stat.st_mode & S_IXOTH) != 0);
 	}
+#elif defined (G_OS_WIN32)
+	//fix bug #8487: read-only status not shown in title bar
+	GStatBuf file_stat;
+	char *filename = UT_go_filename_from_uri (uri);
+	int result = filename ? g_stat (filename, &file_stat) : -1;
+	g_free (filename);
+	if (result == 0) {
+		file_permissions = g_new0 (UT_GOFilePermissions, 1);
+		/* Owner  Permissions */
+		file_permissions->owner_read    = ((file_stat.st_mode & S_IREAD) != 0);
+		file_permissions->owner_write   = ((file_stat.st_mode & S_IWRITE) != 0);
+		file_permissions->owner_execute = ((file_stat.st_mode & S_IEXEC) != 0);
+	}
 #endif
 	return file_permissions;
 }