From 112daf68d0551ff909df39cd145a64e884c55aaf Mon Sep 17 00:00:00 2001 From: Kolan Sh Date: Mon, 25 Jan 2016 00:47:47 +0300 Subject: [PATCH 1/4] Closes #99: Date+time to the pdf file name. --- src/MainWindow.vala | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 59cd333..4e1558b 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -276,8 +276,12 @@ namespace LAview.Desktop { // set current pdf file name or select an existance one var template_name = AppCore.core.get_template_path_by_index (indices[0]); template_name = File.new_for_path(template_name).get_basename (); - if (template_name.down().has_suffix(".lyx")) - template_name = template_name.splice (template_name.length-4, template_name.length, ".pdf"); + if ( template_name.down().has_suffix(".lyx") + || template_name.down().has_suffix(".tex") + ) { + var date = Time.local (time_t()).format("-%Y.%m.%d_%H-%M-%S"); + template_name = template_name.splice (template_name.length-4, template_name.length, date+".pdf"); + } if (File.new_for_path(template_name).query_exists()) chooser.set_filename (template_name); else From fea6cd4404e06d0fd6f1a24786329dd4af38aa65 Mon Sep 17 00:00:00 2001 From: Kolan Sh Date: Wed, 27 Jan 2016 00:52:15 +0300 Subject: [PATCH 2/4] Closes #98: Save last pdf directory and set FileChooserDialog to this directory. --- config/ws.backbone.laview.desktop.gschema.xml | 22 +++------- po/de/laview-desktop.po | 40 +++++------------ po/laview-desktop.pot | 40 +++++------------ po/ru/laview-desktop.po | 44 +++++-------------- src/AppCore.vala | 3 ++ src/MainWindow.vala | 10 +++-- src/Settings.vala | 30 ++++++++++--- src/main.vala | 1 - 8 files changed, 69 insertions(+), 121 deletions(-) diff --git a/config/ws.backbone.laview.desktop.gschema.xml b/config/ws.backbone.laview.desktop.gschema.xml index 5b04dfa..d503f31 100644 --- a/config/ws.backbone.laview.desktop.gschema.xml +++ b/config/ws.backbone.laview.desktop.gschema.xml @@ -1,22 +1,10 @@ - + - - "Hello, earthlings" - A greeting - Greeting of the invading martians - - - - 99 - Bottles of beer - Number of bottles of beer on the wall - - - - false - Is the light switched on? - State of an imaginary light switch. + + "" + Directory to save pdf files (last selected path). + It is too lazy to select a directory each time... diff --git a/po/de/laview-desktop.po b/po/de/laview-desktop.po index 19802b0..7031099 100644 --- a/po/de/laview-desktop.po +++ b/po/de/laview-desktop.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: laview-desktop\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-01-24 02:59+0300\n" +"POT-Creation-Date: 2016-01-27 04:50+0300\n" "PO-Revision-Date: 2015-10-24 20:19+0300\n" "Last-Translator: \n" "Language-Team: German\n" @@ -18,31 +18,11 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: config/ws.backbone.laview.desktop.gschema.xml.h:1 -msgid "\"Hello, earthlings\"" +msgid "Directory to save pdf files (last selected path)." msgstr "" #: config/ws.backbone.laview.desktop.gschema.xml.h:2 -msgid "A greeting" -msgstr "" - -#: config/ws.backbone.laview.desktop.gschema.xml.h:3 -msgid "Greeting of the invading martians" -msgstr "" - -#: config/ws.backbone.laview.desktop.gschema.xml.h:4 -msgid "Bottles of beer" -msgstr "" - -#: config/ws.backbone.laview.desktop.gschema.xml.h:5 -msgid "Number of bottles of beer on the wall" -msgstr "" - -#: config/ws.backbone.laview.desktop.gschema.xml.h:6 -msgid "Is the light switched on?" -msgstr "" - -#: config/ws.backbone.laview.desktop.gschema.xml.h:7 -msgid "State of an imaginary light switch." +msgid "It is too lazy to select a directory each time..." msgstr "" #: src/MainWindow.vala:58 @@ -50,7 +30,7 @@ msgid "We're ready, Commander! Select or create a template. :-)" msgstr "" #: src/MainWindow.vala:76 src/MainWindow.vala:120 src/MainWindow.vala:194 -#: src/MainWindow.vala:212 src/MainWindow.vala:302 +#: src/MainWindow.vala:212 src/MainWindow.vala:312 msgid "Error" msgstr "" @@ -90,15 +70,15 @@ msgstr "" msgid "_Save" msgstr "" -#: src/MainWindow.vala:297 -msgid "bytes copied/saved" -msgstr "" - -#: src/MainWindow.vala:297 +#: src/MainWindow.vala:305 msgid "bytes of" msgstr "" -#: src/MainWindow.vala:299 +#: src/MainWindow.vala:306 +msgid "bytes copied/saved" +msgstr "" + +#: src/MainWindow.vala:309 msgid "Save/Copy operation complete! :-)" msgstr "" diff --git a/po/laview-desktop.pot b/po/laview-desktop.pot index 8f145a8..16d1d10 100644 --- a/po/laview-desktop.pot +++ b/po/laview-desktop.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: laview-desktop\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-01-24 02:59+0300\n" +"POT-Creation-Date: 2016-01-27 04:50+0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -18,31 +18,11 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" #: config/ws.backbone.laview.desktop.gschema.xml.h:1 -msgid "\"Hello, earthlings\"" +msgid "Directory to save pdf files (last selected path)." msgstr "" #: config/ws.backbone.laview.desktop.gschema.xml.h:2 -msgid "A greeting" -msgstr "" - -#: config/ws.backbone.laview.desktop.gschema.xml.h:3 -msgid "Greeting of the invading martians" -msgstr "" - -#: config/ws.backbone.laview.desktop.gschema.xml.h:4 -msgid "Bottles of beer" -msgstr "" - -#: config/ws.backbone.laview.desktop.gschema.xml.h:5 -msgid "Number of bottles of beer on the wall" -msgstr "" - -#: config/ws.backbone.laview.desktop.gschema.xml.h:6 -msgid "Is the light switched on?" -msgstr "" - -#: config/ws.backbone.laview.desktop.gschema.xml.h:7 -msgid "State of an imaginary light switch." +msgid "It is too lazy to select a directory each time..." msgstr "" #: src/MainWindow.vala:58 @@ -50,7 +30,7 @@ msgid "We're ready, Commander! Select or create a template. :-)" msgstr "" #: src/MainWindow.vala:76 src/MainWindow.vala:120 src/MainWindow.vala:194 -#: src/MainWindow.vala:212 src/MainWindow.vala:302 +#: src/MainWindow.vala:212 src/MainWindow.vala:312 msgid "Error" msgstr "" @@ -90,15 +70,15 @@ msgstr "" msgid "_Save" msgstr "" -#: src/MainWindow.vala:297 -msgid "bytes copied/saved" -msgstr "" - -#: src/MainWindow.vala:297 +#: src/MainWindow.vala:305 msgid "bytes of" msgstr "" -#: src/MainWindow.vala:299 +#: src/MainWindow.vala:306 +msgid "bytes copied/saved" +msgstr "" + +#: src/MainWindow.vala:309 msgid "Save/Copy operation complete! :-)" msgstr "" diff --git a/po/ru/laview-desktop.po b/po/ru/laview-desktop.po index 289aa4a..5d3b85c 100644 --- a/po/ru/laview-desktop.po +++ b/po/ru/laview-desktop.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: laview-desktop\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-01-24 02:59+0300\n" +"POT-Creation-Date: 2016-01-27 04:50+0300\n" "PO-Revision-Date: 2015-10-24 20:19+0300\n" "Last-Translator: \n" "Language-Team: Russian\n" @@ -19,39 +19,19 @@ msgstr "" "%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" #: config/ws.backbone.laview.desktop.gschema.xml.h:1 -msgid "\"Hello, earthlings\"" -msgstr "\"Привет, земляне\"" +msgid "Directory to save pdf files (last selected path)." +msgstr "Директория для сохранения pdf файлов (последний выбранный путь)." #: config/ws.backbone.laview.desktop.gschema.xml.h:2 -msgid "A greeting" -msgstr "Приветствие" - -#: config/ws.backbone.laview.desktop.gschema.xml.h:3 -msgid "Greeting of the invading martians" -msgstr "Приветствие вторгнувшихся марсиан" - -#: config/ws.backbone.laview.desktop.gschema.xml.h:4 -msgid "Bottles of beer" -msgstr "Бутылки пива" - -#: config/ws.backbone.laview.desktop.gschema.xml.h:5 -msgid "Number of bottles of beer on the wall" -msgstr "Число бутылок пива на стене" - -#: config/ws.backbone.laview.desktop.gschema.xml.h:6 -msgid "Is the light switched on?" -msgstr "Включен ли свет?" - -#: config/ws.backbone.laview.desktop.gschema.xml.h:7 -msgid "State of an imaginary light switch." -msgstr "Состояние воображаемого выключателя света." +msgid "It is too lazy to select a directory each time..." +msgstr "Слишком лениво выбирать каждый раз директорию для сохранения..." #: src/MainWindow.vala:58 msgid "We're ready, Commander! Select or create a template. :-)" msgstr "Мы готовы, Командир! Выберите или создайте шаблон. :-)" #: src/MainWindow.vala:76 src/MainWindow.vala:120 src/MainWindow.vala:194 -#: src/MainWindow.vala:212 src/MainWindow.vala:302 +#: src/MainWindow.vala:212 src/MainWindow.vala:312 msgid "Error" msgstr "Ошибка" @@ -91,15 +71,15 @@ msgstr "Выберите назначение" msgid "_Save" msgstr "_Сохранить" -#: src/MainWindow.vala:297 -msgid "bytes copied/saved" -msgstr "байт скопировано/сохранено" - -#: src/MainWindow.vala:297 +#: src/MainWindow.vala:305 msgid "bytes of" msgstr "байт из" -#: src/MainWindow.vala:299 +#: src/MainWindow.vala:306 +msgid "bytes copied/saved" +msgstr "байт скопировано/сохранено" + +#: src/MainWindow.vala:309 msgid "Save/Copy operation complete! :-)" msgstr "Операция сохранения/копирования завершена! :-)" diff --git a/src/AppCore.vala b/src/AppCore.vala index cb8a9bc..f1f611c 100644 --- a/src/AppCore.vala +++ b/src/AppCore.vala @@ -2,9 +2,12 @@ namespace LAview.Desktop { class AppCore { public static LAview.Core.Core core; + public static AppSettings settings; public static void init (string[] args) throws Error { core = new LAview.Core.Core(); + settings = new AppSettings(); } + } } diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 4e1558b..f5190ae 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -273,6 +273,10 @@ namespace LAview.Desktop { filter.add_mime_type ("application/pdf"); filter.add_pattern ("*.pdf"); + // set folder + if (AppCore.settings.pdf_save_path != "") + chooser.set_current_folder(AppCore.settings.pdf_save_path); + // set current pdf file name or select an existance one var template_name = AppCore.core.get_template_path_by_index (indices[0]); template_name = File.new_for_path(template_name).get_basename (); @@ -292,15 +296,13 @@ namespace LAview.Desktop { // process response if (response == ResponseType.ACCEPT) { - var save_path = chooser.get_filename (); - var file_src = File.new_for_path (tmp_pdf); - var file_dest = File.new_for_path (save_path); try { - file_src.copy (file_dest, FileCopyFlags.OVERWRITE, null, + File.new_for_path (tmp_pdf).copy (chooser.get_file(), FileCopyFlags.OVERWRITE, null, (current_num_bytes, total_num_bytes) => { statusbar_show (@"$current_num_bytes "+_("bytes of")+ @" $total_num_bytes "+_("bytes copied/saved")+"."); }); + AppCore.settings.pdf_save_path = chooser.get_file().get_parent().get_path(); statusbar_show (_("Save/Copy operation complete! :-)")); } catch (Error err) { var msg = new MessageDialog (chooser, DialogFlags.MODAL, MessageType.ERROR, diff --git a/src/Settings.vala b/src/Settings.vala index fb43e15..cacc831 100644 --- a/src/Settings.vala +++ b/src/Settings.vala @@ -1,15 +1,31 @@ namespace LAview.Desktop { - class AppSettings { - //public static GLib.Settings settings; + public class AppSettings { + Settings settings; - public static void init (string[] args) throws Error { + string _pdf_save_path; + public string pdf_save_path { + get { return _pdf_save_path; } + set { + if (settings != null) settings.set_string ("pdf-save-path", value); + _pdf_save_path = value; + } + default = ""; + } + + public AppSettings () throws Error { SettingsSchemaSource sss = new SettingsSchemaSource.from_directory (AppDirs.settings_dir, null, false); - //SettingsSchema schema = sss.lookup ("ws.backbone.laview.desktop-"+Config.VERSION_MAJOR.to_string(), false); - if (sss.lookup == null) - throw new FileError.NOENT ("Schema ID not found"); + SettingsSchema schema = sss.lookup ("ws.backbone.laview.desktop-"+Config.VERSION_MAJOR.to_string(), false); + if (schema == null) { + stderr.printf ("ID not found.\n"); + throw new IOError.NOT_FOUND ("File "+AppDirs.settings_dir+"/gschemas.compiled not found"); + } + settings = new Settings.full (schema, null, null); - //settings = new Settings.full (schema, null, null); + _pdf_save_path = settings.get_string("pdf-save-path"); + settings.changed["pdf-save-path"].connect (() => { + _pdf_save_path = settings.get_string("pdf-save-path"); + }); } } } diff --git a/src/main.vala b/src/main.vala index b140d9b..ccdcc06 100644 --- a/src/main.vala +++ b/src/main.vala @@ -45,7 +45,6 @@ namespace LAview.Desktop { try { AppDirs.init (args); - AppSettings.init (args); AppCore.init (args); Resources.init (args); From a18b5f05bd8934b3c56e921d49c94595dc030f7c Mon Sep 17 00:00:00 2001 From: Kolan Sh Date: Thu, 28 Jan 2016 02:30:11 +0300 Subject: [PATCH 3/4] Win32 hooks added for localtime_r(). --- src/CMakeLists.txt | 2 +- src/w32hooks.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 src/w32hooks.c diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0b30aea..fcf3fc1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,7 +5,7 @@ SET (BinPkgModules gtk+-3.0 gee-0.8 laview-core-0) SET (BinCustomVapis ${CMAKE_SOURCE_DIR}/config/Config.vapi) INCLUDE_DIRECTORIES ("${CMAKE_BINARY_DIR}/config") SET (BinInstall ON) -SET (BinExtraSources "${CMAKE_SOURCE_DIR}/res/laview-desktop.rc") +SET (BinExtraSources "${CMAKE_SOURCE_DIR}/res/laview-desktop.rc" w32hooks.c) IF (WIN32) SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mwindows") SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--export-all-symbols") diff --git a/src/w32hooks.c b/src/w32hooks.c new file mode 100644 index 0000000..14a3587 --- /dev/null +++ b/src/w32hooks.c @@ -0,0 +1,8 @@ +#if defined(_WIN32) || defined(_WIN64) +#include +struct tm *localtime_r(const time_t *timep, struct tm *result) +{ + localtime_s(result, timep); + return result; +} +#endif From a31cdc4647e012939c3a54d6b611599a27bcc162 Mon Sep 17 00:00:00 2001 From: Kolan Sh Date: Thu, 28 Jan 2016 02:32:15 +0300 Subject: [PATCH 4/4] Bump version number to 1.1.1 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 287936d..42f4a48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ SET (PROJECT_DESCRIPTION "LAview Desktop Application.") SET (MAJOR 1) SET (MINOR 1) -SET (PATCH 0) +SET (PATCH 1) LIST (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/backbone)