diff -Nru unity-scope-keyboard-0.1/debian/bzr-builder.manifest unity-scope-keyboard-0.1/debian/bzr-builder.manifest --- unity-scope-keyboard-0.1/debian/bzr-builder.manifest 2013-11-12 10:34:41.000000000 +0000 +++ unity-scope-keyboard-0.1/debian/bzr-builder.manifest 2013-12-16 04:14:39.000000000 +0000 @@ -1,2 +1,2 @@ -# bzr-builder format 0.3 deb-version {debupstream}-0~2 -lp:unity-scope-keyboard revid:markjtully@gmail.com-20131112025600-1fh5z60a3ke5gvtn +# bzr-builder format 0.3 deb-version {debupstream}-0~7 +lp:unity-scope-keyboard revid:markjtully@gmail.com-20131216013301-wfwaf8pb102llhdb diff -Nru unity-scope-keyboard-0.1/debian/changelog unity-scope-keyboard-0.1/debian/changelog --- unity-scope-keyboard-0.1/debian/changelog 2013-11-12 10:34:41.000000000 +0000 +++ unity-scope-keyboard-0.1/debian/changelog 2013-12-16 04:14:39.000000000 +0000 @@ -1,8 +1,8 @@ -unity-scope-keyboard (0.1-0~2~ubuntu13.10.1) saucy; urgency=low +unity-scope-keyboard (0.1-0~7~ubuntu13.10.1) saucy; urgency=low * Auto build. - -- Mark Tully Tue, 12 Nov 2013 10:34:41 +0000 + -- Mark Tully Mon, 16 Dec 2013 04:14:39 +0000 unity-scope-keyboard (0.1) UNRELEASED; urgency=low diff -Nru unity-scope-keyboard-0.1/debian/control unity-scope-keyboard-0.1/debian/control --- unity-scope-keyboard-0.1/debian/control 2013-11-12 10:34:41.000000000 +0000 +++ unity-scope-keyboard-0.1/debian/control 2013-12-16 04:14:39.000000000 +0000 @@ -32,6 +32,10 @@ gir1.2-gtk-3.0, unicode-data, ttf-ubuntu-font-family, +Suggests: ttf-indic-fonts-core, + fonts-freefont-ttf, + ttf-unifont, + ttf-wqy-microhei, Description: Keyboard scope for Unity This package contains the 'keyboard' scope which allows Unity to search for Keyboard results. diff -Nru unity-scope-keyboard-0.1/po/unity-scope-keyboard.pot unity-scope-keyboard-0.1/po/unity-scope-keyboard.pot --- unity-scope-keyboard-0.1/po/unity-scope-keyboard.pot 2013-11-12 10:34:41.000000000 +0000 +++ unity-scope-keyboard-0.1/po/unity-scope-keyboard.pot 2013-12-16 04:14:39.000000000 +0000 @@ -3,13 +3,13 @@ # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # -#: ../src/unity_keyboard_daemon.py:38 +#: ../src/unity_keyboard_daemon.py:54 #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-11-12 02:54+0000\n" +"POT-Creation-Date: 2013-11-19 16:25+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -18,110 +18,470 @@ "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: ../src/unity_keyboard_daemon.py:36 ../data/keyboard.scope.in.h:4 +#: ../src/unity_keyboard_daemon.py:39 +msgid "Ubuntu-R" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:40 +msgid "Sans" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:41 +msgid "Serif" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:42 +msgid "Microhei" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:43 +msgid "Lohit Bengali" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:44 +msgid "Lohit Gujarati" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:45 +msgid "Lohit Hindi" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:46 +msgid "Lohit Tamil" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:47 +msgid "Kedage" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:48 +msgid "Meera" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:49 +msgid "Pothana" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:50 +msgid "Uktal" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:51 +msgid "Unifont" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:52 ../data/keyboard.scope.in.h:4 msgid "Search Keyboard" msgstr "" -#: ../src/unity_keyboard_daemon.py:37 +#: ../src/unity_keyboard_daemon.py:53 msgid "Sorry, there are no Keyboard results that match your search." msgstr "" -#: ../src/unity_keyboard_daemon.py:46 +#: ../src/unity_keyboard_daemon.py:64 msgid "Result" msgstr "" -#: ../src/unity_keyboard_daemon.py:301 +#: ../src/unity_keyboard_daemon.py:119 +msgid "Letter, Uppercase" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:120 +msgid "Letter, Lowercase" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:121 +msgid "Letter, Titlecase" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:122 +msgid "Letter, Modifier" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:123 +msgid "Letter, Other" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:124 +msgid "Mark, Non-Spacing" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:125 +msgid "Mark, Spacing Combining" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:126 +msgid "Mark, Enclosing" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:127 +msgid "Number, Decimal Digit" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:128 +msgid "Number, Letter" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:129 +msgid "Number, Other" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:130 +msgid "Punctuation, Connector" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:131 +msgid "Punctuation, Dash" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:132 +msgid "Punctuation, Open" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:133 +msgid "Punctuation, Close" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:134 +msgid "Punctuation, Initial quote" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:135 +msgid "Punctuation, Final quote" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:136 +msgid "Punctuation, Other" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:137 +msgid "Symbol, Math" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:138 +msgid "Symbol, Currency" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:139 +msgid "Symbol, Modifier" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:140 +msgid "Symbol, Other" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:141 +msgid "Separator, Space" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:142 +msgid "Separator, Line" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:143 +msgid "Separator, Paragraph" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:144 +msgid "Other, Control" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:145 +msgid "Other, Format" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:146 +msgid "Other, Surrogate" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:147 +msgid "Other, Private Use" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:148 +msgid "Other, Not Assigned" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:150 +msgid "Spacing, split, enclosing, reordrant, and Tibetan subjoined" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:151 +msgid "Overlays and interior" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:152 +msgid "Nuktas" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:153 +msgid "Hiragana/Katakana voicing marks" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:154 +msgid "Viramas" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:155 +msgid "Start of fixed position classes" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:156 +msgid "End of fixed position classes" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:157 +msgid "Below left attached" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:158 +msgid "Below attached" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:159 +msgid "Below right attached" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:160 +msgid "Left attached (reordrant around single base character)" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:161 +msgid "Right attached" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:162 +msgid "Above left attached" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:163 +msgid "Above attached" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:164 +msgid "Above right attached" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:165 +msgid "Below left" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:166 +msgid "Below" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:167 +msgid "Below right" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:168 +msgid "Left (reordrant around single base character)" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:169 +msgid "Right" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:170 +msgid "Above left" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:171 +msgid "Above" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:172 +msgid "Above right" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:173 +msgid "Double below" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:174 +msgid "Double above" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:175 +msgid "Below (iota subscript)" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:177 +msgid "Left-to-Right" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:178 +msgid "Left-to-Right Embedding" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:179 +msgid "Left-to-Right Override" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:180 +msgid "Right-to-Left" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:181 +msgid "Right-to-Left Arabic" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:182 +msgid "Right-to-Left Embedding" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:183 +msgid "Right-to-Left Override" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:184 +msgid "Pop Directional Format" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:185 +msgid "European Number" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:186 +msgid "European Number Separator" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:187 +msgid "European Number Terminator" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:188 +msgid "Arabic Number" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:189 +msgid "Common Number Separator" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:190 +msgid "Non-Spacing Mark" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:191 +msgid "Boundary Neutral" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:192 +msgid "Paragraph Separator" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:193 +msgid "Segment Separator" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:194 +msgid "Whitespace" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:195 +msgid "Other Neutrals" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:366 #, python-format msgid "(ctrl + shift + U) + %s + space" msgstr "" -#: ../src/unity_keyboard_daemon.py:302 +#: ../src/unity_keyboard_daemon.py:367 #, python-format msgid "Category: %s" msgstr "" -#: ../src/unity_keyboard_daemon.py:304 +#: ../src/unity_keyboard_daemon.py:369 #, python-format msgid "" "\n" "Combining: %s" msgstr "" -#: ../src/unity_keyboard_daemon.py:306 +#: ../src/unity_keyboard_daemon.py:371 #, python-format msgid "" "\n" "Bidirectional: %s" msgstr "" -#: ../src/unity_keyboard_daemon.py:314 +#: ../src/unity_keyboard_daemon.py:379 #, python-format msgid "" "\n" "Decomposition: %s" msgstr "" -#: ../src/unity_keyboard_daemon.py:316 +#: ../src/unity_keyboard_daemon.py:381 #, python-format msgid "" "\n" "Digit: %s" msgstr "" -#: ../src/unity_keyboard_daemon.py:318 +#: ../src/unity_keyboard_daemon.py:383 #, python-format msgid "" "\n" "Numeric: %s" msgstr "" -#: ../src/unity_keyboard_daemon.py:320 +#: ../src/unity_keyboard_daemon.py:385 #, python-format msgid "" "\n" "Mirrored: %s" msgstr "" -#: ../src/unity_keyboard_daemon.py:322 +#: ../src/unity_keyboard_daemon.py:387 #, python-format msgid "" "\n" "Unicode-1-Name: %s" msgstr "" -#: ../src/unity_keyboard_daemon.py:324 +#: ../src/unity_keyboard_daemon.py:389 #, python-format msgid "" "\n" "ISO Comment: %s" msgstr "" -#: ../src/unity_keyboard_daemon.py:326 +#: ../src/unity_keyboard_daemon.py:391 #, python-format msgid "" "\n" "Uppercase: %s" msgstr "" -#: ../src/unity_keyboard_daemon.py:328 +#: ../src/unity_keyboard_daemon.py:393 #, python-format msgid "" "\n" "Lowercase: %s" msgstr "" -#: ../src/unity_keyboard_daemon.py:330 +#: ../src/unity_keyboard_daemon.py:395 #, python-format msgid "" "\n" "Titlecase: %s" msgstr "" -#: ../src/unity_keyboard_daemon.py:333 +#: ../src/unity_keyboard_daemon.py:397 +#, python-format +msgid "" +"\n" +"\n" +"Available in: %s" +msgstr "" + +#: ../src/unity_keyboard_daemon.py:400 msgid "Copy to Clipboard" msgstr "" -#: ../src/unity_keyboard_daemon.py:401 +#: ../src/unity_keyboard_daemon.py:486 #, python-format msgid "Copied %s to clipboard" msgstr "" diff -Nru unity-scope-keyboard-0.1/src/unity_keyboard_daemon.py unity-scope-keyboard-0.1/src/unity_keyboard_daemon.py --- unity-scope-keyboard-0.1/src/unity_keyboard_daemon.py 2013-11-12 10:34:41.000000000 +0000 +++ unity-scope-keyboard-0.1/src/unity_keyboard_daemon.py 2013-12-16 04:14:39.000000000 +0000 @@ -1,6 +1,10 @@ #! /usr/bin/python3 # -*- coding: utf-8 -*- +''' +unity_keyboard_daemon.py searches the unicode database for matching glyphs +''' + # Copyright(C) 2013 name # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License version 3, as published @@ -32,7 +36,19 @@ GROUP_NAME = 'com.canonical.Unity.Scope.Info.Keyboard' UNIQUE_PATH = '/com/canonical/unity/scope/info/keyboard' UNICODE_FILE = '/usr/share/unicode/UnicodeData.txt' -FONT_FILE = ["Ubuntu-R", "/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-R.ttf", 1082] +FONTS = [[_("Ubuntu-R"), "/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-R.ttf"], + [_("Sans"), "/usr/share/fonts/truetype/freefont/FreeSans.ttf"], + [_("Serif"), "/usr/share/fonts/truetype/freefont/FreeSerif.ttf"], + [_("Microhei"), "/usr/share/fonts/truetype/wqy/wqy-microhei.ttc"], + [_("Lohit Bengali"), "/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_bn.ttf"], + [_("Lohit Gujarati"), "/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_gu.ttf"], + [_("Lohit Hindi"), "/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_hi.ttf"], + [_("Lohit Tamil"), "/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_ta.ttf"], + [_("Kedage"), "/usr/share/fonts/truetype/ttf-indic-fonts-core/Kedage-n.ttf"], + [_("Meera"), "/usr/share/fonts/truetype/ttf-indic-fonts-core/Meera_04.ttf"], + [_("Pothana"), "/usr/share/fonts/truetype/ttf-indic-fonts-core/Pothana2000.ttf"], + [_("Uktal"), "/usr/share/fonts/truetype/ttf-indic-fonts-core/utkal.ttf"], + [_("Unifont"), "/usr/share/fonts/truetype/unifont/unifont.ttf"]] SEARCH_HINT = _('Search Keyboard') NO_RESULTS_HINT = _('Sorry, there are no Keyboard results that match your search.') PROVIDER_CREDITS = _('') @@ -40,7 +56,9 @@ PROVIDER_ICON = SVG_DIR+'service-keyboard.svg' DEFAULT_RESULT_ICON = SVG_DIR+'result-info.svg' DEFAULT_RESULT_MIMETYPE = 'text/html' -DEFAULT_RESULT_TYPE = Unity.ResultType.DEFAULT +DEFAULT_RESULT_TYPE = Unity.ResultType.PERSONAL +SIZE = [] +DATABASE = open(UNICODE_FILE).readlines() CAT1 = {'id': 'results', 'name': _('Result'), @@ -93,85 +111,88 @@ METADATA14 = {'id': 'codepoint', 'type': 's', 'field': Unity.SchemaFieldType.OPTIONAL} -EXTRA_METADATA = [METADATA1, METADATA2, METADATA3, METADATA4, METADATA5, METADATA6, METADATA7, METADATA8, METADATA9, METADATA10, METADATA11, METADATA12, METADATA13, METADATA14] +METADATA15 = {'id': 'fontname', + 'type': 's', + 'field': Unity.SchemaFieldType.OPTIONAL} +EXTRA_METADATA = [METADATA1, METADATA2, METADATA3, METADATA4, METADATA5, METADATA6, METADATA7, METADATA8, METADATA9, METADATA10, METADATA11, METADATA12, METADATA13, METADATA14, METADATA15] -UNICODE_CATEGORY = {'Lu': 'Letter, Uppercase', - 'Ll': 'Letter, Lowercase', - 'Lt': 'Letter, Titlecase', - 'Lm': 'Letter, Modifier', - 'Lo': 'Letter, Other', - 'Mn': 'Mark, Non-Spacing', - 'Mc': 'Mark, Spacing Combining', - 'Me': 'Mark, Enclosing', - 'Nd': 'Number, Decimal Digit', - 'Nl': 'Number, Letter', - 'No': 'Number, Other', - 'Pc': 'Punctuation, Connector', - 'Pd': 'Punctuation, Dash', - 'Ps': 'Punctuation, Open', - 'Pe': 'Punctuation, Close', - 'Pi': 'Punctuation, Initial quote', - 'Pf': 'Punctuation, Final quote', - 'Po': 'Punctuation, Other', - 'Sm': 'Symbol, Math', - 'Sc': 'Symbol, Currency', - 'Sk': 'Symbol, Modifier', - 'So': 'Symbol, Other', - 'Zs': 'Separator, Space', - 'Zl': 'Separator, Line', - 'Zp': 'Separator, Paragraph', - 'Cc': 'Other, Control', - 'Cf': 'Other, Format', - 'Cs': 'Other, Surrogate', - 'Co': 'Other, Private Use', - 'Cn': 'Other, Not Assigned', } - -COMBINING_CLASS = {'0': 'Spacing, split, enclosing, reordrant, and Tibetan subjoined', - '1': 'Overlays and interior', - '7': 'Nuktas', - '8': 'Hiragana/Katakana voicing marks', - '9': 'Viramas', - '10': 'Start of fixed position classes', - '199': 'End of fixed position classes', - '200': 'Below left attached', - '202': 'Below attached', - '204': 'Below right attached', - '208': 'Left attached (reordrant around single base character)', - '210': 'Right attached', - '212': 'Above left attached', - '214': 'Above attached', - '216': 'Above right attached', - '218': 'Below left', - '220': 'Below', - '222': 'Below right', - '224': 'Left (reordrant around single base character)', - '226': 'Right', - '228': 'Above left', - '230': 'Above', - '232': 'Above right', - '233': 'Double below', - '234': 'Double above', - '240': 'Below (iota subscript)', } - -BIDIRECTIONAL = {'L': 'Left-to-Right', - 'LRE': 'Left-to-Right Embedding', - 'LRO': 'Left-to-Right Override', - 'R': 'Right-to-Left', - 'AL': 'Right-to-Left Arabic', - 'RLE': 'Right-to-Left Embedding', - 'RLO': 'Right-to-Left Override', - 'PDF': 'Pop Directional Format', - 'EN': 'European Number', - 'ES': 'European Number Separator', - 'ET': 'European Number Terminator', - 'AN': 'Arabic Number', - 'CS': 'Common Number Separator', - 'NSM': 'Non-Spacing Mark', - 'BN': 'Boundary Neutral', - 'B': 'Paragraph Separator', - 'S': 'Segment Separator', - 'WS': 'Whitespace', - 'ON': 'Other Neutrals', } +UNICODE_CATEGORY = {'Lu': _('Letter, Uppercase'), + 'Ll': _('Letter, Lowercase'), + 'Lt': _('Letter, Titlecase'), + 'Lm': _('Letter, Modifier'), + 'Lo': _('Letter, Other'), + 'Mn': _('Mark, Non-Spacing'), + 'Mc': _('Mark, Spacing Combining'), + 'Me': _('Mark, Enclosing'), + 'Nd': _('Number, Decimal Digit'), + 'Nl': _('Number, Letter'), + 'No': _('Number, Other'), + 'Pc': _('Punctuation, Connector'), + 'Pd': _('Punctuation, Dash'), + 'Ps': _('Punctuation, Open'), + 'Pe': _('Punctuation, Close'), + 'Pi': _('Punctuation, Initial quote'), + 'Pf': _('Punctuation, Final quote'), + 'Po': _('Punctuation, Other'), + 'Sm': _('Symbol, Math'), + 'Sc': _('Symbol, Currency'), + 'Sk': _('Symbol, Modifier'), + 'So': _('Symbol, Other'), + 'Zs': _('Separator, Space'), + 'Zl': _('Separator, Line'), + 'Zp': _('Separator, Paragraph'), + 'Cc': _('Other, Control'), + 'Cf': _('Other, Format'), + 'Cs': _('Other, Surrogate'), + 'Co': _('Other, Private Use'), + 'Cn': _('Other, Not Assigned'), } + +COMBINING_CLASS = {'0': _('Spacing, split, enclosing, reordrant, and Tibetan subjoined'), + '1': _('Overlays and interior'), + '7': _('Nuktas'), + '8': _('Hiragana/Katakana voicing marks'), + '9': _('Viramas'), + '10': _('Start of fixed position classes'), + '199': _('End of fixed position classes'), + '200': _('Below left attached'), + '202': _('Below attached'), + '204': _('Below right attached'), + '208': _('Left attached (reordrant around single base character)'), + '210': _('Right attached'), + '212': _('Above left attached'), + '214': _('Above attached'), + '216': _('Above right attached'), + '218': _('Below left'), + '220': _('Below'), + '222': _('Below right'), + '224': _('Left (reordrant around single base character)'), + '226': _('Right'), + '228': _('Above left'), + '230': _('Above'), + '232': _('Above right'), + '233': _('Double below'), + '234': _('Double above'), + '240': _('Below (iota subscript)'), } + +BIDIRECTIONAL = {'L': _('Left-to-Right'), + 'LRE': _('Left-to-Right Embedding'), + 'LRO': _('Left-to-Right Override'), + 'R': _('Right-to-Left'), + 'AL': _('Right-to-Left Arabic'), + 'RLE': _('Right-to-Left Embedding'), + 'RLO': _('Right-to-Left Override'), + 'PDF': _('Pop Directional Format'), + 'EN': _('European Number'), + 'ES': _('European Number Separator'), + 'ET': _('European Number Terminator'), + 'AN': _('Arabic Number'), + 'CS': _('Common Number Separator'), + 'NSM': _('Non-Spacing Mark'), + 'BN': _('Boundary Neutral'), + 'B': _('Paragraph Separator'), + 'S': _('Segment Separator'), + 'WS': _('Whitespace'), + 'ON': _('Other Neutrals'), } def search(query, filters): @@ -189,55 +210,39 @@ extras metadata fields(variant) ''' results = [] - character = [] - - filename = open(UNICODE_FILE) - database = filename.readlines() - for line in database: - fields = line.split(";") - - # If it's a one letter query, get all the glyphs associated with that letter - if len(query) == 1: - # Get the character's root glyph (eg ø --> o) - if not fields[5] == "": - chars = fields[5].split(" ") - for char in chars: - if not char.startswith("<"): - if query.upper() in chr(int(char, 16)).upper(): - character.append(fields) - # Match to the character's glyph for upper and lower case - if query.upper() in chr(int(fields[0], 16)).upper(): - character.append(fields) - else: - if query.upper() in fields[1]: - character.append(fields) - continue - if query.upper() in fields[10]: - character.append(fields) - continue - if query.upper() in fields[0]: - character.append(fields) + character = get_characters(query) for item in character: + add_result = False name = item[1].title() - glyph = (chr(int(item[0], 16))) - number = int(item[0], 16) - tb_filename = "/tmp/unity_scope_keyboard/%s.png" % number + codepoint = int(item[0], 16) + tb_filename = "/tmp/unity_scope_keyboard/%s.png" % codepoint + available = [] + for font in FONTS: + if os.path.exists(font[1]): + if os.path.exists(tb_filename): + if os.stat(tb_filename).st_size in SIZE: + generate_image(codepoint, font[1], tb_filename) + if not os.stat(tb_filename).st_size in SIZE: + add_result = True + available.append(font[0]) + break + else: + add_result = True + available.append(font[0]) + break + else: + generate_image(codepoint, font[1], tb_filename) + if not os.stat(tb_filename).st_size in SIZE: + add_result = True + available.append(font[0]) + break - if not os.path.exists(tb_filename): - font = ImageFont.truetype(FONT_FILE[1], 256, encoding='unic') - img = Image.new("RGBA", (384, 384)) - draw = ImageDraw.Draw(img) - width, height = draw.textsize(chr(int(item[0], 16)), font=font) - draw.text(((384-width)/2, (384-height)/2), glyph, (255, 255, 255), font=font) - draw = ImageDraw.Draw(img) - img.save(tb_filename, transparancy=0) - stats = os.stat(tb_filename) - if not stats.st_size == FONT_FILE[2]: + if add_result: results.append({'uri': "file://" + tb_filename, 'icon': "file://" + tb_filename, 'title': name, - 'glyph': glyph, + 'glyph': chr(codepoint), 'unicode_category': item[2], 'combining': item[3], 'bidi': item[4], @@ -250,15 +255,69 @@ 'uppercase': item[12], 'lowercase': item[13], 'titlecase': item[14][:-1], - 'codepoint': item[0]}) + 'codepoint': item[0], + 'fontname': ", ".join(available)}) return results +def generate_image(glyph, font_path, tb_filename): + ''' + Generates a 384x384 transparent png with the glyph in white 256pt text + ''' + font = ImageFont.truetype(font_path, 256, encoding='unic') + img = Image.new("RGBA", (384, 384)) + draw = ImageDraw.Draw(img) + width, height = draw.textsize(chr(glyph), font=font) + draw.text(((384-width)/2, (384-height)/2), chr(glyph), (255, 255, 255), font=font) + draw = ImageDraw.Draw(img) + img.save(tb_filename, transparancy=0) + return + + +def get_characters(query): + ''' + Searches the unicode database for characters matching the query + ''' + character = [] + for line in DATABASE: + fields = line.split(";") + # If it's a one letter query, get all the glyphs associated with that letter + if len(query) == 1: + # Get the character's root glyph (eg ø --> o) + if not fields[5] == "": + chars = fields[5].split(" ") + for char in chars: + if not char.startswith("<"): + if query.upper() in chr(int(char, 16)).upper(): + character.append(fields) + break + # Match to the character's glyph for upper and lower case + else: + if query.upper() in chr(int(fields[0], 16)).upper(): + character.append(fields) + continue + else: + # Match the query to the character description + if (fields[1].startswith(query.upper() + " ")) or (fields[1].endswith(" " + query.upper())) or (" %s " % query.upper() in fields[1]): + character.append(fields) + continue + # Match the query to the unicode-1-name field + if (fields[10].startswith(query.upper() + " ")) or (fields[10].endswith(" " + query.upper())) or (" %s " % query.upper() in fields[10]): + character.append(fields) + continue + # Match the query to the glyph + if query.upper() is fields[0]: + character.append(fields) + return character + # Classes below this point establish communication # with Unity, you probably shouldn't modify them. class MySearch(Unity.ScopeSearchBase): + ''' + The MySearch() class returns the results to Scope() + ''' def __init__(self, search_context): super(MySearch, self).__init__() self.set_search_context(search_context) @@ -293,8 +352,14 @@ class Preview(Unity.ResultPreviewer): + ''' + Creates the preview for the result + ''' def do_run(self): + ''' + Create a preview and return it + ''' preview = Unity.GenericPreview.new(self.result.title, self.result.comment, None) preview.props.image_source_uri = self.result.icon_hint icon = Gio.FileIcon.new(Gio.file_new_for_path(PROVIDER_ICON)) @@ -328,6 +393,8 @@ description += _('\nLowercase: %s') % chr(int(self.result.metadata['lowercase'].get_string(), 16)) if self.result.metadata['titlecase'].get_string(): description += _('\nTitlecase: %s') % chr(int(self.result.metadata['titlecase'].get_string(), 16)) + if self.result.metadata['fontname'].get_string(): + description += _('\n\nAvailable in: %s') % self.result.metadata['fontname'].get_string() preview.props.description_markup = description view_action = Unity.PreviewAction.new('clipboard', _('Copy to Clipboard'), icon) @@ -336,10 +403,16 @@ class Scope(Unity.AbstractScope): + ''' + The Scope() class contains all the scope's details for unity to display + ''' def __init__(self): Unity.AbstractScope.__init__(self) def do_get_search_hint(self): + ''' + Returns the SEARCH_HINT text + ''' return SEARCH_HINT def do_get_schema(self): @@ -348,9 +421,8 @@ ''' schema = Unity.Schema.new() if EXTRA_METADATA: - for m in EXTRA_METADATA: - schema.add_field(m['id'], m['type'], m['field']) - #FIXME should be REQUIRED for credits + for metadata in EXTRA_METADATA: + schema.add_field(metadata['id'], metadata['type'], metadata['field']) schema.add_field('provider_credits', 's', Unity.SchemaFieldType.OPTIONAL) return schema @@ -358,41 +430,54 @@ ''' Adds categories ''' - cs = Unity.CategorySet.new() + category_set = Unity.CategorySet.new() if CATEGORIES: - for c in CATEGORIES: - cat = Unity.Category.new(c['id'], c['name'], - Gio.ThemedIcon.new(c['icon']), - c['renderer']) - cs.add(cat) - return cs + for cat in CATEGORIES: + category = Unity.Category.new(cat['id'], cat['name'], + Gio.ThemedIcon.new(cat['icon']), + cat['renderer']) + category_set.add(category) + return category_set def do_get_filters(self): ''' Adds filters ''' - fs = Unity.FilterSet.new() -# if FILTERS: -# - return fs + filters = Unity.FilterSet.new() + return filters def do_get_group_name(self): + ''' + Returns GROUP_NAME + ''' return GROUP_NAME def do_get_unique_name(self): + ''' + Returns UNIQUE_PATH + ''' return UNIQUE_PATH def do_create_search_for_query(self, search_context): - se = MySearch(search_context) - return se + ''' + Creates the search + ''' + scope_search = MySearch(search_context) + return scope_search def do_create_previewer(self, result, metadata): - rp = Preview() - rp.set_scope_result(result) - rp.set_search_metadata(metadata) - return rp + ''' + Creates a preview when a resut is right-clicked + ''' + result_preview = Preview() + result_preview.set_scope_result(result) + result_preview.set_search_metadata(metadata) + return result_preview - def do_activate(self, result, metadata, id): + def do_activate(self, result, metadata, identifier): + ''' + What to do when a resut is clicked + ''' glyph = result.metadata['glyph'].get_string() clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) clipboard.set_text(glyph, -1) @@ -403,6 +488,16 @@ def load_scope(): + ''' + Called by scope-runner.py. Sets things up and returns the scope + ''' if not os.path.exists("/tmp/unity_scope_keyboard"): os.mkdir("/tmp/unity_scope_keyboard") + for font in FONTS: + tb_filename = "/tmp/unity_scope_keyboard/%s.png" % font[0] + if not os.path.exists(tb_filename): + if os.path.exists(font[1]): + generate_image(65536, font[1], tb_filename) + if os.path.exists(tb_filename): + SIZE.append(os.stat(tb_filename).st_size) return Scope() diff -Nru unity-scope-keyboard-0.1/tests/test_keyboard.py unity-scope-keyboard-0.1/tests/test_keyboard.py --- unity-scope-keyboard-0.1/tests/test_keyboard.py 2013-11-12 10:34:41.000000000 +0000 +++ unity-scope-keyboard-0.1/tests/test_keyboard.py 2013-12-16 04:14:39.000000000 +0000 @@ -47,7 +47,7 @@ self.assertEqual(results, expected_results) def test_failing_search(self): - for s in ['print']: + for s in ['upnriitnyt']: result_set = self.perform_query(s) self.assertEqual(len(result_set.results), 0)