~ubuntu-branches/ubuntu/precise/gnome-orca/precise-proposed

« back to all changes in this revision

Viewing changes to src/orca/script_utilities.py

  • Committer: Package Import Robot
  • Author(s): Luke Yelavich
  • Date: 2011-09-23 11:53:49 UTC
  • mfrom: (0.9.41 upstream)
  • Revision ID: package-import@ubuntu.com-20110923115349-9mv0aw0lw19v7puu
Tags: 3.1.92-0ubuntu1
* New upstream release
  - General:
    + Fix for bug 659054 - Orca fails to present decimal values of
      GtkScale widgets in Gtk+ 3
    + Fix for bug 659379 - Orca is not presenting panel menus and menu
      items in fallback mode
    + Fix for bug 659264 - Return in onFocus if the object is not focused
    + Fix for bug 659122 - Unicode decode error traceback with speech
      generation if I using hungarian locale
    + Fix for bug 617833 - Orca should indicate state of NumLock key
    + Fix for bug 652485 - Gtk+ Deprecations (Remainder of the work)
    + Fix for bug 659015 - The mnemonic widget property on the voice page
      is absent for several widgets
    + Fix for bug 658134 - Lines with unexpected characters are not always
      displayed in braille by Orca
    + Fix for bug 658781 - Some text not spoken at all since gobject
      introspection changes in orca 3.1.9x.
    + Fix for bug 658993 - Two GtkGrid spacing issues
  - Build:
    + Fix for bug 659092 - Do not reference non-existing doc figures
  - New and updated translations (THANKS EVERYONE!!!):
    + ast        Asturian                        Xandru Armesto
    + bg         Bulgarian                       Alexander Shopov
    + ca         Catalan                         Pau Iranzo
    + cs         Czech                           Marek Černocký
    + da         Danish                          Kenneth Nielsen
    + de         German                          Christian Kirbach
    + en_GB      British English                 Bruce Cowan
    + es         Spanish                         Jorge González,
                                                 Daniel Mustieles
    + fi         Finnish                         Timo Jyrinki
    + fr         French                          Bruno Brouard
    + gl         Galician                        Fran Diéguez
    + hu         Hungarian                       Attila Hammer
    + it         Italian                         Luca Ferretti
    + lt         Lithuanian                      Aurimas Černius
    + lv         Latvian                         Rudolfs Mazurs
    + pa         Punjabi                         Amanpreet Singh Alam
    + pl         Polish                          Piotr Drąg
    + pt         Portuguese                      Rui Batista
    + ru         Russian                         Yuri Myasoedov
    + sl         Slovenian                       Matej Urbančič
    + sv         Swedish                         Daniel Nylander
    + ta         Tamil                           Dr.T.Vasudevan
    + zh_CN      Simplified Chinese              Yinghua Wang
    + zh_HK      Traditional Chinese - HongKong  Chao-Hsiung Liao
    + zh_TW      Traditional Chinese - Taiwan    Chao-Hsiung Liao
* Dropped patches, applied upstream:
  - 03_Fix-for-bug-658781-Some-text-not-spoken-at-all-since.patch
  - 04_Fix-for-bug-658134-Lines-with-unexpected-characters-.patch
* debian/control: Bump at-spi build dep to >= 2.1.92

Show diffs side-by-side

added added

removed removed

Lines of Context:
2326
2326
        import punctuation_settings
2327
2327
        import chnames
2328
2328
 
 
2329
        try:
 
2330
            line = line.decode("UTF-8")
 
2331
        except UnicodeEncodeError:
 
2332
            pass
 
2333
 
 
2334
        try:
 
2335
            segment = segment.decode("UTF-8")
 
2336
        except UnicodeEncodeError:
 
2337
            pass
 
2338
 
2329
2339
        style = settings.verbalizePunctuationStyle
2330
2340
        isPunctChar = True
2331
2341
        try:
2343
2353
                # space characters".  The %d is the number and the %s
2344
2354
                # is the spoken word for the character.
2345
2355
                #
2346
 
                line += " " \
2347
 
                     + ngettext("%(count)d %(repeatChar)s character",
 
2356
                repeatSegment = ngettext("%(count)d %(repeatChar)s character",
2348
2357
                                "%(count)d %(repeatChar)s characters",
2349
 
                                count) \
2350
 
                       % {"count" : count, "repeatChar": repeatChar}
 
2358
                                 count) \
 
2359
                                 % {"count" : count, "repeatChar": repeatChar}
 
2360
 
 
2361
                try:
 
2362
                    repeatSegment = repeatSegment.decode("UTF-8")
 
2363
                except UnicodeEncodeError:
 
2364
                    pass
 
2365
 
 
2366
                line = "%s %s" % (line, repeatSegment)
2351
2367
            else:
