14
14
from gi.repository import Unity, UnityExtras
16
16
from datetime import datetime, timedelta
20
APP_NAME = "unity-scope-gdrive"
21
LOCAL_PATH = "/usr/share/locale/"
23
gettext.bindtextdomain(APP_NAME, LOCAL_PATH)
24
gettext.textdomain(APP_NAME)
20
28
# The primary bus name we grab *must* match what we specify in our .scope file
57
65
# Fitler, as we re-do the search anyway, this catch-all signal is perfect for
59
67
self._scope.connect ("notify::filtering", self._on_filters_or_preferences_changed);
69
filters = Unity.FilterSet.new()
70
f = Unity.RadioOptionFilter.new ("modified", _("Last modified"), Gio.ThemedIcon.new("input-keyboard-symbolic"), False)
71
f.add_option ("last-7-days", _("Last 7 days"), None)
72
f.add_option ("last-30-days", _("Last 30 days"), None)
73
f.add_option ("last-year", _("Last year"), None);
75
f2 = Unity.CheckOptionFilter.new ("type", _("Type"), Gio.ThemedIcon.new("input-keyboard-symbolic"), False)
76
f2.add_option ("documents", _("Documents"), None)
77
f2.add_option ("folders", _("Folders"), None)
78
f2.add_option ("images", _("Images"), None)
79
f2.add_option ("audio", _("Audio"), None)
80
f2.add_option ("videos", _("Videos"), None)
81
f2.add_option ("presentations", _("Presentations"), None)
82
f2.add_option ("other", _("Other"), None)
84
self._scope.props.filters = filters
85
cats = Unity.CategorySet.new()
86
cats.add (Unity.Category.new ('global',
88
Gio.ThemedIcon.new(THEME + "group-folders.svg"),
89
Unity.CategoryRenderer.VERTICAL_TILE))
90
cats.add (Unity.Category.new ('recent',
92
Gio.ThemedIcon.new(THEME + "group-recent.svg"),
93
Unity.CategoryRenderer.VERTICAL_TILE))
94
cats.add (Unity.Category.new ('downloads',
96
Gio.ThemedIcon.new(THEME + "group-downloads.svg"),
97
Unity.CategoryRenderer.VERTICAL_TILE))
98
cats.add (Unity.Category.new ('folders',
100
Gio.ThemedIcon.new(THEME + "group-folders.svg"),
101
Unity.CategoryRenderer.VERTICAL_TILE))
102
self._scope.props.categories = cats
60
103
self._scope.export()
62
105
def _on_enabled_event (self, account_manager, account_id):
234
277
last_time = datetime.now() - timedelta(age)
235
278
query.set_updated_min(time.mktime(last_time.timetuple()))
237
def filter_results (self, entry, s):
280
def filter_results (self, feed, s):
238
281
f = s.get_filter("type")
239
if not f: return entry
282
if not f: return feed
241
283
if not f.props.filtering:
244
rtype = entry.get_resource_id().split(":")[0]
246
filter_type = TYPE_MAP.get(rtype, "other")
247
return f.get_option(filter_type).props.active
287
rtype = entry.get_resource_id().split(":")[0]
288
filter_type = TYPE_MAP.get(rtype, "other")
289
if f.get_option(filter_type).props.active:
249
293
# Send back a useful icon depending on the document type
250
294
def icon_for_type (self, doc_type):