Merge lp:~stolowski/unity-lens-applications/use-icon-uri into lp:unity-lens-applications

Proposed by Paweł Stołowski
Status: Merged
Approved by: Michal Hruby
Approved revision: 307
Merged at revision: 305
Proposed branch: lp:~stolowski/unity-lens-applications/use-icon-uri
Merge into: lp:unity-lens-applications
Diff against target: 117 lines (+23/-32)
2 files modified
src/daemon.vala (+21/-32)
src/software-center-data-provider.vala (+2/-0)
To merge this branch: bzr merge lp:~stolowski/unity-lens-applications/use-icon-uri
Reviewer Review Type Date Requested Status
Michal Hruby (community) Approve
Review via email: mp+126002@code.launchpad.net

Commit message

Use icon_url when displaying preview of an installable app; use find_pkg_icon instead of find_app_install_icon_path, as it also uses icons from ~/.cache/software-center/icons. Removed find_app_install_icon_path as it's no longer used.

Description of the change

Use icon_url when displaying preview of an installable app; use find_pkg_icon instead of find_app_install_icon_path, as it also uses icons from ~/.cache/software-center/icons. Removed find_app_install_icon_path as it's no longer used.

This improves icon handling in previews, as previous implementation wouldn't look in ~/.cache/software-center/icons, and therefore a lot of purchasable content would be missing icon in the preview. Note however that this doesn't fix a problem with generic app icons being used in app lens 'More suggestions' results if icon is not available in ~/.cache/software-center/icons. Fixing this would be too expensive, as it could result in fetching several icons at the same time.

Note about testing:
- for testing purposes you may want to remove some icons from ~/.cache/software-center/icons
- both app-lens and unity caches icons internally, so you may need to restart both if you removed icons from ~/.cache/software-center/icons.

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

Could you please use a const string for the "applications-other"? Otherwise looking fine.

307. By Paweł Stołowski

Added GENERIC_APP_ICON const string. Removed unused ICON_APP_INSTALL_PATH.

Revision history for this message
Paweł Stołowski (stolowski) wrote :

Fixed.

Revision history for this message
Michal Hruby (mhr3) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/daemon.vala'
2--- src/daemon.vala 2012-09-18 14:06:48 +0000
3+++ src/daemon.vala 2012-09-25 10:26:21 +0000
4@@ -41,7 +41,7 @@
5 const int64 TOP_RATED_ITEMS_CACHE_LIFETIME = 24*3600; // 24 hours
6
7 const string ICON_PATH = Config.DATADIR + "/icons/unity-icon-theme/places/svg/";
8- const string ICON_APP_INSTALL_PATH = Config.DATADIR + "/app-install/icons";
9+ const string GENERIC_APP_ICON = "applications-other";
10
11 public class Daemon : GLib.Object
12 {
13@@ -791,34 +791,18 @@
14 }
15 }
16
17- /**
18- * Find app icon in DATADIR/app-install/icons trying all supported image extensions.
19- */
20- private string find_app_install_icon_path (string icon_name)
21+ public Icon find_pkg_icon (string? desktop_file, string icon_name)
22 {
23- string icon = @"$ICON_APP_INSTALL_PATH/$icon_name.";
24-
25- foreach (string ext in image_extensions)
26+ if (desktop_file != null)
27 {
28- string path = icon + ext;
29- if (FileUtils.test (path, FileTest.EXISTS))
30- {
31- return path;
32- }
33+ string desktop_id = Path.get_basename (desktop_file);
34+ bool installed = AppInfoManager.get_default().lookup (desktop_id) != null;
35+
36+ /* If the app is already installed we should be able to pull the
37+ * icon from the theme */
38+ if (installed)
39+ return new ThemedIcon (icon_name);
40 }
41- var default_icon = new ThemedIcon ("applications-other");
42- return default_icon.to_string ();
43- }
44-
45- public Icon find_pkg_icon (string desktop_file, string icon_name)
46- {
47- string desktop_id = Path.get_basename (desktop_file);
48- bool installed = AppInfoManager.get_default().lookup (desktop_id) != null;
49-
50- /* If the app is already installed we should be able to pull the
51- * icon from the theme */
52- if (installed)
53- return new ThemedIcon (icon_name);
54
55 /* App is not installed - we need to find the right icon in the bowels
56 * of the software center */
57@@ -873,7 +857,7 @@
58 }
59
60 /* Cache the fact that we couldn't find this icon */
61- var icon = new ThemedIcon ("applications-other");
62+ var icon = new ThemedIcon (GENERIC_APP_ICON);
63 file_icon_cache.insert (icon_name, icon);
64
65 return icon;
66@@ -1145,9 +1129,8 @@
67
68 launcherservice.connect_to_launcher ();
69 string desktop_file = preview_installable_desktop_file;
70- string icon = find_app_install_icon_path (preview_installable_icon_file);
71-
72- launcherservice.add_launcher_item_from_position (appname, icon, 0, 0, 32, desktop_file, tid);
73+ Icon icon = find_pkg_icon (null, preview_installable_icon_file);
74+ launcherservice.add_launcher_item_from_position (appname, icon.to_string (), 0, 0, 32, desktop_file, tid);
75 }
76 catch (IOError e)
77 {
78@@ -1296,11 +1279,17 @@
79 debug ("Requesting pkg info: %s, %s\n", pkgname, appname);
80 sc_data_provider.get_app_details (appname, pkgname);
81
82- Icon icon;
83+ Icon? icon = null;
84 if (installed)
85 icon = new GLib.ThemedIcon (sc_data_provider.icon);
86 else
87- icon = new GLib.FileIcon (File.new_for_path (find_app_install_icon_path (sc_data_provider.icon)));
88+ {
89+ icon = find_pkg_icon (null, sc_data_provider.icon);
90+ if (icon.to_string () == GENERIC_APP_ICON && sc_data_provider.icon_url != null && sc_data_provider.icon_url != "")
91+ {
92+ icon = new GLib.FileIcon (File.new_for_uri (sc_data_provider.icon_url));
93+ }
94+ }
95
96 Icon? screenshot = null;
97
98
99=== modified file 'src/software-center-data-provider.vala'
100--- src/software-center-data-provider.vala 2012-09-18 12:57:06 +0000
101+++ src/software-center-data-provider.vala 2012-09-25 10:26:21 +0000
102@@ -56,6 +56,7 @@
103 public string desktop_file { get; set; }
104 public string license { get; set; }
105 public string icon { get; set; }
106+ public string icon_url { get; set; }
107 public string price { get; set; }
108 public string raw_price { get; set; }
109 public PackageState pkg_state { get; set; }
110@@ -94,6 +95,7 @@
111 desktop_file = data["desktop_file"].get_string ();
112 license = data["license"].get_string ();
113 icon = data["icon_file_name"].get_string ();
114+ icon_url = data["icon_url"].get_string ();
115 price = data["price"].get_string ();
116 raw_price = data["raw_price"].get_string ();
117 installation_date = data["installation_date"].get_string ();

Subscribers

People subscribed via source and target branches