def __init__(self):
        self.bluez_manager = dinterface(dbus.SystemBus(), "org.bluez", "/org/bluez", "org.bluez.Manager")
        self.bluez_manager.InterfaceVersion()
        self.config = config()
        self.adapter = {}
        self.menu = {}
        self.bluez_manager.connect_to_signal("AdapterAdded", self._bluez_adapter_added)
        self.bluez_manager.connect_to_signal("AdapterRemoved", self._bluez_adapter_removed)
        self.menu["bz_visible"] = {"title": _("Bluetooth visible"), "callback": (self._bluez_switch_visible, 0)}
        self.menu["bz_shorttime"] = {
            "title": _("Bluetooth visible (automatic hiding)"),
            "callback": (self._bluez_switch_visible, 180),
        }
        self.menu["bz_invisible"] = {"title": _("Bluetooth invisible"), "callback": (self._bluez_switch_visible, -1)}

        for menu in self.menu.values():
            menuitem = gtk.CheckMenuItem(menu["title"])
            menuitem.set_draw_as_radio(1)
            menuitem.set_sensitive(0)
            menu["handler"] = menuitem.connect("toggled", *menu["callback"])
            menu["menuitem"] = menuitem

        self.menu_list = [i["menuitem"] for i in self.menu.values()]
        menuitem = gtk.SeparatorMenuItem()
        self.menu_list.append(menuitem)
        self.set_menus_visible(self.config.get_config_item_fb("show-bluetooth", True))
        self._bluez_init_adapter()
    def keycode(self, mapping, keycode):
        """
        More or less a dummy method, that in this class only checks
        whether the supplied keycode is the configured keycode and
        the mapping maps to key release. If this is the case
        the list is generated from the L{dbusinterface} and send to the phone via
        a L{BTServer} Instance.

        @param  mapping:        mapping state of the keycode
        @type   mapping:        Integer
        @param  keycode:        keycode received
        @type   keycode:        Integer
        """
        if self._keycode and \
           keycode == self._keycode and \
           mapping == 1:
            self.profilestore = profilestore = []
            for (config_type, profile) in self.config.get_profiles():
                if config_type == 'system':
                    profilestore.append([ "%s (%s)" % (profile, _("System")), 
                                         (config_type,profile)])
                else:
                    profilestore.append([profile, (config_type, profile)])
            btconnection = self.bluetooth_connector.get_bt_connection()
            btconnection.send_list_query(_("Switch Profile"), 
                                         [i[0] for i in profilestore], 
                                         self._handle_list_reply)
Beispiel #3
0
 def reread(self):
     """
     Reread config from disk. There is no distinction between system and user config
     files. Both will be reread.
     """
     self.user = None
     self.system = None
     try:
         self.user = self._read_config(self.paths.get_userconfigfile())
     except IOError:
         pass
     if not self.user:
         logging.debug(_("Could not open config file: %s"), self.paths.get_userconfigfile())
         self.user = {}
         self.user['generic-config'] = {}
         self.user['profiles'] = {}
     try:
         self.system = self._read_config(self.paths.get_systemconfigfile())
     except IOError:
         pass
     if not self.system:
         logging.debug(_("Could not open config file: %s"), self.paths.get_systemconfigfile())
         self.system = {}
         self.system['generic-config'] = {}
         self.system['profiles'] = {}
 
     self.profile_index = []
     self.profile_index.extend([('system', profile_name) for profile_name in self.system['profiles']])
     self.profile_index.extend([('user', profile_name) for profile_name in self.user['profiles']])
