Skip to content

Commit

Permalink
ui: Add insert rule below button
Browse files Browse the repository at this point in the history
This change adds an explicit button to add a new rule. Previously a new
rule could only be created via context menu, which is hard is not
beginner-friendly and not obvious. This change improves that.

Related pwr-Solaar#2349
  • Loading branch information
MattHag committed Mar 8, 2024
1 parent 49e2c0f commit 2322bdc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/solaar/ui/diversion_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ def _create_button_box(self):
button_box = Gtk.HBox(spacing=20)
button_box.set_margin_start(10)
button_box.set_margin_end(10)
self.insert_rule_btn = Gtk.Button.new_from_icon_name("document-revert", Gtk.IconSize.BUTTON)
self.insert_rule_btn.set_label(_("Insert new rule"))
self.insert_rule_btn.set_sensitive(False)
self.insert_rule_btn.set_valign(Gtk.Align.CENTER)
self.insert_rule_btn.connect("clicked", lambda *_args: ()) # TODO insert rule below
self.save_btn = Gtk.Button.new_from_icon_name("document-save", Gtk.IconSize.BUTTON)
self.save_btn = Gtk.Button.new_from_icon_name("document-save", Gtk.IconSize.BUTTON)
self.save_btn.set_label(_("Save changes"))
self.save_btn.set_always_show_image(True)
Expand All @@ -215,6 +221,7 @@ def _create_button_box(self):
self.discard_btn.set_valign(Gtk.Align.CENTER)
self.save_btn.connect("clicked", lambda *_args: self._save_yaml_file())
self.discard_btn.connect("clicked", lambda *_args: self._reload_yaml_file())
button_box.pack_start(self.insert_rule_btn, False, False, 0)
button_box.pack_start(self.discard_btn, False, False, 0)
button_box.pack_start(self.save_btn, False, False, 0)
button_box.set_halign(Gtk.Align.END)
Expand Down

0 comments on commit 2322bdc

Please sign in to comment.