src/packagemanager.py
author Michal Pryc <Michal.Pryc@Sun.Com>
Tue, 03 Mar 2009 08:15:21 +0000
changeset 892 ff66cde11b73
parent 882 b7593a33c0cf
child 893 43894973bcdc
permissions -rw-r--r--
6973 Initial Category 7019 The first package in the category is not shown 7020 Gray out empty top level categories.
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
#
815
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
    22
# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
424
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
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
    40
MAX_DESC_LEN = 60                         # Max length of the description
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
    41
MAX_INFO_CACHE_LIMIT = 100                # Max number of package descriptions to cache
866
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
    42
NOTEBOOK_PACKAGE_LIST_PAGE = 0            # Main Package List page index
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
    43
NOTEBOOK_START_PAGE = 1                   # Main View Start page index
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
    44
TYPE_AHEAD_DELAY = 600    # The last type in search box after which search is performed
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
    45
INITIAL_SHOW_FILTER_PREFERENCES = "/apps/packagemanager/preferences/initial_show_filter"
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
    46
INITIAL_SECTION_PREFERENCES = "/apps/packagemanager/preferences/initial_section"
866
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
    47
SHOW_STARTPAGE_PREFERENCES = "/apps/packagemanager/preferences/show_startpage"
872
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
    48
TYPEAHEAD_SEARCH_PREFERENCES = "/apps/packagemanager/preferences/typeahead_search"
866
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
    49
CATEGORIES_STATUS_COLUMN_INDEX = 0   # Index of Status Column in Categories TreeView
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
    50
833
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
    51
STATUS_COLUMN_INDEX = 3   # Index of Status Column in Application TreeView
500
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
    52
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
    53
CLIENT_API_VERSION = 4
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
    54
PKG_CLIENT_NAME = "packagemanager"
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
    55
866
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
    56
# Load Start Page from lang dir if available
872
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
    57
START_PAGE_LANG_BASE = "usr/share/package-manager/data/startpagebase/%s/%s"
866
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
    58
START_PAGE_HOME = "startpage.html" # Default page
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
    59
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
    60
# StartPage Action support for url's on StartPage pages
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
    61
PM_ACTION = 'pm-action'          # Action field for StartPage url's
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
    62
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
    63
# Internal Example: <a href="pm?pm-action=internal&uri=top_picks.html">
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
    64
ACTION_INTERNAL = 'internal'   # Internal Action value: pm-action=internal
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
    65
INTERNAL_URI = 'uri'           # Internal field: uri to navigate to in StartPage
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
    66
                               # without protocol scheme specified
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
    67
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
    68
# External Example: <a href="pm?pm-action=external&uri=www.opensolaris.com">
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
    69
ACTION_EXTERNAL = 'external'   # External Action value: pm-action=external
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
    70
EXTERNAL_URI = 'uri'           # External field: uri to navigate to in external
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
    71
                               # default browser without protocol scheme specified
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
    72
EXTERNAL_PROTOCOL = 'protocol' # External field: optional protocol scheme,
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
    73
                               # defaults to http
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
    74
DEFAULT_PROTOCOL = 'http'
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
    75
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    76
import getopt
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    77
import os
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    78
import sys
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    79
import time
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    80
import locale
866
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
    81
import urllib
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
    82
import urlparse
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
    83
import socket
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    84
import gettext
830
687f8a73665e 6019 ctrl-c hangs packagemanager
Padraig O'Briain <padraig.obriain@sun.com>
parents: 827
diff changeset
    85
import signal
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    86
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
    87
from urllib2 import HTTPError, URLError
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
    88
from cPickle import UnpicklingError
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
    89
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    90
try:
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    91
        import gobject
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
    92
        import gnome
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    93
        gobject.threads_init()
821
c86df5cfbe44 5738 Need mechanism to change initial value for TopLevel and category
Padraig O'Briain <padraig.obriain@sun.com>
parents: 816
diff changeset
    94
        import gconf
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    95
        import gtk
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
    96
        import gtk.glade
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
    97
        import pygtk
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
    98
        pygtk.require("2.0")
866
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
    99
        import gtkhtml2
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   100
except ImportError:
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   101
        sys.exit(1)
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
   102
import pkg.misc as misc
539
7486304966c5 1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents: 537
diff changeset
   103
import pkg.client.history as history
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   104
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
   105
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
   106
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
   107
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
   108
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
   109
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
   110
import pkg.gui.beadmin as beadm
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
   111
import pkg.gui.cache as cache
869
0197953cd88a 5398 UM not following steps consistently
Padraig O'Briain <padraig.obriain@sun.com>
parents: 868
diff changeset
   112
import pkg.gui.misc as gui_misc
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   113
import pkg.gui.imageinfo as imageinfo
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   114
import pkg.gui.installupdate as installupdate
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   115
import pkg.gui.enumerations as enumerations
866
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   116
import pkg.gui.parseqs as parseqs
576
6ee6de304041 3777 PKG_TIMEOUT_MAX is a placebo setting
Dan Price <dp@eng.sun.com>
parents: 565
diff changeset
   117
from pkg.client import global_settings
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   118
660
ea2809ad4582 4126 I10n update for IPS CLI PM and UM
John Rice <john.rice@sun.com>
parents: 653
diff changeset
   119
# Put _() in the global namespace
ea2809ad4582 4126 I10n update for IPS CLI PM and UM
John Rice <john.rice@sun.com>
parents: 653
diff changeset
   120
import __builtin__
ea2809ad4582 4126 I10n update for IPS CLI PM and UM
John Rice <john.rice@sun.com>
parents: 653
diff changeset
   121
__builtin__._ = gettext.gettext
457
9ee1bf88afb2 1905 GUI package manager slow responsiveness
John.Rice@Sun.COM
parents: 450
diff changeset
   122
866
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   123
(
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   124
DISPLAY_LINK,
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   125
CLICK_LINK,
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   126
) = range(2)
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   127
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   128
class PackageManager:
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   129
        def __init__(self):
830
687f8a73665e 6019 ctrl-c hangs packagemanager
Padraig O'Briain <padraig.obriain@sun.com>
parents: 827
diff changeset
   130
                signal.signal(signal.SIGINT, self.__main_application_quit)
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   131
                self.api_o = None
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
   132
                self.cache_o = None
821
c86df5cfbe44 5738 Need mechanism to change initial value for TopLevel and category
Padraig O'Briain <padraig.obriain@sun.com>
parents: 816
diff changeset
   133
                self.client = gconf.client_get_default()
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   134
                self.initial_show_filter = \
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   135
                    self.client.get_int(INITIAL_SHOW_FILTER_PREFERENCES)
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   136
                self.initial_section = self.client.get_int(INITIAL_SECTION_PREFERENCES)
872
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
   137
                self.show_startpage = self.client.get_bool(SHOW_STARTPAGE_PREFERENCES)
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
   138
                self.typeahead_search = self.client.get_bool(TYPEAHEAD_SEARCH_PREFERENCES)
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
   139
                
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   140
                socket.setdefaulttimeout(
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   141
                    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
   142
576
6ee6de304041 3777 PKG_TIMEOUT_MAX is a placebo setting
Dan Price <dp@eng.sun.com>
parents: 565
diff changeset
   143
                # 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
   144
                # in the environment.
576
6ee6de304041 3777 PKG_TIMEOUT_MAX is a placebo setting
Dan Price <dp@eng.sun.com>
parents: 565
diff changeset
   145
                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
   146
                    global_settings.PKG_TIMEOUT_MAX))
696
6bbfd2dece6f 4371 user-agent string needs to be different for different client front-ends
Danek Duvall <danek.duvall@sun.com>
parents: 660
diff changeset
   147
6bbfd2dece6f 4371 user-agent string needs to be different for different client front-ends
Danek Duvall <danek.duvall@sun.com>
parents: 660
diff changeset
   148
                global_settings.client_name = PKG_CLIENT_NAME
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   149
                    
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   150
                try:
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   151
                        self.application_dir = os.environ["PACKAGE_MANAGER_ROOT"]
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   152
                except KeyError:
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   153
                        self.application_dir = "/"
791
123e9401e939 5778 Inability to set locale leads to stack trace
Danek Duvall <danek.duvall@sun.com>
parents: 781
diff changeset
   154
                misc.setlocale(locale.LC_ALL, "")
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   155
                for module in (gettext, gtk.glade):
660
ea2809ad4582 4126 I10n update for IPS CLI PM and UM
John Rice <john.rice@sun.com>
parents: 653
diff changeset
   156
                        module.bindtextdomain("pkg", self.application_dir + \
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   157
                            "/usr/share/locale")
660
ea2809ad4582 4126 I10n update for IPS CLI PM and UM
John Rice <john.rice@sun.com>
parents: 653
diff changeset
   158
                        module.textdomain("pkg")
ea2809ad4582 4126 I10n update for IPS CLI PM and UM
John Rice <john.rice@sun.com>
parents: 653
diff changeset
   159
                # XXX Remove and use _() where self._ and self.parent._ are being used
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
   160
                main_window_title = _('Package Manager')
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   161
                self.user_rights = portable.is_admin()
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   162
                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
   163
                self.image_directory = None
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   164
                self.description_thread_running = False   # For background processes
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   165
                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
   166
                self.main_clipboard_text = None
500
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
   167
                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
   168
                self.progress_fraction_time_count = 0
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   169
                self.progress_canceled = False
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   170
                self.image_dir_arg = None
823
0db1bfc6d455 4848 PM fails with a blank error message
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 821
diff changeset
   171
                self.update_all_proceed = False
0db1bfc6d455 4848 PM fails with a blank error message
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 821
diff changeset
   172
                self.ua_be_name = None
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   173
                self.application_path = None
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   174
                self.default_authority = None
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   175
                self.first_run = True
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
   176
                self.selected_pkgname = None
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
   177
                self.info_cache = {}
816
5d4f7746a490 3978 Selecting package rows should check the package row as well
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 815
diff changeset
   178
                self.selected = 0
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   179
                self.selected_pkgs = {}
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   180
                self.to_install_update = {}
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   181
                self.to_remove = {}
872
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
   182
                self.in_startpage_startup = self.show_startpage
866
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   183
                self.lang = None
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   184
                self.start_page_url = None
833
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   185
                self.visible_status_id = 0
864
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   186
                self.categories_status_id = 0
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
   187
                self.visible_repository = None
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
   188
                self.visible_repository_uptodate = False
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   189
                self.section_list = None
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   190
                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
   191
                self.application_list = None
833
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   192
                self.a11y_application_treeview = None
864
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   193
                self.a11y_categories_treeview = None
833
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   194
                self.application_treeview_range = None
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   195
                self.application_treeview_initialized = False
864
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   196
                self.categories_treeview_range = None
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   197
                self.categories_treeview_initialized = False
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   198
                self.category_list = None
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   199
                self.repositories_list = None
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   200
                self.pr = progress.NullProgressTracker()
866
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   201
                
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   202
                # Create Widgets and show gui
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   203
                self.gladefile = self.application_dir + \
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   204
                    "/usr/share/package-manager/packagemanager.glade"
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   205
                w_tree_main = gtk.glade.XML(self.gladefile, "mainwindow")
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   206
                w_tree_progress = gtk.glade.XML(self.gladefile, "progressdialog")
872
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
   207
                w_tree_preferences = gtk.glade.XML(self.gladefile, "preferencesdialog")
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
   208
                self.w_preferencesdialog = \
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
   209
                    w_tree_preferences.get_widget("preferencesdialog")
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
   210
                self.w_startpage_checkbutton = \
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
   211
                    w_tree_preferences .get_widget("startpage_checkbutton")
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
   212
                self.w_typeaheadsearch_checkbutton = \
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
   213
                    w_tree_preferences .get_widget("typeaheadsearch_checkbutton")
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
   214
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   215
                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
   216
                self.w_application_treeview = \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   217
                    w_tree_main.get_widget("applicationtreeview")
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   218
                self.w_categories_treeview = w_tree_main.get_widget("categoriestreeview")
866
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   219
                self.w_info_notebook = w_tree_main.get_widget("details_notebook")
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   220
                self.w_generalinfo_textview = \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   221
                    w_tree_main.get_widget("generalinfotextview")
815
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
   222
                self.w_generalinfo_textview.set_wrap_mode(gtk.WRAP_WORD)
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   223
                self.w_installedfiles_textview = \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   224
                    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
   225
                self.w_license_textview = \
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   226
                    w_tree_main.get_widget("licensetextview")
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   227
                self.w_dependencies_textview = \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   228
                    w_tree_main.get_widget("dependenciestextview")
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   229
                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
   230
                self.w_shortdescription_label = \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   231
                    w_tree_main.get_widget("shortdescriptionlabel")
815
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
   232
                w_package_hbox = \
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
   233
                    w_tree_main.get_widget("package_hbox")
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
   234
                self.w_general_info_label = \
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
   235
                    w_tree_main.get_widget("general_info_label")
866
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   236
                self.w_startpage_frame = \
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   237
                    w_tree_main.get_widget("startpage_frame")
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   238
                self.w_startpage_eventbox = \
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   239
                    w_tree_main.get_widget("startpage_eventbox")
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   240
                self.w_startpage_eventbox.modify_bg(gtk.STATE_NORMAL,
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   241
                    gtk.gdk.color_parse("white"))
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   242
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   243
                self.w_main_statusbar = w_tree_main.get_widget("statusbar")
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   244
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   245
                
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   246
                self.w_main_view_notebook = \
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   247
                    w_tree_main.get_widget("main_view_notebook")
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   248
                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
   249
                self.w_installupdate_button = \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   250
                    w_tree_main.get_widget("install_update_button")
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   251
                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
   252
                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
   253
                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
   254
                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
   255
                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
   256
                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
   257
                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
   258
                self.w_installupdate_menuitem = \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   259
                    w_tree_main.get_widget("package_install_update")
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   260
                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
   261
                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
   262
                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
   263
                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
   264
                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
   265
                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
   266
                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
   267
                self.w_selectupdates_menuitem = \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   268
                    w_tree_main.get_widget("edit_select_updates")
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   269
                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
   270
                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
   271
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   272
                self.w_progress_dialog = w_tree_progress.get_widget("progressdialog")
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
   273
                self.w_progress_dialog.set_title(_("Update All"))
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   274
                self.w_progressinfo_label = w_tree_progress.get_widget("progressinfo")
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
   275
                self.w_progressinfo_label.set_text(_(
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   276
                    "Checking SUNWipkg and SUNWipkg-gui versions\n\nPlease wait ..."))
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   277
                self.w_progressbar = w_tree_progress.get_widget("progressbar")
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   278
                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
   279
                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
   280
                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
   281
                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
   282
                clear_search_image.set_from_stock(gtk.STOCK_CLEAR, gtk.ICON_SIZE_MENU)
602
cd5a41269b1e 3911 menu item, dialog header 'Manage Repositories'
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 594
diff changeset
   283
                toolbar =  w_tree_main.get_widget("toolbutton2")
cd5a41269b1e 3911 menu item, dialog header 'Manage Repositories'
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 594
diff changeset
   284
                toolbar.set_expand(True)
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   285
                self.__init_repository_tree_view()
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   286
                self.install_button_tooltip = gtk.Tooltips()
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   287
                self.remove_button_tooltip = gtk.Tooltips()
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   288
                self.__update_reload_button()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   289
                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
   290
                self.w_main_window.set_title(main_window_title)
457
9ee1bf88afb2 1905 GUI package manager slow responsiveness
John.Rice@Sun.COM
parents: 450
diff changeset
   291
866
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   292
                # Setup Start Page
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   293
                self.document = None
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   294
                self.view = None
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   295
                self.current_url = None
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   296
                self.opener = None
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   297
                self.__setup_startpage()
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   298
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   299
                try:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   300
                        dic_mainwindow = \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   301
                            {
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   302
                                "on_mainwindow_delete_event": \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   303
                                    self.__on_mainwindow_delete_event,
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   304
                                "on_searchentry_changed":self.__on_searchentry_changed,
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   305
                                "on_searchentry_focus_in_event": \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   306
                                    self.__on_searchentry_focus_in,
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   307
                                "on_searchentry_focus_out_event": \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   308
                                    self.__on_searchentry_focus_out,
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   309
                                "on_searchentry_event":self.__on_searchentry_event,
872
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
   310
                                "on_searchentry_key_press_event": \
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
   311
                                    self.__on_searchentry_key_press_event,
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   312
                                "on_sectionscombobox_changed": \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   313
                                    self.__on_sectionscombobox_changed,
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   314
                                "on_filtercombobox_changed": \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   315
                                    self.__on_filtercombobox_changed,
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   316
                                "on_repositorycombobox_changed": \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   317
                                    self.__on_repositorycombobox_changed,
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   318
                                #menu signals
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   319
                                "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
   320
                                "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
   321
                                "on_package_install_update_activate": \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   322
                                    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
   323
                                "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
   324
                                    self.__on_edit_repositories_activate,
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   325
                                "on_package_remove_activate":self.__on_remove,
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   326
                                "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
   327
                                "on_help_help_activate":self.__on_help_help,
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   328
                                "on_edit_paste_activate":self.__on_edit_paste,
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   329
                                "on_edit_clear_activate":self.__on_clear_paste,
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   330
                                "on_edit_copy_activate":self.__on_copy,
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   331
                                "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
   332
                                "on_clear_search_clicked":self.__on_clear_search,
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   333
                                "on_edit_select_all_activate":self.__on_select_all,
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   334
                                "on_edit_select_updates_activate": \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   335
                                    self.__on_select_updates,
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   336
                                "on_edit_deselect_activate":self.__on_deselect,
872
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
   337
                                "on_edit_preferences_activate":self.__on_preferences,
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   338
                                # XXX disabled until new API
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   339
                                "on_package_update_all_activate":self.__on_update_all,
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   340
                                #toolbar signals
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   341
                                # XXX disabled until new API
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   342
                                "on_update_all_button_clicked":self.__on_update_all,
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   343
                                "on_reload_button_clicked":self.__on_reload,
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   344
                                "on_install_update_button_clicked": \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   345
                                    self.__on_install_update,
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
   346
                                "on_remove_button_clicked":self.__on_remove,
866
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   347
                                "on_help_start_page_activate":self.__on_startpage,
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   348
                                "on_details_notebook_switch_page": \
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
   349
                                    self.__on_notebook_change,
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   350
                            }
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   351
                        dic_progress = \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   352
                            {
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   353
                                "on_cancel_progressdialog_clicked": \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   354
                                    self.__on_cancel_progressdialog_clicked,
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   355
                            }
872
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
   356
                        dic_preferences = \
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
   357
                            {
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
   358
                                "on_startpage_checkbutton_toggled": \
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
   359
                                    self.__on_startpage_checkbutton_toggled,
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
   360
                                "on_typeaheadsearch_checkbutton_toggled": \
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
   361
                                    self.__on_typeaheadsearch_checkbutton_toggled,
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
   362
                                "on_preferenceshelp_clicked": \
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
   363
                                    self.__on_preferenceshelp_clicked,
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
   364
                                "on_preferencesclose_clicked": \
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
   365
                                    self.__on_preferencesclose_clicked,
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
   366
                            }
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   367
                        w_tree_main.signal_autoconnect(dic_mainwindow)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   368
                        w_tree_progress.signal_autoconnect(dic_progress)
872
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
   369
                        w_tree_preferences.signal_autoconnect(dic_preferences)
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   370
                except AttributeError, error:
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
   371
                        print _(
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
   372
                            "GUI will not respond to any event! %s." 
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
   373
                            "Check declare_signals()") \
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   374
                            % error
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   375
                            
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   376
                self.package_selection = None
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   377
                self.category_list_filter = None
697
a1fd77e4007a 4852 PM search is slow
John Rice <john.rice@sun.com>
parents: 696
diff changeset
   378
                self.application_list_filter = None
a1fd77e4007a 4852 PM search is slow
John Rice <john.rice@sun.com>
parents: 696
diff changeset
   379
                self.application_refilter_id = 0 
865
81af5326a965 6239 time.sleep() should not be called when getting package info
Padraig O'Briain <padraig.obriain@sun.com>
parents: 864
diff changeset
   380
                self.show_info_id = 0 
81af5326a965 6239 time.sleep() should not be called when getting package info
Padraig O'Briain <padraig.obriain@sun.com>
parents: 864
diff changeset
   381
                self.show_licenses_id = 0 
500
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
   382
                self.in_setup = True
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   383
                self.w_main_window.show_all()
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
   384
                gdk_win = self.w_main_window.get_window()
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
   385
                self.gdk_window = gtk.gdk.Window(gdk_win, gtk.gdk.screen_width(), 
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
   386
                    gtk.gdk.screen_height(), gtk.gdk.WINDOW_CHILD, 0, gtk.gdk.INPUT_ONLY)
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
   387
                gdk_cursor = gtk.gdk.Cursor(gtk.gdk.WATCH)
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
   388
                self.gdk_window.set_cursor(gdk_cursor)
815
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
   389
                # Until package icons become available hide Package Icon Panel
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
   390
                w_package_hbox.hide()
872
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
   391
                if self.show_startpage:
