summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Roberto de Souza <jose.souza@intel.com>2016-03-02 11:37:02 -0300
committerJosé Roberto de Souza <jose.souza@intel.com>2016-03-02 17:48:41 -0300
commit3119354fd2cd44c7dfb13bdf6d9199a8e3d8f138 (patch)
tree358896bbed5e5eb8144105ee87941d7b2a6695e7
parentc4f7d0a18cfa19e6126be076351efcfdd886e23a (diff)
Allow user to set the title of the each tabdevs/zehortigoza/user-title
-rw-r--r--src/bin/controls.c12
-rw-r--r--src/bin/termio.c16
-rw-r--r--src/bin/termio.h1
-rw-r--r--src/bin/termpty.c1
-rw-r--r--src/bin/termpty.h2
-rw-r--r--src/bin/termptyesc.c3
-rw-r--r--src/bin/win.c54
-rw-r--r--src/bin/win.h1
8 files changed, 88 insertions, 2 deletions
diff --git a/src/bin/controls.c b/src/bin/controls.c
index d75041a..29af255 100644
--- a/src/bin/controls.c
+++ b/src/bin/controls.c
@@ -92,6 +92,12 @@ _cb_ct_miniview(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *even
92} 92}
93 93
94static void 94static void
95_cb_ct_set_title(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
96{
97 term_set_title(termio_term_get(ct_term));
98}
99
100static void
95_cb_ct_close(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED) 101_cb_ct_close(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
96{ 102{
97 term_close(ct_win, ct_term, EINA_FALSE); 103 term_close(ct_win, ct_term, EINA_FALSE);
@@ -277,6 +283,12 @@ controls_toggle(Evas_Object *win, Evas_Object *bg, Evas_Object *term,
277 o = _button_add(win, _("Miniview"), "mini-view", _cb_ct_miniview, NULL); 283 o = _button_add(win, _("Miniview"), "mini-view", _cb_ct_miniview, NULL);
278 elm_box_pack_end(ct_box, o); 284 elm_box_pack_end(ct_box, o);
279 285
286 o = _sep_add_h(win);
287 elm_box_pack_end(ct_box, o);
288
289 o = _button_add(win, "Set title", "mini-view", _cb_ct_set_title, NULL);
290 elm_box_pack_end(ct_box, o);
291
280 o = _sep_add_v(win); 292 o = _sep_add_v(win);
281 elm_box_pack_end(ct_boxh, o); 293 elm_box_pack_end(ct_boxh, o);
282 294
diff --git a/src/bin/termio.c b/src/bin/termio.c
index 20d5759..2d3a941 100644
--- a/src/bin/termio.c
+++ b/src/bin/termio.c
@@ -348,9 +348,25 @@ termio_title_get(Evas_Object *obj)
348{ 348{
349 Termio *sd = evas_object_smart_data_get(obj); 349 Termio *sd = evas_object_smart_data_get(obj);
350 EINA_SAFETY_ON_NULL_RETURN_VAL(sd, NULL); 350 EINA_SAFETY_ON_NULL_RETURN_VAL(sd, NULL);
351 if (sd->pty->prop.user_title)
352 return sd->pty->prop.user_title;
351 return sd->pty->prop.title; 353 return sd->pty->prop.title;
352} 354}
353 355
356void
357termio_user_title_set(Evas_Object *obj, const char *title)
358{
359 Termio *sd = evas_object_smart_data_get(obj);
360 EINA_SAFETY_ON_NULL_RETURN(sd);
361
362 if (sd->pty->prop.user_title)
363 eina_stringshare_del(sd->pty->prop.user_title);
364
365 sd->pty->prop.user_title = eina_stringshare_add(title);
366 if (sd->pty->cb.set_title.func)
367 sd->pty->cb.set_title.func(sd->pty->cb.set_title.data);
368}
369
354const char * 370const char *
355termio_icon_name_get(Evas_Object *obj) 371termio_icon_name_get(Evas_Object *obj)
356{ 372{
diff --git a/src/bin/termio.h b/src/bin/termio.h
index e4d8df6..3b660e9 100644
--- a/src/bin/termio.h
+++ b/src/bin/termio.h
@@ -35,6 +35,7 @@ Eina_Bool termio_cwd_get(const Evas_Object *obj, char *buf, size_t size);
35Evas_Object *termio_textgrid_get(Evas_Object *obj); 35Evas_Object *termio_textgrid_get(Evas_Object *obj);
36Evas_Object *termio_win_get(Evas_Object *obj); 36Evas_Object *termio_win_get(Evas_Object *obj);
37const char *termio_title_get(Evas_Object *obj); 37const char *termio_title_get(Evas_Object *obj);
38void termio_user_title_set(Evas_Object *obj, const char *title);
38const char *termio_icon_name_get(Evas_Object *obj); 39const char *termio_icon_name_get(Evas_Object *obj);
39void termio_media_mute_set(Evas_Object *obj, Eina_Bool mute); 40void termio_media_mute_set(Evas_Object *obj, Eina_Bool mute);
40void termio_media_visualize_set(Evas_Object *obj, Eina_Bool visualize); 41void termio_media_visualize_set(Evas_Object *obj, Eina_Bool visualize);
diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index 612c0e9..d9373ae 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -603,6 +603,7 @@ termpty_free(Termpty *ty)
603 if (ty->hand_exe_exit) ecore_event_handler_del(ty->hand_exe_exit); 603 if (ty->hand_exe_exit) ecore_event_handler_del(ty->hand_exe_exit);
604 if (ty->hand_fd) ecore_main_fd_handler_del(ty->hand_fd); 604 if (ty->hand_fd) ecore_main_fd_handler_del(ty->hand_fd);
605 if (ty->prop.title) eina_stringshare_del(ty->prop.title); 605 if (ty->prop.title) eina_stringshare_del(ty->prop.title);
606 if (ty->prop.user_title) eina_stringshare_del(ty->prop.user_title);
606 if (ty->prop.icon) eina_stringshare_del(ty->prop.icon); 607 if (ty->prop.icon) eina_stringshare_del(ty->prop.icon);
607 if (ty->back) 608 if (ty->back)
608 { 609 {
diff --git a/src/bin/termpty.h b/src/bin/termpty.h
index e841245..ac1f553 100644
--- a/src/bin/termpty.h
+++ b/src/bin/termpty.h
@@ -85,7 +85,7 @@ struct _Termpty
85 } change, set_title, set_icon, cancel_sel, exited, bell, command; 85 } change, set_title, set_icon, cancel_sel, exited, bell, command;
86 } cb; 86 } cb;
87 struct { 87 struct {
88 const char *title, *icon; 88 const char *title, *icon, *user_title;
89 } prop; 89 } prop;
90 const char *cur_cmd; 90 const char *cur_cmd;
91 Termcell *screen, *screen2; 91 Termcell *screen, *screen2;
diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index 3b0552f..0daeda4 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -1326,7 +1326,8 @@ _handle_esc_xterm(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
1326 ty->prop.title = NULL; 1326 ty->prop.title = NULL;
1327 ty->prop.icon = NULL; 1327 ty->prop.icon = NULL;
1328 } 1328 }
1329 if (ty->cb.set_title.func) ty->cb.set_title.func(ty->cb.set_title.data); 1329 if (ty->cb.set_title.func && !ty->prop.user_title)
1330 ty->cb.set_title.func(ty->cb.set_title.data);
1330 if (ty->cb.set_icon.func) ty->cb.set_icon.func(ty->cb.set_icon.data); 1331 if (ty->cb.set_icon.func) ty->cb.set_icon.func(ty->cb.set_icon.data);
1331 } 1332 }
1332 break; 1333 break;
diff --git a/src/bin/win.c b/src/bin/win.c
index 143984e..91ba310 100644
--- a/src/bin/win.c
+++ b/src/bin/win.c
@@ -3209,6 +3209,60 @@ term_miniview_toggle(Term *term)
3209} 3209}
3210 3210
3211static void 3211static void
3212_set_title_ok_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
3213{
3214 Evas_Object *popup = data;
3215 Term *term = evas_object_data_get(popup, "term");
3216 Evas_Object *entry = elm_object_content_get(popup);
3217 const char *title = elm_entry_entry_get(entry);
3218
3219 if (!strlen(title))
3220 title = NULL;
3221
3222 termio_user_title_set(term->termio, title);
3223 evas_object_del(popup);
3224}
3225
3226static void
3227_set_title_cancel_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
3228{
3229 evas_object_del(data);
3230}
3231
3232void
3233term_set_title(Term *term)
3234{
3235 Evas_Object *o;
3236 Evas_Object *popup;
3237
3238 EINA_SAFETY_ON_NULL_RETURN(term);
3239
3240 popup = elm_popup_add(term->wn->win);
3241 evas_object_data_set(popup, "term", term);
3242 elm_object_part_text_set(popup, "title,text", "Set title:");
3243
3244 o = elm_button_add(popup);
3245 evas_object_smart_callback_add(o, "clicked", _set_title_ok_cb, popup);
3246 elm_object_text_set(o, "OK");
3247 elm_object_part_content_set(popup, "button1", o);
3248
3249 o = elm_button_add(popup);
3250 evas_object_smart_callback_add(o, "clicked", _set_title_cancel_cb, popup);
3251 elm_object_text_set(o, "Cancel");
3252 elm_object_part_content_set(popup, "button2", o);
3253
3254 o = elm_entry_add(popup);
3255 elm_entry_single_line_set(o, EINA_TRUE);
3256 evas_object_smart_callback_add(o, "activated", _set_title_ok_cb, popup);
3257 evas_object_smart_callback_add(o, "aborted", _set_title_cancel_cb, popup);
3258 elm_object_content_set(popup, o);
3259 evas_object_show(o);
3260 elm_object_focus_set(o, EINA_TRUE);
3261
3262 evas_object_show(popup);
3263}
3264
3265static void
3212_popmedia_queue_process(Term *term) 3266_popmedia_queue_process(Term *term)
3213{ 3267{
3214 const char *src; 3268 const char *src;
diff --git a/src/bin/win.h b/src/bin/win.h
index 62c3c4b..9c5a91e 100644
--- a/src/bin/win.h
+++ b/src/bin/win.h
@@ -14,6 +14,7 @@ void term_unfocus(Term *term);
14Evas_Object *term_termio_get(Term *term); 14Evas_Object *term_termio_get(Term *term);
15Evas_Object *term_miniview_get(Term *term); 15Evas_Object *term_miniview_get(Term *term);
16void term_miniview_toggle(Term *term); 16void term_miniview_toggle(Term *term);
17void term_set_title(Term *term);
17void term_miniview_hide(Term *term); 18void term_miniview_hide(Term *term);
18Eina_Bool term_tab_go(Term *term, int tnum); 19Eina_Bool term_tab_go(Term *term, int tnum);
19 20