2
# -*- coding: utf-8 -*-
5
# J Phani Mahesh <phanimahesh@gmail.com>
6
# Barneedhar (jokerdino) <barneedhar@ubuntu.com>
7
# Amith KK <amithkumaran@gmail.com>
8
# Georgi Karavasilev <motorslav@gmail.com>
9
# Sam Tran <samvtran@gmail.com>
10
# Sam Hewitt <hewittsamuel@gmail.com>
11
# Angel Araya <al.arayaq@gmail.com>
14
# A One-stop configuration tool for Unity.
18
# This file is a part of Unity Tweak Tool
20
# Unity Tweak Tool is free software; you can redistribute it and/or modify it under
21
# the terms of the GNU General Public License as published by the Free Software
22
# Foundation; version 3.
24
# Unity Tweak Tool is distributed in the hope that it will be useful, but WITHOUT
25
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
26
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
29
# You should have received a copy of the GNU General Public License along with
30
# this program; if not, see <https://www.gnu.org/licenses/gpl-3.0.txt>
32
''' Definitions for cbox element. '''
33
from UnityTweakTool.backends import gsettings
36
logger=logging.getLogger('UnityTweakTool.elements.cbox')
39
def __init__(self,controlObj):
40
''' Initialise a ComboBox element from a dictionary'''
41
self.id = controlObj['id']
42
self.ui = controlObj['builder'].get_object(controlObj['id'])
43
self.schema = controlObj['schema']
44
self.path = controlObj['path']
45
self.key = controlObj['key']
46
self.type = controlObj['type']
47
self.map = controlObj['map']
48
self.invmap = dict([ (v,k) for (k,v) in self.map.items() ])
49
assert gsettings.is_valid(
54
logger.debug('Initialised a ComboBox with id {self.id} to control key {self.key} of type {self.type} in schema {self.schema} with path {self.path}'.format(self=self))
56
def register(self,handler):
57
''' register handler on a handler object '''
58
handler['on_%s_changed'%self.id]=self.handler
59
logger.debug('Handler for {self.id} registered'.format(self=self))
62
''' Refresh UI reading from backend '''
63
logger.debug('Refreshing UI display for {self.id}'.format(self=self))
75
def handler(self,*args,**kwargs):
76
''' handle toggle signals '''
82
value=self.invmap[self.ui.get_active()]
84
logger.info('Handler for {self.id} executed'.format(self=self))
87
''' Reset the controlled key '''
88
gsettings.reset(schema=self.schema,path=self.path,key=self.key)
89
logger.debug('Key {self.key} in schema {self.schema} and path {self.path} reset.'.format(self=self))