summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlastair Poole <netstar@gmail.com>2020-05-12 19:09:03 +0100
committerAlastair Poole <netstar@gmail.com>2020-05-12 19:09:03 +0100
commit8d72d3624677fa6da5c4cf38560db8751a302910 (patch)
tree2d8a0a3bc75e58cfba9189515d11b1724c5e7ec4 /src
parent9cb83899b4778c9a4a6b5a9004f63662a7ea000c (diff)
e_conf_env: Display variable and assignment.
When setting a custom environment variable display the variable name and the value in NAME=VALUE format within the UI list. If the value string is long then use an ellipsis. Adds some clarity.
Diffstat (limited to 'src')
-rw-r--r--src/modules/conf_paths/e_int_config_env.c69
1 files changed, 44 insertions, 25 deletions
diff --git a/src/modules/conf_paths/e_int_config_env.c b/src/modules/conf_paths/e_int_config_env.c
index 4474a1bfd..bfcfa939c 100644
--- a/src/modules/conf_paths/e_int_config_env.c
+++ b/src/modules/conf_paths/e_int_config_env.c
@@ -10,10 +10,10 @@ struct _E_Config_Dialog_Data
10 E_Config_Dialog *cfd; 10 E_Config_Dialog *cfd;
11 11
12 Eina_List *env_vars; 12 Eina_List *env_vars;
13 13
14 char *var_str, *val_str; 14 char *var_str, *val_str;
15 int unset; 15 int unset;
16 16
17 struct { 17 struct {
18 Evas_Object *var_en, *val_en, *unset, *list; 18 Evas_Object *var_en, *val_en, *unset, *list;
19 } gui; 19 } gui;
@@ -27,15 +27,15 @@ e_int_config_env(Evas_Object *parent EINA_UNUSED, const char *params EINA_UNUSED
27 27
28 if (e_config_dialog_find("E", "advanced/environment_variables")) return NULL; 28 if (e_config_dialog_find("E", "advanced/environment_variables")) return NULL;
29 v = E_NEW(E_Config_Dialog_View, 1); 29 v = E_NEW(E_Config_Dialog_View, 1);
30 30
31 v->create_cfdata = _create_data; 31 v->create_cfdata = _create_data;
32 v->free_cfdata = _free_data; 32 v->free_cfdata = _free_data;
33 v->basic.create_widgets = _basic_create_widgets; 33 v->basic.create_widgets = _basic_create_widgets;
34 v->basic.apply_cfdata = _basic_apply_data; 34 v->basic.apply_cfdata = _basic_apply_data;
35 35
36 cfd = e_config_dialog_new(NULL, _("Environment Variables"), 36 cfd = e_config_dialog_new(NULL, _("Environment Variables"),
37 "E", "advanced/environment_variables", 37 "E", "advanced/environment_variables",
38 "preferences-system", 0, v, NULL); 38 "preferences-system", 0, v, NULL);
39 return cfd; 39 return cfd;
40} 40}
41 41
@@ -44,7 +44,7 @@ _fill_data(E_Config_Dialog_Data *cfdata)
44{ 44{
45 Eina_List *l; 45 Eina_List *l;
46 E_Config_Env_Var *evr, *evr2; 46 E_Config_Env_Var *evr, *evr2;
47 47
48 EINA_LIST_FOREACH(e_config->env_vars, l, evr) 48 EINA_LIST_FOREACH(e_config->env_vars, l, evr)
49 { 49 {
50 evr2 = E_NEW(E_Config_Env_Var, 1); 50 evr2 = E_NEW(E_Config_Env_Var, 1);
@@ -70,7 +70,7 @@ static void
70_free_data(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfdata) 70_free_data(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfdata)
71{ 71{
72 E_Config_Env_Var *evr; 72 E_Config_Env_Var *evr;
73 73
74 EINA_LIST_FREE(cfdata->env_vars, evr) 74 EINA_LIST_FREE(cfdata->env_vars, evr)
75 { 75 {
76 eina_stringshare_del(evr->var); 76 eina_stringshare_del(evr->var);
@@ -88,7 +88,7 @@ _basic_apply_data(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfdata
88 Eina_List *l, *l2; 88 Eina_List *l, *l2;
89 E_Config_Env_Var *evr, *evr2; 89 E_Config_Env_Var *evr, *evr2;
90 int same; 90 int same;
91 91
92 // old env vars removed from new set - unset 92 // old env vars removed from new set - unset
93 EINA_LIST_FOREACH(e_config->env_vars, l, evr) 93 EINA_LIST_FOREACH(e_config->env_vars, l, evr)
94 { 94 {
@@ -112,7 +112,7 @@ _basic_apply_data(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfdata
112 EINA_LIST_FOREACH(cfdata->env_vars, l, evr) 112 EINA_LIST_FOREACH(cfdata->env_vars, l, evr)
113 { 113 {
114 evr2 = E_NEW(E_Config_Env_Var, 1); 114 evr2 = E_NEW(E_Config_Env_Var, 1);
115 115
116 evr2->var = eina_stringshare_add(evr->var); 116 evr2->var = eina_stringshare_add(evr->var);
117 if (evr->val) evr2->val = eina_stringshare_add(evr->val); 117 if (evr->val) evr2->val = eina_stringshare_add(evr->val);
118 evr2->unset = evr->unset; 118 evr2->unset = evr->unset;
@@ -147,6 +147,24 @@ _sel_cb(void *data)
147 e_widget_entry_text_set(cfdata->gui.val_en, ""); 147 e_widget_entry_text_set(cfdata->gui.val_en, "");
148} 148}
149 149
150static const char *
151_env_text(E_Config_Env_Var *evr)
152{
153 static Eina_Slstr *text;
154 char *val;
155
156 val = strndup(evr->val, 64);
157
158 if (strlen(evr->val) > 64)
159 text = eina_slstr_printf("%s=%s...", evr->var, val);
160 else
161 text = eina_slstr_printf("%s=%s", evr->var, val);
162
163 free(val);
164
165 return text;
166}
167
150static void 168static void
151_add_cb(void *data, void *data2 EINA_UNUSED) 169_add_cb(void *data, void *data2 EINA_UNUSED)
152{ 170{
@@ -154,9 +172,9 @@ _add_cb(void *data, void *data2 EINA_UNUSED)
154 Eina_List *l; 172 Eina_List *l;
155 E_Config_Env_Var *evr = NULL; 173 E_Config_Env_Var *evr = NULL;
156 int i, sel = -1; 174 int i, sel = -1;
157 175
158 if (!cfdata->var_str) return; 176 if (!cfdata->var_str) return;
159 177
160 i = 0; 178 i = 0;
161 EINA_LIST_FOREACH(cfdata->env_vars, l, evr) 179 EINA_LIST_FOREACH(cfdata->env_vars, l, evr)
162 { 180 {
@@ -183,8 +201,8 @@ _add_cb(void *data, void *data2 EINA_UNUSED)
183 cfdata->unset = 0; 201 cfdata->unset = 0;
184 } 202 }
185 cfdata->env_vars = eina_list_append(cfdata->env_vars, evr); 203 cfdata->env_vars = eina_list_append(cfdata->env_vars, evr);
186 e_widget_ilist_append(cfdata->gui.list, NULL, 204 e_widget_ilist_append(cfdata->gui.list, NULL,
187 evr->var, _sel_cb, cfdata, NULL); 205 _env_text(evr), _sel_cb, cfdata, NULL);
188 e_widget_ilist_go(cfdata->gui.list); 206 e_widget_ilist_go(cfdata->gui.list);
189 sel = e_widget_ilist_count(cfdata->gui.list) - 1; 207 sel = e_widget_ilist_count(cfdata->gui.list) - 1;
190 e_widget_ilist_selected_set(cfdata->gui.list, sel); 208 e_widget_ilist_selected_set(cfdata->gui.list, sel);
@@ -206,6 +224,7 @@ _add_cb(void *data, void *data2 EINA_UNUSED)
206 if (sel >= 0) 224 if (sel >= 0)
207 { 225 {
208 e_widget_ilist_selected_set(cfdata->gui.list, sel); 226 e_widget_ilist_selected_set(cfdata->gui.list, sel);
227 e_widget_ilist_nth_label_set(cfdata->gui.list, sel, _env_text(evr));
209 e_widget_ilist_nth_show(cfdata->gui.list, sel, 0); 228 e_widget_ilist_nth_show(cfdata->gui.list, sel, 0);
210 } 229 }
211 } 230 }
@@ -220,7 +239,7 @@ _del_cb(void *data, void *data2 EINA_UNUSED)
220 int sel_n; 239 int sel_n;
221/* 240/*
222 int i, sel = -1; 241 int i, sel = -1;
223 242
224 EINA_LIST_FOREACH(cfdata->env_vars, l, evr) 243 EINA_LIST_FOREACH(cfdata->env_vars, l, evr)
225 { 244 {
226 if (!strcmp(cfdata->var_str, evr->var)) 245 if (!strcmp(cfdata->var_str, evr->var))
@@ -249,7 +268,7 @@ _del_cb(void *data, void *data2 EINA_UNUSED)
249 e_widget_ilist_freeze(cfdata->gui.list); 268 e_widget_ilist_freeze(cfdata->gui.list);
250 EINA_LIST_FOREACH(cfdata->env_vars, l, evr) 269 EINA_LIST_FOREACH(cfdata->env_vars, l, evr)
251 { 270 {
252 e_widget_ilist_append(cfdata->gui.list, NULL, evr->var, 271 e_widget_ilist_append(cfdata->gui.list, NULL, _env_text(evr),
253 _sel_cb, cfdata, NULL); 272 _sel_cb, cfdata, NULL);
254 } 273 }
255 e_widget_ilist_go(cfdata->gui.list); 274 e_widget_ilist_go(cfdata->gui.list);
@@ -278,36 +297,36 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
278 Evas_Object *o, *ol, *oe, *ob, *oc; 297 Evas_Object *o, *ol, *oe, *ob, *oc;
279 Eina_List *l; 298 Eina_List *l;
280 E_Config_Env_Var *evr; 299 E_Config_Env_Var *evr;
281 300
282 e_dialog_resizable_set(cfd->dia, 1); 301 e_dialog_resizable_set(cfd->dia, 1);
283 302
284 o = e_widget_table_add(e_win_evas_win_get(evas), 0); 303 o = e_widget_table_add(e_win_evas_win_get(evas), 0);
285 304
286 ol = e_widget_ilist_add(evas, 0, 0, NULL); 305 ol = e_widget_ilist_add(evas, 0, 0, NULL);
287 cfdata->gui.list = ol; 306 cfdata->gui.list = ol;
288 e_widget_ilist_freeze(ol); 307 e_widget_ilist_freeze(ol);
289 EINA_LIST_FOREACH(cfdata->env_vars, l, evr) 308 EINA_LIST_FOREACH(cfdata->env_vars, l, evr)
290 { 309 {
291 e_widget_ilist_append(ol, NULL, evr->var, _sel_cb, cfdata, NULL); 310 e_widget_ilist_append(ol, NULL, _env_text(evr), _sel_cb, cfdata, NULL);
292 } 311 }
293 e_widget_ilist_go(ol); 312 e_widget_ilist_go(ol);
294 e_widget_ilist_thaw(ol); 313 e_widget_ilist_thaw(ol);
295 e_widget_size_min_set(ol, 200, 160); 314 e_widget_size_min_set(ol, 200, 160);
296 e_widget_table_object_append(o, ol, 0, 0, 3, 1, 1, 1, 1, 1); 315 e_widget_table_object_append(o, ol, 0, 0, 3, 1, 1, 1, 1, 1);
297 316
298 oe = e_widget_entry_add(cfd->dia->win, &(cfdata->var_str), NULL, NULL, NULL); 317 oe = e_widget_entry_add(cfd->dia->win, &(cfdata->var_str), NULL, NULL, NULL);
299 cfdata->gui.var_en = oe; 318 cfdata->gui.var_en = oe;
300 e_widget_table_object_append(o, oe, 0, 1, 1, 1, 1, 1, 1, 0); 319 e_widget_table_object_append(o, oe, 0, 1, 1, 1, 1, 1, 1, 0);
301 320
302 oe = e_widget_entry_add(cfd->dia->win, &(cfdata->val_str), NULL, NULL, NULL); 321 oe = e_widget_entry_add(cfd->dia->win, &(cfdata->val_str), NULL, NULL, NULL);
303 cfdata->gui.val_en = oe; 322 cfdata->gui.val_en = oe;
304 e_widget_table_object_append(o, oe, 1, 1, 1, 1, 1, 1, 1, 0); 323 e_widget_table_object_append(o, oe, 1, 1, 1, 1, 1, 1, 1, 0);
305 324
306 oc = e_widget_check_add(evas, _("Unset"), &(cfdata->unset)); 325 oc = e_widget_check_add(evas, _("Unset"), &(cfdata->unset));
307 cfdata->gui.unset = oc; 326 cfdata->gui.unset = oc;
308 e_widget_table_object_append(o, oc, 2, 1, 1, 1, 1, 1, 1, 0); 327 e_widget_table_object_append(o, oc, 2, 1, 1, 1, 1, 1, 1, 0);
309 evas_object_smart_callback_add(oc, "changed", _unset_cb, cfdata); 328 evas_object_smart_callback_add(oc, "changed", _unset_cb, cfdata);
310 329
311 ob = e_widget_button_add(evas, _("Add"), "list-add", _add_cb, cfdata, NULL); 330 ob = e_widget_button_add(evas, _("Add"), "list-add", _add_cb, cfdata, NULL);
312 e_widget_table_object_append(o, ob, 0, 2, 1, 1, 1, 1, 0, 0); 331 e_widget_table_object_append(o, ob, 0, 2, 1, 1, 1, 1, 0, 0);
313 332
@@ -316,6 +335,6 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
316 335
317 ob = e_widget_button_add(evas, _("Delete"), "list-remove", _del_cb, cfdata, NULL); 336 ob = e_widget_button_add(evas, _("Delete"), "list-remove", _del_cb, cfdata, NULL);
318 e_widget_table_object_append(o, ob, 2, 2, 1, 1, 1, 1, 0, 0); 337 e_widget_table_object_append(o, ob, 2, 2, 1, 1, 1, 1, 0, 0);
319 338
320 return o; 339 return o;
321} 340}