Activate/deactivate the frame on F5

This commit is contained in:
Marco Pesenti Gritti 2006-08-28 16:53:29 +02:00
parent 3f4625f0a1
commit 7d01cee2ef
8 changed files with 72 additions and 58 deletions

1
README
View File

@ -22,4 +22,5 @@ F1 Activity zoom level
F2 Home zoom level
F3 Friends zoom level
F4 Mesh zoom level
F5 Show the frame
F6 Open a terminal activity

View File

@ -5,7 +5,6 @@ from sugar import conf
from sugar.activity import Activity
from sugar.presence import PresenceService
from sugar.canvas.IconColor import IconColor
from PeopleWindow import PeopleWindow
class ActivityHost:
def __init__(self, shell, window):
@ -21,7 +20,6 @@ class ActivityHost:
self._id = self._activity.get_id()
self._default_type = self._activity.get_default_type()
self._gdk_window = gtk.gdk.window_foreign_new(self._xid)
self._people_window = PeopleWindow(shell, self)
registry = conf.get_activity_registry()
info = registry.get_activity(self._default_type)
@ -50,9 +48,6 @@ class ActivityHost:
def get_default_type(self):
return self._default_type
def show_people(self):
self.show_dialog(self._people_window)
def present(self):
self._window.activate(gtk.get_current_event_time())

View File

@ -28,16 +28,9 @@ class ShellDbusService(dbus.service.Object):
dbus.service.Object.__init__(self, bus_name, '/com/redhat/Sugar/Shell')
self._shell = shell
def __show_people_idle(self):
self._shell.show_people()
def __show_console_idle(self):
self._shell.show_console()
@dbus.service.method('com.redhat.Sugar.Shell')
def show_people(self):
gobject.idle_add(self.__show_people_idle)
@dbus.service.method('com.redhat.Sugar.Shell')
def show_console(self):
gobject.idle_add(self.__show_console_idle)
@ -59,6 +52,7 @@ class Shell(gobject.GObject):
self._key_grabber.grab('F2')
self._key_grabber.grab('F3')
self._key_grabber.grab('F4')
self._key_grabber.grab('F5')
self._screen = wnck.screen_get_default()
self._hosts = {}
@ -89,6 +83,8 @@ class Shell(gobject.GObject):
self.set_zoom_level(sugar.ZOOM_FRIENDS)
elif key == 'F4':
self.set_zoom_level(sugar.ZOOM_MESH)
elif key == 'F5':
self._panel_manager.toggle_visibility()
def __first_time_dialog_destroy_cb(self, dialog):
conf.get_profile().save()
@ -112,6 +108,10 @@ class Shell(gobject.GObject):
self.set_zoom_level(sugar.ZOOM_HOME)
self._panel_manager = PanelManager(self)
self._panel_manager.show()
def get_panel_manager(self):
return self._panel_manager
def set_console(self, console):
self._console = console
@ -158,10 +158,6 @@ class Shell(gobject.GObject):
return None
def show_people(self):
activity = self.get_current_activity()
activity.show_people()
def show_console(self):
self._console.show()

View File

@ -24,8 +24,8 @@ class ActionsBar(goocanvas.Group):
self.add_icon(icon)
def add_icon(self, icon):
self._y += (self._width + 6)
icon.set_property('y', self._y)
self._y += (self._width + 6)
self.add_child(icon)
def __share_clicked_cb(self, item):
@ -48,5 +48,4 @@ class FriendsPanel(Panel):
Panel.construct(self)
actions_bar = ActionsBar(self._shell, self.get_width())
actions_bar.translate(self.get_border(), self.get_border())
self.get_root().add_child(actions_bar)

View File

