Commit 754f987d authored by Meg Ford's avatar Meg Ford

main.js: start adding app menu

parent c732e084
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.6 -->
<object class="GtkApplicationWindow" id="main-window">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Sound Recorder</property>
<child>
<object class="GtkLabel" id="content">
<property name="label" translatable="yes">Placeholder for real content</property>
<property name="visible">True</property>
</object>
</child>
</object>
</interface>
......@@ -4,13 +4,13 @@
jsdir = $(pkgdatadir)
dist_js_DATA = \
util.js \
application.js \
util.js \
audioProfile.js \
fileUtil.js \
info.js \
listview.js \
main.js \
mainWindow.js \
package.js \
play.js \
record.js \
......
......@@ -31,24 +31,24 @@ const Mainloop = imports.mainloop;
const containerProfileMap = {
OGG: "application/ogg",
MP3: "application/x-id3",
AAC: "video/quicktime,variant=(string)iso"
ID3: "application/x-id3",
MP4: "video/quicktime,variant=(string)iso"
};
const audioCodecMap = {
FLAC: "audio/x-flac",
MP3: "audio/mpeg,mpegversion=(int)1,layer=(int)3",
AAC: "audio/mpeg,mpegversion=(int)4",
OGG_OPUS: "audio/x-opus",
ID3: "audio/mpeg,mpegversion=(int)1,layer=(int)3",
MP4: "audio/mpeg,mpegversion=(int)4",
OPUS: "audio/x-opus",
OGG_VORBIS: "audio/x-vorbis"
};
const comboBoxMap = {
OGG_VORBIS: 0,
OGG_OPUS: 1,
OPUS: 1,
FLAC: 2,
MP3: 3,
AAC: 4
ID3: 3,
MP4: 4
};
const AudioProfile = new Lang.Class({
......@@ -66,17 +66,17 @@ const AudioProfile = new Lang.Class({
case comboBoxMap.OGG_VORBIS:
this._values.push({ container: containerProfileMap.OGG, audio: audioCodecMap.OGG_VORBIS });
break;
case comboBoxMap.OGG_OPUS:
this._values.push({ container: containerProfileMap.OGG, audio: audioCodecMap.OGG_OPUS });
case comboBoxMap.OPUS:
this._values.push({ container: containerProfileMap.OGG, audio: audioCodecMap.OPUS });
break;
case comboBoxMap.FLAC:
this._values.push({ container: containerProfileMap.OGG, audio: audioCodecMap.FLAC });
break;
case comboBoxMap.MP3:
this._values.push({ container: containerProfileMap.MP3, audio: audioCodecMap.MP3 });
case comboBoxMap.ID3:
this._values.push({ container: containerProfileMap.MP3, audio: audioCodecMap.ID3 });
break;
case comboBoxMap.AAC:
this._values.push({ container: containerProfileMap.AAC, audio: audioCodecMap.AAC });
case comboBoxMap.MP4:
this._values.push({ container: containerProfileMap.AAC, audio: audioCodecMap.MP4 });
break;
default:
this._values.push({ container: containerProfileMap.OGG, audio: audioCodecMap.OGG_VORBIS });
......
......@@ -42,10 +42,10 @@ const EnumeratorState = {
const mediaTypeMap = {
OGG_VORBIS: "Ogg Vorbis",
OGG_OPUS: "Ogg Opus",
OPUS: "Opus",
FLAC: "Flac",
MP3: "MP3",
AAC: "AAC"
MP4: "MP4"
};
const Listview = new Lang.Class({
......@@ -56,7 +56,7 @@ const Listview = new Lang.Class({
this._allFilesInfo = [];
this.mp3Caps = Gst.Caps.from_string("audio/mpeg, mpegversion=(int)1");
this.oggCaps = Gst.Caps.from_string("audio/ogg");
this.aacCaps = Gst.Caps.from_string("video/quicktime, variant=(string)iso");
this.mp4Caps = Gst.Caps.from_string("video/quicktime, variant=(string)iso");
this.flacCaps = Gst.Caps.from_string("audio/x-flac");
},
......@@ -249,14 +249,14 @@ const Listview = new Lang.Class({
if (containerCaps.is_subset(Gst.Caps.from_string(AudioProfile.containerProfileMap.OGG))) {
if (audioCaps.is_subset(Gst.Caps.from_string(AudioProfile.audioCodecMap.OGG_VORBIS)))
this.file.mediaType = mediaTypeMap.OGG_VORBIS;
else if (audioCaps.is_subset(Gst.Caps.from_string(AudioProfile.audioCodecMap.OGG_OPUS)))
this.file.mediaType = mediaTypeMap.OGG_OPUS;
} else if (containerCaps.is_subset(Gst.Caps.from_string(AudioProfile.containerProfileMap.MP3))) {
if (audioCaps.is_subset(Gst.Caps.from_string(AudioProfile.audioCodecMap.MP3)))
else if (audioCaps.is_subset(Gst.Caps.from_string(AudioProfile.audioCodecMap.OPUS)))
this.file.mediaType = mediaTypeMap.OPUS;
} else if (containerCaps.is_subset(Gst.Caps.from_string(AudioProfile.containerProfileMap.ID3))) {
if (audioCaps.is_subset(Gst.Caps.from_string(AudioProfile.audioCodecMap.ID3)))
this.file.mediaType = mediaTypeMap.MP3;
} else if (containerCaps.is_subset(Gst.Caps.from_string(AudioProfile.containerProfileMap.AAC))) {
if (audioCaps.is_subset(Gst.Caps.from_string(AudioProfile.audioCodecMap.AAC)))
this.file.mediaType = mediaTypeMap.AAC;
} else if (containerCaps.is_subset(Gst.Caps.from_string(AudioProfile.containerProfileMap.MP4))) {
if (audioCaps.is_subset(Gst.Caps.from_string(AudioProfile.audioCodecMap.MP4)))
this.file.mediaType = mediaTypeMap.MP4;
} else if (audioCaps.is_subset(Gst.Caps.from_string(AudioProfile.audioCodecMap.FLAC))) {
this.file.mediaType = mediaTypeMap.FLAC;
} else if (containerCaps) { // !GstPbutils.DiscovererResult.OK should filter these out already
......
......@@ -48,8 +48,29 @@ const Application = new Lang.Class({
Extends: Gtk.Application,
_init: function() {
GLib.set_application_name(_("SoundRecorder"));
this.parent({ application_id: pkg.name });
this.parent({ application_id: pkg.name });
GLib.set_application_name(_("SoundRecorder"));
},
_initAppMenu: function() {
let menu = new Gio.Menu();
menu.append("Preferences", 'app.preferences');
menu.append("Quit",'app.quit');
this.set_app_menu(menu);
let preferences = new Gio.SimpleAction ({ name: 'preferences' });
preferences.connect('activate', Lang.bind(this,
function() {
this._showPreferences();
}));
this.add_action(preferences);
let quitAction = new Gio.SimpleAction ({ name: 'quit' });
quitAction.connect('activate', Lang.bind(this,
function() {
this.quit();
}));
this.add_action(quitAction);
},
vfunc_startup: function() {
......@@ -58,15 +79,17 @@ const Application = new Lang.Class({
Util.loadStyleSheet();
log(_("Sound Recorder started"));
Gst.init(null, 0);
this._initAppMenu();
},
vfunc_activate: function() {
(new MainWindow.MainWindow({ application: this })).show();
},
});
function main(argv) {
return (new Application()).run(argv);
}
......@@ -126,7 +126,7 @@ const MainWindow = new Lang.Class({
},
_defineThemes : function() {
let settings = Gtk.Settings.get_default();
//let settings = Gtk.Settings.get_default();
//settings.gtk_application_prefer_dark_theme = true;
}
});
......
......@@ -294,13 +294,13 @@ function initSubmodule(name) {
}
}
function launch(params) {
/*function launch(params) {
params.flags = params.flags || 0;
let app = new Gio.Application({ application_id: params.name,
flags: (Gio.ApplicationFlags.IS_LAUNCHER |
params.flags),
});
return app.run(ARGV);
}
}*/
......@@ -24,17 +24,17 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/*function loadUI(file) {
file = file || 'main.ui';
/*function loadAppMenu() {
let file = 'appMenu.ui';
let ui = new Gtk.Builder();
ui.add_from_file(GLib.build_filenamev([pkg.pkgdatadir,
file]));
ui.new_from_resource (GLib.build_filenamev([pkg.pkgdatadir,
file]));
return ui;
}*/
function loadStyleSheet(file) {
file = file || 'application.css';
function loadStyleSheet() {
let file = 'application.css';
let provider = new Gtk.CssProvider();
provider.load_from_path(GLib.build_filenamev([pkg.pkgdatadir,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment