Merge lp:~bluesabre/xubuntu-default-settings/xubuntu-templates into lp:~xubuntu-dev/xubuntu-default-settings/trunk

Proposed by Sean Davis
Status: Merged
Merged at revision: 631
Proposed branch: lp:~bluesabre/xubuntu-default-settings/xubuntu-templates
Merge into: lp:~xubuntu-dev/xubuntu-default-settings/trunk
Diff against target: 289 lines (+194/-8)
10 files modified
Makefile (+1/-1)
debian/changelog (+13/-0)
debian/control (+11/-5)
debian/copyright (+1/-1)
debian/rules (+1/-1)
etc/xdg/xdg-xubuntu/autostart/xdg-xubuntu-templates.desktop (+3/-0)
usr/share/xubuntu/templates/po/Makefile (+24/-0)
usr/share/xubuntu/templates/po/POTFILES.in (+1/-0)
usr/share/xubuntu/templates/po/xdg-xubuntu-templates.pot (+30/-0)
usr/share/xubuntu/templates/xdg-xubuntu-templates (+109/-0)
To merge this branch: bzr merge lp:~bluesabre/xubuntu-default-settings/xubuntu-templates
Reviewer Review Type Date Requested Status
Xubuntu Developers Pending
Review via email: mp+317186@code.launchpad.net

Description of the change

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

[xubuntu-dev] Add Create document templates with translations for default apps: INPROGRESS

To post a comment you must log in.
632. By Sean Davis on 2017-02-15

Packaging updates for Python, use XDG_CONFIG_HOME, add copyright and fix error handling in xdg-xubuntu-templates

633. By Sean Davis on 2017-02-15

