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