Merge lp:~spud/spud/copy-paste-fix into lp:spud

Proposed by Fraser Waters
Status: Merged
Merged at revision: 417
Proposed branch: lp:~spud/spud/copy-paste-fix
Merge into: lp:spud
Diff against target: 37 lines (+20/-0)
1 file modified
diamond/diamond/interface.py (+20/-0)
To merge this branch: bzr merge lp:~spud/spud/copy-paste-fix
Reviewer Review Type Date Requested Status
Stephan Kramer Approve
Review via email: mp+67851@code.launchpad.net

Description of the change

Copy paste signals were being swallowed by treeview and not going to other controls. This branch fixes that so the focused control gets copy paste signals.

To post a comment you must log in.
Revision history for this message
Stephan Kramer (s-kramer) wrote :

Just tried out your fix. Everything works again as expected. Thanks

Revision history for this message
Stephan Kramer (s-kramer) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'diamond/diamond/interface.py'
2--- diamond/diamond/interface.py 2011-07-11 11:11:00 +0000
3+++ diamond/diamond/interface.py 2011-07-13 15:52:44 +0000
4@@ -644,7 +644,21 @@
5 clipboard.set_text(name)
6 clipboard.store()
7
8+ def _get_focus_widget(self, parent):
9+ """Gets the widget that is a child of parent with the focus."""
10+ focus = parent.get_focus_child()
11+ if focus is None or (focus.flags() & gtk.HAS_FOCUS):
12+ return focus
13+ else:
14+ return self._get_focus_widget(focus)
15+
16 def on_copy(self, widget=None):
17+
18+ widget = self._get_focus_widget(self.main_window)
19+ if widget is not self.treeview and gobject.signal_lookup("copy-clipboard", widget):
20+ widget.emit("copy-clipboard")
21+ return
22+
23 if isinstance(self.selected_node, MixedTree):
24 node = self.selected_node.parent
25 else:
26@@ -662,6 +676,12 @@
27 return
28
29 def on_paste(self, widget=None):
30+
31+ widget = self._get_focus_widget(self.main_window)
32+ if widget is not self.treeview and gobject.signal_lookup("paste-clipboard", widget):
33+ widget.emit("paste-clipboard")
34+ return
35+
36 clipboard = gtk.clipboard_get()
37 ios = StringIO.StringIO(clipboard.wait_for_text())
38

Subscribers

People subscribed via source and target branches