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