/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-09 17:43:44 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-20060809174344-61ca8dac23ebe7cb
Main window preferences (size, position) are stored.

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

    * olive/frontend/gtk/__init__.py: simplified preference handling
    * olive/frontend/gtk/handler.py: window preferences are stored on quit

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright (C) 2006 by Szilveszter Farkas (Phanatic) <szilveszter.farkas@gmail.com>
2
 
#
 
2
 
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
5
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
7
 
#
 
7
 
8
8
# This program is distributed in the hope that it will be useful,
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
11
# GNU General Public License for more details.
12
 
#
 
12
 
13
13
# You should have received a copy of the GNU General Public License
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
29
29
except:
30
30
    sys.exit(1)
31
31
 
32
 
from bzrlib import version_info
 
32
import bzrlib
33
33
 
34
 
if version_info < (0, 9):
 
34
if bzrlib.version_info[1] < 9:
35
35
    # function deprecated after 0.9
36
36
    from bzrlib.delta import compare_trees
37
37
 
38
38
import bzrlib.errors as errors
39
39
from bzrlib.workingtree import WorkingTree
40
40
 
 
41
from dialog import OliveDialog
 
42
 
41
43
class OliveCommit:
42
44
    """ Display Commit dialog and perform the needed actions. """
43
 
    def __init__(self, gladefile, comm, dialog):
 
45
    def __init__(self, gladefile, comm):
44
46
        """ Initialize the Commit dialog. """
45
47
        self.gladefile = gladefile
46
 
        self.glade = gtk.glade.XML(self.gladefile, 'window_commit', 'olive-gtk')
 
48
        self.glade = gtk.glade.XML(self.gladefile, 'window_commit')
47
49
        
48
 
        # Communication object
49
50
        self.comm = comm
50
 
        # Dialog object
51
 
        self.dialog = dialog
52
 
        
53
 
        # Get some important widgets
54
 
        self.window = self.glade.get_widget('window_commit')
55
 
        self.checkbutton_local = self.glade.get_widget('checkbutton_commit_local')
56
 
        self.textview = self.glade.get_widget('textview_commit')
57
 
        self.file_view = self.glade.get_widget('treeview_commit_select')
58
 
 
 
51
        
 
52
        self.dialog = OliveDialog(self.gladefile)
 
53
        
59
54
        # Check if current location is a branch
60
55
        try:
61
56
            (self.wt, path) = WorkingTree.open_containing(self.comm.get_path())
75
70
        
76
71
        # Set the delta
77
72
        self.old_tree = self.wt.branch.repository.revision_tree(self.wt.branch.last_revision())
78
 
        if version_info < (0, 9):
 
73
        if bzrlib.version_info[1] < 9:
79
74
            self.delta = compare_trees(self.old_tree, self.wt)
80
75
        else:
81
76
            self.delta = self.wt.changes_from(self.old_tree)
82
77
        
 
78
        # Get the Commit dialog widget
 
79
        self.window = self.glade.get_widget('window_commit')
 
80
        
83
81
        # Dictionary for signal_autoconnect
84
82
        dic = { "on_button_commit_commit_clicked": self.commit,
85
83
                "on_button_commit_cancel_clicked": self.close }
89
87
        
90
88
        # Create the file list
91
89
        self._create_file_view()
 
90
        
 
91
        # Some additional widgets
 
92
        self.checkbutton_local = self.glade.get_widget('checkbutton_commit_local')
 
93
        self.textview = self.glade.get_widget('textview_commit')
92
94
    
93
95
    def display(self):
94
96
        """ Display the Push dialog. """
95
97
        if self.notbranch:
96
 
            self.dialog.error_dialog(_('Directory is not a branch'),
97
 
                                     _('You can perform this action only in a branch.'))
98
 
            self.close()
 
98
            self.dialog.error_dialog('Directory is not a branch.')
99
99
        else:
100
100
            from olive.backend.info import is_checkout
101
101
            if is_checkout(self.comm.get_path()):
111
111
        self.file_store = gtk.ListStore(gobject.TYPE_BOOLEAN,
112
112
                                        gobject.TYPE_STRING,
113
113
                                        gobject.TYPE_STRING)
 
114
        self.file_view = self.glade.get_widget('treeview_commit_select')
114
115
        self.file_view.set_model(self.file_store)
