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

  • Committer: Szilveszter Farkas (Phanatic)
  • Date: 2006-08-20 13:02:35 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-20060820130235-62c9c5753f5d8774
Gettext support added.

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

    * po/hu.po: added Hungarian traslation
    * Added gettext support to all files.
    * genpot.sh: added olive-gtk.pot generator script

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
    pygtk.require("2.0")
23
23
except:
24
24
    pass
25
 
 
26
 
import gtk
27
 
 
28
 
import bzrlib.errors as errors
29
 
from dialog import error_dialog
30
 
 
31
 
from launch import launch
 
25
try:
 
26
    import gtk
 
27
    import gtk.glade
 
28
except:
 
29
    sys.exit(1)
 
30
 
 
31
import olive.backend.fileops as fileops
 
32
import olive.backend.errors as errors
32
33
 
33
34
class OliveMenu:
34
35
    """ This class is responsible for building the context menus. """
35
 
    def __init__(self):
 
36
    def __init__(self, gladefile, comm, dialog):
36
37
        # Load the UI file
37
38
        if sys.platform == 'win32':
38
39
            self.uifile = os.path.dirname(sys.executable) + "/share/olive/cmenu.ui"
48
49
                print _('UI description file cannot be found.')
49
50
                sys.exit(1)
50
51
        
 
52
        self.gladefile = gladefile
 
53
        self.comm = comm
 
54
        self.dialog = dialog
 
55
        
51
56
        # Create the file list context menu
52
57
        self.ui = gtk.UIManager()
53
58
        
60
65
                                       _('Remove'), None,
61
66
                                       _('Remove the selected file'),
62
67
                                       self.remove_file),
63
 
                                      ('open', gtk.STOCK_OPEN,
64
 
                                       _('Open'), None,
65
 
                                       _('Open the selected file'),
66
 
                                       self.open_file),
67
68
                                      ('commit', None,
68
69
                                       _('Commit'), None,
69
70
                                       _('Commit the changes'),
76
77
                                       _('Bookmark'), None,
77
78
                                       _('Bookmark current location'),
78
79
                                       self.bookmark),
79
 
                                      ('edit_bookmark', gtk.STOCK_EDIT,
80
 
                                       _('Edit'), None,
81
 
                                       _('Edit the selected bookmark'),
82
 
                                       self.edit_bookmark),
83
80
                                      ('remove_bookmark', gtk.STOCK_REMOVE,
84
81
                                       _('Remove'), None,
85
82
                                       _('Remove the selected bookmark'),
86
83
                                       self.remove_bookmark),
87
 
                                      ('open_folder', gtk.STOCK_OPEN,
88
 
                                       _('Open Folder'), None,
89
 
                                       _('Open bookmark folder in Nautilus'),
90
 
                                       self.open_folder),
