Exemplo n.º 1
0
    def __init__(self, options):
        """Create the Key Mon window.
    Options dict:
      scale: float 1.0 is default which means normal size.
      meta: boolean show the meta (windows key)
      kbd_file: string Use the kbd file given.
      emulate_middle: Emulate the middle mouse button.
      theme: Name of the theme to use to draw keys
    """
        settings.SettingsDialog.register()
        self.btns = [
            'MOUSE', 'BTN_RIGHT', 'BTN_MIDDLE', 'BTN_MIDDLERIGHT', 'BTN_LEFT',
            'BTN_LEFTRIGHT', 'BTN_LEFTMIDDLE', 'BTN_LEFTMIDDLERIGHT'
        ]
        self.options = options
        self.pathname = os.path.dirname(__file__)
        if self.options.scale < 1.0:
            self.svg_size = '-small'
        else:
            self.svg_size = ''
        # Make lint happy by defining these.
        self.mouse_image = None
        self.alt_image = None
        self.hbox = None
        self.window = None
        self.event_box = None
        self.mouse_indicator_win = None
        self.key_image = None
        self.shift_image = None
        self.ctrl_image = None
        self.meta_image = None
        self.buttons = None

        self.enabled = {
            'MOUSE': self.options.mouse,
            'SHIFT': self.options.shift,
            'CTRL': self.options.ctrl,
            'META': self.options.meta,
            'ALT': self.options.alt,
            'KEYS': self.options.keys,
            'BUTTONS': self.options.buttons,
        }

        #Disables all Buttons when nobuttons has been triggered
        if not self.enabled['BUTTONS']:
            self.enabled['SHIFT'] = False
            self.enabled['META'] = False
            self.enabled['ALT'] = False
            self.enabled['CTRL'] = False
            self.enabled['KEYS'] = False

        self.modmap = mod_mapper.safely_read_mod_map(self.options.kbd_file)

        self.name_fnames = self.create_names_to_fnames()
        self.devices = xlib.XEvents()
        self.devices.start()

        self.pixbufs = lazy_pixbuf_creator.LazyPixbufCreator(
            self.name_fnames, self.options.scale)
        self.create_window()
Exemplo n.º 2
0
    def __init__(self, fname, opacity, color=None, scale=1.0, timeout=0.2):
        gtk.Window.__init__(self)
        self.connect('size-allocate', self._on_size_allocate)
        self.set_decorated(False)
        self.set_keep_above(True)
        self.set_accept_focus(False)
        self.scale = scale
        self.shown = False
        self.opacity = opacity
        self.timeout = timeout
        self.timeout_timer = None
        self.name_fnames = {
            'mouse': [fname],
        }
        self.pixbufs = lazy_pixbuf_creator.LazyPixbufCreator(self.name_fnames,
                                                             self.scale,
                                                             color=color)
        self.pixbuf = self.pixbufs.get('mouse')
        self.resize(self.pixbuf.get_width(), self.pixbuf.get_height())

        # a pixmap widget to contain the pixmap
        self.image = gtk.Image()
        bitmap, self.mask = self.pixbuf.render_pixmap_and_mask()
        self.image.set_from_pixmap(bitmap, self.mask)
        self.image.show()
        self.add(self.image)
Exemplo n.º 3
0
    def __init__(self, options):
        """Create the Key Mon window.
    Options dict:
      scale: float 1.0 is default which means normal size.
      meta: boolean show the meta (windows key)
      kbd_file: string Use the kbd file given.
      emulate_middle: Emulate the middle mouse button.
      theme: Name of the theme to use to draw keys
    """
        settings.SettingsDialog.register()
        self.btns = [
            'MOUSE', 'BTN_RIGHT', 'BTN_MIDDLE', 'BTN_MIDDLERIGHT', 'BTN_LEFT',
            'BTN_LEFTRIGHT', 'BTN_LEFTMIDDLE', 'BTN_LEFTMIDDLERIGHT'
        ]
        self.options = options
        self.pathname = os.path.dirname(os.path.abspath(__file__))
        if self.options.scale < 1.0:
            self.svg_size = '-small'
        else:
            self.svg_size = ''
        # Make lint happy by defining these.
        self.hbox = None
        self.window = None
        self.event_box = None
        self.mouse_indicator_win = None
        self.key_image = None
        self.buttons = None

        self.no_press_timer = None

        self.move_dragged = False
        self.shape_mask_current = None
        self.shape_mask_cache = {}

        self.MODS = ['SHIFT', 'CTRL', 'META', 'ALT']
        self.IMAGES = ['MOUSE'] + self.MODS
        self.images = dict([(img, None) for img in self.IMAGES])
        self.enabled = dict([(img, self.get_option(cstrf(img.lower)))
                             for img in self.IMAGES])

        self.options.kbd_files = settings.get_kbd_files()
        self.modmap = mod_mapper.safely_read_mod_map(self.options.kbd_file,
                                                     self.options.kbd_files)

        self.name_fnames = self.create_names_to_fnames()
        self.devices = xlib.XEvents()
        self.devices.start()

        self.pixbufs = lazy_pixbuf_creator.LazyPixbufCreator(
            self.name_fnames, self.options.scale)
        self.create_window()
        self.reset_no_press_timer()