diff options
author | Brendan Long <self@brendanlong.com> | 2019-02-20 20:49:38 +0300 |
---|---|---|
committer | Brendan Long <self@brendanlong.com> | 2019-02-20 21:12:04 +0300 |
commit | 33e9ebee64be11fc7f9bbaecaa2ab661f01e0869 (patch) | |
tree | 56039bd62acb4b057159b60578e5ceb93af4e2c7 /src | |
parent | 7291e166156731daa168baa83a0718d8c950c085 (diff) |
Add braces around all if/else/while/etc statements
This will make it easier to programatically fix the indentation.
Diffstat (limited to 'src')
63 files changed, 1397 insertions, 118 deletions
diff --git a/src/ActionCache.vala b/src/ActionCache.vala index 36413376..8bb8285d 100644 --- a/src/ActionCache.vala +++ b/src/ActionCache.vala @@ -29,7 +29,9 @@ private static ActionCache? m_cache = null; public static ActionCache get_default() { if(m_cache == null) + { m_cache = new ActionCache(); + } return m_cache; } @@ -43,7 +45,9 @@ public void markArticleRead(string id, ArticleStatus read) { var cachedAction = CachedActions.MARK_READ; if(read == ArticleStatus.UNREAD) + { cachedAction = CachedActions.MARK_UNREAD; + } var action = new CachedAction(cachedAction, id, ""); addAction(action); @@ -53,7 +57,9 @@ public void markArticleStarred(string id, ArticleStatus marked) { var cachedAction = CachedActions.MARK_STARRED; if(marked == ArticleStatus.UNMARKED) + { cachedAction = CachedActions.MARK_UNSTARRED; + } var action = new CachedAction(cachedAction, id, ""); addAction(action); @@ -126,7 +132,9 @@ private void removeForFeed(string feedID) || a.getType() == CachedActions.MARK_UNREAD) { if (db == null) + { db = DataBase.readOnly(); + } if(feedID == db.getFeedIDofArticle(a.getID())) { m_list.remove(a); @@ -174,9 +182,13 @@ public ArticleStatus checkStarred(string articleID, ArticleStatus marked) { var type = CachedActions.NONE; if(marked == ArticleStatus.UNMARKED) + { type = CachedActions.MARK_STARRED; + } else if(marked == ArticleStatus.MARKED) + { type = CachedActions.MARK_UNSTARRED; + } foreach(CachedAction a in m_list) { @@ -184,10 +196,14 @@ public ArticleStatus checkStarred(string articleID, ArticleStatus marked) && a.getID() == articleID) { if(type == CachedActions.MARK_STARRED) + { return ArticleStatus.MARKED; + } if(type == CachedActions.MARK_UNSTARRED) + { return ArticleStatus.UNMARKED; + } } } @@ -202,7 +218,9 @@ public ArticleStatus checkRead(Article a) { if(action.getType() == CachedActions.MARK_UNREAD && action.getID() == a.getArticleID()) + { return ArticleStatus.UNREAD; + } } } else if(a.getUnread() == ArticleStatus.UNREAD) @@ -217,17 +235,23 @@ public ArticleStatus checkRead(Article a) case CachedActions.MARK_READ_FEED: if(action.getID() == a.getFeedID()) + { return ArticleStatus.READ; + } break; case CachedActions.MARK_READ_CATEGORY: if (db == null) + { db = DataBase.readOnly(); + } var feedIDs = db.getFeedIDofCategorie(a.getArticleID()); foreach(string feedID in feedIDs) { if(feedID == a.getFeedID()) + { return ArticleStatus.READ; + } } break; } diff --git a/src/Backend/Backend.vala b/src/Backend/Backend.vala index a60197f7..a315c4f2 100644 --- a/src/Backend/Backend.vala +++ b/src/Backend/Backend.vala @@ -48,7 +48,9 @@ private static FeedReaderBackend? m_backend; public static FeedReaderBackend get_default() { if(m_backend == null) + { m_backend = new FeedReaderBackend(); + } return m_backend; } @@ -59,9 +61,13 @@ private FeedReaderBackend() var plugID = Settings.general().get_string("plugin"); if(plugID == "none") + { m_loggedin = LoginResponse.NO_BACKEND; + } else + { login(plugID); + } #if LIBUNITY m_launcher = Unity.LauncherEntry.get_for_desktop_id("org.gnome.FeedReader.desktop"); @@ -171,7 +177,9 @@ public void scheduleSync(int time) } if(time == 0) + { return; + } m_timeout_source_id = GLib.Timeout.add_seconds_full(GLib.Priority.DEFAULT, time*60, () => { if(!Settings.state().get_boolean("currently-updating") @@ -206,7 +214,9 @@ private void sync(bool initSync = false, GLib.Cancellable? cancellable = null) } if(cancellable != null && cancellable.is_cancelled()) + { return; + } Logger.info("backend: sync started"); syncStarted(); @@ -228,9 +238,13 @@ private void sync(bool initSync = false, GLib.Cancellable? cancellable = null) m_cacheSync = true; if(initSync && FeedServer.get_default().doInitSync()) + { FeedServer.get_default().InitSyncContent(cancellable); + } else + { FeedServer.get_default().syncContent(cancellable); + } if(cancellable != null && cancellable.is_cancelled()) { @@ -294,7 +308,9 @@ public bool checkOnline() public async bool checkOnlineAsync() { if(!FeedServer.get_default().pluginLoaded()) + { return false; + } Logger.debug("backend: checkOnlineAsync"); bool online = false; @@ -362,11 +378,15 @@ public bool isOnline() public void updateArticleRead(Article article) { if(m_offline) + { CachedActionManager.get_default().markArticleRead(article.getArticleID(), article.getUnread()); + } else { if(m_cacheSync) + { ActionCache.get_default().markArticleRead(article.getArticleID(), article.getUnread()); + } asyncPayload pl = () => { FeedServer.get_default().setArticleIsRead(article.getArticleID(), article.getUnread()); }; callAsync.begin((owned)pl, (obj, res) => { callAsync.end(res); }); @@ -383,11 +403,15 @@ public void updateArticleRead(Article article) public void updateArticleMarked(Article article) { if(m_offline) + { CachedActionManager.get_default().markArticleStarred(article.getArticleID(), article.getMarked()); + } else { if(m_cacheSync) + { ActionCache.get_default().markArticleStarred(article.getArticleID(), article.getMarked()); + } asyncPayload pl = () => { FeedServer.get_default().setArticleIsMarked(article.getArticleID(), article.getMarked()); }; callAsync.begin((owned)pl, (obj, res) => { callAsync.end(res); }); } @@ -404,7 +428,9 @@ public void updateArticleMarked(Article article) public Tag? createTag(string caption) { if(m_offline) + { return null; + } string tagID = FeedServer.get_default().createTag(caption); var tag = new Tag(tagID, caption, 0); @@ -417,7 +443,9 @@ public Tag? createTag(string caption) public void tagArticle(Article article, Tag tag, bool add) { if(m_offline) + { return; + } if(add) { @@ -457,7 +485,9 @@ public void tagArticle(Article article, Tag tag, bool add) public Tag renameTag(Tag tag, string newName) { if(m_offline) + { return tag; + } tag.setTitle(newName); @@ -476,7 +506,9 @@ public Tag renameTag(Tag tag, string newName) public void deleteTag(Tag tag) { if(m_offline) + { return; + } asyncPayload pl = () => { FeedServer.get_default().deleteTag(tag.getTagID()); }; callAsync.begin((owned)pl, (obj, res) => { callAsync.end(res); }); @@ -526,24 +558,36 @@ public void markFeedAsRead(string feedID, bool isCat) if(m_offline) { if(useID) + { CachedActionManager.get_default().markArticleRead(articleIDs, ArticleStatus.READ); + } else + { CachedActionManager.get_default().markCategoryRead(feedID); + } } else { if(m_cacheSync) { if(useID) + { ActionCache.get_default().markArticleRead(articleIDs, ArticleStatus.READ); + } else + { ActionCache.get_default().markCategoryRead(feedID); + } } asyncPayload pl = () => { if(useID) + { FeedServer.get_default().setArticleIsRead(articleIDs, ArticleStatus.READ); + } else + { FeedServer.get_default().setCategoryRead(feedID); + } }; callAsync.begin((owned)pl, (obj, res) => { callAsync.end(res); }); } @@ -561,24 +605,36 @@ public void markFeedAsRead(string feedID, bool isCat) if(m_offline) { if(useID) + { CachedActionManager.get_default().markArticleRead(articleIDs, ArticleStatus.READ); + } else + { CachedActionManager.get_default().markFeedRead(feedID); + } } else { if(m_cacheSync) { if(useID) + { ActionCache.get_default().markArticleRead(articleIDs, ArticleStatus.READ); + } else + { ActionCache.get_default().markFeedRead(feedID); + } } asyncPayload pl = () => { if(useID) + { FeedServer.get_default().setArticleIsRead(articleIDs, ArticleStatus.READ); + } else + { FeedServer.get_default().setFeedRead(feedID); + } }; callAsync.begin((owned)pl, (obj, res) => { callAsync.end(res); }); } @@ -611,24 +667,36 @@ public void markAllItemsRead() if(m_offline) { if(useID) + { CachedActionManager.get_default().markArticleRead(articleIDs, ArticleStatus.READ); + } else + { CachedActionManager.get_default().markAllRead(); + } } else { if(m_cacheSync) { if(useID) + { ActionCache.get_default().markArticleRead(articleIDs, ArticleStatus.READ); + } else + { ActionCache.get_default().markAllRead(); + } } asyncPayload pl = () => { if(useID) + { FeedServer.get_default().setArticleIsRead(articleIDs, ArticleStatus.READ); + } else + { FeedServer.get_default().markAllItemsRead(); + } }; callAsync.begin((owned)pl, (obj, res) => { callAsync.end(res); }); } @@ -788,9 +856,13 @@ public void addFeed(string feedURL, string cat, bool isID) if(cat != "") { if(isID) + { catID = cat; + } else + { newCatName = cat; + } } string errmsg; @@ -849,9 +921,13 @@ public void updateBadge() Logger.debug("backend: update badge count %u".printf(count)); m_launcher.count = count; if(count > 0) + { m_launcher.count_visible = true; + } else + { m_launcher.count_visible = false; + } } #endif } diff --git a/src/Backend/FeedServer.vala b/src/Backend/FeedServer.vala index 58ef831e..9ecd0ac1 100644 --- a/src/Backend/FeedServer.vala +++ b/src/Backend/FeedServer.vala @@ -29,7 +29,9 @@ private static FeedServer? m_server; public static FeedServer get_default() { if(m_server == null) + { m_server = new FeedServer(); + } return m_server; } @@ -54,7 +56,9 @@ private FeedServer() // so lookup the alias before trying to create it. var secrets = Secret.Collection.for_alias_sync(secret_service, Secret.COLLECTION_DEFAULT, Secret.CollectionFlags.NONE); if(secrets == null) - secrets = Secret.Collection.create_sync(secret_service, "Login", Secret.COLLECTION_DEFAULT, Secret.CollectionCreateFlags.COLLECTION_CREATE_NONE); + { + secrets = Secret.Collection.create_sync(secret_service, "Login", Secret.COLLECTION_DEFAULT, Secret.CollectionCreateFlags.COLLECTION_CREATE_NONE); + } var settings_backend = null; // FIXME: Why does SettingsBackend.get_default() crash on Arch Linux? (extension as FeedServerInterface).init(settings_backend, secrets); @@ -182,7 +186,9 @@ public void syncContent(GLib.Cancellable? cancellable = null) var tags = new Gee.LinkedList<Tag>(); if(cancellable != null && cancellable.is_cancelled()) + { return; + } syncProgress(_("Getting feeds and categories")); @@ -193,10 +199,14 @@ public void syncContent(GLib.Cancellable? cancellable = null) } if(cancellable != null && cancellable.is_cancelled()) + { return; + } if(cancellable != null && cancellable.is_cancelled()) + { return; + } // write categories db.reset_exists_flag(); @@ -219,7 +229,9 @@ public void syncContent(GLib.Cancellable? cancellable = null) } if(cancellable != null && cancellable.is_cancelled()) + { return; + } var drop_articles = (DropArticles)Settings.general().get_enum("drop-articles-after"); DateTime? since = drop_articles.to_start_date(); @@ -251,7 +263,9 @@ public void syncContent(GLib.Cancellable? cancellable = null) } if(cancellable != null && cancellable.is_cancelled()) + { return; + } //update fulltext table db.updateFTS(); @@ -267,7 +281,9 @@ public void syncContent(GLib.Cancellable? cancellable = null) var drop_weeks = drop_articles.to_weeks(); if(drop_weeks != null) + { db.dropOldArticles(-(int)drop_weeks); + } var now = new DateTime.now_local(); Settings.state().set_int("last-sync", (int)now.to_unix()); @@ -293,10 +309,14 @@ public void InitSyncContent(GLib.Cancellable? cancellable = null) getFeedsAndCats(feeds, categories, tags, cancellable); if(cancellable != null && cancellable.is_cancelled()) + { return; + } if(cancellable != null && cancellable.is_cancelled()) + { return; + } // write categories db.write_categories(categories); @@ -311,7 +331,9 @@ public void InitSyncContent(GLib.Cancellable? cancellable = null) } if(cancellable != null && cancellable.is_cancelled()) + { return; + } var drop_articles = (DropArticles)Settings.general().get_enum("drop-articles-after"); DateTime? since = drop_articles.to_start_date(); @@ -321,7 +343,9 @@ public void InitSyncContent(GLib.Cancellable? cancellable = null) getArticles(Settings.general().get_int("max-articles"), ArticleStatus.MARKED, since, null, false, cancellable); if(cancellable != null && cancellable.is_cancelled()) + { return; + } // get articles for each tag syncProgress(_("Getting tagged articles")); @@ -329,7 +353,9 @@ public void InitSyncContent(GLib.Cancellable? cancellable = null) { getArticles((Settings.general().get_int("max-articles")/8), ArticleStatus.ALL, since, tag_item.getTagID(), true, cancellable); if(cancellable != null && cancellable.is_cancelled()) + { return; + } } if(useMaxArticles()) @@ -339,14 +365,18 @@ public void InitSyncContent(GLib.Cancellable? cancellable = null) } if(cancellable != null && cancellable.is_cancelled()) + { return; + } // get unread articles syncProgress(_("Getting unread articles")); getArticles(getUnreadCount(), ArticleStatus.UNREAD, since, null, false, cancellable); if(cancellable != null && cancellable.is_cancelled()) + { return; + } //update fulltext table db.updateFTS(); @@ -383,7 +413,9 @@ public async void grabContent(GLib.Cancellable? cancellable = null) { if(!Settings.general().get_boolean("download-images") && !Settings.general().get_boolean("content-grabber")) + { return; + } Logger.debug("FeedServer: grabContent"); var db = DataBase.writeAccess(); @@ -404,7 +436,9 @@ public async void grabContent(GLib.Cancellable? cancellable = null) { var threads = new ThreadPool<Article>.with_owned_data((article) => { if(cancellable != null && cancellable.is_cancelled()) - return; + { + return; + } if(Settings.general().get_boolean("content-grabber")) { @@ -443,9 +477,9 @@ public async void grabContent(GLib.Cancellable? cancellable = null) if(cancellable == null || !cancellable.is_cancelled()) { - mutex.lock(); - new_article_content.add(article); - mutex.unlock(); + mutex.lock(); + new_article_content.add(article); + mutex.unlock(); } ++i; @@ -469,12 +503,16 @@ public async void grabContent(GLib.Cancellable? cancellable = null) foreach(var content in new_article_content) { if (cancellable != null && cancellable.is_cancelled()) + { return; + } db.writeContent(content); } if (cancellable != null && cancellable.is_cancelled()) + { return; + } //update fulltext table db.updateFTS(); @@ -484,7 +522,9 @@ public async void grabContent(GLib.Cancellable? cancellable = null) private void downloadImages(Soup.Session session, Article article, GLib.Cancellable? cancellable = null) { if(!Settings.general().get_boolean("download-images")) + { return; + } var html_cntx = new Html.ParserCtxt(); html_cntx.use_options(Html.ParserOption.NOERROR + Html.ParserOption.NOWARNING); @@ -522,7 +562,9 @@ private void downloadImages(Soup.Session session, Article article, GLib.Cancella private int ArticleSyncCount() { if(!useMaxArticles()) + { return -1; + } return Settings.general().get_int("max-articles"); } @@ -564,14 +606,18 @@ public static void grabArticle(string url) string path = GLib.Environment.get_user_data_dir() + "/feedreader/debug-article/%s.html".printf(title); if(FileUtils.test(path, GLib.FileTest.EXISTS)) + { GLib.FileUtils.remove(path); + } try { var file = GLib.File.new_for_path(path); var parent = file.get_parent(); if(!parent.query_exists()) + { parent.make_directory_with_parents(); + } var stream = file.create(FileCreateFlags.REPLACE_DESTINATION); @@ -592,7 +638,9 @@ public static void grabArticle(string url) path = GLib.Environment.get_user_data_dir() + "/feedreader/debug-article/%s.txt".printf(title); if(FileUtils.test(path, GLib.FileTest.EXISTS)) + { GLib.FileUtils.remove(path); + } file = GLib.File.new_for_path(path); stream = file.create(FileCreateFlags.REPLACE_DESTINATION); @@ -657,9 +705,13 @@ public static void grabImages(string htmlFile, string url) html = html.replace(broken_iframe, fixed_iframe); int pos3 = html.index_of("<iframe", pos1+7); if(pos3 == pos1) + { break; + } else + { pos1 = pos3; + } } try @@ -679,7 +731,9 @@ public static void grabImages(string htmlFile, string url) public bool supportTags() { if(!m_pluginLoaded) + { return false; + } return m_plugin.supportTags(); } @@ -687,7 +741,9 @@ public bool supportTags() public bool doInitSync() { if(!m_pluginLoaded) + { return false; + } return m_plugin.doInitSync(); } @@ -697,7 +753,9 @@ public string symbolicIcon() Logger.debug("feedserver: symbolicIcon"); if(!m_pluginLoaded) + { return "none"; + } return m_plugin.symbolicIcon(); } @@ -705,7 +763,9 @@ public string symbolicIcon() public string accountName() { if(!m_pluginLoaded) + { return "none"; + } return m_plugin.accountName(); } @@ -713,7 +773,9 @@ public string accountName() public string getServerURL() { if(!m_pluginLoaded) + { return "none"; + } return m_plugin.getServerURL(); } @@ -721,7 +783,9 @@ public string getServerURL() public string uncategorizedID() { if(!m_pluginLoaded) + { return ""; + } return m_plugin.uncategorizedID(); } @@ -729,7 +793,9 @@ public string uncategorizedID() public bool hideCategoryWhenEmpty(string catID) { if(!m_pluginLoaded) + { return false; + } return m_plugin.hideCategoryWhenEmpty(catID); } @@ -737,7 +803,9 @@ public bool hideCategoryWhenEmpty(string catID) public bool supportCategories() { if(!m_pluginLoaded) + { return false; + } return m_plugin.supportCategories(); } @@ -745,7 +813,9 @@ public bool supportCategories() public bool supportFeedManipulation() { if(!m_pluginLoaded) + { return false; + } return m_plugin.supportFeedManipulation(); } @@ -753,7 +823,9 @@ public bool supportFeedManipulation() public bool supportMultiLevelCategories() { if(!m_pluginLoaded) + { return false; + } return m_plugin.supportMultiLevelCategories(); } @@ -761,7 +833,9 @@ public bool supportMultiLevelCategories() public bool supportMultiCategoriesPerFeed() { if(!m_pluginLoaded) + { return false; + } return m_plugin.supportMultiCategoriesPerFeed(); } @@ -769,7 +843,9 @@ public bool supportMultiCategoriesPerFeed() public bool syncFeedsAndCategories() { if(!m_pluginLoaded) + { return false; + } return m_plugin.syncFeedsAndCategories(); } @@ -779,7 +855,9 @@ public bool syncFeedsAndCategories() public bool tagIDaffectedByNameChange() { if(!m_pluginLoaded) + { return false; + } return m_plugin.tagIDaffectedByNameChange(); } @@ -787,7 +865,9 @@ public bool tagIDaffectedByNameChange() public void resetAccount() { if(!m_pluginLoaded) + { return; + } m_plugin.resetAccount(); } @@ -796,7 +876,9 @@ public void resetAccount() public bool useMaxArticles() { if(!m_pluginLoaded) + { return true; + } return m_plugin.useMaxArticles(); } @@ -809,7 +891,9 @@ public LoginResponse login() public bool logout() { if(!m_pluginLoaded) + { return false; + } return m_plugin.logout(); } @@ -817,7 +901,9 @@ public bool logout() public void setArticleIsRead(string articleIDs, ArticleStatus read) { if(!m_pluginLoaded) + { return; + } m_plugin.setArticleIsRead(articleIDs, read); } @@ -825,7 +911,9 @@ public void setArticleIsRead(string articleIDs, ArticleStatus read) public void setArticleIsMarked(string articleID, ArticleStatus marked) { if(!m_pluginLoaded) + { return; + } m_plugin.setArticleIsMarked(articleID, marked); } @@ -833,7 +921,9 @@ public void setArticleIsMarked(string articleID, ArticleStatus marked) public bool alwaysSetReadByID() { if(!m_pluginLoaded) + { return false; + } return m_plugin.alwaysSetReadByID(); } @@ -841,7 +931,9 @@ public bool alwaysSetReadByID() public void setFeedRead(string feedID) { if(!m_pluginLoaded) + { return; + } m_plugin.setFeedRead(feedID); } @@ -849,7 +941,9 @@ public void setFeedRead(string feedID) public void setCategoryRead(string catID) { if(!m_pluginLoaded) + { return; + } m_plugin.setCategoryRead(catID); } @@ -857,7 +951,9 @@ public void setCategoryRead(string catID) public void markAllItemsRead() { if(!m_pluginLoaded) + { return; + } m_plugin.markAllItemsRead(); } @@ -865,7 +961,9 @@ public void markAllItemsRead() public void tagArticle(Article article, Tag tag) { if(!m_pluginLoaded) + { return; + } m_plugin.tagArticle(article.getArticleID(), tag.getTagID()); } @@ -873,7 +971,9 @@ public void tagArticle(Article article, Tag tag) public void removeArticleTag(Article article, Tag tag) { if(!m_pluginLoaded) + { return; + } m_plugin.removeArticleTag(article.getArticleID(), tag.getTagID()); } @@ -881,7 +981,9 @@ public void removeArticleTag(Article article, Tag tag) public string createTag(string caption) { if(!m_pluginLoaded) + { return ""; + } return m_plugin.createTag(caption); } @@ -889,7 +991,9 @@ public string createTag(string caption) public void deleteTag(string tagID) { if(!m_pluginLoaded) + { return; + } m_plugin.deleteTag(tagID); } @@ -897,7 +1001,9 @@ public void deleteTag(string tagID) public void renameTag(string tagID, string title) { if(!m_pluginLoaded) + { return; + } m_plugin.renameTag(tagID, title); } @@ -905,21 +1011,26 @@ public void renameTag(string tagID, string title) public bool serverAvailable() { if(!m_pluginLoaded) + { return false; + } return m_plugin.serverAvailable(); } public bool addFeed(string feedURL, string? catID, string? newCatName, out string? feedID, out string errmsg) { - if(!m_pluginLoaded) { + if(!m_pluginLoaded) + { feedID = null; errmsg = "Plugin not loaded"; return false; } if(!m_plugin.addFeed(feedURL, catID, newCatName, out feedID, out errmsg)) + { return false; + } int maxArticles = ArticleSyncCount(); DateTime? since = ((DropArticles)Settings.general().get_enum("drop-articles-after")).to_start_date(); @@ -932,7 +1043,9 @@ public bool addFeed(string feedURL, string? catID, string? newCatName, out strin public void addFeeds(Gee.List<Feed> feeds) { if(!m_pluginLoaded) + { return; + } m_plugin.addFeeds(feeds); } @@ -940,7 +1053,9 @@ public void addFeeds(Gee.List<Feed> feeds) public void removeFeed(string feedID) { if(!m_pluginLoaded) + { return; + } m_plugin.removeFeed(feedID); } @@ -948,7 +1063,9 @@ public void removeFeed(string feedID) public void renameFeed(string feedID, string title) { if(!m_pluginLoaded) + { return; + } m_plugin.renameFeed(feedID, title); } @@ -956,7 +1073,9 @@ public void renameFeed(string feedID, string title) public void moveFeed(string feedID, string newCatID, string? currentCatID = null) { if(!m_pluginLoaded) + { return; + } m_plugin.moveFeed(feedID, newCatID, currentCatID); } @@ -964,7 +1083,9 @@ public void moveFeed(string feedID, string newCatID, string? currentCatID = null public string createCategory(string title, string? parentID = null) { if(!m_pluginLoaded) + { return ""; + } return m_plugin.createCategory(title, parentID); } @@ -972,7 +1093,9 @@ public string createCategory(string title, string? parentID = null) public void renameCategory(string catID, string title) { if(!m_pluginLoaded) + { return; + } m_plugin.renameCategory(catID, title); } @@ -980,7 +1103,9 @@ public void renameCategory(string catID, string title) public void moveCategory(string catID, string newParentID) { if(!m_pluginLoaded) + { return; + } m_plugin.moveCategory(catID, newParentID); } @@ -988,7 +1113,9 @@ public void moveCategory(string catID, string newParentID) public void deleteCategory(string catID) { if(!m_pluginLoaded) + { return; + } m_plugin.deleteCategory(catID); } @@ -996,7 +1123,9 @@ public void deleteCategory(string catID) public void removeCatFromFeed(string feedID, string catID) { if(!m_pluginLoaded) + { return; + } m_plugin.removeCatFromFeed(feedID, catID); } @@ -1004,7 +1133,9 @@ public void removeCatFromFeed(string feedID, string catID) public void importOPML(string opml) { if(!m_pluginLoaded) + { return; + } m_plugin.importOPML(opml); } @@ -1012,7 +1143,9 @@ public void importOPML(string opml) public bool getFeedsAndCats(Gee.List<Feed> feeds, Gee.List<Category> categories, Gee.List<Tag> tags, GLib.Cancellable? cancellable = null) { if(!m_pluginLoaded) + { return false; + } return m_plugin.getFeedsAndCats(feeds, categories, tags); } @@ -1020,7 +1153,9 @@ public bool getFeedsAndCats(Gee.List<Feed> feeds, Gee.List<Category> categories, public int getUnreadCount() { if(!m_pluginLoaded) + { return 0; + } return m_plugin.getUnreadCount(); } diff --git a/src/Backend/OPMLparser.vala b/src/Backend/OPMLparser.vala index 6781ca51..aca553aa 100644 --- a/src/Backend/OPMLparser.vala +++ b/src/Backend/OPMLparser.vala @@ -41,7 +41,9 @@ public Gee.List<Feed> parse() Xml.Node* root = doc->get_root_element(); if(root->name != "opml") + { return m_feeds; + } Logger.debug("OPML version: " + root->get_prop("version")); @@ -101,7 +103,9 @@ private void parseTree(Xml.Node* root, string? catID = null) if(!hasProp(node, "xmlUrl")) { if(hasProp(node, "title") || !hasProp(node, "schema-version")) + { parseCat(node, catID); + } } else { @@ -116,9 +120,13 @@ private void parseCat(Xml.Node* node, string? parentCatID = null) { string title = "No Title"; if(hasProp(node, "text")) + { title = node->get_prop("text"); + } else if(hasProp(node, "title")) + { title = node->get_prop("title"); + } Logger.debug(space() + "Category: " + title); string catID = FeedReaderBackend.get_default().addCategory(title, parentCatID, true); @@ -131,9 +139,13 @@ private void parseFeed(Xml.Node* node, string? catID = null) { string title = "No Title"; if(hasProp(node, "text")) + { title = node->get_prop("text"); + } else if(hasProp(node, "title")) + { title = node->get_prop("title"); + } string feedURL = node->get_prop("xmlUrl"); string website = ""; @@ -150,9 +162,13 @@ private void parseFeed(Xml.Node* node, string? catID = null) var categories = new Gee.ArrayList<string>(); if(catID == null) + { categories.add(FeedServer.get_default().uncategorizedID()); + } else + { categories.add(catID); + } m_feeds.add(new Feed("", title, website, 0, categories, null, feedURL)); } @@ -161,7 +177,9 @@ private void parseFeed(Xml.Node* node, string? catID = null) private bool hasProp(Xml.Node* node, string prop) { if(node->get_prop(prop) != null) + { return true; + } return false; } diff --git a/src/CachedActionManager.vala b/src/CachedActionManager.vala index edfe0c7f..5f4e9141 100644 --- a/src/CachedActionManager.vala +++ b/src/CachedActionManager.vala @@ -23,7 +23,9 @@ private static CachedActionManager? m_manager = null; public static CachedActionManager get_default() { if(m_manager == null) + { m_manager = new CachedActionManager(); + } return m_manager; } @@ -38,7 +40,9 @@ public void markArticleRead(string id, ArticleStatus read) { var cachedAction = CachedActions.MARK_READ; if(read == ArticleStatus.UNREAD) + { cachedAction = CachedActions.MARK_UNREAD; + } var action = new CachedAction(cachedAction, id, ""); addAction(action); @@ -48,7 +52,9 @@ public void markArticleStarred(string id, ArticleStatus marked) { var cachedAction = CachedActions.MARK_STARRED; if(marked == ArticleStatus.UNMARKED) + { cachedAction = CachedActions.MARK_UNSTARRED; + } var action = new CachedAction(cachedAction, id, ""); addAction(action); diff --git a/src/ContentGrabber/grabber.vala b/src/ContentGrabber/grabber.vala index 7acc8f56..93ccc494 100644 --- a/src/ContentGrabber/grabber.vala +++ b/src/ContentGrabber/grabber.vala @@ -37,7 +37,9 @@ public Grabber(Soup.Session session, Article article) { m_article = article; if(m_article.getURL().has_prefix("//")) + { m_article.setURL("http:" + m_article.getURL()); + } m_articleURL = m_article.getURL(); m_firstPage = true; @@ -96,10 +98,14 @@ public bool process(GLib.Cancellable? cancellable = null) } if(!checkContentType()) + { return false; + } if(cancellable != null && cancellable.is_cancelled()) + { return false; + } bool downloaded = false; @@ -129,7 +135,9 @@ public bool process(GLib.Cancellable? cancellable = null) { // check again after possible redirect if(!checkConfigFile()) + { return false; + } } else { @@ -139,12 +147,16 @@ public bool process(GLib.Cancellable? cancellable = null) } if(cancellable != null && cancellable.is_cancelled()) + { return false; + } Logger.debug("Grabber: config found"); if(!downloaded && !download()) + { return false; + } Logger.debug("Grabber: download success"); @@ -154,7 +166,9 @@ public bool process(GLib.Cancellable? cancellable = null) Logger.debug("Grabber: empty article preped"); if(!parse(cancellable)) + { return false; + } if(!m_foundSomething) { @@ -171,7 +185,9 @@ private bool checkContentType() var message = new Soup.Message("HEAD", m_articleURL.escape("")); if(message == null) + { return false; + } m_session.send_message(message); var params = new GLib.HashTable<string, string>(null, null); @@ -179,7 +195,9 @@ private bool checkContentType() if(contentType != null) { if(contentType == "text/html") + { return true; + } } Logger.debug(@"Grabber: type $contentType"); @@ -203,10 +221,14 @@ private bool download() }); if(msg == null) + { return false; + } if(Settings.tweaks().get_boolean("do-not-track")) + { msg.request_headers.append("DNT", "1"); + } m_session.send_message(msg); msg.disconnect(handlerID); @@ -329,7 +351,9 @@ private bool parse(GLib.Cancellable? cancellable = null) { string tmptitle = grabberUtils.getValue(doc, xpath, m_firstPage); if(tmptitle != null && tmptitle != "") + { m_title = tmptitle.chomp().chug(); + } } } @@ -348,7 +372,9 @@ private bool parse(GLib.Cancellable? cancellable = null) { string tmpAuthor = grabberUtils.getValue(doc, xpath); if(tmpAuthor != null) + { m_author = tmpAuthor.chomp().chug(); + } } } @@ -367,7 +393,9 @@ private bool parse(GLib.Cancellable? cancellable = null) { string tmpDate = grabberUtils.getValue(doc, xpath); if(tmpDate != null) + { m_date = tmpDate.chomp().chug(); + } } } @@ -503,9 +531,13 @@ private bool parse(GLib.Cancellable? cancellable = null) foreach(string bodyXPath in bodyList) { if(grabberUtils.extractBody(doc, bodyXPath, m_root)) + { m_foundSomething = true; + } else + { Logger.info("Failed to find: " + bodyXPath); + } } if(m_foundSomething) @@ -526,7 +558,9 @@ private bool parse(GLib.Cancellable? cancellable = null) delete doc; if(cancellable != null && cancellable.is_cancelled()) + { return false; + } m_firstPage = false; @@ -553,7 +587,9 @@ private bool parse(GLib.Cancellable? cancellable = null) } if(cancellable != null && cancellable.is_cancelled()) + { return false; + } m_doc->dump_memory_enc(out m_html); m_html = grabberUtils.postProcessing(ref m_html); @@ -577,13 +613,19 @@ public string getArticle() public void print() { if(m_title != null) + { Logger.debug("Grabber: title: %s".printf(m_title)); + } if(m_author != null) + { Logger.debug("Grabber: author: %s".printf(m_author)); + } if(m_date != null) + { Logger.debug("Grabber: date: %s".printf(m_date)); + } } public string? getAuthor() diff --git a/src/ContentGrabber/grabberConfig.vala b/src/ContentGrabber/grabberConfig.vala index e3bf7cec..0621bdb2 100644 --- a/src/ContentGrabber/grabberConfig.vala +++ b/src/ContentGrabber/grabberConfig.vala @@ -95,17 +95,23 @@ public GrabberConfig(string filename) else if(line.has_prefix("tidy:")) { if(extractValue("tidy:", line) == "no") + { m_tidy = false; + } } else if(line.has_prefix("prune:")) { if(extractValue("prune:", line) == "no") + { m_prune = false; + } } else if(line.has_prefix("autodetect_on_failure:")) { if(extractValue("autodetect_on_failure:", line) == "no") + { m_autodetectOnFailure = false; + } } else if(line.has_prefix("single_page_link:")) { @@ -231,25 +237,41 @@ public void print() } if(m_tidy) + { Logger.debug("tidy: yes"); + } else + { Logger.debug("tidy: no"); + } if(m_prune) + { Logger.debug("prune: yes"); + } else + { Logger.debug("prune: no"); + } if(m_autodetectOnFailure) + { Logger.debug("autodetectOnFailure: yes"); + } else + { Logger.debug("autodetectOnFailure: no"); + } if(m_singlePageLink != null) + { Logger.debug("singlePageLink: " + m_singlePageLink); + } if(m_nextPageLink != null) + { Logger.debug("nextPageLink: " + m_nextPageLink); + } if(m_replace.size != 0) { @@ -261,7 +283,9 @@ public void print() } if(m_testURL != null) + { Logger.debug("testURL: " + m_testURL); + } } diff --git a/src/ContentGrabber/grabberUtils.vala b/src/ContentGrabber/grabberUtils.vala index ae4a8c0e..50169c6f 100644 --- a/src/ContentGrabber/grabberUtils.vala +++ b/src/ContentGrabber/grabberUtils.vala @@ -47,7 +47,9 @@ public static bool extractBody(Html.Doc* doc, string xpath, Xml.Node* destinatio destination->add_child(node); if(!foundSomething) + { foundSomething = true; + } } delete res; @@ -126,7 +128,9 @@ public static bool repairURL(string xpath, string attr, Html.Doc* doc, string ar { Xml.Node* node = res->nodesetval->item(i); if(node->get_prop(attr) != null) + { node->set_prop(attr, completeURL(node->get_prop(attr), articleURL)); + } } delete res; @@ -214,7 +218,9 @@ public static void stripNode(Html.Doc* doc, string xpath) { Xml.Node* node = res->nodesetval->item(i); if(node == null) + { continue; + } node->unlink(); node->free_list(); @@ -241,7 +247,9 @@ public static void onlyRemoveNode(Html.Doc* doc, string xpath) { Xml.Node* node = res->nodesetval->item(i); if(node == null) + { continue; + } Xml.Node* parent = node->parent; Xml.Node* children = node->children; @@ -290,9 +298,13 @@ public static bool removeAttributes(Html.Doc* doc, string? tag, string attribute Xml.XPath.Context cntx = new Xml.XPath.Context(doc); Xml.XPath.Object* res; if(tag == null) + { res = cntx.eval_expression("//*[@%s]".printf(attribute)); + } else + { res = cntx.eval_expression("//%s[@%s]".printf(tag, attribute)); + } if(res == null) { @@ -378,7 +390,9 @@ public static void stripIDorClass(Html.Doc* doc, string IDorClass) public static string cleanString(string? text) { if(text == null) + { return ""; + } var tmpText = text.replace("\n", ""); var array = tmpText.split(" "); @@ -403,7 +417,9 @@ public static string completeURL(string incompleteURL, string articleURL) index = 8; } else + { index = articleURL.index_of_char('.', 0); + } string baseURL = ""; @@ -495,7 +511,9 @@ public static bool saveImages(Soup.Session session, Html.Doc* doc, Article artic for(int i = 0; i < res->nodesetval->length(); i++) { if(cancellable != null && cancellable.is_cancelled()) + { break; + } Xml.Node* node = res->nodesetval->item(i); if(node->get_prop("src") != null) @@ -511,7 +529,9 @@ public static bool saveImages(Soup.Session session, Html.Doc* doc, Article artic string? original = downloadImage(session, node->get_prop("src"), article, i+1); if(original == null) + { continue; + } string? parentURL = checkParent(session, node); if(parentURL != null) @@ -541,7 +561,9 @@ public static bool saveImages(Soup.Session session, Html.Doc* doc, Article artic node->set_prop("FR_huge", original); } else + { node->set_prop("src", original); + } } } } @@ -555,7 +577,9 @@ public static bool saveImages(Soup.Session session, Html.Doc* doc, Article artic public static string? downloadImage(Soup.Session session, string? url, Article article, int nr, bool parent = false) { if(url == null || url.down().has_prefix("data:image")) + { return null; + } string fixedURL = url; string imgPath = GLib.Environment.get_user_data_dir(); @@ -566,9 +590,13 @@ public static string? downloadImage(Soup.Session session, string? url, Article a } if(article.getArticleID() == "" && article.getFeedID() == "") + { imgPath += "/debug-article/ArticleImages/"; + } else + { imgPath += "/feedreader/data/images/%s/%s/".printf(article.getFeedFileName(), article.getArticleFileName()); + } var path = GLib.File.new_for_path(imgPath); try @@ -583,7 +611,9 @@ public static string? downloadImage(Soup.Session session, string? url, Article a string localFilename = imgPath + nr.to_string(); if(parent) + { localFilename += "_parent"; + } if(!FileUtils.test(localFilename, GLib.FileTest.EXISTS)) { @@ -596,7 +626,9 @@ public static string? downloadImage(Soup.Session session, string? url, Article a } if(Settings.tweaks().get_boolean("do-not-track")) + { message_dlImg.request_headers.append("DNT", "1"); + } var status = session.send_message(message_dlImg); if(status == 200) @@ -645,16 +677,22 @@ private static string? resizeImg(string path) Gdk.PixbufFormat? format = Gdk.Pixbuf.get_file_info(path, out width, out height); if(format == null || height == null || width == null) + { return null; + } if(width > 2000 || height > 2000) { int nHeight = 1000; int nWidth = 1000; if(width > height) + { nHeight = -1; + } else if(height > width) + { nWidth = -1; + } var img = new Gdk.Pixbuf.from_file_at_scale(path, nWidth, nHeight, true); img.save(path + "_resized", "png"); @@ -694,11 +732,17 @@ private static int compareImageSize(string file1, string file2) if(height1 == height2 && width1 == width2) + { return 0; + } else if(height1*width1 > height2*width2) + { return 1; + } else + { return -1; + } } // check if the parent node is a link that points to a picture @@ -719,18 +763,24 @@ private static string? checkParent(Soup.Session session, Xml.Node* node) if(url != "" && url != null) { if(url.has_prefix("//")) + { url = "http:" + url; + } var message = new Soup.Message("HEAD", url); if(message == null) + { return null; + } session.send_message(message); var params = new GLib.HashTable<string, string>(null, null); string? contentType = message.response_headers.get_content_type(out params); size = message.response_headers.get_content_length(); var message2 = new Soup.Message("HEAD", smallImgURL); if(message2 == null) + { return null; + } session.send_message(message2); origSize = message2.response_headers.get_content_length(); if(contentType != null) @@ -741,12 +791,18 @@ private static string? checkParent(Soup.Session session, Xml.Node* node) if(size != 0 && origSize != 0) { if(size > origSize) + { return url; + } else + { return null; + } } else + { return url; + } } } } @@ -791,9 +847,13 @@ public static string postProcessing(ref string html) html = html.replace(broken_iframe, fixed_iframe); pos3 = html.index_of("<iframe", pos1+7); if(pos3 == pos1 || pos3 > html.length) + { break; + } else + { pos1 = pos3; + } } Logger.debug("GrabberUtils: postProcessing done"); return html; diff --git a/src/DataBaseReadOnly.vala b/src/DataBaseReadOnly.vala index adc26fbc..bd2fd757 100644 --- a/src/DataBaseReadOnly.vala +++ b/src/DataBaseReadOnly.vala @@ -165,7 +165,9 @@ private uint count_article_status(ArticleStatus status) var query = "SELECT COUNT(*) FROM articles"; string status_column = status.column(); if(status_column != null) + { query += @" WHERE $status_column = ?"; + } var rows = m_db.execute(query, { status }); assert(rows.size == 1 && rows[0].size == 1); return rows[0][0].to_int(); @@ -187,7 +189,9 @@ private uint count_status_uncategorized(ArticleStatus status) query.select_field("count(*)"); var status_column = status.column(); if(status_column != null) + { query.where_equal_int(status_column, status.to_int()); + } var subquery = new QueryBuilder(QueryType.SELECT, "feeds"); @@ -218,7 +222,9 @@ public uint get_marked_uncategorized() public int get_new_unread_count(int row_id) { if(row_id == 0) + { return 0; + } string query = "SELECT count(*) FROM articles WHERE unread = ? AND rowid > ?"; var rows = m_db.execute(query, { ArticleStatus.UNREAD, row_id }); @@ -247,7 +253,9 @@ public string? getTagName(string tag_id) var rows = m_db.execute(query, { tag_id }); assert(rows.size == 0 || (rows.size == 1 && rows[0].size == 1)); if(rows.size == 1) + { return rows[0][0].to_string(); + } return _("Unknown tag"); } @@ -257,25 +265,35 @@ public int getLastModified() var rows = m_db.execute(query); assert(rows.size == 0 || (rows.size == 1 && rows[0].size == 1)); if(rows.size == 1 && rows[0][0] != null) + { return rows[0][0].to_int(); + } else + { return 0; + } } public string getCategoryName(string catID) { if(catID == CategoryID.TAGS.to_string()) + { return "Tags"; + } var query = "SELECT title FROM categories WHERE categorieID = ?"; var rows = m_db.execute(query, { catID }); string result = ""; if(rows.size != 0) + { result = rows[0][0].to_string(); + } if(result == "") + { result = _("Uncategorized"); + } return result; } @@ -285,9 +303,13 @@ public string? getCategoryID(string catname) var query = "SELECT categorieID FROM categories WHERE title = ?"; var rows = m_db.execute(query, { catname }); if(rows.size == 0) + { return null; + } else + { return rows[0][0].to_string(); + } } public bool preview_empty(string articleID) @@ -312,11 +334,13 @@ public Gee.List<Article> read_article_between( var sorting = (ArticleListSort)Settings.general().get_enum("articlelist-sort-by"); if(sorting == ArticleListSort.RECEIVED) + { query.where( "date BETWEEN (SELECT rowid FROM articles WHERE articleID = %s) AND (SELECT rowid FROM articles WHERE articleID = %s)" .printf( SQLite.quote_string(id1), SQLite.quote_string(id2))); + } else { bool bigger = (date1.to_unix() > date2.to_unix()); @@ -332,7 +356,9 @@ public Gee.List<Article> read_article_between( { if(stmt.column_text(2) == id1 || stmt.column_text(2) == id2) + { continue; + } articles.add(new Article( stmt.column_text(2), // articleID @@ -395,11 +421,15 @@ public Article? read_article(string articleID) Logger.debug(@"DataBaseReadOnly.read_article(): $articleID"); var rows = m_db.execute("SELECT ROWID, * FROM articles WHERE articleID = ?", { articleID }); if(rows.size == 0) + { return null; + } var row = rows[0]; string? author = row[4].to_string(); if(author == "") + { author = null; + } return new Article( articleID, @@ -425,7 +455,9 @@ public int getMaxCatLevel() assert(rows.size == 1 && rows[0].size == 1); int maxCatLevel = rows[0][0].to_int(); if(maxCatLevel == 0) + { maxCatLevel = 1; + } return maxCatLevel; } @@ -441,7 +473,9 @@ public bool haveFeedsWithoutCat() int count = stmt.column_int(0); if(count > 0) + { return true; + } } return false; } @@ -474,9 +508,13 @@ ensures (result >= 0) query.select_field(order_by); if(Settings.general().get_boolean("articlelist-oldest-first") && state == ArticleListState.UNREAD) + { query2.where(@"$order_by < (%s)".printf(query.to_string())); + } else + { query2.where(@"$order_by > (%s)".printf(query.to_string())); + } if(selectedType == FeedListType.FEED && feedID != FeedID.ALL.to_string()) @@ -505,7 +543,8 @@ ensures (result >= 0) query2.where_equal_int("marked", ArticleStatus.MARKED.to_int()); } - if(searchTerm != "") { + if(searchTerm != "") + { string search_column; if(searchTerm.has_prefix("title: ")) { @@ -603,9 +642,13 @@ public string getFeedIDofArticle(string articleID) var rows = m_db.execute("SELECT feedID FROM articles WHERE articleID = ?", { articleID }); string id = null; if(rows.size != 0) + { id = rows[0][0].to_string(); + } if(id == null) + { id = ""; + } return id; } @@ -613,7 +656,9 @@ public string getNewestArticle() { var rows = m_db.execute("SELECT articleID FROM articles WHERE rowid = ?", { getMaxID("articles", "rowid") }); if(rows.size == 0) + { return ""; + } return rows[0][0].to_string(); } @@ -622,9 +667,13 @@ public string getMaxID(string table, string field) var rows = m_db.execute(@"SELECT MAX($field) FROM $table"); string? id = null; if(rows.size > 0) + { id = rows[0][0].to_string(); + } if(id == null) + { id = ""; + } return id; } @@ -640,7 +689,9 @@ public Feed? read_feed(string feedID) { var rows = m_db.execute("SELECT * FROM feeds WHERE feed_id = ?", { feedID }); if(rows.size == 0) + { return null; + } var row = rows[0]; return new Feed( @@ -677,9 +728,13 @@ public Gee.List<Feed> read_feeds(bool starredCount = false) uint count = 0; if(starredCount) + { count = getFeedStarred(feedID); + } else + { count = getFeedUnread(feedID); + } var feed = new Feed(feedID, name, url, count, categories, iconURL, xmlURL); feeds.add(feed); @@ -738,7 +793,9 @@ public Category? read_category(string catID) var query = "SELECT * FROM categories WHERE categorieID = ?"; var rows = m_db.execute(query, { catID }); if(rows.size == 0) + { return null; + } var row = rows[0]; return new Category( @@ -801,7 +858,9 @@ public Tag? read_tag(string tagID) var query = "SELECT * FROM tags WHERE tagID = ?"; var rows = m_db.execute(query, { tagID }); if(rows.size == 0) + { return null; + } var row = rows[0]; return new Tag( @@ -936,7 +995,8 @@ public QueryBuilder articleQuery(string id, FeedListType selectedType, ArticleLi query.where_equal_int("marked", ArticleStatus.MARKED.to_int()); } - if(searchTerm != "") { + if(searchTerm != "") + { if(searchTerm.has_prefix("title: ")) { query.where("articleID IN (SELECT articleID FROM fts_table WHERE title MATCH '%s')".printf(Utils.prepareSearchQuery(searchTerm))); @@ -957,7 +1017,9 @@ public QueryBuilder articleQuery(string id, FeedListType selectedType, ArticleLi bool desc = true; if(Settings.general().get_boolean("articlelist-oldest-first") && state == ArticleListState.UNREAD) + { desc = false; + } query.order_by(order_by, desc); @@ -971,7 +1033,9 @@ requires (limit > 0) string desc = "DESC"; if(Settings.general().get_boolean("articlelist-oldest-first") && state == ArticleListState.UNREAD) + { desc = "ASC"; + } if(searchRows != 0) { diff --git a/src/DataBaseWriteAccess.vala b/src/DataBaseWriteAccess.vala index e2cccc8a..9fb78ef2 100644 --- a/src/DataBaseWriteAccess.vala +++ b/src/DataBaseWriteAccess.vala @@ -19,7 +19,9 @@ public static new DataBase writeAccess() { var database = new DataBase(); if(database.uninitialized()) + { database.init(); + } return database; } @@ -282,9 +284,13 @@ public void updateArticlesByID(Gee.List<string> ids, string field) // first reset all articles var reset_query = new QueryBuilder(QueryType.UPDATE, "main.articles"); if(field == "unread") + { reset_query.update_int(field, ArticleStatus.READ.to_int()); + } else if(field == "marked") + { reset_query.update_int(field, ArticleStatus.UNMARKED.to_int()); + } m_db.simple_query(reset_query.to_string()); @@ -294,9 +300,13 @@ public void updateArticlesByID(Gee.List<string> ids, string field) var update_query = new QueryBuilder(QueryType.UPDATE, "main.articles"); if(field == "unread") + { update_query.update_int(field, ArticleStatus.UNREAD.to_int()); + } else if(field == "marked") + { update_query.update_int(field, ArticleStatus.MARKED.to_int()); + } update_query.where_equal_param("articleID", "$ARTICLEID"); @@ -372,10 +382,14 @@ public void update_articles(Gee.List<Article> articles) var marked = ActionCache.get_default().checkStarred(a.getArticleID(), a.getMarked()); if(unread != ArticleStatus.READ && unread != ArticleStatus.UNREAD) + { Logger.warning(@"DataBase.update_articles: writing invalid unread status $unread for article " + a.getArticleID()); + } if(marked != ArticleStatus.MARKED && marked != ArticleStatus.UNMARKED) + { Logger.warning(@"DataBase.update_articles: writing invalid marked status $marked for article " + a.getArticleID()); + } stmt.bind_int (unread_position, unread); stmt.bind_int (marked_position, marked); @@ -447,7 +461,9 @@ public void write_articles(Gee.List<Article> articles) // if article time is in the future var now = new GLib.DateTime.now_local(); if(article.getDate().compare(now) == 1) + { article.SetDate(now); + } int? weeks = ((DropArticles)Settings.general().get_enum("drop-articles-after")).to_weeks(); if(weeks != null && article.getDate().compare(now.add_weeks(-(int)weeks)) == -1) @@ -649,7 +665,9 @@ public void move_feed(string feedID, string currentCatID, string? newCatID = nul categories.remove(currentCatID); if(newCatID != null) + { categories.add(newCatID); + } string catString = StringUtils.join(categories, ","); diff --git a/src/Enums.vala b/src/Enums.vala index 13316182..b41891ef 100644 --- a/src/Enums.vala +++ b/src/Enums.vala @@ -198,7 +198,9 @@ public enum DropArticles { { int? weeks = to_weeks(); if(weeks == null) + { return null; + } return new DateTime.now_utc().add_weeks(-(int)weeks); } @@ -250,11 +252,17 @@ public enum EnclosureType { if (str != null) { if (str.contains("audio")) + { return AUDIO; + } else if (str.contains("video")) + { return VIDEO; + } else if (str.contains("image")) + { return IMAGE; + } } return FILE; } diff --git a/src/FavIcon.vala b/src/FavIcon.vala index 9fc7f0e7..d9dd8277 100644 --- a/src/FavIcon.vala +++ b/src/FavIcon.vala @@ -20,7 +20,9 @@ private static Gee.Map<string?, FavIcon?> m_map = null; public static FavIcon for_feed(Feed? feed) { if(m_map == null) + { m_map = new Gee.HashMap<string?, FavIcon?>(); + } var feed_id = feed != null ? feed.getFeedID() : null; var icon = m_map.get(feed_id); @@ -37,12 +39,16 @@ public static void delete_feed(string feed_id) ensures (m_map == null || !m_map.has_key(feed_id)) { if(m_map == null) + { return; + } FavIcon icon; m_map.unset(feed_id, out icon); if(icon == null) + { return; + } icon.delete.begin((obj,res) => { icon.delete.end(res); @@ -93,7 +99,9 @@ public async Cairo.Surface? get_surface() { Gdk.Pixbuf pixbuf = yield m_pixbuf.future.wait_async(); if(pixbuf == null) + { return null; + } return create_surface_from_pixbuf(pixbuf); } @@ -110,7 +118,9 @@ private async void load() { var stream = yield downloadFavIcon(); if(stream == null) + { return; + } var pixbuf = yield new Gdk.Pixbuf.from_stream_async(stream); stream.close(); @@ -125,7 +135,9 @@ private async void load() m_pixbuf.set_value(pixbuf); if(pixbuf != null) + { surface_changed(m_feed, create_surface_from_pixbuf(pixbuf)); + } } catch(Error e) { @@ -134,14 +146,18 @@ private async void load() finally { if(!m_pixbuf.future.ready) + { m_pixbuf.set_value(null); + } } } private InputStream? try_load_data_uri(string? icon_url) { if(icon_url == null || !icon_url.has_prefix("data")) + { return null; + } // LibSoup doesn't seem to handle data URI's properly, so handle them // ourselves.. @@ -186,7 +202,9 @@ private string metadataFileName() private async void delete() { if (m_feed == null) + { return; + } try { @@ -216,19 +234,25 @@ requires(m_feed != null) { var datastream = try_load_data_uri(m_feed.getIconURL()); if(datastream != null) + { return datastream; + } string icon_filename = iconFileName(); string metadata_filename = metadataFileName(); if(!yield Utils.ensure_path(m_icon_path)) + { return null; + } m_metadata = yield ResourceMetadata.from_file_async(metadata_filename); DateTime? expires = m_metadata.expires; if(cancellable != null && cancellable.is_cancelled()) + { return null; + } bool use_cached = false; if(!m_metadata.is_expired()) @@ -259,7 +283,9 @@ requires(m_feed != null) var obvious_icons = new Gee.ArrayList<string>(); if(m_feed.getIconURL() != null) + { obvious_icons.add(m_feed.getIconURL()); + } // try domainname/favicon.ico var uri = new Soup.URI(m_feed.getURL()); @@ -271,7 +297,9 @@ requires(m_feed != null) var icon_url = siteURL; if(!icon_url.has_suffix("/")) + { icon_url += "/"; + } icon_url += "favicon.ico"; obvious_icons.add(icon_url); } @@ -281,19 +309,27 @@ requires(m_feed != null) { var stream = yield downloadIcon(url, cancellable); if(stream != null) + { return stream; + } if(cancellable != null && cancellable.is_cancelled()) + { return null; + } } // If all else fails, download html and parse to find location of favicon if(siteURL == null) + { return null; + } var message_html = new Soup.Message("GET", siteURL); if(Settings.tweaks().get_boolean("do-not-track")) + { message_html.request_headers.append("DNT", "1"); + } string html; try @@ -323,12 +359,16 @@ requires(m_feed != null) var xpath = grabberUtils.getURL(doc, "//link[@rel='icon']"); if(xpath == null) + { // check for <link rel="shortcut icon"> xpath = grabberUtils.getURL(doc, "//link[@rel='shortcut icon']"); + } if(xpath == null) + { // check for <link rel="apple-touch-icon"> xpath = grabberUtils.getURL(doc, "//link[@rel='apple-touch-icon']"); + } if(xpath != null) { @@ -376,12 +416,18 @@ private async InputStream? downloadIcon(string? icon_url, Cancellable? cancellab return null; } if(Settings.tweaks().get_boolean("do-not-track")) + { message.request_headers.append("DNT", "1"); + } if(etag != null) + { message.request_headers.append("If-None-Match", etag); + } if(last_modified != null) + { message.request_headers.append("If-Modified-Since", last_modified); + } uint8[]? data; try @@ -427,7 +473,9 @@ private async InputStream? downloadIcon(string? icon_url, Cancellable? cancellab { var parts = header.split("="); if(parts.length < 2 || parts[0] != "max-age") + { continue; + } var seconds = int64.parse(parts[1]); var expires = new DateTime.now_utc(); expires.add_seconds(seconds); diff --git a/src/FeedReader.vala b/src/FeedReader.vala index df19c3db..b212eaa4 100644 --- a/src/FeedReader.vala +++ b/src/FeedReader.vala @@ -32,7 +32,9 @@ public signal void callback (string content); public new static FeedReaderApp get_default() { if(m_app == null) + { m_app = new FeedReaderApp(); + } return m_app; } @@ -169,7 +171,9 @@ public override void activate() Logger.debug("FeedReader: feedAdded"); ColumnView.get_default().footerSetReady(); if(error) - ColumnView.get_default().footerShowError(errmsg); + { + ColumnView.get_default().footerShowError(errmsg); + } return GLib.Source.REMOVE; }); }); @@ -271,7 +275,9 @@ public static void show_about(string[] args) Gtk.AboutDialog dialog = new Gtk.AboutDialog(); dialog.response.connect ((response_id) => { if(response_id == Gtk.ResponseType.CANCEL || response_id == Gtk.ResponseType.DELETE_EVENT) - Gtk.main_quit(); + { + Gtk.main_quit(); + } }); dialog.artists = AboutInfo.artists; diff --git a/src/FeedReaderMain.vala b/src/FeedReaderMain.vala index 07afaf92..ce499e40 100644 --- a/src/FeedReaderMain.vala +++ b/src/FeedReaderMain.vala @@ -68,7 +68,9 @@ public static int main (string[] args) { Logger.init(verbose); if(!Utils.ping(pingURL)) + { Logger.error("Ping failed"); + } return 0; } diff --git a/src/Logger.vala b/src/Logger.vala index 4f129ff6..0b9237a2 100644 --- a/src/Logger.vala +++ b/src/Logger.vala @@ -41,7 +41,9 @@ public static void info(string message) public static void debug(string message) { if(m_log_debug_information) + { log(GLib.LogLevelFlags.LEVEL_DEBUG, message); + } } public static void init(bool verbose) diff --git a/src/Model/Article.vala b/src/Model/Article.vala index e98508e4..8eab4b42 100644 --- a/src/Model/Article.vala +++ b/src/Model/Article.vala @@ -198,14 +198,20 @@ public string getDateNice(bool addTime = false) } } else + { formats.add("%Y-%m-%d"); + } if(addTime) { if(m_clock_12_hour) + { formats.add("%l:%M %p"); + } else + { formats.add("%H:%M"); + } } string format = StringUtils.join(formats, ", "); @@ -250,13 +256,17 @@ public void setTags(Gee.List<string> tags) public void addTag(string tagID) { if(!m_tags.contains(tagID)) + { m_tags.add(tagID); + } } public void removeTag(string tagID) { if(m_tags.contains(tagID)) + { m_tags.remove(tagID); + } } public unowned Gee.List<Enclosure> getEnclosures() @@ -272,7 +282,9 @@ public void setImages(Gee.List<Enclosure> enclosures) public void addEnclosure(Enclosure enc) { if(!m_enclosures.contains(enc)) + { m_enclosures.add(enc); + } } public bool haveMedia() diff --git a/src/Model/Feed.vala b/src/Model/Feed.vala index 2e801e1c..2044b745 100644 --- a/src/Model/Feed.vala +++ b/src/Model/Feed.vala @@ -110,10 +110,14 @@ public void setCategory(string id) public bool isUncategorized() { if(m_catIDs.size == 0) + { return true; + } if(m_catIDs.size == 1 && m_catIDs[0].contains("global.must")) + { return true; + } return false; } diff --git a/src/Model/InterfaceState.vala b/src/Model/InterfaceState.vala index 85103202..4caf65c5 100644 --- a/src/Model/InterfaceState.vala +++ b/src/Model/InterfaceState.vala @@ -147,9 +147,13 @@ public string getArticleListSelectedRow() public void setArticleListTopRow(Article? article) { if(article == null) + { m_ArticleListTopRow = null; + } else + { m_ArticleListTopRow = article.getArticleID(); + } } public string getArticleListTopRow() diff --git a/src/Notification.vala b/src/Notification.vala index 41478033..d93d2c9a 100644 --- a/src/Notification.vala +++ b/src/Notification.vala @@ -24,9 +24,13 @@ public static void send(uint new_articles, int new_and_unread) if(new_articles > 0 && new_and_unread > 0) { if(new_articles == 1) + { message = _("There is 1 new article (%u unread)").printf(unread); + } else + { message = _("There are %u new articles (%u unread)").printf(new_articles, unread); + } var notification = new GLib.Notification(summary); notification.set_body(message); diff --git a/src/Password.vala b/src/Password.vala index 64d5af4c..583ecbf9 100644 --- a/src/Password.vala +++ b/src/Password.vala @@ -33,7 +33,9 @@ public Password(Secret.Collection secrets, Secret.Schema schema, string label, o private void unlock_keyring(Cancellable? cancellable = null) throws Error { if (!m_secrets.get_locked()) + { return; + } var collections_to_unlock = new List<Secret.Collection>(); collections_to_unlock.append(m_secrets); @@ -49,19 +51,25 @@ public string get_password(Cancellable? cancellable = null) unlock_keyring(cancellable); if(cancellable != null && cancellable.is_cancelled()) + { return ""; + } var secrets = m_secrets.search_sync(m_schema, attributes, Secret.SearchFlags.NONE, cancellable); if(cancellable != null && cancellable.is_cancelled()) + { return ""; + } if(secrets.length() != 0) { var item = secrets.data; item.load_secret_sync(cancellable); if(cancellable != null && cancellable.is_cancelled()) + { return ""; + } var secret = item.get_secret(); if(secret == null) @@ -93,7 +101,9 @@ public void set_password(string password, Cancellable? cancellable = null) unlock_keyring(cancellable); if(cancellable != null && cancellable.is_cancelled()) + { return; + } var value = new Secret.Value(password, password.length, "text/plain"); Secret.Item.create_sync(m_secrets, m_schema, attributes, m_label, value, Secret.ItemCreateFlags.REPLACE, cancellable); @@ -112,12 +122,16 @@ public bool delete_password(Cancellable? cancellable = null) unlock_keyring(cancellable); if(cancellable != null && cancellable.is_cancelled()) + { return false; + } var secrets = m_secrets.search_sync(m_schema, attributes, Secret.SearchFlags.NONE, cancellable); if(cancellable != null && cancellable.is_cancelled()) + { return false; + } if(secrets.length() != 0) { diff --git a/src/QueryBuilder.vala b/src/QueryBuilder.vala index 965a63f5..c0b5c9db 100644 --- a/src/QueryBuilder.vala +++ b/src/QueryBuilder.vala @@ -126,9 +126,12 @@ requires (m_type == QueryType.UPDATE || m_type == QueryType.SELECT || m_type == QueryType.DELETE) { - if (values.size == 0) { + if (values.size == 0) + { m_conditions.add("1 <> 1"); - } else { + } + else + { var compound_values = new GLib.StringBuilder(); foreach(string value in values) { @@ -170,9 +173,13 @@ public string to_string() query.append("INSERT "); if(m_type == QueryType.INSERT_OR_IGNORE) + { query.append("OR IGNORE "); + } else if(m_type == QueryType.INSERT_OR_REPLACE) + { query.append("OR REPLACE "); + } query.append_printf("INTO %s (", m_table); StringUtils.stringbuilder_append_join(query, m_fields, ", "); @@ -188,7 +195,9 @@ public string to_string() for(int i = 0; i < m_fields.size; i++) { if (i > 0) + { query.append(", "); + } query.append(m_fields.get(i)); query.append(" = "); @@ -213,7 +222,8 @@ public string to_string() append_conditions(query); - if (m_order_by_column != null) { + if (m_order_by_column != null) + { query.append_printf( " ORDER BY %s COLLATE NOCASE %s", m_order_by_column, @@ -221,10 +231,14 @@ public string to_string() } if (m_limit != null) + { query.append_printf(" LIMIT %u", m_limit); + } if (m_offset != null) + { query.append_printf(" OFFSET %u", m_offset); + } break; } @@ -234,7 +248,9 @@ public string to_string() private void append_conditions(StringBuilder query) { if(m_conditions.size == 0) + { return; + } query.append(" WHERE "); StringUtils.stringbuilder_append_join(query, m_conditions, " AND "); diff --git a/src/Rfc822.vala b/src/Rfc822.vala index 91de7732..c551803e 100644 --- a/src/Rfc822.vala +++ b/src/Rfc822.vala @@ -11,7 +11,9 @@ namespace FeedReader.Rfc822 { public static DateTime? parseDate(string? str) { if (str == null) + { return null; + } Regex re; try { @@ -40,7 +42,9 @@ public static DateTime? parseDate(string? str) MatchInfo info; if (!re.match(str, 0, out info)) + { return null; + } var dayStr = info.fetch_named("day"); var day = int.parse(dayStr); @@ -94,10 +98,14 @@ public static DateTime? parseDate(string? str) var year = int.parse(yearStr); // Two-digit years from 00 to 49 should be interpreted as 2000 to 2049 if (year >= 0 && year <= 49) + { year += 2000; + } // Two-digit years from 50 to 99 should be interpreted as 1950 to 1999 else if (year >= 50 && year < 100) + { year += 1900; + } var hourStr = info.fetch_named("hour"); var hour = int.parse(hourStr); var minuteStr = info.fetch_named("minute"); diff --git a/src/SQLite.vala b/src/SQLite.vala index 44a1233b..6f8055fb 100644 --- a/src/SQLite.vala +++ b/src/SQLite.vala @@ -52,7 +52,9 @@ requires (query != "") Sqlite.Statement stmt; int rc = m_db.prepare_v2(query, query.length, out stmt); if(rc != Sqlite.OK) + { error("Can't prepare statement: %d: %s\nSQL is %s".printf(m_db.errcode(), m_db.errmsg(), query)); + } return stmt; } @@ -93,7 +95,9 @@ requires (query != "") foreach(var param in params) { if(param == null) + { stmt.bind_null(i); + } else { // The order of operations matters here because floats and doubles diff --git a/src/Settings.vala b/src/Settings.vala index 017f69c8..d4c37c5a 100644 --- a/src/Settings.vala +++ b/src/Settings.vala @@ -24,7 +24,9 @@ private static Gee.HashMap<string, GLib.Settings>? m_share = null; public static GLib.Settings general() { if(m_general == null) + { m_general = new GLib.Settings("org.gnome.feedreader"); + } return m_general; } @@ -32,7 +34,9 @@ public static GLib.Settings general() public static GLib.Settings tweaks() { if(m_tweaks == null) + { m_tweaks = new GLib.Settings("org.gnome.feedreader.tweaks"); + } return m_tweaks; } @@ -40,7 +44,9 @@ public static GLib.Settings tweaks() public static GLib.Settings state() { if(m_state == null) + { m_state = new GLib.Settings("org.gnome.feedreader.saved-state"); + } return m_state; } @@ -48,7 +54,9 @@ public static GLib.Settings state() public static GLib.Settings keybindings() { if(m_keys == null) + { m_keys = new GLib.Settings("org.gnome.feedreader.keybindings"); + } return m_keys; } @@ -56,10 +64,14 @@ public static GLib.Settings keybindings() public static GLib.Settings? share(string pluginName) { if(m_share == null) + { m_share = new Gee.HashMap<string, GLib.Settings>(); + } if(m_share.has_key(pluginName)) + { return m_share.get(pluginName); + } else { var settings = new GLib.Settings(@"org.gnome.feedreader.share.$pluginName"); diff --git a/src/Share/ServiceSetup.vala b/src/Share/ServiceSetup.vala index 635e3722..73edd014 100644 --- a/src/Share/ServiceSetup.vala +++ b/src/Share/ServiceSetup.vala @@ -138,21 +138,27 @@ public virtual void logout() private bool onEnter() { if(m_isLoggedIN) + { m_iconStack.set_visible_child_full("logOUT", Gtk.StackTransitionType.SLIDE_LEFT); + } return false; } private bool onLeave() { if(m_isLoggedIN) + { m_iconStack.set_visible_child_full("loggedIN", Gtk.StackTransitionType.SLIDE_RIGHT); + } return false; } public void reveal(bool animate = true) { if(!animate) + { m_revealer.set_transition_type(Gtk.RevealerTransitionType.NONE); + } m_revealer.set_reveal_child(true); this.show_all(); diff --git a/src/Share/share.vala b/src/Share/share.vala index 35746a05..992f01a2 100644 --- a/src/Share/share.vala +++ b/src/Share/share.vala @@ -23,7 +23,9 @@ private Goa.Client? m_client = null; public static Share get_default() { if(m_share == null) + { m_share = new Share(); + } return m_share; } @@ -127,10 +129,14 @@ public Gee.List<ShareAccount> getAccountTypes() if(plugin.singleInstance()) { if(plugin.needSetup() && !Settings.share(pluginID).get_boolean("enabled")) - singleInstance = true; + { + singleInstance = true; + } } else - singleInstance = true; + { + singleInstance = true; + } if(plugin.needSetup() && !plugin.useSystemAccounts() && singleInstance) { @@ -170,7 +176,9 @@ public string generateNewID() }); if(!unique) + { return generateNewID(); + } return id; } diff --git a/src/StringUtils.vala b/src/StringUtils.vala index 428f3c7e..6d38c9ad 100644 --- a/src/StringUtils.vala +++ b/src/StringUtils.vala @@ -18,7 +18,9 @@ public static Gee.List<string> split(string s, string sep, bool ignore_empty=fal { var items = s.split(sep); if (!ignore_empty) + { return new Gee.ArrayList<string>.wrap(items); + } var res = new Gee.ArrayList<string>(); foreach(string item in items) @@ -43,7 +45,9 @@ public static void stringbuilder_append_join(StringBuilder out, Gee.Collection<s foreach (var v in l) { if (!first) + { out.append(sep); + } out.append(v); first = false; } diff --git a/src/Structs.vala b/src/Structs.vala index 3699e2fc..a2380d10 100644 --- a/src/Structs.vala +++ b/src/Structs.vala @@ -67,7 +67,9 @@ public struct ResourceMetadata catch (KeyFileError.KEY_NOT_FOUND e) {} catch (KeyFileError.GROUP_NOT_FOUND e) {} if(expires != null) + { this.expires = new DateTime.from_unix_utc(expires); + } } catch (KeyFileError e) { @@ -115,11 +117,17 @@ public struct ResourceMetadata { var config = new KeyFile(); if(this.etag != null) + { config.set_string(CACHE_GROUP, ETAG_KEY, this.etag); + } if(this.last_modified != null) + { config.set_string(CACHE_GROUP, LAST_MODIFIED_KEY, this.last_modified); + } if(this.expires != null) + { config.set_int64(CACHE_GROUP, EXPIRES_KEY, this.expires.to_unix()); + } var data = config.to_data(); try { @@ -143,10 +151,14 @@ public struct ResourceMetadata public bool is_expired() { if(expires == null) + { return true; + } if(expires.compare(new DateTime.now_utc()) == 1) + { return false; + } return true; } diff --git a/src/Utils.vala b/src/Utils.vala index 61289a0e..2539bef0 100644 --- a/src/Utils.vala +++ b/src/Utils.vala @@ -51,7 +51,9 @@ public static void generatePreviews(Gee.List<Article> articles) Logger.debug("Utils: generate preview for article: " + Article.getArticleID()); string output = Utils.UTF8fix(Article.getHTML(), true); if(output != null) + { output = output.strip(); + } if(output == "" || output == null) { @@ -151,7 +153,9 @@ public static bool springCleaningNecessary() Logger.debug("difference: %f".printf(difference/GLib.TimeSpan.DAY)); if((difference/GLib.TimeSpan.DAY) >= Settings.general().get_int("spring-clean-after")) + { doCleaning = true; + } return doCleaning; } @@ -176,7 +180,9 @@ public static bool arrayContains(string[] array, string key) foreach(string s in array) { if(s == key) + { return true; + } } return false; @@ -396,19 +402,27 @@ public static string prepareSearchQuery(string raw_query) { string lower = s.down(); if(lower == "" || lower == "and" || lower == "or" || lower == "not" || lower == "near" || lower.has_prefix("near/")) + { continue; + } if(s.has_prefix("-")) + { s = s.substring(1); + } if(s == "") + { continue; + } s = "\"" + s + "*\""; } if(in_quote && quotes % 2 != 0) + { in_quote = false; + } prepared_query.append(s); prepared_query.append(" "); @@ -422,8 +436,9 @@ public static string prepareSearchQuery(string raw_query) public static int countChar(string s, unichar c) { int count = 0; - for (int index = 0; (index = s.index_of_char(c, index)) >= 0; ++index, ++count) + for (int index = 0; (index = s.index_of_char(c, index)) >= 0; ++index, ++count) { ; + } return count; } @@ -497,21 +512,31 @@ public static void resetSettings(GLib.Settings settings) public static string URLtoFeedName(string? url) { if(url == null) + { return ""; + } var feedname = new GLib.StringBuilder(url); if(feedname.str.has_suffix("/")) + { feedname.erase(feedname.str.char_count()-1); + } if(feedname.str.has_prefix("https://")) + { feedname.erase(0, 8); + } if(feedname.str.has_prefix("http://")) + { feedname.erase(0, 7); + } if(feedname.str.has_prefix("www.")) + { feedname.erase(0, 4); + } return feedname.str; } @@ -534,7 +559,9 @@ public static async bool ensure_path(string path_str) { var path = GLib.File.new_for_path(path_str); if(yield file_exists(path_str, FileType.DIRECTORY)) + { return true; + } try { @@ -556,7 +583,9 @@ public static string gsettingReadString(GLib.Settings setting, string key) { string val = setting.get_string(key); if(val == "") + { Logger.warning("Utils.gsettingReadString: failed to read %s %s".printf(setting.schema_id, key)); + } return val; } @@ -564,10 +593,14 @@ public static string gsettingReadString(GLib.Settings setting, string key) public static void gsettingWriteString(GLib.Settings setting, string key, string val) { if(val == "" || val == null) + { Logger.warning("Utils.gsettingWriteString: resetting %s %s".printf(setting.schema_id, key)); + } if(!setting.set_string(key, val)) + { Logger.error("Utils.gsettingWriteString: writing %s %s failed".printf(setting.schema_id, key)); + } } public static async uint8[] inputStreamToArray(InputStream stream, Cancellable? cancellable=null) throws Error @@ -579,7 +612,9 @@ public static async uint8[] inputStreamToArray(InputStream stream, Cancellable? size_t bytesRead = 0; yield stream.read_all_async(buffer, Priority.DEFAULT_IDLE, cancellable, out bytesRead); if (bytesRead == 0) + { break; + } result.append_vals(buffer, (uint)bytesRead); } @@ -591,7 +626,9 @@ public static string buildArticle(string html, string title, string url, string? var article = new GLib.StringBuilder(); string author_date = ""; if(author != null) + { author_date += _("posted by: %s, ").printf(author); + } author_date += date; @@ -679,12 +716,16 @@ public static string buildArticle(string html, string title, string url, string? // Try to use the configured font if it exists var font_setting = Settings.general().get_value("font").get_maybe(); if (font_setting != null) + { font_options.add(font_setting.get_string()); + } // If there is no configured font, or it's broken, use the system default font var system_font = new GLib.Settings("org.gnome.desktop.interface").get_string("document-font-name"); if (system_font != null) + { font_options.add(system_font); + } // Backup if the system font is broken too font_options.add("sans"); @@ -698,11 +739,15 @@ public static string buildArticle(string html, string title, string url, string? var desc = Pango.FontDescription.from_string(font); font_families.add(desc.get_family()); if (font_size == null && desc.get_size() > 0) + { font_size = (uint)GLib.Math.roundf(desc.get_size()); + } } if (font_size == null) + { font_size = 12; + } font_size = font_size / Pango.SCALE; string font_family = StringUtils.join(font_families, ", "); @@ -756,18 +801,26 @@ public static bool canManipulateContent(bool? online = null) { // if backend = local RSS -> return true; if(Settings.general().get_string("plugin") == "local") + { return true; + } if(!FeedReaderBackend.get_default().supportFeedManipulation()) + { return false; + } // when we already know wheather feedreader is online or offline if(online != null) { if(online) + { return true; + } else + { return false; + } } // otherwise check if online @@ -797,13 +850,17 @@ public static GLib.Menu getMenu() public static bool onlyShowFeeds() { if(Settings.general().get_boolean("only-feeds")) + { return true; + } var db = DataBase.readOnly(); if(!db.haveCategories() && !FeedReaderBackend.get_default().supportTags() && !db.haveFeedsWithoutCat()) + { return true; + } return false; } @@ -816,7 +873,9 @@ public static void saveImageDialog(string imagePath) string articleName = "Article.pdf"; string? articleID = ColumnView.get_default().displayedArticle(); if(articleID != null) + { articleName = DataBase.readOnly().read_article(articleID).getTitle(); + } var file = GLib.File.new_for_path(imagePath); var mimeType = file.query_info("standard::content-type", 0, null).get_content_type(); @@ -904,9 +963,13 @@ public static Gtk.Image checkIcon(string name, string fallback, Gtk.IconSize siz { Gtk.Image icon = null; if(Gtk.IconTheme.get_default().lookup_icon(name, 0, Gtk.IconLookupFlags.FORCE_SVG) != null) + { icon = new Gtk.Image.from_icon_name(name, size); + } else + { icon = new Gtk.Image.from_icon_name(fallback, size); + } return icon; } @@ -956,7 +1019,9 @@ public static uint getRelevantArticles() int count = 0; if(topRow != null) + { count = DataBase.readOnly().getArticleCountNewerThanID(topRow, selectedRow[1], IDtype, state, searchTerm); + } Logger.debug(@"getRelevantArticles: $count"); return count; diff --git a/src/Widgets/ArticleList/ArticleList.vala b/src/Widgets/ArticleList/ArticleList.vala index fa2ae03e..bd483ce8 100644 --- a/src/Widgets/ArticleList/ArticleList.vala +++ b/src/Widgets/ArticleList/ArticleList.vala @@ -100,15 +100,17 @@ public ArticleList() this.size_allocate.connect((allocation) => { if(allocation.height != m_height) { - if(allocation.height > m_height - && m_stack.get_visible_child_name() != "empty" - && m_stack.get_visible_child_name() != "syncing") - { - Logger.debug("ArticleList: size changed"); - if(m_currentList.needLoadMore(allocation.height)) - loadMore(); + if(allocation.height > m_height + && m_stack.get_visible_child_name() != "empty" + && m_stack.get_visible_child_name() != "syncing") + { + Logger.debug("ArticleList: size changed"); + if(m_currentList.needLoadMore(allocation.height)) + { + loadMore(); + } } - m_height = allocation.height; + m_height = allocation.height; } }); } @@ -118,7 +120,9 @@ public void newList(Gtk.StackTransitionType transition = Gtk.StackTransitionType Logger.debug("ArticleList: newList"); if(m_overlay != null) + { m_overlay.dismiss(); + } Logger.debug("ArticleList: disallow signals from scroll"); m_currentScroll.allowSignals(false); @@ -130,11 +134,11 @@ public void newList(Gtk.StackTransitionType transition = Gtk.StackTransitionType Logger.debug("load articles from db"); articles = DataBase.readOnly().read_articles(m_selectedFeedListID, - m_selectedFeedListType, - m_state, - m_searchTerm, - limit, - offset); + m_selectedFeedListType, + m_state, + m_searchTerm, + limit, + offset); Logger.debug("actual articles loaded: " + articles.size.to_string()); if(articles.size == 0) @@ -211,7 +215,9 @@ private void checkForNewRows() private void loadMore() { if(m_currentList == null) + { return; + } Logger.debug("ArticleList.loadmore()"); @@ -219,11 +225,11 @@ private void loadMore() uint offset = m_currentList.getSizeForState() + determineNewRowCount(null, null); var articles = DataBase.readOnly().read_articles(m_selectedFeedListID, - m_selectedFeedListType, - m_state, - m_searchTerm, - m_dynamicRowThreshold, - offset); + m_selectedFeedListType, + m_state, + m_searchTerm, + m_dynamicRowThreshold, + offset); Logger.debug("actual articles loaded: " + articles.size.to_string()); if(articles.size > 0) @@ -253,11 +259,11 @@ private void loadNewer(int newCount, int offset) Logger.debug("load articles from db"); var articles = DataBase.readOnly().read_articles(m_selectedFeedListID, - m_selectedFeedListType, - m_state, - m_searchTerm, - newCount, - offset); + m_selectedFeedListType, + m_state, + m_searchTerm, + newCount, + offset); Logger.debug("actual articles loaded: " + articles.size.to_string()); if(articles.size > 0) @@ -265,9 +271,13 @@ private void loadNewer(int newCount, int offset) if(m_stack.get_visible_child_name() == "empty") { if(m_currentList == m_List1) + { m_stack.set_visible_child_full("list1", Gtk.StackTransitionType.CROSSFADE); + } else + { m_stack.set_visible_child_full("list2", Gtk.StackTransitionType.CROSSFADE); + } } m_currentScroll.valueChanged.disconnect(updateVisibleRows); @@ -327,7 +337,9 @@ public void updateArticleList() if(first == null || second == null) + { continue; + } var insertArticles = DataBase.readOnly().read_article_between( m_selectedFeedListID, m_selectedFeedListType, @@ -431,9 +443,13 @@ private void updateVisibleRows(ScrollDirection direction) { int visible = m_currentScroll.isVisible(row); if(visible == 0 || visible == 1) + { visibleArticles.add(row.getID()); + } else if(visible == -1) + { break; + } } } m_currentList.setVisibleRows(visibleArticles); @@ -449,13 +465,17 @@ private bool keyPressed(Gdk.EventKey event) case Gdk.Key.Down: int diff = m_currentList.move(true); if(m_state != ArticleListState.UNREAD) + { m_currentScroll.scrollDiff(diff); + } break; case Gdk.Key.Up: int diff = m_currentList.move(false); if(m_state != ArticleListState.UNREAD) + { m_currentScroll.scrollDiff(diff); + } break; case Gdk.Key.Page_Down: @@ -474,7 +494,9 @@ public int move(bool down) int diff = m_currentList.move(down); if(m_state != ArticleListState.UNREAD) + { m_currentScroll.scrollDiff(diff); + } return diff; } @@ -483,14 +505,18 @@ public void showOverlay() { Logger.debug("ArticleList: showOverlay"); if(m_currentScroll.getScroll() > 0.0) + { showNotification(); + } } private void showNotification() { if(m_overlay != null || m_state != ArticleListState.ALL) + { return; + } m_overlay = new InAppNotification.withIcon( _("New articles"), @@ -509,14 +535,18 @@ private void showNotification() public void dismissOverlay() { if(m_overlay != null) + { m_overlay.dismiss(); + } } public Article? getSelectedArticle() { if(m_stack.get_visible_child_name() == "empty" || m_stack.get_visible_child_name() == "syncing") + { return null; + } return m_currentList.getSelectedArticle(); } @@ -525,7 +555,9 @@ public Article? getFirstArticle() { ArticleRow? selectedRow = m_currentList.getFirstRow(); if(selectedRow == null) + { return null; + } return selectedRow.getArticle(); } diff --git a/src/Widgets/ArticleList/ArticleListBox.vala b/src/Widgets/ArticleList/ArticleListBox.vala index 209cb020..391d82c6 100644 --- a/src/Widgets/ArticleList/ArticleListBox.vala +++ b/src/Widgets/ArticleList/ArticleListBox.vala @@ -95,19 +95,27 @@ private void addRow(ArticleListBalance balance, bool reverse = false, bool anima var priority = GLib.Priority.DEFAULT_IDLE; if(ColumnView.get_default().playingMedia()) + { priority = GLib.Priority.HIGH_IDLE; + } m_idleID = GLib.Idle.add(() => { if(m_lazyQeue == null || m_lazyQeue.size == 0) - return false; + { + return false; + } Article item; if(reverse) - item = m_lazyQeue.last(); + { + item = m_lazyQeue.last(); + } else - item = m_lazyQeue.first(); + { + item = m_lazyQeue.first(); + } // check if row is already there if(m_articles.has_key(item.getArticleID())) @@ -143,9 +151,13 @@ private void addRow(ArticleListBalance balance, bool reverse = false, bool anima this.insert(newRow, item.getPos()); if(animate) - newRow.reveal(true, 150); + { + newRow.reveal(true, 150); + } else - newRow.reveal(true, 0); + { + newRow.reveal(true, 0); + } return false; }, priority); @@ -205,7 +217,9 @@ private void selectAfter(ArticleRow row, int time) m_selectSourceID = Timeout.add(time, () => { if(!ColumnView.get_default().searchFocused()) - row.activate(); + { + row.activate(); + } m_selectSourceID = 0; return false; }); @@ -225,7 +239,9 @@ public ArticleStatus toggleReadSelected() ArticleRow selectedRow = this.get_selected_row() as ArticleRow; if(selectedRow == null) + { return ArticleStatus.READ; + } return selectedRow.toggleUnread(); } @@ -235,7 +251,9 @@ public ArticleStatus toggleMarkedSelected() ArticleRow selectedRow = this.get_selected_row() as ArticleRow; if(selectedRow == null) + { return ArticleStatus.UNMARKED; + } return selectedRow.toggleMarked(); } @@ -249,7 +267,9 @@ public Article? getSelectedArticle() { ArticleRow selectedRow = this.get_selected_row() as ArticleRow; if(selectedRow != null) + { return selectedRow.getArticle(); + } return null; } @@ -258,10 +278,14 @@ public string getSelectedURL() { ArticleRow selectedRow = this.get_selected_row() as ArticleRow; if(selectedRow != null) + { return selectedRow.getURL(); + } if(this.get_children().length() == 0) + { return "empty"; + } return ""; } @@ -274,7 +298,9 @@ public int move(bool down) { ArticleRow? firstRow = getFirstRow(); if(firstRow == null) + { return 0; + } else { selectAfter(firstRow, time); @@ -289,7 +315,9 @@ public int move(bool down) var rows = this.get_children(); if(!down) + { rows.reverse(); + } int current = rows.index(selectedRow); uint length = rows.length(); @@ -298,7 +326,9 @@ public int move(bool down) { current++; if(current >= length) + { return 0; + } nextRow = rows.nth_data(current) as ArticleRow; } @@ -309,7 +339,9 @@ public int move(bool down) Logger.debug(@"ArticleListBox.move: height: $height"); if(down) + { return height; + } return -height; } @@ -321,7 +353,9 @@ public void removeRow(ArticleRow row, int animateDuration = 700) m_articles.unset(id); GLib.Timeout.add(animateDuration + 50, () => { if(row.get_parent() != null) - this.remove(row); + { + this.remove(row); + } return false; }); } @@ -401,7 +435,9 @@ public void setVisibleRows(Gee.HashSet<string> visibleArticles) // mark all rows that are not visible now and have been before as read m_visibleArticles.foreach((id) => { if(!visibleArticles.contains(id)) - invisibleRows.add(id); + { + invisibleRows.add(id); + } return true; }); @@ -428,7 +464,9 @@ public void removeTagFromSelectedRow(string tagID) ArticleRow selectedRow = this.get_selected_row() as ArticleRow; if(selectedRow == null) + { return; + } selectedRow.removeTag(tagID); } @@ -438,12 +476,16 @@ public ArticleRow? getFirstRow() var children = this.get_children(); if(children == null) + { return null; + } var firstRow = children.first().data as ArticleRow; if(firstRow == null) + { return null; + } return firstRow; } @@ -453,12 +495,16 @@ public ArticleRow? getLastRow() var children = this.get_children(); if(children == null) + { return null; + } var lastRow = children.last().data as ArticleRow; if(lastRow == null) + { return null; + } return lastRow; } @@ -471,9 +517,13 @@ public bool selectedIsFirst() var lastRow = children.first().data as ArticleRow; if(n == 0) + { return true; + } else if(m_state == ArticleListState.UNREAD && n == 1 && !lastRow.isBeingRevealed()) + { return true; + } return false; } @@ -487,9 +537,13 @@ public bool selectedIsLast() var lastRow = children.last().data as ArticleRow; if(n + 1 == length) + { return true; + } else if(m_state == ArticleListState.UNREAD && n + 2 == length && !lastRow.isBeingRevealed()) + { return true; + } return false; } @@ -502,7 +556,9 @@ public void markAllAsRead() { var tmpRow = row as ArticleRow; if(tmpRow != null) + { tmpRow.updateUnread(ArticleStatus.READ); + } } } @@ -512,7 +568,9 @@ public int selectedRowPosition() int scroll = 0; if(selectedRow == null) + { return scroll; + } var FeedChildList = this.get_children(); foreach(Gtk.Widget row in FeedChildList) @@ -551,7 +609,9 @@ private void highlightRow(string articleID) { var tmpRow = row as ArticleRow; if(tmpRow != null && tmpRow.getID() != articleID) + { tmpRow.opacity = 0.5; + } } } @@ -562,7 +622,9 @@ private void unHighlightRow() { var tmpRow = row as ArticleRow; if(tmpRow != null) + { tmpRow.opacity = 1.0; + } } } @@ -581,7 +643,9 @@ public int getSizeForState() { var tmpRow = row as ArticleRow; if(tmpRow != null && tmpRow.getArticle().getUnread() == ArticleStatus.UNREAD) + { unread += 1; + } } return unread; } @@ -598,11 +662,15 @@ public bool needLoadMore(int height) { var tmpRow = row as ArticleRow; if(tmpRow != null && tmpRow.isRevealed()) + { rowHeight += tmpRow.get_allocated_height(); + } } if(rowHeight < height + 100) + { return true; + } return false; } @@ -624,7 +692,9 @@ public void setAllUpdated(bool updated = false) { var tmpRow = row as ArticleRow; if(tmpRow != null) + { tmpRow.setUpdated(updated); + } } } diff --git a/src/Widgets/ArticleList/ArticleListEmptyLabel.vala b/src/Widgets/ArticleList/ArticleListEmptyLabel.vala index c794af11..14a907b3 100644 --- a/src/Widgets/ArticleList/ArticleListEmptyLabel.vala +++ b/src/Widgets/ArticleList/ArticleListEmptyLabel.vala @@ -44,23 +44,35 @@ public void build(string selectedID, FeedListType type, ArticleListState state, if(state == ArticleListState.UNREAD) { if(searchTerm != "") + { message = _(@"No unread articles that fit \"$search\" in feed \"$name\""); + } else + { message = _(@"No unread articles in feed \"$name\""); + } } else if(state == ArticleListState.MARKED) { if(searchTerm != "") + { message = _(@"No starred articles that fit \"$search\" in feed \"$name\""); + } else + { message = _(@"No starred articles in feed \"$name\""); + } } else if(state == ArticleListState.ALL) { if(searchTerm != "") + { message = _(@"No articles that fit \"$search\" in feed \"$name\""); + } else + { message = _(@"No articles in feed \"$name\""); + } } break; case FeedListType.TAG: @@ -68,23 +80,35 @@ public void build(string selectedID, FeedListType type, ArticleListState state, if(state == ArticleListState.UNREAD) { if(searchTerm != "") + { message = _(@"No unread articles that fit \"$search\" in tag \"$name\""); + } else + { message = _(@"No unread articles in tag \"$name\""); + } } else if(state == ArticleListState.MARKED) { if(searchTerm != "") + { message = _(@"No starred articles that fit \"$search\" in tag \"$name\""); + } else + { message = _(@"No starred articles in tag \"$name\""); + } } else if(state == ArticleListState.ALL) { if(searchTerm != "") + { message = _(@"No articles that fit \"$search\" in tag \"$name\""); + } else + { message = _(@"No articles in tag \"$name\""); + } } break; case FeedListType.CATEGORY: @@ -92,23 +116,35 @@ public void build(string selectedID, FeedListType type, ArticleListState state, if(state == ArticleListState.UNREAD) { if(searchTerm != "") + { message = _(@"No unread articles that fit \"$search\" in category \"$name\""); + } else + { message = _(@"No unread articles in category \"$name\""); + } } else if(state == ArticleListState.MARKED) { if(searchTerm != "") + { message = _(@"No starred articles that fit \"$search\" in category \"$name\""); + } else + { message = _(@"No starred articles in category \"$name\""); + } } else if(state == ArticleListState.ALL) { if(searchTerm != "") + { message = _(@"No articles that fit \"$search\" in category \"$name\""); + } else + { message = _(@"No articles in category \"$name\""); + } } break; } @@ -118,23 +154,35 @@ public void build(string selectedID, FeedListType type, ArticleListState state, if(state == ArticleListState.UNREAD) { if(searchTerm != "") + { message = _(@"No unread articles that fit \"$search\""); + } else + { message = _("No unread articles"); + } } else if(state == ArticleListState.MARKED) { if(searchTerm != "") + { message = _(@"No starred articles that fit \"$search\""); + } else + { message = _("No starred articles"); + } } else if(state == ArticleListState.ALL) { if(searchTerm != "") + { message = _(@"No articles that fit \"$search\""); + } else + { message = _("No articles"); + } } } diff --git a/src/Widgets/ArticleList/ArticleListScroll.vala b/src/Widgets/ArticleList/ArticleListScroll.vala index 3f023436..486c7285 100644 --- a/src/Widgets/ArticleList/ArticleListScroll.vala +++ b/src/Widgets/ArticleList/ArticleListScroll.vala @@ -68,7 +68,9 @@ private void trackUpper() } if(GLib.Math.fabs(vadjustment.upper - m_upperCache) > 2.0) + { checkScrolledDown(); + } m_upperCache = vadjustment.upper; m_valueCache = vadjustment.value; @@ -77,9 +79,13 @@ private void trackUpper() private void trackValue() { if(vadjustment.value > (m_valueCache + m_valueThreshold)) + { valueChanged(ScrollDirection.DOWN); + } else if(vadjustment.value < (m_valueCache - m_valueThreshold)) + { valueChanged(ScrollDirection.UP); + } checkScrolledTop(); checkScrolledDown(); @@ -99,7 +105,9 @@ private void checkScrolledTop() GLib.Timeout.add(m_scrollCooldown, () => { m_scrolledTopOnCooldown = false; if(vadjustment.value < 2.0) - scrolledTop(); + { + scrolledTop(); + } return false; }); } @@ -190,9 +198,13 @@ public void scrollToPos(double pos, bool animate = true) Logger.debug(@"ArticleListScroll.scrollToPos: %f".printf(pos+leftOverScroll)); if(pos == -1) + { m_transitionDiff = (vadjustment.upper - vadjustment.page_size - vadjustment.value); + } else + { m_transitionDiff = (pos-this.vadjustment.value)+leftOverScroll; + } m_transitionStartValue = this.vadjustment.value; Logger.debug(@"ArticleListScroll.scrollDiff: startValue $m_transitionStartValue"); @@ -212,9 +224,13 @@ public double getScroll() private void setScroll(double pos) { if(pos == -1) + { this.vadjustment.value = this.vadjustment.upper - this.vadjustment.page_size; + } else + { this.vadjustment.value = pos; + } } public double getPageSize() @@ -232,11 +248,15 @@ public int isVisible(Gtk.ListBoxRow row, int additionalRows = 0) // row is (additionalRows * rowHeight) above the current viewport if(y < -( (1+additionalRows) * rowHeight)) + { return -1; + } // row is (additionalRows * rowHeight) below the current viewport if(y > additionalRows * rowHeight + scrollHeight) + { return 1; + } // row is visible return 0; @@ -254,7 +274,9 @@ private bool scrollTick(Gtk.Widget widget, Gdk.FrameClock frame_clock) double t = 1.0; if(now < this.m_endTime) + { t = (now - m_startTime) / (double)(m_endTime - m_startTime); + } t = easeOutCubic(t); diff --git a/src/Widgets/ArticleRow.vala b/src/Widgets/ArticleRow.vala index 16502275..4f25a105 100644 --- a/src/Widgets/ArticleRow.vala +++ b/src/Widgets/ArticleRow.vala @@ -87,9 +87,13 @@ private bool populate() m_label.set_line_wrap(true); m_label.set_lines(2); if(m_article.getUnread() == ArticleStatus.UNREAD) + { m_label.get_style_context().add_class("headline-unread"); + } else + { m_label.get_style_context().add_class("headline-read"); + } m_label.set_ellipsize(Pango.EllipsizeMode.END); m_label.set_alignment(0.0f, 0.2f); m_label.set_tooltip_text(m_article.getTitle()); @@ -117,11 +121,17 @@ private bool populate() m_unread_eventbox.add(m_unread_stack); m_unread_eventbox.show_all(); if(m_article.getUnread() == ArticleStatus.UNREAD) + { m_unread_stack.set_visible_child_name("unread"); + } else if(m_article.getUnread() == ArticleStatus.READ) + { m_unread_stack.set_visible_child_name("empty"); + } else + { Logger.warning("ArticleRow: id %s - unread status undefined %i".printf(m_article.getArticleID(), m_article.getUnread())); + } m_unread_eventbox.enter_notify_event.connect(unreadIconEnter); m_unread_eventbox.leave_notify_event.connect(unreadIconLeave); @@ -136,11 +146,17 @@ private bool populate() m_marked_eventbox.add(m_marked_stack); m_marked_eventbox.show_all(); if(m_article.getMarked() == ArticleStatus.MARKED) + { m_marked_stack.set_visible_child_name("marked"); + } else if(m_article.getMarked() == ArticleStatus.UNMARKED) + { m_marked_stack.set_visible_child_name("empty"); + } else + { Logger.warning("ArticleRow: id %s - unread status undefined %i".printf(m_article.getArticleID(), m_article.getMarked())); + } m_marked_eventbox.enter_notify_event.connect(markedIconEnter); m_marked_eventbox.leave_notify_event.connect(markedIconLeave); @@ -163,7 +179,9 @@ private bool populate() short_preview = short_preview.strip(); } else + { short_preview = m_article.getPreview(); + } } @@ -274,7 +292,9 @@ private Gtk.Image createFavIcon() favicon.get_surface.begin((obj, res) => { var surface = favicon.get_surface.end(res); if(surface != null) - icon.surface = surface; + { + icon.surface = surface; + } }); ulong handler_id = favicon.surface_changed.connect((feed, surface) => { icon.surface = surface; @@ -302,7 +322,9 @@ private Gtk.Window getFeedIconWindow() private bool rowEnter(Gdk.EventCrossing event) { if(event.detail == Gdk.NotifyType.INFERIOR) + { return true; + } m_hovering_row = true; @@ -332,7 +354,9 @@ private bool rowEnter(Gdk.EventCrossing event) private bool rowLeave(Gdk.EventCrossing event) { if(event.detail == Gdk.NotifyType.INFERIOR) + { return true; + } m_hovering_row = false; @@ -364,7 +388,10 @@ private bool rowClick(Gdk.EventButton event) switch (event.button) { //if double left clicked, open the article in an external browser: case 1: - if (event.type != Gdk.EventType.@2BUTTON_PRESS) return false; + if (event.type != Gdk.EventType.@2BUTTON_PRESS) + { + return false; + } try{ Gtk.show_uri_on_window(MainWindow.get_default(), m_article.getURL(), Gdk.CURRENT_TIME); @@ -483,10 +510,12 @@ public void updateUnread(ArticleStatus unread) private bool unreadIconEnter() { m_hovering_unread = true; - if(m_article.getUnread() == ArticleStatus.READ) { + if(m_article.getUnread() == ArticleStatus.READ) + { m_unread_stack.set_visible_child_name("unread"); } - else if(m_article.getUnread() == ArticleStatus.UNREAD) { + else if(m_article.getUnread() == ArticleStatus.UNREAD) + { m_unread_stack.set_visible_child_name("read"); } this.show_all(); @@ -497,10 +526,12 @@ private bool unreadIconEnter() private bool unreadIconLeave() { m_hovering_unread = false; - if(m_article.getUnread() == ArticleStatus.READ) { + if(m_article.getUnread() == ArticleStatus.READ) + { m_unread_stack.set_visible_child_name("read"); } - else{ + else + { m_unread_stack.set_visible_child_name("unread"); } this.show_all(); @@ -574,10 +605,12 @@ public void updateMarked(ArticleStatus marked) private bool markedIconEnter() { m_hovering_marked = true; - if(m_article.getMarked() == ArticleStatus.UNMARKED) { + if(m_article.getMarked() == ArticleStatus.UNMARKED) + { m_marked_stack.set_visible_child_name("marked"); } - else if (m_article.getMarked() == ArticleStatus.MARKED) { + else if (m_article.getMarked() == ArticleStatus.MARKED) + { m_marked_stack.set_visible_child_name("unmarked"); } this.show_all(); @@ -588,10 +621,12 @@ private bool markedIconEnter() private bool markedIconLeave() { m_hovering_marked = false; - if(m_article.getMarked() == ArticleStatus.UNMARKED) { + if(m_article.getMarked() == ArticleStatus.UNMARKED) + { m_marked_stack.set_visible_child_name("unmarked"); } - else if(m_article.getMarked() == ArticleStatus.MARKED) { + else if(m_article.getMarked() == ArticleStatus.MARKED) + { m_marked_stack.set_visible_child_name("marked"); } this.show_all(); @@ -652,9 +687,11 @@ public void copyArticleURL(string article_id){ /* Copy selected article url to clipboard */ - if (article_id != "") { + if (article_id != "") + { Article? article = DataBase.readOnly().read_article(article_id); - if (article != null) { + if (article != null) + { string article_url = article.getURL(); Gdk.Display display = MainWindow.get_default().get_display (); Gtk.Clipboard clipboard = Gtk.Clipboard.get_for_display (display, Gdk.SELECTION_CLIPBOARD); @@ -667,7 +704,9 @@ public void copyArticleURL(string article_id){ public void reveal(bool reveal, uint duration = 500) { if(!reveal) + { this.set_size_request(0, 0); + } m_revealer.set_transition_duration(duration); m_revealer.set_reveal_child(reveal); } @@ -687,7 +726,9 @@ public bool hasTag(string tagID) foreach(string tag in m_article.getTagIDs()) { if(tag == tagID) + { return true; + } } return false; diff --git a/src/Widgets/ArticleView.vala b/src/Widgets/ArticleView.vala index 95d6bc80..fa2afea1 100644 --- a/src/Widgets/ArticleView.vala +++ b/src/Widgets/ArticleView.vala @@ -98,11 +98,11 @@ public ArticleView() if(allocation.width != m_width || allocation.height != m_height) { - m_width = allocation.width; - m_height = allocation.height; - Logger.debug("ArticleView: size changed"); - setBackgroundColor(); - recalculate(); + m_width = allocation.width; + m_height = allocation.height; + Logger.debug("ArticleView: size changed"); + setBackgroundColor(); + recalculate(); } }); @@ -191,7 +191,9 @@ private WebKit.WebView getNewView() //view.load_failed.connect(loadFailed); view.decide_policy.connect(decidePolicy); if(m_color != null) + { view.set_background_color(m_color); + } view.show(); return view; @@ -223,9 +225,13 @@ public void fillContent(string articleID) switchViews(); if(m_FullscreenArticle) - m_currentView.zoom_level = m_FullscreenZoomLevel; + { + m_currentView.zoom_level = m_FullscreenZoomLevel; + } else - m_currentView.zoom_level = 1.0; + { + m_currentView.zoom_level = 1.0; + } m_fsHead.setTitle(article.getTitle()); m_fsHead.setMarked(article.getMarked()); @@ -303,14 +309,22 @@ private void switchViews() if(m_FullscreenArticle) { if(ColumnView.get_default().ArticleListSelectedIsLast()) + { m_prevButton.reveal(false); + } else + { m_prevButton.reveal(true); + } if(ColumnView.get_default().ArticleListSelectedIsFirst()) + { m_nextButton.reveal(false); + } else + { m_nextButton.reveal(true); + } } } @@ -318,7 +332,9 @@ private void removeFromStack(string childName) { Gtk.Widget? widget = m_stack.get_child_by_name(childName); if(widget != null) + { m_stack.remove(widget); + } } private void checkQueue() @@ -339,12 +355,16 @@ public void clearContent() Gtk.Widget? oldView = null; if(m_stack.get_visible_child_name() != "empty" && m_stack.get_visible_child_name() != "crash") + { oldView = m_stack.get_visible_child(); + } m_progress.reveal(false); m_stack.set_visible_child_name("empty"); GLib.Timeout.add((uint)(1.2*m_animationDuration), () => { if(oldView != null) - m_stack.remove(oldView); + { + m_stack.remove(oldView); + } checkQueue(); return false; }, GLib.Priority.HIGH); @@ -380,7 +400,9 @@ public void open_link(WebKit.LoadEvent load_event) case WebKit.LoadEvent.COMMITTED: Logger.debug("ArticleView: load COMMITTED"); if(m_searchTerm != "") + { m_currentView.get_find_controller().search(m_searchTerm, WebKit.FindOptions.CASE_INSENSITIVE, 99); + } break; case WebKit.LoadEvent.FINISHED: Logger.debug("ArticleView: load FINISHED"); @@ -417,7 +439,9 @@ public void setScrollPos(int pos) if(m_stack.get_visible_child_name() == "empty" || m_stack.get_visible_child_name() == "crash" || m_currentView == null) + { return; + } m_busy = true; m_currentView.run_javascript.begin("window.scrollTo(0,%i);".printf(pos), null, (obj, res) => { @@ -438,7 +462,9 @@ private int getScollUpper() if(m_stack.get_visible_child_name() == "empty" || m_stack.get_visible_child_name() == "crash" || m_currentView == null) + { return 0; + } string javascript = """ document.title = Math.max ( @@ -476,7 +502,9 @@ public int getScrollPos() if(m_stack.get_visible_child_name() == "empty" || m_stack.get_visible_child_name() == "crash" || m_currentView == null) + { return 0; + } // use mainloop to prevent app from shutting down before the result can be fetched // ugly but works =/ @@ -537,10 +565,12 @@ private void recalculate() try { if(m_connected - && m_stack.get_visible_child_name() != "empty" - && m_stack.get_visible_child_name() != "crash" - && m_currentView != null) + && m_stack.get_visible_child_name() != "empty" + && m_stack.get_visible_child_name() != "crash" + && m_currentView != null) + { m_messenger.recalculate(); + } } catch(Error e) { @@ -642,9 +672,13 @@ private bool onKeyPress(Gdk.EventKey event) { case Gdk.Key.KP_0: if(m_FullscreenArticle) + { m_currentView.zoom_level = m_FullscreenZoomLevel; + } else + { m_currentView.zoom_level = 1.0; + } return true; case Gdk.Key.KP_Add: @@ -678,7 +712,9 @@ public void load(string? id = null) private bool updateDragMomentum() { if(!m_inDrag) + { return false; + } for(int i = 9; i > 0; --i) { @@ -694,7 +730,9 @@ private bool updateDragMomentum() private bool ScrollDragRelease() { if(m_inDrag) + { return true; + } m_momentum /= 1.2; @@ -721,7 +759,9 @@ private bool ScrollDragRelease() return false; } else + { return true; + } } private void setBackgroundColor() @@ -750,6 +790,7 @@ private bool onContextMenu(WebKit.ContextMenu menu, Gdk.Event event, WebKit.HitT && (menuItem.get_gaction().name != "context-menu-action-9") // copy text && (menuItem.get_gaction().name != "context-menu-action-6") // copy image && (menuItem.get_gaction().name != "context-menu-action-7")) // copy image address + { menu.remove(menuItem); } @@ -766,7 +807,9 @@ private bool onContextMenu(WebKit.ContextMenu menu, Gdk.Event event, WebKit.HitT } if(menu.first() == null) + { return true; + } return false; } @@ -780,7 +823,9 @@ private void onMouseOver(WebKit.HitTestResult hitTest, uint modifiers) double relY = m_posY2/this.get_allocated_width(); if(relY >= 0.85 && relX <= 0.5) + { align = Gtk.Align.END; + } m_UrlOverlay.setURL(hitTest.get_link_uri(), align); m_UrlOverlay.reveal(true); @@ -818,7 +863,9 @@ private bool enterFullscreenVideo() public void exitFullscreenVideo() { if(m_currentView != null) + { m_currentView.leave_fullscreen(); + } } public bool fullscreenVideo() @@ -839,10 +886,14 @@ public void enterFullscreenArticle() m_currentView.zoom_level = m_FullscreenZoomLevel; if(!ColumnView.get_default().ArticleListSelectedIsFirst()) + { m_nextButton.reveal(true); + } if(!ColumnView.get_default().ArticleListSelectedIsLast()) + { m_prevButton.reveal(true); + } } public void leaveFullscreenArticle() @@ -871,7 +922,9 @@ private void printProgress() m_progress.setPercentageF(progress); if(progress == 1.0) + { m_progress.reveal(false); + } } public void setMarked(ArticleStatus marked) @@ -901,11 +954,15 @@ private void onCrash(WebKit.WebProcessTerminationReason reason) m_progress.reveal(false); Gtk.Widget? oldView = null; if(m_stack.get_visible_child_name() != "crash") + { oldView = m_stack.get_visible_child(); + } m_stack.set_visible_child_name("crash"); GLib.Timeout.add((uint)(1.2*m_animationDuration), () => { if(oldView != null) - m_stack.remove(oldView); + { + m_stack.remove(oldView); + } checkQueue(); return false; }, GLib.Priority.HIGH); @@ -934,7 +991,9 @@ public void killMedia() public bool playingMedia() { if(m_currentMedia == null) + { return false; + } return true; } @@ -942,7 +1001,9 @@ public bool playingMedia() public void print() { if(m_currentView == null) + { return; + } string articleName = DataBase.readOnly().read_article(m_currentArticle).getTitle() + ".pdf"; diff --git a/src/Widgets/ArticleViewHeader.vala b/src/Widgets/ArticleViewHeader.vala index 48958917..22495c3e 100644 --- a/src/Widgets/ArticleViewHeader.vala +++ b/src/Widgets/ArticleViewHeader.vala @@ -194,7 +194,9 @@ public void setOffline() m_share_button.sensitive = false; if(Utils.canManipulateContent() && FeedReaderBackend.get_default().supportTags()) + { m_tag_button.sensitive = false; + } } public void setOnline() @@ -204,7 +206,9 @@ public void setOnline() m_share_button.sensitive = true; if(Utils.canManipulateContent() && FeedReaderBackend.get_default().supportTags()) + { m_tag_button.sensitive = true; + } } } @@ -217,7 +221,9 @@ public void showMediaButton(bool show) public void refreshSahrePopover() { if(m_sharePopover == null) + { return; + } m_sharePopover.refreshList(); } diff --git a/src/Widgets/BackendInfoPopover.vala b/src/Widgets/BackendInfoPopover.vala index 42deb595..758c7b16 100644 --- a/src/Widgets/BackendInfoPopover.vala +++ b/src/Widgets/BackendInfoPopover.vala @@ -138,7 +138,9 @@ private bool websiteClicked(Gdk.EventButton event) { // only accept left mouse button if(event.button != 1) + { return false; + } switch(event.type) { diff --git a/src/Widgets/CategorieRow.vala b/src/Widgets/CategorieRow.vala index 106b237c..4662ab72 100644 --- a/src/Widgets/CategorieRow.vala +++ b/src/Widgets/CategorieRow.vala @@ -133,9 +133,13 @@ public CategoryRow(string name, string categorieID, int orderID, uint unread_cou set_unread_count(m_unread_count); if(m_collapsed) + { m_stack.set_visible_child_name("collapsed"); + } else + { m_stack.set_visible_child_name("expanded"); + } if(Utils.canManipulateContent()) { @@ -360,10 +364,14 @@ private bool onClick(Gdk.EventButton event) { // only right click allowed if(event.button != 3) + { return false; + } if(!Utils.canManipulateContent()) + { return false; + } switch(event.type) @@ -385,7 +393,9 @@ private bool onClick(Gdk.EventButton event) } if(this.is_selected()) - moveUP(); + { + moveUP(); + } uint time = 300; this.reveal(false, time); @@ -399,17 +409,23 @@ private bool onClick(Gdk.EventButton event) notification.disconnect(eventID); this.reveal(true, time); if(wasExpanded) - expand_collapse(); + { + expand_collapse(); + } notification.dismiss(); }); }); var removeWithChildren_action = new GLib.SimpleAction("deleteAllCat", null); removeWithChildren_action.activate.connect(() => { if(!m_collapsed) - expand_collapse(); + { + expand_collapse(); + } if(this.is_selected()) - moveUP(); + { + moveUP(); + } uint time = 300; this.reveal(false, time); @@ -484,10 +500,12 @@ private void showRenamePopover(Gdk.DragContext? context = null, uint time = 0, s m_categorieID = FeedReaderBackend.get_default().addCategory(renameEntry.get_text(), "", true); if(id2 == null) // move feed + { FeedReaderBackend.get_default().moveCategory(id1, m_categorieID); } else // move category + { FeedReaderBackend.get_default().moveFeed(id1, id2, m_categorieID); } @@ -500,7 +518,9 @@ private void showRenamePopover(Gdk.DragContext? context = null, uint time = 0, s string label = _("rename"); if(m_categorieID == CategoryID.NEW.to_string() && context != null) + { label = _("add"); + } var renameButton = new Gtk.Button.with_label(label); renameButton.get_style_context().add_class("suggested-action"); @@ -555,7 +575,9 @@ private bool onExpandClick(Gdk.EventButton event) { // only accept left mouse button if(event.button != 1) + { return false; + } switch(event.type) { @@ -597,7 +619,9 @@ private bool onExpandLeave(Gdk.EventCrossing event) { if(event.detail != Gdk.NotifyType.VIRTUAL && event.mode != Gdk.CrossingMode.NORMAL) + { return false; + } m_hovered = false; @@ -633,7 +657,9 @@ public void upUnread() public void downUnread() { if(m_unread_count > 0) + { set_unread_count(m_unread_count-1); + } } public string getID() @@ -689,7 +715,9 @@ public bool isRevealed() public void reveal(bool reveal, uint duration = 500) { if(!reveal && this.is_selected()) + { deselectRow(); + } m_revealer.set_transition_duration(duration); m_revealer.set_reveal_child(reveal); diff --git a/src/Widgets/ColorCircle.vala b/src/Widgets/ColorCircle.vala index dc2634ae..c9aa9b9b 100644 --- a/src/Widgets/ColorCircle.vala +++ b/src/Widgets/ColorCircle.vala @@ -69,7 +69,9 @@ private bool IconLeave() private bool IconClicked(Gdk.EventButton event) { if(event.button != 1) + { return false; + } switch(event.type) { @@ -93,7 +95,9 @@ private Cairo.Surface drawIcon(bool light = false) color.parse(Constants.COLORS[m_color]); double lighten = 1.0; if(light) + { lighten = 0.7; + } var surface = this.get_window().create_similar_image_surface(0, size, size, 0); Cairo.Context context = new Cairo.Context(surface); diff --git a/src/Widgets/ColumnView.vala b/src/Widgets/ColumnView.vala index c90a0a74..80f6ac83 100644 --- a/src/Widgets/ColumnView.vala +++ b/src/Widgets/ColumnView.vala @@ -27,7 +27,9 @@ private static ColumnView? m_columnView = null; public static ColumnView get_default() { if(m_columnView == null) + { m_columnView = new ColumnView(); + } return m_columnView; } @@ -110,7 +112,9 @@ private ColumnView() m_articleList = new ArticleList(); m_articleList.drag_begin.connect((context) => { if(DataBase.readOnly().read_tags().is_empty) - m_feedList.newFeedlist(m_articleList.getState(), false, true); + { + m_feedList.newFeedlist(m_articleList.getState(), false, true); + } m_feedList.expand_collapse_category(CategoryID.TAGS.to_string(), true); m_feedList.expand_collapse_category(CategoryID.MASTER.to_string(), false); m_feedList.addEmptyTagRow(); @@ -122,9 +126,13 @@ private ColumnView() m_articleList.drag_failed.connect((context, result) => { Logger.debug("ContentPage: articleList drag_failed signal"); if(DataBase.readOnly().read_tags().is_empty) - m_feedList.newFeedlist(m_articleList.getState(), false, false); + { + m_feedList.newFeedlist(m_articleList.getState(), false, false); + } else - m_feedList.removeEmptyTagRow(); + { + m_feedList.removeEmptyTagRow(); + } return false; }); setArticleListState((ArticleListState)Settings.state().get_enum("show-articles")); @@ -207,7 +215,9 @@ public void showPane() public int ArticleListNEXT() { if(m_article_view.fullscreenArticle()) + { m_article_view.setTransition(Gtk.StackTransitionType.SLIDE_LEFT, 500); + } return m_articleList.move(false); } @@ -215,7 +225,9 @@ public int ArticleListNEXT() public int ArticleListPREV() { if(m_article_view.fullscreenArticle()) + { m_article_view.setTransition(Gtk.StackTransitionType.SLIDE_RIGHT, 500); + } return m_articleList.move(true); } @@ -276,7 +288,9 @@ private void setArticleListState(ArticleListState state) if(oldState == ArticleListState.MARKED || state == ArticleListState.MARKED) + { m_feedList.refreshCounters(state); + } } private void setSearchTerm(string searchTerm) @@ -484,7 +498,9 @@ public void saveState(ref InterfaceState state) state.setArticleViewScrollPos(m_article_view.getScrollPos()); var selectedArticle = m_articleList.getSelectedArticle(); if(selectedArticle != null) + { state.setArticleListSelectedRow(selectedArticle.getArticleID()); + } state.setArticleListTopRow(m_articleList.getFirstArticle()); m_headerbar.saveState(ref state); diff --git a/src/Widgets/ColumnViewHeader.vala b/src/Widgets/ColumnViewHeader.vala index a44dcccb..57eda1b6 100644 --- a/src/Widgets/ColumnViewHeader.vala +++ b/src/Widgets/ColumnViewHeader.vala @@ -61,7 +61,9 @@ public ColumnViewHeader() m_refresh_button.updating(updating); m_refresh_button.clicked.connect(() => { if(!m_refresh_button.getStatus()) - refresh(); + { + refresh(); + } else { cancel(); @@ -74,7 +76,9 @@ public ColumnViewHeader() m_search = new Gtk.SearchEntry(); m_search.placeholder_text = _("Search Articles"); if(Settings.tweaks().get_boolean("restore-searchterm")) + { m_search.text = Settings.state().get_string("search-term"); + } // connect after 160ms because Gtk.SearchEntry fires search_changed with 150ms delay // with the timeout the signal should not trigger a newList() when restoring the state at startup @@ -133,7 +137,8 @@ public ColumnViewHeader() private void set_window_buttons() { string[] buttons = Gtk.Settings.get_default().gtk_decoration_layout.split(":"); - if (buttons.length < 2) { + if (buttons.length < 2) + { buttons = {buttons[0], ""}; Logger.warning("gtk_decoration_layout in unexpected format"); } diff --git a/src/Widgets/FeedList.vala b/src/Widgets/FeedList.vala index bf0cff7e..ba50c21f 100644 --- a/src/Widgets/FeedList.vala +++ b/src/Widgets/FeedList.vala @@ -49,7 +49,9 @@ public feedList () { { if(selected_feed.getID() == m_selectedID && m_selectedType == FeedListType.FEED) - return; + { + return; + } m_selectedID = selected_feed.getID(); m_selectedType = FeedListType.FEED; @@ -62,7 +64,9 @@ public feedList () { { if(selected_categorie.getID() == m_selectedID && m_selectedType == FeedListType.CATEGORY) - return; + { + return; + } m_selectedID = selected_categorie.getID(); m_selectedType = FeedListType.CATEGORY; @@ -75,7 +79,9 @@ public feedList () { { if(selected_tag.getTag().getTagID() == m_selectedID && m_selectedType == FeedListType.TAG) - return; + { + return; + } m_selectedID = selected_tag.getTag().getTagID(); m_selectedType = FeedListType.TAG; @@ -87,9 +93,13 @@ public feedList () { m_list.key_press_event.connect((event) => { if(event.keyval == Gdk.Key.Down) - move(true); + { + move(true); + } else if(event.keyval == Gdk.Key.Up) - move(false); + { + move(false); + } else if(event.keyval == Gdk.Key.Left || event.keyval == Gdk.Key.Right) { CategoryRow selected_categorie = m_list.get_selected_row() as CategoryRow; @@ -120,7 +130,8 @@ public void move(bool down) var FeedListChildren = m_list.get_children(); - if(!down) { + if(!down) + { FeedListChildren.reverse(); } @@ -224,7 +235,9 @@ private bool isEmpty() { var FeedChildList = m_list.get_children(); if(FeedChildList == null) + { return true; + } return false; } @@ -236,9 +249,13 @@ private void createFeedlist(ArticleListState state, bool defaultSettings, bool m uint unread = 0; if(state == ArticleListState.MARKED) + { unread = DataBase.readOnly().get_marked_total(); + } else + { unread = DataBase.readOnly().get_unread_total(); + } var allFeed = new Feed(FeedID.ALL.to_string(), _("All Articles"), "", unread); var row_separator1 = new FeedRow(separatorFeed, "-1", 0); @@ -304,7 +321,9 @@ private void createFeedlist(ArticleListState state, bool defaultSettings, bool m }); feedrow.drag_failed.connect(onDragEnd); if(!Settings.general().get_boolean("feedlist-only-show-unread") || item.getUnread() != 0) + { feedrow.reveal(true, 0); + } feedrow.activateUnreadEventbox((state == ArticleListState.MARKED) ? false : true); pos++; } @@ -326,7 +345,9 @@ private void createFeedlist(ArticleListState state, bool defaultSettings, bool m }); feedrow.drag_failed.connect(onDragEnd); if(!Settings.general().get_boolean("feedlist-only-show-unread") || item.getUnread() != 0) + { feedrow.reveal(true, 0); + } feedrow.activateUnreadEventbox((state == ArticleListState.MARKED) ? false : true); } } @@ -353,7 +374,9 @@ private void restoreSelectedRow() { m_list.select_row(tmpRow); if(m_selectedID != selectedRow[1]) + { tmpRow.activate(); + } return; } } @@ -368,7 +391,9 @@ private void restoreSelectedRow() { m_list.select_row(tmpRow); if(m_selectedID != selectedRow[1]) + { tmpRow.activate(); + } return; } } @@ -383,7 +408,9 @@ private void restoreSelectedRow() { m_list.select_row(tmpRow); if(m_selectedID != selectedRow[1]) + { tmpRow.activate(); + } return; } } @@ -427,9 +454,13 @@ private void addMasterCategory(int length, string name) ); CategoryRow.collapse.connect((collapse, catID, selectParent) => { if(collapse) - collapseCategorieInternal(catID, selectParent); + { + collapseCategorieInternal(catID, selectParent); + } else - expandCategorieInternal(catID); + { + expandCategorieInternal(catID); + } }); m_list.insert(CategoryRow, length+1); CategoryRow.setAsRead.connect(markSelectedRead); @@ -452,9 +483,13 @@ private void addTagCategory(int length) ); tagrow.collapse.connect((collapse, catID, selectParent) => { if(collapse) - collapseCategorieInternal(catID, selectParent); + { + collapseCategorieInternal(catID, selectParent); + } else - expandCategorieInternal(catID); + { + expandCategorieInternal(catID); + } }); m_list.insert(tagrow, length+2); tagrow.setAsRead.connect(markSelectedRead); @@ -532,7 +567,9 @@ private void createCategories(ref Gee.List<Feed> feeds, bool masterCat, ArticleL if(m_TagsDisplayed) { if(level == 1) + { parent = CategoryID.MASTER.to_string(); + } level++; } @@ -548,9 +585,13 @@ private void createCategories(ref Gee.List<Feed> feeds, bool masterCat, ArticleL expand = false; CategoryRow.collapse.connect((collapse, catID, selectParent) => { if(collapse) - collapseCategorieInternal(catID, selectParent); + { + collapseCategorieInternal(catID, selectParent); + } else - expandCategorieInternal(catID); + { + expandCategorieInternal(catID); + } }); m_list.insert(CategoryRow, pos); CategoryRow.setAsRead.connect(markSelectedRead); @@ -559,11 +600,15 @@ private void createCategories(ref Gee.List<Feed> feeds, bool masterCat, ArticleL CategoryRow.drag_begin.connect((context) => { onDragBegin(context); if(supportMultiLevelCategories) - showNewCategory(); + { + showNewCategory(); + } }); CategoryRow.drag_failed.connect(onDragEnd); if(!Settings.general().get_boolean("feedlist-only-show-unread") || item.getUnreadCount() != 0) + { CategoryRow.reveal(true, 0); + } CategoryRow.activateUnreadEventbox((state == ArticleListState.MARKED) ? false : true); break; } @@ -638,9 +683,13 @@ public void refreshCounters(ArticleListState state) if(Settings.general().get_boolean("feedlist-only-show-unread")) { if(tmpFeedRow.getUnreadCount() == 0) + { tmpFeedRow.reveal(false); + } else if(isCategorieExpanded(tmpFeedRow.getCatID()) || Utils.onlyShowFeeds()) + { tmpFeedRow.reveal(true); + } } @@ -665,9 +714,13 @@ public void refreshCounters(ArticleListState state) if(Settings.general().get_boolean("feedlist-only-show-unread")) { if(tmpCatRow.getUnreadCount() == 0) + { tmpCatRow.reveal(false); + } else + { tmpCatRow.reveal(true); + } } break; @@ -694,7 +747,9 @@ public void refreshCounters(ArticleListState state) tmpCatRow.activateUnreadEventbox(true); } if(Settings.general().get_boolean("feedlist-only-show-unread") && tmpCatRow.getUnreadCount() != 0) + { tmpCatRow.reveal(true); + } break; } @@ -783,7 +838,9 @@ private void expandCategorieInternal(string catID) if(tmpFeedRow != null && tmpFeedRow.getCatID() == catID) { if(!Settings.general().get_boolean("feedlist-only-show-unread") || tmpFeedRow.getUnreadCount() != 0) + { tmpFeedRow.reveal(true, m_expand_collapse_time); + } } if(tmpCatRow != null && tmpCatRow.getParent() == catID) { @@ -791,7 +848,9 @@ private void expandCategorieInternal(string catID) { tmpCatRow.reveal(true, m_expand_collapse_time); if(tmpCatRow.isExpanded()) + { expandCategorieInternal(tmpCatRow.getID()); + } } } if(tmpTagRow != null && catID == CategoryID.TAGS.to_string()) @@ -811,7 +870,9 @@ public void expand_collapse_category(string catID, bool expand = true) { if((!expand && tmpCatRow.isExpanded()) ||(expand && !tmpCatRow.isExpanded())) + { tmpCatRow.expand_collapse(false); + } } } } @@ -825,7 +886,9 @@ private bool isCategorieExpanded(string catID) { var tmpCatRow = row as CategoryRow; if(tmpCatRow != null && tmpCatRow.getID() == catID && tmpCatRow.isExpanded()) + { return true; + } } return false; @@ -836,7 +899,9 @@ public string getSelectedFeed() { FeedRow selected_row = m_list.get_selected_row() as FeedRow; if(selected_row != null) + { return selected_row.getID(); + } return ""; } @@ -925,7 +990,9 @@ private bool getCatState(string id) foreach(string str in list) { if(id == str) + { return true; + } } return false; @@ -952,11 +1019,14 @@ public void copySelectedFeedURL(string feed_id){ /* Copy selected feed url to clipboard */ - if (feed_id != "" && feed_id != null) { + if (feed_id != "" && feed_id != null) + { var feed = DataBase.readOnly().read_feed(feed_id); - if (feed != null) { + if (feed != null) + { string feed_url = feed.getXmlUrl(); - if (feed_url != null) { + if (feed_url != null) + { Gdk.Display display = MainWindow.get_default().get_display(); Gtk.Clipboard clipboard = Gtk.Clipboard.get_for_display(display, Gdk.SELECTION_CLIPBOARD); @@ -1181,7 +1251,9 @@ private bool onDragEnd(Gdk.DragContext context, Gtk.DragResult result) && tmpFeed.getID() != FeedID.ALL.to_string()) { if(isCategorieExpanded(tmpFeed.getCatID())) + { tmpFeed.reveal(true); + } } } else if(tmpTag != null && isCategorieExpanded(CategoryID.TAGS.to_string())) diff --git a/src/Widgets/FeedListFooter.vala b/src/Widgets/FeedListFooter.vala index b2f49e45..bb2c71df 100644 --- a/src/Widgets/FeedListFooter.vala +++ b/src/Widgets/FeedListFooter.vala @@ -71,7 +71,9 @@ public void setReady() public void setRemoveButtonSensitive(bool sensitive) { if(FeedReaderApp.get_default().isOnline() && FeedReaderBackend.get_default().supportFeedManipulation()) + { m_removeButton.set_sensitive(sensitive); + } } public void setSelectedRow(FeedListType type, string id) diff --git a/src/Widgets/FeedRow.vala b/src/Widgets/FeedRow.vala index 2a7f9b46..c7932c2d 100644 --- a/src/Widgets/FeedRow.vala +++ b/src/Widgets/FeedRow.vala @@ -73,9 +73,13 @@ public FeedRow(Feed feed, string parentCat, int level) if(!Utils.onlyShowFeeds() && m_feed.getFeedID() != FeedID.ALL.to_string()) + { this.get_style_context().add_class("fr-sidebar-feed"); + } else + { this.get_style_context().add_class("fr-sidebar-row"); + } m_box.pack_start(m_icon, false, false, 8); m_box.pack_start(m_label, true, true, 0); @@ -125,7 +129,9 @@ public FeedRow(Feed feed, string parentCat, int level) { activateUnreadEventbox(false); if(m_eventBox != null) + { m_eventBox.button_press_event.disconnect(onClick); + } this.drag_begin.disconnect(onDragBegin); this.drag_data_get.disconnect(onDragDataGet); } @@ -188,10 +194,14 @@ private bool onClick(Gdk.EventButton event) { // only right click allowed if(event.button != 3) + { return false; + } if(!Utils.canManipulateContent()) + { return false; + } switch(event.type) { @@ -215,9 +225,13 @@ private bool onClick(Gdk.EventButton event) }); if(m_feed.getUnread() != 0) + { markAsRead_action.set_enabled(true); + } else + { markAsRead_action.set_enabled(false); + } var rename_action = new GLib.SimpleAction("renameFeed", null); rename_action.activate.connect(showRenamePopover); @@ -343,7 +357,9 @@ public void upUnread() public void downUnread() { if(m_feed.getUnread() > 0) + { set_unread_count(m_feed.getUnread() - 1); + } } public void update(string text, uint unread_count) @@ -405,7 +421,9 @@ public void reveal(bool reveal, uint duration = 500) if(!reveal) { if(this.is_selected()) + { deselectRow(); + } m_timeout_source_id = GLib.Timeout.add(duration, () => { this.hide(); @@ -418,7 +436,9 @@ public void reveal(bool reveal, uint duration = 500) public void activateUnreadEventbox(bool activate) { if(m_unreadBox == null) + { return; + } if(activate) { @@ -437,7 +457,9 @@ public void activateUnreadEventbox(bool activate) private void RemoveThisFeed(Variant? parameter) { if(this.is_selected()) + { moveUP(); + } uint time = 300; this.reveal(false, time); diff --git a/src/Widgets/FullscreenHeader.vala b/src/Widgets/FullscreenHeader.vala index c0be4d9b..127b46ab 100644 --- a/src/Widgets/FullscreenHeader.vala +++ b/src/Widgets/FullscreenHeader.vala @@ -44,7 +44,9 @@ public FullscreenHeader() m_header.popClosed.connect(() => { m_popover = false; if(!m_hover) - m_revealer.set_reveal_child(false); + { + m_revealer.set_reveal_child(false); + } }); m_header.showArticleButtons(true); m_revealer = new Gtk.Revealer(); @@ -65,15 +67,21 @@ public FullscreenHeader() }); this.leave_notify_event.connect((event) => { if(event.detail == Gdk.NotifyType.INFERIOR) - return false; + { + return false; + } if(event.detail == Gdk.NotifyType.NONLINEAR_VIRTUAL) - return false; + { + return false; + } m_hover = false; if(m_popover) - return false; + { + return false; + } removeTimeout(); diff --git a/src/Widgets/HoverButton.vala b/src/Widgets/HoverButton.vala index b4aca643..bde2d2e2 100644 --- a/src/Widgets/HoverButton.vala +++ b/src/Widgets/HoverButton.vala @@ -41,9 +41,13 @@ public HoverButton(Gtk.Image inactive, Gtk.Image active, bool isActive) m_button.add(m_stack); if(isActive) + { m_stack.set_visible_child_name("active"); + } else + { m_stack.set_visible_child_name("inactive"); + } @@ -104,7 +108,9 @@ private bool onEnter(Gdk.EventCrossing event) private bool onLeave(Gdk.EventCrossing event) { if(event.detail == Gdk.NotifyType.INFERIOR) + { return false; + } if(m_isActive) { diff --git a/src/Widgets/ImagePopup.vala b/src/Widgets/ImagePopup.vala index ccd3f351..adbee8d4 100644 --- a/src/Widgets/ImagePopup.vala +++ b/src/Widgets/ImagePopup.vala @@ -131,7 +131,9 @@ public imagePopup(string imagePath, string? url, Gtk.Window parent, double img_h m_zoomButton.add(new Gtk.Image.from_icon_name("zoom-in-symbolic", Gtk.IconSize.BUTTON)); m_zoomButton.toggled.connect(() => { if(!m_zoomButton.get_active()) - m_image.notify["scale"].disconnect(onImageScrolled); + { + m_image.notify["scale"].disconnect(onImageScrolled); + } if(m_zoomButton.get_active()) { m_scale.set_value(m_image.scale); @@ -169,7 +171,9 @@ public imagePopup(string imagePath, string? url, Gtk.Window parent, double img_h }); headerEvents.leave_notify_event.connect((event) => { if(event.detail != Gdk.NotifyType.VIRTUAL && event.mode != Gdk.CrossingMode.NORMAL) - return false; + { + return false; + } m_hoverHeader = false; return false; @@ -351,10 +355,14 @@ private bool onEnter(Gdk.EventCrossing event) private bool onLeave(Gdk.EventCrossing event) { if(event.detail != Gdk.NotifyType.VIRTUAL && event.mode != Gdk.CrossingMode.NORMAL) + { return false; + } if(m_dragWindow) + { return false; + } m_hoverImage = false; m_revealer.set_reveal_child(false); @@ -364,7 +372,9 @@ private bool onLeave(Gdk.EventCrossing event) private bool updateDragMomentum() { if(!m_inDrag) + { return false; + } for(int i = 9; i > 0; --i) { @@ -383,7 +393,9 @@ private bool updateDragMomentum() private bool ScrollDragRelease() { if(m_inDrag) + { return true; + } Gtk.Allocation allocation; this.get_allocation(out allocation); @@ -426,7 +438,9 @@ private bool ScrollDragRelease() return false; } else + { return true; + } } private void closeWindow() diff --git a/src/Widgets/InfoBar.vala b/src/Widgets/InfoBar.vala index 3acc4a4d..3844d784 100644 --- a/src/Widgets/InfoBar.vala +++ b/src/Widgets/InfoBar.vala @@ -31,7 +31,9 @@ public InfoBar(string text) bar.set_show_close_button(true); bar.response.connect((response_id) => { if(response_id == Gtk.ResponseType.CLOSE) - this.set_reveal_child(false); + { + this.set_reveal_child(false); + } }); this.set_transition_duration(200); diff --git a/src/Widgets/LoginRow.vala b/src/Widgets/LoginRow.vala index 5c7e21ea..b7bbe8ea 100644 --- a/src/Widgets/LoginRow.vala +++ b/src/Widgets/LoginRow.vala @@ -73,7 +73,9 @@ public BackendInfo getInfo() private bool rowEnter(Gdk.EventCrossing event) { if(event.detail == Gdk.NotifyType.INFERIOR) + { return true; + } m_hovered = true; m_infoStack.set_visible_child_name("button"); @@ -86,7 +88,9 @@ private bool rowLeave(Gdk.EventCrossing event) || event.detail == Gdk.NotifyType.VIRTUAL) { if(event.detail == Gdk.NotifyType.VIRTUAL) + { m_hovered = false; + } return true; } @@ -103,7 +107,9 @@ private void infoClicked() pop.closed.connect_after(() => { GLib.Timeout.add(50, () => { if(!m_hovered) - m_infoStack.set_visible_child_name("empty"); + { + m_infoStack.set_visible_child_name("empty"); + } return false; }); }); diff --git a/src/Widgets/MainWindow.vala b/src/Widgets/MainWindow.vala index 76901972..4566d9ba 100644 --- a/src/Widgets/MainWindow.vala +++ b/src/Widgets/MainWindow.vala @@ -34,7 +34,9 @@ private static MainWindow? m_window = null; public static MainWindow get_default() { if(m_window == null) + { m_window = new MainWindow(); + } return m_window; } @@ -177,12 +179,16 @@ private bool onStateEvent(Gdk.EventWindowState event) { Logger.debug("MainWindow: fullscreen event"); if(ColumnView.get_default().getSelectedArticle() == null) + { return true; + } if(ColumnView.get_default().isFullscreenVideo()) { if((event.new_window_state & Gdk.WindowState.FULLSCREEN) != Gdk.WindowState.FULLSCREEN) + { ColumnView.get_default().exitFullscreenVideo(); + } base.window_state_event(event); return true; @@ -217,7 +223,9 @@ public void showContent(Gtk.StackTransitionType transition = Gtk.StackTransition { Logger.debug("MainWindow: show content"); if(!noNewFeedList) + { ColumnView.get_default().newFeedList(); + } m_stack.set_visible_child_full("content", transition); ColumnView.get_default().getHeader().setButtonsSensitive(true); @@ -516,7 +524,9 @@ private bool checkShortcut(Gdk.EventKey event, string gsettingKey) { if(event.state == 16 || event.state == 0) + { return true; + } } else if(mod in event.state) { @@ -530,10 +540,14 @@ private bool checkShortcut(Gdk.EventKey event, string gsettingKey) private bool shortcuts(Gdk.EventKey event) { if(m_stack.get_visible_child_name() != "content") + { return false; + } if(ColumnView.get_default().searchFocused()) + { return false; + } if(checkShortcut(event, "articlelist-prev")) { @@ -568,14 +582,20 @@ private bool shortcuts(Gdk.EventKey event) if(ColumnView.get_default().isFullscreen()) { if(event.keyval == Gdk.Key.Left) + { ColumnView.get_default().ArticleListPREV(); + } else + { ColumnView.get_default().ArticleListNEXT(); + } return true; } else + { return false; + } } if(checkShortcut(event, "articleview-up")) diff --git a/src/Widgets/MediaButton.vala b/src/Widgets/MediaButton.vala index bb707d49..e49e5afc 100644 --- a/src/Widgets/MediaButton.vala +++ b/src/Widgets/MediaButton.vala @@ -50,9 +50,13 @@ public AttachedMediaButton() m_pop.hide(); mediaRow? mRow = row as mediaRow; if(mRow != null) - playMedia(mRow.getURL()); + { + playMedia(mRow.getURL()); + } else - Logger.error("MediaPopover: invalid row clicked"); + { + Logger.error("MediaPopover: invalid row clicked"); + } }); m_pop = new Gtk.Popover(this); diff --git a/src/Widgets/MediaPlayer.vala b/src/Widgets/MediaPlayer.vala index ec9585bc..fc4b90d7 100644 --- a/src/Widgets/MediaPlayer.vala +++ b/src/Widgets/MediaPlayer.vala @@ -103,7 +103,9 @@ private void buildUI() double duration = (double)dur/1000000000; double percent = position*100.0/duration; if(m_seek_source_id == 0) - m_scale.set_value(percent); + { + m_scale.set_value(percent); + } calcTime(); } return true; @@ -182,7 +184,9 @@ private void buildUI() this.get_style_context().add_class("osd"); this.margin = 40; if(m_type == MediaType.VIDEO) + { this.pack_start(bufferOverlay, true, true); + } this.pack_start(hBox, false, false); this.valign = Gtk.Align.END; this.show_all(); @@ -212,9 +216,13 @@ private void togglePause() } if(m_muted) + { m_player["volume"] = 0.0; + } else + { m_player["volume"] = 1.0; + } } private void switchDisplay() @@ -430,9 +438,13 @@ private bool busCallback(Gst.Bus bus, Gst.Message message) { m_player.set_state(Gst.State.PLAYING); if(m_type == MediaType.VIDEO) + { m_bufferLabel.hide(); + } else + { m_playStack.set_visible_child_name("button"); + } } break; diff --git a/src/Widgets/ModeButton.vala b/src/Widgets/ModeButton.vala index 4dc70299..2209e8b2 100644 --- a/src/Widgets/ModeButton.vala +++ b/src/Widgets/ModeButton.vala @@ -147,17 +147,22 @@ public void set_active (int new_active_index, bool initSet = false) { return_if_fail (item_map.has_key (new_active_index)); var new_item = item_map[new_active_index] as Item; - if (new_item != null) { + if (new_item != null) + { assert (new_item.index == new_active_index); new_item.set_active (true); if (_selected == new_active_index) + { return; + } // Unselect the previous item var old_item = item_map[_selected] as Item; if (old_item != null) + { old_item.set_active (false); + } _selected = new_active_index; @@ -188,7 +193,8 @@ public void set_item_visible (int index, bool val) { return_if_fail (item_map.has_key (index)); var item = item_map[index] as Item; - if (item != null) { + if (item != null) + { assert (item.index == index); item.no_show_all = !val; item.visible = val; @@ -204,7 +210,8 @@ public new void remove (int index) { return_if_fail (item_map.has_key (index)); var item = item_map[index] as Item; - if (item != null) { + if (item != null) + { assert (item.index == index); item_map.unset (index); mode_removed (index, item.get_child ()); @@ -219,7 +226,9 @@ public void clear_children () { foreach (weak Gtk.Widget button in get_children ()) { button.hide (); if (button.get_parent () != null) + { base.remove (button); + } } item_map.clear (); @@ -251,17 +260,22 @@ private bool on_scroll_event (Gtk.Widget widget, Gdk.EventScroll ev) { var selected_item = item_map[selected]; if (selected_item == null) + { return false; + } int new_item = children.index (selected_item); if (new_item < 0) + { return false; + } do { new_item += offset; var item = children.nth_data (new_item) as Item; - if (item != null && item.visible && item.sensitive) { + if (item != null && item.visible && item.sensitive) + { selected = item.index; break; } diff --git a/src/Widgets/RemovePopover.vala b/src/Widgets/RemovePopover.vala index 1d2ddc33..4026345b 100644 --- a/src/Widgets/RemovePopover.vala +++ b/src/Widgets/RemovePopover.vala @@ -84,7 +84,9 @@ private void removeTag() ulong eventID = notification.dismissed.connect(() => { var tag = DataBase.readOnly().read_tag(m_id); if(tag != null) - FeedReaderBackend.get_default().deleteTag(tag); + { + FeedReaderBackend.get_default().deleteTag(tag); + } }); notification.action.connect(() => { notification.disconnect(eventID); diff --git a/src/Widgets/ResetPage.vala b/src/Widgets/ResetPage.vala index 0e71b260..fa3cd012 100644 --- a/src/Widgets/ResetPage.vala +++ b/src/Widgets/ResetPage.vala @@ -88,7 +88,9 @@ private void resetAllData() } if(!m_reset) + { return; + } } // set "currently-updating" ourself to prevent the backend to start sync diff --git a/src/Widgets/ServiceInfo.vala b/src/Widgets/ServiceInfo.vala index fc24576f..e23d3fa0 100644 --- a/src/Widgets/ServiceInfo.vala +++ b/src/Widgets/ServiceInfo.vala @@ -76,7 +76,9 @@ public void refresh() m_label.set_label(user_name); m_stack.set_visible_child_name("info"); if(server != "none") + { this.set_tooltip_text(Utils.shortenURL(server)); + } } } diff --git a/src/Widgets/Setting.vala b/src/Widgets/Setting.vala index ee3fdab4..61aabf8e 100644 --- a/src/Widgets/Setting.vala +++ b/src/Widgets/Setting.vala @@ -50,9 +50,9 @@ public SettingFont(string name, GLib.Settings settings, string key){ font_button.set_use_size(false); font_button.set_show_size(true); font_button.font_set.connect(() => { - var new_font = new Variant.string(font_button.get_font_name()); - settings.set_value(key, new Variant.maybe(VariantType.STRING, new_font)); - }); + var new_font = new Variant.string(font_button.get_font_name()); + settings.set_value(key, new Variant.maybe(VariantType.STRING, new_font)); + }); this.pack_end(font_button, false, false, 0); } diff --git a/src/Widgets/SettingsDialog.vala b/src/Widgets/SettingsDialog.vala index 622607db..eb4fd8cb 100644 --- a/src/Widgets/SettingsDialog.vala +++ b/src/Widgets/SettingsDialog.vala @@ -24,7 +24,9 @@ private static SettingsDialog? m_dialog = null; public static SettingsDialog get_default() { if(m_dialog == null) + { m_dialog = new SettingsDialog(); + } return m_dialog; } @@ -165,7 +167,9 @@ private Gtk.Box setup_Internal() internalsBox.expand = true; internalsBox.pack_start(sync_settings, false, true, 0); if(FeedReaderBackend.get_default().useMaxArticles()) + { internalsBox.pack_start(sync_count, false, true, 0); + } internalsBox.pack_start(sync_time, false, true, 0); internalsBox.pack_start(db_settings, false, true, 0); internalsBox.pack_start(drop_articles, false, true, 0); @@ -292,27 +296,43 @@ private int sortFunc(Gtk.ListBoxRow row1, Gtk.ListBoxRow row2) var r2 = row2 as ServiceSetup; if(r1 == null && r2 == null) + { return 0; + } else if(r1 == null) + { return 1; + } else if(r2 == null) + { return -1; + } if(r1.getUserName() == "" && r2.getUserName() == "") + { return 0; + } else if(r1.getUserName() == "") + { return 1; + } else if(r2.getUserName() == "") + { return -1; + } bool sys1 = r1.isSystemAccount(); bool sys2 = r2.isSystemAccount(); if(sys1 && sys2) + { return 0; + } else if(sys1) + { return -1; + } return 1; } @@ -333,7 +353,9 @@ private void headerFunc(Gtk.ListBoxRow row, Gtk.ListBoxRow? before) // this is the plus-button if(r1 == null) + { return; + } bool sys1 = r1.isSystemAccount(); diff --git a/src/Widgets/SharePopover.vala b/src/Widgets/SharePopover.vala index dcb0c70f..db25a664 100644 --- a/src/Widgets/SharePopover.vala +++ b/src/Widgets/SharePopover.vala @@ -105,7 +105,9 @@ private void clicked(Gtk.ListBoxRow row) { var widget = Share.get_default().shareWidget(shareRow.getType(), selectedArticle.getURL()); if(widget == null) + { shareURL(id, selectedArticle.getURL()); + } else { m_stack.add_named(widget, "form"); diff --git a/src/Widgets/TagPopover.vala b/src/Widgets/TagPopover.vala index 6268e436..329369b6 100644 --- a/src/Widgets/TagPopover.vala +++ b/src/Widgets/TagPopover.vala @@ -40,7 +40,9 @@ public TagPopover(Gtk.Widget widget) // in the DB. This works around that but we should fix the // underlying problem at some point if (tag != null) + { m_tags.add(tag); + } } } @@ -86,9 +88,13 @@ public TagPopover(Gtk.Widget widget) this.show_all(); if(m_tags.size == 0) + { m_stack.set_visible_child_name("empty"); + } else + { m_stack.set_visible_child_name("tags"); + } } @@ -121,7 +127,9 @@ private void prepareCompletion() foreach(Tag tag2 in m_tags) { if(tag2.getTitle() == tag.getTitle()) + { alreadyHasTag = true; + } } if(!alreadyHasTag) @@ -148,7 +156,9 @@ private void setupEntry() m_entry.activate.connect(() => { unowned string str = m_entry.get_text(); if(str == "") - return; + { + return; + } bool available = false; Tag? selectedTag = null; diff --git a/src/Widgets/TagRow.vala b/src/Widgets/TagRow.vala index 3d8032b0..ac6b5f1c 100644 --- a/src/Widgets/TagRow.vala +++ b/src/Widgets/TagRow.vala @@ -148,10 +148,14 @@ private bool onClick(Gdk.EventButton event) { // only right click allowed if(event.button != 3) + { return false; + } if(!Utils.canManipulateContent()) + { return false; + } switch(event.type) { @@ -164,7 +168,9 @@ private bool onClick(Gdk.EventButton event) var remove_action = new GLib.SimpleAction("deleteTag", null); remove_action.activate.connect(() => { if(this.is_selected()) - moveUP(); + { + moveUP(); + } uint time = 300; this.reveal(false, time); @@ -271,7 +277,9 @@ private void showRenamePopover(Gdk.DragContext? context = null, uint time = 0, A string label = _("rename"); if(m_tag.getTagID() == TagID.NEW && context != null) + { label = _("add"); + } var renameButton = new Gtk.Button.with_label(label); renameButton.get_style_context().add_class("suggested-action"); diff --git a/src/Widgets/UpdateButton.vala b/src/Widgets/UpdateButton.vala index cd11c59b..5f72bf74 100644 --- a/src/Widgets/UpdateButton.vala +++ b/src/Widgets/UpdateButton.vala @@ -74,7 +74,9 @@ public void updating(bool status, bool insensitive = true) m_status = status; this.set_has_tooltip(!status); if(insensitive) + { this.setSensitive(!status); + } if(status) { this.set_tooltip_text(_("Cancel")); @@ -104,13 +106,17 @@ public void setSensitive(bool sensitive) public void setProgress(string text) { if(m_hasPopup) + { m_ProgressText.set_text(text); + } } private bool onClick(Gdk.EventButton event) { if(event.button != 3) + { return false; + } if(m_status && !m_Popover.get_visible()) { diff --git a/src/Widgets/WebLoginPage.vala b/src/Widgets/WebLoginPage.vala index e4926be6..dd9907d1 100644 --- a/src/Widgets/WebLoginPage.vala +++ b/src/Widgets/WebLoginPage.vala @@ -60,8 +60,10 @@ public void redirection(WebKit.LoadEvent load_event) private void check() { if(m_success) + { // code already successfully extracted return; + } string url = m_view.get_uri(); |