Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu@sugarlabs.org>2009-02-20 15:32:15 (GMT)
committer Tomeu Vizoso <tomeu@sugarlabs.org>2009-02-20 15:32:15 (GMT)
commit0f62a26ec206d0a2756326f5a71646079ee27720 (patch)
tree4f0a8ac0d6fea4a5333d50e7d93e9983d6d9f291 /src
parentd5d8a5338a4f214a799bf437e207bce6fce80599 (diff)
Listen for changes in the Activities dir and install/uninstall activities accordingly #235
Diffstat (limited to 'src')
-rw-r--r--src/jarabe/model/bundleregistry.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/jarabe/model/bundleregistry.py b/src/jarabe/model/bundleregistry.py
index 75b8ee4..15839c0 100644
--- a/src/jarabe/model/bundleregistry.py
+++ b/src/jarabe/model/bundleregistry.py
@@ -20,6 +20,7 @@ import traceback
import sys
import gobject
+import gio
import cjson
from sugar.bundle.activitybundle import ActivityBundle
@@ -30,7 +31,7 @@ from sugar import env
from jarabe import config
class BundleRegistry(gobject.GObject):
- """Service that tracks the available activity bundles"""
+ """Tracks the available activity bundles"""
__gsignals__ = {
'bundle-added': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
@@ -51,6 +52,9 @@ class BundleRegistry(gobject.GObject):
user_path = env.get_user_activities_path()
for activity_dir in [user_path, config.activities_path]:
self._scan_directory(activity_dir)
+ directory = gio.File(activity_dir)
+ monitor = directory.monitor_directory()
+ monitor.connect('changed', self.__file_monitor_changed_cb)
self._last_defaults_mtime = -1
self._favorite_bundles = {}
@@ -63,6 +67,15 @@ class BundleRegistry(gobject.GObject):
self._merge_default_favorites()
+ def __file_monitor_changed_cb(self, monitor, one_file, other_file, event_type):
+ logging.debug('__file_monitor_changed_cb %r' % ((monitor, one_file, other_file, event_type),))
+ if not one_file.get_path().endswith('.activity'):
+ return
+ if event_type == gio.FILE_MONITOR_EVENT_CREATED:
+ self.add_bundle(one_file.get_path())
+ elif event_type == gio.FILE_MONITOR_EVENT_DELETED:
+ self.remove_bundle(one_file.get_path())
+
def _load_mime_defaults(self):
defaults = {}