From 256059af6ea44907c0efeed5b9415bfe5fcb4956 Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Sun, 24 Jun 2012 06:39:54 +0000 Subject: [PATCH] move current options pane 1 level down and now its a controls pane with copy, paste and options. copy & paste use clipboard, not primary. SVN revision: 72755 --- TODO | 6 +- data/themes/default.edc | 47 ++++++++++++++- src/bin/Makefile.am | 1 + src/bin/controls.c | 126 ++++++++++++++++++++++++++++++++++++++++ src/bin/controls.h | 2 + src/bin/main.c | 4 +- src/bin/options.c | 26 +++++---- src/bin/options.h | 2 +- src/bin/termio.c | 32 ++++++---- src/bin/termio.h | 2 + 10 files changed, 221 insertions(+), 27 deletions(-) create mode 100644 src/bin/controls.c create mode 100644 src/bin/controls.h diff --git a/TODO b/TODO index ff8fc222..a1df07bf 100644 --- a/TODO +++ b/TODO @@ -5,11 +5,13 @@ make it a first-class terminal: [ ] blink and blink2 attributes need to be supported [ ] improve terminal emulation handling. known apps with problems: mc -[ ] copy & paste support for clipboard not just primary (like xterm) +[ ] elm_cnp has no way to call an event/cb to let you know your + selection has gone (selection_clear() doesnt do anything). also + elm_cnp doesn't track target object delections. [ ] dnd text (to/from terminal) [ ] handle multibyte displays better (does handle utf8 only atm and then maybe not according to convention like double cell spacing - for jp/kr/zh etc.) + for jp/kr/zh etc. needs textgrid work in evas) [ ] general input mode handling improvements (keypad, other key input, etc.) [ ] selection of themes diff --git a/data/themes/default.edc b/data/themes/default.edc index be22650a..622a59fc 100644 --- a/data/themes/default.edc +++ b/data/themes/default.edc @@ -322,16 +322,59 @@ collections { signal: "options,show"; source: "terminology"; action: STATE_SET "visible" 0.0; - transition: DECELERATE 0.5; + transition: DECELERATE 0.4; target: "terminology.options"; } program { name: "op_hide"; signal: "options,hide"; source: "terminology"; action: STATE_SET "default" 0.0; - transition: DECELERATE 0.5; + transition: DECELERATE 0.6; target: "terminology.options"; } + part { name: "terminology.controls"; type: SWALLOW; + scale: 1; + description { state: "default" 0.0; + fixed: 1 1; + min: 10 10; + align: 0.0 0.5; + visible: 0; + rel1 { + relative: 1.0 0.5; + offset: 8 8; + } + rel2 { + relative: 1.0 0.5; + offset: 8 -9; + } + } + description { state: "visible" 0.0; + inherit: "default" 0.0; + visible: 1; + align: 1.0 0.5; + rel1 { + relative: 1.0 0.5; + offset: -9 8; + } + rel2 { + offset: -9 -9; + } + } + } + program { name: "ct_show"; + signal: "controls,show"; + source: "terminology"; + action: STATE_SET "visible" 0.0; + transition: DECELERATE 0.3; + target: "terminology.controls"; + } + program { name: "ct_hide"; + signal: "controls,hide"; + source: "terminology"; + action: STATE_SET "default" 0.0; + transition: DECELERATE 0.5; + target: "terminology.controls"; + } } } diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index 6c8ff11e..00f88cfd 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -12,6 +12,7 @@ terminology_SOURCES = \ private.h \ col.c col.h \ config.c config.h \ +controls.c controls.h \ keyin.c keyin.h \ main.c main.h \ media.c media.h \ diff --git a/src/bin/controls.c b/src/bin/controls.c new file mode 100644 index 00000000..3393c8d0 --- /dev/null +++ b/src/bin/controls.c @@ -0,0 +1,126 @@ +#include "private.h" + +#include +#include "controls.h" +#include "options.h" +#include "termio.h" + +static Evas_Object *ct_frame, *ct_box = NULL; +static Eina_Bool ct_out = EINA_FALSE; +static Ecore_Timer *ct_del_timer = NULL; + +static Evas_Object *ct_win, *ct_bg, *ct_term; + +static Eina_Bool +_cb_ct_del_delay(void *data __UNUSED__) +{ + evas_object_del(ct_frame); + ct_frame = NULL; + ct_del_timer = NULL; + elm_cache_all_flush(); + return EINA_FALSE; +} + +static void +_cb_ct_copy(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__) +{ + controls_toggle(ct_win, ct_bg, ct_term); + termio_copy_clipboard(data); +} + +static void +_cb_ct_paste(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__) +{ + controls_toggle(ct_win, ct_bg, ct_term); + termio_paste_clipboard(data); +} + +static void +_cb_ct_options(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__) +{ + controls_toggle(ct_win, ct_bg, ct_term); + options_toggle(ct_win, ct_bg, ct_term); +} + +void +controls_toggle(Evas_Object *win, Evas_Object *bg, Evas_Object *term) +{ + Evas_Object *o; + + if (!ct_out) + { + if (options_active_get()) + { + options_toggle(win, bg, term); + return; + } + } + if (!ct_frame) + { + ct_frame = o = elm_frame_add(win); + evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_object_text_set(o, "Controls"); + + ct_box = o = elm_box_add(win); + elm_object_content_set(ct_frame, o); + evas_object_show(o); + + o = elm_button_add(win); + evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_object_text_set(o, "Copy"); + elm_box_pack_end(ct_box, o); + evas_object_show(o); + evas_object_smart_callback_add(o, "clicked", _cb_ct_copy, term); + + o = elm_button_add(win); + evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_object_text_set(o, "Paste"); + elm_box_pack_end(ct_box, o); + evas_object_show(o); + evas_object_smart_callback_add(o, "clicked", _cb_ct_paste, term); + + o = elm_separator_add(win); + evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5); + elm_separator_horizontal_set(o, EINA_TRUE); + elm_box_pack_end(ct_box, o); + evas_object_show(o); + + o = elm_button_add(win); + evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_object_text_set(o, "Options"); + elm_box_pack_end(ct_box, o); + evas_object_show(o); + evas_object_smart_callback_add(o, "clicked", _cb_ct_options, NULL); + + edje_object_part_swallow(bg, "terminology.controls", ct_frame); + evas_object_show(ct_frame); + } + if (!ct_out) + { + ct_win = win; + ct_bg = bg; + ct_term = term; + edje_object_signal_emit(bg, "controls,show", "terminology"); + ct_out = EINA_TRUE; + elm_object_focus_set(ct_frame, EINA_TRUE); + if (ct_del_timer) + { + ecore_timer_del(ct_del_timer); + ct_del_timer = NULL; + } + } + else + { + edje_object_signal_emit(bg, "controls,hide", "terminology"); + ct_out = EINA_FALSE; + elm_object_focus_set(ct_frame, EINA_FALSE); + elm_object_focus_set(term, EINA_TRUE); + if (ct_del_timer) ecore_timer_del(ct_del_timer); + ct_del_timer = ecore_timer_add(10.0, _cb_ct_del_delay, NULL); + } +} diff --git a/src/bin/controls.h b/src/bin/controls.h new file mode 100644 index 00000000..0114ac6c --- /dev/null +++ b/src/bin/controls.h @@ -0,0 +1,2 @@ +void controls_toggle(Evas_Object *win, Evas_Object *bg, Evas_Object *term); + diff --git a/src/bin/main.c b/src/bin/main.c index 65b1b778..b42e013d 100644 --- a/src/bin/main.c +++ b/src/bin/main.c @@ -6,7 +6,7 @@ #include "win.h" #include "termio.h" #include "config.h" -#include "options.h" +#include "controls.h" #include "media.h" #include "utils.h" @@ -56,7 +56,7 @@ _cb_size_hint(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void static void _cb_options(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__) { - options_toggle(win, bg, term); + controls_toggle(win, bg, term); } static Eina_Bool diff --git a/src/bin/options.c b/src/bin/options.c index 5847fdb8..90628f31 100644 --- a/src/bin/options.c +++ b/src/bin/options.c @@ -73,7 +73,7 @@ options_toggle(Evas_Object *win, Evas_Object *bg, Evas_Object *term) if (!op_frame) { - Elm_Object_Item *it_fn, *it_th, *it_wp, *it_bh; + Elm_Object_Item *it_fn; Config *config = termio_config_get(term); op_frame = o = elm_frame_add(win); @@ -113,14 +113,14 @@ options_toggle(Evas_Object *win, Evas_Object *bg, Evas_Object *term) it_fn = elm_toolbar_item_append(o, "preferences-desktop-font", "Font", _cb_op_font, term); - it_th = elm_toolbar_item_append(o, "preferences-desktop-theme", - "Theme", _cb_op_theme, term); - it_wp = elm_toolbar_item_append(o, "preferences-desktop-wallpaper", - "Wallpaper", _cb_op_wallpaper, term); - it_wp = elm_toolbar_item_append(o, "preferences-desktop-multimedia", - "Video", _cb_op_video, term); - it_bh = elm_toolbar_item_append(o, "system-run", - "Behavior", _cb_op_behavior, term); + elm_toolbar_item_append(o, "preferences-desktop-theme", + "Theme", _cb_op_theme, term); + elm_toolbar_item_append(o, "preferences-desktop-wallpaper", + "Wallpaper", _cb_op_wallpaper, term); + elm_toolbar_item_append(o, "preferences-desktop-multimedia", + "Video", _cb_op_video, term); + elm_toolbar_item_append(o, "system-run", + "Behavior", _cb_op_behavior, term); elm_box_pack_end(op_tbox, o); evas_object_show(o); @@ -137,7 +137,7 @@ options_toggle(Evas_Object *win, Evas_Object *bg, Evas_Object *term) evas_object_smart_callback_add(o, "changed", _cb_op_tmp_chg, config); edje_object_part_swallow(bg, "terminology.options", op_frame); - evas_object_show(o); + evas_object_show(op_frame); } if (!op_out) { @@ -160,3 +160,9 @@ options_toggle(Evas_Object *win, Evas_Object *bg, Evas_Object *term) op_del_timer = ecore_timer_add(10.0, _cb_op_del_delay, NULL); } } + +Eina_Bool +options_active_get(void) +{ + return op_out; +} diff --git a/src/bin/options.h b/src/bin/options.h index 465f6c73..f7989b0a 100644 --- a/src/bin/options.h +++ b/src/bin/options.h @@ -1,2 +1,2 @@ void options_toggle(Evas_Object *win, Evas_Object *bg, Evas_Object *term); - +Eina_Bool options_active_get(void); diff --git a/src/bin/termio.c b/src/bin/termio.c index aa5d7afa..edf693e1 100644 --- a/src/bin/termio.c +++ b/src/bin/termio.c @@ -340,7 +340,7 @@ _smart_update_queue(Evas_Object *obj, Termio *sd) } static void -_take_selection(Evas_Object *obj) +_take_selection(Evas_Object *obj, Elm_Sel_Type type) { Termio *sd = evas_object_smart_data_get(obj); int start_x, start_y, end_x, end_y; @@ -362,7 +362,7 @@ _take_selection(Evas_Object *obj) if (s) { if (sd->win) - elm_cnp_selection_set(sd->win, ELM_SEL_TYPE_PRIMARY, + elm_cnp_selection_set(sd->win, type, ELM_SEL_FORMAT_TEXT, s, strlen(s)); free(s); } @@ -383,12 +383,12 @@ _getsel_cb(void *data, Evas_Object *obj __UNUSED__, Elm_Selection_Data *ev) } static void -_paste_selection(Evas_Object *obj) +_paste_selection(Evas_Object *obj, Elm_Sel_Type type) { Termio *sd = evas_object_smart_data_get(obj); if (!sd) return; if (!sd->win) return; - elm_cnp_selection_get(sd->win, ELM_SEL_TYPE_PRIMARY, ELM_SEL_FORMAT_TEXT, + elm_cnp_selection_get(sd->win, type, ELM_SEL_FORMAT_TEXT, _getsel_cb, obj); } @@ -457,7 +457,7 @@ _smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, } else if (!strcmp(ev->keyname, "Insert")) { - _paste_selection(data); + _paste_selection(data, ELM_SEL_TYPE_CLIPBOARD); goto end; } } @@ -823,7 +823,7 @@ _rep_mouse_up(Evas_Object *obj, Evas_Event_Mouse_Up *ev, int cx, int cy) } static void -_rep_mouse_move(Evas_Object *obj, Evas_Event_Mouse_Move *ev, int cx, int cy) +_rep_mouse_move(Evas_Object *obj, Evas_Event_Mouse_Move *ev __UNUSED__, int cx __UNUSED__, int cy __UNUSED__) { Termio *sd; @@ -849,7 +849,7 @@ _smart_cb_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__ if (ev->flags & EVAS_BUTTON_TRIPLE_CLICK) { _sel_line(data, cx, cy - sd->scroll); - if (sd->cur.sel) _take_selection(data); + if (sd->cur.sel) _take_selection(data, ELM_SEL_TYPE_PRIMARY); } else if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK) { @@ -867,7 +867,7 @@ _smart_cb_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__ { _sel_word(data, cx, cy - sd->scroll); } - if (sd->cur.sel) _take_selection(data); + if (sd->cur.sel) _take_selection(data, ELM_SEL_TYPE_PRIMARY); } else { @@ -886,7 +886,7 @@ _smart_cb_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__ _smart_update_queue(data, sd); } else if (ev->button == 2) - _paste_selection(data); + _paste_selection(data, ELM_SEL_TYPE_PRIMARY); else if (ev->button == 3) evas_object_smart_callback_call(data, "options", NULL); } @@ -910,7 +910,7 @@ _smart_cb_mouse_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, sd->cur.sel2.x = cx; sd->cur.sel2.y = cy - sd->scroll; _smart_update_queue(data, sd); - _take_selection(data); + _take_selection(data, ELM_SEL_TYPE_PRIMARY); } } } @@ -1541,3 +1541,15 @@ termio_config_get(const Evas_Object *obj) EINA_SAFETY_ON_NULL_RETURN_VAL(sd, NULL); return sd->config; } + +void +termio_copy_clipboard(Evas_Object *obj) +{ + _take_selection(obj, ELM_SEL_TYPE_CLIPBOARD); +} + +void +termio_paste_clipboard(Evas_Object *obj) +{ + _paste_selection(obj, ELM_SEL_TYPE_CLIPBOARD); +} diff --git a/src/bin/termio.h b/src/bin/termio.h index 5b325fa3..d7274681 100644 --- a/src/bin/termio.h +++ b/src/bin/termio.h @@ -8,5 +8,7 @@ void termio_win_set(Evas_Object *obj, Evas_Object *win); char *termio_selection_get(Evas_Object *obj, int c1x, int c1y, int c2x, int c2y); void termio_config_update(Evas_Object *obj); Config *termio_config_get(const Evas_Object *obj); +void termio_copy_clipboard(Evas_Object *obj); +void termio_paste_clipboard(Evas_Object *obj); #endif