~ubuntu-branches/ubuntu/precise/pybackpack/precise

« back to all changes in this revision

Viewing changes to src/pybackpack/statuswindow.py

  • Committer: Bazaar Package Importer
  • Author(s): Andy Price, Andy Price, Piotr Ożarowski, Marco Rodrigues
  • Date: 2007-12-23 15:07:21 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20071223150721-16ur0rbpnlppmbz3
Tags: 0.5.4-1
[ Andy Price ]
* New upstream release
* Update debian/docs - TODO file has been removed
* Depend on genisoimage which upstream now uses
* Remove debian/dirs - distutils creates usr/bin
* Fix section in debian/menu to follow menu guidelines

[ Piotr Ożarowski ]
* Homepage field added
* Rename XS-Vcs-* fields to Vcs-* (dpkg supports them now)

[ Marco Rodrigues ]
* Update Standards-Version to 3.7.3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import os
2
 
import time
3
 
import gtk
4
 
import gtk.glade
5
 
 
6
 
class StatusWindow:
7
 
 
8
 
    """StatusWindow provides a graphical window into which messages are
9
 
       added. The messages are timestamped and put on a new line."""
10
 
 
11
 
    def __init__(self):
12
 
 
13
 
        """Set up a new status window."""
14
 
 
15
 
        try:
16
 
            self.widgets = gtk.glade.XML("%s/statuswindow.glade"
17
 
                           % os.path.dirname(__file__))
18
 
        except RuntimeError, e:
19
 
            dlg = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, 
20
 
                  gtk.BUTTONS_CLOSE,_("Failed to initialise status window."))
21
 
 
22
 
        self.widgets.signal_autoconnect(self)
23
 
 
24
 
    def show(self):
25
 
 
26
 
        """Make the status window visible."""
27
 
 
28
 
        self.widgets.get_widget('window_output_log').show()
29
 
 
30
 
    def addmsg(self, msg):
31
 
 
32
 
        """Adds a timestamped message to the status window."""
33
 
 
34
 
        buf = self.widgets.get_widget('output_log').get_buffer()
35
 
        buf.insert(buf.get_end_iter(), "%s: %s\n" % (time.ctime(), msg))
36
 
 
37
 
    def get_buffer(self):
38
 
 
39
 
        """Returns the text buffer of the status window."""
40
 
 
41
 
        return self.widgets.get_widget('output_log').get_buffer()
42
 
 
43
 
    def scroll(self):
44
 
 
45
 
        """Scrolls the status text box to the end."""
46
 
 
47
 
        self.widgets.get_widget('output_log').scroll_to_iter(
48
 
            self.widgets.get_widget('output_log').get_buffer().get_end_iter(), 0)
49
 
 
50
 
    def on_button_output_log_close_clicked(self, widget):
51
 
 
52
 
        """Hides the status window when the close button is clicked."""
53
 
 
54
 
        self.widgets.get_widget('window_output_log').hide()
55
 
    
56
 
    def on_window_output_log_delete_event(self, widget, event):
57
 
 
58
 
        """Hide the status window when the x is clicked."""
59
 
 
60
 
        widget.hide()
61
 
        return True
62