Skip to content

Commit

Permalink
Set up gsettings
Browse files Browse the repository at this point in the history
  • Loading branch information
phanimahesh committed Jan 16, 2013
0 parents commit bdec5cd
Show file tree
Hide file tree
Showing 83 changed files with 15,379 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
@@ -0,0 +1,4 @@
__pycache__
*~
*.bak
build
Empty file added .is-devel-dir
Empty file.
691 changes: 691 additions & 0 deletions COPYING

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions MANIFEST.in
@@ -0,0 +1 @@
include COPYING
4 changes: 4 additions & 0 deletions README.md
@@ -0,0 +1,4 @@
unity-tweak-tool
========

Unity Tweak Tool - Unity configuration tool
49 changes: 49 additions & 0 deletions UnityTweakTool/__init__.py
@@ -0,0 +1,49 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Team:
# J Phani Mahesh <phanimahesh@gmail.com>
# Barneedhar (jokerdino) <barneedhar@ubuntu.com>
# Amith KK <amithkumaran@gmail.com>
# Georgi Karavasilev <motorslav@gmail.com>
# Sam Tran <samvtran@gmail.com>
# Sam Hewitt <hewittsamuel@gmail.com>
#
# Description:
# A One-stop configuration tool for Unity.
#
# Legal Stuff:
#
# This file is a part of Unity Tweak Tool
#
# Unity Tweak Tool is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; version 3.
#
# Unity Tweak Tool is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see <https://www.gnu.org/licenses/gpl-3.0.txt>

# List of all subpackages that can be imported using
# from UnityTweakTool import *
__all__=['backends','config','elements']

import logging

logger=logging.getLogger('UnityTweakTool')
logger.setLevel(logging.DEBUG)

# TODO : give a sensible logfile name.
_fh=logging.FileHandler(logfile)
_fh.setLevel(logging.DEBUG)

_formatter=logging.Formatter('%(asctime)s - %(levelname)-8s :: %(name)s - %(funcName)s - %(message)s')

_fh.setFormatter(_formatter)
logger.setHandler(_fh)

del _fh, _formatter
1 change: 1 addition & 0 deletions UnityTweakTool/backends/__init__.py
@@ -0,0 +1 @@
#! /usr/bin/env python3
88 changes: 88 additions & 0 deletions UnityTweakTool/backends/gsettings.py
@@ -0,0 +1,88 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Team:
# J Phani Mahesh <phanimahesh@gmail.com>
# Barneedhar (jokerdino) <barneedhar@ubuntu.com>
# Amith KK <amithkumaran@gmail.com>
# Georgi Karavasilev <motorslav@gmail.com>
# Sam Tran <samvtran@gmail.com>
# Sam Hewitt <hewittsamuel@gmail.com>
#
# Description:
# A One-stop configuration tool for Unity.
#
# Legal Stuff:
#
# This file is a part of Unity Tweak Tool
#
# Unity Tweak Tool is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; version 3.
#
# Unity Tweak Tool is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see <https://www.gnu.org/licenses/gpl-3.0.txt>

# This file contains the bindings to Gio.Settings
from gi.repository import Gio
import logging

logger=logging.getLogger('UnityTweakTool.backends.gsettings')

all_schemas = frozenset(
Gio.Settings.list_schemas()
)
all_relocatable_schemas = frozenset(
Gio.Settings.list_relocatable_schemas()
)

GSettings = dict()


def is_valid(*,schema,key=None,path=None):
if schema in all_schemas:
if key is not None:
return key in Gio.Settings(schema).list_keys()
else:
return True
if schema in all_relocatable_schemas:
if key is not None:
assert path is not None, 'Relocatable schemas must be accompanied with path'
return key in Gio.Settings(schema,path).list_keys()
else:
return True

# get_<type> and set_<type> are available for the following in Gio.Settings
VALID_TYPES=frozenset([
'boolean',
'int',
'uint',
'double',
'string',
'strv',
'enum',
'flags'
])

def get(*,schema,key,type,path=None):
_suffix=':'+path if path is not None else ''
try:
_gs=GSettings[schema+_suffix]
except KeyError as e:
_gs=Gio.Settings(schema,path)
return _gs.__getattr__('get_'+type)(key)

