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 cbc4b58
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions lib/solaar/ui/diversion_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,13 @@ def _create_rules_panel(self):
return vbox, view

def _create_button_box(self):
button_box = Gtk.HBox(spacing=20)
button_box.set_margin_start(10)
button_box.set_margin_end(10)
hbox = Gtk.HBox(spacing=20)
hbox.set_margin_start(10)
hbox.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_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.set_label(_("Save changes"))
self.save_btn.set_always_show_image(True)
Expand All @@ -215,12 +219,12 @@ 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.discard_btn, False, False, 0)
button_box.pack_start(self.save_btn, False, False, 0)
button_box.set_halign(Gtk.Align.END)
button_box.set_valign(Gtk.Align.CENTER)
button_box.set_size_request(0, 50)
return button_box
hbox.pack_start(self.insert_rule_btn, False, False, 0)
hbox.pack_end(self.discard_btn, False, False, 0)
hbox.pack_end(self.save_btn, False, False, 0)
hbox.set_valign(Gtk.Align.CENTER)
hbox.set_size_request(0, 50)
return hbox

def _create_model(self):
model = Gtk.TreeStore(RuleComponentWrapper)
Expand Down

0 comments on commit cbc4b58

Please sign in to comment.