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

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

633. By Sean Davis

Add missing changelog info

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Makefile'
--- Makefile 2014-08-19 01:45:00 +0000
+++ Makefile 2017-02-15 02:23:33 +0000
@@ -1,6 +1,6 @@
1#!/usr/bin/make -f1#!/usr/bin/make -f
22
3SUBDIRS := etc/xdg/xdg-xubuntu/Thunar/po usr/share/xubuntu/applications/po usr/share/polkit-1/actions/po3SUBDIRS := etc/xdg/xdg-xubuntu/Thunar/po usr/share/polkit-1/actions/po usr/share/xubuntu/applications/po usr/share/xubuntu/templates/po
44
5all:5all:
6 @echo "Nothing to build, call 'make install' instead."6 @echo "Nothing to build, call 'make install' instead."
77
=== modified file 'debian/changelog'
--- debian/changelog 2016-09-28 10:06:39 +0000
+++ debian/changelog 2017-02-15 02:23:33 +0000
@@ -1,3 +1,16 @@
1xubuntu-default-settings (17.04.0) UNRELEASED; urgency=medium
2
3 * Add default document templates
4 - debian/copyright
5 - etc/xdg/xdg-xubuntu/autostart/xdg-xubuntu-templates.desktop
6 - usr/share/xubuntu/templates/*
7 - usr/share/xubuntu/templates/po/*
8 * debian/control, debian/rules:
9 - Bump to Standards Version 3.9.8
10 - Add python3 dependencies for new xdg-xubuntu-templates script
11
12 -- Sean Davis <smd.seandavis@gmail.com> Tue, 14 Feb 2017 21:22:54 -0500
13
1xubuntu-default-settings (16.10.2) yakkety; urgency=medium14xubuntu-default-settings (16.10.2) yakkety; urgency=medium
215
3 * Revert systemd user unit changes (LP: #1622303)16 * Revert systemd user unit changes (LP: #1622303)
417
=== modified file 'debian/control'
--- debian/control 2016-07-26 12:52:16 +0000
+++ debian/control 2017-02-15 02:23:33 +0000
@@ -2,8 +2,8 @@
2Section: x112Section: x11
3Priority: optional3Priority: optional
4Maintainer: Xubuntu Developers <xubuntu-devel@lists.ubuntu.com>4Maintainer: Xubuntu Developers <xubuntu-devel@lists.ubuntu.com>
5Build-Depends: debhelper (>= 9), intltool5Build-Depends: debhelper (>= 9), intltool, python3
6Standards-Version: 3.9.66Standards-Version: 3.9.8
7Homepage: https://launchpad.net/xubuntu-default-settings7Homepage: https://launchpad.net/xubuntu-default-settings
8Vcs-Bzr: lp:xubuntu-default-settings8Vcs-Bzr: lp:xubuntu-default-settings
9Vcs-Browser: http://bazaar.launchpad.net/~xubuntu-dev/xubuntu-default-settings/trunk/files9Vcs-Browser: http://bazaar.launchpad.net/~xubuntu-dev/xubuntu-default-settings/trunk/files
@@ -11,10 +11,16 @@
11Package: xubuntu-default-settings11Package: xubuntu-default-settings
12Architecture: all12Architecture: all
13Pre-Depends: ${misc:Pre-Depends}13Pre-Depends: ${misc:Pre-Depends}
14Depends: ${misc:Depends}, xubuntu-artwork (>= 12.10.1~), fonts-noto-hinted,14Depends:
15 x11-common (>= 1:7.6+7ubuntu2), lightdm-gtk-greeter (>= 2.0.1-1),15 ${misc:Depends},
16 ${python3:Depends},
17 xubuntu-artwork (>= 12.10.1~),
18 fonts-noto-hinted,
19 x11-common (>= 1:7.6+7ubuntu2),
20 lightdm-gtk-greeter (>= 2.0.1-1),
16 xfce4-session (>= 4.12.1-3ubuntu2~),21 xfce4-session (>= 4.12.1-3ubuntu2~),
17 dbus-user-session, systemd (>= 231-1~),22 dbus-user-session,
23 systemd (>= 231-1~)
18Recommends: libxfce4ui-utils24Recommends: libxfce4ui-utils
19Breaks: upstart (<< 1.13.2-0ubuntu28~)25Breaks: upstart (<< 1.13.2-0ubuntu28~)
20Provides: lightdm-gtk-greeter-config26Provides: lightdm-gtk-greeter-config
2127
=== modified file 'debian/copyright'
--- debian/copyright 2014-10-26 22:39:06 +0000
+++ debian/copyright 2017-02-15 02:23:33 +0000
@@ -3,7 +3,7 @@
3Upstream-Contact: Xubuntu Team <xubuntu-devel@lists.ubuntu.com>3Upstream-Contact: Xubuntu Team <xubuntu-devel@lists.ubuntu.com>
44
5Files: *5Files: *
6Copyright: 2013-2014, Sean Davis <bluesabre@ubuntu.com>6Copyright: 2013-2017, Sean Davis <bluesabre@ubuntu.com>
7 2007-2011, Lionel Le Folgoc <mrpouit@ubuntu.com>7 2007-2011, Lionel Le Folgoc <mrpouit@ubuntu.com>
8 2007-2009, Cody A.W. Somerville <cody-somerville@ubuntu.com>8 2007-2009, Cody A.W. Somerville <cody-somerville@ubuntu.com>
9 2006-2008, Gauvain Pocentek <gauvainpocentek@ubuntu.com>9 2006-2008, Gauvain Pocentek <gauvainpocentek@ubuntu.com>
1010
=== modified file 'debian/rules'
--- debian/rules 2011-11-19 19:35:17 +0000
+++ debian/rules 2017-02-15 02:23:33 +0000
@@ -7,4 +7,4 @@
7 dh_installgsettings --priority=207 dh_installgsettings --priority=20
88
9%:9%:
10 dh $@10 dh $@ --with python3
1111
=== 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-15 02:23:33 +0000
@@ -0,0 +1,3 @@
1[Desktop Entry]
2Name=Xubuntu Templates
3Exec=/usr/share/xubuntu/templates/xdg-xubuntu-templates
04
=== added directory 'usr/share/xubuntu/templates'
=== added file 'usr/share/xubuntu/templates/OpenDocument Spreadsheet.ods'
1Binary 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 differ5Binary 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
=== added file 'usr/share/xubuntu/templates/OpenDocument Text.odt'
2Binary 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 differ6Binary 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
=== 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-15 02:23:33 +0000
@@ -0,0 +1,24 @@
1#!/usr/bin/make -f
2
3POTFILES := $(shell cat POTFILES.in)
4
5all: generate-locales
6
7generate-pot: POTFILES.in
8 intltool-update --pot --gettext-package=xdg-xubuntu-templates
9
10generate-locales:
11 for i in $$(find $$1 -name *.po); do \
12 code=$$(echo $$i | sed 's/.po//'); \
13 mkdir -p locale/$$code/LC_MESSAGES/; \
14 msgfmt -o locale/$$code/LC_MESSAGES/xdg-xubuntu-templates.mo $$i; \
15 done; \
16 mv locale ../../../
17
18update-po:
19 for i in *.po; do \
20 code=$$(echo $$i | sed 's/.po//'); \
21 intltool-update --gettext-package=xdg-xubuntu-templates --dist $$code; \
22 done
23
24# vim:ts=4
025
=== 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-15 02:23:33 +0000
@@ -0,0 +1,1 @@
1xdg-xubuntu-templates
02
=== 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-15 02:23:33 +0000
@@ -0,0 +1,30 @@
1# SOME DESCRIPTIVE TITLE.
2# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3# This file is distributed under the same license as the PACKAGE package.
4# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5#
6#, fuzzy
7msgid ""
8msgstr ""
9"Project-Id-Version: PACKAGE VERSION\n"
10"Report-Msgid-Bugs-To: \n"
11"POT-Creation-Date: 2017-01-01 15:14-0500\n"
12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14"Language-Team: LANGUAGE <LL@li.org>\n"
15"Language: \n"
16"MIME-Version: 1.0\n"
17"Content-Type: text/plain; charset=CHARSET\n"
18"Content-Transfer-Encoding: 8bit\n"
19
20#: ../xdg-xubuntu-templates:12
21msgid "OpenDocument Text"
22msgstr ""
23
24#: ../xdg-xubuntu-templates:13
25msgid "OpenDocument Spreadsheet"
26msgstr ""
27
28#: ../xdg-xubuntu-templates:14
29msgid "Plain Text"
30msgstr ""
031
=== 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-15 02:23:33 +0000
@@ -0,0 +1,109 @@
1#!/usr/bin/python3
2# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
3# Copyright (C) 2017 Sean Davis <bluesabre@ubuntu.com>
4#
5# This program is free software: you can redistribute it and/or modify it
6# under the terms of the GNU General Public License as published by
7# the Free Software Foundation, either version 2 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful, but
11# WITHOUT ANY WARRANTY; without even the implied warranties of
12# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
13# PURPOSE. See the GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License along
16# with this program. If not, see <http://www.gnu.org/licenses/>.
17
18import os
19import subprocess
20import shutil
21
22from locale import gettext as _
23
24config_dir = os.path.join(
25 os.getenv('XDG_CONFIG_HOME', os.path.expanduser("~/.config/")), "xubuntu")
26config_file = "xdg-xubuntu-templates.cfg"
27
28source_directory = "/usr/share/xubuntu/templates/"
29templates = {
30 "OpenDocument Text.odt": _("OpenDocument Text"),
31 "OpenDocument Spreadsheet.ods": _("OpenDocument Spreadsheet"),
32 "Plain Text.txt": _("Plain Text"),
33}
34
35
36def get_template_directory():
37 templates = subprocess.check_output(["xdg-user-dir", "TEMPLATES"]).strip()
38 templates = templates.decode("utf-8")
39 home = os.path.expanduser("~")
40 if home != templates:
41 return templates
42 if os.path.exists(templates):
43 return templates
44 return False
45
46
47def read_config():
48 global config_dir
49 global config_file
50
51 filename = os.path.join(config_dir, config_file)
52
53 created = []
54 if os.path.exists(filename):
55 with open(filename, 'r') as config:
56 for line in config.readlines():
57 created.append(line.strip())
58
59 print("Already created: " + ", ".join(created))
60 return created
61
62
63def write_config(created):
64 global config_dir
65 global config_file
66
67 filename = os.path.join(config_dir, config_file)
68
69 try:
70 if not os.path.exists(config_dir):
71 os.makedirs(config_dir)
72
73 with open(filename, 'w') as config:
74 for template in created:
75 config.write(template + "\n")
76 except PermissionError:
77 print("Unable to write config to %s" % filename)
78
79previous = read_config()
80created = previous
81
82template_dir = get_template_directory()
83if template_dir:
84 print("Found template directory: '%s'" % template_dir)
85 for filename in templates.keys():
86 if filename in previous:
87 print("'%s' already created" % filename)
88 continue
89
90 print("Copying template file: '%s'" % filename)
91
92 extension = os.path.splitext(filename)[1]
93
94 source_filename = os.path.join(source_directory, filename)
95 if not os.path.exists(source_filename):
96 print("'%s' does not exist" % source_filename)
97 continue
98
99 target_filename = templates[filename] + extension
100 target_filename = os.path.join(template_dir, target_filename)
101 if os.path.exists(target_filename):
102 print("'%s' already exists" % target_filename)
103 continue
104
105 print("%s => %s" % (source_filename, target_filename))
106 shutil.copy2(source_filename, target_filename)
107 created.append(filename)
108
109write_config(created)

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: