~ubuntu-branches/debian/squeeze/ibus-hangul/squeeze

« back to all changes in this revision

Viewing changes to setup/keycapturedialog.py

  • Committer: Bazaar Package Importer
  • Author(s): LI Daobing
  • Date: 2010-01-03 12:46:27 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20100103124627-myjyr6sjtomh148o
Tags: 1.2.0.20100102-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import gtk
 
2
import gtk.gdk as gdk
 
3
import gettext
 
4
 
 
5
_ = lambda a : gettext.dgettext("ibus-hangul", a)
 
6
 
 
7
class KeyCaptureDialog ():
 
8
    def __init__ (self, title, parent):
 
9
        self.__key_str = ''
 
10
        self.__dialog = gtk.MessageDialog(parent,
 
11
                        gtk.DIALOG_MODAL,
 
12
                        gtk.MESSAGE_INFO,
 
13
                        gtk.BUTTONS_OK_CANCEL,
 
14
                        "")
 
15
        self.__dialog.set_markup(_("Press any key which you want to use as hanja key. "
 
16
                "The key you pressed is displayed below.\n"
 
17
                "If you want to use it, click \"Ok\" or click \"Cancel\""))
 
18
 
 
19
        self.__dialog.format_secondary_markup(" ")
 
20
        self.__dialog.connect("key-press-event", self.on_keypress, None)
 
21
 
 
22
    def destroy(self):
 
23
        self.__dialog.destroy()
 
24
 
 
25
    def run(self):
 
26
        return self.__dialog.run()
 
27
 
 
28
    def get_key_string(self):
 
29
        return self.__key_str
 
30
 
 
31
    def on_keypress(self, widget, event, data = None):
 
32
        self.__key_str = ""
 
33
        if event.state & gdk.CONTROL_MASK :
 
34
            self.__key_str += "Control+"
 
35
        if event.state & gdk.MOD1_MASK :
 
36
            self.__key_str += "Alt+"
 
37
        if event.state & gdk.SHIFT_MASK :
 
38
            self.__key_str += "Shift+"
 
39
 
 
40
        self.__key_str += gdk.keyval_name(event.keyval)
 
41
            
 
42
        self.__dialog.format_secondary_markup('<span size="large" weight="bold">%s</span>' % self.__key_str)