summaryrefslogtreecommitdiff
path: root/src/app/recording.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/recording.js')
-rw-r--r--src/app/recording.js172
1 files changed, 172 insertions, 0 deletions
diff --git a/src/app/recording.js b/src/app/recording.js
new file mode 100644
index 0000000..40ed78b
--- /dev/null
+++ b/src/app/recording.js
@@ -0,0 +1,172 @@
+// -*- Mode: js; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4 -*-
+//
+// Copyright (c) 2012 Giovanni Campagna <scampa.giovanni@gmail.com>
+//
+// Gnome Screen Recorder is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2 of the License, or (at your
+// option) any later version.
+//
+// Gnome Screen Recorder is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with Gnome Screen Recorder; if not, write to the Free Software Foundation,
+// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+const Gd = imports.gi.Gd;
+const GdkPixbuf = imports.gi.GdkPixbuf;
+const GLib = imports.gi.GLib;
+const GObject = imports.gi.GObject;
+const Gtk = imports.gi.Gtk;
+const Lang = imports.lang;
+
+const Params = imports.misc.params;
+const Util = imports.misc.util;
+
+const Columns = {
+ ID: Gd.MainColumns.ID,
+ URI: Gd.MainColumns.URI,
+ PRIMARY_TEXT: Gd.MainColumns.PRIMARY_TEXT,
+ SECONDARY_TEXT: Gd.MainColumns.SECONDARY_TEXT,
+ ICON: Gd.MainColumns.ICON,
+ MTIME: Gd.MainColumns.MTIME,
+ SELECTED: Gd.MainColumns.SELECTED
+};
+
+const ICON_SIZE = 128;
+
+const RecordingsModel = new Lang.Class({
+ Name: 'RecordingsModel',
+ Extends: Gtk.ListStore,
+ Properties: {
+ 'loading': GObject.ParamSpec.boolean('loading', '', '', GObject.ParamFlags.READABLE, false)
+ },
+
+ _init: function() {
+ this.parent();
+ this.set_column_types([GObject.TYPE_STRING,
+ GObject.TYPE_STRING,
+ GObject.TYPE_STRING,
+ GObject.TYPE_STRING,
+ GdkPixbuf.Pixbuf,
+ GObject.TYPE_INT,
+ GObject.TYPE_BOOLEAN ]);
+
+ this._settings = Util.getSettings('org.gnome.ScreenRecorder.Application');
+
+ this._loadingCount = 0;
+ },
+
+ _updateLoadingCount: function(delta) {
+ let wasLoading = this._loadingCount > 0;
+ this._loadingCount += delta;
+ let isLoading = this._loadingCount > 0;
+
+ if (wasLoading != isLoading)
+ this.notify('loading');
+ },
+
+ updateInfo: function(info) {
+ info.update();
+ this._updateLoadingCount(+1);
+ },
+
+ get loading() {
+ return this._loadingCount > 0;
+ },
+});
+
+const RecordingsIconView = new Lang.Class({
+ Name: 'RecordingsView',
+ Extends: Gd.MainView,
+
+ _init: function(params) {
+ params = Params.fill(params, { view_type: Gd.MainViewType.ICON });
+ this.parent(params);
+
+ this.connect('selection-mode-request', Lang.bind(this, function() {
+ this.selection_mode = true;
+ }));
+ }
+});
+
+const RecordingsContentView = new Lang.Class({
+ Name: 'RecordingsContentView',
+ Extends: Gtk.Bin,
+ Properties: { 'empty': GObject.ParamSpec.boolean('empty', '', '', GObject.ParamFlags.READABLE, false) },
+
+ _init: function(model, params) {
+ params = Params.fill(params, { hexpand: true, vexpand: true,
+ halign: Gtk.Align.FILL, valign: Gtk.Align.FILL });
+ this.parent(params);
+
+ this.iconView = new RecordingsIconView({ model: model, visible: true });
+
+ this._placeHolder = new Gtk.Grid({ halign: Gtk.Align.CENTER,
+ valign: Gtk.Align.CENTER,
+ name: 'recordings-page-placeholder',
+ column_spacing: 6 });
+ this._placeHolder.get_style_context().add_class('dim-label');
+
+ this._placeHolder.attach(new Gtk.Label({ name: 'recordings-page-placeholder-title',
+ label: _("Add Recording"),
+ xalign: 0.0 }),
+ 1, 0, 1, 1);
+ this._placeHolder.attach(new Gtk.Label({ label: _("Use the <b>New</b> button on the toolbar to create a new recording"),
+ use_markup: true,
+ max_width_chars: 30,
+ wrap: true,
+ halign: Gtk.Align.START,
+ valign: Gtk.Align.START }),
+ 1, 1, 1, 1);
+ this._placeHolder.show_all();
+
+ this.model = model;
+ this._rowInsertedId = model.connect('row-inserted', Lang.bind(this, this._updateEmpty));
+ this._rowDeletedId = model.connect('row-deleted', Lang.bind(this, this._updateEmpty));
+
+ let [ok, ] = model.get_iter_first();
+ if (ok)
+ this.add(this.iconView);
+ else
+ this.add(this._placeHolder);
+ this._empty = !ok;
+ },
+
+ get empty() {
+ return this._empty;
+ },
+
+ vfunc_destroy: function() {
+ if (this._rowInsertedId) {
+ this.model.disconnect(this._rowInsertedId);
+ this._rowInsertedId = 0;
+ }
+ if (this._rowDeletedId) {
+ this.model.disconnect(this._rowDeletedId);
+ this._rowDeletedId = 0;
+ }
+
+ this.parent();
+ },
+
+ _updateEmpty: function() {
+ let [ok, iter] = this.model.get_iter_first();
+
+ if (!ok != this._empty) {
+ if (ok) {
+ this.remove(this._placeHolder);
+ this.add(this.iconView);
+ } else {
+ this.remove(this.iconView);
+ this.add(this._placeHolder);
+ }
+
+ this._empty = !ok;
+ this.notify('empty');
+ }
+ }
+});