866
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   392
                        self.w_main_view_notebook.set_current_page(NOTEBOOK_START_PAGE)
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   393
                else:
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   394
                        self.w_main_view_notebook.set_current_page(
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   395
                            NOTEBOOK_PACKAGE_LIST_PAGE)
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   396
866
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   397
        def __setup_startpage(self):
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   398
                self.opener = urllib.FancyURLopener()
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   399
                self.document = gtkhtml2.Document()
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   400
                self.document.connect('request_url', self.__request_url)
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   401
                self.document.connect('link_clicked', self.__handle_link)
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   402
                self.document.clear()
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   403
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   404
                self.view = gtkhtml2.View()
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   405
                self.view.set_document(self.document)
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   406
                self.view.connect('request_object', self.__request_object)
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   407
                self.view.connect('on_url', self.__on_url)
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   408
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   409
                try:
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   410
                        self.lang, encode = locale.getlocale(locale.LC_CTYPE)
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   411
                        if debug:
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   412
                                print "Lang: %s: Encode: %s" % (self.lang, encode)
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   413
                except locale.Error:
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   414
                        self.lang = "C"
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   415
                if self.lang == None or self.lang == "":
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   416
                        self.lang = "C"
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   417
                self.__load_startpage()
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   418
                self.w_startpage_frame.add(self.view)
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   419
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   420
        # Stub handler required by GtkHtml widget
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   421
        def __request_object(self, *vargs):
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   422
                pass
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   423
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   424
        def __load_startpage(self):
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   425
                self.start_page_url = self.application_dir + \
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   426
                    START_PAGE_LANG_BASE % (self.lang, START_PAGE_HOME)
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   427
                if not self.__load_uri(self.document, self.start_page_url):
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   428
                        self.start_page_url = self.application_dir + \
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   429
                            START_PAGE_LANG_BASE % ("C", START_PAGE_HOME)
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   430
                        if not self.__load_uri(self.document, self.start_page_url):
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   431
                                self.document.open_stream('text/html')
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   432
                                self.document.write_stream(_(
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   433
                                    "<html><head></head><body><H2>Welcome to \
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   434
                                    PackageManager!</H2><br>\
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   435
                                    <font color='#0000FF'>Warning: Unable to load \
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   436
                                    Start Page:<br>%s</font></body></html>"
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   437
                                    % (self.start_page_url)))
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   438
                                self.document.close_stream()
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   439
                                self.w_main_view_notebook.set_current_page(
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   440
                                    NOTEBOOK_PACKAGE_LIST_PAGE)
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   441
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   442
        def __on_url(self, view, link):
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   443
                # Handle mouse over events on links and reset when not on link
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   444
                if link == None or link == "":
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   445
                        self.update_statusbar()
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   446
                else:
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   447
                        display_link = self.__handle_link(None, link, DISPLAY_LINK)
866
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   448
                        if display_link != None:
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   449
                                self.w_main_statusbar.push(0, display_link)
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   450
                        else:
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   451
                                self.update_statusbar()
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   452
        
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   453
        @staticmethod
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   454
        def __is_relative_to_server(url):
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   455
                parts = urlparse.urlparse(url)
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   456
                if parts[0] or parts[1]:
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   457
                        return 0
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   458
                return 1
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   459
                
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   460
        def __open_url(self, url):
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   461
                uri = self.__resolve_uri(url)
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   462
                return self.opener.open(uri)
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   463
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   464
        def __resolve_uri(self, uri):
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   465
                if self.__is_relative_to_server(uri) and self.current_url != uri:
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   466
                        return urlparse.urljoin(self.current_url, uri)
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   467
                return uri
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   468
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   469
        def __request_url(self, document, url, stream):
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   470
                f = self.__open_url(url)
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   471
                stream.set_cancel_func(self.__stream_cancel)
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   472
                stream.write(f.read())
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   473
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   474
        # Stub handler required by GtkHtml widget or widget will assert
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   475
        def __stream_cancel(self, *vargs):
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   476
                pass
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   477
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   478
        def __load_uri(self, document, link):
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   479
                self.w_main_statusbar.push(0, _("Loading... " + link))
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   480
                try:
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   481
                        f = self.__open_url(link)
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   482
                except  (IOError, OSError), err:
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   483
                        if debug:
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   484
                                print "err: %s" % (err)
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   485
                        self.w_main_statusbar.push(0, _("Stopped"))
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   486
                        return False
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   487
                self.current_url = self.__resolve_uri(link)
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   488
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   489
                self.document.clear()
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   490
                headers = f.info()
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   491
                mime = headers.getheader('Content-type').split(';')[0]
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   492
                if mime:
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   493
                        self.document.open_stream(mime)
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   494
                else:
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   495
                        self.document.open_stream('text/plain')
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   496
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   497
                self.document.write_stream(f.read())
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   498
                self.document.close_stream()
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   499
                self.w_main_statusbar.push(0, _("Done"))
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   500
                return True
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   501
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   502
        def __link_load_error(self, link):
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   503
                self.document.clear()
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   504
                self.document.open_stream('text/html')
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   505
                self.document.write_stream(_(
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   506
                    "<html><head></head><body><font color='#000000'>\
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   507
                    <a href='stub'></a></font>\
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   508
                    <a href='pm?%s=internal&uri=%s'>\
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   509
                    <IMG SRC = 'startpage_star.png' \
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   510
                    style='border-style: none'></a> <br><br>\
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   511
                    <h2><font color='#0000FF'>Warning: Unable to \
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   512
                    load URL</font></h2><br>%s</body></html>" 
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   513
                    % (PM_ACTION, START_PAGE_HOME, link)))
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   514
                self.document.close_stream()
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   515
 
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   516
        def __handle_link(self, document, link, handle_what = CLICK_LINK):
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   517
                query_dict = self.__urlparse_qs(link)
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   518
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   519
                action = None
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   520
                if query_dict.has_key(PM_ACTION):
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   521
                        action = query_dict[PM_ACTION][0]
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   522
                elif handle_what == DISPLAY_LINK:
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   523
                        return link
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   524
                ext_uri = ""
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   525
                protocol = None
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   526
                
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   527
                # Internal Browse
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   528
                if action == ACTION_INTERNAL:
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   529
                        if query_dict.has_key(INTERNAL_URI):
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   530
                                int_uri = query_dict[INTERNAL_URI][0]
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   531
                                if handle_what == DISPLAY_LINK:
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   532
                                        return int_uri
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   533
                        else:
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   534
                                if handle_what == CLICK_LINK:
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   535
                                        self.__link_load_error(_("No URI specified"))
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   536
                                return
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   537
                        if handle_what == CLICK_LINK and \
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   538
                            not self.__load_uri(document, int_uri):
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   539
                                self.__link_load_error(int_uri)
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   540
                        return
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   541
                # External browse
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   542
                elif action == ACTION_EXTERNAL:
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   543
                        if query_dict.has_key(EXTERNAL_URI):
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   544
                                ext_uri = query_dict[EXTERNAL_URI][0]
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   545
                        else:
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   546
                                if handle_what == CLICK_LINK:
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   547
                                        self.__link_load_error(_("No URI specified"))
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   548
                                return
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   549
                        if query_dict.has_key(EXTERNAL_PROTOCOL):
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   550
                                protocol = query_dict[EXTERNAL_PROTOCOL][0]
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   551
                        else:
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   552
                                protocol = DEFAULT_PROTOCOL
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   553
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   554
                        if handle_what == DISPLAY_LINK:  
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   555
                                return protocol + "://" + ext_uri
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   556
                        try:
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   557
                                gnome.url_show(protocol + "://" + ext_uri)
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   558
                        except gobject.GError:
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   559
                                self.__link_load_error(protocol + "://" + ext_uri)
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   560
                elif handle_what == DISPLAY_LINK:
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   561
                        return None
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   562
                elif action == None:
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   563
                        try:
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   564
                                gnome.url_show(link)
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   565
                        except gobject.GError:
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   566
                                self.__link_load_error(link)
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   567
                # Handle empty and unsupported actions
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   568
                elif action == "":
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   569
                        self.__link_load_error(_("Empty Action not supported"
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   570
                            % action)) 
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   571
                        return
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   572
                elif action != None:
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   573
                        self.__link_load_error(_("Action not supported: %s"
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   574
                            % action)) 
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   575
                        return
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   576
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   577
        @staticmethod
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   578
        def __urlparse_qs(url, keep_blank_values=0, strict_parsing=0):
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   579
                scheme, netloc, url, params, querystring, fragment = urlparse.urlparse(
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   580
                    url)
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   581
                if debug:
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   582
                        print ("Query: scheme %s, netloc %s, url %s, params %s,"
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   583
                            "querystring %s, fragment %s"
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   584
                            % (scheme, netloc, url, params, querystring, fragment))
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   585
                return parseqs.parse_qs(querystring)
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
   586
                
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   587
        @staticmethod
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   588
        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
   589
                return gtk.ListStore(
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   590
                        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
   591
                        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
   592
                        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
   593
                        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
   594
                        gobject.TYPE_STRING,      # enumerations.DESCRIPTION_COLUMN
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
   595
                        gobject.TYPE_INT,         # enumerations.STATUS_COLUMN
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
   596
                        gobject.TYPE_PYOBJECT,    # enumerations.FMRI_COLUMN
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
   597
                        gobject.TYPE_STRING,      # enumerations.STEM_COLUMN
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
   598
                        gobject.TYPE_STRING,      # enumerations.DISPLAY_NAME_COLUMN
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   599
                        gobject.TYPE_BOOLEAN,     # enumerations.IS_VISIBLE_COLUMN
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
   600
                        gobject.TYPE_PYOBJECT     # enumerations.CATEGORY_LIST_COLUMN
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   601
                        )
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   602
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   603
        @staticmethod
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   604
        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
   605
                return gtk.ListStore(
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   606
                        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
   607
                        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
   608
                        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
   609
                        gtk.gdk.Pixbuf,           # enumerations.CATEGORY_ICON
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   610
                        gobject.TYPE_BOOLEAN,     # enumerations.CATEGORY_ICON_VISIBLE
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   611
                        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
   612
                        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
   613
                        )
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   614
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   615
        @staticmethod
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   616
        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
   617
                return gtk.ListStore(
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   618
                        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
   619
                        gobject.TYPE_STRING,      # enumerations.SECTION_NAME
827
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
   620
                        gobject.TYPE_STRING,      # enumerations.SECTION_SUBCATEGORY
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   621
                        gobject.TYPE_BOOLEAN,     # enumerations.SECTION_ENABLED
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   622
                        )
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   623
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   624
        @staticmethod                    
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   625
        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
   626
                return gtk.ListStore(
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   627
                        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
   628
                        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
   629
                        )
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   630
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   631
        @staticmethod
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   632
        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
   633
                return gtk.ListStore(
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   634
                        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
   635
                        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
   636
                        )
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   637
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   638
        def __init_tree_views(self, application_list, category_list, section_list):
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   639
                '''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
   640
                filters'''
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   641
                self.__disconnect_models()
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   642
                # The logic for initial section needs to be here as some sections
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   643
                # might be not enabled. In such situation we are setting the initial
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   644
                # section to "All Categories" one.
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   645
                row = section_list[self.initial_section]
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   646
                if row[enumerations.SECTION_ENABLED] and self.initial_section >= 0 and \
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   647
                    self.initial_section < len(section_list):
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   648
                        if row[enumerations.SECTION_ID] != self.initial_section:
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   649
                                self.initial_section = 0
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   650
                else:
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   651
                        self.initial_section = 0
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   652
                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
   653
                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
   654
                ##APPLICATION MAIN TREEVIEW
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   655
                application_list_filter = application_list.filter_new()
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   656
                application_list_sort = \
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   657
                    gtk.TreeModelSort(application_list_filter)
602
cd5a41269b1e 3911 menu item, dialog header 'Manage Repositories'
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 594
diff changeset
   658
                application_list_sort.set_sort_column_id(\
cd5a41269b1e 3911 menu item, dialog header 'Manage Repositories'
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 594
diff changeset
   659
                    enumerations.NAME_COLUMN, gtk.SORT_ASCENDING)
cd5a41269b1e 3911 menu item, dialog header 'Manage Repositories'
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 594
diff changeset
   660
                application_list_sort.set_sort_func(\
cd5a41269b1e 3911 menu item, dialog header 'Manage Repositories'
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 594
diff changeset
   661
                    enumerations.STATUS_ICON_COLUMN, self.__status_sort_func)
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   662
                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
   663
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   664
                column = gtk.TreeViewColumn("", toggle_renderer, \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   665
                    active = enumerations.MARK_COLUMN)
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   666
                column.set_sort_column_id(enumerations.MARK_COLUMN)
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   667
                column.set_sort_indicator(True)
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   668
                column.set_cell_data_func(toggle_renderer, self.cell_data_function, None)
868
3ccd83eaeaf9 6439 Accessible image descriptions not correct after sorting
Padraig O'Briain <padraig.obriain@sun.com>
parents: 866
diff changeset
   669
                column.connect_after('clicked', 
3ccd83eaeaf9 6439 Accessible image descriptions not correct after sorting
Padraig O'Briain <padraig.obriain@sun.com>
parents: 866
diff changeset
   670
                    self.__application_treeview_column_sorted, None)
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   671
                self.w_application_treeview.append_column(column)
827
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
   672
                column = self.__create_icon_column("", False,
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
   673
                    enumerations.ICON_COLUMN, True)
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   674
                self.w_application_treeview.append_column(column)
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   675
                name_renderer = gtk.CellRendererText()
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
   676
                column = gtk.TreeViewColumn(_("Name"), name_renderer,
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   677
                    text = enumerations.NAME_COLUMN)
602
cd5a41269b1e 3911 menu item, dialog header 'Manage Repositories'
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 594
diff changeset
   678
                column.set_resizable(True)
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   679
                column.set_sort_column_id(enumerations.NAME_COLUMN)
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   680
                column.set_sort_indicator(True)
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   681
                column.set_cell_data_func(name_renderer, self.cell_data_function, None)
868
3ccd83eaeaf9 6439 Accessible image descriptions not correct after sorting
Padraig O'Briain <padraig.obriain@sun.com>
parents: 866
diff changeset
   682
                column.connect_after('clicked', 
3ccd83eaeaf9 6439 Accessible image descriptions not correct after sorting
Padraig O'Briain <padraig.obriain@sun.com>
parents: 866
diff changeset
   683
                    self.__application_treeview_column_sorted, None)
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   684
                self.w_application_treeview.append_column(column)
827
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
   685
                column = self.__create_icon_column(_("Status"), True, 
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
   686
                    enumerations.STATUS_ICON_COLUMN, True)
863
6ddc7b63fce3 6346 Sorting packages by status is broken effective build 106
Padraig O'Briain <padraig.obriain@sun.com>
parents: 861
diff changeset
   687
                column.set_sort_column_id(enumerations.STATUS_ICON_COLUMN)
602
cd5a41269b1e 3911 menu item, dialog header 'Manage Repositories'
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 594
diff changeset
   688
                column.set_sort_indicator(True)
868
3ccd83eaeaf9 6439 Accessible image descriptions not correct after sorting
Padraig O'Briain <padraig.obriain@sun.com>
parents: 866
diff changeset
   689
                column.connect_after('clicked', 
3ccd83eaeaf9 6439 Accessible image descriptions not correct after sorting
Padraig O'Briain <padraig.obriain@sun.com>
parents: 866
diff changeset
   690
                    self.__application_treeview_column_sorted, None)
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   691
                self.w_application_treeview.append_column(column)
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   692
                description_renderer = gtk.CellRendererText()
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
   693
                column = gtk.TreeViewColumn(_('Description'), 
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   694
                    description_renderer, text = enumerations.DESCRIPTION_COLUMN)
602
cd5a41269b1e 3911 menu item, dialog header 'Manage Repositories'
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 594
diff changeset
   695
                column.set_resizable(True)
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
   696
                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
   697
                column.set_sort_indicator(True)
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
   698
                column.set_cell_data_func(description_renderer,
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   699
                    self.cell_data_function, None)
868
3ccd83eaeaf9 6439 Accessible image descriptions not correct after sorting
Padraig O'Briain <padraig.obriain@sun.com>
parents: 866
diff changeset
   700
                column.connect_after('clicked', 
3ccd83eaeaf9 6439 Accessible image descriptions not correct after sorting
Padraig O'Briain <padraig.obriain@sun.com>
parents: 866
diff changeset
   701
                    self.__application_treeview_column_sorted, None)
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   702
                self.w_application_treeview.append_column(column)
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   703
                #Added selection listener
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   704
                self.package_selection = self.w_application_treeview.get_selection()
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   705
                if self.first_run:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   706
                        # When vadj changes we need to set image descriptions 
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   707
                        # on visible status icons. This catches moving the scroll bars
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   708
                        # and scrolling up and down using keyboard.
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   709
                        vadj = self.w_application_treeview.get_vadjustment()
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   710
                        vadj.connect('value-changed', 
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   711
                            self.__application_treeview_vadjustment_changed, None)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   712
                        vadj = self.w_categories_treeview.get_vadjustment()
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   713
                        vadj.connect('value-changed', 
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   714
                            self.__categories_treeview_vadjustment_changed, None)
833
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   715
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   716
                        # When the size of the application_treeview changes
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   717
                        # we need to set image descriptions on visible status icons.
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   718
                        self.w_application_treeview.connect('size-allocate', 
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   719
                            self.__application_treeview_size_allocate, None)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   720
                        self.w_categories_treeview.connect('size-allocate', 
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   721
                            self.__categories_treeview_size_allocate, None)
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   722
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   723
                ##CATEGORIES TREEVIEW
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   724
                #enumerations.CATEGORY_NAME
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   725
                category_list_filter = category_list.filter_new()
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   726
                enumerations.CATEGORY_NAME_renderer = gtk.CellRendererText()
827
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
   727
                column =  self.__create_icon_column("", False,
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
   728
                    enumerations.CATEGORY_ICON, False)
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
   729
                self.w_categories_treeview.append_column(column)
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
   730
                column = gtk.TreeViewColumn(_('Name'),
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
   731
                    enumerations.CATEGORY_NAME_renderer,
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   732
                    text = enumerations.CATEGORY_NAME)
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   733
                self.w_categories_treeview.append_column(column)
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   734
                #Added selection listener
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   735
                category_selection = self.w_categories_treeview.get_selection()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   736
                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
   737
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   738
                if self.first_run:
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   739
                        ##SECTION COMBOBOX
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   740
                        #enumerations.SECTION_NAME
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   741
                        cell = gtk.CellRendererText()
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   742
                        self.w_sections_combobox.pack_start(cell, True)
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
   743
                        self.w_sections_combobox.add_attribute(cell, 'text',
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   744
                            enumerations.SECTION_NAME)
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
   745
                        self.w_sections_combobox.set_row_separator_func(
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   746
                            self.combobox_id_separator)
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   747
                        self.w_sections_combobox.add_attribute( cell,
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   748
                            'sensitive', enumerations.SECTION_ENABLED )
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   749
                        ##FILTER COMBOBOX
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   750
                        #enumerations.FILTER_NAME
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   751
                        cell = gtk.CellRendererText()
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   752
                        self.w_filter_combobox.pack_start(cell, True)
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
   753
                        self.w_filter_combobox.add_attribute(cell, 'text',
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   754
                            enumerations.FILTER_NAME)
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
   755
                        self.w_filter_combobox.set_row_separator_func(
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   756
                            self.combobox_id_separator)
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   757
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   758
                self.section_list = section_list
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   759
                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
   760
                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
   761
                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
   762
                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
   763
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   764
                self.w_sections_combobox.set_model(section_list)
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   765
                self.w_sections_combobox.set_active(self.initial_section)
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   766
                self.w_filter_combobox.set_model(self.filter_list)
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   767
                self.w_filter_combobox.set_active(self.initial_show_filter)
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   768
                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
   769
                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
   770
                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
   771
                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
   772
                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
   773
                    application_list_sort)
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
   774
                category_selection = self.w_categories_treeview.get_selection()
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
   775
                category_model, category_iter = category_selection.get_selected()
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
   776
                if not category_iter:         #no category was selected, so select "All"
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
   777
                        category_selection.select_path(0)
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
   778
                        category_model, category_iter = category_selection.get_selected()
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   779
                if self.first_run:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   780
                        category_selection.connect("changed",
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   781
                            self.__on_category_selection_changed, None)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   782
                        self.w_categories_treeview.connect("row-activated",
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   783
                            self.__on_category_row_activated, None)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   784
                        self.package_selection.set_mode(gtk.SELECTION_SINGLE)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   785
                        self.package_selection.connect("changed",
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   786
                            self.__on_package_selection_changed, None)
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   787
                self.__set_categories_visibility(self.initial_section)
833
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   788
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   789
                self.a11y_application_treeview = \
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   790
                    self.w_application_treeview.get_accessible()
864
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   791
                self.a11y_categories_treeview = \
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   792
                    self.w_categories_treeview.get_accessible()
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   793
                self.first_run = False
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   794
                self.process_package_list_end()
833
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   795
864
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   796
        def __categories_treeview_size_allocate(self, widget, allocation, user_data):
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   797
                # We ignore any changes in the size during initialization.
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   798
                if self.categories_treeview_initialized:
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   799
                        if self.categories_status_id == 0:
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   800
                                self.categories_status_id = gobject.idle_add(
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   801
                                    self.__set_accessible_categories_visible_status)
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   802
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   803
        def __categories_treeview_vadjustment_changed(self, widget, user_data):
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   804
                self.__set_accessible_categories_visible_status()
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   805
 
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   806
        def __set_accessible_categories_status(self, model, itr):
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   807
                status = model.get_value(itr, enumerations.CATEGORY_ICON)
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   808
                if status != None:
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   809
                        desc = _("Updates Available")
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   810
                else:
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   811
                        desc = None
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   812
                if desc != None:
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   813
                        obj = self.a11y_categories_treeview.ref_at(
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   814
                            int(model.get_string_from_iter(itr)), 
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   815
                            CATEGORIES_STATUS_COLUMN_INDEX) 
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   816
                        obj.set_image_description(desc)
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   817
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   818
        def __set_accessible_categories_visible_status(self):
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   819
                self.categories_status_id = 0
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   820
                if self.a11y_categories_treeview.get_n_accessible_children() == 0:
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   821
                        # accessibility is not enabled
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   822
                        return
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   823
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   824
                visible_range = self.w_categories_treeview.get_visible_range()
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   825
                if visible_range == None:
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   826
                        return
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   827
                start = visible_range[0][0]
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   828
                end = visible_range[1][0]
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   829
                # We try to minimize the range of accessible objects
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   830
                # on which we set image descriptions
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   831
                if self.categories_treeview_range != None:
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   832
                        old_start = self.categories_treeview_range[0][0]
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   833
                        old_end = self.categories_treeview_range[1][0]
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   834
                         # Old range is the same or smaller than new range
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   835
                         # so do nothing
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   836
                        if start >= old_start and end <= old_end:
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   837
                                return
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   838
                        if start < old_end:
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   839
                                if end < old_end:
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   840
                                        if end >= old_start:
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   841
                                                end = old_start 
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   842
                                else:
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   843
                                        start = old_end
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   844
                self.categories_treeview_range = visible_range
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   845
                model = self.category_list_filter
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   846
                itr = model.get_iter_from_string(str(start))
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   847
                while start <= end:
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   848
                        start += 1
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   849
                        self.__set_accessible_categories_status(model, itr)
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   850
                        itr = model.iter_next(itr)
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   851
868
3ccd83eaeaf9 6439 Accessible image descriptions not correct after sorting
Padraig O'Briain <padraig.obriain@sun.com>
parents: 866
diff changeset
   852
        def __application_treeview_column_sorted(self, widget, user_data):
