Sean Davis has proposed merging 
lp:~bluesabre/xubuntu-default-settings/xubuntu-templates into 
lp:xubuntu-default-settings.

Requested reviews:
  Xubuntu Developers (xubuntu-dev)

For more details, see:
https://code.launchpad.net/~bluesabre/xubuntu-default-settings/xubuntu-templates/+merge/317186

>From blueprint 
>https://blueprints.launchpad.net/ubuntu/+spec/xubuntu-z-development

[xubuntu-dev] Add Create document templates with translations for default apps: 
INPROGRESS
-- 
Your team Xubuntu Developers is requested to review the proposed merge of 
lp:~bluesabre/xubuntu-default-settings/xubuntu-templates into 
lp:xubuntu-default-settings.
=== modified file 'Makefile'
--- Makefile	2014-08-19 01:45:00 +0000
+++ Makefile	2017-02-14 11:16:45 +0000
@@ -1,6 +1,6 @@
 #!/usr/bin/make -f
 
-SUBDIRS := etc/xdg/xdg-xubuntu/Thunar/po usr/share/xubuntu/applications/po usr/share/polkit-1/actions/po
+SUBDIRS := etc/xdg/xdg-xubuntu/Thunar/po usr/share/polkit-1/actions/po usr/share/xubuntu/applications/po usr/share/xubuntu/templates/po 
 
 all:
 	@echo "Nothing to build, call 'make install' instead."

