/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz
0.8.12 by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
1
# Copyright (C) 2006 by Szilveszter Farkas (Phanatic) <szilveszter.farkas@gmail.com>
0.8.29 by Szilveszter Farkas (Phanatic)
Implemented Status window; some code cleanups.
2
#
0.8.12 by Szilveszter Farkas (Phanatic)
2006-07-17 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.29 by Szilveszter Farkas (Phanatic)
Implemented Status window; some code cleanups.
7
#
0.8.12 by Szilveszter Farkas (Phanatic)
2006-07-17 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.29 by Szilveszter Farkas (Phanatic)
Implemented Status window; some code cleanups.
12
#
0.8.12 by Szilveszter Farkas (Phanatic)
2006-07-17 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
0.8.77 by Szilveszter Farkas (Phanatic)
Implemented drive selector for Win32 platforms.
17
import os
0.8.12 by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
18
import sys
19
20
try:
0.8.14 by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
21
    import pygtk
22
    pygtk.require("2.0")
0.8.12 by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
23
except:
0.8.14 by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
24
    pass
0.8.12 by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
25
try:
0.8.14 by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
26
    import gtk
27
    import gtk.glade
0.8.12 by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
28
except:
0.8.14 by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
29
    sys.exit(1)
0.8.12 by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
30
0.11.1 by Jelmer Vernooij
Eliminate olive.backend.errors.
31
import bzrlib.errors as errors
0.11.5 by Jelmer Vernooij
Eliminate olive.backend.update
32
from bzrlib.branch import Branch
0.12.1 by Jelmer Vernooij
Don't use communicator for status.
33
from bzrlib.workingtree import WorkingTree
0.8.19 by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
34
0.8.13 by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
35
from dialog import OliveDialog
0.8.24 by Szilveszter Farkas (Phanatic)
Implemented context menu for the file list.
36
from menu import OliveMenu
0.8.72 by Szilveszter Farkas (Phanatic)
Merge from Richard Ferguson's development branch.
37
from launch import launch
0.8.13 by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
38
0.8.12 by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
39
class OliveHandler:
40
    """ Signal handler class for Olive. """
0.8.15 by Szilveszter Farkas (Phanatic)
2006-07-18 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
41
    def __init__(self, gladefile, comm):
0.8.12 by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
42
        self.gladefile = gladefile
0.8.15 by Szilveszter Farkas (Phanatic)
2006-07-18 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
43
        self.comm = comm
44
        
0.8.13 by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
45
        self.dialog = OliveDialog(self.gladefile)
0.8.24 by Szilveszter Farkas (Phanatic)
Implemented context menu for the file list.
46
        
47
        self.menu = OliveMenu(self.gladefile, self.comm, self.dialog)
0.8.13 by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
48
    
49
    def on_about_activate(self, widget):
50
        self.dialog.about()
0.8.14 by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
51
        
0.8.19 by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
52
    def on_menuitem_add_files_activate(self, widget):
53
        """ Add file(s)... menu handler. """
0.8.36 by Szilveszter Farkas (Phanatic)
Implemented pull functionality.
54
        from add import OliveAdd
0.8.46 by Szilveszter Farkas (Phanatic)
Modified OliveDialog class interface; huge cleanups.
55
        add = OliveAdd(self.gladefile, self.comm, self.dialog)
0.8.19 by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
56
        add.display()
57
    
0.8.22 by Szilveszter Farkas (Phanatic)
2006-07-31 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
58
    def on_menuitem_branch_get_activate(self, widget):
59
        """ Branch/Get... menu handler. """
0.8.36 by Szilveszter Farkas (Phanatic)
Implemented pull functionality.
60
        from branch import OliveBranch
0.8.46 by Szilveszter Farkas (Phanatic)
Modified OliveDialog class interface; huge cleanups.
61
        branch = OliveBranch(self.gladefile, self.comm, self.dialog)
0.8.14 by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
62
        branch.display()
0.8.19 by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
63
    
0.8.22 by Szilveszter Farkas (Phanatic)
2006-07-31 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
64
    def on_menuitem_branch_checkout_activate(self, widget):
