More work on packages refactoring, mostly working

This commit is contained in:
Marco Pesenti Gritti 2006-06-21 16:05:52 -04:00
parent f4e2791c89
commit 9ea6805174
22 changed files with 77 additions and 92 deletions

View File

@ -1 +1 @@
SUBDIRS = sugar cut-n-paste
SUBDIRS = activities shell sugar

View File

@ -6,7 +6,7 @@ pygtk.require('2.0')
import gtk
import geckoembed
from sugar.activity import activity
from sugar.activity.Activity import Activity
from sugar.presence.PresenceService import PresenceService
from sugar.p2p.model.LocalModel import LocalModel
from sugar.p2p.model.RemoteModel import RemoteModel
@ -18,13 +18,13 @@ _BROWSER_ACTIVITY_TYPE = "_web_olpc._udp"
_SERVICE_URI_TAG = "URI"
_SERVICE_TITLE_TAG = "Title"
class BrowserActivity(activity.Activity):
class BrowserActivity(Activity):
SOLO = 1
FOLLOWING = 2
LEADING = 3
def __init__(self, uri, mode = SOLO):
activity.Activity.__init__(self, _BROWSER_ACTIVITY_TYPE)
Activity.__init__(self, _BROWSER_ACTIVITY_TYPE)
self.uri = uri
self._mode = mode

View File

@ -1,4 +1,4 @@
sugardir = $(pythondir)/sugar/browser
sugardir = $(pkgdatadir)/activities/browser
sugar_PYTHON = \
__init__.py \
browser.py \
@ -8,18 +8,7 @@ sugar_PYTHON = \
BrowserActivity.py \
NavigationToolbar.py
icondir = $(pkgdatadir)
icon_DATA = \
fold.png \
unfold.png
rcdir = $(pkgdatadir)
rc_DATA = browser.rc
activitydir = $(pkgdatadir)/activities
activitydir = $(pkgdatadir)/activities/browser
activity_DATA = browser.activity
EXTRA_DIST = \
$(rc_DATA) \
$(activity_DATA) \
$(icon_DATA)
EXTRA_DIST = $(activity_DATA)

View File

@ -6,15 +6,13 @@ import gtk
import dbus
import sugar.env
from sugar.session.LogWriter import LogWriter
from sugar.LogWriter import LogWriter
from BrowserShell import BrowserShell
log_writer = LogWriter("Web")
log_writer.start()
gtk.rc_parse(sugar.env.get_data_file('browser.rc'))
session_bus = dbus.SessionBus()
bus_name = dbus.service.BusName('com.redhat.Sugar.Browser', bus=session_bus)
shell = BrowserShell(bus_name)

View File

@ -1,7 +0,0 @@
style "NotificationBarButton" = "button"
{
xthickness = 0
ythickness = 0
}
widget "*.notif bar.*GtkButton*" style "NotificationBarButton"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 156 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 157 B

View File

