def load_addons(self): """ Loads the enabled addons Arguments: - self: The main object pointer. """ for add in self.cfg.getList("main", "addon"): tmp = __import__("mousetrap.addons.%s" % add, globals(), locals(), [""]) setattr(self, add, tmp.Addon(self.ctr)) debug.debug("ui.main", "Addons loaded")
'r' : [ X.ButtonRelease ], 'c' : [ X.ButtonPress, X.ButtonRelease], 'd' : [ X.ButtonPress, X.ButtonRelease, X.ButtonPress, X.ButtonRelease ] } ## GTK Display for any user gtkDisplay = gtk.gdk.Display( "" ) ## X Display for non gnome users xDisplay = display.Display() isGnome = False if env.desktop == "gnome": isGnome = True debug.debug( "mousetrap.mouse", "GNOME desktop has been detected" ) ## pyatspi registry for gnome users reg = pyatspi.Registry ## Is the D&D click being used ? dragging = False def position( *arg ): """ Get the absolute position of the mouse pointer Returns A list with the X and Y coordinates. """ return list(gtkDisplay.get_pointer()[1:3])
def __init__(self, controller): AddonsBase.__init__(self, controller) gobject.timeout_add(1000, self.check_cpu) debug.debug("addon.cpu", "CPU addon started")
def build_interface(self): """ Builds the interface Arguments: - self: The main object pointer """ self.connect("key-press-event", self.handleKeyboardInput) self.set_resizable(False) self.setWindowsIcon() accelGroup = gtk.AccelGroup() self.add_accel_group(accelGroup) self.accelGroup = accelGroup self.add_events(gtk.gdk.KEY_PRESS_MASK) self.set_title("MouseTrap") self.connect("destroy", self.close) self.setWindowsIcon() self.vBox = gtk.VBox() self.buttonsBox = gtk.HButtonBox() # self.buttonsBox = gtk.HBox(False,0) self.prefButton = gtk.Button(stock=gtk.STOCK_PREFERENCES) self.prefButton.connect("clicked", self._show_settings_gui) self.buttonsBox.pack_start(self.prefButton, True, True) self.closeButton = gtk.Button(stock=gtk.STOCK_QUIT) self.closeButton.connect("clicked", self.close) self.buttonsBox.pack_start(self.closeButton, True, True) self.helpButton = gtk.Button(stock=gtk.STOCK_HELP) self.helpButton.connect("clicked", self._loadHelp) self.buttonsBox.pack_start(self.helpButton, True, True) self.vBox.pack_start(self.buttonsBox, False, False) self.adds_vbox = gtk.VBox() self.adds_vbox.show_all() self.vBox.pack_start(self.adds_vbox, False, False) self.cap_image = gtk.Image() if self.cfg.getboolean("gui", "showCapture"): self.cap_expander = gtk.expander_new_with_mnemonic("_Camera Image") self.cap_expander.add(self.cap_image) # expander.connect('notify::expanded', self.expanded_cb) self.cap_expander.set_expanded(True) self.vBox.pack_start(self.cap_expander) if self.cfg.get("main", "algorithm") == "color": self.pal_expander = gtk.expander_new_with_mnemonic("Color _Picker") # Create a vertical box inside the color picker expander for layout self.pickerBox = gtk.VBox(spacing=10) self.picker = gtk.ColorSelection() self.picker.set_has_palette(True) self.pickerBox.pack_start(self.picker) self.saveColorButton = gtk.Button(stock=gtk.STOCK_SAVE) self.saveColorButton.connect("clicked", self._changeColors) # Weird config file hack. See Module.update_hue_range() docs if self.cfg.getboolean("main", "startCam"): self.saveColorButton.connect("clicked", self.ctr.idm.update_hue_range) self.pickerBox.pack_start(self.saveColorButton) self.pal_expander.add(self.pickerBox) self.vBox.pack_start(self.pal_expander) if self.cfg.getboolean("gui", "showPointMapper"): self.map_expander = gtk.expander_new_with_mnemonic("_Script Mapper") self.map_expander.add(self.script) self.map_expander.set_expanded(True) # expander.connect('notify::expanded', self.expanded_cb) self.vBox.pack_start(self.map_expander) # # flipButton = gtk.Button( _("Flip Image") ) # flipButton.connect("clicked", self.recalcPoint, "flip" ) # hBox.pack_start( flipButton, False, False ) # # recalcButton = gtk.Button( _("Recalc Point") ) # recalcButton.connect("clicked", self.recalcPoint ) # hBox.pack_start( recalcButton, False, False ) # # self.vBox.pack_end(hBox, False, False ) # # self.buttonsBox.show_all() self.statusbar = gtk.Statusbar() self.statusbar_id = self.statusbar.get_context_id("statusbar") self.vBox.pack_start(self.statusbar, True, True) self.vBox.show_all() self.add(self.vBox) self.show() debug.debug("ui.main", "Interface Built")