mirror of
https://github.com/codex-storage/deluge.git
synced 2025-01-11 20:14:13 +00:00
[GTKUI] Small refactor prefs remove_page
This commit is contained in:
parent
7e9a8b801c
commit
bb5dafc61d
@ -225,15 +225,17 @@ class Preferences(component.Component):
|
|||||||
self.page_num_to_remove = None
|
self.page_num_to_remove = None
|
||||||
self.iter_to_remove = None
|
self.iter_to_remove = None
|
||||||
|
|
||||||
def check_row(model, path, _iter, user_data):
|
def on_foreach_row(model, path, _iter, user_data):
|
||||||
row_name = model.get_value(_iter, 1)
|
row_name = model.get_value(_iter, 1)
|
||||||
if row_name == user_data:
|
if row_name == user_data:
|
||||||
# This is the row we need to remove
|
# This is the row we need to remove
|
||||||
self.page_num_to_remove = model.get_value(_iter, 0)
|
self.page_num_to_remove = model.get_value(_iter, 0)
|
||||||
self.iter_to_remove = _iter
|
self.iter_to_remove = _iter
|
||||||
return
|
# Return True to stop foreach iterating
|
||||||
|
return True
|
||||||
|
|
||||||
|
self.liststore.foreach(on_foreach_row, name)
|
||||||
|
|
||||||
self.liststore.foreach(check_row, name)
|
|
||||||
# Remove the page and row
|
# Remove the page and row
|
||||||
if self.page_num_to_remove is not None:
|
if self.page_num_to_remove is not None:
|
||||||
self.notebook.remove_page(self.page_num_to_remove)
|
self.notebook.remove_page(self.page_num_to_remove)
|
||||||
@ -241,8 +243,8 @@ class Preferences(component.Component):
|
|||||||
self.liststore.remove(self.iter_to_remove)
|
self.liststore.remove(self.iter_to_remove)
|
||||||
|
|
||||||
# We need to re-adjust the index values for the remaining pages
|
# We need to re-adjust the index values for the remaining pages
|
||||||
for i, (index, name) in enumerate(self.liststore):
|
for idx, __ in enumerate(self.liststore):
|
||||||
self.liststore[i][0] = i
|
self.liststore[idx][0] = idx
|
||||||
|
|
||||||
def show(self, page=None):
|
def show(self, page=None):
|
||||||
"""Page should be the string in the left list.. ie, 'Network' or
|
"""Page should be the string in the left list.. ie, 'Network' or
|
||||||
|
Loading…
x
Reference in New Issue
Block a user