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

  • Committer: Szilveszter Farkas (Phanatic)
  • Date: 2006-08-15 17:37:54 UTC
  • mto: (0.14.1 main) (93.1.1 win32.bialix)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: Szilveszter.Farkas@gmail.com-20060815173754-9877ef0e3e64660e
Some small tweaks in the .desktop file.

2006-08-15  Szilveszter Farkas <Szilveszter.Farkas@gmail.com>

    * icons/olive-gtk.png: added application icon

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
    pygtk.require("2.0")
22
22
except:
23
23
    pass
24
 
import gtk
25
 
import gtk.glade
26
 
import gobject
27
 
import pango
28
 
 
29
 
from bzrlib import version_info
 
24
try:
 
25
    import gtk
 
26
    import gtk.glade
 
27
    import gobject
 
28
    import pango
 
29
except:
 
30
    sys.exit(1)
 
31
 
 
32
import bzrlib
 
33
 
 
34
if bzrlib.version_info < (0, 9):
 
35
    # function deprecated after 0.9
 
36
    from bzrlib.delta import compare_trees
30
37
 
31
38
import bzrlib.errors as errors
32
39
from bzrlib.workingtree import WorkingTree
33
40
 
34
 
from dialog import error_dialog
35
 
from olive import gladefile
36
 
 
37
41
class OliveCommit:
38
42
    """ Display Commit dialog and perform the needed actions. """
39
 
    def __init__(self, wt, wtpath):
 
43
    def __init__(self, gladefile, comm, dialog):
40
44
        """ Initialize the Commit dialog. """
41
 
        self.glade = gtk.glade.XML(gladefile, 'window_commit', 'olive-gtk')
42
 
        
43
 
        self.wt = wt
44
 
        self.wtpath = wtpath
45
 
 
46
 
        # Get some important widgets
 
45
        self.gladefile = gladefile
 
46
        self.glade = gtk.glade.XML(self.gladefile, 'window_commit')
 
47
        
 
48
        # Communication object
 
49
        self.comm = comm
 
50
        # Dialog object
 
51
        self.dialog = dialog
 
52
        
 
53
        # Get the Commit dialog widget
47
54
        self.window = self.glade.get_widget('window_commit')
48
 
        self.checkbutton_local = self.glade.get_widget('checkbutton_commit_local')
49
 
        self.textview = self.glade.get_widget('textview_commit')
50
 
        self.file_view = self.glade.get_widget('treeview_commit_select')
51
 
 
52
 
        file_id = self.wt.path2id(wtpath)
 
55
 
 
56
        # Check if current location is a branch
 
57
        try:
 
58
            (self.wt, path) = WorkingTree.open_containing(self.comm.get_path())
 
59
            branch = self.wt.branch
 
60
        except errors.NotBranchError:
 
61
            self.notbranch = True
 
62
            return
 
63
        except:
 
64
            raise
 
65
 
 
66
        file_id = self.wt.path2id(path)
53
67
 
54
68
        self.notbranch = False
55
69
        if file_id is None:
58
72
        
59
73
        # Set the delta
60
74
        self.old_tree = self.wt.branch.repository.revision_tree(self.wt.branch.last_revision())
61
 
        self.delta = self.wt.changes_from(self.old_tree)
 
75
        if bzrlib.version_info < (0, 9):
 
76
            self.delta = compare_trees(self.old_tree, self.wt)
 
77
        else:
 
78
            self.delta = self.wt.changes_from(self.old_tree)
62
79
        
63
80
        # Dictionary for signal_autoconnect
