summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <marcel-hollerbach@t-online.de>2017-07-30 19:12:29 +0200
committerMarcel Hollerbach <marcel-hollerbach@t-online.de>2017-07-30 19:12:29 +0200
commit8ace8acd997ec608ea01e454ea722b4fe84fec71 (patch)
tree8cb174542472aa6b4356637a3426b30a71d8c459
parent8227547eb637bb38d6af59e08599a9909a6ac71b (diff)
presentator: display on active zone
-rw-r--r--src/e_mod_main.c87
1 files changed, 54 insertions, 33 deletions
diff --git a/src/e_mod_main.c b/src/e_mod_main.c
index 3ad961e..3c58fa8 100644
--- a/src/e_mod_main.c
+++ b/src/e_mod_main.c
@@ -7,16 +7,14 @@ E_API E_Module_Api e_modapi =
7 "Presentator helper tool" 7 "Presentator helper tool"
8}; 8};
9 9
10static Evas_Object *notify, *bx; 10static Evas_Object *notify, *lb;
11static Eina_Hash *string_hash; 11static Eina_Hash *string_hash;
12static int entry_counter = 0;
13static Ecore_Event_Handler *event_data, *event_error; 12static Ecore_Event_Handler *event_data, *event_error;
14static Ecore_Exe *keylogger; 13static Ecore_Exe *keylogger;
15 14
16typedef struct { 15typedef struct {
17 unsigned int ref; 16 unsigned int ref;
18 char *name; 17 char *name;
19 Evas_Object *vis;
20 Ecore_Timer *timer; 18 Ecore_Timer *timer;
21} Entry; 19} Entry;
22 20
@@ -32,6 +30,48 @@ _timed_del(void *data)
32} 30}
33 31
34static void 32static void
33_update_place(void)
34{
35 E_Zone *zone = e_zone_current_get();
36 Eina_Rectangle geom, notify_geom;
37 Evas_Coord minw = -1, minh = -1;
38 Edje_Object *edje;
39 Eina_Strbuf *buf;
40 Entry *e;
41
42 Eina_Iterator* iter = eina_hash_iterator_data_new(string_hash);
43
44 buf = eina_strbuf_new();
45
46 EINA_ITERATOR_FOREACH(iter, e)
47 {
48 if (!!eina_strbuf_length_get(buf))
49 eina_strbuf_append(buf, " + ");
50 eina_strbuf_append(buf, e->name);
51 }
52
53 if (!eina_strbuf_length_get(buf))
54 evas_object_hide(notify);
55 else
56 evas_object_show(notify);
57
58 elm_object_text_set(lb, eina_strbuf_string_get(buf));
59
60 eina_strbuf_free(buf);
61
62 edje = elm_layout_edje_get(notify);
63 edje_object_size_min_calc(edje, &minw, &minh);
64
65 e_zone_useful_geometry_get(zone, &geom.x, &geom.y, &geom.w, &geom.h);
66 notify_geom.x = (geom.w - minw) /2;
67 notify_geom.y = geom.h - minh;
68 notify_geom.w = minw;
69 notify_geom.h = minh;
70
71 evas_object_geometry_set(notify, EINA_RECTANGLE_ARGS(&notify_geom));
72}
73
74static void
35_del_key(const char *name) 75_del_key(const char *name)
36{ 76{
37 Entry *e = eina_hash_find(string_hash, name); 77 Entry *e = eina_hash_find(string_hash, name);
@@ -58,19 +98,14 @@ _del_key(const char *name)
58 98
59 //if ref is 0 nuke out that entry 99 //if ref is 0 nuke out that entry
60 eina_hash_del_by_key(string_hash, name); 100 eina_hash_del_by_key(string_hash, name);
61 entry_counter --;
62 //we need to update the notify visuals depending on the state of the box 101 //we need to update the notify visuals depending on the state of the box
63 if (entry_counter <= 0) 102 _update_place();
64 evas_object_hide(notify);
65 } 103 }
66} 104}
67 105
68static void 106static void
69_add_key(const char *name) 107_add_key(const char *name)
70{ 108{
71 Eina_Strbuf *buf;
72 Evas_Object *o;
73
74 Entry *e = eina_hash_find(string_hash, name); 109 Entry *e = eina_hash_find(string_hash, name);
75 110
76 //first if we have already displayed that string do not display it again 111 //first if we have already displayed that string do not display it again
@@ -81,33 +116,19 @@ _add_key(const char *name)
81 return; 116 return;
82 } 117 }
83 118
84 //find a considerable text to display
85 buf = eina_strbuf_new();
86 if (entry_counter == 0)
87 eina_strbuf_append_printf(buf, "%s", name);
88 else
89 eina_strbuf_append_printf(buf, " + %s", name);
90
91 //create a label and attach to the box
92 o = elm_label_add(bx);
93 elm_object_text_set(o, eina_strbuf_string_get(buf));
94 evas_object_show(o);
95 elm_box_pack_end(bx, o);
96 evas_object_show(notify);
97
98 //save as entry somewhere 119 //save as entry somewhere
99 e = calloc(1, sizeof(Entry)); 120 e = calloc(1, sizeof(Entry));
100 e->ref = 2; //one for beeing used and one for the minimum time 121 e->ref = 2; //one for beeing used and one for the minimum time
101 e->vis = o;
102 e->name = strdup(name); 122 e->name = strdup(name);
103 entry_counter ++;
104 eina_hash_add(string_hash, name, e); 123 eina_hash_add(string_hash, name, e);
124
125 //update the place here
126 _update_place();
105} 127}
106 128
107static void 129static void
108_entry_free(Entry *e) 130_entry_free(Entry *e)
109{ 131{
110 evas_object_del(e->vis);
111 free(e->name); 132 free(e->name);
112 free(e); 133 free(e);
113} 134}
@@ -146,20 +167,20 @@ _msg_from_child_handler_error(void *data EINA_UNUSED, int type EINA_UNUSED, void
146 return ECORE_CALLBACK_PASS_ON; 167 return ECORE_CALLBACK_PASS_ON;
147} 168}
148 169
170
149static void 171static void
150_start_logging(void) 172_start_logging(void)
151{ 173{
152 string_hash = eina_hash_string_small_new((Eina_Free_Cb)_entry_free); 174 string_hash = eina_hash_string_small_new((Eina_Free_Cb)_entry_free);
153 175
154 notify = elm_notify_add(e_comp->elm); 176 notify = elm_layout_add(e_comp->elm);
155 elm_notify_allow_events_set(notify, EINA_TRUE); 177 elm_layout_theme_set(notify, "notify", "bottom", "default");
156 evas_object_layer_set(notify, E_LAYER_POPUP); 178 evas_object_layer_set(notify, E_LAYER_POPUP);
157 elm_notify_align_set(notify, 0.5, 1.0); 179 evas_object_pass_events_set(notify, EINA_TRUE);
158 180
159 bx = elm_box_add(notify); 181 lb = elm_label_add(notify);
160 elm_box_horizontal_set(bx, EINA_TRUE); 182 elm_object_content_set(notify, lb);
161 elm_object_content_set(notify, bx); 183 evas_object_show(lb);
162 evas_object_show(bx);
163 184
164 /* FIXME this is only on x11 need a different solution for wl */ 185 /* FIXME this is only on x11 need a different solution for wl */
165 { 186 {