Esempio n. 1
0
    def __init__(self, config, section, key):
        self.key = key
        """Section key or key modifier."""
        data = dict(config._config.items(section))
        self.ignored_actions = set()
        """List of ignored actions."""
        if 'ignore_actions' in data:
            ignored_actions = data.get('ignore_actions', '').split(', ')
            self.ignored_actions.update(ignored_actions)
        self.ignored_actions.update(config.ignored_actions)
        if 'grid' in self.ignored_actions:
            self.ignored_actions.update(['grid_width', 'grid_height'])

        self.gravity = Gravity.parse(data.get('gravity', ''))
        """Gravity."""
        self.direction = Gravity.parse(data.get('direction', ''))
        """Direction of window movement."""
        if not self.direction:
            self.direction = self.gravity
        self.position  = Gravity.parse(data.get('position', ''))
        """Position position on :ref:`workarea`."""
        if not self.position:
            self.position = self.gravity
        elif self.position and not self.gravity:
            self.gravity = self.position
        self.size = Size.parse(data.get('widths', ''), 
                               data.get('heights', ''))
        """Window size(s)."""
Esempio n. 2
0
    def __init__(self, config, section, key):
        self.key = key
        data = dict(config._config.items(section))
        self.ignored = set()
        if 'ignore_actions' in data:
            self.ignored.update(data.get('ignore_actions', '').split(', '))
        self.ignored.update(config.ignored)
        if 'grid' in self.ignored:
            self.ignored.update(['grid_width', 'grid_height'])

        self.gravity = Gravity.parse(data.get('gravity', ''))
        self.direction = Gravity.parse(data.get('direction', ''))
        if not self.direction:
            self.direction = self.gravity
        self.position = Gravity.parse(data.get('position', ''))
        if not self.position:
            self.position = self.gravity
        elif self.position and not self.gravity:
            self.gravity = self.position
        self.size = Size.parse(data.get('widths', ''), data.get('heights', ''))
Esempio n. 3
0
    def __init__(self, config, section, key):
        self.key = key
        data = dict(config._config.items(section))
        self.ignored = set()
        if 'ignore_actions' in data:
            self.ignored.update(data.get('ignore_actions', '').split(', '))
        self.ignored.update(config.ignored)
        if 'grid' in self.ignored:
            self.ignored.update(['grid_width', 'grid_height'])

        self.gravity = Gravity.parse(data.get('gravity', ''))
        self.direction = Gravity.parse(data.get('direction', ''))
        if not self.direction:
            self.direction = self.gravity
        self.position  = Gravity.parse(data.get('position', ''))
        if not self.position:
            self.position = self.gravity
        elif self.position and not self.gravity:
            self.gravity = self.position
        self.size = Size.parse(data.get('widths', ''), 
                               data.get('heights', ''))
Esempio n. 4
0
def gravity_callback(option, opt_str, value, parser):
    """Parse gravity, direction, position options to Gravity."""
    largs_callback(option, opt_str, value, parser)
    try:
        gravity = Gravity.parse(value)
    except ValueError:
        msg = 'option %s: error parsing Gravity value: %s' % (opt_str, value)
        raise optparse.OptionValueError(msg)
    setattr(parser.values, option.dest, gravity)
    if option.dest == 'gravity' and not parser.values.position:
        setattr(parser.values, 'position', gravity)
    if option.dest == 'gravity' and not parser.values.direction:
        setattr(parser.values, 'direction', gravity)
    if option.dest == 'position' and not parser.values.gravity:
        setattr(parser.values, 'gravity', gravity)
Esempio n. 5
0
 def test_parse(self):
     self.assertEqual(Gravity.parse(''), None)
     self.assertEqual(Gravity.parse('TOP'), self.TOP)
     self.assertEqual(Gravity.parse('UP'), self.TOP)
     self.assertEqual(Gravity.parse('N'), self.TOP)
     self.assertEqual(Gravity.parse('FULL, 0'), self.TOP_RIGHT)
     self.assertEqual(Gravity.parse('FULL, 0.0'), self.TOP_RIGHT)
     self.assertEqual(Gravity.parse('1, 0'), self.TOP_RIGHT)
     self.assertEqual(Gravity.parse('1,0'), self.TOP_RIGHT)
     self.assertEqual(Gravity.parse('1.0, 0.0'), self.TOP_RIGHT)
     self.assertEqual(Gravity.parse('1.0,0.0'), self.TOP_RIGHT)
     self.assertEqual(Gravity.parse('HALF, HALF'), self.MIDDLE)
     self.assertEqual(Gravity.parse('HALF, 0.5'), self.MIDDLE)
     self.assertEqual(Gravity.parse('HALF, 1.0/2'), self.MIDDLE)
     self.assertEqual(Gravity.parse('0.5, 1.0-0.5'), self.MIDDLE)
     self.assertEqual(Gravity.parse('0.25*2, 2.0/2-0.5'), self.MIDDLE)
     self.assertEqual(Gravity.parse('QUARTER*2, FULL/2'), self.MIDDLE)
     self.assertRaises(ValueError, Gravity.parse, 'top')
     self.assertRaises(ValueError, Gravity.parse, 'slkfsk')
     self.assertRaises(ValueError, Gravity.parse, '1.0')
     self.assertRaises(ValueError, Gravity.parse, '1,2,3')