summaryrefslogtreecommitdiff
path: root/src/modules/conf_display/e_int_config_desks.c
blob: 2bd3e9e0b7308743eff0db75e247358720eae0d8 (plain)
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
#include "e.h"

/* PROTOTYPES - same all the time */
static void *_create_data(E_Config_Dialog *cfd);
static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
static int _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
static int _basic_check_changed(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
static void _cb_slider_change(void *data, Evas_Object *obj);
static void _cb_disable_flip_anim(void *data, Evas_Object *obj);

/* Actual config data we will be playing with whil the dialog is active */
struct _E_Config_Dialog_Data
{
   /*- BASIC -*/
   int x;
   int y;
   int edge_flip_dragging;
   int flip_wrap;
   int flip_mode;
   int flip_interp;
   int flip_pan_bg;
   double flip_speed;
   double x_axis_pan;
   double y_axis_pan;

   /*- GUI -*/
   Evas_Object *preview;
   Eina_List *flip_anim_list;
};

/* a nice easy setup function that does the dirty work */
E_Config_Dialog *
e_int_config_desks(E_Container *con, const char *params __UNUSED__)
{
   E_Config_Dialog *cfd;
   E_Config_Dialog_View *v;
   
   if (e_config_dialog_find("E", "screen/virtual_desktops")) return NULL;
   v = E_NEW(E_Config_Dialog_View, 1);
   
   /* methods */
   v->create_cfdata = _create_data;
   v->free_cfdata = _free_data;
   v->basic.apply_cfdata = _basic_apply_data;
   v->basic.create_widgets = _basic_create_widgets;
   v->basic.check_changed = _basic_check_changed;
   v->advanced.apply_cfdata = NULL;
   v->advanced.create_widgets = NULL;
   v->advanced.check_changed = NULL;
   /* create config diaolg for NULL object/data */
   cfd = e_config_dialog_new(con, _("Virtual Desktops Settings"),
			     "E", "screen/virtual_desktops",
			     "preferences-desktop", 0, v, NULL);
   return cfd;
}

/**--CREATE--**/
static void
_fill_data(E_Config_Dialog_Data *cfdata)
{
   cfdata->x = e_config->zone_desks_x_count;
   cfdata->y = e_config->zone_desks_y_count;
   cfdata->edge_flip_dragging = e_config->edge_flip_dragging;
   cfdata->flip_wrap = e_config->desk_flip_wrap;
   cfdata->flip_mode = e_config->desk_flip_animate_mode;
   cfdata->flip_interp = e_config->desk_flip_animate_interpolation;
   cfdata->flip_pan_bg = e_config->desk_flip_pan_bg;
   cfdata->flip_speed = e_config->desk_flip_animate_time;
   cfdata->x_axis_pan = e_config->desk_flip_pan_x_axis_factor;
   cfdata->y_axis_pan = e_config->desk_flip_pan_y_axis_factor;
}

static void *
_create_data(E_Config_Dialog *cfd __UNUSED__)
{
   E_Config_Dialog_Data *cfdata;

   cfdata = E_NEW(E_Config_Dialog_Data, 1);
   _fill_data(cfdata);
   return cfdata;
}

static void
_free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
{
   eina_list_free(cfdata->flip_anim_list);
   E_FREE(cfdata);
}

/**--APPLY--**/

static int
_basic_apply_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
{
   /* Actually take our cfdata settings and apply them in real life */
   const Eina_List *l, *ll, *lll;
   E_Manager *man;
   E_Container *con;
   E_Zone *zone;

   EINA_LIST_FOREACH(e_manager_list(), l, man)
     EINA_LIST_FOREACH(man->containers, ll, con)
       EINA_LIST_FOREACH(con->zones, lll, zone)
         e_zone_desk_count_set(zone, cfdata->x, cfdata->y);

   e_config->desk_flip_animate_mode = cfdata->flip_mode;
   e_config->desk_flip_animate_interpolation = cfdata->flip_interp;
   e_config->desk_flip_pan_bg = cfdata->flip_pan_bg;
   e_config->desk_flip_animate_time = cfdata->flip_speed;
   e_config->desk_flip_pan_x_axis_factor = cfdata->x_axis_pan;
   e_config->desk_flip_pan_y_axis_factor = cfdata->y_axis_pan;
   
   e_config->edge_flip_dragging = cfdata->edge_flip_dragging;
   e_config->desk_flip_wrap = cfdata->flip_wrap;

   e_config_save_queue();
   return 1; /* Apply was OK */
}

static int
_basic_check_changed(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
{
   const Eina_List *l, *ll, *lll;
   E_Manager *man;
   E_Container *con;
   E_Zone *zone;

   EINA_LIST_FOREACH(e_manager_list(), l, man)
     EINA_LIST_FOREACH(man->containers, ll, con)
       EINA_LIST_FOREACH(con->zones, lll, zone)
         {
	    int x, y;

	    e_zone_desk_count_get(zone, &x, &y);
	    if ((x != cfdata->x) || (y != cfdata->y))
	      return 1;
	 }

   return ((e_config->desk_flip_animate_mode != cfdata->flip_mode) ||
	   (e_config->desk_flip_animate_interpolation != cfdata->flip_interp) ||
	   (e_config->desk_flip_pan_bg != cfdata->flip_pan_bg) ||
	   (e_config->desk_flip_animate_time != cfdata->flip_speed) ||
	   (e_config->desk_flip_pan_x_axis_factor != cfdata->x_axis_pan) ||
	   (e_config->desk_flip_pan_y_axis_factor != cfdata->y_axis_pan) ||
	   (e_config->edge_flip_dragging != cfdata->edge_flip_dragging) ||
	   (e_config->desk_flip_wrap != cfdata->flip_wrap));
}

/**--GUI--**/
static Evas_Object *
_basic_create_widgets(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dialog_Data *cfdata)
{
   /* generate the core widget layout for a basic dialog */
   Evas_Object *o, *ob, *of, *otb;
   E_Radio_Group *rg;

   otb = e_widget_toolbook_add(evas, (48 * e_scale), (48 * e_scale));
   
   o = e_widget_list_add(evas, 0, 0);

   of = e_widget_frametable_add(evas, _("Number of Desktops"), 0);
   e_widget_frametable_content_align_set(of, 0.5, 0.0);

   ob = e_widget_deskpreview_add(evas, cfdata->x, cfdata->y);
   e_widget_frametable_object_append(of, ob, 0, 0, 1, 1, 1, 1, 1, 1);
   cfdata->preview = ob;

   ob = e_widget_slider_add(evas, 0, 0, _("%1.0f"), 1.0, 12.0, 1.0, 0, NULL, 
                            &(cfdata->y), 150);
   e_widget_on_change_hook_set(ob, _cb_slider_change, cfdata);
   e_widget_frametable_object_append(of, ob, 1, 0, 1, 1, 1, 1, 0, 1);

   ob = e_widget_slider_add(evas, 1, 0, _("%1.0f"), 1.0, 12.0, 1.0, 0, NULL, 
                            &(cfdata->x), 200);
   e_widget_on_change_hook_set(ob, _cb_slider_change, cfdata);
   e_widget_frametable_object_append(of, ob, 0, 1, 1, 1, 1, 1, 1, 0);

   e_widget_list_object_append(o, of, 1, 1, 0.5);

   of = e_widget_framelist_add(evas, _("Desktop Flip"), 0);
   ob = e_widget_check_add(evas, _("Flip when dragging objects to the screen edge"), 
                           &(cfdata->edge_flip_dragging));
   e_widget_framelist_object_append(of, ob);
   ob = e_widget_check_add(evas, _("Wrap desktops around when flipping"), 
                           &(cfdata->flip_wrap));
   e_widget_framelist_object_append(of, ob);

   e_widget_list_object_append(o, of, 1, 0, 0.5);
   
   e_widget_toolbook_page_append(otb, NULL, _("Desktops"), o, 1, 1, 1, 1, 
                                 0.5, 0.0);

   o = e_widget_list_add(evas, 0, 0);
   rg = e_widget_radio_group_new(&(cfdata->flip_mode));
   ob = e_widget_radio_add(evas, _("Off"), 0, rg);
   e_widget_on_change_hook_set(ob, _cb_disable_flip_anim, cfdata);
   e_widget_list_object_append(o, ob, 1, 0, 0.5);
   ob = e_widget_radio_add(evas, _("Pane"), 1, rg);
   e_widget_on_change_hook_set(ob, _cb_disable_flip_anim, cfdata);
   e_widget_list_object_append(o, ob, 1, 0, 0.5);
   ob = e_widget_radio_add(evas, _("Zoom"), 2, rg);
   e_widget_on_change_hook_set(ob, _cb_disable_flip_anim, cfdata);
   e_widget_list_object_append(o, ob, 1, 0, 0.5);
   
/* this is broken in e so disable in config dialog.
   ob = e_widget_check_add(evas, _("Background panning"), 
                           &(cfdata->flip_pan_bg));
   e_widget_disabled_set(ob, !cfdata->flip_mode);
   cfdata->flip_anim_list = eina_list_append(cfdata->flip_anim_list, ob);
   e_widget_list_object_append(o, ob, 1, 0, 0.5);
 */
   ob = e_widget_label_add(evas, _("Animation speed"));
   cfdata->flip_anim_list = eina_list_append(cfdata->flip_anim_list, ob);
   e_widget_list_object_append(o, ob, 1, 0, 0.5);
   ob = e_widget_slider_add(evas, 1, 0, _("%1.1f sec"), 0, 5, 0.05, 0, 
                            &(cfdata->flip_speed), NULL, 150);
   e_widget_disabled_set(ob, !cfdata->flip_mode);
   cfdata->flip_anim_list = eina_list_append(cfdata->flip_anim_list, ob);
   e_widget_list_object_append(o, ob, 1, 0, 0.5);
/*
   ob = e_widget_label_add(evas, _("X-Axis pan factor"));
   cfdata->flip_anim_list = eina_list_append(cfdata->flip_anim_list, ob);
   e_widget_list_object_append(o, ob, 1, 0, 0.5);
   ob = e_widget_slider_add(evas, 1, 0, _("%.2f"), 0, 1, 0.01, 0, 
                            &(cfdata->x_axis_pan), NULL, 150);
   e_widget_disabled_set(ob, !cfdata->flip_mode);
   e_widget_list_object_append(o, ob, 1, 0, 0.5);
   cfdata->flip_anim_list = eina_list_append(cfdata->flip_anim_list, ob);

   ob = e_widget_label_add(evas, _("Y-Axis pan factor"));
   cfdata->flip_anim_list = eina_list_append(cfdata->flip_anim_list, ob);
   e_widget_list_object_append(o, ob, 1, 0, 0.5);
   ob = e_widget_slider_add(evas, 1, 0, _("%.2f"), 0, 1, 0.01, 0, 
                            &(cfdata->y_axis_pan), NULL, 150);
   e_widget_disabled_set(ob, !cfdata->flip_mode);
   e_widget_list_object_append(o, ob, 1, 0, 0.5);
   cfdata->flip_anim_list = eina_list_append(cfdata->flip_anim_list, ob);
 */
   e_widget_toolbook_page_append(otb, NULL, _("Flip Animation"), o, 
                                 1, 0, 1, 0, 0.5, 0.0);

   e_widget_toolbook_page_show(otb, 0);

   return otb;
}

static void
_cb_slider_change(void *data, Evas_Object *obj __UNUSED__)
{
   E_Config_Dialog_Data *cfdata = data;

   e_widget_deskpreview_num_desks_set(cfdata->preview, cfdata->x, cfdata->y);
}

static void
_cb_disable_flip_anim(void *data, Evas_Object *obj __UNUSED__)
{
   E_Config_Dialog_Data *cfdata = (E_Config_Dialog_Data*) data;
   Eina_List *list = cfdata->flip_anim_list;
   Eina_List *l;
   Evas_Object *o;

   EINA_LIST_FOREACH(list, l, o)
     e_widget_disabled_set(o, !cfdata->flip_mode);
}