Beispiel #4
0
    def _create_menu(self):
        self.traymenu = gtk.Menu()
        
        profilemenu = gtk.Menu()
        menuitem = gtk.MenuItem(_("Profiles"))
        menuitem.set_submenu(profilemenu)
        menuitem.show()
        self.traymenu.add(menuitem)
        self.pid_menu_map = {}
        group = None

        def sort_func(first, second):
            if first[0] == second[0]:
                return cmp(first[1], second[1])
            elif first[0] == 'system':
                return -1
            else:
                return 1

        for (config, profile) in sorted(self.lbrc.get_profiles(), cmp=sort_func):
            itemname = None
            if config == 'system':
                itemname = "%s (%s)" % (profile, _("System"))
            else:
                itemname = profile

            menuitem = gtk.RadioMenuItem(group, itemname)
            group = menuitem
            menuitem.config = config
            menuitem.pid = profile
            menuitem.connect("toggled", self.profile_change)
            menuitem.show_all()
            self.pid_menu_map[(config, profile)] = menuitem
            profilemenu.append(menuitem)
        
        menuitem = gtk.SeparatorMenuItem()
        menuitem.show()
        self.traymenu.append(menuitem)
        
        if self.bluecontrol:
            for menuitem in self.bluecontrol.get_menus():
                self.traymenu.append(menuitem)

        # Configuration editor 
        menuitem = gtk.ImageMenuItem(stock_id=gtk.STOCK_PREFERENCES)
        menuitem.connect("activate", self.show_config)
        menuitem.show()
        self.traymenu.append(menuitem)

        menuitem = gtk.SeparatorMenuItem()
        menuitem.show()
        self.traymenu.append(menuitem)

        menuitem = gtk.ImageMenuItem(stock_id=gtk.STOCK_QUIT)
        menuitem.connect('activate', self.quit)
        menuitem.show()
        self.traymenu.append(menuitem)
        self.traymenu.show()
Beispiel #5
0
    def __init__(self, *arg):
        gtk.Entry.__init__(self, *arg)
        self.set_editable(False)
        
        self.hwindow = gtk.Window()
        self.hwindow.set_position(gtk.WIN_POS_MOUSE)
        self.hwindow.set_decorated(False)
        vbox = gtk.VBox()
        self.liststore = liststore = gtk.ListStore(str, str)
        self.treeview = treeview = gtk.TreeView(liststore)
        self.hwindow.set_default_size(200,  300)

        comborenderer = gtk.CellRendererCombo()
        comborenderer.connect("edited", self._treeview_changed, "type")
        
        dbus_type_model = gtk.ListStore(str)
        dbus_type_model.append(['boolean'])
        dbus_type_model.append(['byte'])
        dbus_type_model.append(['int16'])
        dbus_type_model.append(['int32'])
        dbus_type_model.append(['int64'])
        dbus_type_model.append(['uint16'])
        dbus_type_model.append(['uint32'])
        dbus_type_model.append(['uint64'])
        dbus_type_model.append(['string'])
        dbus_type_model.append(['double'])
        
        comborenderer.set_property("model", dbus_type_model)
        comborenderer.set_property("text-column", 0)
        comborenderer.set_property("editable", True)
        comborenderer.set_property("has-entry", False)
        treeview.insert_column_with_attributes(0, _("Param-Type"), comborenderer, text=0)
        
        textrenderer = gtk.CellRendererText()
        textrenderer.connect("edited", self._treeview_changed, "param")
        textrenderer.set_property("editable", True)
        treeview.insert_column_with_attributes(1, _("Param"), textrenderer, text=1)

        treeview.set_headers_visible(True)
        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw.add(treeview)
        vbox.pack_start(sw, expand=True, fill=True, padding=0)
        addbutton = gtk.Button(stock=gtk.STOCK_ADD)
        removebutton = gtk.Button(stock=gtk.STOCK_REMOVE)
        addbutton.connect("clicked", self.add_entry)
        removebutton.connect("clicked", self.remove_entry)
        buttonbox = gtk.HButtonBox()
        buttonbox.add(removebutton)
        buttonbox.add(addbutton)
        vbox.pack_start(buttonbox, expand=False, fill=True, padding=0)
        self.hwindow.add(vbox)
        self.hwindow.show_all()
Beispiel #6
0
 def on_profile_new_button_clicked(self, button):
     input_window = ProfileQueryWindow(query=_("New Name"),
                                title=_("What is the name for the new profile?"), 
                                parent = self.widget("config-window"))
     input_window.set_curr_profiles(self.widget("profile-combobox").get_model())
     input_window.set_curr_profile_selection(True)
     responce = input_window.run()
     if responce == gtk.RESPONSE_ACCEPT:
         text = input_window.get_text().strip()
         if len(text) > 0:
             (profile, config_file) = input_window.get_curr_profile()
             self._create_new_profile(text, profile, config_file)
     input_window.destroy()