65
        """ Branch/Checkout... menu handler. """
0.8.36 by Szilveszter Farkas (Phanatic)
Implemented pull functionality.
66
        from checkout import OliveCheckout
0.8.46 by Szilveszter Farkas (Phanatic)
Modified OliveDialog class interface; huge cleanups.
67
        checkout = OliveCheckout(self.gladefile, self.comm, self.dialog)
0.8.22 by Szilveszter Farkas (Phanatic)
2006-07-31 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
68
        checkout.display()
69
    
0.8.19 by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
70
    def on_menuitem_branch_commit_activate(self, widget):
71
        """ Branch/Commit... menu handler. """
0.8.36 by Szilveszter Farkas (Phanatic)
Implemented pull functionality.
72
        from commit import OliveCommit
0.8.46 by Szilveszter Farkas (Phanatic)
Modified OliveDialog class interface; huge cleanups.
73
        commit = OliveCommit(self.gladefile, self.comm, self.dialog)
0.8.19 by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
74
        commit.display()
75
    
0.8.66 by Szilveszter Farkas (Phanatic)
Implemented Missing revisions functionality.
76
    def on_menuitem_branch_missing_revisions_activate(self, widget):
77
        """ Branch/Missing revisions menu handler. """
78
        
79
        self.comm.set_busy(self.comm.window_main)
80
        
81
        try:
0.11.5 by Jelmer Vernooij
Eliminate olive.backend.update
82
            import bzrlib
83
            
84
            try:
85
                local_branch = Branch.open_containing(self.comm.get_path())[0]
86
            except NotBranchError:
87
                self.dialog.error_dialog(_('Directory is not a branch'),
88
                                         _('You can perform this action only in a branch.'))
89
                return
90
            
91
            other_branch = local_branch.get_parent()
92
            if other_branch is None:
93
                self.dialog.error_dialog(_('Parent location is unknown'),
94
                                         _('Cannot determine missing revisions if no parent location is known.'))
95
                return
96
            
97
            remote_branch = Branch.open(other_branch)
98
            
99
            if remote_branch.base == local_branch.base:
100
                remote_branch = local_branch
101
102
            ret = len(local_branch.missing_revisions(remote_branch))
103
0.8.66 by Szilveszter Farkas (Phanatic)
Implemented Missing revisions functionality.
104
            if ret > 0:
105
                self.dialog.info_dialog(_('There are missing revisions'),
106
                                        _('%d revision(s) missing.') % ret)
107
            else:
108
                self.dialog.info_dialog(_('Local branch up to date'),
109
                                        _('There are no missing revisions.'))
0.11.5 by Jelmer Vernooij
Eliminate olive.backend.update
110
        finally:
111
            self.comm.set_busy(self.comm.window_main, False)
0.8.66 by Szilveszter Farkas (Phanatic)
Implemented Missing revisions functionality.
112
    
0.8.36 by Szilveszter Farkas (Phanatic)
Implemented pull functionality.
113
    def on_menuitem_branch_pull_activate(self, widget):
114
        """ Branch/Pull menu handler. """
115
        
116
        self.comm.set_busy(self.comm.window_main)
0.11.5 by Jelmer Vernooij
Eliminate olive.backend.update
117
0.8.36 by Szilveszter Farkas (Phanatic)
Implemented pull functionality.
118
        try:
0.11.5 by Jelmer Vernooij
Eliminate olive.backend.update
119
            try:
0.11.11 by Jelmer Vernooij
Fix a few more bits that I broke earlier.
120
                from bzrlib.workingtree import WorkingTree
0.11.5 by Jelmer Vernooij
Eliminate olive.backend.update
121
                tree_to = WorkingTree.open_containing(self.comm.get_path())[0]
122
                branch_to = tree_to.branch
0.11.11 by Jelmer Vernooij
Fix a few more bits that I broke earlier.
123
            except errors.NoWorkingTree:
0.11.5 by Jelmer Vernooij
Eliminate olive.backend.update
124
                tree_to = None
