~rosco2/ubuntu/wily/gramps/bug-1492304

« back to all changes in this revision

Viewing changes to gramps/gui/editors/editpersonref.py

  • Committer: Package Import Robot
  • Author(s): Ross Gammon
  • Date: 2015-08-11 23:03:11 UTC
  • mfrom: (1.4.3)
  • mto: This revision was merged to the branch mainline in revision 58.
  • Revision ID: package-import@ubuntu.com-20150811230311-acjr8gcfe8isx7ij
* New upstream release
* Drop patches applied upstream or cherry-picked from there
* Add version constraints for gtk and pygobject
* Add goocanvas dependency - available soon
* Drop webkit dpendency as HTML view has been removed
* Force removal of upstream packages when installing Debian one
  (LP: #1464845)
* Drop fixperm override as permissions fixed upstream
* Fix spelling error in changelog
* Switch to nose for unit tests
* Add build dependencies for the nose tests
* Update copyright file
* Add uversionmangle to watch file to deal with alpha/beta versions
* Add manual test cases
* Drop FAQ URL from upstream metadata - changes every release
* Add patch to fix transparent windows in Ubuntu.
  Thanks to Lance Orner (LP: #1451259)

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
from gramps.gen.const import GRAMPS_LOCALE as glocale
34
34
_ = glocale.translation.gettext
35
35
 
 
36
import pickle
 
37
 
36
38
#-------------------------------------------------------------------------
37
39
#
38
40
# GTK/Gnome modules
52
54
from ..selectors import SelectorFactory
53
55
from .displaytabs import CitationEmbedList, NoteTab
54
56
from ..glade import Glade
 
57
from ..ddtargets import DdTargets
 
58
from gi.repository import Gdk
55
59
 
56
60
#-------------------------------------------------------------------------
57
61
#
83
87
                        _('Person Reference Editor'))
84
88
        self.person_label = self.top.get_object('person')
85
89
 
 
90
        #allow for drop:
 
91
        self.person_label.drag_dest_set(Gtk.DestDefaults.MOTION |
 
92
                            Gtk.DestDefaults.DROP,
 
93
                            [],
 
94
                            Gdk.DragAction.COPY)
 
95
        tglist = Gtk.TargetList.new([])
 
96
        tglist.add(DdTargets.PERSON_LINK.atom_drag_type,
 
97
                   DdTargets.PERSON_LINK.target_flags,
 
98
                   DdTargets.PERSON_LINK.app_id)
 
99
        self.person_label.drag_dest_set_target_list(tglist)
 
100
        self.person_label.connect('drag_data_received', self.on_drag_persondata_received)
 
101
        self._update_dnd_capability()
 
102
 
 
103
    def _update_dnd_capability(self):
 
104
        self.label_event_box = self.top.get_object('person_event_box')
 
105
        # Set the drag action from the label
 
106
        if self.obj.ref:
 
107
            self.label_event_box.drag_source_set(Gdk.ModifierType.BUTTON1_MASK, 
 
108
                                       [], Gdk.DragAction.COPY)
 
109
            tglist = Gtk.TargetList.new([])
 
110
            tglist.add(DdTargets.PERSON_LINK.atom_drag_type,
 
111
                       DdTargets.PERSON_LINK.target_flags,
 
112
                       DdTargets.PERSON_LINK.app_id)
 
113
            self.label_event_box.drag_source_set_target_list(tglist)
 
114
            self.label_event_box.drag_source_set_icon_name('gramps-person')
 
115
            self.label_event_box.connect('drag_data_get', self.drag_data_get)
 
116
        else:
 
117
            self.label_event_box.drag_source_unset()
 
118
 
86
119
    def _setup_fields(self):
87
120
 
88
121
        if self.obj.ref:
128
161
 
129
162
        sel = SelectPerson(self.dbstate, self.uistate, self.track)
130
163
        person = sel.run()
 
164
        self.update_person(person)
131
165
 
 
166
    def update_person(self, person):
132
167
        if person:
133
168
            self.obj.ref = person.get_handle()
134
169
            self.person_label.set_text(name_displayer.display(person))
 
170
        self._update_dnd_capability()
 
171
 
 
172
    def on_drag_persondata_received(self, widget, context, x, y, sel_data,
 
173
                                    info, time):
 
174
        """
 
175
        Handle the standard gtk interface for drag_data_received.
 
176
        """
 
177
        if sel_data and sel_data.get_data():
 
178
            (drag_type, idval, handle, val) = pickle.loads(sel_data.get_data())
 
179
            person = self.db.get_person_from_handle(handle)
 
180
            self.update_person(person)
 
181
        
 
182
    def drag_data_get(self, widget, context, sel_data, info, time):
 
183
        # get the selected object, returning if not is defined
 
184
        if info == DdTargets.PERSON_LINK.app_id:
 
185
            data = (DdTargets.PERSON_LINK.drag_type, id(self), self.obj.ref, 0)
 
186
            sel_data.set(DdTargets.PERSON_LINK.atom_drag_type, 8, pickle.dumps(data))
135
187
 
136
188
    def _create_tabbed_pages(self):
137
189
        """
177
229
            ErrorDialog(
178
230
                _('No person selected'),
179
231
                _('You must either select a person or Cancel '
180
 
                  'the edit'))
 
232
                  'the edit'),
 
233
                parent=self.window)