Make conf private, expose the nick name from env
This commit is contained in:
parent
995c74b116
commit
01c4658ee0
@ -46,6 +46,7 @@ bindings/Makefile
|
|||||||
bindings/globalkeys/Makefile
|
bindings/globalkeys/Makefile
|
||||||
bindings/threadframe/Makefile
|
bindings/threadframe/Makefile
|
||||||
shell/Makefile
|
shell/Makefile
|
||||||
|
shell/conf/Makefile
|
||||||
shell/data/Makefile
|
shell/data/Makefile
|
||||||
shell/home/Makefile
|
shell/home/Makefile
|
||||||
shell/frame/Makefile
|
shell/frame/Makefile
|
||||||
@ -58,7 +59,6 @@ sugar/activity/Makefile
|
|||||||
sugar/canvas/Makefile
|
sugar/canvas/Makefile
|
||||||
sugar/chat/Makefile
|
sugar/chat/Makefile
|
||||||
sugar/chat/sketchpad/Makefile
|
sugar/chat/sketchpad/Makefile
|
||||||
sugar/conf/Makefile
|
|
||||||
sugar/p2p/Makefile
|
sugar/p2p/Makefile
|
||||||
sugar/p2p/model/Makefile
|
sugar/p2p/model/Makefile
|
||||||
sugar/presence/Makefile
|
sugar/presence/Makefile
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import gtk
|
import gtk
|
||||||
import dbus
|
import dbus
|
||||||
|
|
||||||
from sugar import conf
|
import conf
|
||||||
from sugar.activity import Activity
|
from sugar.activity import Activity
|
||||||
from sugar.presence import PresenceService
|
from sugar.presence import PresenceService
|
||||||
from sugar.canvas.IconColor import IconColor
|
from sugar.canvas.IconColor import IconColor
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from sugar import conf
|
import conf
|
||||||
from sugar.chat.BuddyChat import BuddyChat
|
from sugar.chat.BuddyChat import BuddyChat
|
||||||
from sugar.activity import ActivityFactory
|
from sugar.activity import ActivityFactory
|
||||||
from sugar.presence import PresenceService
|
from sugar.presence import PresenceService
|
||||||
|
@ -2,35 +2,35 @@ import gtk
|
|||||||
|
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
|
|
||||||
from sugar import conf
|
import conf
|
||||||
|
|
||||||
class FirstTimeDialog(gtk.Window):
|
class FirstTimeDialog(gtk.Dialog):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
gtk.Window.__init__(self)
|
gtk.Dialog.__init__(self)
|
||||||
|
|
||||||
self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
|
|
||||||
|
|
||||||
vbox = gtk.VBox(False, 6)
|
|
||||||
vbox.set_border_width(12)
|
|
||||||
|
|
||||||
label = gtk.Label(_('Nick Name:'))
|
label = gtk.Label(_('Nick Name:'))
|
||||||
label.set_alignment(0.0, 0.5)
|
label.set_alignment(0.0, 0.5)
|
||||||
vbox.pack_start(label)
|
self.vbox.pack_start(label)
|
||||||
label.show()
|
label.show()
|
||||||
|
|
||||||
self._entry = gtk.Entry()
|
self._entry = gtk.Entry()
|
||||||
vbox.pack_start(self._entry)
|
self.vbox.pack_start(self._entry)
|
||||||
self._entry.show()
|
self._entry.show()
|
||||||
|
|
||||||
button = gtk.Button(None, gtk.STOCK_OK)
|
button = gtk.Button(None, gtk.STOCK_OK)
|
||||||
vbox.pack_start(button)
|
self.vbox.pack_start(button)
|
||||||
button.connect('clicked', self.__ok_button_clicked_cb)
|
button.connect('clicked', self.__ok_button_clicked_cb)
|
||||||
button.show()
|
button.show()
|
||||||
|
|
||||||
self.add(vbox)
|
|
||||||
vbox.show()
|
|
||||||
|
|
||||||
def __ok_button_clicked_cb(self, button):
|
def __ok_button_clicked_cb(self, button):
|
||||||
profile = conf.get_profile()
|
profile = conf.get_profile()
|
||||||
profile.set_nick_name(self._entry.get_text())
|
profile.set_nick_name(self._entry.get_text())
|
||||||
self.destroy()
|
self.destroy()
|
||||||
|
|
||||||
|
def get_profile():
|
||||||
|
profile = conf.get_profile()
|
||||||
|
if profile.get_nick_name() == None:
|
||||||
|
dialog = FirstTimeDialog()
|
||||||
|
dialog.connect('destroy', self.__first_time_dialog_destroy_cb)
|
||||||
|
dialog.show()
|
||||||
|
return profile
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import gobject
|
import gobject
|
||||||
|
|
||||||
|
import conf
|
||||||
from sugar.presence import PresenceService
|
from sugar.presence import PresenceService
|
||||||
from sugar.canvas.IconColor import IconColor
|
from sugar.canvas.IconColor import IconColor
|
||||||
from sugar import conf
|
|
||||||
|
|
||||||
class Invite:
|
class Invite:
|
||||||
def __init__(self, issuer, bundle_id, activity_id):
|
def __init__(self, issuer, bundle_id, activity_id):
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
SUBDIRS = data session frame home PresenceService
|
SUBDIRS = conf data session frame home PresenceService
|
||||||
|
|
||||||
bin_SCRIPTS = \
|
bin_SCRIPTS = \
|
||||||
sugar \
|
sugar \
|
||||||
|
@ -2,10 +2,10 @@ import os
|
|||||||
import random
|
import random
|
||||||
import base64
|
import base64
|
||||||
|
|
||||||
|
import conf
|
||||||
from sugar import env
|
from sugar import env
|
||||||
from sugar.p2p import Stream
|
from sugar.p2p import Stream
|
||||||
from sugar.presence import PresenceService
|
from sugar.presence import PresenceService
|
||||||
from sugar import conf
|
|
||||||
from Friends import Friends
|
from Friends import Friends
|
||||||
from Invites import Invites
|
from Invites import Invites
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ import random
|
|||||||
import logging
|
import logging
|
||||||
from sugar import env
|
from sugar import env
|
||||||
from sugar import util
|
from sugar import util
|
||||||
from sugar import conf
|
|
||||||
|
|
||||||
def _get_local_ip_address(ifname):
|
def _get_local_ip_address(ifname):
|
||||||
"""Call Linux specific bits to retrieve our own IP address."""
|
"""Call Linux specific bits to retrieve our own IP address."""
|
||||||
@ -370,7 +369,7 @@ class PresenceService(object):
|
|||||||
self._dbus_helper.ServiceAppeared(service.object_path())
|
self._dbus_helper.ServiceAppeared(service.object_path())
|
||||||
except KeyError:
|
except KeyError:
|
||||||
# Should this service mark the owner?
|
# Should this service mark the owner?
|
||||||
owner_nick = conf.get_profile().get_nick_name()
|
owner_nick = env.get_nick_name()
|
||||||
source_addr = service.get_source_address()
|
source_addr = service.get_source_address()
|
||||||
objid = self._get_next_object_id()
|
objid = self._get_next_object_id()
|
||||||
if name == owner_nick and source_addr in self._local_addrs.values():
|
if name == owner_nick and source_addr in self._local_addrs.values():
|
||||||
|
@ -14,10 +14,9 @@ from ActivityHost import ActivityHost
|
|||||||
from ChatController import ChatController
|
from ChatController import ChatController
|
||||||
from sugar.activity import ActivityFactory
|
from sugar.activity import ActivityFactory
|
||||||
from sugar.activity import Activity
|
from sugar.activity import Activity
|
||||||
from FirstTimeDialog import FirstTimeDialog
|
|
||||||
from frame.Frame import Frame
|
from frame.Frame import Frame
|
||||||
from globalkeys import KeyGrabber
|
from globalkeys import KeyGrabber
|
||||||
from sugar import conf
|
import conf
|
||||||
from sugar import env
|
from sugar import env
|
||||||
import sugar
|
import sugar
|
||||||
import sugar.logger
|
import sugar.logger
|
||||||
@ -67,32 +66,6 @@ class Shell(gobject.GObject):
|
|||||||
self._screen.connect('active-window-changed',
|
self._screen.connect('active-window-changed',
|
||||||
self.__active_window_changed_cb)
|
self.__active_window_changed_cb)
|
||||||
|
|
||||||
profile = conf.get_profile()
|
|
||||||
if profile.get_nick_name() == None:
|
|
||||||
dialog = FirstTimeDialog()
|
|
||||||
dialog.connect('destroy', self.__first_time_dialog_destroy_cb)
|
|
||||||
dialog.set_transient_for(self._home_window)
|
|
||||||
dialog.show()
|
|
||||||
else:
|
|
||||||
self.start()
|
|
||||||
|
|
||||||
def __global_key_pressed_cb(self, grabber, key):
|
|
||||||
if key == 'F1':
|
|
||||||
self.set_zoom_level(sugar.ZOOM_ACTIVITY)
|
|
||||||
elif key == 'F2':
|
|
||||||
self.set_zoom_level(sugar.ZOOM_HOME)
|
|
||||||
elif key == 'F3':
|
|
||||||
self.set_zoom_level(sugar.ZOOM_FRIENDS)
|
|
||||||
elif key == 'F4':
|
|
||||||
self.set_zoom_level(sugar.ZOOM_MESH)
|
|
||||||
elif key == 'F5':
|
|
||||||
self._frame.toggle_visibility()
|
|
||||||
|
|
||||||
def __first_time_dialog_destroy_cb(self, dialog):
|
|
||||||
conf.get_profile().save()
|
|
||||||
self.start()
|
|
||||||
|
|
||||||
def start(self):
|
|
||||||
session_bus = dbus.SessionBus()
|
session_bus = dbus.SessionBus()
|
||||||
bus_name = dbus.service.BusName('com.redhat.Sugar.Shell', bus=session_bus)
|
bus_name = dbus.service.BusName('com.redhat.Sugar.Shell', bus=session_bus)
|
||||||
ShellDbusService(self, bus_name)
|
ShellDbusService(self, bus_name)
|
||||||
@ -111,6 +84,18 @@ class Shell(gobject.GObject):
|
|||||||
self._frame = Frame(self, self._owner)
|
self._frame = Frame(self, self._owner)
|
||||||
self._frame.show_and_hide(10)
|
self._frame.show_and_hide(10)
|
||||||
|
|
||||||
|
def __global_key_pressed_cb(self, grabber, key):
|
||||||
|
if key == 'F1':
|
||||||
|
self.set_zoom_level(sugar.ZOOM_ACTIVITY)
|
||||||
|
elif key == 'F2':
|
||||||
|
self.set_zoom_level(sugar.ZOOM_HOME)
|
||||||
|
elif key == 'F3':
|
||||||
|
self.set_zoom_level(sugar.ZOOM_FRIENDS)
|
||||||
|
elif key == 'F4':
|
||||||
|
self.set_zoom_level(sugar.ZOOM_MESH)
|
||||||
|
elif key == 'F5':
|
||||||
|
self._frame.toggle_visibility()
|
||||||
|
|
||||||
def set_console(self, console):
|
def set_console(self, console):
|
||||||
self._console = console
|
self._console = console
|
||||||
|
|
||||||
|
@ -3,16 +3,9 @@ import os
|
|||||||
from ConfigParser import ConfigParser
|
from ConfigParser import ConfigParser
|
||||||
from ConfigParser import NoOptionError
|
from ConfigParser import NoOptionError
|
||||||
|
|
||||||
|
from sugar import activity
|
||||||
from sugar import env
|
from sugar import env
|
||||||
|
import sugar
|
||||||
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'
|
|
||||||
|
|
||||||
class ActivityModule:
|
class ActivityModule:
|
||||||
"""Info about an activity module. Wraps a .activity file."""
|
"""Info about an activity module. Wraps a .activity file."""
|
||||||
@ -46,7 +39,7 @@ class ActivityModule:
|
|||||||
|
|
||||||
def get_default_type(self):
|
def get_default_type(self):
|
||||||
"""Get the the type of the default activity service."""
|
"""Get the the type of the default activity service."""
|
||||||
return get_default_type(self._id)
|
return activity.get_default_type(self._id)
|
||||||
|
|
||||||
def set_default_type(self, default_type):
|
def set_default_type(self, default_type):
|
||||||
"""Set the the type of the default activity service."""
|
"""Set the the type of the default activity service."""
|
@ -4,7 +4,7 @@ from ConfigParser import ConfigParser
|
|||||||
from sugar.canvas.IconColor import IconColor
|
from sugar.canvas.IconColor import IconColor
|
||||||
from sugar import env
|
from sugar import env
|
||||||
|
|
||||||
class Profile:
|
class _Profile:
|
||||||
def __init__(self,):
|
def __init__(self,):
|
||||||
self._path = env.get_profile_path()
|
self._path = env.get_profile_path()
|
||||||
self._nick_name = None
|
self._nick_name = None
|
@ -1,8 +1,8 @@
|
|||||||
from sugar.conf.ActivityRegistry import _ActivityRegistry
|
from conf.ActivityRegistry import _ActivityRegistry
|
||||||
from sugar.conf.Profile import Profile
|
from conf.Profile import _Profile
|
||||||
|
|
||||||
__registry = _ActivityRegistry()
|
__registry = _ActivityRegistry()
|
||||||
__profile = Profile()
|
__profile = _Profile()
|
||||||
|
|
||||||
def get_activity_registry():
|
def get_activity_registry():
|
||||||
return __registry
|
return __registry
|
@ -1,12 +1,12 @@
|
|||||||
import gtk
|
import gtk
|
||||||
import goocanvas
|
import goocanvas
|
||||||
|
import logging
|
||||||
|
|
||||||
|
import conf
|
||||||
from sugar.canvas.IconItem import IconItem
|
from sugar.canvas.IconItem import IconItem
|
||||||
from sugar.canvas.IconColor import IconColor
|
from sugar.canvas.IconColor import IconColor
|
||||||
from sugar.presence import PresenceService
|
from sugar.presence import PresenceService
|
||||||
from sugar import conf
|
|
||||||
from frame.Panel import Panel
|
from frame.Panel import Panel
|
||||||
import logging
|
|
||||||
|
|
||||||
class ActivityItem(IconItem):
|
class ActivityItem(IconItem):
|
||||||
def __init__(self, activity, size):
|
def __init__(self, activity, size):
|
||||||
|
@ -2,11 +2,10 @@ import gtk
|
|||||||
import goocanvas
|
import goocanvas
|
||||||
import wnck
|
import wnck
|
||||||
|
|
||||||
|
import conf
|
||||||
from sugar.canvas.IconItem import IconItem
|
from sugar.canvas.IconItem import IconItem
|
||||||
from sugar.canvas.IconColor import IconColor
|
from sugar.canvas.IconColor import IconColor
|
||||||
from home.DonutItem import DonutItem
|
from home.DonutItem import DonutItem
|
||||||
import sugar.conf
|
|
||||||
|
|
||||||
import Theme
|
import Theme
|
||||||
|
|
||||||
class TasksItem(DonutItem):
|
class TasksItem(DonutItem):
|
||||||
@ -65,7 +64,7 @@ class HomeGroup(goocanvas.Group):
|
|||||||
tasks.translate(600, 450)
|
tasks.translate(600, 450)
|
||||||
self.add_child(tasks)
|
self.add_child(tasks)
|
||||||
|
|
||||||
profile = sugar.conf.get_profile()
|
profile = conf.get_profile()
|
||||||
me = IconItem(icon_name = 'stock-buddy',
|
me = IconItem(icon_name = 'stock-buddy',
|
||||||
color = profile.get_color(), size = 150)
|
color = profile.get_color(), size = 150)
|
||||||
me.translate(600 - (me.get_property('size') / 2),
|
me.translate(600 - (me.get_property('size') / 2),
|
||||||
|
@ -2,10 +2,10 @@ import random
|
|||||||
|
|
||||||
import goocanvas
|
import goocanvas
|
||||||
|
|
||||||
|
import conf
|
||||||
from sugar.canvas.IconItem import IconItem
|
from sugar.canvas.IconItem import IconItem
|
||||||
from sugar.canvas.IconItem import IconColor
|
from sugar.canvas.IconItem import IconColor
|
||||||
from sugar.presence import PresenceService
|
from sugar.presence import PresenceService
|
||||||
from sugar import conf
|
|
||||||
|
|
||||||
import Theme
|
import Theme
|
||||||
|
|
||||||
|
13
shell/sugar
13
shell/sugar
@ -17,7 +17,7 @@ else:
|
|||||||
|
|
||||||
from sugar import env
|
from sugar import env
|
||||||
|
|
||||||
env.setup()
|
env.setup_system()
|
||||||
|
|
||||||
from session.Emulator import Emulator
|
from session.Emulator import Emulator
|
||||||
|
|
||||||
@ -26,6 +26,17 @@ if os.environ.has_key('SUGAR_EMULATOR') and \
|
|||||||
emulator = Emulator()
|
emulator = Emulator()
|
||||||
emulator.start()
|
emulator.start()
|
||||||
|
|
||||||
|
from FirstTimeDialog import FirstTimeDialog
|
||||||
|
import conf
|
||||||
|
|
||||||
|
profile = conf.get_profile()
|
||||||
|
if profile.get_nick_name() == None:
|
||||||
|
dialog = FirstTimeDialog()
|
||||||
|
dialog.run()
|
||||||
|
profile.save()
|
||||||
|
|
||||||
|
env.setup_user(profile)
|
||||||
|
|
||||||
from session.Session import Session
|
from session.Session import Session
|
||||||
|
|
||||||
session = Session()
|
session = Session()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
SUBDIRS = activity canvas chat conf p2p presence
|
SUBDIRS = activity canvas chat p2p presence
|
||||||
|
|
||||||
sugardir = $(pythondir)/sugar
|
sugardir = $(pythondir)/sugar
|
||||||
sugar_PYTHON = \
|
sugar_PYTHON = \
|
||||||
|
@ -7,7 +7,7 @@ import gtk
|
|||||||
import gobject
|
import gobject
|
||||||
|
|
||||||
from sugar.presence.PresenceService import PresenceService
|
from sugar.presence.PresenceService import PresenceService
|
||||||
from sugar.conf import ActivityRegistry
|
from sugar import activity
|
||||||
import sugar.util
|
import sugar.util
|
||||||
|
|
||||||
ACTIVITY_SERVICE_NAME = "org.laptop.Activity"
|
ACTIVITY_SERVICE_NAME = "org.laptop.Activity"
|
||||||
@ -20,7 +20,6 @@ def get_service_name(xid):
|
|||||||
def get_object_path(xid):
|
def get_object_path(xid):
|
||||||
return ACTIVITY_SERVICE_PATH + "/%s" % xid
|
return ACTIVITY_SERVICE_PATH + "/%s" % xid
|
||||||
|
|
||||||
|
|
||||||
class ActivityDbusService(dbus.service.Object):
|
class ActivityDbusService(dbus.service.Object):
|
||||||
"""Base dbus service object that each Activity uses to export dbus methods.
|
"""Base dbus service object that each Activity uses to export dbus methods.
|
||||||
|
|
||||||
@ -91,7 +90,7 @@ class Activity(gtk.Window):
|
|||||||
def set_type(self, activity_type):
|
def set_type(self, activity_type):
|
||||||
"""Sets the activity type."""
|
"""Sets the activity type."""
|
||||||
self._activity_type = activity_type
|
self._activity_type = activity_type
|
||||||
self._default_type = ActivityRegistry.get_default_type(activity_type)
|
self._default_type = activity.get_default_type(activity_type)
|
||||||
|
|
||||||
def get_type(self):
|
def get_type(self):
|
||||||
"""Gets the activity type."""
|
"""Gets the activity type."""
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
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'
|
@ -9,7 +9,13 @@ except ImportError:
|
|||||||
|
|
||||||
import sugar.setup
|
import sugar.setup
|
||||||
|
|
||||||
def setup():
|
def setup_user(profile):
|
||||||
|
os.environ['SUGAR_NICK_NAME'] = profile.get_nick_name()
|
||||||
|
|
||||||
|
def get_nick_name():
|
||||||
|
return os.environ['SUGAR_NICK_NAME']
|
||||||
|
|
||||||
|
def setup_system():
|
||||||
for path in sugar_python_path:
|
for path in sugar_python_path:
|
||||||
sys.path.insert(0, path)
|
sys.path.insert(0, path)
|
||||||
if os.environ.has_key('PYTHONPATH'):
|
if os.environ.has_key('PYTHONPATH'):
|
||||||
|
Loading…
Reference in New Issue
Block a user