125
                branch_to = Branch.open_containing(self.comm.get_path())[0]
0.11.11 by Jelmer Vernooij
Fix a few more bits that I broke earlier.
126
            except errors.NotBranchError:
0.11.5 by Jelmer Vernooij
Eliminate olive.backend.update
127
                 self.dialog.error_dialog(_('Directory is not a branch'),
128
                                         _('You can perform this action only in a branch.'))
129
130
            location = branch_to.get_parent()
131
            if location is None:
132
                self.dialog.error_dialog(_('Parent location is unknown'),
133
                                         _('Pulling is not possible until there is a parent location.'))
134
                return
135
136
            try:
137
                branch_from = Branch.open(location)
138
            except errors.NotBranchError:
139
                self.dialog.error_dialog(_('Directory is not a branch'),
140
                                         _('You can perform this action only in a branch.'))
141
142
            if branch_to.get_parent() is None:
143
                branch_to.set_parent(branch_from.base)
144
145
            old_rh = branch_to.revision_history()
146
            if tree_to is not None:
0.11.11 by Jelmer Vernooij
Fix a few more bits that I broke earlier.
147
                tree_to.pull(branch_from)
0.11.5 by Jelmer Vernooij
Eliminate olive.backend.update
148
            else:
0.11.11 by Jelmer Vernooij
Fix a few more bits that I broke earlier.
149
                branch_to.pull(branch_from)
0.11.5 by Jelmer Vernooij
Eliminate olive.backend.update
150
            
0.8.55 by Szilveszter Farkas (Phanatic)
Gettext support added.
151
            self.dialog.info_dialog(_('Pull successful'),
152
                                    _('%d revision(s) pulled.') % ret)
0.11.5 by Jelmer Vernooij
Eliminate olive.backend.update
153
            
154
        finally:
155
            self.comm.set_busy(self.comm.window_main, False)
0.8.36 by Szilveszter Farkas (Phanatic)
Implemented pull functionality.
156
    
0.8.19 by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
157
    def on_menuitem_branch_push_activate(self, widget):
158
        """ Branch/Push... menu handler. """
0.8.36 by Szilveszter Farkas (Phanatic)
Implemented pull functionality.
159
        from push import OlivePush
0.8.46 by Szilveszter Farkas (Phanatic)
Modified OliveDialog class interface; huge cleanups.
160
        push = OlivePush(self.gladefile, self.comm, self.dialog)
0.8.19 by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
161
        push.display()
162
    
0.8.29 by Szilveszter Farkas (Phanatic)
Implemented Status window; some code cleanups.
163
    def on_menuitem_branch_status_activate(self, widget):
164
        """ Branch/Status... menu handler. """
0.8.36 by Szilveszter Farkas (Phanatic)
Implemented pull functionality.
165
        from status import OliveStatus
0.12.1 by Jelmer Vernooij
Don't use communicator for status.
166
        wt, wtpath = WorkingTree.open_containing(self.comm.get_path())
167
        status = OliveStatus(self.gladefile, wt, wtpath, self.dialog)
0.8.29 by Szilveszter Farkas (Phanatic)
Implemented Status window; some code cleanups.
168
        status.display()
169
    
0.8.19 by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
170
    def on_menuitem_branch_initialize_activate(self, widget):
171
        """ Initialize current directory. """
172
        try:
0.11.7 by Jelmer Vernooij
Integrate olive.backend.init
173
            location = self.comm.get_path()
174
            from bzrlib.builtins import get_format_type
175
176
            format = get_format_type('default')
177
 
178
            if not os.path.exists(location):
179
                os.mkdir(location)
180
     
181
            try:
182
                existing_bzrdir = bzrdir.BzrDir.open(location)
183
            except NotBranchError:
184
                bzrdir.BzrDir.create_branch_convenience(location, format=format)
185
            else:
186
                if existing_bzrdir.has_branch():
187
                    if existing_bzrdir.has_workingtree():
188
                        raise AlreadyBranchError(location)
189
                    else:
190
                        raise BranchExistsWithoutWorkingTree(location)
191
                else:
