diff -Nru selene-2.5.7~196~ubuntu15.04.1/build.sh selene-2.5.8~198~ubuntu15.04.1/build.sh --- selene-2.5.7~196~ubuntu15.04.1/build.sh 1970-01-01 00:00:00.000000000 +0000 +++ selene-2.5.8~198~ubuntu15.04.1/build.sh 2015-09-08 00:46:25.000000000 +0000 @@ -0,0 +1,2 @@ + +make 2>&1 | grep -E --color=never 'error:|.vala:.*warning:' | grep -E --color=always "error:|$" diff -Nru selene-2.5.7~196~ubuntu15.04.1/debian/bzr-builder.manifest selene-2.5.8~198~ubuntu15.04.1/debian/bzr-builder.manifest --- selene-2.5.7~196~ubuntu15.04.1/debian/bzr-builder.manifest 2015-08-14 22:16:19.000000000 +0000 +++ selene-2.5.8~198~ubuntu15.04.1/debian/bzr-builder.manifest 2015-09-08 00:46:26.000000000 +0000 @@ -1,2 +1,2 @@ -# bzr-builder format 0.3 deb-version {debupstream}~196 -lp:selene revid:tony.george.kol@gmail.com-20150814215945-u2mpdbvmlap2husw +# bzr-builder format 0.3 deb-version {debupstream}~198 +lp:selene revid:tony.george.kol@gmail.com-20150908003712-9dfiu0yoyqmfl1lo diff -Nru selene-2.5.7~196~ubuntu15.04.1/debian/changelog selene-2.5.8~198~ubuntu15.04.1/debian/changelog --- selene-2.5.7~196~ubuntu15.04.1/debian/changelog 2015-08-14 22:16:19.000000000 +0000 +++ selene-2.5.8~198~ubuntu15.04.1/debian/changelog 2015-09-08 00:46:26.000000000 +0000 @@ -1,11 +1,11 @@ -selene (2.5.7~196~ubuntu15.04.1) vivid; urgency=low +selene (2.5.8~198~ubuntu15.04.1) vivid; urgency=low * Auto build. - -- Tony George Fri, 14 Aug 2015 22:16:19 +0000 + -- Tony George Tue, 08 Sep 2015 00:46:26 +0000 -selene (2.5.7) trusty; urgency=low +selene (2.5.8) trusty; urgency=low - * Use newer version of libgee, libgee-0.8 - - -- Tony George Fri, 14 Aug 2015 14:00:00 +0530 + * Fixed a UI issue + + -- Tony George Mon, 07 Sep 2015 14:00:00 +0530 diff -Nru selene-2.5.7~196~ubuntu15.04.1/selene.geany selene-2.5.8~198~ubuntu15.04.1/selene.geany --- selene-2.5.7~196~ubuntu15.04.1/selene.geany 2015-08-14 22:16:18.000000000 +0000 +++ selene-2.5.8~198~ubuntu15.04.1/selene.geany 2015-09-08 00:46:25.000000000 +0000 @@ -17,13 +17,13 @@ long_line_column=80 [files] -current_page=1 +current_page=2 FILE_NAME_0=9149;Vala;0;EUTF-8;1;1;0;%2Fhome%2Fteejee%2Fprojects%2Flinux%2Fselene%2Fsrc%2FUtility.vala;0;4 -FILE_NAME_1=6087;Vala;0;EUTF-8;1;1;0;%2Fhome%2Fteejee%2Fprojects%2Flinux%2Fselene%2Fsrc%2FMain.vala;0;4 -FILE_NAME_2=7609;Vala;0;EUTF-8;1;1;0;%2Fhome%2Fteejee%2Fprojects%2Flinux%2Fselene%2Fsrc%2FMainWindow.vala;0;4 -FILE_NAME_3=2097;Make;0;EUTF-8;1;1;0;%2Fhome%2Fteejee%2Fprojects%2Flinux%2Fselene%2Fsrc%2Fmakefile;0;4 -FILE_NAME_4=309;None;0;EUTF-8;1;1;0;%2Fhome%2Fteejee%2Fprojects%2Flinux%2Fselene%2Fdebian%2Fchangelog;0;4 -FILE_NAME_5=160;Conf;0;EUTF-8;1;1;0;%2Fhome%2Fteejee%2Fprojects%2Flinux%2Fselene%2Fdebian%2Fcontrol;0;4 +FILE_NAME_1=1189;Vala;0;EUTF-8;1;1;0;%2Fhome%2Fteejee%2Fprojects%2Flinux%2Fselene%2Fsrc%2FMain.vala;0;4 +FILE_NAME_2=26275;Vala;0;EUTF-8;1;1;0;%2Fhome%2Fteejee%2Fprojects%2Flinux%2Fselene%2Fsrc%2FMainWindow.vala;0;4 +FILE_NAME_3=618;Make;0;EUTF-8;1;1;0;%2Fhome%2Fteejee%2Fprojects%2Flinux%2Fselene%2Fsrc%2Fmakefile;0;4 +FILE_NAME_4=160;None;0;EUTF-8;1;1;0;%2Fhome%2Fteejee%2Fprojects%2Flinux%2Fselene%2Fdebian%2Fchangelog;0;4 +FILE_NAME_5=186;Conf;0;EUTF-8;1;1;0;%2Fhome%2Fteejee%2Fprojects%2Flinux%2Fselene%2Fdebian%2Fcontrol;0;4 [VTE] last_dir=/home/teejee diff -Nru selene-2.5.7~196~ubuntu15.04.1/selene.pot selene-2.5.8~198~ubuntu15.04.1/selene.pot --- selene-2.5.7~196~ubuntu15.04.1/selene.pot 2015-08-14 22:16:18.000000000 +0000 +++ selene-2.5.8~198~ubuntu15.04.1/selene.pot 2015-09-08 00:46:25.000000000 +0000 @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: selene 2.2\n" "Report-Msgid-Bugs-To: teejee2008@gmail.com\n" -"POT-Creation-Date: 2015-08-14 17:59-0400\n" +"POT-Creation-Date: 2015-09-07 20:26-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,7 +17,7 @@ "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: EncoderConfigWindow.vala:2359 +#: EncoderConfigWindow.vala:2361 msgid "" "\n" "\n" @@ -97,7 +97,7 @@ msgid "Preset:" msgstr "" -#: EncoderConfigWindow.vala:1980 +#: EncoderConfigWindow.vala:1981 msgid "" "Quality Vs Encoding Speed\n" "\n" @@ -106,7 +106,7 @@ "Realtime: Fastest" msgstr "" -#: EncoderConfigWindow.vala:1982 +#: EncoderConfigWindow.vala:1983 msgid "" "Quality Vs Encoding Speed\n" "\n" @@ -114,7 +114,7 @@ "Larger value = Lower quality, faster\n" msgstr "" -#: EncoderConfigWindow.vala:1990 +#: EncoderConfigWindow.vala:1992 msgid "" "Quality Vs Encoding Speed\n" "Higher values speed-up encoding at the expense of quality.\n" @@ -211,13 +211,13 @@ #: EncoderConfigWindow.vala:1572 EncoderConfigWindow.vala:1597 #: EncoderConfigWindow.vala:1628 EncoderConfigWindow.vala:1645 -#: EncoderConfigWindow.vala:2006 EncoderConfigWindow.vala:2029 -#: EncoderConfigWindow.vala:2052 +#: EncoderConfigWindow.vala:2008 EncoderConfigWindow.vala:2031 +#: EncoderConfigWindow.vala:2054 msgid "Average Bitrate" msgstr "" -#: EncoderConfigWindow.vala:2008 EncoderConfigWindow.vala:2031 -#: EncoderConfigWindow.vala:2054 +#: EncoderConfigWindow.vala:2010 EncoderConfigWindow.vala:2033 +#: EncoderConfigWindow.vala:2056 msgid "Average Bitrate (2-pass)" msgstr "" @@ -289,7 +289,7 @@ msgstr "" #: EncoderConfigWindow.vala:1574 EncoderConfigWindow.vala:1599 -#: EncoderConfigWindow.vala:1630 EncoderConfigWindow.vala:2078 +#: EncoderConfigWindow.vala:1630 EncoderConfigWindow.vala:2080 msgid "Constant Bitrate" msgstr "" @@ -412,7 +412,7 @@ msgid "Embed / Soft Subs" msgstr "" -#: EncoderConfigWindow.vala:2394 +#: EncoderConfigWindow.vala:2396 msgid "Empty Preset Name" msgstr "" @@ -804,7 +804,7 @@ msgid "Play File (Source)" msgstr "" -#: EncoderConfigWindow.vala:2392 +#: EncoderConfigWindow.vala:2394 msgid "Please enter a name for this preset" msgstr "" @@ -1026,8 +1026,8 @@ msgid "SuperFast" msgstr "" -#: EncoderConfigWindow.vala:2365 EncoderConfigWindow.vala:2368 -#: EncoderConfigWindow.vala:2371 EncoderConfigWindow.vala:2374 +#: EncoderConfigWindow.vala:2367 EncoderConfigWindow.vala:2370 +#: EncoderConfigWindow.vala:2373 EncoderConfigWindow.vala:2376 msgid "Supported Formats:" msgstr "" @@ -1106,15 +1106,15 @@ #: EncoderConfigWindow.vala:1570 EncoderConfigWindow.vala:1595 #: EncoderConfigWindow.vala:1626 EncoderConfigWindow.vala:1643 -#: EncoderConfigWindow.vala:2050 EncoderConfigWindow.vala:2074 +#: EncoderConfigWindow.vala:2052 EncoderConfigWindow.vala:2076 msgid "Variable Bitrate" msgstr "" -#: EncoderConfigWindow.vala:2076 +#: EncoderConfigWindow.vala:2078 msgid "Variable Bitrate (2pass)" msgstr "" -#: EncoderConfigWindow.vala:2004 EncoderConfigWindow.vala:2027 +#: EncoderConfigWindow.vala:2006 EncoderConfigWindow.vala:2029 msgid "Variable Bitrate / CRF" msgstr "" diff -Nru selene-2.5.7~196~ubuntu15.04.1/src/AboutWindow.vala selene-2.5.8~198~ubuntu15.04.1/src/AboutWindow.vala --- selene-2.5.7~196~ubuntu15.04.1/src/AboutWindow.vala 2015-08-14 22:16:18.000000000 +0000 +++ selene-2.5.8~198~ubuntu15.04.1/src/AboutWindow.vala 2015-09-08 00:46:25.000000000 +0000 @@ -1,26 +1,26 @@ /* * AboutWindow.vala - * + * * Copyright 2012 Tony George * * This program 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. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. - * - * + * + * */ - + using Gtk; using TeeJee.Logging; @@ -39,7 +39,7 @@ private Box hbox_action; private Button btn_credits; private Button btn_close; - + private Gtk.Image img_logo; private Label lbl_program_name; private Label lbl_version; @@ -106,7 +106,7 @@ _donations = value; } } - + private string _license = ""; public string license{ get{ @@ -116,7 +116,7 @@ _license = value; } } - + private Gdk.Pixbuf _logo; public Gdk.Pixbuf logo{ get{ @@ -146,7 +146,7 @@ _translators = value; } } - + private string[] _third_party; public string[] third_party{ get{ @@ -156,7 +156,7 @@ _third_party = value; } } - + private string _version = ""; public string version{ get{ @@ -186,21 +186,21 @@ _website_label = value; } } - + public AboutWindow() { window_position = WindowPosition.CENTER_ON_PARENT; set_destroy_with_parent (true); set_modal (true); skip_taskbar_hint = false; - set_default_size (450, 400); + set_default_size (450, 400); vbox_main = get_content_area(); vbox_main.margin = 6; vbox_main.spacing = 6; - + vbox_logo = new Box(Orientation.VERTICAL,0); vbox_main.add(vbox_logo); - + vbox_credits = new Box(Orientation.VERTICAL,0); vbox_credits.no_show_all = true; vbox_main.add(vbox_credits); @@ -213,7 +213,7 @@ img_logo.margin_top = 6; img_logo.margin_bottom = 6; vbox_logo.add(img_logo); - + //program_name lbl_program_name = new Label(""); lbl_program_name.set_use_markup(true); @@ -230,7 +230,7 @@ lbl_comments.set_use_markup(true); lbl_comments.margin_top = 10; vbox_logo.add(lbl_comments); - + //website lbtn_website = new LinkButton(""); lbtn_website.margin_top = 5; @@ -238,13 +238,13 @@ lbtn_website.activate_link.connect(()=>{ try{ - return Gtk.show_uri(null, lbtn_website.uri, Gdk.CURRENT_TIME); + return Gtk.show_uri(null, lbtn_website.uri, Gdk.CURRENT_TIME); } catch(Error e){ return false; } }); - + //copyright lbl_copyright = new Label(""); lbl_copyright.set_use_markup(true); @@ -260,27 +260,27 @@ var sw_credits = new ScrolledWindow(null, null); sw_credits.set_shadow_type(ShadowType.ETCHED_IN); sw_credits.expand = true; - + vbox_credits.add(sw_credits); sw_credits.add(vbox_lines); - + //hbox_commands -------------------------------------------------- - + hbox_action = (Box) get_action_area(); - + //btn_credits btn_credits = new Button.with_label(" " + _("Credits")); btn_credits.set_image (new Image.from_stock ("gtk-about", IconSize.MENU)); - hbox_action.add(btn_credits); - + hbox_action.add(btn_credits); + btn_credits.clicked.connect(()=>{ vbox_logo.visible = !(vbox_logo.visible); vbox_credits.visible = !(vbox_credits.visible); - + if ((vbox_credits.visible)&&(!sw_credits.visible)){ sw_credits.show_all(); } - + if (vbox_credits.visible){ btn_credits.label = " " + _("Back"); btn_credits.set_image (new Image.from_stock ("gtk-go-back", IconSize.MENU)); @@ -295,10 +295,10 @@ btn_close = new Button.with_label(" " + _("Close")); btn_close.set_image (new Image.from_stock ("gtk-close", IconSize.MENU)); hbox_action.add(btn_close); - + btn_close.clicked.connect(()=>{ this.destroy(); }); } - + public void initialize() { title = program_name; img_logo.pixbuf = logo; @@ -309,7 +309,7 @@ lbtn_website.label = website_label; //lbl_copyright.label = "%s".printf(copyright); lbl_copyright.label = "%s".printf(copyright); - + if (authors.length > 0){ add_line("%s\n".printf(_("Authors"))); foreach(string name in authors){ @@ -317,7 +317,7 @@ } add_line("\n"); } - + if (third_party.length > 0){ add_line("%s\n".printf(_("Third Party Tools"))); foreach(string name in third_party){ @@ -325,7 +325,7 @@ } add_line("\n"); } - + if (artists.length > 0){ add_line("%s\n".printf(_("Artists"))); foreach(string name in artists){ @@ -362,12 +362,12 @@ btn_credits.visible = false; } } - + public void add_line(string text){ if (text.split(":").length >= 2){ var link = new LinkButton(text.split(":")[0]); vbox_lines.add(link); - + string val = text[text.index_of(":") + 1:text.length]; if (val.contains("@")){ link.uri = "mailto:" + val; @@ -381,7 +381,7 @@ link.activate_link.connect(()=>{ try{ - return Gtk.show_uri(null, link.uri, Gdk.CURRENT_TIME); + return Gtk.show_uri(null, link.uri, Gdk.CURRENT_TIME); } catch(Error e){ return false; diff -Nru selene-2.5.7~196~ubuntu15.04.1/src/AppConfigWindow.vala selene-2.5.8~198~ubuntu15.04.1/src/AppConfigWindow.vala --- selene-2.5.7~196~ubuntu15.04.1/src/AppConfigWindow.vala 2015-08-14 22:16:18.000000000 +0000 +++ selene-2.5.8~198~ubuntu15.04.1/src/AppConfigWindow.vala 2015-09-08 00:46:25.000000000 +0000 @@ -1,26 +1,26 @@ /* * PrefWindow.vala - * + * * Copyright 2012 Tony George * * This program 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. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. - * - * + * + * */ - + using Gtk; using TeeJee.Logging; @@ -45,18 +45,18 @@ private Button btnSave; private Button btnCancel; private ComboBox cmbFileView; - + public AppConfigWindow() { title = "Settings"; set_default_size (350, 400); - + window_position = WindowPosition.CENTER_ON_PARENT; destroy_with_parent = true; skip_taskbar_hint = true; modal = true; deletable = false; icon = get_app_icon(16); - + // get content area vboxMain = get_content_area(); vboxMain.margin = 6; @@ -68,7 +68,7 @@ lblView.margin_bottom = 12; lblView.margin_top = 12; vboxMain.pack_start (lblView, false, true, 0); - + //hboxFileView Box hboxFileView = new Box(Orientation.HORIZONTAL,6); vboxMain.add(hboxFileView); @@ -76,13 +76,13 @@ Label lblFileView = new Gtk.Label(_("File View")); lblFileView.xalign = (float) 0.0; hboxFileView.pack_start(lblFileView,false,false,0); - + cmbFileView = new ComboBox(); var textCell = new CellRendererText(); cmbFileView.pack_start(textCell, false); cmbFileView.set_attributes(textCell, "text", 0); hboxFileView.pack_start(cmbFileView,false,false,0); - + Gtk.TreeIter iter; var model = new Gtk.ListStore (2, typeof (string), typeof (string)); model.append (out iter); @@ -90,14 +90,14 @@ model.append (out iter); model.set (iter, 0, _("Tiles"), 1, "tiles"); cmbFileView.set_model(model); - + if (App.TileView){ cmbFileView.set_active(1); } else{ cmbFileView.set_active(0); } - + // lblOutput lblOutput = new Label (_("Output Folder")); lblOutput.set_use_markup(true); @@ -105,7 +105,7 @@ lblOutput.margin_bottom = 12; lblOutput.margin_top = 12; vboxMain.pack_start (lblOutput, false, true, 0); - + // fcbOutput fcbOutput = new FileChooserButton (_("Output Location"), FileChooserAction.SELECT_FOLDER); fcbOutput.set_sensitive(App.OutputDirectory.length > 0); @@ -115,14 +115,14 @@ fcbOutput.set_filename (App.OutputDirectory); } vboxMain.add (fcbOutput); - + // chkOutput chkOutput = new CheckButton.with_label (_("Save in input file location")); chkOutput.active = (App.OutputDirectory.length == 0); chkOutput.margin_left = 6; chkOutput.clicked.connect (chkOutput_clicked); vboxMain.pack_start (chkOutput, false, true, 0); - + // lblBackup lblBackup = new Label (_("Backup Folder")); lblBackup.set_use_markup(true); @@ -130,7 +130,7 @@ lblBackup.margin_bottom = 12; lblBackup.margin_top = 12; vboxMain.pack_start (lblBackup, false, true, 0); - + // fcbBackup fcbBackup = new FileChooserButton (_("Backup Location"), FileChooserAction.SELECT_FOLDER); fcbBackup.set_sensitive(App.BackupDirectory.length > 0); @@ -140,31 +140,31 @@ fcbBackup.set_filename (App.BackupDirectory); } vboxMain.add (fcbBackup); - + // chkBackup chkBackup = new CheckButton.with_label (_("Do not move input files")); chkBackup.active = (App.BackupDirectory.length == 0); chkBackup.margin_left = 6; chkBackup.clicked.connect (chkBackup_clicked); vboxMain.pack_start (chkBackup, false, true, 0); - + // btnSave btnSave = (Button) add_button ("gtk-save", Gtk.ResponseType.ACCEPT); btnSave.clicked.connect (btnSave_clicked); - + // btnCancel btnCancel = (Button) add_button ("gtk-cancel", Gtk.ResponseType.CANCEL); btnCancel.clicked.connect (btnCancel_clicked); } - + private void chkOutput_clicked(){ fcbOutput.set_sensitive(!chkOutput.active); } - + private void chkBackup_clicked(){ fcbBackup.set_sensitive(!chkBackup.active); } - + private void btnSave_clicked(){ if (chkOutput.active){ App.OutputDirectory = ""; @@ -174,7 +174,7 @@ App.OutputDirectory = fcbOutput.get_filename(); } } - + if (chkBackup.active){ App.BackupDirectory = ""; } @@ -183,15 +183,15 @@ App.BackupDirectory = fcbBackup.get_filename(); } } - + App.TileView = (cmbFileView.active == 1); - + // Save settings App.save_config(); - + destroy(); } - + private void btnCancel_clicked(){ destroy(); } diff -Nru selene-2.5.7~196~ubuntu15.04.1/src/DonationWindow.vala selene-2.5.8~198~ubuntu15.04.1/src/DonationWindow.vala --- selene-2.5.7~196~ubuntu15.04.1/src/DonationWindow.vala 2015-08-14 22:16:18.000000000 +0000 +++ selene-2.5.8~198~ubuntu15.04.1/src/DonationWindow.vala 2015-09-08 00:46:25.000000000 +0000 @@ -1,26 +1,26 @@ /* * DonationWindow.vala - * + * * Copyright 2012 Tony George * * This program 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. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. - * - * + * + * */ - + using Gtk; using TeeJee.Logging; @@ -38,23 +38,23 @@ set_destroy_with_parent (true); set_modal (true); skip_taskbar_hint = false; - set_default_size (400, 20); + set_default_size (400, 20); icon = get_app_icon(16); - + //vbox_main Box vbox_main = get_content_area(); vbox_main.margin = 6; vbox_main.homogeneous = false; - + get_action_area().visible = false; - + //lbl_message Label lbl_message = new Gtk.Label(""); string msg = _("Did you find this software useful?\n\nYou can buy me a coffee or make a donation via PayPal to show your support. Or just drop me an email and say Hi.\n\nThis application is completely free and will continue to remain that way. Your contributions will help in keeping this project alive and to develop it further.\n\nFeel free to drop me an email if you find any issues or if you have suggestions for improvement.\n\nRegards,\nTony George\nteejeetech@gmail.com"); lbl_message.label = msg; lbl_message.wrap = true; vbox_main.pack_start(lbl_message,true,true,0); - + //vbox_actions Box vbox_actions = new Box (Orientation.VERTICAL, 6); vbox_actions.margin_left = 50; @@ -75,7 +75,7 @@ btn_send_email.clicked.connect(()=>{ xdg_open("mailto:teejeetech@gmail.com"); }); - + //btn_visit Button btn_visit = new Button.with_label(" " + _("Visit Website") + " "); vbox_actions.add(btn_visit); diff -Nru selene-2.5.7~196~ubuntu15.04.1/src/EncoderConfigWindow.vala selene-2.5.8~198~ubuntu15.04.1/src/EncoderConfigWindow.vala --- selene-2.5.7~196~ubuntu15.04.1/src/EncoderConfigWindow.vala 2015-08-14 22:16:18.000000000 +0000 +++ selene-2.5.8~198~ubuntu15.04.1/src/EncoderConfigWindow.vala 2015-09-08 00:46:25.000000000 +0000 @@ -1,26 +1,26 @@ /* * ConfigWindow.vala - * + * * Copyright 2012 Tony George * * This program 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. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. - * - * + * + * */ - + using Gtk; using Json; @@ -34,50 +34,50 @@ using TeeJee.Misc; public class EncoderConfigWindow : Dialog { - + public string Folder; public string Name; public bool CreateNew = false; - + private Notebook tabMain; private Box vboxMain; private Label lblGeneral; private Grid gridGeneral; - + private Label lblVideo; private Grid gridVideo; - + private Label lblAudio; private Grid gridAudio; - + private Label lblSubtitle; private Grid gridSubtitle; - + private Label lblVideoFilters; private Grid gridVideoFilters; - + private Label lblAudioFilters; private Grid gridAudioFilters; - + private Label lblPresetName; private Entry txtPresetName; private Label lblFileFormat; private ComboBox cmbFileFormat; - + private Label lblFileExtension; private ComboBox cmbFileExtension; - + private Label lblVCodec; private ComboBox cmbVCodec; - + private Label lblVideoMode; private ComboBox cmbVideoMode; - + private Label lblVideoBitrate; private SpinButton spinVideoBitrate; - + private ComboBox cmbX264Preset; private Label lblX264Preset; @@ -86,11 +86,11 @@ private Label lblVideoQuality; private SpinButton spinVideoQuality; - + private ComboBox cmbVpxSpeed; private Label lblVpxSpeed; private Scale scaleVpxSpeed; - + private Label lblHeaderFileFormat; private Label lblHeaderPreset; private Label lblHeaderFrameSize; @@ -99,7 +99,7 @@ private Gtk.Image imgAudioCodec; private Gtk.Image imgVideoCodec; private Gtk.Image imgFileFormat; - + private Label lblFrameSize; private ComboBox cmbFrameSize; private Label lblFrameSizeCustom; @@ -108,7 +108,7 @@ private Box hboxFrameSize; private CheckButton chkNoUpScale; private CheckButton chkFitToBox; - + private Label lblFPS; private ComboBox cmbFPS; private Label lblFPSCustom; @@ -117,37 +117,37 @@ private Box hboxFPS; private Label lblResizingMethod; private ComboBox cmbResizingMethod; - + private Label lblVCodecOptions; private Gtk.TextView txtVCodecOptions; - + private Label lblACodec; private ComboBox cmbACodec; - + private Label lblAudioMode; private ComboBox cmbAudioMode; - + private Label lblAudioBitrate; private SpinButton spinAudioBitrate; - + private Label lblAudioQuality; private SpinButton spinAudioQuality; - + private Label lblOpusOptimize; private ComboBox cmbOpusOptimize; - + private Label lblAuthorName; private Entry txtAuthorName; - + private Label lblAuthorEmail; private Entry txtAuthorEmail; - + private Label lblPresetVersion; private Entry txtPresetVersion; - + private Label lblAudioSampleRate; private ComboBox cmbAudioSampleRate; - + private Label lblAudioChannels; private ComboBox cmbAudioChannels; @@ -173,48 +173,48 @@ private Label lblSubtitleMode; private ComboBox cmbSubtitleMode; - + private Label lblSubFormatMessage; - + private Button btnSave; private Button btnCancel; - + public EncoderConfigWindow() { title = "Preset"; - set_default_size (450, 550); - - window_position = WindowPosition.CENTER_ON_PARENT; - destroy_with_parent = true; - skip_taskbar_hint = true; + set_default_size (450, 550); + + window_position = WindowPosition.CENTER_ON_PARENT; + destroy_with_parent = true; + skip_taskbar_hint = true; modal = true; icon = get_app_icon(16); - + this.delete_event.connect(on_delete_event); - + int row = 0; Gtk.ListStore model; Gtk.CellRendererText textCell; Gtk.TreeIter iter; string tt; - + //get content area vboxMain = get_content_area(); //tabMain tabMain = new Notebook(); - //tabMain.tab_pos = PositionType.LEFT; + tabMain.tab_pos = PositionType.LEFT; tabMain.set_show_border(false); tabMain.margin = 6; vboxMain.pack_start (tabMain, true, true, 0); - + //styles --------------------------------------------------- - + /*string css_style = """ GtkNotebook tab { padding: 1px; } """;//color: #703910; - + CssProvider css_provider = new CssProvider(); try { css_provider.load_from_data(css_style,-1); @@ -222,13 +222,13 @@ } catch (GLib.Error e) { warning(e.message); }*/ - + /* Note: Setting tab button padding to 0 causes problems with some GTK themes like Mint-X */ //General tab --------------------------------------------- - + //lblGeneral - lblGeneral = new Label (" " + _("General") + " "); + lblGeneral = new Label ("" + _("General") + ""); //gridGeneral gridGeneral = new Grid(); @@ -237,9 +237,9 @@ gridGeneral.margin = 12; gridGeneral.visible = false; tabMain.append_page (gridGeneral, lblGeneral); - + row = -1; - + //lblHeaderFileFormat lblHeaderFileFormat = new Gtk.Label(_("File Format:")); lblHeaderFileFormat.set_use_markup(true); @@ -247,15 +247,15 @@ //lblHeaderFileFormat.margin_top = 6; lblHeaderFileFormat.margin_bottom = 6; gridGeneral.attach(lblHeaderFileFormat,0,++row,2,1); - + //lblFileFormat lblFileFormat = new Gtk.Label(_("Format")); lblFileFormat.xalign = (float) 0.0; gridGeneral.attach(lblFileFormat,0,++row,1,1); - + //cmbFileFormat model = new Gtk.ListStore (2, typeof (string), typeof (string)); - + model.append (out iter); model.set (iter,0,_("Matroska Video (*.mkv)"),1,"mkv"); model.append (out iter); @@ -278,7 +278,7 @@ model.set (iter,0,_("Opus Audio (*.opus)"),1,"opus"); model.append (out iter); model.set (iter,0,_("WAV Audio (*.wav)"),1,"wav"); - + cmbFileFormat = new ComboBox.with_model(model); textCell = new CellRendererText(); cmbFileFormat.pack_start( textCell, false ); @@ -296,7 +296,7 @@ cmbFileExtension.pack_start( textCell, false ); cmbFileExtension.set_attributes( textCell, "text", 0 ); gridGeneral.attach(cmbFileExtension,1,row,1,1); - + //lblHeaderPreset lblHeaderPreset = new Gtk.Label(_("Preset:")); lblHeaderPreset.set_use_markup(true); @@ -304,63 +304,63 @@ lblHeaderPreset.margin_top = 6; lblHeaderPreset.margin_bottom = 6; gridGeneral.attach(lblHeaderPreset,0,++row,2,1); - + //lblPresetName lblPresetName = new Gtk.Label(_("Name")); lblPresetName.xalign = (float) 0.0; gridGeneral.attach(lblPresetName,0,++row,1,1); - + //txtPresetName txtPresetName = new Gtk.Entry(); txtPresetName.xalign = (float) 0.0; txtPresetName.text = _("New Preset"); txtPresetName.hexpand = true; gridGeneral.attach(txtPresetName,1,row,1,1); - + //lblPresetVersion lblPresetVersion = new Gtk.Label(_("Version")); lblPresetVersion.xalign = (float) 0.0; gridGeneral.attach(lblPresetVersion,0,++row,1,1); - + //txtPresetVersion txtPresetVersion = new Gtk.Entry(); txtPresetVersion.xalign = (float) 0.0; txtPresetVersion.text = "1.0"; gridGeneral.attach(txtPresetVersion,1,row,1,1); - + //lblAuthorName lblAuthorName = new Gtk.Label(_("Author")); lblAuthorName.xalign = (float) 0.0; gridGeneral.attach(lblAuthorName,0,++row,1,1); - + //txtAuthorName txtAuthorName = new Gtk.Entry(); txtAuthorName.xalign = (float) 0.0; txtAuthorName.text = ""; gridGeneral.attach(txtAuthorName,1,row,1,1); - + //lblAuthorEmail lblAuthorEmail = new Gtk.Label(_("Email")); lblAuthorEmail.xalign = (float) 0.0; gridGeneral.attach(lblAuthorEmail,0,++row,1,1); - + //txtAuthorEmail txtAuthorEmail = new Gtk.Entry(); txtAuthorEmail.xalign = (float) 0.0; txtAuthorEmail.text = ""; gridGeneral.attach(txtAuthorEmail,1,row,1,1); - + //imgFileFormat imgFileFormat = new Gtk.Image(); imgFileFormat.margin_top = 6; imgFileFormat.margin_bottom = 6; imgFileFormat.expand = true; gridGeneral.attach(imgFileFormat,0,++row,2,1); - + //Video tab --------------------------------------------- - + //lblVideo - lblVideo = new Label(" " + _("Video") + " "); + lblVideo = new Label("" + _("Video") + ""); //gridVideo gridVideo = new Grid(); @@ -369,14 +369,14 @@ gridVideo.visible = false; gridVideo.margin = 12; tabMain.append_page (gridVideo, lblVideo); - + row = -1; - + //lblVCodec lblVCodec = new Gtk.Label(_("Format / Codec")); lblVCodec.xalign = (float) 0.0; gridVideo.attach(lblVCodec,0,++row,1,1); - + //cmbVCodec cmbVCodec = new ComboBox(); textCell = new CellRendererText(); @@ -385,12 +385,12 @@ cmbVCodec.changed.connect(cmbVCodec_changed); cmbVCodec.hexpand = true; gridVideo.attach(cmbVCodec,1,row,1,1); - + //lblVideoMode lblVideoMode = new Gtk.Label(_("Encoding Mode")); lblVideoMode.xalign = (float) 0.0; gridVideo.attach(lblVideoMode,0,++row,1,1); - + //cmbVideoMode cmbVideoMode = new ComboBox(); textCell = new CellRendererText(); @@ -410,9 +410,9 @@ spinVideoBitrate = new Gtk.SpinButton (adjVideoBitrate, 0.1, 2); spinVideoBitrate.xalign = (float) 0.5; gridVideo.attach(spinVideoBitrate,1,row,1,1); - + tt = _("Compression Vs Quality\nSmaller values give better quality video and larger files"); - + //lblVideoQuality lblVideoQuality = new Gtk.Label(_("Quality")); lblVideoQuality.xalign = (float) 0.0; @@ -425,15 +425,15 @@ spinVideoQuality.set_tooltip_markup(tt); spinVideoQuality.xalign = (float) 0.5; gridVideo.attach(spinVideoQuality,1,row,1,1); - + tt = _("Compression Vs Encoding Speed\nSlower presets give better compression and smaller files\nbut take more time to encode."); - + //lblPreset lblX264Preset = new Gtk.Label(_("Preset")); lblX264Preset.xalign = (float) 0.0; lblX264Preset.set_tooltip_markup(tt); gridVideo.attach(lblX264Preset,0,++row,1,1); - + //cmbx264Preset model = new Gtk.ListStore (2, typeof (string), typeof (string)); model.append (out iter); @@ -450,7 +450,7 @@ model.set (iter, 0, _("Slower"), 1, "slower"); model.append (out iter); model.set (iter, 0, _("VerySlow"), 1, "veryslow"); - + cmbX264Preset = new ComboBox.with_model(model); textCell = new CellRendererText(); cmbX264Preset.pack_start( textCell, false ); @@ -459,13 +459,13 @@ gridVideo.attach(cmbX264Preset,1,row,1,1); tt = _("Compression Vs Device Compatibility\n'High' profile gives the best compression.\nChange this to 'Baseline' or 'Main' only if you are encoding\nfor a particular device (mobiles,PMPs,etc) which does not\nsupport the 'High' profile"); - + //lblProfile lblX264Profile = new Gtk.Label(_("Profile")); lblX264Profile.xalign = (float) 0.0; lblX264Profile.set_tooltip_markup(tt); gridVideo.attach(lblX264Profile,0,++row,1,1); - + //cmbX264Profile cmbX264Profile = new ComboBox(); textCell = new CellRendererText(); @@ -479,7 +479,7 @@ lblVpxSpeed.xalign = (float) 0.0; lblVpxSpeed.no_show_all = true; gridVideo.attach(lblVpxSpeed,0,++row,1,1); - + Box hboxVpxSpeed = new Box (Orientation.HORIZONTAL, 0); hboxVpxSpeed.homogeneous = false; gridVideo.attach(hboxVpxSpeed,1,row,1,1); @@ -497,12 +497,12 @@ cmbVpxSpeed.pack_start( textCell, false ); cmbVpxSpeed.set_attributes( textCell, "text", 0 ); hboxVpxSpeed.add(cmbVpxSpeed); - + cmbVpxSpeed.changed.connect(cmbVpxSpeed_changed); - + Label lblSpacer = new Gtk.Label(" "); hboxVpxSpeed.add(lblSpacer); - + //scaleVpxSpeed scaleVpxSpeed = new Gtk.Scale.with_range (Gtk.Orientation.HORIZONTAL, 0, 5, 1); scaleVpxSpeed.adjustment.value = 1; @@ -512,14 +512,14 @@ hboxVpxSpeed.add(scaleVpxSpeed); tt = _("Additional Options\nThese options will be passed to the encoder\non the command line. Please do not specify\nany options that are already provided by the GUI."); - + //lblVCodecOptions lblVCodecOptions = new Gtk.Label(_("Extra Options")); lblVCodecOptions.xalign = (float) 0.0; lblVCodecOptions.margin_top = 6; lblVCodecOptions.set_tooltip_markup(tt); gridVideo.attach(lblVCodecOptions,0,++row,1,1); - + //txtVCodecOptions txtVCodecOptions = new Gtk.TextView(); TextBuffer buff = new TextBuffer(null); @@ -530,23 +530,23 @@ //txtVCodecOptions.set_size_request(-1,100); txtVCodecOptions.set_tooltip_markup(tt); txtVCodecOptions.set_wrap_mode (Gtk.WrapMode.WORD); - + Gtk.ScrolledWindow scrollWin = new Gtk.ScrolledWindow (null, null); scrollWin.set_shadow_type (ShadowType.ETCHED_IN); scrollWin.add (txtVCodecOptions); //scrollWin.set_size_request(-1,100); gridVideo.attach(scrollWin,0,++row,2,1); - + //imgVideoCodec imgVideoCodec = new Gtk.Image(); imgVideoCodec.margin_top = 6; imgVideoCodec.margin_bottom = 6; gridVideo.attach(imgVideoCodec,0,++row,2,1); - + //Video Filters tab --------------------------------------------- - + //lblVideoFilters - lblVideoFilters = new Label (" " + _("Filters") + " "); + lblVideoFilters = new Label ("" + _("Filters") + ""); //gridVideoFilters gridVideoFilters = new Grid(); @@ -555,21 +555,21 @@ gridVideoFilters.margin = 12; gridVideoFilters.visible = false; tabMain.append_page (gridVideoFilters, lblVideoFilters); - + row = -1; - + //lblHeaderFrameSize lblHeaderFrameSize = new Gtk.Label(_("Resize:")); lblHeaderFrameSize.set_use_markup(true); lblHeaderFrameSize.xalign = (float) 0.0; lblHeaderFrameSize.margin_bottom = 6; gridVideoFilters.attach(lblHeaderFrameSize,0,++row,1,1); - + //lblFrameSize lblFrameSize = new Gtk.Label(_("Resolution")); lblFrameSize.xalign = (float) 0.0; gridVideoFilters.attach(lblFrameSize,0,++row,1,1); - + //cmbFrameSize model = new Gtk.ListStore (2, typeof (string), typeof (string)); model.append (out iter); @@ -584,7 +584,7 @@ model.set (iter,0,"720p",1,"720p"); model.append (out iter); model.set (iter,0,"1080p",1,"1080p"); - + cmbFrameSize = new ComboBox.with_model(model); textCell = new CellRendererText(); cmbFrameSize.pack_start( textCell, false ); @@ -592,7 +592,7 @@ cmbFrameSize.changed.connect(cmbFrameSize_changed); cmbFrameSize.hexpand = true; gridVideoFilters.attach(cmbFrameSize,1,row,1,1); - + tt = _("Set either Width or Height and leave the other as 0.\nIt will be calculated automatically.\n\nSetting both width and height is not recommended\nsince the video may get stretched or squeezed.\n\nEnable the 'Fit-To-Box' option to avoid changes to aspect ratio."); //lblFrameSizeCustom @@ -624,9 +624,9 @@ spinFrameHeight.width_chars = 5; spinFrameHeight.set_tooltip_text (_("Height")); hboxFrameSize.pack_start (spinFrameHeight, false, false, 5); - + tt = _("The resizing filter affects the sharpness and compressibility of the video.\nFor example, the 'Lanzos' filter gives sharper video but the extra detail\nmakes the video more difficult to compress resulting in slightly bigger files.\nThe 'Bilinear' filter gives smoother video (less detail) and smaller files."); - + //lblResizingMethod lblResizingMethod = new Gtk.Label(_("Resizing Method")); lblResizingMethod.xalign = (float) 0.0; @@ -644,15 +644,15 @@ gridVideoFilters.attach(cmbResizingMethod,1,row,1,1); tt = _("Fits the video in a box of given width and height."); - + //chkFitToBox chkFitToBox = new CheckButton.with_label(_("Do not stretch or squeeze the video (Fit-To-Box)")); chkFitToBox.active = true; chkFitToBox.set_tooltip_markup(tt); gridVideoFilters.attach(chkFitToBox,0,++row,2,1); - + tt = _("Video will not be resized if it's smaller than the given width and height"); - + //chkNoUpScale chkNoUpScale = new CheckButton.with_label(_("No Up-Scaling")); chkNoUpScale.active = true; @@ -666,13 +666,13 @@ lblHeaderFrameRate.margin_top = 6; lblHeaderFrameRate.margin_bottom = 6; gridVideoFilters.attach(lblHeaderFrameRate,0,++row,1,1); - + //lblFPS lblFPS = new Gtk.Label(_("Frame Rate")); lblFPS.xalign = (float) 0.0; lblFPS.set_tooltip_text (_("Frames/sec")); gridVideoFilters.attach(lblFPS,0,++row,1,1); - + //cmbFPS model = new Gtk.ListStore (2, typeof (string), typeof (string)); model.append (out iter); @@ -687,14 +687,14 @@ model.set (iter,0,"30",1,"30"); model.append (out iter); model.set (iter,0,"60",1,"60"); - + cmbFPS = new ComboBox.with_model(model); textCell = new CellRendererText(); cmbFPS.pack_start( textCell, false ); cmbFPS.set_attributes( textCell, "text", 0 ); cmbFPS.changed.connect(cmbFPS_changed); gridVideoFilters.attach(cmbFPS,1,row,1,1); - + //lblFPSCustom lblFPSCustom = new Gtk.Label(_("FPS Ratio")); lblFPSCustom.xalign = (float) 0.0; @@ -707,7 +707,7 @@ hboxFPS = new Box (Orientation.HORIZONTAL, 0); hboxFPS.homogeneous = false; gridVideoFilters.attach(hboxFPS,1,row,1,1); - + //spinFPSNum Gtk.Adjustment adjFPSNum = new Gtk.Adjustment(0, 0, 999999, 1, 1, 0); spinFPSNum = new Gtk.SpinButton (adjFPSNum, 1, 0); @@ -716,7 +716,7 @@ spinFPSNum.width_chars = 5; spinFPSNum.set_tooltip_text (_("Numerator")); hboxFPS.pack_start(spinFPSNum, false, false, 0); - + //spinFPSDenom Gtk.Adjustment adjFPSDenom = new Gtk.Adjustment(0, 0, 999999, 1, 1, 0); spinFPSDenom = new Gtk.SpinButton (adjFPSDenom, 1, 0); @@ -725,11 +725,11 @@ spinFPSDenom.width_chars = 5; spinFPSDenom.set_tooltip_text (_("Denominator")); hboxFPS.pack_start(spinFPSDenom, false, false, 5); - + // Audio tab -------------------------------------------------- - + //lblAudio - lblAudio = new Label (" " + _("Audio") + " "); + lblAudio = new Label ("" + _("Audio") + ""); //gridAudio gridAudio = new Grid(); @@ -738,14 +738,14 @@ gridAudio.margin = 12; gridAudio.visible = false; tabMain.append_page (gridAudio, lblAudio); - + row = -1; //lblACodec lblACodec = new Gtk.Label(_("Format / Codec")); lblACodec.xalign = (float) 0.0; gridAudio.attach(lblACodec,0,++row,1,1); - + //cmbACodec cmbACodec = new ComboBox(); textCell = new CellRendererText(); @@ -754,7 +754,7 @@ cmbACodec.changed.connect(cmbACodec_changed); cmbACodec.hexpand = true; gridAudio.attach(cmbACodec,1,row,1,1); - + //lblAudioMode lblAudioMode = new Gtk.Label(_("Encoding Mode")); lblAudioMode.xalign = (float) 0.0; @@ -767,29 +767,29 @@ cmbAudioMode.set_attributes(textCell, "text", 0); cmbAudioMode.changed.connect(cmbAudioMode_changed); gridAudio.attach(cmbAudioMode,1,row,1,1); - + //lblAudioBitrate lblAudioBitrate = new Gtk.Label(_("Bitrate (kbps)")); lblAudioBitrate.xalign = (float) 0.0; gridAudio.attach(lblAudioBitrate,0,++row,1,1); - + //spinAudioBitrate Gtk.Adjustment adjAudioBitrate = new Gtk.Adjustment(128, 32, 320, 1, 1, 0); spinAudioBitrate = new Gtk.SpinButton (adjAudioBitrate, 1, 0); spinAudioBitrate.xalign = (float) 0.5; gridAudio.attach(spinAudioBitrate,1,row,1,1); - + //lblAudioQuality lblAudioQuality = new Gtk.Label(_("Quality")); lblAudioQuality.xalign = (float) 0.0; gridAudio.attach(lblAudioQuality,0,++row,1,1); - + //spinAudioQuality Gtk.Adjustment adjAudioQuality = new Gtk.Adjustment(4, 0, 9, 1, 1, 0); spinAudioQuality = new Gtk.SpinButton (adjAudioQuality, 1, 0); spinAudioQuality.xalign = (float) 0.5; gridAudio.attach(spinAudioQuality,1,row,1,1); - + //lblOpusOptimize lblOpusOptimize = new Gtk.Label(_("Optimization")); lblOpusOptimize.xalign = (float) 0.0; @@ -804,7 +804,7 @@ cmbOpusOptimize.no_show_all = true; cmbOpusOptimize.set_size_request(150,-1); gridAudio.attach(cmbOpusOptimize,1,row,1,1); - + //populate model = new Gtk.ListStore (2, typeof (string), typeof (string)); model.append (out iter); @@ -814,18 +814,18 @@ model.append (out iter); model.set (iter,0,_("Music"),1,"music"); cmbOpusOptimize.set_model(model); - + //imgAudioCodec imgAudioCodec = new Gtk.Image(); imgAudioCodec.margin_top = 6; imgAudioCodec.margin_bottom = 6; imgAudioCodec.expand = true; gridAudio.attach(imgAudioCodec,0,++row,3,1); - + //Audio Filters tab --------------------------------------------- - + //lblAudioFilters - lblAudioFilters = new Label (" " + _("Filters") + " "); + lblAudioFilters = new Label ("" + _("Filters") + ""); //gridAudioFilters gridAudioFilters = new Grid(); @@ -834,7 +834,7 @@ gridAudioFilters.margin = 12; gridAudioFilters.visible = false; tabMain.append_page (gridAudioFilters, lblAudioFilters); - + row = -1; int col; @@ -843,20 +843,20 @@ lblHeaderSampling.set_use_markup(true); lblHeaderSampling.xalign = (float) 0.0; gridAudioFilters.attach(lblHeaderSampling,col=0,++row,2,1); - + //lblAudioSampleRate lblAudioSampleRate = new Gtk.Label(_("Sampling Rate (Hz)")); lblAudioSampleRate.xalign = (float) 0.0; gridAudioFilters.attach(lblAudioSampleRate,col=0,++row,1,1); - + //cmbAudioSampleRate cmbAudioSampleRate = new ComboBox(); textCell = new CellRendererText(); - cmbAudioSampleRate.pack_start(textCell, false); + cmbAudioSampleRate.pack_start(textCell, false); cmbAudioSampleRate.set_attributes(textCell, "text", 0); cmbAudioSampleRate.hexpand = true; gridAudioFilters.attach(cmbAudioSampleRate,col+1,row,1,1); - + //lblAudioChannels lblAudioChannels = new Gtk.Label(_("Channels")); lblAudioChannels.xalign = (float) 0.0; @@ -874,20 +874,20 @@ int scaleWidth = 200; int sliderMarginBottom = 0; int spacing = 5; - + //lblAudioFilters - Label lblAudioSox = new Label (" " + _("SOX") + " "); + Label lblAudioSox = new Label ("" + _("SOX") + ""); //vboxSox Box vboxSoxOuter = new Box(Orientation.VERTICAL,spacing); vboxSoxOuter.margin = 12; tabMain.append_page (vboxSoxOuter, lblAudioSox); - + //hboxSoxSwitch Box hboxSoxSwitch = new Box(Orientation.HORIZONTAL,0); hboxSoxSwitch.margin_bottom = 6; vboxSoxOuter.add(hboxSoxSwitch); - + //lblHeaderSox lblHeaderSox = new Gtk.Label(_("SOX Audio Processing:")); lblHeaderSox.set_use_markup(true); @@ -903,10 +903,10 @@ //vboxSox Box vboxSox = new Box(Orientation.VERTICAL,spacing); vboxSoxOuter.add(vboxSox); - + switchSox.notify["active"].connect(()=>{ vboxSox.sensitive = switchSox.active; - + App.Encoders["sox"].CheckAvailability(); if (!App.Encoders["sox"].IsAvailable){ if (switchSox.active){ @@ -915,7 +915,7 @@ } } }); - + switchSox.active = false; vboxSox.sensitive = switchSox.active; @@ -927,7 +927,7 @@ //lblHeaderAdjustments.margin_top = 5; lblHeaderAdjustments.margin_bottom = 5; vboxSox.add(lblHeaderAdjustments); - + //hboxBass Box hboxBass = new Box(Orientation.HORIZONTAL,spacing); vboxSox.add(hboxBass); @@ -938,7 +938,7 @@ lblAudioBass.xalign = (float) 0.0; lblAudioBass.set_tooltip_text(tt); hboxBass.pack_start(lblAudioBass,false,false,0); - + scaleBass = new Gtk.Scale.with_range (Gtk.Orientation.HORIZONTAL, -20, 20, 1); scaleBass.adjustment.value = 0; scaleBass.has_origin = false; @@ -946,25 +946,25 @@ scaleBass.set_size_request(scaleWidth,-1); scaleBass.margin_bottom = sliderMarginBottom; hboxBass.pack_start(scaleBass,true,true,0); - + scaleBass.format_value.connect((val)=>{ return "%.0f ".printf(val); }); Button btnReset = new Button.with_label("X"); btnReset.clicked.connect(()=>{ scaleBass.adjustment.value = 0; }); btnReset.set_tooltip_text(_("Reset")); hboxBass.pack_start(btnReset,false,true,0); - + //hboxTreble Box hboxTreble = new Box(Orientation.HORIZONTAL,spacing); vboxSox.add(hboxTreble); tt = _("Boost or cut the treble (upper) frequencies of the audio."); - + lblAudioTreble = new Gtk.Label(_("Treble (upper freq)") + ": "); lblAudioTreble.xalign = (float) 0.0; lblAudioTreble.set_tooltip_text(tt); hboxTreble.pack_start(lblAudioTreble,false,false,0); - + scaleTreble = new Gtk.Scale.with_range (Gtk.Orientation.HORIZONTAL, -20, 20, 1); scaleTreble.adjustment.value = 0; scaleTreble.has_origin = false; @@ -972,14 +972,14 @@ scaleTreble.set_size_request(scaleWidth,-1); scaleTreble.margin_bottom = sliderMarginBottom; hboxTreble.pack_start(scaleTreble,true,true,0); - + scaleTreble.format_value.connect((val)=>{ return "%.0f ".printf(val); }); btnReset = new Button.with_label("X"); btnReset.clicked.connect(()=>{ scaleTreble.adjustment.value = 0; }); btnReset.set_tooltip_text(_("Reset")); hboxTreble.pack_start(btnReset,false,true,0); - + //hboxPitch Box hboxPitch = new Box(Orientation.HORIZONTAL,spacing); vboxSox.add(hboxPitch); @@ -990,7 +990,7 @@ lblAudioPitch.xalign = (float) 0.0; lblAudioPitch.set_tooltip_text(tt); hboxPitch.pack_start(lblAudioPitch,false,false,0); - + scalePitch = new Gtk.Scale.with_range (Gtk.Orientation.HORIZONTAL, 0, 500, 1); scalePitch.adjustment.value = 100; //scalePitch.has_origin = false; @@ -998,25 +998,25 @@ scalePitch.set_size_request(scaleWidth,-1); scalePitch.margin_bottom = sliderMarginBottom; hboxPitch.pack_start(scalePitch,true,true,0); - + scalePitch.format_value.connect((val)=>{ return "%.0f%% ".printf(val); }); btnReset = new Button.with_label("X"); btnReset.clicked.connect(()=>{ scalePitch.adjustment.value = 100; }); btnReset.set_tooltip_text(_("Reset")); hboxPitch.pack_start(btnReset,false,true,0); - + //hboxTempo Box hboxTempo = new Box(Orientation.HORIZONTAL,spacing); vboxSox.add(hboxTempo); - + tt = _("Change audio tempo (speed) without changing audio pitch (shrillness).\n\nWARNING: This will change the duration of the audio track"); lblAudioTempo = new Gtk.Label(_("Tempo (speed)") + ": "); lblAudioTempo.xalign = (float) 0.0; lblAudioTempo.set_tooltip_text(tt); hboxTempo.pack_start(lblAudioTempo,false,false,0); - + scaleTempo = new Gtk.Scale.with_range (Gtk.Orientation.HORIZONTAL, 30, 200, 1); scaleTempo.adjustment.value = 100; //scaleTempo.has_origin = false; @@ -1031,7 +1031,7 @@ btnReset.clicked.connect(()=>{ scaleTempo.adjustment.value = 100; }); btnReset.set_tooltip_text(_("Reset")); hboxTempo.pack_start(btnReset,false,true,0); - + //lblHeaderFade Label lblHeaderFade = new Gtk.Label(_("Fade:")); lblHeaderFade.set_use_markup(true); @@ -1040,11 +1040,11 @@ lblHeaderFade.margin_top = 5; lblHeaderFade.margin_bottom = 5; vboxSox.add(lblHeaderFade); - + //hboxFadeIn Box hboxFadeIn = new Box(Orientation.HORIZONTAL,spacing); vboxSox.add(hboxFadeIn); - + lblFadeIn = new Gtk.Label(_("Fade In (seconds)")); lblFadeIn.xalign = (float) 0.0; lblFadeIn.set_size_request(150,-1); @@ -1054,11 +1054,11 @@ spinFadeIn = new Gtk.SpinButton (adjFadeIn, 1, 0); spinFadeIn.xalign = (float) 0.5; hboxFadeIn.pack_start(spinFadeIn,false,false,0); - + //hboxFadeOut Box hboxFadeOut = new Box(Orientation.HORIZONTAL,spacing); vboxSox.add(hboxFadeOut); - + lblFadeOut = new Gtk.Label(_("Fade Out (seconds)")); lblFadeOut.xalign = (float) 0.0; lblFadeOut.set_size_request(150,-1); @@ -1068,7 +1068,7 @@ spinFadeOut = new Gtk.SpinButton (adjFadeOut, 1, 0); spinFadeOut.xalign = (float) 0.5; hboxFadeOut.pack_start(spinFadeOut,false,false,0); - + //hboxFadeType Box hboxFadeType = new Box(Orientation.HORIZONTAL,spacing); vboxSox.add(hboxFadeType); @@ -1077,13 +1077,13 @@ lblFadeType.xalign = (float) 0.0; lblFadeType.set_size_request(150,-1); hboxFadeType.pack_start(lblFadeType,false,false,0); - + cmbFadeType = new ComboBox(); textCell = new CellRendererText(); cmbFadeType.pack_start(textCell, false); cmbFadeType.set_attributes(textCell, "text", 0); hboxFadeType.pack_start(cmbFadeType,false,false,0); - + model = new Gtk.ListStore (2, typeof (string), typeof (string)); model.append (out iter); model.set (iter,0,_("Quarter Sine"),1,"q"); @@ -1105,19 +1105,19 @@ lblHeaderOther.margin_top = 5; lblHeaderOther.margin_bottom = 5; vboxSox.add(lblHeaderOther); - + //hboxNormalize Box hboxNormalize = new Box(Orientation.HORIZONTAL,0); vboxSox.add(hboxNormalize); tt = _("Maximize the volume level (loudness)"); - + lblNormalize = new Gtk.Label(_("Maximize Volume Level (Normalize)")); lblNormalize.xalign = (float) 0.0; lblNormalize.hexpand = true; lblNormalize.set_tooltip_text(tt); hboxNormalize.pack_start(lblNormalize,true,true,0); - + switchNormalize = new Gtk.Switch(); switchNormalize.set_size_request(100,-1); switchNormalize.active = false; @@ -1128,7 +1128,7 @@ vboxSox.add(hboxEarWax); tt = _("Makes audio easier to listen to on headphones. Adds 'cues' to the audio so that when listened to on headphones the stereo image is moved from inside your head (standard for headphones) to outside and in front of the listener (standard for speakers)."); - + lblEarWax = new Gtk.Label(_("Adjust Stereo for Headphones")); lblEarWax.xalign = (float) 0.0; lblEarWax.hexpand = true; @@ -1146,11 +1146,11 @@ lnkSoxHome.valign = Align.END; lnkSoxHome.activate_link.connect(()=>{ return exo_open_url(lnkSoxHome.uri); }); vboxSoxOuter.pack_end(lnkSoxHome,true,true,0); - + //Subtitles tab --------------------------------------------- - + //lblSubtitle - lblSubtitle = new Label (" " + _("Subs") + " "); + lblSubtitle = new Label ("" + _("Subs") + ""); //gridSubtitle gridSubtitle = new Grid(); @@ -1159,19 +1159,19 @@ gridSubtitle.margin = 12; gridSubtitle.visible = false; tabMain.append_page (gridSubtitle, lblSubtitle); - + row = -1; - + tt = _("Embed - Subtitle files will be combined with the output file.\nThese subtitles can be switched off since they are added as a separate track"); tt += "\n\n"; tt += _("Render - Subtitles are rendered/burned on the video.\nThese subtitles cannot be switched off since they become a part of the video"); - + //lblSubtitleMode lblSubtitleMode = new Gtk.Label(_("Subtitle Mode")); lblSubtitleMode.xalign = (float) 0.0; lblSubtitleMode.set_tooltip_markup (tt); gridSubtitle.attach(lblSubtitleMode,0,++row,1,1); - + //cmbSubtitleMode cmbSubtitleMode = new ComboBox(); textCell = new CellRendererText(); @@ -1181,7 +1181,7 @@ cmbSubtitleMode.hexpand = true; cmbSubtitleMode.set_tooltip_markup (tt); gridSubtitle.attach(cmbSubtitleMode,1,row,1,1); - + //lblSubFormatMessage lblSubFormatMessage = new Gtk.Label(_("Subtitles")); lblSubFormatMessage.xalign = (float) 0.0; @@ -1192,7 +1192,7 @@ gridSubtitle.attach(lblSubFormatMessage,0,++row,2,1); //Defaults -------------------------------- - + cmbFileFormat.set_active(0); //cmbAudioMode.set_active(0); //cmbVideoMode.set_active(0); @@ -1206,30 +1206,30 @@ cmbFadeType.set_active (0); //cmbResizingMethod.set_active (2); //cmbFileExtension.set_active (0); - + // Actions ---------------------------------------------- - + //btnSave btnSave = (Button) add_button ("gtk-save", Gtk.ResponseType.ACCEPT); btnSave.clicked.connect (btnSave_clicked); - + //btnCancel btnCancel = (Button) add_button ("gtk-cancel", Gtk.ResponseType.CANCEL); btnCancel.clicked.connect (() => { destroy(); }); } - + private bool on_delete_event(Gdk.EventAny event){ this.delete_event.disconnect(on_delete_event); //disconnect this handler btnSave_clicked(); return false; } - + private void cmbFileFormat_changed(){ Gtk.ListStore model; TreeIter iter; - + //populate file extensions --------------------------- - + model = new Gtk.ListStore(2, typeof(string), typeof(string)); cmbFileExtension.set_model(model); @@ -1268,12 +1268,12 @@ cmbFileExtension.set_active(0); break; } - + //populate video codecs --------------------------- - + model = new Gtk.ListStore (2, typeof (string), typeof (string)); cmbVCodec.set_model(model); - + switch (format) { case "mkv": model.append (out iter); @@ -1307,7 +1307,7 @@ cmbVCodec.set_active(0); break; } - + switch (format) { case "mkv": case "mp4v": @@ -1321,12 +1321,12 @@ gridVideoFilters.sensitive = false; break; } - + //populate audio codecs --------------------------- - + model = new Gtk.ListStore (2, typeof (string), typeof (string)); cmbACodec.set_model(model); - + switch (format) { case "mkv": model.append (out iter); @@ -1337,7 +1337,7 @@ model.set (iter,0,"AAC / Nero",1,"neroaac"); cmbACodec.set_active(1); break; - + case "mp4v": model.append (out iter); model.set (iter,0,_("Disable Audio"),1,"disable"); @@ -1345,7 +1345,7 @@ model.set (iter,0,"AAC / Nero",1,"neroaac"); cmbACodec.set_active(1); break; - + case "ogv": case "webm": model.append (out iter); @@ -1354,7 +1354,7 @@ model.set (iter,0,"Vorbis",1,"vorbis"); cmbACodec.set_active(1); break; - + case "ogg": model.append (out iter); model.set (iter,0,"Vorbis",1,"vorbis"); @@ -1366,31 +1366,31 @@ model.set (iter,0,"MP3 / LAME",1,"mp3lame"); cmbACodec.set_active(0); break; - + case "mp4a": model.append (out iter); model.set (iter,0,"AAC / Nero",1,"neroaac"); cmbACodec.set_active(0); break; - + case "opus": model.append (out iter); model.set (iter,0,"Opus",1,"opus"); cmbACodec.set_active(0); break; - + case "ac3": model.append (out iter); model.set (iter,0,"AC3 / Libav",1,"ac3"); cmbACodec.set_active(0); break; - + case "flac": model.append (out iter); model.set (iter,0,"FLAC / Libav",1,"flac"); cmbACodec.set_active(0); break; - + case "wav": //model.append (out iter); //model.set (iter,0,"PCM 8-bit Signed / Libav",1,"pcm_s8"); @@ -1423,33 +1423,33 @@ cmbACodec.set_active(1); break; } - + //populate subtitle options - + model = new Gtk.ListStore (2, typeof (string), typeof (string)); cmbSubtitleMode.set_model(model); - + switch (format){ case "mkv": case "mp4v": case "ogg": case "ogv": gridSubtitle.sensitive = true; - + model.append (out iter); model.set (iter,0,_("No Subtitles"),1,"disable"); model.append (out iter); model.set (iter,0,_("Embed / Soft Subs"),1,"embed"); cmbSubtitleMode.set_active(1); break; - + default: gridSubtitle.sensitive = false; break; } //set logo - + switch (format){ case "mkv": imgFileFormat.set_from_file(App.SharedImagesFolder + "/matroska.png"); @@ -1493,7 +1493,7 @@ break; } } - + private void cmbACodec_changed(){ Gtk.ListStore model; TreeIter iter; @@ -1549,7 +1549,7 @@ cmbOpusOptimize.visible = false; break; } - + //disable options when audio is disabled switch (acodec){ case "disable": @@ -1559,11 +1559,11 @@ gridAudioFilters.sensitive = true; break; } - + //populate encoding modes model = new Gtk.ListStore (2, typeof (string), typeof (string)); cmbAudioMode.set_model(model); - + switch (acodec){ case "mp3lame": model.append (out iter); @@ -1575,21 +1575,21 @@ model.append (out iter); model.set (iter,0,_("Constant Bitrate (Strict)"),1,"cbr-strict"); cmbAudioMode.set_active(0); - + spinAudioBitrate.adjustment.configure(128, 32, 320, 1, 1, 0); spinAudioBitrate.set_tooltip_text (""); spinAudioBitrate.digits = 0; - + spinAudioQuality.adjustment.configure(4, 0, 9, 1, 1, 0); spinAudioQuality.set_tooltip_text (""); spinAudioQuality.digits = 0; - + cmbAudioMode.sensitive = true; spinAudioBitrate.sensitive = true; spinAudioQuality.sensitive = true; cmbAudioMode_changed(); break; - + case "neroaac": model.append (out iter); model.set (iter,0,_("Variable Bitrate"),1,"vbr"); @@ -1598,7 +1598,7 @@ model.append (out iter); model.set (iter,0,_("Constant Bitrate"),1,"cbr"); cmbAudioMode.set_active(0); - + spinAudioBitrate.adjustment.configure(160, 8, 400, 1, 1, 0); spinAudioBitrate.set_tooltip_text (""); spinAudioBitrate.digits = 0; @@ -1616,11 +1616,11 @@ 0.85 = ~332 kbps 0.95 = ~381 kbps"""); spinAudioQuality.digits = 1; - + cmbAudioMode.sensitive = true; cmbAudioMode_changed(); break; - + case "opus": model.append (out iter); model.set (iter,0,_("Variable Bitrate"),1,"vbr"); @@ -1629,43 +1629,43 @@ model.append (out iter); model.set (iter,0,_("Constant Bitrate"),1,"cbr"); cmbAudioMode.set_active(0); - + spinAudioBitrate.adjustment.configure(128, 6, 512, 1, 1, 0); spinAudioBitrate.set_tooltip_text (""); spinAudioBitrate.digits = 0; - + cmbAudioMode.sensitive = true; cmbAudioMode_changed(); break; - + case "vorbis": model.append (out iter); model.set (iter,0,_("Variable Bitrate"),1,"vbr"); model.append (out iter); model.set (iter,0,_("Average Bitrate"),1,"abr"); cmbAudioMode.set_active(0); - + spinAudioBitrate.adjustment.configure(128, 32, 500, 1, 1, 0); spinAudioBitrate.set_tooltip_text (""); spinAudioBitrate.digits = 0; - + spinAudioQuality.adjustment.configure(3, -2, 10, 1, 1, 0); spinAudioQuality.set_tooltip_text (""); spinAudioQuality.digits = 1; - + cmbAudioMode.sensitive = true; cmbAudioMode_changed(); break; - + case "ac3": model.append (out iter); model.set (iter,0,_("Fixed Bitrate"),1,"cbr"); cmbAudioMode.set_active(0); - + spinAudioBitrate.adjustment.configure(128, 1, 512, 1, 1, 0); spinAudioBitrate.set_tooltip_text (""); spinAudioBitrate.digits = 0; - + cmbAudioMode.sensitive = true; cmbAudioMode_changed(); break; @@ -1688,17 +1688,17 @@ model.append (out iter); model.set (iter,0,_("Lossless"),1,"lossless"); cmbAudioMode.set_active(0); - + cmbAudioMode.sensitive = true; break; - + default: //disable cmbAudioMode.sensitive = false; spinAudioBitrate.sensitive = false; spinAudioQuality.sensitive = false; break; } - + //populate sampling rates model = new Gtk.ListStore (2, typeof (string), typeof (string)); cmbAudioSampleRate.set_model(model); @@ -1727,7 +1727,7 @@ model.set (iter,0,"48000",1,"48000"); cmbAudioSampleRate.set_active(0); break; - + case "pcm_s8": case "pcm_u8": case "pcm_s16le": @@ -1771,7 +1771,7 @@ model.set (iter,0,"96000",1,"96000"); cmbAudioSampleRate.set_active(0); break; - + case "ac3": model.append (out iter); model.set (iter,0,_("No Change"),1,"disable"); @@ -1785,14 +1785,14 @@ model.set (iter,0,"48000",1,"48000"); cmbAudioSampleRate.set_active(0); break; - + default: model.append (out iter); model.set (iter,0,_("No Change"),1,"disable"); cmbAudioSampleRate.set_active(0); break; } - + //populate channels model = new Gtk.ListStore (2, typeof (string), typeof (string)); cmbAudioChannels.set_model(model); @@ -1845,7 +1845,7 @@ cmbAudioChannels.set_active(0); break; } - + //set logo switch (acodec){ case "opus": @@ -1893,7 +1893,7 @@ break; } } - + private void cmbAudioMode_changed(){ switch (audio_mode) { case "vbr": @@ -1918,7 +1918,7 @@ private void cmbVCodec_changed(){ Gtk.ListStore model; TreeIter iter; - + //show x264 options switch (vcodec){ case "x264": @@ -1935,7 +1935,7 @@ cmbX264Profile.visible = false; break; } - + switch(vcodec){ case "x264": model = new Gtk.ListStore (2, typeof (string), typeof (string)); @@ -1954,7 +1954,7 @@ cmbX264Profile.set_model(model); cmbX264Profile.set_active(2); break; - + case "x265": model = new Gtk.ListStore (2, typeof (string), typeof (string)); model.append (out iter); @@ -1967,37 +1967,39 @@ cmbX264Profile.set_active(0); break; } - + //show vp8 options switch (vcodec){ case "vp8": case "vp9": lblVpxSpeed.visible = true; + cmbVpxSpeed.visible = true; scaleVpxSpeed.visible = true; scaleVpxSpeed.adjustment.value = 1; - + lblVpxSpeed.set_tooltip_markup(""); string tt = _("Quality Vs Encoding Speed\n\nBest: Best quality, slower\nGood: Good quality, faster\nRealtime: Fastest"); cmbVpxSpeed.set_tooltip_markup(tt); tt = _("Quality Vs Encoding Speed\n\nSmaller values = Better quality, slower\nLarger value = Lower quality, faster\n"); scaleVpxSpeed.set_tooltip_markup(tt); break; - + default: lblVpxSpeed.visible = false; + cmbVpxSpeed.visible = false; scaleVpxSpeed.visible = false; - + string tt = _("Quality Vs Encoding Speed\nHigher values speed-up encoding at the expense of quality.\nLower values improve quality at the expense of encoding speed."); lblVpxSpeed.set_tooltip_markup(tt); break; } - + //populate encoding modes model = new Gtk.ListStore (2, typeof (string), typeof (string)); cmbVideoMode.set_model(model); lblVideoQuality.visible = true; spinVideoQuality.visible = true; - + switch (vcodec){ case "x264": model.append (out iter); @@ -2007,21 +2009,21 @@ model.append (out iter); model.set (iter,0,_("Average Bitrate (2-pass)"),1,"2pass"); cmbVideoMode.set_active(0); - + spinVideoBitrate.adjustment.configure(800, 1, 10000000, 1, 1, 0); spinVideoBitrate.set_tooltip_text (""); spinVideoBitrate.digits = 0; - + spinVideoQuality.adjustment.configure(23.0, 0, 51, 1, 1, 0); spinVideoQuality.set_tooltip_text (""); spinVideoQuality.digits = 1; - + cmbVideoMode.sensitive = true; spinVideoBitrate.sensitive = true; spinVideoQuality.sensitive = true; cmbVideoMode_changed(); break; - + case "x265": model.append (out iter); model.set (iter,0,_("Variable Bitrate / CRF"),1,"vbr"); @@ -2030,21 +2032,21 @@ model.append (out iter); model.set (iter,0,_("Average Bitrate (2-pass)"),1,"2pass"); cmbVideoMode.set_active(0); - + spinVideoBitrate.adjustment.configure(800, 1, 10000000, 1, 1, 0); spinVideoBitrate.set_tooltip_text (""); spinVideoBitrate.digits = 0; - + spinVideoQuality.adjustment.configure(28.0, 0, 51, 1, 1, 0); spinVideoQuality.set_tooltip_text (""); spinVideoQuality.digits = 1; - + cmbVideoMode.sensitive = true; spinVideoBitrate.sensitive = true; spinVideoQuality.sensitive = true; cmbVideoMode_changed(); break; - + case "theora": model.append (out iter); model.set (iter,0,_("Variable Bitrate"),1,"vbr"); @@ -2053,21 +2055,21 @@ model.append (out iter); model.set (iter,0,_("Average Bitrate (2-pass)"),1,"2pass"); cmbVideoMode.set_active(0); - + spinVideoBitrate.adjustment.configure(800, 1, 10000000, 1, 1, 0); spinVideoBitrate.set_tooltip_text (""); spinVideoBitrate.digits = 0; - + spinVideoQuality.adjustment.configure(6, 0, 10, 1, 1, 0); spinVideoQuality.set_tooltip_text (""); spinVideoQuality.digits = 1; - + cmbVideoMode.sensitive = true; spinVideoBitrate.sensitive = true; spinVideoQuality.sensitive = true; cmbVideoMode_changed(); break; - + case "vp8": case "vp9": model.append (out iter); @@ -2079,15 +2081,15 @@ //model.append (out iter); //model.set (iter,0,_("Constant Quality"),1,"cq"); cmbVideoMode.set_active(0); - + spinVideoBitrate.adjustment.configure(800, 1, 1000000000, 1, 1, 0); spinVideoBitrate.set_tooltip_text (""); spinVideoBitrate.digits = 0; - + /*spinVideoQuality.adjustment.configure(-1, -1, 63, 1, 1, 0); spinVideoQuality.set_tooltip_text (""); spinVideoQuality.digits = 0;*/ - + cmbVideoMode.sensitive = true; spinVideoBitrate.sensitive = true; //spinVideoQuality.sensitive = true; @@ -2095,18 +2097,18 @@ spinVideoQuality.visible = false; cmbVideoMode_changed(); break; - + default: //disable cmbVideoMode.sensitive = false; spinVideoBitrate.sensitive = false; spinVideoQuality.sensitive = false; break; } - + //populate resize methods model = new Gtk.ListStore (2, typeof (string), typeof (string)); cmbResizingMethod.set_model(model); - + switch (vcodec){ case "x264": case "x265": @@ -2134,12 +2136,12 @@ model.set (iter,0,"Lanczos",1,"lanczos"); cmbResizingMethod.set_active(2); break; - + default: lblResizingMethod.visible = false; cmbResizingMethod.visible = false; break; - + } //set logo @@ -2174,7 +2176,7 @@ break; } } - + private void cmbFrameSize_changed(){ if (gtk_combobox_get_value(cmbFrameSize,1,"disable") == "custom") { spinFrameWidth.sensitive = true; @@ -2184,7 +2186,7 @@ spinFrameWidth.sensitive = false; spinFrameHeight.sensitive = false; } - + if (gtk_combobox_get_value(cmbFrameSize,1,"disable") == "disable") { cmbResizingMethod.sensitive = false; chkFitToBox.sensitive = false; @@ -2195,7 +2197,7 @@ chkFitToBox.sensitive = true; chkNoUpScale.sensitive = true; } - + switch (gtk_combobox_get_value(cmbFrameSize,1,"disable")) { case "disable": spinFrameWidth.value = 0; @@ -2222,11 +2224,11 @@ spinFrameHeight.value = 1080; break; } - + lblFrameSizeCustom.visible = true; spinFrameWidth.visible = true; spinFrameHeight.visible = true; - + /* if (gtk_combobox_get_value(cmbFrameSize,1,"disable") == "disable"){ lblFrameSizeCustom.visible = false; @@ -2249,7 +2251,7 @@ spinFPSNum.sensitive = false; spinFPSDenom.sensitive = false; } - + switch (gtk_combobox_get_value(cmbFPS,1,"disable")) { case "disable": spinFPSNum.value = 0; @@ -2276,7 +2278,7 @@ spinFPSDenom.value = 1; break; } - + lblFPSCustom.visible = true; spinFPSNum.visible = true; spinFPSDenom.visible = true; @@ -2292,7 +2294,7 @@ spinFPSDenom.visible = true; }*/ } - + private void cmbVideoMode_changed(){ switch(vcodec){ case "vp8": @@ -2332,24 +2334,24 @@ } break; } - + } - + private void cmbVpxSpeed_changed(){ switch (vpx_deadline) { case "best": scaleVpxSpeed.adjustment.configure(0, 0, 0, 1, 1, 0); scaleVpxSpeed.sensitive = false; break; - + case "realtime": - scaleVpxSpeed.sensitive = true; + scaleVpxSpeed.sensitive = true; scaleVpxSpeed.adjustment.configure(0, 0, 15, 1, 1, 0); break; - + case "good": default: - scaleVpxSpeed.sensitive = true; + scaleVpxSpeed.sensitive = true; scaleVpxSpeed.adjustment.configure(1, 0, 5, 1, 1, 0); break; } @@ -2378,7 +2380,7 @@ break; } break; - + default: lblSubFormatMessage.label = ""; break; @@ -2396,10 +2398,10 @@ dlg.set_transient_for(this); dlg.run(); dlg.destroy(); - + return; } - + save_script(); destroy(); } @@ -2410,7 +2412,7 @@ var video = new Json.Object(); var audio = new Json.Object(); var subs = new Json.Object(); - + config.set_object_member("general",general); general.set_string_member("format",format); general.set_string_member("extension",extension); @@ -2418,7 +2420,7 @@ general.set_string_member("authorEmail",author_email); general.set_string_member("presetName",preset_name); general.set_string_member("presetVersion",preset_version); - + config.set_object_member("video",video); video.set_string_member("codec",vcodec); if (vcodec != "disable") { @@ -2444,7 +2446,7 @@ video.set_string_member("fpsNum",frame_rate_num); video.set_string_member("fpsDenom",frame_rate_denom); } - + config.set_object_member("audio",audio); audio.set_string_member("codec",acodec); if (acodec != "disable") { @@ -2457,7 +2459,7 @@ } audio.set_string_member("channels",audio_channels); audio.set_string_member("samplingRate",audio_sampling); - + //sox audio.set_boolean_member("soxEnabled",sox_enabled); if (sox_enabled) { @@ -2472,10 +2474,10 @@ audio.set_boolean_member("soxEarwax",sox_earwax); } } - + config.set_object_member("subtitle",subs); subs.set_string_member("mode",subtitle_mode); - + var filePath = Folder + "/" + txtPresetName.text + ".json"; var json = new Json.Generator(); json.pretty = true; @@ -2483,7 +2485,7 @@ var node = new Json.Node(NodeType.OBJECT); node.set_object(config); json.set_root(node); - + try{ json.to_file(filePath); } catch (Error e) { @@ -2493,13 +2495,13 @@ //Set the newly saved file as the active script App.SelectedScript = new ScriptFile(filePath); } - + public void load_script(){ var filePath = Folder + "/" + Name + ".json"; if(file_exists(filePath) == false){ return; } - + txtPresetName.text = Name; - + var parser = new Json.Parser(); try{ parser.load_from_file(filePath); @@ -2512,20 +2514,20 @@ Json.Object video = (Json.Object) config.get_object_member("video"); Json.Object audio = (Json.Object) config.get_object_member("audio"); Json.Object subs = (Json.Object) config.get_object_member("subtitle"); - + //general ---------------------------- - + format = general.get_string_member("format"); extension = general.get_string_member("extension"); //preset_name = general.get_string_member("presetName"); //set from file name preset_version = general.get_string_member("presetVersion"); author_name = general.get_string_member("authorName"); author_email = general.get_string_member("authorEmail"); - + //video -------------------------- - + vcodec = video.get_string_member("codec"); - + if (vcodec != "disable") { switch(vcodec){ case "x264": @@ -2549,7 +2551,7 @@ video_quality = video.get_string_member("quality"); //video filters ------------------------ - + frame_size = video.get_string_member("frameSize"); frame_width = video.get_string_member("frameWidth"); frame_height = video.get_string_member("frameHeight"); @@ -2560,11 +2562,11 @@ frame_rate_num = video.get_string_member("fpsNum"); frame_rate_denom = video.get_string_member("fpsDenom"); } - + //audio --------------------- - + acodec = audio.get_string_member("codec"); - + if (acodec != "disable") { //codec config audio_mode = audio.get_string_member("mode"); @@ -2575,9 +2577,9 @@ } audio_channels = audio.get_string_member("channels"); audio_sampling = audio.get_string_member("samplingRate"); - + //sox config - + if (audio.get_boolean_member("soxEnabled")){ App.Encoders["sox"].CheckAvailability(); if (!App.Encoders["sox"].IsAvailable){ @@ -2605,384 +2607,384 @@ } //subtitles -------------- - + subtitle_mode = subs.get_string_member("mode"); } public string format{ - owned get { + owned get { return gtk_combobox_get_value(cmbFileFormat,1,"mkv"); } - set { + set { gtk_combobox_set_value(cmbFileFormat,1,value); } } public string extension{ - owned get { + owned get { return gtk_combobox_get_value(cmbFileExtension,1,".mkv"); } - set { + set { gtk_combobox_set_value(cmbFileExtension,1,value); } } - + public string author_name{ - owned get { + owned get { return txtAuthorName.text; } - set { + set { txtAuthorName.text = value; } } - + public string author_email{ - owned get { + owned get { return txtAuthorEmail.text; } - set { + set { txtAuthorEmail.text = value; } } - + public string preset_name{ - owned get { + owned get { return txtPresetName.text; } - set { + set { txtPresetName.text = value; } } - + public string preset_version{ - owned get { + owned get { return txtPresetVersion.text; } - set { + set { txtPresetVersion.text = value; } } - + public string vcodec{ - owned get { + owned get { return gtk_combobox_get_value(cmbVCodec,1,"x264"); } - set { + set { gtk_combobox_set_value(cmbVCodec,1,value); } } - + public string video_mode{ - owned get { + owned get { return gtk_combobox_get_value(cmbVideoMode,1,"vbr"); } - set { + set { gtk_combobox_set_value(cmbVideoMode,1,value); } } public string video_bitrate{ - owned get { - return spinVideoBitrate.get_value().to_string(); + owned get { + return spinVideoBitrate.get_value().to_string(); } - set { + set { spinVideoBitrate.set_value(double.parse(value)); } } - + public string video_quality{ - owned get { - return "%.1f".printf(spinVideoQuality.get_value()); + owned get { + return "%.1f".printf(spinVideoQuality.get_value()); } - set { + set { spinVideoQuality.get_adjustment().set_value(double.parse(value)); } } - + public string x264_preset { - owned get { + owned get { return gtk_combobox_get_value(cmbX264Preset,1,"medium"); } - set { + set { gtk_combobox_set_value(cmbX264Preset,1,value); } } - + public string x264_profile{ - owned get { + owned get { return gtk_combobox_get_value(cmbX264Profile,1,"high"); } - set { + set { gtk_combobox_set_value(cmbX264Profile, 1, value); } } public string x264_options{ - owned get { + owned get { return txtVCodecOptions.buffer.text; } - set { + set { txtVCodecOptions.buffer.text = value; } } public string vpx_deadline{ - owned get { + owned get { return gtk_combobox_get_value(cmbVpxSpeed,1,"good"); } - set { + set { gtk_combobox_set_value(cmbVpxSpeed,1,value); } } - + public string vpx_speed{ - owned get { + owned get { return scaleVpxSpeed.adjustment.value.to_string(); } - set { + set { scaleVpxSpeed.adjustment.value = int.parse(value); } } - + public string frame_size{ - owned get { + owned get { return gtk_combobox_get_value(cmbFrameSize,1,"disable"); } - set { + set { gtk_combobox_set_value(cmbFrameSize, 1, value); } } - + public string resizing_method{ - owned get { + owned get { return gtk_combobox_get_value(cmbResizingMethod,1,"cubic"); } - set { + set { gtk_combobox_set_value(cmbResizingMethod, 1, value); } } - + public string frame_width{ - owned get { - return spinFrameWidth.get_value().to_string(); + owned get { + return spinFrameWidth.get_value().to_string(); } - set { + set { spinFrameWidth.set_value(double.parse(value)); } } - + public string frame_height{ - owned get { - return spinFrameHeight.get_value().to_string(); + owned get { + return spinFrameHeight.get_value().to_string(); } - set { + set { spinFrameHeight.set_value(double.parse(value)); } } - + public bool fit_to_box{ - get { - return chkFitToBox.active; + get { + return chkFitToBox.active; } - set { + set { chkFitToBox.set_active((bool)value); } } - + public bool no_upscaling{ - get { - return chkNoUpScale.active; + get { + return chkNoUpScale.active; } - set { + set { chkNoUpScale.set_active((bool)value); } } - + public string frame_rate{ - owned get { + owned get { return gtk_combobox_get_value(cmbFPS,1,"disable"); } - set { + set { gtk_combobox_set_value(cmbFPS, 1, value); } } - + public string frame_rate_num{ - owned get { - return spinFPSNum.get_value().to_string(); + owned get { + return spinFPSNum.get_value().to_string(); } - set { + set { spinFPSNum.set_value(double.parse(value)); } } public string frame_rate_denom{ - owned get { - return spinFPSDenom.get_value().to_string(); + owned get { + return spinFPSDenom.get_value().to_string(); } - set { + set { spinFPSDenom.set_value(double.parse(value)); } } - + public string acodec{ - owned get { + owned get { return gtk_combobox_get_value(cmbACodec,1,"mp3lame"); } - set { + set { gtk_combobox_set_value(cmbACodec,1,value); } } - + public string audio_mode{ - owned get { + owned get { return gtk_combobox_get_value(cmbAudioMode,1,"vbr"); } - set { + set { gtk_combobox_set_value(cmbAudioMode, 1, value); } } - + public string audio_opus_optimize{ - owned get { + owned get { return gtk_combobox_get_value(cmbOpusOptimize,1,"none"); } - set { + set { gtk_combobox_set_value(cmbOpusOptimize, 1, value); } } - + public string audio_bitrate{ - owned get { - return spinAudioBitrate.get_value().to_string(); + owned get { + return spinAudioBitrate.get_value().to_string(); } - set { + set { spinAudioBitrate.set_value(double.parse(value)); } } - + public string audio_quality{ - owned get { - return "%.1f".printf(spinAudioQuality.get_value()); + owned get { + return "%.1f".printf(spinAudioQuality.get_value()); } - set { + set { spinAudioQuality.set_value(double.parse(value)); } } - + public string audio_channels{ - owned get { + owned get { return gtk_combobox_get_value(cmbAudioChannels,1,"disable"); } - set { + set { gtk_combobox_set_value(cmbAudioChannels, 1, value); } } - + public string audio_sampling{ - owned get { + owned get { return gtk_combobox_get_value(cmbAudioSampleRate,1,"disable"); } - set { + set { gtk_combobox_set_value(cmbAudioSampleRate, 1, value); } } public bool sox_enabled{ - get { - return switchSox.active; + get { + return switchSox.active; } - set { + set { switchSox.set_active((bool)value); } } - + public string sox_bass{ - owned get { + owned get { return scaleBass.get_value().to_string(); } - set { + set { scaleBass.set_value(double.parse(value)); } } public string sox_treble{ - owned get { + owned get { return scaleTreble.get_value().to_string(); } - set { + set { scaleTreble.set_value(double.parse(value)); } } public string sox_pitch{ - owned get { + owned get { return "%.1f".printf(scalePitch.get_value()/100); } - set { + set { scalePitch.set_value(double.parse(value) * 100); } } public string sox_tempo{ - owned get { + owned get { return "%.1f".printf(scaleTempo.get_value()/100); } - set { + set { scaleTempo.set_value(double.parse(value) * 100); } } public string sox_fade_in{ - owned get { + owned get { return spinFadeIn.get_value().to_string(); } - set { + set { spinFadeIn.set_value(double.parse(value)); } } public string sox_fade_out{ - owned get { + owned get { return spinFadeOut.get_value().to_string(); } - set { + set { spinFadeOut.set_value(double.parse(value)); } } public string sox_fade_type{ - owned get { + owned get { return gtk_combobox_get_value(cmbFadeType,1,"l"); } - set { + set { gtk_combobox_set_value(cmbFadeType, 1, value); } } - + public bool sox_normalize{ - get { - return switchNormalize.active; + get { + return switchNormalize.active; } - set { + set { switchNormalize.set_active((bool)value); } } public bool sox_earwax{ - get { - return switchEarWax.active; + get { + return switchEarWax.active; } - set { + set { switchEarWax.set_active((bool)value); } } - + public string subtitle_mode{ - owned get { + owned get { return gtk_combobox_get_value(cmbSubtitleMode,1,"disable"); } - set { + set { gtk_combobox_set_value(cmbSubtitleMode, 1, value); } } diff -Nru selene-2.5.7~196~ubuntu15.04.1/src/EncoderStatusWindow.vala selene-2.5.8~198~ubuntu15.04.1/src/EncoderStatusWindow.vala --- selene-2.5.7~196~ubuntu15.04.1/src/EncoderStatusWindow.vala 2015-08-14 22:16:18.000000000 +0000 +++ selene-2.5.8~198~ubuntu15.04.1/src/EncoderStatusWindow.vala 2015-09-08 00:46:25.000000000 +0000 @@ -1,26 +1,26 @@ /* * FileInfoWindow.vala - * + * * Copyright 2012 Tony George - * + * * This program 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. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. - * - * + * + * */ - + using Gtk; using TeeJee.Logging; @@ -40,11 +40,11 @@ private Button btnRefesh; private TreeView tv; private ScrolledWindow sw; - + public EncoderStatusWindow () { title = _("Encoders"); set_default_size (500, 450); - + window_position = WindowPosition.CENTER_ON_PARENT; destroy_with_parent = true; skip_taskbar_hint = true; @@ -63,7 +63,7 @@ tv.get_selection().mode = SelectionMode.NONE; tv.headers_visible = true; tv.set_rules_hint (true); - + sw = new ScrolledWindow(null, null); sw.set_shadow_type (ShadowType.ETCHED_IN); sw.add (tv); @@ -74,11 +74,11 @@ //col_icon.title = _(""); col_icon.resizable = true; tv.append_column(col_icon); - + CellRendererPixbuf cell_icon = new CellRendererPixbuf (); col_icon.pack_start (cell_icon, false); col_icon.set_attributes(cell_icon, "pixbuf", 3); - + TreeViewColumn col_cmd = new TreeViewColumn(); col_cmd.title = " " + _("Encoding Tool") + " "; tv.append_column(col_cmd); @@ -86,43 +86,43 @@ CellRendererText cell_cmd = new CellRendererText (); col_cmd.pack_start (cell_cmd, false); col_cmd.set_attributes(cell_cmd, "text", 0); - + TreeViewColumn col_desc = new TreeViewColumn(); col_desc.title = " " + _("Description") + " "; tv.append_column(col_desc); - + CellRendererText cell_desc = new CellRendererText (); col_desc.pack_start (cell_desc, false); col_desc.set_attributes(cell_desc, "text", 1); - + TreeViewColumn col_status = new TreeViewColumn(); col_status.title = " " + _("Status") + " "; tv.append_column(col_status); - + CellRendererText cell_status = new CellRendererText (); col_status.pack_start (cell_status, false); col_status.set_attributes(cell_status, "text", 2); - + tv_refresh(); - + //btnRefesh btnRefesh = new Button.with_label(" " + _("Refresh") + " "); vbox_actions.add(btnRefesh); btnRefesh.clicked.connect(()=>{ gtk_set_busy(true,this); - App.check_all_encoders(); + App.check_all_encoders(); tv_refresh(); gtk_set_busy(false,this); }); - + //btnOk btnOk = (Button) add_button ("gtk-ok", Gtk.ResponseType.ACCEPT); btnOk.clicked.connect (() => { destroy(); }); } - + public void tv_refresh(){ TreeStore store = new TreeStore (4, typeof (string), typeof (string), typeof (string), typeof(Gdk.Pixbuf)); - + //status icons Gdk.Pixbuf pix_ok = null; Gdk.Pixbuf pix_missing = null; @@ -134,7 +134,7 @@ catch(Error e){ log_error (e.message); } - + foreach (Encoder enc in App.Encoders.values){ TreeIter iter; store.append(out iter, null); @@ -143,7 +143,7 @@ store.set(iter, 2, enc.IsAvailable ? _("Found") : _("Missing")); store.set(iter, 3, enc.IsAvailable ? pix_ok : pix_missing); } - + tv.set_model (store); } } diff -Nru selene-2.5.7~196~ubuntu15.04.1/src/FileInfoWindow.vala selene-2.5.8~198~ubuntu15.04.1/src/FileInfoWindow.vala --- selene-2.5.7~196~ubuntu15.04.1/src/FileInfoWindow.vala 2015-08-14 22:16:18.000000000 +0000 +++ selene-2.5.8~198~ubuntu15.04.1/src/FileInfoWindow.vala 2015-09-08 00:46:25.000000000 +0000 @@ -1,26 +1,26 @@ /* * FileInfoWindow.vala - * + * * Copyright 2012 Tony George - * + * * This program 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. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. - * - * + * + * */ - + using Gtk; using TeeJee.Logging; @@ -39,25 +39,25 @@ public MediaFile file; private TreeView tvInfo; private ScrolledWindow swInfo; - + public FileInfoWindow (MediaFile _file) { title = _("Properties"); set_default_size (700, 500); - + window_position = WindowPosition.CENTER_ON_PARENT; destroy_with_parent = true; skip_taskbar_hint = true; modal = true; deletable = false; icon = get_app_icon(16); - + //save reference file = _file; - + // get content area vboxMain = get_content_area(); vboxMain.margin = 6; - + //tvInfo tvInfo = new TreeView(); tvInfo.get_selection().mode = SelectionMode.MULTIPLE; @@ -77,10 +77,10 @@ int index = -1; infoStore.append (out iter0, null); //infoStore.remove (ref iter0); - + foreach (string line in file.InfoText.split ("\n")){ if (line.strip() == "") { continue; } - + index = line.index_of (":"); if (index == -1){ @@ -95,7 +95,7 @@ } tvInfo.set_model (infoStore); tvInfo.expand_all(); - + // btnOk btnOk = (Button) add_button ("gtk-ok", Gtk.ResponseType.ACCEPT); btnOk.clicked.connect (() => { destroy(); }); diff -Nru selene-2.5.7~196~ubuntu15.04.1/src/Main.vala selene-2.5.8~198~ubuntu15.04.1/src/Main.vala --- selene-2.5.7~196~ubuntu15.04.1/src/Main.vala 2015-08-14 22:16:18.000000000 +0000 +++ selene-2.5.8~198~ubuntu15.04.1/src/Main.vala 2015-09-08 00:46:25.000000000 +0000 @@ -1,24 +1,24 @@ /* * Main.vala - * + * * Copyright 2012 Tony George - * + * * This program 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. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. - * - * + * + * */ using GLib; @@ -38,7 +38,7 @@ public Main App; public const string AppName = "Selene"; public const string AppShortName = "selene"; -public const string AppVersion = "2.5.7"; +public const string AppVersion = "2.5.8"; public const string AppAuthor = "Tony George"; public const string AppAuthorEmail = "teejeetech@gmail.com"; @@ -59,8 +59,8 @@ public enum AppStatus{ NOTSTARTED, //initial state - RUNNING, - PAUSED, + RUNNING, + PAUSED, IDLE, //batch completed WAITFILE //waiting for files } @@ -68,7 +68,7 @@ public class Main : GLib.Object{ public Gee.ArrayList InputFiles; public Gee.HashMap Encoders; - + public string ScriptsFolder_Official = ""; public string ScriptsFolder_Custom = ""; public string PresetsFolder_Official = ""; @@ -78,19 +78,19 @@ public string SharedDataDirectory; public string AppConfPath = ""; public string usr_share_dir; - + public string TempDirectory; public string OutputDirectory = ""; public string BackupDirectory = ""; public string InputDirectory = ""; public bool TileView = true; - + public ScriptFile SelectedScript; public MediaFile CurrentFile; public string CurrentLine; public string StatusLine; public double Progress; - + public bool BatchStarted = false; public bool BatchCompleted = false; public bool Aborted; @@ -104,7 +104,7 @@ public bool BackgroundMode = false; public bool WaitingForShutdown = false; public bool ShowNotificationPopups = false; - + private Regex regex_generic; private Regex regex_mkvmerge; private Regex regex_libav; @@ -117,7 +117,7 @@ private Regex regex_opus; private Regex regex_vpxenc; private Regex regex_neroaacenc; - + private string tempLine; private MatchInfo match; private double dblVal; @@ -127,8 +127,8 @@ private string outLine = ""; private DataInputStream disOut; private DataInputStream disErr; - private DataOutputStream dsLog; - + private DataOutputStream dsLog; + private string blankLine = ""; public static int main (string[] args) { @@ -150,10 +150,10 @@ //init GTK Gtk.init (ref args); - + //init TMP init_tmp(); - + //init app App = new Main(args[0]); @@ -162,7 +162,7 @@ LOG_COLORS = (term == "xterm"); //get command line arguments - for (int k = 1; k < args.length; k++) // Oth arg is app path + for (int k = 1; k < args.length; k++) // Oth arg is app path { switch (args[k].down()){ case "--script": @@ -171,7 +171,7 @@ App.SelectedScript = new ScriptFile(args[k]); } break; - + case "--output-dir": k++; if (k < args.length){ @@ -183,7 +183,7 @@ } } break; - + case "--backup-dir": k++; if (k < args.length){ @@ -195,15 +195,15 @@ } } break; - + case "--console": App.ConsoleMode = true; break; - + case "--debug": App.DebugMode = true; break; - + case "--shutdown": if (App.AdminMode) { App.Shutdown = true; @@ -213,7 +213,7 @@ log_error (_("Warning: User does not have Admin priviledges. '--shutdown' will be ignored.")); } break; - + case "--background": App.BackgroundMode = true; App.set_priority(); @@ -224,11 +224,11 @@ break; } } - + //check UI mode if ((App.SelectedScript == null)||(App.InputFiles.size == 0)) App.ConsoleMode = false; - + //show window if (App.ConsoleMode){ if (App.InputFiles.size == 0){ @@ -245,14 +245,14 @@ } Gtk.main(); - + return 0; } public static string help_message(){ string msg = "\n" + AppName + " v" + AppVersion + " by Tony George (teejee2008@gmail.com)" + "\n"; msg += Environment.get_prgname() + " [options] "; - msg += + msg += """ Options: @@ -260,26 +260,26 @@ --output-dir Set output directory 'none' - Save files in input location - + --backup-dir Set backup directory 'none' - Do not move files - + --console Console mode - GUI will not be loaded --shutdown Shutdown system after completion (disabled by default) --background Run with low priority (recommended) - + --debug Show additional information - + --help List all options - + Notes: 1) The '--console' option is used for automated encoding. Script should be selected using the '--script' option and input files must be specified on the command line. Conversion will start immediately. - + 2) Default settings will be used if an option is not specified. Default settings can be customized using the 'Settings' button in the main window. @@ -287,21 +287,21 @@ 4) '--background' option will run all processes with lower priority. This allows the user to continue with other tasks while files are converted - in the background. - + in the background. + 5) Running the app as Admin (using 'sudo') will enable some extra GUI options. """; return msg; } - + public Main(string arg0){ InputFiles = new Gee.ArrayList(); Encoders = new Gee.HashMap(); - + //check encoders init_encoder_list(); check_all_encoders(); - + //check critical encoders foreach(string enc in new string[]{"mediainfo","avconv"}){ Encoders[enc].CheckAvailability(); @@ -313,7 +313,7 @@ // check for admin priviledges AdminMode = user_is_admin(); - + // check for notify-send string path = get_cmd_path ("notify-send"); if ((path != null)&&(path != "")){ @@ -322,11 +322,11 @@ // set default directory paths string homeDir = Environment.get_home_dir(); - TempDirectory = Environment.get_tmp_dir() + "/" + Environment.get_prgname(); - create_dir (TempDirectory); + TempDirectory = Environment.get_tmp_dir() + "/" + Environment.get_prgname(); + create_dir (TempDirectory); OutputDirectory = ""; BackupDirectory = ""; - + usr_share_dir = "/usr/share"; SharedDataDirectory = "/usr/share/selene"; UserDataDirectory = homeDir + "/.config/selene"; @@ -337,7 +337,7 @@ PresetsFolder_Official = SharedDataDirectory + "/presets"; PresetsFolder_Custom = UserDataDirectory + "/presets"; SharedImagesFolder = SharedDataDirectory + "/images"; - + AppConfPath = UserDataDirectory + "/selene.json"; create_dir (UserDataDirectory); @@ -345,65 +345,65 @@ create_dir (PresetsFolder_Custom); // create a copy of official scripts & presets on first run - + if (dir_exists (ScriptsFolder_Official)){ rsync(ScriptsFolder_Official, ScriptsFolder_Custom, false, false); rsync(PresetsFolder_Official, PresetsFolder_Custom, false, false); } // additional info - + log_msg (_("Loading scripts from:") + " '%s'".printf(ScriptsFolder_Custom)); log_msg (_("Loading presets from:") + " '%s'".printf(PresetsFolder_Custom)); log_msg (_("Using temp folder:") + " '%s'".printf(TempDirectory)); // init config - + load_config(); - + // init regular expressions - + try{ regex_generic = new Regex("""([0-9.]+)%"""); regex_mkvmerge = new Regex("""Progress: ([0-9.]+)%"""); - + regex_libav = new Regex("""time=[ ]*([0-9:.]+)"""); - + //frame= 82 fps= 23 q=28.0 size= 133kB time=1.42 bitrate= 766.9kbits/s regex_libav_video = new Regex("""frame=[ ]*[0-9]+ fps=[ ]*([0-9]+)[.]?[0-9]* q=[ ]*[0-9]+[.]?[0-9]* size=[ ]*([0-9]+)kB time=[ ]*[0-9:.]+ bitrate=[ ]*([0-9.]+)"""); - - //size= 1590kB time=30.62 bitrate= 425.3kbits/s + + //size= 1590kB time=30.62 bitrate= 425.3kbits/s regex_libav_audio = new Regex("""size=[ ]*([0-9]+)kB time=[ ]*[0-9:.]+ bitrate=[ ]*([0-9.]+)"""); - + //531 frames: 72.90 fps, 1509.18 kb/s regex_x264 = new Regex("""[ ]*([0-9]+) frames:[ ]*([0-9.]+) fps,[ ]*([0-9.]+) kb/s"""); - - // 0:00:00.66 audio: 57kbps video: 404kbps, time elapsed: 00:00:00 + + // 0:00:00.66 audio: 57kbps video: 404kbps, time elapsed: 00:00:00 regex_ffmpeg2theora = new Regex ("""([0-9:.]+)[ ]*audio:[ ]*([0-9]+)kbps[ ]*video:[ ]*([0-9]+)kbps"""); // 0:00:00.92 audio: 98kbps video: 87kbps, ET: 00:00:10, est. size: 0.2 MB regex_ffmpeg2theora2 = new Regex ("""([0-9:.]+)[ ]*audio:[ ]*([0-9]+)kbps[ ]*video:[ ]*([0-9]+)kbps,[ ]*ET:[ ]*([0-9:.]+),[ ]*est. size:[ ]*([0-9.]+)"""); //Scanning first pass pos: 0:00:00.00 ET: 00:00:00 regex_ffmpeg2theora3 = new Regex ("""Scanning first pass pos:[ ]*([0-9:.]+)[ ]*ET:[ ]*([0-9:.]+)"""); - + //[/] 00:00:28.21 16.3x realtime, 60.68kbit/s //[-] 00:01:48.09 16x realtime, 60.7kbit/s regex_opus = new Regex ("""\[.\][ ]*([0-9:.]+)[ ]*([0-9]+)[.]?[0-9]*x realtime,[ ]*([0-9]+)[.]?[0-9]*kbit/s"""); - + //Pass 1/1 frame 2/1 6755B regex_vpxenc = new Regex ("""(Pass[ ]*[0-9]+/[0-9]+)[ ]*frame[ ]*([0-9]+)/[0-9]+[ ]*([0-9]+)B"""); - + //Processed 100 seconds... regex_neroaacenc = new Regex("""Processed[ ]*([0-9.]+)[ ]*seconds"""); } catch (Error e) { log_error (e.message); } - + blankLine = ""; for (int i=0; i<80; i++) blankLine += " "; } - + public void init_encoder_list(){ Encoders["avconv"] = new Encoder("avconv","Libav Encoder","Audio-Video Decoding"); Encoders["ffmpeg2theora"] = new Encoder("ffmpeg2theora","Theora Video Encoder","Theora Output"); @@ -419,7 +419,7 @@ Encoders["x264"] = new Encoder("x264","H.264 / MPEG-4 AVC Video Encoder","H264 Output"); Encoders["x265"] = new Encoder("x264","H.265 / MPEG-H HEVC Video Encoder","H265 Output"); } - + public void check_all_encoders(){ foreach(Encoder enc in Encoders.values){ enc.CheckAvailability(); @@ -428,20 +428,20 @@ public void start_input_thread(){ // start thread for reading user input - + try { Thread.create (wait_for_user_input_thread, true); } catch (ThreadError e) { log_error (e.message); } } - + private void wait_for_user_input_thread(){ while (true){ // loop runs for entire application lifetime wait_for_user_input(); } } - + private void wait_for_user_input(){ int ch = stdin.getc(); @@ -473,10 +473,10 @@ return mf; } } - + return null; } - + public void save_config(){ var config = new Json.Object(); config.set_string_member("input-dir", InputDirectory); @@ -484,31 +484,31 @@ config.set_string_member("output-dir", OutputDirectory); config.set_string_member("last-script", SelectedScript.Path); config.set_string_member("tile-view", TileView.to_string()); - + if (SelectedScript != null) { config.set_string_member("last-script", SelectedScript.Path); } else { config.set_string_member("last-script", ""); } - + var json = new Json.Generator(); json.pretty = true; json.indent = 2; var node = new Json.Node(NodeType.OBJECT); node.set_object(config); json.set_root(node); - + try{ json.to_file(AppConfPath); } catch (Error e) { log_error (e.message); } } - + public void load_config(){ var f = File.new_for_path(AppConfPath); if (!f.query_exists()) { return; } - + var parser = new Json.Parser(); try{ parser.load_from_file(AppConfPath); @@ -523,7 +523,7 @@ InputDirectory = val; else InputDirectory = ""; - + val = json_get_string(config,"backup-dir", BackupDirectory); if (dir_exists(val)) BackupDirectory = val; @@ -533,32 +533,32 @@ val = json_get_string(config,"output-dir", OutputDirectory); if (dir_exists(val)) OutputDirectory = val; - else + else OutputDirectory = ""; val = json_get_string(config,"last-script", ""); if (val != null && val.length > 0) { SelectedScript = new ScriptFile(val); } - + TileView = json_get_bool(config,"tile-view",true); } - + public void exit_app(){ - save_config(); + save_config(); Gtk.main_quit(); } - + public bool add_file (string filePath){ MediaFile mFile = new MediaFile (filePath); - - if (mFile.IsValid - && mFile.Extension != ".srt" - && mFile.Extension != ".sub" + + if (mFile.IsValid + && mFile.Extension != ".srt" + && mFile.Extension != ".sub" && mFile.Extension != ".idx" && mFile.Extension != ".ssa" ) { - + bool duplicate = false; foreach(MediaFile mf in InputFiles){ if (mf.Path == mFile.Path){ @@ -566,7 +566,7 @@ break; } } - + if (duplicate) { return true; //not an error since file is already added @@ -580,36 +580,36 @@ else{ log_error (_("Unknown format:") + " '%s'".printf (mFile.Path)); } - + return false; } - + public void remove_files (Gee.ArrayList file_list){ foreach(MediaFile mf in file_list){ InputFiles.remove (mf); log_msg (_("File removed:") + " '%s'".printf (mf.Path)); } } - + public void remove_all(){ InputFiles.clear(); log_msg (_("All files removed")); } //conversion - + public void convert_begin(){ //check for empty list if (InputFiles.size == 0){ log_error (_("Input queue is empty! Please add some files.")); return; } - + log_msg (_("Starting batch of %d file(s):").printf(InputFiles.size), true); - + //check and create output dir - if (OutputDirectory.length > 0) { - create_dir (OutputDirectory); + if (OutputDirectory.length > 0) { + create_dir (OutputDirectory); log_msg (_("Files will be saved in '%s'").printf(OutputDirectory)); } else{ @@ -617,32 +617,32 @@ } //check and create backup dir - if (BackupDirectory.length > 0) { - create_dir (BackupDirectory); + if (BackupDirectory.length > 0) { + create_dir (BackupDirectory); log_msg (_("Source files will be moved to '%s'").printf(BackupDirectory)); - } - + } + //initialize batch control variables BatchStarted = true; BatchCompleted = false; Aborted = false; Status = AppStatus.RUNNING; - + //initialize file status foreach (MediaFile mf in InputFiles) { mf.Status = FileStatus.PENDING; mf.ProgressText = _("Queued"); mf.ProgressPercent = 0; } - + //if(ConsoleMode) //progressTimerID = Timeout.add(500, update_progress); - + //save config and begin save_config(); convert_next(); } - + private void convert_next(){ try { Thread.create(convert_next_thread, true); @@ -653,7 +653,7 @@ private void convert_next_thread(){ MediaFile nextFile = null; - + //find next pending file foreach (MediaFile mf in InputFiles) { if (mf.Status == FileStatus.PENDING){ @@ -661,7 +661,7 @@ break; } } - + //encode the file if (!Aborted && nextFile != null){ convert_file(nextFile); @@ -669,7 +669,7 @@ } else{ Status = AppStatus.IDLE; - + //handle shutdown for console mode if (ConsoleMode){ if (Shutdown){ @@ -681,19 +681,19 @@ //exit app for console mode exit_app(); } - + //shutdown will be handled by GUI window for GUI-mode } } - - public void convert_finish(){ + + public void convert_finish(){ //reset file status foreach(MediaFile mf in InputFiles) { mf.Status = FileStatus.PENDING; mf.ProgressText = _("Queued"); mf.ProgressPercent = 0; } - + //if (ConsoleMode) //Source.remove (progressTimerID); @@ -703,24 +703,24 @@ Aborted = false; Status = AppStatus.NOTSTARTED; } - + private bool convert_file (MediaFile mf){ bool is_success = false; - - if (file_exists (mf.Path) == false) { + + if (file_exists (mf.Path) == false) { mf.Status = FileStatus.ERROR; mf.ProgressText = _("Error: File missing"); mf.ProgressPercent = 0; return false; } - + //prepare file CurrentFile = mf; - CurrentFile.prepare (TempDirectory); + CurrentFile.prepare (TempDirectory); CurrentFile.Status = FileStatus.RUNNING; CurrentFile.ProgressText = null; // (not set) show value as percent CurrentFile.ProgressPercent = 0; - + log_msg (_("Source:") + " '%s'".printf(CurrentFile.Path), true); if ((CurrentFile.SubFile != null) && (CurrentFile.SubFile.length > 0)){ log_msg ((mf.HasVideo) ? _("Subtitles:") : _("Lyrics:") + " '%s'".printf(CurrentFile.SubName)); @@ -728,11 +728,11 @@ else{ log_msg ((mf.HasVideo) ? _("Subtitles:") : _("Lyrics:") + " None"); } - + Progress = 0; StatusLine = ""; CurrentLine = ""; - + //convert file string scriptText = build_script (CurrentFile); string scriptPath = save_script (CurrentFile, scriptText); @@ -749,14 +749,14 @@ return is_success; } - + private string build_script (MediaFile mf){ var script = new StringBuilder(); script.append ("#!/bin/bash\n"); script.append ("\n"); - + // insert variables ----------------- - + script.append ("tempDir='" + escape (mf.TempDirectory) + "'\n"); script.append ("inDir='" + escape (mf.Location) + "'\n"); if (OutputDirectory.length == 0){ @@ -774,7 +774,7 @@ script.append ("hasAudio=" + (mf.HasAudio ? "1" : "0") + "\n"); script.append ("hasVideo=" + (mf.HasVideo ? "1" : "0") + "\n"); script.append ("\n"); - + if (mf.HasAudio){ script.append ("tagTitle='" + escape(mf.TrackName) + "'\n"); script.append ("tagTrackNum='" + escape(mf.TrackNumber) + "'\n"); @@ -785,7 +785,7 @@ script.append ("tagComment='" + escape(mf.Comment) + "'\n"); script.append ("\n"); } - + if (mf.SubFile != null){ script.append ("subFile='" + escape (mf.SubFile) + "'\n"); script.append ("subName='" + escape (mf.SubName) + "'\n"); @@ -800,7 +800,7 @@ script.append ("""scriptDir="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )""""); script.append ("\n"); script.append ("cd \"$scriptDir\"\n"); - + if (SelectedScript.Extension == ".sh") { // read and modify script template --------------- @@ -817,11 +817,11 @@ Regex rxCrop_f2t_right = new Regex ("""ffmpeg2theora.*(--cropright [0-9]+) """); Regex rxCrop_f2t_top = new Regex ("""ffmpeg2theora.*(--croptop [0-9]+) """); Regex rxCrop_f2t_bottom = new Regex ("""ffmpeg2theora.*(--cropbottom [0-9]+) """); - + string line = dis.read_line (null); while (line != null) { line = line.replace ("${audiodec}", """avconv -i "${inFile}" -f wav -acodec pcm_s16le -vn -y -"""); - + if (mf.crop_enabled()){ if (rxCrop_libav.match (line, 0, out match)){ line = line.replace (match.fetch(1), "crop=" + mf.crop_values_libav()); @@ -863,20 +863,20 @@ var config = node.get_object(); script.append (get_preset_commandline (mf, config)); - + //copy preset to temp folder for debugging copy_file(SelectedScript.Path, mf.TempDirectory + "/preset.json"); } - + script.append ("exitCode=$?\n"); script.append ("echo ${exitCode} > ${exitCode}\n"); return script.str; } - + private string escape (string txt){ return txt.replace ("'","'\\''"); } - + private string save_script (MediaFile mf, string scriptText){ try{ // create new script file @@ -888,35 +888,35 @@ // set execute permission chmod (mf.TempScriptFile, "u+x"); - } + } catch (Error e) { log_error (e.message); return ""; } - + return mf.TempScriptFile; } private bool run_script (MediaFile mf, string scriptFile){ bool retVal = true; - + if (ConsoleMode) log_msg (_("Converting: Enter (q) to quit or (p) to pause...")); else log_msg (_("Converting...")); - + string[] argv = new string[1]; argv[0] = scriptFile; - + Pid child_pid; int input_fd; int output_fd; int error_fd; try { - + //execute script file --------------------- - + Process.spawn_async_with_pipes( null, //working dir argv, //argv @@ -927,11 +927,11 @@ out input_fd, out output_fd, out error_fd); - + procID = child_pid; - + set_priority(); - + //create stream readers UnixInputStream uisOut = new UnixInputStream(output_fd, false); UnixInputStream uisErr = new UnixInputStream(error_fd, false); @@ -939,36 +939,36 @@ disErr = new DataInputStream(uisErr); disOut.newline_type = DataStreamNewlineType.ANY; disErr.newline_type = DataStreamNewlineType.ANY; - + //create log file var file = File.new_for_path (mf.LogFile); var file_stream = file.create (FileCreateFlags.REPLACE_DESTINATION); dsLog = new DataOutputStream (file_stream); - + //start another thread for reading error stream - + try { Thread.create (read_std_err, true); } catch (Error e) { log_error (e.message); } - - //start reading output stream in current thread + + //start reading output stream in current thread outLine = disOut.read_line (null); while (outLine != null) { update_progress (outLine.strip()); outLine = disOut.read_line (null); } - + Thread.usleep ((ulong) 0.1 * 1000000); dsLog.close(); - + } catch (Error e) { log_error (e.message); retVal = false; - } - + } + if (ConsoleMode){ //remove the last status line stdout.printf ("\r%s\r", blankLine); @@ -976,10 +976,10 @@ return retVal; } - + private bool check_status (MediaFile mf){ bool retVal = false; - + if (file_exists (mf.TempDirectory + "/0")) { mf.Status = FileStatus.SUCCESS; mf.ProgressText = _("Done"); @@ -995,7 +995,7 @@ mf.ProgressText = _("Error"); mf.ProgressPercent = 0; retVal = false; - + if (ShowNotificationPopups){ notify_send (_("Completed"), mf.Name, 2000, "low", "warning"); } @@ -1010,10 +1010,10 @@ else if (mf.Status == FileStatus.ERROR) { log_msg (_("Failed")); } - + return retVal; } - + private void read_std_err(){ try{ errLine = disErr.read_line (null); @@ -1024,28 +1024,28 @@ } catch (Error e) { log_error (e.message); - } + } } - - public bool update_progress (string line){ + + public bool update_progress (string line){ tempLine = line; if ((tempLine == null)||(tempLine.length == 0)){ return true; } if (tempLine.index_of ("overread, skip") != -1){ return true; } if (tempLine.index_of ("Last message repeated") != -1){ return true; } if (tempLine.index_of ("Converting:") != -1){ return true; } //mkvmerge - + if (regex_libav.match (tempLine, 0, out match)){ - + if (match.fetch(1).contains(":")){ dblVal = parse_time(match.fetch(1)); } else{ dblVal = double.parse(match.fetch(1)); } - + Progress = (dblVal * 1000) / CurrentFile.Duration; - + if (regex_libav_video.match (tempLine, 0, out match)){ StatusLine = "(avconv) %s fps, %s kbps, %s kb".printf(match.fetch(1), match.fetch(3), match.fetch(2)); } @@ -1059,13 +1059,13 @@ else if (regex_x264.match (tempLine, 0, out match)){ dblVal = double.parse(match.fetch(1)); Progress = dblVal / CurrentFile.OutputFrameCount; - + StatusLine = "%s fps, %s kbps".printf(match.fetch(2), match.fetch(3)); } else if (regex_ffmpeg2theora.match (tempLine, 0, out match)){ dblVal = parse_time (match.fetch(1)); Progress = (dblVal * 1000) / CurrentFile.Duration; - + if (regex_ffmpeg2theora2.match (tempLine, 0, out match)){ StatusLine = "(ffmpeg2theora) %s+%s kbps, %s mb, eta %s".printf(match.fetch(2), match.fetch(3), match.fetch(5), match.fetch(4)); } @@ -1116,14 +1116,14 @@ log_error (e.message); } } - + if (Progress < 1) { CurrentFile.ProgressPercent = (int)(Progress * 100); } else{ CurrentFile.ProgressPercent = 100; } - + if (ConsoleMode){ stdout.printf ("\r%s\r", blankLine[0:78]); if (Status == AppStatus.RUNNING){ @@ -1134,85 +1134,85 @@ } stdout.flush(); } - + return true; } - + public void stop_batch(){ // we need to un-freeze the processes before we kill it if (Status == AppStatus.PAUSED){ - resume(); + resume(); } - + Aborted = true; for(int k = InputFiles.index_of(CurrentFile); k < InputFiles.size; k++) { MediaFile mf = InputFiles[k]; mf.ProgressText = _("Cancelled"); } - + process_kill (procID); } - + public void stop_file(){ // we need to un-freeze the processes before we kill them if (Status == AppStatus.PAUSED){ - resume(); + resume(); } - + // Aborted = true; //Do not set Abort flag CurrentFile.Status = FileStatus.SKIPPED; CurrentFile.ProgressText = _("Cancelled"); process_kill (procID); } - + public void pause(){ Pid childPid; foreach (long pid in get_process_children (procID)){ childPid = (Pid) pid; process_pause (childPid); } - + Status = AppStatus.PAUSED; CurrentFile.ProgressText = _("Paused"); - + if (ConsoleMode) log_msg (_("Paused: Enter (r) to resume...")); else log_msg (_("Paused")); } - + public void resume(){ Pid childPid; foreach (long pid in get_process_children (procID)){ childPid = (Pid) pid; process_resume (childPid); } - + Status = AppStatus.RUNNING; CurrentFile.ProgressText = null; - + if (ConsoleMode) log_msg (_("Converting: Enter (q) to quit or (p) to pause...")); else log_msg (_("Converting...")); } - + public void set_priority(){ int prio = 0; if (BackgroundMode) { prio = 5; } - + Pid appPid = Posix.getpid(); process_set_priority (appPid, prio); - + if (Status == AppStatus.RUNNING){ process_set_priority (procID, prio); - + Pid childPid; foreach (long pid in get_process_children (procID)){ childPid = (Pid) pid; - + if (BackgroundMode) process_set_priority (childPid, prio); else @@ -1225,23 +1225,23 @@ shutdown(); return true; } - + //create command string - + private string get_preset_commandline (MediaFile mf, Json.Object settings, out Gee.ArrayList? encoderList = null){ string s = ""; - + //this list is used for returning the list of encoders that is used by the preset encoderList = new Gee.ArrayList(); - + Json.Object general = (Json.Object) settings.get_object_member("general"); Json.Object video = (Json.Object) settings.get_object_member("video"); Json.Object audio = (Json.Object) settings.get_object_member("audio"); //Json.Object subs = (Json.Object) settings.get_object_member("subtitle"); - + //insert temporary file names ------------ - + s += "\n"; s += "outputFile=\"${outDir}/${title}" + general.get_string_member("extension") + "\"\n"; if (mf.HasVideo && video.get_string_member("codec") != "disable"){ @@ -1264,13 +1264,13 @@ } } s += "\n"; - + //create command line -------------- - + string format = general.get_string_member("format"); string acodec = audio.get_string_member("codec"); string vcodec = video.get_string_member("codec"); - + switch (format){ case "mkv": case "mp4v": @@ -1288,7 +1288,7 @@ encoderList.add("avconv"); break; } - + //encode audio if (mf.HasAudio && acodec != "disable") { switch (acodec) { @@ -1315,7 +1315,7 @@ break; } } - + //mux audio, video and subs switch (format){ case "mkv": @@ -1348,12 +1348,12 @@ break; } break; - + case "ogv": s += encode_video_ffmpeg2theora(mf,settings); encoderList.add("ffmpeg2theora"); break; - + case "mp3": s += encode_audio_mp3lame(mf,settings); encoderList.add("lame"); @@ -1361,7 +1361,7 @@ encoderList.add("sox"); }; break; - + case "mp4a": s += encode_audio_neroaac(mf,settings); encoderList.add("neroaacenc"); @@ -1369,7 +1369,7 @@ encoderList.add("sox"); }; break; - + case "opus": s += encode_audio_opus(mf,settings); encoderList.add("opusenc"); @@ -1377,7 +1377,7 @@ encoderList.add("sox"); }; break; - + case "ogg": s += encode_audio_oggenc(mf,settings); encoderList.add("oggenc"); @@ -1396,9 +1396,9 @@ }; break; } - + s += "\n"; - + //set output file path string outpath = ""; if (OutputDirectory.length == 0){ @@ -1407,13 +1407,13 @@ outpath = OutputDirectory; } mf.OutputFilePath = outpath + "/" + mf.Title + general.get_string_member("extension") ; - + return s; } public Gee.ArrayList get_encoder_list(){ var encoderList = new Gee.ArrayList(); - + if (SelectedScript.Extension == ".json") { var parser = new Json.Parser(); try{ @@ -1423,37 +1423,37 @@ } var node = parser.get_root(); var config = node.get_object(); - + get_preset_commandline(InputFiles[0], config, out encoderList); } return encoderList; } - + private string encode_video_x264 (MediaFile mf, Json.Object settings){ string s = ""; - + //Json.Object general = (Json.Object) settings.get_object_member("general"); Json.Object video = (Json.Object) settings.get_object_member("video"); //Json.Object audio = (Json.Object) settings.get_object_member("audio"); string vcodec = video.get_string_member("codec"); - + bool usePiping = true; /* Note: If x264 is compiled without lavf or ffms support then * piping is required. Since this is the most common case, * we will always use piping to ensure that encoding does not fail. * */ - + if (usePiping) { s += decode_video_avconv(mf,settings,true,true,false,false); - - /* Note: + + /* Note: * Resampling with be done by ffmpeg since x264 does not provide this option. * Cropping and scaling will be done by x264 since it provides extra options such as resizing method. * */ } - + switch(vcodec){ case "x264": s += "x264"; @@ -1462,18 +1462,18 @@ s += "x265"; break; } - - + + if (video.get_string_member("mode") == "2pass"){ - s += " --pass {passNumber}"; + s += " --pass {passNumber}"; } - + s += " --preset " + video.get_string_member("preset"); - + if (video.get_string_member("profile").length > 0){ s += " --profile " + video.get_string_member("profile"); } - + switch(video.get_string_member("mode")){ case "vbr": s += " --crf " + video.get_string_member("quality"); @@ -1483,11 +1483,11 @@ s += " --bitrate " + video.get_string_member("bitrate"); break; } - + // filters ---------- - + string vf = ""; - + //cropping if (mf.crop_enabled()) { vf += "/crop:" + mf.crop_values_x264(); @@ -1500,28 +1500,28 @@ string method = video.get_string_member("resizingMethod"); vf += "/resize:width=%d,height=%d,method=%s".printf(w,h,method); } - + if (vf.length > 0){ s += " --vf " + vf[1:vf.length]; } - + //other options if (video.get_string_member("options").strip() != "") { s += " " + video.get_string_member("options").strip(); } - + //add output file path placeholder s += " -o {outputFile}"; - + /* Note: For x264, output is always written to tempVideo and then muxed into outputFile */ - + if (usePiping) { //encode from stdin s += " -"; - + //specify source dimensions s += " --input-res %dx%d".printf(mf.SourceWidth, mf.SourceHeight); - + //specify source FPS int fpsNum = int.parse(video.get_string_member("fpsNum")); int fpsDenom = int.parse(video.get_string_member("fpsDenom")); @@ -1531,7 +1531,7 @@ else{ s += " --fps %.0lf/1000".printf(mf.SourceFrameRate * 1000); } - + } else { //encode from input file @@ -1539,7 +1539,7 @@ } s += "\n"; - + if (video.get_string_member("mode") == "2pass"){ string temp = s.replace("{passNumber}","1").replace("{outputFile}","/dev/null"); temp += s.replace("{passNumber}","2").replace("{outputFile}","\"${tempVideo}\""); @@ -1548,18 +1548,18 @@ else{ s = s.replace("{outputFile}","\"${tempVideo}\""); } - + return s; } - + private string encode_video_ffmpeg2theora (MediaFile mf, Json.Object settings){ string s = ""; - + //Json.Object general = (Json.Object) settings.get_object_member("general"); Json.Object video = (Json.Object) settings.get_object_member("video"); Json.Object audio = (Json.Object) settings.get_object_member("audio"); Json.Object subs = (Json.Object) settings.get_object_member("subtitle"); - + s += "ffmpeg2theora"; s += " \"${inFile}\""; @@ -1574,7 +1574,7 @@ s += " --two-pass --videobitrate " + video.get_string_member("bitrate"); break; } - + //cropping if (mf.crop_enabled()) { s += " --croptop %d --cropbottom %d --cropleft %d --cropright %d".printf(mf.CropT,mf.CropB,mf.CropL,mf.CropR); @@ -1586,7 +1586,7 @@ if (rescale) { s += " --width %d --height %d".printf(w,h); } - + //fps int fpsNum = int.parse(video.get_string_member("fpsNum")); int fpsDenom = int.parse(video.get_string_member("fpsDenom")); @@ -1594,7 +1594,7 @@ s += " --framerate %d/%d".printf(fpsNum,fpsDenom); mf.OutputFrameCount = (long) Math.floor((mf.Duration / 1000.0) * ((float)fpsNum/fpsDenom)); } - + //audio if (mf.HasAudio && audio.get_string_member("codec") != "disable") { //mode @@ -1622,7 +1622,7 @@ else { s += " --noaudio"; } - + //subs if (subs.get_string_member("mode") == "embed") { if (mf.SubExt == ".srt"){ @@ -1632,37 +1632,37 @@ else { s += " --nosubtitles"; } - + //other options if (video.get_string_member("options").strip() != "") { s += " " + video.get_string_member("options").strip(); } - + s += " --output \"${outputFile}\""; s += "\n"; return s; } - + /* private string encode_video_avconv (MediaFile mf, Json.Object settings) { string s = ""; - + Json.Object general = (Json.Object) settings.get_object_member("general"); Json.Object video = (Json.Object) settings.get_object_member("video"); //Json.Object audio = (Json.Object) settings.get_object_member("audio"); - + s += "avconv"; s += " -i \"${inFile}\""; s += " -f " + general.get_string_member("format"); s += " -an -sn -c:v libvpx"; if (video.get_string_member("mode") == "2pass"){ - s += " -pass {passNumber}"; + s += " -pass {passNumber}"; } - + string kbps = video.get_string_member("bitrate"); switch(video.get_string_member("mode")){ case "vbr": @@ -1676,18 +1676,18 @@ s += " -crf %s".printf(video.get_string_member("quality")); break; } - + s += " -deadline " + video.get_string_member("speed"); - + // filters ---------- - + //fps if (video.get_string_member("fpsNum") != "0" && video.get_string_member("fpsDenom") != "0") { s += " -r " + video.get_string_member("fpsNum") + "/" + video.get_string_member("fpsDenom"); } - + string vf = ""; - + //cropping if (mf.crop_enabled()) { vf += ",crop=%s".printf(mf.crop_values_libav()); @@ -1703,19 +1703,19 @@ if (vf.length > 0){ s += " -vf " + vf[1:vf.length]; } - + //--------------- - + //other options if (video.get_string_member("options").strip() != "") { s += " " + video.get_string_member("options").strip(); } - + //add output file path placeholder s += " -y {outputFile}"; - + s += "\n"; - + if (video.get_string_member("mode") == "2pass"){ string temp = s.replace("{passNumber}","1").replace("{outputFile}","/dev/null"); temp += s.replace("{passNumber}","2").replace("{outputFile}","\"${tempVideo}\""); @@ -1725,7 +1725,7 @@ { s = s.replace("{outputFile}","\"${tempVideo}\""); } - + return s; } */ @@ -1733,23 +1733,23 @@ /* * private string encode_video_vpxenc (MediaFile mf, Json.Object settings){ string s = ""; - + //Json.Object general = (Json.Object) settings.get_object_member("general"); Json.Object video = (Json.Object) settings.get_object_member("video"); //Json.Object audio = (Json.Object) settings.get_object_member("audio"); string vcodec = video.get_string_member("codec"); - + s += decode_video_avconv(mf,settings,true); s += "vpxenc"; s += " --codec=" + vcodec; - + if (video.get_string_member("mode") == "2pass"){ - s += " --passes=2 --pass={passNumber} --fpf=stats"; + s += " --passes=2 --pass={passNumber} --fpf=stats"; } else{ s += " --passes=1"; } - + string vquality = "%.0f".printf(double.parse(video.get_string_member("quality"))); switch(video.get_string_member("mode")){ case "vbr": @@ -1763,7 +1763,7 @@ s += " --end-usage=cq --cq-level=" + vquality; break; } - + s += " --good"; switch(video.get_string_member("speed")){ case "good_0": @@ -1787,25 +1787,25 @@ } //--------------- - + //other options if (video.get_string_member("options").strip() != "") { s += " " + video.get_string_member("options").strip(); } - + //specify input dimensions (required) int w,h; calculate_video_resolution(mf, settings, out w, out h); s += " --width=%d --height=%d".printf(w,h); - + //output s += " -o {outputFile}"; - + //input s += " -"; s += "\n"; - + if (video.get_string_member("mode") == "2pass"){ string temp = s.replace("{passNumber}","1").replace("{outputFile}","/dev/null"); temp += s.replace("{passNumber}","2").replace("{outputFile}","\"${tempVideo}\""); @@ -1815,23 +1815,23 @@ { s = s.replace("{outputFile}","\"${tempVideo}\""); } - + return s; }*/ - + private string encode_video_avconv (MediaFile mf, Json.Object settings){ string s = ""; - + Json.Object general = (Json.Object) settings.get_object_member("general"); Json.Object video = (Json.Object) settings.get_object_member("video"); //Json.Object audio = (Json.Object) settings.get_object_member("audio"); string vcodec = video.get_string_member("codec"); string format = general.get_string_member("format"); - + s += "avconv"; s += " -i \"${inFile}\""; s += " -f " + format; - + switch(vcodec){ case "vp8": s += " -c:v libvpx"; @@ -1842,7 +1842,7 @@ } if (video.get_string_member("mode") == "2pass"){ - s += " -pass {passNumber}"; + s += " -pass {passNumber}"; } string vquality = "%.0f".printf(double.parse(video.get_string_member("quality"))); @@ -1862,7 +1862,7 @@ s += " -qmax " + vquality; break; } - + switch(vcodec){ case "vp8": case "vp9": @@ -1882,23 +1882,23 @@ } //--------------- - + //user options if (video.get_string_member("options").strip() != "") { s += " " + video.get_string_member("options").strip(); } - + //resample, crop and resize s += avconv_vf_options(mf,settings); - + //disable audio and subs s += " -an -sn"; - + //output s += " -y {outputFile}"; //no quotes - + s += "\n"; - + if (video.get_string_member("mode") == "2pass"){ string temp = s.replace("{passNumber}","1").replace("{outputFile}","/dev/null"); temp += s.replace("{passNumber}","2").replace("{outputFile}","\"${tempVideo}\""); @@ -1908,36 +1908,36 @@ { s = s.replace("{outputFile}","\"${tempVideo}\""); } - + return s; } - + private bool calculate_video_resolution (MediaFile mf, Json.Object settings, out int OutputWidth, out int OutputHeight){ bool rescale = false; - + OutputWidth = mf.SourceWidth; OutputHeight = mf.SourceHeight; - + Json.Object video = (Json.Object) settings.get_object_member("video"); - + if (mf.crop_enabled()){ OutputWidth -= (mf.CropL + mf.CropR); OutputHeight -= (mf.CropT + mf.CropB); log_msg("Cropped: %.0fx%.0f".printf(OutputWidth,OutputHeight)); } - + int maxw = int.parse(video.get_string_member("frameWidth")); int maxh = int.parse(video.get_string_member("frameHeight")); double iw = OutputWidth; double ow = iw; double ih = OutputHeight; double oh = ih; - + //flags for checking if resizing is actually required bool noResize = false; bool isUpscale = false; bool isSameSize = false; - + if (maxw == 0 && maxh == 0) { //do nothing noResize = true; @@ -1965,14 +1965,14 @@ } else { log_msg("FitToBox is enabled"); - + //fit height if (maxh > 0) { if (oh > maxh) { oh = maxh; } ow = oh * (iw / ih); ow = Math.floor(ow); ow = ow - (ow % 4); - + log_msg("Fit width: %.0f".printf(ow)); rescale = true; } @@ -1997,12 +1997,12 @@ isUpscale = true; } } - + //check if final size is same as original size if ((ow == OutputWidth)&&(oh == OutputHeight)) { isSameSize = true; } - + if (noResize || isUpscale || isSameSize) { //do not resize return false; @@ -2015,14 +2015,14 @@ return true; } } - + private string encode_audio_mp3lame (MediaFile mf, Json.Object settings){ string s = ""; - + //Json.Object general = (Json.Object) settings.get_object_member("general"); Json.Object video = (Json.Object) settings.get_object_member("video"); Json.Object audio = (Json.Object) settings.get_object_member("audio"); - + s += decode_audio_avconv(mf, settings, false); s += "lame --nohist --brief -q 5 --replaygain-fast"; switch (audio.get_string_member("mode")){ @@ -2057,17 +2057,17 @@ s += " \"${outputFile}\""; } s += "\n"; - + return s; } - + private string encode_audio_neroaac (MediaFile mf, Json.Object settings){ string s = ""; - + //Json.Object general = (Json.Object) settings.get_object_member("general"); Json.Object video = (Json.Object) settings.get_object_member("video"); Json.Object audio = (Json.Object) settings.get_object_member("audio"); - + s += decode_audio_avconv(mf, settings, false); s += "neroAacEnc -ignorelength"; switch (audio.get_string_member("mode")){ @@ -2091,7 +2091,7 @@ s += " -of \"${outputFile}\""; } s += "\n"; - + //add tags string tags = ""; string path = get_cmd_path ("neroAacTag"); @@ -2113,17 +2113,17 @@ return s; } - + private string encode_audio_opus (MediaFile mf, Json.Object settings){ string s = ""; - + //Json.Object general = (Json.Object) settings.get_object_member("general"); Json.Object video = (Json.Object) settings.get_object_member("video"); Json.Object audio = (Json.Object) settings.get_object_member("audio"); - + s += decode_audio_avconv(mf, settings, true); s += "opusenc"; - + //tags s += (mf.TrackName.length > 0) ? " --title \"${tagTitle}\"" : ""; s += (mf.TrackNumber.length > 0) ? " --comment=\"track=${tagTrackNum}\"" : ""; @@ -2131,8 +2131,8 @@ s += (mf.Album.length > 0) ? " --comment=\"album=${tagAlbum}\"" : ""; s += (mf.Genre.length > 0) ? " --comment=\"genre=${tagGenre}\"" : ""; s += (mf.RecordedDate.length > 0) ? " --comment=\"year=${tagYear}\"" : ""; - s += (mf.Comment.length > 0) ? " --comment=\"comment=${tagComment}\"" : ""; - + s += (mf.Comment.length > 0) ? " --comment=\"comment=${tagComment}\"" : ""; + //options s += " --bitrate " + audio.get_string_member("bitrate"); switch (audio.get_string_member("mode")){ @@ -2146,7 +2146,7 @@ s += " --hard-cbr"; break; } - + switch (audio.get_string_member("opusOptimize")){ case "none": //do nothing @@ -2158,10 +2158,10 @@ s += " --music"; break; } - + //input s += " -"; - + //output if (mf.HasVideo && video.get_string_member("codec") != "disable") { //encode to tempAudio @@ -2172,20 +2172,20 @@ s += " \"${outputFile}\""; } s += "\n"; - + return s; } - + private string encode_audio_avconv (MediaFile mf, Json.Object settings){ string s = ""; - + Json.Object general = (Json.Object) settings.get_object_member("general"); //Json.Object video = (Json.Object) settings.get_object_member("video"); Json.Object audio = (Json.Object) settings.get_object_member("audio"); string format = general.get_string_member("format"); bool sox_enabled = audio.get_boolean_member("soxEnabled"); - + if (sox_enabled){ s += decode_audio_avconv(mf, settings, true); s += "avconv"; @@ -2209,7 +2209,7 @@ s += " -acodec " + audio.get_string_member("codec"); break; } - + //channels string channels = audio.get_string_member("channels"); if (channels != "disable"){ @@ -2229,26 +2229,26 @@ s += (mf.Album.length > 0) ? " -metadata 'album'=\"${tagAlbum}\"" : ""; s += (mf.Genre.length > 0) ? " -metadata 'genre'=\"${tagGenre}\"" : ""; s += (mf.RecordedDate.length > 0) ? " -metadata 'year'=\"${tagYear}\"" : ""; - s += (mf.Comment.length > 0) ? " -metadata 'comment'=\"${tagComment}\"" : ""; - + s += (mf.Comment.length > 0) ? " -metadata 'comment'=\"${tagComment}\"" : ""; + s += " -vn -sn"; s += " -y \"${outputFile}\""; - + return s; } - + private string encode_audio_oggenc (MediaFile mf, Json.Object settings){ string s = ""; - + //Json.Object general = (Json.Object) settings.get_object_member("general"); Json.Object video = (Json.Object) settings.get_object_member("video"); Json.Object audio = (Json.Object) settings.get_object_member("audio"); Json.Object subs = (Json.Object) settings.get_object_member("subtitle"); - + s += decode_audio_avconv(mf, settings, false); s += "oggenc --quiet"; - + //mode switch (audio.get_string_member("mode")){ case "vbr": @@ -2258,7 +2258,7 @@ s += " --quality " + audio.get_string_member("quality"); break; } - + //tags s += (mf.TrackName.length > 0) ? " --title \"${tagTitle}\"" : ""; s += (mf.TrackNumber.length > 0) ? " --comment=\"track=${tagTrackNum}\"" : ""; @@ -2267,7 +2267,7 @@ s += (mf.Genre.length > 0) ? " --genre \"${tagGenre}\"" : ""; s += (mf.RecordedDate.length > 0) ? " --date \"${tagYear}\"" : ""; s += (mf.Comment.length > 0) ? " --comment='comment=${tagComment}'" : ""; - + //subs if (subs.get_string_member("mode") == "embed") { if (mf.SubExt == ".srt" || mf.SubExt == ".lrc") { @@ -2284,50 +2284,50 @@ //encode to outputFile s += " --output \"${outputFile}\""; } - + //input s += " -"; - + s += "\n"; - + return s; } private string decode_video_avconv (MediaFile mf, Json.Object settings, bool silent, bool resample = true, bool crop = true, bool scale = true){ string s = ""; - + //Json.Object general = (Json.Object) settings.get_object_member("general"); //Json.Object video = (Json.Object) settings.get_object_member("video"); //Json.Object audio = (Json.Object) settings.get_object_member("audio"); //Json.Object subs = (Json.Object) settings.get_object_member("subtitle"); - + s += "avconv"; - + //progress info if (silent){ s += " -nostats"; } //input s += " -i \"${inFile}\""; - + //format s += " -copyinkf -f rawvideo -vcodec rawvideo -pix_fmt yuv420p"; //framerate, crop and resize s += avconv_vf_options(mf,settings, resample, crop, scale); - + //output s += " -an -sn -y - | "; - + return s; } - + private string avconv_vf_options (MediaFile mf, Json.Object settings, bool resample = true, bool crop = true, bool scale = true){ string s = ""; string vf = ""; - + Json.Object video = (Json.Object) settings.get_object_member("video"); - + //resample if (resample){ int fpsNum = int.parse(video.get_string_member("fpsNum")); @@ -2337,14 +2337,14 @@ mf.OutputFrameCount = (long)((mf.Duration / 1000.0) * ((float)fpsNum/fpsDenom)); } } - + //crop if (crop){ if (mf.crop_enabled()) { vf += ",crop=%s".printf(mf.crop_values_libav()); } } - + //scale if (scale){ int w,h; @@ -2357,19 +2357,19 @@ if (vf.length > 0){ s += " -vf " + vf[1:vf.length]; } - + return s; } - + private string decode_audio_avconv(MediaFile mf, Json.Object settings, bool silent){ string s = ""; - + Json.Object audio = (Json.Object) settings.get_object_member("audio"); string acodec = audio.get_string_member("codec"); bool sox_enabled = audio.get_boolean_member("soxEnabled"); - + s += "avconv"; - + //progress info if (silent){ s += " -nostats"; @@ -2377,14 +2377,14 @@ else{ s += " -stats"; } - + //input s += " -i \"${inFile}\""; - + //format s += " -f " + ((sox_enabled) ? "aiff" : "wav"); s += " -acodec pcm_s16le"; - + //channels string channels = audio.get_string_member("channels"); if (channels == "disable"){ @@ -2396,26 +2396,26 @@ else{ s += " -ac " + channels; } - + //sampling string sampling = audio.get_string_member("samplingRate"); if (sampling != "disable"){ s += " -ar " + sampling; } - + //output s += " -vn -y - | "; - + if (sox_enabled){ s += process_audio_sox(mf,settings); } - + return s; } private string process_audio_sox(MediaFile mf, Json.Object settings){ string s = ""; - + Json.Object audio = (Json.Object) settings.get_object_member("audio"); s += "sox"; @@ -2456,41 +2456,41 @@ if (sox_earwax){ s += " earwax"; } - + //pipe s += " | "; - + return s; } - + private string mux_mkvmerge (MediaFile mf, Json.Object settings){ string s = ""; - + Json.Object general = (Json.Object) settings.get_object_member("general"); //Json.Object video = (Json.Object) settings.get_object_member("video"); Json.Object audio = (Json.Object) settings.get_object_member("audio"); Json.Object subs = (Json.Object) settings.get_object_member("subtitle"); - + string format = general.get_string_member("format"); - + s += "mkvmerge"; - + //webm compliance if (format == "webm") { s += " --webm"; } - + //output s += " --output \"${outputFile}\""; - + //add video s += " --compression -1:none \"${tempVideo}\""; - + //add audio if (mf.HasAudio && audio.get_string_member("codec") != "disable") { s += " --compression -1:none \"${tempAudio}\""; } - + //add subs if (format != "webm") { if (subs.get_string_member("mode") == "embed") { @@ -2502,55 +2502,55 @@ else{ //WebM currently does not support subtitles } - + s += "\n"; - + return s; } - + private string mux_mp4box (MediaFile mf, Json.Object settings){ string s = ""; - + //Json.Object general = (Json.Object) settings.get_object_member("general"); //Json.Object video = (Json.Object) settings.get_object_member("video"); Json.Object audio = (Json.Object) settings.get_object_member("audio"); Json.Object subs = (Json.Object) settings.get_object_member("subtitle"); s += "MP4Box -new"; - + if (mf.HasAudio && audio.get_string_member("codec") != "disable") { s += " -add \"${tempAudio}\""; } - + s += " -add \"${tempVideo}\""; - + if (subs.get_string_member("mode") == "embed") { if (mf.SubExt == ".srt" || mf.SubExt == ".sub" || mf.SubExt == ".ttxt" || mf.SubExt == ".xml"){ s += " -add \"${subFile}\""; } } - + s += " \"${outputFile}\""; s += "\n"; - + return s; } - + private string mux_avconv (MediaFile mf, Json.Object settings) { string s = ""; - + Json.Object general = (Json.Object) settings.get_object_member("general"); //Json.Object video = (Json.Object) settings.get_object_member("video"); Json.Object audio = (Json.Object) settings.get_object_member("audio"); string format = general.get_string_member("format"); - + s += "avconv"; if (mf.HasAudio && audio.get_string_member("codec") != "disable") { s += " -i \"${tempAudio}\""; } s += " -i \"${tempVideo}\""; - + switch(format){ case "mp4v": s += " -f mp4"; @@ -2562,7 +2562,7 @@ s += " -c:a copy -c:v copy -sn"; s += " -y \"${outputFile}\""; s += "\n"; - + return s; } } @@ -2573,11 +2573,11 @@ public string Title; public string Extension; public string Location; - + public int64 Size = 0; public long Duration = 0; //in milliseconds public string ThumbnailImagePath = ""; - + public string SubFile = ""; public string SubName = ""; public string SubExt = ""; @@ -2589,7 +2589,7 @@ public string Genre = ""; public string RecordedDate = ""; public string Comment = ""; - + public int CropW = 0; public int CropH = 0; public int CropL = 0; @@ -2597,12 +2597,12 @@ public int CropT = 0; public int CropB = 0; public bool AutoCropError = false; - + public FileStatus Status = FileStatus.PENDING; public bool IsValid; public string ProgressText = _("Queued"); public int ProgressPercent = 0; - + public string InfoText; public bool HasAudio = false; public bool HasVideo = false; @@ -2611,7 +2611,7 @@ public int SourceHeight = 0; public double SourceFrameRate = 0; public int AudioChannels = 0; - + public string FileFormat = ""; public string VideoFormat = ""; public string AudioFormat = ""; @@ -2621,25 +2621,25 @@ public string LogFile = ""; public string OutputFilePath = ""; public long OutputFrameCount = 0; - + public MediaFile(string filePath){ IsValid = false; if (file_exists (filePath) == false) { return; } - + // set file properties ------------ - + File f = File.new_for_path (filePath); File fp = f.get_parent(); - + Path = filePath; Name = f.get_basename(); Title = Name[0: Name.last_index_of(".",0)]; Extension = Name[Name.last_index_of(".",0):Name.length]; Location = fp.get_path(); //stderr.printf(@"file=$filePath, name=$Name, title=$Title, ext=$Extension, dir=$Location\n"); - + FileInfo fi = null; - + try{ fi = f.query_info ("*", FileQueryInfoFlags.NONE, null); Size = fi.get_size(); @@ -2649,12 +2649,12 @@ } // get media information ---------- - + query_mediainfo(); if (Duration == 0) { return; } - + // search for subtitle files --------------- - + try{ var enumerator = fp.enumerate_children ("standard::*", 0); var fileInfo = enumerator.next_file(); @@ -2676,27 +2676,27 @@ catch(Error e){ log_error (e.message); } - - + + // get thumbnail --------- - + generate_thumbnail(); - + IsValid = true; } - + public void query_mediainfo(){ InfoText = get_mediainfo (Path); - + if (InfoText == null || InfoText == ""){ return; } - + string sectionType = ""; - + foreach (string line in InfoText.split ("\n")){ if (line == null || line.length == 0) { continue; } - + if (line.contains (":") == false) { if (line.contains ("Audio")){ @@ -2718,10 +2718,10 @@ else{ string[] arr = line.split (": "); if (arr.length != 2) { continue; } - + string key = arr[0].strip(); string val = arr[1].strip(); - + if (sectionType == "general"){ switch (key.down()) { case "duration": @@ -2794,7 +2794,7 @@ } } } - + public void prepare (string baseTempDir){ TempDirectory = baseTempDir + "/" + timestamp2() + " - " + Name; LogFile = TempDirectory + "/" + "log.txt"; @@ -2810,7 +2810,7 @@ OutputFrameCount = 0; } } - + public void generate_thumbnail(){ int imageWidth = 80; int imageHeight= 64; @@ -2818,13 +2818,13 @@ string std_out, std_err; execute_command_script_sync("avconv -ss 1 -i \"%s\" -y -f image2 -vframes 1 -r 1 -s %dx%d \"%s\"".printf(Path,imageWidth,imageHeight,ThumbnailImagePath), out std_out, out std_err); } - + public bool crop_detect(){ - if (HasVideo == false) { + if (HasVideo == false) { AutoCropError = true; - return false; + return false; } - + string params = get_file_crop_params (Path); string[] arr = params.split (":"); @@ -2834,10 +2834,10 @@ CropL = int.parse (arr[2]); CropT = int.parse (arr[3]); } - + CropR = SourceWidth - CropW - CropL; CropB = SourceHeight - CropH - CropT; - + if ((CropW == 0) && (CropH == 0)){ AutoCropError = true; return false; @@ -2845,14 +2845,14 @@ else return true; } - + public bool crop_enabled(){ if ((CropW == 0)&&(CropH == 0)&&(CropL == 0)&&(CropT == 0)) return false; else return true; } - + public void crop_reset(){ CropW = 0; CropH = 0; @@ -2870,25 +2870,25 @@ else return ""; } - + public string crop_values_libav(){ if (crop_enabled()) return "%i:%i:%i:%i".printf(CropW,CropH,CropL,CropT); else return "iw:ih:0:0"; - } - + } + public string crop_values_x264(){ if (crop_enabled()) return "%i,%i,%i,%i".printf(CropL,CropT,CropR,CropB); else return "0,0,0,0"; } - + public void preview_output(){ string output = ""; string error = ""; - + try { Process.spawn_command_line_sync("avplay -i \"%s\" -vf crop=%s".printf(Path, crop_values_libav()), out output, out error); } @@ -2901,7 +2901,7 @@ if(file_exists(Path)){ string output = ""; string error = ""; - + try { Process.spawn_command_line_sync("avplay -i \"%s\"".printf(Path), out output, out error); } @@ -2910,12 +2910,12 @@ } } } - + public void play_output(){ if(file_exists(OutputFilePath)){ string output = ""; string error = ""; - + try { Process.spawn_command_line_sync("avplay -i \"%s\"".printf(OutputFilePath), out output, out error); } @@ -2932,13 +2932,13 @@ public string Title; public string Extension; public string Folder; - + public ScriptFile(string filePath) { Path = filePath; Name = GLib.Path.get_basename (filePath); Folder = GLib.Path.get_dirname (filePath); - + int index = Name.index_of("."); if (index != -1){ Title = Name[0:Name.last_index_of(".")]; @@ -2956,13 +2956,13 @@ public string Name = ""; public string Description = ""; public bool IsAvailable = false; - + public Encoder(string cmd, string name, string desc){ Command = cmd; Name = name; Description = desc; } - + public bool CheckAvailability(){ bool available = false; string str = get_cmd_path (Command); diff -Nru selene-2.5.7~196~ubuntu15.04.1/src/MainWindow.vala selene-2.5.8~198~ubuntu15.04.1/src/MainWindow.vala --- selene-2.5.7~196~ubuntu15.04.1/src/MainWindow.vala 2015-08-14 22:16:18.000000000 +0000 +++ selene-2.5.8~198~ubuntu15.04.1/src/MainWindow.vala 2015-09-08 00:46:25.000000000 +0000 @@ -1,24 +1,24 @@ /* * MainWindow.vala - * + * * Copyright 2012 Tony George - * + * * This program 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. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. - * - * + * + * */ using Gtk; @@ -52,7 +52,7 @@ private ToggleToolButton btnBackground; private SeparatorToolItem separator1; private SeparatorToolItem separator2; - + //preset toolbar private Gtk.Toolbar toolbar2; private ToolButton btnAddPreset; @@ -73,7 +73,7 @@ private Gtk.Menu menuFile; private ImageMenuItem miFileInfo; private ImageMenuItem miFileInfoOutput; - private ImageMenuItem miFileSkip; + private ImageMenuItem miFileSkip; private Gtk.MenuItem miFileCropAuto; private Gtk.MenuItem miFileRemove; private Gtk.MenuItem miFilePreview; @@ -91,7 +91,7 @@ private TreeViewColumn colProgress; private TreeViewColumn colSpacer; private Grid gridConfig; - + private Regex regexGeneric; private Regex regexMkvMerge; private Regex regexFFmpeg; @@ -99,7 +99,7 @@ private Regex regexLibAV_video; private Regex regexLibAV_audio; private Regex regexX264; - + private string statusLine; private uint timerID = 0; private uint startupTimer = 0; @@ -112,14 +112,14 @@ private const Gtk.TargetEntry[] targets = { { "text/uri-list", 0, 0} }; - + // initialize window ----------------- - + public MainWindow() { set_window_title(); window_position = WindowPosition.CENTER; destroy.connect (Gtk.main_quit); - set_default_size (550, 20); + set_default_size (550, 20); icon = get_app_icon(16); Gtk.drag_dest_set (this,Gtk.DestDefaults.ALL, targets, Gdk.DragAction.COPY); @@ -131,26 +131,26 @@ //main toolbar init_main_toolbar(); - + //listview init_list_view(); refresh_list_view(); init_list_view_context_menu(); - + //presets init_preset_toolbar(); init_preset_dropdowns(); populate_script_folders(); select_script(); - + //statusbar init_statusbar(); statusbar_default_message(); - + //regex init_regular_expressions(); } - + public void init_main_toolbar(){ //toolbar toolbar = new Gtk.Toolbar(); @@ -172,14 +172,14 @@ btnRemoveFiles.clicked.connect (btnRemoveFiles_clicked); btnRemoveFiles.set_tooltip_text (_("Remove selected file(s)")); toolbar.add (btnRemoveFiles); - + //btnClearFiles btnClearFiles = new Gtk.ToolButton.from_stock ("gtk-clear"); btnClearFiles.is_important = true; btnClearFiles.clicked.connect (btnClearFiles_clicked); btnClearFiles.set_tooltip_text (_("Remove all file(s)")); toolbar.add (btnClearFiles); - + //separator separator1 = new Gtk.SeparatorToolItem(); toolbar.add(separator1); @@ -191,7 +191,7 @@ btnStart.clicked.connect (start); btnStart.set_tooltip_text (_("Start")); toolbar.add (btnStart); - + //btnPause btnPause = new Gtk.ToolButton.from_stock ("gtk-media-pause"); btnPause.is_important = true; @@ -200,7 +200,7 @@ btnPause.visible = false; btnPause.no_show_all = true; toolbar.add (btnPause); - + //btnStop btnStop = new Gtk.ToolButton.from_stock ("gtk-media-stop"); btnStop.is_important = true; @@ -209,7 +209,7 @@ btnStop.visible = false; btnStop.no_show_all = true; toolbar.add (btnStop); - + //btnFinish btnFinish = new Gtk.ToolButton.from_stock ("gtk-ok"); btnFinish.is_important = true; @@ -219,13 +219,13 @@ btnFinish.visible = false; btnFinish.no_show_all = true; toolbar.add (btnFinish); - + //separator separator2 = new Gtk.SeparatorToolItem(); separator2.set_draw (false); separator2.set_expand (true); toolbar.add (separator2); - + //btnAppSettings btnAppSettings = new Gtk.ToolButton.from_stock ("gtk-preferences"); btnAppSettings.clicked.connect (btnAppSettings_clicked); @@ -237,7 +237,7 @@ btnEncoders.clicked.connect (btnEncoders_clicked); btnEncoders.set_tooltip_text (_("Encoders")); toolbar.add (btnEncoders); - + //btn_donate btnDonate = new Gtk.ToolButton.from_stock ("gtk-dialog-info"); btnDonate.is_important = false; @@ -247,7 +247,7 @@ //toolbar.add(btnDonate); btnDonate.clicked.connect(btnDonation_clicked); - + //btnAbout btnAbout = new Gtk.ToolButton.from_stock ("gtk-about"); btnAbout.is_important = false; @@ -255,7 +255,7 @@ btnAbout.clicked.connect (btnAbout_clicked); btnAbout.set_tooltip_text (_("About")); toolbar.add (btnAbout); - + //btnShutdown btnShutdown = new Gtk.ToggleToolButton.from_stock ("gtk-quit"); btnShutdown.label = _("Shutdown"); @@ -265,7 +265,7 @@ btnShutdown.clicked.connect (btnShutdown_clicked); btnShutdown.set_tooltip_text (_("Shutdown system after completion")); toolbar.add (btnShutdown); - + //btnBackground btnBackground = new Gtk.ToggleToolButton.from_stock ("gtk-sort-ascending"); btnBackground.label = _("Background"); @@ -275,7 +275,7 @@ btnBackground.clicked.connect (btnBackground_clicked); btnBackground.set_tooltip_text (_("Run processes with lower priority")); toolbar.add (btnBackground); - + //btnOpenOutputFolder btnOpenOutputFolder = new Gtk.ToolButton.from_stock ("gtk-directory"); //btnOpenOutputFolder.is_important = true; @@ -286,7 +286,7 @@ btnOpenOutputFolder.no_show_all = true; toolbar.add (btnOpenOutputFolder); } - + public void init_list_view(){ //tvFiles tvFiles = new TreeView(); @@ -306,13 +306,13 @@ colName = new TreeViewColumn(); colName.title = _("File"); colName.expand = true; - + CellRendererPixbuf cellThumb = new CellRendererPixbuf (); colName.pack_start (cellThumb, false); CellRendererText cellSpacer = new CellRendererText(); colName.pack_start (cellSpacer, false); - + CellRendererText cellName = new CellRendererText(); cellName.ellipsize = Pango.EllipsizeMode.END; colName.pack_start (cellName, false); @@ -320,7 +320,7 @@ colName.set_cell_data_func (cellThumb, (cell_layout, cell, model, iter)=>{ string imagePath; model.get (iter, InputField.FILE_THUMB, out imagePath, -1); - + Gdk.Pixbuf pixThumb = null; try{ pixThumb = new Gdk.Pixbuf.from_file (imagePath); @@ -328,7 +328,7 @@ catch(Error e){ log_error (e.message); } - + if (App.TileView){ (cell as Gtk.CellRendererPixbuf).pixbuf = pixThumb; } @@ -336,7 +336,7 @@ (cell as Gtk.CellRendererPixbuf).pixbuf = null; } }); - + colName.set_cell_data_func (cellName, (cell_layout, cell, model, iter)=>{ string fileName, fileSize, duration, formatInfo, spanStart, spanEnd; MediaFile mf; @@ -344,15 +344,15 @@ model.get (iter, InputField.FILE_NAME, out fileName, -1); model.get (iter, InputField.FILE_SIZE, out fileSize, -1); model.get (iter, InputField.FILE_DURATION, out duration, -1); - + spanStart = ""; spanEnd = ""; fileName = fileName.replace("&","&"); - formatInfo = ((mf.FileFormat.length > 0) ? ("" + mf.FileFormat) : "") - + ((mf.VideoFormat.length > 0) ? (" - " + mf.VideoFormat) : "") + formatInfo = ((mf.FileFormat.length > 0) ? ("" + mf.FileFormat) : "") + + ((mf.VideoFormat.length > 0) ? (" - " + mf.VideoFormat) : "") + ((mf.AudioFormat.length > 0) ? (" - " + mf.AudioFormat) : ""); - + if (App.TileView){ (cell as Gtk.CellRendererText).markup = "%s\n%s%s | %s\n%s%s".printf(fileName, spanStart, duration, fileSize, formatInfo, spanEnd); } @@ -360,9 +360,9 @@ (cell as Gtk.CellRendererText).text = fileName; } }); - + tvFiles.append_column(colName); - + //colSize colSize = new TreeViewColumn(); colSize.title = _("Size"); @@ -370,7 +370,7 @@ colSize.pack_start (cellSize, false); colSize.set_attributes(cellSize, "text", InputField.FILE_SIZE); tvFiles.append_column(colSize); - + //colDuration colDuration = new TreeViewColumn(); colDuration.title = _("Duration"); @@ -389,7 +389,7 @@ colCrop.pack_start (cellCrop, false); colCrop.set_attributes(cellCrop, "text", InputField.FILE_CROPVAL); tvFiles.append_column(colCrop); - + //colProgress colProgress = new TreeViewColumn(); colProgress.title = _("Status"); @@ -400,7 +400,7 @@ colProgress.pack_start (cellProgress, false); colProgress.set_attributes(cellProgress, "value", InputField.FILE_PROGRESS, "text", InputField.FILE_PROGRESS_TEXT); tvFiles.append_column(colProgress); - + //colSpacer colSpacer = new TreeViewColumn(); colSpacer.expand = false; @@ -409,21 +409,21 @@ colSpacer.pack_start (cellSpacer, false); tvFiles.append_column(colSpacer); - startupTimer = Timeout.add (100,() => - { - colProgress.visible = false; - Source.remove (startupTimer); - return true; + startupTimer = Timeout.add (100,() => + { + colProgress.visible = false; + Source.remove (startupTimer); + return true; }); Gtk.drag_dest_set (tvFiles,Gtk.DestDefaults.ALL, targets, Gdk.DragAction.COPY); tvFiles.drag_data_received.connect(on_drag_data_received); } - - public void init_list_view_context_menu(){ + + public void init_list_view_context_menu(){ Gdk.RGBA gray = Gdk.RGBA(); gray.parse ("rgba(200,200,200,1)"); - + // menuFile menuFile = new Gtk.Menu(); @@ -432,7 +432,7 @@ miFileSkip.label = _("Skip File"); miFileSkip.activate.connect (() => { App.stop_file(); }); menuFile.append(miFileSkip); - + // miFileCropAuto miFileCropAuto = new Gtk.MenuItem.with_label (_("AutoCrop Video")); miFileCropAuto.activate.connect(miFileCropAuto_clicked); @@ -441,30 +441,30 @@ // miFilePreview miFilePreview = new Gtk.MenuItem.with_label (_("Preview File")); miFilePreview.activate.connect(miFilePreview_clicked); - menuFile.append(miFilePreview); - + menuFile.append(miFilePreview); + // miFileRemove miFileRemove = new ImageMenuItem.from_stock("gtk-remove", null); miFileRemove.activate.connect(miFileRemove_clicked); - menuFile.append(miFileRemove); - + menuFile.append(miFileRemove); + // miFileSeparator1 miFileSeparator1 = new Gtk.MenuItem(); miFileSeparator1.override_color (StateFlags.NORMAL, gray); menuFile.append(miFileSeparator1); - + // miFileOpenTemp miFileOpenTemp = new ImageMenuItem.from_stock("gtk-directory", null); miFileOpenTemp.label = _("Open Temp Folder"); miFileOpenTemp.activate.connect(miFileOpenTemp_clicked); menuFile.append(miFileOpenTemp); - + // miFileOpenOutput miFileOpenOutput = new ImageMenuItem.from_stock("gtk-directory", null); miFileOpenOutput.label = _("Open Output Folder"); miFileOpenOutput.activate.connect(miFileOpenOutput_clicked); menuFile.append(miFileOpenOutput); - + // miFileOpenLogFile miFileOpenLogFile = new ImageMenuItem.from_stock("gtk-info", null); miFileOpenLogFile.label = _("Open Log File"); @@ -475,33 +475,33 @@ miFileSeparator2 = new Gtk.MenuItem(); miFileSeparator2.override_color (StateFlags.NORMAL, gray); menuFile.append(miFileSeparator2); - + // miFilePlaySource miFilePlaySource = new ImageMenuItem.from_stock("gtk-media-play", null); miFilePlaySource.label = _("Play File (Source)"); miFilePlaySource.activate.connect(miFilePlaySource_clicked); menuFile.append(miFilePlaySource); - + // miFilePlayOutput miFilePlayOutput = new ImageMenuItem.from_stock("gtk-media-play", null); miFilePlayOutput.label = _("Play File (Output)"); miFilePlayOutput.activate.connect(miFilePlayOutput_clicked); menuFile.append(miFilePlayOutput); - + // miFileInfo miFileInfo = new ImageMenuItem.from_stock("gtk-properties", null); miFileInfo.label = _("File Info (Source)"); miFileInfo.activate.connect(miFileInfo_clicked); menuFile.append(miFileInfo); - + // miFileInfoOutput miFileInfoOutput = new ImageMenuItem.from_stock("gtk-properties", null); miFileInfoOutput.label = _("File Info (Output)"); miFileInfoOutput.activate.connect(miFileInfoOutput_clicked); menuFile.append(miFileInfoOutput); - + menuFile.show_all(); - + //connect signal for shift+F10 tvFiles.popup_menu.connect(() => { return menuFile_popup (menuFile, null); }); //connect signal for right-click @@ -517,7 +517,7 @@ private void refresh_list_view (bool refresh_model = true){ if (refresh_model){ Gtk.ListStore inputStore = new Gtk.ListStore (10, typeof(MediaFile), typeof (string), typeof (string), typeof (string), typeof (string), typeof (string), typeof (string), typeof (int), typeof (string), typeof (string)); - + TreeIter iter; foreach(MediaFile mFile in App.InputFiles) { inputStore.append (out iter); @@ -532,19 +532,19 @@ inputStore.set (iter, InputField.FILE_PROGRESS_TEXT, mFile.ProgressText); inputStore.set (iter, InputField.FILE_THUMB, mFile.ThumbnailImagePath); } - + tvFiles.set_model (inputStore); } - + colSize.visible = !App.TileView; colDuration.visible = !App.TileView; colCrop.visible = !App.TileView; tvFiles.headers_visible = !App.TileView; - + tvFiles.columns_autosize(); } - + public void init_preset_toolbar(){ // Preset tool bar -------------------------------------- @@ -570,14 +570,14 @@ btnRemovePreset.clicked.connect (btnRemovePreset_clicked); btnRemovePreset.set_tooltip_text (_("Delete Preset")); toolbar2.add (btnRemovePreset); - + /*//btnEditPreset btnEditPreset = new Gtk.ToolButton.from_stock ("gtk-edit"); btnEditPreset.is_important = true; btnEditPreset.clicked.connect (btnEditPreset_clicked); btnEditPreset.set_tooltip_text (_("Edit Preset")); toolbar2.add (btnEditPreset);*/ - + //btnBrowsePresetFolder btnBrowsePresetFolder = new Gtk.ToolButton.from_stock ("gtk-directory"); btnBrowsePresetFolder.is_important = true; @@ -585,13 +585,13 @@ btnBrowsePresetFolder.clicked.connect (btnBrowsePresetFolder_clicked); btnBrowsePresetFolder.set_tooltip_text (_("Open Folder")); toolbar2.add (btnBrowsePresetFolder); - + /*//separator var separator1 = new Gtk.SeparatorToolItem(); separator1.set_draw (false); separator1.set_expand (true); toolbar2.add (separator1);*/ - + //btnPresetInfo btnPresetInfo = new Gtk.ToolButton.from_stock ("gtk-info"); btnPresetInfo.is_important = true; @@ -601,7 +601,7 @@ btnPresetInfo.set_tooltip_text (_("Info")); toolbar2.add (btnPresetInfo); } - + public void init_preset_dropdowns(){ //vboxMain2 vboxMain2 = new Box (Orientation.VERTICAL, 0); @@ -622,8 +622,8 @@ lblScriptFolder = new Gtk.Label(_("Folder")); lblScriptFolder.xalign = (float) 0.0; gridConfig.attach(lblScriptFolder,0,0,1,1); - - //cmbScriptFolder + + //cmbScriptFolder cmbScriptFolder = new ComboBox(); CellRendererText cellScriptFolder = new CellRendererText(); cmbScriptFolder.pack_start( cellScriptFolder, false ); @@ -632,12 +632,12 @@ cmbScriptFolder.set_tooltip_text (_("Folder")); cmbScriptFolder.changed.connect(cmbScriptFolder_changed); gridConfig.attach(cmbScriptFolder,1,0,1,1); - + //lblScriptFile lblScriptFile = new Gtk.Label(_("Preset")); lblScriptFile.xalign = (float) 0.0; gridConfig.attach(lblScriptFile,0,1,1,1); - + //cmbScriptFile cmbScriptFile = new ComboBox(); cmbScriptFile.hexpand = true; @@ -647,7 +647,7 @@ cmbScriptFile.set_tooltip_text (_("Encoding Script or Preset File")); cmbScriptFile.changed.connect(cmbScriptFile_changed); gridConfig.attach(cmbScriptFile,1,1,1,1); - + //btnEditPreset btnEditPreset = new Button.with_label(""); btnEditPreset.always_show_image = true; @@ -658,7 +658,7 @@ btnEditPreset.clicked.connect(btnEditPreset_clicked); gridConfig.attach(btnEditPreset,2,0,1,2); } - + public void init_statusbar(){ //lblStatus lblStatus = new Label(""); @@ -667,20 +667,20 @@ lblStatus.margin_bottom = 6; vboxMain2.add (lblStatus); } - + public void init_regular_expressions(){ try{ regexGeneric = new Regex("""([0-9]+[.]?[0-9]*)%"""); regexMkvMerge = new Regex("""Progress: ([0-9]+[.]?[0-9]*)%"""); regexFFmpeg = new Regex("""time=([0-9]+[:][0-9]+[:][0-9]+[.]?[0-9]*) """); regexLibAV = new Regex("""time=[ ]*([0-9]+[.]?[0-9]*)[ ]*"""); - + //frame= 82 fps= 23 q=28.0 size= 133kB time=1.42 bitrate= 766.9kbits/s regexLibAV_video = new Regex("""frame=[ ]*[0-9]+[ ]*fps=[ ]*([0-9]+)[.]?[0-9]*[ ]*q=[ ]*[0-9]+[.]?[0-9]*[ ]*size=[ ]*([0-9]+)kB[ ]*time=[ ]*[0-9]+[.]?[0-9]*[ ]*bitrate=[ ]*([0-9]+)[.]?[0-9]*"""); - - //size= 1590kB time=30.62 bitrate= 425.3kbits/s + + //size= 1590kB time=30.62 bitrate= 425.3kbits/s regexLibAV_audio = new Regex("""size=[ ]*([0-9]+)kB[ ]*time=[ ]*[0-9]+[.]?[0-9]*[ ]*bitrate=[ ]*([0-9]+)[.]?[0-9]*"""); - + //[53.4%] 1652/3092 frames, 24.81 fps, 302.88 kb/s, eta 0:00:58 regexX264 = new Regex("""\[[0-9]+[.]?[0-9]*%\][ \t]*[0-9]+/[0-9]+[ \t]*frames,[ \t]*([0-9]+)[.]?[0-9]*[ \t]*fps,[ \t]*([0-9]+)[.]?[0-9]*[ \t]*kb/s,[ \t]*eta ([0-9:]+)"""); } @@ -688,13 +688,13 @@ stderr.printf ("Error: %s\n", e.message); } } - + public void set_window_title(){ title = AppName + " v" + AppVersion;// + " by " + AppAuthor + " (" + "teejeetech.blogspot.in" + ")"; } - + // script dropdown handlers ----------------------- - + private void populate_script_folders(){ TreeStore model = new TreeStore(2, typeof(string), typeof(string)); cmbScriptFolder.set_model(model); @@ -703,12 +703,12 @@ model.append (out iter0, null); model.set (iter0, 0, App.ScriptsFolder_Custom,1, _("scripts")); iter_append_children (model, iter0, App.ScriptsFolder_Custom); - + model.append (out iter0, null); model.set (iter0, 0, App.PresetsFolder_Custom,1, _("presets")); iter_append_children (model, iter0, App.PresetsFolder_Custom); } - + private void iter_append_children (TreeStore model, TreeIter iter0, string path){ try{ var dir = File.parse_name (path); @@ -720,48 +720,48 @@ if (file.get_file_type() == FileType.DIRECTORY){ string dirPath = dir.resolve_relative_path(file.get_name()).get_path(); string dirName = dirPath.replace(App.UserDataDirectory + "/",""); - + model.append(out iter1, null); model.set(iter1, 0, dirPath, 1, dirName); iter_append_children(model, iter1, dir.resolve_relative_path(file.get_name()).get_path()); } - } + } } catch(Error e){ log_error (e.message); } - + } - + private void cmbScriptFolder_changed(){ //create empty model Gtk.ListStore model = new Gtk.ListStore(2, typeof(ScriptFile), typeof(string)); cmbScriptFile.set_model(model); - + string path = gtk_combobox_get_value(cmbScriptFolder,0,""); - + try { var dir = File.parse_name (path); var enumerator = dir.enumerate_children ("standard::*", 0); Gee.ArrayList files = new Gee.ArrayList(); - + FileInfo file; while ((file = enumerator.next_file()) != null) { files.add(dir.resolve_relative_path(file.get_name()).get_path()); - } + } files.sort((a,b) => { return strcmp((string)a, (string)b); }); - + foreach(string filePath in files){ string fileName = File.new_for_path(filePath).get_basename(); - + if (file_exists(filePath)){ ScriptFile sh = new ScriptFile(filePath); if (sh.Extension == ".sh" || sh.Extension == ".json") { TreeIter iter; model.append(out iter); model.set(iter, 0, sh, 1, fileName); - + if (App.SelectedScript != null && App.SelectedScript.Path == sh.Path) { cmbScriptFile.set_active_iter(iter); } @@ -777,27 +777,27 @@ log_error (e.message); } } - + private void cmbScriptFile_changed(){ if ((cmbScriptFile == null)||(cmbScriptFile.model == null)||(cmbScriptFile.active < 0)){ return; } - + ScriptFile sh; TreeIter iter; cmbScriptFile.get_active_iter(out iter); cmbScriptFile.model.get (iter, 0, out sh, -1); - + App.SelectedScript = sh; } - + private bool select_script(){ if ((App.SelectedScript == null)||(file_exists(App.SelectedScript.Path) == false)){ cmbScriptFolder.set_active(2); cmbScriptFile.set_active(0); return false; } - + string filePath = App.SelectedScript.Path; - + string dirPath = GLib.Path.get_dirname(filePath); bool retVal = false; TreeIter iter; @@ -821,17 +821,17 @@ //check if selected file is in some other folder if (retVal == false){ //unselect - cmbScriptFolder.set_active(-1); - + cmbScriptFolder.set_active(-1); + //add the selected file Gtk.ListStore model1 = new Gtk.ListStore(2, typeof(ScriptFile), typeof(string)); cmbScriptFile.set_model(model1); ScriptFile sh = new ScriptFile(filePath); model1.append(out iter); model1.set(iter, 0, sh, 1, sh.Title); - + //select it - cmbScriptFile.set_active(0); + cmbScriptFile.set_active(0); } //select file @@ -845,23 +845,23 @@ break; } } - + return retVal; } - + private bool select_script_recurse_children (string filePath, TreeIter iter0){ TreeStore model = (TreeStore) cmbScriptFolder.model; string dirPath = GLib.Path.get_dirname(filePath); bool retVal = false; - + TreeIter iter1; int index = 0; - + for (bool next = model.iter_children (out iter1, iter0); next; next = model.iter_nth_child (out iter1, iter0, index)) { - + string path; model.get (iter1, 0, out path); - + if (path == dirPath){ cmbScriptFolder.set_active_iter(iter1); return true; @@ -871,43 +871,43 @@ } index++; } - + return retVal; } - + private void cellScriptFile_render (CellLayout cell_layout, CellRenderer cell, TreeModel model, TreeIter iter){ ScriptFile sh; model.get (iter, 0, out sh, -1); (cell as Gtk.CellRendererText).text = sh.Title; } - + private void cellScriptFolder_render (CellLayout cell_layout, CellRenderer cell, TreeModel model, TreeIter iter){ string name; model.get (iter, 1, out name, -1); (cell as Gtk.CellRendererText).text = name; } - + private void btnBrowsePresetFolder_clicked(){ string path; TreeModel model = (TreeModel) cmbScriptFolder.model; TreeIter iter; cmbScriptFolder.get_active_iter(out iter); model.get (iter, 0, out path, -1); - exo_open_folder (path); + exo_open_folder (path); } - + private void miFileOpenLogFile_clicked(){ TreeSelection selection = tvFiles.get_selection(); - + if (selection.count_selected_rows() > 0){ TreeModel model; GLib.List lst = selection.get_selected_rows (out model); TreePath path = lst.nth_data (0); int index = int.parse (path.to_string()); - + MediaFile mf = App.InputFiles[index]; - exo_open_textfile (mf.LogFile); - } + exo_open_textfile (mf.LogFile); + } } private void preset_create(){ @@ -922,13 +922,13 @@ //App.SelectedScript will be set on click of 'Save' button cmbScriptFolder_changed(); } - + private void preset_edit(){ ScriptFile sh; TreeIter iter; cmbScriptFile.get_active_iter(out iter); cmbScriptFile.model.get (iter, 0, out sh, -1); - + if (sh.Extension == ".json") { var window = new EncoderConfigWindow(); window.set_transient_for(this); @@ -940,23 +940,23 @@ cmbScriptFolder_changed(); } } - + private void script_create(){ string folder = gtk_combobox_get_value(cmbScriptFolder,0,""); - + int k = 0; string new_script = "%s/new_script.sh".printf(folder); while (file_exists(new_script)){ new_script = "%s/new_script_%d.sh".printf(folder,++k); } - + write_file(new_script,""); - exo_open_textfile(new_script); - + exo_open_textfile(new_script); + App.SelectedScript = new ScriptFile(new_script); cmbScriptFolder_changed(); } - + private void script_edit(){ ScriptFile sh; TreeIter iter; @@ -964,10 +964,10 @@ cmbScriptFile.model.get (iter, 0, out sh, -1); if (sh.Extension == ".sh") { - exo_open_textfile(sh.Path); + exo_open_textfile(sh.Path); } } - + private void btnAddPreset_clicked(){ TreeIter iter; string folderName; @@ -988,21 +988,21 @@ TreeIter iter; cmbScriptFile.get_active_iter(out iter); cmbScriptFile.model.get (iter, 0, out sh, -1); - + file_delete(sh.Path); cmbScriptFolder_changed(); - + statusbar_show_message (_("Preset deleted") + ": " + sh.Name + "", true, true); } } - + private void btnEditPreset_clicked(){ if ((cmbScriptFile.model == null)||(cmbScriptFile.active == -1)) { TreeIter iter; string folderName; cmbScriptFolder.get_active_iter(out iter); cmbScriptFolder.model.get (iter, 1, out folderName, -1); - + if (folderName.has_prefix("scripts")){ script_create(); } @@ -1011,7 +1011,7 @@ } } else { - + ScriptFile sh; TreeIter iter; cmbScriptFile.get_active_iter(out iter); @@ -1025,7 +1025,7 @@ preset_edit(); break; } - } + } } private void btnPresetInfo_clicked(){ @@ -1062,36 +1062,36 @@ } // statusbar ------------------- - + private void statusbar_show_message (string message, bool is_error = false, bool timeout = true){ Gdk.RGBA red = Gdk.RGBA(); Gdk.RGBA white = Gdk.RGBA(); red.parse ("rgba(255,0,0,1)"); white.parse ("rgba(0,0,0,1)"); - + if (is_error) lblStatus.override_color (StateFlags.NORMAL, red); else lblStatus.override_color (StateFlags.NORMAL, null); - + lblStatus.label = message; - + if (timeout) statusbar_set_timeout(); } - + private void statusbar_set_timeout(){ //Source.remove (statusTimer); statusTimer = Timeout.add (3000, statusbar_clear); } - + private bool statusbar_clear(){ //Source.remove (statusTimer); lblStatus.label = ""; statusbar_default_message(); return true; } - + private void statusbar_default_message(){ switch (App.Status){ case AppStatus.NOTSTARTED: @@ -1100,23 +1100,23 @@ else statusbar_show_message(_("Drag files on this window or click the 'Add' button"), false, false); break; - + case AppStatus.IDLE: statusbar_show_message(_("[Batch completed] Right-click for options or click 'Finish' to continue."), false, false); break; - + case AppStatus.PAUSED: statusbar_show_message(_("[Paused] Click 'Resume' to continue or 'Stop' to abort."), false, false); break; - + case AppStatus.RUNNING: statusbar_show_message(_("Converting: '%s'").printf (App.CurrentFile.Path), false, false); break; } } - + // list view and context menu ------------------------- - + private void on_drag_data_received (Gdk.DragContext drag_context, int x, int y, Gtk.SelectionData data, uint info, uint time) { foreach(string uri in data.get_uris()){ string file = uri.replace("file://","").replace("file:/",""); @@ -1129,20 +1129,20 @@ statusbar_show_message (_("File added: '%s'").printf (file)); } } - + refresh_list_view(); - + Gtk.drag_finish (drag_context, true, false, time); } private bool menuFile_popup (Gtk.Menu popup, Gdk.EventButton? event) { TreeSelection selection = tvFiles.get_selection(); int index = -1; - + if (selection.count_selected_rows() == 0){ return true; } - + if (selection.count_selected_rows() == 1){ TreeModel model; GLib.List lst = selection.get_selected_rows (out model); @@ -1156,7 +1156,7 @@ miFileOpenTemp.visible = false; miFileOpenOutput.visible = false; miFileOpenLogFile.visible = false; - + miFileInfo.visible = true; miFileInfoOutput.visible = false; miFilePreview.visible = true; @@ -1166,23 +1166,23 @@ miFileRemove.visible = true; miFileSeparator1.visible = true; miFileSeparator2.visible = false; - + miFileInfo.sensitive = (selection.count_selected_rows() == 1); miFilePreview.sensitive = (selection.count_selected_rows() == 1); miFilePlaySource.sensitive = (selection.count_selected_rows() == 1); miFileCropAuto.sensitive = (selection.count_selected_rows() > 0); miFileRemove.sensitive = (selection.count_selected_rows() > 0); break; - + case AppStatus.RUNNING: - + miFileSkip.visible = true; miFileSeparator1.visible = true; miFileSeparator2.visible = false; miFileOpenTemp.visible = true; miFileOpenOutput.visible = true; miFileOpenLogFile.visible = false; - + if (selection.count_selected_rows() == 1){ if (App.InputFiles[index].Status == FileStatus.RUNNING){ miFileSkip.sensitive = true; @@ -1212,13 +1212,13 @@ miFileCropAuto.visible = false; miFileRemove.visible = false; break; - + case AppStatus.IDLE: - + miFileOpenTemp.visible = true; miFileOpenOutput.visible = true; miFileOpenLogFile.visible = true; - + if (index != -1){ miFileOpenTemp.sensitive = true; miFileOpenOutput.sensitive = true; @@ -1227,7 +1227,7 @@ miFileOpenTemp.sensitive = false; miFileOpenOutput.sensitive = false; } - + miFileSkip.visible = false; miFileInfo.visible = true; miFileInfoOutput.visible = true; @@ -1238,7 +1238,7 @@ miFileRemove.visible = false; miFileSeparator1.visible = false; miFileSeparator2.visible = true; - + if (selection.count_selected_rows() == 1){ string outpath = App.InputFiles[index].OutputFilePath; if (outpath != null && outpath.length > 0 && file_exists(outpath)){ @@ -1253,7 +1253,7 @@ break; } - + if (event != null) { menuFile.popup (null, null, null, event.button, event.time); } else { @@ -1264,29 +1264,29 @@ private void miFileInfo_clicked() { TreeSelection selection = tvFiles.get_selection(); - + if (selection.count_selected_rows() > 0){ TreeModel model; GLib.List lst = selection.get_selected_rows (out model); TreePath path = lst.nth_data (0); int index = int.parse (path.to_string()); - + var window = new FileInfoWindow(App.InputFiles[index]); window.set_transient_for(this); window.show_all(); window.run(); } } - + private void miFileInfoOutput_clicked() { TreeSelection selection = tvFiles.get_selection(); - + if (selection.count_selected_rows() > 0){ TreeModel model; GLib.List lst = selection.get_selected_rows (out model); TreePath path = lst.nth_data (0); int index = int.parse (path.to_string()); - + MediaFile mf = App.InputFiles[index]; if (file_exists(mf.OutputFilePath)){ @@ -1296,49 +1296,49 @@ window.show_all(); window.run(); } - } + } } - + private void miFileCropAuto_clicked() { TreeSelection selection = tvFiles.get_selection(); if (selection.count_selected_rows() == 0){ return; } - + set_busy (true,this); - + TreeModel model; GLib.List lst = selection.get_selected_rows (out model); - + for(int k=0; k lst = selection.get_selected_rows (out model); - + for(int k=0; k lst = selection.get_selected_rows (out model); - + for(int k=0; k 0 && dir_exists(App.OutputDirectory)){ exo_open_folder (App.OutputDirectory); } } - + private void set_busy (bool busy, Gtk.Window win) { Gdk.Cursor? cursor = null; @@ -1386,59 +1386,59 @@ else{ cursor = new Gdk.Cursor(Gdk.CursorType.ARROW); } - + var window = win.get_window(); - + if (window != null) { window.set_cursor (cursor); } - + do_events(); } - + private void do_events(){ while(Gtk.events_pending()) Gtk.main_iteration(); } - + private void miFilePreview_clicked() { TreeSelection selection = tvFiles.get_selection(); - + if (selection.count_selected_rows() > 0){ TreeModel model; GLib.List lst = selection.get_selected_rows (out model); TreePath path = lst.nth_data (0); int index = int.parse (path.to_string()); MediaFile mf = App.InputFiles[index]; - + mf.preview_output(); } } - + private void miFilePlayOutput_clicked() { TreeSelection selection = tvFiles.get_selection(); - + if (selection.count_selected_rows() > 0){ TreeModel model; GLib.List lst = selection.get_selected_rows (out model); TreePath path = lst.nth_data (0); int index = int.parse (path.to_string()); MediaFile mf = App.InputFiles[index]; - + mf.play_output(); } } - + private void miFilePlaySource_clicked() { TreeSelection selection = tvFiles.get_selection(); - + if (selection.count_selected_rows() > 0){ TreeModel model; GLib.List lst = selection.get_selected_rows (out model); TreePath path = lst.nth_data (0); int index = int.parse (path.to_string()); MediaFile mf = App.InputFiles[index]; - + mf.play_source(); } } @@ -1446,7 +1446,7 @@ public void tvFiles_crop_cell_edited (string path, string new_text) { int index = int.parse (path.to_string()); MediaFile mf = App.InputFiles[index]; - + if (new_text == null || new_text.length == 0){ mf.crop_reset(); } @@ -1461,15 +1461,15 @@ mf.CropH = mf.SourceHeight - mf.CropT - mf.CropB; } } - + Gtk.ListStore model = (Gtk.ListStore) tvFiles.model; TreeIter iter; model.get_iter (out iter, new TreePath.from_string (path)); model.set (iter, InputField.FILE_CROPVAL, mf.crop_values_info()); } - + // toolbar -------------------------------- - + private void btnAddFiles_clicked(){ var dlgAddFiles = new Gtk.FileChooserDialog(_("Add File(s)"), this, Gtk.FileChooserAction.OPEN, "gtk-cancel", Gtk.ResponseType.CANCEL, @@ -1480,9 +1480,9 @@ if (App.InputDirectory.length > 0) { dlgAddFiles.set_current_folder(App.InputDirectory); } - + if (dlgAddFiles.run() == Gtk.ResponseType.ACCEPT){ - + set_busy(true,dlgAddFiles); foreach (string file in dlgAddFiles.get_filenames()){ @@ -1491,7 +1491,7 @@ statusbar_show_message (_("Format not supported:") + "'" + file + "'", true, true); } } - + App.InputDirectory = dlgAddFiles.get_current_folder(); } @@ -1499,14 +1499,14 @@ dlgAddFiles.destroy(); //resets cursor } - + private void btnRemoveFiles_clicked(){ Gee.ArrayList list = new Gee.ArrayList(); TreeSelection sel = tvFiles.get_selection(); - + TreeIter iter; bool iterExists = tvFiles.model.get_iter_first (out iter); - while (iterExists) { + while (iterExists) { if (sel.iter_is_selected (iter)){ MediaFile mf; tvFiles.model.get (iter, InputField.FILE_REF, out mf, -1); @@ -1514,31 +1514,31 @@ } iterExists = tvFiles.model.iter_next (ref iter); } - + App.remove_files(list); refresh_list_view(); } - + private void btnClearFiles_clicked(){ App.remove_all(); refresh_list_view(); } - + private void btnAbout_clicked(){ var dialog = new AboutWindow(); dialog.set_transient_for (this); - dialog.authors = { - "Tony George:teejeetech@gmail.com" + dialog.authors = { + "Tony George:teejeetech@gmail.com" }; - + dialog.translators = { "abuyop (Malay):launchpad.net/~abuyop", "B. W. Knight (Korean):launchpad.net/~kbd0651", "Felix Moreno (Spanish):launchpad.net/~felix-justdust" - }; - - dialog.documenters = null; + }; + + dialog.documenters = null; dialog.artists = null; dialog.donations = null; @@ -1555,7 +1555,7 @@ dialog.initialize(); dialog.show_all(); } - + public void btnDonation_clicked(){ var dialog = new DonationWindow(); dialog.set_transient_for(this); @@ -1563,7 +1563,7 @@ dialog.run(); dialog.destroy(); } - + private void btnEncoders_clicked(){ var dialog = new EncoderStatusWindow(); dialog.set_transient_for(this); @@ -1571,7 +1571,7 @@ dialog.run(); dialog.destroy(); } - + private void btnAppSettings_clicked(){ var dialog = new AppConfigWindow(); dialog.set_transient_for(this); @@ -1580,10 +1580,10 @@ refresh_list_view(false); } - + private void btnShutdown_clicked(){ App.Shutdown = btnShutdown.active; - + if (App.Shutdown){ log_msg (_("Shutdown Enabled") + "\n"); } @@ -1591,21 +1591,21 @@ log_msg (_("Shutdown Disabled") + "\n"); } } - + private void btnBackground_clicked(){ App.BackgroundMode = btnBackground.active; App.set_priority(); } - + private void btnPause_clicked(){ // pause or resume based on value of field 'pause' if (App.Status == AppStatus.RUNNING){ - App.pause(); + App.pause(); } else if (App.Status == AppStatus.PAUSED){ - App.resume(); + App.resume(); } - + // set button statepause or resume based on value of field 'pause' switch (App.Status){ case AppStatus.PAUSED: @@ -1613,25 +1613,25 @@ btnPause.stock_id = "gtk-media-play"; btnPause.set_tooltip_text (_("Resume")); statusbar_default_message(); - break; + break; case AppStatus.RUNNING: btnPause.label = _("Pause"); btnPause.stock_id = "gtk-media-pause"; btnPause.set_tooltip_text (_("Pause")); statusbar_default_message(); - break; + break; } - + update_status_all(); } - + private void btnStop_clicked(){ App.stop_batch(); - update_status_all(); + update_status_all(); } - + // encoding ---------------------------------- - + public void start(){ if (App.InputFiles.size == 0){ string msg = _("Input queue is empty!\nPlease add some files.\n"); @@ -1641,17 +1641,17 @@ dlg.set_transient_for(this); dlg.run(); dlg.destroy(); - + return; - } + } + - ScriptFile sh; TreeIter iter; cmbScriptFile.get_active_iter(out iter); cmbScriptFile.model.get (iter, 0, out sh, -1); App.SelectedScript = sh; - + //check if encoders used by preset are available foreach(string enc in App.get_encoder_list()){ App.Encoders[enc].CheckAvailability(); @@ -1663,20 +1663,20 @@ convert_prepare(); App.convert_begin(); - + timerID = Timeout.add (500, update_status); } - + public void convert_prepare(){ toolbar2.visible = false; gridConfig.visible = false; btnShutdown.active = App.Shutdown; - + btnShutdown.visible = App.AdminMode; btnBackground.visible = App.AdminMode; btnBackground.active = App.BackgroundMode; btnOpenOutputFolder.visible = dir_exists(App.OutputDirectory); - + btnStart.visible = false; btnAddFiles.visible = true; btnRemoveFiles.visible = false; @@ -1685,30 +1685,30 @@ btnEncoders.visible = false; btnDonate.visible = false; btnAbout.visible = false; - + btnShutdown.visible = App.AdminMode; btnShutdown.active = App.Shutdown; - + btnPause.visible = true; btnStop.visible = true; btnFinish.visible = false; - + paused = false; btnPause.stock_id = "gtk-media-pause"; - + colCrop.visible = !App.TileView; colProgress.visible = true; - + start_cpu_usage_timer(); - } - + } + public void convert_finish(){ toolbar2.visible = true; gridConfig.visible = true; colCrop.visible = !App.TileView; colProgress.visible = false; - + btnStart.visible = true; btnAddFiles.visible = true; btnRemoveFiles.visible = true; @@ -1717,20 +1717,20 @@ btnEncoders.visible = true; btnDonate.visible = true; btnAbout.visible = true; - + btnShutdown.visible = false; btnBackground.visible = false; btnOpenOutputFolder.visible = false; - + btnPause.visible = false; btnStop.visible = false; btnFinish.visible = false; separator1.visible = true; App.convert_finish(); - + statusbar_default_message(); - } + } public bool update_status(){ TreeIter iter; @@ -1742,18 +1742,18 @@ btnPause.active = true; }*/ break; - + case AppStatus.IDLE: // remove progress timers Source.remove (timerID); - + // check shutdown flag if (App.Shutdown){ string msg = _("System will shutdown in one minute!") + "\n"; msg += _("Press 'Cancel' to abort shutdown"); var dialog = new Gtk.MessageDialog(null,Gtk.DialogFlags.MODAL,Gtk.MessageType.INFO, Gtk.ButtonsType.CANCEL, msg); dialog.set_title(_("System shutdown")); - + uint shutdownTimerID = Timeout.add (60000, shutdown); App.WaitingForShutdown = true; if (dialog.run() == Gtk.ResponseType.CANCEL){ @@ -1763,10 +1763,10 @@ dialog.destroy(); } } - + // update status for all files update_status_all(); - + // update UI btnShutdown.visible = false; btnBackground.visible = false; @@ -1776,31 +1776,31 @@ btnAddFiles.visible = false; separator1.visible = false; btnFinish.visible = true; - + // update statusbar message statusbar_default_message(); - + //stop cpu usage display stop_cpu_usage_timer(); set_window_title(); - + break; case AppStatus.RUNNING: statusLine = App.StatusLine; if(statusLine == null){ return false; } - + /*if (btnPause.active){ btnPause.active = false; } */ - + if (lastFile == null) { lastFile = App.CurrentFile; } if (lastFile != App.CurrentFile){ update_status_all(); lastFile = App.CurrentFile; } - + if (model.get_iter_from_string (out iter, App.InputFiles.index_of(App.CurrentFile).to_string())){ model.set (iter, InputField.FILE_PROGRESS, App.CurrentFile.ProgressPercent); model.set (iter, InputField.FILE_PROGRESS_TEXT, null); @@ -1812,32 +1812,32 @@ return true; } - + public void start_cpu_usage_timer(){ cpuUsageTimer = Timeout.add (1000, update_cpu_usage); } - private bool update_cpu_usage(){ + private bool update_cpu_usage(){ this.title = _("CPU: ") + "%.2lf %%".printf(ProcStats.get_cpu_usage()); return true; } - + public void stop_cpu_usage_timer(){ if (cpuUsageTimer != 0){ Source.remove(cpuUsageTimer); cpuUsageTimer = 0; } } - + public void update_status_all(){ Gtk.ListStore model = (Gtk.ListStore)tvFiles.model; MediaFile mf; int index = -1; TreeIter iter; - + bool iterExists = model.get_iter_first (out iter); index++; - + while (iterExists){ mf = App.InputFiles[index]; model.set (iter, InputField.FILE_PROGRESS, mf.ProgressPercent); @@ -1847,7 +1847,7 @@ index++; } } - + public bool shutdown(){ shutdown(); return true; diff -Nru selene-2.5.7~196~ubuntu15.04.1/src/makefile selene-2.5.8~198~ubuntu15.04.1/src/makefile --- selene-2.5.7~196~ubuntu15.04.1/src/makefile 2015-08-14 22:16:18.000000000 +0000 +++ selene-2.5.8~198~ubuntu15.04.1/src/makefile 2015-09-08 00:46:25.000000000 +0000 @@ -11,7 +11,7 @@ all: #build binaries - valac -X -D'GETTEXT_PACKAGE="${app_name}"' --Xcc="-lm" -X -Wl,-rpath,/usr/share/${app_name}/libs "Main.vala" "Utility.vala" "MainWindow.vala" "AppConfigWindow.vala" "EncoderConfigWindow.vala" "EncoderStatusWindow.vala" "FileInfoWindow.vala" "AboutWindow.vala" "DonationWindow.vala" -o ${app_name} --pkg glib-2.0 --pkg gio-unix-2.0 --pkg posix --pkg gtk+-3.0 --pkg gee-0.8 --pkg json-glib-1.0 + valac -X -D'GETTEXT_PACKAGE="${app_name}"' --Xcc="-lm" -X -Wl,-rpath,/usr/share/${app_name}/libs "Main.vala" "Utility.vala" "MainWindow.vala" "AppConfigWindow.vala" "EncoderConfigWindow.vala" "EncoderStatusWindow.vala" "FileInfoWindow.vala" "AboutWindow.vala" "DonationWindow.vala" -o ${app_name} --pkg glib-2.0 --pkg gio-unix-2.0 --pkg posix --pkg gtk+-3.0 --pkg gee-0.8 --pkg json-glib-1.0 #update translation template xgettext --language=C --keyword=_ --copyright-holder='Tony George (teejee2008@gmail.com)' --package-name='${app_name}' --package-version='2.2' --msgid-bugs-address='teejee2008@gmail.com' --escape --sort-output -o ../${app_name}.pot *.vala @@ -28,21 +28,21 @@ mkdir -p "$(DESTDIR)$(sharedir)/glib-2.0/schemas/" mkdir -p "$(DESTDIR)$(sharedir)/${app_name}" mkdir -p "$(DESTDIR)$(sharedir)/pixmaps" - + #binary install -m 0755 ${app_name} "$(DESTDIR)$(bindir)" install -m 0755 ${app_name}-uninstall "$(DESTDIR)$(bindir)" - + #shared files cp -dpr --no-preserve=ownership -t "$(DESTDIR)$(sharedir)/${app_name}" ./share/${app_name}/* chmod --recursive 0755 $(DESTDIR)$(sharedir)/${app_name}/* - + #launcher install -m 0755 ${app_name}.desktop "$(DESTDIR)$(launcherdir)" - + #app icon install -m 0755 ./share/pixmaps/${app_name}.png "$(DESTDIR)$(sharedir)/pixmaps" - + #translations mkdir -p "$(DESTDIR)$(localedir)/ms/LC_MESSAGES" msgfmt --check --verbose -o "$(DESTDIR)$(localedir)/ms/LC_MESSAGES/${app_name}.mo" ../po/${app_name}-ms.po @@ -50,20 +50,20 @@ msgfmt --check --verbose -o "$(DESTDIR)$(localedir)/ko/LC_MESSAGES/${app_name}.mo" ../po/${app_name}-ko.po mkdir -p "$(DESTDIR)$(localedir)/es/LC_MESSAGES" msgfmt --check --verbose -o "$(DESTDIR)$(localedir)/es/LC_MESSAGES/${app_name}.mo" ../po/${app_name}-es.po - + uninstall: #binary rm -f "$(DESTDIR)$(bindir)/${app_name}" rm -f "$(DESTDIR)$(bindir)/${app_name}-uninstall" - + #shared files rm -rf "$(DESTDIR)$(sharedir)/${app_name}" - + #launcher rm -f "$(DESTDIR)$(launcherdir)/${app_name}.desktop" - + #app icon rm -f "$(DESTDIR)$(sharedir)/pixmaps/${app_name}.png" - + #translations rm -f $(DESTDIR)$(localedir)/*/LC_MESSAGES/${app_name}.mo diff -Nru selene-2.5.7~196~ubuntu15.04.1/src/Utility.vala selene-2.5.8~198~ubuntu15.04.1/src/Utility.vala --- selene-2.5.7~196~ubuntu15.04.1/src/Utility.vala 2015-08-14 22:16:18.000000000 +0000 +++ selene-2.5.8~198~ubuntu15.04.1/src/Utility.vala 2015-09-08 00:46:25.000000000 +0000 @@ -1,24 +1,24 @@ /* * Utility.vala - * + * * Copyright 2012 Tony George - * + * * This program 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. - * + * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. - * - * + * + * */ using Gtk; @@ -46,13 +46,13 @@ */ namespace TeeJee.Logging{ - + /* Functions for logging messages to console and log files */ using TeeJee.Misc; - + public DataOutputStream dos_log; - + public bool LOG_ENABLE = true; public bool LOG_TIMESTAMP = true; public bool LOG_COLORS = true; @@ -61,32 +61,32 @@ public void log_msg (string message, bool highlight = false){ if (!LOG_ENABLE) { return; } - + string msg = ""; - + if (highlight && LOG_COLORS){ msg += "\033[1;38;5;34m"; } - + if (LOG_TIMESTAMP){ msg += "[" + timestamp() + "] "; } - + msg += message; - + if (highlight && LOG_COLORS){ msg += "\033[0m"; } - + msg += "\n"; - + stdout.printf (msg); - + try { if (dos_log != null){ dos_log.put_string ("[%s] %s\n".printf(timestamp(), message)); } - } + } catch (Error e) { stdout.printf (e.message); } @@ -94,34 +94,34 @@ public void log_error (string message, bool highlight = false, bool is_warning = false){ if (!LOG_ENABLE) { return; } - + string msg = ""; - + if (highlight && LOG_COLORS){ msg += "\033[1;38;5;160m"; } - + if (LOG_TIMESTAMP){ msg += "[" + timestamp() + "] "; } - + string prefix = (is_warning) ? _("Warning") : _("Error"); - + msg += prefix + ": " + message; - + if (highlight && LOG_COLORS){ msg += "\033[0m"; } - + msg += "\n"; - + stdout.printf (msg); - + try { if (dos_log != null){ dos_log.put_string ("[%s] %s: %s\n".printf(timestamp(), prefix, message)); } - } + } catch (Error e) { stdout.printf (e.message); } @@ -129,7 +129,7 @@ public void log_debug (string message){ if (!LOG_ENABLE) { return; } - + if (LOG_DEBUG){ log_msg (message); } @@ -138,7 +138,7 @@ if (dos_log != null){ dos_log.put_string ("[%s] %s\n".printf(timestamp(), message)); } - } + } catch (Error e) { stdout.printf (e.message); } @@ -147,39 +147,39 @@ } namespace TeeJee.FileSystem{ - + /* Convenience functions for handling files and directories */ - + using TeeJee.Logging; using TeeJee.FileSystem; using TeeJee.ProcessManagement; using TeeJee.Misc; - + public void file_delete(string filePath){ - + /* Check and delete file */ - + try { var file = File.new_for_path (filePath); - if (file.query_exists ()) { - file.delete (); + if (file.query_exists ()) { + file.delete (); } } catch (Error e) { log_error (e.message); } } - + public bool file_exists (string filePath){ - + /* Check if file exists */ - + return ( FileUtils.test(filePath, GLib.FileTest.EXISTS) && FileUtils.test(filePath, GLib.FileTest.IS_REGULAR)); } public void file_copy (string src_file, string dest_file){ try{ var file_src = File.new_for_path (src_file); - if (file_src.query_exists()) { + if (file_src.query_exists()) { var file_dest = File.new_for_path (dest_file); file_src.copy(file_dest,FileCopyFlags.OVERWRITE,null,null); } @@ -188,18 +188,18 @@ log_error (e.message); } } - + public bool dir_exists (string filePath){ - + /* Check if directory exists */ - + return ( FileUtils.test(filePath, GLib.FileTest.EXISTS) && FileUtils.test(filePath, GLib.FileTest.IS_DIR)); } - + public bool create_dir (string filePath){ - + /* Creates a directory along with parents */ - + try{ var dir = File.parse_name (filePath); if (dir.query_exists () == false) { @@ -207,66 +207,66 @@ } return true; } - catch (Error e) { - log_error (e.message); + catch (Error e) { + log_error (e.message); return false; } } - + public bool move_file (string sourcePath, string destPath){ - + /* Move file from one location to another */ - + try{ File fromFile = File.new_for_path (sourcePath); File toFile = File.new_for_path (destPath); fromFile.move (toFile, FileCopyFlags.NONE); return true; } - catch (Error e) { - log_error (e.message); + catch (Error e) { + log_error (e.message); return false; } } - + public bool copy_file (string sourcePath, string destPath){ - + /* Copy file from one location to another */ - + try{ File fromFile = File.new_for_path (sourcePath); File toFile = File.new_for_path (destPath); fromFile.copy (toFile, FileCopyFlags.NONE); return true; } - catch (Error e) { - log_error (e.message); + catch (Error e) { + log_error (e.message); return false; } } - + public string? read_file (string file_path){ - + /* Reads text from file */ - + string txt; size_t size; - + try{ GLib.FileUtils.get_contents (file_path, out txt, out size); - return txt; + return txt; } catch (Error e){ log_error (e.message); } - + return null; } - + public bool write_file (string file_path, string contents){ - + /* Write text to file */ - + try{ var file = File.new_for_path (file_path); if (file.query_exists ()) { file.delete (); } @@ -279,63 +279,63 @@ catch (Error e) { log_error (e.message); return false; - } + } } - + public long get_file_count(string path){ - + /* Return total count of files and directories */ - + string cmd = ""; string std_out; string std_err; int ret_val; - + cmd = "find \"%s\" | wc -l".printf(path); ret_val = execute_command_script_sync(cmd, out std_out, out std_err); return long.parse(std_out); } public long get_file_size(string path){ - + /* Returns size of files and directories in KB*/ - + string cmd = ""; string output = ""; - + cmd = "du -s \"%s\"".printf(path); output = execute_command_sync_get_output(cmd); return long.parse(output.split("\t")[0]); } public string get_file_size_formatted(string path){ - + /* Returns size of files and directories in KB*/ - + string cmd = ""; string output = ""; - + cmd = "du -s -h \"%s\"".printf(path); output = execute_command_sync_get_output(cmd); return output.split("\t")[0].strip(); } - + public int chmod (string file, string permission){ - + /* Change file permissions */ - + return execute_command_sync ("chmod " + permission + " \"%s\"".printf(file)); } - + public string resolve_relative_path (string filePath){ - + /* Resolve the full path of given file using 'realpath' command */ - + string filePath2 = filePath; if (filePath2.has_prefix ("~")){ filePath2 = Environment.get_home_dir () + "/" + filePath2[2:filePath2.length]; } - + try { string output = ""; Process.spawn_command_line_sync("realpath \"%s\"".printf(filePath2), out output); @@ -347,14 +347,14 @@ catch(Error e){ log_error (e.message); } - + return filePath2; } - + public int rsync (string sourceDirectory, string destDirectory, bool updateExisting, bool deleteExtra){ - + /* Sync files with rsync */ - + string cmd = "rsync --recursive --perms --chmod=a=rwx"; cmd += updateExisting ? "" : " --ignore-existing"; cmd += deleteExtra ? " --delete" : ""; @@ -365,11 +365,11 @@ } namespace TeeJee.JSON{ - + using TeeJee.Logging; /* Convenience functions for reading and writing JSON files */ - + public string json_get_string(Json.Object jobj, string member, string def_value){ if (jobj.has_member(member)){ return jobj.get_string_member(member); @@ -379,7 +379,7 @@ return def_value; } } - + public bool json_get_bool(Json.Object jobj, string member, bool def_value){ if (jobj.has_member(member)){ return bool.parse(jobj.get_string_member(member)); @@ -389,7 +389,7 @@ return def_value; } } - + public int json_get_int(Json.Object jobj, string member, int def_value){ if (jobj.has_member(member)){ return int.parse(jobj.get_string_member(member)); @@ -399,24 +399,24 @@ return def_value; } } - + } namespace TeeJee.ProcessManagement{ using TeeJee.Logging; using TeeJee.FileSystem; using TeeJee.Misc; - + public string TEMP_DIR; /* Convenience functions for executing commands and managing processes */ - + public static void init_tmp(){ string std_out, std_err; - + TEMP_DIR = Environment.get_tmp_dir() + "/" + AppShortName; create_dir(TEMP_DIR); - + execute_command_script_sync("echo 'ok'",out std_out,out std_err); if ((std_out == null)||(std_out.strip() != "ok")){ TEMP_DIR = Environment.get_home_dir() + "/.temp/" + AppShortName; @@ -426,10 +426,10 @@ } public int execute_command_sync (string cmd){ - - /* Executes single command synchronously and returns exit code + + /* Executes single command synchronously and returns exit code * Pipes and multiple commands are not supported */ - + try { int exitCode; Process.spawn_command_line_sync(cmd, null, null, out exitCode); @@ -440,12 +440,12 @@ return -1; } } - + public string execute_command_sync_get_output (string cmd){ - + /* Executes single command synchronously and returns std_out * Pipes and multiple commands are not supported */ - + try { int exitCode; string std_out; @@ -459,17 +459,17 @@ } public bool execute_command_script_async (string cmd){ - - /* Creates a temporary bash script with given commands and executes it asynchronously + + /* Creates a temporary bash script with given commands and executes it asynchronously * Return value indicates if script was started successfully */ - + try { - + string scriptfile = create_temp_bash_script (cmd); - + string[] argv = new string[1]; argv[0] = scriptfile; - + Pid child_pid; Process.spawn_async_with_pipes( null, //working dir @@ -485,12 +485,12 @@ return false; } } - + public string? create_temp_bash_script (string script_text){ - - /* Creates a temporary bash script with given commands + + /* Creates a temporary bash script with given commands * Returns the script file path */ - + var sh = ""; sh += "#!/bin/bash\n"; sh += script_text; @@ -505,29 +505,29 @@ return null; } } - + public string get_temp_file_path(){ - + /* Generates temporary file path */ - + return TEMP_DIR + "/" + timestamp2() + (new Rand()).next_int().to_string(); } - + public int execute_command_script_sync (string script, out string std_out, out string std_err){ - + /* Executes commands synchronously * Returns exit code, output messages and error messages. * Commands are written to a temporary bash script and executed. */ - + string path = create_temp_bash_script(script); try { - + string[] argv = new string[1]; argv[0] = path; - + int exit_code; - + Process.spawn_sync ( TEMP_DIR, //working dir argv, //argv @@ -538,7 +538,7 @@ out std_err, out exit_code ); - + return exit_code; } catch (Error e){ @@ -546,19 +546,19 @@ return -1; } } - + public bool execute_command_script_in_terminal_sync (string script){ - + /* Executes a command script in a terminal window */ //TODO: Remove this - + try { - + string[] argv = new string[3]; argv[0] = "x-terminal-emulator"; argv[1] = "-e"; argv[2] = script; - + Process.spawn_sync ( TEMP_DIR, //working dir argv, //argv @@ -566,7 +566,7 @@ SpawnFlags.SEARCH_PATH, null // child_setup ); - + return true; } catch (Error e){ @@ -576,54 +576,54 @@ } public int execute_bash_script_fullscreen_sync (string script_file){ - + /* Executes a bash script synchronously. * Script is executed in a fullscreen terminal window */ - + string path; - + path = get_cmd_path ("xfce4-terminal"); if ((path != null)&&(path != "")){ return execute_command_sync ("xfce4-terminal --fullscreen -e \"%s\"".printf(script_file)); } - + path = get_cmd_path ("gnome-terminal"); if ((path != null)&&(path != "")){ return execute_command_sync ("gnome-terminal --full-screen -e \"%s\"".printf(script_file)); } - + path = get_cmd_path ("xterm"); if ((path != null)&&(path != "")){ return execute_command_sync ("xterm --fullscreen -e \"%s\"".printf(script_file)); } - + //default terminal - unknown, normal window path = get_cmd_path ("x-terminal-emulator"); if ((path != null)&&(path != "")){ return execute_command_sync ("x-terminal-emulator -e \"%s\"".printf(script_file)); } - + return -1; } - + public int execute_bash_script_sync (string script_file){ - + /* Executes a bash script synchronously in the default terminal window */ - + string path = get_cmd_path ("x-terminal-emulator"); if ((path != null)&&(path != "")){ return execute_command_sync ("x-terminal-emulator -e \"%s\"".printf(script_file)); } - + return -1; } - + public string get_cmd_path (string cmd){ - + /* Returns the full path to a command */ - + try { - int exitCode; + int exitCode; string stdout, stderr; Process.spawn_command_line_sync("which " + cmd, out stdout, out stderr, out exitCode); return stdout; @@ -635,9 +635,9 @@ } public int get_pid_by_name (string name){ - + /* Get the process ID for a process with given name */ - + try{ string output = ""; Process.spawn_command_line_sync("pidof \"%s\"".printf(name), out output); @@ -647,74 +647,74 @@ return int.parse (arr[0]); } } - } - catch (Error e) { - log_error (e.message); } - + catch (Error e) { + log_error (e.message); + } + return -1; } - + public bool process_is_running(long pid){ - + /* Checks if given process is running */ - + string cmd = ""; string std_out; string std_err; int ret_val; - + try{ cmd = "ps --pid %ld".printf(pid); Process.spawn_command_line_sync(cmd, out std_out, out std_err, out ret_val); } - catch (Error e) { - log_error (e.message); + catch (Error e) { + log_error (e.message); return false; } - + return (ret_val == 0); } public int[] get_process_children (Pid parentPid){ - + /* Returns the list of child processes spawned by given process */ - + string output; - + try { Process.spawn_command_line_sync("ps --ppid %d".printf(parentPid), out output); } catch(Error e){ log_error (e.message); } - + int pid; int[] procList = {}; string[] arr; - + foreach (string line in output.split ("\n")){ arr = line.strip().split (" "); if (arr.length < 1) { continue; } - + pid = 0; pid = int.parse (arr[0]); - + if (pid != 0){ procList += pid; } } return procList; } - - + + public void process_kill(Pid process_pid, bool killChildren = true){ - + /* Kills specified process and its children (optional) */ - + int[] child_pids = get_process_children (process_pid); Posix.kill (process_pid, 15); - + if (killChildren){ Pid childPid; foreach (long pid in child_pids){ @@ -723,28 +723,28 @@ } } } - + public int process_pause (Pid procID){ - + /* Pause/Freeze a process */ - + return execute_command_sync ("kill -STOP %d".printf(procID)); } - + public int process_resume (Pid procID){ - + /* Resume/Un-freeze a process*/ - + return execute_command_sync ("kill -CONT %d".printf(procID)); } public void command_kill(string cmd_name, string cmd){ - + /* Kills a specific command */ string txt = execute_command_sync_get_output ("ps w -C %s".printf(cmd_name)); //use 'ps ew -C conky' for all users - + string pid = ""; foreach(string line in txt.split("\n")){ if (line.index_of(cmd) != -1){ @@ -754,65 +754,65 @@ } } } - - + + public void process_set_priority (Pid procID, int prio){ - + /* Set process priority */ - + if (Posix.getpriority (Posix.PRIO_PROCESS, procID) != prio) Posix.setpriority (Posix.PRIO_PROCESS, procID, prio); } - + public int process_get_priority (Pid procID){ - + /* Get process priority */ - + return Posix.getpriority (Posix.PRIO_PROCESS, procID); } - + public void process_set_priority_normal (Pid procID){ - + /* Set normal priority for process */ - + process_set_priority (procID, 0); } - + public void process_set_priority_low (Pid procID){ - + /* Set low priority for process */ - + process_set_priority (procID, 5); } - + public bool user_is_admin (){ - + /* Check if current application is running with admin priviledges */ - + try{ // create a process string[] argv = { "sleep", "10" }; Pid procId; - Process.spawn_async(null, argv, null, SpawnFlags.SEARCH_PATH, null, out procId); - + Process.spawn_async(null, argv, null, SpawnFlags.SEARCH_PATH, null, out procId); + // try changing the priority Posix.setpriority (Posix.PRIO_PROCESS, procId, -5); - + // check if priority was changed successfully if (Posix.getpriority (Posix.PRIO_PROCESS, procId) == -5) return true; else return false; - } - catch (Error e) { - log_error (e.message); + } + catch (Error e) { + log_error (e.message); return false; } } public string get_user_login(){ - /* + /* Returns Login ID of current user. If running as 'sudo' it will return Login ID of the actual user. */ @@ -822,7 +822,7 @@ string std_err; int ret_val; ret_val = execute_command_script_sync(cmd, out std_out, out std_err); - + string user_name; if ((std_out == null) || (std_out.length == 0)){ user_name = "root"; @@ -830,45 +830,45 @@ else{ user_name = std_out.strip(); } - + return user_name; } public int get_user_id(string user_login){ - /* + /* Returns UID of specified user. */ - + int uid = -1; string cmd = "id %s -u".printf(user_login); string txt = execute_command_sync_get_output(cmd); if ((txt != null) && (txt.length > 0)){ uid = int.parse(txt); } - + return uid; } - - + + public string get_app_path (){ - + /* Get path of current process */ - + try{ - return GLib.FileUtils.read_link ("/proc/self/exe"); + return GLib.FileUtils.read_link ("/proc/self/exe"); } catch (Error e){ log_error (e.message); return ""; } } - + public string get_app_dir (){ - + /* Get parent directory of current process */ - + try{ - return (File.new_for_path (GLib.FileUtils.read_link ("/proc/self/exe"))).get_parent ().get_path (); + return (File.new_for_path (GLib.FileUtils.read_link ("/proc/self/exe"))).get_parent ().get_path (); } catch (Error e){ log_error (e.message); @@ -879,21 +879,21 @@ } namespace TeeJee.GtkHelper{ - + using Gtk; - + public void gtk_do_events (){ - + /* Do pending events */ - + while(Gtk.events_pending ()) Gtk.main_iteration (); } public void gtk_set_busy (bool busy, Gtk.Window win) { - + /* Show or hide busy cursor on window */ - + Gdk.Cursor? cursor = null; if (busy){ @@ -902,18 +902,18 @@ else{ cursor = new Gdk.Cursor(Gdk.CursorType.ARROW); } - + var window = win.get_window (); - + if (window != null) { window.set_cursor (cursor); } - + gtk_do_events (); } - + public void gtk_messagebox(string title, string message, Gtk.Window? parent_win, bool is_error = false){ - + /* Shows a simple message box */ Gtk.MessageType type = Gtk.MessageType.INFO; @@ -923,7 +923,7 @@ else{ type = Gtk.MessageType.INFO; } - + var dlg = new Gtk.MessageDialog.with_markup(null, Gtk.DialogFlags.MODAL, type, Gtk.ButtonsType.OK, message); dlg.title = title; dlg.set_default_size (200, -1); @@ -934,15 +934,15 @@ dlg.run(); dlg.destroy(); } - + public bool gtk_combobox_set_value (ComboBox combo, int index, string val){ - + /* Conveniance function to set combobox value */ - + TreeIter iter; string comboVal; TreeModel model = (TreeModel) combo.model; - + bool iterExists = model.get_iter_first (out iter); while (iterExists){ model.get(iter, 1, out comboVal); @@ -951,45 +951,45 @@ return true; } iterExists = model.iter_next (ref iter); - } - + } + return false; } - + public string gtk_combobox_get_value (ComboBox combo, int index, string default_value){ - + /* Conveniance function to get combobox value */ - + if (combo.model == null) { return default_value; } if (combo.active < 0) { return default_value; } - + TreeIter iter; string val = ""; combo.get_active_iter (out iter); TreeModel model = (TreeModel) combo.model; model.get(iter, index, out val); - + return val; } public class CellRendererProgress2 : Gtk.CellRendererProgress{ public override void render (Cairo.Context cr, Gtk.Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gtk.CellRendererState flags) { - if (text == "--") + if (text == "--") return; - + int diff = (int) ((cell_area.height - height)/2); - + // Apply the new height into the bar, and center vertically: Gdk.Rectangle new_area = Gdk.Rectangle() ; new_area.x = cell_area.x; new_area.y = cell_area.y + diff; new_area.width = width - 5; new_area.height = height; - + base.render(cr, widget, background_area, new_area, flags); } - } - + } + public Gdk.Pixbuf? get_app_icon(int icon_size, string format = ".png"){ var img_icon = get_shared_icon(AppShortName, AppShortName + format,icon_size,"pixmaps"); if (img_icon != null){ @@ -999,94 +999,94 @@ return null; } } - + public Gtk.Image? get_shared_icon(string icon_name, string fallback_icon_file_name, int icon_size, string icon_directory = AppShortName + "/images"){ Gdk.Pixbuf pix_icon = null; Gtk.Image img_icon = null; - + try { Gtk.IconTheme icon_theme = Gtk.IconTheme.get_default(); pix_icon = icon_theme.load_icon (icon_name, icon_size, 0); } catch (Error e) { //log_error (e.message); } - + string fallback_icon_file_path = "/usr/share/%s/%s".printf(icon_directory, fallback_icon_file_name); - - if (pix_icon == null){ + + if (pix_icon == null){ try { pix_icon = new Gdk.Pixbuf.from_file_at_size (fallback_icon_file_path, icon_size, icon_size); } catch (Error e) { log_error (e.message); } } - - if (pix_icon == null){ + + if (pix_icon == null){ log_error (_("Missing Icon") + ": '%s', '%s'".printf(icon_name, fallback_icon_file_path)); } else{ img_icon = new Gtk.Image.from_pixbuf(pix_icon); } - return img_icon; + return img_icon; } } namespace TeeJee.Multimedia{ - + using TeeJee.Logging; - + /* Functions for working with audio/video files */ - + public long get_file_duration(string filePath){ - + /* Returns the duration of an audio/video file using MediaInfo */ - + string output = "0"; - + try { Process.spawn_command_line_sync("mediainfo \"--Inform=General;%Duration%\" \"" + filePath + "\"", out output); } catch(Error e){ log_error (e.message); } - + return long.parse(output); } - + public string get_file_crop_params (string filePath){ - + /* Returns cropping parameters for a video file using avconv */ - + string output = ""; string error = ""; - + try { Process.spawn_command_line_sync("avconv -i \"%s\" -vf cropdetect=30 -ss 5 -t 5 -f matroska -an -y /dev/null".printf(filePath), out output, out error); } catch(Error e){ log_error (e.message); } - + int w=0,h=0,x=10000,y=10000; int num=0; string key,val; string[] arr; - + foreach (string line in error.split ("\n")){ if (line == null) { continue; } if (line.index_of ("crop=") == -1) { continue; } foreach (string part in line.split (" ")){ if (part == null || part.length == 0) { continue; } - + arr = part.split (":"); if (arr.length != 2) { continue; } - + key = arr[0].strip (); val = arr[1].strip (); - + switch (key){ case "x": num = int.parse (arr[1]); @@ -1107,47 +1107,47 @@ } } } - + if (x == 10000 || y == 10000) return "%i:%i:%i:%i".printf(0,0,0,0); - else + else return "%i:%i:%i:%i".printf(w,h,x,y); } - + public string get_mediainfo (string filePath){ - + /* Returns the multimedia properties of an audio/video file using MediaInfo */ - + string output = ""; - + try { Process.spawn_command_line_sync("mediainfo \"%s\"".printf(filePath), out output); } catch(Error e){ log_error (e.message); } - + return output; } - - + + } namespace TeeJee.System{ - + using TeeJee.ProcessManagement; using TeeJee.Logging; public double get_system_uptime_seconds(){ - + /* Returns the system up-time in seconds */ - + string cmd = ""; string std_out; string std_err; int ret_val; - + try{ cmd = "cat /proc/uptime"; Process.spawn_command_line_sync(cmd, out std_out, out std_err, out ret_val); @@ -1160,18 +1160,18 @@ return 0; } } - + public string get_desktop_name(){ - + /* Return the names of the current Desktop environment */ - + int pid = -1; - + pid = get_pid_by_name("cinnamon"); if (pid > 0){ return "Cinnamon"; } - + pid = get_pid_by_name("xfdesktop"); if (pid > 0){ return "Xfce"; @@ -1186,12 +1186,12 @@ if (pid > 0){ return "Gnome"; } - + pid = get_pid_by_name("wingpanel"); if (pid > 0){ return "Elementary"; } - + pid = get_pid_by_name("unity-panel-service"); if (pid > 0){ return "Unity"; @@ -1201,7 +1201,7 @@ if (pid > 0){ return "KDE"; } - + return "Unknown"; } @@ -1217,22 +1217,22 @@ catch (Error e){ log_error (e.message); } - + return (exit_code == 0); } - + public bool shutdown (){ - + /* Shutdown the system immediately */ - + try{ string[] argv = { "shutdown", "-h", "now" }; Pid procId; - Process.spawn_async(null, argv, null, SpawnFlags.SEARCH_PATH, null, out procId); + Process.spawn_async(null, argv, null, SpawnFlags.SEARCH_PATH, null, out procId); return true; - } - catch (Error e) { - log_error (e.message); + } + catch (Error e) { + log_error (e.message); return false; } } @@ -1245,20 +1245,20 @@ } return false; } - + public bool exo_open_folder (string dir_path, bool xdg_open_try_first = true){ - + /* Tries to open the given directory in a file manager */ /* xdg-open is a desktop-independent tool for configuring the default applications of a user. - Inside a desktop environment (e.g. GNOME, KDE, Xfce), xdg-open simply passes the arguments + Inside a desktop environment (e.g. GNOME, KDE, Xfce), xdg-open simply passes the arguments to that desktop environment's file-opener application (gvfs-open, kde-open, exo-open, respectively). - We will first try using xdg-open and then check for specific file managers if it fails. + We will first try using xdg-open and then check for specific file managers if it fails. */ - + string path; - + if (xdg_open_try_first){ //try using xdg-open path = get_cmd_path ("xdg-open"); @@ -1266,17 +1266,17 @@ return execute_command_script_async ("xdg-open \"" + dir_path + "\""); } } - + path = get_cmd_path ("nemo"); if ((path != null)&&(path != "")){ return execute_command_script_async ("nemo \"" + dir_path + "\""); } - + path = get_cmd_path ("nautilus"); if ((path != null)&&(path != "")){ return execute_command_script_async ("nautilus \"" + dir_path + "\""); } - + path = get_cmd_path ("thunar"); if ((path != null)&&(path != "")){ return execute_command_script_async ("thunar \"" + dir_path + "\""); @@ -1286,7 +1286,7 @@ if ((path != null)&&(path != "")){ return execute_command_script_async ("pantheon-files \"" + dir_path + "\""); } - + path = get_cmd_path ("marlin"); if ((path != null)&&(path != "")){ return execute_command_script_async ("marlin \"" + dir_path + "\""); @@ -1299,16 +1299,16 @@ return execute_command_script_async ("xdg-open \"" + dir_path + "\""); } } - + return false; } public bool exo_open_textfile (string txt){ - + /* Tries to open the given text file in a text editor */ - + string path; - + path = get_cmd_path ("exo-open"); if ((path != null)&&(path != "")){ return execute_command_script_async ("exo-open \"" + txt + "\""); @@ -1323,11 +1323,11 @@ } public bool exo_open_url (string url){ - + /* Tries to open the given text file in a text editor */ - + string path; - + path = get_cmd_path ("exo-open"); if ((path != null)&&(path != "")){ return execute_command_script_async ("exo-open \"" + url + "\""); @@ -1342,19 +1342,19 @@ if ((path != null)&&(path != "")){ return execute_command_script_async ("chromium-browser \"" + url + "\""); } - + return false; } - + private DateTime dt_last_notification = null; private const int NOTIFICATION_INTERVAL = 3; - + public int notify_send (string title, string message, int durationMillis, string urgency, string dialog_type = "info"){ - + /* Displays notification bubble on the desktop */ int retVal = 0; - + switch (dialog_type){ case "error": case "info": @@ -1365,14 +1365,14 @@ dialog_type = "info"; break; } - + long seconds = 9999; if (dt_last_notification != null){ DateTime dt_end = new DateTime.now_local(); TimeSpan elapsed = dt_end.difference(dt_last_notification); seconds = (long)(elapsed * 1.0 / TimeSpan.SECOND); } - + if (seconds > NOTIFICATION_INTERVAL){ string s = "notify-send -t %d -u %s -i %s \"%s\" \"%s\"".printf(durationMillis, urgency, "gtk-dialog-" + dialog_type, title, message); retVal = execute_command_sync (s); @@ -1381,13 +1381,13 @@ return retVal; } - + public bool set_directory_ownership(string dir_name, string login_name){ try { string cmd = "chown %s -R %s".printf(login_name, dir_name); int exit_code; Process.spawn_command_line_sync(cmd, null, null, out exit_code); - + if (exit_code == 0){ //log_msg(_("Ownership changed to '%s' for files in directory '%s'").printf(login_name, dir_name)); return true; @@ -1409,29 +1409,29 @@ public double system = 0; public double idle = 0; public double iowait = 0; - + public double user_delta = 0; public double nice_delta = 0; public double system_delta = 0; public double idle_delta = 0; public double iowait_delta = 0; - + public double usage_percent = 0; - + public static ProcStats stat_prev = null; - + public ProcStats(string line){ string[] arr = line.split(" "); int col = 0; if (arr[col++] == "cpu"){ if (arr[col].length == 0){ col++; }; - + user = double.parse(arr[col++]); nice = double.parse(arr[col++]); system = double.parse(arr[col++]); idle = double.parse(arr[col++]); iowait = double.parse(arr[col++]); - + if (ProcStats.stat_prev != null){ user_delta = user - ProcStats.stat_prev.user; nice_delta = nice - ProcStats.stat_prev.nice; @@ -1443,13 +1443,13 @@ } else{ usage_percent = 0; - + } ProcStats.stat_prev = this; } } - + public static double get_cpu_usage(){ string txt = read_file("/proc/stat"); foreach(string line in txt.split("\n")){ @@ -1462,35 +1462,35 @@ return 0; } } - - + + } namespace TeeJee.Misc { - + /* Various utility functions */ - + using Gtk; using TeeJee.Logging; using TeeJee.FileSystem; using TeeJee.ProcessManagement; - + public class DistInfo : GLib.Object{ - + /* Class for storing information about linux distribution */ - + public string dist_id = ""; public string description = ""; public string release = ""; public string codename = ""; - + public DistInfo(){ dist_id = ""; description = ""; release = ""; codename = ""; } - + public string full_name(){ if (dist_id == ""){ return ""; @@ -1503,14 +1503,14 @@ return val; } } - + public static DistInfo get_dist_info(string root_path){ - - /* Returns information about the Linux distribution + + /* Returns information about the Linux distribution * installed at the given root path */ - + DistInfo info = new DistInfo(); - + string dist_file = root_path + "/etc/lsb-release"; var f = File.new_for_path(dist_file); if (f.query_exists()){ @@ -1521,22 +1521,22 @@ DISTRIB_CODENAME=raring DISTRIB_DESCRIPTION="Ubuntu 13.04" */ - + foreach(string line in read_file(dist_file).split("\n")){ - + if (line.split("=").length != 2){ continue; } - + string key = line.split("=")[0].strip(); string val = line.split("=")[1].strip(); - + if (val.has_prefix("\"")){ val = val[1:val.length]; } - + if (val.has_suffix("\"")){ val = val[0:val.length-1]; } - + switch (key){ case "DISTRIB_ID": info.dist_id = val; @@ -1554,11 +1554,11 @@ } } else{ - + dist_file = root_path + "/etc/os-release"; f = File.new_for_path(dist_file); if (f.query_exists()){ - + /* NAME="Ubuntu" VERSION="13.04, Raring Ringtail" @@ -1570,14 +1570,14 @@ SUPPORT_URL="http://help.ubuntu.com/" BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/" */ - + foreach(string line in read_file(dist_file).split("\n")){ - + if (line.split("=").length != 2){ continue; } - + string key = line.split("=")[0].strip(); string val = line.split("=")[1].strip(); - + switch (key){ case "ID": info.dist_id = val; @@ -1598,33 +1598,33 @@ return info; } - + } public static Gdk.RGBA hex_to_rgba (string hex_color){ - + /* Converts the color in hex to RGBA */ - + string hex = hex_color.strip().down(); if (hex.has_prefix("#") == false){ hex = "#" + hex; } - + Gdk.RGBA color = Gdk.RGBA(); if(color.parse(hex) == false){ color.parse("#000000"); } color.alpha = 255; - + return color; } - + public static string rgba_to_hex (Gdk.RGBA color, bool alpha = false, bool prefix_hash = true){ - + /* Converts the color in RGBA to hex */ - + string hex = ""; - + if (alpha){ hex = "%02x%02x%02x%02x".printf((uint)(Math.round(color.red*255)), (uint)(Math.round(color.green*255)), @@ -1632,54 +1632,54 @@ (uint)(Math.round(color.alpha*255))) .up(); } - else { + else { hex = "%02x%02x%02x".printf((uint)(Math.round(color.red*255)), (uint)(Math.round(color.green*255)), (uint)(Math.round(color.blue*255))) .up(); - } - + } + if (prefix_hash){ hex = "#" + hex; - } - - return hex; + } + + return hex; } public string timestamp2 (){ - + /* Returns a numeric timestamp string */ - + return "%ld".printf((long) time_t ()); } - - public string timestamp (){ - + + public string timestamp (){ + /* Returns a formatted timestamp string */ - + Time t = Time.local (time_t ()); return t.format ("%H:%M:%S"); } - public string timestamp3 (){ - + public string timestamp3 (){ + /* Returns a formatted timestamp string */ - + Time t = Time.local (time_t ()); return t.format ("%Y-%d-%m_%H-%M-%S"); } - + public string format_file_size (int64 size){ - + /* Format file size in MB */ - + return "%0.1f MB".printf (size / (1024.0 * 1024)); } - + public string format_duration (long millis){ - + /* Converts time in milliseconds to format '00:00:00.0' */ - + double time = millis / 1000.0; // time in seconds double hr = Math.floor(time / (60.0 * 60)); @@ -1687,14 +1687,14 @@ double min = Math.floor(time / 60.0); time = time - (min * 60); double sec = Math.floor(time); - + return "%02.0lf:%02.0lf:%02.0lf".printf (hr, min, sec); } - + public double parse_time (string time){ - + /* Converts time in format '00:00:00.0' to seconds */ - + string[] arr = time.split (":"); double secs = 0; if (arr.length >= 3){ @@ -1704,7 +1704,7 @@ } return secs; } - + public string escape_html(string html){ return html .replace("&","&") @@ -1714,7 +1714,7 @@ .replace(">",">") ; } - + public string unescape_html(string html){ return html .replace("&","&") @@ -1725,4 +1725,3 @@ ; } } -