Merge lp:~voluntatefaber/slingshot/icon-search-view into lp:~elementary-pantheon/slingshot/trunk

Proposed by Andrea Basso
Status: Rejected
Rejected by: Cody Garver
Proposed branch: lp:~voluntatefaber/slingshot/icon-search-view
Merge into: lp:~elementary-pantheon/slingshot/trunk
Diff against target: 148 lines (+45/-30)
2 files modified
src/Backend/App.vala (+39/-12)
src/Widgets/SearchItem.vala (+6/-18)
To merge this branch: bzr merge lp:~voluntatefaber/slingshot/icon-search-view
Reviewer Review Type Date Requested Status
elementary Pantheon team Pending
Review via email: mp+129942@code.launchpad.net
To post a comment you must log in.
284. By Andrea Basso

Little improvements in variable naming

Unmerged revisions

284. By Andrea Basso

Little improvements in variable naming

283. By Andrea Basso

Icons are displayed correctly, even in search view

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Backend/App.vala'
2--- src/Backend/App.vala 2012-09-16 16:53:01 +0000
3+++ src/Backend/App.vala 2012-10-16 16:48:21 +0000
4@@ -30,6 +30,8 @@
5 public double popularity { get; set; }
6 public double relevancy { get; set; }
7 public string desktop_path { get; private set; }
8+
9+ private unowned GLib.DesktopAppInfo info;
10
11 private bool is_command = false;
12
13@@ -38,7 +40,7 @@
14
15 public App (GMenu.TreeEntry entry) {
16
17- unowned GLib.DesktopAppInfo info = entry.get_app_info ();
18+ info = entry.get_app_info ();
19 name = info.get_display_name ().dup ();
20 description = info.get_description ().dup () ?? name;
21 exec = info.get_commandline ().dup ();
22@@ -80,35 +82,42 @@
23 update_icon ();
24
25 }
26-
27- public void update_icon () {
28-
29+
30+ private Gdk.Pixbuf private_get_scaled_icon (int size = Slingshot.settings.icon_size) {
31+
32+ Gdk.Pixbuf result;
33+
34 try {
35- icon = Slingshot.icon_theme.load_icon (icon_name, Slingshot.settings.icon_size,
36- Gtk.IconLookupFlags.FORCE_SIZE);
37+ result = Slingshot.icon_theme.load_icon (icon_name, size, Gtk.IconLookupFlags.FORCE_SIZE);
38 } catch (Error e) {
39 try {
40 if (icon_name.last_index_of (".") > 0)
41- icon = Slingshot.icon_theme.load_icon (icon_name[0:icon_name.last_index_of (".")],
42- Slingshot.settings.icon_size, Gtk.IconLookupFlags.FORCE_SIZE);
43+ result = Slingshot.icon_theme.load_icon (icon_name[0:icon_name.last_index_of (".")],
44+ size, Gtk.IconLookupFlags.FORCE_SIZE);
45 else
46 throw new IOError.NOT_FOUND ("Requested image could not be found.");
47
48 } catch (Error e) {
49 try {
50- icon = new Gdk.Pixbuf.from_file_at_scale (icon_name, Slingshot.settings.icon_size,
51- Slingshot.settings.icon_size, false);
52+ result = new Gdk.Pixbuf.from_file_at_scale (icon_name, size, size, false);
53 } catch (Error e) {
54 try {
55- icon = Slingshot.icon_theme.load_icon ("application-default-icon", Slingshot.settings.icon_size,
56+ result = Slingshot.icon_theme.load_icon ("application-default-icon", size,
57 Gtk.IconLookupFlags.FORCE_SIZE);
58 } catch (Error e) {
59- icon = Slingshot.icon_theme.load_icon ("gtk-missing-image", Slingshot.settings.icon_size,
60+ result = Slingshot.icon_theme.load_icon ("gtk-missing-image", size,
61 Gtk.IconLookupFlags.FORCE_SIZE);
62 }
63 }
64 }
65 }
66+
67+ return result;
68+ }
69+
70+ public void update_icon () {
71+
72+ icon = private_get_scaled_icon ();
73
74 icon_changed ();
75
76@@ -130,6 +139,24 @@
77 }
78
79 }
80+
81+ public Gdk.Pixbuf get_scaled_icon (int size) {
82+
83+ Gdk.Pixbuf result;
84+
85+ if (info.get_icon () is LoadableIcon) {
86+ try {
87+ var ios = (info.get_icon () as LoadableIcon).load (0, null, null);
88+ result = new Gdk.Pixbuf.from_stream_at_scale (ios, size, size, true, null);
89+ } catch {
90+ result = private_get_scaled_icon (size);
91+ }
92+ } else {
93+ result = private_get_scaled_icon (size);
94+ }
95+
96+ return result;
97+ }
98
99 }
100
101
102=== modified file 'src/Widgets/SearchItem.vala'
103--- src/Widgets/SearchItem.vala 2012-09-09 18:14:52 +0000
104+++ src/Widgets/SearchItem.vala 2012-10-16 16:48:21 +0000
105@@ -22,6 +22,8 @@
106 namespace Slingshot.Widgets {
107
108 public class SearchItem : Button {
109+
110+ private Backend.App app;
111
112 private Pixbuf icon;
113 private string icon_name;
114@@ -33,6 +35,8 @@
115 public signal void launch_app ();
116
117 public SearchItem (Backend.App app) {
118+
119+ this.app = app;
120
121 get_style_context ().add_class ("app");
122
123@@ -65,24 +69,8 @@
124 get_allocation (out size);
125
126 base.draw (cr);
127-
128- Pixbuf scaled_icon = null;
129- try {
130- scaled_icon = Slingshot.icon_theme.load_icon (icon_name, icon_size,
131- Gtk.IconLookupFlags.FORCE_SIZE);
132- } catch (Error e) {
133- try {
134- scaled_icon = new Gdk.Pixbuf.from_file_at_scale (icon_name, icon_size, icon_size, false);
135- } catch (Error e) {
136- try {
137- scaled_icon = Slingshot.icon_theme.load_icon ("application-default-icon", icon_size,
138- Gtk.IconLookupFlags.FORCE_SIZE);
139- } catch (Error e) {
140- scaled_icon = Slingshot.icon_theme.load_icon ("gtk-missing-image", icon_size,
141- Gtk.IconLookupFlags.FORCE_SIZE);
142- }
143- }
144- }
145+
146+ Pixbuf scaled_icon = app.get_scaled_icon (icon_size);
147
148 height_request = icon_size + 10;
149

Subscribers

People subscribed via source and target branches