Skip to content

Commit

Permalink
refactor(gui: presets_list): s/listview/treeview/g
Browse files Browse the repository at this point in the history
  • Loading branch information
actionless committed Jun 23, 2016
1 parent 43ec963 commit eed171b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions gui/presets_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,43 +15,43 @@ class ThemePresetsList(Gtk.Box):
def on_preset_select(self, widget):
list_index = widget.get_cursor()[0].to_string()
selected_preset = list(
self.liststore[list_index]
self.treestore[list_index]
)
self.current_theme = selected_preset[0]
self.current_preset_path = selected_preset[1]
self.preset_select_callback(
self.current_theme, self.current_preset_path
)
self.treeiter = self.liststore.get_iter(
self.treeiter = self.treestore.get_iter(
Gtk.TreePath.new_from_string(list_index)
)

def add_preset(self, preset_name, preset_path):
self.liststore.append(None, (preset_name, preset_path))
self.treestore.append(None, (preset_name, preset_path))

def update_current_preset_path(self, new_path):
self.liststore[self.treeiter][1] = new_path
self.treestore[self.treeiter][1] = new_path

def __init__(self, preset_select_callback):
super().__init__(orientation=Gtk.Orientation.VERTICAL)
self.preset_select_callback = preset_select_callback
self.presets = get_presets()

self.liststore = Gtk.TreeStore(str, str)
self.treestore = Gtk.TreeStore(str, str)
for preset_dir, preset_list in self.presets.items():
sorted_preset_list = sorted(preset_list, key=lambda x: x['name'])
piter = self.liststore.append(
piter = self.treestore.append(
None,
(sorted_preset_list[0]['name'], sorted_preset_list[0]['path'])
)
for preset in sorted_preset_list[1:]:
self.liststore.append(
self.treestore.append(
piter,
(preset['name'], preset['path'])
)
self.liststore.set_sort_column_id(0, Gtk.SortType.ASCENDING)
self.treestore.set_sort_column_id(0, Gtk.SortType.ASCENDING)

treeview = Gtk.TreeView(model=self.liststore, headers_visible=False)
treeview = Gtk.TreeView(model=self.treestore, headers_visible=False)
treeview.connect("cursor_changed", self.on_preset_select)

column = Gtk.TreeViewColumn(
Expand Down

0 comments on commit eed171b

Please sign in to comment.