Skip to content

Commit

Permalink
ui: Move save/revert buttons to bottom right
Browse files Browse the repository at this point in the history
  • Loading branch information
MattHag committed Mar 10, 2024
1 parent c23c6b7 commit 870ea46
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions lib/solaar/ui/diversion_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ def __init__(self):
window.connect("delete-event", self._closing)
vbox = Gtk.VBox()

self.top_panel, self.view = self._create_top_panel()
rules_panel, self.view = self._create_rules_panel()
for col in self._create_view_columns():
self.view.append_column(col)
vbox.pack_start(self.top_panel, True, True, 0)
vbox.pack_start(rules_panel, True, True, 0)

self.dirty = False # if dirty, there are pending changes to be saved

Expand All @@ -109,6 +109,9 @@ def __init__(self):
)
vbox.pack_start(self.bottom_panel, False, False, 10)

button_box = self._create_button_box()
vbox.pack_start(button_box, True, True, 0)

self.model = self._create_model()
self.view.set_model(self.model)
self.view.expand_all()
Expand Down Expand Up @@ -179,7 +182,7 @@ def _save_yaml_file(self):
self.save_btn.set_sensitive(False)
self.discard_btn.set_sensitive(False)

def _create_top_panel(self):
def _create_rules_panel(self):
sw = Gtk.ScrolledWindow()
sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.ALWAYS)
view = Gtk.TreeView()
Expand All @@ -192,8 +195,14 @@ def _create_top_panel(self):
view.get_selection().connect("changed", self._selection_changed)
sw.add(view)
sw.set_size_request(0, 300) # don't ask for so much height
vbox = Gtk.VBox()
vbox.pack_start(sw, True, True, 0)
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)
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 @@ -206,17 +215,12 @@ def _create_top_panel(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.save_btn, False, False, 0)
button_box.pack_start(self.discard_btn, False, False, 0)
button_box.set_halign(Gtk.Align.CENTER)
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)

vbox = Gtk.VBox()
vbox.pack_start(button_box, False, False, 0)
vbox.pack_start(sw, True, True, 0)

return vbox, view
return button_box

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

0 comments on commit 870ea46

Please sign in to comment.