~alecu/unity-scope-click/publisher-field

« back to all changes in this revision

Viewing changes to src/click-interface.vala

  • Committer: Tarmac
  • Author(s): Alejandro J. Cura
  • Date: 2013-10-01 22:13:05 UTC
  • mfrom: (60.2.2 prevent-non-removable)
  • Revision ID: tarmac-20131001221305-4pmk4ookwwrog011
Don't show Uninstall button if manifest has _removable:0, and remove pin-to-launcher. Fixes: https://bugs.launchpad.net/bugs/1233641, https://bugs.launchpad.net/bugs/1233653.

Approved by PS Jenkins bot, Rodney Dawes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
public class ClickInterface : GLib.Object {
23
23
    const string ARG_DESKTOP_FILE_HINT = "--desktop_file_hint";
24
 
    delegate void ProcessManifestFunc (Json.Object manifest);
25
24
 
26
25
    public string get_click_id (string full_app_id) {
27
26
        return full_app_id.split("_")[0];
110
109
        throw new ClickError.EXEC_FAILURE(msg);
111
110
    }
112
111
 
 
112
    public async bool can_uninstall (string app_id) {
 
113
        const string REMOVABLE_FIELD = "_removable";
 
114
        GLib.List<weak Json.Node> manifests;
 
115
        try {
 
116
            manifests = yield get_manifests();
 
117
        } catch (ClickError e) {
 
118
            debug ("Can't get _removable for %s, ignoring", app_id);
 
119
            return true;
 
120
        }
 
121
        foreach (var element in manifests) {
 
122
            var manifest = element.get_object();
 
123
            var pkg_name = manifest.get_string_member("name");
 
124
            if (pkg_name == app_id) {
 
125
                if (manifest.has_member(REMOVABLE_FIELD)) {
 
126
                    var removable = manifest.get_int_member(REMOVABLE_FIELD);
 
127
                    return removable != 0;
 
128
                } else {
 
129
                    return true;
 
130
                }
 
131
            }
 
132
        }
 
133
        return true;
 
134
    }
 
135
 
113
136
    public async void uninstall (string app_id) throws ClickError {
114
137
        string version = null;
115
138
        try {