Merge lp:~elementary-apps/granite/contractor-supports-multiple into lp:~elementary-pantheon/granite/granite

Proposed by Tom Beckmann
Status: Rejected
Rejected by: Danielle Foré
Proposed branch: lp:~elementary-apps/granite/contractor-supports-multiple
Merge into: lp:~elementary-pantheon/granite/granite
Diff against target: 74 lines (+28/-1)
1 file modified
lib/Services/ContractorProxy.vala (+28/-1)
To merge this branch: bzr merge lp:~elementary-apps/granite/contractor-supports-multiple
Reviewer Review Type Date Requested Status
xapantu (community) Needs Information
Review via email: mp+231133@code.launchpad.net

Description of the change

This branch adds support for contractor's new support_multiple_files field. API-wise, you can call it directly on a Contract instance or rely on get_contracts_for_file[s](), which will now filter the contracts returned by contractor to remove those which only support a single file, if multiple files have been passed to the methods.

This branch relies on https://code.launchpad.net/~elementary-apps/contractor/multiple-files/+merge/231132 Otherwise apps will crash immediately if they use contractor directly or if they have a contractor plugin, like pantheon-files, the plugin won't load with an undefined symbol error.

To post a comment you must log in.
Revision history for this message
xapantu (xapantu) wrote :

Hum, can you elaborate on the "Otherwise apps will crash immediately". Does that mean it breaks API or is it more complicated?

Does this branch still need to be merged or has it been superseded because of our lack of reactivity?

review: Needs Information

Unmerged revisions

770. By Tom Beckmann

add support for contractor's new support_multiple_files field

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/Services/ContractorProxy.vala'
2--- lib/Services/ContractorProxy.vala 2014-04-09 00:03:08 +0000
3+++ lib/Services/ContractorProxy.vala 2014-08-17 21:23:51 +0000
4@@ -49,6 +49,15 @@
5 public abstract Icon get_icon ();
6
7 /**
8+ * Returns whether the contract's program supports invocation with multiple files.
9+ * If called with multiple files anyway, the program will only be invoked with the
10+ * first file in the list.
11+ *
12+ * @return Whether the contract supports multiple files.
13+ */
14+ public abstract bool supports_multiple_files ();
15+
16+ /**
17 * Executes the action on the given file
18 */
19 public abstract void execute_with_file (File file) throws Error;
20@@ -80,6 +89,7 @@
21 string display_name;
22 string description;
23 string icon;
24+ bool supports_multiple_files;
25 }
26
27 [DBus (name = "org.elementary.Contractor")]
28@@ -103,6 +113,7 @@
29 private string display_name;
30 private string description;
31 private string icon_key;
32+ private bool _supports_multiple_files;
33
34 private Icon icon;
35
36@@ -115,6 +126,7 @@
37 id = data.id ?? "";
38 display_name = data.display_name ?? "";
39 description = data.description ?? "";
40+ _supports_multiple_files = data.supports_multiple_files;
41
42 if (icon_key != data.icon) {
43 icon_key = data.icon ?? "";
44@@ -141,6 +153,10 @@
45 return icon;
46 }
47
48+ public bool supports_multiple_files () {
49+ return _supports_multiple_files;
50+ }
51+
52 public void execute_with_file (File file) throws Error {
53 ContractorProxy.execute_with_uri (id, file.get_uri ());
54 }
55@@ -310,7 +326,18 @@
56 mime_types.add (ContentType.get_mime_type (content_type));
57 }
58
59- return get_contracts_by_mimelist (mime_types.to_array ());
60+ var needs_multiple_support = files.length > 1;
61+ var list = get_contracts_by_mimelist (mime_types.to_array ());
62+
63+ if (needs_multiple_support) {
64+ var iter = list.iterator ();
65+ while (iter.next ()) {
66+ if (!iter.@get ().supports_multiple_files ())
67+ iter.remove ();
68+ }
69+ }
70+
71+ return list;
72 }
73
74 private static Gee.List<Contract> get_contracts_from_data (ContractData[] data) {

Subscribers

People subscribed via source and target branches