=== modified file 'debian/changelog'
--- debian/changelog	2016-09-28 10:06:39 +0000
+++ debian/changelog	2017-02-14 11:16:45 +0000
@@ -1,3 +1,9 @@
+xubuntu-default-settings (17.04.0) UNRELEASED; urgency=medium
+
+  * Add default templates
+
+ -- Sean Davis <smd.seanda...@gmail.com>  Sun, 01 Jan 2017 16:53:33 -0500
+
 xubuntu-default-settings (16.10.2) yakkety; urgency=medium
 
   * Revert systemd user unit changes (LP: #1622303)

=== added file 'etc/xdg/xdg-xubuntu/autostart/xdg-xubuntu-templates.desktop'
--- etc/xdg/xdg-xubuntu/autostart/xdg-xubuntu-templates.desktop	1970-01-01 00:00:00 +0000
+++ etc/xdg/xdg-xubuntu/autostart/xdg-xubuntu-templates.desktop	2017-02-14 11:16:45 +0000
@@ -0,0 +1,3 @@
+[Desktop Entry]
+Name=Xubuntu Templates
+Exec=/usr/share/xubuntu/templates/xdg-xubuntu-templates

=== added directory 'usr/share/xubuntu/templates'
=== added file 'usr/share/xubuntu/templates/OpenDocument Spreadsheet.ods'
Binary files usr/share/xubuntu/templates/OpenDocument Spreadsheet.ods	1970-01-01 00:00:00 +0000 and usr/share/xubuntu/templates/OpenDocument Spreadsheet.ods	2017-02-14 11:16:45 +0000 differ
=== added file 'usr/share/xubuntu/templates/OpenDocument Text.odt'
Binary files usr/share/xubuntu/templates/OpenDocument Text.odt	1970-01-01 00:00:00 +0000 and usr/share/xubuntu/templates/OpenDocument Text.odt	2017-02-14 11:16:45 +0000 differ
=== added file 'usr/share/xubuntu/templates/Plain Text.txt'
=== added directory 'usr/share/xubuntu/templates/po'
=== added file 'usr/share/xubuntu/templates/po/Makefile'
--- usr/share/xubuntu/templates/po/Makefile	1970-01-01 00:00:00 +0000
+++ usr/share/xubuntu/templates/po/Makefile	2017-02-14 11:16:45 +0000
@@ -0,0 +1,24 @@
+#!/usr/bin/make -f
+
+POTFILES := $(shell cat POTFILES.in)
+
+all: generate-locales
+
+generate-pot: POTFILES.in
+	intltool-update --pot --gettext-package=xdg-xubuntu-templates
+
+generate-locales:
+	for i in $$(find $$1 -name *.po); do \
+		code=$$(echo $$i | sed 's/.po//'); \
+		mkdir -p locale/$$code/LC_MESSAGES/; \
+    msgfmt -o locale/$$code/LC_MESSAGES/xdg-xubuntu-templates.mo $$i; \
+	done; \
+	mv locale ../../../
+
+update-po:
+	for i in *.po; do \
+		code=$$(echo $$i | sed 's/.po//'); \
+		intltool-update --gettext-package=xdg-xubuntu-templates --dist $$code; \
+	done
+
+# vim:ts=4

=== added file 'usr/share/xubuntu/templates/po/POTFILES.in'
--- usr/share/xubuntu/templates/po/POTFILES.in	1970-01-01 00:00:00 +0000
+++ usr/share/xubuntu/templates/po/POTFILES.in	2017-02-14 11:16:45 +0000
@@ -0,0 +1,1 @@
+xdg-xubuntu-templates

=== added file 'usr/share/xubuntu/templates/po/xdg-xubuntu-templates.pot'
--- usr/share/xubuntu/templates/po/xdg-xubuntu-templates.pot	1970-01-01 00:00:00 +0000
+++ usr/share/xubuntu/templates/po/xdg-xubuntu-templates.pot	2017-02-14 11:16:45 +0000
@@ -0,0 +1,30 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2017-01-01 15:14-0500\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <l...@li.org>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: ../xdg-xubuntu-templates:12
+msgid "OpenDocument Text"
+msgstr ""
+
+#: ../xdg-xubuntu-templates:13
+msgid "OpenDocument Spreadsheet"
+msgstr ""
+
+#: ../xdg-xubuntu-templates:14
+msgid "Plain Text"
+msgstr ""

=== added file 'usr/share/xubuntu/templates/xdg-xubuntu-templates'
--- usr/share/xubuntu/templates/xdg-xubuntu-templates	1970-01-01 00:00:00 +0000
+++ usr/share/xubuntu/templates/xdg-xubuntu-templates	2017-02-14 11:16:45 +0000
@@ -0,0 +1,91 @@
+#!/usr/bin/python3
+
+import os
+import subprocess
+import shutil
+
+from locale import gettext as _
+
+config_dir = os.path.expanduser("~/.config/xubuntu/")
+config_file = "xdg-xubuntu-templates.cfg"
+
+source_directory = "/usr/share/xubuntu/templates/"
+templates = {
+    "OpenDocument Text.odt": _("OpenDocument Text"),
+    "OpenDocument Spreadsheet.ods": _("OpenDocument Spreadsheet"),
+    "Plain Text.txt": _("Plain Text"),
+}
+
+
+def get_template_directory():
+    templates = subprocess.check_output(["xdg-user-dir", "TEMPLATES"]).strip()
+    templates = templates.decode("utf-8")
+    home = os.path.expanduser("~")
+    if home != templates:
+        return templates
+    if os.path.exists(templates):
+        return templates
+    return False
+
+
+def read_config():
+    global config_dir
+    global config_file
+
+    filename = os.path.join(config_dir, config_file)
+
+    created = []
+    if os.path.exists(filename):
+        with open(filename, 'r') as config:
+            for line in config.readlines():
+                created.append(line.strip())
+
+    print("Already created: " + ", ".join(created))
+    return created
+
+
+def write_config(created):
+    global config_dir
+    global config_file
+
+    if not os.path.exists(config_dir):
+        os.makedirs(config_dir)
+
+    filename = os.path.join(config_dir, config_file)
+
+    with open(filename, 'w') as config:
+        for template in created:
+            config.write(template + "\n")
+
+
+previous = read_config()
+created = previous
+
+template_dir = get_template_directory()
+if template_dir:
+    print("Found template directory: '%s'" % template_dir)
+    for filename in templates.keys():
+        if filename in previous:
+            print("'%s' already created" % filename)
+            continue
+
+        print("Copying template file: '%s'" % filename)
+
+        extension = os.path.splitext(filename)[1]
+
+        source_filename = os.path.join(source_directory, filename)
+        if not os.path.exists(source_filename):
+            print("'%s' does not exist" % source_filename)
+            continue
+
+        target_filename = templates[filename] + extension
+        target_filename = os.path.join(template_dir, target_filename)
+        if os.path.exists(target_filename):
+            print("'%s' already exists" % target_filename)
+            continue
+
+        print("%s => %s" % (source_filename, target_filename))
+        shutil.copy2(source_filename, target_filename)
+        created.append(filename)
+
+write_config(created)

_______________________________________________
Mailing list: https://launchpad.net/~xubuntu-dev
Post to     : xubuntu-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~xubuntu-dev
More help   : https://help.launchpad.net/ListHelp

Reply via email to