[orca] Create generic switcher script and use it for all non-gnome-shell switchers
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Create generic switcher script and use it for all non-gnome-shell switchers
- Date: Wed, 6 Mar 2019 18:53:34 +0000 (UTC)
commit d15c3d99e48766b81785ff3c3c9c3e7048bbe8b6
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Wed Mar 6 19:48:43 2019 +0100
Create generic switcher script and use it for all non-gnome-shell switchers
configure.ac | 3 +-
src/orca/script_manager.py | 14 ++-
src/orca/scripts/Makefile.am | 2 +-
src/orca/scripts/apps/Makefile.am | 2 -
src/orca/scripts/apps/__init__.py | 2 -
.../scripts/apps/gtk-window-decorator/Makefile.am | 5 -
.../scripts/apps/gtk-window-decorator/__init__.py | 23 ----
.../scripts/apps/gtk-window-decorator/script.py | 97 ----------------
src/orca/scripts/apps/metacity/Makefile.am | 5 -
src/orca/scripts/apps/metacity/script.py | 118 -------------------
src/orca/scripts/switcher/Makefile.am | 6 +
.../{apps/metacity => switcher}/__init__.py | 2 +-
src/orca/scripts/switcher/script.py | 125 +++++++++++++++++++++
src/orca/scripts/switcher/script_utilities.py | 59 ++++++++++
14 files changed, 201 insertions(+), 262 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 1d720e364..5d46a4917 100644
--- a/configure.ac
+++ b/configure.ac
@@ -106,9 +106,7 @@ src/orca/scripts/apps/gnome-screensaver-dialog/Makefile
src/orca/scripts/apps/gnome-search-tool/Makefile
src/orca/scripts/apps/gnome-shell/Makefile
src/orca/scripts/apps/gnome-window-properties/Makefile
-src/orca/scripts/apps/gtk-window-decorator/Makefile
src/orca/scripts/apps/Instantbird/Makefile
-src/orca/scripts/apps/metacity/Makefile
src/orca/scripts/apps/notification-daemon/Makefile
src/orca/scripts/apps/notify-osd/Makefile
src/orca/scripts/apps/Mozilla/Makefile
@@ -119,6 +117,7 @@ src/orca/scripts/apps/SeaMonkey/Makefile
src/orca/scripts/apps/smuxi-frontend-gnome/Makefile
src/orca/scripts/apps/Thunderbird/Makefile
src/orca/scripts/apps/xfwm4/Makefile
+src/orca/scripts/switcher/Makefile
src/orca/scripts/terminal/Makefile
src/orca/scripts/web/Makefile
src/orca/scripts/toolkits/Makefile
diff --git a/src/orca/script_manager.py b/src/orca/script_manager.py
index 648f5a180..b58694d03 100644
--- a/src/orca/script_manager.py
+++ b/src/orca/script_manager.py
@@ -47,14 +47,16 @@ class ScriptManager:
"orca.scripts.apps",
"orca.scripts.toolkits"]
self._appNames = \
- {'Firefox': 'Mozilla',
- 'Icedove': 'Thunderbird',
- 'empathy-chat': 'empathy',
+ {'Firefox': 'Mozilla',
+ 'Icedove': 'Thunderbird',
+ 'Nereid': 'Banshee',
+ 'empathy-chat': 'empathy',
'gnome-calculator': 'gcalctool',
- 'marco': 'metacity',
- 'Nereid': 'Banshee',
+ 'gtk-window-decorator': 'switcher',
+ 'marco': 'switcher',
'mate-notification-daemon': 'notification-daemon',
- 'pluma': 'gedit',
+ 'metacity': 'switcher',
+ 'pluma': 'gedit',
}
self.setActiveScript(None, "__init__")
diff --git a/src/orca/scripts/Makefile.am b/src/orca/scripts/Makefile.am
index 60c4a4ac7..54614f6fc 100644
--- a/src/orca/scripts/Makefile.am
+++ b/src/orca/scripts/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = apps toolkits terminal web
+SUBDIRS = apps toolkits switcher terminal web
orca_python_PYTHON = \
__init__.py \
diff --git a/src/orca/scripts/apps/Makefile.am b/src/orca/scripts/apps/Makefile.am
index 787bf0e96..9df8aa38e 100644
--- a/src/orca/scripts/apps/Makefile.am
+++ b/src/orca/scripts/apps/Makefile.am
@@ -16,9 +16,7 @@ SUBDIRS = \
gnome-shell \
gnome-search-tool \
gnome-window-properties \
- gtk-window-decorator \
Instantbird \
- metacity \
notification-daemon \
notify-osd \
Mozilla \
diff --git a/src/orca/scripts/apps/__init__.py b/src/orca/scripts/apps/__init__.py
index c0ef25cb6..751692275 100644
--- a/src/orca/scripts/apps/__init__.py
+++ b/src/orca/scripts/apps/__init__.py
@@ -16,10 +16,8 @@ __all__ = ['Banshee',
'gnome-search-tool',
'gnome-shell',
'gnome-window-properties',
- 'gtk-window-decorator',
'Instantbird',
'liferea',
- 'metacity',
'Mozilla',
'notification-daemon',
'notify-osd',
diff --git a/src/orca/scripts/switcher/Makefile.am b/src/orca/scripts/switcher/Makefile.am
new file mode 100644
index 000000000..87650a401
--- /dev/null
+++ b/src/orca/scripts/switcher/Makefile.am
@@ -0,0 +1,6 @@
+orca_python_PYTHON = \
+ __init__.py \
+ script.py \
+ script_utilities.py
+
+orca_pythondir=$(pkgpythondir)/scripts/switcher
diff --git a/src/orca/scripts/apps/metacity/__init__.py b/src/orca/scripts/switcher/__init__.py
similarity index 93%
rename from src/orca/scripts/apps/metacity/__init__.py
rename to src/orca/scripts/switcher/__init__.py
index 7190f56c7..78e10f0a5 100644
--- a/src/orca/scripts/apps/metacity/__init__.py
+++ b/src/orca/scripts/switcher/__init__.py
@@ -17,7 +17,7 @@
# Free Software Foundation, Inc., Franklin Street, Fifth Floor,
# Boston MA 02110-1301 USA.
-"""Custom script for metacity."""
+"""Custom script for basic switchers like Metacity."""
from .script import Script
diff --git a/src/orca/scripts/switcher/script.py b/src/orca/scripts/switcher/script.py
new file mode 100644
index 000000000..22e7b8966
--- /dev/null
+++ b/src/orca/scripts/switcher/script.py
@@ -0,0 +1,125 @@
+# Orca
+#
+# Copyright 2019 Igalia, S.L.
+# Author: Joanmarie Diggs <jdiggs igalia com>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., Franklin Street, Fifth Floor,
+# Boston MA 02110-1301 USA.
+
+"""Custom script for basic switchers like Metacity."""
+
+__id__ = "$Id$"
+__version__ = "$Revision$"
+__date__ = "$Date$"
+__copyright__ = "Copyright (c) 2019 Igalia, S.L."
+__license__ = "LGPL"
+
+from orca import debug
+from orca import orca
+from orca import orca_state
+from orca.scripts import default
+
+from .script_utilities import Utilities
+
+
+class Script(default.Script):
+
+ def __init__(self, app):
+ """Creates a new script for the given application."""
+
+ super().__init__(app)
+
+ def getUtilities(self):
+ """Returns the utilites for this script."""
+
+ return Utilities(self)
+
+ def _handleSwitcherEvent(self, event):
+ """Presents the currently selected item, if appropriate."""
+
+ if not self.utilities.isSwitcherContainer(event.source):
+ msg = "SWITCHER: Event is not from switcher container"
+ debug.println(debug.LEVEL_INFO, msg, True)
+ return False
+
+ if not self.utilities.isSwitcherSelectionChangeEventType(event):
+ msg = "SWITCHER: Not treating event as selection change."
+ debug.println(debug.LEVEL_INFO, msg, True)
+ return True
+
+ msg = "SWITCHER: Treating event as selection change"
+ debug.println(debug.LEVEL_INFO, msg, True)
+
+ self.presentationInterrupt()
+ orca_state.activeWindow = self.utilities.topLevelObject(event.source)
+ orca.setLocusOfFocus(event, event.source, False)
+ self.presentMessage(self.utilities.getSelectionName(event.source))
+ return True
+
+ def onNameChanged(self, event):
+ """Callback for object:property-change:accessible-name events."""
+
+ if self._handleSwitcherEvent(event):
+ return
+
+ super().onNameChanged(event)
+
+ def onSelectedChanged(self, event):
+ """Callback for object:state-changed:selected accessibility events."""
+
+ if self._handleSwitcherEvent(event):
+ return
+
+ super().onSelectedChanged(event)
+
+ def onSelectionChanged(self, event):
+ """Callback for object:selection-changed accessibility events."""
+
+ if self._handleSwitcherEvent(event):
+ return
+
+ super().onSelectionChanged(event)
+
+ def onShowingChanged(self, event):
+ """Callback for object:state-changed:showing accessibility events."""
+
+ if self._handleSwitcherEvent(event):
+ return
+
+ super().onShowingChanged(event)
+
+ def onCaretMoved(self, event):
+ """Callback for object:text-caret-moved accessibility events."""
+
+ if self._handleSwitcherEvent(event):
+ return
+
+ super().onCaretMoved(event)
+
+ def onTextDeleted(self, event):
+ """Callback for object:text-changed:delete accessibility events."""
+
+ if self._handleSwitcherEvent(event):
+ return
+
+ super().onTextDeleted(event)
+
+ def onTextInserted(self, event):
+ """Callback for object:text-changed:insert accessibility events."""
+
+ if self._handleSwitcherEvent(event):
+ return
+
+ super().onTextInserted(event)
diff --git a/src/orca/scripts/switcher/script_utilities.py b/src/orca/scripts/switcher/script_utilities.py
new file mode 100644
index 000000000..c0d26fdf9
--- /dev/null
+++ b/src/orca/scripts/switcher/script_utilities.py
@@ -0,0 +1,59 @@
+# Orca
+#
+# Copyright 2019 Igalia, S.L.
+# Author: Joanmarie Diggs <jdiggs igalia com>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., Franklin Street, Fifth Floor,
+# Boston MA 02110-1301 USA.
+
+__id__ = "$Id$"
+__version__ = "$Revision$"
+__date__ = "$Date$"
+__copyright__ = "Copyright (c) 2019 Igalia, S.L."
+__license__ = "LGPL"
+
+import pyatspi
+
+from orca import script_utilities
+
+
+class Utilities(script_utilities.Utilities):
+
+ def __init__(self, script):
+ super().__init__(script)
+
+ def isSwitcherContainer(self, obj):
+ """Returns True if obj is the switcher container."""
+
+ return obj and obj.getRole() == pyatspi.ROLE_STATUS_BAR
+
+ def isSwitcherSelectionChangeEventType(self, event):
+ """Returns True if this event is the one we use to present changes."""
+
+ if event.type.startswith("object:text-changed:insert"):
+ return True
+
+ if event.type.startswith("object:state-changed:showing"):
+ return event.detail1
+
+ return False
+
+ def getSelectionName(self, container):
+ """Returns the name of the currently-selected item."""
+
+ if self.isSwitcherContainer(container):
+ return container.name
+
+ return ""
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]