91
84
                                      ('diff_selected', None,
92
85
                                       _('Selected...'), None,
93
86
                                       _('Show the differences of the selected file'),
132
125
        filename = self.comm.get_selected_right()
133
126
            
134
127
        if filename is None:
135
 
            error_dialog(_('No file was selected'),
136
 
                         _('Please select a file from the list,\nor choose the other option.'))
 
128
            self.dialog.error_dialog(_('No file was selected'),
 
129
                                     _('Please select a file from the list,\nor choose the other option.'))
137
130
            return
138
131
        
139
132
        try:
140
 
            bzrlib.add.smart_add([directory + '/' + filename])
 
133
            fileops.add([directory + '/' + filename])
141
134
        except errors.NotBranchError:
142
 
            error_dialog(_('Directory is not a branch'),
143
 
                         _('You can perform this action only in a branch.'))
 
135
            self.dialog.error_dialog(_('Directory is not a branch'),
 
136
                                     _('You can perform this action only in a branch.'))
144
137
            return
 
138
        except:
 
139
            raise
145
140
        
146
141
        self.comm.refresh_right()
147
142
    
152
147
        filename = self.comm.get_selected_right()
153
148
        
154
149
        if filename is None:
155
 
            error_dialog(_('No file was selected'),
156
 
                         _('Please select a file from the list,\nor choose the other option.'))
 
150
            self.dialog.error_dialog(_('No file was selected'),
 
151
                                     _('Please select a file from the list,\nor choose the other option.'))
157
152
            return
158
153
        
159
154
        try:
160
 
            wt, path = WorkingTree.open_containing(directory+'/'+filename)
161
 
            wt.remove(path)
162
 
 
 
155
            fileops.remove([directory + '/' + filename])
163
156
        except errors.NotBranchError:
164
 
            error_dialog(_('Directory is not a branch'),
 
157
            self.dialog.error_dialog(_('Directory is not a branch'),
165
158
                                     _('You can perform this action only in a branch.'))
166
159
            return
167
160
        except errors.NotVersionedError:
168
 
            error_dialog(_('File not versioned'),
 
161
            self.dialog.error_dialog(_('File not versioned'),
169
162
                                     _('The selected file is not versioned.'))
170
163
            return
171
 
        
172
 
        self.comm.refresh_right()
173
 
 
174
 
    def open_file(self, action):
175
 
        """ Right context menu -> Open """
176
 
        # Open only the selected file
177
 
        filename = self.comm.get_selected_right()
178
 
        
179
 
        if filename is None:
180
 
            error_dialog(_('No file was selected'),
181
 
                                     _('Please select a file from the list,\nor choose the other option.'))
182
 
            return
183
 
 
184
 
        if filename == '..':
185
 
            self.comm.set_path(os.path.split(self.comm.get_path())[0])
186
 
        else:
187
 
            fullpath = self.comm.get_path() + os.sep + filename
188
 
            if os.path.isdir(fullpath):
189
 
                # selected item is an existant directory
190
 
                self.comm.set_path(fullpath)
191
 
            else:
192
 
                launch(fullpath) 
 
164
        except:
 
165
            raise
193
166
        
194
167
        self.comm.refresh_right()
195
168
 
196
169
    def commit(self, action):
197
170
        """ Right context menu -> Commit """
198
171
        from commit import OliveCommit
199
 
        wt, path = WorkingTree.open_containing(self.comm.get_path())
200
 
        commit = OliveCommit(wt, path)
 
172
        commit = OliveCommit(self.gladefile, self.comm, self.dialog)
201
173
        commit.display()
202
174
    
203
175
    def diff(self, action):
204
176
        """ Right context menu -> Diff """
205
177
        from diff import OliveDiff
206
 
        diff = OliveDiff(self.comm)
 
178
        diff = OliveDiff(self.gladefile, self.comm, self.dialog)
207
179
        diff.display()
208
180
    
209
181
    def bookmark(self, action):
210
182
        """ Right context menu -> Bookmark """
211
183
        if self.comm.pref.add_bookmark(self.comm.get_path()):
212
 
            info_dialog(_('Bookmark successfully added'),
 
184
            self.dialog.info_dialog(_('Bookmark successfully added'),
213
185
                                    _('The current directory was bookmarked. You can reach\nit by selecting it from the left panel.'))
214
186
        else:
215
 
            warning_dialog(_('Location already bookmarked'),
 
187
            self.dialog.warning_dialog(_('Location already bookmarked'),
216
188
                                       _('The current directory is already bookmarked.\nSee the left panel for reference.'))
217
189
        
218
190
        self.comm.refresh_left()
219
191
 
220
 
    def edit_bookmark(self, action):
221
 
        """ Left context menu -> Edit """
222
 
        from bookmark import OliveBookmark
223
 
 
224
 
        if self.comm.get_selected_left() != None:
225
 
            bookmark = OliveBookmark(self.comm)
226
 
            bookmark.display()
227
 
 
228
192
    def remove_bookmark(self, action):
229
193
        """ Left context menu -> Remove """
 
194
        self.comm.pref.remove_bookmark(self.comm.get_selected_left())
230
195
        
231
 
        if self.comm.get_selected_left() != None:
232
 
            self.comm.pref.remove_bookmark(self.comm.get_selected_left())
233
 
            self.comm.refresh_left()
234
 
    
235
 
    def open_folder(self, action):
236
 
        """ Left context menu -> Open Folder """
237
 
        path = self.comm.get_selected_left()
238
 
 
239
 
        if path != None:
240
 
            launch(path)
 
196
        self.comm.refresh_left()
241
197
    
242
198
    def diff_selected(self, action):
243
199
        """ Diff toolbutton -> Selected... """
246
202
    def diff_all(self, action):
247
203
        """ Diff toolbutton -> All... """
248
204
        from diff import OliveDiff
249
 
        diff = OliveDiff(self.comm)
 
205
        diff = OliveDiff(self.gladefile, self.comm, self.dialog)
250
206
        diff.display()