192
                    existing_bzrdir.create_branch()
193
                    existing_bzrdir.create_workingtree()
0.8.19 by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
194
        except errors.AlreadyBranchError, errmsg:
0.8.55 by Szilveszter Farkas (Phanatic)
Gettext support added.
195
            self.dialog.error_dialog(_('Directory is already a branch'),
196
                                     _('The current directory (%s) is already a branch.\nYou can start using it, or initialize another directory.') % errmsg)
0.8.19 by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
197
        except errors.BranchExistsWithoutWorkingTree, errmsg:
0.8.55 by Szilveszter Farkas (Phanatic)
Gettext support added.
198
            self.dialog.error_dialog(_('Branch without a working tree'),
199
                                     _('The current directory (%s)\nis a branch without a working tree.') % errmsg)
0.8.19 by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
200
        else:
0.11.7 by Jelmer Vernooij
Integrate olive.backend.init
201
            self.dialog.info_dialog(_('Initialize successful'),
0.8.55 by Szilveszter Farkas (Phanatic)
Gettext support added.
202
                                    _('Directory successfully initialized.'))
0.8.19 by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
203
            self.comm.refresh_right()
204
        
0.8.37 by Szilveszter Farkas (Phanatic)
Implemented Make directory functionality; some cleanups.
205
    def on_menuitem_file_make_directory_activate(self, widget):
206
        """ File/Make directory... menu handler. """
207
        from mkdir import OliveMkdir
0.8.46 by Szilveszter Farkas (Phanatic)
Modified OliveDialog class interface; huge cleanups.
208
        mkdir = OliveMkdir(self.gladefile, self.comm, self.dialog)
0.8.37 by Szilveszter Farkas (Phanatic)
Implemented Make directory functionality; some cleanups.
209
        mkdir.display()
210
    
0.8.38 by Szilveszter Farkas (Phanatic)
Implemented Move functionality; move() backend code refined.
211
    def on_menuitem_file_move_activate(self, widget):
212
        """ File/Move... menu handler. """
213
        from move import OliveMove
0.8.46 by Szilveszter Farkas (Phanatic)
Modified OliveDialog class interface; huge cleanups.
214
        move = OliveMove(self.gladefile, self.comm, self.dialog)
0.8.38 by Szilveszter Farkas (Phanatic)
Implemented Move functionality; move() backend code refined.
215
        move.display()
216
    
0.8.40 by Szilveszter Farkas (Phanatic)
Implemented Rename functionality.
217
    def on_menuitem_file_rename_activate(self, widget):
218
        """ File/Rename... menu handler. """
219
        from rename import OliveRename
0.8.46 by Szilveszter Farkas (Phanatic)
Modified OliveDialog class interface; huge cleanups.
220
        rename = OliveRename(self.gladefile, self.comm, self.dialog)
0.8.40 by Szilveszter Farkas (Phanatic)
Implemented Rename functionality.
221
        rename.display()
222
0.8.19 by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
223
    def on_menuitem_remove_file_activate(self, widget):
224
        """ Remove (unversion) selected file. """
0.8.36 by Szilveszter Farkas (Phanatic)
Implemented pull functionality.
225
        from remove import OliveRemove
0.8.46 by Szilveszter Farkas (Phanatic)
Modified OliveDialog class interface; huge cleanups.
226
        remove = OliveRemove(self.gladefile, self.comm, self.dialog)
0.8.19 by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
227
        remove.display()
228
    
0.8.28 by Szilveszter Farkas (Phanatic)
Statistics menu added
229
    def on_menuitem_stats_diff_activate(self, widget):
230
        """ Statistics/Differences... menu handler. """
0.8.36 by Szilveszter Farkas (Phanatic)
Implemented pull functionality.
231
        from diff import OliveDiff
0.8.46 by Szilveszter Farkas (Phanatic)
Modified OliveDialog class interface; huge cleanups.
232
        diff = OliveDiff(self.gladefile, self.comm, self.dialog)
0.8.28 by Szilveszter Farkas (Phanatic)
Statistics menu added
233
        diff.display()
234
    
