From 16fe2e5d0525422ba6ca5db9e92a93d17caae302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sun, 27 Sep 2015 15:05:13 +0200 Subject: Imported Upstream version 0.6.6 --- src/themes/theme.vala | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src/themes/theme.vala') diff --git a/src/themes/theme.vala b/src/themes/theme.vala index a7dd4f8..98e8994 100644 --- a/src/themes/theme.vala +++ b/src/themes/theme.vala @@ -115,6 +115,42 @@ public class Theme : GLib.Object { return true; } + + ///////////////////////////////////////////////////////////////////// + /// Exports the theme directory to an importable archive. + ///////////////////////////////////////////////////////////////////// + + public void export(string file) { + + var archive = new ArchiveWriter(); + bool success = true; + + if (!archive.open(file)) { + warning("Cannot open file " + file + " for writing!"); + success = false; + } else if (!archive.add(this.directory)) { + warning("Cannot append directory " + this.directory + " to archive!"); + success = false; + } + + archive.close(); + + if (success) { + var message = _("Successfully exported the theme \"%s\"!").printf(this.name); + var dialog = new Gtk.MessageDialog(null, Gtk.DialogFlags.MODAL, + Gtk.MessageType.INFO, Gtk.ButtonsType.CLOSE, message); + dialog.run(); + dialog.destroy(); + + } else { + var message = _("An error occured while exporting the theme \"%s\"! Please check the console output.").printf(this.name); + var dialog = new Gtk.MessageDialog(null, Gtk.DialogFlags.MODAL, + Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE, message); + dialog.run(); + dialog.destroy(); + } + } + ///////////////////////////////////////////////////////////////////// /// Loads all images of the theme. ///////////////////////////////////////////////////////////////////// -- cgit v1.2.3