diff options
author | Brendan Long <self@brendanlong.com> | 2017-10-10 01:39:11 +0300 |
---|---|---|
committer | Brendan Long <self@brendanlong.com> | 2017-10-10 18:08:19 +0300 |
commit | 6d7e9501167d9e78d9c8cd15a9f50f74bcdcd2d7 (patch) | |
tree | 9e67b0e5c84d4e7a4c7c368f7452c20218671003 | |
parent | 2eec57c58fc623fe6d96649220e8f0624db85269 (diff) |
Fix favicons on the local account setup page
-rw-r--r-- | plugins/backend/local/SuggestedFeedRow.vala | 51 |
1 files changed, 24 insertions, 27 deletions
diff --git a/plugins/backend/local/SuggestedFeedRow.vala b/plugins/backend/local/SuggestedFeedRow.vala index caa73e8e..07d7bc66 100644 --- a/plugins/backend/local/SuggestedFeedRow.vala +++ b/plugins/backend/local/SuggestedFeedRow.vala @@ -63,36 +63,33 @@ public class FeedReader.SuggestedFeedRow : Gtk.ListBoxRow { var uri = new Soup.URI(url); var fakeFeed = new Feed(uri.get_host(), "", "", 0); - Utils.downloadIcon.begin(fakeFeed, iconURL, null, "/tmp/", (obj, res) => { - bool success = Utils.downloadIcon.end(res); - Gtk.Image? icon = null; - - if(success) - { - try - { - string filename = "/tmp/" + uri.get_host().replace("/", "_").replace(".", "_") + ".ico"; - Logger.debug("load icon %s".printf(filename)); - var tmp_icon = new Gdk.Pixbuf.from_file_at_scale(filename, 24, 24, true); - icon = new Gtk.Image.from_pixbuf(tmp_icon); - } - catch(GLib.Error e) - { - Logger.error("SuggestedFeedRow.constructor: %s".printf(e.message)); - icon = new Gtk.Image.from_icon_name("feed-rss-symbolic", Gtk.IconSize.LARGE_TOOLBAR); - } - } - else - { - icon = new Gtk.Image.from_icon_name("feed-rss-symbolic", Gtk.IconSize.LARGE_TOOLBAR); - } - - iconStack.add_named(icon, "icon"); - show_all(); - iconStack.set_visible_child_name("icon"); + load_favicon.begin(iconStack, fakeFeed, iconURL, (obj, res) => { + load_favicon.end(res); }); } + private async void load_favicon(Gtk.Stack iconStack, Feed feed, string iconURL) + { + bool success = yield Utils.downloadIcon(feed, iconURL, null); + + Gtk.Image? icon = null; + if(success) + { + var pixBuf = yield FavIconCache.get_default().getIcon(feed.getFeedID()); + if(pixBuf != null) + icon = new Gtk.Image.from_pixbuf(pixBuf); + } + + if(icon == null) + { + icon = new Gtk.Image.from_icon_name("feed-rss-symbolic", Gtk.IconSize.LARGE_TOOLBAR); + } + + iconStack.add_named(icon, "icon"); + show_all(); + iconStack.set_visible_child_name("icon"); + } + public bool checked() { return m_check.active; |