/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to status.py

  • Committer: Vincent Ladeuil
  • Date: 2008-10-23 08:14:59 UTC
  • mto: This revision was merged to the branch mainline in revision 618.
  • Revision ID: v.ladeuil+lp@free.fr-20081023081459-3rgjsohomf8rbe44
Fix bug #131589 by using a gtk.Window instead of a gtk.Dialog.

* status.py:
(StatusWindow): Renamed from StatusDialog, we're a window now.
(StatusWindow.__init__, StatusWindow._create): Adjusted to Window
inheritance.

* __init__.py:
(cmd_gstatus.run): Use a Window instead of a dialog.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
    pass
22
22
 
23
23
import gtk
24
 
from bzrlib.plugins.gtk import _i18n
25
 
 
26
 
 
27
 
class StatusDialog(gtk.Dialog):
 
24
from bzrlib.plugins.gtk import (
 
25
    _i18n,
 
26
    window,
 
27
    )
 
28
 
 
29
 
 
30
class StatusWindow(window.Window):
28
31
    """ Display Status window and perform the needed actions. """
29
32
    def __init__(self, wt, wtpath, revision=None):
30
33
        """ Initialize the Status window. """
31
 
        super(StatusDialog, self).__init__(flags=gtk.DIALOG_MODAL, buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))
 
34
        super(StatusWindow, self).__init__()
32
35
        self.set_title("Working tree changes")
33
 
        self.set_default_response(gtk.RESPONSE_CLOSE)
34
36
        self._create()
35
37
        self.wt = wt
36
38
        self.wtpath = wtpath
37
39
 
38
40
        if revision is None:
39
41
            revision = self.wt.branch.last_revision()
40
 
            
 
42
 
41
43
        # Set the old working tree
42
44
        self.old_tree = self.wt.branch.repository.revision_tree(revision)
43
45
        # Generate status output
45
47
 
46
48
    def _create(self):
47
49
        self.set_default_size(400, 300)
48
 
        self.set_has_separator(False)
49
50
        sw = gtk.ScrolledWindow()
50
51
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
51
52
        sw.set_shadow_type(gtk.SHADOW_IN)
52
53
        self.treeview = gtk.TreeView()
53
54
        sw.add(self.treeview)
54
 
        self.vbox.pack_start(sw, True, True)
55
 
        self.vbox.show_all()
 
55
        self.add(sw)
56
56
 
57
57
        # sane border and spacing widths (as recommended by GNOME HIG) 
58
58
        self.set_border_width(5)
59
59
        sw.set_border_width(5)
60
 
        self.vbox.set_spacing(2)
61
 
        self.action_area.set_border_width(5)
 
60
        self.show_all()
62
61
 
63
62
 
64
63
    def row_diff(self, tv, path, tvc):
78
77
        self.treeview.set_headers_visible(False)
79
78
        self.treeview.set_model(self.model)
80
79
        self.treeview.connect("row-activated", self.row_diff)
81
 
        
 
80
 
82
81
        cell = gtk.CellRendererText()
83
82
        cell.set_property("width-chars", 20)
84
83
        column = gtk.TreeViewColumn()
85
84
        column.pack_start(cell, expand=True)
86
85
        column.add_attribute(cell, "text", 0)
87
86
        self.treeview.append_column(column)
88
 
        
 
87
 
89
88
        delta = self.wt.changes_from(self.old_tree)
90
89
 
91
90
        changes = False
92
 
        
 
91
 
93
92
        if len(delta.added):
94
93
            changes = True
95
94
            titer = self.model.append(None, [ _i18n('Added'), None ])
114
113
            titer = self.model.append(None, [ _i18n('Modified'), None ])
115
114
            for path, id, kind, text_modified, meta_modified in delta.modified:
116
115
                self.model.append(titer, [ path, path ])
117
 
        
 
116
 
118
117
        done_unknown = False
119
118
        for path in self.wt.unknowns():
120
119
            changes = True
127
126
            self.model.append(None, [ _i18n('No changes.'), None ])
128
127
 
129
128
        self.treeview.expand_all()
130
 
    
 
129
 
131
130
    def close(self, widget=None):
132
131
        self.window.destroy()