~ubuntu-branches/ubuntu/saucy/unity-tweak-tool/saucy-proposed

« back to all changes in this revision

Viewing changes to UnityTweakTool/section/spaghetti/gsettings.py

  • Committer: Package Import Robot
  • Author(s): Barneedhar Vigneshwar, J Phani Mahesh, Barneedhar Vigneshwar
  • Date: 2013-09-16 19:34:38 UTC
  • Revision ID: package-import@ubuntu.com-20130916193438-dw14bzxkohvxub2y
Tags: 0.0.5
[ J Phani Mahesh ]
* New upstream release (LP: #1226059)
  - New application icon 
  - Show error dialog when schemas are missing instead of crashing
  - Trigger new build of pot files
* UnityTweakTool/section/unity.py
  - Fix Show recently used and more suggestions in dash search (LP: #1166294)
  - Fix Launcher reveal sensitivity scale update issues (LP: #1168863)
* UnityTweakTool/elements/colorchooser.py
  - Fix TypeError in get_rgba() (LP: #1165627)
  - Fix segmentation fault on selecting custom launcher (LP: #1190398)
* UnityTweakTool/elements/option.py
  - Fix "Restore defaults" button (LP: #1186634)
* UnityTweakTool/__init__.py  
  - Fix unity-tweak-tool crashed with dbus.exceptions.DBusException in
  call_blocking() (LP: #1168738)
  - Fix FileNotFoundError (LP: #1225463)
  - Fix dbus.exceptions.DBusException (LP: #1170571)
* data/unity.ui
  - Remove Panel transparency switch (LP: #1168836)
  - Remove Launcher transparency switch (LP: #1168834)

[ Barneedhar Vigneshwar ]
* UnityTweakTool/section/unity.py
  - Fix 'Can't set background blur to static' (LP: #1167343)
  - Fix non-working Launcher only on primary desktop (LP: #1173977)
* UnityTweakTool/section/sphagetti/compiz.py
  - Fix TypeError in color_to_hash() (LP: #1166884)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python3
 
2
# -*- coding: utf-8 -*-
 
3
#
 
4
# Team:
 
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>
 
12
#
 
13
# Description:
 
14
#   A One-stop configuration tool for Unity.
 
15
#
 
16
# Legal Stuff:
 
17
#
 
18
# This file is a part of Unity Tweak Tool
 
19
#
 
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.
 
23
#
 
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
 
27
# details.
 
28
#
 
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>
 
31
 
 
32
import sys,os
 
33
from gi.repository import Gio,  Gdk,Gtk
 
34
import UnityTweakTool.config.data as data
 
35
 
 
36
def test_schema(schema):
 
37
    if schema in Gio.Settings.list_relocatable_schemas():
 
38
        pass
 
39
    elif schema in Gio.Settings.list_schemas():
 
40
        pass
 
41
    else:
 
42
        print("Error: schema %s not installed" % schema)
 
43
        builder=Gtk.Builder()
 
44
        builder.set_translation_domain('unity-tweak-tool')
 
45
        ui = os.path.join(data.get_data_path(),'errordialog.ui')
 
46
        builder.add_from_file(ui)
 
47
        dialog = builder.get_object('errordialog')
 
48
        message = schema + "\n\nIn order to work properly, Unity Tweak Tool recommends you install the necessary packages"
 
49
        dialog.format_secondary_text(message)
 
50
        dialog.run()
 
51
        sys.exit()
 
52
 
 
53
def test_key(schema, key):
 
54
    if key in schema.list_keys():
 
55
        return True
 
56
    else:
 
57
        return False
 
58
 
 
59
def plugin(plugin):
 
60
    schema = 'org.compiz.'+plugin
 
61
    path = '/org/compiz/profiles/unity/plugins/'+plugin+'/'
 
62
    test_schema(schema)
 
63
    return Gio.Settings(schema = schema,  path = path)
 
64
 
 
65
def unity(child = None):
 
66
    schema = 'com.canonical.Unity'
 
67
    schema = schema+'.'+child if child else schema
 
68
    test_schema(schema)
 
69
    return Gio.Settings(schema)
 
70
 
 
71
def unity_webapps(child = None):
 
72
    schema = 'com.canonical.unity'
 
73
    schema = schema+'.'+child if child else schema
 
74
    test_schema(schema)
 
75
    return Gio.Settings(schema)
 
76
 
 
77
def canonical(child):
 
78
    schema = 'com.canonical.'+child
 
79
    test_schema(schema)
 
80
    return Gio.Settings(schema)
 
81
 
 
82
def compiz(child):
 
83
    schema = 'org.compiz.'+child
 
84
    test_schema(schema)
 
85
    return Gio.Settings(schema)
 
86
 
 
87
def gnome(child):
 
88
    schema = 'org.gnome.'+child
 
89
    test_schema(schema)
 
90
    return Gio.Settings(schema)
 
91
 
 
92
def color_to_hash(c,alpha=1):
 
93
    """Convert a Gdk.Color or Gdk.RGBA object to hex representation, overriding the alpha if asked"""
 
94
    if isinstance(c, Gdk.Color):
 
95
        return "#{:02x}{:02x}{:02x}{:02x}".format(*[round(x*255) for x in [c.red_float, c.green_float, c.blue_float,alpha]])
 
96
    if isinstance(x, Gdk.RGBA):
 
97
        return "#{:02x}{:02x}{:02x}{:02x}".format(*[round(x*255) for x in [c.red, c.green, c.blue, alpha]])
 
98
    # If it is neither a Gdk.Color object nor a Gdk.RGBA object,
 
99
    raise NotImplementedError
 
100
 
 
101
# GSettings objects go here
 
102
 
 
103
# Sorted by function type and alphabetical order
 
104
 
 
105
bluetooth = canonical('indicator.bluetooth')
 
106
datetime = canonical('indicator.datetime')
 
107
hud = canonical('indicator.appmenu.hud')
 
108
power = canonical('indicator.power')
 
109
notifyosd = canonical('notify-osd')
 
110
scrollbars= canonical('desktop.interface')
 
111
session = canonical('indicator.session')
 
112
sound = canonical('indicator.sound')
 
113
 
 
114
antialiasing = gnome('settings-daemon.plugins.xsettings')
 
115
background = gnome('desktop.background')
 
116
desktop = gnome('nautilus.desktop')
 
117
interface = gnome('desktop.interface')
 
118
lockdown = gnome('desktop.lockdown')
 
119
wm = gnome('desktop.wm.preferences')
 
120
touch = gnome('settings-daemon.peripherals.touchpad')
 
121
 
 
122
animation = plugin('animation')
 
123
core = plugin('core')
 
124
expo = plugin('expo')
 
125
grid = plugin('grid')
 
126
move = plugin('move')
 
127
opengl = plugin('opengl')
 
128
resize = plugin('resize')
 
129
scale = plugin('scale')
 
130
unityshell = plugin('unityshell')
 
131
zoom = plugin('ezoom')
 
132
 
 
133
launcher = unity('Launcher')
 
134
lenses = unity('Lenses')
 
135
lens_apps = unity('ApplicationsLens')
 
136
lens_files = unity('FilesLens')
 
137
runner = unity('Runner')
 
138
webapps = unity_webapps('webapps')