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

  • Committer: Szilveszter Farkas (Phanatic)
  • Date: 2006-08-13 11:02:48 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-20060813110248-4f256d8db6247b61
Some bugs fixed in the Push dialog; added TODO items.

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

    * TODO: some more items added
    * olive.glade: Push window should not be visible by default
    * olive/frontend/gtk/push.py: fixed a bug if no push location known; user
      gets an error if directory is not a branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2006 by Szilveszter Farkas (Phanatic) <szilveszter.farkas@gmail.com>
 
2
#
 
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.
 
7
#
 
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.
 
12
#
 
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
 
 
17
import sys
 
18
 
 
19
try:
 
20
    import pygtk
 
21
    pygtk.require("2.0")
 
22
except:
 
23
    pass
 
24
try:
 
25
    import gtk
 
26
    import gtk.glade
 
27
except:
 
28
    sys.exit(1)
 
29
 
 
30
import olive.backend.errors as errors
 
31
 
 
32
from dialog import OliveDialog
 
33
from menu import OliveMenu
 
34
 
 
35
class OliveHandler:
 
36
    """ Signal handler class for Olive. """
 
37
    def __init__(self, gladefile, comm):
 
38
        self.gladefile = gladefile
 
39
        self.comm = comm
 
40
        
 
41
        self.dialog = OliveDialog(self.gladefile)
 
42
        
 
43
        self.menu = OliveMenu(self.gladefile, self.comm, self.dialog)
 
44
    
 
45
    def on_about_activate(self, widget):
 
46
        self.dialog.about()
 
47
        
 
48
    def on_menuitem_add_files_activate(self, widget):
 
49
        """ Add file(s)... menu handler. """
 
50
        from add import OliveAdd
 
51
        add = OliveAdd(self.gladefile, self.comm)
 
52
        add.display()
 
53
    
 
54
    def on_menuitem_branch_get_activate(self, widget):
 
55
        """ Branch/Get... menu handler. """
 
56
        from branch import OliveBranch
 
57
        branch = OliveBranch(self.gladefile, self.comm)
 
58
        branch.display()
 
59
    
 
60
    def on_menuitem_branch_checkout_activate(self, widget):
 
61
        """ Branch/Checkout... menu handler. """
 
62
        from checkout import OliveCheckout
 
63
        checkout = OliveCheckout(self.gladefile, self.comm)
 
64
        checkout.display()
 
65
    
 
66
    def on_menuitem_branch_commit_activate(self, widget):
 
67
        """ Branch/Commit... menu handler. """
 
68
        from commit import OliveCommit
 
69
        commit = OliveCommit(self.gladefile, self.comm)
 
70
        commit.display()
 
71
    
 
72
    def on_menuitem_branch_pull_activate(self, widget):
 
73
        """ Branch/Pull menu handler. """
 
74
        import olive.backend.update as update
 
75
        
 
76
        self.comm.set_busy(self.comm.window_main)
 
77
        
 
78
        try:
 
79
            ret = update.pull(self.comm.get_path())
 
80
        except errors.NotBranchError:
 
81
            self.dialog.error_dialog('Directory is not a branch.')
 
82
        except errors.NoLocationKnown:
 
83
            self.dialog.error_dialog('Parent location is unknown.')
 
84
        else:
 
85
            self.dialog.info_dialog('%d revision(s) pulled.' % ret)
 
86
        
 
87
        self.comm.set_busy(self.comm.window_main, False)
 
88
    
 
89
    def on_menuitem_branch_push_activate(self, widget):
 
90
        """ Branch/Push... menu handler. """
 
91
        from push import OlivePush
 
92
        push = OlivePush(self.gladefile, self.comm)
 
93
        push.display()
 
94
    
 
95
    def on_menuitem_branch_status_activate(self, widget):
 
96
        """ Branch/Status... menu handler. """
 
97
        from status import OliveStatus
 
98
        status = OliveStatus(self.gladefile, self.comm)
 
99
        status.display()
 
100
    
 
101
    def on_menuitem_branch_initialize_activate(self, widget):
 
102
        """ Initialize current directory. """
 
103
        import olive.backend.init as init
 
104
        
 
105
        try:
 
106
            init.init(self.comm.get_path())
 
107
        except errors.AlreadyBranchError, errmsg:
 
108
            self.dialog.error_dialog('Directory is already a branch: %s' % errmsg)
 
109
        except errors.BranchExistsWithoutWorkingTree, errmsg:
 
110
            self.dialog.error_dialog('Branch exists without a working tree: %s' % errmsg)
 
111
        else:
 
