/[gli]/branches/overhaul/src/fe/gtk/ExtraPackages.py
Gentoo

Contents of /branches/overhaul/src/fe/gtk/ExtraPackages.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1623 - (show annotations) (download) (as text)
Fri Jan 19 10:19:38 2007 UTC (7 years, 3 months ago) by agaffney
File MIME type: text/x-python
File size: 8661 byte(s)
remove Help button
rearrange Stage screen
1 # Copyright 1999-2005 Gentoo Foundation
2 # This source code is distributed under the terms of version 2 of the GNU
3 # General Public License as published by the Free Software Foundation, a copy
4 # of which can be found in the main directory of this project.
5
6 import gtk, gobject, copy
7 import GLIScreen
8 from Widgets import Widgets
9 import GLIUtility
10
11 class Panel(GLIScreen.GLIScreen):
12 """
13 The extrapackages section of the installer.
14
15 @author: John N. Laliberte <allanonjl@gentoo.org>
16 @license: GPL
17 """
18 # Attributes:
19 title="Do you need any extra packages?"
20 _helptext = """
21 <b><u>Extra Packages</u></b>
22
23 Packages available via GRP (pre-compiled binaries on the livecd that get copied
24 over) are labeled with (GRP), and include all of their dependencies. For
25 instance gnome (GRP) includes all of gnome, including xorg-x11. Fluxbox,
26 however, is not available in GRP and must be compiled. The list of packages is
27 very limited, as Portage has a vast list of available packages. If you have
28 packages you need to install in addition to the list, enter them in a space
29 separated list in the text field. The installer is designed to get you a system
30 capable of booting into a graphical environment, not install every single
31 package you will ever use. That would just massively increase the changes of a
32 failed package ruining your installation.
33
34 If you choose a graphical desktop such as gnome, kde, or fluxbox, be sure to
35 choose xdm from the startup services and to set your Display Manager (and/or
36 XSession for fluxbox) in the Other Settings screen.
37 """
38
39 # list of packages to emerge from the checked off items.
40 checked_items = []
41
42 def __init__(self, controller):
43 GLIScreen.GLIScreen.__init__(self, controller)
44
45 self.vert = gtk.VBox(False, 10)
46 self.vert2 = gtk.VBox(False, 10)
47
48 def draw_screen(self):
49 content_str = """
50 This is where you emerge extra packages that your system may need. Packages that
51 are fetch-restricted (e.g. sun-jdk) or require you to accept licenses (e.g. many
52 big games) will cause your install to fail. Add additional packages with
53 caution. These trouble packages can be installed manually after you reboot.
54 """
55
56 # pack the description
57 self.vert.pack_start(gtk.Label(content_str), expand=False, fill=False, padding=5)
58
59 scrolled_window = gtk.ScrolledWindow(hadjustment=None, vadjustment=None)
60 scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS)
61
62 # store the objects for later ( when loading )
63 self.category_objects = {}
64 self.package_objects = {}
65
66 self.categories = self.controller.install_profile.get_install_package_list()
67 self.grp_packages = GLIUtility.get_grp_pkgs_from_cd()
68
69 # first load the category
70 for category in self.categories:
71 categ = self.Category(category)
72 self.category_objects[category] = categ
73 hbox = categ.Generate_GTK()
74 self.vert2.pack_start(hbox,expand=False,fill=False,padding=0)
75
76 # then load the packages in that category
77 packages = self.categories[category][1]
78 for package in packages:
79 if self.controller.install_type == "networkless" and not package in self.grp_packages:
80 continue
81 # grp_packages may be in the format category/package or just package
82 if "/" in package:
83 displayname = package[package.index("/")+1:]
84 else:
85 displayname = package
86
87 # if its a grp install, append (GRP) to the name
88 if self.controller.install_profile.get_grp_install():
89 if package in self.grp_packages:
90 displayname = displayname + " (GRP)"
91
92 pack = self.Package(self, package, packages[package], displayname)
93 self.package_objects[package] = pack
94 hbox = pack.Generate_GTK()
95 self.vert2.pack_start(hbox,expand=False,fill=False,padding=0)
96
97 # add the custom space-seperated list bar
98 entry_description = gtk.Label("Enter a space seperated list of extra packages to install on the system ( in addition to those checked above ):")
99 self.entry=gtk.Entry()
100 if self.controller.install_type == "networkless":
101 self.entry.set_sensitive(False)
102
103 scrolled_window.add_with_viewport(self.vert2)
104 viewport = scrolled_window.get_children()[0]
105 viewport.set_shadow_type (gtk.SHADOW_IN)
106 viewport.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse ("white"))
107
108 self.vert.pack_start(scrolled_window,expand=True,fill=True,padding=0)
109 self.vert.pack_start(entry_description,expand=False,fill=False,padding=0)
110 self.vert.pack_start(self.entry,expand=False,fill=False,padding=0)
111 self.vert.show_all()
112 self.add_content(self.vert)
113
114 def activate(self):
115 self.controller.SHOW_BUTTON_EXIT = True
116 # self.controller.SHOW_BUTTON_HELP = True
117 self.controller.SHOW_BUTTON_BACK = True
118 self.controller.SHOW_BUTTON_FORWARD = True
119 self.controller.SHOW_BUTTON_FINISH = False
120
121 # remove all checked items to start with
122 self.checked_items = []
123
124 # we are destroying and redrawing because we have to
125 # dynamically change what the options looks like based
126 # on another screen's values.
127 self.vert.destroy()
128 self.draw_screen()
129
130 # load the custom packages from the profile
131 unjoined = self.controller.install_profile.get_install_packages()
132 #print "loaded custom packages: " + str(unjoined)
133
134 # generate a full list of packages offered by the fe
135 package_list = []
136 for item in self.categories:
137 for pack in self.categories[item][1]:
138 #package_list.update()
139 package_list.append(pack)
140
141 # now check to see if any match
142 unjoined_reduced = copy.deepcopy(unjoined)
143 for package in unjoined:
144 #print "Trying to match: " + package
145 if package in package_list:
146 # check it off!
147 #print "matched! " + package
148 self.package_objects[package].ToggleOn()
149
150 # and remove it from the list
151 unjoined_reduced.remove(package)
152
153
154 s=" ".join(unjoined_reduced)
155 self.entry.set_text(s)
156
157 def deactivate(self):
158 return_value = False
159 # save the space seperated list
160 #print self.custom_box.get_text()
161 try:
162 packages_to_emerge = ""
163 packages_to_emerge = self.entry.get_text() + " " + " ".join(self.checked_items)
164
165 self.controller.install_profile.set_install_packages(None, packages_to_emerge, None)
166 #print packages_to_emerge
167 return_value = True
168 except:
169 box = Widgets().error_Box("Error saving packages","You need to fix your input! \n Theres a problem, are you sure didn't enter \n funny characters?")
170 box.show()
171 return_value = False
172
173 return return_value
174
175 class Category:
176
177 def __init__(self, category_name):
178 self.category_name = category_name
179
180 def Name(self):
181 return category_name
182
183 def Generate_GTK(self):
184 # Generate GTK needed.
185 hbox=gtk.HBox(True,0)
186
187 name=gtk.Label("")
188 name.set_markup('<span size="x-large" weight="bold" foreground="white">'+self.category_name+'</span>')
189 name.set_justify(gtk.JUSTIFY_LEFT)
190
191 table = gtk.Table(1, 1, False)
192 table.set_col_spacings(10)
193 table.set_row_spacings(6)
194 table.attach(name,0,1,0,1)
195
196 eb=gtk.EventBox()
197 eb.add(Widgets().hBoxIt2(False, 0, table))
198 eb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#737db5"))
199 hbox.pack_start(eb, expand=True, fill=True,padding=5)
200
201 return hbox
202
203 property(Name)
204
205 class Package:
206
207 def __init__(self, parent, portage_name, description, display_name):
208 self.parent = parent
209 self.portage_name = portage_name
210 self.description = description
211 self._display_name = display_name
212
213 def Name(self):
214 return self.portage_name
215
216 def DisplayName(self):
217 return self._display_name
218
219 def Description(self):
220 return self.description
221
222 def isChecked(self):
223 return True
224
225 def ToggleOn(self):
226 self.checkbox.set_active(True)
227
228 def Generate_GTK(self):
229 # Generate the pygtk code ncessary for this object.
230 hbox=gtk.HBox(False,0)
231 table = gtk.Table(2, 2, False)
232 table.set_col_spacings(10)
233 table.set_row_spacings(1)
234
235 button = gtk.CheckButton()
236
237 title=gtk.Label("")
238 title.set_markup('<span weight="bold">' + self._display_name + '</span>'
239 + " - " + self.description)
240 button.add(title)
241 button.connect("toggled", self.checkbox_callback, self.portage_name)
242 self.checkbox = button
243
244 table.attach(Widgets().hBoxIt2(False,0,button),1,2,0,1)
245 hbox.pack_start(table,expand=False,fill=False,padding=0)
246
247 return hbox
248
249 def checkbox_callback(self, widget, data=None):
250 #print "%s was toggled %s" % (data, ("OFF", "ON")[widget.get_active()])
251 if widget.get_active():
252 self.parent.checked_items.append(data)
253 else:
254 self.parent.checked_items.remove(data)
255 # debug
256 #print self.parent.checked_items
257
258 property(Name)
259 property(Description)
260 property(isChecked)

Properties

Name Value
svn:eol-style native

  ViewVC Help
Powered by ViewVC 1.1.20