3ccd83eaeaf9 6439 Accessible image descriptions not correct after sorting
Padraig O'Briain <padraig.obriain@sun.com>
parents: 866
diff changeset
   853
                self.__set_accessible_visible_status(False)
3ccd83eaeaf9 6439 Accessible image descriptions not correct after sorting
Padraig O'Briain <padraig.obriain@sun.com>
parents: 866
diff changeset
   854
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   855
        def __init_repository_tree_view(self):
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   856
                cell = gtk.CellRendererText()
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   857
                self.w_repository_combobox.pack_start(cell, True)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   858
                self.w_repository_combobox.add_attribute(cell, 'text',
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   859
                    enumerations.REPOSITORY_NAME)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   860
                self.w_repository_combobox.set_row_separator_func(
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   861
                    self.combobox_id_separator)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   862
833
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   863
        def __application_treeview_size_allocate(self, widget, allocation, user_data):
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   864
                # We ignore any changes in the size during initialization.
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   865
                if self.application_treeview_initialized:
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   866
                        if self.visible_status_id == 0:
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   867
                                self.visible_status_id = gobject.idle_add(
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   868
                                    self.__set_accessible_visible_status)
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   869
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   870
        def __application_treeview_vadjustment_changed(self, widget, user_data):
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   871
                self.__set_accessible_visible_status()
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   872
 
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   873
        def __set_accessible_status(self, model, itr):
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   874
                status = model.get_value(itr, enumerations.STATUS_COLUMN)
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   875
                if status == enumerations.INSTALLED:
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   876
                        desc = _("Installed")
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   877
                elif status == enumerations.NOT_INSTALLED:
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   878
                        desc = _("Not Installed")
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   879
                elif status == enumerations.UPDATABLE:
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   880
                        desc = _("Updates Available")
864
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   881
                else:
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   882
                        desc = None
833
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   883
                if desc != None:
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   884
                        obj = self.a11y_application_treeview.ref_at(
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   885
                            int(model.get_string_from_iter(itr)), 
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   886
                            STATUS_COLUMN_INDEX) 
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   887
                        obj.set_image_description(desc)
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   888
868
3ccd83eaeaf9 6439 Accessible image descriptions not correct after sorting
Padraig O'Briain <padraig.obriain@sun.com>
parents: 866
diff changeset
   889
        def __set_accessible_visible_status(self, check_range = True):
833
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   890
                self.visible_status_id = 0
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   891
                if self.a11y_application_treeview.get_n_accessible_children() == 0:
864
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   892
                        # accessibility is not enabled
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
   893
                        return
833
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   894
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   895
                visible_range = self.w_application_treeview.get_visible_range()
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   896
                if visible_range == None:
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   897
                        return
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   898
                start = visible_range[0][0]
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   899
                end = visible_range[1][0]
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   900
                # We try to minimize the range of accessible objects
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   901
                # on which we set image descriptions
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   902
                if self.application_treeview_range != None:
868
3ccd83eaeaf9 6439 Accessible image descriptions not correct after sorting
Padraig O'Briain <padraig.obriain@sun.com>
parents: 866
diff changeset
   903
                        if check_range:
3ccd83eaeaf9 6439 Accessible image descriptions not correct after sorting
Padraig O'Briain <padraig.obriain@sun.com>
parents: 866
diff changeset
   904
                                old_start = self.application_treeview_range[0][0]
3ccd83eaeaf9 6439 Accessible image descriptions not correct after sorting
Padraig O'Briain <padraig.obriain@sun.com>
parents: 866
diff changeset
   905
                                old_end = self.application_treeview_range[1][0]
3ccd83eaeaf9 6439 Accessible image descriptions not correct after sorting
Padraig O'Briain <padraig.obriain@sun.com>
parents: 866
diff changeset
   906
                                 # Old range is the same or smaller than new range
3ccd83eaeaf9 6439 Accessible image descriptions not correct after sorting
Padraig O'Briain <padraig.obriain@sun.com>
parents: 866
diff changeset
   907
                                 # so do nothing
3ccd83eaeaf9 6439 Accessible image descriptions not correct after sorting
Padraig O'Briain <padraig.obriain@sun.com>
parents: 866
diff changeset
   908
                                if start >= old_start and end <= old_end:
3ccd83eaeaf9 6439 Accessible image descriptions not correct after sorting
Padraig O'Briain <padraig.obriain@sun.com>
parents: 866
diff changeset
   909
                                        return
3ccd83eaeaf9 6439 Accessible image descriptions not correct after sorting
Padraig O'Briain <padraig.obriain@sun.com>
parents: 866
diff changeset
   910
                                if start < old_end:
3ccd83eaeaf9 6439 Accessible image descriptions not correct after sorting
Padraig O'Briain <padraig.obriain@sun.com>
parents: 866
diff changeset
   911
                                        if end < old_end:
3ccd83eaeaf9 6439 Accessible image descriptions not correct after sorting
Padraig O'Briain <padraig.obriain@sun.com>
parents: 866
diff changeset
   912
                                                if end >= old_start:
3ccd83eaeaf9 6439 Accessible image descriptions not correct after sorting
Padraig O'Briain <padraig.obriain@sun.com>
parents: 866
diff changeset
   913
                                                        end = old_start 
3ccd83eaeaf9 6439 Accessible image descriptions not correct after sorting
Padraig O'Briain <padraig.obriain@sun.com>
parents: 866
diff changeset
   914
                                        else:
3ccd83eaeaf9 6439 Accessible image descriptions not correct after sorting
Padraig O'Briain <padraig.obriain@sun.com>
parents: 866
diff changeset
   915
                                                start = old_end
833
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   916
                self.application_treeview_range = visible_range
863
6ddc7b63fce3 6346 Sorting packages by status is broken effective build 106
Padraig O'Briain <padraig.obriain@sun.com>
parents: 861
diff changeset
   917
                model = self.w_application_treeview.get_model()
833
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   918
                itr = model.get_iter_from_string(str(start))
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   919
                while start <= end:
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   920
                        start += 1
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   921
                        self.__set_accessible_status(model, itr)
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
   922
                        itr = model.iter_next(itr)
827
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
   923
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
   924
        def __create_icon_column(self, name, expand_pixbuf, enum_value, set_data_func):
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
   925
                column = gtk.TreeViewColumn()
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
   926
                column.set_title(name)
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
   927
                #Commented, since there was funny jumping of the icons
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
   928
                #column.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE)
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
   929
                render_pixbuf = gtk.CellRendererPixbuf()
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
   930
                column.pack_start(render_pixbuf, expand = expand_pixbuf)
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
   931
                column.add_attribute(render_pixbuf, "pixbuf", enum_value)
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
   932
                column.set_fixed_width(32)
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
   933
                if set_data_func:
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
   934
                        column.set_cell_data_func(render_pixbuf,
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
   935
                            self.cell_data_function, None)
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
   936
                return column
602
cd5a41269b1e 3911 menu item, dialog header 'Manage Repositories'
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 594
diff changeset
   937
                
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   938
        def __disconnect_models(self):
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   939
                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
   940
                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
   941
                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
   942
                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
   943
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   944
        def __disconnect_repository_model(self):
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   945
                self.w_repository_combobox.set_model(None)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
   946
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   947
        @staticmethod
602
cd5a41269b1e 3911 menu item, dialog header 'Manage Repositories'
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 594
diff changeset
   948
        def __status_sort_func(treemodel, iter1, iter2, user_data=None):
cd5a41269b1e 3911 menu item, dialog header 'Manage Repositories'
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 594
diff changeset
   949
                get_val = treemodel.get_value
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
   950
                status1 = get_val(iter1, enumerations.STATUS_COLUMN)
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
   951
                status2 = get_val(iter2, enumerations.STATUS_COLUMN)
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
   952
                return cmp(status1, status2)
602
cd5a41269b1e 3911 menu item, dialog header 'Manage Repositories'
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 594
diff changeset
   953
cd5a41269b1e 3911 menu item, dialog header 'Manage Repositories'
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 594
diff changeset
   954
        @staticmethod
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   955
        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
   956
                columns = treeview.get_columns()
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   957
                if columns:
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   958
                        for column in columns:
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
   959
                                treeview.remove_column(column)
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   960
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   961
        def __init_sections(self, section_list):
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   962
                '''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
   963
                Category. It sets active section combobox entry "All"'''
827
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
   964
                cat_path = None
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   965
                enabled = True
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   966
                # We enable only first section and later we might enable the rest, 
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   967
                # depending if there are some packages connected with them
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   968
                section_list.append([0, _('All Categories'), cat_path, enabled ])
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   969
                section_list.append([-1, "", cat_path, enabled ])
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   970
                enabled = False
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   971
                section_list.append([2, _('Meta Packages'), cat_path, enabled ])
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   972
                section_list.append([3, _('Applications'), cat_path, enabled ])
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   973
                section_list.append([4, _('Desktop (GNOME)'), cat_path, enabled ])
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   974
                section_list.append([5, _('Development'), cat_path, enabled ])
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   975
                section_list.append([6, _('Distributions'), cat_path, enabled ])
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   976
                section_list.append([7, _('Drivers'), cat_path, enabled ])
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   977
                section_list.append([8, _('System'), cat_path, enabled ])
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   978
                section_list.append([9, _('Web Services'), cat_path, enabled ])
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   979
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   980
        def __init_show_filter(self):
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
   981
                self.filter_list.append([0, _('All Packages'), ])
457
9ee1bf88afb2 1905 GUI package manager slow responsiveness
John.Rice@Sun.COM
parents: 450
diff changeset
   982
                self.filter_list.append([-1, "", ])
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
   983
                self.filter_list.append([2, _('Installed Packages'), ])
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
   984
                self.filter_list.append([3, _('Updates'), ])
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
   985
                self.filter_list.append([4, _('Non-installed Packages'), ])
457
9ee1bf88afb2 1905 GUI package manager slow responsiveness
John.Rice@Sun.COM
parents: 450
diff changeset
   986
                self.filter_list.append([-1, "", ])
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
   987
                # self.filter_list.append([_('Locked Packages'), ])
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
   988
                # self.filter_list.append(["", ])
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
   989
                self.filter_list.append([6, _('Selected Packages'), ])
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   990
                if self.initial_show_filter >= 0 and \
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   991
                    self.initial_show_filter < len(self.filter_list):
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   992
                        row = self.filter_list[self.initial_show_filter]
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   993
                        if row[enumerations.SECTION_ID] != self.initial_show_filter:
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   994
                                self.initial_show_filter = 0
821
c86df5cfbe44 5738 Need mechanism to change initial value for TopLevel and category
Padraig O'Briain <padraig.obriain@sun.com>
parents: 816
diff changeset
   995
                else:
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
   996
                        self.initial_show_filter = 0
821
c86df5cfbe44 5738 Need mechanism to change initial value for TopLevel and category
Padraig O'Briain <padraig.obriain@sun.com>
parents: 816
diff changeset
   997
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   998
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
   999
        def __on_cancel_progressdialog_clicked(self, widget):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1000
                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
  1001
                self.progress_stop_timer_thread = True
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1002
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1003
        def __on_mainwindow_delete_event(self, widget, event):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1004
                ''' handler for delete event of the main window '''
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1005
                if self.__check_if_something_was_changed() == True:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1006
                        # XXX Change this to not quit and show dialog
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1007
                        # XXX if some changes were applied:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1008
                        self.__main_application_quit()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1009
                        return True
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1010
                else:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1011
                        self.__main_application_quit()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1012
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1013
        def __on_file_quit_activate(self, widget):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1014
                ''' handler for quit menu event '''
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1015
                self.__on_mainwindow_delete_event(None, None)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1016
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  1017
        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
  1018
                ''' 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
  1019
                repository.Repository(self)
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  1020
543
9889330c2ab5 3201 Add Dialog for setting default and removing Boot Environments
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 539
diff changeset
  1021
        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
  1022
                ''' 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
  1023
                beadm.Beadmin(self)
9889330c2ab5 3201 Add Dialog for setting default and removing Boot Environments
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 539
diff changeset
  1024
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1025
        def __on_searchentry_changed(self, widget):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1026
                '''On text search field changed we should refilter the main view'''
872
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
  1027
                if self.typeahead_search:
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
  1028
                        self.__do_search()
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
  1029
                
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
  1030
        def __do_search(self):
866
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
  1031
                self.__set_main_view_package_list()
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  1032
                self.set_busy_cursor()
697
a1fd77e4007a 4852 PM search is slow
John Rice <john.rice@sun.com>
parents: 696
diff changeset
  1033
                if self.application_refilter_id != 0:
a1fd77e4007a 4852 PM search is slow
John Rice <john.rice@sun.com>
parents: 696
diff changeset
  1034
                        gobject.source_remove(self.application_refilter_id)
a1fd77e4007a 4852 PM search is slow
John Rice <john.rice@sun.com>
parents: 696
diff changeset
  1035
                        self.application_refilter_id = 0
a1fd77e4007a 4852 PM search is slow
John Rice <john.rice@sun.com>
parents: 696
diff changeset
  1036
                if self.w_searchentry_dialog.get_text() == "":
a1fd77e4007a 4852 PM search is slow
John Rice <john.rice@sun.com>
parents: 696
diff changeset
  1037
                        self.application_refilter_id = \
a1fd77e4007a 4852 PM search is slow
John Rice <john.rice@sun.com>
parents: 696
diff changeset
  1038
                            gobject.idle_add(self.__application_refilter)
a1fd77e4007a 4852 PM search is slow
John Rice <john.rice@sun.com>
parents: 696
diff changeset
  1039
                else:
a1fd77e4007a 4852 PM search is slow
John Rice <john.rice@sun.com>
parents: 696
diff changeset
  1040
                        self.application_refilter_id = \
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  1041
                            gobject.timeout_add(TYPE_AHEAD_DELAY, 
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  1042
                            self.__application_refilter)
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1043
697
a1fd77e4007a 4852 PM search is slow
John Rice <john.rice@sun.com>
parents: 696
diff changeset
  1044
        def __application_refilter(self):
793
0f219154d202 5526 Package Manager _very_ slow after UA "Screen R&M" turned on
Padraig O'Briain <padraig.obriain@sun.com>
parents: 791
diff changeset
  1045
                ''' Disconnecting the model from the treeview improves
0f219154d202 5526 Package Manager _very_ slow after UA "Screen R&M" turned on
Padraig O'Briain <padraig.obriain@sun.com>
parents: 791
diff changeset
  1046
                performance when assistive technologies are enabled'''
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1047
                if self.in_setup:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1048
                        return
793
0f219154d202 5526 Package Manager _very_ slow after UA "Screen R&M" turned on
Padraig O'Briain <padraig.obriain@sun.com>
parents: 791
diff changeset
  1049
                model = self.w_application_treeview.get_model()
0f219154d202 5526 Package Manager _very_ slow after UA "Screen R&M" turned on
Padraig O'Briain <padraig.obriain@sun.com>
parents: 791
diff changeset
  1050
                self.w_application_treeview.set_model(None)
697
a1fd77e4007a 4852 PM search is slow
John Rice <john.rice@sun.com>
parents: 696
diff changeset
  1051
                self.application_list_filter.refilter()
793
0f219154d202 5526 Package Manager _very_ slow after UA "Screen R&M" turned on
Padraig O'Briain <padraig.obriain@sun.com>
parents: 791
diff changeset
  1052
                self.w_application_treeview.set_model(model)
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1053
                gobject.idle_add(self.__enable_disable_selection_menus)
833
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
  1054
                self.application_treeview_initialized = True
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
  1055
                self.application_treeview_range = None
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
  1056
                if self.visible_status_id == 0:
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
  1057
                        self.visible_status_id = gobject.idle_add(
9aef5ca23264 5914 Images in "Status" column need accessible descriptions
Padraig O'Briain <padraig.obriain@sun.com>
parents: 830
diff changeset
  1058
                            self.__set_accessible_visible_status)
864
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
  1059
                self.categories_treeview_initialized = True
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
  1060
                self.categories_treeview_range = None
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
  1061
                if self.categories_status_id == 0:
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
  1062
                        self.categories_status_id = gobject.idle_add(
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
  1063
                            self.__set_accessible_categories_visible_status)
697
a1fd77e4007a 4852 PM search is slow
John Rice <john.rice@sun.com>
parents: 696
diff changeset
  1064
                self.application_refilter_id = 0
a1fd77e4007a 4852 PM search is slow
John Rice <john.rice@sun.com>
parents: 696
diff changeset
  1065
                return False
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1066
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1067
        def __on_edit_paste(self, widget):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1068
                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
  1069
                    self.w_searchentry_dialog.get_position())
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1070
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1071
        def __on_clear_paste(self, widget):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1072
                bounds = self.w_searchentry_dialog.get_selection_bounds()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1073
                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
  1074
                return
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1075
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1076
        def __on_copy(self, widget):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1077
                bounds = self.w_searchentry_dialog.get_selection_bounds()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1078
                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
  1079
                self.w_main_clipboard.set_text(text)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1080
                return
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1081
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1082
        def __on_cut(self, widget):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1083
                bounds = self.w_searchentry_dialog.get_selection_bounds()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1084
                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
  1085
                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
  1086
                self.w_main_clipboard.set_text(text)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1087
                return
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1088
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  1089
        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
  1090
                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
  1091
                return
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  1092
866
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
  1093
        def __on_startpage(self, widget):
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
  1094
                self.__load_startpage()
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
  1095
                self.w_main_view_notebook.set_current_page(NOTEBOOK_START_PAGE)
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
  1096
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1097
        def __on_notebook_change(self, widget, event, pagenum):
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1098
                if pagenum == 3:
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1099
                        licbuffer = self.w_license_textview.get_buffer()
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  1100
                        leg_txt = _("Fetching legal information...")
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1101
                        licbuffer.set_text(leg_txt)
865
81af5326a965 6239 time.sleep() should not be called when getting package info
Padraig O'Briain <padraig.obriain@sun.com>
parents: 864
diff changeset
  1102
                        if self.show_licenses_id != 0:
81af5326a965 6239 time.sleep() should not be called when getting package info
Padraig O'Briain <padraig.obriain@sun.com>
parents: 864
diff changeset
  1103
                                gobject.source_remove(self.show_licenses_id)
81af5326a965 6239 time.sleep() should not be called when getting package info
Padraig O'Briain <padraig.obriain@sun.com>
parents: 864
diff changeset
  1104
                                self.show_licenses_id = 0
81af5326a965 6239 time.sleep() should not be called when getting package info
Padraig O'Briain <padraig.obriain@sun.com>
parents: 864
diff changeset
  1105
                        self.show_licenses_id = \
