Skip to content

Commit

Permalink
PropertiesWindow: redesign permisssions (#2463)
Browse files Browse the repository at this point in the history
Co-authored-by: Jeremy Wootten <jeremywootten@gmail.com>
  • Loading branch information
danirabbit and jeremypw authored Aug 30, 2024
1 parent 9c41d78 commit c625efc
Show file tree
Hide file tree
Showing 12 changed files with 281 additions and 32 deletions.
9 changes: 9 additions & 0 deletions data/files.gresource.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/io/elementary/files/">
<file alias="Application.css" compressed="true">styles/Application.css</file>
<file alias="ColorButton.css" compressed="true">styles/ColorButton.css</file>
<file alias="DiskRenderer.css" compressed="true">styles/DiskRenderer.css</file>
<file alias="SidebarExpander.css" compressed="true">styles/SidebarExpander.css</file>
</gresource>
<gresource prefix="/io/elementary/files/icons">
<file alias="scalable/status/permission-execute-prevent-symbolic.svg" compressed="true" preprocess="xml-stripblanks">icons/permission-execute-prevent.svg</file>
<file alias="scalable/status/permission-execute-symbolic.svg" compressed="true" preprocess="xml-stripblanks">icons/permission-execute.svg</file>
<file alias="scalable/status/permission-read-prevent-symbolic.svg" compressed="true" preprocess="xml-stripblanks">icons/permission-read-prevent.svg</file>
<file alias="scalable/status/permission-read-symbolic.svg" compressed="true" preprocess="xml-stripblanks">icons/permission-read.svg</file>
<file alias="scalable/status/permission-write-prevent-symbolic.svg" compressed="true" preprocess="xml-stripblanks">icons/permission-write-prevent.svg</file>
<file alias="scalable/status/permission-write-symbolic.svg" compressed="true" preprocess="xml-stripblanks">icons/permission-write.svg</file>
</gresource>
</gresources>
39 changes: 39 additions & 0 deletions data/icons/permission-execute-prevent.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions data/icons/permission-execute.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions data/icons/permission-read-prevent.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions data/icons/permission-read.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions data/icons/permission-write-prevent.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions data/icons/permission-write.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions data/styles/Application.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*FIXME: Remove list styles in Gtk4*/
list.rich-list > row {
padding: 6px;
min-height: 32px;
}

list.rich-list label {
margin: 0 6px;
}

list.rich-list button.toggle {
margin: 3px 0;
}

list:not(.horizontal) row.separator,
list.separators:not(.horizontal) > row:not(.separator) + row:not(.separator) {
border-top: 1px solid @menu_separator;
}

list.boxed-list {
border-radius: 6px;
box-shadow: 0 1px 3px alpha(black, 0.1);
}

list.boxed-list > row:first-child {
border-top-left-radius: 6px;
border-top-right-radius: 6px;
}

list.boxed-list > row:last-child {
border-bottom-left-radius: 6px;
border-bottom-right-radius: 6px;
border-bottom-width: 0;
}
5 changes: 5 additions & 0 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ public class Files.Application : Gtk.Application {
QuicklistHandler.get_singleton ();
#endif

var app_provider = new Gtk.CssProvider ();
app_provider.load_from_resource ("/io/elementary/files/Application.css");

Gtk.StyleContext.add_provider_for_screen (Gdk.Screen.get_default (), app_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);

var granite_settings = Granite.Settings.get_default ();
var gtk_settings = Gtk.Settings.get_default ();

Expand Down
39 changes: 20 additions & 19 deletions src/Dialogs/PropertiesWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -964,13 +964,8 @@ public class Files.View.PropertiesWindow : AbstractPropertiesDialog {
var group_combo = create_group_choice ();
group_combo.margin_bottom = 12;

var owner_label = make_key_label (_("Owner:"));
perm_button_user = create_perm_choice (Permissions.Type.USER);

var group_label = make_key_label (_("Group:"));
perm_button_group = create_perm_choice (Permissions.Type.GROUP);

var other_label = make_key_label (_("Everyone:"));
perm_button_other = create_perm_choice (Permissions.Type.OTHER);

perm_code = new Gtk.Entry ();
Expand All @@ -981,23 +976,29 @@ public class Files.View.PropertiesWindow : AbstractPropertiesDialog {
l_perm.halign = Gtk.Align.START;
l_perm.use_markup = true;

var permission_box = new Gtk.ListBox () {
selection_mode = NONE
};
// FIXME: use constants in Gtk4
permission_box.get_style_context ().add_class ("frame");
permission_box.get_style_context ().add_class ("rich-list");
permission_box.get_style_context ().add_class ("boxed-list");
permission_box.get_style_context ().add_class ("separators");
permission_box.add (perm_button_user);
permission_box.add (perm_button_group);
permission_box.add (perm_button_other);

perm_grid = new Gtk.Grid () {
column_spacing = 6,
row_spacing = 6,
halign = Gtk.Align.CENTER
row_spacing = 6
};
perm_grid.attach (owner_user_label, 0, 1, 1, 1);
perm_grid.attach (owner_user_choice, 1, 1, 2, 1);
perm_grid.attach (group_combo_label, 0, 2, 1, 1);
perm_grid.attach (group_combo, 1, 2, 2, 1);
perm_grid.attach (owner_label, 0, 3, 1, 1);
perm_grid.attach (perm_button_user, 1, 3, 2, 1);
perm_grid.attach (group_label, 0, 4, 1, 1);
perm_grid.attach (perm_button_group, 1, 4, 2, 1);
perm_grid.attach (other_label, 0, 5, 1, 1);
perm_grid.attach (perm_button_other, 1, 5, 2, 1);
perm_grid.attach (l_perm, 1, 6, 1, 1);
perm_grid.attach (perm_code, 2, 6, 1, 1);
perm_grid.attach (owner_user_label, 0, 0);
perm_grid.attach (owner_user_choice, 1, 0);
perm_grid.attach (group_combo_label, 0, 1);
perm_grid.attach (group_combo, 1, 1);
perm_grid.attach (permission_box, 0, 2, 2);
perm_grid.attach (l_perm, 0, 3);
perm_grid.attach (perm_code, 1, 3);

update_perm_grid_toggle_states (goffile.permissions);

Expand Down
14 changes: 13 additions & 1 deletion src/Utils/Permissions.vala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,19 @@ namespace Permissions {
public enum Type {
USER,
GROUP,
OTHER
OTHER;

public string to_string () {
switch (this) {
case USER:
return _("Owner");
case GROUP:
return _("Group");
default:
case OTHER:
return _("Everyone");
}
}
}

public enum Value {
Expand Down
Loading

0 comments on commit c625efc

Please sign in to comment.