Skip to content

Commit 7c68e16

Browse files
committed
Add new submodules
- in threading, multihreading decorators - in util, gettext initialization - in widgets, a ListEditor for string CRUD operations
1 parent e97e119 commit 7c68e16

File tree

12 files changed

+1039
-1
lines changed

12 files changed

+1039
-1
lines changed

makepot

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
xgettext --language=Python -cTRANSLATORS --keyword=_ --keyword=N_ --output=python-xapp.pot xapp/*.py xapp/*/*.py

meson.build

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,10 @@ project('python-xapp', version : '2.4.2', meson_version : '>=0.47.0')
33
pymod = import('python')
44
python3 = pymod.find_installation(get_option('python_target'))
55

6+
i18n = import('i18n')
7+
gettext_package = meson.project_name()
8+
podir = meson.source_root() / 'po'
9+
10+
subdir('po')
611
subdir('xapp')
712

po/LINGUAS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fr

po/fr.po

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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
7+
msgid ""
8+
msgstr ""
9+
"Project-Id-Version: linuxmint\n"
10+
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
11+
"POT-Creation-Date: 2025-07-28 12:48+0200\n"
12+
"PO-Revision-Date: 2025-07-28 11:29+0000\n"
13+
"Last-Translator: Clement Lefebvre <[email protected]>\n"
14+
"Language-Team: French <[email protected]>\n"
15+
"MIME-Version: 1.0\n"
16+
"Content-Type: text/plain; charset=UTF-8\n"
17+
"Content-Transfer-Encoding: 8bit\n"
18+
"Plural-Forms: nplurals=2; plural=n > 1;\n"
19+
"X-Launchpad-Export-Date: 2025-08-26 15:17+0000\n"
20+
"X-Generator: Launchpad (build 919009172d854f2b8e4e8262db447f12f11d25eb)\n"
21+
"Language: fr\n"
22+
23+
#: xapp/widgets/ListEditor.py:230
24+
msgid "Cancel"
25+
msgstr "Annuler"
26+
27+
#: xapp/widgets/ListEditor.py:233
28+
msgid "Save"
29+
msgstr "Enregistrer"
30+
31+
#: xapp/widgets/ListEditor.py:353
32+
msgid "Add"
33+
msgstr "Ajouter"
34+
35+
#: xapp/widgets/ListEditor.py:361
36+
msgid "Remove"
37+
msgstr "Retirer"
38+
39+
#: xapp/widgets/ListEditor.py:368
40+
msgid "Edit"
41+
msgstr "Modifier"
42+
43+
#: xapp/widgets/ListEditor.py:376
44+
msgid "Remove all"
45+
msgstr "Tout retirer"
46+
47+
#: xapp/widgets/ListEditor.py:485
48+
#, python-format
49+
msgid "'%s' is already in the list."
50+
msgstr ""
51+
52+
#: xapp/widgets/ListEditor.py:570
53+
msgid "Remove?"
54+
msgstr ""
55+
56+
#: xapp/widgets/ListEditor.py:572
57+
#, python-format
58+
msgid "Are you sure you want to remove '%s'?"
59+
msgstr ""
60+
61+
#: xapp/widgets/ListEditor.py:625
62+
msgid "Remove all?"
63+
msgstr ""
64+
65+
#: xapp/widgets/ListEditor.py:627
66+
msgid "This will remove all items from the list."
67+
msgstr ""

po/meson.build

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
i18n.gettext(gettext_package,
2+
preset: 'glib'
3+
)

python-xapp.pot

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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
7+
msgid ""
8+
msgstr ""
9+
"Project-Id-Version: PACKAGE VERSION\n"
10+
"Report-Msgid-Bugs-To: \n"
11+
"POT-Creation-Date: 2025-11-11 13:45+0000\n"
12+
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14+
"Language-Team: LANGUAGE <[email protected]>\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+
#: xapp/widgets/ListEditor.py:161
21+
msgid "Move up"
22+
msgstr ""
23+
24+
#: xapp/widgets/ListEditor.py:167
25+
msgid "Move down"
26+
msgstr ""
27+
28+
#: xapp/widgets/ListEditor.py:231
29+
msgid "Cancel"
30+
msgstr ""
31+
32+
#: xapp/widgets/ListEditor.py:234
33+
msgid "Save"
34+
msgstr ""
35+
36+
#: xapp/widgets/ListEditor.py:354
37+
msgid "Add"
38+
msgstr ""
39+
40+
#: xapp/widgets/ListEditor.py:362
41+
msgid "Remove"
42+
msgstr ""
43+
44+
#: xapp/widgets/ListEditor.py:369
45+
msgid "Edit"
46+
msgstr ""
47+
48+
#: xapp/widgets/ListEditor.py:377
49+
msgid "Remove all"
50+
msgstr ""
51+
52+
#: xapp/widgets/ListEditor.py:486
53+
#, python-format
54+
msgid "'%s' is already in the list."
55+
msgstr ""
56+
57+
#: xapp/widgets/ListEditor.py:571
58+
msgid "Remove?"
59+
msgstr ""
60+
61+
#: xapp/widgets/ListEditor.py:573
62+
#, python-format
63+
msgid "Are you sure you want to remove '%s'?"
64+
msgstr ""
65+
66+
#: xapp/widgets/ListEditor.py:626
67+
msgid "Remove all?"
68+
msgstr ""
69+
70+
#: xapp/widgets/ListEditor.py:628
71+
msgid "This will remove all items from the list."
72+
msgstr ""

xapp/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
__all__ = [ "os", "GSettingsWidgets", "SettingsWidgets" ]
1+
__all__ = [ "os", "GSettingsWidgets", "SettingsWidgets", "widgets", "threading", "util"]
22

33
__version__ = "2.4.1"

xapp/meson.build

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,25 @@ python3.install_sources(
66
'SettingsWidgets.py'
77
],
88
subdir: 'xapp'
9+
)
10+
11+
# Install widgets submodule files
12+
python3.install_sources(
13+
[
14+
'widgets/__init__.py',
15+
'widgets/ListEditor.py',
16+
],
17+
subdir: 'xapp/widgets'
18+
)
19+
python3.install_sources(
20+
[
21+
'threading/__init__.py',
22+
],
23+
subdir: 'xapp/threading'
24+
)
25+
python3.install_sources(
26+
[
27+
'util/__init__.py',
28+
],
29+
subdir: 'xapp/util'
930
)

xapp/threading/__init__.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import gi
2+
import threading
3+
4+
from gi.repository import GLib
5+
6+
# Decorator to run things in the background
7+
def run_async(func):
8+
def wrapper(*args, **kwargs):
9+
thread = threading.Thread(target=func, args=args, kwargs=kwargs)
10+
thread.daemon = True
11+
thread.start()
12+
return thread
13+
return wrapper
14+
15+
# Decorator to run things in the main Gtk loop
16+
def run_idle(func):
17+
def wrapper(*args):
18+
GLib.idle_add(func, *args)
19+
return wrapper
20+
21+
__all__ = ["run_async", "run_idle"]

xapp/util/__init__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
def l10n(domain, locale_dir="/usr/share/locale"):
3+
"""
4+
Initialize gettext and locale bindings for the given app.
5+
Returns:
6+
function: The gettext translation function `_` for convenience.
7+
"""
8+
import gettext
9+
import locale
10+
locale.bindtextdomain(domain, locale_dir)
11+
gettext.bindtextdomain(domain, locale_dir)
12+
gettext.textdomain(domain)
13+
return gettext.gettext
14+
15+
__all__ = ["l10n"]

0 commit comments

Comments
 (0)