I see the problem now, but fixing it will take a bit of a refactor. You are creating a model when you construct the menu window. You create another *separate* model when you construct the config window. The user edits the second model with the config window, and when finished, writes this directly to the config file. The first model never gets updated. I see two possibilities:
1) Once the config has been written, trigger the menu window to re-read config. This is probably quicker and easier to do.
2) Another approach is to change all code to use a single shared model. This seems like it will be a bit more involved as my quick 60-second try failed elsewhere in the code. It would make the "Cancel" button in the edit window pointless however, which you might prefer to keep. Changes in edit would propagate immediately.
Small side note. Avoid tabs for indentation. Standard coding style for Terminator is 4 spaces per indentation level. Most editors can translate tabs to spaces for you, and handle indentation automatically.
Here's the changes I made to try and use a shared store, but it fails in the on_new method with an exception. And I have to stop now, so good luck ;-)
- store = Gtk.TreeStore(str,str,str)
+ #store = Gtk.TreeStore(str,str,str)
for group in groups:
- rabbit = store.append(None, [group,"blah","blah"])
- subgroup = [d for d in self.cmd_list if d['group'] == group]
- for command in subgroup:
- store.append(rabbit,[command['name'], command['command'], command['group']])
+ rabbit = self.store.append(None, [group,"blah","blah"])
+ subgroup = [d for d in self.cmd_list if d['group'] == group]
+ for command in subgroup:
+ self.store.append(rabbit,[command['name'], command['command'], command['group']])
OK, yeah, I totally misunderstood :-)
I see the problem now, but fixing it will take a bit of a refactor. You are creating a model when you construct the menu window. You create another *separate* model when you construct the config window. The user edits the second model with the config window, and when finished, writes this directly to the config file. The first model never gets updated. I see two possibilities:
1) Once the config has been written, trigger the menu window to re-read config. This is probably quicker and easier to do.
2) Another approach is to change all code to use a single shared model. This seems like it will be a bit more involved as my quick 60-second try failed elsewhere in the code. It would make the "Cancel" button in the edit window pointless however, which you might prefer to keep. Changes in edit would propagate immediately.
Small side note. Avoid tabs for indentation. Standard coding style for Terminator is 4 spaces per indentation level. Most editors can translate tabs to spaces for you, and handle indentation automatically.
Here's the changes I made to try and use a shared store, but it fails in the on_new method with an exception. And I have to stop now, so good luck ;-)
--- /home/steve/ Downloads/ ssh-menu- terminator- master/ ssh_menu. py 2017-04-25 11:42:45.000000000 +0200 join(get_ config_ dir()," ssh_menu" ) str,str, str)
+++ ssh_menu.py 2017-04-26 08:26:15.459785141 +0200
@@ -26,6 +26,7 @@
capabilities = ['terminal_menu']
cmd_list = []
conf_file = os.path.
+ store = Gtk.TreeStore(
def __init__( self): append( self.cmd_ list[elem] ['group' ]) allgroups) )
config = Config()
@@ -130,15 +131,15 @@
allgroups.
groups = list(set(
- store = Gtk.TreeStore( str,str, str) str,str, str)
+ #store = Gtk.TreeStore(
for group in groups: "blah", "blah"] ) rabbit, [command[ 'name'] , command['command'], command['group']]) append( None, [group, "blah", "blah"] ) append( rabbit, [command[ 'name'] , command['command'], command['group']])
- rabbit = store.append(None, [group,
- subgroup = [d for d in self.cmd_list if d['group'] == group]
- for command in subgroup:
- store.append(
+ rabbit = self.store.
+ subgroup = [d for d in self.cmd_list if d['group'] == group]
+ for command in subgroup:
+ self.store.
- treeview = Gtk.TreeView(store) self.store) get_selection( )
selection. set_mode( Gtk.SelectionMo de.SINGLE)
+ treeview = Gtk.TreeView(
selection = treeview.
@@ -189,12 +190,12 @@
Gtk. STOCK_OK, Gtk.ResponseTyp e.ACCEPT
)
)
- store = Gtk.ListStore(str, str, str)
+ #store = Gtk.ListStore(str, str, str)
- for command in self.cmd_list: [command[ 'name'] , command['command'], command['group']]) [command[ 'name'] , command['command'], command['group']])
- store.append(
+ #for command in self.cmd_list:
+ # store.append(
- treeview = Gtk.TreeView(store) self.store)
#treeview. connect( "cursor- changed" , self.on_ cursor_ changed, ui) get_selection( )
selection. set_mode( Gtk.SelectionMo de.SINGLE) e.ACCEPT: iter_first( ) get_iter_ first()
self. cmd_list = [] get(iter,
CC_ COL_NAME,
CC_ COL_COMMAND,
CC_ COL_GROUP)
'command' : command,
'group' : group}
) next(iter) iter_next( iter)
self. _save_config( )
+ treeview = Gtk.TreeView(
selection = treeview.
@@ -267,10 +268,10 @@
res = window.run()
if res == Gtk.ResponseTyp
#we save the config
- iter = store.get_
+ iter = self.store.
while iter:
- (name, command, group) = store.get(iter,
+ (name, command, group) = self.store.
@@ -279,7 +280,7 @@
- iter = store.iter_
+ iter = self.store.