0.8.42 by Szilveszter Farkas (Phanatic)
Implemented Informations functionality; some bzrlib API changes handled.
235
    def on_menuitem_stats_infos_activate(self, widget):
236
        """ Statistics/Informations... menu handler. """
237
        from info import OliveInfo
0.8.46 by Szilveszter Farkas (Phanatic)
Modified OliveDialog class interface; huge cleanups.
238
        info = OliveInfo(self.gladefile, self.comm, self.dialog)
0.8.42 by Szilveszter Farkas (Phanatic)
Implemented Informations functionality; some bzrlib API changes handled.
239
        info.display()
240
    
0.8.43 by Szilveszter Farkas (Phanatic)
Implemented Log functionality (via bzrk).
241
    def on_menuitem_stats_log_activate(self, widget):
242
        """ Statistics/Log... menu handler. """
243
        from log import OliveLog
0.8.46 by Szilveszter Farkas (Phanatic)
Modified OliveDialog class interface; huge cleanups.
244
        log = OliveLog(self.gladefile, self.comm, self.dialog)
0.8.43 by Szilveszter Farkas (Phanatic)
Implemented Log functionality (via bzrk).
245
        log.display()
246
    
0.8.49 by Szilveszter Farkas (Phanatic)
Added View menu; implemented Refresh; some TODO changes.
247
    def on_menuitem_view_refresh_activate(self, widget):
248
        """ View/Refresh menu handler. """
249
        # Refresh the left pane
250
        self.comm.refresh_left()
251
        # Refresh the right pane
252
        self.comm.refresh_right()
253
    
254
    def on_menuitem_view_show_hidden_files_activate(self, widget):
255
        """ View/Show hidden files menu handler. """
256
        if widget.get_active():
257
            # Show hidden files
258
            self.comm.pref.set_preference('dotted_files', True)
259
            self.comm.pref.refresh()
260
            self.comm.refresh_right()
261
        else:
262
            # Do not show hidden files
263
            self.comm.pref.set_preference('dotted_files', False)
264
            self.comm.pref.refresh()
265
            self.comm.refresh_right()
266
0.8.33 by Szilveszter Farkas (Phanatic)
Implemented bookmarking.
267
    def on_treeview_left_button_press_event(self, widget, event):
268
        """ Occurs when somebody right-clicks in the bookmark list. """
269
        if event.button == 3:
0.8.72 by Szilveszter Farkas (Phanatic)
Merge from Richard Ferguson's development branch.
270
            # Don't show context with nothing selected
271
            if self.comm.get_selected_left() == None:
272
                return
273
0.8.33 by Szilveszter Farkas (Phanatic)
Implemented bookmarking.
274
            self.menu.left_context_menu().popup(None, None, None, 0,
0.8.41 by Szilveszter Farkas (Phanatic)
Main window preferences (size, position) are stored.
275
                                                event.time)
0.8.33 by Szilveszter Farkas (Phanatic)
Implemented bookmarking.
276
        
277
    def on_treeview_left_row_activated(self, treeview, path, view_column):
278
        """ Occurs when somebody double-clicks or enters an item in the
279
        bookmark list. """
0.8.72 by Szilveszter Farkas (Phanatic)
Merge from Richard Ferguson's development branch.
280
281
        newdir = self.comm.get_selected_left()
282
        if newdir == None:
283
            return
284
0.8.33 by Szilveszter Farkas (Phanatic)
Implemented bookmarking.
285
        self.comm.set_busy(treeview)
286
        self.comm.set_path(newdir)
287
        self.comm.refresh_right()
288
        self.comm.set_busy(treeview, False)
289
    
0.8.24 by Szilveszter Farkas (Phanatic)
Implemented context menu for the file list.
290
    def on_treeview_right_button_press_event(self, widget, event):
291
        """ Occurs when somebody right-clicks in the file list. """
292
        if event.button == 3:
0.8.53 by Szilveszter Farkas (Phanatic)
Set sensitivity of menus and toolbuttons.
293
            # get the menu items
294
            m_add = self.menu.ui.get_widget('/context_right/add')
