~davidc3/onehundredscopes/scummvm

« back to all changes in this revision

Viewing changes to src/unity-scope-scummvm

  • Committer: David Callé
  • Date: 2012-01-18 12:59:49 UTC
  • Revision ID: davidc@framli.eu-20120118125949-9ws732nat962odw8
Commit some old changes before porting

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
                self.scope.search_in_global = False
32
32
                self.scope.connect ("notify::active-search", self.on_search_changed)
33
33
                self.scope.connect ("notify::active", self.on_search_changed)
 
34
                self.scope.connect ("notify::active-global-search", self.on_global_search_changed)
34
35
                self.scope.connect ("filters-changed", self.on_search_changed);
35
36
                self.scope.connect ("activate-uri", self.on_click);
36
37
                self.scope.export()
38
39
        def on_click (self, scope, uri):
39
40
                from subprocess import call
40
41
                print uri
41
 
#               GLib.spawn_async([uri.split('---')[0],uri.split('---')[1]], flags=(GLib.SPAWN_SEARCH_PATH | GLib.SPAWN_DO_NOT_REAP_CHILD))
42
 
                call("scummvm %s" % uri , shell=True)
43
 
                return Unity.ActivationResponse.new(Unity.HandledType.HIDE_DASH, uri)
 
42
#               return Unity.ActivationResponse.new(Unity.HandledType.HIDE_DASH, uri)
44
43
 
45
44
        def get_search_string (self):
46
45
                search = self.scope.props.active_search
47
46
                return search.props.search_string if search else None
 
47
                
 
48
        def get_global_search_string (self):
 
49
                search = self.scope.props.active_global_search
 
50
                return search.props.search_string if search else None
48
51
 
49
52
        def on_search_changed (self, scope, param_spec=None):
50
53
                        search = self.get_search_string()
53
56
                        results.clear()
54
57
                        self.update_results_model (search, results)
55
58
                        results.flush_revision_queue ()
 
59
                        
 
60
        def on_global_search_changed (self, scope, param_spec=None):
 
61
                        search = self.get_global_search_string()
 
62
                        print "Global search changed to: '%s'" % search
 
63
                        results = self.scope.props.global_results_model
 
64
                        results.clear()
 
65
                        self.update_results_model (search, results)
 
66
                        results.flush_revision_queue ()
 
67
 
56
68
 
57
69
        def update_results_model(self, search, model):
58
 
                if not self.check_filters("gameshelf") or self.check_filters("gameshelf") == "scummvm":
 
70
                if not self.check_filters("type") or self.check_filters("type") == "game":
59
71
                        for i in self.scummvm(search):
60
72
                                title = i[0]
61
73
                                comment = ""
62
74
                                uri = i[1]
63
 
#                               uri = GLib.spawn_async(i[1], flags=GLib.SPAWN_SEARCH_PATH)
64
75
                                icon_hint = i[2]
65
 
                                model.append (uri, icon_hint, 0,"application-x-desktop", title, comment, uri)
66
 
#                               model.append (uri, icon_hint, 1,"text/html", title, "A game of fun and mayhem...", uri)
 
76
                                model.append (uri, icon_hint, 1,"application-x-desktop", title, comment, uri)
67
77
                                if self.scope.props.active_search:
68
78
                                        self.scope.props.active_search.emit("finished")
69
79
 
89
99
                                        game_description = line.split("=")[1].replace("\n", "").split("(")[0]
90
100
                                        
91
101
                                        description_list.append(game_description)
 
102
                                        
92
103
                i = 0
93
104
                for id in id_list:
94
 
                        if search is None or search is '' or description_list[i].lower().find(search.lower())  > -1:
 
105
                        if search == "" or description_list[i].lower().find(search.lower()) > -1:
95
106
                                item_list = []
96
107
                                icon_hint = ''
97
108
                                for image in self.google_image_search("cover %s" % description_list[i]):
100
111
                                print description_list[i]
101
112
                                item_list.append(id_list[i])
102
113
                                item_list.append(icon_hint)
 
114
                                data_list.append(item_list)
103
115
                                i = i+1
104
 
                                data_list.append(item_list)
105
116
                return data_list
106
117
 
107
118
        # Google Images search
119
130
                                f = urllib2.urlopen(url)
120
131
                                content = f.read()
121
132
                                results = simplejson.loads(content)
122
 
                                print "google_image_search " + str(results['responseStatus'])
123
133
                                if results['responseStatus'] == 200:
124
134
                                        return results['responseData']['results']
125
135
                                else: