Merge lp:~voldyman/granite/contractor-wid-dep-new-Contractor into lp:~elementary-pantheon/granite/granite
- contractor-wid-dep-new-Contractor
- Merge into granite
Proposed by
Akshay Shekher
Status: | Superseded |
---|---|
Proposed branch: | lp:~voldyman/granite/contractor-wid-dep-new-Contractor |
Merge into: | lp:~elementary-pantheon/granite/granite |
Diff against target: |
649 lines (+200/-134) 4 files modified
demo/main.vala (+11/-38) lib/Services/Contractor.vala (+146/-55) lib/Widgets/ContractorMenu.vala (+14/-13) lib/Widgets/ContractorView.vala (+29/-28) |
To merge this branch: | bzr merge lp:~voldyman/granite/contractor-wid-dep-new-Contractor |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Sergey "Shnatsel" Davidoff (community) | Needs Fixing | ||
Review via email: mp+158154@code.launchpad.net |
This proposal has been superseded by a proposal from 2013-04-10.
Commit message
Description of the change
the contractor widgets have been deprecated and the Services/
To post a comment you must log in.
Revision history for this message
Sergey "Shnatsel" Davidoff (shnatsel) wrote : | # |
review:
Needs Fixing
- 557. By Akshay Shekher
-
Deprecated ContractorView and ContractorMenu. Added support for the new contractor API in services/
Contractor. vala - 558. By Akshay Shekher
-
Change the constructor of Contractor.vala to private
- 559. By Akshay Shekher
-
Changed GenericContract to ContractorContract and renamed arguments
- 560. By Akshay Shekher
-
fixed coding style
- 561. By Akshay Shekher
-
More OO contractor interface
Unmerged revisions
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'demo/main.vala' | |||
2 | --- demo/main.vala 2013-03-20 15:42:25 +0000 | |||
3 | +++ demo/main.vala 2013-04-10 16:09:20 +0000 | |||
4 | @@ -13,7 +13,7 @@ | |||
5 | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
6 | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
7 | 15 | Lesser General Public License for more details. | 15 | Lesser General Public License for more details. |
9 | 16 | 16 | ||
10 | 17 | You should have received a copy of the GNU Lesser General | 17 | You should have received a copy of the GNU Lesser General |
11 | 18 | Public License along with this library; if not, write to the | 18 | Public License along with this library; if not, write to the |
12 | 19 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
13 | @@ -275,33 +275,6 @@ | |||
14 | 275 | right_sep.draw = false; | 275 | right_sep.draw = false; |
15 | 276 | right_sep.set_expand (true); | 276 | right_sep.set_expand (true); |
16 | 277 | main_toolbar.insert (right_sep, -1); | 277 | main_toolbar.insert (right_sep, -1); |
17 | 278 | |||
18 | 279 | // Contractor | ||
19 | 280 | var contractor_tab = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); | ||
20 | 281 | var text_view = new Gtk.TextView (); | ||
21 | 282 | |||
22 | 283 | var hash_tables = Granite.Services.Contractor.get_contract ("/.zip", "application/zip"); | ||
23 | 284 | foreach (var hash_table in hash_tables) { | ||
24 | 285 | text_view.buffer.text += hash_table.lookup ("Name") | ||
25 | 286 | + ": " + hash_table.lookup ("Description") | ||
26 | 287 | + " icon: " + hash_table.lookup ("Exec") + "\n"; | ||
27 | 288 | } | ||
28 | 289 | |||
29 | 290 | contractor_tab.add (text_view); | ||
30 | 291 | contractor_tab.add (new Granite.Widgets.ContractorView ("file:///home/user/file.txt", "text/plain")); | ||
31 | 292 | var contractor_menu = new Granite.Widgets.ContractorMenu ("/home/user/file.txt", "text"); | ||
32 | 293 | var contractor_button_image = new Gtk.Image.from_icon_name ("document-export", | ||
33 | 294 | Gtk.IconSize.LARGE_TOOLBAR); | ||
34 | 295 | var contractor_tool_item = new Granite.Widgets.ToolButtonWithMenu (contractor_button_image, | ||
35 | 296 | "Share", contractor_menu); | ||
36 | 297 | main_toolbar.insert (contractor_tool_item, -1); | ||
37 | 298 | |||
38 | 299 | contractor_tool_item.halign = contractor_tool_item.valign = Gtk.Align.CENTER; | ||
39 | 300 | |||
40 | 301 | var contractor_item = new SourceListItem ("Contractor"); | ||
41 | 302 | contractor_item.page_num = page_switcher.append_page (contractor_tab, null); | ||
42 | 303 | services_category.add (contractor_item); | ||
43 | 304 | |||
44 | 305 | // Search Entry | 278 | // Search Entry |
45 | 306 | var search_entry = new Granite.Widgets.SearchBar ("Search"); | 279 | var search_entry = new Granite.Widgets.SearchBar ("Search"); |
46 | 307 | var search_item = new Gtk.ToolItem (); | 280 | var search_item = new Gtk.ToolItem (); |
47 | @@ -343,42 +316,42 @@ | |||
48 | 343 | 316 | ||
49 | 344 | private void show_light_window () { | 317 | private void show_light_window () { |
50 | 345 | var light_window = new Granite.Widgets.LightWindow (); | 318 | var light_window = new Granite.Widgets.LightWindow (); |
52 | 346 | 319 | ||
53 | 347 | var light_window_notebook = new Granite.Widgets.StaticNotebook (); | 320 | var light_window_notebook = new Granite.Widgets.StaticNotebook (); |
54 | 348 | var entry = new Gtk.Entry (); | 321 | var entry = new Gtk.Entry (); |
55 | 349 | var open_drop = new Gtk.ComboBoxText (); | 322 | var open_drop = new Gtk.ComboBoxText (); |
56 | 350 | var open_lbl = new LLabel ("Alwas Open Mpeg Video Files with Audience"); | 323 | var open_lbl = new LLabel ("Alwas Open Mpeg Video Files with Audience"); |
58 | 351 | 324 | ||
59 | 352 | var grid = new Gtk.Grid (); | 325 | var grid = new Gtk.Grid (); |
60 | 353 | grid.attach (new Gtk.Image.from_icon_name ("video-x-generic", Gtk.IconSize.DIALOG), 0, 0, 1, 2); | 326 | grid.attach (new Gtk.Image.from_icon_name ("video-x-generic", Gtk.IconSize.DIALOG), 0, 0, 1, 2); |
61 | 354 | grid.attach (entry, 1, 0, 1, 1); | 327 | grid.attach (entry, 1, 0, 1, 1); |
62 | 355 | grid.attach (new LLabel ("1.13 GB, Mpeg Video File"), 1, 1, 1, 1); | 328 | grid.attach (new LLabel ("1.13 GB, Mpeg Video File"), 1, 1, 1, 1); |
64 | 356 | 329 | ||
65 | 357 | grid.attach (light_window_notebook, 0, 2, 2, 1); | 330 | grid.attach (light_window_notebook, 0, 2, 2, 1); |
67 | 358 | 331 | ||
68 | 359 | var general = new Gtk.Grid (); | 332 | var general = new Gtk.Grid (); |
69 | 360 | general.attach (new LLabel.markup ("<b>Info:</b>"), 0, 0, 2, 1); | 333 | general.attach (new LLabel.markup ("<b>Info:</b>"), 0, 0, 2, 1); |
71 | 361 | 334 | ||
72 | 362 | general.attach (new LLabel.right ("Created:"), 0, 1, 1, 1); | 335 | general.attach (new LLabel.right ("Created:"), 0, 1, 1, 1); |
73 | 363 | general.attach (new LLabel.right ("Modified:"), 0, 2, 1, 1); | 336 | general.attach (new LLabel.right ("Modified:"), 0, 2, 1, 1); |
74 | 364 | general.attach (new LLabel.right ("Opened:"), 0, 3, 1, 1); | 337 | general.attach (new LLabel.right ("Opened:"), 0, 3, 1, 1); |
75 | 365 | general.attach (new LLabel.right ("Mimetype:"), 0, 4, 1, 1); | 338 | general.attach (new LLabel.right ("Mimetype:"), 0, 4, 1, 1); |
76 | 366 | general.attach (new LLabel.right ("Location:"), 0, 5, 1, 1); | 339 | general.attach (new LLabel.right ("Location:"), 0, 5, 1, 1); |
78 | 367 | 340 | ||
79 | 368 | general.attach (new LLabel ("Today at 9:50 PM"), 1, 1, 1, 1); | 341 | general.attach (new LLabel ("Today at 9:50 PM"), 1, 1, 1, 1); |
80 | 369 | general.attach (new LLabel ("Today at 9:50 PM"), 1, 2, 1, 1); | 342 | general.attach (new LLabel ("Today at 9:50 PM"), 1, 2, 1, 1); |
81 | 370 | general.attach (new LLabel ("Today at 10:00 PM"), 1, 3, 1, 1); | 343 | general.attach (new LLabel ("Today at 10:00 PM"), 1, 3, 1, 1); |
82 | 371 | general.attach (new LLabel ("video/mpeg"), 1, 4, 1, 1); | 344 | general.attach (new LLabel ("video/mpeg"), 1, 4, 1, 1); |
83 | 372 | general.attach (new LLabel ("/home/daniel/Downloads"), 1, 5, 1, 1); | 345 | general.attach (new LLabel ("/home/daniel/Downloads"), 1, 5, 1, 1); |
85 | 373 | 346 | ||
86 | 374 | general.attach (new LLabel.markup ("<b>Open with:</b>"), 0, 6, 2, 1); | 347 | general.attach (new LLabel.markup ("<b>Open with:</b>"), 0, 6, 2, 1); |
87 | 375 | general.attach (open_drop, 0, 7, 2, 1); | 348 | general.attach (open_drop, 0, 7, 2, 1); |
88 | 376 | general.attach (open_lbl, 0, 8, 2, 1); | 349 | general.attach (open_lbl, 0, 8, 2, 1); |
90 | 377 | 350 | ||
91 | 378 | light_window_notebook.append_page (general, new Gtk.Label ("General")); | 351 | light_window_notebook.append_page (general, new Gtk.Label ("General")); |
92 | 379 | light_window_notebook.append_page (new Gtk.Label ("More"), new Gtk.Label ("More")); | 352 | light_window_notebook.append_page (new Gtk.Label ("More"), new Gtk.Label ("More")); |
93 | 380 | light_window_notebook.append_page (new Gtk.Label ("Sharing"), new Gtk.Label ("Sharing")); | 353 | light_window_notebook.append_page (new Gtk.Label ("Sharing"), new Gtk.Label ("Sharing")); |
95 | 381 | 354 | ||
96 | 382 | open_lbl.margin_left = 24; | 355 | open_lbl.margin_left = 24; |
97 | 383 | open_drop.margin_left = 12; | 356 | open_drop.margin_left = 12; |
98 | 384 | open_drop.append ("audience", "Audience"); | 357 | open_drop.append ("audience", "Audience"); |
99 | @@ -389,7 +362,7 @@ | |||
100 | 389 | entry.text = "Cool Hand Luke"; | 362 | entry.text = "Cool Hand Luke"; |
101 | 390 | general.column_spacing = 6; | 363 | general.column_spacing = 6; |
102 | 391 | general.row_spacing = 6; | 364 | general.row_spacing = 6; |
104 | 392 | 365 | ||
105 | 393 | light_window.add (grid); | 366 | light_window.add (grid); |
106 | 394 | light_window.show_all (); | 367 | light_window.show_all (); |
107 | 395 | } | 368 | } |
108 | 396 | 369 | ||
109 | === modified file 'lib/Services/Contractor.vala' | |||
110 | --- lib/Services/Contractor.vala 2013-04-04 20:05:38 +0000 | |||
111 | +++ lib/Services/Contractor.vala 2013-04-10 16:09:20 +0000 | |||
112 | @@ -1,5 +1,6 @@ | |||
113 | 1 | /*** | 1 | /*** |
115 | 2 | Copyright (C) 2011-2013 Lucas Baudin <xapantu@gmail.com> | 2 | Copyright (C) 2011-2013 Lucas Baudin <xapantu@gmail.com>, |
116 | 3 | Akshay Shekher <voldyman666@gmail.com> | ||
117 | 3 | 4 | ||
118 | 4 | This program or library is free software; you can redistribute it | 5 | This program or library is free software; you can redistribute it |
119 | 5 | and/or modify it under the terms of the GNU Lesser General Public | 6 | and/or modify it under the terms of the GNU Lesser General Public |
120 | @@ -10,7 +11,7 @@ | |||
121 | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
122 | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
123 | 12 | Lesser General Public License for more details. | 13 | Lesser General Public License for more details. |
125 | 13 | 14 | ||
126 | 14 | You should have received a copy of the GNU Lesser General | 15 | You should have received a copy of the GNU Lesser General |
127 | 15 | Public License along with this library; if not, write to the | 16 | Public License along with this library; if not, write to the |
128 | 16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
129 | @@ -19,86 +20,176 @@ | |||
130 | 19 | 20 | ||
131 | 20 | namespace Granite.Services { | 21 | namespace Granite.Services { |
132 | 21 | 22 | ||
136 | 22 | [DBus (name = "org.elementary.contractor")] | 23 | public struct GenericContract { |
137 | 23 | interface ContractorDBus : Object | 24 | string id; |
138 | 24 | { | 25 | string display_name; |
139 | 26 | string description; | ||
140 | 27 | string icon_path; | ||
141 | 28 | } | ||
142 | 29 | |||
143 | 30 | [DBus (name = "org.elementary.Contractor")] | ||
144 | 31 | interface ContractorDBus : Object { | ||
145 | 32 | public abstract GenericContract[] list_all_contracts () throws Error; | ||
146 | 33 | public abstract GenericContract[] get_contracts_by_mime (string mime_type) throws Error; | ||
147 | 34 | public abstract GenericContract[] get_contracts_by_mimelist (string[] mime_types) throws Error; | ||
148 | 35 | public abstract int execute_with_uri (string id, string path) throws Error; | ||
149 | 36 | public abstract int execute_with_uri_list (string id, string[] path) throws Error; | ||
150 | 37 | [Deprecated] | ||
151 | 25 | public abstract GLib.HashTable<string,string>[] GetServicesByLocation (string strlocation, string? file_mime="") throws IOError; | 38 | public abstract GLib.HashTable<string,string>[] GetServicesByLocation (string strlocation, string? file_mime="") throws IOError; |
152 | 39 | [Deprecated] | ||
153 | 26 | public abstract GLib.HashTable<string,string>[] GetServicesByLocationsList (GLib.HashTable<string,string>[] locations) throws IOError; | 40 | public abstract GLib.HashTable<string,string>[] GetServicesByLocationsList (GLib.HashTable<string,string>[] locations) throws IOError; |
154 | 27 | } | 41 | } |
155 | 28 | 42 | ||
156 | 29 | /** | 43 | /** |
157 | 30 | * A way to handle contractor, a way to communicate between apps. | 44 | * A way to handle contractor, a way to communicate between apps. |
160 | 31 | * | 45 | * |
159 | 32 | * /!\ Highly unstable API | ||
161 | 33 | */ | 46 | */ |
164 | 34 | public class Contractor : Object | 47 | public class Contractor : Object { |
163 | 35 | { | ||
165 | 36 | 48 | ||
166 | 37 | internal ContractorDBus contract; | 49 | internal ContractorDBus contract; |
167 | 38 | 50 | ||
168 | 39 | internal static Contractor? contractor = null; | 51 | internal static Contractor? contractor = null; |
169 | 40 | 52 | ||
170 | 41 | /** | 53 | /** |
172 | 42 | * This creates a new Contractor | 54 | * This creates a new Contractor |
173 | 43 | */ | 55 | */ |
178 | 44 | public Contractor() | 56 | public Contractor () { |
179 | 45 | { | 57 | try { |
176 | 46 | try | ||
177 | 47 | { | ||
180 | 48 | contract = Bus.get_proxy_sync (BusType.SESSION, | 58 | contract = Bus.get_proxy_sync (BusType.SESSION, |
182 | 49 | "org.elementary.contractor", | 59 | "org.elementary.Contractor", |
183 | 50 | "/org/elementary/contractor"); | 60 | "/org/elementary/contractor"); |
199 | 51 | } | 61 | } catch (IOError e) { |
200 | 52 | catch (IOError e) | 62 | stderr.printf ("%s\n", e.message); |
201 | 53 | { | 63 | } |
202 | 54 | stderr.printf ("%s\n", e.message); | 64 | } |
203 | 55 | } | 65 | |
204 | 56 | } | 66 | internal static void ensure () { |
205 | 57 | 67 | if (contractor == null) { | |
206 | 58 | internal static void ensure () | 68 | contractor = new Contractor (); |
207 | 59 | { | 69 | } |
208 | 60 | if(contractor == null) contractor = new Contractor (); | 70 | } |
209 | 61 | } | 71 | /** |
210 | 62 | 72 | * Lists all the contracts | |
211 | 63 | /** | 73 | * |
212 | 64 | * This searches for available contracts of a particular file | 74 | * @return an array of struct GenericContract |
213 | 65 | * | 75 | */ |
214 | 76 | public static GenericContract[] list_all_contracts () { | ||
215 | 77 | ensure (); | ||
216 | 78 | GenericContract[] contracts = null; | ||
217 | 79 | |||
218 | 80 | try { | ||
219 | 81 | contracts = contractor.contract.list_all_contracts (); | ||
220 | 82 | } catch (Error e) { | ||
221 | 83 | stderr.printf ("%s\n", e.message); | ||
222 | 84 | } | ||
223 | 85 | |||
224 | 86 | return contracts; | ||
225 | 87 | } | ||
226 | 88 | /** | ||
227 | 89 | * This searches for available contracts of a particular file | ||
228 | 90 | * | ||
229 | 91 | * @param mime mime type of file | ||
230 | 92 | * @return an array of struct GenericContract | ||
231 | 93 | */ | ||
232 | 94 | public static GenericContract[] get_contracts_by_mime (string mime_type) { | ||
233 | 95 | ensure (); | ||
234 | 96 | GenericContract[] contracts = null; | ||
235 | 97 | |||
236 | 98 | try { | ||
237 | 99 | contracts = contractor.contract.get_contracts_by_mime (mime_type); | ||
238 | 100 | } catch (IOError e) { | ||
239 | 101 | stderr.printf ("%s\n", e.message); | ||
240 | 102 | } | ||
241 | 103 | |||
242 | 104 | return contracts; | ||
243 | 105 | } | ||
244 | 106 | |||
245 | 107 | /** | ||
246 | 108 | * generate contracts for a list of mime types. the contracts which support | ||
247 | 109 | * all of them are returned | ||
248 | 110 | * | ||
249 | 111 | * @param locations Array of MimeTypes | ||
250 | 112 | * @return array of struct (GenericContract) | ||
251 | 113 | */ | ||
252 | 114 | public static GenericContract[] get_contracts_by_mimelist (string[] mime_types) { | ||
253 | 115 | ensure (); | ||
254 | 116 | GenericContract[] contracts = null; | ||
255 | 117 | |||
256 | 118 | try { | ||
257 | 119 | contracts = contractor.contract.get_contracts_by_mimelist (mime_types); | ||
258 | 120 | } catch (IOError e) { | ||
259 | 121 | stderr.printf ("%s\n", e.message); | ||
260 | 122 | } | ||
261 | 123 | |||
262 | 124 | return contracts; | ||
263 | 125 | } | ||
264 | 126 | /** | ||
265 | 127 | * This executes the exec parameter provided by the contract of given id | ||
266 | 128 | * with the path as arguments | ||
267 | 129 | * | ||
268 | 130 | * @param id id of the contract | ||
269 | 131 | * @param paths path to execute | ||
270 | 132 | * @return int status of execution | ||
271 | 133 | */ | ||
272 | 134 | public static int execute_with_uri (string id, string path) { | ||
273 | 135 | ensure (); | ||
274 | 136 | int ret_val = 1; | ||
275 | 137 | |||
276 | 138 | try { | ||
277 | 139 | ret_val = contractor.contract.execute_with_uri (id, path); | ||
278 | 140 | } catch (Error e) { | ||
279 | 141 | stderr.printf ("%s\n", e.message); | ||
280 | 142 | } | ||
281 | 143 | return ret_val; | ||
282 | 144 | } | ||
283 | 145 | /** | ||
284 | 146 | * This executes the exec parameter provided by the contract of given id | ||
285 | 147 | * with the paths as arguments | ||
286 | 148 | * | ||
287 | 149 | * @param id id of the contract | ||
288 | 150 | * @param paths array of paths to execute | ||
289 | 151 | * @return int status of execution | ||
290 | 152 | */ | ||
291 | 153 | public static int execute_with_uri_list (string id, string[] paths) { | ||
292 | 154 | ensure (); | ||
293 | 155 | int ret_val = 1; | ||
294 | 156 | |||
295 | 157 | try { | ||
296 | 158 | ret_val = contractor.contract.execute_with_uri_list (id, paths); | ||
297 | 159 | } catch (Error e) { | ||
298 | 160 | stderr.printf ("%s\n", e.message); | ||
299 | 161 | } | ||
300 | 162 | return ret_val; | ||
301 | 163 | } | ||
302 | 164 | /** | ||
303 | 165 | * The functions below have been deprecated in order to support the | ||
304 | 166 | * the new contractor API. | ||
305 | 167 | */ | ||
306 | 168 | |||
307 | 169 | /** | ||
308 | 170 | * This searches for available contracts of a particular file | ||
309 | 171 | * | ||
310 | 66 | * @param uri uri of file | 172 | * @param uri uri of file |
311 | 67 | * @param mime mime type of file | 173 | * @param mime mime type of file |
312 | 68 | * @return Hashtable of available contracts | 174 | * @return Hashtable of available contracts |
313 | 69 | */ | 175 | */ |
326 | 70 | public static GLib.HashTable<string,string>[] get_contract(string uri, string mime) | 176 | [Deprecated] |
327 | 71 | { | 177 | public static GLib.HashTable<string,string>[] get_contract(string uri, string mime) { |
328 | 72 | ensure (); | 178 | |
329 | 73 | GLib.HashTable<string,string>[] contracts = null; | 179 | return { new GLib.HashTable<string,string> (null, null) }; |
318 | 74 | |||
319 | 75 | try { | ||
320 | 76 | contracts = contractor.contract.GetServicesByLocation(uri, mime); | ||
321 | 77 | }catch (IOError e) { | ||
322 | 78 | stderr.printf ("%s\n", e.message); | ||
323 | 79 | } | ||
324 | 80 | |||
325 | 81 | return contracts; | ||
330 | 82 | } | 180 | } |
331 | 83 | 181 | ||
332 | 84 | /** | 182 | /** |
333 | 85 | * generate contracts for rguments and filter them by common parent mimetype. | 183 | * generate contracts for rguments and filter them by common parent mimetype. |
335 | 86 | * | 184 | * |
336 | 87 | * @param locations Hashtable of locations | 185 | * @param locations Hashtable of locations |
337 | 88 | * @return Hashtable of available contracts | 186 | * @return Hashtable of available contracts |
338 | 89 | */ | 187 | */ |
351 | 90 | public static GLib.HashTable<string,string>[] get_selection_contracts (GLib.HashTable<string, string>[] locations) | 188 | [Deprecated] |
352 | 91 | { | 189 | public static GLib.HashTable<string,string>[] get_selection_contracts (GLib.HashTable<string, string>[] locations) { |
353 | 92 | ensure (); | 190 | |
354 | 93 | GLib.HashTable<string,string>[] contracts = null; | 191 | return { new GLib.HashTable<string,string> (null, null) }; |
343 | 94 | |||
344 | 95 | try { | ||
345 | 96 | contracts = contractor.contract.GetServicesByLocationsList (locations); | ||
346 | 97 | }catch (IOError e) { | ||
347 | 98 | stderr.printf ("%s\n", e.message); | ||
348 | 99 | } | ||
349 | 100 | |||
350 | 101 | return contracts; | ||
355 | 102 | } | 192 | } |
356 | 103 | } | 193 | } |
357 | 104 | } | 194 | } |
358 | 195 | |||
359 | 105 | 196 | ||
360 | === modified file 'lib/Widgets/ContractorMenu.vala' | |||
361 | --- lib/Widgets/ContractorMenu.vala 2013-03-20 15:42:25 +0000 | |||
362 | +++ lib/Widgets/ContractorMenu.vala 2013-04-10 16:09:20 +0000 | |||
363 | @@ -10,7 +10,7 @@ | |||
364 | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
365 | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
366 | 12 | Lesser General Public License for more details. | 12 | Lesser General Public License for more details. |
368 | 13 | 13 | ||
369 | 14 | You should have received a copy of the GNU Lesser General | 14 | You should have received a copy of the GNU Lesser General |
370 | 15 | Public License along with this library; if not, write to the | 15 | Public License along with this library; if not, write to the |
371 | 16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
372 | @@ -20,6 +20,7 @@ | |||
373 | 20 | /** | 20 | /** |
374 | 21 | * This class provides a simple menu for managing Contractor. | 21 | * This class provides a simple menu for managing Contractor. |
375 | 22 | */ | 22 | */ |
376 | 23 | [Deprecated] | ||
377 | 23 | public class Granite.Widgets.ContractorMenu : Gtk.Menu { | 24 | public class Granite.Widgets.ContractorMenu : Gtk.Menu { |
378 | 24 | /** | 25 | /** |
379 | 25 | * The Hashtable of available contracts | 26 | * The Hashtable of available contracts |
380 | @@ -32,12 +33,12 @@ | |||
381 | 32 | public delegate void ContractCallback (); | 33 | public delegate void ContractCallback (); |
382 | 33 | private string filepath; | 34 | private string filepath; |
383 | 34 | private string filemime; | 35 | private string filemime; |
385 | 35 | 36 | ||
386 | 36 | /** | 37 | /** |
387 | 37 | * Passes when contract is clicked | 38 | * Passes when contract is clicked |
388 | 38 | */ | 39 | */ |
389 | 39 | public signal void contract_activated (string contract_name); | 40 | public signal void contract_activated (string contract_name); |
391 | 40 | 41 | ||
392 | 41 | /** | 42 | /** |
393 | 42 | * Makes new Contractor Meu | 43 | * Makes new Contractor Meu |
394 | 43 | * | 44 | * |
395 | @@ -49,7 +50,7 @@ | |||
396 | 49 | filemime = mime; | 50 | filemime = mime; |
397 | 50 | load_items (filename, mime); | 51 | load_items (filename, mime); |
398 | 51 | } | 52 | } |
400 | 52 | 53 | ||
401 | 53 | /** | 54 | /** |
402 | 54 | * Adds new item to Contractor Menu | 55 | * Adds new item to Contractor Menu |
403 | 55 | * | 56 | * |
404 | @@ -73,7 +74,7 @@ | |||
405 | 73 | insert(item, position); | 74 | insert(item, position); |
406 | 74 | item.show (); | 75 | item.show (); |
407 | 75 | } | 76 | } |
409 | 76 | 77 | ||
410 | 77 | /** | 78 | /** |
411 | 78 | * Deletes a group of menu items | 79 | * Deletes a group of menu items |
412 | 79 | * | 80 | * |
413 | @@ -85,14 +86,14 @@ | |||
414 | 85 | remove (item); | 86 | remove (item); |
415 | 86 | }); | 87 | }); |
416 | 87 | } | 88 | } |
418 | 88 | 89 | ||
419 | 89 | private void load_items (string filename, string mime) { | 90 | private void load_items (string filename, string mime) { |
420 | 90 | contracts = Granite.Services.Contractor.get_contract (filename, mime); | 91 | contracts = Granite.Services.Contractor.get_contract (filename, mime); |
421 | 91 | execs = new Gee.HashMap<string,string> (); | 92 | execs = new Gee.HashMap<string,string> (); |
423 | 92 | 93 | ||
424 | 93 | for (int i=0;i<contracts.length;i++) { | 94 | for (int i=0;i<contracts.length;i++) { |
425 | 94 | execs[contracts[i].lookup ("Name")] = contracts[i].lookup ("Exec"); | 95 | execs[contracts[i].lookup ("Name")] = contracts[i].lookup ("Exec"); |
427 | 95 | 96 | ||
428 | 96 | var item = new Gtk.ImageMenuItem (); | 97 | var item = new Gtk.ImageMenuItem (); |
429 | 97 | item.set_always_show_image (true); | 98 | item.set_always_show_image (true); |
430 | 98 | var image = new Gtk.Image.from_icon_name (contracts[i].lookup ("IconName"), Gtk.IconSize.MENU); | 99 | var image = new Gtk.Image.from_icon_name (contracts[i].lookup ("IconName"), Gtk.IconSize.MENU); |
431 | @@ -109,7 +110,7 @@ | |||
432 | 109 | item.show_all (); | 110 | item.show_all (); |
433 | 110 | } | 111 | } |
434 | 111 | } | 112 | } |
436 | 112 | 113 | ||
437 | 113 | /** | 114 | /** |
438 | 114 | * Updates Contractor menu items | 115 | * Updates Contractor menu items |
439 | 115 | * | 116 | * |
440 | @@ -118,24 +119,24 @@ | |||
441 | 118 | */ | 119 | */ |
442 | 119 | public void update (string? filename, string? mime) { | 120 | public void update (string? filename, string? mime) { |
443 | 120 | this.foreach ((w) => {remove (w);}); | 121 | this.foreach ((w) => {remove (w);}); |
445 | 121 | 122 | ||
446 | 122 | string fn = ""; | 123 | string fn = ""; |
447 | 123 | string mm = ""; | 124 | string mm = ""; |
449 | 124 | 125 | ||
450 | 125 | if (filename != null) { | 126 | if (filename != null) { |
451 | 126 | fn = filename; | 127 | fn = filename; |
452 | 127 | filepath = filename; | 128 | filepath = filename; |
453 | 128 | } else { | 129 | } else { |
454 | 129 | fn = filepath; | 130 | fn = filepath; |
455 | 130 | } | 131 | } |
457 | 131 | 132 | ||
458 | 132 | if (mime != null) { | 133 | if (mime != null) { |
459 | 133 | mm = mime; | 134 | mm = mime; |
460 | 134 | filemime = mime; | 135 | filemime = mime; |
461 | 135 | } else { | 136 | } else { |
462 | 136 | mm = filemime; | 137 | mm = filemime; |
463 | 137 | } | 138 | } |
465 | 138 | 139 | ||
466 | 139 | load_items (fn, mm); | 140 | load_items (fn, mm); |
467 | 140 | } | 141 | } |
468 | 141 | } | 142 | } |
469 | 142 | 143 | ||
470 | === modified file 'lib/Widgets/ContractorView.vala' | |||
471 | --- lib/Widgets/ContractorView.vala 2013-03-20 15:42:25 +0000 | |||
472 | +++ lib/Widgets/ContractorView.vala 2013-04-10 16:09:20 +0000 | |||
473 | @@ -10,7 +10,7 @@ | |||
474 | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
475 | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
476 | 12 | Lesser General Public License for more details. | 12 | Lesser General Public License for more details. |
478 | 13 | 13 | ||
479 | 14 | You should have received a copy of the GNU Lesser General | 14 | You should have received a copy of the GNU Lesser General |
480 | 15 | Public License along with this library; if not, write to the | 15 | Public License along with this library; if not, write to the |
481 | 16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
482 | @@ -22,20 +22,21 @@ | |||
483 | 22 | /** | 22 | /** |
484 | 23 | * This class provides a simple way to look at contracts from Contractor | 23 | * This class provides a simple way to look at contracts from Contractor |
485 | 24 | */ | 24 | */ |
486 | 25 | [Deprecated ()] | ||
487 | 25 | public class Granite.Widgets.ContractorView : TreeView { | 26 | public class Granite.Widgets.ContractorView : TreeView { |
489 | 26 | 27 | ||
490 | 27 | /** | 28 | /** |
491 | 28 | * indicates if it was possible to connect to contractor | 29 | * indicates if it was possible to connect to contractor |
492 | 29 | */ | 30 | */ |
493 | 30 | public bool contractor_available; | 31 | public bool contractor_available; |
495 | 31 | 32 | ||
496 | 32 | public delegate void ContractCallback (); | 33 | public delegate void ContractCallback (); |
497 | 33 | private Gee.HashMap<int, DelegateWrapper?> outsiders; | 34 | private Gee.HashMap<int, DelegateWrapper?> outsiders; |
498 | 34 | private int[] blacklisted_pos; | 35 | private int[] blacklisted_pos; |
499 | 35 | private ListStore list; | 36 | private ListStore list; |
500 | 36 | 37 | ||
501 | 37 | private struct DelegateWrapper { unowned ContractCallback method; } | 38 | private struct DelegateWrapper { unowned ContractCallback method; } |
503 | 38 | 39 | ||
504 | 39 | /** | 40 | /** |
505 | 40 | * the index of the currently selected contract | 41 | * the index of the currently selected contract |
506 | 41 | */ | 42 | */ |
507 | @@ -49,17 +50,17 @@ | |||
508 | 49 | this.set_cursor (new TreePath.from_string (value.to_string ()), null, false); | 50 | this.set_cursor (new TreePath.from_string (value.to_string ()), null, false); |
509 | 50 | } | 51 | } |
510 | 51 | } | 52 | } |
512 | 52 | 53 | ||
513 | 53 | /** | 54 | /** |
514 | 54 | * A contract was launched using double clicking | 55 | * A contract was launched using double clicking |
515 | 55 | */ | 56 | */ |
516 | 56 | public signal void executed (); | 57 | public signal void executed (); |
518 | 57 | 58 | ||
519 | 58 | /** | 59 | /** |
520 | 59 | * the original array of contracts returned by contractor | 60 | * the original array of contracts returned by contractor |
521 | 60 | */ | 61 | */ |
522 | 61 | HashTable<string,string>[] contracts; | 62 | HashTable<string,string>[] contracts; |
524 | 62 | 63 | ||
525 | 63 | /** | 64 | /** |
526 | 64 | * Create the default ContractorView | 65 | * Create the default ContractorView |
527 | 65 | * | 66 | * |
528 | @@ -73,17 +74,17 @@ | |||
529 | 73 | list = new ListStore (2, typeof (Gdk.Pixbuf), typeof (string)); | 74 | list = new ListStore (2, typeof (Gdk.Pixbuf), typeof (string)); |
530 | 74 | outsiders = new Gee.HashMap<int, DelegateWrapper?> (); | 75 | outsiders = new Gee.HashMap<int, DelegateWrapper?> (); |
531 | 75 | this.model = list; | 76 | this.model = list; |
533 | 76 | 77 | ||
534 | 77 | /* GUI */ | 78 | /* GUI */ |
535 | 78 | this.headers_visible = false; | 79 | this.headers_visible = false; |
536 | 79 | this.hexpand = true; | 80 | this.hexpand = true; |
538 | 80 | 81 | ||
539 | 81 | /* Events */ | 82 | /* Events */ |
541 | 82 | row_activated.connect (() => { | 83 | row_activated.connect (() => { |
542 | 83 | run_selected (); | 84 | run_selected (); |
543 | 84 | executed (); | 85 | executed (); |
544 | 85 | }); | 86 | }); |
546 | 86 | 87 | ||
547 | 87 | /* View */ | 88 | /* View */ |
548 | 88 | var cell1 = new CellRendererPixbuf (); | 89 | var cell1 = new CellRendererPixbuf (); |
549 | 89 | cell1.set_padding (5, 8); | 90 | cell1.set_padding (5, 8); |
550 | @@ -102,9 +103,9 @@ | |||
551 | 102 | string message = contractor_installed ? _("Could not contact Contractor. You may need to install it") : _("No action found for this file"); | 103 | string message = contractor_installed ? _("Could not contact Contractor. You may need to install it") : _("No action found for this file"); |
552 | 103 | try { | 104 | try { |
553 | 104 | var icon = IconTheme.get_default ().load_icon ( | 105 | var icon = IconTheme.get_default ().load_icon ( |
555 | 105 | contractor_installed ? Gtk.Stock.DIALOG_ERROR : Gtk.Stock.DIALOG_INFO, | 106 | contractor_installed ? Gtk.Stock.DIALOG_ERROR : Gtk.Stock.DIALOG_INFO, |
556 | 106 | icon_size, 0); | 107 | icon_size, 0); |
558 | 107 | list.set (it, | 108 | list.set (it, |
559 | 108 | 0, icon, 1, message); | 109 | 0, icon, 1, message); |
560 | 109 | } | 110 | } |
561 | 110 | catch (Error e) { | 111 | catch (Error e) { |
562 | @@ -114,7 +115,7 @@ | |||
563 | 114 | } | 115 | } |
564 | 115 | else { | 116 | else { |
565 | 116 | contractor_available = true; | 117 | contractor_available = true; |
567 | 117 | 118 | ||
568 | 118 | for (var i=0; i<this.contracts.length; i++){ | 119 | for (var i=0; i<this.contracts.length; i++){ |
569 | 119 | TreeIter it; | 120 | TreeIter it; |
570 | 120 | list.append (out it); | 121 | list.append (out it); |
571 | @@ -122,8 +123,8 @@ | |||
572 | 122 | if (show_contract_name) | 123 | if (show_contract_name) |
573 | 123 | text = "<b>"+this.contracts[i].lookup ("Name")+"</b>\n"+text; | 124 | text = "<b>"+this.contracts[i].lookup ("Name")+"</b>\n"+text; |
574 | 124 | try{ | 125 | try{ |
577 | 125 | list.set (it, | 126 | list.set (it, |
578 | 126 | 0, IconTheme.get_default ().load_icon (this.contracts[i].lookup ("IconName"), | 127 | 0, IconTheme.get_default ().load_icon (this.contracts[i].lookup ("IconName"), |
579 | 127 | icon_size, 0), 1, text); | 128 | icon_size, 0), 1, text); |
580 | 128 | } | 129 | } |
581 | 129 | catch (Error e) { | 130 | catch (Error e) { |
582 | @@ -133,7 +134,7 @@ | |||
583 | 133 | this.selected = 0; | 134 | this.selected = 0; |
584 | 134 | } | 135 | } |
585 | 135 | } | 136 | } |
587 | 136 | 137 | ||
588 | 137 | /** | 138 | /** |
589 | 138 | * A method to add items to the tree | 139 | * A method to add items to the tree |
590 | 139 | * | 140 | * |
591 | @@ -148,21 +149,21 @@ | |||
592 | 148 | public void add_item (string name, string desc, string icon_name, int icon_size, int position, ContractCallback method) { | 149 | public void add_item (string name, string desc, string icon_name, int icon_size, int position, ContractCallback method) { |
593 | 149 | TreeIter it; | 150 | TreeIter it; |
594 | 150 | list.insert (out it, position); | 151 | list.insert (out it, position); |
596 | 151 | 152 | ||
597 | 152 | string text = "<b>" + name + "</b>\n" + desc; | 153 | string text = "<b>" + name + "</b>\n" + desc; |
599 | 153 | 154 | ||
600 | 154 | try{ | 155 | try{ |
601 | 155 | list.set (it, 0, IconTheme.get_default ().load_icon (icon_name, icon_size, 0), 1, text); | 156 | list.set (it, 0, IconTheme.get_default ().load_icon (icon_name, icon_size, 0), 1, text); |
602 | 156 | } catch (Error e) { | 157 | } catch (Error e) { |
603 | 157 | error (e.message); | 158 | error (e.message); |
604 | 158 | } | 159 | } |
606 | 159 | 160 | ||
607 | 160 | DelegateWrapper wr = { method }; | 161 | DelegateWrapper wr = { method }; |
608 | 161 | outsiders[position] = wr; | 162 | outsiders[position] = wr; |
610 | 162 | 163 | ||
611 | 163 | this.selected = 0; | 164 | this.selected = 0; |
612 | 164 | } | 165 | } |
614 | 165 | 166 | ||
615 | 166 | public void name_blacklist (string[] names) { | 167 | public void name_blacklist (string[] names) { |
616 | 167 | TreeIter it; | 168 | TreeIter it; |
617 | 168 | TreeIter it2; | 169 | TreeIter it2; |
618 | @@ -171,25 +172,25 @@ | |||
619 | 171 | int cur_pos = 0; | 172 | int cur_pos = 0; |
620 | 172 | list.get_iter_first (out it); | 173 | list.get_iter_first (out it); |
621 | 173 | list.get_iter_first (out it2); | 174 | list.get_iter_first (out it2); |
623 | 174 | 175 | ||
624 | 175 | while (true) { | 176 | while (true) { |
625 | 176 | list.get_value (it, 1, out value); | 177 | list.get_value (it, 1, out value); |
626 | 177 | check = list.iter_next (ref it2); | 178 | check = list.iter_next (ref it2); |
627 | 178 | string text = value.get_string (); | 179 | string text = value.get_string (); |
629 | 179 | 180 | ||
630 | 180 | if (text[3:text.index_of ("</b>")] in names) { | 181 | if (text[3:text.index_of ("</b>")] in names) { |
631 | 181 | list.remove (it); | 182 | list.remove (it); |
632 | 182 | blacklisted_pos += cur_pos; | 183 | blacklisted_pos += cur_pos; |
633 | 183 | } | 184 | } |
634 | 184 | if (!check) | 185 | if (!check) |
635 | 185 | break; | 186 | break; |
637 | 186 | 187 | ||
638 | 187 | it = it2; | 188 | it = it2; |
640 | 188 | cur_pos++; | 189 | cur_pos++; |
641 | 189 | } | 190 | } |
642 | 190 | } | 191 | } |
645 | 191 | 192 | ||
646 | 192 | 193 | ||
647 | 193 | public void run_selected () { | 194 | public void run_selected () { |
648 | 194 | if (this.selected in outsiders.keys ) { | 195 | if (this.selected in outsiders.keys ) { |
649 | 195 | outsiders[this.selected].method (); | 196 | outsiders[this.selected].method (); |
This seems to break the ABI (according to Rico's check in deb-packaging) even thought it shouldn't.