orca r3863 - in trunk: . src/orca/scripts
- From: richb svn gnome org
- To: svn-commits-list gnome org
- Subject: orca r3863 - in trunk: . src/orca/scripts
- Date: Tue, 29 Apr 2008 17:19:05 +0100 (BST)
Author: richb
Date: Tue Apr 29 16:19:04 2008
New Revision: 3863
URL: http://svn.gnome.org/viewvc/orca?rev=3863&view=rev
Log:
* src/orca/scripts/gaim.py:
Fix for bug #474673 - Add option to have chatroom-specific message
histories in Pidgin.
Modified:
trunk/ChangeLog
trunk/src/orca/scripts/gaim.py
Modified: trunk/src/orca/scripts/gaim.py
==============================================================================
--- trunk/src/orca/scripts/gaim.py (original)
+++ trunk/src/orca/scripts/gaim.py Tue Apr 29 16:19:04 2008
@@ -59,6 +59,10 @@
#
announceBuddyTyping = False
+# Whether we provide chat room specific message histories.
+#
+chatRoomHistories = False
+
# Possible ways of how Orca should speak pidgin chat messages.
#
SPEAK_ALL_MESSAGES = 0
@@ -330,14 +334,21 @@
# chat room messages and the other that will contain the names
# of the associated chat rooms.
#
- self.previousMessages = RingList(Script.MESSAGE_LIST_LENGTH)
+ self.allPreviousMessages = RingList(Script.MESSAGE_LIST_LENGTH)
self.previousChatRoomNames = RingList(Script.MESSAGE_LIST_LENGTH)
+ # Create a dictionary that will be used to contain chat room
+ # specific message histories. The key will be the chat room
+ # name and the value will be a cyclic list of previous messages
+ # for that chat room.
+ #
+ self.chatRoomMessages = {}
+
# Initially populate the cyclic lists with empty strings.
#
i = 0
- while i < self.previousMessages.maxsize():
- self.previousMessages.append("")
+ while i < self.allPreviousMessages.maxsize():
+ self.allPreviousMessages.append("")
i += 1
i = 0
@@ -366,6 +377,7 @@
self.allChannelsRadioButton = None
self.allMessagesRadioButton = None
self.buddyTypingCheckButton = None
+ self.chatRoomHistoriesCheckButton = None
default.Script.__init__(self, app)
@@ -400,6 +412,12 @@
Script.toggleBuddyTyping,
_("Toggle whether we announce when our buddies are typing."))
+ self.inputEventHandlers["toggleMessageHistoriesHandler"] = \
+ input_event.InputEventHandler(
+ Script.toggleMessageHistories,
+ _("Toggle whether we provide chat room specific message " \
+ "histories."))
+
# Add the chat room message history event handler.
#
self.inputEventHandlers["reviewMessage"] = \
@@ -432,6 +450,13 @@
None,
self.inputEventHandlers["toggleBuddyTypingHandler"]))
+ keyBindings.add(
+ keybindings.KeyBinding(
+ "",
+ None,
+ None,
+ self.inputEventHandlers["toggleMessageHistoriesHandler"]))
+
# keybindings to provide chat room message history.
#
messageKeys = [ "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9" ]
@@ -486,6 +511,19 @@
gtk.ToggleButton.set_active(self.buddyTypingCheckButton,
announceBuddyTyping)
+ # Translators: If this checkbox is checked, then Orca will provide
+ # the user with chat room specific message histories rather than just
+ # a single history which contains the latest messages from all the
+ # chat rooms that they are currently in.
+ #
+ label = _("Provide chat room specific _message histories")
+ self.chatRoomHistoriesCheckButton = gtk.CheckButton(label)
+ gtk.Widget.show(self.chatRoomHistoriesCheckButton)
+ gtk.Box.pack_start(vbox, self.chatRoomHistoriesCheckButton,
+ False, False, 0)
+ gtk.ToggleButton.set_active(self.chatRoomHistoriesCheckButton,
+ chatRoomHistories)
+
# "Speak Messages" frame.
#
messagesFrame = gtk.Frame()
@@ -557,7 +595,8 @@
- prefs: file handle for application preferences.
"""
- global announceBuddyTyping, prefixChatMessage, speakMessages
+ global announceBuddyTyping, chatRoomHistories
+ global prefixChatMessage, speakMessages
prefixChatMessage = self.speakNameCheckButton.get_active()
prefs.writelines("\n")
@@ -568,6 +607,10 @@
prefs.writelines("orca.scripts.gaim.announceBuddyTyping = %s\n" % \
announceBuddyTyping)
+ chatRoomHistories = self.chatRoomHistoriesCheckButton.get_active()
+ prefs.writelines("orca.scripts.gaim.chatRoomHistories = %s\n" % \
+ chatRoomHistories)
+
if self.allMessagesRadioButton.get_active():
speakMessages = SPEAK_ALL_MESSAGES
option = "orca.scripts.gaim.SPEAK_ALL_MESSAGES"
@@ -585,8 +628,9 @@
object will be use by setAppState to restore any state information
that was being maintained by the script."""
return [default.Script.getAppState(self),
- self.previousMessages,
+ self.allPreviousMessages,
self.previousChatRoomNames,
+ self.chatRoomMessages,
self.chatAreas]
def setAppState(self, appState):
@@ -597,8 +641,9 @@
"""
try:
[defaultAppState,
- self.previousMessages,
+ self.allPreviousMessages,
self.previousChatRoomNames,
+ self.chatRoomMessages,
self.chatAreas] = appState
default.Script.setAppState(self, defaultAppState)
except:
@@ -645,6 +690,26 @@
return True
+ def toggleMessageHistories(self, inputEvent):
+ """ Toggle whether we provide chat room specific message histories.
+
+ Arguments:
+ - inputEvent: if not None, the input event that caused this action.
+ """
+
+ global chatRoomHistories
+
+ debug.println(self.debugLevel, "gaim.toggleMessageHistories.")
+
+ line = _("Provide chat room specific message histories.")
+ chatRoomHistories = not chatRoomHistories
+ if not chatRoomHistories:
+ line = _("Do not provide chat room specific message histories.")
+
+ speech.speak(line)
+
+ return True
+
def utterMessage(self, chatRoomName, message, hasFocus=True):
""" Speak/braille a chat room message.
@@ -686,12 +751,18 @@
i = int(inputEvent.event_string[1:])
messageNo = Script.MESSAGE_LIST_LENGTH - i
- chatRoomNames = self.previousChatRoomNames.get()
- chatRoomName = chatRoomNames[messageNo]
+ if chatRoomHistories:
+ chatRoomTab = self.getChatRoomTab(orca_state.locusOfFocus)
+ chatRoomName = self.getDisplayedText(chatRoomTab)
+ if not chatRoomName in self.chatRoomMessages:
+ return
+ messages = self.chatRoomMessages[chatRoomName].get()
+ else:
+ chatRoomNames = self.previousChatRoomNames.get()
+ chatRoomName = chatRoomNames[messageNo]
+ messages = self.allPreviousMessages.get()
- messages = self.previousMessages.get()
message = messages[messageNo]
-
self.utterMessage(chatRoomName, message)
def getChatRoomTab(self, obj):
@@ -844,7 +915,7 @@
# children-changed events and clean up in that.]]]
#
chatArea = None
- if not self.chatAreas.has_key(chatRoomTab):
+ if not chatRoomTab in self.chatAreas:
# Different message types (AIM, IRC ...) have a different
# component hierarchy for their chat rooms. By testing
# with AIM and IRC, we've found that the messages area for
@@ -862,6 +933,19 @@
else:
chatArea = self.chatAreas[chatRoomTab]
+ # Create a new cyclic message list for this chat room name
+ # (if one doesn't already exist) and populate it with empty
+ # strings.
+ #
+ chatRoomName = self.getDisplayedText(chatRoomTab)
+ if not chatRoomName in self.chatRoomMessages:
+ self.chatRoomMessages[chatRoomName] = \
+ RingList(Script.MESSAGE_LIST_LENGTH)
+ i = 0
+ while i < self.chatRoomMessages[chatRoomName].maxsize():
+ self.chatRoomMessages[chatRoomName].append("")
+ i += 1
+
if event.source and (event.source == chatArea):
# We always automatically go back to focus tracking mode when
# someone sends us a message.
@@ -906,9 +990,13 @@
# We don't want to do this for the status messages however.
#
if not self.lastStatus:
- self.previousMessages.append(message)
+ chatRoomName = self.getDisplayedText(chatRoomTab)
+
+ self.allPreviousMessages.append(message)
self.previousChatRoomNames.append(chatRoomName)
+ self.chatRoomMessages[chatRoomName].append(message)
+
elif isinstance(orca_state.lastInputEvent, input_event.KeyboardEvent) \
and orca_state.lastNonModifierKeyEvent \
and (orca_state.lastNonModifierKeyEvent.event_string == "Tab") \
@@ -960,7 +1048,10 @@
if not self.isInBuddyList(obj):
return default.Script.getNodeLevel(self, obj)
- obj = obj.parent[obj.getIndexInParent() - 1]
+ try:
+ obj = obj.parent[obj.getIndexInParent() - 1]
+ except:
+ return -1
try:
table = obj.parent.queryTable()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]