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
This commit is contained in:
Carsten Haitzler 2012-06-24 06:39:54 +00:00
parent b3003cadc0
commit 256059af6e
10 changed files with 221 additions and 27 deletions

6
TODO
View File

@ -5,11 +5,13 @@ make it a first-class terminal:
[ ] blink and blink2 attributes need to be supported [ ] blink and blink2 attributes need to be supported
[ ] improve terminal emulation handling. known apps with problems: [ ] improve terminal emulation handling. known apps with problems:
mc 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) [ ] dnd text (to/from terminal)
[ ] handle multibyte displays better (does handle utf8 only atm and [ ] handle multibyte displays better (does handle utf8 only atm and
then maybe not according to convention like double cell spacing 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 [ ] general input mode handling improvements (keypad, other key
input, etc.) input, etc.)
[ ] selection of themes [ ] selection of themes

View File

@ -322,16 +322,59 @@ collections {
signal: "options,show"; signal: "options,show";
source: "terminology"; source: "terminology";
action: STATE_SET "visible" 0.0; action: STATE_SET "visible" 0.0;
transition: DECELERATE 0.5; transition: DECELERATE 0.4;
target: "terminology.options"; target: "terminology.options";
} }
program { name: "op_hide"; program { name: "op_hide";
signal: "options,hide"; signal: "options,hide";
source: "terminology"; source: "terminology";
action: STATE_SET "default" 0.0; action: STATE_SET "default" 0.0;
transition: DECELERATE 0.5; transition: DECELERATE 0.6;
target: "terminology.options"; 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";
}
} }
} }

View File

@ -12,6 +12,7 @@ terminology_SOURCES = \
private.h \ private.h \
col.c col.h \ col.c col.h \
config.c config.h \ config.c config.h \
controls.c controls.h \
keyin.c keyin.h \ keyin.c keyin.h \
main.c main.h \ main.c main.h \
media.c media.h \ media.c media.h \

126
src/bin/controls.c Normal file
View File

@ -0,0 +1,126 @@
#include "private.h"
#include <Elementary.h>
#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);
}
}

2
src/bin/controls.h Normal file
View File

@ -0,0 +1,2 @@
void controls_toggle(Evas_Object *win, Evas_Object *bg, Evas_Object *term);

View File

@ -6,7 +6,7 @@
#include "win.h" #include "win.h"
#include "termio.h" #include "termio.h"
#include "config.h" #include "config.h"
#include "options.h" #include "controls.h"
#include "media.h" #include "media.h"
#include "utils.h" #include "utils.h"
@ -56,7 +56,7 @@ _cb_size_hint(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void
static void static void
_cb_options(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__) _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 static Eina_Bool

View File

@ -73,7 +73,7 @@ options_toggle(Evas_Object *win, Evas_Object *bg, Evas_Object *term)
if (!op_frame) 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); Config *config = termio_config_get(term);
op_frame = o = elm_frame_add(win); 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", it_fn = elm_toolbar_item_append(o, "preferences-desktop-font",
"Font", _cb_op_font, term); "Font", _cb_op_font, term);
it_th = elm_toolbar_item_append(o, "preferences-desktop-theme", elm_toolbar_item_append(o, "preferences-desktop-theme",
"Theme", _cb_op_theme, term); "Theme", _cb_op_theme, term);
it_wp = elm_toolbar_item_append(o, "preferences-desktop-wallpaper", elm_toolbar_item_append(o, "preferences-desktop-wallpaper",
"Wallpaper", _cb_op_wallpaper, term); "Wallpaper", _cb_op_wallpaper, term);
it_wp = elm_toolbar_item_append(o, "preferences-desktop-multimedia", elm_toolbar_item_append(o, "preferences-desktop-multimedia",
"Video", _cb_op_video, term); "Video", _cb_op_video, term);
it_bh = elm_toolbar_item_append(o, "system-run", elm_toolbar_item_append(o, "system-run",
"Behavior", _cb_op_behavior, term); "Behavior", _cb_op_behavior, term);
elm_box_pack_end(op_tbox, o); elm_box_pack_end(op_tbox, o);
evas_object_show(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); evas_object_smart_callback_add(o, "changed", _cb_op_tmp_chg, config);
edje_object_part_swallow(bg, "terminology.options", op_frame); edje_object_part_swallow(bg, "terminology.options", op_frame);
evas_object_show(o); evas_object_show(op_frame);
} }
if (!op_out) 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); op_del_timer = ecore_timer_add(10.0, _cb_op_del_delay, NULL);
} }
} }
Eina_Bool
options_active_get(void)
{
return op_out;
}

View File

@ -1,2 +1,2 @@
void options_toggle(Evas_Object *win, Evas_Object *bg, Evas_Object *term); void options_toggle(Evas_Object *win, Evas_Object *bg, Evas_Object *term);
Eina_Bool options_active_get(void);

View File

@ -340,7 +340,7 @@ _smart_update_queue(Evas_Object *obj, Termio *sd)
} }
static void static void
_take_selection(Evas_Object *obj) _take_selection(Evas_Object *obj, Elm_Sel_Type type)
{ {
Termio *sd = evas_object_smart_data_get(obj); Termio *sd = evas_object_smart_data_get(obj);
int start_x, start_y, end_x, end_y; int start_x, start_y, end_x, end_y;
@ -362,7 +362,7 @@ _take_selection(Evas_Object *obj)
if (s) if (s)
{ {
if (sd->win) 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)); ELM_SEL_FORMAT_TEXT, s, strlen(s));
free(s); free(s);
} }
@ -383,12 +383,12 @@ _getsel_cb(void *data, Evas_Object *obj __UNUSED__, Elm_Selection_Data *ev)
} }
static void static void
_paste_selection(Evas_Object *obj) _paste_selection(Evas_Object *obj, Elm_Sel_Type type)
{ {
Termio *sd = evas_object_smart_data_get(obj); Termio *sd = evas_object_smart_data_get(obj);
if (!sd) return; if (!sd) return;
if (!sd->win) 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); _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")) else if (!strcmp(ev->keyname, "Insert"))
{ {
_paste_selection(data); _paste_selection(data, ELM_SEL_TYPE_CLIPBOARD);
goto end; goto end;
} }
} }
@ -823,7 +823,7 @@ _rep_mouse_up(Evas_Object *obj, Evas_Event_Mouse_Up *ev, int cx, int cy)
} }
static void 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; 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) if (ev->flags & EVAS_BUTTON_TRIPLE_CLICK)
{ {
_sel_line(data, cx, cy - sd->scroll); _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) 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); _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 else
{ {
@ -886,7 +886,7 @@ _smart_cb_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__
_smart_update_queue(data, sd); _smart_update_queue(data, sd);
} }
else if (ev->button == 2) else if (ev->button == 2)
_paste_selection(data); _paste_selection(data, ELM_SEL_TYPE_PRIMARY);
else if (ev->button == 3) else if (ev->button == 3)
evas_object_smart_callback_call(data, "options", NULL); 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.x = cx;
sd->cur.sel2.y = cy - sd->scroll; sd->cur.sel2.y = cy - sd->scroll;
_smart_update_queue(data, sd); _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); EINA_SAFETY_ON_NULL_RETURN_VAL(sd, NULL);
return sd->config; 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);
}

View File

@ -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); char *termio_selection_get(Evas_Object *obj, int c1x, int c1y, int c2x, int c2y);
void termio_config_update(Evas_Object *obj); void termio_config_update(Evas_Object *obj);
Config *termio_config_get(const 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 #endif