Merge branch 'master' of git://dev.laptop.org/sugar
This commit is contained in:
commit
242f96deb3
@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
import logging
|
||||||
|
|
||||||
import gtk
|
import gtk
|
||||||
import gtkmozembed
|
import gtkmozembed
|
||||||
@ -23,6 +24,8 @@ class PopupCreator(gobject.GObject):
|
|||||||
def __init__(self, parent_window):
|
def __init__(self, parent_window):
|
||||||
gobject.GObject.__init__(self)
|
gobject.GObject.__init__(self)
|
||||||
|
|
||||||
|
logging.debug('Creating the popup widget')
|
||||||
|
|
||||||
self._sized_popup = False
|
self._sized_popup = False
|
||||||
self._parent_window = parent_window
|
self._parent_window = parent_window
|
||||||
|
|
||||||
@ -39,16 +42,19 @@ class PopupCreator(gobject.GObject):
|
|||||||
self._dialog.add(self._embed)
|
self._dialog.add(self._embed)
|
||||||
|
|
||||||
def _size_to_cb(self, embed, width, height):
|
def _size_to_cb(self, embed, width, height):
|
||||||
|
logging.debug('Resize the popup to %d %d' % (width, height))
|
||||||
self._sized_popup = True
|
self._sized_popup = True
|
||||||
self._dialog.resize(width, height)
|
self._dialog.resize(width, height)
|
||||||
|
|
||||||
def _visibility_cb(self, embed, visible):
|
def _visibility_cb(self, embed, visible):
|
||||||
if visible:
|
if visible:
|
||||||
if self._sized_popup:
|
if self._sized_popup:
|
||||||
|
logging.debug('Show the popup')
|
||||||
self._embed.show()
|
self._embed.show()
|
||||||
self._dialog.set_transient_for(self._parent_window)
|
self._dialog.set_transient_for(self._parent_window)
|
||||||
self._dialog.show()
|
self._dialog.show()
|
||||||
else:
|
else:
|
||||||
|
logging.debug('Open a new activity for the popup')
|
||||||
self._dialog.remove(self._embed)
|
self._dialog.remove(self._embed)
|
||||||
|
|
||||||
activity = BrowserActivity(self._embed)
|
activity = BrowserActivity(self._embed)
|
||||||
|
@ -7,10 +7,25 @@ from sugar.presence import PresenceService
|
|||||||
from sugar.canvas.IconColor import IconColor
|
from sugar.canvas.IconColor import IconColor
|
||||||
from sugar.p2p import Stream
|
from sugar.p2p import Stream
|
||||||
from sugar.p2p import network
|
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:
|
class ActivityHost:
|
||||||
def __init__(self, shell, window):
|
def __init__(self, shell, window):
|
||||||
self._shell = shell
|
self._shell = shell
|
||||||
|
|
||||||
self._window = window
|
self._window = window
|
||||||
self._xid = window.get_xid()
|
self._xid = window.get_xid()
|
||||||
self._pservice = PresenceService.get_instance()
|
self._pservice = PresenceService.get_instance()
|
||||||
@ -28,6 +43,13 @@ class ActivityHost:
|
|||||||
info = registry.get_activity(self._type)
|
info = registry.get_activity(self._type)
|
||||||
self._icon_name = info.get_icon()
|
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):
|
def get_id(self):
|
||||||
return self._id
|
return self._id
|
||||||
|
|
||||||
@ -49,6 +71,7 @@ class ActivityHost:
|
|||||||
|
|
||||||
def share(self):
|
def share(self):
|
||||||
self._activity.share()
|
self._activity.share()
|
||||||
|
self._chat_widget.share()
|
||||||
|
|
||||||
def invite(self, buddy):
|
def invite(self, buddy):
|
||||||
if not self.get_shared():
|
if not self.get_shared():
|
||||||
@ -76,3 +99,27 @@ class ActivityHost:
|
|||||||
def show_dialog(self, dialog):
|
def show_dialog(self, dialog):
|
||||||
dialog.show()
|
dialog.show()
|
||||||
dialog.window.set_transient_for(self._gdk_window)
|
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.Menu import Menu
|
||||||
from sugar.canvas.IconItem import IconItem
|
from sugar.canvas.IconItem import IconItem
|
||||||
from sugar.presence import PresenceService
|
from sugar.presence import PresenceService
|
||||||
import gtk
|
import gtk, gobject
|
||||||
import goocanvas
|
import goocanvas
|
||||||
|
|
||||||
_ICON_SIZE = 75
|
_ICON_SIZE = 75
|
||||||
|
@ -41,6 +41,7 @@ class Shell(gobject.GObject):
|
|||||||
self._key_grabber.grab('F4')
|
self._key_grabber.grab('F4')
|
||||||
self._key_grabber.grab('F5')
|
self._key_grabber.grab('F5')
|
||||||
self._key_grabber.grab('F6')
|
self._key_grabber.grab('F6')
|
||||||
|
self._key_grabber.grab('F9')
|
||||||
|
|
||||||
self._home_window = HomeWindow(self)
|
self._home_window = HomeWindow(self)
|
||||||
self._home_window.show()
|
self._home_window.show()
|
||||||
@ -67,6 +68,8 @@ class Shell(gobject.GObject):
|
|||||||
self._frame.notify_key_press()
|
self._frame.notify_key_press()
|
||||||
elif key == 'F6':
|
elif key == 'F6':
|
||||||
self.start_activity('org.sugar.Terminal')
|
self.start_activity('org.sugar.Terminal')
|
||||||
|
elif key == 'F9':
|
||||||
|
self._show_hide_activity_chat()
|
||||||
|
|
||||||
def __global_key_released_cb(self, grabber, key):
|
def __global_key_released_cb(self, grabber, key):
|
||||||
if key == 'F5':
|
if key == 'F5':
|
||||||
@ -147,3 +150,17 @@ class Shell(gobject.GObject):
|
|||||||
if host.get_id() == activity_id:
|
if host.get_id() == activity_id:
|
||||||
return host
|
return host
|
||||||
return None
|
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:
|
if self._mode == Frame.TEMPORARY:
|
||||||
self._timeline.play('before_slide_out', 'slide_out')
|
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:
|
if not self._windows[0].props.visible:
|
||||||
for panel in self._windows:
|
for panel in self._windows:
|
||||||
panel.show()
|
panel.show()
|
||||||
self._event_frame.hide()
|
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:
|
if self._windows[0].props.visible:
|
||||||
for panel in self._windows:
|
for panel in self._windows:
|
||||||
panel.hide()
|
panel.hide()
|
||||||
self._event_frame.show()
|
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.Emoticons import Emoticons
|
||||||
from sugar.chat.ChatToolbar import ChatToolbar
|
from sugar.chat.ChatToolbar import ChatToolbar
|
||||||
from sugar.chat.ChatEditor import ChatEditor
|
from sugar.chat.ChatEditor import ChatEditor
|
||||||
from sugar.presence.PresenceService import PresenceService
|
from sugar.presence import PresenceService
|
||||||
import richtext
|
import richtext
|
||||||
|
|
||||||
PANGO_SCALE = 1024 # Where is this defined?
|
PANGO_SCALE = 1024 # Where is this defined?
|
||||||
@ -29,7 +29,7 @@ class Chat(gtk.VBox):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
gtk.VBox.__init__(self, False, 6)
|
gtk.VBox.__init__(self, False, 6)
|
||||||
|
|
||||||
self._pservice = PresenceService()
|
self._pservice = PresenceService.get_instance()
|
||||||
|
|
||||||
self._stream_writer = None
|
self._stream_writer = None
|
||||||
self.set_border_width(12)
|
self.set_border_width(12)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import gtk
|
import gtk, gobject
|
||||||
|
|
||||||
from sugar.chat.Emoticons import Emoticons
|
from sugar.chat.Emoticons import Emoticons
|
||||||
from sugar.chat.sketchpad.Toolbox import Toolbox
|
from sugar.chat.sketchpad.Toolbox import Toolbox
|
||||||
@ -82,8 +82,11 @@ class ChatToolbar(gtk.HBox):
|
|||||||
|
|
||||||
for name in Emoticons.get_instance().get_all():
|
for name in Emoticons.get_instance().get_all():
|
||||||
icon_theme = gtk.icon_theme_get_default()
|
icon_theme = gtk.icon_theme_get_default()
|
||||||
|
try:
|
||||||
pixbuf = icon_theme.load_icon(name, 16, 0)
|
pixbuf = icon_theme.load_icon(name, 16, 0)
|
||||||
model.append([pixbuf, name])
|
model.append([pixbuf, name])
|
||||||
|
except gobject.GError:
|
||||||
|
pass
|
||||||
|
|
||||||
icon_view = gtk.IconView(model)
|
icon_view = gtk.IconView(model)
|
||||||
icon_view.connect('selection-changed', self.__emoticon_selection_changed_cb)
|
icon_view.connect('selection-changed', self.__emoticon_selection_changed_cb)
|
||||||
|
Loading…
Reference in New Issue
Block a user