@ -1,59 +1,66 @@
import gtk
import goocanvas
class PanelModel(goocanvas.CanvasModelSimple):
class PanelView(goocanvas.CanvasView):
BORDER = 4
def __init__(self, width, height):
goocanvas.CanvasModelSimple.__init__(self)
def construct(self, x, y):
model = goocanvas.CanvasModelSimple()
root = model.get_root_item()
root = self.get_root_item()
item = goocanvas.Rect(x=0, y=0, width=width, height=height,
item = goocanvas.Rect(x=0, y=0,
width=self.get_allocation().width,
height=self.get_allocation().height,
line_width=0, fill_color="#4f4f4f")
root.add_child(item)
class PanelView(goocanvas.CanvasView):
def construct(self):
canvas_model = PanelModel(self.get_allocation().width,
self.get_allocation().height)
self.set_model(canvas_model)
self._group = goocanvas.Group()
root.add_child(self._group)
self._group.translate(x + PanelView.BORDER, y + PanelView.BORDER)
self.set_model(model)
def get_root_group(self):
return self._group
class Panel(gtk.Window):
def __init__(self):
gtk.Window.__init__(self)
self._x = 0
self._y = 0
self._view = PanelView()
self.add(self._view)
self._view.show()
self.connect('realize', self.__realize_cb)
self.set_decorated(False)
self.realize()
self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
screen = gtk.gdk.screen_get_default()
self.window.set_transient_for(screen.get_root_window())
def get_view(self):
return self._view
def get_model(self):
return self._view.get_model()
def get_root(self):
return self.get_model().get_root_item()
def get_border(self):
return PanelModel.BORDER
return self._view.get_root_group()
def get_height(self):
height = self._view.get_allocation().height
return height - self.get_border() * 2
return height - PanelView.BORDER * 2
def get_width(self):
width = self._view.get_allocation().width
return width - self.get_border() * 2
return width - PanelView.BORDER * 2
def __realize_cb(self, window):
self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DOCK)
def set_position(self, x, y):
self._x = x
self._y = y
def construct(self):
self._view.construct()
self._view.construct(self._x, self._y)
def show(self):
gtk.Window.show(self)

View File

@ -10,21 +10,38 @@ class PanelManager:
size = 30
self._verbs_panel = VerbsPanel(shell)
self._verbs_panel.move(0, gtk.gdk.screen_height() - size)
self._verbs_panel.resize(gtk.gdk.screen_width(), size)
self._verbs_panel.show()
self._verbs_panel.set_position(size, 0)
self._verbs_panel.move(1, gtk.gdk.screen_height() - size + 1)
self._verbs_panel.resize(gtk.gdk.screen_width() - 1, size - 1)
self._friends_panel = FriendsPanel(shell)
self._friends_panel.move(gtk.gdk.screen_width() - size, 0)
self._friends_panel.resize(size, gtk.gdk.screen_height())
self._friends_panel.show()
self._friends_panel.move(gtk.gdk.screen_width() - size, size)
self._friends_panel.resize(size, gtk.gdk.screen_height() - size * 2 + 1)
self._top_panel = TopPanel(shell)
self._top_panel.move(0, 0)
self._top_panel.resize(gtk.gdk.screen_width(), size)
self._top_panel.show()
self._top_panel.set_position(size, 0)
# FIXME bug in matchbox, can't use 0,0
self._top_panel.move(0, 1)
self._top_panel.resize(gtk.gdk.screen_width() - 1, size - 1)
panel = Panel()
panel.move(0, 0)
panel.resize(size, gtk.gdk.screen_height())
panel.show()
self._left_panel = Panel()
self._left_panel.move(0, size)
self._left_panel.resize(size, gtk.gdk.screen_height() - size * 2 + 1)
def show(self):
self._verbs_panel.show()
self._friends_panel.show()
self._top_panel.show()
self._left_panel.show()
def hide(self):
self._verbs_panel.hide()
self._friends_panel.hide()
self._top_panel.hide()
self._left_panel.hide()
def toggle_visibility(self):
if self._verbs_panel.props.visible:
self.hide()
else:
self.show()

View File

@ -37,5 +37,4 @@ class TopPanel(Panel):
Panel.construct(self)
zoom_bar = ZoomBar(self._shell, self.get_height())
zoom_bar.translate(self.get_border(), self.get_border())
self.get_root().add_child(zoom_bar)

View File

@ -59,10 +59,9 @@ class VerbsPanel(Panel):
def construct(self):
Panel.construct(self)
root = self.get_model().get_root_item()
root = self.get_root()
activity_bar = ActivityBar(self._shell, self.get_height())
activity_bar.translate(self.get_border(), self.get_border())
root.add_child(activity_bar)
def __item_view_created_cb(self, view, item_view, item):
@ -73,3 +72,4 @@ class VerbsPanel(Panel):
def __activity_button_press_cb(self, view, target, event, activity_id):
self._shell.start_activity(activity_id)
self._shell.get_panel_manager().hide()