Merge lp:~voldyman/slingshot/fix-install-exp into lp:~elementary-pantheon/slingshot/trunk

Proposed by Akshay Shekher
Status: Merged
Approved by: David Gomes
Approved revision: 426
Merged at revision: 426
Proposed branch: lp:~voldyman/slingshot/fix-install-exp
Merge into: lp:~elementary-pantheon/slingshot/trunk
Diff against target: 176 lines (+55/-13)
5 files modified
AUTHORS (+1/-0)
src/Backend/App.vala (+46/-11)
src/SlingshotView.vala (+1/-1)
src/Widgets/AppEntry.vala (+4/-1)
src/Widgets/Switcher.vala (+3/-0)
To merge this branch: bzr merge lp:~voldyman/slingshot/fix-install-exp
Reviewer Review Type Date Requested Status
David Gomes (community) Approve
Review via email: mp+225866@code.launchpad.net

Commit message

Fixes buggy rendering of app icons right after installing them.

Description of the change

This branch fixes the buggy rendering of the app icons when installing

To post a comment you must log in.
Revision history for this message
David Gomes (davidgomes) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'AUTHORS'
--- AUTHORS 2012-06-20 22:40:16 +0000
+++ AUTHORS 2014-07-07 17:05:07 +0000
@@ -4,3 +4,4 @@
4 * Giulio Collura <random.cpp@gmail.com>4 * Giulio Collura <random.cpp@gmail.com>
5 * Maxwell Barvian5 * Maxwell Barvian
6 * Andrea Basso <andrea@elementaryos.org>6 * Andrea Basso <andrea@elementaryos.org>
7 * Akshay Shekher <akshay@elementaryos.org>
78
=== modified file 'src/Backend/App.vala'
--- src/Backend/App.vala 2014-06-12 09:36:00 +0000
+++ src/Backend/App.vala 2014-07-07 17:05:07 +0000
@@ -1,6 +1,7 @@
1// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-1// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
2//2//
3// Copyright (C) 2011-2012 Giulio Collura3// Copyright (C) 2011-2012 Giulio Collura
4// 2013-2014 Akshay Shekher
4//5//
5// This program is free software: you can redistribute it and/or modify6// This program is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by7// it under the terms of the GNU General Public License as published by
@@ -50,6 +51,12 @@
50 public signal void icon_changed ();51 public signal void icon_changed ();
51 public signal void launched (App app);52 public signal void launched (App app);
5253
54 // seconds to wait before retrying icon check
55 private const int RECHECK_TIMEOUT = 2;
56 private bool check_icon_again = true;
57
58 private LoadableIcon loadable_icon = null;
59
53 public App (GMenu.TreeEntry entry) {60 public App (GMenu.TreeEntry entry) {
54 app_type = AppType.APP;61 app_type = AppType.APP;
5562
@@ -68,21 +75,16 @@
68 if (info.get_icon () is ThemedIcon) {75 if (info.get_icon () is ThemedIcon) {
69 icon_name = (info.get_icon () as ThemedIcon).get_names ()[0].dup ();76 icon_name = (info.get_icon () as ThemedIcon).get_names ()[0].dup ();
70 } else if (info.get_icon () is LoadableIcon) {77 } else if (info.get_icon () is LoadableIcon) {
71 try {78 loadable_icon = info.get_icon () as LoadableIcon;
72 var ios = (info.get_icon () as LoadableIcon).load (0, null, null);79 icon = get_loadable_icon ();
73 icon = new Gdk.Pixbuf.from_stream_at_scale (ios, Slingshot.settings.icon_size,
74 Slingshot.settings.icon_size, true, null);
75 } catch {
76 icon_name = "application-default-icon";
77 }
78 } else {80 } else {
79 icon_name = "application-default-icon";81 icon_name = "application-default-icon";
80 }82 }
8183 if (icon == null) {
82 if (icon == null)
83 update_icon ();84 update_icon ();
8485
85 Slingshot.icon_theme.changed.connect (update_icon);86 Slingshot.icon_theme.changed.connect (update_icon);
87 }
86 }88 }
8789
88 public App.from_command (string command) {90 public App.from_command (string command) {
@@ -113,8 +115,13 @@
113115
114 }116 }
115117
118 ~App () {
119 Slingshot.icon_theme.changed.disconnect (update_icon);
120 }
121
116 public void update_icon () {122 public void update_icon () {
117 icon = load_icon (Slingshot.settings.icon_size);123 icon = load_icon (Slingshot.settings.icon_size);
124
118 icon_changed ();125 icon_changed ();
119 }126 }
120127
@@ -156,6 +163,9 @@
156 Gdk.Pixbuf icon = null;163 Gdk.Pixbuf icon = null;
157 var flags = Gtk.IconLookupFlags.FORCE_SIZE;164 var flags = Gtk.IconLookupFlags.FORCE_SIZE;
158165
166 if (loadable_icon != null)
167 return get_loadable_icon ();
168
159 IconLoadFallbackMethod[] fallbacks = {169 IconLoadFallbackMethod[] fallbacks = {
160 new IconLoadFallbackMethod (() => {170 new IconLoadFallbackMethod (() => {
161 try {171 try {
@@ -166,6 +176,20 @@
166 }),176 }),
167177
168 new IconLoadFallbackMethod (() => {178 new IconLoadFallbackMethod (() => {
179 // Since the best method didn't work retry after some time
180 if (check_icon_again) {
181 // only recheck once
182 check_icon_again = false;
183
184 Timeout.add_seconds (RECHECK_TIMEOUT, () => {
185 Slingshot.icon_theme.rescan_if_needed ();
186 update_icon ();
187 return false;
188 });
189 }
190 }),
191
192 new IconLoadFallbackMethod (() => {
169 try {193 try {
170 if (icon_name.last_index_of (".") > 0) {194 if (icon_name.last_index_of (".") > 0) {
171 var name = icon_name[0:icon_name.last_index_of (".")];195 var name = icon_name[0:icon_name.last_index_of (".")];
@@ -200,7 +224,6 @@
200 }224 }
201 })225 })
202 };226 };
203
204 foreach (IconLoadFallbackMethod fallback in fallbacks) {227 foreach (IconLoadFallbackMethod fallback in fallbacks) {
205 fallback.load_icon ();228 fallback.load_icon ();
206 if (icon != null)229 if (icon != null)
@@ -210,6 +233,18 @@
210 return icon;233 return icon;
211 }234 }
212235
236 public Gdk.Pixbuf? get_loadable_icon () {
237 Gdk.Pixbuf? tmp_loadable_icon;
238 try {
239 var icon_stream = loadable_icon.load (0, null, null);
240 tmp_loadable_icon = new Gdk.Pixbuf.from_stream_at_scale (icon_stream, Slingshot.settings.icon_size,
241 Slingshot.settings.icon_size, true, null);
242 } catch (Error e) {
243 tmp_loadable_icon = null;
244 }
245 return tmp_loadable_icon;
246 }
247
213 public bool launch () {248 public bool launch () {
214 try {249 try {
215 switch (app_type) {250 switch (app_type) {
216251
=== modified file 'src/SlingshotView.vala'
--- src/SlingshotView.vala 2014-06-12 09:14:57 +0000
+++ src/SlingshotView.vala 2014-07-07 17:05:07 +0000
@@ -812,8 +812,8 @@
812 app_entry.show_all ();812 app_entry.show_all ();
813 }813 }
814814
815
815 stack.set_visible_child_name ("normal");816 stack.set_visible_child_name ("normal");
816
817 }817 }
818818
819 private void read_settings (bool first_start = false, bool check_columns = true, bool check_rows = true) {819 private void read_settings (bool first_start = false, bool check_columns = true, bool check_rows = true) {
820820
=== modified file 'src/Widgets/AppEntry.vala'
--- src/Widgets/AppEntry.vala 2014-02-24 20:43:38 +0000
+++ src/Widgets/AppEntry.vala 2014-07-07 17:05:07 +0000
@@ -84,7 +84,10 @@
84 sel.set_uris ({File.new_for_path (desktop_path).get_uri ()});84 sel.set_uris ({File.new_for_path (desktop_path).get_uri ()});
85 });85 });
8686
87 app.icon_changed.connect (queue_draw);87 app.icon_changed.connect (() => {
88 icon = app.icon;
89 queue_draw ();
90 });
8891
89 }92 }
9093
9194
=== modified file 'src/Widgets/Switcher.vala'
--- src/Widgets/Switcher.vala 2014-02-24 20:43:38 +0000
+++ src/Widgets/Switcher.vala 2014-07-07 17:05:07 +0000
@@ -66,6 +66,9 @@
66 buttons.set (widget, button);66 buttons.set (widget, button);
67 if (buttons.size == 1)67 if (buttons.size == 1)
68 button.active = true;68 button.active = true;
69
70 // show all children after update
71 show_all ();
69 }72 }
70 73
71 public override void show () {74 public override void show () {

Subscribers

People subscribed via source and target branches