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

[merge] Alexander

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
import pango
27
27
 
28
28
import bzrlib.errors as errors
 
29
from bzrlib import osutils
29
30
 
30
31
from dialog import error_dialog
31
 
from olive import gladefile
 
32
from guifiles import GLADEFILENAME
 
33
 
32
34
 
33
35
class CommitDialog:
34
36
    """ Display Commit dialog and perform the needed actions. """
35
 
    def __init__(self, wt, wtpath):
36
 
        """ Initialize the Commit dialog. """
37
 
        self.glade = gtk.glade.XML(gladefile, 'window_commit', 'olive-gtk')
 
37
    def __init__(self, wt, wtpath, standalone=False):
 
38
        """ Initialize the Commit dialog.
 
39
        @param  wt:         bzr working tree object
 
40
        @param  wtpath:     path to working tree root
 
41
        @param  standalone: when used in gcommit command as standalone window
 
42
                            this argument should be True
 
43
        """
 
44
        self.glade = gtk.glade.XML(GLADEFILENAME, 'window_commit', 'olive-gtk')
38
45
        
39
46
        self.wt = wt
40
47
        self.wtpath = wtpath
41
48
 
 
49
        self.standalone = standalone
 
50
 
42
51
        # Get some important widgets
43
52
        self.window = self.glade.get_widget('window_commit')
44
53
        self.checkbutton_local = self.glade.get_widget('checkbutton_commit_local')
64
73
        # Dictionary for signal_autoconnect
65
74
        dic = { "on_button_commit_commit_clicked": self.commit,
66
75
                "on_button_commit_cancel_clicked": self.close }
 
76
 
 
77
        if self.standalone:
 
78
            dic["on_button_commit_cancel_clicked"] = self.quit
 
79
            self.window.connect("delete_event", gtk.main_quit)
67
80
        
68
81
        # Connect the signals to the handlers
69
82
        self.glade.signal_autoconnect(dic)
96
109
            
97
110
    
98
111
    def _create_file_view(self):
99
 
        self.file_store = gtk.ListStore(gobject.TYPE_BOOLEAN,
100
 
                                        gobject.TYPE_STRING,
101
 
                                        gobject.TYPE_STRING)
 
112
        self.file_store = gtk.ListStore(gobject.TYPE_BOOLEAN,   # [0] checkbox
 
113
                                        gobject.TYPE_STRING,    # [1] path to display
 
114
                                        gobject.TYPE_STRING,    # [2] changes type
 
115
                                        gobject.TYPE_STRING)    # [3] real path
102
116
        self.file_view.set_model(self.file_store)
103
117
        crt = gtk.CellRendererToggle()
104
118
        crt.set_property("activatable", True)
111
125
                                     gtk.CellRendererText(), text=2))
112
126
 
113
127
        for path, id, kind in self.delta.added:
114
 
            self.file_store.append([ True, path, _('added') ])
 
128
            marker = osutils.kind_marker(kind)
 
129
            self.file_store.append([ True, path+marker, _('added'), path ])
115
130
 
116
131
        for path, id, kind in self.delta.removed:
117
 
            self.file_store.append([ True, path, _('removed') ])
 
132
            marker = osutils.kind_marker(kind)
 
133
            self.file_store.append([ True, path+marker, _('removed'), path ])
118
134
 
119
135
        for oldpath, newpath, id, kind, text_modified, meta_modified in self.delta.renamed:
120
 
            self.file_store.append([ True, oldpath, _('renamed') ])
 
136
            marker = osutils.kind_marker(kind)
 
137
            if text_modified or meta_modified:
 
138
                changes = _('renamed and modified')
 
139
            else:
 
140
                changes = _('renamed')
 
141
            self.file_store.append([ True,
 
142
                                     oldpath+marker + '  =>  ' + newpath+marker,
 
143
                                     changes,
 
144
                                     newpath
 
145
                                   ])
121
146
 
122
147
        for path, id, kind, text_modified, meta_modified in self.delta.modified:
123
 
            self.file_store.append([ True, path, _('modified') ])
 
148
            marker = osutils.kind_marker(kind)
 
149
            self.file_store.append([ True, path+marker, _('modified'), path ])
124
150
    
125
151
    def _create_pending_merges(self):
126
152
        liststore = gtk.ListStore(gobject.TYPE_STRING,
148
174
        it = self.file_store.get_iter_first()
149
175
        while it:
150
176
            if self.file_store.get_value(it, 0):
151
 
                ret.append(self.file_store.get_value(it, 1))
 
177
                # get real path from hidden column 3
 
178
                ret.append(self.file_store.get_value(it, 3))
152
179
            it = self.file_store.iter_next(it)
153
180
 
154
181
        return ret
224
251
    def commit(self, widget):
225
252
        textbuffer = self.textview.get_buffer()
226
253
        start, end = textbuffer.get_bounds()
227
 
        message = textbuffer.get_text(start, end)
 
254
        message = textbuffer.get_text(start, end).decode('utf-8')
228
255
        
229
256
        checkbutton_strict = self.glade.get_widget('checkbutton_commit_strict')
230
257
        checkbutton_force = self.glade.get_widget('checkbutton_commit_force')
270
297
        except Exception, msg:
271
298
            error_dialog(_('Unknown error'), str(msg))
272
299
            return
273
 
        
274
 
        self.close()
 
300
 
 
301
        if not self.standalone:
 
302
            self.close()
 
303
        else:
 
304
            self.quit()
275
305
        
276
306
    def close(self, widget=None):
277
307
        self.window.destroy()
 
308
 
 
309
    def quit(self, widget=None):
 
310
        self.close(widget)
 
311
        gtk.main_quit()