示例#1
0
 def __init__(self):
 
     self.recorder = Recorder()
         
     keybinder.init()
     keybinder.bind('<Control>Escape', self.callback, None)
     
     self.overlay = Overlay()
     self.overlay.connect('trigger', lambda *args: self.start_recording(*self.overlay.get_selection()))
     self.overlay.show_all()
示例#2
0
class Screencast:
    
    def __init__(self):
    
        self.recorder = Recorder()
            
        keybinder.init()
        keybinder.bind('<Control>Escape', self.callback, None)
        
        self.overlay = Overlay()
        self.overlay.connect('trigger', lambda *args: self.start_recording(*self.overlay.get_selection()))
        self.overlay.show_all()
    
    
    def start_recording(self, x, y, width, height):
        
        def completed_cb(*args):
            #loop.quit()
            self.recorder.start(x, y, width, height)
    
        countdown = Countdown()
        countdown.connect('completed', completed_cb)
        countdown.start()
    
        
    def callback(self, key, data):
    
        def progress_cb(*args):
            pass
    
        self.recorder.stop()
        
        filechooser = gtk.FileChooserDialog("Save", self.overlay, gtk.FileChooserAction.SAVE, buttons=(gtk.STOCK_CANCEL, gtk.ResponseType.CANCEL, gtk.STOCK_OPEN, gtk.ResponseType.ACCEPT))
        filechooser.set_current_name('Screencast.avi')
        filechooser.set_type_hint(gdk.WindowTypeHint.NORMAL)
        filechooser.set_urgency_hint(True)
        res = filechooser.run()
        
        filechooser.hide()
        
        if res == gtk.ResponseType.ACCEPT:
            source = gio.File.new_for_path(self.recorder.get_path())
            dest = gio.File.new_for_uri(filechooser.get_uri())
            source.copy(dest, gio.FileCopyFlags.OVERWRITE, None, progress_cb, None)
            loop.quit()
        else:
            loop.quit()