bzr branch
http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz
| 
0.8.19
by Szilveszter Farkas (Phanatic)
 2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
1  | 
# Copyright (C) 2006 by Szilveszter Farkas (Phanatic) <szilveszter.farkas@gmail.com>
 | 
| 
0.8.46
by Szilveszter Farkas (Phanatic)
 Modified OliveDialog class interface; huge cleanups.  | 
2  | 
#
 | 
| 
0.8.19
by Szilveszter Farkas (Phanatic)
 2006-07-21 Szilveszter Farkas <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.
 | 
|
| 
0.8.46
by Szilveszter Farkas (Phanatic)
 Modified OliveDialog class interface; huge cleanups.  | 
7  | 
#
 | 
| 
0.8.19
by Szilveszter Farkas (Phanatic)
 2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
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.
 | 
|
| 
0.8.46
by Szilveszter Farkas (Phanatic)
 Modified OliveDialog class interface; huge cleanups.  | 
12  | 
#
 | 
| 
0.8.19
by Szilveszter Farkas (Phanatic)
 2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
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  | 
try:  | 
|
18  | 
import pygtk  | 
|
19  | 
pygtk.require("2.0")  | 
|
20  | 
except:  | 
|
21  | 
    pass
 | 
|
| 
0.8.98
by Szilveszter Farkas (Phanatic)
 Loads of fixes. Pyflakes cleanup.  | 
22  | 
|
| 
0.13.11
by Jelmer Vernooij
 Bunch of small fixes, cleanups and simplifications.  | 
23  | 
import gtk  | 
24  | 
import gtk.glade  | 
|
25  | 
import gobject  | 
|
26  | 
import pango  | 
|
| 
0.8.19
by Szilveszter Farkas (Phanatic)
 2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
27  | 
|
| 
0.8.20
by Szilveszter Farkas (Phanatic)
 2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
