[nautilus/wip/antoniof/properties-followup: 13/21] properties-window: Show current permissions in main page
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/antoniof/properties-followup: 13/21] properties-window: Show current permissions in main page
- Date: Fri, 5 Aug 2022 20:14:12 +0000 (UTC)
commit c8749e26de05d3889a883c32abcf1476721e43b2
Author: António Fernandes <antoniof gnome org>
Date: Thu Aug 4 17:54:44 2022 +0100
properties-window: Show current permissions in main page
This is immediately useful information.
Deemphasize the action aspect: most people have no need for setting
custom permissions.
src/nautilus-file.c | 30 +++++++++++++++++++++
src/nautilus-file.h | 2 ++
src/nautilus-properties-window.c | 36 ++++++++++++++++++++++++++
src/resources/ui/nautilus-properties-window.ui | 18 ++++++++-----
4 files changed, 79 insertions(+), 7 deletions(-)
---
diff --git a/src/nautilus-file.c b/src/nautilus-file.c
index 068b219c0..cbab57a8e 100644
--- a/src/nautilus-file.c
+++ b/src/nautilus-file.c
@@ -6257,6 +6257,21 @@ nautilus_file_can_get_owner (NautilusFile *file)
return file->details->uid != -1;
}
+/**
+ * nautilus_file_get_uid:
+ *
+ * Get the user id of the file's owner.
+ *
+ * @file: The file in question.
+ *
+ * Return value: (transfer none): the user id.
+ */
+const uid_t
+nautilus_file_get_uid (NautilusFile *file)
+{
+ return file->details->uid;
+}
+
/**
* nautilus_file_get_owner_name:
*
@@ -6448,6 +6463,21 @@ nautilus_file_can_get_group (NautilusFile *file)
return file->details->gid != -1;
}
+/**
+ * nautilus_file_get_gid:
+ *
+ * Get the group id of the file's group.
+ *
+ * @file: The file in question.
+ *
+ * Return value: (transfer none): the group id.
+ */
+const gid_t
+nautilus_file_get_gid (NautilusFile *file)
+{
+ return file->details->gid;
+}
+
/**
* nautilus_file_get_group_name:
*
diff --git a/src/nautilus-file.h b/src/nautilus-file.h
index 02cda5535..1cd331777 100644
--- a/src/nautilus-file.h
+++ b/src/nautilus-file.h
@@ -268,7 +268,9 @@ gboolean nautilus_file_can_get_owner (Nautilu
gboolean nautilus_file_can_set_owner (NautilusFile
*file);
gboolean nautilus_file_can_get_group (NautilusFile
*file);
gboolean nautilus_file_can_set_group (NautilusFile
*file);
+uid_t nautilus_file_get_uid (NautilusFile
*file);
char * nautilus_file_get_owner_name (NautilusFile
*file);
+gid_t nautilus_file_get_gid (NautilusFile
*file);
char * nautilus_file_get_group_name (NautilusFile
*file);
GList * nautilus_get_user_names (void);
GList * nautilus_get_all_group_names (void);
diff --git a/src/nautilus-properties-window.c b/src/nautilus-properties-window.c
index f9790d403..502ccd655 100644
--- a/src/nautilus-properties-window.c
+++ b/src/nautilus-properties-window.c
@@ -126,6 +126,7 @@ struct _NautilusPropertiesWindow
GtkWidget *accessed_value_label;
GtkWidget *permissions_navigation_row;
+ GtkWidget *permissions_value_label;
GtkListBox *extension_list_box;
@@ -1183,6 +1184,39 @@ get_target_permissions (NautilusPropertiesWindow *self)
return p;
}
+static void
+update_permissions_navigation_row (NautilusPropertiesWindow *self,
+ TargetPermissions *target_perm)
+{
+ if (!target_perm->is_multi_file_window)
+ {
+ uid_t user_id = geteuid ();
+ gid_t group_id = getegid ();
+ PermissionType permission_type = PERMISSION_OTHER;
+ const gchar *text;
+
+ if (user_id == nautilus_file_get_uid (get_original_file (self)))
+ {
+ permission_type = PERMISSION_USER;
+ }
+ else if (group_id == nautilus_file_get_gid (get_original_file (self)))
+ {
+ permission_type = PERMISSION_GROUP;
+ }
+
+ if (nautilus_file_is_directory (get_original_file (self)))
+ {
+ text = permission_value_to_string (target_perm->folder_permissions[permission_type], TRUE);
+ }
+ else
+ {
+ text = permission_value_to_string (target_perm->file_permissions[permission_type], FALSE);
+ }
+
+ gtk_label_set_text (GTK_LABEL (self->permissions_value_label), text);
+ }
+}
+
static void
properties_window_update (NautilusPropertiesWindow *self,
GList *files)
@@ -1238,6 +1272,7 @@ properties_window_update (NautilusPropertiesWindow *self,
{
g_autofree TargetPermissions *target_perm = get_target_permissions (self);
+ update_permissions_navigation_row (self, target_perm);
update_owner_row (self->owner_row, target_perm);
update_group_row (self->group_row, target_perm);
update_execution_row (GTK_WIDGET (self->execution_row), target_perm);
@@ -4270,6 +4305,7 @@ nautilus_properties_window_class_init (NautilusPropertiesWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, accessed_row);
gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, accessed_value_label);
gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow,
permissions_navigation_row);
+ gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, permissions_value_label);
gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, extension_list_box);
gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, free_space_value_label);
gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, permissions_stack);
diff --git a/src/resources/ui/nautilus-properties-window.ui b/src/resources/ui/nautilus-properties-window.ui
index 1e4a08154..d62941335 100644
--- a/src/resources/ui/nautilus-properties-window.ui
+++ b/src/resources/ui/nautilus-properties-window.ui
@@ -609,16 +609,20 @@
<object class="AdwActionRow" id="permissions_navigation_row">
<property name="activatable">True</property>
<property name="selectable">False</property>
- <property name="title" translatable="yes">Set Custom
_Permissions</property>
+ <property name="title" translatable="yes">_Permissions</property>
<property name="use-underline">True</property>
<signal name="activated" handler="navigate_permissions_page"
object="NautilusPropertiesWindow" swapped="yes"/>
<child>
- <object class="GtkBox" id="permissions_navigation_action_box">
- <child>
- <object class="GtkImage">
- <property name="icon-name">go-next-symbolic</property>
- </object>
- </child>
+ <object class="GtkLabel" id="permissions_value_label">
+ <property name="ellipsize">end</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImage">
+ <property name="icon-name">go-next-symbolic</property>
</object>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]