[nautilus/wip/antoniof/modernize-properties-dialog: 8/19] properties-window: move permissions related code snippets around




commit 14dd85834630967b2c27ec58f2c6aa304f3791f6
Author: Peter Eisenmann <p3732 getgoogleoff me>
Date:   Fri Dec 31 05:19:26 2021 +0100

    properties-window: move permissions related code snippets around
    
    This commit moves around some code snippets, partly to have
    functions declared before their (future) usage and partly in
    preparation for further changes.

 src/nautilus-properties-window.c | 179 +++++++++++++++++++--------------------
 1 file changed, 89 insertions(+), 90 deletions(-)
---
diff --git a/src/nautilus-properties-window.c b/src/nautilus-properties-window.c
index dd2c2652e..7202789b0 100644
--- a/src/nautilus-properties-window.c
+++ b/src/nautilus-properties-window.c
@@ -230,6 +230,40 @@ typedef enum
     FILES_AND_FOLDERS   = FILES_ONLY | FOLDERS_ONLY,
 } FilterType;
 
+enum
+{
+    UNIX_PERM_SUID = S_ISUID,
+    UNIX_PERM_SGID = S_ISGID,
+    UNIX_PERM_STICKY = 01000,           /* S_ISVTX not defined on all systems */
+    UNIX_PERM_USER_READ = S_IRUSR,
+    UNIX_PERM_USER_WRITE = S_IWUSR,
+    UNIX_PERM_USER_EXEC = S_IXUSR,
+    UNIX_PERM_USER_ALL = S_IRUSR | S_IWUSR | S_IXUSR,
+    UNIX_PERM_GROUP_READ = S_IRGRP,
+    UNIX_PERM_GROUP_WRITE = S_IWGRP,
+    UNIX_PERM_GROUP_EXEC = S_IXGRP,
+    UNIX_PERM_GROUP_ALL = S_IRGRP | S_IWGRP | S_IXGRP,
+    UNIX_PERM_OTHER_READ = S_IROTH,
+    UNIX_PERM_OTHER_WRITE = S_IWOTH,
+    UNIX_PERM_OTHER_EXEC = S_IXOTH,
+    UNIX_PERM_OTHER_ALL = S_IROTH | S_IWOTH | S_IXOTH
+};
+
+typedef enum
+{
+    PERMISSION_NONE = (0),
+    PERMISSION_READ = (1 << 0),
+    PERMISSION_WRITE = (1 << 1),
+    PERMISSION_EXEC = (1 << 2)
+} PermissionValue;
+
+typedef enum
+{
+    PERMISSION_USER,
+    PERMISSION_GROUP,
+    PERMISSION_OTHER
+} PermissionType;
+
 enum
 {
     COLUMN_NAME,
@@ -820,6 +854,61 @@ start_deep_count_for_file (NautilusFile             *file,
     }
 }
 
+static guint32 vfs_perms[3][3] =
+{
+    {UNIX_PERM_USER_READ, UNIX_PERM_USER_WRITE, UNIX_PERM_USER_EXEC},
+    {UNIX_PERM_GROUP_READ, UNIX_PERM_GROUP_WRITE, UNIX_PERM_GROUP_EXEC},
+    {UNIX_PERM_OTHER_READ, UNIX_PERM_OTHER_WRITE, UNIX_PERM_OTHER_EXEC},
+};
+
+static guint32
+permission_to_vfs (PermissionType  type,
+                   PermissionValue perm)
+{
+    guint32 vfs_perm;
+    g_assert (type >= 0 && type < 3);
+
+    vfs_perm = 0;
+    if (perm & PERMISSION_READ)
+    {
+        vfs_perm |= vfs_perms[type][0];
+    }
+    if (perm & PERMISSION_WRITE)
+    {
+        vfs_perm |= vfs_perms[type][1];
+    }
+    if (perm & PERMISSION_EXEC)
+    {
+        vfs_perm |= vfs_perms[type][2];
+    }
+
+    return vfs_perm;
+}
+
+static PermissionValue
+permission_from_vfs (PermissionType type,
+                     guint32        vfs_perm)
+{
+    PermissionValue perm = PERMISSION_NONE;
+
+    g_assert (type >= 0 && type < 3);
+
+    if (vfs_perm & vfs_perms[type][0])
+    {
+        perm |= PERMISSION_READ;
+    }
+    if (vfs_perm & vfs_perms[type][1])
+    {
+        perm |= PERMISSION_WRITE;
+    }
+    if (vfs_perm & vfs_perms[type][2])
+    {
+        perm |= PERMISSION_EXEC;
+    }
+
+    return perm;
+}
+
 static void
 properties_window_update (NautilusPropertiesWindow *self,
                           GList                    *files)
