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

  • Committer: Szilveszter Farkas (Phanatic)
  • Date: 2006-09-29 12:17:19 UTC
  • mto: (0.14.3 main)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: Szilveszter.Farkas@gmail.com-20060929121719-cf814acd83d1bd77
Cleanup Jelmer's changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
import os
18
 
import os.path
19
18
import sys
20
19
 
21
20
try:
23
22
    pygtk.require("2.0")
24
23
except:
25
24
    pass
 
25
 
26
26
import gtk
27
27
import gtk.gdk
28
28
import gtk.glade
29
29
 
 
30
from bzrlib.branch import Branch
30
31
import bzrlib.errors as errors
31
32
from bzrlib.workingtree import WorkingTree
32
33
 
48
49
        print _('Glade file cannot be found.')
49
50
        sys.exit(1)
50
51
 
 
52
from dialog import error_dialog, info_dialog
 
53
 
51
54
class OliveGtk:
52
55
    """ The main Olive GTK frontend class. This is called when launching the
53
56
    program. """
166
169
            self.combobox_drive.show()
167
170
            self.gen_hard_selector()
168
171
        
169
 
        # Load default data into the panels
170
 
        self.treeview_left = self.toplevel.get_widget('treeview_left')
171
 
        self.treeview_right = self.toplevel.get_widget('treeview_right')
172
172
        self._load_left()
173
173
 
174
174
        # Apply menu state
175
175
        self.menuitem_view_show_hidden_files.set_active(self.pref.get_preference('dotted_files', 'bool'))
176
176
 
177
177
        self.set_path(os.getcwd())
 
178
        self._load_right()
178
179
 
179
180
    def set_path(self, path):
180
181
        self.path = path
181
182
        self.notbranch = False
182
183
        try:
183
184
            self.wt, self.wtpath = WorkingTree.open_containing(self.path)
184
 
        except NotBranchError:
 
185
        except errors.NotBranchError:
185
186
            self.notbranch = True
186
 
        self._load_right()
187
187
 
188
188
    def get_path(self):
189
189
        return self.path
190
190
   
191
191
    def on_about_activate(self, widget):
 
192
        from dialog import about
192
193
        about()
193
194
        
194
195
    def on_menuitem_add_files_activate(self, widget):
217
218
    
218
219
    def on_menuitem_branch_missing_revisions_activate(self, widget):
219
220
        """ Branch/Missing revisions menu handler. """
220
 
        
221
 
        import bzrlib
222
 
        
223
221
        local_branch = self.wt.branch
224
222
        
225
223
        other_branch = local_branch.get_parent()
244
242
 
245
243
    def on_menuitem_branch_pull_activate(self, widget):
246
244
        """ Branch/Pull menu handler. """
247
 
        
248
245
        branch_to = self.wt.branch
249
246
 
250
247
        location = branch_to.get_parent()
262
259
        if branch_to.get_parent() is None:
263
260
            branch_to.set_parent(branch_from.base)
264
261
 
265
 
        old_rh = branch_to.revision_history()
266
 
        if tree_to is not None:
267
 
            tree_to.pull(branch_from)
268
 
        else:
269
 
            branch_to.pull(branch_from)
 
262
        #old_rh = branch_to.revision_history()
 
263
        #if tree_to is not None:
 
264
        #    tree_to.pull(branch_from)
 
265
        #else:
 
266
        #    branch_to.pull(branch_from)
 
267
        branch_to.pull(branch_from)
 
268
        
 
269
        # TODO: get the number of pulled revisions
 
270
        ret = 0
270
271
        
271
272
        info_dialog(_('Pull successful'), _('%d revision(s) pulled.') % ret)
272
273
    
284
285
    
285
286
    def on_menuitem_branch_initialize_activate(self, widget):
286
287
        """ Initialize current directory. """
 
288
        import bzrlib.bzrdir as bzrdir
 
289
        
287
290
        try:
288
291
            if not os.path.exists(self.path):
289
292
                os.mkdir(self.path)
290
293
     
291
294
            try:
