about summary refs log tree commit diff stats
path: root/src/config
diff options
context:
space:
mode:
Diffstat (limited to 'src/config')
-rw-r--r--src/config/preferences.c63
-rw-r--r--src/config/preferences.h6
2 files changed, 69 insertions, 0 deletions
diff --git a/src/config/preferences.c b/src/config/preferences.c
index a3d9276a..2051e66b 100644
--- a/src/config/preferences.c
+++ b/src/config/preferences.c
@@ -65,6 +65,8 @@ static GKeyFile *prefs;
 gint log_maxsize = 0;
 
 static Autocomplete boolean_choice_ac;
+static Autocomplete message_trigger_ac;
+static Autocomplete room_trigger_ac;
 
 static void _save_prefs(void);
 static gchar* _get_preferences_file(void);
@@ -133,12 +135,33 @@ prefs_load(void)
     boolean_choice_ac = autocomplete_new();
     autocomplete_add(boolean_choice_ac, "on");
     autocomplete_add(boolean_choice_ac, "off");
+
+    message_trigger_ac = autocomplete_new();
+    gsize len = 0;
+    gchar **triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "message.trigger.list", &len, NULL);
+
+    int i;
+    for (i = 0; i < len; i++) {
+        autocomplete_add(message_trigger_ac, triggers[i]);
+    }
+    g_strfreev(triggers);
+
+    room_trigger_ac = autocomplete_new();
+    len = 0;
+    triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", &len, NULL);
+
+    for (i = 0; i < len; i++) {
+        autocomplete_add(room_trigger_ac, triggers[i]);
+    }
+    g_strfreev(triggers);
 }
 
 void
 prefs_close(void)
 {
     autocomplete_free(boolean_choice_ac);
+    autocomplete_free(message_trigger_ac);
+    autocomplete_free(room_trigger_ac);
     g_key_file_free(prefs);
     prefs = NULL;
 }
@@ -155,6 +178,30 @@ prefs_reset_boolean_choice(void)
     autocomplete_reset(boolean_choice_ac);
 }
 
+char*
+prefs_autocomplete_message_trigger(const char *const prefix)
+{
+    return autocomplete_complete(message_trigger_ac, prefix, TRUE);
+}
+
+void
+prefs_reset_message_trigger_ac(void)
+{
+    autocomplete_reset(message_trigger_ac);
+}
+
+char*
+prefs_autocomplete_room_trigger(const char *const prefix)
+{
+    return autocomplete_complete(room_trigger_ac, prefix, TRUE);
+}
+
+void
+prefs_reset_room_trigger_ac(void)
+{
+    autocomplete_reset(room_trigger_ac);
+}
+
 gboolean
 prefs_get_boolean(preference_t pref)
 {
@@ -613,6 +660,10 @@ prefs_add_msg_notify_trigger(const char * const text)
     gboolean res = conf_string_list_add(prefs, PREF_GROUP_NOTIFICATIONS, "message.trigger.list", text);
     _save_prefs();
 
+    if (res) {
+        autocomplete_add(message_trigger_ac, text);
+    }
+
     return res;
 }
 
@@ -622,6 +673,10 @@ prefs_remove_msg_notify_trigger(const char * const text)
     gboolean res = conf_string_list_remove(prefs, PREF_GROUP_NOTIFICATIONS, "message.trigger.list", text);
     _save_prefs();
 
+    if (res) {
+        autocomplete_remove(message_trigger_ac, text);
+    }
+
     return res;
 }
 
@@ -648,6 +703,10 @@ prefs_add_room_notify_trigger(const char * const text)
     gboolean res = conf_string_list_add(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", text);
     _save_prefs();
 
+    if (res) {
+        autocomplete_add(room_trigger_ac, text);
+    }
+
     return res;
 }
 
@@ -657,6 +716,10 @@ prefs_remove_room_notify_trigger(const char * const text)
     gboolean res = conf_string_list_remove(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", text);
     _save_prefs();
 
+    if (res) {
+        autocomplete_remove(room_trigger_ac, text);
+    }
+
     return res;
 }
 
diff --git a/src/config/preferences.h b/src/config/preferences.h
index acf62ddb..9038591d 100644
--- a/src/config/preferences.h
+++ b/src/config/preferences.h
@@ -135,9 +135,15 @@ void prefs_close(void);
 
 char* prefs_find_login(char *prefix);
 void prefs_reset_login_search(void);
+
 char* prefs_autocomplete_boolean_choice(const char *const prefix);
 void prefs_reset_boolean_choice(void);
 
+char* prefs_autocomplete_message_trigger(const char *const prefix);
+void prefs_reset_message_trigger_ac(void);
+char* prefs_autocomplete_room_trigger(const char *const prefix);
+void prefs_reset_room_trigger_ac(void);
+
 gint prefs_get_gone(void);
 void prefs_set_gone(gint value);
 
uration' href='/akspecs/aerc/commit/config/config.go?h=0.2.1&id=b5d5e0dbedee34bd5d3edf13616f055d4f227d36'>b5d5e0d ^
77c76ba ^




b5d5e0d ^



77c76ba ^
b5d5e0d ^












39c93d2 ^
39c93d2 ^



a0be5e8 ^

39c93d2 ^



8d20e92 ^


39c93d2 ^














8d20e92 ^
a729179 ^


39c93d2 ^
8d20e92 ^








b5d5e0d ^





39c93d2 ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140