81af5326a965 6239 time.sleep() should not be called when getting package info
Padraig O'Briain <padraig.obriain@sun.com>
parents: 864
diff changeset
  1106
                            gobject.timeout_add(TYPE_AHEAD_DELAY, 
81af5326a965 6239 time.sleep() should not be called when getting package info
Padraig O'Briain <padraig.obriain@sun.com>
parents: 864
diff changeset
  1107
                                self.__show_licenses)
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1108
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1109
        def __on_select_all(self, widget):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1110
                sort_filt_model = \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1111
                    self.w_application_treeview.get_model() #gtk.TreeModelSort
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1112
                filt_model = sort_filt_model.get_model() #gtk.TreeModelFilter
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1113
                model = filt_model.get_model() #gtk.ListStore
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1114
                iter_next = sort_filt_model.get_iter_first()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1115
                list_of_paths = []
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1116
                while iter_next != None:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1117
                        sorted_path = sort_filt_model.get_path(iter_next)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1118
                        filtered_path = \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1119
                            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
  1120
                        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
  1121
                        list_of_paths.append(path)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1122
                        iter_next = sort_filt_model.iter_next(iter_next)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1123
                for path in list_of_paths:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1124
                        itr = model.get_iter(path)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1125
                        model.set_value(itr, enumerations.MARK_COLUMN, True)
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1126
                        pkg_stem = model.get_value(itr, enumerations.STEM_COLUMN)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1127
                        pkg_status = model.get_value(itr, enumerations.STATUS_COLUMN)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1128
                        self.__add_pkg_stem_to_list(pkg_stem, pkg_status)
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1129
                self.__enable_disable_selection_menus()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1130
                self.update_statusbar()
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1131
                self.__enable_disable_install_remove()
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1132
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1133
        def __on_select_updates(self, widget):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1134
                sort_filt_model = \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1135
                    self.w_application_treeview.get_model() #gtk.TreeModelSort
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1136
                filt_model = sort_filt_model.get_model() #gtk.TreeModelFilter
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1137
                model = filt_model.get_model() #gtk.ListStore
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1138
                iter_next = sort_filt_model.get_iter_first()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1139
                list_of_paths = []
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1140
                while iter_next != None:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1141
                        sorted_path = sort_filt_model.get_path(iter_next)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1142
                        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
  1143
                            iter_next)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1144
                        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
  1145
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1146
                        filtered_path = \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1147
                            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
  1148
                        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
  1149
                        if model.get_value(app_iter, \
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  1150
                            enumerations.STATUS_COLUMN) == enumerations.UPDATABLE:
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  1151
                                list_of_paths.append(path)
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1152
                        iter_next = sort_filt_model.iter_next(iter_next)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1153
                for path in list_of_paths:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1154
                        itr = model.get_iter(path)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1155
                        model.set_value(itr, enumerations.MARK_COLUMN, True)
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1156
                        pkg_stem = model.get_value(itr, enumerations.STEM_COLUMN)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1157
                        pkg_status = model.get_value(itr, enumerations.STATUS_COLUMN)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1158
                        self.__add_pkg_stem_to_list(pkg_stem, pkg_status)
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1159
                self.__enable_disable_selection_menus()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1160
                self.update_statusbar()
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1161
                self.__enable_disable_install_remove()
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1162
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1163
        def __on_deselect(self, widget):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1164
                sort_filt_model = \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1165
                    self.w_application_treeview.get_model() #gtk.TreeModelSort
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1166
                filt_model = sort_filt_model.get_model() #gtk.TreeModelFilter
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1167
                model = filt_model.get_model() #gtk.ListStore
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1168
                iter_next = sort_filt_model.get_iter_first()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1169
                list_of_paths = []
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1170
                while iter_next != None:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1171
                        sorted_path = sort_filt_model.get_path(iter_next)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1172
                        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
  1173
                            iter_next)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1174
                        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
  1175
                        filtered_path = \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1176
                            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
  1177
                        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
  1178
                        if model.get_value(app_iter, enumerations.MARK_COLUMN):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1179
                                list_of_paths.append(path)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1180
                        iter_next = sort_filt_model.iter_next(iter_next)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1181
                for path in list_of_paths:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1182
                        itr = model.get_iter(path)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1183
                        model.set_value(itr, enumerations.MARK_COLUMN, False)
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1184
                        self.__remove_pkg_stem_from_list(model.get_value(itr, 
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1185
                            enumerations.STEM_COLUMN))
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1186
                self.__enable_disable_selection_menus()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1187
                self.update_statusbar()
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1188
                self.__enable_disable_install_remove()
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1189
872
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
  1190
        def __on_preferences(self, widget):
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
  1191
                self.w_startpage_checkbutton.set_active(self.show_startpage)
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
  1192
                self.w_typeaheadsearch_checkbutton.set_active(self.typeahead_search)
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
  1193
                self.w_preferencesdialog.show()
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
  1194
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
  1195
        def __on_preferencesclose_clicked(self, widget):
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
  1196
                self.w_preferencesdialog.hide()
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
  1197
                
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
  1198
        def __on_preferenceshelp_clicked(self, widget):
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
  1199
                self.__on_help_help(widget)
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
  1200
                
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
  1201
        def __on_startpage_checkbutton_toggled(self, widget):
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
  1202
                self.show_startpage = self.w_startpage_checkbutton.get_active()
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
  1203
                self.client.set_bool(SHOW_STARTPAGE_PREFERENCES, self.show_startpage)
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
  1204
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
  1205
        def __on_typeaheadsearch_checkbutton_toggled(self, widget):
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
  1206
                self.typeahead_search = self.w_typeaheadsearch_checkbutton.get_active()
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
  1207
                self.client.set_bool(TYPEAHEAD_SEARCH_PREFERENCES, self.typeahead_search)
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
  1208
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1209
        def __on_searchentry_focus_in(self, widget, event):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1210
                self.w_paste_menuitem.set_sensitive(True)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1211
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1212
        def __on_searchentry_focus_out(self, widget, event):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1213
                self.w_paste_menuitem.set_sensitive(False)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1214
872
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
  1215
        def __on_searchentry_key_press_event(self, widget, event):
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
  1216
                if self.typeahead_search:
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
  1217
                        return False
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
  1218
                from gtk.gdk import keyval_name
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
  1219
                if debug:
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
  1220
                        print "Pressed %s" % keyval_name(event.keyval)
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
  1221
                if event.keyval == gtk.keysyms.Return:
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
  1222
                        self.__do_search()
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
  1223
                        return True
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
  1224
                return False
6e436e167ae4 6354 Add Preferences Dialog to PM
John Rice <john.rice@sun.com>
parents: 871
diff changeset
  1225
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1226
        def __on_searchentry_event(self, widget, event):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1227
                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
  1228
                if widget.get_selection_bounds():
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1229
                        #enable selection functions
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1230
                        self.w_cut_menuitem.set_sensitive(True)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1231
                        self.w_copy_menuitem.set_sensitive(True)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1232
                        self.w_clear_menuitem.set_sensitive(True)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1233
                else:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1234
                        self.w_cut_menuitem.set_sensitive(False)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1235
                        self.w_copy_menuitem.set_sensitive(False)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1236
                        self.w_clear_menuitem.set_sensitive(False)
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  1237
866
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
  1238
        def __on_category_row_activated(self, view, path, col, user):
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
  1239
                '''This function is for handling category double click activations'''
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
  1240
                if self.w_main_view_notebook.get_current_page() != NOTEBOOK_START_PAGE:
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
  1241
                        return
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
  1242
                self.__set_main_view_package_list()
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
  1243
                self.set_busy_cursor()
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
  1244
                gobject.idle_add(self.__application_refilter)
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
  1245
                if self.selected == 0:
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1246
                        gobject.idle_add(self.__enable_disable_install_remove)
866
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
  1247
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
  1248
        def __set_main_view_package_list(self):
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
  1249
                # Only switch from Start Page View to List view if we are not in startup
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
  1250
                if not self.in_startpage_startup:
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
  1251
                        self.w_main_view_notebook.set_current_page(
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
  1252
                                NOTEBOOK_PACKAGE_LIST_PAGE)
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
  1253
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1254
        def __on_category_selection_changed(self, selection, widget):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1255
                '''This function is for handling category selection changes'''
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1256
                if self.in_setup:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1257
                        return
866
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
  1258
                self.__set_main_view_package_list()
827
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
  1259
                model, itr = selection.get_selected()
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
  1260
                if itr:
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
  1261
                        cat_path = model.get_string_from_iter(itr)
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
  1262
                        selected_section = self.w_sections_combobox.get_active()
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
  1263
                        section_row = self.section_list[selected_section]
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
  1264
                        section_row[enumerations.SECTION_SUBCATEGORY] = cat_path
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
  1265
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  1266
                self.set_busy_cursor()
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  1267
                gobject.idle_add(self.__application_refilter)
816
5d4f7746a490 3978 Selecting package rows should check the package row as well
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 815
diff changeset
  1268
                if self.selected == 0:
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1269
                        gobject.idle_add(self.__enable_disable_install_remove)
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1270
861
2a5fb898a335 4578 IPS GUI does not update the package info after upgrading
Padraig O'Briain <padraig.obriain@sun.com>
parents: 844
diff changeset
  1271
        def __process_package_selection(self):
2a5fb898a335 4578 IPS GUI does not update the package info after upgrading
Padraig O'Briain <padraig.obriain@sun.com>
parents: 844
diff changeset
  1272
                model, itr = self.package_selection.get_selected()
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1273
                if itr:
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1274
                        self.__enable_disable_install_remove()
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1275
                        self.selected_pkgname = \
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1276
                               model.get_value(itr, enumerations.NAME_COLUMN)
865
81af5326a965 6239 time.sleep() should not be called when getting package info
Padraig O'Briain <padraig.obriain@sun.com>
parents: 864
diff changeset
  1277
                        if self.show_info_id != 0:
81af5326a965 6239 time.sleep() should not be called when getting package info
Padraig O'Briain <padraig.obriain@sun.com>
parents: 864
diff changeset
  1278
                                gobject.source_remove(self.show_info_id)
81af5326a965 6239 time.sleep() should not be called when getting package info
Padraig O'Briain <padraig.obriain@sun.com>
parents: 864
diff changeset
  1279
                                self.show_info_id = 0
81af5326a965 6239 time.sleep() should not be called when getting package info
Padraig O'Briain <padraig.obriain@sun.com>
parents: 864
diff changeset
  1280
                        pkg = model.get_value(itr, enumerations.FMRI_COLUMN)
81af5326a965 6239 time.sleep() should not be called when getting package info
Padraig O'Briain <padraig.obriain@sun.com>
parents: 864
diff changeset
  1281
                        gobject.idle_add(self.__show_fetching_package_info, pkg)
81af5326a965 6239 time.sleep() should not be called when getting package info
Padraig O'Briain <padraig.obriain@sun.com>
parents: 864
diff changeset
  1282
                        self.show_info_id = \
81af5326a965 6239 time.sleep() should not be called when getting package info
Padraig O'Briain <padraig.obriain@sun.com>
parents: 864
diff changeset
  1283
                            gobject.timeout_add(TYPE_AHEAD_DELAY, 
81af5326a965 6239 time.sleep() should not be called when getting package info
Padraig O'Briain <padraig.obriain@sun.com>
parents: 864
diff changeset
  1284
                                self.__show_info, model, model.get_path(itr))
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1285
                        if self.w_info_notebook.get_current_page() == 3:
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1286
                                self.__on_notebook_change(None, None, 3)
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  1287
861
2a5fb898a335 4578 IPS GUI does not update the package info after upgrading
Padraig O'Briain <padraig.obriain@sun.com>
parents: 844
diff changeset
  1288
        def __on_package_selection_changed(self, selection, widget):
2a5fb898a335 4578 IPS GUI does not update the package info after upgrading
Padraig O'Briain <padraig.obriain@sun.com>
parents: 844
diff changeset
  1289
                '''This function is for handling package selection changes'''
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1290
                if self.in_setup:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1291
                        return
