~ubuntu-branches/ubuntu/utopic/ibus-cangjie/utopic-updates

« back to all changes in this revision

Viewing changes to src/engine.py

  • Committer: Package Import Robot
  • Author(s): Didier Roche
  • Date: 2015-05-26 09:19:14 UTC
  • mfrom: (6.1.4 sid)
  • Revision ID: package-import@ubuntu.com-20150526091914-bterkby7t7a62eux
Tags: 2.4-1~utopic1
Backporting wily release sync to utopic to fix multiple UX issues
as per upstream request (LP: #1452376)

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
 
48
48
        self.canberra = Canberra()
49
49
 
50
 
        self.settings = Gio.Settings("org.cangjians.ibus.%s" % self.__name__)
 
50
        schema_id = "org.cangjians.ibus.%s" % self.__name__
 
51
        self.settings = Gio.Settings(schema_id=schema_id)
51
52
        self.settings.connect("changed", self.on_value_changed)
52
53
 
53
54
        self.current_input = ""
249
250
                self.get_candidates(by_shortcode=True)
250
251
 
251
252
            else:
252
 
                self.get_candidates()
 
253
                try:
 
254
                    self.get_candidates()
 
255
 
 
256
                except cangjie.errors.CangjieNoCharsError:
 
257
                    self.play_error_bell()
 
258
                    return True
253
259
 
254
260
        if self.lookuptable.get_number_of_candidates():
255
261
            self.do_select_candidate(1)
394
400
        else:
395
401
            chars = self.cangjie.get_characters_by_shortcode(code)
396
402
 
 
403
        # Finding an element in a dict is **much** faster than in a list
 
404
        seen = {}
 
405
 
397
406
        for c in sorted(chars, key=attrgetter("frequency"), reverse=True):
 
407
            if c.chchar in seen:
 
408
                continue
 
409
 
398
410
            self.lookuptable.append_candidate(IBus.Text.new_from_string(c.chchar))
399
411
            num_candidates += 1
 
412
            seen[c.chchar] = True
400
413
 
401
414
        if num_candidates == 1:
402
415
            self.do_select_candidate(1)
421
434
        text = IBus.Text.new_from_string(self.current_radicals)
422
435
        super(Engine, self).update_auxiliary_text(text, len(self.current_radicals)>0)
423
436
 
 
437
        # We don't use pre-edit at all for Cangjie or Quick
 
438
        #
 
439
        # However, some applications (most notably Firefox) fail to correctly
 
440
        # position the candidate popup, as if they got confused by the absence
 
441
        # of a pre-edit text. :(
 
442
        #
 
443
        # This is a horrible hack, but it fixes the immediate problem.
 
444
        if self.current_radicals:
 
445
            super(Engine, self).update_preedit_text(IBus.Text.new_from_string('\u200B'), 0, True)
 
446
 
 
447
        else:
 
448
            super(Engine, self).update_preedit_text(IBus.Text.new_from_string(''), 0, False)
 
449
        # End of the horrible workaround
 
450
 
424
451
    def update_lookup_table(self):
425
452
        """Update the lookup table."""
426
453
        if not self.current_input: