More work on packages refactoring, mostly working
This commit is contained in:
parent
f4e2791c89
commit
9ea6805174
@ -1 +1 @@
|
|||||||
SUBDIRS = sugar cut-n-paste
|
SUBDIRS = activities shell sugar
|
||||||
|
@ -6,7 +6,7 @@ pygtk.require('2.0')
|
|||||||
import gtk
|
import gtk
|
||||||
import geckoembed
|
import geckoembed
|
||||||
|
|
||||||
from sugar.activity import activity
|
from sugar.activity.Activity import Activity
|
||||||
from sugar.presence.PresenceService import PresenceService
|
from sugar.presence.PresenceService import PresenceService
|
||||||
from sugar.p2p.model.LocalModel import LocalModel
|
from sugar.p2p.model.LocalModel import LocalModel
|
||||||
from sugar.p2p.model.RemoteModel import RemoteModel
|
from sugar.p2p.model.RemoteModel import RemoteModel
|
||||||
@ -18,13 +18,13 @@ _BROWSER_ACTIVITY_TYPE = "_web_olpc._udp"
|
|||||||
_SERVICE_URI_TAG = "URI"
|
_SERVICE_URI_TAG = "URI"
|
||||||
_SERVICE_TITLE_TAG = "Title"
|
_SERVICE_TITLE_TAG = "Title"
|
||||||
|
|
||||||
class BrowserActivity(activity.Activity):
|
class BrowserActivity(Activity):
|
||||||
SOLO = 1
|
SOLO = 1
|
||||||
FOLLOWING = 2
|
FOLLOWING = 2
|
||||||
LEADING = 3
|
LEADING = 3
|
||||||
|
|
||||||
def __init__(self, uri, mode = SOLO):
|
def __init__(self, uri, mode = SOLO):
|
||||||
activity.Activity.__init__(self, _BROWSER_ACTIVITY_TYPE)
|
Activity.__init__(self, _BROWSER_ACTIVITY_TYPE)
|
||||||
self.uri = uri
|
self.uri = uri
|
||||||
self._mode = mode
|
self._mode = mode
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
sugardir = $(pythondir)/sugar/browser
|
sugardir = $(pkgdatadir)/activities/browser
|
||||||
sugar_PYTHON = \
|
sugar_PYTHON = \
|
||||||
__init__.py \
|
__init__.py \
|
||||||
browser.py \
|
browser.py \
|
||||||
@ -8,18 +8,7 @@ sugar_PYTHON = \
|
|||||||
BrowserActivity.py \
|
BrowserActivity.py \
|
||||||
NavigationToolbar.py
|
NavigationToolbar.py
|
||||||
|
|
||||||
icondir = $(pkgdatadir)
|
activitydir = $(pkgdatadir)/activities/browser
|
||||||
icon_DATA = \
|
|
||||||
fold.png \
|
|
||||||
unfold.png
|
|
||||||
|
|
||||||
rcdir = $(pkgdatadir)
|
|
||||||
rc_DATA = browser.rc
|
|
||||||
|
|
||||||
activitydir = $(pkgdatadir)/activities
|
|
||||||
activity_DATA = browser.activity
|
activity_DATA = browser.activity
|
||||||
|
|
||||||
EXTRA_DIST = \
|
EXTRA_DIST = $(activity_DATA)
|
||||||
$(rc_DATA) \
|
|
||||||
$(activity_DATA) \
|
|
||||||
$(icon_DATA)
|
|
||||||
|
@ -6,15 +6,13 @@ import gtk
|
|||||||
import dbus
|
import dbus
|
||||||
|
|
||||||
import sugar.env
|
import sugar.env
|
||||||
from sugar.session.LogWriter import LogWriter
|
from sugar.LogWriter import LogWriter
|
||||||
|
|
||||||
from BrowserShell import BrowserShell
|
from BrowserShell import BrowserShell
|
||||||
|
|
||||||
log_writer = LogWriter("Web")
|
log_writer = LogWriter("Web")
|
||||||
log_writer.start()
|
log_writer.start()
|
||||||
|
|
||||||
gtk.rc_parse(sugar.env.get_data_file('browser.rc'))
|
|
||||||
|
|
||||||
session_bus = dbus.SessionBus()
|
session_bus = dbus.SessionBus()
|
||||||
bus_name = dbus.service.BusName('com.redhat.Sugar.Browser', bus=session_bus)
|
bus_name = dbus.service.BusName('com.redhat.Sugar.Browser', bus=session_bus)
|
||||||
shell = BrowserShell(bus_name)
|
shell = BrowserShell(bus_name)
|
||||||
|
@ -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 |
@ -17,12 +17,14 @@ AC_SUBST(PYGTK_LIBS)
|
|||||||
|
|
||||||
AC_OUTPUT([
|
AC_OUTPUT([
|
||||||
Makefile
|
Makefile
|
||||||
|
activities/Makefile
|
||||||
activities/browser/Makefile
|
activities/browser/Makefile
|
||||||
cut-n-paste/Makefile
|
|
||||||
shell/Makefile
|
shell/Makefile
|
||||||
|
shell/google/Makefile
|
||||||
shell/session/Makefile
|
shell/session/Makefile
|
||||||
sugar/Makefile
|
sugar/Makefile
|
||||||
sugar/__installed__.py
|
sugar/__installed__.py
|
||||||
|
sugar/activity/Makefile
|
||||||
sugar/chat/Makefile
|
sugar/chat/Makefile
|
||||||
sugar/chat/sketchpad/Makefile
|
sugar/chat/sketchpad/Makefile
|
||||||
sugar/p2p/Makefile
|
sugar/p2p/Makefile
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
sugardir = $(pythondir)/sugar/shell
|
SUBDIRS = google session
|
||||||
|
|
||||||
|
bin_SCRIPTS = sugar
|
||||||
|
|
||||||
|
sugardir = $(pkgdatadir)/shell
|
||||||
sugar_PYTHON = \
|
sugar_PYTHON = \
|
||||||
__init__.py \
|
__init__.py \
|
||||||
activity.py \
|
|
||||||
shell.py \
|
shell.py \
|
||||||
Owner.py \
|
Owner.py \
|
||||||
PresenceWindow.py \
|
PresenceWindow.py \
|
||||||
StartPage.py
|
StartPage.py \
|
||||||
|
WindowManager.py
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
cut_n_pastedir = $(datadir)/sugar
|
googledir = $(pkgdatadir)/shell/google
|
||||||
cut_n_paste_PYTHON = \
|
google_PYTHON = \
|
||||||
|
__init__.py \
|
||||||
google.py \
|
google.py \
|
||||||
GoogleSOAPFacade.py \
|
GoogleSOAPFacade.py \
|
||||||
SOAP.py
|
SOAP.py
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
sugardir = $(pythondir)/sugar/session
|
sugardir = $(pkgdatadir)/shell/session
|
||||||
sugar_PYTHON = \
|
sugar_PYTHON = \
|
||||||
__init__.py \
|
__init__.py \
|
||||||
session.py \
|
session.py
|
||||||
LogWriter.py
|
|
||||||
|
@ -18,20 +18,28 @@ class Session:
|
|||||||
shell.connect('close', self._shell_close_cb)
|
shell.connect('close', self._shell_close_cb)
|
||||||
shell.start()
|
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 = []
|
||||||
activities_dirs = []
|
for filename in os.listdir(activity_dir):
|
||||||
|
|
||||||
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):
|
|
||||||
if filename.endswith(".activity"):
|
if filename.endswith(".activity"):
|
||||||
path = os.path.join(activities_dir, filename)
|
path = os.path.join(activity_dir, filename)
|
||||||
cp = ConfigParser()
|
cp = ConfigParser()
|
||||||
cp.read([path])
|
cp.read([path])
|
||||||
python_class = cp.get('Activity', "python_class")
|
python_class = cp.get('Activity', "python_class")
|
||||||
|
@ -11,7 +11,7 @@ import gobject
|
|||||||
import sugar.util
|
import sugar.util
|
||||||
from sugar.chat.ChatWindow import ChatWindow
|
from sugar.chat.ChatWindow import ChatWindow
|
||||||
from sugar.chat.GroupChat import GroupChat
|
from sugar.chat.GroupChat import GroupChat
|
||||||
from sugar.session.LogWriter import LogWriter
|
from sugar.LogWriter import LogWriter
|
||||||
|
|
||||||
from Owner import ShellOwner
|
from Owner import ShellOwner
|
||||||
from StartPage import StartPage
|
from StartPage import StartPage
|
||||||
|
17
shell/sugar
17
shell/sugar
@ -9,13 +9,6 @@ import pygtk
|
|||||||
pygtk.require('2.0')
|
pygtk.require('2.0')
|
||||||
import gobject
|
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():
|
def start_dbus():
|
||||||
curdir = os.path.dirname(__file__)
|
curdir = os.path.dirname(__file__)
|
||||||
args = "/bin/dbus-daemon --session --print-address".split()
|
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__))
|
curdir = os.path.abspath(os.path.dirname(__file__))
|
||||||
basedir = os.path.dirname(curdir)
|
basedir = os.path.dirname(curdir)
|
||||||
|
|
||||||
|
import sugar.env
|
||||||
|
|
||||||
if os.path.isfile(os.path.join(basedir, 'sugar/__uninstalled__.py')):
|
if os.path.isfile(os.path.join(basedir, 'sugar/__uninstalled__.py')):
|
||||||
print 'Running sugar from ' + basedir + ' ...'
|
print 'Running sugar from ' + basedir + ' ...'
|
||||||
add_to_python_path(basedir)
|
sugar.env.add_to_python_path(basedir)
|
||||||
add_to_python_path(os.path.join(basedir, 'shell'))
|
sugar.env.add_to_python_path(os.path.join(basedir, 'shell'))
|
||||||
add_to_python_path(os.path.join(basedir, 'activities/browser'))
|
|
||||||
else:
|
else:
|
||||||
|
sugar.env.add_to_python_path(os.path.join(sugar.env.get_data_dir(), 'shell'))
|
||||||
print 'Running the installed sugar...'
|
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.'
|
print 'Redirecting output to the console, press ctrl+d to open it.'
|
||||||
|
|
||||||
from session.session import Session
|
from session.session import Session
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
SUBDIRS = chat browser p2p shell session presence
|
SUBDIRS = activity chat p2p presence
|
||||||
|
|
||||||
bin_SCRIPTS = sugar
|
|
||||||
|
|
||||||
sugardir = $(pythondir)/sugar
|
sugardir = $(pythondir)/sugar
|
||||||
sugar_PYTHON = \
|
sugar_PYTHON = \
|
||||||
__init__.py \
|
__init__.py \
|
||||||
__installed__.py \
|
__installed__.py \
|
||||||
|
bots.py \
|
||||||
env.py \
|
env.py \
|
||||||
util.py
|
util.py \
|
||||||
|
LogWriter.py
|
||||||
|
|
||||||
EXTRA_DIST = sugar __uninstalled__.py
|
EXTRA_DIST = sugar __uninstalled__.py
|
||||||
|
@ -1,3 +1,2 @@
|
|||||||
data_basedir = '@prefix@/share/'
|
sugar_data_dir = '@prefix@/share/sugar'
|
||||||
data_dirs = [ 'sugar' ]
|
sugar_activities_dir = '@prefix@/share/sugar/activities'
|
||||||
activities_dir = 'activities'
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
data_basedir = os.path.dirname(os.path.dirname(__file__))
|
sugar_data_dir = os.path.dirname(os.path.dirname(__file__))
|
||||||
data_dirs = [ 'activities/browser' ]
|
sugar_activities_dir = os.path.join(sugar_data_dir, 'activities')
|
||||||
activities_dir = ''
|
|
||||||
|
@ -4,6 +4,9 @@ sugardir = $(pythondir)/sugar/chat
|
|||||||
sugar_PYTHON = \
|
sugar_PYTHON = \
|
||||||
__init__.py \
|
__init__.py \
|
||||||
Chat.py \
|
Chat.py \
|
||||||
|
ChatEditor.py \
|
||||||
|
ChatToolbar.py \
|
||||||
|
ChatWindow.py \
|
||||||
Emoticons.py \
|
Emoticons.py \
|
||||||
GroupChat.py \
|
GroupChat.py \
|
||||||
richtext.py
|
richtext.py
|
||||||
|
25
sugar/env.py
25
sugar/env.py
@ -1,10 +1,18 @@
|
|||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from sugar.__uninstalled__ import *
|
from sugar.__uninstalled__ import *
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from sugar.__installed__ import *
|
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():
|
def get_user_dir():
|
||||||
if os.environ.has_key('SUGAR_USER_DIR'):
|
if os.environ.has_key('SUGAR_USER_DIR'):
|
||||||
return os.environ['SUGAR_USER_DIR']
|
return os.environ['SUGAR_USER_DIR']
|
||||||
@ -23,19 +31,8 @@ def get_nick_name():
|
|||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_data_file(filename):
|
def get_data_dir():
|
||||||
for data_dir in get_data_dirs():
|
return sugar_data_dir
|
||||||
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_activities_dir():
|
def get_activities_dir():
|
||||||
return activities_dir
|
return sugar_activities_dir
|
||||||
|
Loading…
Reference in New Issue
Block a user