64
81
        dic = { "on_button_commit_commit_clicked": self.commit,
69
86
        
70
87
        # Create the file list
71
88
        self._create_file_view()
 
89
        
 
90
        # Some additional widgets
 
91
        self.checkbutton_local = self.glade.get_widget('checkbutton_commit_local')
 
92
        self.textview = self.glade.get_widget('textview_commit')
72
93
    
73
94
    def display(self):
74
95
        """ Display the Push dialog. """
75
96
        if self.notbranch:
76
 
            error_dialog(_('Directory is not a branch'),
77
 
                                     _('You can perform this action only in a branch.'))
 
97
            self.dialog.error_dialog('Directory is not a branch',
 
98
                                     'You can perform this action only in a branch.')
78
99
            self.close()
79
100
        else:
80
 
            if self.wt.branch.get_bound_location() is not None:
 
101
            from olive.backend.info import is_checkout
 
102
            if is_checkout(self.comm.get_path()):
81
103
                # we have a checkout, so the local commit checkbox must appear
82
104
                self.checkbutton_local.show()
83
105
            
85
107
            self.window.show()
86
108
            
87
109
    
 
110
    # This code is from Jelmer Vernooij's bzr-gtk branch
88
111
    def _create_file_view(self):
89
112
        self.file_store = gtk.ListStore(gobject.TYPE_BOOLEAN,
90
113
                                        gobject.TYPE_STRING,
91
114
                                        gobject.TYPE_STRING)
 
115
        self.file_view = self.glade.get_widget('treeview_commit_select')
92
116
        self.file_view.set_model(self.file_store)
93
117
        crt = gtk.CellRendererToggle()
94
118
        crt.set_property("activatable", True)
95
119
        crt.connect("toggled", self._toggle_commit, self.file_store)
96
 
        self.file_view.append_column(gtk.TreeViewColumn(_('Commit'),
 
120
        self.file_view.append_column(gtk.TreeViewColumn("Commit",
97
121
                                     crt, active=0))
98
 
        self.file_view.append_column(gtk.TreeViewColumn(_('Path'),
 
122
        self.file_view.append_column(gtk.TreeViewColumn("Path",
99
123
                                     gtk.CellRendererText(), text=1))
100
 
        self.file_view.append_column(gtk.TreeViewColumn(_('Type'),
 
124
        self.file_view.append_column(gtk.TreeViewColumn("Type",
101
125
                                     gtk.CellRendererText(), text=2))
102
126
 
103
 
        for path, id, kind in self.delta.added:
104
 
            self.file_store.append([ True, path, _('added') ])
105
 
 
106
 
        for path, id, kind in self.delta.removed:
107
 
            self.file_store.append([ True, path, _('removed') ])
108
 
 
109
 
        for oldpath, newpath, id, kind, text_modified, meta_modified in self.delta.renamed:
110
 
            self.file_store.append([ True, oldpath, _('renamed') ])
111
 
 
112
 
        for path, id, kind, text_modified, meta_modified in self.delta.modified:
113
 
            self.file_store.append([ True, path, _('modified') ])
 
127
        for path, _, _ in self.delta.added:
 
128
            self.file_store.append([ True, path, "added" ])
 
129
 
 
130
        for path, _, _ in self.delta.removed:
 
131
            self.file_store.append([ True, path, "removed" ])
 
132
 
 
133
        for oldpath, _, _, _, _, _ in self.delta.renamed:
 
134
            self.file_store.append([ True, oldpath, "renamed"])
 
135
 
 
136
        for path, _, _, _, _ in self.delta.modified:
 
137
            self.file_store.append([ True, path, "modified"])
114
138
    
115
139
    def _get_specific_files(self):
116
140
        ret = []
121
145
            it = self.file_store.iter_next(it)
122
146
 
123
147
        return ret
 
148
    # end of bzr-gtk code
124
149
    
125
150
    def _toggle_commit(self, cell, path, model):
126
151
        model[path][0] = not model[path][0]
136
161
        
137
162
        specific_files = self._get_specific_files()
138
163
        
 
164
        self.comm.set_busy(self.window)
 
165
        # merged from Jelmer Vernooij's olive integration branch
139
166
        try:
140
167
            self.wt.commit(message, 
141
168
                           allow_pointless=checkbutton_force.get_active(),
143
170
                           local=self.checkbutton_local.get_active(),
144
171
                           specific_files=specific_files)
145
172
        except errors.NotBranchError:
146
 
            error_dialog(_('Directory is not a branch'),
147
 
                                     _('You can perform this action only in a branch.'))
 
173
            self.dialog.error_dialog('Directory is not a branch',
 
174
                                     'You can perform this action only in a branch.')
 
175
            self.comm.set_busy(self.window, False)
148
176
            return
149
177
        except errors.LocalRequiresBoundBranch:
150
 
            error_dialog(_('Directory is not a checkout'),
151
 
                                     _('You can perform local commit only on checkouts.'))
 
178
            self.dialog.error_dialog('Directory is not a checkout',
 
179
                                     'You can perform local commit only on checkouts.')
 
180
            self.comm.set_busy(self.window, False)
152
181
            return
153
182
        except errors.PointlessCommit:
154
 
            error_dialog(_('No changes to commit'),
155
 
                                     _('Try force commit if you want to commit anyway.'))
 
183
            self.dialog.error_dialog('No changes to commit',
 
184
                                     'Try force commit if you want to commit anyway.')
 
185
            self.comm.set_busy(self.window, False)
156
186
            return
157
187
        except errors.ConflictsInTree:
158
 
            error_dialog(_('Conflicts in tree'),
159
 
                                     _('You need to resolve the conflicts before committing.'))
 
188
            self.dialog.error_dialog('Conflicts in tree'
 
189
                                     'You need to resolve the conflicts before committing.')
 
190
            self.comm.set_busy(self.window, False)
160
191
            return
161
192
        except errors.StrictCommitFailed:
162
 
            error_dialog(_('Strict commit failed'),
163
 
                                     _('There are unknown files in the working tree.\nPlease add or delete them.'))
 
193
            self.dialog.error_dialog('Strict commit failed'
 
194
                                     'There are unknown files in the working tree.\nPlease add or delete them.')
 
195
            self.comm.set_busy(self.window, False)
164
196
            return
165
197
        except errors.BoundBranchOutOfDate, errmsg:
166
 
            error_dialog(_('Bound branch is out of date'),
167
 
                                     _('%s') % errmsg)
168
 
            return
169
 
        except errors.BzrError, msg:
170
 
            error_dialog(_('Unknown bzr error'), str(msg))
171
 
            return
172
 
        except Exception, msg:
173
 
            error_dialog(_('Unknown error'), str(msg))
174
 
            return
 
198
            self.dialog.error_dialog('Bound branch is out of date',
 
199
                                     '%s' % errmsg)
 
200
            self.comm.set_busy(self.window, False)
 
201
            return
 
202
        except:
 
203
            raise
175
204
        
176
205
        self.close()
 
206
        self.comm.refresh_right()
177
207
        
178
208
    def close(self, widget=None):
179
209
        self.window.destroy()