Merge lp:~donadigo/appcenter/prefer-stock into lp:~elementary-apps/appcenter/appcenter

Proposed by Adam Bieńkowski
Status: Merged
Approved by: Danielle Foré
Approved revision: 209
Merged at revision: 210
Proposed branch: lp:~donadigo/appcenter/prefer-stock
Merge into: lp:~elementary-apps/appcenter/appcenter
Diff against target: 129 lines (+43/-54)
3 files modified
src/Core/Package.vala (+41/-0)
src/Views/AppInfoView.vala (+1/-32)
src/Widgets/PackageRow.vala (+1/-22)
To merge this branch: bzr merge lp:~donadigo/appcenter/prefer-stock
Reviewer Review Type Date Requested Status
Corentin Noël code Approve
Danielle Foré testing Approve
Review via email: mp+297967@code.launchpad.net

Commit message

Use icons from the theme when available

Description of the change

Fixes bug #1525037: "Use icons from the theme when available".

Prefer the stock icons, if there is no icon found in the icon theme, fallback to URLs / filenames.

* Instead of duplicating the code, the icon code has been moved to the Package class for consistency.

To post a comment you must log in.
Revision history for this message
Danielle Foré (danrabbit) wrote :

I can confirm that this works and in all views :)

review: Approve (testing)
Revision history for this message
Corentin Noël (tintou) wrote :

We discussed about some changes to do

review: Needs Fixing (code)
lp:~donadigo/appcenter/prefer-stock updated
209. By Adam Bieńkowski

Prefer stock icons

Revision history for this message
Corentin Noël (tintou) wrote :

Nice, now working as intended

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/Core/Package.vala'
--- src/Core/Package.vala 2016-05-01 22:39:22 +0000
+++ src/Core/Package.vala 2016-06-21 17:44:46 +0000
@@ -141,6 +141,47 @@
141 return null;141 return null;
142 }142 }
143143
144 public GLib.Icon get_icon (uint size = 32) {
145 GLib.Icon icon = new ThemedIcon ("application-default-icon");
146 uint current_size = 0;
147
148 bool is_stock = false;
149 component.get_icons ().foreach ((_icon) => {
150 if (is_stock) {
151 return;
152 }
153
154 switch (_icon.get_kind ()) {
155 case AppStream.IconKind.STOCK:
156 if (Gtk.IconTheme.get_default ().has_icon (_icon.get_name ())) {
157 is_stock = true;
158 icon = new ThemedIcon (_icon.get_name ());
159 }
160
161 break;
162 case AppStream.IconKind.CACHED:
163 case AppStream.IconKind.LOCAL:
164 if (_icon.get_width () > current_size && current_size < size) {
165 var file = File.new_for_path (_icon.get_filename ());
166 icon = new FileIcon (file);
167 current_size = _icon.get_width ();
168 }
169
170 break;
171 case AppStream.IconKind.REMOTE:
172 if (_icon.get_width () > current_size && current_size < size) {
173 var file = File.new_for_uri (_icon.get_url ());
174 icon = new FileIcon (file);
175 current_size = _icon.get_width ();
176 }
177
178 break;
179 }
180 });
181
182 return icon;
183 }
184
144 public string? get_version () {185 public string? get_version () {
145 var package = find_package ();186 var package = find_package ();
146 if (package != null) {187 if (package != null) {
147188
=== modified file 'src/Views/AppInfoView.vala'
--- src/Views/AppInfoView.vala 2016-06-12 22:00:29 +0000
+++ src/Views/AppInfoView.vala 2016-06-21 17:44:46 +0000
@@ -43,38 +43,7 @@
43 app_name.label = package.get_name ();43 app_name.label = package.get_name ();
44 app_summary.label = package.get_summary ();44 app_summary.label = package.get_summary ();
45 parse_description (package.component.get_description ());45 parse_description (package.component.get_description ());
46 uint size = 0;46 app_icon.gicon = package.get_icon (128);
47 string icon_name = "application-default-icon";
48 package.component.get_icons ().foreach ((icon) => {
49 switch (icon.get_kind ()) {
50 case AppStream.IconKind.STOCK:
51 icon_name = icon.get_name ();
52 break;
53 case AppStream.IconKind.CACHED:
54 case AppStream.IconKind.LOCAL:
55 var current_size = icon.get_width ();
56 if (current_size > size) {
57 size = current_size;
58 var file = File.new_for_path (icon.get_filename ());
59 app_icon.gicon = new FileIcon (file);
60 }
61
62 break;
63 case AppStream.IconKind.REMOTE:
64 var current_size = icon.get_width ();
65 if (current_size > size) {
66 size = current_size;
67 var file = File.new_for_uri (icon.get_url ());
68 app_icon.gicon = new FileIcon (file);
69 }
70
71 break;
72 }
73 });
74
75 if (app_icon.gicon == null) {
76 app_icon.gicon = new ThemedIcon (icon_name);
77 }
7847
79 if (package.update_available) {48 if (package.update_available) {
80 action_button.label = _("Update");49 action_button.label = _("Update");
8150
=== modified file 'src/Widgets/PackageRow.vala'
--- src/Widgets/PackageRow.vala 2016-06-15 17:07:50 +0000
+++ src/Widgets/PackageRow.vala 2016-06-21 17:44:46 +0000
@@ -39,28 +39,7 @@
39 package_name.label = package.get_name ();39 package_name.label = package.get_name ();
40 package_summary.label = package.get_summary ();40 package_summary.label = package.get_summary ();
41 package_summary.ellipsize = Pango.EllipsizeMode.END;41 package_summary.ellipsize = Pango.EllipsizeMode.END;
4242 image.gicon = package.get_icon ();
43 string icon_name = "application-default-icon";
44 package.component.get_icons ().foreach ((icon) => {
45 switch (icon.get_kind ()) {
46 case AppStream.IconKind.STOCK:
47 icon_name = icon.get_name ();
48 break;
49 case AppStream.IconKind.CACHED:
50 case AppStream.IconKind.LOCAL:
51 var file = File.new_for_path (icon.get_filename ());
52 image.gicon = new FileIcon (file);
53 break;
54 case AppStream.IconKind.REMOTE:
55 var file = File.new_for_uri (icon.get_url ());
56 image.gicon = new FileIcon (file);
57 break;
58 }
59 });
60
61 if (image.gicon == null) {
62 image.gicon = new ThemedIcon (icon_name);
63 }
6443
65 package.notify["installed"].connect (() => {44 package.notify["installed"].connect (() => {
66 changed ();45 changed ();

Subscribers

People subscribed via source and target branches