11
11
from gi.repository import GLib, GObject, Gio
12
from gi.repository import Dee
13
12
from gi.repository import Accounts, Signon
14
13
from gi.repository import GData
16
# FIXME: Some weird bug in Dee or PyGI makes Dee fail unless we probe
17
# it *before* we import the Unity module... ?!
18
_m = dir(Dee.SequenceModel)
19
from gi.repository import Unity
14
from gi.repository import Unity, UnityExtras
21
16
from datetime import datetime, timedelta
40
35
def __init__ (self):
41
self._scope = Unity.Scope.new ("/net/launchpad/unity/scope/gdrive")
36
self._scope = Unity.DeprecatedScope.new ("/net/launchpad/unity/scope/gdrive", "gdrive")
42
37
self._scope.search_in_global = True;
43
38
self._preferences = Unity.PreferencesManager.get_default()
44
39
self._preferences.connect ("notify::remote-content-search",
61
56
# Though it's possible to connect to a more-specific changed signal on each
62
57
# Fitler, as we re-do the search anyway, this catch-all signal is perfect for
64
self._scope.connect ("filters-changed", self._on_filters_or_preferences_changed);
59
# self._scope.connect ("filters-changed", self._on_filters_or_preferences_changed);
65
60
self._scope.export()
67
62
def _on_enabled_event (self, account_manager, account_id):
82
77
search_string = search.props.search_string
83
78
results = search.props.results_model
86
results.flush_revision_queue()
88
81
if self._preferences.props.remote_content_search != Unity.PreferencesManagerRemoteContent.ALL:
89
82
search.emit("finished")
129
122
identity = auth_data.get_credentials_id()
130
123
session_data = auth_data.get_parameters()
131
124
self._auth_session = Signon.AuthSession.new(identity, auth_data.get_method())
132
self._main_loop = GObject.MainLoop()
125
self._main_loop = GLib.MainLoop()
133
126
self._auth_session.process(session_data,
134
127
auth_data.get_mechanism(),
135
128
self.login_cb, None)
196
model.append(entry.look_up_link(GData.LINK_ALTERNATE).get_uri(),
197
self.icon_for_type(rtype),
202
entry.props.content_uri);
189
model.append(uri=entry.look_up_link(GData.LINK_ALTERNATE).get_uri(),
190
icon_hint=self.icon_for_type(rtype),
192
mimetype="text/html",
193
title=entry.props.title,
195
dnd_uri=entry.props.content_uri,
196
result_type=Unity.ResultType.PERSONAL);
204
198
# This is where we do the actual search for documents
205
199
def get_doc_list (self, search, is_global):
278
if __name__ == "__main__":
279
# NOTE: If we used the normal 'dbus' module for Python we'll get
280
# slightly odd results because it uses a default connection
281
# to the session bus that is different from the default connection
282
# GDBus (hence libunity) will use. Meaning that the daemon name
283
# will be owned by a connection different from the one all our
284
# Dee + Unity magic is working on...
285
# Still waiting for nice GDBus bindings to land:
286
# http://www.piware.de/2011/01/na-zdravi-pygi/
287
session_bus_connection = Gio.bus_get_sync (Gio.BusType.SESSION, None)
288
session_bus = Gio.DBusProxy.new_sync (session_bus_connection, 0, None,
289
'org.freedesktop.DBus',
290
'/org/freedesktop/DBus',
291
'org.freedesktop.DBus', None)
292
result = session_bus.call_sync('RequestName',
293
GLib.Variant ("(su)", (BUS_NAME, 0x4)),
296
# Unpack variant response with signature "(u)". 1 means we got it.
297
result = result.unpack()[0]
300
print("Failed to own name %s. Bailing out." % BUS_NAME)
304
GObject.MainLoop().run()
272
if __name__ == '__main__':
273
daemon = UnityExtras.dbus_own_name(BUS_NAME, Daemon, None)
275
GLib.unix_signal_add(0, 2, lambda x: daemon.quit(), None)