Esempio n. 1
0
  def settings_changed(self, unused_dlg):
    """Event received from the settings dialog."""
    for img in self.IMAGES:
      self._toggle_a_key(self.images[img], img, self.get_option(cstrf(img.lower)))
    self.create_buttons()
    self.layout_boxes()
    self.mouse_indicator_win.hide()
    self.mouse_indicator_win.timeout = self.options.visible_click_timeout
    self.window.set_decorated(self.options.decorated)
    self.name_fnames = self.create_names_to_fnames()
    self.pixbufs.reset_all(self.name_fnames, self.options.scale)
    for but in self.buttons:
      if but.normal != 'KEY_EMPTY':
        but.reset_image(self.enabled[but.normal.replace('_EMPTY', '')])
      else:
        but.reset_image()
      if but.normal == 'MOUSE':
        but.timeout_secs = self.options.mouse_timeout
      else:
        but.timeout_secs = self.options.key_timeout

    # all this to get it to resize smaller
    x, y = self.window.get_position()
    self.hbox.resize_children()
    self.window.resize_children()
    self.window.reshow_with_initial_size()
    self.hbox.resize_children()
    self.event_box.resize_children()
    self.window.resize_children()
    self.window.move(x, y)
    self.update_shape_mask(force=True)

    # reload keymap
    self.modmap = mod_mapper.safely_read_mod_map(
            self.options.kbd_file, self.options.kbd_files)
Esempio n. 2
0
  def settings_changed(self, unused_dlg):
    """Event received from the settings dialog."""
    for img in self.IMAGES:
      self._toggle_a_key(self.images[img], img, self.get_option(cstrf(img.lower)))
    self.create_buttons()
    self.layout_boxes()
    self.mouse_indicator_win.hide()
    self.mouse_indicator_win.timeout = self.options.visible_click_timeout
    self.window.set_decorated(self.options.decorated)
    self.name_fnames = self.create_names_to_fnames()
    self.pixbufs.reset_all(self.name_fnames, self.options.scale)
    for but in self.buttons:
      if but.normal != 'KEY_EMPTY':
        but.reset_image(self.enabled[but.normal.replace('_EMPTY', '')])
      else:
        but.reset_image()
      if but.normal == 'MOUSE':
        but.timeout_secs = self.options.mouse_timeout
      else:
        but.timeout_secs = self.options.key_timeout

    # all this to get it to resize smaller
    x, y = self.window.get_position()
    self.hbox.resize_children()
    self.window.resize_children()
    self.window.reshow_with_initial_size()
    self.hbox.resize_children()
    self.event_box.resize_children()
    self.window.resize_children()
    self.window.move(x, y)
    self.update_shape_mask(force=True)

    # reload keymap
    self.modmap = mod_mapper.safely_read_mod_map(
            self.options.kbd_file, self.options.kbd_files)
Esempio 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(__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()
Esempio n. 4
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()
Esempio n. 5
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()
Esempio n. 6
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', 'ALTGR', 'CAPS']
    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()
Esempio n. 7
0
  def __init__(self, options):
    """Options dict:
      meta: boolean show the meta (windows key)
      kbd_file: string Use the kbd file given.
    """
    self.btns = ['MOUSE', 'BTN_RIGHT', 'BTN_MIDDLE', 'BTN_MIDDLERIGHT',
                 'BTN_LEFT', 'BTN_LEFTRIGHT', 'BTN_LEFTMIDDLE',
                 'BTN_LEFTMIDDLERIGHT']
    self.options = options

    self.MODS = ['SHIFT', 'CTRL', 'META', 'ALT']

    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.devices = xlib.XEvents()
    self.devices.start()

    path = '/tmp/prvak-log-%s' % time.strftime('%Y%m%d-%H%M%S', time.gmtime())
    print 'Logging into: %s' % path
    self.event_log = open(path, 'w')

    self.add_events()