2012-09-02 21:23:50 -04:00
|
|
|
|
|
|
|
const Lang = imports.lang;
|
2012-08-09 20:39:43 -04:00
|
|
|
const Main = imports.ui.main;
|
2012-09-02 21:23:50 -04:00
|
|
|
|
|
|
|
const Gio = imports.gi.Gio;
|
|
|
|
const Meta = imports.gi.Meta;
|
|
|
|
const Shell = imports.gi.Shell;
|
|
|
|
|
|
|
|
const Recorder = new Lang.Class({
|
|
|
|
Name: 'Recorder',
|
|
|
|
|
|
|
|
_init: function() {
|
|
|
|
this._recorderSettings = new Gio.Settings({ schema: 'org.gnome.shell.recorder' });
|
|
|
|
this._desktopLockdownSettings = new Gio.Settings({ schema: 'org.gnome.desktop.lockdown' });
|
|
|
|
this._bindingSettings = new Gio.Settings({ schema: 'org.gnome.shell.keybindings' });
|
|
|
|
this._recorder = null;
|
|
|
|
},
|
|
|
|
|
|
|
|
enable: function() {
|
2012-08-09 20:39:43 -04:00
|
|
|
Main.wm.addKeybinding('toggle-recording',
|
|
|
|
this._bindingSettings,
|
|
|
|
Meta.KeyBindingFlags.NONE,
|
2013-03-20 10:44:03 -04:00
|
|
|
Shell.KeyBindingMode.ALL,
|
2012-08-09 20:39:43 -04:00
|
|
|
Lang.bind(this, this._toggleRecorder));
|
2012-09-02 21:23:50 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
disable: function() {
|
2012-08-09 20:39:43 -04:00
|
|
|
Main.wm.removeKeybinding('toggle-recording');
|
2012-09-02 21:23:50 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
_ensureRecorder: function() {
|
|
|
|
if (this._recorder == null)
|
|
|
|
this._recorder = new Shell.Recorder({ stage: global.stage });
|
|
|
|
return this._recorder;
|
|
|
|
},
|
|
|
|
|
|
|
|
_toggleRecorder: function() {
|
|
|
|
let recorder = this._ensureRecorder();
|
|
|
|
if (recorder.is_recording()) {
|
|
|
|
recorder.close();
|
|
|
|
Meta.enable_unredirect_for_screen(global.screen);
|
2012-09-13 08:27:37 -04:00
|
|
|
} else if (!this._desktopLockdownSettings.get_boolean('disable-save-to-disk')) {
|
2012-09-02 21:23:50 -04:00
|
|
|
// read the parameters from GSettings always in case they have changed
|
2012-09-13 08:27:37 -04:00
|
|
|
recorder.set_framerate(this._recorderSettings.get_int('framerate'));
|
2012-09-02 21:23:50 -04:00
|
|
|
/* Translators: this is a filename used for screencast recording */
|
|
|
|
// xgettext:no-c-format
|
2012-10-25 17:14:20 -04:00
|
|
|
recorder.set_file_template(_("Screencast from %d %t") + '.' + this._recorderSettings.get_string('file-extension'));
|
2012-09-13 08:27:37 -04:00
|
|
|
let pipeline = this._recorderSettings.get_string('pipeline');
|
2012-09-02 21:23:50 -04:00
|
|
|
|
|
|
|
if (!pipeline.match(/^\s*$/))
|
|
|
|
recorder.set_pipeline(pipeline);
|
|
|
|
else
|
|
|
|
recorder.set_pipeline(null);
|
|
|
|
|
|
|
|
Meta.disable_unredirect_for_screen(global.screen);
|
|
|
|
recorder.record();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
const Component = Recorder;
|