Merge lp:~donadigo/appcenter/install-notify-canceled-new into lp:~elementary-apps/appcenter/appcenter

Proposed by Adam Bieńkowski
Status: Merged
Approved by: Danielle Foré
Approved revision: 232
Merged at revision: 232
Proposed branch: lp:~donadigo/appcenter/install-notify-canceled-new
Merge into: lp:~elementary-apps/appcenter/appcenter
Diff against target: 63 lines (+14/-14)
2 files modified
src/Core/Client.vala (+5/-2)
src/Core/Package.vala (+9/-12)
To merge this branch: bzr merge lp:~donadigo/appcenter/install-notify-canceled-new
Reviewer Review Type Date Requested Status
elementary Apps team Pending
Review via email: mp+298966@code.launchpad.net

Commit message

Don't send notifications when installation is canceled

Description of the change

Fixes bug #1592291: "Application installed Notification even if you canceled".

This is a follow up to the old branch, it should fix the issue correctly now.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Core/Client.vala'
2--- src/Core/Client.vala 2016-06-28 21:47:23 +0000
3+++ src/Core/Client.vala 2016-07-01 22:03:31 +0000
4@@ -107,7 +107,8 @@
5 return null;
6 }
7
8- public async void install_package (Package package, Pk.ProgressCallback cb, GLib.Cancellable cancellable) throws GLib.Error {
9+ public async Pk.Exit install_package (Package package, Pk.ProgressCallback cb, GLib.Cancellable cancellable) throws GLib.Error {
10+ Pk.Exit exit_status = Pk.Exit.UNKNOWN;
11 AppCenter.Task install_task = request_task ();
12 AppCenter.Task search_task = request_task ();
13 string[] packages_ids = {};
14@@ -125,7 +126,8 @@
15 packages_ids += null;
16
17 results = yield install_task.install_packages_async (packages_ids, cancellable, cb);
18- if (results.get_exit_code () != Pk.Exit.SUCCESS) {
19+ exit_status = results.get_exit_code ();
20+ if (exit_status != Pk.Exit.SUCCESS) {
21 release_task (search_task);
22 release_task (install_task);
23 throw new GLib.IOError.FAILED (Pk.Exit.enum_to_string (results.get_exit_code ()));
24@@ -138,6 +140,7 @@
25
26 release_task (search_task);
27 release_task (install_task);
28+ return exit_status;
29 }
30
31 public async void update_package (Package package, Pk.ProgressCallback cb, GLib.Cancellable cancellable) throws GLib.Error {
32
33=== modified file 'src/Core/Package.vala'
34--- src/Core/Package.vala 2016-06-29 21:40:17 +0000
35+++ src/Core/Package.vala 2016-07-01 22:03:31 +0000
36@@ -75,18 +75,15 @@
37 var application = (Gtk.Application)Application.get_default ();
38 var window = application.get_active_window ().get_window ();
39
40- yield AppCenterCore.Client.get_default ().install_package (this, (progress, type) => {
41- if (type == Pk.ProgressType.STATUS && progress.status == Pk.Status.FINISHED && (window.get_state () & Gdk.WindowState.FOCUSED) == 0) {
42- var notification = new Notification (_("Application installed"));
43- notification.set_body (_("%s has been successfully installed").printf (get_name ()));
44- notification.set_icon (new ThemedIcon ("system-software-install"));
45- notification.set_default_action ("app.open-application");
46-
47- application.send_notification ("installed", notification);
48- }
49-
50- change_information.ProgressCallback (progress, type);
51- }, action_cancellable);
52+ var exit_status = yield AppCenterCore.Client.get_default ().install_package (this, (progress, type) => {change_information.ProgressCallback (progress, type);}, action_cancellable);
53+ if (exit_status == Pk.Exit.SUCCESS && (window.get_state () & Gdk.WindowState.FOCUSED) == 0) {
54+ var notification = new Notification (_("Application installed"));
55+ notification.set_body (_("%s has been successfully installed").printf (get_name ()));
56+ notification.set_icon (new ThemedIcon ("system-software-install"));
57+ notification.set_default_action ("app.open-application");
58+
59+ application.send_notification ("installed", notification);
60+ }
61
62 installed_packages.add_all (change_information.changes);
63 change_information.clear ();

Subscribers

People subscribed via source and target branches