Skip to content
Draft
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ set (PKG_DEPS
gudev-1.0
libevdev
libsoup-2.4
libarchive
)

set (VALA_DEPS
Expand All @@ -39,6 +40,7 @@ set (VALA_DEPS
libevdev
linux
libsoup-2.4
libarchive
)


Expand Down
3 changes: 2 additions & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ Build-Depends: cmake,
libjson-glib-dev,
libgudev-1.0-dev,
libevdev-dev,
libsoup2.4-dev
libsoup2.4-dev,
libarchive-dev

Standards-Version: 3.9.6
Package: com.github.philip-scott.spice-up
Expand Down
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ vala_precompile(VALA_C
Services/Utils.vala
Services/GamepadSlideController.vala

Services/FileFormat/SpiceUpFile.vala
Services/FileFormat/ZipArchiveHandler.vala

Widgets/Canvas.vala
Widgets/EntryCombo.vala
Widgets/Headerbar.vala
Expand Down
3 changes: 2 additions & 1 deletion src/Services/Clipboard.vala
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public class Spice.Clipboard {
Gtk.Clipboard clipboard = Gtk.Clipboard.get_default (Gdk.Display.get_default ());

object_data = clone (object);
print (object_data);

if (object is Spice.TextItem) {
debug ("set text target list");
Expand Down Expand Up @@ -153,7 +154,7 @@ public class Spice.Clipboard {
var root_object = Utils.get_json_object (data);
if (root_object == null) return;

if (root_object.has_member ("preview")) {
if (root_object.has_member ("items")) {
manager.new_slide (root_object, true);
} else {
var item = Utils.canvas_item_from_data (root_object, manager.current_slide.canvas);
Expand Down
28 changes: 28 additions & 0 deletions src/Services/FileFormat/Converter.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// /*
// * Copyright (C) 2019 Felipe Escoto <[email protected]>
// *
// * This program or library is free software; you can redistribute it
// * and/or modify it under the terms of the GNU Lesser General Public
// * License as published by the Free Software Foundation; either
// * version 3 of the License, or (at your option) any later version.
// *
// * This library is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// * Lesser General Public License for more details.
// *
// * You should have received a copy of the GNU Lesser General
// * Public License along with this library; if not, write to the
// * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// * Boston, MA 02110-1301 USA.
// */

// public class Spice.Services.Converter {

// public static void json_to_archive (File original_file) {
// var data = FileManager.get_data (original_file);

// var spice_up_file = new SpiceUpFile (original_file);
// spice_up_file.prepare ();
// }
// }
78 changes: 78 additions & 0 deletions src/Services/FileFormat/SpiceUpFile.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* Copyright (C) 2019 Felipe Escoto <[email protected]>
*
* This program or library is free software; you can redistribute it
* and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*/

public class Spice.Services.SpiceUpFile : Spice.Services.ZipArchiveHandler {
public File pictures_folder { get; private set; }
public File thumbnails_folder { get; private set; }

public File content_file { get; private set; }
public File styles_file { get; private set; }
public File version_file { get; private set; }

public unowned Spice.SlideManager slide_manager {get; construct set; }

public SpiceUpFile (File _gzipped_file, Spice.SlideManager _slide_manager) {
Object (opened_file: _gzipped_file.dup (), slide_manager: _slide_manager);
}

public void load_file () {
try {
open_archive ();
string content = Services.FileManager.get_presentation_data (content_file);
slide_manager.load_data (content);
} catch (Error e) {
// GZipped file is probably the old format. T
// Try to use it as content_file as fallback
debug ("Opening file in legacy mode\n");

string content = Services.FileManager.get_presentation_data (opened_file);
slide_manager.load_data (content);
}
}

public void save_file () {
if (slide_manager.slide_count () == 0) {
Services.FileManager.delete_file (opened_file);
clean ();
} else {
Services.FileManager.write_file (content_file, slide_manager.serialise ());
write_to_archive ();
clean ();
}
}

public override void prepare () {
base.prepare ();

var base_path = unarchived_location.get_path ();
pictures_folder = File.new_for_path (Path.build_filename (base_path, "Pictures"));
thumbnails_folder = File.new_for_path (Path.build_filename (base_path, "Thumbnails"));

make_dir (pictures_folder);
make_dir (thumbnails_folder);

content_file = File.new_for_path (Path.build_filename (base_path, "content.json"));
styles_file = File.new_for_path (Path.build_filename (base_path, "styles.json"));
version_file = File.new_for_path (Path.build_filename (base_path, "version.json"));

make_file (content_file);
make_file (styles_file);
make_file (version_file);
}
}
Loading