/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: Jelmer Vernooij
  • Author(s): Chris Lamb
  • Date: 2008-05-01 13:00:15 UTC
  • mto: This revision was merged to the branch mainline in revision 482.
  • Revision ID: jelmer@samba.org-20080501130015-lmn22j03044vqngp
Set suitable FDO categories in .desktop files

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
    pass
22
22
 
23
23
import gtk
24
 
import gtk.glade
25
 
 
26
 
from guifiles import GLADEFILENAME
27
 
 
28
 
 
29
 
class OliveStatus:
 
24
 
 
25
class StatusDialog(gtk.Dialog):
30
26
    """ Display Status window and perform the needed actions. """
31
 
    def __init__(self, wt, wtpath):
 
27
    def __init__(self, wt, wtpath, revision=None):
32
28
        """ Initialize the Status window. """
33
 
        self.glade = gtk.glade.XML(GLADEFILENAME, 'window_status')
34
 
        
35
 
        # Get the Status window widget
36
 
        self.window = self.glade.get_widget('window_status')
37
 
        
 
29
        super(StatusDialog, self).__init__(flags=gtk.DIALOG_MODAL, buttons=(gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
 
30
        self.set_title("Working tree changes")
 
31
        self._create()
38
32
        self.wt = wt
39
33
        self.wtpath = wtpath
40
34
        
41
 
        # Check if current location is a branch
42
 
        file_id = self.wt.path2id(wtpath)
43
 
 
 
35
        if revision is None:
 
36
            revision = self.wt.branch.last_revision()
 
37
            
44
38
        # Set the old working tree
45
 
        self.old_tree = self.wt.branch.repository.revision_tree(self.wt.branch.last_revision())
46
 
        
47
 
        # Dictionary for signal_autoconnect
48
 
        dic = { "on_button_status_close_clicked": self.close }
49
 
        
50
 
        # Connect the signals to the handlers
51
 
        self.glade.signal_autoconnect(dic)
52
 
        
 
39
        self.old_tree = self.wt.branch.repository.revision_tree(revision)
53
40
        # Generate status output
54
41
        self._generate_status()
55
42
 
 
43
    def _create(self):
 
44
        self.set_default_size(400, 300)
 
45
        scrolledwindow = gtk.ScrolledWindow()
 
46
        scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
 
47
        self.treeview = gtk.TreeView()
 
48
        scrolledwindow.add(self.treeview)
 
49
        self.vbox.pack_start(scrolledwindow, True, True)
 
50
        self.vbox.show_all()
 
51
 
 
52
    def row_diff(self, tv, path, tvc):
 
53
        file = self.model[path][1]
 
54
        if file is None:
 
55
            return
 
56
        from bzrlib.plugins.gtk.diff import DiffWindow
 
57
        window = DiffWindow()
 
58
        window.set_diff("Working tree changes", self.old_tree, self.wt)
 
59
        window.set_file(file)
 
60
        window.show()
 
61
 
56
62
    def _generate_status(self):
57
63
        """ Generate 'bzr status' output. """
58
64
        self.model = gtk.TreeStore(str, str)
59
 
        self.treeview = self.glade.get_widget('treeview_status')
 
65
        self.treeview.set_headers_visible(False)
60
66
        self.treeview.set_model(self.model)
 
67
        self.treeview.connect("row-activated", self.row_diff)
61
68
        
62
69
        cell = gtk.CellRendererText()
63
70
        cell.set_property("width-chars", 20)
108
115
 
109
116
        self.treeview.expand_all()
110
117
    
111
 
    def display(self):
112
 
        """ Display the Diff window. """
113
 
        self.window.show_all()
114
 
 
115
118
    def close(self, widget=None):
116
119
        self.window.destroy()