summaryrefslogtreecommitdiffstats
path: root/build_tools/larch7/larch0/gui/front/page_mediumprofile.py
blob: 0ebb76967d7fb500b7f7215625fc85acbbd31fb4 (plain)
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
# page_mediumprofile.py - Handler for the project settings page
#
# (c) Copyright 2010 Michael Towers (larch42 at googlemail dot com)
#
# This file is part of the larch project.
#
#    larch 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 2 of the License, or
#    (at your option) any later version.
#
#    larch 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 larch; if not, write to the Free Software Foundation, Inc.,
#    51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
#
#----------------------------------------------------------------------------
# 2010.07.14


class MediumProfile:
    def __init__(self):
        ui.widgetlist(fss('fetch_layout', 'page_mediumprofile.uim'))

        ui.connectlist(
                (':bootlines*clicked', self.editbootlines),
                (':grubtemplate*clicked', self.editgrub),
                (':syslinuxtemplate*clicked', self.editsyslin),
                (':cdroot*clicked', self.browsecdroot),
                (':nosessionsave*toggled', self.nosessionsave),
            )


    def enter(self):
        """This is called when the page is entered/selected/shown.
        It performs initializations which depend on the state.
        """
        docviewer.gohome('gui_mediumprofile.html')
        ui.command(':nosessionsave.set', fss('isfile', 'profile:nosave'))


#    def data(self, key):
#        return ui.command('mediumprofile_page_data.get', key)


    def editbootlines(self):
        edit('profile:bootlines', 'base:data/bootlines')


    def editgrub(self):
        f0 = 'profile:cd-root/grub0/menu.lst'
        if not fss('isfile', f0):
            f0 = 'base:cd-root/grub0/menu.lst'
        edit('profile:cd-root/grub/menu.lst', f0)


    def editsyslin(self):
        f0 = 'profile:cd-root/isolinux0/isolinux.cfg'
        if not fss('isfile', f0):
            f0 = 'base:cd-root/isolinux0/isolinux.cfg'
        edit('profile:cd-root/isolinux/isolinux.cfg', f0)


    def browsecdroot(self):
        fss('browse', 'profile:cd-root')


    def nosessionsave(self, on):
        """Whether session saving is available is firstly determined by
        the writability of the boot device (assuming the extension
        feature to allow the use of other devices is not being used).
        The standard scripts will also not offer session saving if the
        file larch/nosave is present on the boot medium.
        """
        ns = fss('isfile', 'profile:nosave')
        if on:
            if not ns:
                fss('savefile', 'profile:nosave',
                        "Suggestion to disable session saving"
                        " (can be overridden)")
        else:
            fss('rm_rf', 'profile:nosave')