aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBoris Faure <boris@fau.re>2016-06-10 03:31:10 +0200
committerBoris Faure <boris@fau.re>2016-06-10 03:31:10 +0200
commit37e92063307effe8682998a62ad4e8a69b74bb10 (patch)
treee1c47c6104115e4167aac9a88f6f7fb442c7c4ee
parentminiview: add checks on termio_pty_get(). Closes CID1356203 and CID1356204 (diff)
downloadterminology-37e92063307effe8682998a62ad4e8a69b74bb10.tar.gz
options_keys: use an edje layout
-rw-r--r--data/themes/default.edc31
-rw-r--r--src/bin/options_keys.c71
2 files changed, 66 insertions, 36 deletions
diff --git a/data/themes/default.edc b/data/themes/default.edc
index 7b5cc26..5bc66e4 100644
--- a/data/themes/default.edc
+++ b/data/themes/default.edc
@@ -7,6 +7,36 @@ color_classes {
collections {
+ group { name: "terminology/keybinding";
+ parts {
+ part { name: "shadow"; type: RECT;
+ description { state: "default" 0.0;
+ color: 0 0 0 196;
+ }
+ }
+ part { name: "label"; type: TEXT;
+ mouse_events: 0;
+ effect: SOFT_SHADOW BOTTOM;
+ scale: 1;
+ description { state: "default" 0.0;
+ fixed: 1 1;
+ rel1.to: "shadow";
+ rel2.to: "shadow";
+ rel1.relative: 0.5 0.5;
+ rel1.offset: 0 0;
+ rel2.relative: 0.5 0.5;
+ rel2.offset: 0 0;
+ color: 255 255 255 255;
+ color3: 0 0 0 18;
+ align: 0.5 0.5;
+ text { font: "Sans"; size: 12;
+ min: 1 1;
+ ellipsis: 0;
+ }
+ }
+ }
+ };
+ };
group { name: "terminology/miniview";
images {
image: "icon_close.png" COMP;
@@ -1110,7 +1140,6 @@ collections {
part { name: "tabtitle"; type: TEXT; mouse_events: 0;
scale: 1;
effect: SOFT_SHADOW BOTTOM;
- mouse_events: 0;
description { state: "default" 0.0;
color: 255 255 255 255;
color3: 0 0 0 18;
diff --git a/src/bin/options_keys.c b/src/bin/options_keys.c
index b70035f..d74089c 100644
--- a/src/bin/options_keys.c
+++ b/src/bin/options_keys.c
@@ -10,7 +10,7 @@
/*XXX: can have only one widget at a timeā€¦ */
static Config *_config;
static Evas_Object *_fr;
-static Evas_Object *_rect, *_bg, *_lbl;
+static Evas_Object *_layout;
static void _hover_del(Evas_Object *o);
@@ -154,22 +154,10 @@ _hover_sizing_eval(void)
Evas_Coord x = 0, y = 0, w = 0, h = 0, min_w, min_h, new_x, new_y;
evas_object_geometry_get(_fr, &x, &y, &w, &h);
#if (ECORE_VERSION_MAJOR > 1) || (ECORE_VERSION_MINOR >= 8)
- evas_object_geometry_set(_rect, x, y, w, h);
+ evas_object_geometry_set(_layout, x, y, w, h);
#else
- evas_object_move(_rect, x, y);
- evas_object_resize(_rect, w, h);
-#endif
- evas_object_size_hint_min_get(_lbl, &min_w, &min_h);
- new_x = x + w/2 - min_w/2;
- new_y = y + h/2 - min_h/2;
-#if (ECORE_VERSION_MAJOR > 1) || (ECORE_VERSION_MINOR >= 8)
- evas_object_geometry_set(_lbl, new_x, new_y, min_w, min_h);
- evas_object_geometry_set(_bg, new_x - 1, new_y - 1, min_w + 2, min_h + 2);
-#else
- evas_object_move(_lbl, new_x, new_y);
- evas_object_resize(_lbl, min_w, min_h);
- evas_object_move(_bg, new_x - 1, new_y - 1);
- evas_object_resize(_bg, min_w + 2, min_h + 2);
+ evas_object_move(_layout, x, y);
+ evas_object_resize(_layout, w, h);
#endif
}
@@ -210,7 +198,6 @@ _parent_del_cb(void *data,
static void
_hover_del(Evas_Object *o)
{
- elm_object_focus_set(o, EINA_FALSE);
evas_object_event_callback_del(o, EVAS_CALLBACK_KEY_UP,
_cb_key_up);
evas_object_event_callback_del(o, EVAS_CALLBACK_MOUSE_DOWN,
@@ -223,35 +210,49 @@ _hover_del(Evas_Object *o)
_parent_hide_cb);
evas_object_event_callback_del(_fr, EVAS_CALLBACK_DEL,
_parent_del_cb);
- evas_object_del(_bg);
- _bg = NULL;
- evas_object_del(_lbl);
- _lbl = NULL;
evas_object_del(o);
- _rect = NULL;
+ _layout = NULL;
+}
+
+static void
+_cb_focused(void *data EINA_UNUSED,
+ Evas_Object *obj EINA_UNUSED,
+ void *event EINA_UNUSED)
+{
+ 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);
}
static void
on_shortcut_add(void *data,
- Evas_Object *obj,
+ Evas_Object *bt,
void *event_info EINA_UNUSED)
{
- Evas_Object *o, *bx;
-
- bx = data;
+ Evas_Object *o, *oe;
+ Evas_Object *bx = data;
- _rect = o = evas_object_rectangle_add(evas_object_evas_get(obj));
- evas_object_repeat_events_set(o, EINA_TRUE);
- evas_object_color_set(o, 0, 0, 0, 127);
- elm_object_focus_set(o, EINA_TRUE);
+ _layout = o = elm_layout_add(bt);
+ oe = elm_layout_edje_get(o);
+ theme_apply(oe, _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);
- _bg = elm_bg_add(_fr);
- _lbl = elm_label_add(_fr);
- elm_layout_text_set(_lbl, NULL, _("Please press key sequence"));
_hover_sizing_eval();
- evas_object_show(_bg);
- evas_object_show(_lbl);
evas_object_event_callback_add(o, EVAS_CALLBACK_KEY_UP,
_cb_key_up, bx);