def build_grid(self): permissions_header = Util.create_label("<big>PERMISSIONS</big>", align=Gtk.Align.START) permissions_header.set_use_markup(True) self.attach(permissions_header, 0, 0, 1, 1) # create attribute labels owner_label = Util.create_label("Owner:") group_label = Util.create_label("Group:") perms_label = Util.create_info_label( Util.create_perm_str(self._filestat.st_mode), align=Gtk.Align.END) # create attribute values owner = Util.create_info_label(self._owner_name) group = Util.create_info_label(self._group_name) # Entry box perms_entry = Gtk.Entry.new() perms_entry.set_max_length(3) perms_entry.set_width_chars(3) perms_entry.set_text(Util.create_777_format(self._filestat.st_mode)) perms_entry.connect("changed", self.on_perms_changed, perms_label) self.attach(owner_label, 0, 1, 1, 1) self.attach(group_label, 0, 2, 1, 1) self.attach(perms_label, 0, 3, 1, 1) self.attach(owner, 1, 1, 1, 1) self.attach(group, 1, 2, 1, 1) self.attach(perms_entry, 1, 3, 1, 1)
def on_perms_changed(self, entry, perms_label): text = entry.get_text() if len(text) == 3 and Util.is_integer(text): (model, treepaths) = self._treeview.get_selection().get_selected_rows() treeiter = model.get_iter(treepaths[0]) os.chmod(model[treeiter][1], int(text, 8)) filestat = Util.get_file_stat(model[treeiter][1]) perms_label.set_label(Util.create_perm_str(filestat.st_mode))