Add tasks to the home window. A bunch of fixes.
This commit is contained in:
parent
1cc14e406a
commit
9f9f420863
@ -135,7 +135,7 @@ class BrowserActivity(Activity):
|
||||
self.set_mode(BrowserActivity.LEADING)
|
||||
|
||||
def __title_cb(self, embed):
|
||||
self.set_tab_text(embed.get_title())
|
||||
self.set_title(embed.get_title())
|
||||
|
||||
def __shared_location_changed_cb(self, model, key):
|
||||
self.set_has_changes(True)
|
||||
|
@ -1,14 +1,15 @@
|
||||
from gettext import gettext as _
|
||||
|
||||
import gtk
|
||||
import wnck
|
||||
|
||||
from sugar.activity import Activity
|
||||
|
||||
class NewActivityButton(gtk.MenuToolButton):
|
||||
def __init__(self, shell):
|
||||
def __init__(self, home):
|
||||
gtk.MenuToolButton.__init__(self, None, _('New Activity'))
|
||||
|
||||
self._shell = shell
|
||||
self._home = home
|
||||
|
||||
self.set_menu(gtk.Menu())
|
||||
self.connect("show-menu", self.__show_menu_cb)
|
||||
@ -16,7 +17,7 @@ class NewActivityButton(gtk.MenuToolButton):
|
||||
def __show_menu_cb(self, button):
|
||||
menu = gtk.Menu()
|
||||
|
||||
for activity_info in self._shell.get_registry().list_activities():
|
||||
for activity_info in self._home.list_activities():
|
||||
item = gtk.MenuItem(activity_info.get_title(), False)
|
||||
name = activity_info.get_name()
|
||||
item.connect('activate', self.__menu_item_activate_cb, name)
|
||||
@ -26,7 +27,7 @@ class NewActivityButton(gtk.MenuToolButton):
|
||||
self.set_menu(menu)
|
||||
|
||||
def __menu_item_activate_cb(self, item, name):
|
||||
Activity.create(name)
|
||||
self._home.create(name)
|
||||
|
||||
class Toolbar(gtk.Toolbar):
|
||||
def __init__(self, shell):
|
||||
@ -36,15 +37,66 @@ class Toolbar(gtk.Toolbar):
|
||||
self.insert(new_activity_button, -1)
|
||||
new_activity_button.show()
|
||||
|
||||
class ActivityGrid(gtk.VBox):
|
||||
def __init__(self, home):
|
||||
gtk.VBox.__init__(self)
|
||||
|
||||
self._home = home
|
||||
self.update()
|
||||
|
||||
def _add_all(self):
|
||||
screen = wnck.screen_get_default()
|
||||
for window in screen.get_windows():
|
||||
if not window.is_skip_tasklist():
|
||||
self.add(window)
|
||||
|
||||
def _remove_all(self):
|
||||
for child in self.get_children():
|
||||
self.remove(child)
|
||||
|
||||
def add(self, window):
|
||||
button = gtk.Button(window.get_name())
|
||||
button.connect('clicked', self.__button_clicked_cb, window)
|
||||
self.pack_start(button, False)
|
||||
button.show()
|
||||
|
||||
def update(self):
|
||||
self._remove_all()
|
||||
self._add_all()
|
||||
|
||||
def __button_clicked_cb(self, button, window):
|
||||
self._home.activate(window)
|
||||
|
||||
class HomeWindow(gtk.Window):
|
||||
def __init__(self, shell):
|
||||
gtk.Window.__init__(self)
|
||||
|
||||
self._shell = shell
|
||||
|
||||
vbox = gtk.VBox()
|
||||
|
||||
toolbar = Toolbar(shell)
|
||||
toolbar = Toolbar(self)
|
||||
vbox.pack_start(toolbar, False)
|
||||
toolbar.show()
|
||||
|
||||
self._grid = ActivityGrid(self)
|
||||
vbox.pack_start(self._grid)
|
||||
self._grid.show()
|
||||
|
||||
self.add(vbox)
|
||||
vbox.show()
|
||||
|
||||
def list_activities(self):
|
||||
return self._shell.get_registry().list_activities()
|
||||
|
||||
def create(self, activity_name):
|
||||
Activity.create(activity_name)
|
||||
self.hide()
|
||||
|
||||
def activate(self, activity_window):
|
||||
activity_window.activate(gtk.get_current_event_time())
|
||||
self.hide()
|
||||
|
||||
def show(self):
|
||||
self._grid.update()
|
||||
gtk.Window.show(self)
|
||||
|
@ -51,7 +51,6 @@ class PresenceWindow(gtk.Window):
|
||||
self._share_button.set_sensitive(False)
|
||||
else:
|
||||
self._share_button.set_sensitive(True)
|
||||
self._activity.connect('shared', lambda w: self._share_button.set_sensitive(False))
|
||||
else:
|
||||
self._share_button.set_sensitive(False)
|
||||
|
||||
|
@ -11,6 +11,7 @@ from sugar import keybindings
|
||||
from sugar.activity import Activity
|
||||
from PresenceWindow import PresenceWindow
|
||||
from sugar.chat.ActivityChat import ActivityChat
|
||||
from Owner import ShellOwner
|
||||
|
||||
class ShellDbusService(dbus.service.Object):
|
||||
def __init__(self, shell, bus_name):
|
||||
@ -41,6 +42,8 @@ class Shell(gobject.GObject):
|
||||
def __init__(self):
|
||||
gobject.GObject.__init__(self)
|
||||
|
||||
self._screen = wnck.screen_get_default()
|
||||
|
||||
def start(self):
|
||||
self._console = ConsoleLogger()
|
||||
keybindings.setup_global_keys(self._console.get_window(), self)
|
||||
@ -52,6 +55,8 @@ class Shell(gobject.GObject):
|
||||
bus_name = dbus.service.BusName('com.redhat.Sugar.Shell', bus=session_bus)
|
||||
ShellDbusService(self, bus_name)
|
||||
|
||||
self._owner = ShellOwner()
|
||||
|
||||
self._registry = ActivityRegistry()
|
||||
|
||||
self._home_window = HomeWindow(self)
|
||||
@ -59,7 +64,9 @@ class Shell(gobject.GObject):
|
||||
self._home_window.show()
|
||||
|
||||
self._presence_window = PresenceWindow(self)
|
||||
self._presence_window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
|
||||
self._presence_window.set_skip_taskbar_hint(True)
|
||||
self._presence_window.set_decorated(False)
|
||||
keybindings.setup_global_keys(self._presence_window, self)
|
||||
|
||||
self._chat_windows = {}
|
||||
@ -73,15 +80,22 @@ class Shell(gobject.GObject):
|
||||
def toggle_home(self):
|
||||
self._toggle_window_visibility(self._home_window)
|
||||
|
||||
def get_current_activity(self):
|
||||
window = wnck.screen_get_default().get_active_window()
|
||||
if window and not window.is_skip_tasklist():
|
||||
def get_activity_from_xid(self, xid):
|
||||
bus = dbus.SessionBus()
|
||||
xid = window.get_xid()
|
||||
service = Activity.ACTIVITY_SERVICE_NAME + "%s" % xid
|
||||
path = Activity.ACTIVITY_SERVICE_PATH + "/%s" % xid
|
||||
proxy_obj = bus.get_object(service, path)
|
||||
|
||||
return dbus.Interface(proxy_obj, 'com.redhat.Sugar.Activity')
|
||||
|
||||
def get_current_activity(self):
|
||||
window = self._screen.get_active_window()
|
||||
|
||||
if window and window.is_skip_tasklist():
|
||||
window = self._screen.get_previously_active_window()
|
||||
|
||||
if window and not window.is_skip_tasklist():
|
||||
return self.get_activity_from_xid(window.get_xid())
|
||||
else:
|
||||
return None
|
||||
|
||||
@ -93,20 +107,25 @@ class Shell(gobject.GObject):
|
||||
|
||||
if not self._chat_windows.has_key(activity_id):
|
||||
window = gtk.Window()
|
||||
window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
|
||||
window.set_skip_taskbar_hint(True)
|
||||
window.set_decorated(False)
|
||||
keybindings.setup_global_keys(window, self)
|
||||
chat = ActivityChat(activity)
|
||||
window.add(chat)
|
||||
chat.show()
|
||||
self._chat_windows[activity_id] = window
|
||||
self._toggle_window_visibility(self._chat_windows[activity_id])
|
||||
else:
|
||||
window = self._chat_windows[activity_id]
|
||||
|
||||
window.move(210, 10)
|
||||
window.resize(380, 440)
|
||||
self._toggle_window_visibility(window)
|
||||
|
||||
self._presence_window.move(10, 10)
|
||||
self._presence_window.resize(180, 440)
|
||||
self._presence_window.set_activity(activity)
|
||||
self._toggle_window_visibility(self._presence_window)
|
||||
else:
|
||||
self._presence_window.hide()
|
||||
for window in self._chat_windows.values():
|
||||
window.hide()
|
||||
|
||||
def toggle_console(self):
|
||||
self._toggle_window_visibility(self._console.get_window())
|
||||
|
@ -179,7 +179,7 @@ class Activity(gtk.Window):
|
||||
|
||||
self.connect('realize', self.__realize)
|
||||
|
||||
self.show()
|
||||
self.present()
|
||||
|
||||
def __realize(self, window):
|
||||
if not self._dbus_service:
|
||||
|
@ -13,6 +13,8 @@ def setup_global_keys(window, shell = None):
|
||||
window.connect("key-press-event", __key_press_event_cb, shell)
|
||||
|
||||
def __key_press_event_cb(window, event, shell):
|
||||
if event.keyval == gtk.keysyms.F1:
|
||||
shell.toggle_home()
|
||||
if event.keyval == gtk.keysyms.F2:
|
||||
shell.toggle_people()
|
||||
if event.keyval == gtk.keysyms.F3:
|
||||
|
Loading…
Reference in New Issue
Block a user