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

  • Committer: Szilveszter Farkas (Phanatic)
  • Date: 2006-08-15 17:37:54 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-20060815173754-9877ef0e3e64660e
Some small tweaks in the .desktop file.

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

    * icons/olive-gtk.png: added application icon

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
    pygtk.require("2.0")
22
22
except:
23
23
    pass
24
 
 
25
 
import gtk
26
 
import gtk.glade
27
 
 
28
 
import bzrlib.add
29
 
import bzrlib.errors as errors
30
 
 
31
 
from olive import gladefile
 
24
try:
 
25
    import gtk
 
26
    import gtk.glade
 
27
except:
 
28
    sys.exit(1)
 
29
 
 
30
import olive.backend.errors as errors
 
31
import olive.backend.fileops as fileops
32
32
 
33
33
class OliveAdd:
34
34
    """ Display the Add file(s) dialog and perform the needed actions. """
35
 
    def __init__(self, wt, wtpath, selected=[]):
 
35
    def __init__(self, gladefile, comm, dialog):
36
36
        """ Initialize the Add file(s) dialog. """
37
 
        self.glade = gtk.glade.XML(gladefile, 'window_add', 'olive-gtk')
 
37
        self.gladefile = gladefile
 
38
        self.glade = gtk.glade.XML(self.gladefile, 'window_add')
 
39
        
 
40
        # Communication object
 
41
        self.comm = comm
 
42
        # Dialog object
 
43
        self.dialog = dialog
38
44
        
39
45
        self.window = self.glade.get_widget('window_add')
40
46
        
45
51
        # Connect the signals to the handlers
46
52
        self.glade.signal_autoconnect(dic)
47
53
 
48
 
        self.wt = wt
49
 
        self.wtpath = wtpath
50
 
        self.selected = selected
51
 
 
52
54
    def display(self):
53
55
        """ Display the Add file(s) dialog. """
54
56
        self.window.show_all()
57
59
        radio_selected = self.glade.get_widget('radiobutton_add_selected')
58
60
        radio_unknown = self.glade.get_widget('radiobutton_add_unknown')
59
61
        
 
62
        directory = self.comm.get_path()
 
63
        
 
64
        self.comm.set_busy(self.window)
60
65
        if radio_selected.get_active():
61
66
            # Add only the selected file
62
 
            filename = self.selected
 
67
            filename = self.comm.get_selected_right()
63
68
            
64
69
            if filename is None:
65
 
                error_dialog(_('No file was selected'),
66
 
                                         _('Please select a file from the list,\nor choose the other option.'))
 
70
                self.dialog.error_dialog('No file was selected',
 
71
                                         'Please select a file from the list,\nor choose the other option.')
67
72
                return
68
73
            
69
74
            try:
70
 
                bzrlib.add.smart_add([directory + '/' + filename])
 
75
                fileops.add([directory + '/' + filename])
71
76
            except errors.NotBranchError:
72
 
                error_dialog(_('Directory is not a branch'),
73
 
                                         _('You can perform this action only in a branch.'))
 
77
                self.dialog.error_dialog('Directory is not a branch',
 
78
                                         'You can perform this action only in a branch.')
 
79
                self.comm.set_busy(self.window, False)
74
80
                return
 
81
            except:
 
82
                raise
75
83
        elif radio_unknown.get_active():
76
84
            # Add unknown files recursively
77
85
            try:
78
 
                bzrlib.add.smart_add([directory], True)
 
86
                fileops.add([directory], True)
79
87
            except errors.NotBranchError:
80
 
                error_dialog(_('Directory is not a branch'),
81
 
                                         _('You can perform this action only in a branch.'))
 
88
                self.dialog.error_dialog('Directory is not a branch',
 
89
                                         'You can perform this action only in a branch.')
 
90
                self.comm.set_busy(self.window, False)
82
91
                return
 
92
            except:
 
93
                raise
 
94
        else:
 
95
            # This should really never happen.
 
96
            pass
83
97
        
84
98
        self.close()
 
99
        self.comm.refresh_right()
85
100
    
86
101
    def close(self, widget=None):
87
102
        self.window.destroy()