Compare commits

...

1 Commits

Author SHA1 Message Date
José Roberto de Souza 3119354fd2 Allow user to set the title of the each tab 7 years ago
  1. 12
      src/bin/controls.c
  2. 16
      src/bin/termio.c
  3. 1
      src/bin/termio.h
  4. 1
      src/bin/termpty.c
  5. 2
      src/bin/termpty.h
  6. 3
      src/bin/termptyesc.c
  7. 54
      src/bin/win.c
  8. 1
      src/bin/win.h

@ -91,6 +91,12 @@ _cb_ct_miniview(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *even
term_miniview_toggle(termio_term_get(ct_term));
}
static void
_cb_ct_set_title(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
{
term_set_title(termio_term_get(ct_term));
}
static void
_cb_ct_close(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
{
@ -277,6 +283,12 @@ controls_toggle(Evas_Object *win, Evas_Object *bg, Evas_Object *term,
o = _button_add(win, _("Miniview"), "mini-view", _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", "mini-view", _cb_ct_set_title, NULL);
elm_box_pack_end(ct_box, o);
o = _sep_add_v(win);
elm_box_pack_end(ct_boxh, o);

@ -348,9 +348,25 @@ termio_title_get(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;
}
void
termio_user_title_set(Evas_Object *obj, const char *title)
{
Termio *sd = evas_object_smart_data_get(obj);
EINA_SAFETY_ON_NULL_RETURN(sd);
if (sd->pty->prop.user_title)
eina_stringshare_del(sd->pty->prop.user_title);
sd->pty->prop.user_title = eina_stringshare_add(title);
if (sd->pty->cb.set_title.func)
sd->pty->cb.set_title.func(sd->pty->cb.set_title.data);
}
const char *
termio_icon_name_get(Evas_Object *obj)
{

@ -35,6 +35,7 @@ Eina_Bool termio_cwd_get(const Evas_Object *obj, char *buf, size_t size);
Evas_Object *termio_textgrid_get(Evas_Object *obj);
Evas_Object *termio_win_get(Evas_Object *obj);
const char *termio_title_get(Evas_Object *obj);
void termio_user_title_set(Evas_Object *obj, const char *title);
const char *termio_icon_name_get(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);

@ -603,6 +603,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)
{

@ -85,7 +85,7 @@ struct _Termpty
} change, set_title, set_icon, cancel_sel, exited, bell, command;
} cb;
struct {
const char *title, *icon;
const char *title, *icon, *user_title;
} prop;
const char *cur_cmd;
Termcell *screen, *screen2;

@ -1326,7 +1326,8 @@ _handle_esc_xterm(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
ty->prop.title = NULL;
ty->prop.icon = NULL;
}
if (ty->cb.set_title.func) ty->cb.set_title.func(ty->cb.set_title.data);
if (ty->cb.set_title.func && !ty->prop.user_title)
ty->cb.set_title.func(ty->cb.set_title.data);
if (ty->cb.set_icon.func) ty->cb.set_icon.func(ty->cb.set_icon.data);
}
break;

@ -3208,6 +3208,60 @@ term_miniview_toggle(Term *term)
}
}
static void
_set_title_ok_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
Evas_Object *popup = data;
Term *term = evas_object_data_get(popup, "term");
Evas_Object *entry = elm_object_content_get(popup);
const char *title = elm_entry_entry_get(entry);
if (!strlen(title))
title = NULL;
termio_user_title_set(term->termio, title);
evas_object_del(popup);
}
static void
_set_title_cancel_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
evas_object_del(data);
}
void
term_set_title(Term *term)
{
Evas_Object *o;
Evas_Object *popup;
EINA_SAFETY_ON_NULL_RETURN(term);
popup = elm_popup_add(term->wn->win);
evas_object_data_set(popup, "term", term);
elm_object_part_text_set(popup, "title,text", "Set title:");
o = elm_button_add(popup);
evas_object_smart_callback_add(o, "clicked", _set_title_ok_cb, popup);
elm_object_text_set(o, "OK");
elm_object_part_content_set(popup, "button1", o);
o = elm_button_add(popup);
evas_object_smart_callback_add(o, "clicked", _set_title_cancel_cb, popup);
elm_object_text_set(o, "Cancel");
elm_object_part_content_set(popup, "button2", o);
o = elm_entry_add(popup);
elm_entry_single_line_set(o, EINA_TRUE);
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);
evas_object_show(o);
elm_object_focus_set(o, EINA_TRUE);
evas_object_show(popup);
}
static void
_popmedia_queue_process(Term *term)
{

@ -14,6 +14,7 @@ void term_unfocus(Term *term);
Evas_Object *term_termio_get(Term *term);
Evas_Object *term_miniview_get(Term *term);
void term_miniview_toggle(Term *term);
void term_set_title(Term *term);
void term_miniview_hide(Term *term);
Eina_Bool term_tab_go(Term *term, int tnum);

Loading…
Cancel
Save