1 #include "e.h"
2 
3 /* PROTOTYPES - same all the time */
4 static void *_create_data(E_Config_Dialog *cfd);
5 static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
6 static int _basic_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
7 static int _basic_check_changed(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
8 static Evas_Object *_basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
9 
10 /* Actual config data we will be playing with whil the dialog is active */
11 struct _E_Config_Dialog_Data
12 {
13    int kill_if_close_not_possible;
14    int kill_process;
15    double kill_timer_wait;
16    int ping_clients;
17    int ping_clients_interval;
18 };
19 
20 /* a nice easy setup function that does the dirty work */
21 E_Config_Dialog *
e_int_config_window_process(Evas_Object * parent EINA_UNUSED,const char * params EINA_UNUSED)22 e_int_config_window_process(Evas_Object *parent EINA_UNUSED, const char *params EINA_UNUSED)
23 {
24    E_Config_Dialog *cfd;
25    E_Config_Dialog_View *v;
26 
27    if (e_config_dialog_find("E", "windows/window_process"))
28      return NULL;
29    v = E_NEW(E_Config_Dialog_View, 1);
30 
31    /* methods */
32    v->create_cfdata = _create_data;
33    v->free_cfdata = _free_data;
34    v->basic.apply_cfdata = _basic_apply;
35    v->basic.create_widgets = _basic_create;
36    v->basic.check_changed = _basic_check_changed;
37 
38    /* create config diaolg for NULL object/data */
39    cfd = e_config_dialog_new(NULL, _("Window Process Management"),
40 			     "E", "windows/window_process",
41 			     "preferences-window-process", 0, v, NULL);
42    return cfd;
43 }
44 
45 static void *
_create_data(E_Config_Dialog * cfd EINA_UNUSED)46 _create_data(E_Config_Dialog *cfd EINA_UNUSED)
47 {
48    E_Config_Dialog_Data *cfdata;
49 
50    cfdata = E_NEW(E_Config_Dialog_Data, 1);
51    if (!cfdata) return NULL;
52    cfdata->kill_if_close_not_possible = e_config->kill_if_close_not_possible;
53    cfdata->kill_process = e_config->kill_process;
54    cfdata->kill_timer_wait = e_config->kill_timer_wait;
55    cfdata->ping_clients = e_config->ping_clients;
56    cfdata->ping_clients_interval = e_config->ping_clients_interval;
57    return cfdata;
58 }
59 
60 static void
_free_data(E_Config_Dialog * cfd EINA_UNUSED,E_Config_Dialog_Data * cfdata)61 _free_data(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfdata)
62 {
63    E_FREE(cfdata);
64 }
65 
66 static int
_basic_apply(E_Config_Dialog * cfd EINA_UNUSED,E_Config_Dialog_Data * cfdata)67 _basic_apply(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfdata)
68 {
69    e_config->kill_if_close_not_possible = cfdata->kill_if_close_not_possible;
70    e_config->kill_process = cfdata->kill_process;
71    e_config->kill_timer_wait = cfdata->kill_timer_wait;
72    e_config->ping_clients = cfdata->ping_clients;
73    e_config->ping_clients_interval = cfdata->ping_clients_interval;
74    e_config_save_queue();
75    return 1;
76 }
77 
78 static int
_basic_check_changed(E_Config_Dialog * cfd EINA_UNUSED,E_Config_Dialog_Data * cfdata)79 _basic_check_changed(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfdata)
80 {
81    return ((e_config->kill_if_close_not_possible != cfdata->kill_if_close_not_possible) ||
82            (e_config->kill_process != cfdata->kill_process) ||
83            (!EINA_DBL_EQ(e_config->kill_timer_wait, cfdata->kill_timer_wait)) ||
84            (e_config->ping_clients != cfdata->ping_clients) ||
85            (e_config->ping_clients_interval != cfdata->ping_clients_interval));
86 }
87 
88 static Evas_Object *
_basic_create(E_Config_Dialog * cfd EINA_UNUSED,Evas * evas,E_Config_Dialog_Data * cfdata)89 _basic_create(E_Config_Dialog *cfd EINA_UNUSED, Evas *evas, E_Config_Dialog_Data *cfdata)
90 {
91    Evas_Object *o, *ob;
92 
93    o = e_widget_list_add(evas, 0, 0);
94 
95    ob = e_widget_check_add(evas, _("Kill process if unclosable"), &(cfdata->kill_if_close_not_possible));
96    e_widget_list_object_append(o, ob, 1, 0, 0.5);
97    ob = e_widget_check_add(evas, _("Kill process instead of client"), &(cfdata->kill_process));
98    e_widget_list_object_append(o, ob, 1, 0, 0.5);
99    ob = e_widget_label_add(evas, _("Kill timeout:"));
100    e_widget_list_object_append(o, ob, 1, 0, 0.5);
101    ob = e_widget_slider_add(evas, 1, 0, _("%1.0f s"), 1.0, 30.0, 1.0, 0,
102                             &(cfdata->kill_timer_wait), NULL, 100);
103    e_widget_list_object_append(o, ob, 1, 0, 0.5);
104 
105    ob = e_widget_check_add(evas, _("Ping clients"), &(cfdata->ping_clients));
106    e_widget_list_object_append(o, ob, 1, 0, 0.5);
107    ob = e_widget_label_add(evas, _("Ping interval:"));
108    e_widget_list_object_append(o, ob, 1, 0, 0.5);
109    ob = e_widget_slider_add(evas, 1, 0, _("%1.0f ticks"), 1.0, 256.0, 1.0, 0,
110                             NULL, &(cfdata->ping_clients_interval), 100);
111    e_widget_list_object_append(o, ob, 1, 0, 0.5);
112 
113    return o;
114 }
115