22
22
from ubiquity.plugin import *
23
23
from mythbuntu_common.dictionaries import get_graphics_dictionary
24
from mythbuntu_common.installer import *
25
from ubiquity import install_misc
26
29
NAME = 'myth-drivers'
27
30
AFTER = 'myth-remote'
30
class PageGtk(PluginUI):
31
def __init__(self, *args, **kwargs):
32
if os.environ['UBIQUITY_FRONTEND'] == 'mythbuntu_ui' and \
33
len(get_graphics_dictionary()) > 0:
34
self.plugin_widgets = 'mythbuntu_stepDrivers'
33
class PageGtk(MythPageGtk):
34
def __init__(self, controller, *args, **kwargs):
35
if len(get_graphics_dictionary()) > 0:
36
self.ui_file = 'mythbuntu_stepDrivers'
37
MythPageGtk.__init__(self, controller, *args, **kwargs)
40
def populate_video(self):
41
"""Finds the currently active video driver"""
42
dictionary=get_graphics_dictionary()
43
if len(dictionary) > 0:
44
for driver in dictionary:
45
self.video_driver.append_text(driver)
46
self.video_driver.append_text("Open Source Driver")
47
self.video_driver.set_active(len(dictionary))
48
self.tvoutstandard.set_active(0)
49
self.tvouttype.set_active(0)
51
def toggle_tv_out (self,widget):
52
"""Called when the tv-out type is toggled"""
53
if (self.tvouttype.get_active() == 0):
54
self.tvoutstandard.set_active(0)
55
elif ((self.tvouttype.get_active() == 1 or self.tvouttype.get_active() == 2) and (self.tvoutstandard.get_active() == 0 or self.tvoutstandard.get_active() >= 11 )):
56
self.tvoutstandard.set_active(10)
57
elif self.tvouttype.get_active() == 3:
58
self.tvoutstandard.set_active(11)
60
def toggle_tv_standard(self,widget):
61
"""Called when the tv standard is toggled"""
62
if (self.tvoutstandard.get_active() >= 11):
63
self.tvouttype.set_active(3)
64
elif (self.tvoutstandard.get_active() < 11 and self.tvoutstandard.get_active() > 0 and self.tvouttype.get_active() == 0):
65
self.tvouttype.set_active(1)
66
elif (self.tvoutstandard.get_active() < 11 and self.tvouttype.get_active() ==3):
67
self.tvouttype.set_active(1)
68
elif (self.tvoutstandard.get_active() == 0):
69
self.tvouttype.set_active(0)
71
def video_changed (self,widget):
72
"""Called whenever the modify video driver option is toggled or its kids"""
73
drivers=get_graphics_dictionary()
74
if (widget is not None and widget.get_name() == 'video_driver'):
76
self.controller.allow_go_forward(True)
77
except AttributeError:
78
#depends on when video_changed got called
79
#the UI might not be ready yet
81
type = widget.get_active()
82
if (type < len(drivers)):
83
self.tvout_vbox.set_sensitive(True)
85
self.tvout_vbox.set_sensitive(False)
86
self.tvoutstandard.set_active(0)
87
self.tvouttype.set_active(0)
90
def set_driver(self,name,value):
91
"""Preseeds the status of a driver"""
92
lists = [{'video_driver': self.video_driver,
93
'tvout': self.tvouttype,
94
'tvstandard': self.tvoutstandard}]
95
preseed_list(lists,name,value)
97
def get_drivers(self):
98
video_drivers=get_graphics_dictionary()
99
active_video_driver=self.video_driver.get_active_text()
100
for item in video_drivers:
101
if (active_video_driver == item):
102
active_video_driver=video_drivers[item]
104
return build_static_list([{'video_driver': active_video_driver,
105
'tvout': self.tvouttype,
106
'tvstandard': self.tvoutstandard}])
36
108
class Page(Plugin):
37
109
def prepare(self):
39
drivers = self.frontend.get_drivers()
111
drivers = self.ui.get_drivers()
41
113
for this_driver in drivers:
42
114
answer = self.db.get('mythbuntu/' + this_driver)
44
self.frontend.set_driver(this_driver,answer)
116
self.ui.set_driver(this_driver,answer)
45
117
questions.append('^mythbuntu/' + this_driver)
46
118
return (['/usr/share/ubiquity/ask-mythbuntu','drivers'], questions)
48
120
def ok_handler(self):
49
drivers = self.frontend.get_drivers()
121
drivers = self.ui.get_drivers()
51
123
for this_driver in drivers:
52
124
if drivers[this_driver] is True or drivers[this_driver] is False:
55
127
self.preseed('mythbuntu/' + this_driver, drivers[this_driver])
56
128
Plugin.ok_handler(self)
130
class Install(InstallPlugin):
132
def enable_nvidia(self, type, fmt):
133
"""Enables an NVIDIA graphics driver using XKit"""
134
xorg_conf=XKit.xutils.XUtils()
136
extra_conf_options={'NoLogo': '1',
139
if type == 'Composite Video Output':
140
extra_conf_options["ConnectedMonitor"]="TV"
141
extra_conf_options["TVOutFormat"]="COMPOSITE"
142
extra_conf_options["TVStandard"]=fmt
143
elif type == 'S-Video Video Output':
144
extra_conf_options["ConnectedMonitor"]="TV"
145
extra_conf_options["TVOutFormat"]="SVIDEO"
146
extra_conf_options["TVStandard"]=fmt
147
elif type == 'Component Video Output':
148
extra_conf_options["ConnectedMonitor"]="TV"
149
extra_conf_options["TVOutFormat"]="COMPONENT"
150
extra_conf_options["TVStandard"]=fmt
152
#Set up device section
153
relevant_devices = []
154
if len(xorg_conf.globaldict['Device']) == 0:
155
device = xorg_conf.makeSection('Device', identifier='Default Device')
156
relevant_devices.append(device)
157
xorg_conf.setDriver('Device', 'nvidia', device)
159
devices = xorg_conf.getDevicesInUse()
161
relevant_devices = devices
163
relevant_devices = xorg_conf.globaldict['Device'].keys()
164
for device in relevant_devices:
165
xorg_conf.setDriver('Device', 'nvidia', device)
167
for device_section in relevant_devices:
168
for k, v in extra_conf_options.iteritems():
169
xorg_conf.addOption('Device', k, v, optiontype='Option', position=device_section)
171
#Set up screen section
172
if len(xorg_conf.globaldict['Screen']) == 0:
173
screen = xorg_conf.makeSection('Screen', identifier='Default Screen')
175
xorg_conf.addOption('Screen', 'DefaultDepth', '24', position=0, prefix='')
177
xorg_conf.writeFile(self.target + "/etc/X11/xorg.conf")
179
def enable_amd(self):
180
"""Enables an AMD graphics driver using XKit"""
181
xorg_conf=XKit.xutils.XUtils()
183
#Set up device section
184
relevant_devices = []
185
if len(xorg_conf.globaldict['Device']) == 0:
186
device = xorg_conf.makeSection('Device', identifier='Default Device')
187
relevant_devices.append(device)
188
xorg_conf.setDriver('Device', 'fglrx', device)
190
devices = xorg_conf.getDevicesInUse()
192
relevant_devices = devices
194
relevant_devices = xorg_conf.globaldict['Device'].keys()
195
for device in relevant_devices:
196
xorg_conf.setDriver('Device', 'fglrx', device)
198
#Set up screen section
199
if len(xorg_conf.globaldict['Screen']) == 0:
200
screen = xorg_conf.makeSection('Screen', identifier='Default Screen')
202
xorg_conf.addOption('Screen', 'DefaultDepth', '24', position=0, prefix='')
204
xorg_conf.writeFile(self.target + "/etc/X11/xorg.conf")
206
def install(self, target, progress, *args, **kwargs):
207
progress.info('ubiquity/install/drivers')
210
video_driver = progress.get('mythbuntu/video_driver')
211
if video_driver != "Open Source Driver":
213
to_install.append(video_driver)
215
#Build tvout/tvstandard
216
out = progress.get('mythbuntu/tvout')
217
standard = progress.get('mythbuntu/tvstandard')
218
#Enabling xorg.conf stuff
219
if 'nvidia' in video_driver:
220
self.enable_nvidia(out,standard)
225
install_misc.record_installed(to_install)
227
return InstallPlugin.install(self, target, progress, *args, **kwargs)