aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/imfos/e_mod_config.c
blob: 00bf04def2eb1a11b319234cc6840555bb23c929 (plain) (blame)
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
#include <e.h>
#include <Eeze.h>
#include "e_mod_main.h"
#include "imfos_devices.h"

typedef struct _Imfos_Config_Panel
{
   Evas_Object *main;
   Evas_Object *current;
   Imfos_Device *dev;
   Imfos_Device *config;

} Imfos_Config_Panel;

static void _v4l_create(void);
static void _device_create(void);
static void *_create_data(E_Config_Dialog *cfd);
static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
static void _fill_data(E_Config_Dialog_Data *cfdata);
static Evas_Object *_basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
static int _apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);

Imfos_Config_Panel *_tmp_cfg = NULL;
static Evas_Object *_imfos_cam_widget = NULL;
int flipped = EINA_FALSE;


EAPI E_Config_Dialog *
e_mod_config_imfos(Evas_Object *parent, const char *params EINA_UNUSED)
{
   E_Config_Dialog *cfd = NULL;
   E_Config_Dialog_View *v = NULL;
   char buf[PATH_MAX];


   if (e_config_dialog_find("Imfos", "advanced/Imfos")) return NULL;

   v = E_NEW(E_Config_Dialog_View, 1);
   if (!v) return NULL;

   v->create_cfdata = _create_data;
   v->free_cfdata = _free_data;
   v->basic.create_widgets = _basic_create;
   v->basic.apply_cfdata = _apply;

   /* Icon */
   cfd = e_config_dialog_new(NULL, "Imfos module", "Imfos", "advanced/Imfos",
                             NULL, 0, v, NULL);
   return cfd;
}

static void *
_create_data(E_Config_Dialog *cfd)
{
   _tmp_cfg = calloc(1, sizeof(Imfos_Config_Panel));
   return NULL;
}

static void
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
{
   free(_tmp_cfg->config);
   free(_tmp_cfg);
   _tmp_cfg = NULL;
   _imfos_cam_widget = NULL;
}

static void
_fill_data(E_Config_Dialog_Data *cfdata)
{
}

static void
_imfos_device_changed(void *data)
{
   Imfos_Device *dev;

   dev = data;
   if (_tmp_cfg->dev)
     imfos_devices_cancel(_tmp_cfg->dev);
   _tmp_cfg->dev = dev;
   _tmp_cfg->config = malloc(sizeof(Imfos_Device));
   /* Warning just a copy ! */
   memcpy(_tmp_cfg->config, dev, sizeof(Imfos_Device));
   if (_tmp_cfg->current)
       evas_object_del(_tmp_cfg->current);
   _tmp_cfg->current = e_widget_list_add(evas_object_evas_get(_tmp_cfg->main), 0, 0);
   e_widget_list_object_append(_tmp_cfg->main, _tmp_cfg->current, 1, 0, 0.5);
   _device_create();
   printf ("sel %s\n", dev->name);

}

static void
_imfos_cam_widget_delete(void *data, Evas *evas, Evas_Object *obj, void *event_info)
{
   Imfos_Device *dev;

   dev = data;
   printf("deleting cam widget\n");

   dev->param.v4l.cam = NULL;
   imfos_devices_cancel(dev);
}

static void
_fill_devices(Evas *evas, Evas_Object *list)
{
   const Eina_List *devices, *l;
   Imfos_Device *dev;
   char buf[1024];
   Evas_Object *o;

   EINA_LIST_FOREACH(imfos_config->devices, l, dev)
     {
        snprintf(buf, sizeof(buf), "%s(%s)", dev->name, dev->dev_name);
        e_widget_ilist_append(list, NULL, buf, _imfos_device_changed, dev, NULL);
        printf("dev %s(%s)\n", dev->name, dev->dev_name);
     }
   e_widget_ilist_selected_set(list, 1);
   _imfos_device_changed(eina_list_data_get(imfos_config->devices));
}

