use CONTACTS like C_VALUE (Column that holds value) instead of 0 1 2 3 for model columns (hidden or not). that is very wise and clean code
This commit is contained in:
parent
0709dec1c0
commit
65d7b18441
|
@ -32,6 +32,12 @@ gtk.glade.textdomain(APP)
|
||||||
OPT_TYPE = 0
|
OPT_TYPE = 0
|
||||||
OPT_VAL = 1
|
OPT_VAL = 1
|
||||||
|
|
||||||
|
(
|
||||||
|
C_PREFNAME,
|
||||||
|
C_VALUE,
|
||||||
|
C_TYPE
|
||||||
|
) = range(3)
|
||||||
|
|
||||||
GTKGUI_GLADE = 'gtkgui.glade'
|
GTKGUI_GLADE = 'gtkgui.glade'
|
||||||
|
|
||||||
class AdvancedConfigurationWindow:
|
class AdvancedConfigurationWindow:
|
||||||
|
@ -83,8 +89,8 @@ class AdvancedConfigurationWindow:
|
||||||
self.plugin.windows['advanced_config'] = self
|
self.plugin.windows['advanced_config'] = self
|
||||||
|
|
||||||
def cb_value_column_data(self, col, cell, model, iter):
|
def cb_value_column_data(self, col, cell, model, iter):
|
||||||
optname = model[iter][0]
|
optname = model[iter][C_PREFNAME]
|
||||||
opttype = model[iter][2]
|
opttype = model[iter][C_TYPE]
|
||||||
if opttype == 'boolean' or optname.find('password') != -1 or\
|
if opttype == 'boolean' or optname.find('password') != -1 or\
|
||||||
optname.find('passphrase') != -1:
|
optname.find('passphrase') != -1:
|
||||||
cell.set_property('editable', 0)
|
cell.set_property('editable', 0)
|
||||||
|
@ -149,7 +155,7 @@ class AdvancedConfigurationWindow:
|
||||||
else:
|
else:
|
||||||
iter = model.iter_children(parent_iter)
|
iter = model.iter_children(parent_iter)
|
||||||
while iter:
|
while iter:
|
||||||
if model[iter][0].decode('utf-8') == name:
|
if model[iter][C_PREFNAME].decode('utf-8') == name:
|
||||||
break
|
break
|
||||||
iter = model.iter_next(iter)
|
iter = model.iter_next(iter)
|
||||||
return iter
|
return iter
|
||||||
|
@ -176,16 +182,16 @@ class AdvancedConfigurationWindow:
|
||||||
str = self.entry.get_text().decode('utf-8')
|
str = self.entry.get_text().decode('utf-8')
|
||||||
if str is None or str == '':
|
if str is None or str == '':
|
||||||
return True # show all
|
return True # show all
|
||||||
name = model[iter][0].decode('utf-8')
|
name = model[iter][C_PREFNAME].decode('utf-8')
|
||||||
# If a child of the iter matches, we return True
|
# If a child of the iter matches, we return True
|
||||||
if model.iter_has_child(iter):
|
if model.iter_has_child(iter):
|
||||||
iterC = model.iter_children(iter)
|
iterC = model.iter_children(iter)
|
||||||
while iterC:
|
while iterC:
|
||||||
nameC = model[iterC][0].decode('utf-8')
|
nameC = model[iterC][C_PREFNAME].decode('utf-8')
|
||||||
if model.iter_has_child(iterC):
|
if model.iter_has_child(iterC):
|
||||||
iterCC = model.iter_children(iterC)
|
iterCC = model.iter_children(iterC)
|
||||||
while iterCC:
|
while iterCC:
|
||||||
nameCC = model[iterCC][0].decode('utf-8')
|
nameCC = model[iterCC][C_PREFNAME].decode('utf-8')
|
||||||
if nameCC.find(str) != -1:
|
if nameCC.find(str) != -1:
|
||||||
return True
|
return True
|
||||||
iterCC = model.iter_next(iterCC)
|
iterCC = model.iter_next(iterCC)
|
||||||
|
|
Loading…
Reference in New Issue