Add a sample activity. Too bad gmail crashes the
This commit is contained in:
parent
e31583daad
commit
3f624fdcf7
2
examples/README
Normal file
2
examples/README
Normal file
@ -0,0 +1,2 @@
|
||||
Just drop gmail.py and gmail.activity inside ~/.sugar/activities
|
||||
Then run sugar as usual.
|
2
examples/gmail.activity
Normal file
2
examples/gmail.activity
Normal file
@ -0,0 +1,2 @@
|
||||
[Activity]
|
||||
python_class = gmail
|
33
examples/gmail.py
Executable file
33
examples/gmail.py
Executable file
@ -0,0 +1,33 @@
|
||||
import pygtk
|
||||
pygtk.require('2.0')
|
||||
import gtk
|
||||
import geckoembed
|
||||
|
||||
from sugar.shell import activity
|
||||
|
||||
class GMailActivity(activity.Activity):
|
||||
def __init__(self):
|
||||
activity.Activity.__init__(self)
|
||||
|
||||
def activity_on_connected_to_shell(self):
|
||||
self.activity_set_tab_text("Mail")
|
||||
self.activity_set_tab_icon_name("stock_mail")
|
||||
self.activity_show_icon(True)
|
||||
|
||||
plug = self.activity_get_gtk_plug()
|
||||
|
||||
embed = geckoembed.Embed()
|
||||
plug.add(embed)
|
||||
embed.show()
|
||||
|
||||
plug.show()
|
||||
|
||||
embed.load_address("http://www.gmail.com")
|
||||
|
||||
def activity_on_disconnected_from_shell(self):
|
||||
gtk.main_quit()
|
||||
|
||||
activity = GMailActivity()
|
||||
activity.activity_connect_to_shell()
|
||||
|
||||
gtk.main()
|
@ -14,8 +14,15 @@ def start(console):
|
||||
|
||||
activities = []
|
||||
|
||||
activities_dirs = []
|
||||
|
||||
for data_dir in env.get_data_dirs():
|
||||
activities_dir = os.path.join(data_dir, env.get_activities_dir())
|
||||
act_dir = os.path.join(data_dir, env.get_activities_dir())
|
||||
activities_dirs.append(act_dir)
|
||||
|
||||
activities_dirs.append(os.path.expanduser('~/.sugar/activities'))
|
||||
|
||||
for activities_dir in activities_dirs:
|
||||
for filename in os.listdir(activities_dir):
|
||||
if filename.endswith(".activity"):
|
||||
path = os.path.join(activities_dir, filename)
|
||||
|
@ -18,10 +18,12 @@ if os.path.isfile(os.path.join(curdir, '__uninstalled__.py')):
|
||||
else:
|
||||
print 'Running sugar from ' + basedir + ' ...'
|
||||
sys.path.insert(0, basedir)
|
||||
os.environ['PYTHONPATH'] = basedir
|
||||
os.environ['PYTHONPATH'] += ':' + basedir
|
||||
console = True
|
||||
else:
|
||||
print 'Running the installed sugar...'
|
||||
|
||||
os.environ['PYTHONPATH'] += ':' + os.path.expanduser('~/.sugar/activities')
|
||||
|
||||
if console:
|
||||
print 'Redirecting output to the console, press ctrl+d to open it.'
|
||||
@ -29,4 +31,3 @@ if console:
|
||||
from sugar.session import session
|
||||
|
||||
session.start(console)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user