861
2a5fb898a335 4578 IPS GUI does not update the package info after upgrading
Padraig O'Briain <padraig.obriain@sun.com>
parents: 844
diff changeset
  1292
                self.__process_package_selection()
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1293
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1294
        def __on_filtercombobox_changed(self, widget):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1295
                '''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
  1296
                if self.in_setup:
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  1297
                        return
866
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
  1298
                self.__set_main_view_package_list()
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  1299
                self.set_busy_cursor()
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  1300
                gobject.idle_add(self.__application_refilter)
816
5d4f7746a490 3978 Selecting package rows should check the package row as well
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 815
diff changeset
  1301
                if self.selected == 0:
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1302
                        gobject.idle_add(self.__enable_disable_install_remove)
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1303
821
c86df5cfbe44 5738 Need mechanism to change initial value for TopLevel and category
Padraig O'Briain <padraig.obriain@sun.com>
parents: 816
diff changeset
  1304
        def __set_categories_visibility(self, selected_section):
864
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
  1305
                self.category_list[0][enumerations.CATEGORY_ICON] = None
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1306
                if selected_section == 0:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1307
                        for category in self.category_list:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1308
                                category[enumerations.CATEGORY_VISIBLE] = True
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1309
                else:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1310
                        for category in self.category_list:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1311
                                if category[enumerations.CATEGORY_ID] == 0:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1312
                                        category[enumerations.CATEGORY_VISIBLE] = True
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1313
                                else:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1314
                                        category_list = \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1315
                                            category[enumerations.SECTION_LIST_OBJECT]
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1316
                                        if not category_list:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1317
                                                category[enumerations.CATEGORY_VISIBLE] \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1318
                                                    = False
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1319
                                        else:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1320
                                                for section in category_list:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1321
                                                        if section == selected_section:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1322
                                                                category[enumerations. \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1323
                                                                    CATEGORY_VISIBLE] = \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1324
                                                                    True
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1325
                                                        else:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1326
                                                                category[enumerations. \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1327
                                                                    CATEGORY_VISIBLE] = \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1328
                                                                    False
827
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
  1329
864
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
  1330
                # Set category icon for All if a visible category has it
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
  1331
                for category in self.category_list:
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
  1332
                        if category[enumerations.CATEGORY_ICON] != None:
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
  1333
                                self.category_list[0][enumerations.CATEGORY_ICON] = \
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
  1334
                                    category[enumerations.CATEGORY_ICON]
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
  1335
                                break
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
  1336
827
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
  1337
                section_row = self.section_list[selected_section]
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
  1338
                cat_path = section_row[enumerations.SECTION_SUBCATEGORY]
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
  1339
                if cat_path != None:
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
  1340
                        itr = self.category_list_filter.get_iter_from_string(cat_path)
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
  1341
                        path = self.category_list_filter.get_path(itr)
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
  1342
                        self.w_categories_treeview.set_cursor(path,
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
  1343
                            None, start_editing=False)
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
  1344
821
c86df5cfbe44 5738 Need mechanism to change initial value for TopLevel and category
Padraig O'Briain <padraig.obriain@sun.com>
parents: 816
diff changeset
  1345
        def __on_sectionscombobox_changed(self, widget):
c86df5cfbe44 5738 Need mechanism to change initial value for TopLevel and category
Padraig O'Briain <padraig.obriain@sun.com>
parents: 816
diff changeset
  1346
                '''On section combobox changed'''
c86df5cfbe44 5738 Need mechanism to change initial value for TopLevel and category
Padraig O'Briain <padraig.obriain@sun.com>
parents: 816
diff changeset
  1347
                if self.in_setup:
c86df5cfbe44 5738 Need mechanism to change initial value for TopLevel and category
Padraig O'Briain <padraig.obriain@sun.com>
parents: 816
diff changeset
  1348
                        return
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  1349
                self.__set_first_category_text()
866
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
  1350
                self.__set_main_view_package_list()
821
c86df5cfbe44 5738 Need mechanism to change initial value for TopLevel and category
Padraig O'Briain <padraig.obriain@sun.com>
parents: 816
diff changeset
  1351
                self.__set_categories_visibility(widget.get_active())
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  1352
                self.set_busy_cursor()
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1353
                self.category_list_filter.refilter()
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  1354
                gobject.idle_add(self.__application_refilter)
816
5d4f7746a490 3978 Selecting package rows should check the package row as well
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 815
diff changeset
  1355
                if self.selected == 0:
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1356
                        gobject.idle_add(self.__enable_disable_install_remove)
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1357
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  1358
        def __set_first_category_text(self):
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  1359
                active_section = self.w_sections_combobox.get_active()
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  1360
                all_cat_text = _("All")
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  1361
                if active_section != 0:
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  1362
                        all_cat_text += " " + self.section_list[active_section][1]
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  1363
                category_model = self.w_categories_treeview.get_model()
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  1364
                if category_model:
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  1365
                        list_store = category_model.get_model()
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  1366
                        list_store[0][1] = all_cat_text
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  1367
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1368
        def __on_repositorycombobox_changed(self, widget):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1369
                '''On repository combobox changed'''
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1370
                self.cancelled = True
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1371
                self.in_setup = True
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  1372
                self.set_busy_cursor()
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1373
                authority = self.__get_active_authority()
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1374
                auth = [authority, ]
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1375
                Thread(target = self.__setup_authority, args = [auth]).start()
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1376
                self.__set_main_view_package_list()
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1377
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1378
        def __get_active_authority(self):
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1379
                auth_iter = self.w_repository_combobox.get_active_iter()
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1380
                return self.repositories_list.get_value(auth_iter, \
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1381
                            enumerations.REPOSITORY_NAME)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1382
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1383
        def __setup_authority(self, authorities=[]):
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  1384
                application_list, category_list , section_list = \
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1385
                    self.__get_application_categories_lists(authorities)
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  1386
                gobject.idle_add(self.__init_tree_views, application_list,
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  1387
                    category_list, section_list)
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1388
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1389
        def __get_application_categories_lists(self, authorities=[]):
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  1390
                if not self.visible_repository:
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  1391
                        self.visible_repository = self.__get_active_authority()
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1392
                application_list = self.__get_new_application_liststore()
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1393
                category_list = self.__get_new_category_liststore()
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  1394
                section_list = self.__get_new_section_liststore()
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  1395
                first_loop = True
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1396
                for authority in authorities:
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  1397
                        uptodate = False
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  1398
                        try:
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  1399
                                uptodate = self.__check_if_cache_uptodate(authority)
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  1400
                                if uptodate:
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  1401
                                        self.__add_pkgs_to_lists_from_cache(authority, 
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  1402
                                            application_list, category_list, 
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  1403
                                            section_list)
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  1404
                        except UnpicklingError:
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  1405
                                #Most likely cache is corrupted, silently load list from api.
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  1406
                                #raise
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  1407
                                application_list = self.__get_new_application_liststore()
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  1408
                                category_list = self.__get_new_category_liststore()
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  1409
                                uptodate = False
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  1410
                        if not uptodate:
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  1411
                                if first_loop == True:
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  1412
                                        first_loop = False
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  1413
                                        gobject.idle_add(self.setup_progressdialog_show)
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  1414
                                self.api_o.img.load_catalogs(self.pr)
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  1415
                                self.__add_pkgs_to_lists_from_api(authority, application_list, 
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  1416
                                    category_list, section_list)
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  1417
                                category_list.prepend([0, _('All'), None, None, False, 
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  1418
                                    True, None])
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  1419
                        if self.application_list and self.category_list and \
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  1420
                            not self.visible_repository_uptodate:
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  1421
                                self.__dump_datamodels(self.visible_repository, 
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  1422
                                    self.application_list, self.category_list,
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  1423
                                    self.section_list)
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  1424
                        self.visible_repository = self.__get_active_authority()
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  1425
                        self.visible_repository_uptodate = uptodate
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  1426
                return application_list, category_list, section_list
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1427
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  1428
        def __check_if_cache_uptodate(self, authority):
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  1429
                if self.cache_o:
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  1430
                        return self.cache_o.check_if_cache_uptodate(authority)
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  1431
                return False
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  1432
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  1433
        def __dump_datamodels(self, authority, application_list, category_list,
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  1434
            section_list):
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  1435
                if self.cache_o:
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  1436
                        Thread(target = self.cache_o.dump_datamodels,
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  1437
                            args = (authority, application_list, category_list,
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  1438
                            section_list)).start()
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  1439
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1440
        def __on_install_update(self, widget):
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1441
                self.api_o.reset()
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  1442
                install_update = []
816
5d4f7746a490 3978 Selecting package rows should check the package row as well
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 815
diff changeset
  1443
                if self.selected == 0:
5d4f7746a490 3978 Selecting package rows should check the package row as well
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 815
diff changeset
  1444
                        model, itr = self.package_selection.get_selected()
5d4f7746a490 3978 Selecting package rows should check the package row as well
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 815
diff changeset
  1445
                        if itr:
5d4f7746a490 3978 Selecting package rows should check the package row as well
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 815
diff changeset
  1446
                                install_update.append(
5d4f7746a490 3978 Selecting package rows should check the package row as well
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 815
diff changeset
  1447
                                    model.get_value(itr, enumerations.STEM_COLUMN))
5d4f7746a490 3978 Selecting package rows should check the package row as well
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 815
diff changeset
  1448
                else:
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1449
                        for authority in self.selected_pkgs:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1450
                                pkgs = self.selected_pkgs.get(authority)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1451
                                for pkg_stem in pkgs:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1452
                                        status = pkgs.get(pkg_stem)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1453
                                        if status == enumerations.NOT_INSTALLED or \
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1454
                                            status == enumerations.UPDATABLE:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1455
                                                install_update.append(pkg_stem)
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  1456
                installupdate.InstallUpdate(install_update, self, \
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1457
                    self.api_o, ips_update = False, \
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  1458
                    action = enumerations.INSTALL_UPDATE)
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1459
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1460
        def __on_update_all(self, widget):
823
0db1bfc6d455 4848 PM fails with a blank error message
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 821
diff changeset
  1461
                self.api_o.reset()
0db1bfc6d455 4848 PM fails with a blank error message
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 821
diff changeset
  1462
                installupdate.InstallUpdate([], self,
0db1bfc6d455 4848 PM fails with a blank error message
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 821
diff changeset
  1463
                    self.api_o, ips_update = False,
869
0197953cd88a 5398 UM not following steps consistently
Padraig O'Briain <padraig.obriain@sun.com>
parents: 868
diff changeset
  1464
                    action = enumerations.IMAGE_UPDATE, be_name = self.ua_be_name,
0197953cd88a 5398 UM not following steps consistently
Padraig O'Briain <padraig.obriain@sun.com>
parents: 868
diff changeset
  1465
                    parent_name = _("Package Manager"),
0197953cd88a 5398 UM not following steps consistently
Padraig O'Briain <padraig.obriain@sun.com>
parents: 868
diff changeset
  1466
                    pkg_list = ["SUNWipkg", "SUNWipkg-gui"],
0197953cd88a 5398 UM not following steps consistently
Padraig O'Briain <padraig.obriain@sun.com>
parents: 868
diff changeset
  1467
                    main_window = self.w_main_window)
823
0db1bfc6d455 4848 PM fails with a blank error message
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 821
diff changeset
  1468
                return
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1469
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1470
        def __on_help_about(self, widget):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1471
                wTreePlan = gtk.glade.XML(self.gladefile, "aboutdialog") 
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1472
                aboutdialog = wTreePlan.get_widget("aboutdialog")
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1473
                aboutdialog.connect("response", lambda x = None, \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1474
                    y = None: aboutdialog.destroy())
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1475
                aboutdialog.run()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1476
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  1477
        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
  1478
                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
  1479
                            '/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
  1480
                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
  1481
                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
  1482
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1483
        def __on_remove(self, widget):
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1484
                self.api_o.reset()
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  1485
                remove_list = []
816
5d4f7746a490 3978 Selecting package rows should check the package row as well
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 815
diff changeset
  1486
                if self.selected == 0:
5d4f7746a490 3978 Selecting package rows should check the package row as well
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 815
diff changeset
  1487
                        model, itr = self.package_selection.get_selected()
5d4f7746a490 3978 Selecting package rows should check the package row as well
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 815
diff changeset
  1488
                        if itr:
5d4f7746a490 3978 Selecting package rows should check the package row as well
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 815
diff changeset
  1489
                                remove_list.append(
5d4f7746a490 3978 Selecting package rows should check the package row as well
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 815
diff changeset
  1490
                                    model.get_value(itr, enumerations.STEM_COLUMN))
5d4f7746a490 3978 Selecting package rows should check the package row as well
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 815
diff changeset
  1491
                else:
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1492
                        for authority in self.selected_pkgs:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1493
                                pkgs = self.selected_pkgs.get(authority)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1494
                                for pkg_stem in pkgs:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1495
                                        status = pkgs.get(pkg_stem)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1496
                                        if status == enumerations.INSTALLED or \
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1497
                                            status == enumerations.UPDATABLE:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1498
                                                remove_list.append(pkg_stem)
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  1499
                installupdate.InstallUpdate(remove_list, self,
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  1500
                    self.api_o, ips_update = False,
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  1501
                    action = enumerations.REMOVE)
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1502
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1503
        def __on_reload(self, widget):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1504
                if self.description_thread_running:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1505
                        self.cancelled = True
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  1506
                self.in_setup = True
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  1507
                self.w_progress_dialog.set_title(_("Refreshing catalogs"))
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  1508
                self.w_progressinfo_label.set_text(_("Refreshing catalogs..."))
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  1509
                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
  1510
                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
  1511
                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
  1512
                self.__disconnect_models()
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  1513
                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
  1514
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  1515
        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
  1516
                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
  1517
                #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
  1518
                #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
  1519
                time.sleep(0.2)
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1520
                self.process_package_list_start(self.image_directory)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1521
                self.__enable_disable_selection_menus()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1522
                self.update_statusbar()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1523
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1524
        def __clipboard_text_received(self, clipboard, text, data):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1525
                self.main_clipboard_text = text
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1526
                return
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1527
823
0db1bfc6d455 4848 PM fails with a blank error message
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 821
diff changeset
  1528
        def __main_application_quit(self, be_name = None):
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1529
                '''quits the main gtk loop'''
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1530
                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
  1531
                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
  1532
                        return
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  1533
                        
823
0db1bfc6d455 4848 PM fails with a blank error message
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 821
diff changeset
  1534
                if be_name:
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  1535
                        if self.image_dir_arg:
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  1536
                                gobject.spawn_async([self.application_path, "-R",
823
0db1bfc6d455 4848 PM fails with a blank error message
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 821
diff changeset
  1537
                                    self.image_dir_arg, "-U", be_name])
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1538
                        else:
864
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
  1539
                                gobject.spawn_async([self.application_path, 
590c24c40a56 6202 All category does not report updates available.
Padraig O'Briain <padraig.obriain@sun.com>
parents: 863
diff changeset
  1540
                                    "-U", be_name])
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  1541
                else:
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  1542
                        visible_repository = self.__get_visible_repository_name()
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  1543
                        self.__dump_datamodels(visible_repository, 
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  1544
                                self.application_list, self.category_list, 
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  1545
                                self.section_list)
796
bcd90655ad83 4019 Package Manager close bug
Padraig O'Briain <padraig.obriain@sun.com>
parents: 795
diff changeset
  1546
                self.w_main_window.hide()
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  1547
                while gtk.events_pending():
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  1548
                        gtk.main_iteration(False)
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1549
                gtk.main_quit()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1550
                sys.exit(0)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1551
                return True
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1552
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1553
        def __check_if_something_was_changed(self):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1554
                ''' 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
  1555
                if not'''
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1556
                for pkg in self.application_list:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1557
                        if pkg[enumerations.MARK_COLUMN] == True:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1558
                                return True
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1559
                return False
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1560
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1561
        def __setup_repositories_combobox(self, api_o, repositories_list):
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1562
                img = api_o.img
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1563
                if img == None:
500
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  1564
                        return
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1565
                self.__disconnect_repository_model()
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1566
                img.load_config()
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1567
                auths = img.gen_authorities()
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1568
                default_auth = img.get_default_authority()
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1569
                if self.default_authority != default_auth:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1570
                        self.__clear_pkg_selections()
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1571
                        self.default_authority = default_auth
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1572
                selected_repos = []
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1573
                enabled_repos = []
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1574
                for repo in self.selected_pkgs:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1575
                        selected_repos.append(repo)
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  1576
                i = 0
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  1577
                active = 0
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1578
                for repo in auths:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1579
                        prefix = repo.get("prefix")
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1580
                        if cmp(prefix, self.default_authority) == 0:
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  1581
                                active = i
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1582
                        repositories_list.append([i, prefix, ])
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1583
                        enabled_repos.append(prefix)
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  1584
                        i = i + 1
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1585
                pkgs_to_remove = []
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1586
                for repo_name in selected_repos:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1587
                        if repo_name not in enabled_repos:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1588
                                pkg_stems = self.selected_pkgs.get(repo_name)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1589
                                for pkg_stem in pkg_stems:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1590
                                        pkgs_to_remove.append(pkg_stem)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1591
                for pkg_stem in pkgs_to_remove:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1592
                        self.__remove_pkg_stem_from_list(pkg_stem)
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  1593
                self.w_repository_combobox.set_model(repositories_list)
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1594
                if self.default_authority:
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1595
                        self.w_repository_combobox.set_active(active)
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  1596
                else:
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1597
                        self.w_repository_combobox.set_active(0)
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  1598
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1599
        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
  1600
                '''Toggle function for column enumerations.MARK_COLUMN'''
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  1601
                applicationModel = model_sort.get_model()
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  1602
                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
  1603
                filterModel = applicationModel.get_model()
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  1604
                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
  1605
                itr = filterModel.get_iter(child_path)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1606
                if itr:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1607
                        modified = filterModel.get_value(itr, enumerations.MARK_COLUMN)
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  1608
                        filterModel.set_value(itr, enumerations.MARK_COLUMN,
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1609
                            not modified)
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  1610
                        pkg_status = filterModel.get_value(itr,
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  1611
                            enumerations.STATUS_COLUMN)
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1612
                        pkg_stem = filterModel.get_value(itr, enumerations.STEM_COLUMN)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1613
                        if modified:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1614
                                self.__remove_pkg_stem_from_list(pkg_stem)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1615
                        else:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1616
                                self.__add_pkg_stem_to_list(pkg_stem, pkg_status)
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  1617
                        self.update_statusbar()
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1618
                        self.__enable_disable_selection_menus()
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  1619
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1620
        def __update_reload_button(self):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1621
                if self.user_rights:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1622
                        self.w_reload_button.set_sensitive(True)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1623
                else:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1624
                        self.w_reload_button.set_sensitive(False)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1625
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1626
        def __add_pkg_stem_to_list(self, stem, status):
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1627
                authority = self.__get_active_authority()
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1628
                if self.selected_pkgs.get(authority) == None:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1629
                        self.selected_pkgs[authority] = {}
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1630
                self.selected_pkgs.get(authority)[stem] = status
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1631
                if status == enumerations.NOT_INSTALLED or \
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1632
                    status == enumerations.UPDATABLE:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1633
                        if self.to_install_update.get(authority) == None:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1634
                                self.to_install_update[authority] = 1
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1635
                        else:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1636
                                self.to_install_update[authority] += 1
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1637
                if status == enumerations.UPDATABLE or status == enumerations.INSTALLED:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1638
                        if self.to_remove.get(authority) == None:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1639
                                self.to_remove[authority] = 1
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1640
                        else:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1641
                                self.to_remove[authority] += 1
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1642
                self.__update_tooltips()
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1643
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1644
        def __update_tooltips(self):
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1645
                to_remove = None
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1646
                to_install = None
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1647
                no_iter = 0
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1648
                for authority in self.to_remove:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1649
                        packages = self.to_remove.get(authority)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1650
                        if packages > 0:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1651
                                if no_iter == 0:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1652
                                        to_remove = _("Selected for Removal:")
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1653
                                to_remove += "\n   %s: %d" % (authority, packages)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1654
                                no_iter += 1
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1655
                no_iter = 0
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1656
                for authority in self.to_install_update:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1657
                        packages = self.to_install_update.get(authority)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1658
                        if packages > 0:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1659
                                if no_iter == 0:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1660
                                        to_install = _("Selected for Install/Update:")
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1661
                                to_install += "\n   %s: %d" % (authority, packages)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1662
                                no_iter += 1
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1663
                if not to_install:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1664
                        to_install = _("Select packages by marking checkbox\n"+
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1665
                            "and click to Install/Update.")
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1666
                self.w_installupdate_button.set_tooltip(self.install_button_tooltip, 
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1667
                    to_install)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1668
                if not to_remove:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1669
                        to_remove = _("Select packages by marking checkbox\n"+
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1670
                            "and click to Remove selected.")
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1671
                self.w_remove_button.set_tooltip(self.remove_button_tooltip, to_remove)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1672
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1673
        def __remove_pkg_stem_from_list(self, stem):
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1674
                remove_auth = []
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1675
                for authority in self.selected_pkgs:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1676
                        pkgs = self.selected_pkgs.get(authority)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1677
                        status = None
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1678
                        if stem in pkgs:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1679
                                status = pkgs.pop(stem)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1680
                        if status == enumerations.NOT_INSTALLED or \
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1681
                            status == enumerations.UPDATABLE:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1682
                                if self.to_install_update.get(authority) == None:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1683
                                        self.to_install_update[authority] = 0
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1684
                                else:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1685
                                        self.to_install_update[authority] -= 1
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1686
                        if status == enumerations.UPDATABLE or \
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1687
                            status == enumerations.INSTALLED:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1688
                                if self.to_remove.get(authority) == None:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1689
                                        self.to_remove[authority] = 0
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1690
                                else:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1691
                                        self.to_remove[authority] -= 1
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1692
                        if len(pkgs) == 0:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1693
                                remove_auth.append(authority)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1694
                for authority in remove_auth:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1695
                        self.selected_pkgs.pop(authority)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1696
                self.__update_tooltips()
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1697
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1698
        def __clear_pkg_selections(self):
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1699
                # We clear the selections as the preffered repository was changed
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1700
                # and pkg stems are not valid.
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1701
                remove_auth = []
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1702
                for authority in self.selected_pkgs:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1703
                        stems = self.selected_pkgs.get(authority)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1704
                        for pkg_stem in stems:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1705
                                remove_auth.append(pkg_stem)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1706
                for pkg_stem in remove_auth:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1707
                        self.__remove_pkg_stem_from_list(pkg_stem)
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  1708
815
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1709
        def __show_fetching_package_info(self, pkg):
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1710
                pkg_name = pkg.get_name()
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1711
                self.w_packagename_label.set_markup("<b>" + pkg_name + "</b>")
815
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1712
                self.w_general_info_label.set_markup("<b>" + pkg_name + "</b>")
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  1713
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  1714
                pkg_stem = pkg.get_pkg_stem()                
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  1715
                if self.__setting_from_cache(pkg_stem):
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1716
                        return
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1717
                        
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  1718
                self.w_shortdescription_label.set_text(
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  1719
                    _("Fetching description..."))
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1720
                instbuffer = self.w_installedfiles_textview.get_buffer()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1721
                depbuffer = self.w_dependencies_textview.get_buffer()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1722
                infobuffer = self.w_generalinfo_textview.get_buffer()
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  1723
                fetching_text = _("Fetching information...")
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  1724
                instbuffer.set_text(fetching_text)
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  1725
                depbuffer.set_text(fetching_text)
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  1726
                infobuffer.set_text(fetching_text)
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1727
                return
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1728
                
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  1729
        def __setting_from_cache(self, pkg_stem):
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1730
                if len(self.info_cache) > MAX_INFO_CACHE_LIMIT:
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1731
                        self.info_cache = {}
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1732
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  1733
                if self.info_cache.has_key(pkg_stem):
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  1734
                        self.w_shortdescription_label.set_text(
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  1735
                            self.info_cache[pkg_stem][0])
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1736
                        instbuffer = self.w_installedfiles_textview.get_buffer()
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1737
                        depbuffer = self.w_dependencies_textview.get_buffer()
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1738
                        infobuffer = self.w_generalinfo_textview.get_buffer()
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  1739
                        infobuffer.set_text(self.info_cache[pkg_stem][1])
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  1740
                        instbuffer.set_text(self.info_cache[pkg_stem][2])
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  1741
                        depbuffer.set_text(self.info_cache[pkg_stem][3])
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1742
                        return True
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1743
                else:
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1744
                        return False
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1745
                
815
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1746
        def __update_package_info(self, pkg, local_info, remote_info):
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1747
                pkg_name = pkg.get_name()
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  1748
                pkg_stem = pkg.get_pkg_stem()
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1749
                self.w_packagename_label.set_markup("<b>" + pkg_name + "</b>")
815
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1750
                self.w_general_info_label.set_markup("<b>" + pkg_name + "</b>")
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1751
                installed = True
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1752
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  1753
                if self.__setting_from_cache(pkg_stem):
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  1754
                        return
815
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1755
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1756
                instbuffer = self.w_installedfiles_textview.get_buffer()
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1757
                depbuffer = self.w_dependencies_textview.get_buffer()
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1758
                infobuffer = self.w_generalinfo_textview.get_buffer()
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1759
815
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1760
                if not local_info and not remote_info:
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  1761
                        self.w_shortdescription_label.set_text(
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  1762
                            _("Description not available for this package..."))
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1763
                        instbuffer.set_text( \
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  1764
                            _("Files Details not available for this package..."))
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  1765
                        depbuffer.set_text(_(
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1766
                            "Dependencies info not available for this package..."))
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  1767
                        infobuffer.set_text(
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  1768
                            _("Information not available for this package..."))
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  1769
                        return
815
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1770
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1771
                if not local_info:
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1772
                        # Package is not installed
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1773
                        local_info = remote_info
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1774
                        installed = False
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1775
823
0db1bfc6d455 4848 PM fails with a blank error message
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 821
diff changeset
  1776
                if not remote_info:
0db1bfc6d455 4848 PM fails with a blank error message
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 821
diff changeset
  1777
                        remote_info = local_info
0db1bfc6d455 4848 PM fails with a blank error message
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 821
diff changeset
  1778
                        installed = True
0db1bfc6d455 4848 PM fails with a blank error message
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 821
diff changeset
  1779
815
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1780
                description = local_info.summary
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1781
                #XXX long term need to have something more robust here for multi byte
602
cd5a41269b1e 3911 menu item, dialog header 'Manage Repositories'
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 594
diff changeset
  1782
                if len(description) > MAX_DESC_LEN:
cd5a41269b1e 3911 menu item, dialog header 'Manage Repositories'
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 594
diff changeset
  1783
                        description = description[:MAX_DESC_LEN] + " ..."
cd5a41269b1e 3911 menu item, dialog header 'Manage Repositories'
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 594
diff changeset
  1784
                self.w_shortdescription_label.set_text(description)
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  1785
                inst_str = _("Root: %s\n") % self.api_o.img.get_root()
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  1786
                dep_str = _("Dependencies:\n")
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1787
815
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1788
                if local_info.dependencies:
866
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
  1789
                        dep_str += ''.join(
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
  1790
                            ["\t%s\n" % x for x in local_info.dependencies])
815
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1791
                if local_info.dirs:
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1792
                        inst_str += ''.join(["\t%s\n" % x for x in local_info.dirs])
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1793
                if local_info.files:
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1794
                        inst_str += ''.join(["\t%s\n" % x for x in local_info.files])
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1795
                if local_info.hardlinks:
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1796
                        inst_str += ''.join(["\t%s\n" % x for x in local_info.hardlinks])
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1797
                if local_info.links:
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1798
                        inst_str += ''.join(["\t%s\n" % x for x in local_info.links])
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1799
                info_str = ""
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1800
                labs = {}
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1801
                labs["sum"] = _("Summary:\t\t")
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1802
                labs["size"] = _("Size:\t\t\t")
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1803
                labs["cat"] = _("Category:\t\t")
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1804
                labs["ins"] = _("Installed Version:\t")
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1805
                labs["lat"] = ("Latest Version:\t")
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1806
                labs["pkg_date"] = _("Packaging Date:\t")
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1807
                labs["fmri"] = _("FMRI:\t\t\t")
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1808
                max_len = 0
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1809
                for lab in labs:
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1810
                        if len(labs[lab]) > max_len:
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1811
                                max_len = len(labs[lab])
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1812
                categories = _("None")
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1813
                if local_info.category_info_list:
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1814
                        verbose = len(local_info.category_info_list) > 1
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1815
                        categories = ""
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1816
                        categories += local_info.category_info_list[0].__str__(verbose)
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1817
                        if len(local_info.category_info_list) > 1:
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1818
                                for ci in local_info.category_info_list[1:]:
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1819
                                        categories += ", " + ci.__str__(verbose)
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1820
                summary = _("None")
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1821
                if local_info.summary:
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1822
                        summary = local_info.summary
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1823
                info_str += "  %s %s" % (labs["sum"], summary)
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1824
                info_str += "\n  %s %s" % (labs["size"], 
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1825
                    misc.bytes_to_str(local_info.size))
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1826
                info_str += "\n  %s %s" % (labs["cat"], categories)
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  1827
                if installed:
815
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1828
                        info_str += "\n  %s %s,%s-%s" % (labs["ins"], local_info.version,
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1829
                            local_info.build_release, local_info.branch)
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1830
                info_str += "\n  %s %s,%s-%s" % (labs["lat"], remote_info.version,
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1831
                    remote_info.build_release, remote_info.branch)
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1832
                info_str += "\n  %s %s" % (labs["pkg_date"], local_info.packaging_date)
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1833
                info_str += "\n  %s %s" % (labs["fmri"], local_info.fmri)
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1834
                infobuffer.set_text(info_str)
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1835
                instbuffer.set_text(inst_str)
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1836
                depbuffer.set_text(dep_str)
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  1837
                self.info_cache[pkg_stem] = \
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  1838
                    (description, info_str, inst_str, dep_str)
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1839
                
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  1840
        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
  1841
                lic = ""
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  1842
                lic_u = ""
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1843
                if licenses == None:
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  1844
                        lic_u = _("Not available")
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1845
                else:
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1846
                        for licens in licenses:
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1847
                                lic += licens.get_text()
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1848
                                lic += "\n"
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1849
                        try:
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1850
                                lic_u = unicode(lic, "utf-8")
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1851
                        except UnicodeDecodeError:
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1852
                                lic_u += ""
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  1853
                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
  1854
                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
  1855
865
81af5326a965 6239 time.sleep() should not be called when getting package info
Padraig O'Briain <padraig.obriain@sun.com>
parents: 864
diff changeset
  1856
        def __show_licenses(self):
81af5326a965 6239 time.sleep() should not be called when getting package info
Padraig O'Briain <padraig.obriain@sun.com>
parents: 864
diff changeset
  1857
                self.show_licenses_id = 0
81af5326a965 6239 time.sleep() should not be called when getting package info
Padraig O'Briain <padraig.obriain@sun.com>
parents: 864
diff changeset
  1858
                Thread(target = self.__show_package_licenses).start()
81af5326a965 6239 time.sleep() should not be called when getting package info
Padraig O'Briain <padraig.obriain@sun.com>
parents: 864
diff changeset
  1859
81af5326a965 6239 time.sleep() should not be called when getting package info
Padraig O'Briain <padraig.obriain@sun.com>
parents: 864
diff changeset
  1860
        def __show_package_licenses(self):
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1861
                if self.selected_pkgname == None:
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  1862
                        gobject.idle_add(self.__update_package_license, None)
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1863
                        return
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1864
                info = self.api_o.info([self.selected_pkgname], True, True)
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  1865
                pkgs_info = None
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  1866
                package_info = None
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  1867
                no_licenses = 0
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  1868
                if info:
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  1869
                        pkgs_info = info[0]
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  1870
                if pkgs_info:
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  1871
                        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
  1872
                if package_info:
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  1873
                        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
  1874
                if no_licenses == 0:
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  1875
                        gobject.idle_add(self.__update_package_license, None)
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  1876
                        return
865
81af5326a965 6239 time.sleep() should not be called when getting package info
Padraig O'Briain <padraig.obriain@sun.com>
parents: 864
diff changeset
  1877
                else:
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  1878
                        gobject.idle_add(self.__update_package_license,
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  1879
                            package_info.licenses)
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  1880
815
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1881
        def __get_pkg_info(self, pkg_name, local):
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1882
                info = self.api_o.info([pkg_name], local, get_licenses=False,
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  1883
                    get_action_info=True)
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1884
                pkgs_info = None
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1885
                package_info = None
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1886
                if info:
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1887
                        pkgs_info = info[0]
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1888
                if pkgs_info:
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1889
                        package_info = pkgs_info[0]
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1890
                if package_info:
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1891
                        return package_info
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1892
                else:
865
81af5326a965 6239 time.sleep() should not be called when getting package info
Padraig O'Briain <padraig.obriain@sun.com>
parents: 864
diff changeset
  1893
                        return None
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1894
865
81af5326a965 6239 time.sleep() should not be called when getting package info
Padraig O'Briain <padraig.obriain@sun.com>
parents: 864
diff changeset
  1895
        def __show_info(self, model, path):
81af5326a965 6239 time.sleep() should not be called when getting package info
Padraig O'Briain <padraig.obriain@sun.com>
parents: 864
diff changeset
  1896
                self.show_info_id = 0
81af5326a965 6239 time.sleep() should not be called when getting package info
Padraig O'Briain <padraig.obriain@sun.com>
parents: 864
diff changeset
  1897
                Thread(target = self.__show_package_info,
81af5326a965 6239 time.sleep() should not be called when getting package info
Padraig O'Briain <padraig.obriain@sun.com>
parents: 864
diff changeset
  1898
                    args = (model, path)).start()
81af5326a965 6239 time.sleep() should not be called when getting package info
Padraig O'Briain <padraig.obriain@sun.com>
parents: 864
diff changeset
  1899
81af5326a965 6239 time.sleep() should not be called when getting package info
Padraig O'Briain <padraig.obriain@sun.com>
parents: 864
diff changeset
  1900
        def __show_package_info(self, model, path):
81af5326a965 6239 time.sleep() should not be called when getting package info
Padraig O'Briain <padraig.obriain@sun.com>
parents: 864
diff changeset
  1901
                itr = model.get_iter(path)
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  1902
                pkg = model.get_value(itr, enumerations.FMRI_COLUMN)
815
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1903
                pkg_stem = model.get_value(itr, enumerations.STEM_COLUMN)
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1904
                pkg_status = model.get_value(itr, enumerations.STATUS_COLUMN)
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1905
                if self.info_cache.has_key(pkg_stem):
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1906
                        return
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1907
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  1908
                img = self.api_o.img
556
1c3526ca7b9e 2022 client should provide operational intent to server
Shawn Walker <shawn.walker@sun.com>
parents: 543
diff changeset
  1909
                img.history.operation_name = "info"
815
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1910
                local_info = None
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1911
                remote_info = None
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1912
                if pkg_status == enumerations.INSTALLED or pkg_status == \
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1913
                    enumerations.UPDATABLE:
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1914
                        local_info = self.__get_pkg_info(pkg.get_name(), True)
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1915
                if pkg_status == enumerations.NOT_INSTALLED or pkg_status == \
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1916
                    enumerations.UPDATABLE:
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1917
                        remote_info = self.__get_pkg_info(pkg.get_name(), False)
865
81af5326a965 6239 time.sleep() should not be called when getting package info
Padraig O'Briain <padraig.obriain@sun.com>
parents: 864
diff changeset
  1918
                gobject.idle_add(self.__update_package_info, pkg, 
81af5326a965 6239 time.sleep() should not be called when getting package info
Padraig O'Briain <padraig.obriain@sun.com>
parents: 864
diff changeset
  1919
                    local_info, remote_info)
815
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1920
                img.history.operation_result = history.RESULT_SUCCEEDED
3ffb48a98485 5665 pkg manager "general info" not nearly as good as "pkg info"
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 808
diff changeset
  1921
                return
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1922
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1923
        # This function is ported from pkg.actions.generic.distinguished_name()
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  1924
        @staticmethod
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  1925
        def __locale_distinguished_name(action):
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1926
                if action.key_attr == None:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1927
                        return str(action)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1928
                return "%s: %s" % \
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  1929
                    (_(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
  1930
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1931
        def __application_filter(self, model, itr):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1932
                '''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
  1933
                application view'''
500
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  1934
                if self.in_setup or self.cancelled:
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1935
                        return False
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1936
                # 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
  1937
                selected_category = 0
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1938
                category_selection = self.w_categories_treeview.get_selection()
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1939
                category_model, category_iter = category_selection.get_selected()
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1940
                if category_iter:
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1941
                        selected_category = category_model.get_value(category_iter,
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1942
                            enumerations.CATEGORY_ID)
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1943
                category_list = model.get_value(itr, enumerations.CATEGORY_LIST_COLUMN)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1944
                selected_section = self.w_sections_combobox.get_active()
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1945
                category = False
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1946
                if selected_section == 0 and selected_category == 0:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1947
                        #For section "All" and category "All" always true
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1948
                        category = True
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1949
                elif selected_category != 0:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1950
                        if category_list and selected_category in category_list:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1951
                                category = True
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1952
                elif category_list:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1953
                        #The selected category is "All" so we need to check
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1954
                        #If the package belongs to one of the visible categories
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1955
                        for visible_category in self.w_categories_treeview.get_model():
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1956
                                visible_id = visible_category[enumerations.CATEGORY_ID]
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1957
                                if visible_id in category_list:
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1958
                                        category = True
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1959
                                        break
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1960
                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
  1961
                        return False
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1962
                if self.w_searchentry_dialog.get_text() == "":
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1963
                        return (category &
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1964
                            self.__is_package_filtered(model, itr))
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1965
                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
  1966
                        if self.w_searchentry_dialog.get_text().lower() in \
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1967
                            model.get_value(itr, enumerations.NAME_COLUMN).lower():
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1968
                                return (category &
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1969
                                    self.__is_package_filtered(model, itr))
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1970
                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
  1971
                        if self.w_searchentry_dialog.get_text().lower() in \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1972
                            model.get_value \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1973
                            (itr, enumerations.DESCRIPTION_COLUMN).lower():
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  1974
                                return (category &
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1975
                                    self.__is_package_filtered(model, itr))
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1976
                else:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1977
                        return False
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  1978
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1979
        def __is_package_filtered(self, model, itr):
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  1980
                '''Function for filtercombobox'''
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  1981
                # 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
  1982
                # 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
  1983
                filter_text = self.w_filter_combobox.get_active()
457
9ee1bf88afb2 1905 GUI package manager slow responsiveness
John.Rice@Sun.COM
parents: 450
diff changeset
  1984
                if filter_text == 0:
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  1985
                        return True
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  1986
                status = model.get_value(itr, enumerations.STATUS_COLUMN)
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  1987
                if filter_text == 2:
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  1988
                        return (status == enumerations.INSTALLED or status == \
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  1989
                            enumerations.UPDATABLE)
457
9ee1bf88afb2 1905 GUI package manager slow responsiveness
John.Rice@Sun.COM
parents: 450
diff changeset
  1990
                elif filter_text == 3:
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  1991
                        return status == enumerations.UPDATABLE
457
9ee1bf88afb2 1905 GUI package manager slow responsiveness
John.Rice@Sun.COM
parents: 450
diff changeset
  1992
                elif filter_text == 4:
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  1993
                        return status == enumerations.NOT_INSTALLED
457
9ee1bf88afb2 1905 GUI package manager slow responsiveness
John.Rice@Sun.COM
parents: 450
diff changeset
  1994
                elif filter_text == 6:
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  1995
                        return model.get_value(itr, enumerations.MARK_COLUMN)
457
9ee1bf88afb2 1905 GUI package manager slow responsiveness
John.Rice@Sun.COM
parents: 450
diff changeset
  1996
                elif filter_text == 8:
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  1997
                        # XXX Locked support
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  1998
                        return False
457
9ee1bf88afb2 1905 GUI package manager slow responsiveness
John.Rice@Sun.COM
parents: 450
diff changeset
  1999
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2000
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2001
        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
  2002
                if len(self.repositories_list) <= 1:
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2003
                        return True
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2004
                else:
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  2005
                        visible_repository = self.__get_visible_repository_name()
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2006
                        pkg = model.get_value(itr, enumerations.FMRI_COLUMN)
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2007
                        if not pkg:
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2008
                                return False
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  2009
                        if cmp(pkg.get_authority(), visible_repository) == 0:
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2010
                                return True
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2011
                        else:
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2012
                                return False
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2013
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  2014
        def __get_visible_repository_name(self):
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  2015
                auth_iter = self.w_repository_combobox.get_active_iter()
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  2016
                visible = self.repositories_list.get_value(auth_iter, \
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  2017
                    enumerations.REPOSITORY_NAME)
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  2018
                return visible
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  2019
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2020
        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
  2021
                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
  2022
                        return
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2023
                self.__enable_disable_select_all()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2024
                self.__enable_disable_select_updates()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2025
                self.__enable_disable_deselect()
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2026
                self.unset_busy_cursor()
457
9ee1bf88afb2 1905 GUI package manager slow responsiveness
John.Rice@Sun.COM
parents: 450
diff changeset
  2027
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2028
        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
  2029
                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
  2030
                        return
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2031
                if len(self.w_application_treeview.get_model()) > 0:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2032
                        for row in self.w_application_treeview.get_model():
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2033
                                if not row[enumerations.MARK_COLUMN]:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2034
                                        self.w_selectall_menuitem.set_sensitive(True)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2035
                                        return
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2036
                        self.w_selectall_menuitem.set_sensitive(False)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2037
                else:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2038
                        self.w_selectall_menuitem.set_sensitive(False)
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2039
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2040
        def __enable_disable_install_remove(self):
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2041
                if not self.user_rights:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2042
                        self.w_installupdate_button.set_sensitive(False)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2043
                        self.w_installupdate_menuitem.set_sensitive(False)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2044
                        self.w_remove_button.set_sensitive(False)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2045
                        self.w_remove_menuitem.set_sensitive(False)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2046
                        return
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2047
                selected_removal = self.__enable_if_selected_for_removal()
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2048
                selected_install_update = self.__enable_if_selected_for_install_update()
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2049
                if selected_removal or selected_install_update:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2050
                        return
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2051
                remove = False
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2052
                install = False
816
5d4f7746a490 3978 Selecting package rows should check the package row as well
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 815
diff changeset
  2053
                if self.selected == 0:
5d4f7746a490 3978 Selecting package rows should check the package row as well
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 815
diff changeset
  2054
                        model, itr = self.package_selection.get_selected()
5d4f7746a490 3978 Selecting package rows should check the package row as well
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 815
diff changeset
  2055
                        if itr:
5d4f7746a490 3978 Selecting package rows should check the package row as well
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 815
diff changeset
  2056
                                status = \
5d4f7746a490 3978 Selecting package rows should check the package row as well
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 815
diff changeset
  2057
                                       model.get_value(itr, enumerations.STATUS_COLUMN)
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2058
                                if status == enumerations.NOT_INSTALLED:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2059
                                        remove = False
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2060
                                        install = True
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2061
                                elif status == enumerations.UPDATABLE:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2062
                                        remove = True
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2063
                                        install = True
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2064
                                elif status == enumerations.INSTALLED:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2065
                                        remove = True
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2066
                                        install = False
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2067
                                self.w_installupdate_button.set_sensitive(install)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2068
                                self.w_installupdate_menuitem.set_sensitive(install)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2069
                                self.w_remove_button.set_sensitive(remove)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2070
                                self.w_remove_menuitem.set_sensitive(remove)
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2071
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2072
        def __enable_if_selected_for_removal(self):
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2073
                sensitive = False
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2074
                for authority in self.to_remove:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2075
                        selected = self.to_remove.get(authority)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2076
                        if selected > 0:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2077
                                sensitive = True
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2078
                                break
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2079
                self.w_remove_button.set_sensitive(sensitive)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2080
                self.w_remove_menuitem.set_sensitive(sensitive)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2081
                return sensitive
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2082
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2083
        def __enable_if_selected_for_install_update(self):
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2084
                sensitive = False
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2085
                for authority in self.to_install_update:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2086
                        selected = self.to_install_update.get(authority)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2087
                        if selected > 0:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2088
                                sensitive = True
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2089
                                break
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2090
                self.w_installupdate_button.set_sensitive(sensitive)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2091
                self.w_installupdate_menuitem.set_sensitive(sensitive)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2092
                return sensitive
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2093
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2094
        def __enable_disable_select_updates(self):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2095
                for row in self.w_application_treeview.get_model():
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2096
                        if row[enumerations.STATUS_COLUMN] == enumerations.UPDATABLE:
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2097
                                if not row[enumerations.MARK_COLUMN]:
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2098
                                        self.w_selectupdates_menuitem. \
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2099
                                            set_sensitive(True)
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2100
                                        return
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2101
                self.w_selectupdates_menuitem.set_sensitive(False)
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2102
                return
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2103
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2104
        def __enable_disable_update_all(self):
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2105
                #XXX Api to provide fast information if there are some updates
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2106
                #available within image
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2107
                gobject.idle_add(self.w_updateall_button.set_sensitive, False)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2108
                gobject.idle_add(self.w_updateall_menuitem.set_sensitive, False)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2109
                update_available = self.__check_if_updates_available()
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2110
                gobject.idle_add(self.__g_enable_disable_update_all, update_available)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2111
                return False
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2112
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2113
        def __check_if_updates_available(self):
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2114
                try:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2115
                        img = self.api_o.img
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2116
                        pargs = []
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2117
                        all_known = False
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2118
                        all_versions = False
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2119
                        res = misc.get_inventory_list(img, pargs,
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2120
                            all_known, all_versions)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2121
                        for pfmri, state in res:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2122
                                if state["upgradable"]:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2123
                                        return True
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2124
                except api_errors.InventoryException:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2125
                        return False
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2126
                return False
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2127
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2128
        def __g_enable_disable_update_all(self, update_available):
773
68018dae1ed4 5645 Package Manager should have busy cursor for certain actions (follow up)
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 770
diff changeset
  2129
                self.w_updateall_button.set_sensitive(update_available)
68018dae1ed4 5645 Package Manager should have busy cursor for certain actions (follow up)
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 770
diff changeset
  2130
                self.w_updateall_menuitem.set_sensitive(update_available)
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2131
                self.__enable_disable_install_remove()
823
0db1bfc6d455 4848 PM fails with a blank error message
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 821
diff changeset
  2132
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2133
        def __enable_disable_deselect(self):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2134
                for row in self.w_application_treeview.get_model():
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2135
                        if row[enumerations.MARK_COLUMN]:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2136
                                self.w_deselect_menuitem.set_sensitive(True)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2137
                                return
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2138
                self.w_deselect_menuitem.set_sensitive(False)
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2139
                return
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2140
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2141
        def __catalog_refresh(self, reload_gui=True):
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2142
                """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
  2143
                full_refresh = True
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2144
                try:
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2145
                        self.api_o.refresh(full_refresh)
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  2146
                        self.api_o.img.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
  2147
                except api_errors.UnrecognizedAuthorityException:
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2148
                        # 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
  2149
                        # We are not refrehsing specific authority
660
ea2809ad4582 4126 I10n update for IPS CLI PM and UM
John Rice <john.rice@sun.com>
parents: 653
diff changeset
  2150
                        self.__catalog_refresh_done()
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2151
                        raise
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2152
                except api_errors.PermissionsException:
714
cd9870c8faae 4987 Improve error messages for PM
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 701
diff changeset
  2153
                        #Error will already have been reported in 
cd9870c8faae 4987 Improve error messages for PM
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 701
diff changeset
  2154
                        #Manage Repository dialog
cd9870c8faae 4987 Improve error messages for PM
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 701
diff changeset
  2155
                        self.__catalog_refresh_done()
cd9870c8faae 4987 Improve error messages for PM
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 701
diff changeset
  2156
                        return -1
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2157
                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
  2158
                        total = cre.total
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2159
                        succeeded = cre.succeeded
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2160
                        ermsg = _("Network problem.\n\n")
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2161
                        ermsg += _("Details:\n")
602
cd5a41269b1e 3911 menu item, dialog header 'Manage Repositories'
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 594
diff changeset
  2162
                        ermsg += "%s/%s" % (succeeded, total) 
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2163
                        ermsg += _(" catalogs successfully updated:\n") 
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2164
                        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
  2165
                                if isinstance(err, HTTPError):
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2166
                                        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
  2167
                                            (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
  2168
                                elif isinstance(err, URLError):
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2169
                                        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
  2170
                                                ermsg += "    %s: %s\n" % \
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2171
                                                    (urlparse.urlsplit(
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2172
                                                        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
  2173
                                                    err.args[0][1])
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2174
                                        else:
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2175
                                                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
  2176
                                                    socket.timeout):
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2177
                                                        ermsg += "    %s: %s\n" % \
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2178
                                                            (auth["origin"], "timeout")
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2179
                                                else:
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2180
                                                        ermsg += "    %s: %s\n" % \
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2181
                                                            (auth["origin"], \
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2182
                                                            err.args[0][1])
714
cd9870c8faae 4987 Improve error messages for PM
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 701
diff changeset
  2183
                                elif "data" in err.__dict__ and err.data:
660
ea2809ad4582 4126 I10n update for IPS CLI PM and UM
John Rice <john.rice@sun.com>
parents: 653
diff changeset
  2184
                                        ermsg += err.data
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2185
                                else:
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2186
                                        ermsg += _("Unknown error")
660
ea2809ad4582 4126 I10n update for IPS CLI PM and UM
John Rice <john.rice@sun.com>
parents: 653
diff changeset
  2187
                                        ermsg += "\n"
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2188
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2189
                        gobject.idle_add(self.error_occured, ermsg,
714
cd9870c8faae 4987 Improve error messages for PM
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 701
diff changeset
  2190
                            None, gtk.MESSAGE_INFO)
660
ea2809ad4582 4126 I10n update for IPS CLI PM and UM
John Rice <john.rice@sun.com>
parents: 653
diff changeset
  2191
                        self.__catalog_refresh_done()
602
cd5a41269b1e 3911 menu item, dialog header 'Manage Repositories'
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 594
diff changeset
  2192
                        return -1
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2193
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2194
                except api_errors.UnrecognizedAuthorityException:
660
ea2809ad4582 4126 I10n update for IPS CLI PM and UM
John Rice <john.rice@sun.com>
parents: 653
diff changeset
  2195
                        self.__catalog_refresh_done()
ea2809ad4582 4126 I10n update for IPS CLI PM and UM
John Rice <john.rice@sun.com>
parents: 653
diff changeset
  2196
                        raise
ea2809ad4582 4126 I10n update for IPS CLI PM and UM
John Rice <john.rice@sun.com>
parents: 653
diff changeset
  2197
                except Exception:
ea2809ad4582 4126 I10n update for IPS CLI PM and UM
John Rice <john.rice@sun.com>
parents: 653
diff changeset
  2198
                        self.__catalog_refresh_done()
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2199
                        raise
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2200
                if reload_gui:
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2201
                        self.__catalog_refresh_done()
602
cd5a41269b1e 3911 menu item, dialog header 'Manage Repositories'
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 594
diff changeset
  2202
                return 0
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2203
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  2204
        def __add_pkgs_to_lists_from_cache(self, authority, application_list, 
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  2205
            category_list, section_list):
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  2206
                if self.cache_o:
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  2207
                        self.cache_o.load_application_list(authority, application_list, 
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  2208
                            self.selected_pkgs)
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  2209
                        self.cache_o.load_category_list(authority, category_list)
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  2210
                        self.cache_o.load_section_list(authority, section_list)
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2211
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  2212
        def __add_pkgs_to_lists_from_api(self, authority, application_list,
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  2213
            category_list, section_list):
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2214
                """ This method set up image from the given directory and
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  2215
                returns the image object or None"""                
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2216
                pargs = []
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2217
                pargs.append("pkg://" + authority + "/*")
526
8c243883ae41 822 Depot traceback on "pkgsend -s <server> open foo"
Dan Price <dp@eng.sun.com>
parents: 510
diff changeset
  2218
                try:
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2219
                        pkgs_known = misc.get_inventory_list(self.api_o.img, pargs, 
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2220
                            True, 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
  2221
                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
  2222
                        # 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
  2223
                        # but here for completeness.
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2224
                        err = _("Error occured while getting list of packages")
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2225
                        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
  2226
                        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
  2227
                        return
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  2228
                self.__init_sections(section_list)
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2229
                #Only one instance of those icons should be in memory
869
0197953cd88a 5398 UM not following steps consistently
Padraig O'Briain <padraig.obriain@sun.com>
parents: 868
diff changeset
  2230
                update_available_icon = gui_misc.get_icon_pixbuf(self.application_dir,
0197953cd88a 5398 UM not following steps consistently
Padraig O'Briain <padraig.obriain@sun.com>
parents: 868
diff changeset
  2231
                    "status_newupdate")
0197953cd88a 5398 UM not following steps consistently
Padraig O'Briain <padraig.obriain@sun.com>
parents: 868
diff changeset
  2232
                installed_icon = gui_misc.get_icon_pixbuf(self.application_dir,
0197953cd88a 5398 UM not following steps consistently
Padraig O'Briain <padraig.obriain@sun.com>
parents: 868
diff changeset
  2233
                    "status_installed")
827
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
  2234
                update_for_category_icon = \
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
  2235
                    self.get_icon_pixbuf_from_glade_dir("legend_newupdate")
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2236
                #Imageinfo for categories
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2237
                imginfo = imageinfo.ImageInfo()
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2238
                sectioninfo = imageinfo.ImageInfo()
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2239
                catalogs = self.api_o.img.catalogs
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2240
                categories = {}
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2241
                sections = {}
701
ba35d1b02c04 4884 Package Manager corruption?
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 697
diff changeset
  2242
                share_path = "/usr/share/package-manager/data/"
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2243
                for cat in catalogs:
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2244
                        category = imginfo.read(self.application_dir +
701
ba35d1b02c04 4884 Package Manager corruption?
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 697
diff changeset
  2245
                            share_path + cat)
ba35d1b02c04 4884 Package Manager corruption?
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 697
diff changeset
  2246
                        if len(category) == 0:
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2247
                                category = imginfo.read(self.application_dir +
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2248
                                    share_path + "opensolaris.org")
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2249
                        categories[cat] = category
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2250
                        section = sectioninfo.read(self.application_dir +
701
ba35d1b02c04 4884 Package Manager corruption?
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 697
diff changeset
  2251
                            share_path + cat + ".sections")
ba35d1b02c04 4884 Package Manager corruption?
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 697
diff changeset
  2252
                        if len(section) == 0:
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2253
                                section = sectioninfo.read(self.application_dir +
701
ba35d1b02c04 4884 Package Manager corruption?
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 697
diff changeset
  2254
                                    share_path + "opensolaris.org.sections")
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2255
                        sections[cat] = section
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2256
                icon_path = self.application_dir + \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2257
                    "/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
  2258
                pkg_count = 0
825
5d8b3ed4c293 6002 Two entries appear in packagemanager for installed package
Padraig O'Briain <padraig.obriain@sun.com>
parents: 823
diff changeset
  2259
                pkg_add = 0
500
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2260
                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
  2261
                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
  2262
                progress_increment = \
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2263
                        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
  2264
                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
  2265
                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
  2266
                        gtk.main_iteration(False)
825
5d8b3ed4c293 6002 Two entries appear in packagemanager for installed package
Padraig O'Briain <padraig.obriain@sun.com>
parents: 823
diff changeset
  2267
                prev_stem = ""
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2268
                prev_pfmri_str = ""
825
5d8b3ed4c293 6002 Two entries appear in packagemanager for installed package
Padraig O'Briain <padraig.obriain@sun.com>
parents: 823
diff changeset
  2269
                next_app = None
5d8b3ed4c293 6002 Two entries appear in packagemanager for installed package
Padraig O'Briain <padraig.obriain@sun.com>
parents: 823
diff changeset
  2270
                pkg_name = None
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2271
                prev_state = None
827
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
  2272
                category_icon = None
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2273
                for pkg, state in pkgs_known:
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2274
                        if prev_pfmri_str and \
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2275
                            prev_pfmri_str == pkg.get_short_fmri() and \
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2276
                            prev_state == state:
825
5d8b3ed4c293 6002 Two entries appear in packagemanager for installed package
Padraig O'Briain <padraig.obriain@sun.com>
parents: 823
diff changeset
  2277
                                pkg_count += 1
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2278
                                continue
825
5d8b3ed4c293 6002 Two entries appear in packagemanager for installed package
Padraig O'Briain <padraig.obriain@sun.com>
parents: 823
diff changeset
  2279
                        if prev_stem and \
5d8b3ed4c293 6002 Two entries appear in packagemanager for installed package
Padraig O'Briain <padraig.obriain@sun.com>
parents: 823
diff changeset
  2280
                            prev_stem == pkg.get_pkg_stem() and \
5d8b3ed4c293 6002 Two entries appear in packagemanager for installed package
Padraig O'Briain <padraig.obriain@sun.com>
parents: 823
diff changeset
  2281
                            prev_state["state"] == "known" and \
5d8b3ed4c293 6002 Two entries appear in packagemanager for installed package
Padraig O'Briain <padraig.obriain@sun.com>
parents: 823
diff changeset
  2282
                            state["state"] == "installed":
5d8b3ed4c293 6002 Two entries appear in packagemanager for installed package
Padraig O'Briain <padraig.obriain@sun.com>
parents: 823
diff changeset
  2283
                                pass
5d8b3ed4c293 6002 Two entries appear in packagemanager for installed package
Padraig O'Briain <padraig.obriain@sun.com>
parents: 823
diff changeset
  2284
                        elif next_app != None:
5d8b3ed4c293 6002 Two entries appear in packagemanager for installed package
Padraig O'Briain <padraig.obriain@sun.com>
parents: 823
diff changeset
  2285
                                self.__add_package_to_list(next_app, 
5d8b3ed4c293 6002 Two entries appear in packagemanager for installed package
Padraig O'Briain <padraig.obriain@sun.com>
parents: 823
diff changeset
  2286
                                    application_list,
5d8b3ed4c293 6002 Two entries appear in packagemanager for installed package
Padraig O'Briain <padraig.obriain@sun.com>
parents: 823
diff changeset
  2287
                                    pkg_add, pkg_name,
827
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
  2288
                                    category_icon,
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2289
                                    categories, category_list, authority)
825
5d8b3ed4c293 6002 Two entries appear in packagemanager for installed package
Padraig O'Briain <padraig.obriain@sun.com>
parents: 823
diff changeset
  2290
                                pkg_add += 1
5d8b3ed4c293 6002 Two entries appear in packagemanager for installed package
Padraig O'Briain <padraig.obriain@sun.com>
parents: 823
diff changeset
  2291
                        prev_stem = pkg.get_pkg_stem()
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2292
                        prev_pfmri_str = pkg.get_short_fmri()
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2293
                        prev_state = state
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2294
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2295
                        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
  2296
                                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
  2297
                                if progress_percent <= PACKAGE_PROGRESS_PERCENT_TOTAL:
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2298
                                        self.__progressdialog_progress_percent(
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2299
                                            progress_percent, 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
  2300
                                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
  2301
                                        gtk.main_iteration(False)
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2302
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2303
                        status_icon = None
827
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
  2304
                        category_icon = None
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2305
                        pkg_name = pkg.get_name()
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2306
                        pkg_stem = pkg.get_pkg_stem()
869
0197953cd88a 5398 UM not following steps consistently
Padraig O'Briain <padraig.obriain@sun.com>
parents: 868
diff changeset
  2307
                        package_icon = gui_misc.get_pixbuf_from_path(icon_path, 
0197953cd88a 5398 UM not following steps consistently
Padraig O'Briain <padraig.obriain@sun.com>
parents: 868
diff changeset
  2308
                            pkg_name) 
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2309
                        pkg_state = enumerations.NOT_INSTALLED
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2310
                        if state["state"] == "installed":
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2311
                                pkg_state = enumerations.INSTALLED
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2312
                                if state["upgradable"] == True:
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2313
                                        status_icon = update_available_icon
827
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
  2314
                                        category_icon = update_for_category_icon
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2315
                                        pkg_state = enumerations.UPDATABLE
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2316
                                else:
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2317
                                        status_icon = installed_icon
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2318
                        marked = False
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2319
                        authority = self.__get_active_authority()
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2320
                        pkgs = self.selected_pkgs.get(authority)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2321
                        if pkgs != None:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2322
                                if pkg_stem in pkgs:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2323
                                        marked = True
825
5d8b3ed4c293 6002 Two entries appear in packagemanager for installed package
Padraig O'Briain <padraig.obriain@sun.com>
parents: 823
diff changeset
  2324
                        next_app = \
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2325
                            [
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2326
                                marked, status_icon, package_icon, pkg_name,
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2327
                                '...', pkg_state, pkg, pkg_stem, None, True, None
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2328
                            ]
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2329
                        pkg_count += 1
825
5d8b3ed4c293 6002 Two entries appear in packagemanager for installed package
Padraig O'Briain <padraig.obriain@sun.com>
parents: 823
diff changeset
  2330
5d8b3ed4c293 6002 Two entries appear in packagemanager for installed package
Padraig O'Briain <padraig.obriain@sun.com>
parents: 823
diff changeset
  2331
                self.__add_package_to_list(next_app, application_list, pkg_add, 
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2332
                    pkg_name, category_icon, categories, category_list, authority)
825
5d8b3ed4c293 6002 Two entries appear in packagemanager for installed package
Padraig O'Briain <padraig.obriain@sun.com>
parents: 823
diff changeset
  2333
                pkg_add += 1
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2334
                for authority in sections:
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2335
                        for section in sections[authority]:
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2336
                                for category in sections[authority][section].split(","):
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2337
                                        self.__add_category_to_section(_(category),
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  2338
                                            _(section), category_list, section_list)
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2339
 
500
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2340
                #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
  2341
                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
  2342
                        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
  2343
                        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
  2344
                        r = []
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2345
                        category_list.reorder([r[-1] for r in rows])
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2346
                self.__progressdialog_progress_percent(PACKAGE_PROGRESS_PERCENT_TOTAL, 
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2347
                    total_pkg_count, total_pkg_count)
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2348
                return
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2349
825
5d8b3ed4c293 6002 Two entries appear in packagemanager for installed package
Padraig O'Briain <padraig.obriain@sun.com>
parents: 823
diff changeset
  2350
        def __add_package_to_list(self, app, application_list, pkg_add, 
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2351
            pkg_name, category_icon, categories, category_list, authority):
825
5d8b3ed4c293 6002 Two entries appear in packagemanager for installed package
Padraig O'Briain <padraig.obriain@sun.com>
parents: 823
diff changeset
  2352
                row_iter = application_list.insert(pkg_add, app)
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2353
                cat_auth = categories.get(authority)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2354
                if pkg_name in cat_auth:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2355
                        pkg_categories = cat_auth.get(pkg_name)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2356
                        for pcat in pkg_categories.split(","):
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2357
                                self.__add_package_to_category(_(pcat), None, 
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2358
                                    category_icon, row_iter, application_list, 
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2359
                                    category_list)
825
5d8b3ed4c293 6002 Two entries appear in packagemanager for installed package
Padraig O'Briain <padraig.obriain@sun.com>
parents: 823
diff changeset
  2360
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2361
        @staticmethod
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2362
        def __add_package_to_category(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
  2363
            category_icon, package, application_list, category_list):
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2364
                if not package or category_name == _('All'):
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2365
                        return
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2366
                if not category_name:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2367
                        return
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2368
                category_id = None
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2369
                icon_visible = False
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2370
                if category_icon:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2371
                        icon_visible = True
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2372
                for category in category_list:
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2373
                        if category[enumerations.CATEGORY_NAME] == category_name:
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2374
                                category_id = category[enumerations.CATEGORY_ID]
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2375
                                if category_icon:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2376
                                        category[enumerations.CATEGORY_ICON] = \
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2377
                                            category_icon
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2378
                                        category[enumerations.CATEGORY_ICON_VISIBLE] = \
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2379
                                            icon_visible
827
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
  2380
                                break
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2381
                if not category_id:                       # Category not exists
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2382
                        category_id = len(category_list) + 1
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2383
                        category_list.append([category_id, category_name, 
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2384
                            category_description, category_icon, icon_visible, 
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2385
                            True, None])
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  2386
                if application_list.get_value(package,
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  2387
                    enumerations.CATEGORY_LIST_COLUMN):
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  2388
                        a = application_list.get_value(package,
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  2389
                            enumerations.CATEGORY_LIST_COLUMN)
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  2390
                        a.append(category_id)
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2391
                else:
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  2392
                        category_list = []
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  2393
                        category_list.append(category_id)
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  2394
                        application_list.set(package,
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  2395
                            enumerations.CATEGORY_LIST_COLUMN, category_list)
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2396
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  2397
        def __add_category_to_section(self, category_name, section_name, category_list, 
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  2398
            section_list):
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2399
                '''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
  2400
                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
  2401
                is skipped. Sections must be case sensitive'''
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2402
                if not category_name:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2403
                        return
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  2404
                for section in section_list:
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2405
                        if section[enumerations.SECTION_NAME] == section_name:
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  2406
                                section_id = section[enumerations.SECTION_ID]
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2407
                                for category in category_list:
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2408
                                        if category[enumerations.CATEGORY_NAME] == \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2409
                                            category_name:
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  2410
                                                section_lst = category[ \
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  2411
                                                    enumerations.SECTION_LIST_OBJECT]
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  2412
                                                section[enumerations.SECTION_ENABLED] = True
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  2413
                                                if not section_lst:
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2414
                                                        category[ \
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  2415
                                                    enumerations.SECTION_LIST_OBJECT] = \
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  2416
                                                            [section_id, ]
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2417
                                                else:
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2418
                                                        if not section_name in \
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  2419
                                                            section_lst:
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  2420
                                                                section_lst.append(
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  2421
                                                                    section_id)
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2422
500
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2423
        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
  2424
                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
  2425
                        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
  2426
                        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
  2427
                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
  2428
                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
  2429
                
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2430
        # 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
  2431
        # 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
  2432
        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
  2433
                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
  2434
                        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
  2435
                            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
  2436
                                
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2437
                        gobject.idle_add(self.w_progressbar.set_fraction,
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2438
                            self.progress_fraction_time_count)
500
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2439
                        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
  2440
                                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
  2441
                        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
  2442
                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
  2443
                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
  2444
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2445
        def __progressdialog_progress_percent(self, fraction, count, total):
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2446
                gobject.idle_add(self.w_progressinfo_label.set_text, _(
660
ea2809ad4582 4126 I10n update for IPS CLI PM and UM
John Rice <john.rice@sun.com>
parents: 653
diff changeset
  2447
                    "Processing package entries: %d of %d") % (count, total)  )
500
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2448
                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
  2449
602
cd5a41269b1e 3911 menu item, dialog header 'Manage Repositories'
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 594
diff changeset
  2450
        def error_occured(self, error_msg, msg_title=None, msg_type=gtk.MESSAGE_ERROR):
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2451
                msgbox = gtk.MessageDialog(parent =
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2452
                    self.w_main_window,
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2453
                    buttons = gtk.BUTTONS_CLOSE,
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2454
                    flags = gtk.DIALOG_MODAL,
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2455
                    type = msg_type,
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2456
                    message_format = None)
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2457
                msgbox.set_markup(error_msg)
602
cd5a41269b1e 3911 menu item, dialog header 'Manage Repositories'
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 594
diff changeset
  2458
                title = None
cd5a41269b1e 3911 menu item, dialog header 'Manage Repositories'
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 594
diff changeset
  2459
                if msg_title:
cd5a41269b1e 3911 menu item, dialog header 'Manage Repositories'
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 594
diff changeset
  2460
                        title = msg_title
cd5a41269b1e 3911 menu item, dialog header 'Manage Repositories'
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 594
diff changeset
  2461
                else:
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2462
                        title = _("Package Manager")
602
cd5a41269b1e 3911 menu item, dialog header 'Manage Repositories'
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 594
diff changeset
  2463
                msgbox.set_title(title)
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2464
                msgbox.run()
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2465
                msgbox.destroy()
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2466
500
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2467
#-----------------------------------------------------------------------------#
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2468
# Static Methods
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2469
#-----------------------------------------------------------------------------#
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2470
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2471
        #@staticmethod
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2472
        #def N_(message): 
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2473
        #        return message
500
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2474
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2475
        @staticmethod
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2476
        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
  2477
                return cmp(a[1], b[1])
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2478
                
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2479
        @staticmethod
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2480
        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
  2481
                '''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
  2482
                selected'''
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2483
                if itr:
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2484
                        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
  2485
                                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
  2486
                                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
  2487
                        else:
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2488
                                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
  2489
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2490
        @staticmethod
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2491
        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
  2492
                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
  2493
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2494
        @staticmethod
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2495
        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
  2496
                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
  2497
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2498
        @staticmethod
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2499
        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
  2500
                '''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
  2501
                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
  2502
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2503
        @staticmethod
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2504
        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
  2505
                dt = None
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2506
                try:
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2507
                        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
  2508
                except AttributeError:
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2509
                        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
  2510
                return dt
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2511
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2512
        @staticmethod
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  2513
        def get_installed_version(api_o, pkg):
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  2514
                return api_o.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
  2515
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2516
        @staticmethod
