Export the color in the env and initialize the buddy with it
This commit is contained in:
parent
d14628fdfa
commit
6a90ef11d3
@ -3,6 +3,7 @@ import logging
|
|||||||
|
|
||||||
import gobject
|
import gobject
|
||||||
import dbus, dbus.service
|
import dbus, dbus.service
|
||||||
|
from sugar import env
|
||||||
|
|
||||||
|
|
||||||
PRESENCE_SERVICE_TYPE = "_presence_olpc._tcp"
|
PRESENCE_SERVICE_TYPE = "_presence_olpc._tcp"
|
||||||
@ -287,6 +288,7 @@ class Owner(Buddy):
|
|||||||
def __init__(self, ps, bus_name, object_id, nick):
|
def __init__(self, ps, bus_name, object_id, nick):
|
||||||
Buddy.__init__(self, bus_name, object_id, None)
|
Buddy.__init__(self, bus_name, object_id, None)
|
||||||
self._nick_name = nick
|
self._nick_name = nick
|
||||||
|
self._color = env.get_color()
|
||||||
self._ps = ps
|
self._ps = ps
|
||||||
|
|
||||||
def add_service(self, service):
|
def add_service(self, service):
|
||||||
|
@ -11,10 +11,14 @@ import sugar.setup
|
|||||||
|
|
||||||
def setup_user(profile):
|
def setup_user(profile):
|
||||||
os.environ['SUGAR_NICK_NAME'] = profile.get_nick_name()
|
os.environ['SUGAR_NICK_NAME'] = profile.get_nick_name()
|
||||||
|
os.environ['SUGAR_COLOR'] = profile.get_color().to_string()
|
||||||
|
|
||||||
def get_nick_name():
|
def get_nick_name():
|
||||||
return os.environ['SUGAR_NICK_NAME']
|
return os.environ['SUGAR_NICK_NAME']
|
||||||
|
|
||||||
|
def get_color():
|
||||||
|
return os.environ['SUGAR_COLOR']
|
||||||
|
|
||||||
def setup_python_path():
|
def setup_python_path():
|
||||||
for path in sugar_python_path:
|
for path in sugar_python_path:
|
||||||
sys.path.insert(0, path)
|
sys.path.insert(0, path)
|
||||||
|
@ -67,7 +67,8 @@ class Bot:
|
|||||||
self._color = color
|
self._color = color
|
||||||
self._timeline = _Timeline(0.01)
|
self._timeline = _Timeline(0.01)
|
||||||
|
|
||||||
os.environ['SUGAR_NICK_NAME'] = self._nick
|
os.environ['SUGAR_NICK_NAME'] = nick
|
||||||
|
os.environ['SUGAR_COLOR'] = color.to_string()
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
session = TestSession()
|
session = TestSession()
|
||||||
@ -78,17 +79,9 @@ class Bot:
|
|||||||
owner = _ShellOwner(self._nick, self._color)
|
owner = _ShellOwner(self._nick, self._color)
|
||||||
owner.announce()
|
owner.announce()
|
||||||
|
|
||||||
gobject.timeout_add(1000, self._real_start)
|
pservice = PresenceService.get_instance()
|
||||||
|
|
||||||
gtk.main()
|
gtk.main()
|
||||||
|
|
||||||
def add_action(self, action, minutes):
|
def add_action(self, action, minutes):
|
||||||
self._timeline.add(action, minutes)
|
self._timeline.add(action, minutes)
|
||||||
|
|
||||||
def _real_start(self):
|
|
||||||
pservice = PresenceService.get_instance()
|
|
||||||
|
|
||||||
if not pservice.get_owner().get_color():
|
|
||||||
return True
|
|
||||||
|
|
||||||
return False
|
|
||||||
|
Loading…
Reference in New Issue
Block a user