Re: [Patch] fix bug #8487: read-only status not shown in title bar
joe joe <[email protected]> Sun, 7 Apr 2013 21:06:28 +0800
| Newsgroups | gmane.editors.abiword.devel |
|---|---|
| Message-ID | <CAKBgNKqTT7aFjmDrmY-T9X5aPLBDHR2YL7XUgTMgmM2a6vdfmg@mail.gmail.com> |
http://bugzilla.abisource.com/show_bug.cgi?id=8487 ------- Comment #14 From joe 2013-04-07 14:48:48 [reply] ------- (In reply to comment #13) > The idea looks good, but if you look closely to ut_go_file.cpp, ideally the > case #elif ! defined (G_OS_WIN32) should just be a #else and file_stat should > just be a GStatBuf as per the documentation. and it would be equivalent. > Hi Hub, If we would like to merge the code together, should like the Patch in the attachment. Because the following code can't merge together since: 1. the Macro definition of "S_IRUSR" && "S_IREAD" are not same in different OS. 2. the file attributions are not the same. in windows, there are not Group Permissions & Other Permissions Joe On Sat, Apr 6, 2013 at 11:43 PM, joe joe <[email protected]> wrote: > 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, 2.4 KB)
Index: ut_go_file.cpp
===================================================================
--- ut_go_file.cpp (revision 32831)
+++ ut_go_file.cpp (working copy)
@@ -1454,29 +1454,36 @@
}
gnome_vfs_file_info_unref (file_info);
-#elif ! defined (G_OS_WIN32)
- struct stat file_stat;
+#else
+ 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);
+ #if ! defined (G_OS_WIN32)
+ /* Owner Permissions */
+ file_permissions->owner_read = ((file_stat.st_mode & S_IRUSR) != 0);
+ file_permissions->owner_write = ((file_stat.st_mode & S_IWUSR) != 0);
+ file_permissions->owner_execute = ((file_stat.st_mode & S_IXUSR) != 0);
- /* Owner Permissions */
- file_permissions->owner_read = ((file_stat.st_mode & S_IRUSR) != 0);
- file_permissions->owner_write = ((file_stat.st_mode & S_IWUSR) != 0);
- file_permissions->owner_execute = ((file_stat.st_mode & S_IXUSR) != 0);
+ /* Group Permissions */
+ file_permissions->group_read = ((file_stat.st_mode & S_IRGRP) != 0);
+ file_permissions->group_write = ((file_stat.st_mode & S_IWGRP) != 0);
+ file_permissions->group_execute = ((file_stat.st_mode & S_IXGRP) != 0);
- /* Group Permissions */
- file_permissions->group_read = ((file_stat.st_mode & S_IRGRP) != 0);
- file_permissions->group_write = ((file_stat.st_mode & S_IWGRP) != 0);
- file_permissions->group_execute = ((file_stat.st_mode & S_IXGRP) != 0);
-
- /* Others Permissions */
- file_permissions->others_read = ((file_stat.st_mode & S_IROTH) != 0);
- file_permissions->others_write = ((file_stat.st_mode & S_IWOTH) != 0);
- file_permissions->others_execute = ((file_stat.st_mode & S_IXOTH) != 0);
+ /* Others Permissions */
+ file_permissions->others_read = ((file_stat.st_mode & S_IROTH) != 0);
+ file_permissions->others_write = ((file_stat.st_mode & S_IWOTH) != 0);
+ file_permissions->others_execute = ((file_stat.st_mode & S_IXOTH) != 0);
+ #else
+ //fix bug #8487: read-only status not shown in title bar
+ /* 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
}
#endif
return file_permissions;