LAview Core API fixed: null-returns replaced with exceptions.

This commit is contained in:
Kolan Sh 2016-02-28 22:25:26 +03:00
parent c1a53e8cba
commit 02d7d47daa
1 changed files with 36 additions and 15 deletions

View File

@ -162,11 +162,18 @@ namespace LAview.Desktop {
}
void compose_object () {
try {
var t_indices = get_template_indices ();
var o_indices = get_objects_indices ();
if (t_indices.length != 0 && o_indices.length != 0)
AppCore.core.compose_object (t_indices[0], o_indices[0]);
statusbar_show (_("After composing all objects print the document."));
} catch (Error err) {
var msg = new MessageDialog (window, DialogFlags.MODAL, MessageType.ERROR,
ButtonsType.CLOSE, _("Error")+@": $(err.message).");
msg.response.connect ((response_id) => { msg.destroy (); } );
msg.show ();
}
}
[CCode (instance_pos = -1)]
@ -183,18 +190,30 @@ namespace LAview.Desktop {
[CCode (instance_pos = -1)]
public void action_edit_result_activate (Gtk.Action action) {
try {
var indices = get_template_indices();
if (indices.length != 0) {
var lyx_path = AppCore.core.get_lyx_file_path (indices[0]);
edit_lyx_files ({ lyx_path });
}
} catch (Error err) {
var msg = new MessageDialog (window, DialogFlags.MODAL, MessageType.ERROR,
ButtonsType.CLOSE, _("Error")+@": $(err.message).");
msg.response.connect ((response_id) => { msg.destroy (); } );
msg.show ();
}
}
void post_print () {
try {
var indices = get_template_indices();
var pdf_file = AppCore.core.get_pdf_file_path (indices[0]);
if (pdf_file != null && pdf_file != "")
Utils.open_document (pdf_file, window);
Utils.open_document (AppCore.core.get_pdf_file_path (indices[0]), window);
} catch (Error err) {
var msg = new MessageDialog (window, DialogFlags.MODAL, MessageType.ERROR,
ButtonsType.CLOSE, _("Error")+@": $(err.message).");
msg.response.connect ((response_id) => { msg.destroy (); } );
msg.show ();
}
}
[CCode (instance_pos = -1)]
@ -281,8 +300,10 @@ namespace LAview.Desktop {
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 == "") {
string tmp_pdf = "";
try {
tmp_pdf = AppCore.core.get_pdf_file_path (indices[0]);
} catch (Error err) {
statusbar_show (_("Prepare the document first! >;-]"));
return;
}