diff options
author | Wim Taymans <wtaymans@redhat.com> | 2014-06-05 15:31:30 +0200 |
---|---|---|
committer | Wim Taymans <wtaymans@redhat.com> | 2014-06-05 15:31:30 +0200 |
commit | 345f70429d9482b2113a8e2aa4bdef6c55841e66 (patch) | |
tree | 15b99b6f7517ec6ab7b450a717e69c93f3412cb6 | |
parent | 87fe3eb01144c31a246fb49d17b1b19ec264bd7c (diff) |
.
-rw-r--r-- | data/app-menu.ui | 22 | ||||
-rw-r--r-- | data/new-recording-dialog.ui | 146 | ||||
-rw-r--r-- | data/new-screenshot-dialog.ui | 176 | ||||
-rw-r--r-- | data/org.gnome.ScreenRecorder.Application.data.gresource.xml | 2 | ||||
-rw-r--r-- | data/window.ui | 60 | ||||
-rw-r--r-- | src/app/main.js | 54 | ||||
-rw-r--r-- | src/app/recording.js | 172 | ||||
-rw-r--r-- | src/app/window.js | 176 | ||||
-rw-r--r-- | src/org.gnome.ScreenRecorder.Application.src.gresource.xml | 6 |
9 files changed, 636 insertions, 178 deletions
diff --git a/data/app-menu.ui b/data/app-menu.ui index 36e29a2..9450cd5 100644 --- a/data/app-menu.ui +++ b/data/app-menu.ui @@ -2,24 +2,16 @@ <menu id="app-menu"> <section> <item> - <attribute name="label" translatable="yes">_New</attribute> - <attribute name="action">win.new-location</attribute> - <attribute name="accel"><Primary>n</attribute> - </item> - </section> - <submenu> - <attribute translatable="yes" name="label">Temperature unit</attribute> - <item> - <attribute translatable="yes" name="label">Celsius</attribute> - <attribute name="action">app.temperature-unit</attribute> - <attribute name="target">centigrade</attribute> + <attribute name="label" translatable="yes">New _Screenshot</attribute> + <attribute name="action">win.new-screenshot</attribute> + <attribute name="accel"><Primary>s</attribute> </item> <item> - <attribute translatable="yes" name="label">Fahrenheit</attribute> - <attribute name="action">app.temperature-unit</attribute> - <attribute name="target">fahrenheit</attribute> + <attribute name="label" translatable="yes">New Screen _Recording</attribute> + <attribute name="action">win.new-recording</attribute> + <attribute name="accel"><Primary>r</attribute> </item> - </submenu> + </section> <section> <item> <attribute name="action">win.about</attribute> diff --git a/data/new-recording-dialog.ui b/data/new-recording-dialog.ui new file mode 100644 index 0000000..d89dee7 --- /dev/null +++ b/data/new-recording-dialog.ui @@ -0,0 +1,146 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.18.1 --> +<interface> + <requires lib="gtk+" version="3.12"/> + <object class="GtkAdjustment" id="adjustment1"> + <property name="upper">99</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkDialog" id="recording-dialog"> + <property name="can_focus">False</property> + <property name="title" translatable="yes">New Screenshot</property> + <property name="modal">True</property> + <property name="type_hint">dialog</property> + <property name="transient-for">parent-window</property> + <child internal-child="vbox"> + <object class="GtkBox" id="dialog-vbox1"> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">2</property> + <child internal-child="action_area"> + <object class="GtkButtonBox" id="dialog-action_area1"> + <property name="can_focus">False</property> + <property name="layout_style">end</property> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkBox" id="box1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child> + <object class="GtkLabel" id="label1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="xalign">0</property> + <property name="label" translatable="yes"><b>Record Screen</b></property> + <property name="use_markup">True</property> + <property name="ellipsize">start</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkRadioButton" id="record-all"> + <property name="label" translatable="yes">Record the whole sc_reen</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_underline">True</property> + <property name="xalign">0</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkRadioButton" id="record-area"> + <property name="label" translatable="yes">Select _area to record</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_underline">True</property> + <property name="xalign">0</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + <property name="group">record-all</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkBox" id="box4"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkLabel" id="label2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="xalign">0</property> + <property name="label" translatable="yes"><b>Audio</b></property> + <property name="use_markup">True</property> + <property name="ellipsize">start</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="checkbutton1"> + <property name="label" translatable="yes">Record audio</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + </object> + </child> + </object> +</interface> diff --git a/data/new-screenshot-dialog.ui b/data/new-screenshot-dialog.ui new file mode 100644 index 0000000..0667335 --- /dev/null +++ b/data/new-screenshot-dialog.ui @@ -0,0 +1,176 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.18.1 --> +<interface> + <requires lib="gtk+" version="3.12"/> + <object class="GtkAdjustment" id="adjustment1"> + <property name="upper">99</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkDialog" id="screenshot-dialog"> + <property name="can_focus">False</property> + <property name="title" translatable="yes">New Screenshot</property> + <property name="modal">True</property> + <property name="type_hint">dialog</property> + <property name="transient-for">parent-window</property> + <child internal-child="vbox"> + <object class="GtkBox" id="dialog-vbox1"> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">2</property> + <child internal-child="action_area"> + <object class="GtkButtonBox" id="dialog-action_area1"> + <property name="can_focus">False</property> + <property name="layout_style">end</property> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkBox" id="box1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child> + <object class="GtkLabel" id="label1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="xalign">0</property> + <property name="label" translatable="yes"><b>Take Screenshot</b></property> + <property name="use_markup">True</property> + <property name="ellipsize">start</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkRadioButton" id="screenshot-all"> + <property name="label" translatable="yes">Grab the whole sc_reen</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_underline">True</property> + <property name="xalign">0</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkRadioButton" id="screenshot-window"> + <property name="label" translatable="yes">Grab the current _window</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_underline">True</property> + <property name="xalign">0</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + <property name="group">screenshot-all</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + <child> + <object class="GtkRadioButton" id="screenshot-area"> + <property name="label" translatable="yes">Select _area to grab</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_underline">True</property> + <property name="xalign">0</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + <property name="group">screenshot-window</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">3</property> + </packing> + </child> + <child> + <object class="GtkBox" id="box2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="spacing">6</property> + <child> + <object class="GtkLabel" id="label2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">Grab after a _delay of</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">spinbutton1</property> + <property name="ellipsize">start</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkSpinButton" id="spinbutton1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="max_width_chars">7</property> + <property name="adjustment">adjustment1</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">seconds</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">4</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + </object> +</interface> diff --git a/data/org.gnome.ScreenRecorder.Application.data.gresource.xml b/data/org.gnome.ScreenRecorder.Application.data.gresource.xml index 313313c..b9b62ac 100644 --- a/data/org.gnome.ScreenRecorder.Application.data.gresource.xml +++ b/data/org.gnome.ScreenRecorder.Application.data.gresource.xml @@ -3,6 +3,8 @@ <gresource prefix="/org/gnome/ScreenRecorder/Application"> <file preprocess="xml-stripblanks">app-menu.ui</file> <file preprocess="xml-stripblanks">window.ui</file> + <file preprocess="xml-stripblanks">new-screenshot-dialog.ui</file> + <file preprocess="xml-stripblanks">new-recording-dialog.ui</file> <file>application.css</file> </gresource> </gresources> diff --git a/data/window.ui b/data/window.ui index a5a1318..37ce5ea 100644 --- a/data/window.ui +++ b/data/window.ui @@ -14,6 +14,18 @@ </item> </section> </menu> + <menu id="new-menu"> + <section> + <item> + <attribute name="action">win.new-screenshot</attribute> + <attribute name="label" translatable="yes">New Screenshot...</attribute> + </item> + <item> + <attribute name="action">win.new-recording</attribute> + <attribute name="label" translatable="yes">New Screen recording...</attribute> + </item> + </section> + </menu> <object class="GtkMenuButton" id="selection-menu-button"> <property name="menu-model">selection-menu</property> <property name="visible">True</property> @@ -28,7 +40,7 @@ <object class="GtkLabel" id="selection-menu-button-label"> <property name="visible">True</property> <property name="can-focus">False</property> - <property name="label" translatable="yes">Click on locations to select them</property> + <property name="label" translatable="yes">Click on recordings to select them</property> </object> <packing> <property name="pack-type">start</property> @@ -58,39 +70,21 @@ <property name="vexpand">False</property> <property name="show-close-button">True</property> <child> - <object class="GtkButton" id="new-button"> + <object class="GtkMenuButton" id="new-button"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="label" translatable="yes">New</property> - <property name="action-name">win.new-location</property> <property name="valign">center</property> + <property name="menu_model">new-menu</property> + <property name="action_name">win.new-menu</property> <style> <class name="text-button"/> </style> - </object> - <packing> - <property name="pack_type">start</property> - </packing> - </child> - <child> - <object class="GtkButton" id="world-button"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="action-name">win.go-world</property> - <property name="valign">center</property> - <style> - <class name="image-button"/> - </style> - <child internal-child="accessible"> - <object class="AtkObject" id="world-button-a11y"> - <property name="accessible-name" translatable="yes">Back</property> - </object> - </child> <child> - <object class="GtkImage" id="world-button-image"> + <object class="GtkLabel" id="new-button-label"> <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="icon-size">1</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes">New</property> + <property name="valign">center</property> </object> </child> </object> @@ -176,20 +170,14 @@ <property name="can_focus">False</property> <property name="orientation">vertical</property> <child> - <object class="GtkStack" id="main-stack"> - <property name="transition-type">crossfade</property> - <child> - <placeholder/> <!-- world view --> - </child> + <object class="GtkAlignment" id="recordings-view"> + <property name="visible">True</property> + <property name="vexpand">True</property> <child> - <placeholder/> <!-- city view --> + <placeholder/> <!-- recordings view --> </child> </object> <packing> - <property name="left-attach">0</property> - <property name="top-attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> diff --git a/src/app/main.js b/src/app/main.js index 3dbc46b..3aea457 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -36,8 +36,8 @@ const Lang = imports.lang; const Util = imports.misc.util; const Window = imports.app.window; -const World = imports.shared.world; -const CurrentLocationController = imports.app.currentLocationController; +const Recording = imports.app.recording; + function initEnvironment() { window.getApp = function() { @@ -58,27 +58,6 @@ const Application = new Lang.Class({ this.quit(); }, - _onShowLocation: function(action, parameter) { - let location = this.world.deserialize(parameter.deep_unpack()); - let win = this._createWindow(); - - let info = this.model.getLocationInfo(location); - if (!info) { - this.model.addLocation(location, false); - info = this.model.getLocationInfo(location); - } - - win.showInfo(info); - }, - - _onNewLocation: function(action, parameter) { - let win = this.get_active_window(); - if (!win) - win = this._createWindow(); - - win.activate_action('new-location', null); - }, - _initAppMenu: function() { let builder = new Gtk.Builder(); builder.add_from_resource('/org/gnome/ScreenRecorder/Application/app-menu.ui'); @@ -96,8 +75,7 @@ const Application = new Lang.Class({ let settings = Gtk.Settings.get_for_screen(Gdk.Screen.get_default()); settings.gtk_application_prefer_dark_theme = true; - this.model = new World.WorldModel(this.world, true); - this._currentLocationController = new CurrentLocationController.CurrentLocationController(this.model); + this.model = new Recording.RecordingsModel(); this.model.connect('notify::loading', Lang.bind(this, function() { if (this.model.loading) @@ -110,12 +88,7 @@ const Application = new Lang.Class({ Util.initActions(this, [{ name: 'quit', - activate: this._onQuit }, - { name: 'show-location', - activate: this._onShowLocation, - parameter_type: new GLib.VariantType('v') }, - { name: 'new-location', - activate: this._onNewLocation }]); + activate: this._onQuit }]); this._initAppMenu(); @@ -126,24 +99,7 @@ const Application = new Lang.Class({ _createWindow: function() { let win = new Window.MainWindow({ application: this }); - if (this.model.loading) { - let timeoutId, notifyId; - let model = this.model; - - timeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 1000, function() { - log('Timeout during model load, perhaps the network is not available?'); - model.disconnect(notifyId); - win.show(); - return false; - }); - notifyId = this.model.connect('notify::loading', function(model) { - model.disconnect(notifyId); - GLib.source_remove(timeoutId); - win.show(); - }); - } else { - win.show(); - } + win.show(); return win; }, 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'); + } + } +}); diff --git a/src/app/window.js b/src/app/window.js index 4fa4653..d32c55d 100644 --- a/src/app/window.js +++ b/src/app/window.js @@ -1,6 +1,6 @@ // -*- Mode: js; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4 -*- // -// Copyright (c) 2012 Giovanni Campagna <scampa.giovanni@gmail.com> +// Copyright (c) 2014 Wim Taymans <wtaymans@redhat.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 @@ -21,45 +21,40 @@ const GObject = imports.gi.GObject; const Gtk = imports.gi.Gtk; const Lang = imports.lang; -const City = imports.app.city; const Params = imports.misc.params; -const World = imports.shared.world; const Util = imports.misc.util; const Gettext = imports.gettext; const Tweener = imports.tweener.tweener; +const Recording = imports.app.recording; const Page = { - WORLD: 0, - CITY: 1 + SCREENSHOTS: 0, + RECORDINGS: 1 }; -const NewLocationController = new Lang.Class({ - Name: 'NewLocationController', +const NewScreenshotController = new Lang.Class({ + Name: 'NewScreenshotController', - _init: function(parentWindow, worldModel) { - this._worldModel = worldModel; + _init: function(parentWindow, recordingsModel) { + this._recordingsModel = recordingsModel; - let builder = Util.loadUI('/org/gnome/ScreenRecorder/Application/new-location-dialog.ui', + let builder = Util.loadUI('/org/gnome/ScreenRecorder/Application/new-screenshot-dialog.ui', { 'parent-window': parentWindow }); - let dialog = builder.get_object('location-dialog'); - let entry = builder.get_object('location-entry'); + let dialog = builder.get_object('screenshot-dialog'); dialog.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL); dialog.add_button(Gtk.STOCK_ADD, Gtk.ResponseType.OK); dialog.set_default_response(Gtk.ResponseType.OK); dialog.connect('response', Lang.bind(this, this._onResponse)); - entry.connect('notify::location', Lang.bind(this, this._locationChanged)); this._dialog = dialog; - this._entry = entry; }, run: function() { this._dialog.show(); - this._locationChanged(this._entry); }, _onResponse: function(dialog, response) { @@ -68,15 +63,41 @@ const NewLocationController = new Lang.Class({ if (response != Gtk.ResponseType.OK) return; - let location = this._entry.location; - if (!location) - return; + this._recordingsModel.addScreenshot(location, true); + } +}); + +const NewRecordingController = new Lang.Class({ + Name: 'NewRecordingController', + + _init: function(parentWindow, recordingsModel) { + this._recordingsModel = recordingsModel; + + let builder = Util.loadUI('/org/gnome/ScreenRecorder/Application/new-recording-dialog.ui', + { 'parent-window': parentWindow }); + + let dialog = builder.get_object('recording-dialog'); + + dialog.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL); + dialog.add_button(Gtk.STOCK_ADD, Gtk.ResponseType.OK); + dialog.set_default_response(Gtk.ResponseType.OK); + + dialog.connect('response', Lang.bind(this, this._onResponse)); + + this._dialog = dialog; + }, - this._worldModel.addLocation(location, true); + run: function() { + this._dialog.show(); }, - _locationChanged: function(entry) { - this._dialog.set_response_sensitive(Gtk.ResponseType.OK, entry.location != null); + _onResponse: function(dialog, response) { + dialog.destroy(); + + if (response != Gtk.ResponseType.OK) + return; + + this._recordingsModel.addRecording(location, true); } }); @@ -89,14 +110,17 @@ const MainWindow = new Lang.Class({ height_request: 520 }); this.parent(params); - this._world = this.application.world; this._currentInfo = null; - this._currentPage = Page.WORLD; + this._currentPage = Page.SCREENSHOTS; this._pageWidgets = [[],[]]; Util.initActions(this, - [{ name: 'new-location', - activate: this._newLocation }, + [{ name: 'new-button', + activate: this._newButton }, + { name: 'new-screenshot', + activate: this._newScreenshot }, + { name: 'new-recording', + activate: this._newRecording }, { name: 'about', activate: this._showAbout }, { name: 'close', @@ -105,8 +129,10 @@ const MainWindow = new Lang.Class({ activate: this._setSelectionMode, parameter_type: new GLib.VariantType('b'), state: new GLib.Variant('b', false) }, - { name: 'go-world', - activate: this._goWorld }, + { name: 'go-screenshot', + activate: this._goScreenshot }, + { name: 'go-recording', + activate: this._goRecording }, { name: 'select-all', activate: this._selectAll }, { name: 'select-none', @@ -122,45 +148,35 @@ const MainWindow = new Lang.Class({ let grid = builder.get_object('main-panel'); this._header = builder.get_object('header-bar'); this.set_titlebar(this._header); - let [title, subtitle] = this._getTitle(); - this._header.title = title; - this._header.subtitle = subtitle; let newButton = builder.get_object('new-button'); - this._pageWidgets[Page.WORLD].push(newButton); - - let goWorldButton = builder.get_object('world-button'); - this._pageWidgets[Page.CITY].push(goWorldButton); - - let goWorldButtonImage = builder.get_object('world-button-image'); - goWorldButtonImage.icon_name = (goWorldButton.get_direction() == Gtk.TextDirection.RTL ? - 'go-previous-rtl-symbolic' : 'go-previous-symbolic'); + this._pageWidgets[Page.SCREENSHOTS].push(newButton); let select = builder.get_object('select-button'); - this._pageWidgets[Page.WORLD].push(select); + this._pageWidgets[Page.SCREENSHOTS].push(select); let refresh = builder.get_object('refresh-button'); - this._pageWidgets[Page.CITY].push(refresh); + this._pageWidgets[Page.RECORDINGS].push(refresh); let selectDone = builder.get_object('done-button'); - this._pageWidgets[Page.WORLD].push(selectDone); + this._pageWidgets[Page.SCREENSHOTS].push(selectDone); let selectionBar = builder.get_object('selection-bar'); let selectionMenu = builder.get_object("selection-menu"); this._selectionMenuButton = builder.get_object('selection-menu-button'); this._selectionMenuButtonLabel = builder.get_object('selection-menu-button-label'); - this._stack = builder.get_object('main-stack'); + this._stack = builder.get_object('recordings-view'); this._deleteButton = builder.get_object('delete-button'); - this._cityView = new City.ScreenRecorderView({ hexpand: true, - vexpand: true }); - this._stack.add(this._cityView); +// this._recordingsView = new Recording.RecordingsContentView({ hexpand: true, + //vexpand: true }); +// this._stack.add(this._recordingsView); - this._worldView = new World.WorldContentView(this.application.model, { visible: true }); - let iconView = this._worldView.iconView; - this._stack.add(this._worldView); + this._recordingsView = new Recording.RecordingsContentView(this.application.model, { visible: true }); + let iconView = this._recordingsView.iconView; + this._stack.add(this._recordingsView); iconView.connect('item-activated', Lang.bind(this, this._itemActivated)); @@ -187,12 +203,10 @@ const MainWindow = new Lang.Class({ GObject.BindingFlags.SYNC_CREATE); iconView.bind_property('selection-mode', selectionBar, 'visible', GObject.BindingFlags.SYNC_CREATE); - this._worldView.bind_property('empty', this.lookup_action('selection-mode'), 'enabled', + this._recordingsView.bind_property('empty', this.lookup_action('selection-mode'), 'enabled', GObject.BindingFlags.SYNC_CREATE | GObject.BindingFlags.INVERT_BOOLEAN); - this._stack.set_visible_child(this._worldView); - iconView.connect('view-selection-changed', Lang.bind(this, function() { let items = iconView.get_selection(); let label; @@ -204,7 +218,7 @@ const MainWindow = new Lang.Class({ items.length).format(items.length); sensitive = true; } else { - label = _("Click on locations to select them"); + label = _("Click on recordings to select them"); sensitive = false; } @@ -215,12 +229,12 @@ const MainWindow = new Lang.Class({ this.add(grid); grid.show_all(); - for (let i = 0; i < this._pageWidgets[Page.CITY].length; i++) - this._pageWidgets[Page.CITY][i].hide(); + for (let i = 0; i < this._pageWidgets[Page.RECORDINGS].length; i++) + this._pageWidgets[Page.RECORDINGS][i].hide(); }, update: function() { - this._cityView.update(); + this._recordingsView.update(); }, _getTitle: function() { @@ -255,37 +269,53 @@ const MainWindow = new Lang.Class({ }, showInfo: function(info) { - this._cityView.info = info; - this._cityView.connectClock(); - this._stack.set_visible_child(this._cityView); - this._goToPage(Page.CITY); + this._recordingsView.info = info; + this._recordingsView.connectClock(); + this._stack.set_visible_child(this._recordingsView); + this._goToPage(Page.RECORDINGS); + }, + + _goScreenshot: function() { + this._stack.set_visible_child(this._recordingsView); + this._goToPage(Page.SCREENSHOTS); + this._recordingsView.disconnectClock(); + }, + + _goRecording: function() { + this._stack.set_visible_child(this._recordingsView); + this._goToPage(Page.RECORDINGS); + this._recordingsView.disconnectClock(); }, - _goWorld: function() { - this._stack.set_visible_child(this._worldView); - this._goToPage(Page.WORLD); - this._cityView.disconnectClock(); + _newButton: function() { }, - _newLocation: function() { - let controller = new NewLocationController(this.get_toplevel(), - this._worldView.model); + _newScreenshot: function() { + let controller = new NewScreenshotController(this.get_toplevel(), + this._recordingsView.model); controller.run(); }, + _newRecording: function() { + let controller = new NewRecordingController(this.get_toplevel(), + this._recordingsView.model); + + controller.run(); + }, + _setSelectionMode: function(action, param) { - this._worldView.iconView.selection_mode = param.get_boolean(); + this._recordingsView.iconView.selection_mode = param.get_boolean(); this._deleteButton.sensitive = false; }, _selectAll: function() { - this._worldView.iconView.selection_mode = true; - this._worldView.iconView.select_all(); + this._recordingsView.iconView.selection_mode = true; + this._recordingsView.iconView.select_all(); }, _selectNone: function() { - this._worldView.iconView.unselect_all(); + this._recordingsView.iconView.unselect_all(); }, _showAbout: function() { @@ -314,8 +344,8 @@ const MainWindow = new Lang.Class({ }, _deleteSelected: function() { - let items = this._worldView.iconView.get_selection(); - let model = this._worldView.iconView.model; + let items = this._recordingsView.iconView.get_selection(); + let model = this._recordingsView.iconView.model; for (let i = items.length - 1; i >= 0; i--) { let [res, iter] = model.get_iter(items[i]); @@ -323,7 +353,7 @@ const MainWindow = new Lang.Class({ model.removeLocation(iter); } - this._worldView.iconView.selection_mode = false; + this._recordingsView.iconView.selection_mode = false; }, _close: function() { diff --git a/src/org.gnome.ScreenRecorder.Application.src.gresource.xml b/src/org.gnome.ScreenRecorder.Application.src.gresource.xml index 04de2c7..9dae5ae 100644 --- a/src/org.gnome.ScreenRecorder.Application.src.gresource.xml +++ b/src/org.gnome.ScreenRecorder.Application.src.gresource.xml @@ -1,14 +1,10 @@ <?xml version="1.0" encoding="UTF-8"?> <gresources> <gresource prefix="/org/gnome/ScreenRecorder/Application/js"> - <file>app/city.js</file> - <file>app/currentLocationController.js</file> - <file>app/forecast.js</file> + <file>app/recording.js</file> <file>app/main.js</file> <file>app/window.js</file> <file>misc/params.js</file> <file>misc/util.js</file> - <file>shared/strings.js</file> - <file>shared/world.js</file> </gresource> </gresources> |