844
8596a8d12813 6268 PackageManager does not work with latest ips code
Padraig O'Briain <padraig.obriain@sun.com>
parents: 833
diff changeset
  2517
        def get_manifest(img, package):
500
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2518
                '''helper function'''
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2519
                # 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
  2520
                manifest = None
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2521
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2522
                # 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
  2523
                if packagemanager.cancelled:
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2524
                        return manifest
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2525
                try:
844
8596a8d12813 6268 PackageManager does not work with latest ips code
Padraig O'Briain <padraig.obriain@sun.com>
parents: 833
diff changeset
  2526
                        manifest = img.get_manifest(package)
500
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2527
                except OSError:
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2528
                        # 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
  2529
                        # 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
  2530
                        # 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
  2531
                        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
  2532
                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
  2533
                    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
  2534
                        pass
844
8596a8d12813 6268 PackageManager does not work with latest ips code
Padraig O'Briain <padraig.obriain@sun.com>
parents: 833
diff changeset
  2535
                except misc.TransportFailures:
8596a8d12813 6268 PackageManager does not work with latest ips code
Padraig O'Briain <padraig.obriain@sun.com>
parents: 833
diff changeset
  2536
                        pass
500
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2537
                return manifest
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2538
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2539
        @staticmethod
724
f67376f059f7 4986 PM search is slow during loading of descriptions
John Rice <john.rice@sun.com>
parents: 714
diff changeset
  2540
        def update_desc(description, pkg):
