(name)
| 1090 | ) |
| 1091 | |
| 1092 | def acltable(name): |
| 1093 | aclfrm = ttk.LabelFrame(dlg, text=name, borderwidth=0) |
| 1094 | |
| 1095 | tvfr = ttk.Frame(aclfrm) |
| 1096 | tvfr.grid_columnconfigure(0, weight=1) |
| 1097 | tvfr.grid_rowconfigure(0, weight=1) |
| 1098 | |
| 1099 | acltree = ttk.Treeview( |
| 1100 | tvfr, show="headings", columns=("type", "trustee", "rights", "flags") |
| 1101 | ) |
| 1102 | acltree.heading("type", text="Type") |
| 1103 | acltree.heading("trustee", text="Trustee") |
| 1104 | acltree.heading("rights", text="Rights") |
| 1105 | acltree.heading("flags", text="Flags") |
| 1106 | |
| 1107 | tree_scrollbar = AutoHideScrollbar( |
| 1108 | tvfr, orient="vertical", command=acltree.yview |
| 1109 | ) |
| 1110 | acltree.configure(yscrollcommand=tree_scrollbar.set) |
| 1111 | acltree.grid(row=0, column=0, sticky="nsew") |
| 1112 | |
| 1113 | # Populate |
| 1114 | aclobj = getattr(nTSecurityDescriptor, name, None) |
| 1115 | if aclobj is not None: |
| 1116 | for i, ace in enumerate(aclobj.Aces): |
| 1117 | addace(i, acltree, ace) |
| 1118 | |
| 1119 | def add(*_): |
| 1120 | ace = WINNT_ACE_HEADER() / WINNT_ACCESS_ALLOWED_ACE() |
| 1121 | acegui(ace) |
| 1122 | # Append |
| 1123 | aclobj.Aces.append(ace) |
| 1124 | addace(len(aclobj.Aces) - 1, acltree, ace) |
| 1125 | |
| 1126 | def delete(*_): |
| 1127 | try: |
| 1128 | selected = int(acltree.selection()[0]) |
| 1129 | del aclobj.Aces[selected] |
| 1130 | except IndexError: |
| 1131 | return |
| 1132 | # Full refresh as indexes change. |
| 1133 | acltree.delete(*acltree.get_children()) |
| 1134 | for i, ace in enumerate(aclobj.Aces): |
| 1135 | addace(i, acltree, ace) |
| 1136 | |
| 1137 | def edit(*_): |
| 1138 | try: |
| 1139 | selected = int(acltree.selection()[0]) |
| 1140 | ace = aclobj.Aces[selected] |
| 1141 | except IndexError: |
| 1142 | return |
| 1143 | acegui(ace) |
| 1144 | # Update |
| 1145 | acltree.delete(selected) |
| 1146 | addace(selected, acltree, ace, pos=selected) |
| 1147 | |
| 1148 | btnfrm = ttk.Frame(aclfrm) |
| 1149 | btnfrm.grid_columnconfigure(0, weight=1) |
nothing calls this directly
no test coverage detected