~davidc3/onehundredscopes/calculator-raring

« back to all changes in this revision

Viewing changes to src/unity-scope-calculator

  • Committer: David Callé
  • Date: 2012-01-29 10:44:32 UTC
  • Revision ID: davidc@framli.eu-20120129104432-qoix9roclyrqvin2
Port to precise

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
class Daemon:
29
29
        def __init__ (self):
30
30
                self.scope = Unity.Scope.new ("/net/launchpad/scope/math/calculator")
31
 
                self.scope.search_in_global = False
32
 
                self.scope.connect ("notify::active-search", self.on_search_changed)
33
 
                self.scope.connect ("notify::active-global-search", self.on_search_changed)
34
 
                self.scope.connect ("notify::active", self.on_search_changed)
35
 
                self.scope.connect ("filters-changed", self.on_search_changed);
 
31
                self.scope.search_in_global = True
 
32
                self.scope.connect ("search-changed", self.on_search_changed)
36
33
                self.scope.connect ("activate-uri", self.on_activate_uri);
37
34
                self.scope.export()
38
35
 
44
41
                GLib.spawn_command_line_async("notify-send -i gtk-copy '%s'" % uri)
45
42
                return Unity.ActivationResponse(handled=Unity.HandledType.HIDE_DASH, goto_uri='')
46
43
 
47
 
        def get_search_string (self):
48
 
                search = self.scope.props.active_global_search
49
 
                if search is None:
50
 
                        search = self.scope.props.active_search
51
 
                return search.props.search_string if search else None
52
 
 
53
 
        def on_search_changed (self, scope, param_spec=None):
54
 
                        search = self.get_search_string()
55
 
                        print "Search changed to: '%s'" % search
56
 
                        results_global = self.scope.props.global_results_model
57
 
                        results_global.clear()
58
 
                        self.update_results_model (search, results_global)
59
 
                        results_global.flush_revision_queue ()
 
44
        def on_search_changed (self, scope, search=None, search_type=0, cancellable=None):
 
45
                if search:
 
46
                        search_string = search.props.search_string.strip()
 
47
                        print 'Search changed to %s' % search_string
 
48
                else:
 
49
                        search_string = ''
 
50
                if search_type == Unity.SearchType.DEFAULT:
 
51
                        model = self.scope.props.results_model
 
52
                else:
 
53
                        model = self.scope.props.global_results_model
 
54
                model.clear()
 
55
                self.update_results_model (search_string, model)
 
56
                model.flush_revision_queue ()
 
57
                if search:
 
58
                        search.finished()
60
59
 
61
60
        def update_results_model(self, search, model):
62
61