Merge lp:~michael-sheldon/ubuntu-system-settings/support-additional-keyboard-plugin-paths into lp:ubuntu-system-settings

Proposed by Michael Sheldon
Status: Merged
Approved by: Ken VanDine
Approved revision: 1379
Merged at revision: 1396
Proposed branch: lp:~michael-sheldon/ubuntu-system-settings/support-additional-keyboard-plugin-paths
Merge into: lp:ubuntu-system-settings
Diff against target: 105 lines (+35/-21)
2 files modified
plugins/language/language-plugin.cpp (+34/-21)
plugins/language/language-plugin.h (+1/-0)
To merge this branch: bzr merge lp:~michael-sheldon/ubuntu-system-settings/support-additional-keyboard-plugin-paths
Reviewer Review Type Date Requested Status
Ken VanDine Approve
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+256286@code.launchpad.net

Commit message

Allow system settings to find keyboard plugins in additional locations specified via gsettings.

Description of the change

Allow system settings to find keyboard plugins in additional locations specified via gsettings.

This depends on https://code.launchpad.net/~michael-sheldon/ubuntu-keyboard/custom-plugin-paths/+merge/256285 which adds the new setting to the schema.

It can be tested by installing the ubuntu-keyboard-tests package and adding "/usr/share/maliit/tests/ubuntu-keyboard/" to the plugin paths by running:

gsettings set com.canonical.keyboard.maliit plugin-paths "['/custom/share/maliit/plugins/com/ubuntu/lib', '/usr/share/maliit/tests/ubuntu-keyboard/']"

A layout called "Testlayout" should then be displayed in the settings panel.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ken VanDine (ken-vandine) wrote :

Please look into the test failures, they look related to your branch.

review: Needs Fixing
Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

The tests fail because the language plugin won't work without the corresponding keyboard branch (which makes required changes to the keyboard settings schema)

Revision history for this message
Ken VanDine (ken-vandine) wrote :

Looks fine and works as described

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/language/language-plugin.cpp'
2--- plugins/language/language-plugin.cpp 2014-09-02 15:44:19 +0000
3+++ plugins/language/language-plugin.cpp 2015-04-15 10:45:02 +0000
4@@ -28,6 +28,7 @@
5
6 #define KEY_ENABLED_LAYOUTS "enabled-languages"
7 #define KEY_CURRENT_LAYOUT "active-language"
8+#define KEY_PLUGIN_PATHS "plugin-paths"
9
10 #define LANGUAGE2LOCALE "/usr/share/language-tools/language2locale"
11 #define LAYOUTS_DIR "/usr/share/maliit/plugins/com/ubuntu/lib"
12@@ -96,6 +97,9 @@
13 m_user(nullptr),
14 m_maliitSettings(g_settings_new(UBUNTU_KEYBOARD_SCHEMA_ID))
15 {
16+ GVariantIter *iter;
17+ const gchar *path;
18+
19 if (m_manager != nullptr) {
20 g_object_ref(m_manager);
21
22@@ -109,6 +113,11 @@
23 G_CALLBACK(::managerLoaded), this);
24 }
25
26+ m_layoutPaths.append(LAYOUTS_DIR);
27+ g_settings_get(m_maliitSettings, KEY_PLUGIN_PATHS, "as", &iter);
28+ for (int i(0); g_variant_iter_next(iter, "&s", &path); i++) {
29+ m_layoutPaths.append(path);
30+ }
31 updateLanguageNamesAndCodes();
32 updateCurrentLanguage();
33 updateEnabledLayouts();
34@@ -353,13 +362,15 @@
35
36 icu::Locale locale(qPrintable(formatsLocale));
37 const char *code(locale.getLanguage());
38- QFileInfo fileInfo(QDir(LAYOUTS_DIR), code);
39-
40- if (fileInfo.exists() && fileInfo.isDir()) {
41- g_settings_set_string(m_maliitSettings,
42- KEY_CURRENT_LAYOUT, code);
43-
44- updateEnabledLayouts();
45+ for (int i = 0; i < m_layoutPaths.count(); i++) {
46+ QFileInfo fileInfo(QDir(m_layoutPaths.at(i)), code);
47+
48+ if (fileInfo.exists() && fileInfo.isDir()) {
49+ g_settings_set_string(m_maliitSettings,
50+ KEY_CURRENT_LAYOUT, code);
51+
52+ updateEnabledLayouts();
53+ }
54 }
55 } else {
56 QString formatsLocale(act_user_get_formats_locale(m_user));
57@@ -415,20 +426,22 @@
58 {
59 m_keyboardLayouts.clear();
60
61- QDir layoutsDir(LAYOUTS_DIR);
62- layoutsDir.setFilter(QDir::Dirs);
63- layoutsDir.setSorting(QDir::Name);
64-
65- QFileInfoList fileInfoList(layoutsDir.entryInfoList());
66-
67- for (QFileInfoList::const_iterator
68- i(fileInfoList.begin()); i != fileInfoList.end(); ++i) {
69- KeyboardLayout *layout(new KeyboardLayout(*i));
70-
71- if (!layout->language().isEmpty())
72- m_keyboardLayouts += layout;
73- else
74- delete layout;
75+ for (int i = 0; i < m_layoutPaths.count(); i++) {
76+ QDir layoutsDir(m_layoutPaths.at(i));
77+ layoutsDir.setFilter(QDir::Dirs);
78+ layoutsDir.setSorting(QDir::Name);
79+
80+ QFileInfoList fileInfoList(layoutsDir.entryInfoList());
81+
82+ for (QFileInfoList::const_iterator
83+ i(fileInfoList.begin()); i != fileInfoList.end(); ++i) {
84+ KeyboardLayout *layout(new KeyboardLayout(*i));
85+
86+ if (!layout->language().isEmpty())
87+ m_keyboardLayouts += layout;
88+ else
89+ delete layout;
90+ }
91 }
92
93 qSort(m_keyboardLayouts.begin(), m_keyboardLayouts.end(), compareLayouts);
94
95=== modified file 'plugins/language/language-plugin.h'
96--- plugins/language/language-plugin.h 2014-09-02 15:44:19 +0000
97+++ plugins/language/language-plugin.h 2015-04-15 10:45:02 +0000
98@@ -126,6 +126,7 @@
99 SubsetModel m_keyboardLayoutsModel;
100 SubsetModel m_spellCheckingModel;
101 SessionService m_sessionService;
102+ QStringList m_layoutPaths;
103 };
104
105 #endif // LANGUAGE_PLUGIN_H

Subscribers

People subscribed via source and target branches