2 #include "e_mod_main.h"
3 #include "e_mod_config.h"
4 #include "e_mod_physics.h"
6 struct _E_Config_Dialog_Data
8 double delay; /* delay before applying physics */
9 double max_mass; /* maximum mass for a window */
10 double gravity; /* maximum mass for a window */
11 Eina_Bool ignore_fullscreen;
12 Eina_Bool ignore_maximized;
13 Eina_Bool ignore_shelves;
16 Eina_Bool disable_rotate;
17 Eina_Bool disable_move;
22 static int _basic_check_changed(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata);
23 static void *_create_data(E_Config_Dialog *cfd);
24 static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
25 static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
26 static int _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
29 e_int_config_physics_module(E_Container *con,
30 const char *params __UNUSED__)
33 E_Config_Dialog_View *v;
35 Mod *mod = _physics_mod;
37 if (mod->config_dialog) return NULL;
38 snprintf(buf, sizeof(buf), "%s/e-module-physics.edj", e_module_dir_get(mod->module));
39 v = E_NEW(E_Config_Dialog_View, 1);
41 v->create_cfdata = _create_data;
42 v->free_cfdata = _free_data;
43 v->basic.apply_cfdata = _basic_apply_data;
44 v->basic.create_widgets = _basic_create_widgets;
45 v->basic.check_changed = _basic_check_changed;
47 cfd = e_config_dialog_new(con, _("Physics Settings"),
48 "E", "appearance/physics", buf, 32, v, mod);
49 mod->config_dialog = cfd;
54 _create_data(E_Config_Dialog *cfd __UNUSED__)
56 E_Config_Dialog_Data *cfdata;
58 cfdata = E_NEW(E_Config_Dialog_Data, 1);
60 cfdata->delay = _physics_mod->conf->delay;
61 cfdata->max_mass = _physics_mod->conf->max_mass;
67 _free_data(E_Config_Dialog *cfd __UNUSED__,
68 E_Config_Dialog_Data *cfdata)
70 _physics_mod->config_dialog = NULL;
75 _basic_check_changed(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
78 if (cfdata->X != _physics_mod->conf->X) return 1
82 CHECK(ignore_fullscreen);
83 CHECK(ignore_maximized);
84 CHECK(ignore_shelves);
85 CHECK(shelf.disable_move);
86 CHECK(shelf.disable_rotate);
87 if ((unsigned int)cfdata->delay != _physics_mod->conf->delay) return 1;
94 _basic_create_widgets(E_Config_Dialog *cfd,
96 E_Config_Dialog_Data *cfdata)
98 Evas_Object *ob, *ol, *otb, *tab;
100 tab = e_widget_table_add(evas, 0);
101 evas_object_name_set(tab, "dia_table");
103 otb = e_widget_toolbook_add(evas, 48 * e_scale, 48 * e_scale);
105 ///////////////////////////////////////////
107 ol = e_widget_list_add(evas, 0, 0);
108 ob = e_widget_label_add(evas, _("Physics delay after drag"));
109 e_widget_list_object_append(ol, ob, 1, 1, 0.5);
110 ob = e_widget_slider_add(evas, 1, 0, _("%2.0f Frames"), 5, 20, 1, 0, &(cfdata->delay), NULL, 150);
111 e_widget_list_object_append(ol, ob, 1, 1, 0.5);
112 ob = e_widget_label_add(evas, _("Maximum window mass"));
113 e_widget_list_object_append(ol, ob, 1, 1, 0.5);
114 ob = e_widget_slider_add(evas, 1, 0, _("%2.1f Kg"), 1, 6, 1, 0, &(cfdata->max_mass), NULL, 150);
115 e_widget_list_object_append(ol, ob, 1, 1, 0.5);
116 ob = e_widget_label_add(evas, _("Desktop gravity"));
117 e_widget_list_object_append(ol, ob, 1, 1, 0.5);
118 ob = e_widget_slider_add(evas, 1, 0, _("%1.1f m/s^2"), -5, 5, 1, 0, &(cfdata->gravity), NULL, 150);
119 e_widget_list_object_append(ol, ob, 1, 1, 0.5);
121 e_widget_toolbook_page_append(otb, NULL, _("General"), ol, 1, 1, 1, 1, 0.5, 0.5);
123 ///////////////////////////////////////////
125 ol = e_widget_list_add(evas, 0, 0);
127 ob = e_widget_check_add(evas, _("Disable Movement"), (int*)&(cfdata->shelf.disable_move));
128 e_widget_list_object_append(ol, ob, 1, 0, 0.5);
130 ob = e_widget_check_add(evas, _("Disable Rotation"), (int*)&(cfdata->shelf.disable_rotate));
131 e_widget_list_object_append(ol, ob, 1, 0, 0.5);
133 e_widget_toolbook_page_append(otb, NULL, _("Shelves"), ol, 1, 1, 1, 1, 0.5, 0.5);
135 ///////////////////////////////////////////
137 ol = e_widget_list_add(evas, 0, 0);
138 ob = e_widget_check_add(evas, _("Ignore Fullscreen"), (int*)&(cfdata->ignore_fullscreen));
139 e_widget_list_object_append(ol, ob, 1, 0, 0.5);
141 ob = e_widget_check_add(evas, _("Ignore Maximized"), (int*)&(cfdata->ignore_maximized));
142 e_widget_list_object_append(ol, ob, 1, 0, 0.5);
144 ob = e_widget_check_add(evas, _("Ignore Shelves"), (int*)&(cfdata->ignore_shelves));
145 e_widget_list_object_append(ol, ob, 1, 0, 0.5);
147 e_widget_toolbook_page_append(otb, NULL, _("Ignore"), ol, 1, 1, 1, 1, 0.5, 0.5);
149 e_widget_toolbook_page_show(otb, 0);
151 e_dialog_resizable_set(cfd->dia, 1);
153 e_widget_table_object_append(tab, otb, 0, 0, 1, 1, 1, 1, 1, 1);
159 _basic_apply_data(E_Config_Dialog *cfd __UNUSED__,
160 E_Config_Dialog_Data *cfdata)
162 if ((cfdata->delay != _physics_mod->conf->delay) ||
163 (cfdata->max_mass != _physics_mod->conf->max_mass) ||
164 (cfdata->ignore_fullscreen != _physics_mod->conf->ignore_fullscreen) ||
165 (cfdata->ignore_maximized != _physics_mod->conf->ignore_maximized) ||
166 (cfdata->gravity != _physics_mod->conf->gravity)
169 #define SET(X) _physics_mod->conf->X = cfdata->X
170 _physics_mod->conf->delay = (unsigned int)cfdata->delay;
172 SET(ignore_fullscreen);
173 SET(ignore_maximized);
176 SET(shelf.disable_move);
177 SET(shelf.disable_rotate);
178 e_mod_physics_shutdown();
179 e_mod_physics_init();
181 e_config_save_queue();