sugar-toolkit-gtk3/sugar/session/session.py

45 lines
1002 B
Python
Raw Normal View History

2006-05-16 22:32:08 +02:00
import os
import sys
2006-05-18 06:24:32 +02:00
from ConfigParser import ConfigParser
2006-05-16 22:32:08 +02:00
import pygtk
pygtk.require('2.0')
import gtk
from sugar.shell import shell
2006-05-18 06:24:32 +02:00
from sugar import env
2006-05-16 22:32:08 +02:00
def start(console):
2006-05-16 22:32:08 +02:00
shell.main()
2006-05-17 06:23:00 +02:00
2006-05-18 06:24:32 +02:00
activities = []
activities_dirs = []
2006-05-18 06:24:32 +02:00
for data_dir in env.get_data_dirs():
act_dir = os.path.join(data_dir, env.get_activities_dir())
activities_dirs.append(act_dir)
2006-05-22 03:31:57 +02:00
activities_dirs.append(os.path.join(env.get_user_dir(), 'activities'))
for activities_dir in activities_dirs:
2006-05-18 18:17:25 +02:00
if os.path.isdir(activities_dir):
for filename in os.listdir(activities_dir):
if filename.endswith(".activity"):
path = os.path.join(activities_dir, filename)
cp = ConfigParser()
cp.read([path])
python_class = cp.get('Activity', "python_class")
activities.append(python_class)
2006-05-16 22:32:08 +02:00
for activity in activities:
args = [ 'python', '-m', activity ]
if console:
args.append('--console')
os.spawnvp(os.P_NOWAIT, 'python', args)
2006-05-16 22:32:08 +02:00
2006-05-19 20:19:03 +02:00
try:
gtk.main()
except KeyboardInterrupt:
pass