From 99cce220cde2710f9ba58847f4e49eede99f89e2 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Wed, 20 Dec 2006 12:43:54 +0000 Subject: Get the default type from env, clean stuff a bit --- (limited to 'sugar') diff --git a/sugar/activity/Activity.py b/sugar/activity/Activity.py index 7a8e68c..0340259 100644 --- a/sugar/activity/Activity.py +++ b/sugar/activity/Activity.py @@ -125,7 +125,7 @@ class Activity(gtk.Window): def get_default_type(self): """Gets the type of the default activity network service""" - return activity.get_default_type(self.get_type()) + return env.get_bundle_default_type() def get_shared(self): """Returns TRUE if the activity is shared on the mesh.""" diff --git a/sugar/activity/ActivityFactory.py b/sugar/activity/ActivityFactory.py index 64c4fed..481c5b9 100644 --- a/sugar/activity/ActivityFactory.py +++ b/sugar/activity/ActivityFactory.py @@ -103,5 +103,6 @@ def start_factory(activity_class, bundle_path): os.environ['SUGAR_BUNDLE_PATH'] = bundle_path os.environ['SUGAR_BUNDLE_SERVICE_NAME'] = bundle.get_service_name() + os.environ['SUGAR_BUNDLE_DEFAULT_TYPE'] = bundle.get_default_type() factory = ActivityFactory(bundle.get_service_name(), activity_class) diff --git a/sugar/activity/__init__.py b/sugar/activity/__init__.py index 1e606d5..4b69e24 100644 --- a/sugar/activity/__init__.py +++ b/sugar/activity/__init__.py @@ -7,12 +7,3 @@ settings = gtk.settings_get_default() grid = Grid() sizes = 'gtk-large-toolbar=%d, %d' % (grid.dimension(1), grid.dimension(1)) settings.set_string_property('gtk-icon-sizes', sizes, '') - -def get_default_type(activity_type): - """Get the activity default type. - - It's the type of the main network service which tracks presence - and provides info about the activity, for example the title.""" - splitted_id = activity_type.split('.') - splitted_id.reverse() - return '_' + '_'.join(splitted_id) + '._udp' diff --git a/sugar/activity/bundle.py b/sugar/activity/bundle.py index 00d2d52..d9fd0bf 100644 --- a/sugar/activity/bundle.py +++ b/sugar/activity/bundle.py @@ -69,6 +69,13 @@ class Bundle: """Get the activity service name""" return self._service_name + def get_default_type(self): + """Get the type of the main network service which tracks presence + and provides info about the activity, for example the title.""" + splitted = self.get_service_name().split('.') + splitted.reverse() + return '_' + '_'.join(splitted) + '._udp' + def get_icon(self): """Get the activity icon name""" return self._icon diff --git a/sugar/env.py b/sugar/env.py index 1c7164c..09511f4 100644 --- a/sugar/env.py +++ b/sugar/env.py @@ -36,6 +36,12 @@ def get_bundle_service_name(): else: return None +def get_bundle_default_type(): + if os.environ.has_key('SUGAR_BUNDLE_DEFAULT_TYPE'): + return os.environ['SUGAR_BUNDLE_DEFAULT_TYPE'] + else: + return None + def get_profile_path(): if os.environ.has_key('SUGAR_PROFILE'): profile_id = os.environ['SUGAR_PROFILE'] -- cgit v0.9.1