115
116
        crt = gtk.CellRendererToggle()
116
117
        crt.set_property("activatable", True)
117
118
        crt.connect("toggled", self._toggle_commit, self.file_store)
118
 
        self.file_view.append_column(gtk.TreeViewColumn(_('Commit'),
 
119
        self.file_view.append_column(gtk.TreeViewColumn("Commit",
119
120
                                     crt, active=0))
120
 
        self.file_view.append_column(gtk.TreeViewColumn(_('Path'),
 
121
        self.file_view.append_column(gtk.TreeViewColumn("Path",
121
122
                                     gtk.CellRendererText(), text=1))
122
 
        self.file_view.append_column(gtk.TreeViewColumn(_('Type'),
 
123
        self.file_view.append_column(gtk.TreeViewColumn("Type",
123
124
                                     gtk.CellRendererText(), text=2))
124
125
 
125
 
        for path, id, kind in self.delta.added:
126
 
            self.file_store.append([ True, path, _('added') ])
127
 
 
128
 
        for path, id, kind in self.delta.removed:
129
 
            self.file_store.append([ True, path, _('removed') ])
130
 
 
131
 
        for oldpath, newpath, id, kind, text_modified, meta_modified in self.delta.renamed:
132
 
            self.file_store.append([ True, oldpath, _('renamed') ])
133
 
 
134
 
        for path, id, kind, text_modified, meta_modified in self.delta.modified:
135
 
            self.file_store.append([ True, path, _('modified') ])
 
126
        for path, _, _ in self.delta.added:
 
127
            self.file_store.append([ True, path, "added" ])
 
128
 
 
129
        for path, _, _ in self.delta.removed:
 
130
            self.file_store.append([ True, path, "removed" ])
 
131
 
 
132
        for oldpath, _, _, _, _, _ in self.delta.renamed:
 
133
            self.file_store.append([ True, oldpath, "renamed"])
 
134
 
 
135
        for path, _, _, _, _ in self.delta.modified:
 
136
            self.file_store.append([ True, path, "modified"])
136
137
    
137
138
    def _get_specific_files(self):
138
139
        ret = []
168
169
                           local=self.checkbutton_local.get_active(),
169
170
                           specific_files=specific_files)
170
171
        except errors.NotBranchError:
171
 
            self.dialog.error_dialog(_('Directory is not a branch'),
172
 
                                     _('You can perform this action only in a branch.'))
 
172
            self.dialog.error_dialog('Directory is not a branch.')
173
173
            self.comm.set_busy(self.window, False)
174
174
            return
175
175
        except errors.LocalRequiresBoundBranch:
176
 
            self.dialog.error_dialog(_('Directory is not a checkout'),
177
 
                                     _('You can perform local commit only on checkouts.'))
 
176
            self.dialog.error_dialog('Local commit requires a bound branch.')
178
177
            self.comm.set_busy(self.window, False)
179
178
            return
180
179
        except errors.PointlessCommit:
181
 
            self.dialog.error_dialog(_('No changes to commit'),
182
 
                                     _('Try force commit if you want to commit anyway.'))
 
180
            self.dialog.error_dialog('No changes to commit. Try force commit.')
183
181
            self.comm.set_busy(self.window, False)
184
182
            return
185
183
        except errors.ConflictsInTree:
186
 
            self.dialog.error_dialog(_('Conflicts in tree'),
187
 
                                     _('You need to resolve the conflicts before committing.'))
 
184
            self.dialog.error_dialog('Conflicts in tree. Please resolve them first.')
188
185
            self.comm.set_busy(self.window, False)
189
186
            return
190
187
        except errors.StrictCommitFailed:
191
 
            self.dialog.error_dialog(_('Strict commit failed'),
192
 
                                     _('There are unknown files in the working tree.\nPlease add or delete them.'))
 
188
            self.dialog.error_dialog('Strict commit failed. There are unknown files.')
193
189
            self.comm.set_busy(self.window, False)
194
190
            return
195
191
        except errors.BoundBranchOutOfDate, errmsg:
196
 
            self.dialog.error_dialog(_('Bound branch is out of date'),
197
 
                                     _('%s') % errmsg)
 
192
            self.dialog.error_dialog('Bound branch is out of date: %s' % errmsg)
198
193
            self.comm.set_busy(self.window, False)
199
194
            return
200
195
        except: