Merge branch 'master' of git+ssh://dev.laptop.org/git/sugar
This commit is contained in:
commit
1e75007161
@ -7,10 +7,25 @@ from sugar.presence import PresenceService
|
||||
from sugar.canvas.IconColor import IconColor
|
||||
from sugar.p2p import Stream
|
||||
from sugar.p2p import network
|
||||
from sugar.chat import ActivityChat
|
||||
|
||||
class ActivityChatWindow(gtk.Window):
|
||||
def __init__(self, gdk_window, chat_widget):
|
||||
gtk.Window.__init__(self)
|
||||
|
||||
self.realize()
|
||||
self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
|
||||
self.window.set_accept_focus(True)
|
||||
self.window.set_transient_for(gdk_window)
|
||||
self.set_position(gtk.WIN_POS_CENTER_ALWAYS)
|
||||
self.set_default_size(600, 450)
|
||||
|
||||
self.add(chat_widget)
|
||||
|
||||
class ActivityHost:
|
||||
def __init__(self, shell, window):
|
||||
self._shell = shell
|
||||
|
||||
self._window = window
|
||||
self._xid = window.get_xid()
|
||||
self._pservice = PresenceService.get_instance()
|
||||
@ -28,6 +43,13 @@ class ActivityHost:
|
||||
info = registry.get_activity(self._type)
|
||||
self._icon_name = info.get_icon()
|
||||
|
||||
self._chat_widget = ActivityChat.ActivityChat(self)
|
||||
self._chat_window = ActivityChatWindow(self._gdk_window, self._chat_widget)
|
||||
|
||||
self._frame_was_visible = False
|
||||
self._shell.connect('activity-changed', self._activity_changed_cb)
|
||||
self._shell.connect('activity-closed', self._activity_closed_cb)
|
||||
|
||||
def get_id(self):
|
||||
return self._id
|
||||
|
||||
@ -49,6 +71,7 @@ class ActivityHost:
|
||||
|
||||
def share(self):
|
||||
self._activity.share()
|
||||
self._chat_widget.share()
|
||||
|
||||
def invite(self, buddy):
|
||||
if not self.get_shared():
|
||||
@ -76,3 +99,27 @@ class ActivityHost:
|
||||
def show_dialog(self, dialog):
|
||||
dialog.show()
|
||||
dialog.window.set_transient_for(self._gdk_window)
|
||||
|
||||
def chat_show(self, frame_was_visible):
|
||||
self._chat_window.show_all()
|
||||
self._frame_was_visible = frame_was_visible
|
||||
|
||||
def chat_hide(self):
|
||||
self._chat_window.hide()
|
||||
wasvis = self._frame_was_visible
|
||||
self._frame_was_visible = False
|
||||
return wasvis
|
||||
|
||||
def is_chat_visible(self):
|
||||
return self._chat_window.get_property('visible')
|
||||
|
||||
def _activity_changed_cb(self, shell, activity):
|
||||
if activity != self:
|
||||
self.chat_hide()
|
||||
self._frame_was_visible = False
|
||||
|
||||
def _activity_closed_cb(self, shell, activity):
|
||||
if activity == self:
|
||||
self.chat_hide()
|
||||
self._frame_was_visible = False
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
from sugar.canvas.Menu import Menu
|
||||
from sugar.canvas.IconItem import IconItem
|
||||
from sugar.presence import PresenceService
|
||||
import gtk
|
||||
import gtk, gobject
|
||||
import goocanvas
|
||||
|
||||
_ICON_SIZE = 75
|
||||
|
@ -41,6 +41,7 @@ class Shell(gobject.GObject):
|
||||
self._key_grabber.grab('F4')
|
||||
self._key_grabber.grab('F5')
|
||||
self._key_grabber.grab('F6')
|
||||
self._key_grabber.grab('F9')
|
||||
|
||||
self._home_window = HomeWindow(self)
|
||||
self._home_window.show()
|
||||
@ -67,6 +68,8 @@ class Shell(gobject.GObject):
|
||||
self._frame.notify_key_press()
|
||||
elif key == 'F6':
|
||||
self.start_activity('org.sugar.Terminal')
|
||||
elif key == 'F9':
|
||||
self._show_hide_activity_chat()
|
||||
|
||||
def __global_key_released_cb(self, grabber, key):
|
||||
if key == 'F5':
|
||||
@ -147,3 +150,17 @@ class Shell(gobject.GObject):
|
||||
if host.get_id() == activity_id:
|
||||
return host
|
||||
return None
|
||||
|
||||
def _show_hide_activity_chat(self):
|
||||
act = self.get_current_activity()
|
||||
if not act:
|
||||
return
|
||||
is_visible = self._frame.is_visible()
|
||||
if act.is_chat_visible():
|
||||
frame_was_visible = act.chat_hide()
|
||||
if not frame_was_visible:
|
||||
self._frame.do_slide_out()
|
||||
else:
|
||||
if not is_visible:
|
||||
self._frame.do_slide_in()
|
||||
act.chat_show(is_visible)
|
||||
|
@ -210,14 +210,19 @@ class Frame:
|
||||
if self._mode == Frame.TEMPORARY:
|
||||
self._timeline.play('before_slide_out', 'slide_out')
|
||||
|
||||
def do_slide_in(self, current, n_frames):
|
||||
def do_slide_in(self, current=0, n_frames=0):
|
||||
if not self._windows[0].props.visible:
|
||||
for panel in self._windows:
|
||||
panel.show()
|
||||
self._event_frame.hide()
|
||||
|
||||
def do_slide_out(self, current, n_frames):
|
||||
def do_slide_out(self, current=0, n_frames=0):
|
||||
if self._windows[0].props.visible:
|
||||
for panel in self._windows:
|
||||
panel.hide()
|
||||
self._event_frame.show()
|
||||
|
||||
def is_visible(self):
|
||||
if self._windows[0].props.visible:
|
||||
return True
|
||||
return False
|
||||
|
@ -14,7 +14,7 @@ import logging
|
||||
from sugar.chat.Emoticons import Emoticons
|
||||
from sugar.chat.ChatToolbar import ChatToolbar
|
||||
from sugar.chat.ChatEditor import ChatEditor
|
||||
from sugar.presence.PresenceService import PresenceService
|
||||
from sugar.presence import PresenceService
|
||||
import richtext
|
||||
|
||||
PANGO_SCALE = 1024 # Where is this defined?
|
||||
@ -29,7 +29,7 @@ class Chat(gtk.VBox):
|
||||
def __init__(self):
|
||||
gtk.VBox.__init__(self, False, 6)
|
||||
|
||||
self._pservice = PresenceService()
|
||||
self._pservice = PresenceService.get_instance()
|
||||
|
||||
self._stream_writer = None
|
||||
self.set_border_width(12)
|
||||
|
@ -1,4 +1,4 @@
|
||||
import gtk
|
||||
import gtk, gobject
|
||||
|
||||
from sugar.chat.Emoticons import Emoticons
|
||||
from sugar.chat.sketchpad.Toolbox import Toolbox
|
||||
@ -82,8 +82,11 @@ class ChatToolbar(gtk.HBox):
|
||||
|
||||
for name in Emoticons.get_instance().get_all():
|
||||
icon_theme = gtk.icon_theme_get_default()
|
||||
try:
|
||||
pixbuf = icon_theme.load_icon(name, 16, 0)
|
||||
model.append([pixbuf, name])
|
||||
except gobject.GError:
|
||||
pass
|
||||
|
||||
icon_view = gtk.IconView(model)
|
||||
icon_view.connect('selection-changed', self.__emoticon_selection_changed_cb)
|
||||
|
Loading…
Reference in New Issue
Block a user