summaryrefslogtreecommitdiff
path: root/src/bin/controls.c
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>2013-11-01 16:46:23 -0200
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>2013-11-01 16:46:23 -0200
commitb50e64f80b58660c2ebb1c75d959b65e2bf0b4ec (patch)
tree34ca1b31c800efb31fca766686e123baeec963cc /src/bin/controls.c
parent6562cdabc26860a9e62b5d6016b4b677e4ffe5d8 (diff)
controls: disable "copy" when there is no selection.
Diffstat (limited to 'src/bin/controls.c')
-rw-r--r--src/bin/controls.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/bin/controls.c b/src/bin/controls.c
index ec697a3..1b73c64 100644
--- a/src/bin/controls.c
+++ b/src/bin/controls.c
@@ -15,6 +15,22 @@ static Evas_Object *ct_win = NULL, *ct_bg = NULL, *ct_term = NULL;
15static void (*ct_donecb) (void *data) = NULL; 15static void (*ct_donecb) (void *data) = NULL;
16static void *ct_donedata = NULL; 16static void *ct_donedata = NULL;
17 17
18static void
19_cb_sel_on(void *data EINA_UNUSED, Evas_Object *term EINA_UNUSED, void *ev EINA_UNUSED)
20{
21 Evas_Object *bt_copy = evas_object_data_get(ct_frame, "bt_copy");
22 if (bt_copy)
23 elm_object_disabled_set(bt_copy, EINA_FALSE);
24}
25
26static void
27_cb_sel_off(void *data EINA_UNUSED, Evas_Object *term EINA_UNUSED, void *ev EINA_UNUSED)
28{
29 Evas_Object *bt_copy = evas_object_data_get(ct_frame, "bt_copy");
30 if (bt_copy)
31 elm_object_disabled_set(bt_copy, EINA_TRUE);
32}
33
18static Eina_Bool 34static Eina_Bool
19_cb_ct_del_delay(void *data EINA_UNUSED) 35_cb_ct_del_delay(void *data EINA_UNUSED)
20{ 36{
@@ -94,6 +110,11 @@ _cb_mouse_down(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EIN
94static void 110static void
95_cb_frame_del(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *ev EINA_UNUSED) 111_cb_frame_del(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *ev EINA_UNUSED)
96{ 112{
113 if (ct_term)
114 {
115 evas_object_smart_callback_del(ct_term, "selection,on", _cb_sel_on);
116 evas_object_smart_callback_del(ct_term, "selection,off", _cb_sel_off);
117 }
97 ct_frame = NULL; 118 ct_frame = NULL;
98} 119}
99 120
@@ -247,6 +268,9 @@ controls_toggle(Evas_Object *win, Evas_Object *bg, Evas_Object *term,
247 evas_object_show(o); 268 evas_object_show(o);
248 269
249 o = _button_add(win, "Copy", "copy", _cb_ct_copy, term); 270 o = _button_add(win, "Copy", "copy", _cb_ct_copy, term);
271 evas_object_data_set(ct_frame, "bt_copy", o);
272 if (!termio_selection_exists(term))
273 elm_object_disabled_set(o, EINA_TRUE);
250 elm_box_pack_end(ct_box, o); 274 elm_box_pack_end(ct_box, o);
251 o = _button_add(win, "Paste", "paste", _cb_ct_paste, term); 275 o = _button_add(win, "Paste", "paste", _cb_ct_paste, term);
252 elm_box_pack_end(ct_box, o); 276 elm_box_pack_end(ct_box, o);
@@ -265,6 +289,11 @@ controls_toggle(Evas_Object *win, Evas_Object *bg, Evas_Object *term,
265 289
266 evas_object_event_callback_add(ct_frame, EVAS_CALLBACK_DEL, 290 evas_object_event_callback_add(ct_frame, EVAS_CALLBACK_DEL,
267 _cb_frame_del, NULL); 291 _cb_frame_del, NULL);
292
293 evas_object_smart_callback_add(term, "selection,on", _cb_sel_on,
294 NULL);
295 evas_object_smart_callback_add(term, "selection,off", _cb_sel_off,
296 NULL);
268 } 297 }
269 if (!ct_out) 298 if (!ct_out)
270 { 299 {