mirror of
https://gitlab.gnome.org/julianschacher/top-bar-organizer.git
synced 2025-10-27 07:09:07 +00:00
Refactor: Install forget action using install_action as well
This commit is contained in:
parent
9b7ab0614c
commit
a77c6d2f2b
@ -55,7 +55,7 @@
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label">Forget</attribute>
|
||||
<attribute name="action">options.forget</attribute>
|
||||
<attribute name="action">row.forget</attribute>
|
||||
</item>
|
||||
</section>
|
||||
</menu>
|
||||
|
||||
@ -21,6 +21,12 @@ export default class PrefsBoxOrderItemRow extends Adw.ActionRow {
|
||||
}
|
||||
}
|
||||
}, this);
|
||||
this.install_action("row.forget", null, (self, _actionName, _param) => {
|
||||
const parentListBox = self.get_parent();
|
||||
parentListBox.removeRow(self);
|
||||
parentListBox.saveBoxOrderToSettings();
|
||||
parentListBox.determineRowMoveActionEnable();
|
||||
});
|
||||
this.install_action("row.move-up", null, (self, _actionName, _param) => self.emit("move", "up"));
|
||||
this.install_action("row.move-down", null, (self, _actionName, _param) => self.emit("move", "down"));
|
||||
}
|
||||
@ -32,7 +38,6 @@ export default class PrefsBoxOrderItemRow extends Adw.ActionRow {
|
||||
super(params);
|
||||
|
||||
this.#associateItem(item);
|
||||
this.#setupActions();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -52,26 +57,6 @@ export default class PrefsBoxOrderItemRow extends Adw.ActionRow {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup actions.
|
||||
*/
|
||||
#setupActions() {
|
||||
const actionGroup = new Gio.SimpleActionGroup();
|
||||
|
||||
const forgetAction = new Gio.SimpleAction({
|
||||
name: "forget"
|
||||
});
|
||||
forgetAction.connect("activate", (_action, _params) => {
|
||||
const parentListBox = this.get_parent();
|
||||
parentListBox.removeRow(this);
|
||||
parentListBox.saveBoxOrderToSettings();
|
||||
parentListBox.determineRowMoveActionEnable();
|
||||
});
|
||||
actionGroup.add_action(forgetAction);
|
||||
|
||||
this.insert_action_group("options", actionGroup);
|
||||
}
|
||||
|
||||
onDragPrepare(_source, x, y) {
|
||||
const value = new GObject.Value();
|
||||
value.init(PrefsBoxOrderItemRow);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user