f67376f059f7 4986 PM search is slow during loading of descriptions
John Rice <john.rice@sun.com>
parents: 714
diff changeset
  2541
                pkg[enumerations.DESCRIPTION_COLUMN] = description
f67376f059f7 4986 PM search is slow during loading of descriptions
John Rice <john.rice@sun.com>
parents: 714
diff changeset
  2542
                return
500
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2543
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2544
#-----------------------------------------------------------------------------#
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2545
# Public Methods
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2546
#-----------------------------------------------------------------------------#
500
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2547
        def setup_progressdialog_show(self):
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2548
                self.w_progress_dialog.set_title(_("Loading Repository Information"))
500
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2549
                self.w_progressinfo_label.set_text(
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2550
                    _( "Fetching package entries ..."))
500
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2551
                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
  2552
                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
  2553
                Thread(target = self.__progressdialog_progress_time).start()
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2554
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2555
        def setup_progressdialog_hide(self):
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2556
                self.progress_stop_timer_thread = True
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2557
                self.w_progress_dialog.hide()
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2558
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2559
        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
  2560
                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
  2561
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2562
        def reload_packages(self):
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2563
                self.api_o = self.__get_api_object(self.image_directory, self.pr)
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  2564
                self.cache_o = self.__get_cache_obj(self.application_dir, self.api_o)
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2565
                self.__on_reload(None)
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2566
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2567
        def set_busy_cursor(self):
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2568
                self.gdk_window.show()
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2569
    
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2570
        def unset_busy_cursor(self):
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2571
                self.gdk_window.hide()
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2572
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2573
        def process_package_list_start(self, image_directory):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2574
                self.image_directory = image_directory
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2575
                if not self.api_o:
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  2576
                        self.api_o = self.__get_api_object(image_directory, self.pr)
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  2577
                        self.cache_o = self.__get_cache_obj(self.application_dir, self.api_o)
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2578
                self.repositories_list = self.__get_new_repositories_liststore()
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2579
                self.__setup_repositories_combobox(self.api_o, self.repositories_list)
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2580
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2581
        @staticmethod
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  2582
        def __get_cache_obj(application_dir, api_o):
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  2583
                cache_o = cache.CacheListStores(application_dir,
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  2584
                    api_o)
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  2585
                return cache_o
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  2586
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  2587
        @staticmethod
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2588
        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
  2589
                api_o = None
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2590
                try:
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2591
                        api_o = api.ImageInterface(img_dir,
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2592
                            CLIENT_API_VERSION,
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2593
                            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
  2594
                except (api_errors.VersionException,\
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2595
                    api_errors.ImageNotFoundException):
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2596
                        raise
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2597
                return api_o
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2598
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2599
        def process_package_list_end(self):
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  2600
                self.__set_first_category_text()
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2601
                self.__get_manifests_thread()
866
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
  2602
                self.in_startpage_startup = False
823
0db1bfc6d455 4848 PM fails with a blank error message
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 821
diff changeset
  2603
                if self.update_all_proceed:
866
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
  2604
                # TODO: Handle situation where only SUNWipkg/SUNWipg-gui have been updated
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
  2605
                # in update all: bug 6357
823
0db1bfc6d455 4848 PM fails with a blank error message
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 821
diff changeset
  2606
                        self.__on_update_all(None)
0db1bfc6d455 4848 PM fails with a blank error message
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 821
diff changeset
  2607
                        self.update_all_proceed = False
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2608
                self.setup_progressdialog_hide()
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2609
                self.__enable_disable_install_remove()
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2610
                self.update_statusbar()
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2611
                self.in_setup = False
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2612
                self.cancelled = False
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  2613
                if self.initial_section != 0:
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  2614
                        self.__application_refilter()
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  2615
                self.unset_busy_cursor()
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2616
                Thread(target = self.__enable_disable_update_all).start()                
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2617
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2618
        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
  2619
                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
  2620
                    args = ()).start()
543
9889330c2ab5 3201 Add Dialog for setting default and removing Boot Environments
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 539
diff changeset
  2621
827
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
  2622
        def get_icon_pixbuf_from_glade_dir(self, icon_name):
869
0197953cd88a 5398 UM not following steps consistently
Padraig O'Briain <padraig.obriain@sun.com>
parents: 868
diff changeset
  2623
                return gui_misc.get_pixbuf_from_path(self.application_dir +
827
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
  2624
                    "/usr/share/package-manager/", icon_name)
