Browse Source

Closes #98: Save last pdf directory and set FileChooserDialog to this directory.

develop
Kolan Sh 5 years ago
parent
commit
fea6cd4404
8 changed files with 67 additions and 119 deletions
  1. +5
    -17
      config/ws.backbone.laview.desktop.gschema.xml
  2. +9
    -29
      po/de/laview-desktop.po
  3. +9
    -29
      po/laview-desktop.pot
  4. +12
    -32
      po/ru/laview-desktop.po
  5. +3
    -0
      src/AppCore.vala
  6. +6
    -4
      src/MainWindow.vala
  7. +23
    -7
      src/Settings.vala
  8. +0
    -1
      src/main.vala

+ 5
- 17
config/ws.backbone.laview.desktop.gschema.xml View File

@ -1,22 +1,10 @@
<schemalist>
<schema id="ws.backbone.lavew.desktop-@MAJOR@" path="/ws/backbone/laview/desktop-@MAJOR@/" gettext-domain="laview-desktop-@MAJOR@">
<schema id="ws.backbone.laview.desktop-@MAJOR@" path="/ws/backbone/laview/desktop-@MAJOR@/" gettext-domain="laview-desktop-@MAJOR@">
<key name="greeting" type="s">
<default l10n="messages">"Hello, earthlings"</default>
<summary>A greeting</summary>
<description>Greeting of the invading martians</description>
</key>
<key name="bottles-of-beer" type="i">
<default>99</default>
<summary>Bottles of beer</summary>
<description>Number of bottles of beer on the wall</description>
</key>
<key name="lighting" type="b">
<default>false</default>
<summary>Is the light switched on?</summary>
<description>State of an imaginary light switch.</description>
<key name="pdf-save-path" type="s">
<default>""</default>
<summary>Directory to save pdf files (last selected path).</summary>
<description>It is too lazy to select a directory each time...</description>
</key>
</schema>


+ 9
- 29
po/de/laview-desktop.po View File

@ -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: <backbone@backbone.ws>\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"
#: src/MainWindow.vala:305
msgid "bytes of"
msgstr ""
#: src/MainWindow.vala:297
msgid "bytes of"
#: src/MainWindow.vala:306
msgid "bytes copied/saved"
msgstr ""
#: src/MainWindow.vala:299
#: src/MainWindow.vala:309
msgid "Save/Copy operation complete! :-)"
msgstr ""


+ 9
- 29
po/laview-desktop.pot View File

@ -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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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"
#: src/MainWindow.vala:305
msgid "bytes of"
msgstr ""
#: src/MainWindow.vala:297
msgid "bytes of"
#: src/MainWindow.vala:306
msgid "bytes copied/saved"
msgstr ""
#: src/MainWindow.vala:299
#: src/MainWindow.vala:309
msgid "Save/Copy operation complete! :-)"
msgstr ""


+ 12
- 32
po/ru/laview-desktop.po View File

@ -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: <backbone@backbone.ws>\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 "Операция сохранения/копирования завершена! :-)"


+ 3
- 0
src/AppCore.vala View File

@ -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();
}
}
}

+ 6
- 4
src/MainWindow.vala View File

@ -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,


+ 23
- 7
src/Settings.vala View File

@ -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");
});
}
}
}

+ 0
- 1
src/main.vala View File

@ -45,7 +45,6 @@ namespace LAview.Desktop {
try {
AppDirs.init (args);
AppSettings.init (args);
AppCore.init (args);
Resources.init (args);


Loading…
Cancel
Save