52
57
del _fh, _formatter
55
from UnityTweakTool.section.overview import Overview
56
from UnityTweakTool.section.unity import Unity
57
from UnityTweakTool.section.windowmanager import WindowManager
58
from UnityTweakTool.section.system import System
59
from UnityTweakTool.section.appearance import Appearance
60
sections=[Overview(notebook),Unity,WindowManager,Appearance,System]
61
for section in sections:
62
id=notebook.append_page(section.page,None)
65
def connecthandlers(builder):
67
def show_overview(*args,**kwargs):
68
notebook.set_current_page(0)
69
handler['on_b_overview_clicked']=show_overview
72
'unity_launcher' :(1,0),
75
'unity_switcher' :(1,3),
76
'unity_webapps' :(1,4),
77
'unity_additional' :(1,5),
79
'compiz_general' :(2,0),
80
'compiz_workspace' :(2,1),
81
'compiz_windows_spread' :(2,2),
82
'compiz_windows_snapping':(2,3),
83
'compiz_hotcorners' :(2,4),
84
'compiz_additional' :(2,5),
86
'theme_system' :(3,0),
88
'theme_cursor' :(3,2),
90
'window_controls' :(3,4),
92
'desktop_icons' :(4,0),
93
'system_security' :(4,1),
97
def gen_appmenu_handler(loc):
98
def appmenu_handler(*args):
99
notebook.set_current_page(loc[0])
100
notebook.get_nth_page(loc[0]).set_current_page(loc[1])
101
return appmenu_handler
103
for item,location in appmenu.items():
104
handler['on_menuitem_%s_activate'%item]=gen_appmenu_handler(location)
106
handler['on_menuimage_quit_activate']=lambda *args:Gtk.main_quit()
107
from UnityTweakTool.about import About
108
handler['on_menuimage_about_activate']=lambda *args: About()
109
builder.connect_signals(handler)
110
60
##########################################################################
112
print('Initialising...')
113
from UnityTweakTool.config.data import get_data_path
115
builder=Gtk.Builder()
116
ui=os.path.join(get_data_path(),'unitytweak.ui')
117
builder.add_from_file(ui)
118
notebook=builder.get_object('nb_unitytweak')
120
notebook.set_current_page(page)
121
connecthandlers(builder)
122
builder.get_object('unitytweak_main').show_all()
123
builder.get_object('unitytweak_main').connect('delete-event',Gtk.main_quit)
62
class Application(dbus.service.Object):
63
def __init__(self,pageid=-1):
64
DIR=os.path.expanduser('~/.config/unity-tweak-tool/')
65
LOCKFILE=os.path.join(DIR,"pid.lockfile")
66
if not os.path.exists(DIR):
68
if os.access(LOCKFILE, os.F_OK):
69
pidfile = open(LOCKFILE, "r")
71
old_pd = pidfile.readline()
73
if os.path.exists("/proc/%s" % old_pd):
75
Another instance of Unity Tweak Tool seems to be running with
76
process id %s. Switching to the already existing window.
78
self.call_running_instance(pageid)
83
pidfile = open(LOCKFILE, "w")
84
pidfile.write("%s" % os.getpid())
87
self.register_dbus_session()
91
from UnityTweakTool.config.data import get_data_path
92
self.builder=Gtk.Builder()
93
self.builder.set_translation_domain('unity-tweak-tool')
94
self.ui=os.path.join(get_data_path(),'unitytweak.ui')
95
self.builder.add_from_file(self.ui)
96
self.notebook=self.builder.get_object('nb_unitytweak')
98
self.connecthandlers()
99
# from gi.repository import Unity
100
# self.launcher = Unity.LauncherEntry.get_for_desktop_id("unity-tweak-tool.desktop")
101
self.window=self.builder.get_object('unitytweak_main')
102
self.window.show_all()
103
self.window.connect('delete-event',Gtk.main_quit)
104
if pageid is not None:
105
self.switch_to_page(pageid)
108
def connectpages(self):
109
from UnityTweakTool.section.overview import Overview
110
from UnityTweakTool.section.unity import Unity
111
from UnityTweakTool.section.windowmanager import WindowManager
112
from UnityTweakTool.section.system import System
113
from UnityTweakTool.section.appearance import Appearance
114
sections=[Overview(self.notebook),Unity,WindowManager,Appearance,System]
115
for section in sections:
116
id=self.notebook.append_page(section.page,None)
119
def connecthandlers(self):
121
def show_overview(*args,**kwargs):
122
self.notebook.set_current_page(0)
123
handler['on_b_overview_clicked']=show_overview
126
'unity_launcher' :(1,0),
128
'unity_panel' :(1,2),
129
'unity_switcher' :(1,3),
130
'unity_webapps' :(1,4),
131
'unity_additional' :(1,5),
133
'compiz_general' :(2,0),
134
'compiz_workspace' :(2,1),
135
'compiz_windows_spread' :(2,2),
136
'compiz_windows_snapping':(2,3),
137
'compiz_hotcorners' :(2,4),
138
'compiz_additional' :(2,5),
140
'theme_system' :(3,0),
142
'theme_cursor' :(3,2),
143
'theme_fonts' :(3,3),
144
'window_controls' :(3,4),
146
'desktop_icons' :(4,0),
147
'system_security' :(4,1),
151
def gen_appmenu_handler(loc):
152
def appmenu_handler(*args):
153
self.notebook.set_current_page(loc[0])
154
self.notebook.get_nth_page(loc[0]).set_current_page(loc[1])
155
return appmenu_handler
157
for item,location in appmenu.items():
158
handler['on_menuitem_%s_activate'%item]=gen_appmenu_handler(location)
160
handler['on_menuimage_quit_activate']=lambda *args:Gtk.main_quit()
161
from UnityTweakTool.about import About
162
handler['on_menuimage_about_activate']=lambda *args: About()
163
self.builder.connect_signals(handler)
167
def register_dbus_session(self):
168
bus_name = dbus.service.BusName('org.freyja.utt', bus=dbus.SessionBus())
169
dbus.service.Object.__init__(self, bus_name, '/org/freyja/utt')
171
def call_running_instance(self, pageid):
172
bus = dbus.SessionBus()
173
service = bus.get_object('org.freyja.utt', '/org/freyja/utt')
174
service.get_dbus_method('switch_to_page', 'org.freyja.utt')(pageid)
176
@dbus.service.method('org.freyja.utt', in_signature='i')
177
def switch_to_page(self, pageid):
179
self.notebook.set_current_page(pageid)
180
self.window.present()
183
import UnityTweakTool.utils.unityreset as unityreset
184
unityreset.UnityReset()