static void
_v4l_create(void)
{
   Evas_Object *o;
   Evas *evas;
   Evas_Object *list;


   list = _tmp_cfg->current;
   evas = evas_object_evas_get(_tmp_cfg->current);

   printf("V4l panel\n");
   o = evas_object_image_filled_add(evas);
   evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
   evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   evas_object_size_hint_min_set(o, 320, 240);
   e_widget_list_object_append(list, o, 1, 1, 0.5);
   _tmp_cfg->dev->param.v4l.cam = o;
//   if (_tmp_cfg->config->enabled)
//     imfos_devices_run(_tmp_cfg->dev);
   evas_object_event_callback_add(o, EVAS_CALLBACK_DEL, _imfos_cam_widget_delete, _tmp_cfg->dev);

   o = e_widget_check_add(evas, "Flip camera", &flipped);
   e_widget_list_object_append(list, o, 1, 0, 0.5);

   o = e_widget_check_add(evas, "Set as the fallback", &flipped);
   e_widget_list_object_append(list, o, 1, 0, 0.5);
}

static void
_device_create(void)
{
   Evas_Object *o;
   Evas *evas;
   Evas_Object *list;
   char buf[4096];

   list = _tmp_cfg->current;
   evas = evas_object_evas_get(_tmp_cfg->current);

   printf("Device Create\n");
   o = e_widget_check_add(evas, "Enabled",
                          (int *)&_tmp_cfg->config->enabled);
   e_widget_list_object_append(list, o, 1, 0, 0.0);
   snprintf(buf, sizeof(buf), "Name : %s", _tmp_cfg->config->name);
   o = e_widget_label_add(evas, buf);
   e_widget_list_object_append(list, o, 1, 0, 0.0);
   snprintf(buf, sizeof(buf), "System path : %s", _tmp_cfg->config->syspath);
   o = e_widget_label_add(evas, buf);
   e_widget_list_object_append(list, o, 1, 0, 0.0);
   snprintf(buf, sizeof(buf), "Device path : %s", _tmp_cfg->config->dev_name);
   o = e_widget_label_add(evas, buf);
   e_widget_list_object_append(list, o, 1, 0, 0.0);
   o = e_widget_check_add(evas, "Lock the device path",
                          (int *)&_tmp_cfg->config->dev_name_locked);
   e_widget_list_object_append(list, o, 1, 0, 0.0);
   _v4l_create();
   o = e_widget_slider_add(evas, 1, 0, "Priority : %d", -100.0, 100.0, 5.0, 50,
                           NULL, &_tmp_cfg->config->priority, 110);
   e_widget_list_object_append(list, o, 1, 0, 0.5);
   o = e_widget_check_add(evas, "async", (int *)&_tmp_cfg->config->async);
   e_widget_list_object_append(list, o, 1, 0, 0.5);
   o = e_widget_check_add(evas, "Timeout", (int *)&_tmp_cfg->config->timeout_enabled);
   e_widget_list_object_append(list, o, 1, 0, 0.5);
   o = e_widget_slider_add(evas, 1, 0, "Timeout (%2.0f)", 0.0, 64580.0, 5.0, 0,
                           NULL, &_tmp_cfg->config->timeout, 110);
   e_widget_list_object_append(list, o, 1, 0, 0.5);
//   o = e_widget_radio_group_new((int*) &(_tmp_cfg->config->powersave_min_state));
//   e_widget_list_object_append(list, o, 1, 0, 0.5);
   o = e_widget_check_add(evas, "Force the login when detected",
                          (int*)&_tmp_cfg->config->auto_login);
   e_widget_list_object_append(list, o, 1, 0, 0.5);
   o = e_widget_check_add(evas, "Force the logoff when missmatch",
                          (int*)&_tmp_cfg->config->auto_logout);
   e_widget_list_object_append(list, o, 1, 0, 0.5);
   o = e_widget_check_add(evas, "Report the screensaver when detected",
                          (int*)&_tmp_cfg->config->auto_screen_on);
   e_widget_list_object_append(list, o, 1, 0, 0.5);
   o = e_widget_check_add(evas, "Enable the screensaver when missmatch",
                          (int*)&_tmp_cfg->config->auto_screen_off);
   e_widget_list_object_append(list, o, 1, 0, 0.5);


   /*
   powersave_min_state
   */

}


static Evas_Object *
_basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
{
   Evas_Object *list, *list_cam, *devices_list, *o;

   _tmp_cfg->main = e_widget_list_add(evas, 0, 1);

   o = e_widget_ilist_add(evas, 0, 0, NULL);
   e_widget_ilist_multi_select_set(o, EINA_FALSE);
   evas_object_size_hint_min_set(o, 160, 240);
   e_widget_list_object_append(_tmp_cfg->main, o, 1, 0, 0.5);
   evas_object_show(o);

   _fill_devices(evas, o);
   return _tmp_cfg->main;
}

static int
_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
{
}