~gilir/+junk/ubiquity-lxdm-autologin

« back to all changes in this revision

Viewing changes to ubiquity/components/myth-drivers.py

  • Committer: Bazaar Package Importer
  • Author(s): Mario Limonciello, Mario Limonciello, Evan Dandrea
  • Date: 2010-01-31 23:44:44 UTC
  • Revision ID: james.westby@ubuntu.com-20100131234444-tr2u4n0evnu2pv02
Tags: 2.1.15
[ Mario Limonciello ]
* Add a new template, ubiquity/only-show-installable-languages for modifying
  the behavior of what languages to offer on an invokation based upon
  what's installed or "available" to install according to an apt cache.
* Expose extra functions get and substitute to plugins via it's
  second argument (currently called Progress).
* Drop extraneous handlers from Mythbuntu pages.
* Move all handlers from mythbuntu_ui directly into plugins themselves.
* Move some functions from the install.py script into a new file,
  install_misc.  The intention here is that they can then be used more
  directly by ubiquity plugins.
* Add a new method for package removals to install_misc to allow
  plugins to mark packages to be removed later in remove_extras.
* Modify the Mythbuntu services plugin to not even offer VNC if a short
  pw. (LP: #469312)
* Convert most of the functions from mythbuntu_install.py into plugin
  type Install methods.
* Support using pkgsel/install-language-support preseeded to false to
  ignore installation of language packs (just like alternates).
* Drop mythbuntu_ui and all references to it.  The (former) Mythbuntu 
  frontend is now fully pluggable into ubiquity's gtk_ui on it's own.
* Fix unmount command in chroot_cleanup to actually release /target/dev.
* In the KDE frontend for ubi-language, use findChildren to find widgets
  because QWidget itself is not iterable.
* In the KDE frontend, don't try to set the text on the breadcrumbs early
  as translations don't appear ready yet.  The widgets will still load,
  and translate when the langauge is changed. (LP: #511947)
* Automatic update of included source packages: console-setup
  1.34ubuntu8, debian-installer-utils 1.72ubuntu2, tzsetup
  1:0.26ubuntu4.

[ Evan Dandrea ]
* Support getting the timezone from a geoip server (LP: #229884).
* Move oem-config runtime debconf questions into the oem-config
  package.
* Add oem-config/early_command (run a command just before oem-config
  starts).
* Support installing additional packages at runtime in oem-config, as
  specified by oem-config/extra_packages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
#
3
3
# Copyright (C) 2006, 2007, 2009 Canonical Ltd.
4
4
# Written by Colin Watson <cjwatson@ubuntu.com>.
5
 
# Copyright (C) 2007 Mario Limonciello
 
5
# Copyright (C) 2007-2010 Mario Limonciello
6
6
#
7
7
# This file is part of Ubiquity.
8
8
#
21
21
 
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
import XKit.xutils
24
27
import os
25
28
 
26
29
NAME = 'myth-drivers'
27
30
AFTER = 'myth-remote'
28
31
WEIGHT = 10
29
32
 
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)
 
38
            self.populate_video()
 
39
 
 
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)
 
50
 
 
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)
 
59
 
 
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)
 
70
 
 
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'):
 
75
            try:
 
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
 
80
                pass
 
81
            type = widget.get_active()
 
82
            if (type < len(drivers)):
 
83
                self.tvout_vbox.set_sensitive(True)
 
84
            else:
 
85
                self.tvout_vbox.set_sensitive(False)
 
86
                self.tvoutstandard.set_active(0)
 
87
                self.tvouttype.set_active(0)
 
88
 
 
89
 
 
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)
 
96
 
 
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]
 
103
                break
 
104
        return build_static_list([{'video_driver': active_video_driver,
 
105
                                         'tvout': self.tvouttype,
 
106
                                         'tvstandard': self.tvoutstandard}])
35
107
 
36
108
class Page(Plugin):
37
109
    def prepare(self):
38
110
        #drivers
39
 
        drivers = self.frontend.get_drivers()
 
111
        drivers = self.ui.get_drivers()
40
112
        questions = []
41
113
        for this_driver in drivers:
42
114
            answer = self.db.get('mythbuntu/' + this_driver)
43
115
            if answer != '':
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)
47
119
 
48
120
    def ok_handler(self):
49
 
        drivers = self.frontend.get_drivers()
 
121
        drivers = self.ui.get_drivers()
50
122
 
51
123
        for this_driver in drivers:
52
124
            if drivers[this_driver] is True or drivers[this_driver] is False:
54
126
            else:
55
127
                self.preseed('mythbuntu/' + this_driver, drivers[this_driver])
56
128
        Plugin.ok_handler(self)
 
129
 
 
130
class Install(InstallPlugin):
 
131
 
 
132
    def enable_nvidia(self, type, fmt):
 
133
        """Enables an NVIDIA graphics driver using XKit"""
 
134
        xorg_conf=XKit.xutils.XUtils()
 
135
 
 
136
        extra_conf_options={'NoLogo': '1',
 
137
                           'DPI': '100x100'}
 
138
 
 
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
 
151
 
 
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)
 
158
        else:
 
159
            devices = xorg_conf.getDevicesInUse()
 
160
            if len(devices) > 0:
 
161
                relevant_devices = devices
 
162
            else:
 
163
                relevant_devices = xorg_conf.globaldict['Device'].keys()
 
164
            for device in relevant_devices:
 
165
                xorg_conf.setDriver('Device', 'nvidia', device)
 
166
 
 
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)
 
170
 
 
171
        #Set up screen section
 
172
        if len(xorg_conf.globaldict['Screen']) == 0:
 
173
            screen = xorg_conf.makeSection('Screen', identifier='Default Screen')
 
174
 
 
175
        xorg_conf.addOption('Screen', 'DefaultDepth', '24', position=0, prefix='')
 
176
 
 
177
        xorg_conf.writeFile(self.target + "/etc/X11/xorg.conf")
 
178
 
 
179
    def enable_amd(self):
 
180
        """Enables an AMD graphics driver using XKit"""
 
181
        xorg_conf=XKit.xutils.XUtils()
 
182
 
 
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)
 
189
        else:
 
190
            devices = xorg_conf.getDevicesInUse()
 
191
            if len(devices) > 0:
 
192
                relevant_devices = devices
 
193
            else:
 
194
                relevant_devices = xorg_conf.globaldict['Device'].keys()
 
195
            for device in relevant_devices:
 
196
                xorg_conf.setDriver('Device', 'fglrx', device)
 
197
 
 
198
        #Set up screen section
 
199
        if len(xorg_conf.globaldict['Screen']) == 0:
 
200
            screen = xorg_conf.makeSection('Screen', identifier='Default Screen')
 
201
 
 
202
        xorg_conf.addOption('Screen', 'DefaultDepth', '24', position=0, prefix='')
 
203
 
 
204
        xorg_conf.writeFile(self.target + "/etc/X11/xorg.conf")
 
205
 
 
206
    def install(self, target, progress, *args, **kwargs):
 
207
        progress.info('ubiquity/install/drivers')
 
208
        self.target = target
 
209
        to_install = []
 
210
        video_driver = progress.get('mythbuntu/video_driver')
 
211
        if video_driver != "Open Source Driver":
 
212
            #Install driver
 
213
            to_install.append(video_driver)
 
214
 
 
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)
 
221
            else:
 
222
                self.enable_amd()
 
223
 
 
224
        #Mark new items
 
225
        install_misc.record_installed(to_install)
 
226
 
 
227
        return InstallPlugin.install(self, target, progress, *args, **kwargs)