Beispiel #7
0
    def __init__(self, *arg):
        gtk.Entry.__init__(self, *arg)
        #gtk.CellEditable.__init__(self, *arg)
        self.set_editable(False)
        
        self.hwindow = gtk.Window()
        self.hwindow.set_position(gtk.WIN_POS_MOUSE)
        self.hwindow.set_decorated(False)
        vbox = gtk.VBox()
        self.liststore = liststore = gtk.ListStore(str)
        self.treeview = treeview = gtk.TreeView(liststore)
        self.hwindow.set_default_size(200,  300)
        
        textrenderer = gtk.CellRendererText()
        textrenderer.connect("edited", self._treeview_changed, "param")
        textrenderer.set_property("editable", True)
        treeview.insert_column_with_attributes(0, _("Param"), textrenderer, text=0)

        treeview.set_headers_visible(True)
        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw.add(treeview)
        vbox.pack_start(sw, expand=True, fill=True, padding=0)
        addbutton = gtk.Button(stock=gtk.STOCK_ADD)
        removebutton = gtk.Button(stock=gtk.STOCK_REMOVE)
        addbutton.connect("clicked", self.add_entry)
        removebutton.connect("clicked", self.remove_entry)
        buttonbox = gtk.HButtonBox()
        buttonbox.add(removebutton)
        buttonbox.add(addbutton)
        vbox.pack_start(buttonbox, expand=False, fill=True, padding=0)
        self.hwindow.add(vbox)
        self.hwindow.show_all()
Beispiel #8
0
 def __init__(self, **args):
     if 'label' in args:
         gtk.Frame.__init__(self, label=_("Info for %s:") % args['label'])
     else:
         gtk.Frame.__init__(self, label=_("Info:"))
     self.info_display = gtk.TextView()
     scroll = gtk.ScrolledWindow()
     scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
     scroll.add(self.info_display)
     self.add(scroll)
     self.info_display.set_wrap_mode(gtk.WRAP_WORD)
     self.info_buffer = self.info_display.get_buffer()
     self.info_buffer.create_tag(
         "warning",
         foreground='red'
     )
Beispiel #9
0
    def _create_menu(self):
        self.traymenu = gtk.Menu()

        self.profilemenu = gtk.Menu()
        menuitem = gtk.MenuItem(_("Profiles"))
        menuitem.set_submenu(self.profilemenu)
        self._fill_profile_menu()
        menuitem.show()
        self.traymenu.add(menuitem)

        menuitem = gtk.SeparatorMenuItem()
        menuitem.show()
        self.traymenu.append(menuitem)

        if self.bluecontrol:
            for menuitem in self.bluecontrol.get_menus():
                self.traymenu.append(menuitem)

        # Configuration editor
        menuitem = gtk.ImageMenuItem(stock_id=gtk.STOCK_PREFERENCES)
        menuitem.connect("activate", self.show_config)
        menuitem.show()
        self.traymenu.append(menuitem)

        menuitem = gtk.SeparatorMenuItem()
        menuitem.show()
        self.traymenu.append(menuitem)

        menuitem = gtk.ImageMenuItem(stock_id=gtk.STOCK_QUIT)
        menuitem.connect("activate", self.quit)
        menuitem.show()
        self.traymenu.append(menuitem)
        self.traymenu.show()
Beispiel #10
0
 def _query_fileselection(self, base=None):
     """
     Create a fileselection menu. I{base} refers to the directory the selection
     is created for. If base is not supplied, the users home directory will be used.
     """
     self.querymap = []
     if not base:
         base = osp.expanduser("~")
     files = os.listdir(base)
     for file in files:
         if file[0] == ".":
             continue
         fullname = osp.join(base, file)
         file = file.decode('utf-8')
         if osp.isfile(fullname):
             self.querymap.append((file, fullname, 'f'))
         elif osp.isdir(fullname):
             self.querymap.append(("[" + file + "]", fullname, 'd'))
     def sort_filelist(a, b):
         if a[2] == b[2]:
             return cmp(a[0], b[0])
         else:
             if a[2] == 'd':
                 return -1
             else:
                 return 1
     self.querymap.sort(sort_filelist)
     self.querymap.insert(0, ("[..]", osp.normpath(osp.join(base, "..")), 'd'))
     self.querytype = 'fileselection'
     btconnection = self.bluetooth_connector.get_bt_connection()
     btconnection.send_list_query(_("Select file"), 
                                  [i[0] for i in self.querymap],
                                  self._handle_list_reply)