a3fae94c1cce 5765 Enhancements to Categories
Padraig O'Briain <padraig.obriain@sun.com>
parents: 825
diff changeset
  2625
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2626
        def get_manifests_for_packages(self):
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2627
                ''' 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
  2628
                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
  2629
                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
  2630
                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
  2631
                time.sleep(3)
724
f67376f059f7 4986 PM search is slow during loading of descriptions
John Rice <john.rice@sun.com>
parents: 714
diff changeset
  2632
                count = 0
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2633
                self.description_thread_running = True
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  2634
                img = self.api_o.img
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2635
                for pkg in self.application_list:
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2636
                        if self.cancelled:
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2637
                                self.description_thread_running = False
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2638
                                return
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2639
                        info = None
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2640
                        package = pkg[enumerations.FMRI_COLUMN]
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2641
                        if (img and package):
844
8596a8d12813 6268 PackageManager does not work with latest ips code
Padraig O'Briain <padraig.obriain@sun.com>
parents: 833
diff changeset
  2642
                                man = self.get_manifest(img, package)
724
f67376f059f7 4986 PM search is slow during loading of descriptions
John Rice <john.rice@sun.com>
parents: 714
diff changeset
  2643
                                if man:
f67376f059f7 4986 PM search is slow during loading of descriptions
John Rice <john.rice@sun.com>
parents: 714
diff changeset
  2644
                                        info = man.get("description", "")
f67376f059f7 4986 PM search is slow during loading of descriptions
John Rice <john.rice@sun.com>
parents: 714
diff changeset
  2645
                        gobject.idle_add(self.update_desc, info, pkg)
f67376f059f7 4986 PM search is slow during loading of descriptions
John Rice <john.rice@sun.com>
parents: 714
diff changeset
  2646
                        count += 1
f67376f059f7 4986 PM search is slow during loading of descriptions
John Rice <john.rice@sun.com>
parents: 714
diff changeset
  2647
                        if count % 2 ==  0:
f67376f059f7 4986 PM search is slow during loading of descriptions
John Rice <john.rice@sun.com>
parents: 714
diff changeset
  2648
                                time.sleep(0.001)
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2649
                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
  2650
                img.history.operation_result = history.RESULT_SUCCEEDED
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2651
                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
  2652
                
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2653
        def update_statusbar(self):
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2654
                '''Function which updates statusbar'''
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2655
                installed = 0
816
5d4f7746a490 3978 Selecting package rows should check the package row as well
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 815
diff changeset
  2656
                self.selected = 0
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2657
                sel = 0
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  2658
                visible_repository = self.__get_visible_repository_name()
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2659
                for authority in self.selected_pkgs:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2660
                        pkgs = self.selected_pkgs.get(authority)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2661
                        self.selected += len(pkgs)
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2662
                for pkg_row in self.application_list:
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2663
                        if pkg_row[enumerations.STATUS_COLUMN] == enumerations.INSTALLED \
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2664
                            or pkg_row[enumerations.STATUS_COLUMN] == \
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2665
                            enumerations.UPDATABLE:
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2666
                                installed = installed + 1
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2667
                        if pkg_row[enumerations.MARK_COLUMN]:
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2668
                                sel = sel + 1
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2669
                listed_str = _('%d listed') % len(self.application_list)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2670
                sel_str = _('%d selected') % sel
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2671
                inst_str = _('%d installed') % installed
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  2672
                status_str = _("%s: %s , %s, %s.") % (visible_repository, listed_str, 
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2673
                        inst_str, sel_str)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2674
                self.w_main_statusbar.push(0, status_str)
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2675
868
3ccd83eaeaf9 6439 Accessible image descriptions not correct after sorting
Padraig O'Briain <padraig.obriain@sun.com>
parents: 866
diff changeset
  2676
        def update_package_list(self, update_list):
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  2677
                img = self.api_o.img
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  2678
                visible_repository = self.__get_visible_repository_name()
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2679
                default_authority = self.default_authority
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2680
                img.clear_pkg_state()
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2681
                img.load_catalogs(self.pr)
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2682
                installed_icon = gui_misc.get_icon_pixbuf(self.application_dir, 
869
0197953cd88a 5398 UM not following steps consistently
Padraig O'Briain <padraig.obriain@sun.com>
parents: 868
diff changeset
  2683
                    "status_installed")
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  2684
                visible_list = update_list.get(visible_repository)
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2685
                if visible_list:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2686
                        for row in self.application_list:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2687
                                if row[enumerations.NAME_COLUMN] in visible_list:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2688
                                        pkg = row[enumerations.FMRI_COLUMN]
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2689
                                        pkg_stem = row[enumerations.STEM_COLUMN]
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2690
                                        self.__remove_pkg_stem_from_list(pkg_stem)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2691
                                        if self.info_cache.has_key(pkg_stem):
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2692
                                                del self.info_cache[pkg_stem]
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2693
                                        package_installed = \
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2694
                                            self.get_installed_version(self.api_o, pkg)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2695
                                        if package_installed:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2696
                                                inst_stem = \
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2697
                                                    package_installed.get_pkg_stem()
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2698
                                                if inst_stem == pkg_stem:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2699
                                                        row[enumerations.STATUS_COLUMN] = \
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2700
                                                            enumerations.INSTALLED
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2701
                                                        row[enumerations.STATUS_ICON_COLUMN] = \
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2702
                                                            installed_icon
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2703
                                        else:
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2704
                                                row[enumerations.STATUS_COLUMN] = \
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2705
                                                    enumerations.NOT_INSTALLED
770
51cc59540c42 4341 IPS GUI and CLI list different status for some packages
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 757
diff changeset
  2706
                                                row[enumerations.STATUS_ICON_COLUMN] = \
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2707
                                                    None
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2708
                                        row[enumerations.MARK_COLUMN] = False
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  2709
                        self.__dump_datamodels(visible_repository, 
892
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  2710
                                self.application_list, self.category_list,
ff66cde11b73 6973 Initial Category
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 882
diff changeset
  2711
                                self.section_list)
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2712
                for authority in update_list:
882
b7593a33c0cf 6725 Add caching support for lists/categories
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 878
diff changeset
  2713
                        if authority != visible_repository:
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2714
                                pkg_list = update_list.get(authority)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2715
                                for pkg in pkg_list:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2716
                                        pkg_stem = None
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2717
                                        if authority != default_authority:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2718
                                                pkg_stem = "pkg://%s/%s" % (authority, pkg)
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2719
                                        else:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2720
                                                pkg_stem = "pkg:/%s" % pkg
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2721
                                        if pkg_stem:
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2722
                                                if self.info_cache.has_key(pkg_stem):
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2723
                                                        del self.info_cache[pkg_stem]
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2724
                                                self.__remove_pkg_stem_from_list(pkg_stem)
861
2a5fb898a335 4578 IPS GUI does not update the package info after upgrading
Padraig O'Briain <padraig.obriain@sun.com>
parents: 844
diff changeset
  2725
                self.__process_package_selection()
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2726
                self.__enable_disable_selection_menus()
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2727
                self.__enable_disable_install_remove()
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2728
                self.update_statusbar()
871
9fc6dca6583b 6516 split the repository data models
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 869
diff changeset
  2729
                Thread(target = self.__enable_disable_update_all).start()
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2730
823
0db1bfc6d455 4848 PM fails with a blank error message
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 821
diff changeset
  2731
        def restart_after_ips_update(self, be_name):
0db1bfc6d455 4848 PM fails with a blank error message
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 821
diff changeset
  2732
                self.__main_application_quit(be_name)
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2733
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2734
        def shutdown_after_image_update(self):    
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2735
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2736
                msgbox = gtk.MessageDialog(parent = self.w_main_window,
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2737
                    buttons = gtk.BUTTONS_OK,
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2738
                    flags = gtk.DIALOG_MODAL, type = gtk.MESSAGE_INFO,
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2739
                    message_format = _("Update All has completed and Package " \
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2740
                    "Manager will now exit.\n\nPlease reboot after reviewing the "
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2741
                    "release notes posted at:\n\n"
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2742
                    "http://opensolaris.org/os/project/indiana/resources/"
653
2354712b6ff7 4213 CLI PM and UM need to point to correct release note URL on successful image update
John Rice <john.rice@sun.com>
parents: 641
diff changeset
  2743
                    "relnotes/200811/x86/"))
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2744
                msgbox.set_title(_("Update All"))
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2745
                msgbox.run()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2746
                msgbox.destroy()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2747
                self.__main_application_quit()
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2748
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2749
###############################################################################
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2750
#-----------------------------------------------------------------------------#
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2751
# Test functions
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2752
#-----------------------------------------------------------------------------#
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2753
        def fill_with_fake_data(self):
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2754
                '''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
  2755
                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
  2756
                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
  2757
                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
  2758
                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
  2759
                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
  2760
869
0197953cd88a 5398 UM not following steps consistently
Padraig O'Briain <padraig.obriain@sun.com>
parents: 868
diff changeset
  2761
                app1 = [False, gui_misc.get_icon_pixbuf(self.application_dir, "locked"), \
0197953cd88a 5398 UM not following steps consistently
Padraig O'Briain <padraig.obriain@sun.com>
parents: 868
diff changeset
  2762
                    gui_misc.get_icon_pixbuf(self.application_dir, "None"), \
0197953cd88a 5398 UM not following steps consistently
Padraig O'Briain <padraig.obriain@sun.com>
parents: 868
diff changeset
  2763
                    "acc", None, None, None, 4, "desc6", \
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2764
                    "Object Name1", None, True, None]
869
0197953cd88a 5398 UM not following steps consistently
Padraig O'Briain <padraig.obriain@sun.com>
parents: 868
diff changeset
  2765
                app2 = [False, gui_misc.get_icon_pixbuf(self.application_dir, 
0197953cd88a 5398 UM not following steps consistently
Padraig O'Briain <padraig.obriain@sun.com>
parents: 868
diff changeset
  2766
                    "update_available"), \
0197953cd88a 5398 UM not following steps consistently
Padraig O'Briain <padraig.obriain@sun.com>
parents: 868
diff changeset
  2767
                    gui_misc.get_icon_pixbuf(self.application_dir, \
0197953cd88a 5398 UM not following steps consistently
Padraig O'Briain <padraig.obriain@sun.com>
parents: 868
diff changeset
  2768
                     _('All')), "acc_gam", \
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2769
                    "2.3", None, "2.8", \
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2770
                    4, "desc7", "Object Name2", None, True, None]
869
0197953cd88a 5398 UM not following steps consistently
Padraig O'Briain <padraig.obriain@sun.com>
parents: 868
diff changeset
  2771
                app3 = [False, gui_misc.get_icon_pixbuf(self.application_dir, "None"), \
0197953cd88a 5398 UM not following steps consistently
Padraig O'Briain <padraig.obriain@sun.com>
parents: 868
diff changeset
  2772
                    gui_misc.get_icon_pixbuf(self.application_dir, "Other"), \
0197953cd88a 5398 UM not following steps consistently
Padraig O'Briain <padraig.obriain@sun.com>
parents: 868
diff changeset
  2773
                    "gam_grap", "2.3", None, None, 4, \
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2774
                    "desc8", "Object Name3", None, True, None]
869
0197953cd88a 5398 UM not following steps consistently
Padraig O'Briain <padraig.obriain@sun.com>
parents: 868
diff changeset
  2775
                app4 = [False, gui_misc.get_icon_pixbuf(self.application_dir, 
0197953cd88a 5398 UM not following steps consistently
Padraig O'Briain <padraig.obriain@sun.com>
parents: 868
diff changeset
  2776
                    "update_locked"), \
0197953cd88a 5398 UM not following steps consistently
Padraig O'Briain <padraig.obriain@sun.com>
parents: 868
diff changeset
  2777
                    gui_misc.get_icon_pixbuf(self.application_dir, "Office"), \
0197953cd88a 5398 UM not following steps consistently
Padraig O'Briain <padraig.obriain@sun.com>
parents: 868
diff changeset
  2778
                    "grap_gam", "2.3", None, "2.8", 4, \
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2779
                    "desc9", "Object Name2", None, True, None]
869
0197953cd88a 5398 UM not following steps consistently
Padraig O'Briain <padraig.obriain@sun.com>
parents: 868
diff changeset
  2780
                app5 = [False, gui_misc.get_icon_pixbuf(self.application_dir, 
0197953cd88a 5398 UM not following steps consistently
Padraig O'Briain <padraig.obriain@sun.com>
parents: 868
diff changeset
  2781
                    "update_available"), \
0197953cd88a 5398 UM not following steps consistently
Padraig O'Briain <padraig.obriain@sun.com>
parents: 868
diff changeset
  2782
                    gui_misc.get_icon_pixbuf(self.application_dir, "None"), \
0197953cd88a 5398 UM not following steps consistently
Padraig O'Briain <padraig.obriain@sun.com>
parents: 868
diff changeset
  2783
                    "grap", "2.3", None, "2.8", 4, \
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2784
                    "desc0", "Object Name3", None, True, None]
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2785
                itr1 = self.application_list.append(app1)
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2786
                itr2 = self.application_list.append(app2)
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2787
                itr3 = self.application_list.append(app3)
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2788
                itr4 = self.application_list.append(app4)
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2789
                itr5 = self.application_list.append(app5)
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2790
                #      self.__add_package_to_category(_("All"),None,None,None);
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2791
                self.__add_package_to_category(_("Accessories"), \
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2792
                    None, None, itr1, self.application_list, self.category_list)
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2793
                self.__add_package_to_category(_("Accessories"), None, None, itr2,
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2794
                    self.application_list, self.category_list)
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2795
                self.__add_package_to_category(_("Games"), None, None, itr3,
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2796
                    self.application_list, self.category_list)
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2797
                self.__add_package_to_category(_("Graphics"), None, None, itr3,
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2798
                    self.application_list, self.category_list)
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2799
                self.__add_package_to_category(_("Games"), None, None, itr2,
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2800
                    self.application_list, self.category_list)
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2801
                self.__add_package_to_category(_("Graphics"), None, None, itr4,
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2802
                    self.application_list, self.category_list)
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2803
                self.__add_package_to_category(_("Games"), None, None, itr4,
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2804
                    self.application_list, self.category_list)
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2805
                self.__add_package_to_category(_("Graphics"), None, None, itr5,
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2806
                    self.application_list, self.category_list)
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2807
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2808
                #     Category names until xdg is imported.
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2809
                #     from xdg.DesktopEntry import *
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2810
                #     entry = DesktopEntry ()
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2811
                #     directory = '/usr/share/desktop-directories'
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2812
                #     for root, dirs, files in os.walk (directory):
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2813
                #       for name in files:
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2814
                #       entry.parse (os.path.join (root, name))
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2815
                #       self.__add_category_to_section (entry.getName (),
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2816
                #   _('Applications Desktop'))
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2817
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2818
                self.__add_category_to_section(_("Accessories"), 
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2819
                    _('Applications Desktop'), self.category_list)
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2820
                self.__add_category_to_section(_("Games"),
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2821
                    _('Applications Desktop'), self.category_list)
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2822
                self.__add_category_to_section(_("Graphics"),
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2823
                    _('Applications Desktop'), self.category_list)
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2824
                self.__add_category_to_section(_("Internet"),
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2825
                    _('Applications Desktop'), self.category_list)
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2826
                self.__add_category_to_section(_("Office"),
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2827
                    _('Applications Desktop'), self.category_list)
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2828
                self.__add_category_to_section(_("Sound & Video"),
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2829
                    _('Applications Desktop'), self.category_list)
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2830
                self.__add_category_to_section(_("System Tools"),
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2831
                    _('Applications Desktop'), self.category_list)
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2832
                self.__add_category_to_section(_("Universal Access"),
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2833
                    _('Applications Desktop'), self.category_list)
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2834
                self.__add_category_to_section(_("Developer Tools"),
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2835
                    _('Applications Desktop'), self.category_list)
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2836
                self.__add_category_to_section(_("Core"),
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2837
                    _('Operating System'), self.category_list)
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2838
                self.__add_category_to_section(_("Graphics"),
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2839
                    _('Operating System'), self.category_list)
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2840
                self.__add_category_to_section(_("Media"),
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2841
                    _('Operating System'), self.category_list)
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2842
                #Can be twice :)
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2843
                self.__add_category_to_section(_("Developer Tools"),
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2844
                    _('Operating System'), self.category_list)
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2845
                self.__add_category_to_section(_("Office"), "Progs",
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2846
                    self.category_list)
808
6c89385ac9ff 4463 Change PM and UM to use _() as opposed to self._()
Padraig O'Briain <padraig.obriain@sun.com>
parents: 796
diff changeset
  2847
                self.__add_category_to_section(_("Office2"), "Progs",
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2848
                    self.category_list)
636
a8306e269861 4008 Client API api.info is slow and appears to be consuming a...
John Rice <john.rice@sun.com>
parents: 608
diff changeset
  2849
                self.__setup_repositories_combobox(self.api_o)
500
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2850
                self.in_setup = False
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2851
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2852
###############################################################################
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2853
#-----------------------------------------------------------------------------#
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2854
# Main
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2855
#-----------------------------------------------------------------------------#
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2856
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2857
def main():
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2858
        gtk.main()
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2859
        return 0
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2860
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2861
if __name__ == '__main__':
866
1768eb95fd29 6355 Add StartPage to PM
John Rice <john.rice@sun.com>
parents: 865
diff changeset
  2862
        debug = False
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2863
        packagemanager = PackageManager()
457
9ee1bf88afb2 1905 GUI package manager slow responsiveness
John.Rice@Sun.COM
parents: 450
diff changeset
  2864
        passed_test_arg = False
9ee1bf88afb2 1905 GUI package manager slow responsiveness
John.Rice@Sun.COM
parents: 450
diff changeset
  2865
        passed_imagedir_arg = False
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
  2866
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2867
        try:
823
0db1bfc6d455 4848 PM fails with a blank error message
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 821
diff changeset
  2868
                opts, args = getopt.getopt(sys.argv[1:], "htR:U:", \
0db1bfc6d455 4848 PM fails with a blank error message
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 821
diff changeset
  2869
                    ["help", "test-gui", "image-dir=", "update-all"])
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2870
        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
  2871
                print "%s, for help use --help" % msg
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2872
                sys.exit(2)
457
9ee1bf88afb2 1905 GUI package manager slow responsiveness
John.Rice@Sun.COM
parents: 450
diff changeset
  2873
781
06837558bc07 5798 GUI Packagemanger does not start if the user's home directory is not world readable
Padraig O'Briain <padraig.obriain@sun.com>
parents: 780
diff changeset
  2874
        if os.path.isabs(sys.argv[0]):
06837558bc07 5798 GUI Packagemanger does not start if the user's home directory is not world readable
Padraig O'Briain <padraig.obriain@sun.com>
parents: 780
diff changeset
  2875
                packagemanager.application_path = sys.argv[0]
06837558bc07 5798 GUI Packagemanger does not start if the user's home directory is not world readable
Padraig O'Briain <padraig.obriain@sun.com>
parents: 780
diff changeset
  2876
        else: 
06837558bc07 5798 GUI Packagemanger does not start if the user's home directory is not world readable
Padraig O'Briain <padraig.obriain@sun.com>
parents: 780
diff changeset
  2877
                cmd = os.path.join(os.getcwd(), sys.argv[0])
06837558bc07 5798 GUI Packagemanger does not start if the user's home directory is not world readable
Padraig O'Briain <padraig.obriain@sun.com>
parents: 780
diff changeset
  2878
                packagemanager.application_path = os.path.realpath(cmd)
457
9ee1bf88afb2 1905 GUI package manager slow responsiveness
John.Rice@Sun.COM
parents: 450
diff changeset
  2879
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
  2880
        for option, argument in opts:
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2881
                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
  2882
                        print """\
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
  2883
Use -R (--image-dir) to specify image directory.
823
0db1bfc6d455 4848 PM fails with a blank error message
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 821
diff changeset
  2884
Use -t (--test-gui) to work on fake data.
0db1bfc6d455 4848 PM fails with a blank error message
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 821
diff changeset
  2885
Use -U (--update-all) to proceed with Update All"""
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2886
                        sys.exit(0)
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2887
                if option in ("-t", "--test-gui"):
457
9ee1bf88afb2 1905 GUI package manager slow responsiveness
John.Rice@Sun.COM
parents: 450
diff changeset
  2888
                        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
  2889
                if option in ("-R", "--image-dir"):
457
9ee1bf88afb2 1905 GUI package manager slow responsiveness
John.Rice@Sun.COM
parents: 450
diff changeset
  2890
                        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
  2891
                        image_dir = argument
457
9ee1bf88afb2 1905 GUI package manager slow responsiveness
John.Rice@Sun.COM
parents: 450
diff changeset
  2892
                        passed_imagedir_arg = True
823
0db1bfc6d455 4848 PM fails with a blank error message
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 821
diff changeset
  2893
                if option in ("-U", "--update-all"):
0db1bfc6d455 4848 PM fails with a blank error message
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 821
diff changeset
  2894
                        packagemanager.update_all_proceed = True
0db1bfc6d455 4848 PM fails with a blank error message
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 821
diff changeset
  2895
                        packagemanager.ua_be_name = argument
450
579517b41de2 1313 How to list packages I don't have installed?
Michal Pryc <Michal.Pryc@Sun.COM>
parents: 424
diff changeset
  2896
457
9ee1bf88afb2 1905 GUI package manager slow responsiveness
John.Rice@Sun.COM
parents: 450
diff changeset
  2897
        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
  2898
                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
  2899
                sys.exit(2)
457
9ee1bf88afb2 1905 GUI package manager slow responsiveness
John.Rice@Sun.COM
parents: 450
diff changeset
  2900
        if not passed_imagedir_arg:
9ee1bf88afb2 1905 GUI package manager slow responsiveness
John.Rice@Sun.COM
parents: 450
diff changeset
  2901
                try:
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2902
                        image_dir = os.environ["PKG_IMAGE"]
457
9ee1bf88afb2 1905 GUI package manager slow responsiveness
John.Rice@Sun.COM
parents: 450
diff changeset
  2903
                except KeyError:
483
2110c070804c #2735: pylint_gui_cleanup
John Rice <john.rice@sun.com>
parents: 457
diff changeset
  2904
                        image_dir = os.getcwd()
457
9ee1bf88afb2 1905 GUI package manager slow responsiveness
John.Rice@Sun.COM
parents: 450
diff changeset
  2905
577
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2906
        while gtk.events_pending():
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2907
                gtk.main_iteration(False)
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2908
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2909
        packagemanager.init_show_filter()
cd4e8df4322b 873 Text is wrong in the General Info tab
Michal Pryc <Michal.Pryc@Sun.Com>
parents: 576
diff changeset
  2910
457
9ee1bf88afb2 1905 GUI package manager slow responsiveness
John.Rice@Sun.COM
parents: 450
diff changeset
  2911
        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
  2912
                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
  2913
        else:
e3ac4c2d99a1 1723 startup performance 3087 shutdown too long 1915 category ordering
John Rice <john.rice@sun.com>
parents: 483
diff changeset
  2914
                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
  2915
424
a767ef6bf887 2578 integrate packagemanager into ips gate
Danek Duvall <danek.duvall@sun.com>
parents:
diff changeset
  2916
        main()