292
295
                existing_bzrdir = bzrdir.BzrDir.open(self.path)
293
 
            except NotBranchError:
 
296
            except errors.NotBranchError:
294
297
                bzrdir.BzrDir.create_branch_convenience(self.path)
295
298
            else:
296
299
                if existing_bzrdir.has_branch():
297
300
                    if existing_bzrdir.has_workingtree():
298
 
                        raise AlreadyBranchError(self.path)
 
301
                        raise errors.AlreadyBranchError(self.path)
299
302
                    else:
300
 
                        raise BranchExistsWithoutWorkingTree(self.path)
 
303
                        raise errors.BranchExistsWithoutWorkingTree(self.path)
301
304
                else:
302
305
                    existing_bzrdir.create_branch()
303
306
                    existing_bzrdir.create_workingtree()
367
370
   
368
371
    def on_menuitem_view_show_hidden_files_activate(self, widget):
369
372
        """ View/Show hidden files menu handler. """
370
 
        self.set_preference('dotted_files', widget.get_active())
 
373
        self.pref.set_preference('dotted_files', widget.get_active())
371
374
 
372
375
    def on_treeview_left_button_press_event(self, widget, event):
373
376
        """ Occurs when somebody right-clicks in the bookmark list. """
393
396
    def on_treeview_right_button_press_event(self, widget, event):
394
397
        """ Occurs when somebody right-clicks in the file list. """
395
398
        if event.button == 3:
 
399
            # Create a menu
 
400
            from menu import OliveMenu
 
401
            menu = OliveMenu(self.get_path(), self.get_selected_right())
396
402
            # get the menu items
397
 
            m_add = self.menu.ui.get_widget('/context_right/add')
398
 
            m_remove = self.menu.ui.get_widget('/context_right/remove')
399
 
            m_commit = self.menu.ui.get_widget('/context_right/commit')
400
 
            m_diff = self.menu.ui.get_widget('/context_right/diff')
 
403
            m_add = menu.ui.get_widget('/context_right/add')
 
404
            m_remove = menu.ui.get_widget('/context_right/remove')
 
405
            m_commit = menu.ui.get_widget('/context_right/commit')
 
406
            m_diff = menu.ui.get_widget('/context_right/diff')
401
407
            # check if we're in a branch
402
408
            try:
403
409
                from bzrlib.branch import Branch
404
410
                Branch.open_containing(self.get_path())
 
411
                m_add.set_sensitive(True)
 
412
                m_remove.set_sensitive(True)
 
413
                m_commit.set_sensitive(True)
 
414
                m_diff.set_sensitive(True)
 
415
            except errors.NotBranchError:
405
416
                m_add.set_sensitive(False)
406
417
                m_remove.set_sensitive(False)
407
418
                m_commit.set_sensitive(False)
408
419
                m_diff.set_sensitive(False)
409
 
            except errors.NotBranchError:
410
 
                m_add.set_sensitive(True)
411
 
                m_remove.set_sensitive(True)
412
 
                m_commit.set_sensitive(True)
413
 
                m_diff.set_sensitive(True)
414
 
            self.menu.right_context_menu().popup(None, None, None, 0,
415
 
                                                 event.time)
 
420
            menu.right_context_menu().popup(None, None, None, 0,
 
421
                                            event.time)
416
422
        
417
423
    def on_treeview_right_row_activated(self, treeview, path, view_column):
418
424
        """ Occurs when somebody double-clicks or enters an item in the
419
425
        file list. """
420
426
        import os.path
421
427
        
 
428
        from launch import launch
 
429
        
422
430
        newdir = self.get_selected_right()
423
431
        
424
432
        if newdir == '..':
865
873
        """
866
874
        if self.config.has_option('preferences', option):
867
875
            if kind == 'bool':
868
 
                return self.config.getboolean('preferences', option)
 
876
                #return self.config.getboolean('preferences', option)
 
877
                return True
869
878
            elif kind == 'int':
870
879
                return self.config.getint('preferences', option)
871
880
            elif kind == 'float':