Beispiel #11
0
 def write(self):
     """
     Write user configuration to file
     """
     try:
         self._write_config(self.paths.get_userconfigfile(), self.user)
     except Exception, e:
         logging.error(_("Could not write config file: %s\n%s") % (self.paths.get_userconfigfile(), str(e)))
Beispiel #12
0
 def _read_config(absfilename):
     """
     Parse configuration from file
     
     @param absfilename:    Filename to read data from
     """
     config_hash = {}
     try:
         config_file = open(absfilename)
         config_data = config_file.read()
         config_hash = json.read(config_data)
         config_file.close()
     except IOError:
         logging.getLogger('LBRC.Config').exception(
                             _("Error while opening: %s") % absfilename)
     except json.ReadException:
         logging.getLogger('LBRC.Config').exception(
                             _("Error while interpreting json data in file: %s") % absfilename)
     return config_hash
Beispiel #13
0
 def _write_config(absfilename, source_config_data):
     """
     Serialize configuration stored in C{config} and write to file
     
     @param    absfilename:    Filename to store config in
     @type     absfilename:    String
     @param    config:         dictionary holding the config data
     @type     config:         dictionary
     """
     try:
         config_file = open(absfilename, 'w')
         config_data = json.write(source_config_data, pretty_print=True)
         config_file.write(config_data)
         config_file.close()
     except IOError:
         logging.getLogger('LBRC.Config').exception(
                             _("Error while writing to: %s") % absfilename)
     except json.ReadException:
         logging.getLogger('LBRC.Config').exception(
                             _("Error while encoding config data to json"))
Beispiel #14
0
 def on_profile_rename_button_clicked(self, object):        
     input_window = ProfileQueryWindow(query=_("New Name"),
                                title=_("Specify the new name for the new profile"), 
                                parent = self.widget("config-window"))
     input_window.set_curr_profiles(self.widget("profile-combobox").get_model())
     responce = input_window.run()
     if responce == gtk.RESPONSE_ACCEPT:
         text = input_window.get_text().strip()
         iter = self.widget("profile-combobox").get_active_iter()
         if len(text) > 0 and not text in self.user_profiles and iter:
             model = self.widget("profile-combobox").get_model()
             data = model.get(iter,1,2)       
             if data[1] == "user":
                 model.set(iter, 0, text, 1, text)
                 self.user_profiles[text] = self.user_profiles[data[0]]
                 del(self.user_profiles[data[0]])
                 self.modified = True
                 self._fill_profiles(select_item = text)
                 self.update_configs()
     input_window.destroy()
Beispiel #15
0
 def reread(self):
     """
     Reread config from disk. There is no distinction between system and user config
     files. Both will be reread.
     """
     self.user = None
     self.system = None
     try:
         self.user = self._read_config(self.paths.get_userconfigfile())
     except IOError:
         self.logger.debug(_("Could not open config file: %s"), self.paths.get_userconfigfile())
     
     if not self.user:
         self.user = {}
         self.user['generic-config'] = {}
         self.user['profiles'] = {}
     try:
         self.system = self._read_config(self.paths.get_systemconfigfile())
     except IOError:
         self.logger.debug(_("Could not open config file: %s"), self.paths.get_systemconfigfile())
     
     if not self.system:
         self.system = {}
         self.system['generic-config'] = {}
         self.system['profiles'] = {}
 
     self.profile_index = []
     try:
         self.profile_index.extend([('system', profile_name) for profile_name in self.system['profiles']])
     except KeyError:
         self.logger.debug("Error while adding system profiles - None defined?")
     try:
         self.profile_index.extend([('user', profile_name) for profile_name in self.user['profiles']])
     except KeyError:
         self.logger.debug("Error while adding user profiles - Probably none defined!")
     # pylint: disable-msg=E1101
     self.emit('config-reread')
Beispiel #16
0
 def _read_config(absfilename):
     """
     Parse configuration from file
     
     @param absfilename:    Filename to read data from
     """
     config = {}
     try:
          config_file = open(absfilename)
          config_data = config_file.read()
          config = cjson.decode(config_data)
          config_file.close()
     except Exception, e:
          logging.error(_("Could not read config file: %s\n%s") % (absfilename, str(e)))
          config = {}
