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