I enter specific “technical” data in Notes. This data has a dedicated format described by abstract rules. I want to right-click on it to trigger actions.
This is inspired by URLs in Notes where hovering the mouse displays a tooltip and right-clicking will jump to the destination (through a context menu or Ctl-click).
I have added a regexp in gramps/gui/widgets/styledtexteditor.py and activated it with a call to method match_add(…). It works and I can retrieve it in method do_match_changed(…).
Next step is to create a tooltip. But I need other “environment” data which obviously is not in the styled text buffer. To probe the data I must first find which Note record owns this StyledTextEditor object (the parent).
- How can I find it?
- Once I have computed the tooltip, how do I return it to the StyledTextEditor in an orderly manner?
Would signals be an appropriate track? Notably to invalidate detection as a “false positive” when the construct is not allowed (Note has not the allowed type).
EDIT 1:
Method get_parent() called on StyledTextEditor object allows me to reach the ScrolledWindow hosting the full GUI for the editor. From there, can I get the “Gramps genealogical” object it is associated with?
EDIT 2:
Exploring the get_parent() chain, I end up on a Gtk.Dialog() object. This dialog is created in _local_init(self) method of the various editxxx.py modules.
My knowledge of GTK is next to zero. Do you know if there is an available property in dialog objects for free use? If such a property exists, I can store the relevant Gramps object (pointer) in it when it is created and this solves one problem.
