Skip to content

Commit 0ceec78

Browse files
committed
When a form action is activated, call EditForm.action_callback to exec the actions command implementation
1 parent 7775fcb commit 0ceec78

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

Form/editform.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,8 @@ def __populate_gui(self, event):
307307
self.track,
308308
self.event,
309309
self.citation,
310-
form_id)
310+
form_id,
311+
self.action_callback)
311312

312313
self.headings = HeadingsTab(self.dbstate,
313314
self.uistate,
@@ -370,6 +371,9 @@ def help_clicked(self, obj):
370371
"""
371372
display_help(webpage='Form_Addons')
372373

374+
def action_callback(self, section, object, row, column, value, command):
375+
exec(command)
376+
373377
#------------------------------------------------------------------------
374378
#
375379
# Headings Tab
@@ -477,11 +481,12 @@ class DetailsTab(GrampsTab):
477481
"""
478482
Details tab in the form editor.
479483
"""
480-
def __init__(self, dbstate, uistate, track, event, citation, form_id):
484+
def __init__(self, dbstate, uistate, track, event, citation, form_id, action_callback):
481485
self.db = dbstate.db
482486
self.event = event
483487
self.citation = citation
484488
self.form_id = form_id
489+
self._action_callback = action_callback
485490
GrampsTab.__init__(self, dbstate, uistate, track, _('Details'))
486491

487492
self.populate_gui(event)
@@ -502,7 +507,7 @@ def build_interface(self):
502507
if section_type == 'multi':
503508
section = MultiSection(self.dbstate, self.uistate, self.track,
504509
self.event, self.citation, self.form_id,
505-
role)
510+
role, self._action_callback)
506511
elif section_type == 'person':
507512
section = PersonSection(self.dbstate, self.uistate, self.track,
508513
self.event, self.citation, self.form_id,
@@ -555,7 +560,7 @@ class MultiSection(Gtk.Box):
555560
SelectPerson = SelectorFactory('Person')
556561

557562
def __init__(self, dbstate, uistate, track, event, citation, form_id,
558-
section):
563+
section, action_callback):
559564
Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)
560565

561566
self.dbstate = dbstate
@@ -567,6 +572,8 @@ def __init__(self, dbstate, uistate, track, event, citation, form_id,
567572
self.event = event
568573
self.citation = citation
569574

575+
self._action_callback = action_callback
576+
570577
self.model = None
571578
self.columns = []
572579
self.initial_people = []
@@ -626,7 +633,7 @@ def __init__(self, dbstate, uistate, track, event, citation, form_id,
626633
down_btn.connect('clicked', self.__move_person, 'down')
627634
hbox.pack_start(down_btn, expand=False, fill=True, padding=0)
628635

629-
self.entry_grid = EntryGrid(callback=self.change_person)
636+
self.entry_grid = EntryGrid(callback=self.change_person, action_callback=self.action_callback)
630637

631638
self.pack_start(hbox, expand=False, fill=True, padding=0)
632639
self.pack_start(self.entry_grid, expand=True, fill=True, padding=0)
@@ -701,6 +708,9 @@ def change_person(self, model, iter_):
701708
if person:
702709
self.model.set_value(iter_, 0, person.get_handle())
703710

711+
def action_callback(self, row, column, command):
712+
self._action_callback(self, self.model[row][0], row, column, self.model[row][column], command)
713+
704714
def __new_person_row(self, person):
705715
"""
706716
Create a new model entry for a person.

Form/entrygrid.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def _draw(self, widget, cr):
6969
#------------------------------------------------------------------------
7070
class EntryGrid(Gtk.Grid):
7171

72-
def __init__(self, headings=None, tooltips=None, actions=None, model=None, callback=None):
72+
def __init__(self, headings=None, tooltips=None, actions=None, model=None, callback=None, action_callback=None):
7373
Gtk.Grid.__init__(self)
7474

7575
self.headings = headings
@@ -80,6 +80,7 @@ def __init__(self, headings=None, tooltips=None, actions=None, model=None, callb
8080
self.indicators = []
8181
self.selected = None
8282
self.callback = callback
83+
self.action_callback = action_callback
8384

8485
def set_model(self, model):
8586
self.model = model
@@ -142,6 +143,7 @@ def build(self):
142143
entry.set_tooltip_text(self.tooltips[column - 1])
143144
entry.connect('changed', self.changed, row, column)
144145
entry.connect('focus-in-event', self.got_focus, row)
146+
entry.connect('populate_popup', self.populate_popup, row, column)
145147
entry.show()
146148
self.attach(entry, column + 1, row + 1, 1, 1)
147149
entry_row.append(entry)
@@ -161,7 +163,7 @@ def got_focus(self, entry, event, row):
161163
self.indicators[row].set_active(True)
162164

163165
def activate_action(self, widget, row, column, action):
164-
pass
166+
self.action_callback(row, column, action.command)
165167

166168
def populate_popup(self, entry, menu, row, column):
167169
if self.actions[column - 1]:
@@ -214,6 +216,7 @@ def clean_up(self):
214216
self.indicators = None
215217
self.selected = None
216218
self.callback = None
219+
self.callback_action = None
217220

218221
def set_size(entry):
219222
layout = entry.get_layout()

0 commit comments

Comments
 (0)