295
            m_remove = self.menu.ui.get_widget('/context_right/remove')
296
            m_commit = self.menu.ui.get_widget('/context_right/commit')
297
            m_diff = self.menu.ui.get_widget('/context_right/diff')
298
            # check if we're in a branch
0.11.11 by Jelmer Vernooij
Fix a few more bits that I broke earlier.
299
            try:
300
                from bzrlib.branch import Branch
301
                Branch.open_containing(self.comm.get_path())
0.8.53 by Szilveszter Farkas (Phanatic)
Set sensitivity of menus and toolbuttons.
302
                m_add.set_sensitive(False)
303
                m_remove.set_sensitive(False)
304
                m_commit.set_sensitive(False)
305
                m_diff.set_sensitive(False)
0.11.11 by Jelmer Vernooij
Fix a few more bits that I broke earlier.
306
            except errors.NotBranchError:
0.8.53 by Szilveszter Farkas (Phanatic)
Set sensitivity of menus and toolbuttons.
307
                m_add.set_sensitive(True)
308
                m_remove.set_sensitive(True)
309
                m_commit.set_sensitive(True)
310
                m_diff.set_sensitive(True)
0.8.24 by Szilveszter Farkas (Phanatic)
Implemented context menu for the file list.
311
            self.menu.right_context_menu().popup(None, None, None, 0,
312
                                                 event.time)
313
        
0.8.18 by Szilveszter Farkas (Phanatic)
2006-07-20 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
314
    def on_treeview_right_row_activated(self, treeview, path, view_column):
315
        """ Occurs when somebody double-clicks or enters an item in the
316
        file list. """
317
        import os.path
318
        
0.8.19 by Szilveszter Farkas (Phanatic)
2006-07-21 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
319
        newdir = self.comm.get_selected_right()
0.8.18 by Szilveszter Farkas (Phanatic)
2006-07-20 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
320
        
321
        if newdir == '..':
322
            self.comm.set_path(os.path.split(self.comm.get_path())[0])
323
        else:
0.8.72 by Szilveszter Farkas (Phanatic)
Merge from Richard Ferguson's development branch.
324
            fullpath = self.comm.get_path() + os.sep + newdir
0.8.54 by Szilveszter Farkas (Phanatic)
Fixed a bug when double-clicking a file.
325
            if os.path.isdir(fullpath):
326
                # selected item is an existant directory
327
                self.comm.set_path(fullpath)
328
            else:
0.8.72 by Szilveszter Farkas (Phanatic)
Merge from Richard Ferguson's development branch.
329
                launch(fullpath) 
0.8.18 by Szilveszter Farkas (Phanatic)
2006-07-20 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
330
        
331
        self.comm.refresh_right()
0.8.13 by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
332
    
0.8.32 by Szilveszter Farkas (Phanatic)
Implemented OlivePreferences; some wording fixes.
333
    def on_window_main_delete_event(self, widget, event=None):
334
        """ Do some stuff before exiting. """
0.8.41 by Szilveszter Farkas (Phanatic)
Main window preferences (size, position) are stored.
335
        width, height = self.comm.window_main.get_size()
336
        self.comm.pref.set_preference('window_width', width)
337
        self.comm.pref.set_preference('window_height', height)
338
        x, y = self.comm.window_main.get_position()
339
        self.comm.pref.set_preference('window_x', x)
340
        self.comm.pref.set_preference('window_y', y)
341
        self.comm.pref.set_preference('paned_position',
342
                                      self.comm.hpaned_main.get_position())
343
        
0.8.32 by Szilveszter Farkas (Phanatic)
Implemented OlivePreferences; some wording fixes.
344
        self.comm.pref.write()
345
        self.comm.window_main.destroy()
346
0.8.13 by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
347
    def not_implemented(self, widget):
348
        """ Display a Not implemented error message. """
0.8.55 by Szilveszter Farkas (Phanatic)
Gettext support added.
349
        self.dialog.error_dialog(_('We feel sorry'),
350
                                 _('This feature is not yet implemented.'))
0.8.13 by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
351