Print this page
*** NO COMMENTS ***
| Split |
Close |
| Expand all |
| Collapse all |
--- old/src/packagemanager.py
+++ new/src/packagemanager.py
1 1 #!/usr/bin/python2.4
2 2 #
3 3 # CDDL HEADER START
4 4 #
5 5 # The contents of this file are subject to the terms of the
6 6 # Common Development and Distribution License (the "License").
7 7 # You may not use this file except in compliance with the License.
8 8 #
9 9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 # or http://www.opensolaris.org/os/licensing.
11 11 # See the License for the specific language governing permissions
12 12 # and limitations under the License.
13 13 #
14 14 # When distributing Covered Code, include this CDDL HEADER in each
15 15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 # If applicable, add the following below this CDDL HEADER, with the
17 17 # fields enclosed by brackets "[]" replaced with your own identifying
18 18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 19 #
20 20 # CDDL HEADER END
21 21 #
22 22 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 23 # Use is subject to license terms.
24 24 #
25 25
26 26 # Progress:
|
↓ open down ↓ |
26 lines elided |
↑ open up ↑ |
27 27 # Startup Progress has two phases:
28 28 # - Start phase:
29 29 # The start phase should be fairly constant at around a few seconds and so is given 5%
30 30 # of the total progress bar.
31 31 # - Package entry loading phase:
32 32 # The package entry loading phase is given the remaining 95% of the bar for progress.
33 33
34 34 INITIAL_PROGRESS_TIME_INTERVAL = 0.5 # Time to update progress during start phase
35 35 INITIAL_PROGRESS_TIME_PERCENTAGE = 0.005 # Amount to update progress during start phase
36 36 INITIAL_PROGRESS_TOTAL_PERCENTAGE = 0.05 # Total progress for start phase
37 -PACKAGE_PROGRESS_TOTAL_INCREMENTS = 95.0 # Total increments for loading phase
37 +PACKAGE_PROGRESS_TOTAL_INCREMENTS = 95 # Total increments for loading phase
38 38 PACKAGE_PROGRESS_PERCENT_INCREMENT = 0.01 # Amount to update progress during loading phase
39 39 PACKAGE_PROGRESS_PERCENT_TOTAL = 1.0 # Total progress for loading phase
40 40
41 +CLIENT_API_VERSION = 0
42 +PKG_CLIENT_NAME = "packagemanager"
43 +
41 44 import getopt
42 45 import os
43 46 import sys
44 47 import time
45 48 import locale
49 +import urlparse
46 50 import socket
47 51 import gettext
48 52 from threading import Thread
53 +from urllib2 import HTTPError, URLError
54 +
49 55 try:
50 56 import gobject
57 + import gnome
51 58 gobject.threads_init()
52 59 import gtk
53 60 import gtk.glade
54 61 import pygtk
55 62 pygtk.require("2.0")
56 63 except ImportError:
57 64 sys.exit(1)
58 65 import pkg.client.history as history
59 66 import pkg.client.image as image
60 67 import pkg.client.progress as progress
61 -import pkg.client.retrieve as retrieve
62 68 import pkg.client.api_errors as api_errors
69 +import pkg.client.api as api
70 +import pkg.client.retrieve as retrieve
63 71 import pkg.portable as portable
72 +import pkg.gui.repository as repository
64 73 import pkg.gui.beadmin as beadm
65 74 import pkg.gui.imageinfo as imageinfo
66 75 import pkg.gui.installupdate as installupdate
67 -import pkg.gui.remove as remove
68 76 import pkg.gui.enumerations as enumerations
69 77 from pkg.client import global_settings
70 78
71 79
72 80 class PackageManager:
73 81 def __init__(self):
74 82 self.image_o = None
83 + self.api_o = None
75 84 socket.setdefaulttimeout(
76 85 int(os.environ.get("PKG_CLIENT_TIMEOUT", "30"))) # in seconds
77 86
78 87 # Override default PKG_TIMEOUT_MAX if a value has been specified
79 88 # in the environment.
80 89 global_settings.PKG_TIMEOUT_MAX = int(os.environ.get("PKG_TIMEOUT_MAX",
81 90 global_settings.PKG_TIMEOUT_MAX))
82 91
83 92 try:
84 93 self.application_dir = os.environ["PACKAGE_MANAGER_ROOT"]
85 94 except KeyError:
86 95 self.application_dir = "/"
87 96 locale.setlocale(locale.LC_ALL, '')
88 97 for module in (gettext, gtk.glade):
89 98 module.bindtextdomain("packagemanager", self.application_dir + \
90 99 "/usr/share/locale")
91 100 module.textdomain("packagemanager")
92 101 self._ = gettext.gettext
93 - main_window_title = self._('Package Manager - revision 0.1')
102 + main_window_title = self._('Package Manager')
94 103 self.user_rights = portable.is_admin()
95 104 self.cancelled = False # For background processes
96 105 self.image_directory = None
97 106 self.description_thread_running = False # For background processes
98 - self.pkginfo_thread = None # For background processes
107 + self.pkginfo_thread = -1 # For background processes
99 108 gtk.rc_parse('~/.gtkrc-1.2-gnome2') # Load gtk theme
100 109 self.main_clipboard_text = None
101 110 self.ipkg_fmri = "SUNWipkg"
102 111 self.ipkggui_fmri = "SUNWipkg-gui"
103 112 self.progress_stop_timer_thread = False
104 113 self.progress_fraction_time_count = 0
105 114 self.progress_canceled = False
106 115 self.ips_uptodate = False
107 116 self.image_dir_arg = None
108 117 self.application_path = None
118 + self.first_run = True
119 + self.provided_image_dir = True
109 120
110 - self.application_list = \
111 - gtk.ListStore(
112 - gobject.TYPE_BOOLEAN, # enumerations.MARK_COLUMN
113 - gtk.gdk.Pixbuf, # enumerations.STATUS_ICON_COLUMN
114 - gtk.gdk.Pixbuf, # enumerations.ICON_COLUMN
115 - gobject.TYPE_STRING, # enumerations.NAME_COLUMN
116 - gobject.TYPE_STRING, # enumerations.INSTALLED_VERSION_COLUMN
117 - gobject.TYPE_PYOBJECT, # enumerations.INSTALLED_OBJECT_COLUMN
118 - gobject.TYPE_STRING, # enumerations.LATEST_AVAILABLE_COLUMN
119 - gobject.TYPE_INT, # enumerations.RATING_COLUMN
120 - gobject.TYPE_STRING, # enumerations.DESCRIPTION_COLUMN
121 - gobject.TYPE_PYOBJECT, # enumerations.PACKAGE_OBJECT_COLUMN
122 - gobject.TYPE_PYOBJECT, # enumerations.IMAGE_OBJECT_COLUMN
123 - gobject.TYPE_BOOLEAN, # enumerations.IS_VISIBLE_COLUMN
124 - gobject.TYPE_PYOBJECT # enumerations.CATEGORY_LIST_OBJECT
125 - )
126 - self.category_list = \
127 - gtk.ListStore(
128 - gobject.TYPE_INT, # enumerations.CATEGORY_ID
129 - gobject.TYPE_STRING, # enumerations.CATEGORY_NAME
130 - gobject.TYPE_STRING, # enumerations.CATEGORY_DESCRIPTION
131 - gtk.gdk.Pixbuf, # enumerations.CATEGORY_ICON
132 - gobject.TYPE_BOOLEAN, # enumerations.CATEGORY_VISIBLE
133 - gobject.TYPE_PYOBJECT, # enumerations.SECTION_LIST_OBJECT
134 - )
135 - self.section_list = \
136 - gtk.ListStore(
137 - gobject.TYPE_INT, # enumerations.SECTION_ID
138 - gobject.TYPE_STRING, # enumerations.SECTION_NAME
139 - )
140 - self.filter_list = \
141 - gtk.ListStore(
142 - gobject.TYPE_INT, # enumerations.FILTER_ID
143 - gobject.TYPE_STRING, # enumerations.FILTER_NAME
144 - )
145 - self.repositories_list = \
146 - gtk.ListStore(
147 - gobject.TYPE_INT, # enumerations.REPOSITORY_ID
148 - gobject.TYPE_STRING, # enumerations.REPOSITORY_NAME
149 - )
121 + self.section_list = self.__get_new_section_liststore()
122 + self.filter_list = self.__get_new_filter_liststore()
123 + self.application_list = None
124 + self.category_list = None
125 + self.repositories_list = None
150 126
151 - self.application_list_filter = self.application_list.filter_new()
152 127 self.pr = progress.NullProgressTracker()
153 128
154 129 # Create Widgets and show gui
155 130
156 131 self.gladefile = self.application_dir + \
157 132 "/usr/share/package-manager/packagemanager.glade"
158 133 w_tree_main = gtk.glade.XML(self.gladefile, "mainwindow")
159 134 w_tree_progress = gtk.glade.XML(self.gladefile, "progressdialog")
160 135
161 136 self.w_main_window = w_tree_main.get_widget("mainwindow")
162 137 self.w_application_treeview = \
163 138 w_tree_main.get_widget("applicationtreeview")
164 139 self.w_categories_treeview = w_tree_main.get_widget("categoriestreeview")
140 + self.w_info_notebook = w_tree_main.get_widget("notebook1")
165 141 self.w_generalinfo_textview = \
166 142 w_tree_main.get_widget("generalinfotextview")
167 143 self.w_installedfiles_textview = \
168 144 w_tree_main.get_widget("installedfilestextview")
145 + self.w_license_textview = \
146 + w_tree_main.get_widget("licensetextview")
169 147 self.w_dependencies_textview = \
170 148 w_tree_main.get_widget("dependenciestextview")
171 149 self.w_packagename_label = w_tree_main.get_widget("packagenamelabel")
172 150 self.w_shortdescription_label = \
173 151 w_tree_main.get_widget("shortdescriptionlabel")
174 152 self.w_searchentry_dialog = w_tree_main.get_widget("searchentry")
175 153 self.w_installupdate_button = \
176 154 w_tree_main.get_widget("install_update_button")
177 155 self.w_remove_button = w_tree_main.get_widget("remove_button")
178 156 self.w_updateall_button = w_tree_main.get_widget("update_all_button")
179 157 self.w_reload_button = w_tree_main.get_widget("reloadbutton")
180 158 self.w_repository_combobox = w_tree_main.get_widget("repositorycombobox")
181 159 self.w_sections_combobox = w_tree_main.get_widget("sectionscombobox")
182 160 self.w_filter_combobox = w_tree_main.get_widget("filtercombobox")
183 161 self.w_packageicon_image = w_tree_main.get_widget("packageimage")
184 162 self.w_main_statusbar = w_tree_main.get_widget("statusbar")
185 163 self.w_installupdate_menuitem = \
186 164 w_tree_main.get_widget("package_install_update")
187 165 self.w_remove_menuitem = w_tree_main.get_widget("package_remove")
188 166 self.w_updateall_menuitem = w_tree_main.get_widget("package_update_all")
189 167 self.w_cut_menuitem = w_tree_main.get_widget("edit_cut")
190 168 self.w_copy_menuitem = w_tree_main.get_widget("edit_copy")
191 169 self.w_paste_menuitem = w_tree_main.get_widget("edit_paste")
192 170 self.w_clear_menuitem = w_tree_main.get_widget("edit_clear")
193 171 self.w_selectall_menuitem = w_tree_main.get_widget("edit_select_all")
194 172 self.w_selectupdates_menuitem = \
195 173 w_tree_main.get_widget("edit_select_updates")
196 174 self.w_deselect_menuitem = w_tree_main.get_widget("edit_deselect")
197 175 self.w_main_clipboard = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD)
|
↓ open down ↓ |
19 lines elided |
↑ open up ↑ |
198 176
199 177 self.w_progress_dialog = w_tree_progress.get_widget("progressdialog")
200 178 self.w_progress_dialog.set_title(self._("Update All"))
201 179 self.w_progressinfo_label = w_tree_progress.get_widget("progressinfo")
202 180 self.w_progressinfo_label.set_text(self._( \
203 181 "Checking SUNWipkg and SUNWipkg-gui versions\n\nPlease wait ..."))
204 182 self.w_progressbar = w_tree_progress.get_widget("progressbar")
205 183 self.w_progressbar.set_pulse_step(0.1)
206 184 self.w_progress_cancel = w_tree_progress.get_widget("progresscancel")
207 185 self.progress_canceled = False
186 + clear_search_image = w_tree_main.get_widget("clear_image")
187 + clear_search_image.set_from_stock(gtk.STOCK_CLEAR, gtk.ICON_SIZE_MENU)
208 188
209 189 self.__update_reload_button()
210 190 self.w_main_clipboard.request_text(self.__clipboard_text_received)
211 191 self.w_main_window.set_title(main_window_title)
192 + self.w_license_page = self.w_info_notebook.get_nth_page(3)
193 + self.w_info_notebook.remove_page(3)
212 194
213 195 try:
214 196 dic_mainwindow = \
215 197 {
216 198 "on_mainwindow_delete_event": \
217 199 self.__on_mainwindow_delete_event,
218 200 "on_searchentry_changed":self.__on_searchentry_changed,
219 201 "on_searchentry_focus_in_event": \
220 202 self.__on_searchentry_focus_in,
221 203 "on_searchentry_focus_out_event": \
222 204 self.__on_searchentry_focus_out,
223 205 "on_searchentry_event":self.__on_searchentry_event,
224 206 "on_sectionscombobox_changed": \
|
↓ open down ↓ |
3 lines elided |
↑ open up ↑ |
225 207 self.__on_sectionscombobox_changed,
226 208 "on_filtercombobox_changed": \
227 209 self.__on_filtercombobox_changed,
228 210 "on_repositorycombobox_changed": \
229 211 self.__on_repositorycombobox_changed,
230 212 #menu signals
231 213 "on_file_quit_activate":self.__on_file_quit_activate,
232 214 "on_file_be_activate":self.__on_file_be_activate,
233 215 "on_package_install_update_activate": \
234 216 self.__on_install_update,
217 + "on_settings_edit_repositories_activate": \
218 + self.__on_edit_repositories_activate,
235 219 "on_package_remove_activate":self.__on_remove,
236 220 "on_help_about_activate":self.__on_help_about,
221 + "on_help_help_activate":self.__on_help_help,
237 222 "on_edit_paste_activate":self.__on_edit_paste,
238 223 "on_edit_clear_activate":self.__on_clear_paste,
239 224 "on_edit_copy_activate":self.__on_copy,
240 225 "on_edit_cut_activate":self.__on_cut,
226 + "on_clear_search_clicked":self.__on_clear_search,
241 227 "on_edit_select_all_activate":self.__on_select_all,
242 228 "on_edit_select_updates_activate": \
243 229 self.__on_select_updates,
244 230 "on_edit_deselect_activate":self.__on_deselect,
245 231 # XXX disabled until new API
246 232 "on_package_update_all_activate":self.__on_update_all,
247 233 #toolbar signals
248 234 # XXX disabled until new API
249 235 "on_update_all_button_clicked":self.__on_update_all,
250 236 "on_reload_button_clicked":self.__on_reload,
251 237 "on_install_update_button_clicked": \
252 238 self.__on_install_update,
253 239 "on_remove_button_clicked":self.__on_remove
254 240 }
255 241 dic_progress = \
256 242 {
257 243 "on_cancel_progressdialog_clicked": \
258 244 self.__on_cancel_progressdialog_clicked,
259 245 }
|
↓ open down ↓ |
9 lines elided |
↑ open up ↑ |
260 246 w_tree_main.signal_autoconnect(dic_mainwindow)
261 247 w_tree_progress.signal_autoconnect(dic_progress)
262 248 except AttributeError, error:
263 249 print self._( \
264 250 'GUI will not respond to any event! %s.' + \
265 251 'Check declare_signals()') \
266 252 % error
267 253
268 254 self.package_selection = None
269 255 self.category_list_filter = None
256 + self.application_list_filter = None
270 257 self.in_setup = True
271 258 self.w_main_window.show_all()
272 259
273 - def __init_tree_views(self):
260 + @staticmethod
261 + def __get_new_application_liststore():
262 + return gtk.ListStore(
263 + gobject.TYPE_BOOLEAN, # enumerations.MARK_COLUMN
264 + gtk.gdk.Pixbuf, # enumerations.STATUS_ICON_COLUMN
265 + gtk.gdk.Pixbuf, # enumerations.ICON_COLUMN
266 + gobject.TYPE_STRING, # enumerations.NAME_COLUMN
267 + gobject.TYPE_STRING, # enumerations.INSTALLED_VERSION_COLUMN
268 + gobject.TYPE_PYOBJECT, # enumerations.INSTALLED_OBJECT_COLUMN
269 + gobject.TYPE_STRING, # enumerations.LATEST_AVAILABLE_COLUMN
270 + gobject.TYPE_INT, # enumerations.RATING_COLUMN
271 + gobject.TYPE_STRING, # enumerations.DESCRIPTION_COLUMN
272 + gobject.TYPE_PYOBJECT, # enumerations.PACKAGE_OBJECT_COLUMN
273 + gobject.TYPE_BOOLEAN, # enumerations.IS_VISIBLE_COLUMN
274 + gobject.TYPE_PYOBJECT # enumerations.CATEGORY_LIST_OBJECT
275 + )
276 +
277 + @staticmethod
278 + def __get_new_category_liststore():
279 + return gtk.ListStore(
280 + gobject.TYPE_INT, # enumerations.CATEGORY_ID
281 + gobject.TYPE_STRING, # enumerations.CATEGORY_NAME
282 + gobject.TYPE_STRING, # enumerations.CATEGORY_DESCRIPTION
283 + gtk.gdk.Pixbuf, # enumerations.CATEGORY_ICON
284 + gobject.TYPE_BOOLEAN, # enumerations.CATEGORY_VISIBLE
285 + gobject.TYPE_PYOBJECT, # enumerations.SECTION_LIST_OBJECT
286 + )
287 +
288 + @staticmethod
289 + def __get_new_section_liststore():
290 + return gtk.ListStore(
291 + gobject.TYPE_INT, # enumerations.SECTION_ID
292 + gobject.TYPE_STRING, # enumerations.SECTION_NAME
293 + )
294 +
295 + @staticmethod
296 + def __get_new_filter_liststore():
297 + return gtk.ListStore(
298 + gobject.TYPE_INT, # enumerations.FILTER_ID
299 + gobject.TYPE_STRING, # enumerations.FILTER_NAME
300 + )
301 +
302 + @staticmethod
303 + def __get_new_repositories_liststore():
304 + return gtk.ListStore(
305 + gobject.TYPE_INT, # enumerations.REPOSITORY_ID
306 + gobject.TYPE_STRING, # enumerations.REPOSITORY_NAME
307 + )
308 +
309 + def __init_tree_views(self, application_list, category_list, repositories_list):
274 310 '''This function connects treeviews with their models and also applies
275 311 filters'''
312 + self.__disconnect_models()
313 + self.__remove_treeview_columns(self.w_application_treeview)
314 + self.__remove_treeview_columns(self.w_categories_treeview)
276 315 ##APPLICATION MAIN TREEVIEW
316 + application_list_filter = application_list.filter_new()
277 317 application_list_sort = \
278 - gtk.TreeModelSort(self.application_list_filter)
279 - self.w_application_treeview.set_model(application_list_sort)
280 - model = self.w_application_treeview.get_model()
318 + gtk.TreeModelSort(application_list_filter)
281 319 toggle_renderer = gtk.CellRendererToggle()
282 - toggle_renderer.connect('toggled', self.__active_pane_toggle, model)
320 +
283 321 column = gtk.TreeViewColumn("", toggle_renderer, \
284 322 active = enumerations.MARK_COLUMN)
285 323 column.set_sort_column_id(enumerations.MARK_COLUMN)
286 324 column.set_sort_indicator(True)
287 325 column.set_cell_data_func(toggle_renderer, self.cell_data_function, None)
288 326 self.w_application_treeview.append_column(column)
289 327 column = gtk.TreeViewColumn()
290 328 column.set_title("")
291 329 #Commented, since there was funny jumping of the icons
292 330 #column.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE)
293 331 render_pixbuf = gtk.CellRendererPixbuf()
294 332 column.pack_start(render_pixbuf, expand = False)
295 - column.add_attribute(render_pixbuf, "pixbuf", \
296 - enumerations.STATUS_ICON_COLUMN)
297 - column.set_fixed_width(32)
298 - column.set_cell_data_func(render_pixbuf, self.cell_data_function, None)
299 - self.w_application_treeview.append_column(column)
300 - column = gtk.TreeViewColumn()
301 - column.set_title("")
302 - #Commented, since there was funny jumping of the icons
303 - #column.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE)
304 - render_pixbuf = gtk.CellRendererPixbuf()
305 - column.pack_start(render_pixbuf, expand = False)
306 333 column.add_attribute(render_pixbuf, "pixbuf", enumerations.ICON_COLUMN)
307 334 column.set_fixed_width(32)
308 335 column.set_cell_data_func(render_pixbuf, self.cell_data_function, None)
309 336 self.w_application_treeview.append_column(column)
310 337 name_renderer = gtk.CellRendererText()
311 338 column = gtk.TreeViewColumn(self._("Name"), name_renderer, \
312 339 text = enumerations.NAME_COLUMN)
313 340 column.set_sort_column_id(enumerations.NAME_COLUMN)
314 341 column.set_sort_indicator(True)
315 342 column.set_cell_data_func(name_renderer, self.cell_data_function, None)
316 343 self.w_application_treeview.append_column(column)
344 + column = gtk.TreeViewColumn()
345 + column.set_title(self._("Status"))
346 + #Commented, since there was funny jumping of the icons
347 + #column.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE)
348 + render_pixbuf = gtk.CellRendererPixbuf()
349 + column.pack_start(render_pixbuf, expand = True)
350 + column.add_attribute(render_pixbuf, "pixbuf", \
351 + enumerations.STATUS_ICON_COLUMN)
352 + column.set_fixed_width(32)
353 + column.set_cell_data_func(render_pixbuf, self.cell_data_function, None)
354 + self.w_application_treeview.append_column(column)
317 355 installed_version_renderer = gtk.CellRendererText()
318 356 column = gtk.TreeViewColumn(self._('Installed Version'), \
319 357 installed_version_renderer, \
320 358 text = enumerations.INSTALLED_VERSION_COLUMN)
321 359 column.set_sort_column_id(enumerations.INSTALLED_VERSION_COLUMN)
322 360 column.set_sort_indicator(True)
323 361 column.set_cell_data_func(installed_version_renderer, \
324 362 self.cell_data_function, None)
325 - self.w_application_treeview.append_column(column)
326 363 latest_available_renderer = gtk.CellRendererText()
327 364 column = gtk.TreeViewColumn(self._('Latest Version'), \
328 365 latest_available_renderer, \
329 366 text = enumerations.LATEST_AVAILABLE_COLUMN)
330 367 column.set_sort_column_id(enumerations.LATEST_AVAILABLE_COLUMN)
331 368 column.set_sort_indicator(True)
332 369 column.set_cell_data_func(latest_available_renderer, \
333 370 self.cell_data_function, None)
334 - self.w_application_treeview.append_column(column)
335 371 rating_renderer = gtk.CellRendererText()
336 372 column = gtk.TreeViewColumn(self._('Rating'), rating_renderer, \
337 373 text = enumerations.RATING_COLUMN)
338 374 column.set_cell_data_func(rating_renderer, self.cell_data_function, None)
339 375 description_renderer = gtk.CellRendererText()
340 376 column = gtk.TreeViewColumn(self._('Description'), \
341 377 description_renderer, text = enumerations.DESCRIPTION_COLUMN)
342 378 column.set_sort_column_id(enumerations.DESCRIPTION_COLUMN)
343 379 column.set_sort_indicator(True)
344 380 column.set_cell_data_func(description_renderer, \
345 381 self.cell_data_function, None)
346 382 self.w_application_treeview.append_column(column)
347 383 #Added selection listener
348 384 self.package_selection = self.w_application_treeview.get_selection()
349 - self.package_selection.set_mode(gtk.SELECTION_SINGLE)
350 - self.package_selection.connect("changed", \
351 - self.__on_package_selection_changed, None)
385 +
352 386 ##CATEGORIES TREEVIEW
353 387 #enumerations.CATEGORY_NAME
354 - self.category_list_filter = self.category_list.filter_new()
355 - self.category_list_filter.set_visible_func(self.category_filter)
356 - self.w_categories_treeview.set_model(self.category_list_filter)
388 + category_list_filter = category_list.filter_new()
357 389 enumerations.CATEGORY_NAME_renderer = gtk.CellRendererText()
358 390 column = gtk.TreeViewColumn(self._('Name'), \
359 391 enumerations.CATEGORY_NAME_renderer, \
360 392 text = enumerations.CATEGORY_NAME)
361 393 self.w_categories_treeview.append_column(column)
362 394 #Added selection listener
363 395 category_selection = self.w_categories_treeview.get_selection()
364 396 category_selection.set_mode(gtk.SELECTION_SINGLE)
365 - category_selection.connect("changed", \
366 - self.__on_category_selection_changed, None)
367 - ##SECTION COMBOBOX
368 - #enumerations.SECTION_NAME
397 +
398 + if self.first_run:
399 + ##SECTION COMBOBOX
400 + #enumerations.SECTION_NAME
401 + cell = gtk.CellRendererText()
402 + self.w_sections_combobox.pack_start(cell, True)
403 + self.w_sections_combobox.add_attribute(cell, 'text', \
404 + enumerations.SECTION_NAME)
405 + self.w_sections_combobox.set_row_separator_func( \
406 + self.combobox_id_separator)
407 + ##FILTER COMBOBOX
408 + #enumerations.FILTER_NAME
409 + cell = gtk.CellRendererText()
410 + self.w_filter_combobox.pack_start(cell, True)
411 + self.w_filter_combobox.add_attribute(cell, 'text', \
412 + enumerations.FILTER_NAME)
413 + self.w_filter_combobox.set_row_separator_func(\
414 + self.combobox_id_separator)
415 + ##FILTER COMBOBOX
416 + #enumerations.FILTER_NAME
417 + cell = gtk.CellRendererText()
418 + self.w_repository_combobox.pack_start(cell, True)
419 + self.w_repository_combobox.add_attribute(cell, 'text', \
420 + enumerations.REPOSITORY_NAME)
421 + self.w_repository_combobox.set_row_separator_func( \
422 + self.combobox_id_separator)
423 +
424 + self.application_list = application_list
425 + self.category_list = category_list
426 + self.repositories_list = repositories_list
427 + self.category_list_filter = category_list_filter
428 + self.application_list_filter = application_list_filter
429 +
369 430 self.w_sections_combobox.set_model(self.section_list)
370 - cell = gtk.CellRendererText()
371 - self.w_sections_combobox.pack_start(cell, True)
372 - self.w_sections_combobox.add_attribute(cell, 'text', \
373 - enumerations.SECTION_NAME)
374 - self.w_sections_combobox.set_row_separator_func( \
375 - self.combobox_id_separator)
376 - ##FILTER COMBOBOX
377 - #enumerations.FILTER_NAME
431 + self.w_sections_combobox.set_active(0)
378 432 self.w_filter_combobox.set_model(self.filter_list)
379 - cell = gtk.CellRendererText()
380 - self.w_filter_combobox.pack_start(cell, True)
381 - self.w_filter_combobox.add_attribute(cell, 'text', \
382 - enumerations.FILTER_NAME)
383 - self.w_filter_combobox.set_row_separator_func(self.combobox_id_separator)
384 - ##FILTER COMBOBOX
385 - #enumerations.FILTER_NAME
386 - self.w_repository_combobox.set_model(self.repositories_list)
387 - cell = gtk.CellRendererText()
388 - self.w_repository_combobox.pack_start(cell, True)
389 - self.w_repository_combobox.add_attribute(cell, 'text', \
390 - enumerations.REPOSITORY_NAME)
391 - self.w_repository_combobox.set_row_separator_func( \
392 - self.combobox_id_separator)
393 433 self.w_filter_combobox.set_active(0)
434 + self.w_repository_combobox.set_model(repositories_list)
435 + self.w_categories_treeview.set_model(category_list_filter)
436 + self.w_application_treeview.set_model(application_list_sort)
437 + application_list_filter.set_visible_func(self.__application_filter)
438 + category_list_filter.set_visible_func(self.category_filter)
439 + toggle_renderer.connect('toggled', self.__active_pane_toggle, \
440 + application_list_sort)
441 + category_selection.connect("changed", \
442 + self.__on_category_selection_changed, None)
443 + self.package_selection.set_mode(gtk.SELECTION_SINGLE)
444 + self.package_selection.connect("changed", \
445 + self.__on_package_selection_changed, None)
446 + self.first_run = False
447 +
448 + def __disconnect_models(self):
449 + self.w_application_treeview.set_model(None)
450 + self.w_categories_treeview.set_model(None)
451 + self.w_repository_combobox.set_model(None)
452 + self.w_sections_combobox.set_model(None)
453 + self.w_filter_combobox.set_model(None)
454 +
455 + @staticmethod
456 + def __remove_treeview_columns(treeview):
457 + columns = treeview.get_columns()
458 + if columns:
459 + for column in columns:
460 + treeview.remove_column(column)
394 461
395 462 def __init_sections(self):
396 463 '''This function is for initializing sections combo box, also adds "All"
397 464 Category. It sets active section combobox entry "All"'''
398 465 self.section_list.append([0, self._('All'), ])
399 466 self.section_list.append([-1, "", ])
400 467 self.section_list.append([2, self._('Meta Packages'), ])
401 468 self.section_list.append([3, self._('Applications Desktop'), ])
402 469 self.section_list.append([4, self._('Applications Web-Based'), ])
403 470 self.section_list.append([5, self._('Operating System'), ])
404 471 self.section_list.append([6, self._('User Environment'), ])
405 472 self.section_list.append([7, self._('Web Infrastructure'), ])
406 473
407 474 def __init_show_filter(self):
408 475 self.filter_list.append([0, self._('All Packages'), ])
409 476 self.filter_list.append([-1, "", ])
410 477 self.filter_list.append([2, self._('Installed Packages'), ])
411 478 self.filter_list.append([3, self._('Updates'), ])
412 479 self.filter_list.append([4, self._('Non-installed Packages'), ])
413 480 self.filter_list.append([-1, "", ])
414 481 # self.filter_list.append([self._('Locked Packages'), ])
415 482 # self.filter_list.append(["", ])
416 483 self.filter_list.append([6, self._('Selected Packages'), ])
417 484
418 485 def __on_cancel_progressdialog_clicked(self, widget):
419 486 self.progress_canceled = True
420 487 self.progress_stop_timer_thread = True
421 488
422 489 def __on_mainwindow_delete_event(self, widget, event):
423 490 ''' handler for delete event of the main window '''
424 491 if self.__check_if_something_was_changed() == True:
425 492 # XXX Change this to not quit and show dialog
|
↓ open down ↓ |
22 lines elided |
↑ open up ↑ |
426 493 # XXX if some changes were applied:
427 494 self.__main_application_quit()
428 495 return True
429 496 else:
430 497 self.__main_application_quit()
431 498
432 499 def __on_file_quit_activate(self, widget):
433 500 ''' handler for quit menu event '''
434 501 self.__on_mainwindow_delete_event(None, None)
435 502
503 + def __on_edit_repositories_activate(self, widget):
504 + ''' handler for repository menu event '''
505 + repository.Repository(self)
506 +
436 507 def __on_file_be_activate(self, widget):
437 508 ''' handler for be menu event '''
438 509 beadm.Beadmin(self)
439 510
440 511 def __on_searchentry_changed(self, widget):
441 512 '''On text search field changed we should refilter the main view'''
442 513 Thread(target = self.__on_searchentry_threaded, args = ()).start()
443 514
444 515 def __on_searchentry_threaded(self):
445 516 gobject.idle_add(self.application_list_filter.refilter)
446 517 gobject.idle_add(self.__enable_disable_selection_menus)
447 518
448 519 def __on_edit_paste(self, widget):
449 520 self.w_searchentry_dialog.insert_text(self.main_clipboard_text, \
450 521 self.w_searchentry_dialog.get_position())
451 522
452 523 def __on_clear_paste(self, widget):
453 524 bounds = self.w_searchentry_dialog.get_selection_bounds()
454 525 self.w_searchentry_dialog.delete_text(bounds[0], bounds[1])
455 526 return
456 527
457 528 def __on_copy(self, widget):
458 529 bounds = self.w_searchentry_dialog.get_selection_bounds()
459 530 text = self.w_searchentry_dialog.get_chars(bounds[0], bounds[1])
|
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
460 531 self.w_main_clipboard.set_text(text)
461 532 return
462 533
463 534 def __on_cut(self, widget):
464 535 bounds = self.w_searchentry_dialog.get_selection_bounds()
465 536 text = self.w_searchentry_dialog.get_chars(bounds[0], bounds[1])
466 537 self.w_searchentry_dialog.delete_text(bounds[0], bounds[1])
467 538 self.w_main_clipboard.set_text(text)
468 539 return
469 540
541 + def __on_clear_search(self, widget):
542 + self.w_searchentry_dialog.delete_text(0, -1)
543 + return
544 +
470 545 def __on_select_all(self, widget):
471 546 sort_filt_model = \
472 547 self.w_application_treeview.get_model() #gtk.TreeModelSort
473 548 filt_model = sort_filt_model.get_model() #gtk.TreeModelFilter
474 549 model = filt_model.get_model() #gtk.ListStore
475 550 iter_next = sort_filt_model.get_iter_first()
476 551 list_of_paths = []
477 552 while iter_next != None:
478 553 sorted_path = sort_filt_model.get_path(iter_next)
479 554 filtered_path = \
480 555 sort_filt_model.convert_path_to_child_path(sorted_path)
481 556 path = filt_model.convert_path_to_child_path(filtered_path)
482 557 list_of_paths.append(path)
483 558 iter_next = sort_filt_model.iter_next(iter_next)
484 559 for path in list_of_paths:
485 560 itr = model.get_iter(path)
486 561 model.set_value(itr, enumerations.MARK_COLUMN, True)
487 562 self.__enable_disable_selection_menus()
488 563 self.update_statusbar()
489 564 self.__enable_disable_install_update()
490 565 self.__enable_disable_remove()
491 566
492 567 def __on_select_updates(self, widget):
493 568 sort_filt_model = \
494 569 self.w_application_treeview.get_model() #gtk.TreeModelSort
495 570 filt_model = sort_filt_model.get_model() #gtk.TreeModelFilter
496 571 model = filt_model.get_model() #gtk.ListStore
497 572 iter_next = sort_filt_model.get_iter_first()
498 573 list_of_paths = []
499 574 while iter_next != None:
500 575 sorted_path = sort_filt_model.get_path(iter_next)
501 576 filtered_iter = sort_filt_model.convert_iter_to_child_iter(None, \
502 577 iter_next)
503 578 app_iter = filt_model.convert_iter_to_child_iter(filtered_iter)
504 579
505 580 filtered_path = \
506 581 sort_filt_model.convert_path_to_child_path(sorted_path)
507 582 path = filt_model.convert_path_to_child_path(filtered_path)
508 583 if model.get_value(app_iter, \
509 584 enumerations.INSTALLED_VERSION_COLUMN):
510 585 if model.get_value(app_iter, \
511 586 enumerations.LATEST_AVAILABLE_COLUMN):
512 587 list_of_paths.append(path)
513 588 iter_next = sort_filt_model.iter_next(iter_next)
514 589 for path in list_of_paths:
515 590 itr = model.get_iter(path)
516 591 model.set_value(itr, enumerations.MARK_COLUMN, True)
517 592 self.__enable_disable_selection_menus()
518 593 self.update_statusbar()
519 594 self.__enable_disable_install_update()
520 595 self.__enable_disable_remove()
521 596
522 597 def __on_deselect(self, widget):
523 598 sort_filt_model = \
524 599 self.w_application_treeview.get_model() #gtk.TreeModelSort
525 600 filt_model = sort_filt_model.get_model() #gtk.TreeModelFilter
526 601 model = filt_model.get_model() #gtk.ListStore
527 602 iter_next = sort_filt_model.get_iter_first()
528 603 list_of_paths = []
529 604 while iter_next != None:
530 605 sorted_path = sort_filt_model.get_path(iter_next)
531 606 filtered_iter = sort_filt_model.convert_iter_to_child_iter(None, \
532 607 iter_next)
533 608 app_iter = filt_model.convert_iter_to_child_iter(filtered_iter)
534 609 filtered_path = \
535 610 sort_filt_model.convert_path_to_child_path(sorted_path)
536 611 path = filt_model.convert_path_to_child_path(filtered_path)
537 612 if model.get_value(app_iter, enumerations.MARK_COLUMN):
538 613 list_of_paths.append(path)
539 614 iter_next = sort_filt_model.iter_next(iter_next)
540 615 for path in list_of_paths:
541 616 itr = model.get_iter(path)
542 617 model.set_value(itr, enumerations.MARK_COLUMN, False)
543 618 self.__enable_disable_selection_menus()
544 619 self.update_statusbar()
545 620 self.__enable_disable_install_update()
546 621 self.__enable_disable_remove()
547 622
548 623 def __on_searchentry_focus_in(self, widget, event):
549 624 self.w_paste_menuitem.set_sensitive(True)
550 625
551 626 def __on_searchentry_focus_out(self, widget, event):
552 627 self.w_paste_menuitem.set_sensitive(False)
553 628
554 629 def __on_searchentry_event(self, widget, event):
555 630 self.w_main_clipboard.request_text(self.__clipboard_text_received)
556 631 if widget.get_selection_bounds():
557 632 #enable selection functions
558 633 self.w_cut_menuitem.set_sensitive(True)
559 634 self.w_copy_menuitem.set_sensitive(True)
560 635 self.w_clear_menuitem.set_sensitive(True)
561 636 else:
562 637 self.w_cut_menuitem.set_sensitive(False)
563 638 self.w_copy_menuitem.set_sensitive(False)
564 639 self.w_clear_menuitem.set_sensitive(False)
|
↓ open down ↓ |
85 lines elided |
↑ open up ↑ |
565 640
566 641 def __on_category_selection_changed(self, selection, widget):
567 642 '''This function is for handling category selection changes'''
568 643 self.application_list_filter.refilter()
569 644 self.__enable_disable_selection_menus()
570 645
571 646 def __on_package_selection_changed(self, selection, widget):
572 647 '''This function is for handling package selection changes'''
573 648 model, itr = selection.get_selected()
574 649 if itr:
575 - pkg = model.get_value(itr, enumerations.INSTALLED_OBJECT_COLUMN)
576 - if not pkg:
577 - packages = model.get_value(itr, \
578 - enumerations.PACKAGE_OBJECT_COLUMN)
579 - pkg = max(packages)
580 - self.pkginfo_thread = pkg
650 + self.pkginfo_thread += 1
651 + self.w_info_notebook.remove_page(3)
581 652 Thread(target = self.__show_package_info, \
582 - args = (model, itr)).start()
653 + args = (model, itr, self.pkginfo_thread)).start()
654 + Thread(target = self.__show_package_licenses, \
655 + args = (model, itr, self.pkginfo_thread)).start()
656 +
583 657
584 658 def __on_filtercombobox_changed(self, widget):
585 659 '''On filter combobox changed'''
660 + if self.in_setup:
661 + return
586 662 self.application_list_filter.refilter()
587 663 self.__enable_disable_selection_menus()
588 664
589 665 def __on_sectionscombobox_changed(self, widget):
590 666 '''On section combobox changed'''
667 + if self.in_setup:
668 + return
591 669 selected_section = widget.get_active()
592 670 if selected_section == 0:
593 671 for category in self.category_list:
594 672 category[enumerations.CATEGORY_VISIBLE] = True
595 673 else:
596 674 for category in self.category_list:
597 675 if category[enumerations.CATEGORY_ID] == 0:
598 676 category[enumerations.CATEGORY_VISIBLE] = True
599 677 else:
600 678 category_list = \
601 679 category[enumerations.SECTION_LIST_OBJECT]
602 680 if not category_list:
603 681 category[enumerations.CATEGORY_VISIBLE] \
604 682 = False
605 683 else:
606 684 for section in category_list:
607 685 if section == selected_section:
608 686 category[enumerations. \
609 687 CATEGORY_VISIBLE] = \
610 688 True
611 689 else:
|
↓ open down ↓ |
11 lines elided |
↑ open up ↑ |
612 690 category[enumerations. \
613 691 CATEGORY_VISIBLE] = \
614 692 False
615 693 self.category_list_filter.refilter()
616 694 self.application_list_filter.refilter()
617 695 self.__enable_disable_selection_menus()
618 696
619 697 def __on_repositorycombobox_changed(self, widget):
620 698 '''On repository combobox changed'''
621 699 if self.in_setup:
622 - return
700 + return
623 701 self.application_list_filter.refilter()
624 702 self.__enable_disable_selection_menus()
625 703
626 704 def __on_install_update(self, widget):
627 - installupdate.InstallUpdate(self.application_list, self, False)
705 + install_update = []
706 + for row in self.application_list:
707 + if row[enumerations.MARK_COLUMN]:
708 + install_update.append(row[\
709 + enumerations.NAME_COLUMN])
710 + installupdate.InstallUpdate(install_update, self, \
711 + self.image_directory, ips_update = False, \
712 + action = enumerations.INSTALL_UPDATE)
628 713
629 714 def __on_update_all(self, widget):
630 715 opensolaris_image = True
716 + self.progress_stop_timer_thread = False
631 717 notfound = self.__installed_fmris_from_args(self.image_o, \
632 718 ["SUNWipkg", "SUNWcs"])
633 719
634 720 if notfound:
635 721 opensolaris_image = False
636 722
637 723 if opensolaris_image:
638 724 # Load the catalogs from the repository, its a long
639 725 # running tasks so need a progress dialog
640 726 self.w_progress_dialog.set_title(self._("Update All"))
641 727 self.w_progressinfo_label.set_text(self._( \
642 728 "Checking SUNWipkg and SUNWipkg-gui versions\n" + \
643 729 "\nPlease wait ..."))
644 -
645 - self.w_progress_dialog.show()
646 730 Thread(target = self.__progressdialog_progress_pulse).start()
647 731 Thread(target = self.__do_ips_uptodate_check).start()
648 732 self.w_progress_dialog.run()
649 -
650 733 if self.progress_canceled:
651 734 return
652 735 else:
653 736 self.ips_uptodate = True
654 -
737 +
655 738 #2790: Make sure ipkg and ipkg-gui are up to date, if not update them and
656 739 # prompt user to restart
657 740 if not self.ips_uptodate:
658 741 # Prompt user
659 742 msgbox = gtk.MessageDialog(parent = self.w_main_window, \
660 743 buttons = gtk.BUTTONS_YES_NO, \
661 744 flags = gtk.DIALOG_MODAL, type = gtk.MESSAGE_QUESTION, \
662 - message_format = self._("Newer versions of SUNWipkg and" + \
663 - "SUNWipkg-gui are available " + "and\nmust be updated" + \
664 - "before running Update All.\n\n Do you want to update" + \
745 + message_format = self._("Newer versions of SUNWipkg and " + \
746 + "SUNWipkg-gui\n" + "are available and must be updated " + \
747 + "before\nrunning Update All.\n\nDo you want to update " + \
665 748 "them now?"))
666 749 msgbox.set_title(self._("Update All"))
667 750 result = msgbox.run()
668 751 msgbox.destroy()
669 752 if result == gtk.RESPONSE_YES:
670 753 pkg_list = [self.ipkg_fmri, self.ipkggui_fmri]
671 - installupdate.InstallUpdate({self.image_o:pkg_list}, \
672 - self, False, True)
754 + installupdate.InstallUpdate(pkg_list, \
755 + self, self.image_directory, \
756 + ips_update = True, \
757 + action = enumerations.INSTALL_UPDATE)
673 758 else:
674 759 msgbox = gtk.MessageDialog(parent = self.w_main_window, \
675 760 buttons = gtk.BUTTONS_OK, \
676 761 flags = gtk.DIALOG_MODAL, type = gtk.MESSAGE_INFO, \
677 762 message_format = self._("Update All was not " + \
678 - "run.\n\n It can not be run until SUNWipkg and " + \
763 + "run.\n\nIt can not be run until SUNWipkg and " + \
679 764 "SUNWipkg-gui have been updated."))
680 765 msgbox.set_title(self._("Update All"))
681 766 result = msgbox.run()
682 767 msgbox.destroy()
683 - else:
684 - pkg_list = [ ipkg.get_pkg_stem() for ipkg in \
685 - self.image_o.gen_installed_pkgs() ]
686 - installupdate.InstallUpdate({self.image_o:pkg_list}, self, \
687 - True, False)
768 + else:
769 + installupdate.InstallUpdate([], self, \
770 + self.image_directory, ips_update = False, \
771 + action = enumerations.IMAGE_UPDATE)
688 772
689 773 def __on_help_about(self, widget):
690 774 wTreePlan = gtk.glade.XML(self.gladefile, "aboutdialog")
691 775 aboutdialog = wTreePlan.get_widget("aboutdialog")
692 776 aboutdialog.connect("response", lambda x = None, \
693 777 y = None: aboutdialog.destroy())
694 778 aboutdialog.run()
695 779
780 + def __on_help_help(self, widget):
781 + props = { gnome.PARAM_APP_DATADIR : self.application_dir + \
782 + '/usr/share/package-manager/help' }
783 + gnome.program_init('package-manager', '0.1', properties=props)
784 + gnome.help_display('package-manager')
785 +
696 786 def __on_remove(self, widget):
697 - remove.Remove(self.application_list, self)
787 + remove_list = []
788 + for pkg in self.application_list:
789 + if pkg[enumerations.MARK_COLUMN] and \
790 + pkg[enumerations.INSTALLED_VERSION_COLUMN]:
791 + remove_list.append(\
792 + pkg[enumerations.NAME_COLUMN])
793 + installupdate.InstallUpdate(remove_list, self, \
794 + self.image_directory, ips_update = False, \
795 + action = enumerations.REMOVE)
698 796
699 797 def __on_reload(self, widget):
700 798 if self.description_thread_running:
701 799 self.cancelled = True
702 - self.__catalog_refresh()
800 + self.in_setup = True
801 + self.w_progress_dialog.set_title(self._("Refreshing catalogs"))
802 + self.w_progressinfo_label.set_text(self._("Refreshing catalogs..."))
803 + self.progress_stop_timer_thread = False
804 + Thread(target = self.__progressdialog_progress_pulse).start()
805 + self.w_progress_dialog.show()
806 + self.__disconnect_models()
807 + Thread(target = self.__catalog_refresh).start()
808 +
809 + def __catalog_refresh_done(self):
810 + self.progress_stop_timer_thread = True
811 + #Let the progress_pulse finish. This should be done other way, but at
812 + #The moment this works fine
813 + time.sleep(0.2)
703 814 self.process_package_list_start(self.image_directory)
704 - self.category_list_filter.refilter()
705 - self.application_list_filter.refilter()
706 815 self.__enable_disable_selection_menus()
707 816 self.update_statusbar()
708 817 self.__update_install_update_button(None, True)
709 818 self.__update_remove_button(None, True)
710 819
711 820 def __clipboard_text_received(self, clipboard, text, data):
712 821 self.main_clipboard_text = text
713 822 return
714 823
715 824 def __main_application_quit(self, restart_app = False):
716 825 '''quits the main gtk loop'''
717 826 self.cancelled = True
718 827 if self.in_setup:
719 828 return
720 829
721 830 if restart_app:
722 - if "image_dir_arg" in self.__dict__:
831 + if self.image_dir_arg:
723 832 gobject.spawn_async([self.application_path, "-R", \
724 833 self.image_dir_arg])
725 834 else:
726 835 gobject.spawn_async([self.application_path])
727 836 gtk.main_quit()
728 837 sys.exit(0)
729 838 return True
730 839
731 840 def __check_if_something_was_changed(self):
732 841 ''' Returns True if any of the check boxes for package was changed, false
733 842 if not'''
734 843 for pkg in self.application_list:
735 844 if pkg[enumerations.MARK_COLUMN] == True:
736 845 return True
737 846 return False
738 847
739 - def __setup_repositories_combobox(self, img):
848 + def __setup_repositories_combobox(self, img, repositories_list):
740 849 if self.in_setup or img == None:
741 850 return
742 -
743 851 repositories = img.catalogs
744 852 default_authority = img.get_default_authority()
745 - self.repositories_list.clear()
746 853 i = 0
747 854 active = 0
748 855 for repo in repositories:
749 856 if cmp(repo, default_authority) == 0:
750 857 active = i
751 858
752 - self.repositories_list.append([i, repo, ])
859 + repositories_list.append([i, repo, ])
753 860 i = i + 1
861 + self.w_repository_combobox.set_model(repositories_list)
754 862 if default_authority:
755 863 self.w_repository_combobox.set_active(active)
756 864 else:
757 865 self.w_repository_combobox.set_active(0)
758 866
759 867 def __active_pane_toggle(self, cell, path, model_sort):
760 868 '''Toggle function for column enumerations.MARK_COLUMN'''
761 869 applicationModel = model_sort.get_model()
762 870 applicationPath = model_sort.convert_path_to_child_path(path)
763 871 filterModel = applicationModel.get_model()
764 872 child_path = applicationModel.convert_path_to_child_path(applicationPath)
765 873 itr = filterModel.get_iter(child_path)
766 874 if itr:
767 875 modified = filterModel.get_value(itr, enumerations.MARK_COLUMN)
768 876 filterModel.set_value(itr, enumerations.MARK_COLUMN, \
769 877 not modified)
770 878 latest_available = filterModel.get_value(itr, \
771 879 enumerations.LATEST_AVAILABLE_COLUMN)
772 880 installed_available = filterModel.get_value(itr, \
773 881 enumerations.INSTALLED_VERSION_COLUMN)
774 882 self.update_statusbar()
775 883 self.__update_install_update_button(latest_available, modified)
776 884 self.__update_remove_button(installed_available, modified)
777 885 self.__enable_disable_selection_menus()
778 886
779 887
780 888 def __update_install_update_button(self, latest_available, toggle_true):
781 889 if not toggle_true and self.user_rights:
782 890 if latest_available:
783 891 self.w_installupdate_button.set_sensitive(True)
784 892 self.w_installupdate_menuitem.set_sensitive(True)
785 893 else:
786 894 available = None
787 895 for row in self.application_list:
788 896 if row[enumerations.MARK_COLUMN]:
789 897 available = \
790 898 row[enumerations.LATEST_AVAILABLE_COLUMN]
791 899 if available:
792 900 return
793 901 if not available:
794 902 self.w_installupdate_button.set_sensitive(False)
795 903 self.w_installupdate_menuitem.set_sensitive(False)
796 904
797 905 def __update_reload_button(self):
798 906 if self.user_rights:
799 907 self.w_reload_button.set_sensitive(True)
800 908 else:
801 909 self.w_reload_button.set_sensitive(False)
802 910
803 911 def __update_remove_button(self, installed_available, toggle_true):
804 912 if not toggle_true and self.user_rights:
805 913 if installed_available:
806 914 self.w_remove_button.set_sensitive(True)
807 915 self.w_remove_menuitem.set_sensitive(True)
808 916 else:
809 917 available = None
810 918 for row in self.application_list:
811 919 if row[enumerations.MARK_COLUMN]:
812 920 installed = \
813 921 row[enumerations.INSTALLED_VERSION_COLUMN]
814 922 if installed:
815 923 return
816 924 if not available:
817 925 self.w_remove_button.set_sensitive(False)
818 926 self.w_remove_menuitem.set_sensitive(False)
819 927
820 928 def __update_package_info(self, pkg, icon, installed, manifest):
821 929 if icon and icon != pkg:
822 930 self.w_packageicon_image.set_from_pixbuf(icon)
823 931 else:
824 932 self.w_packageicon_image.set_from_pixbuf( \
825 933 self.__get_pixbuf_from_path("/usr/share/package-manager/", \
826 934 "PM_package_36x"))
827 935 self.w_packagename_label.set_markup("<b>" + pkg.get_name() + "</b>")
828 936 instbuffer = self.w_installedfiles_textview.get_buffer()
829 937 depbuffer = self.w_dependencies_textview.get_buffer()
830 938 infobuffer = self.w_generalinfo_textview.get_buffer()
831 939 if not manifest:
832 940 self.w_shortdescription_label.set_text( \
833 941 self._("Fetching description..."))
834 942 instbuffer.set_text(self._("Fetching information..."))
835 943 depbuffer.set_text(self._("Fetching information..."))
836 944 infobuffer.set_text(self._("Fetching information..."))
837 945 return
838 946 if manifest == "NotAvailable":
839 947 self.w_shortdescription_label.set_text( \
840 948 self._("Description not available for this package..."))
841 949 instbuffer.set_text( \
842 950 self._("Files Details not available for this package..."))
843 951 depbuffer.set_text(self._( \
844 952 "Dependencies info not available for this package..."))
845 953 infobuffer.set_text( \
846 954 self._("Information not available for this package..."))
847 955 return
848 956 self.w_shortdescription_label.set_text(manifest.get("description", ""))
849 957 instbuffer.set_text(self._("Root: %s\n") % manifest.img.get_root())
850 958 depbuffer.set_text(self._("Dependencies:\n"))
851 959 if installed:
852 960 infobuffer.set_text( \
853 961 self._("Information for installed package:\n\n"))
854 962 else:
855 963 infobuffer.set_text( \
856 964 self._("Information for latest available package:\n\n"))
857 965 depiter = depbuffer.get_end_iter()
858 966 institer = instbuffer.get_end_iter()
859 967 infoiter = infobuffer.get_end_iter()
860 968 #Name: SUNWckr
861 969 #FMRI: pkg://opensolaris.org/SUNWckr@0.5.11,5.11-0.75:20071114T203148Z
862 970 #Version: 0.5.11
863 971 #Branch: 0.75
864 972 #Packaging Date: 2007-11-14 20:31:48
865 973 #Size: 29369698
866 974 #Summary: Core Solaris Kernel (Root)
867 975 for a in manifest.actions:
868 976 if cmp(a.name, self.n_("depend")) == 0:
869 977 #Remove "depend: " -> [8:]
870 978 depbuffer.insert(depiter, "\t" + \
871 979 self.__locale_distinguished_name(a)[8:]+"\n")
872 980 elif cmp(a.name,self.n_("dir")) == 0:
873 981 instbuffer.insert(institer, "\t" + \
874 982 self.__locale_distinguished_name(a)+"\n")
875 983 elif cmp(a.name,self.n_("file")) == 0:
876 984 instbuffer.insert(institer, "\t" + \
877 985 self.__locale_distinguished_name(a)+"\n")
878 986 elif cmp(a.name,self.n_("hardlink")) == 0:
879 987 instbuffer.insert(institer, "\t" + \
880 988 self.__locale_distinguished_name(a)+"\n")
881 989 elif cmp(a.name,self.n_("link")) == 0:
882 990 instbuffer.insert(institer, "\t" + \
883 991 self.__locale_distinguished_name(a)+"\n")
884 992 elif cmp(a.name,self.n_("legacy")) == 0:
885 993 if cmp(a.attrlist(self.n_("pkg"))[0], \
886 994 pkg.get_name()) == 0:
887 995 desc = a.attrlist(self.n_("desc"))
888 996 infobuffer.insert(infoiter, \
|
↓ open down ↓ |
125 lines elided |
↑ open up ↑ |
889 997 self._(" Description:\t%s\n") % desc[0])
890 998 else:
891 999 pass
892 1000 infobuffer.insert(infoiter, self._(" Name:\t\t%s\n") % pkg.get_name())
893 1001 infobuffer.insert(infoiter, self._(" FMRI:\t\t%s\n") % pkg.get_fmri())
894 1002 infobuffer.insert(infoiter, self._(" Version:\t\t%s\n") % \
895 1003 pkg.version.get_short_version())
896 1004 infobuffer.insert(infoiter, self._(" Packaged:\t%s\n") % \
897 1005 self.get_datetime(pkg.version))
898 1006
1007 + def __update_package_license(self, licenses):
1008 + lic = ""
1009 + lic_u = ""
1010 + for licens in licenses:
1011 + lic += licens.get_text()
1012 + lic += "\n"
1013 + self.w_info_notebook.insert_page(self.w_license_page, \
1014 + gtk.Label("Licenses"), 3)
1015 + licbuffer = self.w_license_textview.get_buffer()
1016 + try:
1017 + lic_u = unicode(lic, "utf-8")
1018 + except UnicodeDecodeError:
1019 + lic_u += ""
1020 + licbuffer.set_text(lic_u)
1021 +
899 1022 def __update_description(self, description, package):
900 1023 '''workaround function'''
901 1024 for pkg in self.application_list:
902 1025 p = pkg[enumerations.PACKAGE_OBJECT_COLUMN][0]
903 1026 if p == package:
904 1027 pkg[enumerations.DESCRIPTION_COLUMN] = description
905 1028 return
906 1029
907 - def __show_package_info(self, model, itr):
908 - img = model.get_value(itr, enumerations.IMAGE_OBJECT_COLUMN)
1030 + def __show_package_licenses(self, model, itr, th_no):
1031 + pkg_name = model.get_value(itr, enumerations.NAME_COLUMN)
1032 + # sleep for a little time, this id done for tue users which are
1033 + # fast browsing the list of the packages.
1034 + time.sleep(1)
1035 + if th_no != self.pkginfo_thread:
1036 + return
1037 + info = self.api_o.info([pkg_name], True, True)
1038 + pkgs_info = None
1039 + package_info = None
1040 + no_licenses = 0
1041 + if info:
1042 + pkgs_info = info[0]
1043 + if pkgs_info:
1044 + package_info = pkgs_info[0]
1045 + if package_info:
1046 + no_licenses = len(package_info.licenses)
1047 + if no_licenses == 0:
1048 + return
1049 + if th_no == self.pkginfo_thread:
1050 + gobject.idle_add(self.__update_package_license, \
1051 + package_info.licenses)
1052 + else:
1053 + return
1054 +
1055 + def __show_package_info(self, model, itr, th_no):
909 1056 pkg = model.get_value(itr, enumerations.INSTALLED_OBJECT_COLUMN)
910 1057 icon = model.get_value(itr, enumerations.INSTALLED_OBJECT_COLUMN)
1058 + installed = False
911 1059 if not pkg:
912 1060 packages = model.get_value(itr, \
913 1061 enumerations.PACKAGE_OBJECT_COLUMN)
914 1062 pkg = max(packages)
915 1063 gobject.idle_add(self.__update_package_info, pkg, icon, False, \
916 1064 None)
917 1065 else:
918 1066 gobject.idle_add(self.__update_package_info, pkg, icon,
919 1067 True, None)
1068 + installed = True
1069 + # sleep for a little time, this is done for the users which are
1070 + # fast browsing the list of the packages.
1071 + time.sleep(1)
1072 + if th_no != self.pkginfo_thread:
1073 + return
920 1074 man = None
1075 + img = self.image_o
921 1076 img.history.operation_name = "info"
1077 +
922 1078 try:
923 - man = img.get_manifest(pkg, filtered = True)
1079 + man = self.image_o.get_manifest(pkg, filtered = True)
924 1080 except IOError:
925 1081 man = "NotAvailable"
926 1082 img.history.operation_result = \
927 1083 history.RESULT_FAILED_STORAGE
928 1084 except:
1085 + if not img.history.operation_name:
1086 + img.history.operation_name = "info"
929 1087 img.history.operation_result = \
930 1088 history.RESULT_FAILED_UNKNOWN
931 1089
932 - if cmp(self.pkginfo_thread, pkg) == 0:
1090 + if not img.history.operation_name:
1091 + img.history.operation_name = "info"
1092 +
1093 + if th_no == self.pkginfo_thread:
933 1094 if not pkg:
934 1095 gobject.idle_add(self.__update_package_info, pkg, icon, \
935 - False, man)
1096 + installed, man)
936 1097 else:
937 1098 gobject.idle_add(self.__update_package_info, pkg, icon, \
938 - True, man)
1099 + installed, man)
939 1100 img.history.operation_result = \
940 1101 history.RESULT_SUCCEEDED
941 1102 else:
942 1103 img.history.operation_result = \
943 1104 history.RESULT_SUCCEEDED
944 1105 return
945 1106
946 1107 # This function is ported from pkg.actions.generic.distinguished_name()
947 1108 def __locale_distinguished_name(self, action):
948 1109 if action.key_attr == None:
949 1110 return str(action)
950 1111 return "%s: %s" % \
951 1112 (self._(action.name), action.attrs.get(action.key_attr, "???"))
952 1113
953 1114 def __application_filter(self, model, itr):
954 1115 '''This function is used to filter content in the main
955 1116 application view'''
956 1117 if self.in_setup or self.cancelled:
957 1118 return False
958 1119 # XXX Show filter, chenge text to integers
959 1120 selected_category = 0
960 1121 selection = self.w_categories_treeview.get_selection()
|
↓ open down ↓ |
12 lines elided |
↑ open up ↑ |
961 1122 category_model, category_iter = selection.get_selected()
962 1123 if not category_iter: #no category was selected, so select "All"
963 1124 selection.select_path(0)
964 1125 category_model, category_iter = selection.get_selected()
965 1126 if category_iter:
966 1127 selected_category = category_model.get_value(category_iter, \
967 1128 enumerations.CATEGORY_ID)
968 1129 category_list_iter = model.get_value(itr, \
969 1130 enumerations.CATEGORY_LIST_OBJECT)
970 1131 category = False
971 - repository = self.__is_pkg_repository_visible(model, itr)
1132 + repo = self.__is_pkg_repository_visible(model, itr)
972 1133 if category_list_iter:
973 1134 sel = False
974 1135 for category_iter in category_list_iter:
975 1136 if category != True:
976 1137 category = \
977 1138 self.category_filter(self.category_list, \
978 1139 category_iter)
979 1140 if selected_category != 0:
980 1141 if selected_category == \
981 1142 self.category_list.get_value(category_iter, \
982 1143 enumerations.CATEGORY_ID):
|
↓ open down ↓ |
1 lines elided |
↑ open up ↑ |
983 1144 sel = True
984 1145 category = sel
985 1146 else:
986 1147 if selected_category == 0:
987 1148 selected_section = self.w_sections_combobox.get_active()
988 1149 if selected_section == 0:
989 1150 category = True
990 1151 if (model.get_value(itr, enumerations.IS_VISIBLE_COLUMN) == False):
991 1152 return False
992 1153 if self.w_searchentry_dialog.get_text() == "":
993 - return (repository & category & \
1154 + return (repo & category & \
994 1155 self.__is_package_filtered(model, itr))
995 1156 if not model.get_value(itr, enumerations.NAME_COLUMN) == None:
996 1157 if self.w_searchentry_dialog.get_text().lower() in \
997 1158 model.get_value \
998 1159 (itr, enumerations.NAME_COLUMN).lower():
999 - return (repository & category & \
1160 + return (repo & category & \
1000 1161 self.__is_package_filtered(model, itr))
1001 1162 if not model.get_value(itr, enumerations.DESCRIPTION_COLUMN) == None:
1002 1163 if self.w_searchentry_dialog.get_text().lower() in \
1003 1164 model.get_value \
1004 1165 (itr, enumerations.DESCRIPTION_COLUMN).lower():
1005 - return (repository & category & \
1166 + return (repo & category & \
1006 1167 self.__is_package_filtered(model, itr))
1007 1168 else:
1008 1169 return False
1009 1170
1010 1171 def __is_package_filtered(self, model, itr):
1011 1172 '''Function for filtercombobox'''
1012 1173 # XXX Instead of string comparison, we should do it through integers.
1013 1174 # XXX It should be faster and better for localisations.
1014 1175 filter_text = self.w_filter_combobox.get_active()
1015 1176 if filter_text == 0:
1016 1177 return True
1017 1178 elif filter_text == 2:
1018 1179 return model.get_value(itr, \
1019 1180 enumerations.INSTALLED_VERSION_COLUMN) != None
1020 1181 elif filter_text == 3:
1021 1182 return (model.get_value(itr, \
1022 1183 enumerations.INSTALLED_VERSION_COLUMN) != None) & \
1023 1184 (model.get_value(itr, \
1024 1185 enumerations.LATEST_AVAILABLE_COLUMN) != None)
1025 1186 elif filter_text == 4:
1026 1187 return not model.get_value(itr, \
1027 1188 enumerations.INSTALLED_VERSION_COLUMN) != None
1028 1189 elif filter_text == 6:
1029 1190 return model.get_value(itr, enumerations.MARK_COLUMN)
1030 1191 elif filter_text == 8:
1031 1192 # XXX Locked support
1032 1193 return False
1033 1194
1034 1195
1035 1196 def __is_pkg_repository_visible(self, model, itr):
1036 1197 if len(self.repositories_list) <= 1:
1037 1198 return True
1038 1199 else:
1039 1200 auth_iter = self.w_repository_combobox.get_active_iter()
1040 1201 authority = self.repositories_list.get_value(auth_iter, \
1041 1202 enumerations.REPOSITORY_NAME)
1042 1203 packages = model.get_value(itr, \
|
↓ open down ↓ |
27 lines elided |
↑ open up ↑ |
1043 1204 enumerations.PACKAGE_OBJECT_COLUMN)
1044 1205 if not packages:
1045 1206 return False
1046 1207 pkg = max(packages)
1047 1208 if cmp(pkg.get_authority(), authority) == 0:
1048 1209 return True
1049 1210 else:
1050 1211 return False
1051 1212
1052 1213 def __do_ips_uptodate_check(self):
1053 - self.ips_uptodate = self.__ipkg_ipkgui_uptodate(self.image_o)
1214 + self.__catalog_refresh(False)
1215 + self.ips_uptodate = self.__ipkg_ipkgui_uptodate()
1054 1216 self.progress_stop_timer_thread = True
1055 1217
1056 - def __ipkg_ipkgui_uptodate(self, img):
1057 - if not img.is_liveroot():
1058 - newimg = image.Image()
1059 - cmdpath = os.path.join(os.getcwd(), sys.argv[0])
1060 - cmdpath = os.path.realpath(cmdpath)
1061 - cmddir = os.path.dirname(os.path.realpath(cmdpath))
1062 - try:
1063 - #
1064 - # Find the path to ourselves, and use that
1065 - # as a way to locate the image we're in. It's
1066 - # not perfect-- we could be in a developer's
1067 - # workspace, for example.
1068 - #
1069 - newimg.find_root(cmddir)
1070 - except ValueError:
1071 - # We can't answer in this case, so we return True to
1072 - # let installation proceed.
1073 - # TODO: log - msg(_("No image corresponding to '%s' was
1074 - # located. " \ "Proceeding.") % cmdpath)
1075 - return True
1076 - newimg.load_config()
1077 - img = newimg
1078 -
1218 + def __ipkg_ipkgui_uptodate(self):
1219 + self.api_o.reset()
1220 + list_of_packages = [self.ipkg_fmri, self.ipkggui_fmri]
1221 + ret = True
1079 1222 try:
1080 - img.retrieve_catalogs()
1081 - except api_errors.CatalogRefreshException:
1223 + if self.api_o.plan_install(list_of_packages, \
1224 + filters = []):
1225 + ret = False
1226 + except (api_errors.InvalidCertException, \
1227 + api_errors.PlanCreationException, \
1228 + api_errors.InventoryException):
1082 1229 raise
1083 - # Reload catalog. This picks up the update from retrieve_catalogs.
1084 - img.load_catalogs(self.pr)
1085 -
1086 - try:
1087 - def __check_cancelation():
1088 - return False
1089 -
1090 - # We will use whatever the incorporation provides as the latest
1091 - # version of ipkg and ipkg-gui
1092 - img.make_install_plan([self.ipkg_fmri, self.ipkggui_fmri], \
1093 - self.pr, __check_cancelation, filters = [],
1094 - noexecute = True)
1095 - except RuntimeError:
1096 - return True
1097 -
1098 - if img.imageplan.nothingtodo():
1099 - return True
1100 -
1101 - return False
1102 -
1230 + except api_errors.CanceledException:
1231 + raise
1232 + return ret
1103 1233
1104 1234 def __enable_disable_selection_menus(self):
1105 1235
1106 1236 if self.in_setup:
1107 1237 return
1108 1238 self.__enable_disable_select_all()
1109 1239 self.__enable_disable_select_updates()
1110 1240 self.__enable_disable_deselect()
1111 1241 # XXX disabled until new API
1112 1242 self.__enable_disable_update_all()
1113 1243
1114 1244 def __enable_disable_select_all(self):
1115 1245
1116 1246 if self.in_setup:
1117 1247 return
1118 1248 if len(self.w_application_treeview.get_model()) > 0:
1119 1249 for row in self.w_application_treeview.get_model():
1120 1250 if not row[enumerations.MARK_COLUMN]:
1121 1251 self.w_selectall_menuitem.set_sensitive(True)
1122 1252 return
1123 1253 self.w_selectall_menuitem.set_sensitive(False)
1124 1254 else:
1125 1255 self.w_selectall_menuitem.set_sensitive(False)
1126 1256
1127 1257 def __enable_disable_install_update(self):
1128 1258 for row in self.application_list:
1129 1259 if row[enumerations.MARK_COLUMN]:
1130 1260 if row[enumerations.LATEST_AVAILABLE_COLUMN] and \
1131 1261 self.user_rights:
1132 1262 self.w_installupdate_button.set_sensitive(True)
1133 1263 self.w_installupdate_menuitem.set_sensitive(True)
1134 1264 return
1135 1265 self.w_installupdate_button.set_sensitive(False)
1136 1266 self.w_installupdate_menuitem.set_sensitive(False)
1137 1267
1138 1268 def __enable_disable_remove(self):
1139 1269 for row in self.application_list:
1140 1270 if row[enumerations.MARK_COLUMN]:
1141 1271 if row[enumerations.INSTALLED_VERSION_COLUMN] and \
1142 1272 self.user_rights:
1143 1273 self.w_remove_button.set_sensitive(True)
1144 1274 self.w_remove_menuitem.set_sensitive(True)
1145 1275 return
1146 1276 self.w_remove_button.set_sensitive(False)
1147 1277 self.w_remove_menuitem.set_sensitive(False)
1148 1278
1149 1279 def __enable_disable_select_updates(self):
1150 1280 for row in self.w_application_treeview.get_model():
1151 1281 if row[enumerations.INSTALLED_VERSION_COLUMN]:
1152 1282 if row[enumerations.LATEST_AVAILABLE_COLUMN]:
1153 1283 if not row[enumerations.MARK_COLUMN]:
1154 1284 self.w_selectupdates_menuitem. \
1155 1285 set_sensitive(True)
1156 1286 return
1157 1287 self.w_selectupdates_menuitem.set_sensitive(False)
1158 1288 return
1159 1289
1160 1290 def __enable_disable_update_all(self):
1161 1291 for row in self.application_list:
1162 1292 if self.__is_pkg_repository_visible(self.application_list, \
1163 1293 row.iter):
1164 1294 if self.application_list.get_value(row.iter, \
1165 1295 enumerations.INSTALLED_VERSION_COLUMN):
1166 1296 if self.application_list.get_value(row.iter, \
1167 1297 enumerations.LATEST_AVAILABLE_COLUMN) and \
1168 1298 self.user_rights:
1169 1299 self.w_updateall_menuitem. \
1170 1300 set_sensitive(True)
1171 1301 self.w_updateall_button. \
1172 1302 set_sensitive(True)
1173 1303 return
1174 1304 self.w_updateall_button.set_sensitive(False)
1175 1305 self.w_updateall_menuitem.set_sensitive(False)
|
↓ open down ↓ |
63 lines elided |
↑ open up ↑ |
1176 1306
1177 1307 def __enable_disable_deselect(self):
1178 1308 for row in self.w_application_treeview.get_model():
1179 1309 if row[enumerations.MARK_COLUMN]:
1180 1310 self.w_deselect_menuitem.set_sensitive(True)
1181 1311 return
1182 1312 self.w_deselect_menuitem.set_sensitive(False)
1183 1313 return
1184 1314
1185 1315
1186 - def __catalog_refresh(self):
1316 + def __catalog_refresh(self, reload_gui=True):
1187 1317 """Update image's catalogs."""
1188 - images = self.__get_images_from_model()
1189 - full_refresh = False
1190 - for img in images:
1191 - # Ensure Image directory structure is valid.
1192 - if not os.path.isdir("%s/catalog" % img.imgdir):
1193 - img.mkdirs()
1194 - # Loading catalogs allows us to perform incremental update
1195 - img.retrieve_catalogs(full_refresh)
1318 + full_refresh = True
1319 + try:
1320 + self.api_o.refresh(full_refresh)
1321 + self.image_o.load_catalogs(self.pr)
1322 + except api_errors.UnrecognizedAuthorityException:
1323 + # In current implementation, this will never happen
1324 + # We are not refrehsing specific authority
1325 + raise
1326 + except api_errors.CatalogRefreshException, cre:
1327 + total = cre.total
1328 + succeeded = cre.succeeded
1329 + ermsg = "%s/%s" % (succeeded, total)
1330 + ermsg += self._(" catalogs successfully updated:\n")
1331 + for auth, err in cre.failed:
1332 + if isinstance(err, HTTPError):
1333 + ermsg += " %s: %s - %s\n" % \
1334 + (err.filename, err.code, err.msg)
1335 + elif isinstance(err, URLError):
1336 + if err.args[0][0] == 8:
1337 + ermsg += " %s: %s\n" % \
1338 + (urlparse.urlsplit(
1339 + auth["origin"])[1].split(":")[0],
1340 + err.args[0][1])
1341 + else:
1342 + if isinstance(err.args[0], \
1343 + socket.timeout):
1344 + ermsg += " %s: %s\n" % \
1345 + (auth["origin"], "timeout")
1346 + else:
1347 + ermsg += " %s: %s\n" % \
1348 + (auth["origin"], \
1349 + err.args[0][1])
1350 + else:
1351 + ermsg += self._("Unknown error")
1196 1352
1197 - def __get_images_from_model(self):
1198 - images = []
1199 - for row in self.application_list:
1200 - img = row[enumerations.IMAGE_OBJECT_COLUMN]
1201 - if img:
1202 - if not img in images:
1203 - images.append(img)
1204 - return images
1353 + gobject.idle_add(self.error_occured, ermsg)
1354 +
1355 + except api_errors.UnrecognizedAuthorityException:
1356 + raise
1357 + if reload_gui:
1358 + self.__catalog_refresh_done()
1205 1359
1206 1360 def __get_image_obj_from_directory(self, image_directory):
1207 1361 image_obj = image.Image()
1208 - dr = "/"
1209 1362 try:
1210 1363 image_obj.find_root(image_directory,
1211 1364 self.provided_image_dir)
1212 1365 image_obj.load_config()
1213 1366 image_obj.load_catalogs(self.pr)
1214 - except image.ImageNotFoundException, infe:
1367 + except api_errors.ImageNotFoundException, infe:
1215 1368 print self._("%s is not a valid root image, return "
1216 1369 "None") % infe.user_dir
1217 1370 image_obj = None
1218 1371
1219 -
1220 1372 # Tell the image the name of the client performing operations.
1221 1373 if image_obj is not None:
1222 - image_obj.history.client_name = "packagemanager"
1374 + image_obj.history.client_name = PKG_CLIENT_NAME
1223 1375
1224 1376 return image_obj
1225 1377
1226 1378 def __get_image_from_directory(self, image_obj, progressdialog_progress):
1227 1379 """ This method set up image from the given directory and
1228 1380 returns the image object or None"""
1229 - # XXX Convert timestamp to some nice date :)
1230 - self.application_list.clear()
1231 - self.category_list.clear()
1232 - self.application_list_filter.refilter()
1381 + application_list = self.__get_new_application_liststore()
1382 + category_list = self.__get_new_category_liststore()
1383 + repositories_list = self.__get_new_repositories_liststore()
1384 +
1233 1385 try:
1234 1386 pkgs_known = [ pf[0] for pf in
1235 1387 sorted(image_obj.inventory(all_known = True)) ]
1236 1388 except api_errors.InventoryException:
1237 1389 # Can't happen when all_known is true and no args,
1238 1390 # but here for completeness.
1239 - raise
1391 + err = self._("Error occured while getting list of packages")
1392 + gobject.idle_add(self.w_progress_dialog.hide)
1393 + gobject.idle_add(self.error_occured, err)
1394 + return
1395 +
1240 1396 #Only one instance of those icons should be in memory
1241 - update_available_icon = self.get_icon_pixbuf("new_update")
1397 + update_available_icon = self.get_icon_pixbuf("status_newupdate")
1398 + installed_icon = self.get_icon_pixbuf("status_installed")
1242 1399 #Imageinfo for categories
1243 1400 imginfo = imageinfo.ImageInfo()
1244 1401 sectioninfo = imageinfo.ImageInfo()
1245 1402 catalogs = image_obj.catalogs
1246 1403 categories = {}
1247 1404 sections = {}
1248 - self.__setup_repositories_combobox(image_obj)
1249 1405 for cat in catalogs:
1250 1406 category = imginfo.read(self.application_dir + \
1251 1407 "/usr/share/package-manager/data/" + cat)
1252 1408 categories[cat] = category
1253 1409 section = sectioninfo.read(self.application_dir + \
1254 1410 "/usr/share/package-manager/data/" + cat + ".sections")
1255 1411 sections[cat] = section
1256 1412 # Speedup, instead of checking if the pkg is already in the list,
1257 1413 # iterating through all elements, we will only compare to the previous
1258 1414 # package and if the package is the same (version difference) then we
1259 1415 # are adding to the first iterator for the set of those packages.
1260 1416 # We can do that, since the list pkgs_known is sorted
1261 1417 # This will give a sppedup from 18sec to ~3!!!
1262 1418 p_pkg_iter = None
1263 1419 p_pkg = None
1264 1420 insert_count = 0
1265 1421 icon_path = self.application_dir + \
1266 1422 "/usr/share/package-manager/data/pixmaps/"
1267 1423
|
↓ open down ↓ |
9 lines elided |
↑ open up ↑ |
1268 1424 pkg_count = 0
1269 1425 progress_percent = INITIAL_PROGRESS_TOTAL_PERCENTAGE
1270 1426 total_pkg_count = len(pkgs_known)
1271 1427 progress_increment = \
1272 1428 total_pkg_count / PACKAGE_PROGRESS_TOTAL_INCREMENTS
1273 1429
1274 1430 self.progress_stop_timer_thread = True
1275 1431 while gtk.events_pending():
1276 1432 gtk.main_iteration(False)
1277 1433 for pkg in pkgs_known:
1278 - if pkg_count % progress_increment == 0:
1434 + if progress_increment > 0 and pkg_count % progress_increment == 0:
1279 1435 progress_percent += PACKAGE_PROGRESS_PERCENT_INCREMENT
1280 1436 if progress_percent <= PACKAGE_PROGRESS_PERCENT_TOTAL:
1281 - gobject.idle_add(progressdialog_progress,
1282 - progress_percent, pkg_count, total_pkg_count)
1437 + progressdialog_progress(progress_percent, \
1438 + pkg_count, total_pkg_count)
1283 1439 while gtk.events_pending():
1284 1440 gtk.main_iteration(False)
1285 1441 pkg_count += 1
1286 1442
1287 1443 #speedup hack, check only last package
1288 1444 already_in_model = \
1289 1445 self.check_if_pkg_have_row_in_model(pkg, p_pkg)
1290 1446 if not already_in_model: #Create new row
1291 1447 available_version = None
1292 1448 version_installed = None
1293 1449 status_icon = None
1294 1450 fmris = [pkg, ]
1295 1451 package_installed = \
1296 1452 self.get_installed_version(image_obj, pkg)
1297 1453 if package_installed:
1298 1454 version_installed = \
1299 1455 package_installed.version.get_short_version()
1300 1456 #HACK, sometimes the package is installed but
1301 1457 #it's not in the pkgs_known
1458 + status_icon = installed_icon
1302 1459 if package_installed != pkg:
1303 1460 fmris.append(package_installed)
1304 1461 else:
1305 1462 dt = self.get_datetime(pkg.version)
1306 1463 dt_str = (":%02d%02d") % (dt.month, dt.day)
1307 1464 available_version = \
1308 1465 pkg.version.get_short_version() + dt_str
1309 1466 package_icon = self.__get_pixbuf_from_path(icon_path, \
1310 1467 pkg.get_name())
1311 1468 app = \
1312 1469 [
1313 1470 False, status_icon, package_icon, pkg.get_name(),
1314 1471 version_installed, package_installed,
1315 1472 available_version, -1, '...', fmris,
1316 - image_obj, True, None
1473 + True, None
1317 1474 ]
1318 1475 # XXX Small hack, if this is not applied, first package
1319 1476 # is listed twice. Insert is ~0.5 sec faster than append
1320 1477 if insert_count == 0:
1321 - row_iter = self.application_list.append(app)
1478 + row_iter = application_list.append(app)
1322 1479 else:
1323 1480 row_iter = \
1324 - self.application_list.insert(insert_count, \
1481 + application_list.insert(insert_count, \
1325 1482 app)
1326 1483 # XXX Do not iterate through all the catalogs. Package
1327 1484 # should know what is package fmri prefix?
1328 1485 apc = self.__add_package_to_category
1486 + app_ls = application_list
1329 1487 for cat in categories:
1330 1488 if cat in categories:
1331 1489 name = pkg.get_name()
1332 1490 if name in categories[cat]:
1333 1491 pkg_categories = \
1334 1492 categories[cat][ \
1335 1493 name]
1336 1494 for pcat in \
1337 1495 pkg_categories.split(","):
1338 1496 if pcat:
1339 1497 apc(self._( \
1340 1498 pcat), None \
1341 1499 , None, \
1342 - row_iter)
1500 + row_iter, \
1501 + app_ls, \
1502 + category_list)
1343 1503 insert_count = insert_count + 1
1344 1504 p_pkg_iter = row_iter
1345 1505 p_pkg = pkg #The current become previous
1346 1506 else:
1347 1507 # XXX check versions in here. For all installed/not
1348 1508 # installed:
1349 1509 # if there is newer version, put it in the available
1350 1510 # field.
1351 1511 #
1352 1512 # XXXhack, since image_get_version_installed(pkg) is not
1353 1513 # working,as it should. For example package:
1354 1514 # SUNWarc@0.5.11,5.11-0.79:20080205T152309Z
1355 1515 # is not installed and it's newer version of installed
1356 1516 # package:
1357 1517 # SUNWarc@0.5.11,5.11-0.75:20071114T201151Z
1358 1518 # the function returns only proper installed version for
1359 1519 # the older package and None for the newer.
1360 1520 # The hack is a little bit slow since we are iterating
1361 1521 # for all known packages
1362 1522 list_of_pkgs = \
1363 - self.application_list.get_value(p_pkg_iter, \
1523 + application_list.get_value(p_pkg_iter, \
1364 1524 enumerations.PACKAGE_OBJECT_COLUMN)
1365 1525 if pkg not in list_of_pkgs:
1366 1526 list_of_pkgs.append(pkg)
1367 - installed = self.application_list.get_value(p_pkg_iter, \
1527 + installed = application_list.get_value(p_pkg_iter, \
1368 1528 enumerations.INSTALLED_OBJECT_COLUMN)
1369 1529 latest = max(list_of_pkgs)
1370 1530 dt = self.get_datetime(latest.version)
1371 1531 dt_str = (":%02d%02d") % (dt.month, dt.day)
1372 1532 if not installed:
1373 - self.application_list.set_value(p_pkg_iter, \
1533 + application_list.set_value(p_pkg_iter, \
1374 1534 enumerations.LATEST_AVAILABLE_COLUMN, \
1375 1535 latest.version.get_short_version() + \
1376 1536 dt_str)
1377 1537 else:
1378 1538 if installed < latest:
1379 - self.application_list.set_value( \
1539 + application_list.set_value( \
1380 1540 p_pkg_iter, \
1381 1541 enumerations. \
1382 1542 LATEST_AVAILABLE_COLUMN, \
1383 1543 latest.version.get_short_version() + \
1384 1544 dt_str)
1385 - self.application_list.set_value(\
1545 + application_list.set_value(\
1386 1546 p_pkg_iter, \
1387 1547 enumerations.STATUS_ICON_COLUMN, \
1388 1548 update_available_icon)
1389 1549 # XXX How to get descriptions without manifest?
1390 1550 # XXX Downloading manifest is slow and can not work without
1391 1551 # XXX Network connection
1392 1552 #if not image_obj.has_manifest(pkg):
1393 1553 # image_obj.get_manifest(pkg)#verify(pkg, pr)
1394 1554 #installed_version = None
1395 1555 #package_iter = None #the iterator which points for other package
1396 1556 for authority in sections:
1397 1557 for section in sections[authority]:
1398 1558 for category in sections[authority][section].split(","):
1399 1559 self.__add_category_to_section(self._(category), \
1400 - self._(section))
1560 + self._(section), category_list)
1401 1561
1402 1562 #1915 Sort the Categories into alphabetical order and prepend All Category
1403 - if len(self.category_list) > 0:
1404 - rows = [tuple(r) + (i,) for i, r in enumerate(self.category_list)]
1563 + if len(category_list) > 0:
1564 + rows = [tuple(r) + (i,) for i, r in enumerate(category_list)]
1405 1565 rows.sort(self.__sort)
1406 1566 r = []
1407 - self.category_list.reorder([r[-1] for r in rows])
1408 - self.category_list.prepend([0, self._('All'), None, None, True, None])
1567 + category_list.reorder([r[-1] for r in rows])
1568 + category_list.prepend([0, self._('All'), None, None, True, None])
1409 1569
1410 - gobject.idle_add(progressdialog_progress, PACKAGE_PROGRESS_PERCENT_TOTAL,
1411 - pkg_count, total_pkg_count)
1570 + progressdialog_progress(PACKAGE_PROGRESS_PERCENT_TOTAL, pkg_count, \
1571 + total_pkg_count)
1572 + gobject.idle_add(self.process_package_list_end, image_obj, \
1573 + application_list, category_list, repositories_list)
1412 1574
1413 1575 def __add_package_to_category(self, category_name, category_description, \
1414 - category_icon, package):
1576 + category_icon, package, application_list, category_list):
1415 1577 if not package or category_name == self._('All'):
1416 1578 return
1417 1579 if not category_name:
1418 1580 return
1419 1581 # XXX check if needed
1420 1582 # category_name = self._('All')
1421 1583 # category_description = self._('All packages')
1422 1584 # category_icon = None
1423 1585 category_ref = None
1424 - for category in self.category_list:
1586 + for category in category_list:
1425 1587 if category[enumerations.CATEGORY_NAME] == category_name:
1426 1588 category_ref = category.iter
1427 1589 if not category_ref: # Category not exists
1428 - category_ref = self.category_list.append([len( \
1429 - self.category_list), category_name, category_description, \
1590 + category_ref = category_list.append([len( \
1591 + category_list)+1, category_name, category_description, \
1430 1592 category_icon, True, None])
1431 1593 if category_ref:
1432 - if self.application_list.get_value(package, \
1594 + if application_list.get_value(package, \
1433 1595 enumerations.CATEGORY_LIST_OBJECT):
1434 - a = self.application_list.get_value(package, \
1596 + a = application_list.get_value(package, \
1435 1597 enumerations.CATEGORY_LIST_OBJECT)
1436 1598 a.append(category_ref)
1437 1599 else:
1438 1600 category_list = []
1439 1601 category_list.append(category_ref)
1440 - self.application_list.set(package, \
1602 + application_list.set(package, \
1441 1603 enumerations.CATEGORY_LIST_OBJECT, category_list)
1442 1604
1443 - def __add_category_to_section(self, category_name, section_name):
1605 + def __add_category_to_section(self, category_name, section_name, category_list):
1444 1606 '''Adds the section to section list in category. If there is no such
1445 1607 section, than it is not added. If there was already section than it
1446 1608 is skipped. Sections must be case sensitive'''
1447 1609 if not category_name:
1448 1610 return
1449 1611 for section in self.section_list:
1450 1612 if section[enumerations.SECTION_NAME] == section_name:
1451 - for category in self.category_list:
1613 + for category in category_list:
1452 1614 if category[enumerations.CATEGORY_NAME] == \
1453 1615 category_name:
1454 1616 if not category[ \
1455 1617 enumerations.SECTION_LIST_OBJECT]:
1456 1618 category[ \
1457 1619 enumerations. \
1458 1620 SECTION_LIST_OBJECT] = \
1459 1621 [section[ \
1460 1622 enumerations.SECTION_ID], ]
1461 1623 else:
1462 1624 if not section_name in \
1463 1625 category[ \
1464 1626 enumerations. \
1465 1627 SECTION_LIST_OBJECT]:
1466 1628 category[enumerations. \
1467 1629 SECTION_LIST_OBJECT \
1468 1630 ].append(section[ \
1469 1631 enumerations. \
1470 1632 SECTION_ID])
1471 1633
1472 1634 def __get_pixbuf_from_path(self, path, icon_name):
1473 1635 icon = icon_name.replace(' ', '_')
1474 1636
1475 1637 # Performance: Faster to check if files exist rather than catching
1476 1638 # exceptions when they do not. Picked up open failures using dtrace
1477 1639 png_exists = os.path.exists(self.application_dir + path + icon + ".png")
1478 1640 svg_exists = os.path.exists(self.application_dir + path + icon + ".svg")
1479 1641
1480 1642 if not png_exists and not svg_exists:
1481 1643 return None
1482 1644 try:
1483 1645 return gtk.gdk.pixbuf_new_from_file( \
1484 1646 self.application_dir + path + icon + ".png")
1485 1647 except gobject.GError:
1486 1648 try:
1487 1649 return gtk.gdk.pixbuf_new_from_file( \
1488 1650 self.application_dir + path + icon + ".svg")
1489 1651 except gobject.GError:
1490 1652 iconview = gtk.IconView()
1491 1653 icon = iconview.render_icon(getattr(gtk, \
1492 1654 "STOCK_MISSING_IMAGE"), \
1493 1655 size = gtk.ICON_SIZE_MENU,
1494 1656 detail = None)
1495 1657 # XXX Could return image-we don't want to show ugly icon.
1496 1658 return None
1497 1659
1498 1660 def __progressdialog_progress_pulse(self):
1499 1661 while not self.progress_stop_timer_thread:
1500 1662 gobject.idle_add(self.w_progressbar.pulse)
1501 1663 time.sleep(0.1)
1502 1664 gobject.idle_add(self.w_progress_dialog.hide)
1503 1665 self.progress_stop_timer_thread = False
1504 1666
1505 1667 # For initial setup before loading package entries allow 5% of progress bar
1506 1668 # update it on a time base as we have no other way to judge progress at this point
1507 1669 def __progressdialog_progress_time(self):
1508 1670 while not self.progress_stop_timer_thread and \
1509 1671 self.progress_fraction_time_count <= \
1510 1672 INITIAL_PROGRESS_TOTAL_PERCENTAGE:
1511 1673
1512 1674 gobject.idle_add(self.w_progressbar.set_fraction, \
1513 1675 self.progress_fraction_time_count)
1514 1676 self.progress_fraction_time_count += \
|
↓ open down ↓ |
53 lines elided |
↑ open up ↑ |
1515 1677 INITIAL_PROGRESS_TIME_PERCENTAGE
1516 1678 time.sleep(INITIAL_PROGRESS_TIME_INTERVAL)
1517 1679 self.progress_stop_timer_thread = False
1518 1680 self.progress_fraction_time_count = 0
1519 1681
1520 1682 def __progressdialog_progress_percent(self, fraction, count, total):
1521 1683 gobject.idle_add(self.w_progressinfo_label.set_text, self._( \
1522 1684 "Processing package entries: %d of %d" % (count, total) ))
1523 1685 gobject.idle_add(self.w_progressbar.set_fraction, fraction)
1524 1686
1525 - def __setup_data_finished(self):
1526 - gobject.idle_add(self.w_progress_dialog.hide)
1527 - self.in_setup = False
1528 -
1687 + def error_occured(self, error_msg):
1688 + msgbox = gtk.MessageDialog(parent = \
1689 + self.w_main_window, \
1690 + buttons = gtk.BUTTONS_CLOSE, \
1691 + flags = gtk.DIALOG_MODAL, \
1692 + type = gtk.MESSAGE_ERROR, \
1693 + message_format = None)
1694 + msgbox.set_markup(error_msg)
1695 + msgbox.set_title(self._("Packagemanager error"))
1696 + msgbox.run()
1697 + msgbox.destroy()
1698 +
1529 1699 #-----------------------------------------------------------------------------#
1530 1700 # Static Methods
1531 1701 #-----------------------------------------------------------------------------#
1532 1702
1533 1703 @staticmethod
1534 1704 def n_(message):
1535 1705 return message
1536 1706
1537 1707 @staticmethod
1538 1708 def __sort(a, b):
1539 1709 return cmp(a[1], b[1])
1540 1710
1541 1711 @staticmethod
1542 - def __installed_fmris_from_args(img, args):
1712 + def __installed_fmris_from_args(img, args_f):
1543 1713 found = []
1544 1714 notfound = []
1545 1715 try:
1546 - for m in img.inventory(args):
1716 + for m in img.inventory(args_f):
1547 1717 found.append(m[0])
1548 1718 except api_errors.InventoryException, e:
1549 1719 notfound = e.notfound
1550 1720
1551 1721 return notfound
1552 1722
1553 1723 @staticmethod
1554 1724 def cell_data_function(column, renderer, model, itr, data):
1555 1725 '''Function which sets the background colour to black if package is
1556 1726 selected'''
1557 1727 if itr:
1558 1728 if model.get_value(itr, enumerations.MARK_COLUMN):
1559 1729 renderer.set_property("cell-background", "#ffe5cc")
1560 1730 renderer.set_property("cell-background-set", True)
1561 1731 else:
1562 1732 renderer.set_property("cell-background-set", False)
1563 1733
1564 1734 @staticmethod
1565 1735 def combobox_separator(model, itr):
1566 1736 return model.get_value(itr, enumerations.FILTER_NAME) == ""
1567 1737
1568 1738 @staticmethod
1569 1739 def combobox_id_separator(model, itr):
1570 1740 return model.get_value(itr, 0) == -1
1571 1741
1572 1742 @staticmethod
1573 1743 def check_if_pkg_have_row_in_model(pkg, p_pkg):
1574 1744 """Returns True if package is already in model or False if not"""
1575 1745 if p_pkg:
1576 1746 if pkg.is_same_pkg(p_pkg):
1577 1747 return True
1578 1748 else:
1579 1749 return False
1580 1750 return False
1581 1751
1582 1752 @staticmethod
1583 1753 def category_filter(model, itr):
1584 1754 '''This function filters category in the main application view'''
1585 1755 return model.get_value(itr, enumerations.CATEGORY_VISIBLE)
1586 1756
1587 1757 @staticmethod
1588 1758 def get_datetime(version):
1589 1759 dt = None
1590 1760 try:
1591 1761 dt = version.get_datetime()
1592 1762 except AttributeError:
1593 1763 dt = version.get_timestamp()
1594 1764 return dt
1595 1765
1596 1766 @staticmethod
1597 1767 def get_installed_version(img, pkg):
1598 1768 return img.get_version_installed(pkg)
1599 1769
1600 1770 @staticmethod
1601 1771 def get_manifest(img, package, filtered = True):
1602 1772 '''helper function'''
1603 1773 # XXX Should go to the -> imageinfo.py
1604 1774 manifest = None
1605 1775
1606 1776 # 3087 shutdown time is too long when closing down soon after startup
1607 1777 if packagemanager.cancelled:
1608 1778 return manifest
1609 1779 try:
1610 1780 manifest = img.get_manifest(package, filtered)
1611 1781 except OSError:
1612 1782 # XXX It is possible here that the user doesn't have network con,
1613 1783 # XXX proper permissions to save manifest, should we do something
1614 1784 # XXX and popup information dialog?
1615 1785 pass
1616 1786 except (retrieve.ManifestRetrievalError,
1617 1787 retrieve.DatastreamRetrievalError, NameError):
1618 1788 pass
1619 1789 return manifest
1620 1790
1621 1791 @staticmethod
1622 1792 def update_desc(description, pkg, package):
1623 1793 p = pkg[enumerations.PACKAGE_OBJECT_COLUMN][0]
1624 1794 if p == package:
1625 1795 pkg[enumerations.DESCRIPTION_COLUMN] = description
|
↓ open down ↓ |
69 lines elided |
↑ open up ↑ |
1626 1796 return
1627 1797
1628 1798 #-----------------------------------------------------------------------------#
1629 1799 # Public Methods
1630 1800 #-----------------------------------------------------------------------------#
1631 1801 def setup_progressdialog_show(self):
1632 1802 self.w_progress_dialog.set_title(self._("Loading Repository Information"))
1633 1803 self.w_progressinfo_label.set_text(
1634 1804 self._( "Fetching package entries ..."))
1635 1805 self.w_progress_cancel.hide()
1636 -
1637 - Thread(target = self.w_progress_dialog.run).start()
1806 + self.w_progress_dialog.show()
1638 1807 Thread(target = self.__progressdialog_progress_time).start()
1639 1808
1640 1809 def init_sections(self):
1641 1810 self.__init_sections() #Initiates sections
1642 1811
1812 + def init_show_filter(self):
1813 + self.__init_show_filter() #Initiates filter
1814 +
1815 + def reload_packages(self):
1816 + self.api_o = self.__get_api_object(self.image_directory, self.pr)
1817 + self.__on_reload(None)
1818 +
1643 1819 def process_package_list_start(self, image_directory):
1820 + self.cancelled = True
1821 + self.setup_progressdialog_show()
1822 + while gtk.events_pending():
1823 + gtk.main_iteration(False)
1644 1824 self.image_directory = image_directory
1645 1825 # Create our image object based on image directory.
1646 1826 image_obj = self.__get_image_obj_from_directory(image_directory)
1647 1827 self.image_o = image_obj
1648 -
1649 1828 # Acquire image contents and update progress bar as you do so.
1650 - self.__get_image_from_directory(image_obj,
1651 - self.__progressdialog_progress_percent)
1829 + Thread(target = self.__get_image_from_directory, args = (image_obj,
1830 + self.__progressdialog_progress_percent)).start()
1831 + self.api_o = self.__get_api_object(image_directory, self.pr)
1832 +
1833 + @staticmethod
1834 + def __get_api_object(img_dir, progtrack):
1835 + api_o = None
1836 + try:
1837 + api_o = api.ImageInterface(img_dir, \
1838 + CLIENT_API_VERSION, \
1839 + progtrack, None, PKG_CLIENT_NAME)
1840 + except (api_errors.VersionException,\
1841 + api_errors.ImageNotFoundException):
1842 + raise
1843 + return api_o
1844 +
1845 + def process_package_list_end(self, image_object, application_list, \
1846 + category_list, repositories_list):
1847 + self.__init_tree_views(application_list, category_list, repositories_list)
1848 + self.update_statusbar()
1849 + self.in_setup = False
1850 + self.__setup_repositories_combobox(image_object, repositories_list)
1851 + self.cancelled = False
1652 1852 while gtk.events_pending():
1653 1853 gtk.main_iteration(False)
1654 -
1655 - def init_package_view(self):
1656 - self.__init_show_filter()
1657 - self.__setup_data_finished()
1658 - self.__init_tree_views()
1854 + self.w_categories_treeview.expand_all()
1855 + self.w_categories_treeview.grab_focus()
1856 + self.w_categories_treeview.set_cursor(0, \
1857 + None, start_editing=False)
1858 + self.w_application_treeview.expand_all()
1859 + while gtk.events_pending():
1860 + gtk.main_iteration(False)
1861 + self.__get_manifests_thread()
1862 + self.w_progress_dialog.hide()
1659 1863
1660 - self.w_filter_combobox.set_active(0)
1661 - self.w_sections_combobox.set_active(0)
1662 - self.application_list_filter.set_visible_func(self.__application_filter)
1663 - self.__setup_repositories_combobox(self.image_o)
1864 + def __get_manifests_thread(self):
1865 + Thread(target = self.get_manifests_for_packages,
1866 + args = ()).start()
1664 1867
1665 1868 def get_icon_pixbuf(self, icon_name):
1666 1869 #2821: The get_icon_pixbuf should use PACKAGE_MANAGER_ROOT
1667 1870 return self.__get_pixbuf_from_path(self.application_dir + \
1668 1871 "/usr/share/icons/package-manager/", icon_name)
1669 1872
1670 1873 def get_manifests_for_packages(self):
1671 1874 ''' Function, which get's manifest for packages. If the manifest is not
1672 1875 locally tries to retrieve it. For installed packages gets manifest
1673 1876 for the particular version (local operation only), if the package is
1674 1877 not installed than the newest one'''
1878 + time.sleep(3)
1675 1879 self.description_thread_running = True
1676 1880 img = self.image_o
1677 1881 img.history.operation_name = "info"
1678 1882 for pkg in self.application_list:
1679 1883 if self.cancelled:
1680 1884 self.description_thread_running = False
1681 1885 return
1682 1886 info = None
1683 - img = pkg[enumerations.IMAGE_OBJECT_COLUMN]
1887 + img = self.image_o
1684 1888 package = pkg[enumerations.PACKAGE_OBJECT_COLUMN][0]
1685 1889 if (img and package):
1686 1890 version = img.has_version_installed(package)
1687 1891 if version:
1688 1892 version = self.get_installed_version(img, \
1689 1893 package)
1690 1894 man = self.get_manifest(img, version, \
1691 1895 filtered = True)
1692 1896 if man:
1693 1897 info = man.get("description", "")
1694 1898 else:
1695 1899 newest = max( \
1696 1900 pkg[enumerations.PACKAGE_OBJECT_COLUMN])
1697 1901 man = self.get_manifest(img, newest, \
1698 1902 filtered = True)
1699 1903 if man:
1700 1904 info = man.get("description", "")
1701 1905 # XXX workaround, this should be done nicer
1702 1906 gobject.idle_add(self.update_desc, info, pkg, package)
1703 1907 time.sleep(0.01)
1908 + img.history.operation_name = "info"
1704 1909 img = self.image_o
1705 1910 img.history.operation_result = history.RESULT_SUCCEEDED
1706 1911 self.description_thread_running = False
1707 1912
1708 1913 def update_statusbar(self):
1709 1914 '''Function which updates statusbar'''
1710 1915 installed = 0
1711 1916 selected = 0
1712 1917 broken = 0
1713 1918 for pkg in self.application_list:
1714 1919 if pkg[enumerations.INSTALLED_VERSION_COLUMN]:
1715 1920 installed = installed + 1
|
↓ open down ↓ |
2 lines elided |
↑ open up ↑ |
1716 1921 if pkg[enumerations.MARK_COLUMN]:
1717 1922 selected = selected + 1
1718 1923 listed_str = self._('%d packages listed') % len(self.application_list)
1719 1924 inst_str = self._('%d installed') % installed
1720 1925 sel_str = self._('%d selected') % selected
1721 1926 broken_str = self._('%d broken') % broken
1722 1927 self.w_main_statusbar.push(0, listed_str + ', ' + inst_str + ', ' + \
1723 1928 sel_str + ', ' + broken_str + '.')
1724 1929
1725 1930
1726 - def update_package_list(self):
1931 + def update_package_list(self, update_list):
1932 + img = self.image_o
1933 + img.clear_pkg_state()
1934 + img.load_catalogs(self.pr)
1935 + installed_icon = self.get_icon_pixbuf("status_installed")
1727 1936 for row in self.application_list:
1728 - if row[enumerations.MARK_COLUMN]:
1729 - img = row[enumerations.IMAGE_OBJECT_COLUMN]
1937 + status_icon = None
1938 + if row[enumerations.MARK_COLUMN] or \
1939 + row[enumerations.NAME_COLUMN] in update_list:
1730 1940 pkg = row[enumerations.PACKAGE_OBJECT_COLUMN][0]
1731 1941 package_installed = self.get_installed_version(img, pkg)
1732 1942 version_installed = None
1733 1943 if package_installed:
1944 + status_icon = installed_icon
1734 1945 version_installed = \
1735 1946 package_installed.version.get_short_version()
1736 1947 row[enumerations.MARK_COLUMN] = False
1737 - row[enumerations.STATUS_ICON_COLUMN] = None
1738 1948 row[enumerations.INSTALLED_VERSION_COLUMN] = \
1739 1949 version_installed
1740 1950 row[enumerations.INSTALLED_OBJECT_COLUMN] = \
1741 1951 package_installed
1952 + row[enumerations.STATUS_ICON_COLUMN] = \
1953 + status_icon
1742 1954 if not package_installed:
1743 1955 pkg = max(row[enumerations.PACKAGE_OBJECT_COLUMN])
1744 1956 dt = self.get_datetime(pkg.version)
1745 1957 dt_str = (":%02d%02d") % (dt.month, dt.day)
1746 1958 available_version = \
1747 1959 pkg.version.get_short_version() + dt_str
1748 1960 row[enumerations.LATEST_AVAILABLE_COLUMN] = \
1749 1961 available_version
1750 1962 else:
1751 1963 row[enumerations.LATEST_AVAILABLE_COLUMN] = None
1752 1964 self.w_installupdate_button.set_sensitive(False)
1753 1965 self.w_installupdate_menuitem.set_sensitive(False)
1754 1966 self.w_remove_button.set_sensitive(False)
1755 1967 self.w_remove_menuitem.set_sensitive(False)
|
↓ open down ↓ |
4 lines elided |
↑ open up ↑ |
1756 1968 self.__enable_disable_selection_menus()
1757 1969 self.update_statusbar()
1758 1970
1759 1971 def shutdown_after_ips_update(self):
1760 1972
1761 1973 # 2790: As IPS and IPS-GUI have been updated the IPS GUI must be shutdown
1762 1974 # and restarted
1763 1975 msgbox = gtk.MessageDialog(parent = self.w_main_window, \
1764 1976 buttons = gtk.BUTTONS_OK, \
1765 1977 flags = gtk.DIALOG_MODAL, type = gtk.MESSAGE_INFO, \
1766 - message_format = self._("SUNWipkg and SUNWipkg-gui have been" + \
1767 - "updated and Package Manager will now be restarted.\n\nAfter" + \
1978 + message_format = self._("SUNWipkg and SUNWipkg-gui have been " + \
1979 + "updated and Package Manager will now be restarted.\n\nAfter " + \
1768 1980 "restart select Update All to continue."))
1769 1981 msgbox.set_title(self._("Update All"))
1770 1982 msgbox.run()
1771 1983 msgbox.destroy()
1772 1984 self.__main_application_quit(restart_app = True)
1773 1985
1774 1986 def shutdown_after_image_update(self):
1775 1987
1776 1988 msgbox = gtk.MessageDialog(parent = self.w_main_window, \
1777 1989 buttons = gtk.BUTTONS_OK, \
1778 1990 flags = gtk.DIALOG_MODAL, type = gtk.MESSAGE_INFO, \
1779 - message_format = self._("Update All has completed and Package" + \
1780 - "Manager will now exit.\n\nPlease review posted release notes" + \
1991 + message_format = self._("Update All has completed and Package " + \
1992 + "Manager will now exit.\n\nPlease review posted release notes " + \
1781 1993 "before rebooting:\n\n" + \
1782 1994 " http://opensolaris.org/os/project/indiana/resources/rn3/"))
1783 1995 msgbox.set_title(self._("Update All"))
1784 1996 msgbox.run()
1785 1997 msgbox.destroy()
1786 1998 self.__main_application_quit()
1787 1999
1788 2000 ###############################################################################
1789 2001 #-----------------------------------------------------------------------------#
1790 2002 # Test functions
1791 2003 #-----------------------------------------------------------------------------#
1792 2004 def fill_with_fake_data(self):
1793 2005 '''test data for gui'''
2006 + self.application_list = self.__get_new_application_liststore()
2007 + self.category_list = self.__get_new_category_liststore()
2008 + self.section_list = self.__get_new_section_liststore()
2009 + self.filter_list = self.__get_new_filter_liststore()
2010 + self.repositories_list = self.__get_new_repositories_liststore()
2011 +
1794 2012 app1 = [False, self.get_icon_pixbuf("locked"), \
1795 2013 self.get_icon_pixbuf("None"), "acc", None, None, None, 4, "desc6", \
1796 2014 "Object Name1", None, True, None]
1797 2015 app2 = [False, self.get_icon_pixbuf("update_available"), \
1798 2016 self.get_icon_pixbuf(self._('All')), "acc_gam", \
1799 2017 "2.3", None, "2.8", \
1800 2018 4, "desc7", "Object Name2", None, True, None]
1801 2019 app3 = [False, self.get_icon_pixbuf("None"), \
1802 2020 self.get_icon_pixbuf("Other"), "gam_grap", "2.3", None, None, 4, \
1803 2021 "desc8", "Object Name3", None, True, None]
1804 2022 app4 = [False, self.get_icon_pixbuf("update_locked"), \
1805 2023 self.get_icon_pixbuf("Office"), "grap_gam", "2.3", None, "2.8", 4, \
|
↓ open down ↓ |
2 lines elided |
↑ open up ↑ |
1806 2024 "desc9", "Object Name2", None, True, None]
1807 2025 app5 = [False, self.get_icon_pixbuf("update_available"), \
1808 2026 self.get_icon_pixbuf("None"), "grap", "2.3", None, "2.8", 4, \
1809 2027 "desc0", "Object Name3", None, True, None]
1810 2028 itr1 = self.application_list.append(app1)
1811 2029 itr2 = self.application_list.append(app2)
1812 2030 itr3 = self.application_list.append(app3)
1813 2031 itr4 = self.application_list.append(app4)
1814 2032 itr5 = self.application_list.append(app5)
1815 2033 # self.__add_package_to_category(_("All"),None,None,None);
1816 - self.__add_package_to_category(self._("Accessories"), None, None, itr1)
1817 - self.__add_package_to_category(self._("Accessories"), None, None, itr2)
1818 - self.__add_package_to_category(self._("Games"), None, None, itr3)
1819 - self.__add_package_to_category(self._("Graphics"), None, None, itr3)
1820 - self.__add_package_to_category(self._("Games"), None, None, itr2)
1821 - self.__add_package_to_category(self._("Graphics"), None, None, itr4)
1822 - self.__add_package_to_category(self._("Games"), None, None, itr4)
1823 - self.__add_package_to_category(self._("Graphics"), None, None, itr5)
2034 + self.__add_package_to_category(self._("Accessories"), \
2035 + None, None, itr1, self.application_list, self.category_list)
2036 + self.__add_package_to_category(self._("Accessories"), None, None, itr2, \
2037 + self.application_list, self.category_list)
2038 + self.__add_package_to_category(self._("Games"), None, None, itr3, \
2039 + self.application_list, self.category_list)
2040 + self.__add_package_to_category(self._("Graphics"), None, None, itr3, \
2041 + self.application_list, self.category_list)
2042 + self.__add_package_to_category(self._("Games"), None, None, itr2, \
2043 + self.application_list, self.category_list)
2044 + self.__add_package_to_category(self._("Graphics"), None, None, itr4, \
2045 + self.application_list, self.category_list)
2046 + self.__add_package_to_category(self._("Games"), None, None, itr4, \
2047 + self.application_list, self.category_list)
2048 + self.__add_package_to_category(self._("Graphics"), None, None, itr5, \
2049 + self.application_list, self.category_list)
1824 2050
1825 2051 # Category names until xdg is imported.
1826 2052 # from xdg.DesktopEntry import *
1827 2053 # entry = DesktopEntry ()
1828 2054 # directory = '/usr/share/desktop-directories'
1829 2055 # for root, dirs, files in os.walk (directory):
1830 2056 # for name in files:
1831 2057 # entry.parse (os.path.join (root, name))
1832 2058 # self.__add_category_to_section (entry.getName (), \
1833 2059 # self._('Applications Desktop'))
1834 2060
1835 2061 self.__add_category_to_section(self._("Accessories"), \
1836 - self._('Applications Desktop'))
2062 + self._('Applications Desktop'), self.category_list)
1837 2063 self.__add_category_to_section(self._("Games"), \
1838 - self._('Applications Desktop'))
2064 + self._('Applications Desktop'), self.category_list)
1839 2065 self.__add_category_to_section(self._("Graphics"), \
1840 - self._('Applications Desktop'))
2066 + self._('Applications Desktop'), self.category_list)
1841 2067 self.__add_category_to_section(self._("Internet"), \
1842 - self._('Applications Desktop'))
2068 + self._('Applications Desktop'), self.category_list)
1843 2069 self.__add_category_to_section(self._("Office"), \
1844 - self._('Applications Desktop'))
2070 + self._('Applications Desktop'), self.category_list)
1845 2071 self.__add_category_to_section(self._("Sound & Video"), \
1846 - self._('Applications Desktop'))
2072 + self._('Applications Desktop'), self.category_list)
1847 2073 self.__add_category_to_section(self._("System Tools"), \
1848 - self._('Applications Desktop'))
2074 + self._('Applications Desktop'), self.category_list)
1849 2075 self.__add_category_to_section(self._("Universal Access"), \
1850 - self._('Applications Desktop'))
2076 + self._('Applications Desktop'), self.category_list)
1851 2077 self.__add_category_to_section(self._("Developer Tools"), \
1852 - self._('Applications Desktop'))
1853 - self.__add_category_to_section(self._("Core"), self._('Operating System'))
2078 + self._('Applications Desktop'), self.category_list)
2079 + self.__add_category_to_section(self._("Core"), \
2080 + self._('Operating System'), self.category_list)
1854 2081 self.__add_category_to_section(self._("Graphics"), \
1855 - self._('Operating System'))
2082 + self._('Operating System'), self.category_list)
1856 2083 self.__add_category_to_section(self._("Media"), \
1857 - self._('Operating System'))
2084 + self._('Operating System'), self.category_list)
1858 2085 #Can be twice :)
1859 2086 self.__add_category_to_section(self._("Developer Tools"), \
1860 - self._('Operating System'))
1861 - self.__add_category_to_section(self._("Office"), "Progs")
1862 - self.__add_category_to_section(self._("Office2"), "Progs")
2087 + self._('Operating System'), self.category_list)
2088 + self.__add_category_to_section(self._("Office"), "Progs", \
2089 + self.category_list)
2090 + self.__add_category_to_section(self._("Office2"), "Progs", \
2091 + self.category_list)
1863 2092 self.__setup_repositories_combobox(self.image_o)
1864 2093 self.in_setup = False
1865 2094
1866 2095 ###############################################################################
1867 2096 #-----------------------------------------------------------------------------#
1868 2097 # Main
1869 2098 #-----------------------------------------------------------------------------#
1870 2099
1871 2100 def main():
1872 2101 gtk.main()
1873 2102 return 0
1874 2103
1875 2104 if __name__ == '__main__':
1876 2105 packagemanager = PackageManager()
1877 2106 passed_test_arg = False
1878 2107 passed_imagedir_arg = False
1879 2108 packagemanager.provided_image_dir = True
1880 2109
1881 2110 try:
1882 2111 opts, args = getopt.getopt(sys.argv[1:], "htR:", \
1883 2112 ["help", "test-gui", "image-dir="])
1884 2113 except getopt.error, msg:
1885 2114 print "%s, for help use --help" % msg
1886 2115 sys.exit(2)
1887 2116
1888 2117 cmd = os.path.join(os.getcwd(), sys.argv[0])
1889 2118 cmd = os.path.realpath(cmd)
1890 2119 packagemanager.application_path = cmd
1891 2120
1892 2121 for option, argument in opts:
1893 2122 if option in ("-h", "--help"):
1894 2123 print """\
1895 2124 Use -R (--image-dir) to specify image directory.
1896 2125 Use -t (--test-gui) to work on fake data."""
1897 2126 sys.exit(0)
1898 2127 if option in ("-t", "--test-gui"):
1899 2128 passed_test_arg = True
1900 2129 if option in ("-R", "--image-dir"):
1901 2130 packagemanager.image_dir_arg = argument
1902 2131 image_dir = argument
1903 2132 passed_imagedir_arg = True
1904 2133
|
↓ open down ↓ |
32 lines elided |
↑ open up ↑ |
1905 2134 if passed_test_arg and passed_imagedir_arg:
1906 2135 print "Options -R and -t can not be used together."
1907 2136 sys.exit(2)
1908 2137 if not passed_imagedir_arg:
1909 2138 try:
1910 2139 image_dir = os.environ["PKG_IMAGE"]
1911 2140 except KeyError:
1912 2141 image_dir = os.getcwd()
1913 2142 packagemanager.provided_image_dir = False
1914 2143
2144 + while gtk.events_pending():
2145 + gtk.main_iteration(False)
2146 +
2147 + packagemanager.init_sections()
2148 + packagemanager.init_show_filter()
2149 +
1915 2150 if not passed_test_arg:
1916 - packagemanager.setup_progressdialog_show()
1917 - packagemanager.init_sections()
1918 2151 packagemanager.process_package_list_start(image_dir)
1919 2152 else:
1920 - packagemanager.init_sections()
1921 2153 packagemanager.fill_with_fake_data()
1922 2154
1923 - packagemanager.init_package_view()
1924 - packagemanager.update_statusbar()
1925 - while gtk.events_pending():
1926 - gtk.main_iteration(False)
1927 -
1928 - # Performance: Start this background thread after progress dialog thread has
1929 - # completed in init_package_view()->self.__setup_data_finished() or GUI will block
1930 - if not passed_test_arg:
1931 - Thread(target = packagemanager.get_manifests_for_packages,
1932 - args = ()).start()
1933 2155 main()
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX