Esempio n. 1
0
    def _setup_keybinder(self):
        self._mateconf.connect("keybinding-changed",
                               self._on_keybinding_changed)

        self._keybinder = Keybinder()
        keybinding = self.get_keybinding()
        if (keybinding == None or gtk.accelerator_parse(keybinding) == (0, 0)):
            # Keybinding is not set or invalid, set default keybinding
            keybinding = self.DEFAULT_KEYBINDING
            self.set_keybinding(keybinding)  # try to save it to Gconf
        else:
            keybinding = self.get_keybinding()
        self.bind_keybinding(keybinding)  # use keybindingx
Esempio n. 2
0
 def _setup_keybinder(self):
     self._mateconf.connect("keybinding-changed", self._on_keybinding_changed)
     
     self._keybinder = Keybinder()
     keybinding = self.get_keybinding()
     if (keybinding == None or gtk.accelerator_parse(keybinding) == (0,0)):
         # Keybinding is not set or invalid, set default keybinding
         keybinding = self.DEFAULT_KEYBINDING
         self.set_keybinding(keybinding) # try to save it to Gconf
     else:
         keybinding = self.get_keybinding()
     self.bind_keybinding(keybinding) # use keybindingx
Esempio n. 3
0
class CoreImpl(deskbar.interfaces.Core):
    
    DEFAULT_KEYBINDING = "<Alt>F3"
    
    def __init__(self, modules_dir):
        super(CoreImpl, self).__init__()
        
        self._loaded_modules = 0
        self._inited_modules = 0
        self._start_query_id = 0
        self._last_query = None
        self._stop_queries = True
        
        self._threadpool = ThreadPool(5)
        self._mateconf = GconfStore.get_instance()
        self._history = DeskbarHistory.get_instance(self._mateconf.get_max_history_items())
        self._mateconf.connect("max-history-items-changed", lambda s, num: self._history.set_max_history_items(num))
        
        self._setup_module_loader(modules_dir)
        self._setup_module_list()
        
        self._disabled_module_list = DisabledModuleList()
        self._module_loader.connect ("module-not-initialized", self._disabled_module_list.add)
        
        self._module_installer = ModuleInstaller(self._module_loader)
        
        self._mateconf.connect("default-browser-changed", self._on_default_browser_changed)
        #prevent double notifications
        self.browser = None
        
    def run(self):
        """
        Load modules, set keybinding and create L{deskbar.core.ThreadPool.ThreadPool}
        """
        # Ready to load modules
        self._module_loader.load_all_async()
        
        self._setup_keybinder()
        self._threadpool.start()
        
    def _setup_module_loader(self, modules_dir):
        self._module_loader = ModuleLoader( modules_dir )
        self._module_loader.connect ("modules-loaded", self.on_modules_loaded)
        self._module_loader.connect ("module-initialized", self.on_module_initialized)
    
    def _setup_module_list(self):
        self._module_list = ModuleList ()
        self._mateconf.connect("enabled-modules-changed", self._on_enabled_modules_changed)
        self._module_loader.connect ("module-loaded", self._module_list.update_row_cb)
        self._module_loader.connect ("module-initialized", self._module_list.module_toggled_cb)
        self._module_loader.connect ("module-stopped", self._module_list.module_toggled_cb)
        
    def _setup_keybinder(self):
        self._mateconf.connect("keybinding-changed", self._on_keybinding_changed)
        
        self._keybinder = Keybinder()
        keybinding = self.get_keybinding()
        if (keybinding == None or gtk.accelerator_parse(keybinding) == (0,0)):
            # Keybinding is not set or invalid, set default keybinding
            keybinding = self.DEFAULT_KEYBINDING
            self.set_keybinding(keybinding) # try to save it to Gconf
        else:
            keybinding = self.get_keybinding()
        self.bind_keybinding(keybinding) # use keybindingx
    
    def get_modules_dir(self):
        """
        Get directory where modules are stored
        """
        return self._modules_dir
    
    def get_modules(self):
        """
        Get a list of module
        """
        return self._module_loader.filelist
    
    def get_enabled_modules(self):
        """
        Get a list of class names of enabled modules
        """
        return self._mateconf.get_enabled_modules()
    
    def set_enabled_modules(self, name):
        """
        Set enabled modules
        
        @type name: list of class names 
        """
        if not self._mateconf.set_enabled_modules(name):
            LOGGER.error("Unable to save enabled modules list to MateConf")

    def get_keybinding(self):
        """
        Get keybinding
        
        @return: str
        """
        return self._mateconf.get_keybinding()
    
    def get_min_chars(self):
        return self._mateconf.get_min_chars()
    
    def get_type_delay(self):
        return self._mateconf.get_type_delay()
    
    def get_use_selection(self):
        return self._mateconf.get_use_selection()

    def get_clear_entry(self):
        return self._mateconf.get_clear_entry()
    
    def get_use_http_proxy(self):
        return self._mateconf.get_use_http_proxy()
    
    def get_proxy_host(self):
        return self._mateconf.get_proxy_host()
    
    def get_proxy_port(self):
        return self._mateconf.get_proxy_port()
    
    def get_collapsed_cat(self):
        return self._mateconf.get_collapsed_cat()
    
    def get_window_width(self):
        return self._mateconf.get_window_width()
    
    def get_window_height(self):
        return self._mateconf.get_window_height()
    
    def get_window_x(self):      
        return self._mateconf.get_window_x()      
       
    def get_window_y(self):      
        return self._mateconf.get_window_y()
    
    def get_hide_after_action(self):
        return self._mateconf.get_hide_after_action()
    
    def get_max_history_items(self):
        return self._mateconf.get_max_history_items()
    
    def get_ui_name(self):
        return self._mateconf.get_ui_name()
    
    def get_entry_width(self):
        return self._mateconf.get_entry_width()

    def set_keybinding(self, binding):
        """
        Store keybinding
        """
        if not self._mateconf.set_keybinding(binding):
            LOGGER.error("Unable to save keybinding setting to MateConf")

    def bind_keybinding(self, binding):
        """
        Actually bind keybinding
        """
        if not self._keybinder.bind(binding):
            LOGGER.error("Keybinding is already in use")
        else:
            LOGGER.info("Successfully binded Deskbar to %s", binding)
    
    def set_min_chars(self, number):
        if not self._mateconf.set_min_chars(number):
            LOGGER.error("Unable to save min chars setting to MateConf")
    
    def set_type_delay(self, seconds):
        if not self._mateconf.set_type_delay(seconds):
            LOGGER.error("Unable to save type delay setting to MateConf")
    
    def set_use_selection(self, val):
        if not self._mateconf.set_use_selection(val):
            LOGGER.error("Unable to save use selection setting to MateConf")

    def set_clear_entry(self, val):
        if not self._mateconf.set_clear_entry(val):
            LOGGER.error("Unable to save clear entry setting to MateConf")
    
    def set_use_http_proxy(self, val):
        if not self._mateconf.set_use_http_proxy(val):
            LOGGER.error("Unable to save http proxy setting to MateConf")
    
    def set_proxy_host(self, host):
        if not self._mateconf.set_proxy_host(host):
            LOGGER.error("Unable to save http proxy host setting to MateConf")
    
    def set_proxy_port(self, port):
        if not self._mateconf.set_proxy_port(port):
            LOGGER.error("Unable to save proxy port setting to MateConf")
    
    def set_collapsed_cat(self, cat):
        if not self._mateconf.set_collapsed_cat(cat):
            LOGGER.error("Unable to save collapsed cat setting to MateConf")
    
    def set_window_width(self, width):
        if not self._mateconf.set_window_width(width):
            LOGGER.error("Unable to save window width setting to MateConf")
    
    def set_window_height(self, height):
        if not self._mateconf.set_window_height(height):
            LOGGER.error("Unable to save window height setting to MateConf")
    
    def set_window_x(self, x):      
        if not self._mateconf.set_window_x(x):     
            LOGGER.error("Unable to save window x position setting to MateConf")
       
    def set_window_y(self, y):      
        if not self._mateconf.set_window_y(y):
            LOGGER.error("Unable to save window y position setting to MateConf")
    
    def set_hide_after_action(self, width):
        if not self._mateconf.set_hide_after_action(width):
            LOGGER.error("Unable to save hide after action setting to MateConf")
    
    def set_max_history_items(self, amount):
        if not self._mateconf.set_max_history_items(amount):
            LOGGER.error("Unable to save max history items setting to MateConf")
        
    def set_ui_name(self, name):
        if not self._mateconf.set_ui_name(name):
            LOGGER.error("Unable to save ui name setting to MateConf")
    
    def set_entry_width(self, width):
        return self._mateconf.set_entry_width(width)

    def get_history(self):
        """
        @return: L{deskbar.core.DeskbarHistory.DeskbarHistory}
        """
        return self._history
    
    def get_module_list(self):
        """
        @return: L{deskbar.core.ModuleList.ModuleList}
        """
        return self._module_list
    
    def get_disabled_module_list(self):
        return self._disabled_module_list
    
    def install_module(self, filename):
        return self._module_installer.install(filename)
    
    def uninstall_module(self, mod):
        raise NotImplementedError
    
    def stop_module(self, mod, async=True):
        if async:
            self._module_loader.stop_module_async(mod)
        else:
            self._module_loader.stop_module(mod)
        self._module_list.decrease_bottom_enabled_path()
