14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
19
pygtk.require("2.0")
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
24
from bzrlib.plugins.gtk import _i18n
27
class StatusDialog(gtk.Dialog):
44
28
""" 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)
29
def __init__(self, wt, wtpath, revision=None):
30
""" Initialize the Status window. """
31
super(StatusDialog, self).__init__(flags=gtk.DIALOG_MODAL, buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))
32
self.set_title("Working tree changes")
33
self.set_default_response(gtk.RESPONSE_CLOSE)
66
self.notbranch = False
39
revision = self.wt.branch.last_revision()
71
41
# 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)
42
self.old_tree = self.wt.branch.repository.revision_tree(revision)
83
43
# Generate status output
84
44
self._generate_status()
47
self.set_default_size(400, 300)
48
self.set_has_separator(False)
49
sw = gtk.ScrolledWindow()
50
sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
51
sw.set_shadow_type(gtk.SHADOW_IN)
52
self.treeview = gtk.TreeView()
54
self.vbox.pack_start(sw, True, True)
57
# sane border and spacing widths (as recommended by GNOME HIG)
58
self.set_border_width(5)
59
sw.set_border_width(5)
60
self.vbox.set_spacing(2)
61
self.action_area.set_border_width(5)
64
def row_diff(self, tv, path, tvc):
65
file = self.model[path][1]
68
from bzrlib.plugins.gtk.diff import DiffWindow
70
window.set_diff("Working tree changes", self.old_tree, self.wt)
86
75
def _generate_status(self):
87
76
""" Generate 'bzr status' output. """
88
77
self.model = gtk.TreeStore(str, str)
89
self.treeview = self.glade.get_widget('treeview_status')
78
self.treeview.set_headers_visible(False)
90
79
self.treeview.set_model(self.model)
80
self.treeview.connect("row-activated", self.row_diff)
92
82
cell = gtk.CellRendererText()
93
83
cell.set_property("width-chars", 20)
96
86
column.add_attribute(cell, "text", 0)
97
87
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)
89
delta = self.wt.changes_from(self.old_tree)
104
93
if len(delta.added):
105
titer = self.model.append(None, [ "Added", None ])
95
titer = self.model.append(None, [ _i18n('Added'), None ])
106
96
for path, id, kind in delta.added:
107
97
self.model.append(titer, [ path, path ])
109
99
if len(delta.removed):
110
titer = self.model.append(None, [ "Removed", None ])
101
titer = self.model.append(None, [ _i18n('Removed'), None ])
111
102
for path, id, kind in delta.removed:
112
103
self.model.append(titer, [ path, path ])
114
105
if len(delta.renamed):
115
titer = self.model.append(None, [ "Renamed", None ])
107
titer = self.model.append(None, [ _i18n('Renamed'), None ])
116
108
for oldpath, newpath, id, kind, text_modified, meta_modified \
117
109
in delta.renamed:
118
110
self.model.append(titer, [ oldpath, newpath ])
120
112
if len(delta.modified):
121
titer = self.model.append(None, [ "Modified", None ])
114
titer = self.model.append(None, [ _i18n('Modified'), None ])
122
115
for path, id, kind, text_modified, meta_modified in delta.modified:
123
116
self.model.append(titer, [ path, path ])
125
118
done_unknown = False
126
119
for path in self.wt.unknowns():
127
121
if not done_unknown:
128
titer = self.model.append(None, [ "Unknown", None ])
122
titer = self.model.append(None, [ _i18n('Unknown'), None ])
129
123
done_unknown = True
130
124
self.model.append(titer, [ path, path ])
127
self.model.append(None, [ _i18n('No changes.'), None ])
132
129
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
131
def close(self, widget=None):
142
132
self.window.destroy()