From f4551e85168b661d7d5edf09f7e8a1a16e331a17 Mon Sep 17 00:00:00 2001 From: Kolan Sh Date: Sun, 24 Jan 2016 02:59:06 +0300 Subject: [PATCH] Closes #97: [Save as...] action/button/menu items. --- po/de/laview-desktop.po | 42 +++++++++++++++++++++----- po/laview-desktop.pot | 42 +++++++++++++++++++++----- po/ru/laview-desktop.po | 42 +++++++++++++++++++++----- src/MainWindow.vala | 56 +++++++++++++++++++++++++++++++++++ ui/glade/laview-desktop.glade | 50 +++++++++++++++++++++++++++++++ 5 files changed, 211 insertions(+), 21 deletions(-) diff --git a/po/de/laview-desktop.po b/po/de/laview-desktop.po index 7e4044b..19802b0 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:51+0300\n" +"POT-Creation-Date: 2016-01-24 02:59+0300\n" "PO-Revision-Date: 2015-10-24 20:19+0300\n" "Last-Translator: \n" "Language-Team: German\n" @@ -50,7 +50,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:212 src/MainWindow.vala:302 msgid "Error" msgstr "" @@ -58,7 +58,7 @@ msgstr "" msgid "Select templates" msgstr "" -#: src/MainWindow.vala:86 +#: src/MainWindow.vala:86 src/MainWindow.vala:268 msgid "_Cancel" msgstr "" @@ -78,6 +78,30 @@ msgstr "" msgid "Press 'Properties' button to compose the object." msgstr "" +#: src/MainWindow.vala:262 +msgid "Prepare the document first! >;-]" +msgstr "" + +#: src/MainWindow.vala:266 +msgid "Select destination" +msgstr "" + +#: src/MainWindow.vala:269 +msgid "_Save" +msgstr "" + +#: src/MainWindow.vala:297 +msgid "bytes copied/saved" +msgstr "" + +#: src/MainWindow.vala:297 +msgid "bytes of" +msgstr "" + +#: src/MainWindow.vala:299 +msgid "Save/Copy operation complete! :-)" +msgstr "" + #: src/main.vala:33 msgid "Show the application's version" msgstr "" @@ -197,21 +221,25 @@ msgid "Edit the result document" msgstr "" #: ui/glade/laview-desktop.glade.h:26 -msgid "Application preferences" +msgid "Save the document as..." msgstr "" #: ui/glade/laview-desktop.glade.h:27 -msgid "Help and reference" +msgid "Application preferences" msgstr "" #: ui/glade/laview-desktop.glade.h:28 -msgid "Close the application" +msgid "Help and reference" msgstr "" #: ui/glade/laview-desktop.glade.h:29 -msgid "Templates" +msgid "Close the application" msgstr "" #: ui/glade/laview-desktop.glade.h:30 +msgid "Templates" +msgstr "" + +#: ui/glade/laview-desktop.glade.h:31 msgid "Document Objects" msgstr "" diff --git a/po/laview-desktop.pot b/po/laview-desktop.pot index 5b28fd5..8f145a8 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:51+0300\n" +"POT-Creation-Date: 2016-01-24 02:59+0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -50,7 +50,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:212 src/MainWindow.vala:302 msgid "Error" msgstr "" @@ -58,7 +58,7 @@ msgstr "" msgid "Select templates" msgstr "" -#: src/MainWindow.vala:86 +#: src/MainWindow.vala:86 src/MainWindow.vala:268 msgid "_Cancel" msgstr "" @@ -78,6 +78,30 @@ msgstr "" msgid "Press 'Properties' button to compose the object." msgstr "" +#: src/MainWindow.vala:262 +msgid "Prepare the document first! >;-]" +msgstr "" + +#: src/MainWindow.vala:266 +msgid "Select destination" +msgstr "" + +#: src/MainWindow.vala:269 +msgid "_Save" +msgstr "" + +#: src/MainWindow.vala:297 +msgid "bytes copied/saved" +msgstr "" + +#: src/MainWindow.vala:297 +msgid "bytes of" +msgstr "" + +#: src/MainWindow.vala:299 +msgid "Save/Copy operation complete! :-)" +msgstr "" + #: src/main.vala:33 msgid "Show the application's version" msgstr "" @@ -197,21 +221,25 @@ msgid "Edit the result document" msgstr "" #: ui/glade/laview-desktop.glade.h:26 -msgid "Application preferences" +msgid "Save the document as..." msgstr "" #: ui/glade/laview-desktop.glade.h:27 -msgid "Help and reference" +msgid "Application preferences" msgstr "" #: ui/glade/laview-desktop.glade.h:28 -msgid "Close the application" +msgid "Help and reference" msgstr "" #: ui/glade/laview-desktop.glade.h:29 -msgid "Templates" +msgid "Close the application" msgstr "" #: ui/glade/laview-desktop.glade.h:30 +msgid "Templates" +msgstr "" + +#: ui/glade/laview-desktop.glade.h:31 msgid "Document Objects" msgstr "" diff --git a/po/ru/laview-desktop.po b/po/ru/laview-desktop.po index 4473e26..289aa4a 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:51+0300\n" +"POT-Creation-Date: 2016-01-24 02:59+0300\n" "PO-Revision-Date: 2015-10-24 20:19+0300\n" "Last-Translator: \n" "Language-Team: Russian\n" @@ -51,7 +51,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:212 src/MainWindow.vala:302 msgid "Error" msgstr "Ошибка" @@ -59,7 +59,7 @@ msgstr "Ошибка" msgid "Select templates" msgstr "Выберите шаблоны" -#: src/MainWindow.vala:86 +#: src/MainWindow.vala:86 src/MainWindow.vala:268 msgid "_Cancel" msgstr "_Отмена" @@ -79,6 +79,30 @@ msgstr "Документ проанализирован, выберите объ msgid "Press 'Properties' button to compose the object." msgstr "Нажмите кнопку 'Свойства' для компоновки объекта." +#: src/MainWindow.vala:262 +msgid "Prepare the document first! >;-]" +msgstr "Сначала подготовьте документ! >;-]" + +#: src/MainWindow.vala:266 +msgid "Select destination" +msgstr "Выберите назначение" + +#: src/MainWindow.vala:269 +msgid "_Save" +msgstr "_Сохранить" + +#: src/MainWindow.vala:297 +msgid "bytes copied/saved" +msgstr "байт скопировано/сохранено" + +#: src/MainWindow.vala:297 +msgid "bytes of" +msgstr "байт из" + +#: src/MainWindow.vala:299 +msgid "Save/Copy operation complete! :-)" +msgstr "Операция сохранения/копирования завершена! :-)" + #: src/main.vala:33 msgid "Show the application's version" msgstr "Показать версию приложения" @@ -198,21 +222,25 @@ msgid "Edit the result document" msgstr "Редактировать полученный документ" #: ui/glade/laview-desktop.glade.h:26 +msgid "Save the document as..." +msgstr "Сохранить документ как..." + +#: ui/glade/laview-desktop.glade.h:27 msgid "Application preferences" msgstr "Параметры приложения" -#: ui/glade/laview-desktop.glade.h:27 +#: ui/glade/laview-desktop.glade.h:28 msgid "Help and reference" msgstr "Помощь и справка" -#: ui/glade/laview-desktop.glade.h:28 +#: ui/glade/laview-desktop.glade.h:29 msgid "Close the application" msgstr "Закрыть приложение" -#: ui/glade/laview-desktop.glade.h:29 +#: ui/glade/laview-desktop.glade.h:30 msgid "Templates" msgstr "Шаблоны" -#: ui/glade/laview-desktop.glade.h:30 +#: ui/glade/laview-desktop.glade.h:31 msgid "Document Objects" msgstr "Объекты документа" diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 68f4256..59cd333 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -252,5 +252,61 @@ namespace LAview.Desktop { public void objects_cursor_changed (Gtk.TreeView treeview) { statusbar_show (_("Press 'Properties' button to compose the object.")); } + + [CCode (instance_pos = -1)] + public void action_saveas_activate (Gtk.Action action) { + var indices = get_template_indices (); + if (indices.length == 0) return; + var tmp_pdf = AppCore.core.get_pdf_file_path (indices[0]); + if (tmp_pdf == null || tmp_pdf == "") { + statusbar_show (_("Prepare the document first! >;-]")); + return; + } + + FileChooserDialog chooser = new Gtk.FileChooserDialog (_("Select destination"), window, + FileChooserAction.SAVE, + _("_Cancel"), ResponseType.CANCEL, + _("_Save"), ResponseType.ACCEPT); + chooser.select_multiple = false; + FileFilter filter = new FileFilter (); + chooser.set_filter (filter); + filter.add_mime_type ("application/pdf"); + filter.add_pattern ("*.pdf"); + + // 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 (File.new_for_path(template_name).query_exists()) + chooser.set_filename (template_name); + else + chooser.set_current_name (template_name); + + // open dialog + var response = chooser.run (); + + // 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, + (current_num_bytes, total_num_bytes) => { + statusbar_show (@"$current_num_bytes "+_("bytes of")+ + @" $total_num_bytes "+_("bytes copied/saved")+"."); + }); + statusbar_show (_("Save/Copy operation complete! :-)")); + } catch (Error err) { + var msg = new MessageDialog (chooser, DialogFlags.MODAL, MessageType.ERROR, + ButtonsType.CLOSE, _("Error")+@": $(err.message)."); + msg.response.connect ((response_id) => { msg.destroy (); chooser.close (); } ); + msg.show (); + } + } + + chooser.close (); + } } } diff --git a/ui/glade/laview-desktop.glade b/ui/glade/laview-desktop.glade index 01cfc9c..b0cf718 100644 --- a/ui/glade/laview-desktop.glade +++ b/ui/glade/laview-desktop.glade @@ -94,6 +94,12 @@ + + + True + + + @@ -523,6 +529,18 @@ True + + + gtk-save + False + action_saveas + True + False + True + True + True + + @@ -722,6 +740,21 @@ True + + + False + action_saveas + True + False + Save the document as... + True + gtk-save + + + False + True + + True @@ -1032,6 +1065,23 @@ 2 + + + gtk-save + False + action_saveas + True + True + True + True + True + + + False + True + 3 + + False