[gnome-games/wip/aplazas/run-uri: 8/21] desktop: Add DesktopTrackerQuery.game_for_uri()



commit 838729dd323aa538c5ddcbf9f5133c9558ac82e2
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Thu Apr 13 15:01:34 2017 +0200

    desktop: Add DesktopTrackerQuery.game_for_uri()
    
    This will be used in a subsequent commit to make a game from an URI.

 plugins/desktop/src/desktop-tracker-query.vala |   25 +++++++++++++++--------
 1 files changed, 16 insertions(+), 9 deletions(-)
---
diff --git a/plugins/desktop/src/desktop-tracker-query.vala b/plugins/desktop/src/desktop-tracker-query.vala
index 174b44e..aef7978 100644
--- a/plugins/desktop/src/desktop-tracker-query.vala
+++ b/plugins/desktop/src/desktop-tracker-query.vala
@@ -19,7 +19,7 @@ private class Games.DesktopTrackerQuery : Object, TrackerQuery {
                return is_uri_valid (uri);
        }
 
-       public bool is_uri_valid (string uri) {
+       private bool is_uri_valid (string uri) {
                try {
                        check_uri (uri);
                } catch (Error e) {
@@ -31,15 +31,13 @@ private class Games.DesktopTrackerQuery : Object, TrackerQuery {
 
        public void process_cursor (Tracker.Sparql.Cursor cursor) {
                var uri = cursor.get_string (0);
-               try {
-                       process_uri (uri);
-               }
-               catch (Error e) {
-                       warning (e.message);
-               }
+               process_uri.begin (uri);
        }
 
-       public void process_uri (string uri) throws Error {
+       public async Game game_for_uri (string uri) throws Error {
+               Idle.add (this.game_for_uri.callback);
+               yield;
+
                check_uri (uri);
 
                var file = File.new_for_uri (uri);
@@ -56,7 +54,7 @@ private class Games.DesktopTrackerQuery : Object, TrackerQuery {
                        throw new CommandError.INVALID_COMMAND (_("Invalid command ā€œ%sā€."), command);
                var runner = new CommandRunner (args, true);
 
-               games += new GenericGame (title, icon, cover, runner);
+               return new GenericGame (title, icon, cover, runner);
        }
 
        public async void foreach_game (GameCallback game_callback) {
@@ -77,6 +75,15 @@ private class Games.DesktopTrackerQuery : Object, TrackerQuery {
                }
        }
 
+       private async void process_uri (string uri) {
+               try {
+                       games += yield game_for_uri (uri);
+               }
+               catch (Error e) {
+                       debug (e.message);
+               }
+       }
+
        private void check_uri (string uri) throws Error {
                var file = File.new_for_uri (uri);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]