-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f17885a
Showing
11 changed files
with
727 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Set default behaviour, in case users don't have core.autocrlf set. | ||
* text=auto | ||
|
||
# Try to ensure that po files in the repo does not include | ||
# source code line numbers. | ||
# Every person expected to commit po files should change their personal config file as described here: | ||
# https://mail.gnome.org/archives/kupfer-list/2010-June/msg00002.html | ||
*.po filter=cleanpo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
addon/doc/*.css | ||
addon/doc/en/ | ||
*_docHandler.py | ||
*.html | ||
*.ini | ||
*.mo | ||
*.pot | ||
*.py[co] | ||
*.nvda-addon | ||
.sconsign.dblite |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#appModules/unigram.py | ||
# Copyright (C) 2020 beqa gozalishvili <[email protected]> | ||
#This file is covered by the GNU General Public License. | ||
#See the file COPYING for more details. | ||
|
||
import addonHandler | ||
import api | ||
import appModuleHandler | ||
import controlTypes | ||
from NVDAObjects.UIA import UIA | ||
import ui | ||
|
||
addonHandler.initTranslation() | ||
|
||
class AppModule(appModuleHandler.AppModule): | ||
|
||
def event_NVDAObject_init(self, obj): | ||
if not isinstance(obj, UIA): return | ||
try: | ||
if obj.UIAElement.CachedClassName == 'Hyperlink' and obj.UIAElement.CachedAutomationId == 'Button' and obj.next.role == controlTypes.ROLE_PROGRESSBAR: | ||
obj.name = _("Play") | ||
if obj.UIAElement.CachedClassName == 'ToggleButton': | ||
return | ||
if obj.role == controlTypes.ROLE_LISTITEM: | ||
if obj.parent.UIAElement.CurrentAutomationId == "Messages": | ||
return | ||
elif obj.parent.UIAElement.CurrentAutomationId == "ScrollingFiles" or obj.parent.UIAElement.CurrentAutomationId == "ScrollingLinks" or obj.parent.UIAElement.CurrentAutomationId == "ScrollingHost" or obj.parent.UIAElement.CurrentAutomationId == "ScrollingMedia" or obj.parent.UIAElement.CurrentAutomationId == "ScrollingMusic" or obj.parent.UIAElement.CurrentAutomationId == "ScrollingVoice" or obj.parent.UIAElement.CurrentAutomationId == "DialogsSearchListView" or obj.lastChild.UIAElement.CurrentAutomationId == "Label": | ||
name = [] | ||
for i in obj.children: | ||
name.append(i.name) | ||
obj.name = ", ".join(name) | ||
except AttributeError: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# -*- coding: UTF-8 -*- | ||
|
||
# Build customizations | ||
# Change this file instead of sconstruct or manifest files, whenever possible. | ||
|
||
# Full getext (please don't change) | ||
_ = lambda x: x | ||
|
||
# Add-on information variables | ||
addon_info = { | ||
# for previously unpublished addons, please follow the community guidelines at: | ||
# https://bitbucket.org/nvdaaddonteam/todo/raw/master/guidelines.txt | ||
# add-on Name, internal for nvda | ||
"addon_name": "unigramAccess", | ||
# Add-on summary, usually the user visible name of the addon. | ||
# Translators: Summary for this add-on to be shown on installation and add-on information. | ||
"addon_summary": _("Unigram-access - makes unigram application more accessible"), | ||
# Add-on description | ||
# Translators: Long description to be shown for this add-on on add-on information from add-ons manager | ||
"addon_description": _("""this addon adds possibility to make unigram application more accessible."""), | ||
# version | ||
"addon_version": "0.1", | ||
# Author(s) | ||
"addon_author": u"Beqa Gozalishvili <[email protected]>", | ||
# URL for the add-on documentation support | ||
"addon_url": "https://gozaltech.org/unigram-access", | ||
# Documentation file name | ||
"addon_docFileName": "readme.html", | ||
# Minimum NVDA version supported (e.g. "2018.3.0", minor version is optional) | ||
"addon_minimumNVDAVersion": "2019.3.0", | ||
# Last NVDA version supported/tested (e.g. "2018.4.0", ideally more recent than minimum version) | ||
"addon_lastTestedNVDAVersion": "2020.1.0", | ||
# Add-on update channel (default is None, denoting stable releases, and for development releases, use "dev"; do not change unless you know what you are doing) | ||
"addon_updateChannel": None, | ||
} | ||
|
||
|
||
import os.path | ||
|
||
# Define the python files that are the sources of your add-on. | ||
# You can use glob expressions here, they will be expanded. | ||
pythonSources = [] | ||
|
||
# Files that contain strings for translation. Usually your python sources | ||
i18nSources = pythonSources + ["buildVars.py"] | ||
|
||
# Files that will be ignored when building the nvda-addon file | ||
# Paths are relative to the addon directory, not to the root directory of your addon sources. | ||
excludedFiles = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
summary = "{addon_summary}" | ||
description = """{addon_description}""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name = {addon_name} | ||
summary = "{addon_summary}" | ||
description = """{addon_description}""" | ||
author = "{addon_author}" | ||
url = {addon_url} | ||
version = {addon_version} | ||
docFileName = {addon_docFileName} | ||
minimumNVDAVersion = {addon_minimumNVDAVersion} | ||
lastTestedNVDAVersion = {addon_lastTestedNVDAVersion} | ||
updateChannel = {addon_updateChannel} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# NVDA Add-on for Unigram application # | ||
|
||
Copyright (C) 2020 Beqa Gozalishvili. | ||
|
||
This addon make a unigram (telegram client for windows 10) more accessible by correcting information in several listviews and labeling unlabeled controls. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,195 @@ | ||
# NVDA add-on template SCONSTRUCT file | ||
# Copyright (C) 2012-2020 Rui Batista, Noelia Martinez, Joseph Lee | ||
# This file is covered by the GNU General Public License. | ||
# See the file COPYING.txt for more details. | ||
|
||
import codecs | ||
import gettext | ||
import os | ||
import os.path | ||
import zipfile | ||
import sys | ||
sys.dont_write_bytecode = True | ||
|
||
import buildVars | ||
|
||
def md2html(source, dest): | ||
import markdown | ||
lang = os.path.basename(os.path.dirname(source)).replace('_', '-') | ||
title="{addonSummary} {addonVersion}".format(addonSummary=buildVars.addon_info["addon_summary"], addonVersion=buildVars.addon_info["addon_version"]) | ||
headerDic = { | ||
"[[!meta title=\"": "# ", | ||
"\"]]": " #", | ||
} | ||
with codecs.open(source, "r", "utf-8") as f: | ||
mdText = f.read() | ||
for k, v in headerDic.items(): | ||
mdText = mdText.replace(k, v, 1) | ||
htmlText = markdown.markdown(mdText) | ||
with codecs.open(dest, "w", "utf-8") as f: | ||
f.write("<!DOCTYPE html>\n" + | ||
"<html lang=\"%s\">\n" % lang + | ||
"<head>\n" + | ||
"<meta charset=\"UTF-8\">\n" + | ||
"<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n" + | ||
"<link rel=\"stylesheet\" type=\"text/css\" href=\"../style.css\" media=\"screen\">\n" + | ||
"<title>%s</title>\n" % title + | ||
"</head>\n<body>\n" | ||
) | ||
f.write(htmlText) | ||
f.write("\n</body>\n</html>") | ||
|
||
def mdTool(env): | ||
mdAction=env.Action( | ||
lambda target,source,env: md2html(source[0].path, target[0].path), | ||
lambda target,source,env: 'Generating %s'%target[0], | ||
) | ||
mdBuilder=env.Builder( | ||
action=mdAction, | ||
suffix='.html', | ||
src_suffix='.md', | ||
) | ||
env['BUILDERS']['markdown']=mdBuilder | ||
|
||
vars = Variables() | ||
vars.Add("version", "The version of this build", buildVars.addon_info["addon_version"]) | ||
vars.Add(BoolVariable("dev", "Whether this is a daily development version", False)) | ||
vars.Add("channel", "Update channel for this build", buildVars.addon_info["addon_updateChannel"]) | ||
|
||
env = Environment(variables=vars, ENV=os.environ, tools=['gettexttool', mdTool]) | ||
env.Append(**buildVars.addon_info) | ||
|
||
if env["dev"]: | ||
import datetime | ||
buildDate = datetime.datetime.now() | ||
year, month, day = str(buildDate.year), str(buildDate.month), str(buildDate.day) | ||
env["addon_version"] = "".join([year, month.zfill(2), day.zfill(2), "-dev"]) | ||
env["channel"] = "dev" | ||
elif env["version"] is not None: | ||
env["addon_version"] = env["version"] | ||
if "channel" in env and env["channel"] is not None: | ||
env["addon_updateChannel"] = env["channel"] | ||
|
||
buildVars.addon_info["addon_version"] = env["addon_version"] | ||
buildVars.addon_info["addon_updateChannel"] = env["addon_updateChannel"] | ||
|
||
addonFile = env.File("${addon_name}-${addon_version}.nvda-addon") | ||
|
||
def addonGenerator(target, source, env, for_signature): | ||
action = env.Action(lambda target, source, env : createAddonBundleFromPath(source[0].abspath, target[0].abspath) and None, | ||
lambda target, source, env : "Generating Addon %s" % target[0]) | ||
return action | ||
|
||
def manifestGenerator(target, source, env, for_signature): | ||
action = env.Action(lambda target, source, env : generateManifest(source[0].abspath, target[0].abspath) and None, | ||
lambda target, source, env : "Generating manifest %s" % target[0]) | ||
return action | ||
|
||
def translatedManifestGenerator(target, source, env, for_signature): | ||
dir = os.path.abspath(os.path.join(os.path.dirname(str(source[0])), "..")) | ||
lang = os.path.basename(dir) | ||
action = env.Action(lambda target, source, env : generateTranslatedManifest(source[1].abspath, lang, target[0].abspath) and None, | ||
lambda target, source, env : "Generating translated manifest %s" % target[0]) | ||
return action | ||
|
||
env['BUILDERS']['NVDAAddon'] = Builder(generator=addonGenerator) | ||
env['BUILDERS']['NVDAManifest'] = Builder(generator=manifestGenerator) | ||
env['BUILDERS']['NVDATranslatedManifest'] = Builder(generator=translatedManifestGenerator) | ||
|
||
def createAddonHelp(dir): | ||
docsDir = os.path.join(dir, "doc") | ||
if os.path.isfile("style.css"): | ||
cssPath = os.path.join(docsDir, "style.css") | ||
cssTarget = env.Command(cssPath, "style.css", Copy("$TARGET", "$SOURCE")) | ||
env.Depends(addon, cssTarget) | ||
if os.path.isfile("readme.md"): | ||
readmePath = os.path.join(docsDir, "en", "readme.md") | ||
readmeTarget = env.Command(readmePath, "readme.md", Copy("$TARGET", "$SOURCE")) | ||
env.Depends(addon, readmeTarget) | ||
|
||
def createAddonBundleFromPath(path, dest): | ||
""" Creates a bundle from a directory that contains an addon manifest file.""" | ||
basedir = os.path.abspath(path) | ||
with zipfile.ZipFile(dest, 'w', zipfile.ZIP_DEFLATED) as z: | ||
# FIXME: the include/exclude feature may or may not be useful. Also python files can be pre-compiled. | ||
for dir, dirnames, filenames in os.walk(basedir): | ||
relativePath = os.path.relpath(dir, basedir) | ||
for filename in filenames: | ||
pathInBundle = os.path.join(relativePath, filename) | ||
absPath = os.path.join(dir, filename) | ||
if pathInBundle not in buildVars.excludedFiles: z.write(absPath, pathInBundle) | ||
return dest | ||
|
||
def generateManifest(source, dest): | ||
addon_info = buildVars.addon_info | ||
with codecs.open(source, "r", "utf-8") as f: | ||
manifest_template = f.read() | ||
manifest = manifest_template.format(**addon_info) | ||
with codecs.open(dest, "w", "utf-8") as f: | ||
f.write(manifest) | ||
|
||
def generateTranslatedManifest(source, language, out): | ||
# No ugettext in Python 3. | ||
if sys.version_info.major == 2: | ||
_ = gettext.translation("nvda", localedir=os.path.join("addon", "locale"), languages=[language]).ugettext | ||
else: | ||
_ = gettext.translation("nvda", localedir=os.path.join("addon", "locale"), languages=[language]).gettext | ||
vars = {} | ||
for var in ("addon_summary", "addon_description"): | ||
vars[var] = _(buildVars.addon_info[var]) | ||
with codecs.open(source, "r", "utf-8") as f: | ||
manifest_template = f.read() | ||
result = manifest_template.format(**vars) | ||
with codecs.open(out, "w", "utf-8") as f: | ||
f.write(result) | ||
|
||
def expandGlobs(files): | ||
return [f for pattern in files for f in env.Glob(pattern)] | ||
|
||
addon = env.NVDAAddon(addonFile, env.Dir('addon')) | ||
|
||
langDirs = [f for f in env.Glob(os.path.join("addon", "locale", "*"))] | ||
|
||
#Allow all NVDA's gettext po files to be compiled in source/locale, and manifest files to be generated | ||
for dir in langDirs: | ||
poFile = dir.File(os.path.join("LC_MESSAGES", "nvda.po")) | ||
moFile=env.gettextMoFile(poFile) | ||
env.Depends(moFile, poFile) | ||
translatedManifest = env.NVDATranslatedManifest(dir.File("manifest.ini"), [moFile, os.path.join("manifest-translated.ini.tpl")]) | ||
env.Depends(translatedManifest, ["buildVars.py"]) | ||
env.Depends(addon, [translatedManifest, moFile]) | ||
|
||
pythonFiles = expandGlobs(buildVars.pythonSources) | ||
for file in pythonFiles: | ||
env.Depends(addon, file) | ||
|
||
#Convert markdown files to html | ||
createAddonHelp("addon") # We need at least doc in English and should enable the Help button for the add-on in Add-ons Manager | ||
for mdFile in env.Glob(os.path.join('addon', 'doc', '*', '*.md')): | ||
htmlFile = env.markdown(mdFile) | ||
env.Depends(htmlFile, mdFile) | ||
env.Depends(addon, htmlFile) | ||
|
||
# Pot target | ||
i18nFiles = expandGlobs(buildVars.i18nSources) | ||
gettextvars={ | ||
'gettext_package_bugs_address' : '[email protected]', | ||
'gettext_package_name' : buildVars.addon_info['addon_name'], | ||
'gettext_package_version' : buildVars.addon_info['addon_version'] | ||
} | ||
|
||
pot = env.gettextPotFile("${addon_name}.pot", i18nFiles, **gettextvars) | ||
env.Alias('pot', pot) | ||
env.Depends(pot, i18nFiles) | ||
mergePot = env.gettextMergePotFile("${addon_name}-merge.pot", i18nFiles, **gettextvars) | ||
env.Alias('mergePot', mergePot) | ||
env.Depends(mergePot, i18nFiles) | ||
|
||
# Generate Manifest path | ||
manifest = env.NVDAManifest(os.path.join("addon", "manifest.ini"), os.path.join("manifest.ini.tpl")) | ||
# Ensure manifest is rebuilt if buildVars is updated. | ||
env.Depends(manifest, "buildVars.py") | ||
|
||
env.Depends(addon, manifest) | ||
env.Default(addon) | ||
env.Clean (addon, ['.sconsign.dblite', 'addon/doc/en/']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
""" This tool allows generation of gettext .mo compiled files, pot files from source code files | ||
and pot files for merging. | ||
Three new builders are added into the constructed environment: | ||
- gettextMoFile: generates .mo file from .pot file using msgfmt. | ||
- gettextPotFile: Generates .pot file from source code files. | ||
- gettextMergePotFile: Creates a .pot file appropriate for merging into existing .po files. | ||
To properly configure get text, define the following variables: | ||
- gettext_package_bugs_address | ||
- gettext_package_name | ||
- gettext_package_version | ||
""" | ||
from SCons.Action import Action | ||
|
||
def exists(env): | ||
return True | ||
|
||
XGETTEXT_COMMON_ARGS = ( | ||
"--msgid-bugs-address='$gettext_package_bugs_address' " | ||
"--package-name='$gettext_package_name' " | ||
"--package-version='$gettext_package_version' " | ||
"-c -o $TARGET $SOURCES" | ||
) | ||
|
||
def generate(env): | ||
env.SetDefault(gettext_package_bugs_address="[email protected]") | ||
env.SetDefault(gettext_package_name="") | ||
env.SetDefault(gettext_package_version="") | ||
|
||
env['BUILDERS']['gettextMoFile']=env.Builder( | ||
action=Action("msgfmt -o $TARGET $SOURCE", "Compiling translation $SOURCE"), | ||
suffix=".mo", | ||
src_suffix=".po" | ||
) | ||
|
||
env['BUILDERS']['gettextPotFile']=env.Builder( | ||
action=Action("xgettext " + XGETTEXT_COMMON_ARGS, "Generating pot file $TARGET"), | ||
suffix=".pot") | ||
|
||
env['BUILDERS']['gettextMergePotFile']=env.Builder( | ||
action=Action("xgettext " + "--omit-header --no-location " + XGETTEXT_COMMON_ARGS, | ||
"Generating pot file $TARGET"), | ||
suffix=".pot") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
@charset "utf-8"; | ||
body { | ||
font-family : Verdana, Arial, Helvetica, Sans-serif; | ||
line-height: 1.2em; | ||
} | ||
h1, h2 {text-align: center} | ||
dt { | ||
font-weight : bold; | ||
float : left; | ||
width: 10%; | ||
clear: left | ||
} | ||
dd { | ||
margin : 0 0 0.4em 0; | ||
float : left; | ||
width: 90%; | ||
display: block; | ||
} | ||
p { clear : both; | ||
} | ||
a { text-decoration : underline; | ||
} | ||
:active { | ||
text-decoration : none; | ||
} | ||
a:focus, a:hover {outline: solid} |