summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/controls.c2
-rw-r--r--src/bin/options.c377
-rw-r--r--src/bin/options.h2
3 files changed, 200 insertions, 181 deletions
diff --git a/src/bin/controls.c b/src/bin/controls.c
index 15335a5..98d6468 100644
--- a/src/bin/controls.c
+++ b/src/bin/controls.c
@@ -148,7 +148,7 @@ _cb_ct_options(void *data,
148{ 148{
149 struct controls_ctx *ctx = data; 149 struct controls_ctx *ctx = data;
150 150
151 options_toggle(ctx->win, ctx->bg, ctx->term, ctx->donecb, ctx->donedata); 151 options_show(ctx->win, ctx->bg, ctx->term, ctx->donecb, ctx->donedata);
152 controls_hide(ctx, EINA_FALSE); 152 controls_hide(ctx, EINA_FALSE);
153} 153}
154 154
diff --git a/src/bin/options.c b/src/bin/options.c
index 381a22d..c4ee74c 100644
--- a/src/bin/options.c
+++ b/src/bin/options.c
@@ -1,6 +1,7 @@
1#include "private.h" 1#include "private.h"
2 2
3#include <Elementary.h> 3#include <Elementary.h>
4#include <assert.h>
4#include "options.h" 5#include "options.h"
5#include "options_font.h" 6#include "options_font.h"
6#include "options_theme.h" 7#include "options_theme.h"
@@ -14,17 +15,8 @@
14#include "config.h" 15#include "config.h"
15#include "termio.h" 16#include "termio.h"
16 17
17static Evas_Object *op_frame, *op_box = NULL, *op_toolbar = NULL, 18
18 *op_opbox = NULL, *op_tbox = NULL, *op_temp = NULL, 19enum option_mode {
19 *op_over = NULL;
20static Eina_Bool op_out = EINA_FALSE;
21static Ecore_Timer *op_del_timer = NULL;
22static Evas_Object *saved_win = NULL;
23static Evas_Object *saved_bg = NULL;
24static void (*op_donecb) (void *data) = NULL;
25static void *op_donedata = NULL;
26
27static enum option_mode {
28 OPTION_NONE = 0, 20 OPTION_NONE = 0,
29 OPTION_FONT, 21 OPTION_FONT,
30 OPTION_THEME, 22 OPTION_THEME,
@@ -34,229 +26,256 @@ static enum option_mode {
34 OPTION_BEHAVIOR, 26 OPTION_BEHAVIOR,
35 OPTION_KEYS, 27 OPTION_KEYS,
36 OPTION_HELPERS, 28 OPTION_HELPERS,
37 OPTION_ELM 29 OPTION_ELM,
38} _mode = 0; 30
31 OPTIONS_MODE_NB
32};
33
34struct options_ctx {
35 enum option_mode mode;
36 Evas_Object *frame;
37 Evas_Object *toolbar;
38 Evas_Object *opbox;
39 Evas_Object *over;
40 Evas_Object *win;
41 Evas_Object *bg;
42 Evas_Object *term;
43 Config *config;
44 void (*donecb) (void *data);
45 void *donedata;
46 struct options_ctx *modes[OPTIONS_MODE_NB];
47};
39 48
40static void 49static void
41_cb_op(void *data, 50_cb_op(void *data,
42 Evas_Object *_obj EINA_UNUSED, 51 Evas_Object *_obj EINA_UNUSED,
43 void *_event EINA_UNUSED) 52 void *_event EINA_UNUSED)
44{ 53{
45 enum option_mode mode = (intptr_t) data; 54 struct options_ctx **pctx = data;
55 struct options_ctx *ctx = *pctx;
56 enum option_mode mode = pctx - ctx->modes;
57
58 if (mode == ctx->mode)
59 return;
46 60
47 if (_mode == mode) return; 61 ctx->mode = mode;
48 _mode = mode; 62
49 edje_object_signal_emit(saved_bg, "optdetails,hide", "terminology"); 63 edje_object_signal_emit(ctx->bg, "optdetails,hide", "terminology");
50} 64}
51 65
52static void 66static void
53_cb_op_tmp_chg(void *data, Evas_Object *obj, void *_event EINA_UNUSED) 67_cb_op_tmp_chg(void *data, Evas_Object *obj, void *_event EINA_UNUSED)
54{ 68{
55 Config *config = data; 69 struct options_ctx *ctx = data;
70 Config *config = ctx->config;
71
56 config->temporary = elm_check_state_get(obj); 72 config->temporary = elm_check_state_get(obj);
57} 73}
58 74
59static Eina_Bool 75static Eina_Bool
60_cb_op_del_delay(void *_data EINA_UNUSED) 76_cb_op_del_delay(void *data)
61{ 77{
62 evas_object_del(op_opbox); 78 struct options_ctx *ctx = data;
63 evas_object_del(op_frame); 79
80 evas_object_del(ctx->opbox);
81 evas_object_del(ctx->frame);
64 options_font_clear(); 82 options_font_clear();
65 options_background_clear(); 83 options_background_clear();
66 options_theme_clear(); 84 options_theme_clear();
67 op_opbox = NULL; 85
68 op_frame = NULL; 86 free(ctx);
69 op_del_timer = NULL;
70 elm_cache_all_flush(); 87 elm_cache_all_flush();
71 return EINA_FALSE; 88 return EINA_FALSE;
72} 89}
73 90
74static void 91static void
75_cb_mouse_down(void *data,
76 Evas *_e EINA_UNUSED,
77 Evas_Object *_obj EINA_UNUSED,
78 void *_ev EINA_UNUSED)
79{
80 options_toggle(saved_win, saved_bg, data, op_donecb, op_donedata);
81}
82
83static void
84_cb_opdt_hide_done(void *data, 92_cb_opdt_hide_done(void *data,
85 Evas_Object *_obj EINA_UNUSED, 93 Evas_Object *_obj EINA_UNUSED,
86 const char *_sig EINA_UNUSED, 94 const char *_sig EINA_UNUSED,
87 const char *_src EINA_UNUSED) 95 const char *_src EINA_UNUSED)
88{ 96{
89 elm_box_clear(op_opbox); 97 struct options_ctx *ctx = data;
90 switch (_mode) 98
99 elm_box_clear(ctx->opbox);
100 switch (ctx->mode)
91 { 101 {
92 case OPTION_NONE: break; 102 case OPTION_NONE: break;
93 case OPTION_FONT: options_font(op_opbox, data); break; 103 case OPTION_FONT: options_font(ctx->opbox, ctx->term); break;
94 case OPTION_THEME: options_theme(op_opbox, data); break; 104 case OPTION_THEME: options_theme(ctx->opbox, ctx->term); break;
95 case OPTION_BACKGROUND: options_background(op_opbox, data); break; 105 case OPTION_BACKGROUND: options_background(ctx->opbox, ctx->term); break;
96 case OPTION_COLORS: options_colors(op_opbox, data); break; 106 case OPTION_COLORS: options_colors(ctx->opbox, ctx->term); break;
97 case OPTION_VIDEO: options_video(op_opbox, data); break; 107 case OPTION_VIDEO: options_video(ctx->opbox, ctx->term); break;
98 case OPTION_BEHAVIOR: options_behavior(op_opbox, data); break; 108 case OPTION_BEHAVIOR: options_behavior(ctx->opbox, ctx->term); break;
99 case OPTION_KEYS: options_keys(op_opbox, data); break; 109 case OPTION_KEYS: options_keys(ctx->opbox, ctx->term); break;
100 case OPTION_HELPERS: options_helpers(op_opbox, data); break; 110 case OPTION_HELPERS: options_helpers(ctx->opbox, ctx->term); break;
101 case OPTION_ELM: options_elm(op_opbox, data); break; 111 case OPTION_ELM: options_elm(ctx->opbox, ctx->term); break;
112 case OPTIONS_MODE_NB: assert(0 && "should not occur");
102 } 113 }
103 edje_object_signal_emit(saved_bg, "optdetails,show", "terminology"); 114 edje_object_signal_emit(ctx->bg, "optdetails,show", "terminology");
104} 115}
105 116
106static void 117static void
107_cb_opdt_hide_done2(void *_data EINA_UNUSED, 118_cb_opdt_hide_done2(void *data,
108 Evas_Object *_obj EINA_UNUSED, 119 Evas_Object *_obj EINA_UNUSED,
109 const char *_sig EINA_UNUSED, 120 const char *_sig EINA_UNUSED,
110 const char *_src EINA_UNUSED) 121 const char *_src EINA_UNUSED)
111{ 122{
112 if (op_del_timer) 123 struct options_ctx *ctx = data;
113 { 124
114 ecore_timer_del(op_del_timer); 125 edje_object_signal_callback_del(ctx->bg, "optdetails,hide,done",
115 op_del_timer = NULL;
116 }
117 _cb_op_del_delay(NULL);
118 edje_object_signal_callback_del(saved_bg, "optdetails,hide,done",
119 "terminology", 126 "terminology",
120 _cb_opdt_hide_done2); 127 _cb_opdt_hide_done2);
128 ecore_timer_add(10.0, _cb_op_del_delay, ctx);
129}
130
131static void
132options_hide(struct options_ctx *ctx)
133{
134 edje_object_part_swallow(ctx->bg, "terminology.optdetails", ctx->opbox);
135 edje_object_part_swallow(ctx->bg, "terminology.options", ctx->frame);
136 edje_object_signal_emit(ctx->bg, "optdetails,show", "terminology");
137 edje_object_signal_emit(ctx->bg, "options,show", "terminology");
138
139 edje_object_signal_callback_del(ctx->bg, "optdetails,hide,done",
140 "terminology",
141 _cb_opdt_hide_done);
142 edje_object_signal_callback_add(ctx->bg, "optdetails,hide,done",
143 "terminology",
144 _cb_opdt_hide_done2, ctx);
145 elm_object_focus_set(ctx->frame, EINA_FALSE);
146 elm_object_focus_set(ctx->opbox, EINA_FALSE);
147 elm_object_focus_set(ctx->toolbar, EINA_FALSE);
148
149 evas_object_del(ctx->over);
150 ctx->over = NULL;
151
152 edje_object_signal_emit(ctx->bg, "options,hide", "terminology");
153 edje_object_signal_emit(ctx->bg, "optdetails,hide", "terminology");
154
155 if (ctx->donecb)
156 ctx->donecb(ctx->donedata);
157}
158
159static void
160_cb_mouse_down(void *data,
161 Evas *_e EINA_UNUSED,
162 Evas_Object *_obj EINA_UNUSED,
163 void *_ev EINA_UNUSED)
164{
165 struct options_ctx *ctx = data;
166
167 options_hide(ctx);
121} 168}
122 169
170
123void 171void
124options_toggle(Evas_Object *win, Evas_Object *bg, Evas_Object *term, 172options_show(Evas_Object *win, Evas_Object *bg, Evas_Object *term,
125 void (*donecb) (void *data), void *donedata) 173 void (*donecb) (void *data), void *donedata)
126{ 174{
127 Evas_Object *o; 175 Evas_Object *o, *op_box, *op_tbox;
176 struct options_ctx *ctx;
177 int i = 0;
128 178
129 _mode = OPTION_NONE; 179 Elm_Object_Item *it_fn;
130 if (!op_frame) 180 Config *config = termio_config_get(term);
131 { 181
132 Elm_Object_Item *it_fn; 182 if (!config) return;
133 Config *config = termio_config_get(term); 183
134 184 ctx = malloc(sizeof(*ctx));
135 if (!config) return; 185 assert(ctx);
136 saved_win = win; 186 ctx->mode = OPTION_NONE;
137 saved_bg = bg; 187 ctx->win = win;
138 188 ctx->bg = bg;
139 op_opbox = o = elm_box_add(win); 189 ctx->term = term;
140 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 190 ctx->donecb = donecb;
141 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); 191 ctx->donedata = donedata;
142 edje_object_part_swallow(bg, "terminology.optdetails", o); 192 ctx->config = config;
143 evas_object_show(o); 193
144 194 for (i = 0; i < OPTIONS_MODE_NB; i++)
145 op_frame = o = elm_frame_add(win); 195 ctx->modes[i] = ctx;
146 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 196
147 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); 197 ctx->opbox = o = elm_box_add(win);
148 elm_object_text_set(o, _("Options")); 198 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
149 199 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
150 op_box = o = elm_box_add(win); 200 edje_object_part_swallow(ctx->bg, "terminology.optdetails", o);
151 elm_box_horizontal_set(o, EINA_TRUE); 201 evas_object_show(o);
152 elm_object_content_set(op_frame, o); 202
153 evas_object_show(o); 203 ctx->frame = o = elm_frame_add(win);
154 204 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
155 op_tbox = o = elm_box_add(win); 205 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
156 evas_object_size_hint_weight_set(o, 0.0, EVAS_HINT_EXPAND); 206 elm_object_text_set(o, _("Options"));
157 evas_object_size_hint_align_set(o, 1.0, EVAS_HINT_FILL); 207
158 elm_box_pack_end(op_box, o); 208 op_box = o = elm_box_add(win);
159 evas_object_show(o); 209 elm_box_horizontal_set(o, EINA_TRUE);
160 210 elm_object_content_set(ctx->frame, o);
161 op_toolbar = o = elm_toolbar_add(win); 211 evas_object_show(o);
162 evas_object_size_hint_weight_set(o, 0.0, EVAS_HINT_EXPAND); 212
163 evas_object_size_hint_align_set(o, 0.5, EVAS_HINT_FILL); 213 op_tbox = o = elm_box_add(win);
164 elm_toolbar_horizontal_set(o, EINA_FALSE); 214 evas_object_size_hint_weight_set(o, 0.0, EVAS_HINT_EXPAND);
165 elm_object_style_set(o, "item_horizontal"); 215 evas_object_size_hint_align_set(o, 1.0, EVAS_HINT_FILL);
166 elm_toolbar_icon_size_set(o, 16 * elm_config_scale_get()); 216 elm_box_pack_end(op_box, o);
167 elm_toolbar_shrink_mode_set(o, ELM_TOOLBAR_SHRINK_SCROLL); 217 evas_object_show(o);
168 elm_toolbar_select_mode_set(o, ELM_OBJECT_SELECT_MODE_ALWAYS); 218
169 elm_toolbar_menu_parent_set(o, win); 219 ctx->toolbar = o = elm_toolbar_add(win);
170 elm_toolbar_homogeneous_set(o, EINA_FALSE); 220 evas_object_size_hint_weight_set(o, 0.0, EVAS_HINT_EXPAND);
221 evas_object_size_hint_align_set(o, 0.5, EVAS_HINT_FILL);
222 elm_toolbar_horizontal_set(o, EINA_FALSE);
223 elm_object_style_set(o, "item_horizontal");
224 elm_toolbar_icon_size_set(o, 16 * elm_config_scale_get());
225 elm_toolbar_shrink_mode_set(o, ELM_TOOLBAR_SHRINK_SCROLL);
226 elm_toolbar_select_mode_set(o, ELM_OBJECT_SELECT_MODE_ALWAYS);
227 elm_toolbar_menu_parent_set(o, win);
228 elm_toolbar_homogeneous_set(o, EINA_FALSE);
171 229
172#define ITEM_APPEND(_icon_name, _name, _option_mode) \ 230#define ITEM_APPEND(_icon_name, _name, _option_mode) \
173 elm_toolbar_item_append(o, _icon_name, _name, _cb_op, \ 231 elm_toolbar_item_append(o, _icon_name, _name, _cb_op, \
174 (void*) OPTION_##_option_mode) 232 (void*) &ctx->modes[OPTION_##_option_mode])
175 233
176 it_fn = 234 it_fn =
177 ITEM_APPEND("preferences-desktop-font", _("Font"), FONT); 235 ITEM_APPEND("preferences-desktop-font", _("Font"), FONT);
178 ITEM_APPEND("preferences-desktop-theme", _("Theme"), THEME); 236 ITEM_APPEND("preferences-desktop-theme", _("Theme"), THEME);
179 ITEM_APPEND("preferences-desktop-background", _("Background"), BACKGROUND); 237 ITEM_APPEND("preferences-desktop-background", _("Background"), BACKGROUND);
180 ITEM_APPEND("preferences-desktop-theme", _("Colors"), COLORS); 238 ITEM_APPEND("preferences-desktop-theme", _("Colors"), COLORS);
181 ITEM_APPEND("video-display", _("Video"), VIDEO); 239 ITEM_APPEND("video-display", _("Video"), VIDEO);
182 ITEM_APPEND("preferences-system", _("Behavior"), BEHAVIOR); 240 ITEM_APPEND("preferences-system", _("Behavior"), BEHAVIOR);
183 ITEM_APPEND("preferences-desktop-keyboard-shortcuts", _("Keys"), KEYS); 241 ITEM_APPEND("preferences-desktop-keyboard-shortcuts", _("Keys"), KEYS);
184 ITEM_APPEND("system-run", _("Helpers"), HELPERS); 242 ITEM_APPEND("system-run", _("Helpers"), HELPERS);
185 ITEM_APPEND("preferences-color", _("Toolkit"), ELM); 243 ITEM_APPEND("preferences-color", _("Toolkit"), ELM);
186#undef ITEM_APPEND 244#undef ITEM_APPEND
187 245
188 elm_box_pack_end(op_tbox, o); 246 elm_box_pack_end(op_tbox, o);
189 evas_object_show(o); 247 evas_object_show(o);
190 248
191 elm_toolbar_item_selected_set(it_fn, EINA_TRUE); 249 elm_toolbar_item_selected_set(it_fn, EINA_TRUE);
192 250
193 op_temp = o = elm_check_add(win); 251 o = elm_check_add(win);
194 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0); 252 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
195 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 1.0); 253 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 1.0);
196 elm_object_text_set(o, _("Temporary")); 254 elm_object_text_set(o, _("Temporary"));
197 elm_check_state_set(o, config->temporary); 255 elm_check_state_set(o, config->temporary);
198 elm_box_pack_end(op_tbox, o); 256 elm_box_pack_end(op_tbox, o);
199 evas_object_show(o); 257 evas_object_show(o);
200 evas_object_smart_callback_add(o, "changed", _cb_op_tmp_chg, config); 258 evas_object_smart_callback_add(o, "changed", _cb_op_tmp_chg, ctx);
201 259
202 edje_object_part_swallow(bg, "terminology.options", op_frame); 260 edje_object_part_swallow(bg, "terminology.options", ctx->frame);
203 evas_object_show(op_frame); 261 evas_object_show(ctx->frame);
204 } 262
205 else if ((op_opbox) && (!op_out)) 263 edje_object_signal_callback_add(ctx->bg, "optdetails,hide,done",
206 { 264 "terminology",
207 edje_object_part_swallow(bg, "terminology.optdetails", op_opbox); 265 _cb_opdt_hide_done, ctx);
208 edje_object_part_swallow(bg, "terminology.options", op_frame); 266 ctx->over = o = evas_object_rectangle_add(evas_object_evas_get(win));
209 edje_object_signal_emit(bg, "optdetails,show", "terminology"); 267 evas_object_color_set(o, 0, 0, 0, 0);
210 edje_object_signal_emit(bg, "options,show", "terminology"); 268 edje_object_part_swallow(ctx->bg, "terminology.dismiss", o);
211 } 269 evas_object_show(o);
212 270 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
213 if (!op_out) 271 _cb_mouse_down, ctx);
214 { 272
215 edje_object_signal_callback_add(bg, "optdetails,hide,done", 273 edje_object_signal_emit(ctx->bg, "options,show", "terminology");
216 "terminology", 274 elm_object_focus_set(ctx->toolbar, EINA_TRUE);
217 _cb_opdt_hide_done, term);
218 op_over = o = evas_object_rectangle_add(evas_object_evas_get(win));
219 evas_object_color_set(o, 0, 0, 0, 0);
220 edje_object_part_swallow(bg, "terminology.dismiss", o);
221 evas_object_show(o);
222 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
223 _cb_mouse_down, term);
224
225 edje_object_signal_emit(bg, "options,show", "terminology");
226 op_out = EINA_TRUE;
227 op_donecb = donecb;
228 op_donedata = donedata;
229 elm_object_focus_set(op_toolbar, EINA_TRUE);
230 if (op_del_timer)
231 {
232 ecore_timer_del(op_del_timer);
233 op_del_timer = NULL;
234 }
235 }
236 else
237 {
238 edje_object_signal_callback_del(bg, "optdetails,hide,done",
239 "terminology",
240 _cb_opdt_hide_done);
241 edje_object_signal_callback_add(bg, "optdetails,hide,done",
242 "terminology",
243 _cb_opdt_hide_done2, term);
244 elm_object_focus_set(op_frame, EINA_FALSE);
245 elm_object_focus_set(op_opbox, EINA_FALSE);
246 elm_object_focus_set(op_toolbar, EINA_FALSE);
247 if (op_donecb) op_donecb(op_donedata);
248 evas_object_del(op_over);
249 op_over = NULL;
250 edje_object_signal_emit(bg, "options,hide", "terminology");
251 edje_object_signal_emit(bg, "optdetails,hide", "terminology");
252 op_out = EINA_FALSE;
253 if (op_del_timer) ecore_timer_del(op_del_timer);
254 op_del_timer = ecore_timer_add(10.0, _cb_op_del_delay, NULL);
255 }
256} 275}
257 276
258Eina_Bool 277Eina_Bool
259options_is_active(Evas_Object *win EINA_UNUSED) 278options_is_active(Evas_Object *win EINA_UNUSED)
260{ 279{
261 return op_out; 280 return EINA_FALSE;
262} 281}
diff --git a/src/bin/options.h b/src/bin/options.h
index 007361c..a530a42 100644
--- a/src/bin/options.h
+++ b/src/bin/options.h
@@ -1,7 +1,7 @@
1#ifndef _TERMINOLOGY_OPTIONS_H__ 1#ifndef _TERMINOLOGY_OPTIONS_H__
2#define _TERMINOLOGY_OPTIONS_H__ 1 2#define _TERMINOLOGY_OPTIONS_H__ 1
3 3
4void options_toggle(Evas_Object *win, Evas_Object *bg, Evas_Object *term, 4void options_show(Evas_Object *win, Evas_Object *bg, Evas_Object *term,
5 void (*donecb) (void *data), void *donedata); 5 void (*donecb) (void *data), void *donedata);
6Eina_Bool options_is_active(Evas_Object *win); 6Eina_Bool options_is_active(Evas_Object *win);
7 7