Skip to content

Commit e09d42f

Browse files
authored
Merge pull request #9584 from keymanapp/refactor/linux/renameOptions
refactor(linux): Rename defines to clarify purpose 🏘️
2 parents 9fbe5f6 + a03eca3 commit e09d42f

File tree

4 files changed

+31
-28
lines changed

4 files changed

+31
-28
lines changed

linux/ibus-keyman/src/keymanutil.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,8 @@ keyman_get_options_fromdconf(gchar *package_id,
335335
g_message("keyman_get_options_fromdconf");
336336

337337
// Obtain keyboard options from DConf
338-
gchar *path = g_strdup_printf("%s%s/%s/", KEYMAN_DCONF_PATH, package_id, keyboard_id);
339-
GSettings *child_settings = g_settings_new_with_path(KEYMAN_CHILD_DCONF_NAME, path);
338+
gchar *path = g_strdup_printf("%s%s/%s/", KEYMAN_DCONF_OPTIONS_PATH, package_id, keyboard_id);
339+
GSettings *child_settings = g_settings_new_with_path(KEYMAN_DCONF_OPTIONS_CHILD_NAME, path);
340340
gchar **options = NULL;
341341
if (child_settings != NULL)
342342
{
@@ -456,8 +456,8 @@ keyman_put_options_todconf(gchar *package_id,
456456
}
457457

458458
// Write to DConf
459-
gchar *path = g_strdup_printf("%s%s/%s/", KEYMAN_DCONF_PATH, package_id, keyboard_id);
460-
GSettings *child_settings = g_settings_new_with_path(KEYMAN_CHILD_DCONF_NAME, path);
459+
gchar *path = g_strdup_printf("%s%s/%s/", KEYMAN_DCONF_OPTIONS_PATH, package_id, keyboard_id);
460+
GSettings *child_settings = g_settings_new_with_path(KEYMAN_DCONF_OPTIONS_CHILD_NAME, path);
461461
if (child_settings != NULL)
462462
{
463463
g_message("writing keyboard options to DConf");

linux/ibus-keyman/src/keymanutil.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,14 @@
6161
#define KEYMAN_ENVIRONMENT_OPTIONS 3
6262

6363
// Path information for Keyman keyboard options in DConf
64-
#define KEYMAN_DCONF_NAME "com.keyman.options"
65-
#define KEYMAN_CHILD_DCONF_NAME "com.keyman.options.child"
66-
#define KEYMAN_DCONF_PATH "/desktop/ibus/keyman/options/"
64+
#define KEYMAN_DCONF_OPTIONS_NAME "com.keyman.options"
65+
#define KEYMAN_DCONF_OPTIONS_CHILD_NAME "com.keyman.options.child"
66+
// TODO: migrate to /com/keyman/options to better follow Gnome recommmendations
67+
// (https://docs.gtk.org/gio/class.Settings.html) (#9579)
68+
#define KEYMAN_DCONF_OPTIONS_PATH "/desktop/ibus/keyman/options/"
6769
#define KEYMAN_DCONF_OPTIONS_KEY "options"
6870

71+
6972
G_BEGIN_DECLS
7073

7174
void ibus_keyman_init (void);

linux/ibus-keyman/src/test/keymanutil_tests.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,27 @@
66
#define TEST_FIXTURE "keymanutil-test"
77

88
void
9-
delete_key(gchar* testname) {
10-
gchar *path = g_strdup_printf("%s%s/%s/", KEYMAN_DCONF_PATH, TEST_FIXTURE, testname);
11-
GSettings *settings = g_settings_new_with_path(KEYMAN_CHILD_DCONF_NAME, path);
9+
delete_options_key(gchar* testname) {
10+
gchar *path = g_strdup_printf("%s%s/%s/", KEYMAN_DCONF_OPTIONS_PATH, TEST_FIXTURE, testname);
11+
GSettings *settings = g_settings_new_with_path(KEYMAN_DCONF_OPTIONS_CHILD_NAME, path);
1212
g_settings_reset(settings, KEYMAN_DCONF_OPTIONS_KEY);
1313
g_object_unref(G_OBJECT(settings));
1414
g_free(path);
1515
}
1616

1717
void
18-
set_key(gchar* testname, gchar** options) {
19-
gchar *path = g_strdup_printf("%s%s/%s/", KEYMAN_DCONF_PATH, TEST_FIXTURE, testname);
20-
GSettings *settings = g_settings_new_with_path(KEYMAN_CHILD_DCONF_NAME, path);
18+
set_options_key(gchar* testname, gchar** options) {
19+
gchar *path = g_strdup_printf("%s%s/%s/", KEYMAN_DCONF_OPTIONS_PATH, TEST_FIXTURE, testname);
20+
GSettings *settings = g_settings_new_with_path(KEYMAN_DCONF_OPTIONS_CHILD_NAME, path);
2121
g_settings_set_strv(settings, KEYMAN_DCONF_OPTIONS_KEY, (const gchar* const*)options);
2222
g_object_unref(G_OBJECT(settings));
2323
g_free(path);
2424
}
2525

2626
gchar**
27-
get_key(gchar* testname) {
28-
gchar* path = g_strdup_printf("%s%s/%s/", KEYMAN_DCONF_PATH, TEST_FIXTURE, testname);
29-
GSettings* settings = g_settings_new_with_path(KEYMAN_CHILD_DCONF_NAME, path);
27+
get_options_key(gchar* testname) {
28+
gchar* path = g_strdup_printf("%s%s/%s/", KEYMAN_DCONF_OPTIONS_PATH, TEST_FIXTURE, testname);
29+
GSettings* settings = g_settings_new_with_path(KEYMAN_DCONF_OPTIONS_CHILD_NAME, path);
3030
gchar** result = g_settings_get_strv(settings, KEYMAN_DCONF_OPTIONS_KEY);
3131
g_object_unref(G_OBJECT(settings));
3232
g_free(path);
@@ -37,14 +37,14 @@ void
3737
test_keyman_put_options_todconf__new_key() {
3838
// Initialize
3939
gchar* testname = "test_keyman_put_options_todconf__new_key";
40-
delete_key(testname);
40+
delete_options_key(testname);
4141
gchar* value = g_strdup_printf("%d", g_test_rand_int());
4242

4343
// Execute
4444
keyman_put_options_todconf(TEST_FIXTURE, testname, "new_key", value);
4545

4646
// Verify
47-
gchar** options = get_key(testname);
47+
gchar** options = get_options_key(testname);
4848
gchar* expected = g_strdup_printf("new_key=%s", value);
4949
g_assert_nonnull(options);
5050
g_assert_cmpstr(options[0], ==, expected);
@@ -54,23 +54,23 @@ test_keyman_put_options_todconf__new_key() {
5454
g_free(expected);
5555
g_free(value);
5656
g_strfreev(options);
57-
delete_key(testname);
57+
delete_options_key(testname);
5858
}
5959

6060
void
6161
test_keyman_put_options_todconf__other_keys() {
6262
// Initialize
6363
gchar* testname = "test_keyman_put_options_todconf__other_keys";
64-
delete_key(testname);
64+
delete_options_key(testname);
6565
gchar* existingKeys[] = {"key1=val1", "key2=val2", NULL};
66-
set_key(testname, existingKeys);
66+
set_options_key(testname, existingKeys);
6767
gchar* value = g_strdup_printf("%d", g_test_rand_int());
6868

6969
// Execute
7070
keyman_put_options_todconf(TEST_FIXTURE, testname, "new_key", value);
7171

7272
// Verify
73-
gchar** options = get_key(testname);
73+
gchar** options = get_options_key(testname);
7474
gchar* expected = g_strdup_printf("new_key=%s", value);
7575
g_assert_nonnull(options);
7676
g_assert_cmpstr(options[0], ==, "key1=val1");
@@ -82,23 +82,23 @@ test_keyman_put_options_todconf__other_keys() {
8282
g_free(expected);
8383
g_free(value);
8484
g_strfreev(options);
85-
delete_key(testname);
85+
delete_options_key(testname);
8686
}
8787

8888
void
8989
test_keyman_put_options_todconf__existing_key() {
9090
// Initialize
9191
gchar* testname = "test_keyman_put_options_todconf__existing_key";
92-
delete_key(testname);
92+
delete_options_key(testname);
9393
gchar* existingKeys[] = {"key1=val1", "new_key=val2", NULL};
94-
set_key(testname, existingKeys);
94+
set_options_key(testname, existingKeys);
9595
gchar* value = g_strdup_printf("%d", g_test_rand_int());
9696

9797
// Execute
9898
keyman_put_options_todconf(TEST_FIXTURE, testname, "new_key", value);
9999

100100
// Verify
101-
gchar** options = get_key(testname);
101+
gchar** options = get_options_key(testname);
102102
gchar* expected = g_strdup_printf("new_key=%s", value);
103103
g_assert_nonnull(options);
104104
g_assert_cmpstr(options[0], ==, "key1=val1");
@@ -109,7 +109,7 @@ test_keyman_put_options_todconf__existing_key() {
109109
g_free(expected);
110110
g_free(value);
111111
g_strfreev(options);
112-
delete_key(testname);
112+
delete_options_key(testname);
113113
}
114114

115115
int

linux/keyman-config/.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Editor configuration, see https://editorconfig.org
2-
[*]
2+
[*.py]
33
indent_style = space
44
indent_size = 4
55

0 commit comments

Comments
 (0)