Make conf private, expose the nick name from env

master
Marco Pesenti Gritti 18 years ago
parent 995c74b116
commit 01c4658ee0

@ -46,6 +46,7 @@ bindings/Makefile
bindings/globalkeys/Makefile
bindings/threadframe/Makefile
shell/Makefile
shell/conf/Makefile
shell/data/Makefile
shell/home/Makefile
shell/frame/Makefile
@ -58,7 +59,6 @@ sugar/activity/Makefile
sugar/canvas/Makefile
sugar/chat/Makefile
sugar/chat/sketchpad/Makefile
sugar/conf/Makefile
sugar/p2p/Makefile
sugar/p2p/model/Makefile
sugar/presence/Makefile

@ -1,7 +1,7 @@
import gtk
import dbus
from sugar import conf
import conf
from sugar.activity import Activity
from sugar.presence import PresenceService
from sugar.canvas.IconColor import IconColor

@ -1,4 +1,4 @@
from sugar import conf
import conf
from sugar.chat.BuddyChat import BuddyChat
from sugar.activity import ActivityFactory
from sugar.presence import PresenceService

@ -2,35 +2,35 @@ import gtk
from gettext import gettext as _
from sugar import conf
import conf
class FirstTimeDialog(gtk.Window):
class FirstTimeDialog(gtk.Dialog):
def __init__(self):
gtk.Window.__init__(self)
self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
vbox = gtk.VBox(False, 6)
vbox.set_border_width(12)
gtk.Dialog.__init__(self)
label = gtk.Label(_('Nick Name:'))
label.set_alignment(0.0, 0.5)
vbox.pack_start(label)
self.vbox.pack_start(label)
label.show()
self._entry = gtk.Entry()
vbox.pack_start(self._entry)
self.vbox.pack_start(self._entry)
self._entry.show()
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.show()
self.add(vbox)
vbox.show()
def __ok_button_clicked_cb(self, button):
profile = conf.get_profile()
profile.set_nick_name(self._entry.get_text())
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 conf
from sugar.presence import PresenceService
from sugar.canvas.IconColor import IconColor
from sugar import conf
class Invite:
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 = \
sugar \

@ -2,10 +2,10 @@ import os
import random
import base64
import conf
from sugar import env
from sugar.p2p import Stream
from sugar.presence import PresenceService
from sugar import conf
from Friends import Friends
from Invites import Invites

@ -6,7 +6,6 @@ import random
import logging
from sugar import env
from sugar import util
from sugar import conf
def _get_local_ip_address(ifname):
"""Call Linux specific bits to retrieve our own IP address."""
@ -370,7 +369,7 @@ class PresenceService(object):
self._dbus_helper.ServiceAppeared(service.object_path())
except KeyError:
# 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()
objid = self._get_next_object_id()
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 sugar.activity import ActivityFactory
from sugar.activity import Activity
from FirstTimeDialog import FirstTimeDialog
from frame.Frame import Frame
from globalkeys import KeyGrabber
from sugar import conf
import conf
from sugar import env
import sugar
import sugar.logger
@ -67,32 +66,6 @@ class Shell(gobject.GObject):
self._screen.connect('active-window-changed',
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()
bus_name = dbus.service.BusName('com.redhat.Sugar.Shell', bus=session_bus)
ShellDbusService(self, bus_name)
@ -111,6 +84,18 @@ class Shell(gobject.GObject):
self._frame = Frame(self, self._owner)
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):
self._console = console

@ -3,16 +3,9 @@ import os
from ConfigParser import ConfigParser
from ConfigParser import NoOptionError
from sugar import activity
from sugar import env
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'
import sugar
class ActivityModule:
"""Info about an activity module. Wraps a .activity file."""
@ -46,7 +39,7 @@ class ActivityModule:
def get_default_type(self):
"""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):
"""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 import env
class Profile:
class _Profile:
def __init__(self,):
self._path = env.get_profile_path()
self._nick_name = None

@ -1,8 +1,8 @@
from sugar.conf.ActivityRegistry import _ActivityRegistry
from sugar.conf.Profile import Profile
from conf.ActivityRegistry import _ActivityRegistry
from conf.Profile import _Profile
__registry = _ActivityRegistry()
__profile = Profile()
__profile = _Profile()
def get_activity_registry():
return __registry

@ -1,12 +1,12 @@
import gtk
import goocanvas
import logging
import conf
from sugar.canvas.IconItem import IconItem
from sugar.canvas.IconColor import IconColor
from sugar.presence import PresenceService
from sugar import conf
from frame.Panel import Panel
import logging
class ActivityItem(IconItem):
def __init__(self, activity, size):

@ -2,11 +2,10 @@ import gtk
import goocanvas
import wnck
import conf
from sugar.canvas.IconItem import IconItem
from sugar.canvas.IconColor import IconColor
from home.DonutItem import DonutItem
import sugar.conf
import Theme
class TasksItem(DonutItem):
@ -65,7 +64,7 @@ class HomeGroup(goocanvas.Group):
tasks.translate(600, 450)
self.add_child(tasks)
profile = sugar.conf.get_profile()
profile = conf.get_profile()
me = IconItem(icon_name = 'stock-buddy',
color = profile.get_color(), size = 150)
me.translate(600 - (me.get_property('size') / 2),

@ -2,10 +2,10 @@ import random
import goocanvas
import conf
from sugar.canvas.IconItem import IconItem
from sugar.canvas.IconItem import IconColor
from sugar.presence import PresenceService
from sugar import conf
import Theme

@ -17,7 +17,7 @@ else:
from sugar import env
env.setup()
env.setup_system()
from session.Emulator import Emulator
@ -26,6 +26,17 @@ if os.environ.has_key('SUGAR_EMULATOR') and \
emulator = Emulator()
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
session = Session()

@ -1,4 +1,4 @@
SUBDIRS = activity canvas chat conf p2p presence
SUBDIRS = activity canvas chat p2p presence
sugardir = $(pythondir)/sugar
sugar_PYTHON = \

@ -7,7 +7,7 @@ import gtk
import gobject
from sugar.presence.PresenceService import PresenceService
from sugar.conf import ActivityRegistry
from sugar import activity
import sugar.util
ACTIVITY_SERVICE_NAME = "org.laptop.Activity"
@ -20,7 +20,6 @@ def get_service_name(xid):
def get_object_path(xid):
return ACTIVITY_SERVICE_PATH + "/%s" % xid
class ActivityDbusService(dbus.service.Object):
"""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):
"""Sets the 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):
"""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
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:
sys.path.insert(0, path)
if os.environ.has_key('PYTHONPATH'):

Loading…
Cancel
Save