Make the Shell own the console. Some view changes.

This commit is contained in:
Marco Pesenti Gritti 2007-09-30 14:24:03 +02:00
parent c8b5ab290e
commit ce72600b02
5 changed files with 19 additions and 26 deletions

View File

@ -1,20 +1 @@
from console import Console
console = None
def show():
global console
if not console:
console = Console()
console.show()
def hide():
if console:
console.hide()
def toggle_visibility():
if not console or not console.props.visible:
show()
else:
hide()

View File

@ -3,10 +3,14 @@ import os
import gtk
import hippo
from sugar.graphics.roundbox import CanvasRoundBox
class Console(gtk.Window):
def __init__(self):
def __init__(self, shell_model):
gtk.Window.__init__(self)
self._shell_model = shell_model
self.set_default_size(gtk.gdk.screen_width() * 3 / 4,
gtk.gdk.screen_height() * 3 / 4)
self.set_decorated(False)
@ -17,8 +21,7 @@ class Console(gtk.Window):
self.add(canvas)
canvas.show()
box = hippo.CanvasBox(padding=20, border_color=0x000000FF,
border=3)
box = hippo.CanvasBox(padding=20, background_color=0x000000FF)
canvas.set_root(box)
self.registry = Registry()

View File

@ -5,7 +5,6 @@ import hippo
import gnomevfs
from louie import dispatcher
from sugar.graphics.roundbox import CanvasRoundBox
from sugar import env
class LogEntry(object):
@ -55,7 +54,7 @@ class LogView(hippo.CanvasBox):
widget.props.vadjustment.connect('changed', self._vadj_changed_cb)
self.append(scrollbars, hippo.PACK_EXPAND)
self.box = hippo.CanvasBox(spacing=5)
self.box = hippo.CanvasBox(spacing=5, background_color=0xFFFFFFFF)
scrollbars.set_root(self.box)
for entry_model in self.model:
@ -64,10 +63,11 @@ class LogView(hippo.CanvasBox):
dispatcher.connect(self._entry_added_cb, 'entry-added', self.model)
def add_entry(self, entry_model):
entry_box = CanvasRoundBox(background_color=0xffffffff, padding=5)
entry_box = hippo.CanvasBox(padding=5)
self.box.append(entry_box)
entry = hippo.CanvasText(text=entry_model.text,
xalign=hippo.ALIGNMENT_START,
size_mode=hippo.CANVAS_SIZE_WRAP_WORD)
entry_box.append(entry)

View File

@ -36,6 +36,7 @@ from view.frame.frame import Frame
from view.keyhandler import KeyHandler
from view.home.HomeWindow import HomeWindow
from model.shellmodel import ShellModel
from console import Console
class Shell(gobject.GObject):
def __init__(self, model):
@ -64,6 +65,8 @@ class Shell(gobject.GObject):
home_model.connect('pending-activity-changed',
self._pending_activity_changed_cb)
self._console = Console(model)
gobject.idle_add(self._start_journal_idle)
def _start_journal_idle(self):
@ -165,6 +168,12 @@ class Shell(gobject.GObject):
return host
return None
def toggle_console_visibility(self):
if self._console.props.visible:
self._console.hide()
else:
self._console.show()
def toggle_chat_visibility(self):
act = self.get_current_activity()
if not act:

View File

@ -148,7 +148,7 @@ class KeyHandler(object):
gobject.idle_add(self._toggle_console_visibility_cb)
def handle_new_console(self):
console.toggle_visibility()
self._shell.toggle_console_visibility()
def handle_frame(self):
self._shell.get_frame().notify_key_press()