2352
2368
                line += segment
2353
2369
        else:
2463
2479
            pass
2464
2480
 
2465
2481
        words = self.WORDS_RE.split(line)
2466
 
        newLine = ' '.join(map(self._pronunciationForSegment, words))
 
2482
        newLine = ''.join(map(self._pronunciationForSegment, words))
2467
2483
 
2468
2484
        try:
2469
2485
            newLine = newLine.encode("UTF-8")
2593
2609
        and returns the new string.  Edge cases, such as no initial text or
2594
2610
        no newText, are handled gracefully."""
2595
2611
 
2596
 
        if not newText or len(newText) == 0:
 
2612
        if not newText:
2597
2613
            return text
2598
 
        elif text and len(text):
2599
 
            return text + delimiter + newText
2600
 
        else:
 
2614
        if not text:
2601
2615
            return newText
2602
2616
 
 
2617
        try:
 
2618
            text = text.decode("UTF-8")
 
2619
        except UnicodeEncodeError:
 
2620
            pass
 
2621
 
 
2622
        try:
 
2623
            newText = newText.decode("UTF-8")
 
2624
        except UnicodeEncodeError:
 
2625
            pass
 
2626
 
 
2627
        return text + delimiter + newText
 
2628
 
2603
2629
    def isAutoTextEvent(self, event):
2604
2630
        """Returns True if event is associated with text being autocompleted
2605
2631
        or autoinserted or autocorrected or autosomethingelsed.
2832
2858
            value = obj.queryValue()
2833
2859
        except NotImplementedError:
2834
2860
            return ""
2835
 
 
2836
 
        # OK, this craziness is all about trying to figure out the most
2837
 
        # meaningful formatting string for the floating point values.
2838
 
        # The number of places to the right of the decimal point should
2839
 
        # be set by the minimumIncrement, but the minimumIncrement isn't
2840
 
        # always set.  So...we'll default the minimumIncrement to 1/100
2841
 
        # of the range.  But, if max == min, then we'll just go for showing
2842
 
        # them off to two meaningful digits.
2843
 
        #
2844
 
        try:
2845
 
            minimumIncrement = value.minimumIncrement
2846
 
        except:
2847
 
            minimumIncrement = 0.0
2848
 
 
2849
 
        if minimumIncrement == 0.0:
2850
 
            minimumIncrement = (value.maximumValue - value.minimumValue) \
2851
 
                               / 100.0
2852
 
 
2853
 
        try:
2854
 
            decimalPlaces = max(0, -math.log10(minimumIncrement))
2855
 
        except:
2856
 
            try:
2857
 
                decimalPlaces = max(0, -math.log10(value.minimumValue))
2858
 
            except:
2859
 
                try:
2860
 
                    decimalPlaces = max(0, -math.log10(value.maximumValue))
2861
 
                except:
2862
 
                    decimalPlaces = 0
 
2861
        else:
 
2862
            currentValue = value.currentValue
 
2863
 
 
2864
        # "The reports of my implementation are greatly exaggerated."
 
2865
        try:
 
2866
            maxValue = value.maximumValue
 
2867
        except LookupError:
 
2868
            maxValue = 0.0
 
2869
            debug.println(debug.LEVEL_FINEST, "VALUE WARNING: " \
 
2870
                          "LookupError accessing maximumValue for %s" % obj)
 
2871
        try:
 
2872
            minValue = value.minimumValue
 
2873
        except LookupError:
 
2874
            minValue = 0.0
 
2875
            debug.println(debug.LEVEL_FINEST, "VALUE WARNING: " \
 
2876
                          "LookupError accessing minimumValue for %s" % obj)
 
2877
        try:
 
2878
            minIncrement = value.minimumIncrement
 
2879
        except LookupError:
 
2880
            minIncrement = (maxValue - minValue) / 100.0
 
2881
            debug.println(debug.LEVEL_FINEST, "VALUE WARNING: " \
 
2882
                          "LookupError accessing minimumIncrement for %s" % obj)
 
2883
 
 
2884
        try:
 
2885
            decimalPlaces = math.ceil(max(0, -math.log10(minIncrement)))
 
2886
        except ValueError:
 
2887
            return ""
2863
2888
 
2864
2889
        formatter = "%%.%df" % decimalPlaces
2865
 
        valueString = formatter % value.currentValue
2866
 
        #minString   = formatter % value.minimumValue
2867
 
        #maxString   = formatter % value.maximumValue
2868
 
 
2869
 
        # [[[TODO: WDW - probably want to do this as a percentage at some
2870
 
        # point?  Logged as bugzilla bug 319743.]]]
2871
 
        #
2872
 
        return valueString
 
2890
        return formatter % currentValue
2873
2891
 
2874
2892
    @staticmethod
2875
2893
    def unicodeValueString(character):