Esempio n. 4
0
class CoreImpl(deskbar.interfaces.Core):

    DEFAULT_KEYBINDING = "<Alt>F3"

    def __init__(self, modules_dir):
        super(CoreImpl, self).__init__()

        self._loaded_modules = 0
        self._inited_modules = 0
        self._start_query_id = 0
        self._last_query = None
        self._stop_queries = True

        self._threadpool = ThreadPool(5)
        self._mateconf = GconfStore.get_instance()
        self._history = DeskbarHistory.get_instance(
            self._mateconf.get_max_history_items())
        self._mateconf.connect(
            "max-history-items-changed",
            lambda s, num: self._history.set_max_history_items(num))

        self._setup_module_loader(modules_dir)
        self._setup_module_list()

        self._disabled_module_list = DisabledModuleList()
        self._module_loader.connect("module-not-initialized",
                                    self._disabled_module_list.add)

        self._module_installer = ModuleInstaller(self._module_loader)

        self._mateconf.connect("default-browser-changed",
                               self._on_default_browser_changed)
        #prevent double notifications
        self.browser = None

    def run(self):
        """
        Load modules, set keybinding and create L{deskbar.core.ThreadPool.ThreadPool}
        """
        # Ready to load modules
        self._module_loader.load_all_async()

        self._setup_keybinder()
        self._threadpool.start()

    def _setup_module_loader(self, modules_dir):
        self._module_loader = ModuleLoader(modules_dir)
        self._module_loader.connect("modules-loaded", self.on_modules_loaded)
        self._module_loader.connect("module-initialized",
                                    self.on_module_initialized)

    def _setup_module_list(self):
        self._module_list = ModuleList()
        self._mateconf.connect("enabled-modules-changed",
                               self._on_enabled_modules_changed)
        self._module_loader.connect("module-loaded",
                                    self._module_list.update_row_cb)
        self._module_loader.connect("module-initialized",
                                    self._module_list.module_toggled_cb)
        self._module_loader.connect("module-stopped",
                                    self._module_list.module_toggled_cb)

    def _setup_keybinder(self):
        self._mateconf.connect("keybinding-changed",
                               self._on_keybinding_changed)

        self._keybinder = Keybinder()
        keybinding = self.get_keybinding()
        if (keybinding == None or gtk.accelerator_parse(keybinding) == (0, 0)):
            # Keybinding is not set or invalid, set default keybinding
            keybinding = self.DEFAULT_KEYBINDING
            self.set_keybinding(keybinding)  # try to save it to Gconf
        else:
            keybinding = self.get_keybinding()
        self.bind_keybinding(keybinding)  # use keybindingx

    def get_modules_dir(self):
        """
        Get directory where modules are stored
        """
        return self._modules_dir

    def get_modules(self):
        """
        Get a list of module
        """
        return self._module_loader.filelist

    def get_enabled_modules(self):
        """
        Get a list of class names of enabled modules
        """
        return self._mateconf.get_enabled_modules()

    def set_enabled_modules(self, name):
        """
        Set enabled modules
        
        @type name: list of class names 
        """
        if not self._mateconf.set_enabled_modules(name):
            LOGGER.error("Unable to save enabled modules list to MateConf")

    def get_keybinding(self):
        """
        Get keybinding
        
        @return: str
        """
        return self._mateconf.get_keybinding()

    def get_min_chars(self):
        return self._mateconf.get_min_chars()

    def get_type_delay(self):
        return self._mateconf.get_type_delay()

    def get_use_selection(self):
        return self._mateconf.get_use_selection()

    def get_clear_entry(self):
        return self._mateconf.get_clear_entry()

    def get_use_http_proxy(self):
        return self._mateconf.get_use_http_proxy()

    def get_proxy_host(self):
        return self._mateconf.get_proxy_host()

    def get_proxy_port(self):
        return self._mateconf.get_proxy_port()

    def get_collapsed_cat(self):
        return self._mateconf.get_collapsed_cat()

    def get_window_width(self):
        return self._mateconf.get_window_width()

    def get_window_height(self):
        return self._mateconf.get_window_height()

    def get_window_x(self):
        return self._mateconf.get_window_x()

    def get_window_y(self):
        return self._mateconf.get_window_y()

    def get_hide_after_action(self):
        return self._mateconf.get_hide_after_action()

    def get_max_history_items(self):
        return self._mateconf.get_max_history_items()

    def get_ui_name(self):
        return self._mateconf.get_ui_name()

    def get_entry_width(self):
        return self._mateconf.get_entry_width()

    def set_keybinding(self, binding):
        """
        Store keybinding
        """
        if not self._mateconf.set_keybinding(binding):
            LOGGER.error("Unable to save keybinding setting to MateConf")

    def bind_keybinding(self, binding):
        """
        Actually bind keybinding
        """
        if not self._keybinder.bind(binding):
            LOGGER.error("Keybinding is already in use")
        else:
            LOGGER.info("Successfully binded Deskbar to %s", binding)

    def set_min_chars(self, number):
        if not self._mateconf.set_min_chars(number):
            LOGGER.error("Unable to save min chars setting to MateConf")

    def set_type_delay(self, seconds):
        if not self._mateconf.set_type_delay(seconds):
            LOGGER.error("Unable to save type delay setting to MateConf")

    def set_use_selection(self, val):
        if not self._mateconf.set_use_selection(val):
            LOGGER.error("Unable to save use selection setting to MateConf")

    def set_clear_entry(self, val):
        if not self._mateconf.set_clear_entry(val):
            LOGGER.error("Unable to save clear entry setting to MateConf")

    def set_use_http_proxy(self, val):
        if not self._mateconf.set_use_http_proxy(val):
            LOGGER.error("Unable to save http proxy setting to MateConf")

    def set_proxy_host(self, host):
        if not self._mateconf.set_proxy_host(host):
            LOGGER.error("Unable to save http proxy host setting to MateConf")

    def set_proxy_port(self, port):
        if not self._mateconf.set_proxy_port(port):
            LOGGER.error("Unable to save proxy port setting to MateConf")

    def set_collapsed_cat(self, cat):
        if not self._mateconf.set_collapsed_cat(cat):
            LOGGER.error("Unable to save collapsed cat setting to MateConf")

    def set_window_width(self, width):
        if not self._mateconf.set_window_width(width):
            LOGGER.error("Unable to save window width setting to MateConf")

    def set_window_height(self, height):
        if not self._mateconf.set_window_height(height):
            LOGGER.error("Unable to save window height setting to MateConf")

    def set_window_x(self, x):
        if not self._mateconf.set_window_x(x):
            LOGGER.error(
                "Unable to save window x position setting to MateConf")

    def set_window_y(self, y):
        if not self._mateconf.set_window_y(y):
            LOGGER.error(
                "Unable to save window y position setting to MateConf")

    def set_hide_after_action(self, width):
        if not self._mateconf.set_hide_after_action(width):
            LOGGER.error(
                "Unable to save hide after action setting to MateConf")

    def set_max_history_items(self, amount):
        if not self._mateconf.set_max_history_items(amount):
            LOGGER.error(
                "Unable to save max history items setting to MateConf")

    def set_ui_name(self, name):
        if not self._mateconf.set_ui_name(name):
            LOGGER.error("Unable to save ui name setting to MateConf")

    def set_entry_width(self, width):
        return self._mateconf.set_entry_width(width)

    def get_history(self):
        """
        @return: L{deskbar.core.DeskbarHistory.DeskbarHistory}
        """
        return self._history

    def get_module_list(self):
        """
        @return: L{deskbar.core.ModuleList.ModuleList}
        """
        return self._module_list

    def get_disabled_module_list(self):
        return self._disabled_module_list

    def install_module(self, filename):
        return self._module_installer.install(filename)

    def uninstall_module(self, mod):
        raise NotImplementedError

    def stop_module(self, mod, async=True):
        if async:
            self._module_loader.stop_module_async(mod)
        else:
            self._module_loader.stop_module(mod)
        self._module_list.decrease_bottom_enabled_path()