summaryrefslogtreecommitdiffstats
path: root/iw/language_gui.py
blob: 5afa2b67434737f158f13cd5591faef1d38816e4 (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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#
# langauge_gui.py: installtime language selection.
#
# Copyright 2000-2002 Red Hat, Inc.
#
# This software may be freely redistributed under the terms of the GNU
# library public license.
#
# You should have received a copy of the GNU Library Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#

import gobject
import gtk
import gui
from iw_gui import *
from rhpl.translate import _, N_

from gui import setupTreeViewFixupIdleHandler

class LanguageWindow (InstallWindow):

    windowTitle = N_("Language Selection")

    def __init__ (self, ics):
	InstallWindow.__init__ (self, ics)
            
    def getNext (self):
        (model, iter) = self.listView.get_selection().get_selected()
	assert iter, "No selection found on language list!"
	choice = self.listStore.get_value(iter, 1)
        self.lang = self.instLang.getNickByName(choice)

	self.instLang.setRuntimeLanguage(self.lang)
	self.instLang.setDefault(self.lang)
	self.ics.getICW().setLanguage()

        # Need to reload the release notes file in case we've changed languages
        self.ics.getICW().rnv.load()

        return None

    def listScroll(self, widget, *args):
        # recenter the list
        (model, iter) = self.listView.get_selection().get_selected()
        if iter is None:
            return
        
        path = self.listStore.get_path(iter)
        col = self.listView.get_column(0)
        self.listView.scroll_to_cell(path, col, True, 0.5, 0.5)
	self.listView.set_cursor(path, col, False)

    # LanguageWindow tag="lang"
    def getScreen (self, anaconda):
        self.running = 0
        mainBox = gtk.VBox (False, 10)

        hbox = gtk.HBox(False, 5)
        pix = gui.readImageFromFile ("gnome-globe.png")
        if pix:
            a = gtk.Alignment ()
            a.add (pix)
            hbox.pack_start (a, False)
            
        label = gtk.Label (_("What language would you like to use during the "
                         "installation process?"))
        label.set_line_wrap (True)
        label.set_size_request(350, -1)
        hbox.pack_start(label, False)
        
	self.instLang = anaconda.id.instLanguage

        self.listStore = gtk.ListStore(gobject.TYPE_STRING,
                                       gobject.TYPE_STRING,
                                       gobject.TYPE_STRING)

        for locale in self.instLang.available():
            iter = self.listStore.append()
            nick = self.instLang.getNickByName(locale)
            lang = '%s (<span lang="%s">%s</span>)' % (
                _(locale), "%s" % (nick.split('.')[0],),
                self.instLang.getNativeLangName(locale))
            self.listStore.set_value(iter, 0, lang)
            self.listStore.set_value(iter, 1, locale)
            self.listStore.set_value(iter, 2, _(locale))

        self.listStore.set_sort_column_id(2, gtk.SORT_ASCENDING)

        self.listView = gtk.TreeView(self.listStore)
        col = gtk.TreeViewColumn(None, gtk.CellRendererText(), markup=0)
        self.listView.append_column(col)
        self.listView.set_property("headers-visible", False)

        current = self.instLang.getLangNameByNick(self.instLang.getCurrent())
        iter = self.listStore.get_iter_first()
        while iter:
            if self.listStore.get_value(iter, 1) == current:
                selection = self.listView.get_selection()
                selection.unselect_all()
                selection.select_iter(iter)
                break
            iter = self.listStore.iter_next(iter)
        self.listView.connect("size-allocate", self.listScroll)

        sw = gtk.ScrolledWindow ()
        sw.set_border_width (5)
        sw.set_shadow_type(gtk.SHADOW_IN)
        sw.set_policy (gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        sw.add (self.listView)

	setupTreeViewFixupIdleHandler(self.listView, self.listStore)

        mainBox.pack_start (hbox, False, False, 10)
        mainBox.pack_start (sw, True, True)

        self.running = 1
        
        return mainBox