|
@@ -10,7 +10,6 @@ namespace Publicate {
|
|
|
|
|
|
private Leaflet leaflet;
|
|
private Leaflet leaflet;
|
|
|
|
|
|
- private Ppub.Publication publication;
|
|
|
|
private File publication_file;
|
|
private File publication_file;
|
|
private ViewerWindow window;
|
|
private ViewerWindow window;
|
|
|
|
|
|
@@ -90,14 +89,14 @@ namespace Publicate {
|
|
|
|
|
|
public async void load_ppub(File file) throws Error {
|
|
public async void load_ppub(File file) throws Error {
|
|
|
|
|
|
- publication = new Ppub.Publication(file.get_path());
|
|
|
|
|
|
+ window.publication = new Ppub.Publication(file.get_path());
|
|
publication_file = file;
|
|
publication_file = file;
|
|
|
|
|
|
- header_title.title = publication.metadata.title ?? "Untitled PPUB";
|
|
|
|
- header_title.subtitle = publication.metadata.author_name ?? "";
|
|
|
|
|
|
+ header_title.title = window.publication.metadata.title ?? "Untitled PPUB";
|
|
|
|
+ header_title.subtitle = window.publication.metadata.author_name ?? "";
|
|
window.title = header_title.title + " - Publicate!";
|
|
window.title = header_title.title + " - Publicate!";
|
|
|
|
|
|
- file_explorer.set_assets(publication.assets);
|
|
|
|
|
|
+ file_explorer.set_assets(window.publication.assets);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -159,7 +158,7 @@ namespace Publicate {
|
|
}
|
|
}
|
|
|
|
|
|
private void add_editor(Editors.EditorWidget editor, Ppub.Asset asset) {
|
|
private void add_editor(Editors.EditorWidget editor, Ppub.Asset asset) {
|
|
- editor.load_asset(publication, asset);
|
|
|
|
|
|
+ editor.load_asset(window.publication, asset);
|
|
open_editors.set(asset.name, editor);
|
|
open_editors.set(asset.name, editor);
|
|
tab_view.selected_page = editor.tab_page;
|
|
tab_view.selected_page = editor.tab_page;
|
|
}
|
|
}
|
|
@@ -183,14 +182,14 @@ namespace Publicate {
|
|
select_file_from_tab();
|
|
select_file_from_tab();
|
|
}
|
|
}
|
|
|
|
|
|
- private async void save_tab() {
|
|
|
|
|
|
+ public async void save_tab() {
|
|
var current_editor = (Editors.EditorWidget)tab_view.selected_page.child;
|
|
var current_editor = (Editors.EditorWidget)tab_view.selected_page.child;
|
|
- var to_save = publication.assets.select<Savable>(a => a.name == current_editor.asset_name ? (Savable)current_editor : new SavableAsset(publication, a));
|
|
|
|
|
|
+ var to_save = window.publication.assets.select<Savable>(a => a.name == current_editor.asset_name ? (Savable)current_editor : new SavableAsset(window.publication, a));
|
|
yield save(to_save);
|
|
yield save(to_save);
|
|
}
|
|
}
|
|
|
|
|
|
private async void save_all() {
|
|
private async void save_all() {
|
|
- var to_save = publication.assets.select<Savable>(get_savable_editor_or_asset);
|
|
|
|
|
|
+ var to_save = window.publication.assets.select<Savable>(get_savable_editor_or_asset);
|
|
yield save(to_save);
|
|
yield save(to_save);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -201,12 +200,12 @@ namespace Publicate {
|
|
return (Savable)editor;
|
|
return (Savable)editor;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return new SavableAsset(publication, asset);
|
|
|
|
|
|
+ return new SavableAsset(window.publication, asset);
|
|
}
|
|
}
|
|
|
|
|
|
private async void save_and_close_tab_page(TabPage page) {
|
|
private async void save_and_close_tab_page(TabPage page) {
|
|
var editor = (Editors.EditorWidget)page.child;
|
|
var editor = (Editors.EditorWidget)page.child;
|
|
- var to_save = publication.assets.select<Savable>(a => a.name == editor.asset_name ? (Savable)editor : new SavableAsset(publication, a));
|
|
|
|
|
|
+ var to_save = window.publication.assets.select<Savable>(a => a.name == editor.asset_name ? (Savable)editor : new SavableAsset(window.publication, a));
|
|
yield save(to_save);
|
|
yield save(to_save);
|
|
open_editors.unset(editor.asset_name);
|
|
open_editors.unset(editor.asset_name);
|
|
tab_view.close_page_finish(page, true);
|
|
tab_view.close_page_finish(page, true);
|
|
@@ -220,7 +219,7 @@ namespace Publicate {
|
|
|
|
|
|
public async void add_asset (string name, string mimetype, GLib.InputStream stream, Ppub.CompressionInfo compression) {
|
|
public async void add_asset (string name, string mimetype, GLib.InputStream stream, Ppub.CompressionInfo compression) {
|
|
|
|
|
|
- var to_save = publication.assets.select<Savable>(a => new SavableAsset(publication, a)).to_sequence();
|
|
|
|
|
|
+ var to_save = window.publication.assets.select<Savable>(a => new SavableAsset(window.publication, a)).to_sequence();
|
|
to_save.add(new SavableNewAsset(name, mimetype, stream, compression));
|
|
to_save.add(new SavableNewAsset(name, mimetype, stream, compression));
|
|
yield save(to_save);
|
|
yield save(to_save);
|
|
|
|
|
|
@@ -277,7 +276,7 @@ namespace Publicate {
|
|
private void update_deletable() {
|
|
private void update_deletable() {
|
|
// Inhibit deletion of default document or metadata.
|
|
// Inhibit deletion of default document or metadata.
|
|
var asset = file_explorer.selected_asset;
|
|
var asset = file_explorer.selected_asset;
|
|
- remove_file_button.sensitive = (asset != null && asset.name != "metadata" && publication.get_default_asset().name != asset.name);
|
|
|
|
|
|
+ remove_file_button.sensitive = (asset != null && asset.name != "metadata" && window.publication.get_default_asset().name != asset.name);
|
|
}
|
|
}
|
|
|
|
|
|
private void delete_file_clicked() {
|
|
private void delete_file_clicked() {
|
|
@@ -299,9 +298,9 @@ namespace Publicate {
|
|
}
|
|
}
|
|
|
|
|
|
private async void delete_file(Ppub.Asset asset) {
|
|
private async void delete_file(Ppub.Asset asset) {
|
|
- var to_save = publication.assets
|
|
|
|
|
|
+ var to_save = window.publication.assets
|
|
.where(a => a.name != asset.name)
|
|
.where(a => a.name != asset.name)
|
|
- .select<Savable>(a => new SavableAsset(publication, a)).to_sequence();
|
|
|
|
|
|
+ .select<Savable>(a => new SavableAsset(window.publication, a)).to_sequence();
|
|
|
|
|
|
if(open_editors.has_key(asset.name)) {
|
|
if(open_editors.has_key(asset.name)) {
|
|
Editors.EditorWidget editor;
|
|
Editors.EditorWidget editor;
|