~ubuntu-branches/ubuntu/trusty/aptoncd/trusty

« back to all changes in this revision

Viewing changes to APTonCD/widgets/propertywindow.py

  • Committer: Bazaar Package Importer
  • Author(s): Fabrice Coutadeur
  • Date: 2009-08-19 21:41:06 UTC
  • mfrom: (3 sid) (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20090819214106-7g72fpzgvl722w6k
* New maintainer (Closes: #542459, #484637, #542501)
* New upstream release
  - Fix the executable flag on non executable files. This fix last lintian
    warnings
* debian/rules: prepared for python2.6 (include of python.mk and use of 
  $(py_setup_install_args) )

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
#############################################
 
3
#  Rafael Proença     <cypherbios@ubuntu.com>
 
4
#  Laudeci Oliveira    <laudeci@gmail.com>
 
5
#
 
6
#  Copyright 2006 APTonCD DevTeam.
 
7
#
 
8
#  This program is free software; you can redistribute it and/or modify
 
9
#  it under the terms of the GNU General Public License as published
 
10
#  by the Free Software Foundation; version 2 only.
 
11
#
 
12
#  This program is distributed in the hope that it will be useful,
 
13
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
#  GNU General Public License for more details.
 
16
#############################################
 
17
import gtk
 
18
 
 
19
from APTonCD.core import gui
 
20
from APTonCD.core import constants
 
21
from APTonCD.core.package import DebPackage
 
22
 
 
23
WINDOW_NAME = 'pkgProperties'
 
24
 
 
25
class PackagePropety:
 
26
    """
 
27
        Class to show a property info from selected package
 
28
    """
 
29
    def __init__(self, package, controller = None, pixbuf = None):
 
30
        """
 
31
            Constructor
 
32
        """
 
33
        self.glade = gui.get_glade(constants.PROPERTY_GUI, WINDOW_NAME)        
 
34
        self.package = package
 
35
        
 
36
        self.window = gui.get_widget(self.glade, WINDOW_NAME)
 
37
        self.window.set_title(" %s " % self.package.package + constants.MESSAGE_0072)
 
38
        
 
39
        if controller:
 
40
            self.window.set_transient_for(controller.get_main_window())
 
41
        
 
42
        self.pixbuf = pixbuf
 
43
        self.create_ui()
 
44
        
 
45
       
 
46
    def create_ui(self):
 
47
        """
 
48
            Setup the user interface.
 
49
        """
 
50
        gui.get_widget(self.glade, 'lblPackage').set_text(self.package.package)
 
51
        gui.get_widget(self.glade, 'lblVersion').set_text(self.package.version)
 
52
        
 
53
        # FIXME: Use this method to show the lblStatus
 
54
        # for a more verbose and elegant label
 
55
        #compare = DebPackage()
 
56
        #status = compare.compare_version(self.package.version)
 
57
        #print status
 
58
        #if status == 0:
 
59
        #       gui.get_widget(self.glade, 'lblStatus').set_text("This package is the same as the installed")
 
60
        #elif status < 0:
 
61
        #       gui.get_widget(self.glade, 'lblStatus').set_text("An older version is installed")
 
62
        #elif status > 0:
 
63
        #       gui.get_widget(self.glade, 'lblStatus').set_text("A later version is already installed")
 
64
        #else:
 
65
        #       gui.get_widget(self.glade, 'lblStatus').set_text("This package is not installed")
 
66
        
 
67
        if self.package.installed == True:
 
68
                gui.get_widget(self.glade, 'lblStatus').set_text(constants.MESSAGE_0058)
 
69
        else:
 
70
                gui.get_widget(self.glade, 'lblStatus').set_text(constants.MESSAGE_0059)
 
71
                
 
72
        gui.get_widget(self.glade, 'lblFilename').set_text(self.package.deb_filename)
 
73
        gui.get_widget(self.glade, 'lblSize').set_text(self.package.size_text)
 
74
        
 
75
        if self.package.custom == True:
 
76
                gui.get_widget(self.glade, 'lblCustom').set_text(constants.MESSAGE_0060)
 
77
        else:
 
78
                gui.get_widget(self.glade, 'lblCustom').set_text(constants.MESSAGE_0061)
 
79
        
 
80
        gui.get_widget(self.glade, 'lblDescription').set_text(self.package.short_description)
 
81
        
 
82
        textview = gui.get_widget(self.glade, 'txtvwDesc').get_buffer()
 
83
        textview.set_text(self.package.long_description)
 
84
        
 
85
        if self.pixbuf:
 
86
            gui.get_widget(self.glade, 'imgPackage').set_from_pixbuf(self.pixbuf)
 
87
        gui.get_widget(self.glade,'button1').connect('clicked', self.on_click)
 
88
 
 
89
    def on_click(self, widget):
 
90
        self.window.destroy()
 
91
        
 
92
    def show(self):
 
93
        """
 
94
            Show the window
 
95
        """
 
96
        self.window.run()