Activate/deactivate the frame on F5
This commit is contained in:
parent
3f4625f0a1
commit
7d01cee2ef
1
README
1
README
@ -22,4 +22,5 @@ F1 Activity zoom level
|
|||||||
F2 Home zoom level
|
F2 Home zoom level
|
||||||
F3 Friends zoom level
|
F3 Friends zoom level
|
||||||
F4 Mesh zoom level
|
F4 Mesh zoom level
|
||||||
|
F5 Show the frame
|
||||||
F6 Open a terminal activity
|
F6 Open a terminal activity
|
||||||
|
@ -5,7 +5,6 @@ from sugar import conf
|
|||||||
from sugar.activity import Activity
|
from sugar.activity import Activity
|
||||||
from sugar.presence import PresenceService
|
from sugar.presence import PresenceService
|
||||||
from sugar.canvas.IconColor import IconColor
|
from sugar.canvas.IconColor import IconColor
|
||||||
from PeopleWindow import PeopleWindow
|
|
||||||
|
|
||||||
class ActivityHost:
|
class ActivityHost:
|
||||||
def __init__(self, shell, window):
|
def __init__(self, shell, window):
|
||||||
@ -21,7 +20,6 @@ class ActivityHost:
|
|||||||
self._id = self._activity.get_id()
|
self._id = self._activity.get_id()
|
||||||
self._default_type = self._activity.get_default_type()
|
self._default_type = self._activity.get_default_type()
|
||||||
self._gdk_window = gtk.gdk.window_foreign_new(self._xid)
|
self._gdk_window = gtk.gdk.window_foreign_new(self._xid)
|
||||||
self._people_window = PeopleWindow(shell, self)
|
|
||||||
|
|
||||||
registry = conf.get_activity_registry()
|
registry = conf.get_activity_registry()
|
||||||
info = registry.get_activity(self._default_type)
|
info = registry.get_activity(self._default_type)
|
||||||
@ -50,9 +48,6 @@ class ActivityHost:
|
|||||||
def get_default_type(self):
|
def get_default_type(self):
|
||||||
return self._default_type
|
return self._default_type
|
||||||
|
|
||||||
def show_people(self):
|
|
||||||
self.show_dialog(self._people_window)
|
|
||||||
|
|
||||||
def present(self):
|
def present(self):
|
||||||
self._window.activate(gtk.get_current_event_time())
|
self._window.activate(gtk.get_current_event_time())
|
||||||
|
|
||||||
|
@ -28,16 +28,9 @@ class ShellDbusService(dbus.service.Object):
|
|||||||
dbus.service.Object.__init__(self, bus_name, '/com/redhat/Sugar/Shell')
|
dbus.service.Object.__init__(self, bus_name, '/com/redhat/Sugar/Shell')
|
||||||
self._shell = shell
|
self._shell = shell
|
||||||
|
|
||||||
def __show_people_idle(self):
|
|
||||||
self._shell.show_people()
|
|
||||||
|
|
||||||
def __show_console_idle(self):
|
def __show_console_idle(self):
|
||||||
self._shell.show_console()
|
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')
|
@dbus.service.method('com.redhat.Sugar.Shell')
|
||||||
def show_console(self):
|
def show_console(self):
|
||||||
gobject.idle_add(self.__show_console_idle)
|
gobject.idle_add(self.__show_console_idle)
|
||||||
@ -59,6 +52,7 @@ class Shell(gobject.GObject):
|
|||||||
self._key_grabber.grab('F2')
|
self._key_grabber.grab('F2')
|
||||||
self._key_grabber.grab('F3')
|
self._key_grabber.grab('F3')
|
||||||
self._key_grabber.grab('F4')
|
self._key_grabber.grab('F4')
|
||||||
|
self._key_grabber.grab('F5')
|
||||||
|
|
||||||
self._screen = wnck.screen_get_default()
|
self._screen = wnck.screen_get_default()
|
||||||
self._hosts = {}
|
self._hosts = {}
|
||||||
@ -89,6 +83,8 @@ class Shell(gobject.GObject):
|
|||||||
self.set_zoom_level(sugar.ZOOM_FRIENDS)
|
self.set_zoom_level(sugar.ZOOM_FRIENDS)
|
||||||
elif key == 'F4':
|
elif key == 'F4':
|
||||||
self.set_zoom_level(sugar.ZOOM_MESH)
|
self.set_zoom_level(sugar.ZOOM_MESH)
|
||||||
|
elif key == 'F5':
|
||||||
|
self._panel_manager.toggle_visibility()
|
||||||
|
|
||||||
def __first_time_dialog_destroy_cb(self, dialog):
|
def __first_time_dialog_destroy_cb(self, dialog):
|
||||||
conf.get_profile().save()
|
conf.get_profile().save()
|
||||||
@ -112,6 +108,10 @@ class Shell(gobject.GObject):
|
|||||||
self.set_zoom_level(sugar.ZOOM_HOME)
|
self.set_zoom_level(sugar.ZOOM_HOME)
|
||||||
|
|
||||||
self._panel_manager = PanelManager(self)
|
self._panel_manager = PanelManager(self)
|
||||||
|
self._panel_manager.show()
|
||||||
|
|
||||||
|
def get_panel_manager(self):
|
||||||
|
return self._panel_manager
|
||||||
|
|
||||||
def set_console(self, console):
|
def set_console(self, console):
|
||||||
self._console = console
|
self._console = console
|
||||||
@ -158,10 +158,6 @@ class Shell(gobject.GObject):
|
|||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def show_people(self):
|
|
||||||
activity = self.get_current_activity()
|
|
||||||
activity.show_people()
|
|
||||||
|
|
||||||
def show_console(self):
|
def show_console(self):
|
||||||
self._console.show()
|
self._console.show()
|
||||||
|
|
||||||
|
@ -24,8 +24,8 @@ class ActionsBar(goocanvas.Group):
|
|||||||
self.add_icon(icon)
|
self.add_icon(icon)
|
||||||
|
|
||||||
def add_icon(self, icon):
|
def add_icon(self, icon):
|
||||||
self._y += (self._width + 6)
|
|
||||||
icon.set_property('y', self._y)
|
icon.set_property('y', self._y)
|
||||||
|
self._y += (self._width + 6)
|
||||||
self.add_child(icon)
|
self.add_child(icon)
|
||||||
|
|
||||||
def __share_clicked_cb(self, item):
|
def __share_clicked_cb(self, item):
|
||||||
@ -48,5 +48,4 @@ class FriendsPanel(Panel):
|
|||||||
Panel.construct(self)
|
Panel.construct(self)
|
||||||
|
|
||||||
actions_bar = ActionsBar(self._shell, self.get_width())
|
actions_bar = ActionsBar(self._shell, self.get_width())
|
||||||
actions_bar.translate(self.get_border(), self.get_border())
|
|
||||||
self.get_root().add_child(actions_bar)
|
self.get_root().add_child(actions_bar)
|
||||||
|
@ -1,59 +1,66 @@
|
|||||||
import gtk
|
import gtk
|
||||||
import goocanvas
|
import goocanvas
|
||||||
|
|
||||||
class PanelModel(goocanvas.CanvasModelSimple):
|
class PanelView(goocanvas.CanvasView):
|
||||||
BORDER = 4
|
BORDER = 4
|
||||||
|
|
||||||
def __init__(self, width, height):
|
def construct(self, x, y):
|
||||||
goocanvas.CanvasModelSimple.__init__(self)
|
model = goocanvas.CanvasModelSimple()
|
||||||
|
root = model.get_root_item()
|
||||||
|
|
||||||
root = self.get_root_item()
|
item = goocanvas.Rect(x=0, y=0,
|
||||||
|
width=self.get_allocation().width,
|
||||||
item = goocanvas.Rect(x=0, y=0, width=width, height=height,
|
height=self.get_allocation().height,
|
||||||
line_width=0, fill_color="#4f4f4f")
|
line_width=0, fill_color="#4f4f4f")
|
||||||
root.add_child(item)
|
root.add_child(item)
|
||||||
|
|
||||||
class PanelView(goocanvas.CanvasView):
|
self._group = goocanvas.Group()
|
||||||
def construct(self):
|
root.add_child(self._group)
|
||||||
canvas_model = PanelModel(self.get_allocation().width,
|
self._group.translate(x + PanelView.BORDER, y + PanelView.BORDER)
|
||||||
self.get_allocation().height)
|
|
||||||
self.set_model(canvas_model)
|
self.set_model(model)
|
||||||
|
|
||||||
|
def get_root_group(self):
|
||||||
|
return self._group
|
||||||
|
|
||||||
class Panel(gtk.Window):
|
class Panel(gtk.Window):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
gtk.Window.__init__(self)
|
gtk.Window.__init__(self)
|
||||||
|
self._x = 0
|
||||||
|
self._y = 0
|
||||||
|
|
||||||
self._view = PanelView()
|
self._view = PanelView()
|
||||||
self.add(self._view)
|
self.add(self._view)
|
||||||
self._view.show()
|
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):
|
def get_view(self):
|
||||||
return self._view
|
return self._view
|
||||||
|
|
||||||
def get_model(self):
|
|
||||||
return self._view.get_model()
|
|
||||||
|
|
||||||
def get_root(self):
|
def get_root(self):
|
||||||
return self.get_model().get_root_item()
|
return self._view.get_root_group()
|
||||||
|
|
||||||
def get_border(self):
|
|
||||||
return PanelModel.BORDER
|
|
||||||
|
|
||||||
def get_height(self):
|
def get_height(self):
|
||||||
height = self._view.get_allocation().height
|
height = self._view.get_allocation().height
|
||||||
return height - self.get_border() * 2
|
return height - PanelView.BORDER * 2
|
||||||
|
|
||||||
def get_width(self):
|
def get_width(self):
|
||||||
width = self._view.get_allocation().width
|
width = self._view.get_allocation().width
|
||||||
return width - self.get_border() * 2
|
return width - PanelView.BORDER * 2
|
||||||
|
|
||||||
def __realize_cb(self, window):
|
def set_position(self, x, y):
|
||||||
self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DOCK)
|
self._x = x
|
||||||
|
self._y = y
|
||||||
|
|
||||||
def construct(self):
|
def construct(self):
|
||||||
self._view.construct()
|
self._view.construct(self._x, self._y)
|
||||||
|
|
||||||
def show(self):
|
def show(self):
|
||||||
gtk.Window.show(self)
|
gtk.Window.show(self)
|
||||||
|
@ -10,21 +10,38 @@ class PanelManager:
|
|||||||
size = 30
|
size = 30
|
||||||
|
|
||||||
self._verbs_panel = VerbsPanel(shell)
|
self._verbs_panel = VerbsPanel(shell)
|
||||||
self._verbs_panel.move(0, gtk.gdk.screen_height() - size)
|
self._verbs_panel.set_position(size, 0)
|
||||||
self._verbs_panel.resize(gtk.gdk.screen_width(), size)
|
self._verbs_panel.move(1, gtk.gdk.screen_height() - size + 1)
|
||||||
self._verbs_panel.show()
|
self._verbs_panel.resize(gtk.gdk.screen_width() - 1, size - 1)
|
||||||
|
|
||||||
self._friends_panel = FriendsPanel(shell)
|
self._friends_panel = FriendsPanel(shell)
|
||||||
self._friends_panel.move(gtk.gdk.screen_width() - size, 0)
|
self._friends_panel.move(gtk.gdk.screen_width() - size, size)
|
||||||
self._friends_panel.resize(size, gtk.gdk.screen_height())
|
self._friends_panel.resize(size, gtk.gdk.screen_height() - size * 2 + 1)
|
||||||
self._friends_panel.show()
|
|
||||||
|
|
||||||
self._top_panel = TopPanel(shell)
|
self._top_panel = TopPanel(shell)
|
||||||
self._top_panel.move(0, 0)
|
self._top_panel.set_position(size, 0)
|
||||||
self._top_panel.resize(gtk.gdk.screen_width(), size)
|
# FIXME bug in matchbox, can't use 0,0
|
||||||
self._top_panel.show()
|
self._top_panel.move(0, 1)
|
||||||
|
self._top_panel.resize(gtk.gdk.screen_width() - 1, size - 1)
|
||||||
|
|
||||||
panel = Panel()
|
self._left_panel = Panel()
|
||||||
panel.move(0, 0)
|
self._left_panel.move(0, size)
|
||||||
panel.resize(size, gtk.gdk.screen_height())
|
self._left_panel.resize(size, gtk.gdk.screen_height() - size * 2 + 1)
|
||||||
panel.show()
|
|
||||||
|
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()
|
||||||
|
@ -37,5 +37,4 @@ class TopPanel(Panel):
|
|||||||
Panel.construct(self)
|
Panel.construct(self)
|
||||||
|
|
||||||
zoom_bar = ZoomBar(self._shell, self.get_height())
|
zoom_bar = ZoomBar(self._shell, self.get_height())
|
||||||
zoom_bar.translate(self.get_border(), self.get_border())
|
|
||||||
self.get_root().add_child(zoom_bar)
|
self.get_root().add_child(zoom_bar)
|
||||||
|
@ -59,10 +59,9 @@ class VerbsPanel(Panel):
|
|||||||
def construct(self):
|
def construct(self):
|
||||||
Panel.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 = ActivityBar(self._shell, self.get_height())
|
||||||
activity_bar.translate(self.get_border(), self.get_border())
|
|
||||||
root.add_child(activity_bar)
|
root.add_child(activity_bar)
|
||||||
|
|
||||||
def __item_view_created_cb(self, view, item_view, item):
|
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):
|
def __activity_button_press_cb(self, view, target, event, activity_id):
|
||||||
self._shell.start_activity(activity_id)
|
self._shell.start_activity(activity_id)
|
||||||
|
self._shell.get_panel_manager().hide()
|
||||||
|
Loading…
Reference in New Issue
Block a user