28  | 
import bzrlib.errors as errors  | 
29  | 
||
| 
0.13.3
by Jelmer Vernooij
 Start removing dialog context (it's not required).  | 
30  | 
from dialog import error_dialog  | 
| 
0.13.10
by Jelmer Vernooij
 Don't pass around gladefile all the time.  | 
31  | 
from olive import gladefile  | 
| 
0.13.3
by Jelmer Vernooij
 Start removing dialog context (it's not required).  | 
32  | 
|
| 
89
by Jelmer Vernooij
 Rename OliveBranch -> BranchDialog.  | 
33  | 
class CommitDialog:  | 
| 
0.8.19
by Szilveszter Farkas (Phanatic)
 2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
34  | 
""" Display Commit dialog and perform the needed actions. """  | 
| 
0.13.10
by Jelmer Vernooij
 Don't pass around gladefile all the time.  | 
35  | 
def __init__(self, wt, wtpath):  | 
| 
0.8.19
by Szilveszter Farkas (Phanatic)
 2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
36  | 
""" Initialize the Commit dialog. """  | 
| 
0.13.10
by Jelmer Vernooij
 Don't pass around gladefile all the time.  | 
37  | 
self.glade = gtk.glade.XML(gladefile, 'window_commit', 'olive-gtk')  | 
| 
0.8.19
by Szilveszter Farkas (Phanatic)
 2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
38  | 
|
| 
0.13.1
by Jelmer Vernooij
 Remove communicator use from Commit.  | 
39  | 
self.wt = wt  | 
40  | 
self.wtpath = wtpath  | 
|
41  | 
||
| 
0.8.55
by Szilveszter Farkas (Phanatic)
 Gettext support added.  | 
42  | 
        # Get some important widgets
 | 
| 
0.8.46
by Szilveszter Farkas (Phanatic)
 Modified OliveDialog class interface; huge cleanups.  | 
43  | 
self.window = self.glade.get_widget('window_commit')  | 
| 
0.8.55
by Szilveszter Farkas (Phanatic)
 Gettext support added.  | 
44  | 
self.checkbutton_local = self.glade.get_widget('checkbutton_commit_local')  | 
45  | 
self.textview = self.glade.get_widget('textview_commit')  | 
|
46  | 
self.file_view = self.glade.get_widget('treeview_commit_select')  | 
|
| 
0.8.46
by Szilveszter Farkas (Phanatic)
 Modified OliveDialog class interface; huge cleanups.  | 
47  | 
|
| 
0.13.1
by Jelmer Vernooij
 Remove communicator use from Commit.  | 
48  | 
file_id = self.wt.path2id(wtpath)  | 
| 
0.8.20
by Szilveszter Farkas (Phanatic)
 2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
49  | 
|
50  | 
self.notbranch = False  | 
|
51  | 
if file_id is None:  | 
|
52  | 
self.notbranch = True  | 
|
53  | 
            return
 | 
|
54  | 
||
55  | 
        # Set the delta
 | 
|
56  | 
self.old_tree = self.wt.branch.repository.revision_tree(self.wt.branch.last_revision())  | 
|
| 
0.13.6
by Jelmer Vernooij
 Don't pass along dialog context everywhere.  | 
57  | 
self.delta = self.wt.changes_from(self.old_tree)  | 
| 
0.8.20
by Szilveszter Farkas (Phanatic)
 2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
58  | 
|
| 
0.8.19
by Szilveszter Farkas (Phanatic)
 2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
59  | 
        # Dictionary for signal_autoconnect
 | 
60  | 
dic = { "on_button_commit_commit_clicked": self.commit,  | 
|
61  | 
"on_button_commit_cancel_clicked": self.close }  | 
|
62  | 
||
63  | 
        # Connect the signals to the handlers
 | 
|
64  | 
self.glade.signal_autoconnect(dic)  | 
|
| 
0.8.20
by Szilveszter Farkas (Phanatic)
 2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
65  | 
|
66  | 
        # Create the file list
 | 
|
67  | 
self._create_file_view()  | 
|
| 
0.8.19
by Szilveszter Farkas (Phanatic)
 2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
68  | 
|
69  | 
def display(self):  | 
|
70  | 
""" Display the Push dialog. """  | 
|
| 
0.8.20
by Szilveszter Farkas (Phanatic)
 2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
71  | 
if self.notbranch:  | 
| 
0.13.3
by Jelmer Vernooij
 Start removing dialog context (it's not required).  | 
72  | 
error_dialog(_('Directory is not a branch'),  | 
| 
0.8.98
by Szilveszter Farkas (Phanatic)
 Loads of fixes. Pyflakes cleanup.  | 
73  | 
_('You can perform this action only in a branch.'))  | 
| 
0.8.46
by Szilveszter Farkas (Phanatic)
 Modified OliveDialog class interface; huge cleanups.  | 
74  | 
self.close()  | 
| 
0.8.20
by Szilveszter Farkas (Phanatic)
 2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
75  | 
else:  | 
| 
0.13.1
by Jelmer Vernooij
 Remove communicator use from Commit.  | 
76  | 
if self.wt.branch.get_bound_location() is not None:  | 
| 
0.8.23
by Szilveszter Farkas (Phanatic)
 Visual feedback when Olive is busy; follow bzr API changes; commit dialog update  | 
77  | 
                # we have a checkout, so the local commit checkbox must appear
 | 
78  | 
self.checkbutton_local.show()  | 
|
79  | 
||
| 
0.8.26
by Szilveszter Farkas (Phanatic)
 Implemented Diff window; added menu.py (was missing from last commit)  | 
80  | 
self.textview.modify_font(pango.FontDescription("Monospace"))  | 
| 
0.8.23
by Szilveszter Farkas (Phanatic)
 Visual feedback when Olive is busy; follow bzr API changes; commit dialog update  | 
81  | 
self.window.show()  | 
82  | 
||
| 
0.8.20
by Szilveszter Farkas (Phanatic)
 2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
83  | 
|
84  | 
def _create_file_view(self):  | 
|
| 
0.8.21
by Szilveszter Farkas (Phanatic)
 2006-07-25 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
85  | 
self.file_store = gtk.ListStore(gobject.TYPE_BOOLEAN,  | 
86  | 
gobject.TYPE_STRING,  | 
|
87  | 
gobject.TYPE_STRING)  | 
|
| 
0.8.20
by Szilveszter Farkas (Phanatic)
 2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
88  | 
self.file_view.set_model(self.file_store)  | 
89  | 
crt = gtk.CellRendererToggle()  | 
|
90  | 
crt.set_property("activatable", True)  | 
|
91  | 
crt.connect("toggled", self._toggle_commit, self.file_store)  | 
|
| 
0.8.55
by Szilveszter Farkas (Phanatic)
 Gettext support added.  | 
92  | 
self.file_view.append_column(gtk.TreeViewColumn(_('Commit'),  | 
| 
0.8.21
by Szilveszter Farkas (Phanatic)
 2006-07-25 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
93  | 
crt, active=0))  | 
| 
0.8.55
by Szilveszter Farkas (Phanatic)
 Gettext support added.  | 
94  | 
self.file_view.append_column(gtk.TreeViewColumn(_('Path'),  | 
| 
0.8.21
by Szilveszter Farkas (Phanatic)
 2006-07-25 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
95  | 
gtk.CellRendererText(), text=1))  | 
| 
0.8.55
by Szilveszter Farkas (Phanatic)
 Gettext support added.  | 
96  | 
self.file_view.append_column(gtk.TreeViewColumn(_('Type'),  | 
| 
0.8.21
by Szilveszter Farkas (Phanatic)
 2006-07-25 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
97  | 
gtk.CellRendererText(), text=2))  | 
| 
0.8.20
by Szilveszter Farkas (Phanatic)
 2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
98  | 
|
| 
0.8.55
by Szilveszter Farkas (Phanatic)
 Gettext support added.  | 
99  | 
for path, id, kind in self.delta.added:  | 
100  | 
self.file_store.append([ True, path, _('added') ])  | 
|
101  | 
||
102  | 
for path, id, kind in self.delta.removed:  | 
|
103  | 
self.file_store.append([ True, path, _('removed') ])  | 
|
104  | 
||
105  | 
for oldpath, newpath, id, kind, text_modified, meta_modified in self.delta.renamed:  | 
|
106  | 
self.file_store.append([ True, oldpath, _('renamed') ])  | 
|
107  | 
||
108  | 
for path, id, kind, text_modified, meta_modified in self.delta.modified:  | 
|
109  | 
self.file_store.append([ True, path, _('modified') ])  | 
|
| 
0.8.20
by Szilveszter Farkas (Phanatic)
 2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
110  | 
|
111  | 
def _get_specific_files(self):  | 
|
112  | 
ret = []  | 
|
113  | 
it = self.file_store.get_iter_first()  | 
|
114  | 
while it:  | 
|
115  | 
if self.file_store.get_value(it, 0):  | 
|
| 
0.8.21
by Szilveszter Farkas (Phanatic)
 2006-07-25 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
116  | 
ret.append(self.file_store.get_value(it, 1))  | 
| 
0.8.20
by Szilveszter Farkas (Phanatic)
 2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
117  | 
it = self.file_store.iter_next(it)  | 
118  | 
||
119  | 
return ret  | 
|
120  | 
||
121  | 
def _toggle_commit(self, cell, path, model):  | 
|
122  | 
model[path][0] = not model[path][0]  | 
|
123  | 
        return
 | 
|
| 
0.8.19
by Szilveszter Farkas (Phanatic)
 2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
124  | 
|
125  | 
def commit(self, widget):  | 
|
| 
0.8.26
by Szilveszter Farkas (Phanatic)
 Implemented Diff window; added menu.py (was missing from last commit)  | 
126  | 
textbuffer = self.textview.get_buffer()  | 
| 
0.8.19
by Szilveszter Farkas (Phanatic)
 2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
127  | 
start, end = textbuffer.get_bounds()  | 
128  | 
message = textbuffer.get_text(start, end)  | 
|
129  | 
||
130  | 
checkbutton_strict = self.glade.get_widget('checkbutton_commit_strict')  | 
|
131  | 
checkbutton_force = self.glade.get_widget('checkbutton_commit_force')  | 
|
132  | 
||
| 
0.8.20
by Szilveszter Farkas (Phanatic)
 2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
133  | 
specific_files = self._get_specific_files()  | 
134  | 
||
| 
0.8.19
by Szilveszter Farkas (Phanatic)
 2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
135  | 
try:  | 
| 
0.8.20
by Szilveszter Farkas (Phanatic)
 2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
136  | 
self.wt.commit(message,  | 
137  | 
allow_pointless=checkbutton_force.get_active(),  | 
|
138  | 
strict=checkbutton_strict.get_active(),  | 
|
| 
0.8.23
by Szilveszter Farkas (Phanatic)
 Visual feedback when Olive is busy; follow bzr API changes; commit dialog update  | 
139  | 
local=self.checkbutton_local.get_active(),  | 
| 
0.8.20
by Szilveszter Farkas (Phanatic)
 2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
140  | 
specific_files=specific_files)  | 
| 
0.8.19
by Szilveszter Farkas (Phanatic)
 2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
141  | 
except errors.NotBranchError:  | 
| 
0.13.3
by Jelmer Vernooij
 Start removing dialog context (it's not required).  | 
142  | 
error_dialog(_('Directory is not a branch'),  | 
| 
0.8.98
by Szilveszter Farkas (Phanatic)
 Loads of fixes. Pyflakes cleanup.  | 
143  | 
_('You can perform this action only in a branch.'))  | 
| 
0.8.19
by Szilveszter Farkas (Phanatic)
 2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
144  | 
            return
 | 
145  | 
except errors.LocalRequiresBoundBranch:  | 
|
| 
0.13.3
by Jelmer Vernooij
 Start removing dialog context (it's not required).  | 
146  | 
error_dialog(_('Directory is not a checkout'),  | 
| 
0.8.98
by Szilveszter Farkas (Phanatic)
 Loads of fixes. Pyflakes cleanup.  | 
147  | 
_('You can perform local commit only on checkouts.'))  | 
| 
0.8.20
by Szilveszter Farkas (Phanatic)
 2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
148  | 
            return
 | 
149  | 
except errors.PointlessCommit:  | 
|
| 
0.13.3
by Jelmer Vernooij
 Start removing dialog context (it's not required).  | 
150  | 
error_dialog(_('No changes to commit'),  | 
| 
0.8.98
by Szilveszter Farkas (Phanatic)
 Loads of fixes. Pyflakes cleanup.  | 
151  | 
_('Try force commit if you want to commit anyway.'))  | 
| 
0.8.20
by Szilveszter Farkas (Phanatic)
 2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
152  | 
            return
 | 
153  | 
except errors.ConflictsInTree:  | 
|
| 
0.13.3
by Jelmer Vernooij
 Start removing dialog context (it's not required).  | 
154  | 
error_dialog(_('Conflicts in tree'),  | 
| 
0.8.98
by Szilveszter Farkas (Phanatic)
 Loads of fixes. Pyflakes cleanup.  | 
155  | 
_('You need to resolve the conflicts before committing.'))  | 
| 
0.8.20
by Szilveszter Farkas (Phanatic)
 2006-07-24 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
156  | 
            return
 | 
157  | 
except errors.StrictCommitFailed:  | 
|
| 
0.13.3
by Jelmer Vernooij
 Start removing dialog context (it's not required).  | 
158  | 
error_dialog(_('Strict commit failed'),  | 
| 
0.8.98
by Szilveszter Farkas (Phanatic)
 Loads of fixes. Pyflakes cleanup.  | 
159  | 
_('There are unknown files in the working tree.\nPlease add or delete them.'))  | 
| 
0.8.19
by Szilveszter Farkas (Phanatic)
 2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
160  | 
            return
 | 
161  | 
except errors.BoundBranchOutOfDate, errmsg:  | 
|
| 
0.13.3
by Jelmer Vernooij
 Start removing dialog context (it's not required).  | 
162  | 
error_dialog(_('Bound branch is out of date'),  | 
| 
0.8.98
by Szilveszter Farkas (Phanatic)
 Loads of fixes. Pyflakes cleanup.  | 
163  | 
_('%s') % errmsg)  | 
| 
0.8.19
by Szilveszter Farkas (Phanatic)
 2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
164  | 
            return
 | 
| 
0.13.2
by Jelmer Vernooij
 Handle unknown errors in commit.  | 
165  | 
except errors.BzrError, msg:  | 
| 
0.13.4
by Jelmer Vernooij
 Handle non-bzr unknown errors as well.  | 
166  | 
error_dialog(_('Unknown bzr error'), str(msg))  | 
167  | 
            return
 | 
|
168  | 
except Exception, msg:  | 
|
| 
0.13.3
by Jelmer Vernooij
 Start removing dialog context (it's not required).  | 
169  | 
error_dialog(_('Unknown error'), str(msg))  | 
| 
0.13.2
by Jelmer Vernooij
 Handle unknown errors in commit.  | 
170  | 
            return
 | 
| 
0.8.19
by Szilveszter Farkas (Phanatic)
 2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>  | 
171  | 
|
172  | 
self.close()  | 
|
173  | 
||
174  | 
def close(self, widget=None):  | 
|
175  | 
self.window.destroy()  |