@ -17,12 +17,14 @@ AC_SUBST(PYGTK_LIBS)
AC_OUTPUT([
Makefile
activities/Makefile
activities/browser/Makefile
cut-n-paste/Makefile
shell/Makefile
shell/google/Makefile
shell/session/Makefile
sugar/Makefile
sugar/__installed__.py
sugar/activity/Makefile
sugar/chat/Makefile
sugar/chat/sketchpad/Makefile
sugar/p2p/Makefile

View File

@ -1,8 +1,12 @@
sugardir = $(pythondir)/sugar/shell
SUBDIRS = google session
bin_SCRIPTS = sugar
sugardir = $(pkgdatadir)/shell
sugar_PYTHON = \
__init__.py \
activity.py \
shell.py \
Owner.py \
PresenceWindow.py \
StartPage.py
StartPage.py \
WindowManager.py

View File

@ -1,5 +1,6 @@
cut_n_pastedir = $(datadir)/sugar
cut_n_paste_PYTHON = \
googledir = $(pkgdatadir)/shell/google
google_PYTHON = \
__init__.py \
google.py \
GoogleSOAPFacade.py \
SOAP.py

View File

@ -1,5 +1,4 @@
sugardir = $(pythondir)/sugar/session
sugardir = $(pkgdatadir)/shell/session
sugar_PYTHON = \
__init__.py \
session.py \
LogWriter.py
session.py

View File

@ -18,20 +18,28 @@ class Session:
shell.connect('close', self._shell_close_cb)
shell.start()
self._run_activities()
def _run_activities(self):
base_dirs = []
base_dirs.append(env.get_activities_dir())
base_dirs.append(os.path.join(env.get_user_dir(), 'activities'))
for base_dir in base_dirs:
if os.path.isdir(base_dir):
for filename in os.listdir(base_dir):
activity_dir = os.path.join(base_dir, filename)
if os.path.isdir(activity_dir):
self._run_activity(os.path.abspath(activity_dir))
def _run_activity(self, activity_dir):
env.add_to_python_path(activity_dir)
activities = []
activities_dirs = []
for data_dir in env.get_data_dirs():
act_dir = os.path.join(data_dir, env.get_activities_dir())
activities_dirs.append(act_dir)
activities_dirs.append(os.path.join(env.get_user_dir(), 'activities'))
for activities_dir in activities_dirs:
if os.path.isdir(activities_dir):
for filename in os.listdir(activities_dir):
for filename in os.listdir(activity_dir):
if filename.endswith(".activity"):
path = os.path.join(activities_dir, filename)
path = os.path.join(activity_dir, filename)
cp = ConfigParser()
cp.read([path])
python_class = cp.get('Activity', "python_class")

View File

@ -11,7 +11,7 @@ import gobject
import sugar.util
from sugar.chat.ChatWindow import ChatWindow
from sugar.chat.GroupChat import GroupChat
from sugar.session.LogWriter import LogWriter
from sugar.LogWriter import LogWriter
from Owner import ShellOwner
from StartPage import StartPage

View File

@ -9,13 +9,6 @@ import pygtk
pygtk.require('2.0')
import gobject
def add_to_python_path(path):
sys.path.insert(0, path)
if os.environ.has_key('PYTHONPATH'):
os.environ['PYTHONPATH'] += ':' + path
else:
os.environ['PYTHONPATH'] = path
def start_dbus():
curdir = os.path.dirname(__file__)
args = "/bin/dbus-daemon --session --print-address".split()
@ -60,16 +53,16 @@ if not os.environ.has_key("SUGAR_NICK_NAME"):
curdir = os.path.abspath(os.path.dirname(__file__))
basedir = os.path.dirname(curdir)
import sugar.env
if os.path.isfile(os.path.join(basedir, 'sugar/__uninstalled__.py')):
print 'Running sugar from ' + basedir + ' ...'
add_to_python_path(basedir)
add_to_python_path(os.path.join(basedir, 'shell'))
add_to_python_path(os.path.join(basedir, 'activities/browser'))
sugar.env.add_to_python_path(basedir)
sugar.env.add_to_python_path(os.path.join(basedir, 'shell'))
else:
sugar.env.add_to_python_path(os.path.join(sugar.env.get_data_dir(), 'shell'))
print 'Running the installed sugar...'
add_to_python_path(os.path.expanduser('~/.sugar/activities'))
print 'Redirecting output to the console, press ctrl+d to open it.'
from session.session import Session

View File

@ -1,12 +1,12 @@
SUBDIRS = chat browser p2p shell session presence
bin_SCRIPTS = sugar
SUBDIRS = activity chat p2p presence
sugardir = $(pythondir)/sugar
sugar_PYTHON = \
__init__.py \
__installed__.py \
bots.py \
env.py \
util.py
util.py \
LogWriter.py
EXTRA_DIST = sugar __uninstalled__.py

View File

@ -1,3 +1,2 @@
data_basedir = '@prefix@/share/'
data_dirs = [ 'sugar' ]
activities_dir = 'activities'
sugar_data_dir = '@prefix@/share/sugar'
sugar_activities_dir = '@prefix@/share/sugar/activities'

View File

@ -1,5 +1,4 @@
import os
data_basedir = os.path.dirname(os.path.dirname(__file__))
data_dirs = [ 'activities/browser' ]
activities_dir = ''
sugar_data_dir = os.path.dirname(os.path.dirname(__file__))
sugar_activities_dir = os.path.join(sugar_data_dir, 'activities')

View File

@ -4,6 +4,9 @@ sugardir = $(pythondir)/sugar/chat
sugar_PYTHON = \
__init__.py \
Chat.py \
ChatEditor.py \
ChatToolbar.py \
ChatWindow.py \
Emoticons.py \
GroupChat.py \
richtext.py

View File

@ -1,10 +1,18 @@
import os
import sys
try:
from sugar.__uninstalled__ import *
except ImportError:
from sugar.__installed__ import *
def add_to_python_path(path):
sys.path.insert(0, path)
if os.environ.has_key('PYTHONPATH'):
os.environ['PYTHONPATH'] += ':' + path
else:
os.environ['PYTHONPATH'] = path
def get_user_dir():
if os.environ.has_key('SUGAR_USER_DIR'):
return os.environ['SUGAR_USER_DIR']
@ -23,19 +31,8 @@ def get_nick_name():
else:
return None
def get_data_file(filename):
for data_dir in get_data_dirs():
path = os.path.join(data_dir, filename)
if os.path.isfile(path):
return path
return None
def get_data_dirs():
dirs = []
for data_dir in data_dirs:
path = os.path.join(data_basedir, data_dir)
dirs.append(path)
return dirs
def get_data_dir():
return sugar_data_dir
def get_activities_dir():
return activities_dir
return sugar_activities_dir