This repository has been archived by the owner on Dec 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.py
executable file
·97 lines (77 loc) · 3.08 KB
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (C) 2012 Deepin, Inc.
# 2012 Zhai Xiang
#
# Author: Zhai Xiang <zhaixiang@linuxdeepin.com>
# Maintainer: Zhai Xiang <zhaixiang@linuxdeepin.com>
#
# This program 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, either version 3 of the License, or
# any later version.
#
# This program 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 <http://www.gnu.org/licenses/>.
import deepin_gsettings
class DeepinGSettings:
def __init__(self, schema_id):
'''
DeepinGSettings construction
@para schema_id
'''
self.handle = deepin_gsettings.new(schema_id)
def __del__(self):
self.handle.delete()
self.handle = None
def connect(self, name, func):
return self.handle.connect(name, func)
def reset(self, key):
return self.handle.reset(key)
def list_keys(self):
return self.handle.list_keys()
def get_boolean(self, key):
return self.handle.get_boolean(key)
def set_boolean(self, key, value):
return self.handle.set_boolean(key, value)
def get_int(self, key):
return self.handle.get_int(key)
def set_int(self, key, value):
return self.handle.set_int(key, value)
def get_uint(self, key):
return self.handle.get_uint(key)
def get_strv(self, key):
return self.handle.get_strv(key)
def set_strv(self, key, value):
return self.handle.set_strv(key, value)
def m_changed(key):
print "DEBUG changed", key
deepin_gsettings_instance1 = DeepinGSettings("org.gnome.settings-daemon.plugins.power")
deepin_gsettings_instance1.connect("changed", m_changed)
deepin_gsettings_instance2 = DeepinGSettings("org.gnome.libgnomekbd.keyboard")
deepin_gsettings_instance2.connect("changed", m_changed)
dg3 = DeepinGSettings("org.gnome.system.locale")
dg4 = DeepinGSettings("org.gnome.settings-daemon.peripherals.mouse")
def test():
print "list_keys", dg3.list_keys()
print "get_int", dg4.get_int("motion-threshold")
print "list_keys", deepin_gsettings_instance1.list_keys()
print "get_boolean active", deepin_gsettings_instance1.get_boolean("active")
print "set_boolean idle-dim-battery", deepin_gsettings_instance1.set_boolean("idle-dim-battery", True)
print "get_int idle-brightness", deepin_gsettings_instance1.get_int("idle-brightness")
print "set_int idle-brightness", deepin_gsettings_instance1.set_int("idle-brightness", 31)
print "get_strv layouts", deepin_gsettings_instance2.get_strv("options")
print "reset layouts", deepin_gsettings_instance2.reset("options")
test()
'''
i = 0
while i < 1000:
print "DEBUG %d times" % (i + 1)
test()
i += 1
'''