Merge lp:~submarine/unity-scope-isgd/isgd-previews into lp:unity-scope-isgd
- isgd-previews
- Merge into trunk
Status: | Approved |
---|---|
Approved by: | David Callé |
Approved revision: | 12 |
Proposed branch: | lp:~submarine/unity-scope-isgd/isgd-previews |
Merge into: | lp:unity-scope-isgd |
Diff against target: |
372 lines (+99/-108) 7 files modified
.bzrignore (+5/-0) data/isgd.scope.in (+3/-3) data/unity-scope-isgd.service (+1/-1) debian/control (+1/-1) po/unity-scope-isgd.pot (+20/-12) setup.py (+1/-1) src/unity_isgd_daemon.py (+68/-90) |
To merge this branch: | bzr merge lp:~submarine/unity-scope-isgd/isgd-previews |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
David Callé | Approve | ||
Review via email:
|
Commit message
Add Previews and Activation
Change from Utilities master scope to Info master scope
Description of the change
Add Previews and Activation
Change from Utilities master scope to Info master scope
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
James Henstridge (jamesh) wrote : | # |
+ description = '<big><b>' + self.result.title + "</b></big>\n\n"
+ description += _('is.gd is a free service for shortening web addresses and ')
+ description += _('other URLs. This is useful in many circumstances e.g. when ')
+ description += _('sending an address to a phone via SMS and character count is limited.\n\n')
+ description += _('Click the <i>Shorten url</i> button below to shorten <b>%s</b> ' % self.result.
+ description += _('and copy the shortened link to the clipboard, ready for pasting or the ')
+ description += _('<i>is.gd Preferences</i> button to visit is.gd\'s preferences ')
+ description += _('page.')
This is going to be a pain to translate, since the translator has 7 separate strings to translate. Can you do something like:
description = _(
'<big>
'...'
'Click the <i>Shorten url</i> button below to shorten <b>%(uri)s</b>'
'...') % dict(title=
It would be necessary to check that the string gets extracted correctly in the .pot file.
Unmerged revisions
- 12. By Mark Tully
-
Fix Previews and Activation
Change from Utilities master scope to Info master scope
Preview Diff
1 | === added file '.bzrignore' | |||
2 | --- .bzrignore 1970-01-01 00:00:00 +0000 | |||
3 | +++ .bzrignore 2013-04-20 13:47:26 +0000 | |||
4 | @@ -0,0 +1,5 @@ | |||
5 | 1 | *.log | ||
6 | 2 | *.substvars | ||
7 | 3 | ./build | ||
8 | 4 | ./debian/files | ||
9 | 5 | ./debian/unity-scope-isgd | ||
10 | 0 | 6 | ||
11 | === modified file 'data/isgd.scope.in' | |||
12 | --- data/isgd.scope.in 2013-03-15 17:29:22 +0000 | |||
13 | +++ data/isgd.scope.in 2013-04-20 13:47:26 +0000 | |||
14 | @@ -1,13 +1,13 @@ | |||
15 | 1 | [Scope] | 1 | [Scope] |
18 | 2 | DBusName=com.canonical.Unity.Scope.Utilities.Isgd | 2 | DBusName=com.canonical.Unity.Scope.Info.Isgd |
19 | 3 | DBusPath=/com/canonical/unity/scope/utilities/isgd | 3 | DBusPath=/com/canonical/unity/scope/info/isgd |
20 | 4 | Icon= | 4 | Icon= |
21 | 5 | _Keywords=isgd; | 5 | _Keywords=isgd; |
22 | 6 | RequiredMetadata= | 6 | RequiredMetadata= |
23 | 7 | OptionalMetadata= | 7 | OptionalMetadata= |
24 | 8 | Loader=/usr/share/unity-scopes/isgd/unity_isgd_daemon.py | 8 | Loader=/usr/share/unity-scopes/isgd/unity_isgd_daemon.py |
25 | 9 | RemoteContent=true | 9 | RemoteContent=true |
27 | 10 | Type=utilities | 10 | Type=info |
28 | 11 | _Name=Isgd | 11 | _Name=Isgd |
29 | 12 | _Description=Find Isgd items | 12 | _Description=Find Isgd items |
30 | 13 | _SearchHint=Search Isgd | 13 | _SearchHint=Search Isgd |
31 | 14 | 14 | ||
32 | === modified file 'data/unity-scope-isgd.service' | |||
33 | --- data/unity-scope-isgd.service 2013-03-14 12:28:39 +0000 | |||
34 | +++ data/unity-scope-isgd.service 2013-04-20 13:47:26 +0000 | |||
35 | @@ -1,3 +1,3 @@ | |||
36 | 1 | [D-BUS Service] | 1 | [D-BUS Service] |
38 | 2 | Name=com.canonical.Unity.Scope.Utilities.Isgd | 2 | Name=com.canonical.Unity.Scope.Info.Isgd |
39 | 3 | Exec=/usr/bin/python3 /usr/share/unity-scopes/scope-runner-dbus.py /usr/share/unity-scopes/isgd/unity_isgd_daemon.py | 3 | Exec=/usr/bin/python3 /usr/share/unity-scopes/scope-runner-dbus.py /usr/share/unity-scopes/isgd/unity_isgd_daemon.py |
40 | 4 | 4 | ||
41 | === modified file 'debian/control' | |||
42 | --- debian/control 2013-03-14 15:15:18 +0000 | |||
43 | +++ debian/control 2013-04-20 13:47:26 +0000 | |||
44 | @@ -19,7 +19,7 @@ | |||
45 | 19 | ${python3:Depends}, | 19 | ${python3:Depends}, |
46 | 20 | python3, | 20 | python3, |
47 | 21 | gir1.2-unity-5.0 (>= 6.8), | 21 | gir1.2-unity-5.0 (>= 6.8), |
49 | 22 | gir1.2-dee-1.0, | 22 | gir1.2-dee-1.0, |
50 | 23 | unity-scopes-runner, | 23 | unity-scopes-runner, |
51 | 24 | gir1.2-glib-2.0 | 24 | gir1.2-glib-2.0 |
52 | 25 | Description: isgd scope for Unity | 25 | Description: isgd scope for Unity |
53 | 26 | 26 | ||
54 | === modified file 'debian/rules' (properties changed: -x to +x) | |||
55 | === modified file 'po/unity-scope-isgd.pot' | |||
56 | --- po/unity-scope-isgd.pot 2013-02-21 00:56:47 +0000 | |||
57 | +++ po/unity-scope-isgd.pot 2013-04-20 13:47:26 +0000 | |||
58 | @@ -9,7 +9,7 @@ | |||
59 | 9 | msgstr "" | 9 | msgstr "" |
60 | 10 | "Project-Id-Version: PACKAGE VERSION\n" | 10 | "Project-Id-Version: PACKAGE VERSION\n" |
61 | 11 | "Report-Msgid-Bugs-To: \n" | 11 | "Report-Msgid-Bugs-To: \n" |
63 | 12 | "POT-Creation-Date: 2013-02-21 01:56+0100\n" | 12 | "POT-Creation-Date: 2013-04-18 01:13+0100\n" |
64 | 13 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | 13 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
65 | 14 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | 14 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
66 | 15 | "Language-Team: LANGUAGE <LL@li.org>\n" | 15 | "Language-Team: LANGUAGE <LL@li.org>\n" |
67 | @@ -30,55 +30,63 @@ | |||
68 | 30 | msgid "Shorten URL" | 30 | msgid "Shorten URL" |
69 | 31 | msgstr "" | 31 | msgstr "" |
70 | 32 | 32 | ||
72 | 33 | #: ../src/unity_isgd_daemon.py:79 | 33 | #: ../src/unity_isgd_daemon.py:80 |
73 | 34 | #, python-format | 34 | #, python-format |
74 | 35 | msgid "Shorten %s with is.gd" | 35 | msgid "Shorten %s with is.gd" |
75 | 36 | msgstr "" | 36 | msgstr "" |
76 | 37 | 37 | ||
78 | 38 | #: ../src/unity_isgd_daemon.py:101 | 38 | #: ../src/unity_isgd_daemon.py:105 |
79 | 39 | msgid "Copied shortened url to clipboard" | 39 | msgid "Copied shortened url to clipboard" |
80 | 40 | msgstr "" | 40 | msgstr "" |
81 | 41 | 41 | ||
83 | 42 | #: ../src/unity_isgd_daemon.py:101 | 42 | #: ../src/unity_isgd_daemon.py:105 |
84 | 43 | #, python-format | 43 | #, python-format |
85 | 44 | msgid "%s → %s" | 44 | msgid "%s → %s" |
86 | 45 | msgstr "" | 45 | msgstr "" |
87 | 46 | 46 | ||
89 | 47 | #: ../src/unity_isgd_daemon.py:125 | 47 | #: ../src/unity_isgd_daemon.py:117 |
90 | 48 | msgid "is.gd url shortener" | 48 | msgid "is.gd url shortener" |
91 | 49 | msgstr "" | 49 | msgstr "" |
92 | 50 | 50 | ||
94 | 51 | #: ../src/unity_isgd_daemon.py:127 | 51 | #: ../src/unity_isgd_daemon.py:120 |
95 | 52 | msgid "is.gd is a free service for shortening web addresses and " | 52 | msgid "is.gd is a free service for shortening web addresses and " |
96 | 53 | msgstr "" | 53 | msgstr "" |
97 | 54 | 54 | ||
99 | 55 | #: ../src/unity_isgd_daemon.py:128 | 55 | #: ../src/unity_isgd_daemon.py:121 |
100 | 56 | msgid "other URLs. This is useful in many circumstances e.g. when " | 56 | msgid "other URLs. This is useful in many circumstances e.g. when " |
101 | 57 | msgstr "" | 57 | msgstr "" |
102 | 58 | 58 | ||
104 | 59 | #: ../src/unity_isgd_daemon.py:129 | 59 | #: ../src/unity_isgd_daemon.py:122 |
105 | 60 | msgid "" | 60 | msgid "" |
106 | 61 | "sending an address to a phone via SMS and character count is limited.\n" | 61 | "sending an address to a phone via SMS and character count is limited.\n" |
107 | 62 | "\n" | 62 | "\n" |
108 | 63 | msgstr "" | 63 | msgstr "" |
109 | 64 | 64 | ||
111 | 65 | #: ../src/unity_isgd_daemon.py:130 | 65 | #: ../src/unity_isgd_daemon.py:123 |
112 | 66 | #, python-format | 66 | #, python-format |
113 | 67 | msgid "Click the <i>Shorten url</i> button below to shorten <b>%s</b> " | 67 | msgid "Click the <i>Shorten url</i> button below to shorten <b>%s</b> " |
114 | 68 | msgstr "" | 68 | msgstr "" |
115 | 69 | 69 | ||
117 | 70 | #: ../src/unity_isgd_daemon.py:131 | 70 | #: ../src/unity_isgd_daemon.py:124 |
118 | 71 | msgid "and copy the shortened link to the clipboard, ready for pasting or the " | 71 | msgid "and copy the shortened link to the clipboard, ready for pasting or the " |
119 | 72 | msgstr "" | 72 | msgstr "" |
120 | 73 | 73 | ||
122 | 74 | #: ../src/unity_isgd_daemon.py:132 | 74 | #: ../src/unity_isgd_daemon.py:125 |
123 | 75 | msgid "<i>is.gd Preferences</i> button to visit is.gd's preferences " | 75 | msgid "<i>is.gd Preferences</i> button to visit is.gd's preferences " |
124 | 76 | msgstr "" | 76 | msgstr "" |
125 | 77 | 77 | ||
127 | 78 | #: ../src/unity_isgd_daemon.py:133 | 78 | #: ../src/unity_isgd_daemon.py:126 |
128 | 79 | msgid "page." | 79 | msgid "page." |
129 | 80 | msgstr "" | 80 | msgstr "" |
130 | 81 | 81 | ||
131 | 82 | #: ../src/unity_isgd_daemon.py:128 | ||
132 | 83 | msgid "Shorten" | ||
133 | 84 | msgstr "" | ||
134 | 85 | |||
135 | 86 | #: ../src/unity_isgd_daemon.py:130 | ||
136 | 87 | msgid "Preferences" | ||
137 | 88 | msgstr "" | ||
138 | 89 | |||
139 | 82 | #: ../data/isgd.scope.in.h:1 | 90 | #: ../data/isgd.scope.in.h:1 |
140 | 83 | msgid "isgd;" | 91 | msgid "isgd;" |
141 | 84 | msgstr "" | 92 | msgstr "" |
142 | 85 | 93 | ||
143 | === modified file 'setup.py' | |||
144 | --- setup.py 2013-03-14 12:28:39 +0000 | |||
145 | +++ setup.py 2013-04-20 13:47:26 +0000 | |||
146 | @@ -16,7 +16,7 @@ | |||
147 | 16 | url='http://launchpad.net/ubuntu-scopes', | 16 | url='http://launchpad.net/ubuntu-scopes', |
148 | 17 | license='GNU General Public License (GPL)', | 17 | license='GNU General Public License (GPL)', |
149 | 18 | data_files=[('share/dbus-1/services', ['data/unity-scope-isgd.service']), | 18 | data_files=[('share/dbus-1/services', ['data/unity-scope-isgd.service']), |
151 | 19 | ('share/icons/unity-icon-theme/places/svg', ['data/icons/service-isgd.svg']), | 19 | #('share/icons/unity-icon-theme/places/svg', ['data/icons/service-isgd.svg']), |
152 | 20 | ('share/unity-scopes/isgd', ['src/unity_isgd_daemon.py']), | 20 | ('share/unity-scopes/isgd', ['src/unity_isgd_daemon.py']), |
153 | 21 | ('share/unity-scopes/isgd', ['src/__init__.py']), ], | 21 | ('share/unity-scopes/isgd', ['src/__init__.py']), ], |
154 | 22 | cmdclass={'build': build_extra.build_extra, | 22 | cmdclass={'build': build_extra.build_extra, |
155 | 23 | 23 | ||
156 | === modified file 'src/unity_isgd_daemon.py' | |||
157 | --- src/unity_isgd_daemon.py 2013-03-14 12:28:39 +0000 | |||
158 | +++ src/unity_isgd_daemon.py 2013-04-20 13:47:26 +0000 | |||
159 | @@ -18,6 +18,7 @@ | |||
160 | 18 | from gi.repository import Unity | 18 | from gi.repository import Unity |
161 | 19 | import gettext | 19 | import gettext |
162 | 20 | import urllib.request | 20 | import urllib.request |
163 | 21 | import urllib.parse | ||
164 | 21 | import json | 22 | import json |
165 | 22 | import subprocess | 23 | import subprocess |
166 | 23 | import webbrowser | 24 | import webbrowser |
167 | @@ -28,20 +29,20 @@ | |||
168 | 28 | gettext.textdomain(APP_NAME) | 29 | gettext.textdomain(APP_NAME) |
169 | 29 | _ = gettext.gettext | 30 | _ = gettext.gettext |
170 | 30 | 31 | ||
173 | 31 | GROUP_NAME = 'com.canonical.Unity.Scope.Utilities.Isgd' | 32 | GROUP_NAME = 'com.canonical.Unity.Scope.Info.Isgd' |
174 | 32 | UNIQUE_PATH = '/com/canonical/unity/scope/utilities/isgd' | 33 | UNIQUE_PATH = '/com/canonical/unity/scope/info/isgd' |
175 | 33 | 34 | ||
176 | 34 | SEARCH_HINT = _('Shorten URL with is.gd') | 35 | SEARCH_HINT = _('Shorten URL with is.gd') |
177 | 35 | NO_RESULTS_HINT = _('Sorry, there is no url to shorten') | 36 | NO_RESULTS_HINT = _('Sorry, there is no url to shorten') |
178 | 36 | PROVIDER_CREDITS = _('') | 37 | PROVIDER_CREDITS = _('') |
179 | 37 | SVG_DIR = '/usr/share/icons/unity-icon-theme/places/svg/' | 38 | SVG_DIR = '/usr/share/icons/unity-icon-theme/places/svg/' |
180 | 38 | PROVIDER_ICON = SVG_DIR + 'service-isgd.svg' | 39 | PROVIDER_ICON = SVG_DIR + 'service-isgd.svg' |
183 | 39 | DEFAULT_RESULT_ICON = SVG_DIR + 'result-help.svg' | 40 | DEFAULT_RESULT_ICON = SVG_DIR + 'result-isgd.svg' |
184 | 40 | DEFAULT_RESULT_MIMETYPE = 'x-scheme-handler/man' | 41 | DEFAULT_RESULT_MIMETYPE = 'text/html' |
185 | 41 | DEFAULT_RESULT_TYPE = Unity.ResultType.DEFAULT | 42 | DEFAULT_RESULT_TYPE = Unity.ResultType.DEFAULT |
186 | 42 | SEARCH_URI = 'http://is.gd/create.php?format=json&url=%s' | 43 | SEARCH_URI = 'http://is.gd/create.php?format=json&url=%s' |
187 | 43 | 44 | ||
189 | 44 | c1 = {'id': 'shorten', | 45 | c1 = {'id': 'results', |
190 | 45 | 'name': _('Shorten URL'), | 46 | 'name': _('Shorten URL'), |
191 | 46 | 'icon': SVG_DIR + 'group-installed.svg', | 47 | 'icon': SVG_DIR + 'group-installed.svg', |
192 | 47 | 'renderer': Unity.CategoryRenderer.VERTICAL_TILE} | 48 | 'renderer': Unity.CategoryRenderer.VERTICAL_TILE} |
193 | @@ -69,90 +70,63 @@ | |||
194 | 69 | try: | 70 | try: |
195 | 70 | urllib.request.urlopen(search) | 71 | urllib.request.urlopen(search) |
196 | 71 | real = True | 72 | real = True |
198 | 72 | except: | 73 | except IOError: |
199 | 73 | real = False | 74 | real = False |
200 | 74 | if real: | 75 | if real: |
201 | 75 | if not search.startswith("http://is.gd"): | 76 | if not search.startswith("http://is.gd"): |
202 | 76 | results.append({'uri': search, | 77 | results.append({'uri': search, |
207 | 77 | 'icon': '', | 78 | 'title': _("Shorten %s with is.gd" % search)}) |
204 | 78 | 'category': 0, | ||
205 | 79 | 'title': _("Shorten %s with is.gd" % search), | ||
206 | 80 | 'comment': ''}) | ||
208 | 81 | return results | 79 | return results |
209 | 82 | 80 | ||
210 | 83 | 81 | ||
212 | 84 | def activate(scope, uri): | 82 | def activate(result, metadata, action): |
213 | 85 | ''' | 83 | ''' |
214 | 86 | On activation, the url is shortened and the shortened version is | 84 | On activation, the url is shortened and the shortened version is |
215 | 87 | copied to the system clipboard. A notificatin is also displayed | 85 | copied to the system clipboard. A notificatin is also displayed |
216 | 88 | letting the user know what has happened. | 86 | letting the user know what has happened. |
217 | 89 | ''' | 87 | ''' |
284 | 90 | # FIXME: Activate is not yet implemented | 88 | if action == 'preferences': |
285 | 91 | search_url = SEARCH_URI % urllib.quote(uri) | 89 | webbrowser.open('http://is.gd/previews.php') |
286 | 92 | response = urllib.request.urlopen(search_url).read() | 90 | else: |
287 | 93 | try: | 91 | search_url = SEARCH_URI % urllib.parse.quote(result.uri) |
288 | 94 | json_response = json.loads(response) | 92 | response = urllib.request.urlopen(search_url).read() |
289 | 95 | except: | 93 | json_response = json.loads(response.decode('utf8')) |
290 | 96 | result = None | 94 | clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) |
291 | 97 | clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) | 95 | clipboard.set_text(json_response['shorturl'], -1) |
292 | 98 | clipboard.set_text(json_response['shorturl'], -1) | 96 | clipboard.store() |
293 | 99 | clipboard.store() | 97 | subprocess.Popen(["notify-send", |
294 | 100 | 98 | _("Copied shortened url to clipboard"), | |
295 | 101 | subprocess.Popen(["notify-send", _("Copied shortened url to clipboard"), _("%s → %s" % (uri, json_response['shorturl'])), "-i", SERVICE_ICON_LOCATION]) | 99 | _("%s → %s" % (result.uri, json_response['shorturl'])), |
296 | 102 | return Unity.ActivationResponse(handled=Unity.HandledType.HIDE_DASH, goto_uri='') | 100 | "-i", |
297 | 103 | 101 | DEFAULT_RESULT_ICON]) | |
298 | 104 | 102 | return Unity.ActivationResponse(handled=Unity.HandledType.HIDE_DASH, goto_uri='') | |
299 | 105 | def visit_prefs(scope, uri): | 103 | |
300 | 106 | ''' | 104 | |
301 | 107 | Open the webbrowser to is.gd's preferences page | 105 | class Preview(Unity.ResultPreviewer): |
302 | 108 | ''' | 106 | ''' |
303 | 109 | webbrowser.open('http://is.gd/previews.php') | 107 | Creates the preview for the result |
304 | 110 | return Unity.ActivationResponse(handled=Unity.HandledType.HIDE_DASH, goto_uri='') | 108 | ''' |
305 | 111 | 109 | def do_run(self): | |
306 | 112 | 110 | ''' | |
307 | 113 | def preview(scope, uri): | 111 | Create a preview and return it |
308 | 114 | ''' | 112 | ''' |
309 | 115 | Preview request handler | 113 | preview = Unity.GenericPreview.new(_("is.gd url shortener"), '', None) |
310 | 116 | ''' | 114 | preview.props.image_source_uri = 'file://%s' % self.result.icon_hint |
311 | 117 | # FIXME: Preview is not yet implemented | 115 | description = '<big><b>' + self.result.title + "</b></big>\n\n" |
312 | 118 | model = self.model | 116 | description += _('is.gd is a free service for shortening web addresses and ') |
313 | 119 | iteration = model.get_first_iter() | 117 | description += _('other URLs. This is useful in many circumstances e.g. when ') |
314 | 120 | end_iter = model.get_last_iter() | 118 | description += _('sending an address to a phone via SMS and character count is limited.\n\n') |
315 | 121 | preview = None | 119 | description += _('Click the <i>Shorten url</i> button below to shorten <b>%s</b> ' % self.result.uri.replace('&', '&')) |
316 | 122 | while iteration != end_iter: | 120 | description += _('and copy the shortened link to the clipboard, ready for pasting or the ') |
317 | 123 | if model.get_value(iteration, 0) == uri: | 121 | description += _('<i>is.gd Preferences</i> button to visit is.gd\'s preferences ') |
318 | 124 | display_uri = uri.replace('&', '&') | 122 | description += _('page.') |
319 | 125 | title = _("is.gd url shortener") | 123 | preview.props.description_markup = description |
320 | 126 | description = '<big><b>' + model.get_value(iteration, 5) + "</b></big>\n\n" | 124 | shorten_action = Unity.PreviewAction.new("shorten", _("Shorten url"), None) |
321 | 127 | description += _('is.gd is a free service for shortening web addresses and ') | 125 | preview.add_action(shorten_action) |
322 | 128 | description += _('other URLs. This is useful in many circumstances e.g. when ') | 126 | preferences_action = Unity.PreviewAction.new("preferences", _("isgd Preferences"), None) |
323 | 129 | description += _('sending an address to a phone via SMS and character count is limited.\n\n') | 127 | preview.add_action(preferences_action) |
324 | 130 | description += _('Click the <i>Shorten url</i> button below to shorten <b>%s</b> ' % display_uri) | 128 | return preview |
325 | 131 | description += _('and copy the shortened link to the clipboard, ready for pasting or the ') | 129 | |
260 | 132 | description += _('<i>is.gd Preferences</i> button to visit is.gd\'s preferences ') | ||
261 | 133 | description += _('page.') | ||
262 | 134 | |||
263 | 135 | icon_hint = SVG_DIR + 'isgd.png' | ||
264 | 136 | # Assemble the preview | ||
265 | 137 | preview = Unity.GenericPreview.new(title, description, None) | ||
266 | 138 | preview.props.image_source_uri = icon_hint | ||
267 | 139 | preview.props.subtitle = model.get_value(iteration, 5) | ||
268 | 140 | |||
269 | 141 | # Add the "View" action | ||
270 | 142 | view_action = Unity.PreviewAction.new("activate_uri", "Shorten url", None) | ||
271 | 143 | view_action.connect("activated", activate) | ||
272 | 144 | preview.add_action(view_action) | ||
273 | 145 | |||
274 | 146 | # Add the "View" action | ||
275 | 147 | view_action = Unity.PreviewAction.new("visit_prefs", "is.gd Preferences", None) | ||
276 | 148 | view_action.connect("activated", visit_prefs) | ||
277 | 149 | preview.add_action(view_action) | ||
278 | 150 | break | ||
279 | 151 | |||
280 | 152 | iteration = model.next(iteration) | ||
281 | 153 | if preview is None: | ||
282 | 154 | print ("Couldn't find model row for requested preview uri: '%s'", uri) | ||
283 | 155 | return preview | ||
326 | 156 | 130 | ||
327 | 157 | # Classes below this point establish communication | 131 | # Classes below this point establish communication |
328 | 158 | # with Unity, you probably shouldn't modify them. | 132 | # with Unity, you probably shouldn't modify them. |
329 | @@ -187,19 +161,8 @@ | |||
330 | 187 | i['comment'] = '' | 161 | i['comment'] = '' |
331 | 188 | if not 'dnd_uri' in i or not i['dnd_uri'] or i['dnd_uri'] == '': | 162 | if not 'dnd_uri' in i or not i['dnd_uri'] or i['dnd_uri'] == '': |
332 | 189 | i['dnd_uri'] = i['uri'] | 163 | i['dnd_uri'] = i['uri'] |
346 | 190 | i['metadata'] = {} | 164 | i['provider_credits'] = GLib.Variant('s', PROVIDER_CREDITS) |
347 | 191 | if EXTRA_METADATA: | 165 | result_set.add_result(**i) |
335 | 192 | for e in i: | ||
336 | 193 | for m in EXTRA_METADATA: | ||
337 | 194 | if m['id'] == e: | ||
338 | 195 | i['metadata'][e] = i[e] | ||
339 | 196 | i['metadata']['provider_credits'] = GLib.Variant('s', PROVIDER_CREDITS) | ||
340 | 197 | result = Unity.ScopeResult.create(str(i['uri']), str(i['icon']), | ||
341 | 198 | i['category'], i['result_type'], | ||
342 | 199 | str(i['mimetype']), str(i['title']), | ||
343 | 200 | str(i['comment']), str(i['dnd_uri']), | ||
344 | 201 | i['metadata']) | ||
345 | 202 | result_set.add_result(result) | ||
348 | 203 | except Exception as error: | 166 | except Exception as error: |
349 | 204 | print(error) | 167 | print(error) |
350 | 205 | 168 | ||
351 | @@ -255,6 +218,21 @@ | |||
352 | 255 | se = MySearch(search_context) | 218 | se = MySearch(search_context) |
353 | 256 | return se | 219 | return se |
354 | 257 | 220 | ||
355 | 221 | def do_activate(self, result, metadata, action): | ||
356 | 222 | ''' | ||
357 | 223 | What to do when a resut is clicked | ||
358 | 224 | ''' | ||
359 | 225 | return activate(result, metadata, action) | ||
360 | 226 | |||
361 | 227 | def do_create_previewer(self, result, metadata): | ||
362 | 228 | ''' | ||
363 | 229 | Creates a preview when a resut is right-clicked | ||
364 | 230 | ''' | ||
365 | 231 | result_preview = Preview() | ||
366 | 232 | result_preview.set_scope_result(result) | ||
367 | 233 | result_preview.set_search_metadata(metadata) | ||
368 | 234 | return result_preview | ||
369 | 235 | |||
370 | 258 | 236 | ||
371 | 259 | def load_scope(): | 237 | def load_scope(): |
372 | 260 | return Scope() | 238 | return Scope() |
+1