1
# Copyright (C) 2006 by Szilveszter Farkas (Phanatic) <szilveszter.farkas@gmail.com>
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
34
if (bzrlib.version_info[0] == 0) and (bzrlib.version_info[1] < 9):
35
# function deprecated after 0.9
36
from bzrlib.delta import compare_trees
38
from bzrlib.status import show_tree_status
39
from bzrlib.workingtree import WorkingTree
41
from dialog import OliveDialog
44
""" Display Status window and perform the needed actions. """
45
def __init__(self, gladefile, comm):
46
""" Initialize the Diff window. """
47
self.gladefile = gladefile
48
self.glade = gtk.glade.XML(self.gladefile, 'window_status')
52
self.dialog = OliveDialog(self.gladefile)
54
# Check if current location is a branch
56
(self.wt, path) = WorkingTree.open_containing(self.comm.get_path())
57
branch = self.wt.branch
58
except errors.NotBranchError:
64
file_id = self.wt.path2id(path)
66
self.notbranch = False
71
# Set the old working tree
72
self.old_tree = self.wt.branch.repository.revision_tree(self.wt.branch.last_revision())
74
# Get the Diff window widget
75
self.window = self.glade.get_widget('window_status')
77
# Dictionary for signal_autoconnect
78
dic = { "on_button_status_close_clicked": self.close }
80
# Connect the signals to the handlers
81
self.glade.signal_autoconnect(dic)
83
# Generate status output
84
self._generate_status()
86
def _generate_status(self):
87
""" Generate 'bzr status' output. """
88
self.model = gtk.TreeStore(str, str)
89
self.treeview = self.glade.get_widget('treeview_status')
90
self.treeview.set_model(self.model)
92
cell = gtk.CellRendererText()
93
cell.set_property("width-chars", 20)
94
column = gtk.TreeViewColumn()
95
column.pack_start(cell, expand=True)
96
column.add_attribute(cell, "text", 0)
97
self.treeview.append_column(column)
99
if (bzrlib.version_info[0] == 0) and (bzrlib.version_info[1] < 9):
100
delta = compare_trees(self.old_tree, self.wt)
102
delta = self.wt.changes_from(self.old_tree)
105
titer = self.model.append(None, [ "Added", None ])
106
for path, id, kind in delta.added:
107
self.model.append(titer, [ path, path ])
109
if len(delta.removed):
110
titer = self.model.append(None, [ "Removed", None ])
111
for path, id, kind in delta.removed:
112
self.model.append(titer, [ path, path ])
114
if len(delta.renamed):
115
titer = self.model.append(None, [ "Renamed", None ])
116
for oldpath, newpath, id, kind, text_modified, meta_modified \
118
self.model.append(titer, [ oldpath, newpath ])
120
if len(delta.modified):
121
titer = self.model.append(None, [ "Modified", None ])
122
for path, id, kind, text_modified, meta_modified in delta.modified:
123
self.model.append(titer, [ path, path ])
126
for path in self.wt.unknowns():
128
titer = self.model.append(None, [ "Unknown", None ])
130
self.model.append(titer, [ path, path ])
132
self.treeview.expand_all()
135
""" Display the Diff window. """
137
self.dialog.error_dialog('Directory is not a branch.')
139
self.window.show_all()
141
def close(self, widget=None):
142
self.window.destroy()