@@ -73,6 +73,10 @@ class FormActions(object):
73
73
"""
74
74
Form Action selector.
75
75
"""
76
+ RUN_ACTION_COL = 0
77
+ ACTION_COL = 1
78
+ DETAIL_COL = 2
79
+ ACTION_COMMAND_COL = 3
76
80
77
81
def __init__ (self , dbstate , uistate , track , citation ):
78
82
self .dbstate = dbstate
@@ -117,12 +121,19 @@ def _create_dialog(self, title):
117
121
box = Gtk .Box ()
118
122
top .vbox .pack_start (box , True , True , 5 )
119
123
120
- self .model = Gtk .TreeStore (str , str , GObject .TYPE_PYOBJECT )
124
+ self .model = Gtk .TreeStore (bool , str , str , GObject .TYPE_PYOBJECT )
121
125
self .tree = Gtk .TreeView (model = self .model )
122
- renderer = Gtk .CellRendererText ()
123
- column1 = Gtk .TreeViewColumn (_ ("Action" ), renderer , text = 0 )
124
- column1 .set_sort_column_id (1 )
125
- column2 = Gtk .TreeViewColumn (_ ("Detail" ), renderer , text = 1 )
126
+ renderer_text = Gtk .CellRendererText ()
127
+ column1 = Gtk .TreeViewColumn (_ ("Action" ))
128
+ renderer_action_toggle = Gtk .CellRendererToggle ()
129
+ renderer_action_toggle .connect ('toggled' , self .on_action_toggled )
130
+ column1 .pack_start (renderer_action_toggle , False )
131
+ column1 .add_attribute (renderer_action_toggle , 'active' , self .RUN_ACTION_COL )
132
+ column1 .pack_start (renderer_text , True )
133
+ column1 .add_attribute (renderer_text , 'text' , self .ACTION_COL )
134
+ column1 .set_cell_data_func (renderer_action_toggle , FormActions .action_data_func )
135
+
136
+ column2 = Gtk .TreeViewColumn (_ ("Detail" ), renderer_text , text = self .DETAIL_COL )
126
137
self .tree .append_column (column1 )
127
138
self .tree .append_column (column2 )
128
139
@@ -141,6 +152,12 @@ def _create_dialog(self, title):
141
152
142
153
return top
143
154
155
+ def on_action_toggled (self , widget , path ):
156
+ self .model [path ][self .RUN_ACTION_COL ] = not self .model [path ][self .RUN_ACTION_COL ]
157
+
158
+ def action_data_func (col , cell , model , iter , user_data ):
159
+ cell .set_property ("visible" , model .get_value (iter , FormActions .ACTION_COMMAND_COL ))
160
+
144
161
def _populate_model (self ):
145
162
form_id = get_form_id (self .source )
146
163
if self .actions_module :
@@ -151,9 +168,9 @@ def _populate_model(self):
151
168
action = (action_class [1 ])()
152
169
(title , action_details ) = action .get_actions (self .dbstate , self .citation , self .event )
153
170
if action_details :
154
- parent = self .model .append (None , (title , None , None ))
171
+ parent = self .model .append (None , (False , title , None , None ))
155
172
for action_detail in action_details :
156
- self .model .append (parent , action_detail )
173
+ self .model .append (parent , ( False , ) + action_detail )
157
174
158
175
def run (self ):
159
176
"""
@@ -177,13 +194,11 @@ def run(self):
177
194
self ._config .save ()
178
195
179
196
# run the selected actions
180
- (model , pathlist ) = self .tree .get_selection ().get_selected_rows ()
181
- for path in pathlist :
182
- tree_iter = model .get_iter (path )
183
-
184
- command = model .get_value (tree_iter , 2 )
185
- if command :
186
- (command )(self .dbstate , self .uistate , self .track )
197
+ for action_type_row in self .model :
198
+ for action_row in action_type_row .iterchildren ():
199
+ if action_row .model .get_value (action_row .iter , self .RUN_ACTION_COL ):
200
+ command = action_row .model .get_value (action_row .iter , self .ACTION_COMMAND_COL )
201
+ (command )(self .dbstate , self .uistate , self .track )
187
202
188
203
self .top .destroy ()
189
204
0 commit comments