More work on the new home page.

Remove obsolete import.
This commit is contained in:
Marco Pesenti Gritti 2006-07-24 15:11:14 +02:00
parent 1acd82599a
commit d2f76cc41d
9 changed files with 71 additions and 26 deletions

View File

@ -7,7 +7,7 @@ import gtk
from sugar.scene.Stage import Stage from sugar.scene.Stage import Stage
from sugar.scene.Group import Group from sugar.scene.Group import Group
from sugar.scene.View import View from sugar.scene.SceneView import SceneView
from sugar.scene.PixbufActor import PixbufActor from sugar.scene.PixbufActor import PixbufActor
from sugar.scene.CircleLayout import CircleLayout from sugar.scene.CircleLayout import CircleLayout
from sugar.scene.Timeline import Timeline from sugar.scene.Timeline import Timeline
@ -43,10 +43,14 @@ stage.add(icons_group)
window = gtk.Window() window = gtk.Window()
window.set_default_size(640, 480) window.set_default_size(640, 480)
view = View(stage) view = SceneView(stage)
window.add(view) window.add(view)
view.show() view.show()
button = gtk.Button('Hello')
view.put(button, 10, 10)
button.show()
window.show() window.show()
timeline = Timeline(stage, 200) timeline = Timeline(stage, 200)

View File

@ -1,8 +1,12 @@
import gtk import gtk
from sugar.scene.Stage import Stage from sugar.scene.Stage import Stage
from sugar.scene.SceneView import SceneView from sugar.scene.StageView import StageView
from sugar.scene.PixbufActor import PixbufActor
from sugar.scene.CircleLayout import CircleLayout
from sugar.scene.Group import Group
from sugar.activity import Activity from sugar.activity import Activity
from sugar import env
class ActivityLauncher(gtk.HButtonBox): class ActivityLauncher(gtk.HButtonBox):
def __init__(self, shell): def __init__(self, shell):
@ -11,6 +15,10 @@ class ActivityLauncher(gtk.HButtonBox):
self._shell = shell self._shell = shell
for module in shell.get_registry().list_activities(): for module in shell.get_registry().list_activities():
if module.get_show_launcher():
self._add_activity(module)
def _add_activity(self, module):
button = gtk.Button(module.get_name()) button = gtk.Button(module.get_name())
activity_id = module.get_id() activity_id = module.get_id()
button.connect('clicked', self.__clicked_cb, activity_id) button.connect('clicked', self.__clicked_cb, activity_id)
@ -20,27 +28,53 @@ class ActivityLauncher(gtk.HButtonBox):
def __clicked_cb(self, button, activity_id): def __clicked_cb(self, button, activity_id):
Activity.create(activity_id) Activity.create(activity_id)
class HomeScene(SceneView): class HomeScene(StageView):
def __init__(self, shell): def __init__(self, shell):
self._stage = Stage() self._stage = self._create_stage()
StageView.__init__(self, self._stage)
SceneView.__init__(self, self._stage)
self._shell = shell self._shell = shell
launcher = ActivityLauncher(shell)
self.put(launcher, 10, 440)
launcher.show()
def _create_stage(self):
stage = Stage()
background = env.get_data_file('home-background.png')
pixbuf = gtk.gdk.pixbuf_new_from_file(background)
stage.add(PixbufActor(pixbuf))
icons_group = Group()
icons_group.set_position(310, 80)
pholder = env.get_data_file('activity-placeholder.png')
pholder_pixbuf = gtk.gdk.pixbuf_new_from_file(pholder)
i = 0
while i < 7:
icons_group.add(PixbufActor(pholder_pixbuf))
i += 1
layout = CircleLayout(110)
icons_group.set_layout(layout)
stage.add(icons_group)
return stage
class HomeWindow(gtk.Window): class HomeWindow(gtk.Window):
def __init__(self, shell): def __init__(self, shell):
gtk.Window.__init__(self) gtk.Window.__init__(self)
self.connect('realize', self.__realize_cb)
fixed = gtk.Fixed() fixed = gtk.Fixed()
scene = HomeScene(shell) scene = HomeScene(shell)
fixed.put(scene, 0, 0) scene.set_size_request(640, 480)
self.add(scene)
scene.show() scene.show()
launcher = ActivityLauncher(shell) def __realize_cb(self, window):
fixed.put(launcher, 0, 0) self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DESKTOP)
launcher.show()
self.add(fixed)
fixed.show()

View File

@ -8,7 +8,6 @@ import wnck
import gobject import gobject
from sugar.LogWriter import LogWriter from sugar.LogWriter import LogWriter
from ConsoleLogger import ConsoleLogger
from ActivityRegistry import ActivityRegistry from ActivityRegistry import ActivityRegistry
from HomeWindow import HomeWindow from HomeWindow import HomeWindow
from sugar import env from sugar import env
@ -56,7 +55,7 @@ class Shell:
bus_name = dbus.service.BusName('com.redhat.Sugar.Shell', bus=session_bus) bus_name = dbus.service.BusName('com.redhat.Sugar.Shell', bus=session_bus)
ShellDbusService(self, bus_name) ShellDbusService(self, bus_name)
self._owner = ShellOwner() #self._owner = ShellOwner()
self._registry = ActivityRegistry() self._registry = ActivityRegistry()
self._registry.scan_directory(env.get_activities_dir()) self._registry.scan_directory(env.get_activities_dir())

View File

@ -1,4 +1,8 @@
confdir = $(datadir) confdir = $(datadir)
conf_DATA = kbdconfig conf_DATA = kbdconfig
EXTRA_DIST = kbdconfig imagesdir = $(imagesdir)
images_DATA = \
home-background.png
EXTRA_DIST = $(conf_DATA) $(images_DATA)

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

View File

@ -34,5 +34,8 @@ def get_nick_name():
def get_data_dir(): def get_data_dir():
return sugar_data_dir return sugar_data_dir
def get_data_file(filename):
return os.path.join(get_data_dir(), filename)
def get_activities_dir(): def get_activities_dir():
return sugar_activities_dir return sugar_activities_dir

View File

@ -2,9 +2,10 @@ import gtk
from sugar.scene.Stage import Stage from sugar.scene.Stage import Stage
class SceneView(gtk.DrawingArea): class StageView(gtk.Fixed):
def __init__(self, stage): def __init__(self, stage):
gtk.DrawingArea.__init__(self) gtk.Fixed.__init__(self)
self.set_has_window(True)
self._stage = stage self._stage = stage
self._stage.connect('changed', self.__stage_changed_cb) self._stage.connect('changed', self.__stage_changed_cb)

View File

@ -15,7 +15,7 @@ class Transformation:
return (translated_x, translated_y) return (translated_x, translated_y)
def compose(self, transf): def compose(self, transf):
composed = copy.copy(transf) composed = copy.copy(self)
composed._translation_x += transf._translation_x composed._translation_x += transf._translation_x
composed._translation_y += transf._translation_y composed._translation_y += transf._translation_y
return composed return composed