~ubuntu-branches/ubuntu/saucy/aptoncd/saucy-proposed

« back to all changes in this revision

Viewing changes to ProgressWindow.py

  • Committer: Bazaar Package Importer
  • Author(s): Fabrice Coutadeur
  • Date: 2009-08-17 22:04:26 UTC
  • mfrom: (1.1.1 upstream) (0.1.11 jaunty)
  • Revision ID: james.westby@ubuntu.com-20090817220426-bhxr3a21ff6y8edm
Tags: 0.1.98+bzr109-0.1
* Non-maintainer upload
* New upstream release (Closes: #452205, #423480, #433915, #541047, #427003,
  #493647, #484636)
* debian/control: 
  - Changed python build dependencies to Build-Depends-Indep
  - Moved url from Description to Homepage
  - Changed Standards-Version to 3.8.2
  - Changed Maintainer to myself
  - Deleted dependency on deprecated mkisofs 
  - Deleted recommend of nautilus-cd-burner
* debian/copyright: Changed (C) to © to make lintian happy
* debian/rules: 
  - deleted deprecated dh_desktop
  - added get-orig-source target to get the latest source from lp
* data/aptoncd.desktop.in: Fixed error and deprecated values in Desktop file

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#  ProgressWindow.py
2
 
#  
3
 
#  Author: Laudeci Oliveira <laudeci@gmail.com>
4
 
5
 
#  This program is free software; you can redistribute it and/or 
6
 
#  modify it under the terms of the GNU General Public License as 
7
 
#  published by the Free Software Foundation; either version 2 of the
8
 
#  License, or (at your option) any later version.
9
 
10
 
#  This program is distributed in the hope that it will be useful,
11
 
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
#  GNU General Public License for more details.
14
 
15
 
#  You should have received a copy of the GNU General Public License
16
 
#  along with this program; if not, write to the Free Software
17
 
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18
 
#  USA
19
 
import gtk
20
 
import pygtk
21
 
import gobject
22
 
import pango
23
 
import msg
24
 
import utils
25
 
class ProgressDialog(gtk.Window):
26
 
        """
27
 
        ProgressWindow returns a window that contains a number of properties to
28
 
        access what a common Progress window should have.
29
 
        """
30
 
        def __init__(self, title = "", description = "", parent = None, task = ""):
31
 
                # Creating the windows and its properties
32
 
                gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
33
 
                self.parentui = parent
34
 
                if self.parentui != None:
35
 
                        self.set_transient_for(parent)
36
 
                self._create_ui(title, description, task)
37
 
                self.cancel_status = False
38
 
 
39
 
        def _create_ui(self, title, description, task):
40
 
                self.set_border_width(6)
41
 
                self.set_resizable(False)
42
 
                #self.set_has_separator(False)
43
 
                self.set_skip_taskbar_hint(True)
44
 
                self.set_type_hint(gtk.WINDOW_POPUP)
45
 
                self.set_size_request(520,190)
46
 
                self.set_title(title)
47
 
                self.realize()
48
 
                self.window.set_functions(gtk.gdk.FUNC_MOVE)
49
 
                # prevent the window from closing with the delete button (there is
50
 
                # a cancel button in the window)
51
 
                self.connect("delete_event", lambda e,w: True);
52
 
 
53
 
                vbox = gtk.VBox()
54
 
                vbox.set_border_width(6)
55
 
                vbox.show()
56
 
                self.add(vbox)
57
 
 
58
 
                self.labelTitle = label = gtk.Label('<big><b>%s</b></big>' % title)
59
 
                label.set_use_markup(True)
60
 
                label.set_alignment(0.0, 0.0)
61
 
                label.show()
62
 
                vbox.pack_start(label, False)
63
 
 
64
 
                self.labelDesc = label = gtk.Label(description)
65
 
                label.set_line_wrap(True)
66
 
                label.set_alignment(0.5, 0.0)
67
 
                label.set_padding(0, 12)
68
 
                label.show()
69
 
                vbox.pack_start(label, False)
70
 
 
71
 
                self.progress = progress = gtk.ProgressBar()
72
 
                progress.show()
73
 
                vbox.pack_start(progress, False)
74
 
 
75
 
                self.progresstext = label = gtk.Label('<i>%s</i>' % task)
76
 
                label.set_use_markup(True)
77
 
                label.set_alignment(0.0, 0.0)
78
 
                label.show()
79
 
                vbox.pack_start(label,False)
80
 
                
81
 
                hbbox =gtk.HButtonBox()
82
 
                hbbox.set_border_width(5)
83
 
                hbbox.set_layout( gtk.BUTTONBOX_END)
84
 
                hbbox.show()
85
 
                vbox.pack_start(hbbox,False)
86
 
 
87
 
                self.btnCancel = btnCancel =gtk.Button(gtk.STOCK_CANCEL)
88
 
                btnCancel.set_use_stock(True)
89
 
                btnCancel.show()
90
 
                hbbox.pack_start(btnCancel)
91
 
 
92
 
                #self.show()        
93
 
 
94
 
        def connectEvent(self,functionEvent):
95
 
                self.btnCancel.connect("clicked",functionEvent)
96
 
        
97
 
        
98
 
        def set_windowtitle(self,title):
99
 
                self.set_title(title)
100
 
                
101
 
        def set_tasktitle(self,title):
102
 
                self.labelTitle.set_markup('<big><b>%s</b></big>' % title)
103
 
 
104
 
        def set_task(self,task):
105
 
                self.progresstext.set_markup('<i>%s</i>' % task)
106
 
 
107
 
        def set_description(self,description):
108
 
                self.labelDesc.set_text(description)
109
 
 
110
 
class AptOnCDProgressDialog(ProgressDialog):
111
 
 
112
 
        def __init__(self, parent = None, start = 0, stop = 0):
113
 
                
114
 
                
115
 
                ProgressDialog.__init__(self,(msg.MESSAGE_0052),
116
 
                                        (msg.MESSAGE_0053),
117
 
                                        parent,(msg.MESSAGE_0054))
118
 
                self.start = start
119
 
                self.stop = stop
120
 
                self.update(start)
121
 
                self.cancel_status = False
122
 
                self.btnCancel.connect("clicked", self.click)
123
 
                self.show()
124
 
 
125
 
        def click(self, *args):
126
 
                self.cancel_status = True
127
 
                self.hide()
128
 
 
129
 
        def TaskLenght(self,lenWork):
130
 
                self.stop = lenWork
131
 
                self.update(self.start)
132
 
        
133
 
        def TaskTitle(self,title):
134
 
                self.set_tasktitle(title)
135
 
        
136
 
        def Title(self,title):
137
 
                self.set_windowtitle(title)
138
 
 
139
 
        def Task(self,task):
140
 
                self.set_task(task)
141
 
 
142
 
        def Description(self,description):
143
 
                self.set_description(description)
144
 
 
145
 
        def isCancelEnabled(self,value = True):
146
 
                self.btnCancel.set_sensitive(value)
147
 
                self.btnCancel.set_property('visible',value)
148
 
        
149
 
        def set_text(self,value):
150
 
                self.progress.set_text(value)
151
 
                utils.updateUI()
152
 
                
153
 
        def updateFraction(self,value):
154
 
                self.progress.set_fraction(value)
155
 
                self.progress.set_text(('%d%%' % (value * 100)))
156
 
                utils.updateUI()
157
 
                
158
 
        def set_fraction(self, value):
159
 
                self.progress.set_text(('%d%%' % (value * 100)))
160
 
                self.progress.set_fraction(value)
161
 
                utils.updateUI()
162
 
                        
163
 
        def update(self, pos):
164
 
                try:
165
 
                        pos = min(max(pos, self.start), self.stop)
166
 
                        remaining = self.stop - pos
167
 
                        self.progress.set_text((msg.MESSAGE_0055 % (remaining, self.stop)))
168
 
                        self.progress.set_fraction(1.0 - float(remaining) / (self.stop - self.start))
169
 
                except ZeroDivisionError:
170
 
                        self.progress.set_fraction(self.start)
171
 
                utils.updateUI()