Merge branch 'grouped-input'

This commit is contained in:
Boris Faure 2018-02-11 11:56:13 +01:00
commit 653173bd85
28 changed files with 2433 additions and 1676 deletions

2
README
View File

@ -63,6 +63,8 @@ Ctrl+Shift+c = copy current selection to clipboard
Ctrl+Shift+v = paste current clipboard selection
Alt+Home = Enter command mode (enter commands to control terminology itself)
Alt+Return = Paste primary selection
Alt+g = Group input: send input to all visible terminals in the window
Alt+Shift+g = Group input: send input to all terminals in the window
Alt+w = Copy selection to primary
Alt+Up = Focus the terminal above
Alt+Down = Focus the terminal below

View File

@ -1,5 +1,5 @@
.\" Manpage for Terminology
.TH man 1 "02 Sep 2017" "1.1.1" "Terminology man page"
.TH man 1 "11 Feb 2018" "1.2.0" "Terminology man page"
.SH NAME
Terminology \- Terminal Emulator written with EFL (Enlightenment Foundation Libraries).
.SH SYNOPSIS
@ -288,6 +288,14 @@ Enter command mode (enter commands to control terminology itself).
Paste primary selection.
.
.TP
.B Alt+g
Group input: send input to all visible terminals in the window
.
.TP
.B Alt+Shift+g
Group input: send input to all terminals in the window
.
.TP
.B Alt+w
Copy selection to primary.
.

View File

@ -1,24 +1,28 @@
#include "private.h"
#include <Elementary.h>
#include <assert.h>
#include "about.h"
#include "config.h"
#include "termio.h"
static Evas_Object *ab_layout = NULL, *ab_over = NULL;
static Eina_Bool ab_out = EINA_FALSE;
static Ecore_Timer *ab_del_timer = NULL;
static Evas_Object *saved_win = NULL;
static Evas_Object *saved_bg = NULL;
static void (*ab_donecb) (void *data) = NULL;
static void *ab_donedata = NULL;
typedef struct _about_ctx {
Evas_Object *layout;
Evas_Object *over;
Evas_Object *win;
Evas_Object *base;
Evas_Object *term;
void (*donecb) (void *data);
void *donedata;
} About_Ctx;
static Eina_Bool
_cb_ab_del_delay(void *_data EINA_UNUSED)
_cb_del_delay(void *data)
{
evas_object_del(ab_layout);
ab_layout = NULL;
ab_del_timer = NULL;
Evas_Object *layout = data;
evas_object_del(layout);
elm_cache_all_flush();
return EINA_FALSE;
}
@ -29,170 +33,166 @@ _cb_mouse_down(void *data,
Evas_Object *_obj EINA_UNUSED,
void *_ev EINA_UNUSED)
{
about_toggle(saved_win, saved_bg, data, ab_donecb, ab_donedata);
About_Ctx *ctx = data;
if (ctx->over)
{
evas_object_del(ctx->over);
}
elm_object_focus_set(ctx->layout, EINA_FALSE);
edje_object_signal_emit(ctx->base, "about,hide", "terminology");
ecore_timer_add(10.0, _cb_del_delay, ctx->layout);
ctx->layout = NULL;
if (ctx->donecb)
ctx->donecb(ctx->donedata);
free(ctx);
}
void
about_toggle(Evas_Object *win, Evas_Object *bg, Evas_Object *term,
about_show(Evas_Object *win, Evas_Object *base, Evas_Object *term,
void (*donecb) (void *data), void *donedata)
{
Evas_Object *o;
About_Ctx *ctx;
Config *config = termio_config_get(term);
char buf[PATH_MAX];
const char *txt;
saved_win = win;
saved_bg = bg;
if (!ab_layout)
{
Config *config = termio_config_get(term);
char buf[PATH_MAX];
const char *txt;
ctx = malloc(sizeof(*ctx));
assert(ctx);
ab_layout = o = elm_layout_add(win);
if (elm_layout_file_set(o, config_theme_path_get(config),
"terminology/about") == 0)
{
snprintf(buf, sizeof(buf), "%s/themes/default.edj",
elm_app_data_dir_get());
elm_layout_file_set(o, buf, "terminology/about");
}
ctx->win = win;
ctx->base = base;
ctx->term = term;
ctx->donecb = donecb;
ctx->donedata = donedata;
txt = eina_stringshare_printf(_(
"<b>Terminology %s</b><br>"
"Why should terminals be boring?<br>"
"<br>"
"This terminal was written for Enlightenment, to use EFL "
"and otherwise push the boundaries of what a modern terminal "
"emulator should be. We hope you enjoy it.<br>"
"<br>"
"Copyright © 2012-%d by:<br>"
"<br>"
"%s" // AUTHORS
"<br>"
"<br>"
"Distributed under the 2-clause BSD license detailed below:<br>"
"<br>"
"%s" // LICENSE
),
PACKAGE_VERSION, 2018,
"Boris Faure<br>"
"Carsten Haitzler<br>"
"Gustavo Sverzut Barbieri<br>"
"Cedric BAIL<br>"
"Sebastian Dransfeld<br>"
"Wonguk Jeong<br>"
"Christopher Michael<br>"
"Daniel Juyung Seo<br>"
"Panagiotis Galatsanos<br>"
"Mike Blumenkrantz<br>"
"Aleksandar Popadić<br>"
"Massimo Maiurana<br>"
"Stefan Schmidt<br>"
"Davide Andreoli<br>"
"Gustavo Lima Chaves<br>"
"Jean-Philippe ANDRÉ<br>"
"Tom Hacohen<br>"
"Alex-P. Natsios<br>"
"Lee Gwang-O<br>"
"Jean Guyomarc'h<br>"
"Jihoon Kim<br>"
"Kai Huuhko<br>"
"Mike McCormack<br>"
"Iván Briano<br>"
"Jerome Pinot<br>"
"José Roberto de Souza<br>"
"Leandro Pereira<br>"
"Leif Middelschulte<br>"
"Markus Törnqvist<br>"
"Thibaut Broggi<br>"
"Lucas De Marchi<br>"
"Marcel Hollerbach<br>"
"Anisse Astier<br>"
"Daniel Zaoui<br>"
"Doug Newgard<br>"
"Flavio Vinicius Alvares Ceolin<br>"
"Samuel F. Baggen<br>"
"Amitesh Singh<br>"
"Anthony F McInerney<br>"
"Aurélien Larcher<br>"
"Bruno Dilly<br>"
"Conrad Meyer<br>"
"Daniel Kolesa<br>"
"Eduardo Lima<br>"
"Flavio Ceolin<br>"
"Jason L. Cook<br>"
"Jérémy Anger<br>"
"Michael BOUCHAUD<br>"
"Michael Jennings<br>"
"Nicholas Hughart<br>"
"Rafael Antognolli<br>"
"Rui Seabra<br>"
"Sanjeev BA<br>"
"Theodor van Nahl<br>"
"Vincent Torri<br>"
"tantSinnister<br>",
"All rights reserved.<br>"
"<br>"
"Redistribution and use in source and binary forms, with or "
"without modification, are permitted provided that the "
"following conditions are met:<br>"
"<br>"
"1. Redistributions of source code must retain the above "
"copyright notice, this list of conditions and the following "
"disclaimer.<br>"
"2. Redistributions in binary form must reproduce the above "
"copyright notice, this list of conditions and the following "
"disclaimer in the documentation and/or other materials "
"provided with the distribution.<br>"
"<br>"
"<b>THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR "
"IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED "
"WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR "
"PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER "
"OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, "
"INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES "
"(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE "
"GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS "
"INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, "
"WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING "
"NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF "
"THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH "
"DAMAGE.</b>");
elm_object_part_text_set(o, "terminology.text", txt);
eina_stringshare_del(txt);
evas_object_show(o);
edje_object_part_swallow(bg, "terminology.about", ab_layout);
}
if (!ab_out)
ctx->layout = o = elm_layout_add(win);
if (elm_layout_file_set(o, config_theme_path_get(config),
"terminology/about") == 0)
{
ab_over = o = evas_object_rectangle_add(evas_object_evas_get(win));
evas_object_color_set(o, 0, 0, 0, 0);
edje_object_part_swallow(bg, "terminology.dismiss", o);
evas_object_show(o);
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
_cb_mouse_down, term);
edje_object_signal_emit(bg, "about,show", "terminology");
elm_object_signal_emit(ab_layout, "begin" ,"terminology");
ab_out = EINA_TRUE;
ab_donecb = donecb;
ab_donedata = donedata;
elm_object_focus_set(ab_layout, EINA_TRUE);
if (ab_del_timer)
{
ecore_timer_del(ab_del_timer);
ab_del_timer = NULL;
}
}
else
{
evas_object_del(ab_over);
ab_over = NULL;
edje_object_signal_emit(bg, "about,hide", "terminology");
ab_out = EINA_FALSE;
elm_object_focus_set(ab_layout, EINA_FALSE);
if (ab_donecb) ab_donecb(ab_donedata);
// elm_object_focus_set(term, EINA_TRUE);
if (ab_del_timer) ecore_timer_del(ab_del_timer);
ab_del_timer = ecore_timer_add(10.0, _cb_ab_del_delay, NULL);
snprintf(buf, sizeof(buf), "%s/themes/default.edj",
elm_app_data_dir_get());
elm_layout_file_set(o, buf, "terminology/about");
}
txt = eina_stringshare_printf(_(
"<b>Terminology %s</b><br>"
"Why should terminals be boring?<br>"
"<br>"
"This terminal was written for Enlightenment, to use EFL "
"and otherwise push the boundaries of what a modern terminal "
"emulator should be. We hope you enjoy it.<br>"
"<br>"
"Copyright © 2012-%d by:<br>"
"<br>"
"%s" // AUTHORS
"<br>"
"<br>"
"Distributed under the 2-clause BSD license detailed below:<br>"
"<br>"
"%s" // LICENSE
),
PACKAGE_VERSION, 2018,
"Boris Faure<br>"
"Carsten Haitzler<br>"
"Gustavo Sverzut Barbieri<br>"
"Cedric BAIL<br>"
"Sebastian Dransfeld<br>"
"Wonguk Jeong<br>"
"Christopher Michael<br>"
"Daniel Juyung Seo<br>"
"Panagiotis Galatsanos<br>"
"Mike Blumenkrantz<br>"
"Aleksandar Popadić<br>"
"Massimo Maiurana<br>"
"Stefan Schmidt<br>"
"Davide Andreoli<br>"
"Gustavo Lima Chaves<br>"
"Jean-Philippe ANDRÉ<br>"
"Tom Hacohen<br>"
"Alex-P. Natsios<br>"
"Lee Gwang-O<br>"
"Jean Guyomarc'h<br>"
"Jihoon Kim<br>"
"Kai Huuhko<br>"
"Mike McCormack<br>"
"Iván Briano<br>"
"Jerome Pinot<br>"
"José Roberto de Souza<br>"
"Leandro Pereira<br>"
"Leif Middelschulte<br>"
"Markus Törnqvist<br>"
"Thibaut Broggi<br>"
"Lucas De Marchi<br>"
"Marcel Hollerbach<br>"
"Anisse Astier<br>"
"Daniel Zaoui<br>"
"Doug Newgard<br>"
"Flavio Vinicius Alvares Ceolin<br>"
"Samuel F. Baggen<br>"
"Amitesh Singh<br>"
"Anthony F McInerney<br>"
"Aurélien Larcher<br>"
"Bruno Dilly<br>"
"Conrad Meyer<br>"
"Daniel Kolesa<br>"
"Eduardo Lima<br>"
"Flavio Ceolin<br>"
"Jason L. Cook<br>"
"Jérémy Anger<br>"
"Michael BOUCHAUD<br>"
"Michael Jennings<br>"
"Nicholas Hughart<br>"
"Rafael Antognolli<br>"
"Rui Seabra<br>"
"Sanjeev BA<br>"
"Theodor van Nahl<br>"
"Vincent Torri<br>"
"tantSinnister<br>",
"All rights reserved.<br>"
"<br>"
"Redistribution and use in source and binary forms, with or "
"without modification, are permitted provided that the "
"following conditions are met:<br>"
"<br>"
"1. Redistributions of source code must retain the above "
"copyright notice, this list of conditions and the following "
"disclaimer.<br>"
"2. Redistributions in binary form must reproduce the above "
"copyright notice, this list of conditions and the following "
"disclaimer in the documentation and/or other materials "
"provided with the distribution.<br>"
"<br>"
"<b>THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR "
"IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED "
"WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR "
"PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER "
"OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, "
"INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES "
"(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE "
"GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS "
"INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, "
"WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING "
"NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF "
"THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH "
"DAMAGE.</b>");
elm_object_part_text_set(o, "terminology.text", txt);
eina_stringshare_del(txt);
evas_object_show(o);
edje_object_part_swallow(base, "terminology.about", ctx->layout);
ctx->over = o = evas_object_rectangle_add(evas_object_evas_get(win));
evas_object_color_set(o, 0, 0, 0, 0);
edje_object_part_swallow(base, "terminology.dismiss", o);
evas_object_show(o);
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
_cb_mouse_down, ctx);
edje_object_signal_emit(base, "about,show", "terminology");
elm_object_signal_emit(ctx->layout, "begin" ,"terminology");
elm_object_focus_set(ctx->layout, EINA_TRUE);
}

View File

@ -1,7 +1,7 @@
#ifndef _ABOUT_H__
#define _ABOUT_H__ 1
void about_toggle(Evas_Object *win, Evas_Object *bg, Evas_Object *term,
void about_show(Evas_Object *win, Evas_Object *base, Evas_Object *term,
void (*donecb) (void *data), void *donedata);
#endif

View File

@ -7,7 +7,7 @@
#include "col.h"
#include "utils.h"
#define CONF_VER 17
#define CONF_VER 18
#define LIM(v, min, max) {if (v >= max) v = max; else if (v <= min) v = min;}
@ -343,6 +343,7 @@ _add_default_keys(Config *config)
ADD_KB("Down", 0, 1, 0, 0, "term_down");
ADD_KB("Left", 0, 1, 0, 0, "term_left");
ADD_KB("Right", 0, 1, 0, 0, "term_right");
ADD_KB("g", 0, 1, 0, 0, "visible_group");
/* Ctrl-Shift- */
ADD_KB("Prior", 1, 0, 1, 0, "split_h");
@ -377,6 +378,9 @@ _add_default_keys(Config *config)
ADD_KB("Right", 0, 0, 1, 0, "term_next");
ADD_KB("Home", 0, 0, 1, 0, "top_backlog");
ADD_KB("End", 0, 0, 1, 0, "reset_scroll");
/* Alt-Shift */
ADD_KB("g", 0, 1, 1, 0, "all_group");
}
void
@ -653,7 +657,12 @@ config_load(const char *key)
config->shine = 255;
EINA_FALLTHROUGH;
/*pass through*/
case CONF_VER: /* 17 */
case 17:
_add_key(config, "g", 0, 1, 0, 0, "visible_group");
_add_key(config, "g", 0, 1, 1, 0, "all_group");
EINA_FALLTHROUGH;
/*pass through*/
case CONF_VER: /* 18 */
config->version = CONF_VER;
break;
default:

View File

