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