Beispiel #17
0
 def _read_config(absfilename):
     """
     Parse configuration from file
     
     @param absfilename:    Filename to read data from
     """
     config = {}
     try:
          config_file = open(absfilename)
          config_data = config_file.read()
          config = json.read(config_data)
          config_file.close()
     except Exception, e:
          logging.getLogger('LBRC.Config').exception(_("Could not read config file: %s") % absfilename)
          config = {}
Beispiel #18
0
 def __init__(self, query="", title = "", parent = None):
     gtk.Dialog.__init__(self, title, parent, gtk.DIALOG_MODAL, 
                             (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, 
                              gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
     self.cancel_button = None
     self.ok_button = None
     self.action_area.foreach(self.get_buttons)
     
     self.datamodel = gtk.ListStore(str, str, str)
     self.userprofiles = []
     
     table = gtk.Table(2, 3)
     
     self.pcombobox = gtk.ComboBox()
     self.pcombobox.set_model(self.datamodel)
     self.plabel = gtk.Label(_("Basisprofile") + ": ")
     renderer = gtk.CellRendererText()
     self.pcombobox.pack_start(renderer)
     self.pcombobox.add_attribute(renderer, "text", 0)
     
     label = gtk.Label(title)
     label2 = gtk.Label(query + ": ")
     self.input_entry = gtk.Entry()
     
     self.vbox.add(label)
     self.vbox.add(table)
     
     self.warn_name_label = gtk.Image()
     self.warn_name_label.set_from_stock(gtk.STOCK_DIALOG_WARNING, 
                                         gtk.ICON_SIZE_SMALL_TOOLBAR)
     
     table.attach(self.plabel, 0, 1, 0, 1, xoptions=gtk.FILL, 
                                           yoptions=gtk.FILL)
     table.attach(self.pcombobox, 1, 3, 0, 1, xoptions=gtk.EXPAND|gtk.FILL, 
                                              yoptions=gtk.FILL)
     table.attach(label2, 0, 1, 1, 2, xoptions=gtk.FILL, yoptions=gtk.FILL)
     table.attach(self.warn_name_label, 1, 2, 1, 2, xoptions=gtk.FILL, 
                                                    yoptions=gtk.FILL)
     table.attach(self.input_entry, 2, 3, 1, 2, xoptions=gtk.EXPAND|gtk.FILL, 
                                                yoptions=gtk.FILL)
     
     self.input_entry.connect("changed", self.check_text)
     self.check_text(self.input_entry)
     
     self.input_entry.show()
     label.show()
     label2.show()
     table.show()
Beispiel #19
0
    def _fill_profiles(self, select_item = None):
        """Fills the profile-combobox widget"""
        profile = self.widget("profile-combobox")
        
        last_active = profile.get_active()

        # 1 => Displayname, 2 => profile, 3 => config
        profile_model = gtk.ListStore(str, str, str)

        for i in sorted(self.system_profiles.keys()):
            itemname = '%s (%s)' % (i, _("System"))
            profile_model.append((itemname, i, "system"))
        
        select_iter = None
        
        for i in sorted(self.user_profiles.keys()):
            iter = profile_model.append((i, i, "user"))
            if i == select_item:
                select_iter = iter
            
        profile.set_model(profile_model)

        if select_iter:
            profile.set_active_iter(select_iter)
Beispiel #20
0
    def _fill_profile_menu(self):
        profilemenu = self.profilemenu

        def cleanup(menu_entry, menu):
            menu_entry.disconnect(menu_entry.handler)
            menu.remove(menu_entry)

        profilemenu.foreach(cleanup, profilemenu)

        self.pid_menu_map = {}
        group = None

        def sort_func(first, second):
            if first[0] == second[0]:
                return cmp(first[1], second[1])
            elif first[0] == "system":
                return -1
            else:
                return 1

        for (config, profile) in sorted(self.lbrc_profile.get_profiles(), cmp=sort_func):
            itemname = None
            if config == "system":
                itemname = "%s (%s)" % (profile, _("System"))
            else:
                itemname = profile

            menuitem = gtk.RadioMenuItem(group, itemname)
            group = menuitem
            menuitem.config = config
            menuitem.pid = profile
            id = menuitem.connect("toggled", self.profile_change)
            menuitem.handler = id
            menuitem.show_all()
            self.pid_menu_map[(config, profile)] = menuitem
            profilemenu.append(menuitem)
Beispiel #21
0
    def __init__(self, config):
        ConfigWindowWidget.__init__(self, config)
        
        expander = gtk.Expander(_("Actions"))
        expander.set_expanded(True)
        expander.connect("activate", self.on_expander_activate)
        
        vbox = gtk.VBox()
        
        infobox = InfoWindow()
        text = "Beware! This module is  deprecated and only provided for " + \
               "backward compatibility. It will probaly removed from the " + \
               "programm in the next release"
        infobox.set_text(text, type="warning")
        vbox.pack_start(infobox, expand=False, fill=True, padding=5)
        
        hbuttonbox = gtk.HButtonBox()
        hbuttonbox.set_layout(gtk.BUTTONBOX_START)
        self.addbutton = addbutton = gtk.Button(stock="gtk-add")
        self.removebutton = removebutton = gtk.Button(stock="gtk-remove")
        addbutton.connect("clicked", self.on_addbutton_clicked)
        removebutton.connect("clicked", self.on_removebutton_clicked)
        
        self.treeview = treeview = gtk.TreeView()
        
        textrenderer = gtk.CellRendererText()
        textrenderer.connect("edited", self._treeview_changed, "keycode")
        textrenderer.set_property("editable", True)
        treeview.insert_column_with_attributes(
            0, 
            _("Cellphone keycode"), 
            textrenderer, 
            text=0
        )
        
        comborenderer = gtk.CellRendererCombo()
        comborenderer.connect("edited", self._treeview_changed, "type")
        mylist = gtk.ListStore(str)
        for i in types_values.values():
            mylist.append([i[4]])
        comborenderer.set_property("model", mylist)
        comborenderer.set_property("text-column", 0)
        comborenderer.set_property("editable", True)
        comborenderer.set_property("has-entry", False)
        treeview.insert_column_with_attributes(
            1, 
            _("Event type"), 
                comborenderer,
                text=5
            )
 
        comborenderer = gtk.CellRendererCombo()
        comborenderer.connect("edited", self._treeview_changed, "event")
        comborenderer.set_property("text-column", 0)
        comborenderer.set_property("editable", True)
        #comborenderer.set_property("has-entry", True)           
        treeview.insert_column_with_attributes(
            2, 
            _("Event generated"), 
            comborenderer,
            model=7,
            has_entry=8,
            text=1
        )
        
        textrenderer = gtk.CellRendererText()
        textrenderer.connect("edited", self._treeview_changed, "repeat")
        textrenderer.set_property("editable-set", True)
        treeview.insert_column_with_attributes(
            3, 
            _("Repeatfrequency"), 
            textrenderer,
            text=2,
            editable = 6,
            visible=6
        )
        treeview.get_column(0).set_resizable(True)
        treeview.get_column(0).set_sort_column_id(0)
        treeview.get_column(1).set_resizable(True)
        treeview.get_column(1).set_sort_column_id(5)
        treeview.get_column(2).set_resizable(True)
        treeview.get_column(2).set_sort_column_id(1)
        
        hbuttonbox.add(addbutton)
        hbuttonbox.add(removebutton)
        
        scrolled = gtk.ScrolledWindow()
        scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        scrolled.add(treeview)
        
        vbox.pack_start(hbuttonbox, expand=False, fill=True, padding=0)
        vbox.pack_start(scrolled, expand=True, fill=True, padding=0)
        expander.add(vbox)
        self.pack_start(expander, expand=True, fill=True, padding=0)
        
        self.show_all()
Beispiel #22
0
 def disconnect_cb(self, btname, btaddress, port):
     self.notify(_("Disconnect from:\n%(btname)s (%(btaddress)s)") % {"btname": btname, "btaddress": btaddress})
Beispiel #23
0
if __name__ == "__main__":
    path.scriptpath = osp.join(osp.dirname(osp.abspath(sys.argv[0])), "..")

LBRC.l10n.init_glade_gettext()

# Backgrounddata for events
# key is event type
# 0 => event mappings allowed apart from the predefined onces (see [1])
# 1 => event mappings
# 2 => gtk-liststore of [1]
# 3 => is this repeatable?
# 4 => Translated Description of the event type
types_values = {
                'key': [True, ["LEFTCTRL", "LEFTALT", "RIGHTCTRL", "RIGHTALT",
                               "UP", "DOWN", "LEFT", "RIGHT", "PAGEUP", "PAGEDOWN", 
                               "ENTER", "SPACE", "BACKSPACE", "HOME", "END"], None, True, _('KEYBOARD')],
                'mousebutton': [False, ["LEFT", "MIDDLE", "RIGHT", "MOUSE", "FORWARD", "BACK", "TOUCH"], None, False, _('MOUSE BUTTON')],
                'mousewheel': [False, ["+WHEEL", "-WHEEL", "+HWHEEL", "-HWHEEL"], None, True, _('MOUSE WHEEL')],
                'mouseaxis': [False, ["+X", "-X", "+Y", "-Y", "+Z", "-Z"], None, False, _('MOUSE AXIS')]
                }

x_types_values = {
                'key': [True, [], None, True, _('KEYBOARD')],
                'mousebutton': [False, ["1", "2", "3", "4", "5", "6", "7"], None, False, _('MOUSE BUTTON')],
                'mouseaxis': [False, ["+X", "-X", "+Y", "-Y", "+Z", "-Z"], None, False, _('MOUSE AXIS')]
                }

# Fill with Numbers
for i in xrange(0,10):
    types_values['key'][1].append(str(i))
Beispiel #24
0
 def profile_change_cb(self, config, profile):
     self.notify(_("Profile changed:\n%(profilename)s") % {"profilename": profile})
     self.pid_menu_map[(config, profile)].set_active(1)
Beispiel #25
0
    def __init__(self, config, subaction, modules):
        gtk.VBox.__init__(self)
        self.current_profileid = None;
        self.current_profilesource = None;
        self.modules = modules
        self.subaction = subaction
        scrolledwindow = gtk.ScrolledWindow()
        scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.treeview = treeview = gtk.TreeView()
        treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
        self.treeview.set_grid_lines(True)
        scrolledwindow.add(treeview)
        self.pack_start(scrolledwindow, True, True, 0)
        buttonbox = gtk.HButtonBox()
        buttonbox.set_homogeneous(True)
        buttonbox.set_layout(gtk.BUTTONBOX_END)
        self.new_button = gtk.Button(label="", stock=gtk.STOCK_NEW)
        self.delete_button = gtk.Button(label="", stock=gtk.STOCK_DELETE)
        self.delete_button.connect("clicked", self.remove_entry)
        buttonbox.pack_start(self.new_button);
        buttonbox.pack_start(self.delete_button);
        self.pack_start(buttonbox, False, True, 0)
        offset = 0
        if subaction == 'actions':
            textrenderer = gtk.CellRendererText()
            #textrenderer.connect("edited", self._treeview_changed, "repeat")
            #textrenderer.set_property("editable-set", True)
            treeview.insert_column_with_attributes(
                        0, 
                        _("Keycode"), 
                        textrenderer,
                        text=0)
            textrenderer = gtk.CellRendererText()
            #textrenderer.connect("edited", self._treeview_changed, "repeat")
            #textrenderer.set_property("editable-set", True)
            treeview.insert_column_with_attributes(
                        1, 
                        _("Map"), 
                        textrenderer,
                        text=1)
            offset = 2

        textrenderer = gtk.CellRendererText()
        #textrenderer.connect("edited", self._treeview_changed, "repeat")
        #textrenderer.set_property("editable-set", True)
        treeview.insert_column_with_attributes(
                    offset, 
                    _("Module"), 
                    textrenderer,
                    text=2)
        textrenderer = gtk.CellRendererText()
        #textrenderer.connect("edited", self._treeview_changed, "repeat")
        #textrenderer.set_property("editable-set", True)
        treeview.insert_column_with_attributes(
                    offset+1, 
                    _("Description"), 
                    textrenderer,
                    text=3)      
        
        for i in xrange(0, offset+2):
            treeview.get_column(i).set_resizable(True)
            treeview.get_column(i).set_sort_column_id(i+offset)     
        
        self.config = config
        self.editable = False
        self.entries = gtk.ListStore(str, str, str, str, gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT)