/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 commit.py

  • Committer: Aaron Bentley
  • Date: 2006-11-21 14:19:41 UTC
  • mfrom: (91.1.12 trunk)
  • mto: (66.6.5 gtk)
  • mto: This revision was merged to the branch mainline in revision 112.
  • Revision ID: abentley@panoramicfeedback.com-20061121141941-m82u7iqexarwirkv
MergeĀ fromĀ upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 Jelmer Vernooij <jelmer@samba.org>
2
 
 
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.
7
 
 
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.
12
 
 
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
16
 
 
17
 
import pygtk
18
 
pygtk.require("2.0")
19
 
import gobject
20
 
import gtk
21
 
import pango
22
 
 
23
 
import bzrlib
24
 
 
25
 
class GCommitDialog(gtk.Dialog):
26
 
    """ Commit Dialog """
27
 
 
28
 
    def __init__(self, tree):
29
 
        gtk.Dialog.__init__(self)
30
 
 
31
 
        self.set_default_size(400, 400)
32
 
 
33
 
        self.old_tree = tree.branch.repository.revision_tree(tree.branch.last_revision())
34
 
        self.pending_merges = tree.pending_merges()
35
 
        self.delta = tree.changes_from(self.old_tree)
36
 
 
37
 
        self._create()
38
 
 
39
 
    def _create_file_view(self):
40
 
        self.file_store = gtk.ListStore(gobject.TYPE_BOOLEAN, gobject.TYPE_STRING, gobject.TYPE_STRING)
41
 
        self.file_view = gtk.TreeView(self.file_store)
42
 
        crt = gtk.CellRendererToggle()
43
 
        crt.set_property("activatable", True)
44
 
        crt.connect("toggled", self._toggle_commit, self.file_store)
45
 
        self.file_view.append_column(gtk.TreeViewColumn("Commit", 
46
 
                                     crt, active=0))
47
 
        self.file_view.append_column(gtk.TreeViewColumn("Path", 
48
 
                                     gtk.CellRendererText(), text=1))
49
 
        self.file_view.append_column(gtk.TreeViewColumn("Type", 
50
 
                                     gtk.CellRendererText(), text=2))
51
 
 
52
 
        for path, _, _ in self.delta.added:
53
 
            self.file_store.append([ True, path, "Added" ])
54
 
 
55
 
        for path, _, _ in self.delta.removed:
56
 
            self.file_store.append([ True, path, "Removed" ])
57
 
 
58
 
        for oldpath, _, _, _, _, _ in self.delta.renamed:
59
 
            self.file_store.append([ True, oldpath, "Renamed"])
60
 
 
61
 
        for path, _, _, _, _ in self.delta.modified:
62
 
            self.file_store.append([ True, path, "Modified"])
63
 
 
64
 
        self.file_view.show()
65
 
 
66
 
    def _toggle_commit(self, cell, path, model):
67
 
        model[path][0] = not model[path][0]
68
 
        return
69
 
    
70
 
    def _get_specific_files(self):
71
 
        ret = []
72
 
        it = self.file_store.get_iter_first()
73
 
        while it:
74
 
            if self.file_store.get_value(it, 0):
75
 
                ret.append(self.file_store.get_value(it, 1))
76
 
            it = self.file_store.iter_next(it)
77
 
 
78
 
        return ret
79
 
 
80
 
    specific_files = property(_get_specific_files)
81
 
 
82
 
    def _create_pending_merge_view(self, merges):
83
 
        self.pending_merge_store = gtk.ListStore(gobject.TYPE_STRING)
84
 
        for revid in merges:
85
 
            self.pending_merge_store.append([revid])
86
 
        self.pending_merge_view = gtk.TreeView(self.pending_merge_store)
87
 
        self.pending_merge_view.show()
88
 
 
89
 
    def _create_message_box(self):
90
 
        self.message_entry = gtk.TextView()
91
 
        self.message_entry.show()
92
 
        return self.message_entry
93
 
 
94
 
    def _get_message(self):
95
 
        buffer = self.message_entry.get_buffer()
96
 
        return buffer.get_text(buffer.get_start_iter(), buffer.get_end_iter())
97
 
 
98
 
    message = property(_get_message)
99
 
 
100
 
    def _create(self):
101
 
        # Show list of changed files with checkboxes
102
 
        self._create_file_view()
103
 
        self.vbox.set_spacing(2)
104
 
        self.vbox.pack_start(self.file_view, expand=True, fill=True)
105
 
 
106
 
        # If_ there are any pending merges, show list of pending merges
107
 
        if self.pending_merges:
108
 
            self._create_pending_merge_view(self.pending_merges)
109
 
            self.vbox.pack_start(self.pending_merge_view, expand=True, fill=True)
110
 
 
111
 
        # Show box where user can add comments
112
 
        self._create_message_box()
113
 
        self.vbox.pack_start(self.message_entry, expand=True, fill=True)
114
 
 
115
 
        # Commit, Cancel buttons
116
 
        self.add_buttons(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, "_Commit", gtk.RESPONSE_OK)
117