@@ -2876,96 +2965,6 @@ setup_execute_checkbox_with_label (NautilusPropertiesWindow *self,
 #endif
 }
 
-enum
-{
-    UNIX_PERM_SUID = S_ISUID,
-    UNIX_PERM_SGID = S_ISGID,
-    UNIX_PERM_STICKY = 01000,           /* S_ISVTX not defined on all systems */
-    UNIX_PERM_USER_READ = S_IRUSR,
-    UNIX_PERM_USER_WRITE = S_IWUSR,
-    UNIX_PERM_USER_EXEC = S_IXUSR,
-    UNIX_PERM_USER_ALL = S_IRUSR | S_IWUSR | S_IXUSR,
-    UNIX_PERM_GROUP_READ = S_IRGRP,
-    UNIX_PERM_GROUP_WRITE = S_IWGRP,
-    UNIX_PERM_GROUP_EXEC = S_IXGRP,
-    UNIX_PERM_GROUP_ALL = S_IRGRP | S_IWGRP | S_IXGRP,
-    UNIX_PERM_OTHER_READ = S_IROTH,
-    UNIX_PERM_OTHER_WRITE = S_IWOTH,
-    UNIX_PERM_OTHER_EXEC = S_IXOTH,
-    UNIX_PERM_OTHER_ALL = S_IROTH | S_IWOTH | S_IXOTH
-};
-
-typedef enum
-{
-    PERMISSION_NONE = (0),
-    PERMISSION_READ = (1 << 0),
-    PERMISSION_WRITE = (1 << 1),
-    PERMISSION_EXEC = (1 << 2)
-} PermissionValue;
-
-typedef enum
-{
-    PERMISSION_USER,
-    PERMISSION_GROUP,
-    PERMISSION_OTHER
-} PermissionType;
-
-static guint32 vfs_perms[3][3] =
-{
-    {UNIX_PERM_USER_READ, UNIX_PERM_USER_WRITE, UNIX_PERM_USER_EXEC},
-    {UNIX_PERM_GROUP_READ, UNIX_PERM_GROUP_WRITE, UNIX_PERM_GROUP_EXEC},
-    {UNIX_PERM_OTHER_READ, UNIX_PERM_OTHER_WRITE, UNIX_PERM_OTHER_EXEC},
-};
-
-static guint32
-permission_to_vfs (PermissionType  type,
-                   PermissionValue perm)
-{
-    guint32 vfs_perm;
-    g_assert (type >= 0 && type < 3);
-
-    vfs_perm = 0;
-    if (perm & PERMISSION_READ)
-    {
-        vfs_perm |= vfs_perms[type][0];
-    }
-    if (perm & PERMISSION_WRITE)
-    {
-        vfs_perm |= vfs_perms[type][1];
-    }
-    if (perm & PERMISSION_EXEC)
-    {
-        vfs_perm |= vfs_perms[type][2];
-    }
-
-    return vfs_perm;
-}
-
-
-static PermissionValue
-permission_from_vfs (PermissionType type,
-                     guint32        vfs_perm)
-{
-    PermissionValue perm = PERMISSION_NONE;
-
-    g_assert (type >= 0 && type < 3);
-
-    if (vfs_perm & vfs_perms[type][0])
-    {
-        perm |= PERMISSION_READ;
-    }
-    if (vfs_perm & vfs_perms[type][1])
-    {
-        perm |= PERMISSION_WRITE;
-    }
-    if (vfs_perm & vfs_perms[type][2])
-    {
-        perm |= PERMISSION_EXEC;
-    }
-
-    return perm;
-}
-
 static void
 permission_combo_changed (GtkWidget                *combo,
                           NautilusPropertiesWindow *self)


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