+18
-7
lines changedFilter options
+18
-7
lines changed Original file line number Diff line number Diff line change
@@ -406,8 +406,7 @@ def on_color_edited(self, colorscheme):
406
406
self._set_save_needed()
407
407
408
408
def reload_presets(self):
409
-
self.preset_list.load_presets()
410
-
self.preset_list.focus_preset_by_filepath(self.colorscheme_path)
409
+
self.preset_list.reload_presets(self.colorscheme_path)
411
410
412
411
def disable(self, message=''):
413
412
def disable_ui_callback():
Original file line number Diff line number Diff line change
@@ -88,8 +88,7 @@ def focus_preset_by_filepath(self, filepath):
88
88
self.treestore, filepath
89
89
)
90
90
if treepath:
91
-
self.treeview.expand_to_path(treepath)
92
-
self.treeview.set_cursor(treepath)
91
+
self._focus_preset_by_treepath(treepath)
93
92
return True
94
93
return False
95
94
@@ -114,15 +113,28 @@ def load_presets(self):
114
113
"cursor_changed", self._on_preset_select
115
114
)
116
115
117
-
def reload_presets(self):
118
-
selected_path = self.get_preset_path()
116
+
def reload_presets(self, focus_on_theme=None):
117
+
old_treepath = self._get_current_treepath()
118
+
focus_on_theme = focus_on_theme or self.get_preset_path()
119
119
self.load_presets()
120
-
self.focus_preset_by_filepath(selected_path)
120
+
if not self.focus_preset_by_filepath(focus_on_theme):
121
+
self._focus_preset_by_treepath(old_treepath)
121
122
122
123
###########################################################################
123
124
# Private methods:
124
125
###########################################################################
125
126
127
+
def _focus_preset_by_treepath(self, treepath):
128
+
path_found = False
129
+
while not path_found:
130
+
try:
131
+
self.treestore.get_iter(treepath)
132
+
path_found = True
133
+
except ValueError:
134
+
treepath.prev()
135
+
self.treeview.expand_to_path(treepath)
136
+
self.treeview.set_cursor(treepath)
137
+
126
138
def _get_current_treepath(self):
127
139
return self.treeview.get_cursor()[0]
128
140
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4