1 #include "e.h"
2 
3 static void *_create_data(E_Config_Dialog *cfd);
4 static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
5 static int _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
6 static int _basic_check_changed(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
7 static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
8 #if 0
9 static int _advanced_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
10 static Evas_Object *_advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
11 #endif
12 
13 struct _E_Config_Dialog_Data
14 {
15    int cnfmdlg_disabled;
16    int cfgdlg_auto_apply;
17    int cfgdlg_default_mode;
18    int cfgdlg_normal_wins;
19    int remember_windows;
20 };
21 
22 E_Config_Dialog *
e_int_config_dialogs(Evas_Object * parent EINA_UNUSED,const char * params EINA_UNUSED)23 e_int_config_dialogs(Evas_Object *parent EINA_UNUSED, const char *params EINA_UNUSED)
24 {
25    E_Config_Dialog *cfd;
26    E_Config_Dialog_View *v;
27 
28    if (e_config_dialog_find("E", "settings/dialogs")) return NULL;
29    v = E_NEW(E_Config_Dialog_View, 1);
30 
31    v->create_cfdata = _create_data;
32    v->free_cfdata = _free_data;
33    v->basic.apply_cfdata = _basic_apply_data;
34    v->basic.create_widgets = _basic_create_widgets;
35    v->basic.check_changed = _basic_check_changed;
36    v->override_auto_apply = 1;
37 
38    cfd = e_config_dialog_new(NULL, _("Dialog Settings"),
39 			     "E", "settings/dialogs",
40 			     "preferences-system", 0, v, NULL);
41    return cfd;
42 }
43 
44 static void
_fill_data(E_Config_Dialog_Data * cfdata)45 _fill_data(E_Config_Dialog_Data *cfdata)
46 {
47    cfdata->cnfmdlg_disabled = e_config->cnfmdlg_disabled;
48    cfdata->cfgdlg_auto_apply = e_config->cfgdlg_auto_apply;
49    cfdata->cfgdlg_default_mode = e_config->cfgdlg_default_mode;
50    cfdata->cfgdlg_normal_wins =  e_config->cfgdlg_normal_wins;
51    cfdata->remember_windows = (e_config->remember_internal_windows & E_REMEMBER_INTERNAL_DIALOGS);
52 }
53 
54 static void *
_create_data(E_Config_Dialog * cfd EINA_UNUSED)55 _create_data(E_Config_Dialog *cfd EINA_UNUSED)
56 {
57    E_Config_Dialog_Data *cfdata = E_NEW(E_Config_Dialog_Data, 1);
58    if (!cfdata) return NULL;
59    _fill_data(cfdata);
60    return cfdata;
61 }
62 
63 static void
_free_data(E_Config_Dialog * cfd EINA_UNUSED,E_Config_Dialog_Data * cfdata)64 _free_data(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfdata)
65 {
66    E_FREE(cfdata);
67 }
68 
69 static int
_basic_apply_data(E_Config_Dialog * cfd EINA_UNUSED,E_Config_Dialog_Data * cfdata)70 _basic_apply_data(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfdata)
71 {
72    e_config->cnfmdlg_disabled = cfdata->cnfmdlg_disabled;
73    /* Auto Apply is disabled in E for now */
74    /* (e_config->cfgdlg_auto_apply = cfdata->cfgdlg_auto_apply; */
75    e_config->cfgdlg_default_mode = cfdata->cfgdlg_default_mode;
76    e_config->cfgdlg_normal_wins = cfdata->cfgdlg_normal_wins;
77    if (cfdata->remember_windows)
78      e_config->remember_internal_windows |= E_REMEMBER_INTERNAL_DIALOGS;
79    else
80      e_config->remember_internal_windows &= ~E_REMEMBER_INTERNAL_DIALOGS;
81 
82    e_config_save_queue();
83    return 1;
84 }
85 
86 static int
_basic_check_changed(E_Config_Dialog * cfd EINA_UNUSED,E_Config_Dialog_Data * cfdata)87 _basic_check_changed(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfdata)
88 {
89    int remember = e_config->remember_internal_windows;
90    if (cfdata->remember_windows)
91      remember |= E_REMEMBER_INTERNAL_DIALOGS;
92    else
93      remember &= ~E_REMEMBER_INTERNAL_DIALOGS;
94 
95    return ((e_config->cnfmdlg_disabled != cfdata->cnfmdlg_disabled) ||
96 	   (e_config->cfgdlg_default_mode != cfdata->cfgdlg_default_mode) ||
97 	   (e_config->cfgdlg_normal_wins != cfdata->cfgdlg_normal_wins) ||
98 	   (e_config->remember_internal_windows != remember));
99 }
100 
101 static Evas_Object *
_basic_create_widgets(E_Config_Dialog * cfd EINA_UNUSED,Evas * evas,E_Config_Dialog_Data * cfdata)102 _basic_create_widgets(E_Config_Dialog *cfd EINA_UNUSED, Evas *evas, E_Config_Dialog_Data *cfdata)
103 {
104    Evas_Object *o, *of, *ob;
105    E_Radio_Group *rg;
106 
107    o = e_widget_list_add(evas, 0, 0);
108 
109    of = e_widget_framelist_add(evas, _("General Settings"), 0);
110 
111    ob = e_widget_check_add(evas, _("Disable Confirmation Dialogs"), &(cfdata->cnfmdlg_disabled));
112    e_widget_framelist_object_append(of, ob);
113    ob = e_widget_check_add(evas, _("Normal Windows"), &(cfdata->cfgdlg_normal_wins));
114    e_widget_framelist_object_append(of, ob);
115 //   ob = e_widget_check_add(evas, _("Auto-Apply Settings Changes"), &(cfdata->cfgdlg_auto_apply));
116 //   e_widget_framelist_object_append(of, ob);
117 
118    e_widget_list_object_append(o, of, 1, 0, 0.5);
119 
120    of = e_widget_framelist_add(evas, _("Default Settings Dialogs Mode"), 0);
121    rg = e_widget_radio_group_new(&(cfdata->cfgdlg_default_mode));
122    ob = e_widget_radio_add(evas, _("Basic Mode"), E_CONFIG_DIALOG_CFDATA_TYPE_BASIC, rg);
123    e_widget_framelist_object_append(of, ob);
124    ob = e_widget_radio_add(evas, _("Advanced Mode"), E_CONFIG_DIALOG_CFDATA_TYPE_ADVANCED, rg);
125    e_widget_framelist_object_append(of, ob);
126    e_widget_list_object_append(o, of, 1, 0, 0.5);
127 
128    of = e_widget_framelist_add(evas, _("Remember"), 0);
129    ob = e_widget_check_add(evas, _("Remember size and position of dialogs"),
130                            &(cfdata->remember_windows));
131    e_widget_framelist_object_append(of, ob);
132    e_widget_list_object_append(o, of, 1, 0, 0.5);
133 
134    return o;
135 }
136 
137 #if 0
138 static int
139 _advanced_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
140 {
141    /* Auto Apply is disabled in E for now */
142    /* (e_config->cfgdlg_auto_apply = cfdata->auto_apply; */
143 
144    e_config->cfgdlg_default_mode = cfdata->default_mode;
145    e_config->cfgdlg_normal_wins = cfdata->cfgdlg_normal_wins;
146    e_config_save_queue();
147    return 1;
148 }
149 
150 static Evas_Object *
151 _advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
152 {
153    Evas_Object *o, *ob, *of;
154    E_Radio_Group *rg;
155 
156    o = e_widget_list_add(evas, 0, 0);
157 
158 //   of = e_widget_framelist_add(evas, _("General Settings"), 0);
159 //   ob = e_widget_check_add(evas, _("Auto-Apply Settings Changes"), &(cfdata->auto_apply));
160 //   e_widget_framelist_object_append(of, ob);
161 //   e_widget_list_object_append(o, of, 1, 1, 0.5);
162 
163    of = e_widget_framelist_add(evas, _("Default Dialog Mode"), 0);
164    rg = e_widget_radio_group_new(&(cfdata->default_mode));
165 
166    ob = e_widget_radio_add(evas, _("Basic Mode"), E_CONFIG_DIALOG_CFDATA_TYPE_BASIC, rg);
167    e_widget_framelist_object_append(of, ob);
168    ob = e_widget_radio_add(evas, _("Advanced Mode"), E_CONFIG_DIALOG_CFDATA_TYPE_ADVANCED, rg);
169    e_widget_framelist_object_append(of, ob);
170 
171    e_widget_list_object_append(o, of, 1, 1, 0.5);
172    return o;
173 }
174 #endif
175 
176