Bring back the user title per tab

Summary: T6719

Reviewers: billiob

Reviewed By: billiob

Differential Revision: https://phab.enlightenment.org/D5852
This commit is contained in:
Boris Faure 2018-04-22 17:27:14 +02:00
parent 2b1ccdfbd7
commit 7c6d581465
5 changed files with 38 additions and 9 deletions

View File

@ -369,25 +369,38 @@ termio_title_get(const Evas_Object *obj)
{
Termio *sd = evas_object_smart_data_get(obj);
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, NULL);
if (sd->pty->prop.user_title)
return sd->pty->prop.user_title;
return sd->pty->prop.title;
}
const char *
termio_user_title_get(const Evas_Object *obj)
{
Termio *sd = evas_object_smart_data_get(obj);
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, NULL);
return sd->pty->prop.user_title;
}
void
termio_title_set(Evas_Object *obj, const char *title)
termio_user_title_set(Evas_Object *obj, const char *title)
{
Termio *sd = evas_object_smart_data_get(obj);
size_t len = 0;
EINA_SAFETY_ON_NULL_RETURN(sd);
if (sd->pty->prop.title)
eina_stringshare_del(sd->pty->prop.title);
if (sd->pty->prop.user_title)
{
eina_stringshare_del(sd->pty->prop.user_title);
sd->pty->prop.user_title = NULL;
}
if (title)
len = strlen(title);
if (len)
{
sd->pty->prop.title = eina_stringshare_add_length(title, len);
len = strlen(title);
}
if (len)
sd->pty->prop.user_title = eina_stringshare_add_length(title, len);
if (sd->pty->cb.set_title.func)
sd->pty->cb.set_title.func(sd->pty->cb.set_title.data);
}

View File

@ -39,7 +39,8 @@ Eina_Bool termio_cwd_get(const Evas_Object *obj, char *buf, size_t size);
Evas_Object *termio_textgrid_get(const Evas_Object *obj);
Evas_Object *termio_win_get(const Evas_Object *obj);
const char *termio_title_get(const Evas_Object *obj);
void termio_title_set(Evas_Object *obj, const char *title);
const char *termio_user_title_get(const Evas_Object *obj);
void termio_user_title_set(Evas_Object *obj, const char *title);
const char *termio_icon_name_get(const Evas_Object *obj);
void termio_media_mute_set(Evas_Object *obj, Eina_Bool mute);
void termio_media_visualize_set(Evas_Object *obj, Eina_Bool visualize);

View File

@ -800,6 +800,7 @@ termpty_free(Termpty *ty)
if (ty->hand_exe_exit) ecore_event_handler_del(ty->hand_exe_exit);
if (ty->hand_fd) ecore_main_fd_handler_del(ty->hand_fd);
if (ty->prop.title) eina_stringshare_del(ty->prop.title);
if (ty->prop.user_title) eina_stringshare_del(ty->prop.user_title);
if (ty->prop.icon) eina_stringshare_del(ty->prop.icon);
if (ty->back)
{

View File

@ -87,7 +87,13 @@ struct _Termpty
} change, set_title, set_icon, cancel_sel, exited, bell, command;
} cb;
struct {
const char *title, *icon;
const char *icon;
/* dynamic title set by xterm, keep it in case user don't want a
* title any more by setting a empty title
*/
const char *title;
/* set by user */
const char *user_title;
} prop;
const char *cur_cmd;
Termcell *screen, *screen2;

View File

@ -4278,7 +4278,7 @@ _set_title_ok_cb(void *data,
if (!title || !strlen(title))
title = NULL;
termio_title_set(term->termio, title);
termio_user_title_set(term->termio, title);
elm_object_focus_set(entry, EINA_FALSE);
elm_popup_dismiss(popup);
}
@ -4315,6 +4315,7 @@ term_set_title(Term *term)
Evas_Object *o;
Evas_Object *popup;
Term_Container *tc = term->container;
const char *prev_title;
EINA_SAFETY_ON_NULL_RETURN(term);
term->wn->on_popover++;
@ -4341,6 +4342,13 @@ term_set_title(Term *term)
o = elm_entry_add(popup);
elm_entry_single_line_set(o, EINA_TRUE);
elm_entry_editable_set(o, EINA_TRUE);
prev_title = termio_user_title_get(term->termio);
if (prev_title)
{
elm_entry_entry_set(o, prev_title);
elm_entry_cursor_pos_set(o, strlen(prev_title));
}
evas_object_smart_callback_add(o, "activated", _set_title_ok_cb, popup);
evas_object_smart_callback_add(o, "aborted", _set_title_cancel_cb, popup);
elm_object_content_set(popup, o);