def set(*,schema,key,type,path=None,value):
_suffix=':'+path if path is not None else ''
try:
_gs=GSettings[schema+_suffix]
except KeyError as e:
_gs=Gio.Settings(schema,path)
# TODO : check if value is legal, if possible.
return _gs.__setattr__('set_'+type)(key,value)

1 change: 1 addition & 0 deletions UnityTweakTool/config/__init__.py
@@ -0,0 +1 @@
#! /usr/bin/env python3
34 changes: 34 additions & 0 deletions UnityTweakTool/config/logging.py
@@ -0,0 +1,34 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Team:
# J Phani Mahesh <phanimahesh@gmail.com>
# Barneedhar (jokerdino) <barneedhar@ubuntu.com>
# Amith KK <amithkumaran@gmail.com>
# Georgi Karavasilev <motorslav@gmail.com>
# Sam Tran <samvtran@gmail.com>
# Sam Hewitt <hewittsamuel@gmail.com>
#
# Description:
# A One-stop configuration tool for Unity.
#
# Legal Stuff:
#
# This file is a part of Unity Tweak Tool
#
# Unity Tweak Tool is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; version 3.
#
# Unity Tweak Tool is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see <https://www.gnu.org/licenses/gpl-3.0.txt>

# This file should control the logging setup for entire application
# TODO : Decide if logger initialisations go here or in UTT.__init__
# Also decide a logfile name.
# LOGFILE =
31 changes: 31 additions & 0 deletions UnityTweakTool/config/u1sync.py
@@ -0,0 +1,31 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Team:
# J Phani Mahesh <phanimahesh@gmail.com>
# Barneedhar (jokerdino) <barneedhar@ubuntu.com>
# Amith KK <amithkumaran@gmail.com>
# Georgi Karavasilev <motorslav@gmail.com>
# Sam Tran <samvtran@gmail.com>
# Sam Hewitt <hewittsamuel@gmail.com>
#
# Description:
# A One-stop configuration tool for Unity.
#
# Legal Stuff:
#
# This file is a part of Unity Tweak Tool
#
# Unity Tweak Tool is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; version 3.
#
# Unity Tweak Tool is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see <https://www.gnu.org/licenses/gpl-3.0.txt>

# Any Unity One Sync settings should appear here.
1 change: 1 addition & 0 deletions UnityTweakTool/elements/__init__.py
@@ -0,0 +1 @@
#! /usr/bin/env python3
Empty file added UnityTweakTool/elements/cbox.py
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file added UnityTweakTool/elements/spin.py
Empty file.
Empty file.
Empty file.
46 changes: 46 additions & 0 deletions data/about.ui
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkAboutDialog" id="about_unitytweak">
<property name="can_focus">False</property>
<property name="border_width">5</property>
<property name="resizable">False</property>
<property name="default_width">70</property>
<property name="type_hint">dialog</property>
<property name="program_name">Unity Tweak Tool</property>
<property name="version">0.0.2</property>
<property name="copyright" translatable="yes">Copyright © 2013 Freyja Development team</property>
<property name="comments" translatable="yes">Unity Tweak Tool is a settings manager intended to be used with Ubuntu Unity.</property>
<property name="website">https://launchpad.net/unity-tweak-tool</property>
<property name="website_label" translatable="yes">Unity Tweak Tool on Launchpad</property>
<property name="license" translatable="yes">GPL3</property>
<property name="authors">J Phani Mahesh &lt;phanimahesh@gmail.com&gt;
Barneedhar (jokerdino) &lt;barneedhar@ubuntu.com&gt;
Amith KK &lt;amithkumaran@gmail.com&gt;
Georgi Karavasilev &lt;motorslav@gmail.com&gt;
Sam Tran &lt;samvtran@gmail.com&gt;
Sam Hewitt &lt;hewittsamuel@gmail.com&gt;</property>
<property name="documenters">Barneedhar (jokerdino) &lt;barneedhar@ubuntu.com&gt;</property>
<property name="artists">Sam Hewitt &lt;hewittsamuel@gmail.com&gt;</property>
<property name="license_type">gpl-3-0</property>
<child internal-child="vbox">
<object class="GtkBox" id="box_aboutdialog">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="action_aboutdialog">
<property name="can_focus">False</property>
<property name="layout_style">end</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

0 comments on commit bdec5cd

Please sign in to comment.