@ -1,224 +1,224 @@
#include "private.h"
#include <Elementary.h>
#include <assert.h>
#include "controls.h"
#include "options.h"
#include "about.h"
#include "termio.h"
#include "main.h"
static Evas_Object *ct_frame = NULL, *ct_boxh = NULL, *ct_boxv = NULL;
static Evas_Object *ct_box = NULL, *ct_box2 = NULL, *ct_box3 = NULL, *ct_over = NULL;
static Eina_Bool ct_out = EINA_FALSE;
static Ecore_Timer *ct_del_timer = NULL;
static Evas_Object *ct_win = NULL, *ct_bg = NULL, *ct_term = NULL;
static void (*ct_donecb) (void *data) = NULL;
static void *ct_donedata = NULL;
static Eina_Hash *controls = NULL;
typedef struct _Controls_Ctx {
Evas_Object *frame;
Evas_Object *over;
Evas_Object *win;
Evas_Object *base;
Evas_Object *bg;
Evas_Object *term;
void (*donecb) (void *data);
void *donedata;
} Controls_Ctx;
static void
_cb_sel_on(void *_data EINA_UNUSED,
controls_hide(Controls_Ctx *ctx, Eina_Bool call_cb);
static void
_cb_sel_on(void *data,
Evas_Object *_term EINA_UNUSED,
void *_ev EINA_UNUSED)
{
Evas_Object *bt_copy = evas_object_data_get(ct_frame, "bt_copy");
Controls_Ctx *ctx = data;
Evas_Object *bt_copy = evas_object_data_get(ctx->frame, "bt_copy");
if (bt_copy)
elm_object_disabled_set(bt_copy, EINA_FALSE);
}
static void
_cb_sel_off(void *_data EINA_UNUSED,
_cb_sel_off(void *data,
Evas_Object *_term EINA_UNUSED,
void *_ev EINA_UNUSED)
{
Evas_Object *bt_copy = evas_object_data_get(ct_frame, "bt_copy");
Controls_Ctx *ctx = data;
Evas_Object *bt_copy = evas_object_data_get(ctx->frame, "bt_copy");
if (bt_copy)
elm_object_disabled_set(bt_copy, EINA_TRUE);
}
static Eina_Bool
_cb_ct_del_delay(void *_data EINA_UNUSED)
_cb_del_delay(void *data)
{
if (ct_over)
{
evas_object_del(ct_over);
ct_over = NULL;
}
if (ct_frame)
{
evas_object_del(ct_frame);
ct_frame = NULL;
}
ct_del_timer = NULL;
Evas_Object *frame = data;
evas_object_del(frame);
elm_cache_all_flush();
return EINA_FALSE;
}
static void
_cb_ct_copy(void *_data EINA_UNUSED,
_cb_ct_copy(void *data,
Evas_Object *_obj EINA_UNUSED,
void *_event EINA_UNUSED)
{
termio_take_selection(ct_term, ELM_SEL_TYPE_CLIPBOARD);
controls_toggle(ct_win, ct_bg, ct_term, ct_donecb, ct_donedata);
Controls_Ctx *ctx = data;
Evas_Object *term = ctx->term;
controls_hide(ctx, EINA_TRUE);
termio_take_selection(term, ELM_SEL_TYPE_CLIPBOARD);
}
static void
_cb_ct_paste(void *_data EINA_UNUSED,
_cb_ct_paste(void *data,
Evas_Object *_obj EINA_UNUSED,
void *_event EINA_UNUSED)
{
termio_paste_selection(ct_term, ELM_SEL_TYPE_CLIPBOARD);
controls_toggle(ct_win, ct_bg, ct_term, ct_donecb, ct_donedata);
Controls_Ctx *ctx = data;
Evas_Object *term = ctx->term;
controls_hide(ctx, EINA_TRUE);
termio_paste_selection(term, ELM_SEL_TYPE_CLIPBOARD);
}
static void
_cb_ct_new(void *_data EINA_UNUSED,
_cb_ct_new(void *data,
Evas_Object *_obj EINA_UNUSED,
void *_event EINA_UNUSED)
{
main_new(ct_win, ct_term);
Controls_Ctx *ctx = data;
main_new(ctx->win, ctx->term);
}
static void
_cb_ct_split_v(void *_data EINA_UNUSED,
_cb_ct_split_v(void *data,
Evas_Object *_obj EINA_UNUSED,
void *_event EINA_UNUSED)
{
split_vertically(ct_win, ct_term, NULL);
Controls_Ctx *ctx = data;
split_vertically(ctx->win, ctx->term, NULL);
}
static void
_cb_ct_split_h(void *_data EINA_UNUSED,
_cb_ct_split_h(void *data,
Evas_Object *_obj EINA_UNUSED,
void *_event EINA_UNUSED)
{
split_horizontally(ct_win, ct_term, NULL);
Controls_Ctx *ctx = data;
split_horizontally(ctx->win, ctx->term, NULL);
}
static void
_cb_ct_miniview(void *_data EINA_UNUSED,
_cb_ct_miniview(void *data,
Evas_Object *_obj EINA_UNUSED,
void *_event EINA_UNUSED)
{
term_miniview_toggle(termio_term_get(ct_term));
Controls_Ctx *ctx = data;
term_miniview_toggle(termio_term_get(ctx->term));
}
static void
_cb_ct_set_title(void *_data EINA_UNUSED,
_cb_ct_set_title(void *data,
Evas_Object *_obj EINA_UNUSED,
void *_event EINA_UNUSED)
{
term_set_title(termio_term_get(ct_term));
Controls_Ctx *ctx = data;
Evas_Object *term = ctx->term;
controls_hide(ctx, EINA_TRUE);
term_set_title(termio_term_get(term));
}
static void
_cb_ct_close(void *_data EINA_UNUSED,
_cb_ct_close(void *data,
Evas_Object *_obj EINA_UNUSED,
void *_event EINA_UNUSED)
{
term_close(ct_win, ct_term, EINA_FALSE);
Controls_Ctx *ctx = data;
Evas_Object *term = ctx->term;
Evas_Object *win = ctx->win;
controls_hide(ctx, EINA_TRUE);
term_close(win, term, EINA_FALSE);
}
static void
_cb_ct_options(void *_data EINA_UNUSED,
_on_sub_done(void *data)
{
Controls_Ctx *ctx = data;
ecore_timer_add(10.0, _cb_del_delay, ctx->frame);
ctx->frame = NULL;
if (ctx->donecb)
ctx->donecb(ctx->donedata);
eina_hash_del(controls, &ctx->win, ctx);
free(ctx);
}
static void
_cb_ct_options(void *data,
Evas_Object *_obj EINA_UNUSED,
void *_event EINA_UNUSED)
{
controls_toggle(ct_win, ct_bg, ct_term, ct_donecb, ct_donedata);
options_toggle(ct_win, ct_bg, ct_term, ct_donecb, ct_donedata);
Controls_Ctx *ctx = data;
options_show(ctx->win, ctx->base, ctx->bg, ctx->term, _on_sub_done, ctx);
controls_hide(ctx, EINA_FALSE);
}
static void
_cb_ct_about(void *_data EINA_UNUSED,
_cb_ct_about(void *data,
Evas_Object *_obj EINA_UNUSED,
void *_event EINA_UNUSED)
{
controls_toggle(ct_win, ct_bg, ct_term, ct_donecb, ct_donedata);
about_toggle(ct_win, ct_bg, ct_term, ct_donecb, ct_donedata);
Controls_Ctx *ctx = data;
about_show(ctx->win, ctx->base, ctx->term, _on_sub_done, ctx);
controls_hide(ctx, EINA_FALSE);
}
static void
_cb_mouse_down(void *_data EINA_UNUSED,
_cb_mouse_down(void *data,
Evas *_e EINA_UNUSED,
Evas_Object *_obj EINA_UNUSED,
void *_ev EINA_UNUSED)
{
controls_toggle(ct_win, ct_bg, ct_term, ct_donecb, ct_donedata);
Controls_Ctx *ctx = data;
controls_hide(ctx, EINA_TRUE);
}
static void
_cb_frame_del(void *_data EINA_UNUSED,
Evas *_e EINA_UNUSED,
Evas_Object *_obj EINA_UNUSED,
void *_ev EINA_UNUSED)
{
if (ct_win)
{
evas_object_smart_callback_del(ct_win, "selection,on", _cb_sel_on);
evas_object_smart_callback_del(ct_win, "selection,off", _cb_sel_off);
}
ct_frame = NULL;
}
static void
_cb_over_del(void *_data EINA_UNUSED,
Evas *_e EINA_UNUSED,
Evas_Object *_obj EINA_UNUSED,
void *_ev EINA_UNUSED)
{
ct_over = NULL;
}
static void
_cb_saved_del(void *_data EINA_UNUSED,
_cb_saved_del(void *data,
Evas *_e EINA_UNUSED,
Evas_Object *obj,
void *_ev EINA_UNUSED)
{
if ((obj == ct_win) || (obj == ct_term))
{
if (obj == ct_term)
{
if (ct_out)
controls_toggle(ct_win, ct_bg, ct_term, ct_donecb, ct_donedata);
ct_term = NULL;
}
else
{
if (ct_frame)
{
evas_object_del(ct_frame);
ct_frame = NULL;
}
if (ct_del_timer)
{
ecore_timer_del(ct_del_timer);
ct_del_timer = NULL;
}
if (ct_over)
{
evas_object_del(ct_over);
ct_over = NULL;
}
evas_object_event_callback_del(ct_win, EVAS_CALLBACK_DEL, _cb_saved_del);
ct_win = NULL;
}
evas_object_event_callback_del(ct_term, EVAS_CALLBACK_DEL, _cb_saved_del);
ct_bg = NULL;
}
Controls_Ctx *ctx = data;
if (obj == ctx->win)
ctx->win = NULL;
else if (obj == ctx->term)
ctx->term = NULL;
controls_hide(ctx, EINA_FALSE);
}
static Evas_Object *
_button_add(Evas_Object *win, const char *label, const char *icon, Evas_Smart_Cb cb, void *cbdata)
{
Evas_Object *o, *bt;
bt = o = elm_button_add(win);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
if (label) elm_object_text_set(o, label);
evas_object_smart_callback_add(o, "clicked", cb, cbdata);
if (icon)
{
o = elm_icon_add(win);
@ -227,7 +227,7 @@ _button_add(Evas_Object *win, const char *label, const char *icon, Evas_Smart_Cb
elm_object_part_content_set(bt, "icon", o);
evas_object_show(o);
}
evas_object_show(bt);
return bt;
}
@ -236,7 +236,7 @@ static Evas_Object *
_sep_add_v(Evas_Object *win)
{
Evas_Object *o = elm_separator_add(win);
evas_object_size_hint_weight_set(o, 0.0, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(o, 0.5, EVAS_HINT_FILL);
elm_separator_horizontal_set(o, EINA_FALSE);
@ -248,7 +248,7 @@ static Evas_Object *
_sep_add_h(Evas_Object *win)
{
Evas_Object *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);
@ -256,167 +256,182 @@ _sep_add_h(Evas_Object *win)
return o;
}
void
controls_toggle(Evas_Object *win, Evas_Object *bg, Evas_Object *term,
void (*donecb) (void *data), void *donedata)
static void
controls_hide(Controls_Ctx *ctx, Eina_Bool call_cb)
{
Evas_Object *o;
if (!ct_out)
if (ctx->win)
{
if (options_active_get())
{
options_toggle(win, bg, term, ct_donecb, ct_donedata);
return;
}
evas_object_event_callback_del(ctx->win, EVAS_CALLBACK_DEL, _cb_saved_del);
evas_object_smart_callback_del(ctx->win, "selection,on", _cb_sel_on);
evas_object_smart_callback_del(ctx->win, "selection,off", _cb_sel_off);
}
if ((win != ct_win) && (ct_frame))
if (ctx->term)
{
evas_object_del(ct_frame);
ct_frame = NULL;
ct_win = NULL;
ct_term = NULL;
evas_object_event_callback_del(ctx->term, EVAS_CALLBACK_DEL, _cb_saved_del);
edje_object_signal_emit(ctx->base, "controls,hide", "terminology");
}
if (!ct_frame)
if (ctx->over)
{
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_boxv = o = elm_box_add(win);
elm_box_horizontal_set(o, EINA_FALSE);
elm_object_content_set(ct_frame, o);
evas_object_show(o);
ct_boxh = o = elm_box_add(win);
elm_box_pack_end(ct_boxv, o);
elm_box_horizontal_set(o, EINA_TRUE);
evas_object_show(o);
ct_box = o = elm_box_add(win);
elm_box_pack_end(ct_boxh, o);
evas_object_show(o);
o = _button_add(win, _("New"), "window-new", _cb_ct_new, NULL);
elm_box_pack_end(ct_box, o);
o = _sep_add_h(win);
elm_box_pack_end(ct_box, o);
o = _button_add(win, _("Split V"), "object-flip-vertical", _cb_ct_split_v, NULL);
elm_box_pack_end(ct_box, o);
o = _button_add(win, _("Split H"), "object-flip-horizontal", _cb_ct_split_h, NULL);
elm_box_pack_end(ct_box, o);
o = _sep_add_h(win);
elm_box_pack_end(ct_box, o);
o = _button_add(win, _("Miniview"), "view-restore", _cb_ct_miniview, NULL);
elm_box_pack_end(ct_box, o);
o = _sep_add_h(win);
elm_box_pack_end(ct_box, o);
o = _button_add(win, _("Set title"), "format-text-underline", _cb_ct_set_title, NULL);
elm_box_pack_end(ct_box, o);
o = _sep_add_v(win);
elm_box_pack_end(ct_boxh, o);
ct_box2 = o = elm_box_add(win);
elm_box_pack_end(ct_boxh, o);
evas_object_show(o);
o = _button_add(win, _("Copy"), "edit-copy", _cb_ct_copy, NULL);
evas_object_data_set(ct_frame, "bt_copy", o);
if (!termio_selection_exists(term))
elm_object_disabled_set(o, EINA_TRUE);
elm_box_pack_end(ct_box2, o);
o = _button_add(win, _("Paste"), "edit-paste", _cb_ct_paste, NULL);
elm_box_pack_end(ct_box2, o);
o = _sep_add_h(win);
elm_box_pack_end(ct_box2, o);
o = _button_add(win, _("Settings"), "preferences-desktop", _cb_ct_options, NULL);
elm_box_pack_end(ct_box2, o);
o = _sep_add_h(win);
elm_box_pack_end(ct_box2, o);
o = _button_add(win, _("About"), "help-about", _cb_ct_about, NULL);
elm_box_pack_end(ct_box2, o);
o = _sep_add_h(win);
elm_box_pack_end(ct_boxv, o);
ct_box3 = o = elm_box_add(win);
elm_box_pack_end(ct_boxv, o);
evas_object_show(o);
o = _button_add(win, _("Close Terminal"), "window-close", _cb_ct_close, NULL);
elm_box_pack_end(ct_box3, o);
evas_object_event_callback_add(ct_frame, EVAS_CALLBACK_DEL,
_cb_frame_del, NULL);
evas_object_smart_callback_add(win, "selection,on", _cb_sel_on,
NULL);
evas_object_smart_callback_add(win, "selection,off", _cb_sel_off,
NULL);
evas_object_del(ctx->over);
}
if (!ct_out)
{
edje_object_part_swallow(bg, "terminology.controls", ct_frame);
evas_object_show(ct_frame);
ct_over = o = evas_object_rectangle_add(evas_object_evas_get(win));
evas_object_color_set(o, 0, 0, 0, 0);
edje_object_part_swallow(bg, "terminology.dismiss", o);
evas_object_show(o);
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
_cb_mouse_down, NULL);
evas_object_event_callback_add(o, EVAS_CALLBACK_DEL,
_cb_over_del, NULL);
elm_object_focus_set(ctx->frame, EINA_FALSE);
ct_win = win;
ct_bg = bg;
ct_term = term;
ct_donecb = donecb;
ct_donedata = donedata;
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
if (call_cb)
{
if (ct_over)
{
evas_object_del(ct_over);
ct_over = NULL;
}
edje_object_signal_emit(ct_bg, "controls,hide", "terminology");
ct_out = EINA_FALSE;
elm_object_focus_set(ct_frame, EINA_FALSE);
if (ct_donecb) ct_donecb(ct_donedata);
// elm_object_focus_set(ct_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);
}
if (ct_win)
{
evas_object_event_callback_del(ct_win, EVAS_CALLBACK_DEL, _cb_saved_del);
evas_object_event_callback_del(ct_term, EVAS_CALLBACK_DEL, _cb_saved_del);
}
if (ct_out)
{
evas_object_event_callback_add(ct_win, EVAS_CALLBACK_DEL, _cb_saved_del, NULL);
evas_object_event_callback_add(ct_term, EVAS_CALLBACK_DEL, _cb_saved_del, NULL);
ecore_timer_add(10.0, _cb_del_delay, ctx->frame);
ctx->frame = NULL;
if (ctx->donecb)
ctx->donecb(ctx->donedata);
eina_hash_del(controls, &ctx->win, ctx);
free(ctx);
}
}
void
controls_show(Evas_Object *win, Evas_Object *base, Evas_Object *bg,
Evas_Object *term, void (*donecb) (void *data), void *donedata)
{
Evas_Object *o;
Evas_Object *ct_boxh, *ct_boxv, *ct_box, *ct_box2, *ct_box3;
Controls_Ctx *ctx;
if (eina_hash_find(controls, &win))
{
donecb(donedata);
return;
}
ctx = malloc(sizeof(*ctx));
assert(ctx);
ctx->win = win;
ctx->base = base;
ctx->bg = bg;
ctx->term = term;
ctx->donecb = donecb;
ctx->donedata = donedata;
eina_hash_add(controls, &win, ctx);
ctx->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_boxv = o = elm_box_add(win);
elm_box_horizontal_set(o, EINA_FALSE);
elm_object_content_set(ctx->frame, o);
evas_object_show(o);
ct_boxh = o = elm_box_add(win);
elm_box_pack_end(ct_boxv, o);
elm_box_horizontal_set(o, EINA_TRUE);
evas_object_show(o);
ct_box = o = elm_box_add(win);
elm_box_pack_end(ct_boxh, o);
evas_object_show(o);
o = _button_add(win, _("New"), "window-new",
_cb_ct_new, ctx);
elm_box_pack_end(ct_box, o);
o = _sep_add_h(win);
elm_box_pack_end(ct_box, o);
o = _button_add(win, _("Split V"), "object-flip-vertical",
_cb_ct_split_v, ctx);
elm_box_pack_end(ct_box, o);
o = _button_add(win, _("Split H"), "object-flip-horizontal",
_cb_ct_split_h, ctx);
elm_box_pack_end(ct_box, o);
o = _sep_add_h(win);
elm_box_pack_end(ct_box, o);
o = _button_add(win, _("Miniview"), "view-restore",
_cb_ct_miniview, ctx);
elm_box_pack_end(ct_box, o);
o = _sep_add_h(win);
elm_box_pack_end(ct_box, o);
o = _button_add(win, _("Set title"), "format-text-underline",
_cb_ct_set_title, ctx);
elm_box_pack_end(ct_box, o);
o = _sep_add_v(win);
elm_box_pack_end(ct_boxh, o);
ct_box2 = o = elm_box_add(win);
elm_box_pack_end(ct_boxh, o);
evas_object_show(o);
o = _button_add(win, _("Copy"), "edit-copy", _cb_ct_copy, ctx);
evas_object_data_set(ctx->frame, "bt_copy", o);
if (!termio_selection_exists(term))
elm_object_disabled_set(o, EINA_TRUE);
elm_box_pack_end(ct_box2, o);
o = _button_add(win, _("Paste"), "edit-paste", _cb_ct_paste, ctx);
elm_box_pack_end(ct_box2, o);
o = _sep_add_h(win);
elm_box_pack_end(ct_box2, o);
o = _button_add(win, _("Settings"), "preferences-desktop", _cb_ct_options, ctx);
elm_box_pack_end(ct_box2, o);
o = _sep_add_h(win);
elm_box_pack_end(ct_box2, o);
o = _button_add(win, _("About"), "help-about", _cb_ct_about, ctx);
elm_box_pack_end(ct_box2, o);
o = _sep_add_h(win);
elm_box_pack_end(ct_boxv, o);
ct_box3 = o = elm_box_add(win);
elm_box_pack_end(ct_boxv, o);
evas_object_show(o);
o = _button_add(win, _("Close Terminal"), "window-close", _cb_ct_close, NULL);
elm_box_pack_end(ct_box3, o);
evas_object_smart_callback_add(win, "selection,on", _cb_sel_on,
ctx);
evas_object_smart_callback_add(win, "selection,off", _cb_sel_off,
ctx);
edje_object_part_swallow(base, "terminology.controls", ctx->frame);
evas_object_show(ctx->frame);
ctx->over = o = evas_object_rectangle_add(evas_object_evas_get(win));
evas_object_color_set(o, 0, 0, 0, 0);
edje_object_part_swallow(base, "terminology.dismiss", o);
evas_object_show(o);
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
_cb_mouse_down, ctx);
edje_object_signal_emit(base, "controls,show", "terminology");
elm_object_focus_set(ctx->frame, EINA_TRUE);
evas_object_event_callback_add(ctx->win, EVAS_CALLBACK_DEL, _cb_saved_del, ctx);
evas_object_event_callback_add(ctx->term, EVAS_CALLBACK_DEL, _cb_saved_del, ctx);
}
void
controls_init(void)
{
controls = eina_hash_pointer_new(NULL);
}
void
controls_shutdown(void)
{
eina_hash_free(controls);
controls = NULL;
}

View File

@ -1,7 +1,11 @@
#ifndef _CONTROLS_H__
#define _CONTROLS_H__ 1
void controls_toggle(Evas_Object *win, Evas_Object *bg, Evas_Object *term,
void (*donecb) (void *data), void *donedata);
void controls_show(Evas_Object *win, Evas_Object *base, Evas_Object *bg,
Evas_Object *term,
void (*donecb) (void *data), void *donedata);
void controls_init(void);
void controls_shutdown(void);
#endif

View File

@ -102,9 +102,9 @@ keyin_compose_seq_reset(Keys_Handler *khdl)
#include "tty_keys.h"
static void
_handle_key_to_pty(Termpty *ty, const Evas_Event_Key_Down *ev,
int alt, int shift, int ctrl)
void
keyin_handle_key_to_pty(Termpty *ty, const Evas_Event_Key_Down *ev,
const int alt, const int shift, const int ctrl)
{
if (!ev->key)
return;
@ -228,92 +228,24 @@ key_binding_lookup(const char *keyname,
}
Eina_Bool
keyin_handle(Keys_Handler *khdl, Termpty *ty, const Evas_Event_Key_Down *ev,
Eina_Bool ctrl, Eina_Bool alt, Eina_Bool shift, Eina_Bool win,
Eina_Bool meta, Eina_Bool hyper)
keyin_handle_key_binding(Evas_Object *termio, const Evas_Event_Key_Down *ev,
Eina_Bool ctrl, Eina_Bool alt, Eina_Bool shift,
Eina_Bool win, Eina_Bool meta, Eina_Bool hyper)
{
Key_Binding *kb;
kb = key_binding_lookup(ev->keyname, ctrl, alt, shift, win, meta, hyper);
if (kb)
{
if (kb->cb(ty->obj))
if (kb->cb(termio))
{
keyin_compose_seq_reset(khdl);
return EINA_TRUE;
}
}
/* composing */
if (khdl->imf)
{
// EXCEPTION. Don't filter modifiers alt+shift -> breaks emacs
// and jed (alt+shift+5 for search/replace for example)
// Don't filter modifiers alt, is used by shells
if ((!alt) && (!ctrl))
{
Ecore_IMF_Event_Key_Down imf_ev;
ecore_imf_evas_event_key_down_wrap((Evas_Event_Key_Down*)ev, &imf_ev);
if (!khdl->composing)
{
if (ecore_imf_context_filter_event
(khdl->imf, ECORE_IMF_EVENT_KEY_DOWN, (Ecore_IMF_Event *)&imf_ev))
goto end;
}
}
}
// if term app asked for kbd lock - dont handle here
if (ty->termstate.kbd_lock) return EINA_TRUE;
// if app asked us to not do autorepeat - ignore press if is it is the same
// timestamp as last one
if ((ty->termstate.no_autorepeat) &&
(ev->timestamp == khdl->last_keyup)) return EINA_TRUE;
if (!khdl->composing)
{
Ecore_Compose_State state;
char *compres = NULL;
keyin_compose_seq_reset(khdl);
khdl->seq = eina_list_append(khdl->seq, eina_stringshare_add(ev->key));
state = ecore_compose_get(khdl->seq, &compres);
if (state == ECORE_COMPOSE_MIDDLE) khdl->composing = EINA_TRUE;
else khdl->composing = EINA_FALSE;
if (!khdl->composing) keyin_compose_seq_reset(khdl);
else goto end;
}
else
{
Ecore_Compose_State state;
char *compres = NULL;
if (key_is_modifier(ev->key)) goto end;
khdl->seq = eina_list_append(khdl->seq, eina_stringshare_add(ev->key));
state = ecore_compose_get(khdl->seq, &compres);
if (state == ECORE_COMPOSE_NONE) keyin_compose_seq_reset(khdl);
else if (state == ECORE_COMPOSE_DONE)
{
keyin_compose_seq_reset(khdl);
if (compres)
{
termpty_write(ty, compres, strlen(compres));
free(compres);
compres = NULL;
}
goto end;
}
else goto end;
}
_handle_key_to_pty(ty, ev, alt, shift, ctrl);
end:
return EINA_FALSE;
}
Eina_Bool
key_is_modifier(const char *key)
{
@ -343,18 +275,62 @@ keyin_handle_up(Keys_Handler *khdl, Evas_Event_Key_Up *ev)
{
Ecore_IMF_Event_Key_Up imf_ev;
ecore_imf_evas_event_key_up_wrap(ev, &imf_ev);
if (ecore_imf_context_filter_event
(khdl->imf, ECORE_IMF_EVENT_KEY_UP, (Ecore_IMF_Event *)&imf_ev))
return;
ecore_imf_context_filter_event
(khdl->imf, ECORE_IMF_EVENT_KEY_UP, (Ecore_IMF_Event *)&imf_ev);
}
}
/* }}} */
/* {{{ Callbacks */
#define RETURN_FALSE_ON_GROUP_ACTION_ALREADY_HANDLED \
Win *wn; \
Term *term = termio_term_get(termio_obj); \
if (!term) \
return EINA_FALSE; \
wn = term_win_get(term); \
if (!wn) \
return EINA_FALSE; \
if (win_is_group_action_handled(wn)) \
return EINA_FALSE; \
#define RETURN_FALSE_ON_GROUP_INPUT \
Win *wn; \
Term *term = termio_term_get(termio_obj); \
if (!term) \
return EINA_FALSE; \
wn = term_win_get(term); \
if (!wn) \
return EINA_FALSE; \
if (win_is_group_input(wn)) \
return EINA_FALSE; \
static Eina_Bool
cb_all_group(Evas_Object *termio_obj)
{
RETURN_FALSE_ON_GROUP_ACTION_ALREADY_HANDLED;
win_toggle_all_group(wn);
ERR("ALL GROUP");
return EINA_TRUE;
}
static Eina_Bool
cb_visible_group(Evas_Object *termio_obj)
{
RETURN_FALSE_ON_GROUP_ACTION_ALREADY_HANDLED;
win_toggle_visible_group(wn);
ERR("VISIBLE GROUP");
return EINA_TRUE;
}
static Eina_Bool
cb_term_prev(Evas_Object *termio_obj)
{
RETURN_FALSE_ON_GROUP_INPUT;
evas_object_smart_callback_call(termio_obj, "prev", NULL);
return EINA_TRUE;
}
@ -362,6 +338,8 @@ cb_term_prev(Evas_Object *termio_obj)
static Eina_Bool
cb_term_next(Evas_Object *termio_obj)
{
RETURN_FALSE_ON_GROUP_INPUT;
evas_object_smart_callback_call(termio_obj, "next", NULL);
return EINA_TRUE;
}
@ -369,9 +347,8 @@ cb_term_next(Evas_Object *termio_obj)
static Eina_Bool
cb_term_up(Evas_Object *termio_obj)
{
Term *term = termio_term_get(termio_obj);
if (!term)
return EINA_FALSE;
RETURN_FALSE_ON_GROUP_INPUT;
term_up(term);
return EINA_TRUE;
}
@ -379,9 +356,8 @@ cb_term_up(Evas_Object *termio_obj)
static Eina_Bool
cb_term_down(Evas_Object *termio_obj)
{
Term *term = termio_term_get(termio_obj);
if (!term)
return EINA_FALSE;
RETURN_FALSE_ON_GROUP_INPUT;
term_down(term);
return EINA_TRUE;
}
@ -389,9 +365,8 @@ cb_term_down(Evas_Object *termio_obj)
static Eina_Bool
cb_term_left(Evas_Object *termio_obj)
{
Term *term = termio_term_get(termio_obj);
if (!term)
return EINA_FALSE;
RETURN_FALSE_ON_GROUP_INPUT;
term_left(term);
return EINA_TRUE;
}
@ -399,9 +374,8 @@ cb_term_left(Evas_Object *termio_obj)
static Eina_Bool
cb_term_right(Evas_Object *termio_obj)
{
Term *term = termio_term_get(termio_obj);
if (!term)
return EINA_FALSE;
RETURN_FALSE_ON_GROUP_INPUT;
term_right(term);
return EINA_TRUE;
}
@ -409,6 +383,8 @@ cb_term_right(Evas_Object *termio_obj)
static Eina_Bool
cb_term_new(Evas_Object *termio_obj)
{
RETURN_FALSE_ON_GROUP_ACTION_ALREADY_HANDLED;
char path[PATH_MAX], cwd[PATH_MAX], *cmd;
const char *template = "%s -d %s";
int length;
@ -450,10 +426,8 @@ cb_tab_set_title(Evas_Object *termio_obj)
static Eina_Bool \
cb_tab_##N(Evas_Object *termio_obj) \
{ \
RETURN_FALSE_ON_GROUP_INPUT; \
int n = (N == 0) ? 9 : N - 1; \
Term *term = termio_term_get(termio_obj); \
if (!term) \
return EINA_FALSE; \
return term_tab_go(term, n); \
}
@ -472,6 +446,7 @@ CB_TAB(9)
static Eina_Bool
cb_cmd_box(Evas_Object *termio_obj)
{
RETURN_FALSE_ON_GROUP_ACTION_ALREADY_HANDLED;
evas_object_smart_callback_call(termio_obj, "cmdbox", NULL);
return EINA_TRUE;
}
@ -479,6 +454,7 @@ cb_cmd_box(Evas_Object *termio_obj)
static Eina_Bool
cb_split_h(Evas_Object *termio_obj)
{
RETURN_FALSE_ON_GROUP_INPUT;
evas_object_smart_callback_call(termio_obj, "split,h", NULL);
return EINA_TRUE;
}
@ -486,6 +462,7 @@ cb_split_h(Evas_Object *termio_obj)
static Eina_Bool
cb_split_v(Evas_Object *termio_obj)
{
RETURN_FALSE_ON_GROUP_INPUT;
evas_object_smart_callback_call(termio_obj, "split,v", NULL);
return EINA_TRUE;
}
@ -493,6 +470,7 @@ cb_split_v(Evas_Object *termio_obj)
static Eina_Bool
cb_tab_new(Evas_Object *termio_obj)
{
RETURN_FALSE_ON_GROUP_INPUT;
evas_object_smart_callback_call(termio_obj, "new", NULL);
return EINA_TRUE;
}
@ -500,6 +478,7 @@ cb_tab_new(Evas_Object *termio_obj)
static Eina_Bool
cb_close(Evas_Object *termio_obj)
{
RETURN_FALSE_ON_GROUP_INPUT;
evas_object_smart_callback_call(termio_obj, "close", NULL);
return EINA_TRUE;
}
@ -507,6 +486,7 @@ cb_close(Evas_Object *termio_obj)
static Eina_Bool
cb_tab_select(Evas_Object *termio_obj)
{
RETURN_FALSE_ON_GROUP_INPUT;
evas_object_smart_callback_call(termio_obj, "select", NULL);
return EINA_TRUE;
}
@ -557,6 +537,7 @@ cb_miniview(Evas_Object *termio_obj)
static Eina_Bool
cb_win_fullscreen(Evas_Object *termio_obj)
{
RETURN_FALSE_ON_GROUP_ACTION_ALREADY_HANDLED;
Evas_Object *win = termio_win_get(termio_obj);
Eina_Bool fullscreen;
@ -707,6 +688,9 @@ static Shortcut_Action _actions[] =
{"tab_9", gettext_noop("Switch to terminal tab 9"), cb_tab_9},
{"tab_10", gettext_noop("Switch to terminal tab 10"), cb_tab_0},
{"tab_title", gettext_noop("Change title"), cb_tab_set_title},
{"visible_group", gettext_noop("Toggle whether input goes to all visible terminals"), cb_visible_group},
{"all_group", gettext_noop("Toggle whether input goes to all visible terminals"), cb_all_group},
{"group", gettext_noop("Font size"), NULL},
{"increase_font_size", gettext_noop("Font size up 1"), cb_increase_font_size},

View File

@ -11,12 +11,19 @@ struct _Keys_Handler
unsigned char composing : 1;
};
void
keyin_handle_key_to_pty(Termpty *ty, const Evas_Event_Key_Down *ev,
const int alt, const int shift, const int ctrl);
Eina_Bool
termpty_can_handle_key(const Termpty *ty,
const Keys_Handler *khdl,
const Evas_Event_Key_Down *ev);
void keyin_compose_seq_reset(Keys_Handler *khdl);
Eina_Bool key_is_modifier(const char *key);
Eina_Bool
keyin_handle(Keys_Handler *khdl, Termpty *ty, const Evas_Event_Key_Down *ev,
Eina_Bool ctrl, Eina_Bool alt, Eina_Bool shift, Eina_Bool win,
Eina_Bool meta, Eina_Bool hyper);
keyin_handle_key_binding(Evas_Object *termio, const Evas_Event_Key_Down *ev,
Eina_Bool ctrl, Eina_Bool alt, Eina_Bool shift,
Eina_Bool win, Eina_Bool meta, Eina_Bool hyper);
void keyin_handle_up(Keys_Handler *khdl, Evas_Event_Key_Up *ev);

View File

@ -978,6 +978,7 @@ remote:
ecore_con_init();
ecore_con_url_init();
controls_init();
terminology_starting_up = EINA_FALSE;
elm_run();
@ -1008,9 +1009,11 @@ remote:
config_del(_main_config);
key_bindings_shutdown();
config_shutdown();
controls_shutdown();
eina_log_domain_unregister(_log_domain);
_log_domain = -1;
#if HAVE_GETTEXT && ENABLE_NLS
eina_stringshare_del(options.copyright);
#endif

View File

@ -1,6 +1,7 @@
#include "private.h"
#include <Elementary.h>
#include <assert.h>
#include "options.h"
#include "options_font.h"
#include "options_theme.h"
@ -14,17 +15,8 @@
#include "config.h"
#include "termio.h"
static Evas_Object *op_frame, *op_box = NULL, *op_toolbar = NULL,
*op_opbox = NULL, *op_tbox = NULL, *op_temp = NULL,
*op_over = NULL;
static Eina_Bool op_out = EINA_FALSE;
static Ecore_Timer *op_del_timer = NULL;
static Evas_Object *saved_win = NULL;
static Evas_Object *saved_bg = NULL;
static void (*op_donecb) (void *data) = NULL;
static void *op_donedata = NULL;
static enum option_mode {
enum option_mode {
OPTION_NONE = 0,
OPTION_FONT,
OPTION_THEME,
@ -34,229 +26,249 @@ static enum option_mode {
OPTION_BEHAVIOR,
OPTION_KEYS,
OPTION_HELPERS,
OPTION_ELM
} _mode = 0;
OPTION_ELM,
OPTIONS_MODE_NB
};
typedef struct _Options_Ctx {
enum option_mode mode;
Evas_Object *frame;
Evas_Object *toolbar;
Evas_Object *opbox;
Evas_Object *over;
Evas_Object *win;
Evas_Object *base;
Evas_Object *bg;
Evas_Object *term;
Config *config;
void (*donecb) (void *data);
void *donedata;
struct _Options_Ctx *modes[OPTIONS_MODE_NB];
} Options_Ctx;
static void
_cb_op(void *data,
Evas_Object *_obj EINA_UNUSED,
void *_event EINA_UNUSED)
{
enum option_mode mode = (intptr_t) data;
Options_Ctx **pctx = data;
Options_Ctx *ctx = *pctx;
enum option_mode mode = pctx - ctx->modes;
if (_mode == mode) return;
_mode = mode;
edje_object_signal_emit(saved_bg, "optdetails,hide", "terminology");
if (mode == ctx->mode)
return;
ctx->mode = mode;
edje_object_signal_emit(ctx->base, "optdetails,hide", "terminology");
}
static void
_cb_op_tmp_chg(void *data, Evas_Object *obj, void *_event EINA_UNUSED)
{
Config *config = data;
Options_Ctx *ctx = data;
Config *config = ctx->config;
config->temporary = elm_check_state_get(obj);
}
static Eina_Bool
_cb_op_del_delay(void *_data EINA_UNUSED)
_cb_op_del_delay(void *data)
{
evas_object_del(op_opbox);
evas_object_del(op_frame);
options_font_clear();
options_background_clear();
options_theme_clear();
op_opbox = NULL;
op_frame = NULL;
op_del_timer = NULL;
Options_Ctx *ctx = data;
evas_object_del(ctx->opbox);
evas_object_del(ctx->frame);
free(ctx);
elm_cache_all_flush();
return EINA_FALSE;
}
static void
_cb_mouse_down(void *data,
Evas *_e EINA_UNUSED,
Evas_Object *_obj EINA_UNUSED,
void *_ev EINA_UNUSED)
{
options_toggle(saved_win, saved_bg, data, op_donecb, op_donedata);
}
static void
_cb_opdt_hide_done(void *data,
Evas_Object *_obj EINA_UNUSED,
const char *_sig EINA_UNUSED,
const char *_src EINA_UNUSED)
{
elm_box_clear(op_opbox);
switch (_mode)
Options_Ctx *ctx = data;
elm_box_clear(ctx->opbox);
switch (ctx->mode)
{
case OPTION_NONE: break;
case OPTION_FONT: options_font(op_opbox, data); break;
case OPTION_THEME: options_theme(op_opbox, data); break;
case OPTION_BACKGROUND: options_background(op_opbox, data); break;
case OPTION_COLORS: options_colors(op_opbox, data); break;
case OPTION_VIDEO: options_video(op_opbox, data); break;
case OPTION_BEHAVIOR: options_behavior(op_opbox, data); break;
case OPTION_KEYS: options_keys(op_opbox, data); break;
case OPTION_HELPERS: options_helpers(op_opbox, data); break;
case OPTION_ELM: options_elm(op_opbox, data); break;
case OPTION_FONT: options_font(ctx->opbox, ctx->term); break;
case OPTION_THEME: options_theme(ctx->opbox, ctx->term); break;
case OPTION_BACKGROUND: options_background(ctx->opbox, ctx->term); break;
case OPTION_COLORS: options_colors(ctx->opbox, ctx->term, ctx->bg); break;
case OPTION_VIDEO: options_video(ctx->opbox, ctx->term); break;
case OPTION_BEHAVIOR: options_behavior(ctx->opbox, ctx->term); break;
case OPTION_KEYS: options_keys(ctx->opbox, ctx->term); break;
case OPTION_HELPERS: options_helpers(ctx->opbox, ctx->term); break;
case OPTION_ELM: options_elm(ctx->opbox, ctx->term); break;
case OPTIONS_MODE_NB: assert(0 && "should not occur");
}
edje_object_signal_emit(saved_bg, "optdetails,show", "terminology");
edje_object_signal_emit(ctx->base, "optdetails,show", "terminology");
}
static void
_cb_opdt_hide_done2(void *_data EINA_UNUSED,
_cb_opdt_hide_done2(void *data,
Evas_Object *_obj EINA_UNUSED,
const char *_sig EINA_UNUSED,
const char *_src EINA_UNUSED)
{
if (op_del_timer)
{
ecore_timer_del(op_del_timer);
op_del_timer = NULL;
}
_cb_op_del_delay(NULL);
edje_object_signal_callback_del(saved_bg, "optdetails,hide,done",
Options_Ctx *ctx = data;
edje_object_signal_callback_del(ctx->base, "optdetails,hide,done",
"terminology",
_cb_opdt_hide_done2);
ecore_timer_add(10.0, _cb_op_del_delay, ctx);
}
static void
options_hide(Options_Ctx *ctx)
{
edje_object_part_swallow(ctx->base, "terminology.optdetails", ctx->opbox);
edje_object_part_swallow(ctx->base, "terminology.options", ctx->frame);
edje_object_signal_emit(ctx->base, "optdetails,show", "terminology");
edje_object_signal_emit(ctx->base, "options,show", "terminology");
edje_object_signal_callback_del(ctx->base, "optdetails,hide,done",
"terminology",
_cb_opdt_hide_done);
edje_object_signal_callback_add(ctx->base, "optdetails,hide,done",
"terminology",
_cb_opdt_hide_done2, ctx);
elm_object_focus_set(ctx->frame, EINA_FALSE);
elm_object_focus_set(ctx->opbox, EINA_FALSE);
elm_object_focus_set(ctx->toolbar, EINA_FALSE);
evas_object_del(ctx->over);
ctx->over = NULL;
edje_object_signal_emit(ctx->base, "options,hide", "terminology");
edje_object_signal_emit(ctx->base, "optdetails,hide", "terminology");
if (ctx->donecb)
ctx->donecb(ctx->donedata);
}
static void
_cb_mouse_down(void *data,
Evas *_e EINA_UNUSED,
Evas_Object *_obj EINA_UNUSED,
void *_ev EINA_UNUSED)
{
Options_Ctx *ctx = data;
options_hide(ctx);
}
void
options_toggle(Evas_Object *win, Evas_Object *bg, Evas_Object *term,
options_show(Evas_Object *win, Evas_Object *base, Evas_Object *bg, Evas_Object *term,
void (*donecb) (void *data), void *donedata)
{
Evas_Object *o;
Evas_Object *o, *op_box, *op_tbox;
Options_Ctx *ctx;
int i = 0;
_mode = OPTION_NONE;
if (!op_frame)
{
Elm_Object_Item *it_fn;
Config *config = termio_config_get(term);
if (!config) return;
saved_win = win;
saved_bg = bg;
op_opbox = o = elm_box_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);
edje_object_part_swallow(bg, "terminology.optdetails", o);
evas_object_show(o);
Elm_Object_Item *it_fn;
Config *config = termio_config_get(term);
op_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, _("Options"));
if (!config) return;
op_box = o = elm_box_add(win);
elm_box_horizontal_set(o, EINA_TRUE);
elm_object_content_set(op_frame, o);
evas_object_show(o);
ctx = malloc(sizeof(*ctx));
assert(ctx);
ctx->mode = OPTION_NONE;
ctx->win = win;
ctx->base = base;
ctx->bg = bg;
ctx->term = term;
ctx->donecb = donecb;
ctx->donedata = donedata;
ctx->config = config;
op_tbox = o = elm_box_add(win);
evas_object_size_hint_weight_set(o, 0.0, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(o, 1.0, EVAS_HINT_FILL);
elm_box_pack_end(op_box, o);
evas_object_show(o);
op_toolbar = o = elm_toolbar_add(win);
evas_object_size_hint_weight_set(o, 0.0, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(o, 0.5, EVAS_HINT_FILL);
elm_toolbar_horizontal_set(o, EINA_FALSE);
elm_object_style_set(o, "item_horizontal");
elm_toolbar_icon_size_set(o, 16 * elm_config_scale_get());
elm_toolbar_shrink_mode_set(o, ELM_TOOLBAR_SHRINK_SCROLL);
elm_toolbar_select_mode_set(o, ELM_OBJECT_SELECT_MODE_ALWAYS);
elm_toolbar_menu_parent_set(o, win);
elm_toolbar_homogeneous_set(o, EINA_FALSE);
for (i = 0; i < OPTIONS_MODE_NB; i++)
ctx->modes[i] = ctx;
ctx->opbox = o = elm_box_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);
edje_object_part_swallow(ctx->base, "terminology.optdetails", o);
evas_object_show(o);
ctx->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, _("Options"));
op_box = o = elm_box_add(win);
elm_box_horizontal_set(o, EINA_TRUE);
elm_object_content_set(ctx->frame, o);
evas_object_show(o);
op_tbox = o = elm_box_add(win);
evas_object_size_hint_weight_set(o, 0.0, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(o, 1.0, EVAS_HINT_FILL);
elm_box_pack_end(op_box, o);
evas_object_show(o);
ctx->toolbar = o = elm_toolbar_add(win);
evas_object_size_hint_weight_set(o, 0.0, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(o, 0.5, EVAS_HINT_FILL);
elm_toolbar_horizontal_set(o, EINA_FALSE);
elm_object_style_set(o, "item_horizontal");
elm_toolbar_icon_size_set(o, 16 * elm_config_scale_get());
elm_toolbar_shrink_mode_set(o, ELM_TOOLBAR_SHRINK_SCROLL);
elm_toolbar_select_mode_set(o, ELM_OBJECT_SELECT_MODE_ALWAYS);
elm_toolbar_menu_parent_set(o, win);
elm_toolbar_homogeneous_set(o, EINA_FALSE);
#define ITEM_APPEND(_icon_name, _name, _option_mode) \
elm_toolbar_item_append(o, _icon_name, _name, _cb_op, \
(void*) OPTION_##_option_mode)
elm_toolbar_item_append(o, _icon_name, _name, _cb_op, \
(void*) &ctx->modes[OPTION_##_option_mode])
it_fn =
ITEM_APPEND("preferences-desktop-font", _("Font"), FONT);
ITEM_APPEND("preferences-desktop-theme", _("Theme"), THEME);
ITEM_APPEND("preferences-desktop-background", _("Background"), BACKGROUND);
ITEM_APPEND("preferences-desktop-theme", _("Colors"), COLORS);
ITEM_APPEND("video-display", _("Video"), VIDEO);
ITEM_APPEND("preferences-system", _("Behavior"), BEHAVIOR);
ITEM_APPEND("preferences-desktop-keyboard-shortcuts", _("Keys"), KEYS);
ITEM_APPEND("system-run", _("Helpers"), HELPERS);
ITEM_APPEND("preferences-color", _("Toolkit"), ELM);
it_fn =
ITEM_APPEND("preferences-desktop-font", _("Font"), FONT);
ITEM_APPEND("preferences-desktop-theme", _("Theme"), THEME);
ITEM_APPEND("preferences-desktop-background", _("Background"), BACKGROUND);
ITEM_APPEND("preferences-desktop-theme", _("Colors"), COLORS);
ITEM_APPEND("video-display", _("Video"), VIDEO);
ITEM_APPEND("preferences-system", _("Behavior"), BEHAVIOR);
ITEM_APPEND("preferences-desktop-keyboard-shortcuts", _("Keys"), KEYS);
ITEM_APPEND("system-run", _("Helpers"), HELPERS);
ITEM_APPEND("preferences-color", _("Toolkit"), ELM);
#undef ITEM_APPEND
elm_box_pack_end(op_tbox, o);
evas_object_show(o);
elm_box_pack_end(op_tbox, o);
evas_object_show(o);
elm_toolbar_item_selected_set(it_fn, EINA_TRUE);
op_temp = o = elm_check_add(win);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 1.0);
elm_object_text_set(o, _("Temporary"));
elm_check_state_set(o, config->temporary);
elm_box_pack_end(op_tbox, o);
evas_object_show(o);
evas_object_smart_callback_add(o, "changed", _cb_op_tmp_chg, config);
elm_toolbar_item_selected_set(it_fn, EINA_TRUE);
edje_object_part_swallow(bg, "terminology.options", op_frame);
evas_object_show(op_frame);
}
else if ((op_opbox) && (!op_out))
{
edje_object_part_swallow(bg, "terminology.optdetails", op_opbox);
edje_object_part_swallow(bg, "terminology.options", op_frame);
edje_object_signal_emit(bg, "optdetails,show", "terminology");
edje_object_signal_emit(bg, "options,show", "terminology");
}
if (!op_out)
{
edje_object_signal_callback_add(bg, "optdetails,hide,done",
"terminology",
_cb_opdt_hide_done, term);
op_over = o = evas_object_rectangle_add(evas_object_evas_get(win));
evas_object_color_set(o, 0, 0, 0, 0);
edje_object_part_swallow(bg, "terminology.dismiss", o);
evas_object_show(o);
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
_cb_mouse_down, term);
o = elm_check_add(win);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 1.0);
elm_object_text_set(o, _("Temporary"));
elm_check_state_set(o, config->temporary);
elm_box_pack_end(op_tbox, o);
evas_object_show(o);
evas_object_smart_callback_add(o, "changed", _cb_op_tmp_chg, ctx);
edje_object_signal_emit(bg, "options,show", "terminology");
op_out = EINA_TRUE;
op_donecb = donecb;
op_donedata = donedata;
elm_object_focus_set(op_toolbar, EINA_TRUE);
if (op_del_timer)
{
ecore_timer_del(op_del_timer);
op_del_timer = NULL;
}
}
else
{
edje_object_signal_callback_del(bg, "optdetails,hide,done",
"terminology",
_cb_opdt_hide_done);
edje_object_signal_callback_add(bg, "optdetails,hide,done",
"terminology",
_cb_opdt_hide_done2, term);
elm_object_focus_set(op_frame, EINA_FALSE);
elm_object_focus_set(op_opbox, EINA_FALSE);
elm_object_focus_set(op_toolbar, EINA_FALSE);
if (op_donecb) op_donecb(op_donedata);
evas_object_del(op_over);
op_over = NULL;
edje_object_signal_emit(bg, "options,hide", "terminology");
edje_object_signal_emit(bg, "optdetails,hide", "terminology");
op_out = EINA_FALSE;
if (op_del_timer) ecore_timer_del(op_del_timer);
op_del_timer = ecore_timer_add(10.0, _cb_op_del_delay, NULL);
}
}
Eina_Bool
options_active_get(void)
{
return op_out;
edje_object_part_swallow(base, "terminology.options", ctx->frame);
evas_object_show(ctx->frame);
edje_object_signal_callback_add(ctx->base, "optdetails,hide,done",
"terminology",
_cb_opdt_hide_done, ctx);
ctx->over = o = evas_object_rectangle_add(evas_object_evas_get(win));
evas_object_color_set(o, 0, 0, 0, 0);
edje_object_part_swallow(ctx->base, "terminology.dismiss", o);
evas_object_show(o);
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
_cb_mouse_down, ctx);
edje_object_signal_emit(ctx->base, "options,show", "terminology");
elm_object_focus_set(ctx->toolbar, EINA_TRUE);
}

View File

@ -1,9 +1,8 @@
#ifndef _TERMINOLOGY_OPTIONS_H__
#define _TERMINOLOGY_OPTIONS_H__ 1
void options_toggle(Evas_Object *win, Evas_Object *bg, Evas_Object *term,
void (*donecb) (void *data), void *donedata);
Eina_Bool options_active_get(void);
void options_show(Evas_Object *win, Evas_Object *base, Evas_Object *bg,
Evas_Object *term,
void (*donecb) (void *data), void *donedata);
#endif

View File

@ -1,6 +1,7 @@
#include "private.h"
#include <Elementary.h>
#include <assert.h>
#include "config.h"
#include "termio.h"
#include "media.h"
@ -11,6 +12,24 @@
#include "main.h"
#include <sys/stat.h>
typedef struct _Background_Ctx {
Config *config;
Evas_Object *frame;
Evas_Object *flip;
Evas_Object *bg_grid;
Evas_Object *term;
Evas_Object *entry;
Evas_Object *bubble;
Evas_Object *op_trans;
Evas_Object *op_opacity;
Evas_Object *op_shine_slider;
Eina_Stringshare *system_path;
Eina_Stringshare *user_path;
Eina_List *background_list;
Ecore_Timer *bubble_disappear;
} Background_Ctx;
typedef struct _Background_Item
{
const char *path;
@ -25,31 +44,14 @@ typedef struct _Insert_Gen_Grid_Item_Notify
} Insert_Gen_Grid_Item_Notify;
static Eina_Stringshare *_system_path,
*_user_path;
static Evas_Object *_bg_grid = NULL,
*_term = NULL,
*_entry = NULL,
*_flip = NULL,
*_bubble = NULL;
static Eina_List *_backgroundlist = NULL;
static Ecore_Timer *_bubble_disappear;
static Ecore_Thread *_thread;
static Evas_Object *op_trans, *op_opacity;
static Evas_Object *op_shine_slider = NULL;
static void
_cb_op_shine_sel(void *data,
Evas_Object *obj,
void *_event EINA_UNUSED)
{
Evas_Object *termio_obj = data;
Config *config = termio_config_get(termio_obj);
Term *term = termio_term_get(termio_obj);
Background_Ctx *ctx = data;
Config *config = ctx->config;
Term *term = termio_term_get(ctx->term);
Win *wn = term_win_get(term);
int shine = elm_slider_value_get(obj);
Eina_List *l, *wn_list;
@ -69,10 +71,11 @@ _cb_op_video_trans_chg(void *data,
Evas_Object *obj,
void *_event EINA_UNUSED)
{
Evas_Object *term = data;
Config *config = termio_config_get(term);
Background_Ctx *ctx = data;
Config *config = ctx->config;
config->translucent = elm_check_state_get(obj);
elm_object_disabled_set(op_opacity, !config->translucent);
elm_object_disabled_set(ctx->op_opacity, !config->translucent);
main_trans_update(config);
config_save(config, NULL);
}
@ -82,64 +85,70 @@ _cb_op_video_opacity_chg(void *data,
Evas_Object *obj,
void *_event EINA_UNUSED)
{
Evas_Object *term = data;
Config *config = termio_config_get(term);
Background_Ctx *ctx = data;
Config *config = ctx->config;
config->opacity = elm_slider_value_get(obj);
if (!config->translucent) return;
if (!config->translucent)
return;
main_trans_update(config);
config_save(config, NULL);
}
static void
_cb_fileselector(void *_data EINA_UNUSED,
_cb_fileselector(void *data,
Evas_Object *obj,
void *event)
{
Background_Ctx *ctx = data;
if (event)
{
elm_object_text_set(_entry, elm_fileselector_path_get(obj));
elm_flip_go_to(_flip, EINA_TRUE, ELM_FLIP_PAGE_LEFT);
}
else
{
elm_flip_go_to(_flip, EINA_TRUE, ELM_FLIP_PAGE_LEFT);
}
if (event)
{
elm_object_text_set(ctx->entry, elm_fileselector_path_get(obj));
elm_flip_go_to(ctx->flip, EINA_TRUE, ELM_FLIP_PAGE_LEFT);
}
else
{
elm_flip_go_to(ctx->flip, EINA_TRUE, ELM_FLIP_PAGE_LEFT);
}
}
static Eina_Bool
_cb_timer_bubble_disappear(void *_data EINA_UNUSED)
_cb_timer_bubble_disappear(void *data)
{
evas_object_del(_bubble);
_bubble_disappear = NULL;
Background_Ctx *ctx = data;
evas_object_del(ctx->bubble);
ctx->bubble = NULL;
ctx->bubble_disappear = NULL;
return ECORE_CALLBACK_CANCEL;
}
static void
_bubble_show(char *text)
_bubble_show(Background_Ctx *ctx, char *text)
{
Evas_Object *opbox = elm_object_top_widget_get(_bg_grid);
Evas_Object *opbox = elm_object_top_widget_get(ctx->bg_grid);
Evas_Object *o;
int x = 0, y = 0, w , h;
evas_object_geometry_get(_bg_grid, &x, &y, &w ,&h);
if (_bubble_disappear)
evas_object_geometry_get(ctx->bg_grid, &x, &y, &w ,&h);
if (ctx->bubble_disappear)
{
ecore_timer_del(_bubble_disappear);
_cb_timer_bubble_disappear(NULL);
ecore_timer_del(ctx->bubble_disappear);
_cb_timer_bubble_disappear(ctx);
}
_bubble = elm_bubble_add(opbox);
elm_bubble_pos_set(_bubble, ELM_BUBBLE_POS_BOTTOM_RIGHT);
evas_object_resize(_bubble, 200, 50);
evas_object_move(_bubble, (x + w - 200), (y + h - 50));
evas_object_show(_bubble);
ctx->bubble = elm_bubble_add(opbox);
elm_bubble_pos_set(ctx->bubble, ELM_BUBBLE_POS_BOTTOM_RIGHT);
evas_object_resize(ctx->bubble, 200, 50);
evas_object_move(ctx->bubble, (x + w - 200), (y + h - 50));
evas_object_show(ctx->bubble);
o = elm_label_add(_bubble);
o = elm_label_add(ctx->bubble);
elm_object_text_set(o, text);
elm_object_content_set(_bubble, o);
elm_object_content_set(ctx->bubble, o);
_bubble_disappear = ecore_timer_add(2.0, _cb_timer_bubble_disappear, NULL);
ctx->bubble_disappear = ecore_timer_add(2.0,
_cb_timer_bubble_disappear, ctx);
}
static char *
@ -150,18 +159,22 @@ _grid_text_get(void *data,
Background_Item *item = data;
const char *s;
if (!item->path) return strdup(_("None"));
if (!item->path)
return strdup(_("None"));
s = ecore_file_file_get(item->path);
if (s) return strdup(s);
if (s)
return strdup(s);
return NULL;
}
static Evas_Object *
_grid_content_get(void *data, Evas_Object *obj, const char *part)
{
Background_Ctx *ctx = evas_object_data_get(obj, "ctx");
assert(ctx);
Background_Item *item = data;
Evas_Object *o, *oe;
Config *config = termio_config_get(_term);
Config *config = ctx->config;
char path[PATH_MAX];
if (!strcmp(part, "elm.swallow.icon"))
@ -181,7 +194,8 @@ _grid_content_get(void *data, Evas_Object *obj, const char *part)
}
else
{
if (!config->theme) return NULL;
if (!config->theme)
return NULL;
snprintf(path, PATH_MAX, "%s/themes/%s", elm_app_data_dir_get(),
config->theme);
o = elm_layout_add(obj);
@ -200,11 +214,12 @@ _grid_content_get(void *data, Evas_Object *obj, const char *part)
static void
_item_selected(void *data,
Evas_Object *_obj EINA_UNUSED,
Evas_Object *obj,
void *_event EINA_UNUSED)
{
Background_Ctx *ctx = evas_object_data_get(obj, "ctx");
Background_Item *item = data;
Config *config = termio_config_get(_term);
Config *config = ctx->config;
if (!config) return;
if (!item->path)
@ -223,17 +238,18 @@ _item_selected(void *data,
}
static void
_insert_gengrid_item(Insert_Gen_Grid_Item_Notify *msg_data)
_insert_gengrid_item(Background_Ctx *ctx,
Insert_Gen_Grid_Item_Notify *msg_data)
{
Insert_Gen_Grid_Item_Notify *insert_msg = msg_data;
Config *config = termio_config_get(_term);
Config *config = ctx->config;
if (insert_msg && insert_msg->item && insert_msg->class && config)
{
Background_Item *item = insert_msg->item;
Elm_Gengrid_Item_Class *item_class = insert_msg->class;
item->item = elm_gengrid_item_append(_bg_grid, item_class, item,
item->item = elm_gengrid_item_append(ctx->bg_grid, item_class, item,
_item_selected, item);
if ((!item->path) && (!config->background))
{
@ -255,8 +271,8 @@ _insert_gengrid_item(Insert_Gen_Grid_Item_Notify *msg_data)
}
static Eina_List*
_rec_read_directorys(Eina_List *list, const char *root_path,
Elm_Gengrid_Item_Class *class)
_rec_read_directorys(Background_Ctx *ctx, Eina_List *list,
const char *root_path, Elm_Gengrid_Item_Class *class)
{
Eina_List *childs = ecore_file_ls(root_path);
char *file_name, path[PATH_MAX];
@ -296,7 +312,7 @@ _rec_read_directorys(Eina_List *list, const char *root_path,
notify->class = class;
notify->item = item;
//ecore_thread_feedback(th, notify);
_insert_gengrid_item(notify);
_insert_gengrid_item(ctx, notify);
}
}
break;
@ -310,31 +326,30 @@ _rec_read_directorys(Eina_List *list, const char *root_path,
}
static void
_refresh_directory(const char* data)
_refresh_directory(Background_Ctx *ctx, const char* data)
{
Background_Item *item;
Elm_Gengrid_Item_Class *item_class;
// This will run elm_gengrid_clear
elm_gengrid_clear(_bg_grid);
elm_gengrid_clear(ctx->bg_grid);
if (_backgroundlist)
if (ctx->background_list)
{
EINA_LIST_FREE(_backgroundlist, item)
EINA_LIST_FREE(ctx->background_list, item)
{
if (item->path)
eina_stringshare_del(item->path);
free(item);
}
_backgroundlist = NULL;
ctx->background_list = NULL;
}
item_class = elm_gengrid_item_class_new();
item_class->func.text_get = _grid_text_get;
item_class->func.content_get = _grid_content_get;
item = calloc(1, sizeof(Background_Item));
_backgroundlist = eina_list_append(_backgroundlist, item);
ctx->background_list = eina_list_append(ctx->background_list, item);
//Insert None Item
Insert_Gen_Grid_Item_Notify *notify = calloc(1,
@ -344,66 +359,93 @@ _refresh_directory(const char* data)
notify->class = item_class;
notify->item = item;
_insert_gengrid_item(notify);
_insert_gengrid_item(ctx, notify);
}
_backgroundlist = _rec_read_directorys(_backgroundlist, data,
ctx->background_list = _rec_read_directorys(ctx, ctx->background_list, data,
item_class);
elm_gengrid_item_class_free(item_class);
_thread = NULL;
}
static void
_gengrid_refresh_samples(const char *path)
_gengrid_refresh_samples(Background_Ctx *ctx, const char *path)
{
if(!ecore_file_exists(path))
return;
_refresh_directory(path);
_refresh_directory(ctx, path);
}
static void
_cb_entry_changed(void *_data EINA_UNUSED,
_cb_entry_changed(void *data,
Evas_Object *parent,
void *_event EINA_UNUSED)
{
Background_Ctx *ctx = data;
const char *path = elm_object_text_get(parent);
_gengrid_refresh_samples(path);
_gengrid_refresh_samples(ctx, path);
}
static void
_cb_hoversel_select(void *data,
Evas_Object *_hoversel EINA_UNUSED,
void *_event EINA_UNUSED)
_cb_hoversel_select(Background_Ctx *ctx, const Eina_Stringshare *path)
{
Evas_Object *o;
char *path = data;
if (path)
{
elm_object_text_set(_entry, path);
elm_flip_go_to(ctx->flip, EINA_TRUE, ELM_FLIP_PAGE_LEFT);
elm_object_text_set(ctx->entry, path);
}
else
{
o = elm_object_part_content_get(_flip, "back");
elm_fileselector_path_set(o, elm_object_text_get(_entry));
elm_flip_go_to(_flip, EINA_FALSE, ELM_FLIP_PAGE_RIGHT);
o = elm_object_part_content_get(ctx->flip, "back");
elm_fileselector_path_set(o, elm_object_text_get(ctx->entry));
elm_flip_go_to(ctx->flip, EINA_FALSE, ELM_FLIP_PAGE_RIGHT);
}
}
static void
_system_background_dir_init(void)
_cb_hoversel_select_system(void *data,
Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Background_Ctx *ctx = data;
_cb_hoversel_select(ctx, ctx->system_path);
}
static void
_cb_hoversel_select_user(void *data,
Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Background_Ctx *ctx = data;
_cb_hoversel_select(ctx, ctx->user_path);
}
static void
_cb_hoversel_select_none(void *data,
Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Background_Ctx *ctx = data;
_cb_hoversel_select(ctx, NULL);
}
static void
_system_background_dir_init(Background_Ctx *ctx)
{
char path[PATH_MAX];
snprintf(path, PATH_MAX, "%s/backgrounds/", elm_app_data_dir_get());
if (_system_path)
eina_stringshare_replace(&_system_path, path);
if (ctx->system_path)
eina_stringshare_replace(&ctx->system_path, path);
else
_system_path = eina_stringshare_add(path);
ctx->system_path = eina_stringshare_add(path);
}
static const char*
_user_background_dir_init(void){
_user_background_dir_init(Background_Ctx *ctx)
{
char path[PATH_MAX], *user;
user = getenv("HOME");
@ -412,52 +454,53 @@ _user_background_dir_init(void){
snprintf(path, PATH_MAX, "%s/.config/terminology/background/", user);
if (!ecore_file_exists(path))
ecore_file_mkpath(path);
if (!_user_path)
_user_path = eina_stringshare_add(path);
if (!ctx->user_path)
ctx->user_path = eina_stringshare_add(path);
else
eina_stringshare_replace(&_user_path, path);
return _user_path;
eina_stringshare_replace(&ctx->user_path, path);
return ctx->user_path;
}
static const char*
_import_background(const char* background)
_import_background(Background_Ctx *ctx, const char* background)
{
char path[PATH_MAX];
const char *filename = ecore_file_file_get(background);
if (!filename)
return NULL;
if (!_user_background_dir_init())
if (!_user_background_dir_init(ctx))
return NULL;
snprintf(path, PATH_MAX, "%s/%s", _user_path, filename);
snprintf(path, PATH_MAX, "%s/%s", ctx->user_path, filename);
if (!ecore_file_cp(background, path))
return NULL;
return eina_stringshare_add(path);
}
static void
_cb_grid_doubleclick(void *_data EINA_UNUSED,
_cb_grid_doubleclick(void *data,
Evas_Object *_obj EINA_UNUSED,
void *_event EINA_UNUSED)
{
Config *config = termio_config_get(_term);
Background_Ctx *ctx = data;
Config *config = ctx->config;
char *config_background_dir = ecore_file_dir_get(config->background);
if (!_user_path) {
if (!_user_background_dir_init())
if (!ctx->user_path) {
if (!_user_background_dir_init(ctx))
return;
}
if (!config->background)
return;
if (strncmp(config_background_dir, _user_path,
if (strncmp(config_background_dir, ctx->user_path,
strlen(config_background_dir)) == 0)
{
_bubble_show(_("Source file is target file"));
_bubble_show(ctx, _("Source file is target file"));
free(config_background_dir);
return;
}
const char *newfile = _import_background(config->background);
const char *newfile = _import_background(ctx, config->background);
if (newfile)
{
@ -465,50 +508,74 @@ _cb_grid_doubleclick(void *_data EINA_UNUSED,
config_save(config, NULL);
main_media_update(config);
eina_stringshare_del(newfile);
_bubble_show(_("Picture imported"));
elm_object_text_set(_entry, config_background_dir);
_bubble_show(ctx, _("Picture imported"));
elm_object_text_set(ctx->entry, config_background_dir);
}
else
{
_bubble_show(_("Failed"));
_bubble_show(ctx, _("Failed"));
}
free(config_background_dir);
}
static void
_parent_del_cb(void *data,
Evas *_e EINA_UNUSED,
Evas_Object *_obj EINA_UNUSED,
void *_event_info EINA_UNUSED)
{
Background_Ctx *ctx = data;
Background_Item *item;
EINA_LIST_FREE(ctx->background_list, item)
{
if (item->path)
eina_stringshare_del(item->path);
free(item);
}
ctx->background_list = NULL;
if (ctx->user_path)
{
eina_stringshare_del(ctx->user_path);
ctx->user_path = NULL;
}
if (ctx->system_path)
{
eina_stringshare_del(ctx->system_path);
ctx->system_path = NULL;
}
free(ctx);
}
void
options_background(Evas_Object *opbox, Evas_Object *term)
{
Evas_Object *frame, *o, *bx, *bx2;
Evas_Object *o, *bx, *bx_front;
Config *config = termio_config_get(term);
char path[PATH_MAX], *config_background_dir;
Background_Ctx *ctx;
_term = term;
ctx = calloc(1, sizeof(*ctx));
assert(ctx);
frame = o = elm_frame_add(opbox);
ctx->config = config;
ctx->term = term;
ctx->frame = o = elm_frame_add(opbox);
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, _("Background"));
evas_object_show(o);
elm_box_pack_end(opbox, o);
_flip = o = elm_flip_add(opbox);
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_content_set(frame, o);
evas_object_show(o);
evas_object_event_callback_add(ctx->frame, EVAS_CALLBACK_DEL,
_parent_del_cb, ctx);
o = elm_fileselector_add(opbox);
bx = o = elm_box_add(ctx->frame);
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_part_content_set(_flip, "back", o);
elm_fileselector_folder_only_set(o, EINA_TRUE);
evas_object_smart_callback_add(o, "done", _cb_fileselector, NULL);
evas_object_show(o);
bx = o = elm_box_add(opbox);
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_part_content_set(_flip, "front", bx);
elm_object_content_set(ctx->frame, bx);
evas_object_show(o);
o = elm_label_add(opbox);
@ -518,7 +585,7 @@ options_background(Evas_Object *opbox, Evas_Object *term)
elm_box_pack_end(bx, o);
evas_object_show(o);
op_shine_slider = o = elm_slider_add(opbox);
ctx->op_shine_slider = o = elm_slider_add(opbox);
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_slider_span_size_set(o, 40);
@ -533,11 +600,11 @@ options_background(Evas_Object *opbox, Evas_Object *term)
evas_object_show(o);
evas_object_smart_callback_add(o, "delay,changed",
_cb_op_shine_sel, term);
_cb_op_shine_sel, ctx);
op_trans = o = elm_check_add(opbox);
ctx->op_trans = o = elm_check_add(opbox);
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_object_text_set(o, _("Translucent"));
@ -545,9 +612,9 @@ options_background(Evas_Object *opbox, Evas_Object *term)
elm_box_pack_end(bx, o);
evas_object_show(o);
evas_object_smart_callback_add(o, "changed",
_cb_op_video_trans_chg, term);
_cb_op_video_trans_chg, ctx);
op_opacity = o = elm_slider_add(opbox);
ctx->op_opacity = o = elm_slider_add(opbox);
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_slider_span_size_set(o, 40);
@ -559,7 +626,7 @@ options_background(Evas_Object *opbox, Evas_Object *term)
elm_box_pack_end(bx, o);
evas_object_show(o);
evas_object_smart_callback_add(o, "changed",
_cb_op_video_opacity_chg, term);
_cb_op_video_opacity_chg, ctx);
o = elm_separator_add(opbox);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
@ -568,89 +635,85 @@ options_background(Evas_Object *opbox, Evas_Object *term)
elm_box_pack_end(bx, o);
evas_object_show(o);
bx2 = o = elm_box_add(opbox);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.0);
elm_box_horizontal_set(o, EINA_TRUE);
elm_box_pack_end(bx, o);
evas_object_show(o);
_entry = o = elm_entry_add(opbox);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.0);
elm_entry_single_line_set(o, EINA_TRUE);
elm_entry_scrollable_set(o, EINA_TRUE);
elm_scroller_policy_set(o, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
evas_object_smart_callback_add(_entry, "changed", _cb_entry_changed, NULL);
elm_box_pack_start(bx2, o);
evas_object_show(o);
o = elm_hoversel_add(opbox);
evas_object_size_hint_weight_set(o, 0.0, 0.0);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.0);
elm_object_text_set(o, _("Select Path"));
elm_box_pack_end(bx2, o);
elm_box_pack_end(bx, o);
evas_object_show(o);
snprintf(path, PATH_MAX, "%s/backgrounds/", elm_app_data_dir_get());
_system_background_dir_init();
elm_hoversel_item_add(o, _("System"), NULL, ELM_ICON_NONE, _cb_hoversel_select ,
_system_path);
if (_user_background_dir_init())
elm_hoversel_item_add(o, _("User"), NULL, ELM_ICON_NONE, _cb_hoversel_select ,
_user_path);
_system_background_dir_init(ctx);
elm_hoversel_item_add(o, _("System"), NULL, ELM_ICON_NONE,
_cb_hoversel_select_system, ctx);
if (_user_background_dir_init(ctx))
elm_hoversel_item_add(o, _("User"), NULL, ELM_ICON_NONE,
_cb_hoversel_select_user, ctx);
//In the other case it has failed, so dont show the user item
elm_hoversel_item_add(o, _("Other"), NULL, ELM_ICON_NONE, _cb_hoversel_select ,
NULL);
elm_hoversel_item_add(o, _("Other"), NULL, ELM_ICON_NONE,
_cb_hoversel_select_none, ctx);
_bg_grid = o = elm_gengrid_add(opbox);
ctx->flip = o = elm_flip_add(opbox);
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);
evas_object_smart_callback_add(o, "clicked,double", _cb_grid_doubleclick, NULL);
elm_box_pack_end(bx, o);
evas_object_show(o);
bx_front = o = elm_box_add(opbox);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.0);
elm_box_horizontal_set(o, EINA_FALSE);
elm_object_part_content_set(ctx->flip, "front", o);
evas_object_show(o);
ctx->entry = o = elm_entry_add(opbox);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.0);
elm_entry_single_line_set(o, EINA_TRUE);
elm_entry_scrollable_set(o, EINA_TRUE);
elm_scroller_policy_set(o, ELM_SCROLLER_POLICY_OFF,
ELM_SCROLLER_POLICY_OFF);
evas_object_smart_callback_add(ctx->entry, "changed",
_cb_entry_changed, ctx);
elm_box_pack_end(bx_front, o);
evas_object_show(o);
ctx->bg_grid = o = elm_gengrid_add(opbox);
evas_object_data_set(ctx->bg_grid, "ctx", ctx);
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);
evas_object_smart_callback_add(o, "clicked,double",
_cb_grid_doubleclick, ctx);
elm_gengrid_item_size_set(o, elm_config_scale_get() * 100,
elm_config_scale_get() * 80);
elm_box_pack_end(bx, o);
elm_box_pack_end(bx_front, o);
evas_object_show(o);
o = elm_label_add(opbox);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.0);
elm_object_text_set(o, _("Double click on a picture to import it"));
elm_box_pack_end(bx, o);
elm_object_text_set(o, _("Click on a picture to use it as background"));
elm_box_pack_end(bx_front, o);
evas_object_show(o);
o = elm_fileselector_add(opbox);
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_part_content_set(ctx->flip, "back", o);
elm_fileselector_folder_only_set(o, EINA_TRUE);
evas_object_smart_callback_add(o, "done", _cb_fileselector, ctx);
evas_object_show(o);
if (config->background)
{
config_background_dir = ecore_file_dir_get(config->background);
elm_object_text_set(_entry, config_background_dir);
elm_object_text_set(ctx->entry, config_background_dir);
free(config_background_dir);
}
else
{
elm_object_text_set(_entry, _system_path);
}
}
void
options_background_clear(void)
{
Background_Item *item;
EINA_LIST_FREE(_backgroundlist, item)
{
if (item->path) eina_stringshare_del(item->path);
free(item);
}
_backgroundlist = NULL;
if (_user_path)
{
eina_stringshare_del(_user_path);
_user_path = NULL;
}
if (_system_path)
{
eina_stringshare_del(_system_path);
_system_path = NULL;
elm_object_text_set(ctx->entry, ctx->system_path);
}
}

View File

@ -1,26 +1,34 @@
#include "private.h"
#include <Elementary.h>
#include <assert.h>
#include "config.h"
#include "termio.h"
#include "options.h"
#include "options_behavior.h"
#include "main.h"
static Evas_Object *op_w, *op_h, *op_wh_current;
typedef struct _Behavior_Ctx {
Evas_Object *op_w;
Evas_Object *op_h;
Evas_Object *op_wh_current;
Evas_Object *term;
Config *config;
} Behavior_Ctx;
#define CB(_cfg_name, _inv) \
static void \
_cb_op_behavior_##_cfg_name(void *data, Evas_Object *obj, \
void *_event EINA_UNUSED) \
{ \
Evas_Object *term = data; \
Config *config = termio_config_get(term); \
Behavior_Ctx *ctx = data; \
Config *config = ctx->config; \
if (_inv) \
config->_cfg_name = !elm_check_state_get(obj); \
else \
config->_cfg_name = elm_check_state_get(obj); \
termio_config_update(term); \
termio_config_update(ctx->term); \
windows_update(); \
config_save(config, NULL); \
}
@ -74,11 +82,11 @@ _cb_op_behavior_sback_chg(void *data,
Evas_Object *obj,
void *_event EINA_UNUSED)
{
Evas_Object *term = data;
Config *config = termio_config_get(term);
Behavior_Ctx *ctx = data;
Config *config = ctx->config;
config->scrollback = (double) sback_double_to_expo_int(elm_slider_value_get(obj));
termio_config_update(term);
termio_config_update(ctx->term);
config_save(config, NULL);
}
@ -87,11 +95,11 @@ _cb_op_behavior_tab_zoom_slider_chg(void *data,
Evas_Object *obj,
void *_event EINA_UNUSED)
{
Evas_Object *term = data;
Config *config = termio_config_get(term);
Behavior_Ctx *ctx = data;
Config *config = ctx->config;
config->tab_zoom = (double)(int)round(elm_slider_value_get(obj) * 10.0) / 10.0;
termio_config_update(term);
termio_config_update(ctx->term);
config_save(config, NULL);
}
@ -100,15 +108,16 @@ _cb_op_behavior_custom_geometry_current_set(void *data,
Evas_Object *obj EINA_UNUSED,
void *_event EINA_UNUSED)
{
Evas_Object *term = data;
Config *config = termio_config_get(term);
if (config->custom_geometry)
{
termio_size_get(term, &config->cg_width, &config->cg_height);
elm_spinner_value_set(op_w, config->cg_width);
elm_spinner_value_set(op_h, config->cg_height);
}
config_save(config, NULL);
Behavior_Ctx *ctx = data;
Config *config = ctx->config;
if (config->custom_geometry)
{
termio_size_get(ctx->term, &config->cg_width, &config->cg_height);
elm_spinner_value_set(ctx->op_w, config->cg_width);
elm_spinner_value_set(ctx->op_h, config->cg_height);
}
config_save(config, NULL);
}
static void
@ -116,20 +125,20 @@ _cb_op_behavior_custom_geometry(void *data,
Evas_Object *obj,
void *_event EINA_UNUSED)
{
Evas_Object *term = data;
Config *config = termio_config_get(term);
Behavior_Ctx *ctx = data;
Config *config = ctx->config;
config->custom_geometry = elm_check_state_get(obj);
if (config->custom_geometry)
{
config->cg_width = (int) elm_spinner_value_get(op_w);
config->cg_height = (int) elm_spinner_value_get(op_h);
config->cg_width = (int) elm_spinner_value_get(ctx->op_w);
config->cg_height = (int) elm_spinner_value_get(ctx->op_h);
}
config_save(config, NULL);
elm_object_disabled_set(op_w, !config->custom_geometry);
elm_object_disabled_set(op_h, !config->custom_geometry);
elm_object_disabled_set(op_wh_current, !config->custom_geometry);
elm_object_disabled_set(ctx->op_w, !config->custom_geometry);
elm_object_disabled_set(ctx->op_h, !config->custom_geometry);
elm_object_disabled_set(ctx->op_wh_current, !config->custom_geometry);
}
static void
@ -137,8 +146,8 @@ _cb_op_behavior_cg_width(void *data,
Evas_Object *obj,
void *_event EINA_UNUSED)
{
Evas_Object *term = data;
Config *config = termio_config_get(term);
Behavior_Ctx *ctx = data;
Config *config = ctx->config;
if (config->custom_geometry)
{
@ -152,8 +161,8 @@ _cb_op_behavior_cg_height(void *data,
Evas_Object *obj,
void *_event EINA_UNUSED)
{
Evas_Object *term = data;
Config *config = termio_config_get(term);
Behavior_Ctx *ctx = data;
Config *config = ctx->config;
if (config->custom_geometry)
{
@ -162,28 +171,49 @@ _cb_op_behavior_cg_height(void *data,
}
}
static void
_parent_del_cb(void *data,
Evas *_e EINA_UNUSED,
Evas_Object *_obj EINA_UNUSED,
void *_event_info EINA_UNUSED)
{
Behavior_Ctx *ctx = data;
free(ctx);
}
void
options_behavior(Evas_Object *opbox, Evas_Object *term)
{
Config *config = termio_config_get(term);
Evas_Object *o, *bx, *sc, *fr;
Evas_Object *o, *bx, *sc, *frame;
int w, h;
const char *tooltip;
Behavior_Ctx *ctx;
termio_size_get(term, &w, &h);
fr = o = elm_frame_add(opbox);
ctx = calloc(1, sizeof(*ctx));
assert(ctx);
ctx->config = config;
ctx->term = term;
frame = o = elm_frame_add(opbox);
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, _("Behavior"));
elm_box_pack_end(opbox, o);
evas_object_show(o);
evas_object_event_callback_add(o, EVAS_CALLBACK_DEL,
_parent_del_cb, ctx);
sc = o = elm_scroller_add(opbox);
elm_scroller_content_min_limit(sc, EINA_TRUE, EINA_FALSE);
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_content_set(fr, o);
elm_object_content_set(frame, o);
evas_object_show(o);
bx = o = elm_box_add(opbox);
@ -201,7 +231,7 @@ options_behavior(Evas_Object *opbox, Evas_Object *term)
elm_box_pack_end(bx, o); \
evas_object_show(o); \
evas_object_smart_callback_add(o, "changed", \
_cb_op_behavior_##_cfg_name, term)
_cb_op_behavior_##_cfg_name, ctx)
CX(_("Scroll to bottom on new content"), jump_on_change, 0);
CX(_("Scroll to bottom when a key is pressed"), jump_on_keypress, 0);
@ -235,9 +265,9 @@ options_behavior(Evas_Object *opbox, Evas_Object *term)
elm_box_pack_end(bx, o);
evas_object_show(o);
evas_object_smart_callback_add(o, "changed",
_cb_op_behavior_custom_geometry, term);
_cb_op_behavior_custom_geometry, ctx);
op_wh_current = o = elm_button_add(bx);
ctx->op_wh_current = o = elm_button_add(bx);
evas_object_size_hint_weight_set(o, 0.0, 0.0);
evas_object_size_hint_align_set(o, 0.0, 0.5);
elm_object_text_set(o, _("Set Current:"));
@ -245,7 +275,8 @@ options_behavior(Evas_Object *opbox, Evas_Object *term)
evas_object_show(o);
elm_object_disabled_set(o, !config->custom_geometry);
evas_object_smart_callback_add(o, "clicked",
_cb_op_behavior_custom_geometry_current_set, term);
_cb_op_behavior_custom_geometry_current_set,
ctx);
o = elm_label_add(bx);
evas_object_size_hint_weight_set(o, 0.0, 0.0);
@ -254,18 +285,20 @@ options_behavior(Evas_Object *opbox, Evas_Object *term)
elm_box_pack_end(bx, o);
evas_object_show(o);
op_w = o = elm_spinner_add(bx);
ctx->op_w = o = elm_spinner_add(bx);
elm_spinner_editable_set(o, EINA_TRUE);
elm_spinner_min_max_set(o, 2.0, 350.0);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5);
if (config->custom_geometry) elm_spinner_value_set(o, config->cg_width);
else elm_spinner_value_set(o, w);
if (config->custom_geometry)
elm_spinner_value_set(o, config->cg_width);
else
elm_spinner_value_set(o, w);
elm_object_disabled_set(o, !config->custom_geometry);
elm_box_pack_end(bx, o);
evas_object_show(o);
evas_object_smart_callback_add(o, "changed",
_cb_op_behavior_cg_width, term);
_cb_op_behavior_cg_width, ctx);
o = elm_label_add(bx);
evas_object_size_hint_weight_set(o, 0.0, 0.0);
@ -274,18 +307,20 @@ options_behavior(Evas_Object *opbox, Evas_Object *term)
elm_box_pack_end(bx, o);
evas_object_show(o);
op_h = o = elm_spinner_add(bx);
ctx->op_h = o = elm_spinner_add(bx);
elm_spinner_editable_set(o, EINA_TRUE);
elm_spinner_min_max_set(o, 1.0, 150.0);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5);
if (config->custom_geometry) elm_spinner_value_set(o, config->cg_height);
else elm_spinner_value_set(o, h);
if (config->custom_geometry)
elm_spinner_value_set(o, config->cg_height);
else
elm_spinner_value_set(o, h);
elm_object_disabled_set(o, !config->custom_geometry);
elm_box_pack_end(bx, o);
evas_object_show(o);
evas_object_smart_callback_add(o, "changed",
_cb_op_behavior_cg_height, term);
_cb_op_behavior_cg_height, ctx);
o = elm_separator_add(bx);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
@ -326,7 +361,7 @@ options_behavior(Evas_Object *opbox, Evas_Object *term)
elm_box_pack_end(bx, o);
evas_object_show(o);
evas_object_smart_callback_add(o, "delay,changed",
_cb_op_behavior_sback_chg, term);
_cb_op_behavior_sback_chg, ctx);
o = elm_label_add(bx);
evas_object_size_hint_weight_set(o, 0.0, 0.0);
@ -352,7 +387,7 @@ options_behavior(Evas_Object *opbox, Evas_Object *term)
elm_box_pack_end(bx, o);
evas_object_show(o);
evas_object_smart_callback_add(o, "delay,changed",
_cb_op_behavior_tab_zoom_slider_chg, term);
_cb_op_behavior_tab_zoom_slider_chg, ctx);
evas_object_size_hint_weight_set(opbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(opbox, EVAS_HINT_FILL, EVAS_HINT_FILL);

View File

@ -1,13 +1,12 @@
#include <Elementary.h>
#include "private.h"
#include <Elementary.h>
#include <assert.h>
#include "config.h"
#include "termio.h"
#include "options.h"
#include "options_colors.h"
static const char mapping[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11 };
static const char *mapping_names[] =
{
gettext_noop("Default"),
@ -19,53 +18,48 @@ static const char *mapping_names[] =
gettext_noop("Magenta"),
gettext_noop("Cyan"),
gettext_noop("White"),
gettext_noop("Invisible"),
gettext_noop("Inverse"),
gettext_noop("Inverse Base")
gettext_noop("Inverse Background")
};
static Elm_Object_Item *colitem[4][11] = { { NULL } };
static Evas_Object *colorsel = NULL;
static Elm_Object_Item *curitem = NULL;
static Evas_Object *colpal[4] = { NULL };
static Evas_Object *label = NULL, *reset = NULL;
typedef struct _Colors_Ctx {
Elm_Object_Item *colitem[4][12];
Evas_Object *colorsel;
Elm_Object_Item *curitem;
Evas_Object *colpal[4];
Evas_Object *label;
Evas_Object *reset;
Config *config;
Evas_Object *term;
Evas_Object *bg;
} Colors_Ctx;
static void
_cb_op_use_custom_chg(void *data,
Evas_Object *obj,
void *_event EINA_UNUSED)
{
Evas_Object *term = data;
Config *config = termio_config_get(term);
Eina_Bool state = EINA_FALSE;
int i;
state = elm_check_state_get(obj);
elm_object_disabled_set(colorsel, !state);
for (i = 0; i < 4; i++) elm_object_disabled_set(colpal[i], !state);
elm_object_disabled_set(label, !state);
config->colors_use = state;
termio_config_update(term);
config_save(config, NULL);
}
static void
_cb_op_color_item_sel(void *_data EINA_UNUSED,
_cb_op_color_item_sel(void *data,
Evas_Object *_obj EINA_UNUSED,
void *event)
{
Colors_Ctx *ctx = data;
Elm_Object_Item *it = event;
int r = 0, g = 0, b = 0, a = 0;
int i, j;
curitem = it;
if (ctx->curitem == it)
return;
if (ctx->curitem)
elm_colorselector_palette_item_selected_set(ctx->curitem, EINA_FALSE);
ctx->curitem = it;
elm_colorselector_palette_item_color_get(it, &r, &g, &b, &a);
elm_colorselector_color_set(colorsel, r, g, b, a);
elm_colorselector_color_set(ctx->colorsel, r, g, b, a);
for (j = 0; j < 4; j++)
{
for (i = 0; i < 11; i++)
for (i = 0; i < 12; i++)
{
if (colitem[j][i] == it)
elm_object_text_set(label,
if (i == COL_INVIS)
continue;
if (ctx->colitem[j][i] == it)
elm_object_text_set(ctx->label,
#if HAVE_GETTEXT && ENABLE_NLS
gettext(mapping_names[i])
#else
@ -81,29 +75,32 @@ _cb_op_color_chg(void *data,
Evas_Object *obj,
void *_event EINA_UNUSED)
{
Evas_Object *term = data;
Config *config = termio_config_get(term);
Colors_Ctx *ctx = data;
Config *config = ctx->config;
int r = 0, g = 0, b = 0, a = 0, rr = 0, gg = 0, bb = 0, aa = 0;
int i, j;
elm_colorselector_palette_item_color_get(curitem, &rr, &gg, &bb, &aa);
elm_colorselector_palette_item_color_get(ctx->curitem, &rr, &gg, &bb, &aa);
elm_colorselector_color_get(obj, &r, &g, &b, &a);
if ((r != rr) || (g != gg) || (b != bb) || (a != aa))
{
if (curitem)
elm_colorselector_palette_item_color_set(curitem, r, g, b, a);
elm_object_disabled_set(reset, EINA_FALSE);
if (ctx->curitem)
elm_colorselector_palette_item_color_set(ctx->curitem, r, g, b, a);
elm_object_disabled_set(ctx->reset, EINA_FALSE);
config->colors_use = EINA_TRUE;
for (j = 0; j < 4; j++)
{
for (i = 0; i < 11; i++)
for (i = 0; i < 12; i++)
{
if (colitem[j][i] == curitem)
if (i == COL_INVIS)
continue;
if (ctx->colitem[j][i] == ctx->curitem)
{
config->colors[(j * 12) + mapping[i]].r = r;
config->colors[(j * 12) + mapping[i]].g = g;
config->colors[(j * 12) + mapping[i]].b = b;
config->colors[(j * 12) + mapping[i]].a = a;
termio_config_update(term);
config->colors[(j * 12) + i].r = r * a / 256;
config->colors[(j * 12) + i].g = g * a / 256;
config->colors[(j * 12) + i].b = b * a / 256;
config->colors[(j * 12) + i].a = a;
termio_config_update(ctx->term);
config_save(config, NULL);
return;
}
@ -113,124 +110,203 @@ _cb_op_color_chg(void *data,
}
static void
_cb_op_reset(void *data,
Evas_Object *_obj EINA_UNUSED,
void *_event EINA_UNUSED)
_reset_config_colors(Colors_Ctx *ctx)
{
Evas_Object *term = data;
Config *config = termio_config_get(term);
int r = 0, g = 0, b = 0, a = 0;
int i, j;
for (j = 0; j < 4; j++)
{
for (i = 0; i < 12; i++)
{
int r, g, b, a;
unsigned char rr = 0, gg = 0, bb = 0, aa = 0;
colors_standard_get(j, i, &rr, &gg, &bb, &aa);
config->colors[(j * 12) + i].r = rr;
config->colors[(j * 12) + i].g = gg;
config->colors[(j * 12) + i].b = bb;
config->colors[(j * 12) + i].a = aa;
}
for (i = 0; i < 11; i++)
{
elm_colorselector_palette_item_color_set
(colitem[j][i],
config->colors[(j * 12) + mapping[i]].r,
config->colors[(j * 12) + mapping[i]].g,
config->colors[(j * 12) + mapping[i]].b,
config->colors[(j * 12) + mapping[i]].a);
char buf[32];
if (i == COL_INVIS)
continue;
snprintf(buf, sizeof(buf) - 1, "c%i", j * 12 + i);
if (!edje_object_color_class_get(ctx->bg, buf,
&r,
&g,
&b,
&a,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL))
{
colors_standard_get(j, i, &rr, &gg, &bb, &aa);
}
else
{
rr = r;
gg = g;
bb = b;
aa = a;
}
ctx->config->colors[(j * 12) + i].r = rr;
ctx->config->colors[(j * 12) + i].g = gg;
ctx->config->colors[(j * 12) + i].b = bb;
ctx->config->colors[(j * 12) + i].a = aa;
}
}
elm_object_disabled_set(reset, EINA_TRUE);
elm_colorselector_palette_item_color_get(curitem, &r, &g, &b, &a);
elm_colorselector_color_set(colorsel, r, g, b, a);
}
static void
_cb_op_reset(void *data,
Evas_Object *_obj EINA_UNUSED,
void *_event EINA_UNUSED)
{
Colors_Ctx *ctx = data;
Evas_Object *term = ctx->term;
Config *config = ctx->config;
int r = 0, g = 0, b = 0, a = 0;
int i, j;
_reset_config_colors(ctx);
for (j = 0; j < 4; j++)
{
for (i = 0; i < 12; i++)
{
if (i == COL_INVIS)
continue;
elm_colorselector_palette_item_color_set
(ctx->colitem[j][i],
config->colors[(j * 12) + i].r,
config->colors[(j * 12) + i].g,
config->colors[(j * 12) + i].b,
config->colors[(j * 12) + i].a);
}
}
elm_object_disabled_set(ctx->reset, EINA_TRUE);
config->colors_use = EINA_FALSE;
elm_colorselector_palette_item_color_get(ctx->curitem, &r, &g, &b, &a);
elm_colorselector_color_set(ctx->colorsel, r, g, b, a);
termio_config_update(term);
config_save(config, NULL);
}
/* make color palettes wrap back. :) works with elm git. */
static void
_cb_op_scroller_resize(void *_data EINA_UNUSED,
_cb_op_scroller_resize(void *data,
Evas *_e EINA_UNUSED,
Evas_Object *_obj EINA_UNUSED,
void *_event EINA_UNUSED)
{
// make color palettes wrap back. :) works with elm git.
Colors_Ctx *ctx = data;
int i;
for (i = 0; i < 4; i++) evas_object_resize(colpal[i], 1, 1);
for (i = 0; i < 4; i++)
evas_object_resize(ctx->colpal[i], 1, 1);
}
static void
_parent_del_cb(void *data,
Evas *_e EINA_UNUSED,
Evas_Object *_obj EINA_UNUSED,
void *_event_info EINA_UNUSED)
{
Colors_Ctx *ctx = data;
free(ctx);
}
void
options_colors(Evas_Object *opbox, Evas_Object *term)
options_colors(Evas_Object *opbox, Evas_Object *term, Evas_Object *bg)
{
Config *config = termio_config_get(term);
Evas_Object *o, *fr, *bx, *sc, *bx2, *bx3, *bx4;
int i, j;
int r = 0, g = 0, b = 0, a = 0;
Colors_Ctx *ctx;
ctx = calloc(1, sizeof(*ctx));
assert(ctx);
ctx->config = config;
ctx->term = term;
ctx->bg = bg;
fr = o = elm_frame_add(opbox);
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, _("Colors"));
elm_box_pack_end(opbox, o);
evas_object_show(o);
evas_object_event_callback_add(fr, EVAS_CALLBACK_DEL,
_parent_del_cb, ctx);
bx = o = elm_box_add(opbox);
elm_box_horizontal_set(o, EINA_TRUE);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.0);
elm_object_content_set(fr, o);
evas_object_show(o);
sc = o = elm_scroller_add(opbox);
evas_object_event_callback_add(o, EVAS_CALLBACK_RESIZE,
_cb_op_scroller_resize, NULL);
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_box_pack_end(bx, o);
evas_object_show(o);
evas_object_event_callback_add(o, EVAS_CALLBACK_RESIZE,
_cb_op_scroller_resize, ctx);
bx3 = o = elm_box_add(opbox);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.0);
elm_object_content_set(sc, o);
evas_object_show(o);
if (!config->colors_use)
{
_reset_config_colors(ctx);
}
for (j = 0; j < 4; j++)
{
o = elm_label_add(opbox);
if (j == 0) elm_object_text_set(o, _("Normal"));
else if (j == 1) elm_object_text_set(o, _("Bright/Bold"));
else if (j == 2) elm_object_text_set(o, _("Intense"));
else if (j == 3) elm_object_text_set(o, _("Intense Bright/Bold"));
if (j == 0)
elm_object_text_set(o, _("Normal"));
else if (j == 1)
elm_object_text_set(o, _("Bright/Bold"));
else if (j == 2)
elm_object_text_set(o, _("Intense"));
else if (j == 3)
elm_object_text_set(o, _("Intense Bright/Bold"));
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_box_pack_end(bx3, o);
evas_object_show(o);
colpal[j] = o = elm_colorselector_add(opbox);
ctx->colpal[j] = o = elm_colorselector_add(opbox);
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_colorselector_mode_set(o, ELM_COLORSELECTOR_PALETTE);
for (i = 0; i < 11; i++)
for (i = 0; i < 12; i++)
{
Elm_Object_Item *it;
if (i == COL_INVIS)
continue;
it = elm_colorselector_palette_color_add
(o,
config->colors[(j * 12) + mapping[i]].r,
config->colors[(j * 12) + mapping[i]].g,
config->colors[(j * 12) + mapping[i]].b,
config->colors[(j * 12) + mapping[i]].a);
colitem[j][i] = it;
config->colors[(j * 12) + i].r,
config->colors[(j * 12) + i].g,
config->colors[(j * 12) + i].b,
config->colors[(j * 12) + i].a);
ctx->colitem[j][i] = it;
if (i == 0 && j == 0)
{
ctx->curitem = ctx->colitem[0][0];
elm_colorselector_palette_item_selected_set(ctx->curitem, EINA_TRUE);
}
}
evas_object_smart_callback_add(o, "color,item,selected",
_cb_op_color_item_sel, term);
elm_box_pack_end(bx3, o);
evas_object_show(o);
evas_object_smart_callback_add(o, "color,item,selected",
_cb_op_color_item_sel, ctx);
if (j == 1)
{
o = elm_separator_add(opbox);
@ -242,15 +318,13 @@ options_colors(Evas_Object *opbox, Evas_Object *term)
}
}
curitem = colitem[0][0];
bx2 = o = elm_box_add(opbox);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.0);
elm_box_pack_end(bx, o);
evas_object_show(o);
label = o = elm_label_add(opbox);
ctx->label = o = elm_label_add(opbox);
elm_object_text_set(o,
#if HAVE_GETTEXT && ENABLE_NLS
gettext(mapping_names[0])
@ -262,16 +336,16 @@ options_colors(Evas_Object *opbox, Evas_Object *term)
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5);
elm_box_pack_end(bx2, o);
evas_object_show(o);
colorsel = o = elm_colorselector_add(opbox);
elm_colorselector_palette_item_color_get(colitem[0][0], &r, &g, &b, &a);
ctx->colorsel = o = elm_colorselector_add(opbox);
elm_colorselector_palette_item_color_get(ctx->curitem, &r, &g, &b, &a);
elm_colorselector_color_set(o, r, g, b, a);
elm_colorselector_mode_set(o, ELM_COLORSELECTOR_COMPONENTS);
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_box_pack_end(bx2, o);
evas_object_show(o);
evas_object_smart_callback_add(o, "changed", _cb_op_color_chg, term);
evas_object_smart_callback_add(o, "changed", _cb_op_color_chg, ctx);
bx4 = o = elm_box_add(opbox);
elm_box_horizontal_set(o, EINA_TRUE);
@ -279,22 +353,13 @@ options_colors(Evas_Object *opbox, Evas_Object *term)
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.0);
elm_box_pack_end(bx2, o);
evas_object_show(o);
o = elm_check_add(opbox);
evas_object_size_hint_weight_set(o, 1.0, 0.0);
evas_object_size_hint_align_set(o, 0.0, 0.5);
elm_object_text_set(o, _("Use"));
elm_check_state_set(o, config->colors_use);
elm_box_pack_end(bx4, o);
evas_object_show(o);
evas_object_smart_callback_add(o, "changed", _cb_op_use_custom_chg, term);
reset = o = elm_button_add(opbox);
elm_object_disabled_set(o, EINA_TRUE);
ctx->reset = o = elm_button_add(opbox);
elm_object_disabled_set(o, !config->colors_use);
evas_object_size_hint_weight_set(o, 1.0, 0.0);
evas_object_size_hint_align_set(o, 1.0, 0.5);
elm_object_text_set(o, _("Reset"));
elm_object_text_set(o, _("Reset all the colors"));
elm_box_pack_end(bx4, o);
evas_object_show(o);
evas_object_smart_callback_add(o, "clicked", _cb_op_reset, term);
evas_object_smart_callback_add(o, "clicked", _cb_op_reset, ctx);
}

View File

@ -1,6 +1,6 @@
#ifndef _OPTIONS_COLORS_H__
#define _OPTIONS_COLORS_H__ 1
void options_colors(Evas_Object *opbox, Evas_Object *term);
void options_colors(Evas_Object *opbox, Evas_Object *term, Evas_Object *bg);
#endif

View File

@ -1,6 +1,7 @@
#include "private.h"
#include <Elementary.h>
#include <assert.h>
#include "config.h"
#include "termio.h"
#include "options.h"
@ -12,37 +13,47 @@
#define FONT_MAX 45
#define FONT_STEP (1.0 / (FONT_MAX - FONT_MIN))
static Evas_Object *op_fontslider, *op_fontlist, *op_fsml, *op_fbig;
typedef struct _Font Font;
typedef struct _Font_Ctx
{
Evas_Object *op_fontslider;
Evas_Object *op_fontlist;
Evas_Object *op_fsml;
Evas_Object *op_fbig;
Evas_Object *term;
Eina_List *fonts;
Eina_Hash *fonthash;
Config *config;
Evas_Coord tsize_w;
Evas_Coord tsize_h;
int expecting_resize;
} Font_Ctx;
struct _Font
typedef struct _Font
{
Elm_Object_Item *item;
const char *pretty_name;
const char *full_name;
Evas_Object *term;
Font_Ctx *ctx;
unsigned char bitmap : 1;
};
} Font;
static Eina_List *fonts = NULL;
static Eina_Hash *fonthash = NULL;
static Evas_Coord tsize_w = 0, tsize_h = 0;
static int expecting_resize = 0;
static void
_update_sizing(Evas_Object *term)
_update_sizing(Font_Ctx *ctx)
{
Evas_Coord mw = 1, mh = 1, w, h;
termio_config_update(term);
evas_object_size_hint_min_get(term, &mw, &mh);
if (mw < 1) mw = 1;
if (mh < 1) mh = 1;
w = tsize_w / mw;
h = tsize_h / mh;
evas_object_size_hint_request_set(term, w * mw, h * mh);
expecting_resize = 1;
termio_config_update(ctx->term);
evas_object_size_hint_min_get(ctx->term, &mw, &mh);
if (mw < 1)
mw = 1;
if (mh < 1)
mh = 1;
w = ctx->tsize_w / mw;
h = ctx->tsize_h / mh;
evas_object_size_hint_request_set(ctx->term, w * mw, h * mh);
ctx->expecting_resize = 1;
}
static int
@ -133,18 +144,19 @@ _cb_op_font_sel(void *data,
void *_event EINA_UNUSED)
{
Font *f = data;
Config *config = termio_config_get(f->term);
Term *term = termio_term_get(f->term);
Font_Ctx *ctx = f->ctx;
Config *config = ctx->config;
Term *term = termio_term_get(ctx->term);
if ((config->font.name) && (!strcmp(f->full_name, config->font.name)))
return;
if (config->font.name) eina_stringshare_del(config->font.name);
config->font.name = eina_stringshare_add(f->full_name);
config->font.bitmap = f->bitmap;
_update_sizing(f->term);
elm_object_disabled_set(op_fsml, f->bitmap);
elm_object_disabled_set(op_fontslider, f->bitmap);
elm_object_disabled_set(op_fbig, f->bitmap);
_update_sizing(ctx);
elm_object_disabled_set(ctx->op_fsml, f->bitmap);
elm_object_disabled_set(ctx->op_fontslider, f->bitmap);
elm_object_disabled_set(ctx->op_fbig, f->bitmap);
config_save(config, NULL);
win_font_update(term);
}
@ -154,15 +166,16 @@ _cb_op_fontsize_sel(void *data,
Evas_Object *obj,
void *_event EINA_UNUSED)
{
Evas_Object *termio_obj = data;
Config *config = termio_config_get(termio_obj);
Term *term = termio_term_get(termio_obj);
Font_Ctx *ctx = data;
Config *config = ctx->config;
Term *term = termio_term_get(ctx->term);
int size = elm_slider_value_get(obj) + 0.5;
if (config->font.size == size) return;
if (config->font.size == size)
return;
config->font.size = size;
_update_sizing(termio_obj);
elm_genlist_realized_items_update(op_fontlist);
_update_sizing(ctx);
elm_genlist_realized_items_update(ctx->op_fontlist);
config_save(config, NULL);
win_font_update(term);
}
@ -181,7 +194,7 @@ _cb_op_font_preview_del(void *_data EINA_UNUSED,
{
Evas_Object *o;
Ecore_Timer *timer = evas_object_data_get(obj, "delay");
if (timer)
{
ecore_timer_del(timer);
@ -203,22 +216,27 @@ _cb_op_font_preview_delayed_eval(void *data)
Evas_Object *o;
Evas_Coord ox, oy, ow, oh, vx, vy, vw, vh;
Config *config;
if (!evas_object_visible_get(obj)) goto done;
if (edje_object_part_swallow_get(obj, "terminology.text.preview")) goto done;
if (!evas_object_visible_get(obj))
goto done;
if (edje_object_part_swallow_get(obj, "terminology.text.preview"))
goto done;
evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
if ((ow < 2) || (oh < 2)) goto done;
if ((ow < 2) || (oh < 2))
goto done;
evas_output_viewport_get(evas_object_evas_get(obj), &vx, &vy, &vw, &vh);
f = evas_object_data_get(obj, "font");
if (!f) goto done;
config = termio_config_get(f->term);
if (!config) goto done;
if (!f)
goto done;
config = f->ctx->config;
if (!config)
goto done;
if (ELM_RECTS_INTERSECT(ox, oy, ow, oh, vx, vy, vw, vh))
{
char buf[4096];
int r, g, b, a;
Evas *evas = evas_object_evas_get(obj);
Evas_Object *textgrid = termio_textgrid_get(f->term);
Evas_Object *textgrid = termio_textgrid_get(f->ctx->term);
evas_object_textgrid_palette_get(textgrid, EVAS_TEXTGRID_PALETTE_STANDARD,
0, &r, &g, &b, &a);
@ -252,11 +270,14 @@ _cb_op_font_preview_eval(void *data,
{
Font *f = data;
Evas_Coord ox, oy, ow, oh, vx, vy, vw, vh;
if (!evas_object_visible_get(obj)) return;
if (edje_object_part_swallow_get(obj, "terminology.text.preview")) return;
if (!evas_object_visible_get(obj))
return;
if (edje_object_part_swallow_get(obj, "terminology.text.preview"))
return;
evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
if ((ow < 2) || (oh < 2)) return;
if ((ow < 2) || (oh < 2))
return;
evas_output_viewport_get(evas_object_evas_get(obj), &vx, &vy, &vw, &vh);
if (ELM_RECTS_INTERSECT(ox, oy, ow, oh, vx, vy, vw, vh))
{
@ -264,8 +285,10 @@ _cb_op_font_preview_eval(void *data,
double rnd = 0.2;
timer = evas_object_data_get(obj, "delay");
if (timer) return;
else evas_object_data_set(obj, "font", f);
if (timer)
return;
else
evas_object_data_set(obj, "font", f);
rnd += (double)(rand() % 100) / 500.0;
timer = ecore_timer_add(rnd, _cb_op_font_preview_delayed_eval, obj);
evas_object_data_set(obj, "delay", timer);
@ -280,8 +303,8 @@ _cb_op_font_content_get(void *data, Evas_Object *obj, const char *part)
if (!strcmp(part, "elm.swallow.icon"))
{
Evas_Object *o;
Config *config = termio_config_get(f->term);
Config *config = f->ctx->config;
o = edje_object_add(evas_object_evas_get(obj));
theme_apply(o, config, "terminology/fontpreview");
theme_auto_reload_enable(o);
@ -324,13 +347,14 @@ _cb_term_resize(void *data,
Evas_Object *_obj EINA_UNUSED,
void *_event EINA_UNUSED)
{
Evas_Object *term = data;
if (expecting_resize)
Font_Ctx *ctx = data;
if (ctx->expecting_resize)
{
expecting_resize = 0;
ctx->expecting_resize = 0;
return;
}
evas_object_geometry_get(term, NULL, NULL, &tsize_w, &tsize_h);
evas_object_geometry_get(ctx->term, NULL, NULL, &ctx->tsize_w, &ctx->tsize_h);
}
static void
@ -339,32 +363,29 @@ _cb_font_del(void *data,
Evas_Object *_obj EINA_UNUSED,
void *_event EINA_UNUSED)
{
Evas_Object *term = data;
evas_object_event_callback_del_full(term, EVAS_CALLBACK_RESIZE,
_cb_term_resize, term);
Font_Ctx *ctx = data;
evas_object_event_callback_del_full(ctx->term, EVAS_CALLBACK_RESIZE,
_cb_term_resize, ctx);
}
void
options_font_clear(void)
static void
_parent_del_cb(void *data,
Evas *_e EINA_UNUSED,
Evas_Object *_obj EINA_UNUSED,
void *_event_info EINA_UNUSED)
{
Font_Ctx *ctx = data;
Font *f;
op_fontslider = NULL;
op_fontlist = NULL;
op_fsml = NULL;
op_fbig = NULL;
EINA_LIST_FREE(fonts, f)
EINA_LIST_FREE(ctx->fonts, f)
{
eina_stringshare_del(f->full_name);
eina_stringshare_del(f->pretty_name);
free(f);
}
if (fonthash)
{
eina_hash_free(fonthash);
fonthash = NULL;
}
eina_hash_free(ctx->fonthash);
free(ctx);
}
static void
@ -372,11 +393,11 @@ _cb_font_bolditalic(void *data,
Evas_Object *obj,
void *_event EINA_UNUSED)
{
Evas_Object *term = data;
Config *config = termio_config_get(term);
Font_Ctx *ctx = data;
Config *config = ctx->config;
config->font.bolditalic = elm_check_state_get(obj);
termio_config_update(term);
termio_config_update(ctx->term);
config_save(config, NULL);
}
@ -390,33 +411,41 @@ options_font(Evas_Object *opbox, Evas_Object *term)
Elm_Object_Item *it, *sel_it = NULL, *sel_it2 = NULL, *grp_it = NULL;
Elm_Genlist_Item_Class *it_class, *it_group;
Config *config = termio_config_get(term);
Font_Ctx *ctx;
ctx = calloc(1, sizeof(*ctx));
assert(ctx);
ctx->config = config;
ctx->term = term;
options_font_clear();
fr = o = elm_frame_add(opbox);
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, _("Font"));
elm_box_pack_end(opbox, o);
evas_object_show(o);
evas_object_event_callback_add(fr, EVAS_CALLBACK_DEL,
_parent_del_cb, ctx);
bx0 = o = elm_box_add(opbox);
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_content_set(fr, o);
evas_object_show(o);
bx = o = elm_box_add(opbox);
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, 0.5);
elm_box_horizontal_set(o, EINA_TRUE);
op_fsml = o = elm_label_add(opbox);
ctx->op_fsml = o = elm_label_add(opbox);
elm_object_text_set(o, "<font_size=6>A</font_size>");
elm_box_pack_end(bx, o);
evas_object_show(o);
op_fontslider = o = elm_slider_add(opbox);
ctx->op_fontslider = o = elm_slider_add(opbox);
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_slider_span_size_set(o, 40);
@ -429,28 +458,28 @@ options_font(Evas_Object *opbox, Evas_Object *term)
elm_slider_value_set(o, config->font.size);
elm_box_pack_end(bx, o);
evas_object_show(o);
evas_object_smart_callback_add(o, "delay,changed",
_cb_op_fontsize_sel, term);
op_fbig = o = elm_label_add(opbox);
evas_object_smart_callback_add(o, "delay,changed",
_cb_op_fontsize_sel, ctx);
ctx->op_fbig = o = elm_label_add(opbox);
elm_object_text_set(o, "<font_size=24>A</font_size>");
elm_box_pack_end(bx, o);
evas_object_show(o);
elm_box_pack_end(bx0, bx);
evas_object_show(bx);
it_class = elm_genlist_item_class_new();
it_class->item_style = "end_icon";
it_class->func.text_get = _cb_op_font_text_get;
it_class->func.content_get = _cb_op_font_content_get;
it_group = elm_genlist_item_class_new();
it_group->item_style = "group_index";
it_group->func.text_get = _cb_op_font_group_text_get;
op_fontlist = o = elm_genlist_add(opbox);
ctx->op_fontlist = o = elm_genlist_add(opbox);
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_genlist_mode_set(o, ELM_LIST_COMPRESS);
@ -476,9 +505,9 @@ options_font(Evas_Object *opbox, Evas_Object *term)
s = strchr(file, '.');
if (s != NULL) *s = '\0';
f->pretty_name = eina_stringshare_add(file);
f->term = term;
f->ctx = ctx;
f->bitmap = EINA_TRUE;
fonts = eina_list_append(fonts, f);
ctx->fonts = eina_list_append(ctx->fonts, f);
f->item = it = elm_genlist_item_append(o, it_class, f, grp_it,
ELM_GENLIST_ITEM_NONE,
@ -488,9 +517,9 @@ options_font(Evas_Object *opbox, Evas_Object *term)
(!strcmp(config->font.name, file))))
{
sel_it = it;
elm_object_disabled_set(op_fsml, EINA_TRUE);
elm_object_disabled_set(op_fontslider, EINA_TRUE);
elm_object_disabled_set(op_fbig, EINA_TRUE);
elm_object_disabled_set(ctx->op_fsml, EINA_TRUE);
elm_object_disabled_set(ctx->op_fontslider, EINA_TRUE);
elm_object_disabled_set(ctx->op_fbig, EINA_TRUE);
}
free(file);
}
@ -499,8 +528,8 @@ options_font(Evas_Object *opbox, Evas_Object *term)
fontlist = evas_font_available_list(evas_object_evas_get(opbox));
fontlist = eina_list_sort(fontlist, eina_list_count(fontlist),
_cb_op_font_sort);
fonthash = eina_hash_string_superfast_new(NULL);
if (fonts)
ctx->fonthash = eina_hash_string_superfast_new(NULL);
if (ctx->fonts)
{
grp_it = elm_genlist_item_append(o, it_group, _("Standard"), NULL,
ELM_GENLIST_ITEM_GROUP,
@ -510,19 +539,20 @@ options_font(Evas_Object *opbox, Evas_Object *term)
}
EINA_LIST_FOREACH(fontlist, l, fname)
{
if (!eina_hash_find(fonthash, fname))
if (!eina_hash_find(ctx->fonthash, fname))
{
f = calloc(1, sizeof(Font));
if (!f) break;
if (!f)
break;
if (_parse_font_name(fname, &f->full_name, &f->pretty_name) <0)
{
free(f);
continue;
}
f->term = term;
f->ctx = ctx;
f->bitmap = EINA_FALSE;
eina_hash_add(fonthash, eina_stringshare_add(fname), f);
fonts = eina_list_append(fonts, f);
eina_hash_add(ctx->fonthash, eina_stringshare_add(fname), f);
ctx->fonts = eina_list_append(ctx->fonts, f);
f->item = it = elm_genlist_item_append(o, it_class, f, grp_it,
ELM_GENLIST_ITEM_NONE,
_cb_op_font_sel, f);
@ -568,12 +598,12 @@ options_font(Evas_Object *opbox, Evas_Object *term)
elm_box_pack_end(bx0, o);
evas_object_show(o);
evas_object_smart_callback_add(o, "changed",
_cb_font_bolditalic, term);
_cb_font_bolditalic, ctx);
expecting_resize = 0;
evas_object_geometry_get(term, NULL, NULL, &tsize_w, &tsize_h);
ctx->expecting_resize = 0;
evas_object_geometry_get(term, NULL, NULL, &ctx->tsize_w, &ctx->tsize_h);
evas_object_event_callback_add(term, EVAS_CALLBACK_RESIZE,
_cb_term_resize, term);
_cb_term_resize, ctx);
evas_object_event_callback_add(opbox, EVAS_CALLBACK_DEL,
_cb_font_del, term);
_cb_font_del, ctx);
}

View File

@ -1,7 +1,6 @@
#ifndef _OPTIONS_FONT_H__
#define _OPTIONS_FONT_H__ 1
void options_font_clear(void);
void options_font(Evas_Object *opbox, Evas_Object *term);
#endif

View File

@ -1,6 +1,7 @@
#include "private.h"
#include <Elementary.h>
#include <assert.h>
#include "config.h"
#include "termio.h"
#include "options.h"
@ -8,12 +9,14 @@
#include "keyin.h"
#include "utils.h"
/*XXX: can have only one widget at a time… */
static Config *_config;
static Evas_Object *_fr;
static Evas_Object *_layout;
typedef struct _Keys_Ctx {
Config *config;
Evas_Object *frame;
Evas_Object *gl;
Evas_Object *layout;
} Keys_Ctx;
static void _hover_del(Evas_Object *o);
static void _hover_del(Keys_Ctx *ctx);
static void
_shortcut_delete(void *data,
@ -23,12 +26,17 @@ _shortcut_delete(void *data,
Evas_Object *hs, *bx;
Config_Keys *cfg_key;
Evas_Coord w, min_w, min_h;
Keys_Ctx *ctx;
hs = data;
bx = evas_object_data_get(hs, "bx");
assert(bx);
cfg_key = evas_object_data_get(hs, "cfg");
assert(cfg_key);
ctx = evas_object_data_get(hs, "ctx");
assert(ctx);
_config->keys = eina_list_remove(_config->keys, cfg_key);
ctx->config->keys = eina_list_remove(ctx->config->keys, cfg_key);
evas_object_size_hint_min_get(hs, &w, NULL);
evas_object_size_hint_min_get(bx, &min_w, &min_h);
min_w -= w;
@ -41,11 +49,13 @@ _shortcut_delete(void *data,
eina_stringshare_del(cfg_key->cb);
free(cfg_key);
config_save(_config, NULL);
config_save(ctx->config, NULL);
}
static Evas_Object *
_shortcut_button_add(Evas_Object *bx, const Config_Keys *key)
_shortcut_button_add(Keys_Ctx *ctx,
Evas_Object *bx,
const Config_Keys *key)
{
const char *txt;
Evas_Object *hs;
@ -58,11 +68,13 @@ _shortcut_button_add(Evas_Object *bx, const Config_Keys *key)
key->meta ? _("Meta+") : "",
key->hyper ? _("Hyper+") : "",
key->keyname);
hs = elm_hoversel_add(_fr);
elm_hoversel_hover_parent_set(hs, _fr);
hs = elm_hoversel_add(ctx->frame);
elm_hoversel_hover_parent_set(hs, ctx->frame);
evas_object_data_set(hs, "bx", bx);
evas_object_data_set(hs, "cfg", key);
evas_object_data_set(hs, "ctx", ctx);
elm_layout_text_set(hs, NULL, txt);
elm_hoversel_item_add(hs, _("Delete"), "delete", ELM_ICON_STANDARD,
@ -75,17 +87,22 @@ _shortcut_button_add(Evas_Object *bx, const Config_Keys *key)
static void
_cb_key_up(void *data,
Evas *_e EINA_UNUSED,
Evas_Object *obj, void *event)
Evas_Object *obj EINA_UNUSED,
void *event)
{
Evas_Event_Key_Up *ev = event;
int ctrl, alt, shift, win, meta, hyper, res;
Config_Keys *cfg_key;
Shortcut_Action *action;
Evas_Object *bx = data;
Keys_Ctx *ctx;
if (key_is_modifier(ev->keyname))
return;
ctx = evas_object_data_get(bx, "ctx");
assert(ctx);
ctrl = evas_key_modifier_is_set(ev->modifiers, "Control");
alt = evas_key_modifier_is_set(ev->modifiers, "Alt");
shift = evas_key_modifier_is_set(ev->modifiers, "Shift");
@ -95,7 +112,7 @@ _cb_key_up(void *data,
evas_key_modifier_is_set(ev->modifiers, "ISO_Level3_Shift");
hyper = evas_key_modifier_is_set(ev->modifiers, "Hyper");
_hover_del(obj);
_hover_del(ctx);
action = evas_object_data_get(bx, "action");
if (!action)
@ -123,8 +140,8 @@ _cb_key_up(void *data,
Evas_Coord w, h, min_w, min_h;
last = evas_object_data_get(bx, "last");
_config->keys = eina_list_append(_config->keys, cfg_key);
bt = _shortcut_button_add(bx, cfg_key);
ctx->config->keys = eina_list_append(ctx->config->keys, cfg_key);
bt = _shortcut_button_add(ctx, bx, cfg_key);
evas_object_show(bt);
evas_object_size_hint_min_get(bt, &w, &h);
evas_object_size_hint_min_get(bx, &min_w, &min_h);
@ -133,7 +150,7 @@ _cb_key_up(void *data,
evas_object_size_hint_min_set(bx, min_w, min_h);
elm_box_pack_before(bx, bt, last);
config_save(_config, NULL);
config_save(ctx->config, NULL);
}
else
{
@ -144,44 +161,49 @@ _cb_key_up(void *data,
}
static void
_cb_mouse_down(void *_data EINA_UNUSED,
_cb_mouse_down(void *data,
Evas *_e EINA_UNUSED,
Evas_Object *obj,
Evas_Object *obj EINA_UNUSED,
void *_event EINA_UNUSED)
{
_hover_del(obj);
Keys_Ctx *ctx = data;
_hover_del(ctx);
}
static void
_hover_sizing_eval(void)
_hover_sizing_eval(Keys_Ctx *ctx)
{
Evas_Coord x = 0, y = 0, w = 0, h = 0;
evas_object_geometry_get(_fr, &x, &y, &w, &h);
evas_object_geometry_get(ctx->frame, &x, &y, &w, &h);
#if (ECORE_VERSION_MAJOR > 1) || (ECORE_VERSION_MINOR >= 8)
evas_object_geometry_set(_layout, x, y, w, h);
evas_object_geometry_set(ctx->layout, x, y, w, h);
#else
evas_object_move(_layout, x, y);
evas_object_resize(_layout, w, h);
evas_object_move(ctx->layout, x, y);
evas_object_resize(ctx->layout, w, h);
#endif
}
static void
_parent_move_cb(void *_data EINA_UNUSED,
_parent_move_cb(void *data,
Evas *_e EINA_UNUSED,
Evas_Object *_obj EINA_UNUSED,
void *_event_info EINA_UNUSED)
{
_hover_sizing_eval();
Keys_Ctx *ctx = data;
_hover_sizing_eval(ctx);
}
static void
_parent_resize_cb(void *_data EINA_UNUSED,
_parent_resize_cb(void *data,
Evas *_e EINA_UNUSED,
Evas_Object *_obj EINA_UNUSED,
void *_event_info EINA_UNUSED)
{
_hover_sizing_eval();
Keys_Ctx *ctx = data;
_hover_sizing_eval(ctx);
}
static void
@ -190,88 +212,74 @@ _parent_hide_cb(void *data,
Evas_Object *_obj EINA_UNUSED,
void *_event_info EINA_UNUSED)
{
_hover_del(data);
Keys_Ctx *ctx = data;
_hover_del(ctx);
}
static void
_parent_del_cb(void *data,
Evas *_e EINA_UNUSED,
Evas_Object *_obj EINA_UNUSED,
void *_event_info EINA_UNUSED)
{
_hover_del(data);
}
Keys_Ctx *ctx = data;
_hover_del(ctx);
static void
_hover_del(Evas_Object *o)
{
evas_object_event_callback_del(o, EVAS_CALLBACK_KEY_UP,
_cb_key_up);
evas_object_event_callback_del(o, EVAS_CALLBACK_MOUSE_DOWN,
_cb_mouse_down);
evas_object_event_callback_del(_fr, EVAS_CALLBACK_MOVE,
_parent_move_cb);
evas_object_event_callback_del(_fr, EVAS_CALLBACK_RESIZE,
_parent_resize_cb);
evas_object_event_callback_del(_fr, EVAS_CALLBACK_HIDE,
_parent_hide_cb);
evas_object_event_callback_del(_fr, EVAS_CALLBACK_DEL,
evas_object_event_callback_del(ctx->frame, EVAS_CALLBACK_DEL,
_parent_del_cb);
evas_object_del(o);
_layout = NULL;
evas_object_event_callback_del(ctx->frame, EVAS_CALLBACK_HIDE,
_parent_hide_cb);
free(ctx);
}
static void
_cb_focused(void *_data EINA_UNUSED,
Evas_Object *_obj EINA_UNUSED,
void *_event EINA_UNUSED)
_hover_del(Keys_Ctx *ctx)
{
DBG("focused");
}
static void
_cb_unfocused(void *_data EINA_UNUSED,
Evas_Object *_obj EINA_UNUSED,
void *_event EINA_UNUSED)
{
DBG("unfocused");
if (_layout)
elm_object_focus_set(_layout, EINA_TRUE);
if (ctx->layout)
{
evas_object_event_callback_del(ctx->frame, EVAS_CALLBACK_KEY_UP,
_cb_key_up);
evas_object_event_callback_del(ctx->frame, EVAS_CALLBACK_MOUSE_DOWN,
_cb_mouse_down);
evas_object_event_callback_del(ctx->frame, EVAS_CALLBACK_MOVE,
_parent_move_cb);
evas_object_event_callback_del(ctx->frame, EVAS_CALLBACK_RESIZE,
_parent_resize_cb);
evas_object_del(ctx->layout);
}
ctx->layout = NULL;
}
static void
on_shortcut_add(void *data,
Evas_Object *bt,
void *_event_info EINA_UNUSED)
_on_shortcut_add(void *data,
Evas_Object *bt,
void *_event_info EINA_UNUSED)
{
Evas_Object *o, *oe;
Evas_Object *bx = data;
Keys_Ctx *ctx;
_layout = o = elm_layout_add(bt);
ctx = evas_object_data_get(bx, "ctx");
assert(ctx);
assert(ctx->layout == NULL);
ctx->layout = o = elm_layout_add(bt);
evas_object_data_set(ctx->layout, "ctx", ctx);
oe = elm_layout_edje_get(o);
theme_apply(oe, _config, "terminology/keybinding");
theme_apply(oe, ctx->config, "terminology/keybinding");
theme_auto_reload_enable(oe);
elm_layout_text_set(o, "label", _("Please press key sequence"));
evas_object_show(o);
elm_object_focus_allow_set(o, EINA_TRUE);
evas_object_smart_callback_add(o, "focused",
_cb_focused, NULL);
evas_object_smart_callback_add(o, "unfocused",
_cb_unfocused, NULL);
elm_object_focus_set(o, EINA_TRUE);
_hover_sizing_eval();
evas_object_event_callback_add(o, EVAS_CALLBACK_KEY_UP,
evas_object_event_callback_add(ctx->frame, EVAS_CALLBACK_KEY_UP,
_cb_key_up, bx);
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
_cb_mouse_down, o);
evas_object_event_callback_add(_fr, EVAS_CALLBACK_MOVE,
_parent_move_cb, o);
evas_object_event_callback_add(_fr, EVAS_CALLBACK_RESIZE,
_parent_resize_cb, o);
evas_object_event_callback_add(_fr, EVAS_CALLBACK_HIDE,
_parent_hide_cb, o);
evas_object_event_callback_add(_fr, EVAS_CALLBACK_DEL,
_parent_del_cb, o);
evas_object_event_callback_add(ctx->frame, EVAS_CALLBACK_MOUSE_DOWN,
_cb_mouse_down, ctx);
elm_object_focus_set(ctx->frame, EINA_TRUE);
elm_object_focus_allow_set(ctx->frame, EINA_TRUE);
_hover_sizing_eval(ctx);
}
static Evas_Object *
@ -282,11 +290,16 @@ gl_content_get(void *data, Evas_Object *obj, const char *_part EINA_UNUSED)
Evas_Object *bx, *bt, *lbl, *sep;
Config_Keys *key;
Eina_List *l;
Keys_Ctx *ctx;
ctx = evas_object_data_get(obj, "ctx");
assert(ctx);
bx = elm_box_add(obj);
elm_box_horizontal_set(bx, EINA_TRUE);
elm_box_homogeneous_set(bx, EINA_FALSE);
evas_object_size_hint_align_set(bx, 0, 0);
evas_object_data_set(bx, "ctx", ctx);
lbl = elm_label_add(obj);
elm_layout_text_set(lbl, NULL, action->description);
@ -304,11 +317,11 @@ gl_content_get(void *data, Evas_Object *obj, const char *_part EINA_UNUSED)
if (h > min_h) min_h = h;
// TODO: have a better data structure
EINA_LIST_FOREACH(_config->keys, l, key)
EINA_LIST_FOREACH(ctx->config->keys, l, key)
{
if (!strcmp(key->cb, action->action))
{
bt = _shortcut_button_add(bx, key);
bt = _shortcut_button_add(ctx, bx, key);
evas_object_show(bt);
evas_object_size_hint_min_get(bt, &w, &h);
min_w += w;
@ -318,7 +331,7 @@ gl_content_get(void *data, Evas_Object *obj, const char *_part EINA_UNUSED)
}
bt = elm_button_add(obj);
evas_object_smart_callback_add(bt, "clicked", on_shortcut_add, bx);
evas_object_smart_callback_add(bt, "clicked", _on_shortcut_add, bx);
elm_layout_text_set(bt, NULL, "+");
evas_object_size_hint_min_get(bt, &w, &h);
min_w += w;
@ -350,10 +363,10 @@ _cb_reset_keys(void *data,
Evas_Object *_obj EINA_UNUSED,
void *_event EINA_UNUSED)
{
Evas_Object *gl = data;
Keys_Ctx *ctx = data;
config_reset_keys(_config);
elm_genlist_realized_items_update(gl);
config_reset_keys(ctx->config);
elm_genlist_realized_items_update(ctx->gl);
}
void
@ -363,23 +376,33 @@ options_keys(Evas_Object *opbox, Evas_Object *term)
const Shortcut_Action *action;
Elm_Genlist_Item_Class *itc, *itc_group;
Elm_Object_Item *git = NULL;
Config *config = termio_config_get(term);
Keys_Ctx *ctx;
_config = termio_config_get(term);
ctx = calloc(1, sizeof(*ctx));
assert(ctx);
_fr = o = elm_frame_add(opbox);
ctx->config = config;
ctx->frame = o = elm_frame_add(opbox);
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, _("Key Bindings"));
elm_box_pack_end(opbox, o);
evas_object_show(o);
evas_object_event_callback_add(ctx->frame, EVAS_CALLBACK_DEL,
_parent_del_cb, ctx);
evas_object_event_callback_add(ctx->frame, EVAS_CALLBACK_HIDE,
_parent_hide_cb, ctx);
bx = elm_box_add(opbox);
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(bx, 0.0, 0.0);
elm_object_content_set(_fr, bx);
elm_object_content_set(ctx->frame, bx);
evas_object_show(bx);
gl = elm_genlist_add(opbox);
ctx->gl = gl = elm_genlist_add(opbox);
evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_scroller_policy_set(gl, ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_AUTO);
@ -387,6 +410,7 @@ options_keys(Evas_Object *opbox, Evas_Object *term)
elm_genlist_homogeneous_set(gl, EINA_FALSE);
elm_box_pack_end(bx, gl);
evas_object_show(gl);
evas_object_data_set(gl, "ctx", ctx);
itc = elm_genlist_item_class_new();
itc->item_style = "one_icon";
@ -434,5 +458,5 @@ options_keys(Evas_Object *opbox, Evas_Object *term)
elm_object_text_set(o, _("Reset bindings"));
elm_box_pack_end(bx, o);
evas_object_show(o);
evas_object_smart_callback_add(o, "clicked", _cb_reset_keys, gl);
evas_object_smart_callback_add(o, "clicked", _cb_reset_keys, ctx);
}

View File

@ -2,6 +2,7 @@
#include <Elementary.h>
#include <Efreet.h>
#include <assert.h>
#include "config.h"
#include "termio.h"
#include "options.h"
@ -10,18 +11,23 @@
#include "utils.h"
#include "main.h"
typedef struct _Theme_Ctx
{
Evas_Object *term;
Config *config;
Evas_Object *op_themelist;
Eina_List *themes;
Ecore_Timer *seltimer;
} Theme_Ctx;
typedef struct _Theme Theme;
struct _Theme
{
Elm_Object_Item *item;
const char *name;
Evas_Object *term;
Theme_Ctx *ctx;
};
static Evas_Object *op_themelist;
static Eina_List *themes = NULL;
static Ecore_Timer *seltimer = NULL;
static char *
_cb_op_theme_text_get(void *data,
Evas_Object *_obj EINA_UNUSED,
@ -32,7 +38,8 @@ _cb_op_theme_text_get(void *data,
eina_strlcpy(buf, t->name, sizeof(buf));
p = strrchr(buf, '.');
if (p) *p = 0;
if (p)
*p = 0;
return strdup(buf);
}
@ -45,7 +52,7 @@ _cb_op_theme_content_get(void *data, Evas_Object *obj, const char *part)
if (!strcmp(part, "elm.swallow.icon"))
{
Evas_Object *o;
Config *config = termio_config_get(t->term);
Config *config = t->ctx->config;
if (config)
{
@ -66,14 +73,14 @@ _cb_op_theme_sel(void *data,
void *_event EINA_UNUSED)
{
Theme *t = data;
Config *config = termio_config_get(t->term);
Config *config = t->ctx->config;
if ((config->theme) && (!strcmp(t->name, config->theme)))
return;
eina_stringshare_replace(&(config->theme), t->name);
config_save(config, NULL);
change_theme(termio_win_get(t->term), config);
change_theme(termio_win_get(t->ctx->term), config);
}
static int
@ -92,10 +99,35 @@ _cb_sel_item(void *data)
elm_gengrid_item_selected_set(t->item, EINA_TRUE);
elm_gengrid_item_bring_in(t->item, ELM_GENGRID_ITEM_SCROLLTO_MIDDLE);
}
seltimer = NULL;
t->ctx->seltimer = NULL;
return EINA_FALSE;
}
static void
_parent_del_cb(void *data,
Evas *_e EINA_UNUSED,
Evas_Object *_obj EINA_UNUSED,
void *_event_info EINA_UNUSED)
{
Theme_Ctx *ctx = data;
Theme *t;
ctx->op_themelist = NULL;
if (ctx->seltimer)
{
ecore_timer_del(ctx->seltimer);
ctx->seltimer = NULL;
}
EINA_LIST_FREE(ctx->themes, t)
{
eina_stringshare_del(t->name);
free(t);
}
free(ctx);
}
void
options_theme(Evas_Object *opbox, Evas_Object *term)
{
@ -108,8 +140,13 @@ options_theme(Evas_Object *opbox, Evas_Object *term)
Config *config = termio_config_get(term);
Eina_Bool to_skip = EINA_FALSE;
double scale = elm_config_scale_get();
Theme_Ctx *ctx;
options_theme_clear();
ctx = calloc(1, sizeof(*ctx));
assert(ctx);
ctx->config = config;
ctx->term = term;
fr = o = elm_frame_add(opbox);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
@ -118,6 +155,9 @@ options_theme(Evas_Object *opbox, Evas_Object *term)
elm_box_pack_end(opbox, o);
evas_object_show(o);
evas_object_event_callback_add(fr, EVAS_CALLBACK_DEL,
_parent_del_cb, ctx);
box = o = elm_box_add(opbox);
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);
@ -130,7 +170,7 @@ options_theme(Evas_Object *opbox, Evas_Object *term)
it_class->func.text_get = _cb_op_theme_text_get;
it_class->func.content_get = _cb_op_theme_content_get;
op_themelist = o = elm_gengrid_add(opbox);
ctx->op_themelist = o = elm_gengrid_add(opbox);
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_gengrid_item_size_set(o, scale * 160, scale * 180);
@ -152,10 +192,10 @@ options_theme(Evas_Object *opbox, Evas_Object *term)
else if (userfiles)
files = userfiles;
if (seltimer)
if (ctx->seltimer)
{
ecore_timer_del(seltimer);
seltimer = NULL;
ecore_timer_del(ctx->seltimer);
ctx->seltimer = NULL;
}
EINA_LIST_FOREACH_SAFE(files, l, l_next, file)
@ -185,19 +225,21 @@ options_theme(Evas_Object *opbox, Evas_Object *term)
}
t = calloc(1, sizeof(Theme));
if (!t) break;
if (!t)
break;
t->name = eina_stringshare_add(file);
t->term = term;
t->ctx = ctx;
t->item = elm_gengrid_item_append(o, it_class, t,
_cb_op_theme_sel, t);
if (t->item)
{
themes = eina_list_append(themes, t);
ctx->themes = eina_list_append(ctx->themes, t);
if ((config) && (config->theme) &&
(!strcmp(config->theme, t->name)))
{
if (seltimer) ecore_timer_del(seltimer);
seltimer = ecore_timer_add(0.2, _cb_sel_item, t);
if (ctx->seltimer)
ecore_timer_del(ctx->seltimer);
ctx->seltimer = ecore_timer_add(0.2, _cb_sel_item, t);
}
}
else
@ -217,22 +259,3 @@ options_theme(Evas_Object *opbox, Evas_Object *term)
evas_object_size_hint_align_set(opbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(o);
}
void
options_theme_clear(void)
{
Theme *t;
op_themelist = NULL;
if (seltimer)
{
ecore_timer_del(seltimer);
seltimer = NULL;
}
EINA_LIST_FREE(themes, t)
{
eina_stringshare_del(t->name);
free(t);
}
}

View File

@ -1,7 +1,6 @@
#ifndef _OPTIONS_THEME_H__
#define _OPTIONS_THEME_H__ 1
void options_theme_clear(void);
void options_theme(Evas_Object *opbox, Evas_Object *term);
#endif

View File

@ -8,8 +8,6 @@
#include "main.h"
static Evas_Object *op_vidmod;
static void
_cb_op_video_mute_chg(void *data,
Evas_Object *obj,
@ -51,7 +49,7 @@ _cb_op_video_vidmod_chg(void *data,
void
options_video(Evas_Object *opbox, Evas_Object *term)
{
Evas_Object *o, *fr, *bx0;
Evas_Object *o, *fr, *bx0, *op_vidmod;
Config *config = termio_config_get(term);
fr = o = elm_frame_add(opbox);

View File

@ -60,6 +60,7 @@ struct _Term_Container {
void (*bell)(Term_Container *tc, Term_Container *child);
void (*close)(Term_Container *container, Term_Container *child);
void (*update)(Term_Container *tc);
Eina_Bool (*is_visible)(Term_Container *tc, Term_Container *child);
};
#endif

View File

@ -86,12 +86,10 @@ struct _Termio
Evas_Object *win, *theme, *glayer;
Config *config;
const char *sel_str;
const char *preedit_str;
Eina_List *cur_chids;
Ecore_Job *sel_reset_job;
double set_sel_at;
Elm_Sel_Type sel_type;
Keys_Handler khdl;
unsigned char jump_on_change : 1;
unsigned char jump_on_keypress : 1;
unsigned char have_sel : 1;
@ -101,6 +99,7 @@ struct _Termio
unsigned char bottom_right : 1;
unsigned char top_left : 1;
unsigned char reset_sel : 1;
unsigned char cb_added : 1;
double gesture_zoom_start_size;
};
@ -1982,70 +1981,6 @@ _block_obj_del(Termblock *blk)
blk->obj = NULL;
}
/* }}} */
/* {{{ Keys */
static void
_smart_cb_key_up(void *data,
Evas *_e EINA_UNUSED,
Evas_Object *_obj EINA_UNUSED,
void *event)
{
Evas_Event_Key_Up *ev = event;
Termio *sd = evas_object_smart_data_get(data);
EINA_SAFETY_ON_NULL_RETURN(sd);
keyin_handle_up(&sd->khdl, ev);
}
static void
_smart_cb_key_down(void *data,
Evas *_e EINA_UNUSED,
Evas_Object *_obj EINA_UNUSED,
void *event)
{
const Evas_Event_Key_Down *ev = event;
Termio *sd = evas_object_smart_data_get(data);
int ctrl, alt, shift, win, meta, hyper;
EINA_SAFETY_ON_NULL_RETURN(sd);
EINA_SAFETY_ON_NULL_RETURN(ev->key);
if (miniview_handle_key(term_miniview_get(sd->term), ev))
return;
if (term_has_popmedia(sd->term) && !strcmp(ev->key, "Escape"))
{
term_popmedia_close(sd->term);
return;
}
ctrl = evas_key_modifier_is_set(ev->modifiers, "Control");
alt = evas_key_modifier_is_set(ev->modifiers, "Alt");
shift = evas_key_modifier_is_set(ev->modifiers, "Shift");
win = evas_key_modifier_is_set(ev->modifiers, "Super");
meta = evas_key_modifier_is_set(ev->modifiers, "Meta") ||
evas_key_modifier_is_set(ev->modifiers, "AltGr") ||
evas_key_modifier_is_set(ev->modifiers, "ISO_Level3_Shift");
hyper = evas_key_modifier_is_set(ev->modifiers, "Hyper");
if (keyin_handle(&sd->khdl, sd->pty, ev, ctrl, alt, shift, win, meta, hyper))
goto end;
if (sd->jump_on_keypress)
{
if (!key_is_modifier(ev->key))
{
sd->scroll = 0;
_smart_update_queue(data, sd);
}
}
end:
if (sd->config->flicker_on_key)
edje_object_signal_emit(sd->cursor.obj, "key,down", "terminology");
}
/* }}} */
/* {{{ Selection */
@ -3493,28 +3428,25 @@ termio_event_feed_mouse_in(Evas_Object *obj)
evas_event_feed_mouse_in(e, 0, NULL);
}
static void
_imf_cursor_set(Termio *sd)
void
termio_imf_cursor_set(Evas_Object *obj, Ecore_IMF_Context *imf)
{
/* TODO */
Termio *sd = evas_object_smart_data_get(obj);
Evas_Coord cx, cy, cw, ch;
if (!imf)
return;
EINA_SAFETY_ON_NULL_RETURN(sd);
evas_object_geometry_get(sd->cursor.obj, &cx, &cy, &cw, &ch);
if (sd->khdl.imf)
ecore_imf_context_cursor_location_set(sd->khdl.imf, cx, cy, cw, ch);
if (sd->khdl.imf) ecore_imf_context_cursor_position_set
(sd->khdl.imf, (sd->cursor.y * sd->grid.w) + sd->cursor.x);
/*
ecore_imf_context_cursor_position_set(sd->imf, 0); // how to get it?
*/
ecore_imf_context_cursor_location_set(imf, cx, cy, cw, ch);
ecore_imf_context_cursor_position_set(imf, (sd->cursor.y * sd->grid.w) + sd->cursor.x);
}
static void
_smart_cb_focus_in(void *data,
Evas *_e EINA_UNUSED,
Evas_Object *_obj EINA_UNUSED,
void *_event EINA_UNUSED)
void
termio_focus_in(Evas_Object *termio)
{
Termio *sd = evas_object_smart_data_get(data);
Termio *sd = evas_object_smart_data_get(termio);
EINA_SAFETY_ON_NULL_RETURN(sd);
if (sd->config->disable_cursor_blink)
@ -3522,39 +3454,20 @@ _smart_cb_focus_in(void *data,
else
edje_object_signal_emit(sd->cursor.obj, "focus,in", "terminology");
if (!sd->win) return;
elm_win_keyboard_mode_set(sd->win, ELM_WIN_KEYBOARD_TERMINAL);
if (sd->khdl.imf)
{
ecore_imf_context_input_panel_show(sd->khdl.imf);
ecore_imf_context_reset(sd->khdl.imf);
ecore_imf_context_focus_in(sd->khdl.imf);
_imf_cursor_set(sd);
}
}
static void
_smart_cb_focus_out(void *data,
Evas *_e EINA_UNUSED,
Evas_Object *obj,
void *_event EINA_UNUSED)
void
termio_focus_out(Evas_Object *termio)
{
Termio *sd = evas_object_smart_data_get(data);
Termio *sd = evas_object_smart_data_get(termio);
EINA_SAFETY_ON_NULL_RETURN(sd);
if (!sd->config->disable_focus_visuals)
edje_object_signal_emit(sd->cursor.obj, "focus,out", "terminology");
if (!sd->win) return;
sd->pty->selection.last_click = 0;
elm_win_keyboard_mode_set(sd->win, ELM_WIN_KEYBOARD_OFF);
if (sd->khdl.imf)
{
ecore_imf_context_reset(sd->khdl.imf);
_imf_cursor_set(sd);
ecore_imf_context_focus_out(sd->khdl.imf);
ecore_imf_context_input_panel_hide(sd->khdl.imf);
}
if (!sd->ctxpopup)
_remove_links(sd, obj);
_remove_links(sd, termio);
term_unfocus(sd->term);
}
@ -4810,6 +4723,7 @@ _smart_apply(Evas_Object *obj)
Eina_List *l, *ln;
Termblock *blk;
int x, y, ch1 = 0, ch2 = 0, inv = 0, preedit_x = 0, preedit_y = 0;
const char *preedit_str;
ssize_t w;
EINA_SAFETY_ON_NULL_RETURN(sd);
@ -4996,7 +4910,9 @@ _smart_apply(Evas_Object *obj)
evas_object_textgrid_update_add(sd->grid.obj, ch1, y,
ch2 - ch1 + 1, 1);
}
if (sd->preedit_str && sd->preedit_str[0])
preedit_str = term_preedit_str_get(sd->term);
if (preedit_str && preedit_str[0])
{
Eina_Unicode *uni, g;
int len = 0, i, jump, xx, backx;
@ -5004,7 +4920,7 @@ _smart_apply(Evas_Object *obj)
Evas_Textgrid_Cell *tc;
x = sd->cursor.x, y = sd->cursor.y;
uni = eina_unicode_utf8_to_unicode(sd->preedit_str, &len);
uni = eina_unicode_utf8_to_unicode(preedit_str, &len);
if (uni)
{
for (i = 0; i < len; i++)
@ -5253,53 +5169,12 @@ _cursor_cb_move(void *data,
void *_event EINA_UNUSED)
{
Termio *sd = evas_object_smart_data_get(data);
Ecore_IMF_Context *imf;
EINA_SAFETY_ON_NULL_RETURN(sd);
_imf_cursor_set(sd);
}
static void
_imf_event_commit_cb(void *data,
Ecore_IMF_Context *_ctx EINA_UNUSED,
void *event)
{
Termio *sd = data;
char *str = event;
DBG("IMF committed '%s'", str);
if (!str) return;
termpty_write(sd->pty, str, strlen(str));
if (sd->preedit_str)
{
eina_stringshare_del(sd->preedit_str);
sd->preedit_str = NULL;
}
_smart_update_queue(sd->self, sd);
}
static void
_imf_event_delete_surrounding_cb(void *data,
Ecore_IMF_Context *_ctx EINA_UNUSED,
void *event)
{
Termio *sd = data;
Ecore_IMF_Event_Delete_Surrounding *ev = event;
DBG("IMF del surrounding %p %i %i", sd, ev->offset, ev->n_chars);
}
static void
_imf_event_preedit_changed_cb(void *data,
Ecore_IMF_Context *ctx,
void *_event EINA_UNUSED)
{
Termio *sd = data;
char *preedit_string;
int cursor_pos;
ecore_imf_context_preedit_string_get(ctx, &preedit_string, &cursor_pos);
if (!preedit_string) return;
DBG("IMF preedit str '%s'", preedit_string);
if (sd->preedit_str) eina_stringshare_del(sd->preedit_str);
sd->preedit_str = eina_stringshare_add(preedit_string);
_smart_update_queue(sd->self, sd);
free(preedit_string);
imf = term_imf_context_get(sd->term);
if (imf)
termio_imf_cursor_set(sd->self, imf);
}
@ -5371,68 +5246,8 @@ _smart_add(Evas_Object *obj)
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_WHEEL,
_smart_cb_mouse_wheel, obj);
evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_DOWN,
_smart_cb_key_down, obj);
evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_UP,
_smart_cb_key_up, obj);
evas_object_event_callback_add(obj, EVAS_CALLBACK_FOCUS_IN,
_smart_cb_focus_in, obj);
evas_object_event_callback_add(obj, EVAS_CALLBACK_FOCUS_OUT,
_smart_cb_focus_out, obj);
sd->link.suspend = 1;
if (ecore_imf_init())
{
const char *imf_id = ecore_imf_context_default_id_get();
Evas *e;
if (!imf_id) sd->khdl.imf = NULL;
else
{
const Ecore_IMF_Context_Info *imf_info;
imf_info = ecore_imf_context_info_by_id_get(imf_id);
if ((!imf_info->canvas_type) ||
(strcmp(imf_info->canvas_type, "evas") == 0))
sd->khdl.imf = ecore_imf_context_add(imf_id);
else
{
imf_id = ecore_imf_context_default_id_by_canvas_type_get("evas");
if (imf_id) sd->khdl.imf = ecore_imf_context_add(imf_id);
}
}
if (!sd->khdl.imf) goto imf_done;
e = evas_object_evas_get(o);
ecore_imf_context_client_window_set
(sd->khdl.imf, (void *)ecore_evas_window_get(ecore_evas_ecore_evas_get(e)));
ecore_imf_context_client_canvas_set(sd->khdl.imf, e);
ecore_imf_context_event_callback_add
(sd->khdl.imf, ECORE_IMF_CALLBACK_COMMIT, _imf_event_commit_cb, sd);
ecore_imf_context_event_callback_add
(sd->khdl.imf, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, _imf_event_delete_surrounding_cb, sd);
ecore_imf_context_event_callback_add
(sd->khdl.imf, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, _imf_event_preedit_changed_cb, sd);
/* make IMF usable by a terminal - no preedit, prediction... */
ecore_imf_context_prediction_allow_set
(sd->khdl.imf, EINA_FALSE);
ecore_imf_context_autocapital_type_set
(sd->khdl.imf, ECORE_IMF_AUTOCAPITAL_TYPE_NONE);
ecore_imf_context_input_panel_layout_set
(sd->khdl.imf, ECORE_IMF_INPUT_PANEL_LAYOUT_TERMINAL);
ecore_imf_context_input_mode_set
(sd->khdl.imf, ECORE_IMF_INPUT_MODE_FULL);
ecore_imf_context_input_panel_language_set
(sd->khdl.imf, ECORE_IMF_INPUT_PANEL_LANG_ALPHABET);
ecore_imf_context_input_panel_return_key_type_set
(sd->khdl.imf, ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT);
imf_done:
if (sd->khdl.imf) DBG("Ecore IMF Setup");
else WRN(_("Ecore IMF failed"));
}
terms = eina_list_append(terms, obj);
}
@ -5445,12 +5260,6 @@ _smart_del(Evas_Object *obj)
EINA_SAFETY_ON_NULL_RETURN(sd);
terms = eina_list_remove(terms, obj);
if (sd->khdl.imf)
{
ecore_imf_context_event_callback_del
(sd->khdl.imf, ECORE_IMF_CALLBACK_COMMIT, _imf_event_commit_cb);
ecore_imf_context_del(sd->khdl.imf);
}
if (sd->cursor.obj) evas_object_del(sd->cursor.obj);
if (sd->event)
{
@ -5470,17 +5279,6 @@ _smart_del(Evas_Object *obj)
evas_object_del(sd->event);
sd->event = NULL;
}
if (sd->self)
{
evas_object_event_callback_del(sd->self, EVAS_CALLBACK_KEY_DOWN,
_smart_cb_key_down);
evas_object_event_callback_del(sd->self, EVAS_CALLBACK_KEY_UP,
_smart_cb_key_up);
evas_object_event_callback_del(sd->self, EVAS_CALLBACK_FOCUS_IN,
_smart_cb_focus_in);
evas_object_event_callback_del(sd->self, EVAS_CALLBACK_FOCUS_OUT,
_smart_cb_focus_out);
}
if (sd->sel.top) evas_object_del(sd->sel.top);
if (sd->sel.bottom) evas_object_del(sd->sel.bottom);
if (sd->sel.theme) evas_object_del(sd->sel.theme);
@ -5517,13 +5315,10 @@ _smart_del(Evas_Object *obj)
}
sd->sendfile.active = EINA_FALSE;
}
keyin_compose_seq_reset(&sd->khdl);
if (sd->sel_str) eina_stringshare_del(sd->sel_str);
if (sd->preedit_str) eina_stringshare_del(sd->preedit_str);
if (sd->sel_reset_job) ecore_job_del(sd->sel_reset_job);
EINA_LIST_FREE(sd->cur_chids, chid) eina_stringshare_del(chid);
sd->sel_str = NULL;
sd->preedit_str = NULL;
sd->sel_reset_job = NULL;
sd->link.down.dndobj = NULL;
sd->cursor.obj = NULL;
@ -5535,10 +5330,8 @@ _smart_del(Evas_Object *obj)
sd->delayed_size_timer = NULL;
sd->font.name = NULL;
sd->pty = NULL;
sd->khdl.imf = NULL;
sd->win = NULL;
sd->glayer = NULL;
ecore_imf_shutdown();
_parent_sc.del(obj);
}
@ -5682,17 +5475,6 @@ _smart_pty_exited(void *data)
evas_object_del(sd->event);
sd->event = NULL;
}
if (sd->self)
{
evas_object_event_callback_del(sd->self, EVAS_CALLBACK_KEY_DOWN,
_smart_cb_key_down);
evas_object_event_callback_del(sd->self, EVAS_CALLBACK_KEY_UP,
_smart_cb_key_up);
evas_object_event_callback_del(sd->self, EVAS_CALLBACK_FOCUS_IN,
_smart_cb_focus_in);
evas_object_event_callback_del(sd->self, EVAS_CALLBACK_FOCUS_OUT,
_smart_cb_focus_out);
}
term_close(sd->win, sd->self, EINA_TRUE);
}
@ -6305,3 +6087,22 @@ termio_add(Evas_Object *win, Config *config,
_smart_size(obj, w, h, EINA_FALSE);
return obj;
}
void
termio_key_down(Evas_Object *termio,
const Evas_Event_Key_Down *ev)
{
Termio *sd = evas_object_smart_data_get(termio);
EINA_SAFETY_ON_NULL_RETURN(sd);
if (sd->jump_on_keypress)
{
if (!key_is_modifier(ev->key))
{
sd->scroll = 0;
_smart_update_queue(termio, sd);
}
}
if (sd->config->flicker_on_key)
edje_object_signal_emit(sd->cursor.obj, "key,down", "terminology");
}

View File

@ -49,8 +49,15 @@ Eina_Bool termio_file_send_ok(const Evas_Object *obj, const char *file);
void termio_file_send_cancel(const Evas_Object *obj);
double termio_file_send_progress_get(const Evas_Object *obj);
void
termio_imf_cursor_set(Evas_Object *obj, Ecore_IMF_Context *imf);
Termpty *termio_pty_get(const Evas_Object *obj);
Evas_Object * termio_miniview_get(const Evas_Object *obj);
Term* termio_term_get(const Evas_Object *obj);
void termio_key_down(Evas_Object *termio, const Evas_Event_Key_Down *ev);
void termio_focus_in(Evas_Object *termio);
void termio_focus_out(Evas_Object *termio);
#endif

View File

@ -1,10 +1,14 @@
#include "private.h"
#include <Elementary.h>
#include <Ecore_Input.h>
#include <Ecore_IMF.h>
#include <Ecore_IMF_Evas.h>
#include "termpty.h"
#include "termptyesc.h"
#include "termptyops.h"
#include "termptysave.h"
#include "termio.h"
#include "keyin.h"
#include <sys/types.h>
#include <signal.h>
#include <sys/wait.h>
@ -54,6 +58,26 @@ termpty_shutdown(void)
_termpty_log_dom = -1;
}
Eina_Bool
termpty_can_handle_key(const Termpty *ty,
const Keys_Handler *khdl,
const Evas_Event_Key_Down *ev)
{
// if term app asked for kbd lock - dont handle here
if (ty->termstate.kbd_lock)
return EINA_FALSE;
// if app asked us to not do autorepeat - ignore press if is it is the same
// timestamp as last one
if ((ty->termstate.no_autorepeat) &&
(ev->timestamp == khdl->last_keyup))
return EINA_FALSE;
return EINA_TRUE;
}
void
termpty_handle_buf(Termpty *ty, const Eina_Unicode *codepoints, int len)
{

File diff suppressed because it is too large Load Diff

View File

@ -47,6 +47,11 @@ Config *win_config_get(const Win *wn);
void win_term_swallow(Win *wn, Term *term);
void win_add_split(Win *wn, Term *term);
void win_sizing_handle(Win *wn);
void win_toggle_visible_group(Win *wn);
void win_toggle_all_group(Win *wn);
Eina_Bool win_is_group_action_handled(Win *wn);
Eina_Bool win_is_group_input(Win *wn);
void term_ref(Term *term);
void term_unref(Term *term);
@ -61,6 +66,13 @@ void term_down(Term *term);
void term_left(Term *term);
void term_right(Term *term);
const char *
term_preedit_str_get(Term *term);
Ecore_IMF_Context *
term_imf_context_get(Term *term);
Eina_Bool term_is_visible(Term *term);
void win_font_size_set(Win *wn, int new_size);
void win_font_update(Term *term);