Merge lp:~jamesh/unity-scope-sshsearch/preview into lp:unity-scope-sshsearch

Proposed by James Henstridge
Status: Merged
Approved by: James Henstridge
Approved revision: 10
Merged at revision: 10
Proposed branch: lp:~jamesh/unity-scope-sshsearch/preview
Merge into: lp:unity-scope-sshsearch
Diff against target: 59 lines (+24/-1)
2 files modified
src/unity_sshsearch_daemon.py (+16/-1)
tests/test_sshsearch.py (+8/-0)
To merge this branch: bzr merge lp:~jamesh/unity-scope-sshsearch/preview
Reviewer Review Type Date Requested Status
David Callé (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+163268@code.launchpad.net

Commit message

Add a preview to the sshsearch scope.

Description of the change

Add a preview to the sshsearch scope.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
David Callé (davidc3) wrote :

Works well +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/unity_sshsearch_daemon.py'
2--- src/unity_sshsearch_daemon.py 2013-03-18 17:55:45 +0000
3+++ src/unity_sshsearch_daemon.py 2013-05-10 06:30:33 +0000
4@@ -44,7 +44,7 @@
5 KNOWN_HOSTS_EXPAND = os.path.expanduser(KNOWN_HOSTS)
6
7 TERMINAL_APP = 'gnome-terminal'
8-TERMINAL_APP_MIMETYPE = 'application-x-desktop'
9+TERMINAL_APP_MIMETYPE = 'application/x-desktop'
10
11
12 class Daemon:
13@@ -62,6 +62,7 @@
14 self.preferences.connect('notify::remote-content-search', self._on_preference_changed)
15 self.scope.connect('search-changed', self.on_search_changed)
16 self.scope.connect("activate-uri", self.on_activate_uri)
17+ self.scope.connect("preview-uri", self.on_preview_uri)
18 self.scope.export()
19
20 def __read_config(self, filemonitor, file, other_file, event_type):
21@@ -183,6 +184,20 @@
22
23 return Unity.ActivationResponse(handled=Unity.HandledType.HIDE_DASH, goto_uri='')
24
25+ def on_preview_uri(self, scope, uri):
26+ uri_splitted = uri.split('/')
27+ hoststring = uri_splitted[-1]
28+ user = uri_splitted[-2]
29+ target, port, conn_desc = self.__parse_hoststring(hoststring, user)
30+
31+ image = Gio.ThemedIcon.new(TERMINAL_APP)
32+ preview = Unity.GenericPreview.new(conn_desc, '', image)
33+ action = Unity.PreviewAction.new("open", _("Connect"), None)
34+ action.connect("activated", self.on_activate_uri)
35+ preview.add_action(action)
36+ return preview
37+
38+
39 if __name__ == '__main__':
40 daemon = UnityExtras.dbus_own_name(BUS_NAME, Daemon, None)
41 if daemon:
42
43=== modified file 'tests/test_sshsearch.py'
44--- tests/test_sshsearch.py 2013-01-28 01:50:41 +0000
45+++ tests/test_sshsearch.py 2013-05-10 06:30:33 +0000
46@@ -36,5 +36,13 @@
47 scope.Daemon.update_results_model(d, searches[0], model)
48 self.assertEqual(len(model), 0)
49
50+ def test_preview(self):
51+ scope.KNOWN_HOSTS_EXPAND = mock_data['should_pass']
52+ preview = d.on_preview_uri(None, "ssh://config//192.168.1.2")
53+ self.assertEqual(preview.props.title, "192.168.1.2")
54+ self.assertNotEqual(preview.props.image, None)
55+ self.assertEqual(preview.props.image.get_names(), ['gnome-terminal'])
56+
57+
58 if __name__ == '__main__':
59 main()

Subscribers

People subscribed via source and target branches

to all changes: