Beispiel #1
0
    def __init__(self, mounter, actions={}):
        """
        Initialize a new menu maker.

        :param object mounter: mount operation provider
        :param dict actions: actions for menu items
        :returns: a new menu maker
        :rtype: cls

        Required keys for the ``_menu_labels``, ``_menu_icons`` and
        ``actions`` dictionaries are:

            - browse    Open mount location
            - mount     Mount a device
            - unmount   Unmount a device
            - unlock    Unlock a LUKS device
            - lock      Lock a LUKS device
            - eject     Eject a drive
            - detach    Detach (power down) a drive
            - quit      Exit the application

        NOTE: If using a main loop other than ``gtk.main`` the 'quit' action
        must be customized.
        """
        self._mounter = mounter
        setdefault(actions, {
            'browse': mounter.browse,
            'mount': mounter.mount,
            'unmount': mounter.unmount,
            'unlock': mounter.unlock,
            'lock': partial(mounter.remove, force=True),
            'eject': partial(mounter.eject, force=True),
            'detach': partial(mounter.detach, force=True),
            'quit': gtk.main_quit, })
        self._actions = actions
Beispiel #2
0
 def __init__(self, icon_names={}):
     """Merge ``icon_names`` into default icon names."""
     _icon_names = icon_names.copy()
     setdefault(_icon_names, self.__class__._icon_names)
     self._icon_names = _icon_names
     for k, v in _icon_names.items():
         if isinstance(v, basestring):
             self._icon_names[k] = [v]
Beispiel #3
0
 def __init__(self, mounter, actions={}):
     self._mounter = mounter
     self._actions = _actions = actions.copy()
     setdefault(_actions, {
         'browse': mounter.browse,
         'mount': mounter.mount,
         'unmount': mounter.unmount,
         'unlock': mounter.unlock,
         'lock': partial(mounter.remove, force=True),
         'eject': partial(mounter.eject, force=True),
         'detach': partial(mounter.detach, force=True),
     })
Beispiel #4
0
 def program_options(self):
     """Get the program options dictionary from the config file."""
     config_options = self._data.get("program_options", {}).copy()
     setdefault(config_options, self.default_program_options())
     return config_options
Beispiel #5
0
 def program_options(self):
     """Get the program options dictionary from the config file."""
     config_options = self._data.get('program_options', {}).copy()
     setdefault(config_options, self.default_program_options())
     return config_options