Add missing changelog info

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2014-08-19 01:45:00 +0000
3+++ Makefile 2017-02-15 02:23:33 +0000
4@@ -1,6 +1,6 @@
5 #!/usr/bin/make -f
6
7-SUBDIRS := etc/xdg/xdg-xubuntu/Thunar/po usr/share/xubuntu/applications/po usr/share/polkit-1/actions/po
8+SUBDIRS := etc/xdg/xdg-xubuntu/Thunar/po usr/share/polkit-1/actions/po usr/share/xubuntu/applications/po usr/share/xubuntu/templates/po
9
10 all:
11 @echo "Nothing to build, call 'make install' instead."
12
13=== modified file 'debian/changelog'
14--- debian/changelog 2016-09-28 10:06:39 +0000
15+++ debian/changelog 2017-02-15 02:23:33 +0000
16@@ -1,3 +1,16 @@
17+xubuntu-default-settings (17.04.0) UNRELEASED; urgency=medium
18+
19+ * Add default document templates
20+ - debian/copyright
21+ - etc/xdg/xdg-xubuntu/autostart/xdg-xubuntu-templates.desktop
22+ - usr/share/xubuntu/templates/*
23+ - usr/share/xubuntu/templates/po/*
24+ * debian/control, debian/rules:
25+ - Bump to Standards Version 3.9.8
26+ - Add python3 dependencies for new xdg-xubuntu-templates script
27+
28+ -- Sean Davis <smd.seandavis@gmail.com> Tue, 14 Feb 2017 21:22:54 -0500
29+
30 xubuntu-default-settings (16.10.2) yakkety; urgency=medium
31
32 * Revert systemd user unit changes (LP: #1622303)
33
34=== modified file 'debian/control'
35--- debian/control 2016-07-26 12:52:16 +0000
36+++ debian/control 2017-02-15 02:23:33 +0000
37@@ -2,8 +2,8 @@
38 Section: x11
39 Priority: optional
40 Maintainer: Xubuntu Developers <xubuntu-devel@lists.ubuntu.com>
41-Build-Depends: debhelper (>= 9), intltool
42-Standards-Version: 3.9.6
43+Build-Depends: debhelper (>= 9), intltool, python3
44+Standards-Version: 3.9.8
45 Homepage: https://launchpad.net/xubuntu-default-settings
46 Vcs-Bzr: lp:xubuntu-default-settings
47 Vcs-Browser: http://bazaar.launchpad.net/~xubuntu-dev/xubuntu-default-settings/trunk/files
48@@ -11,10 +11,16 @@
49 Package: xubuntu-default-settings
50 Architecture: all
51 Pre-Depends: ${misc:Pre-Depends}
52-Depends: ${misc:Depends}, xubuntu-artwork (>= 12.10.1~), fonts-noto-hinted,
53- x11-common (>= 1:7.6+7ubuntu2), lightdm-gtk-greeter (>= 2.0.1-1),
54+Depends:
55+ ${misc:Depends},
56+ ${python3:Depends},
57+ xubuntu-artwork (>= 12.10.1~),
58+ fonts-noto-hinted,
59+ x11-common (>= 1:7.6+7ubuntu2),
60+ lightdm-gtk-greeter (>= 2.0.1-1),
61 xfce4-session (>= 4.12.1-3ubuntu2~),
62- dbus-user-session, systemd (>= 231-1~),
63+ dbus-user-session,
64+ systemd (>= 231-1~)
65 Recommends: libxfce4ui-utils
66 Breaks: upstart (<< 1.13.2-0ubuntu28~)
67 Provides: lightdm-gtk-greeter-config
68
69=== modified file 'debian/copyright'
70--- debian/copyright 2014-10-26 22:39:06 +0000
71+++ debian/copyright 2017-02-15 02:23:33 +0000
72@@ -3,7 +3,7 @@
73 Upstream-Contact: Xubuntu Team <xubuntu-devel@lists.ubuntu.com>
74
75 Files: *
76-Copyright: 2013-2014, Sean Davis <bluesabre@ubuntu.com>
77+Copyright: 2013-2017, Sean Davis <bluesabre@ubuntu.com>
78 2007-2011, Lionel Le Folgoc <mrpouit@ubuntu.com>
79 2007-2009, Cody A.W. Somerville <cody-somerville@ubuntu.com>
80 2006-2008, Gauvain Pocentek <gauvainpocentek@ubuntu.com>
81
82=== modified file 'debian/rules'
83--- debian/rules 2011-11-19 19:35:17 +0000
84+++ debian/rules 2017-02-15 02:23:33 +0000
85@@ -7,4 +7,4 @@
86 dh_installgsettings --priority=20
87
88 %:
89- dh $@
90+ dh $@ --with python3
91
92=== added file 'etc/xdg/xdg-xubuntu/autostart/xdg-xubuntu-templates.desktop'
93--- etc/xdg/xdg-xubuntu/autostart/xdg-xubuntu-templates.desktop 1970-01-01 00:00:00 +0000
94+++ etc/xdg/xdg-xubuntu/autostart/xdg-xubuntu-templates.desktop 2017-02-15 02:23:33 +0000
95@@ -0,0 +1,3 @@
96+[Desktop Entry]
97+Name=Xubuntu Templates
98+Exec=/usr/share/xubuntu/templates/xdg-xubuntu-templates
99
100=== added directory 'usr/share/xubuntu/templates'
101=== added file 'usr/share/xubuntu/templates/OpenDocument Spreadsheet.ods'
102Binary 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-15 02:23:33 +0000 differ
103=== added file 'usr/share/xubuntu/templates/OpenDocument Text.odt'
104Binary 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-15 02:23:33 +0000 differ
105=== added file 'usr/share/xubuntu/templates/Plain Text.txt'
106=== added directory 'usr/share/xubuntu/templates/po'
107=== added file 'usr/share/xubuntu/templates/po/Makefile'
108--- usr/share/xubuntu/templates/po/Makefile 1970-01-01 00:00:00 +0000
109+++ usr/share/xubuntu/templates/po/Makefile 2017-02-15 02:23:33 +0000
110@@ -0,0 +1,24 @@
111+#!/usr/bin/make -f
112+
113+POTFILES := $(shell cat POTFILES.in)
114+
115+all: generate-locales
116+
117+generate-pot: POTFILES.in
118+ intltool-update --pot --gettext-package=xdg-xubuntu-templates
119+
120+generate-locales:
121+ for i in $$(find $$1 -name *.po); do \
122+ code=$$(echo $$i | sed 's/.po//'); \
123+ mkdir -p locale/$$code/LC_MESSAGES/; \
124+ msgfmt -o locale/$$code/LC_MESSAGES/xdg-xubuntu-templates.mo $$i; \
125+ done; \
126+ mv locale ../../../
127+
128+update-po:
129+ for i in *.po; do \
130+ code=$$(echo $$i | sed 's/.po//'); \
131+ intltool-update --gettext-package=xdg-xubuntu-templates --dist $$code; \
132+ done
133+
134+# vim:ts=4
135
136=== added file 'usr/share/xubuntu/templates/po/POTFILES.in'
137--- usr/share/xubuntu/templates/po/POTFILES.in 1970-01-01 00:00:00 +0000
138+++ usr/share/xubuntu/templates/po/POTFILES.in 2017-02-15 02:23:33 +0000
139@@ -0,0 +1,1 @@
140+xdg-xubuntu-templates
141
142=== added file 'usr/share/xubuntu/templates/po/xdg-xubuntu-templates.pot'
143--- usr/share/xubuntu/templates/po/xdg-xubuntu-templates.pot 1970-01-01 00:00:00 +0000
144+++ usr/share/xubuntu/templates/po/xdg-xubuntu-templates.pot 2017-02-15 02:23:33 +0000
145@@ -0,0 +1,30 @@
146+# SOME DESCRIPTIVE TITLE.
147+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
148+# This file is distributed under the same license as the PACKAGE package.
149+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
150+#
151+#, fuzzy
152+msgid ""
153+msgstr ""
154+"Project-Id-Version: PACKAGE VERSION\n"
155+"Report-Msgid-Bugs-To: \n"
156+"POT-Creation-Date: 2017-01-01 15:14-0500\n"
157+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
158+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
159+"Language-Team: LANGUAGE <LL@li.org>\n"
160+"Language: \n"
161+"MIME-Version: 1.0\n"
162+"Content-Type: text/plain; charset=CHARSET\n"
163+"Content-Transfer-Encoding: 8bit\n"
164+
165+#: ../xdg-xubuntu-templates:12
166+msgid "OpenDocument Text"
167+msgstr ""
168+
169+#: ../xdg-xubuntu-templates:13
170+msgid "OpenDocument Spreadsheet"
171+msgstr ""
172+
173+#: ../xdg-xubuntu-templates:14
174+msgid "Plain Text"
175+msgstr ""
176
177=== added file 'usr/share/xubuntu/templates/xdg-xubuntu-templates'
178--- usr/share/xubuntu/templates/xdg-xubuntu-templates 1970-01-01 00:00:00 +0000
179+++ usr/share/xubuntu/templates/xdg-xubuntu-templates 2017-02-15 02:23:33 +0000
180@@ -0,0 +1,109 @@
181+#!/usr/bin/python3
182+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
183+# Copyright (C) 2017 Sean Davis <bluesabre@ubuntu.com>
184+#
185+# This program is free software: you can redistribute it and/or modify it
186+# under the terms of the GNU General Public License as published by
187+# the Free Software Foundation, either version 2 of the License, or
188+# (at your option) any later version.
189+#
190+# This program is distributed in the hope that it will be useful, but
191+# WITHOUT ANY WARRANTY; without even the implied warranties of
192+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
193+# PURPOSE. See the GNU General Public License for more details.
194+#
195+# You should have received a copy of the GNU General Public License along
196+# with this program. If not, see <http://www.gnu.org/licenses/>.
197+
198+import os
199+import subprocess
200+import shutil
201+
202+from locale import gettext as _
203+
204+config_dir = os.path.join(
205+ os.getenv('XDG_CONFIG_HOME', os.path.expanduser("~/.config/")), "xubuntu")
206+config_file = "xdg-xubuntu-templates.cfg"
207+
208+source_directory = "/usr/share/xubuntu/templates/"
209+templates = {
210+ "OpenDocument Text.odt": _("OpenDocument Text"),
211+ "OpenDocument Spreadsheet.ods": _("OpenDocument Spreadsheet"),
212+ "Plain Text.txt": _("Plain Text"),
213+}
214+
215+
216+def get_template_directory():
217+ templates = subprocess.check_output(["xdg-user-dir", "TEMPLATES"]).strip()
218+ templates = templates.decode("utf-8")
219+ home = os.path.expanduser("~")
220+ if home != templates:
221+ return templates
222+ if os.path.exists(templates):
223+ return templates
224+ return False
225+
226+
227+def read_config():
228+ global config_dir
229+ global config_file
230+
231+ filename = os.path.join(config_dir, config_file)
232+
233+ created = []
234+ if os.path.exists(filename):
235+ with open(filename, 'r') as config:
236+ for line in config.readlines():
237+ created.append(line.strip())
238+
239+ print("Already created: " + ", ".join(created))
240+ return created
241+
242+
243+def write_config(created):
244+ global config_dir
245+ global config_file
246+
247+ filename = os.path.join(config_dir, config_file)
248+
249+ try:
250+ if not os.path.exists(config_dir):
251+ os.makedirs(config_dir)
252+
253+ with open(filename, 'w') as config:
254+ for template in created:
255+ config.write(template + "\n")
256+ except PermissionError:
257+ print("Unable to write config to %s" % filename)
258+
259+previous = read_config()
260+created = previous
261+
262+template_dir = get_template_directory()
263+if template_dir:
264+ print("Found template directory: '%s'" % template_dir)
265+ for filename in templates.keys():
266+ if filename in previous:
267+ print("'%s' already created" % filename)
268+ continue
269+
270+ print("Copying template file: '%s'" % filename)
271+
272+ extension = os.path.splitext(filename)[1]
273+
274+ source_filename = os.path.join(source_directory, filename)
275+ if not os.path.exists(source_filename):
276+ print("'%s' does not exist" % source_filename)
277+ continue
278+
279+ target_filename = templates[filename] + extension
280+ target_filename = os.path.join(template_dir, target_filename)
281+ if os.path.exists(target_filename):
282+ print("'%s' already exists" % target_filename)
283+ continue
284+
285+ print("%s => %s" % (source_filename, target_filename))
286+ shutil.copy2(source_filename, target_filename)
287+ created.append(filename)
288+
289+write_config(created)

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: