From cb00582b145d89c80df0849a08c09dbbd77cd32c Mon Sep 17 00:00:00 2001 From: Aleksey Lim Date: Fri, 06 Feb 2009 17:44:34 +0000 Subject: Add mute button to chat tab --- diff --git a/Speak.activity/activity.py b/Speak.activity/activity.py index 06f3535..2e503dc 100755 --- a/Speak.activity/activity.py +++ b/Speak.activity/activity.py @@ -42,8 +42,7 @@ import fft_mouth import waveform_mouth import voice import face -from toolbars import ChatToolbar -from chat import Chat +import chat from collab import CollabActivity from messenger import Messenger, SERVICE @@ -96,7 +95,7 @@ class SpeakActivity(CollabActivity): box.show_all() self.notebook.append_page(box) - self.chat = Chat() + self.chat = chat.View() self.chat.show_all() self.notebook.append_page(self.chat) @@ -115,7 +114,7 @@ class SpeakActivity(CollabActivity): toolbox.add_toolbar("Face", facebar) facebar.show() - chatbar = ChatToolbar() + chatbar = chat.Toolbar(self.chat) toolbox.add_toolbar(_('Chat'), chatbar) chatbar.show() diff --git a/Speak.activity/chat.py b/Speak.activity/chat.py index 9e707a4..f313dbc 100644 --- a/Speak.activity/chat.py +++ b/Speak.activity/chat.py @@ -16,9 +16,11 @@ import gtk import pango import hippo import logging +from gettext import gettext as _ import sugar.graphics.style as style from sugar.graphics.roundbox import CanvasRoundBox +from sugar.graphics.toggletoolbutton import ToggleToolButton import eye import glasses @@ -36,18 +38,36 @@ BUDDY_YPAD = 5 BUDDIES_WIDTH = int(BUDDY_SIZE * 2.5) BUDDIES_COLOR = style.COLOR_SELECTION_GREY -#COLOR_BUTTON_GREY ENTRY_COLOR = style.COLOR_PANEL_GREY ENTRY_XPAD = 0 ENTRY_YPAD = 7 -class Chat(hippo.Canvas): +class Toolbar(gtk.Toolbar): + def __init__(self, chat): + gtk.Toolbar.__init__(self) + self.chat = chat + + mute = ToggleToolButton('stock_volume-mute') + mute.set_tooltip(_('Mute')) + mute.connect('toggled', self._toggled_cb) + mute.show() + self.insert(mute, -1) + + def _toggled_cb(self, widget): + if widget.get_active(): + self.chat.quiet = True + self.chat.shut_up() + else: + self.chat.quiet = False + +class View(hippo.Canvas): def __init__(self): hippo.Canvas.__init__(self) self.messenger = None self.me = None + self.quiet = False self._buddies = {} self.connect('motion_notify_event', self._motion_notify_cb) @@ -136,7 +156,8 @@ class Chat(hippo.Canvas): lang_box.props.text = status.voice.friendlyname if text: self._chat.add_text(buddy, text) - if self.props.window and self.props.window.is_visible(): + if not self.quiet and self.props.window \ + and self.props.window.is_visible(): face.say(text) def farewell(self, buddy): @@ -202,7 +223,8 @@ class Chat(hippo.Canvas): if text: self._chat.add_text(None, text) widget.get_buffer().props.text = '' - self.me.say(text) + if not self.quiet: + self.me.say(text) if self.messenger: self.messenger.post(text) diff --git a/Speak.activity/messenger.py b/Speak.activity/messenger.py index 3de3fd3..5c84387 100644 --- a/Speak.activity/messenger.py +++ b/Speak.activity/messenger.py @@ -37,10 +37,6 @@ class Messenger(ExportedGObject): self._entered = False self._buddies = {} - self._tube.add_signal_receiver(self._ping_cb, '_ping', IFACE, path=PATH, - sender_keyword='sender') - self._tube.add_signal_receiver(self._post_cb, '_post', IFACE, path=PATH, - sender_keyword='sender') self._tube.watch_participants(self._participant_change_cb) def post(self, text): @@ -60,6 +56,12 @@ class Messenger(ExportedGObject): else: if not self._entered: self.me = self._tube.get_unique_name() + + self._tube.add_signal_receiver(self._ping_cb, '_ping', IFACE, path=PATH, + sender_keyword='sender') + self._tube.add_signal_receiver(self._post_cb, '_post', IFACE, path=PATH, + sender_keyword='sender') + if not self.is_initiator: self._ping(self.chat.me.status.serialize()) self._entered = True diff --git a/Speak.activity/toolbars.py b/Speak.activity/toolbars.py deleted file mode 100644 index 9aa5567..0000000 --- a/Speak.activity/toolbars.py +++ /dev/null @@ -1,28 +0,0 @@ -# Speak.activity -# A simple front end to the espeak text-to-speech engine on the XO laptop -# http://wiki.laptop.org/go/Speak -# -# Copyright (C) 2008 Joshua Minor -# This file is part of Speak.activity -# -# Parts of Speak.activity are based on code from Measure.activity -# Copyright (C) 2007 Arjun Sarwal - arjun@laptop.org -# -# Speak.activity is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Speak.activity is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Speak.activity. If not, see . - -import gtk - -class ChatToolbar(gtk.Toolbar): - def __init__(self): - gtk.Toolbar.__init__(self) -- cgit v0.9.1