112
            self.dialog.info_dialog('Directory successfully initialized.')
 
113
            self.comm.refresh_right()
 
114
        
 
115
    def on_menuitem_file_make_directory_activate(self, widget):
 
116
        """ File/Make directory... menu handler. """
 
117
        from mkdir import OliveMkdir
 
118
        mkdir = OliveMkdir(self.gladefile, self.comm)
 
119
        mkdir.display()
 
120
    
 
121
    def on_menuitem_file_move_activate(self, widget):
 
122
        """ File/Move... menu handler. """
 
123
        from move import OliveMove
 
124
        move = OliveMove(self.gladefile, self.comm)
 
125
        move.display()
 
126
    
 
127
    def on_menuitem_file_rename_activate(self, widget):
 
128
        """ File/Rename... menu handler. """
 
129
        from rename import OliveRename
 
130
        rename = OliveRename(self.gladefile, self.comm)
 
131
        rename.display()
 
132
 
 
133
    def on_menuitem_remove_file_activate(self, widget):
 
134
        """ Remove (unversion) selected file. """
 
135
        from remove import OliveRemove
 
136
        remove = OliveRemove(self.gladefile, self.comm)
 
137
        remove.display()
 
138
    
 
139
    def on_menuitem_stats_diff_activate(self, widget):
 
140
        """ Statistics/Differences... menu handler. """
 
141
        from diff import OliveDiff
 
142
        diff = OliveDiff(self.gladefile, self.comm)
 
143
        diff.display()
 
144
    
 
145
    def on_menuitem_stats_infos_activate(self, widget):
 
146
        """ Statistics/Informations... menu handler. """
 
147
        from info import OliveInfo
 
148
        info = OliveInfo(self.gladefile, self.comm)
 
149
        info.display()
 
150
    
 
151
    def on_menuitem_stats_log_activate(self, widget):
 
152
        """ Statistics/Log... menu handler. """
 
153
        from log import OliveLog
 
154
        log = OliveLog(self.gladefile, self.comm)
 
155
        log.display()
 
156
    
 
157
    def on_treeview_left_button_press_event(self, widget, event):
 
158
        """ Occurs when somebody right-clicks in the bookmark list. """
 
159
        if event.button == 3:
 
160
            self.menu.left_context_menu().popup(None, None, None, 0,
 
161
                                                event.time)
 
162
        
 
163
    def on_treeview_left_row_activated(self, treeview, path, view_column):
 
164
        """ Occurs when somebody double-clicks or enters an item in the
 
165
        bookmark list. """
 
166
        self.comm.set_busy(treeview)
 
167
        
 
168
        newdir = self.comm.get_selected_left()
 
169
        self.comm.set_path(newdir)
 
170
        
 
171
        self.comm.refresh_right()
 
172
        
 
173
        self.comm.set_busy(treeview, False)
 
174
    
 
175
    def on_treeview_right_button_press_event(self, widget, event):
 
176
        """ Occurs when somebody right-clicks in the file list. """
 
177
        if event.button == 3:
 
178
            self.menu.right_context_menu().popup(None, None, None, 0,
 
179
                                                 event.time)
 
180
        
 
181
    def on_treeview_right_row_activated(self, treeview, path, view_column):
 
182
        """ Occurs when somebody double-clicks or enters an item in the
 
183
        file list. """
 
184
        import os.path
 
185
        
 
186
        newdir = self.comm.get_selected_right()
 
187
        
 
188
        if newdir == '..':
 
189
            self.comm.set_path(os.path.split(self.comm.get_path())[0])
 
190
        else:
 
191
            self.comm.set_path(self.comm.get_path() + '/' + newdir)
 
192
        
 
193
        self.comm.refresh_right()
 
194
    
 
195
    def on_window_main_delete_event(self, widget, event=None):
 
196
        """ Do some stuff before exiting. """
 
197
        width, height = self.comm.window_main.get_size()
 
198
        self.comm.pref.set_preference('window_width', width)
 
199
        self.comm.pref.set_preference('window_height', height)
 
200
        x, y = self.comm.window_main.get_position()
 
201
        self.comm.pref.set_preference('window_x', x)
 
202
        self.comm.pref.set_preference('window_y', y)
 
203
        self.comm.pref.set_preference('paned_position',
 
204
                                      self.comm.hpaned_main.get_position())
 
205
        
 
206
        self.comm.pref.write()
 
207
        self.comm.window_main.destroy()
 
208
 
 
209
    def not_implemented(self, widget):
 
210
        """ Display a Not implemented error message. """
 
211
        self.dialog.error_dialog('This feature is not yet implemented.')
 
212