Merge branch 'master' of git+ssh://dcbw@crank.laptop.org/git/sugar

This commit is contained in:
Dan Williams
2006-06-19 23:18:57 -04:00
5 changed files with 106 additions and 69 deletions
+23 -13
View File
@@ -54,7 +54,7 @@ class WindowManager:
def set_position(self, position):
self._position = position
def _update_size_and_position(self):
def _calc_size_and_position(self):
screen_width = self._window.get_screen().get_width()
screen_height = self._window.get_screen().get_height()
@@ -69,20 +69,30 @@ class WindowManager:
height = int(screen_height * self._height)
if self._position is WindowManager.CENTER:
x = int((screen_width - width) / 2)
y = int((screen_height - height) / 2)
self._x = int((screen_width - width) / 2)
self._y = int((screen_height - height) / 2)
elif self._position is WindowManager.LEFT:
x = - int((1.0 - self._sliding_pos) * width)
y = int((screen_height - height) / 2)
self._x = - int((1.0 - self._sliding_pos) * width)
self._y = int((screen_height - height) / 2)
elif self._position is WindowManager.TOP:
x = int((screen_width - width) / 2)
y = - int((1.0 - self._sliding_pos) * height)
self._window.move(x, y)
self._window.resize(width, height)
self._x = int((screen_width - width) / 2)
self._y = - int((1.0 - self._sliding_pos) * height)
self._real_width = width
self._real_height = height
def _update_size_and_position(self):
self._calc_size_and_position()
self._window.move(self._x, self._y)
self._window.resize(self._real_width, self._real_height)
def _update_position(self):
self._calc_size_and_position()
self._window.move(self._x, self._y)
def __slide_in_timeout_cb(self):
self._window.show()
if self._sliding_pos == 0:
self._window.show()
left = 1.0 - self._sliding_pos
self._sliding_pos += (left / 2)
@@ -90,7 +100,7 @@ class WindowManager:
if self._sliding_pos > .999:
self._sliding_pos = 1.0
self._update_size_and_position()
self._update_position()
if self._sliding_pos == 1.0:
return False
@@ -106,7 +116,7 @@ class WindowManager:
if self._sliding_pos < .001:
self._sliding_pos = 0
self._update_size_and_position()
self._update_position()
if self._sliding_pos == 0:
self._window.hide()
+31 -18
View File
@@ -472,31 +472,44 @@ class ConsoleLogger(dbus.service.Object):
buf = console.get_buffer()
buf.insert(buf.get_end_iter(), message)
def main():
console = ConsoleLogger()
class Shell(gobject.GObject):
__gsignals__ = {
'close': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
([])),
}
log_writer = LogWriter("Shell", False)
log_writer.start()
def __init__(self):
gobject.GObject.__init__(self)
session_bus = dbus.SessionBus()
service = dbus.service.BusName("com.redhat.Sugar.Shell", bus=session_bus)
def start(self):
console = ConsoleLogger()
activity_container = ActivityContainer(service, session_bus)
activity_container.show()
log_writer = LogWriter("Shell", False)
log_writer.start()
wm = WindowManager(activity_container.window)
wm.set_width(640, WindowManager.ABSOLUTE)
wm.set_height(480, WindowManager.ABSOLUTE)
wm.set_position(WindowManager.CENTER)
wm.show()
wm.manage()
console.set_parent_window(activity_container.window)
session_bus = dbus.SessionBus()
service = dbus.service.BusName("com.redhat.Sugar.Shell", bus=session_bus)
activity_container = ActivityContainer(service, session_bus)
activity_container.window.connect('destroy', self.__activity_container_destroy_cb)
activity_container.show()
wm = WindowManager(activity_container.window)
wm.set_width(640, WindowManager.ABSOLUTE)
wm.set_height(480, WindowManager.ABSOLUTE)
wm.set_position(WindowManager.CENTER)
wm.show()
wm.manage()
console.set_parent_window(activity_container.window)
def __activity_container_destroy_cb(self, activity_container):
self.emit('close')
if __name__ == "__main__":
main()
shell = Shell()
shell.start()
try:
gtk.main()
except KeyboardInterrupt:
print 'Ctrl+c pressed, exiting...'
pass