refactor win.c to use the Term_Container abstraction

terminology-0.9
Boris Faure 8 years ago
parent be62d87f89
commit 2228945f2c
  1. 4
      src/bin/controls.c
  2. 19
      src/bin/main.c
  3. 84
      src/bin/sel.c
  4. 5
      src/bin/sel.h
  5. 61
      src/bin/term_container.h
  6. 3441
      src/bin/win.c
  7. 4
      src/bin/win.h

@ -76,13 +76,13 @@ _cb_ct_new(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EIN
static void
_cb_ct_split_v(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
{
main_split_v(ct_win, ct_term, NULL);
split_vertically(ct_win, ct_term, NULL);
}
static void
_cb_ct_split_h(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
{
main_split_h(ct_win, ct_term, NULL);
split_horizontally(ct_win, ct_term, NULL);
}
static void

@ -291,12 +291,9 @@ main_ipc_new(Ipc_Instance *inst)
free(nargv);
return;
}
else
{
win_term_swallow(wn, term);
}
win_add_split(wn, term);
if (win_term_set(wn, term) < 0)
return;
main_trans_update(config);
main_media_update(config);
@ -866,13 +863,13 @@ remote:
retval = EXIT_FAILURE;
goto end;
}
else
if (win_term_set(wn, term) < 0)
{
win_term_swallow(wn, term);
retval = EXIT_FAILURE;
goto end;
}
win_add_split(wn, term);
main_trans_update(config);
main_media_update(config);
win_sizing_handle(wn);
@ -890,14 +887,14 @@ remote:
if (startup_split[i] == 'v')
{
pch = eina_list_nth(cmds_list, 1);
main_split_v(win_evas_object_get(term_win_get(next)),
split_vertically(win_evas_object_get(term_win_get(next)),
main_term_evas_object_get(next), pch);
cmds_list = eina_list_remove(cmds_list, pch);
}
else if (startup_split[i] == 'h')
{
pch = eina_list_nth(cmds_list, 1);
main_split_h(win_evas_object_get(term_win_get(next)),
split_horizontally(win_evas_object_get(term_win_get(next)),
main_term_evas_object_get(next), pch);
cmds_list = eina_list_remove(cmds_list, pch);
}

@ -6,7 +6,7 @@
#include "sel.h"
#include "config.h"
#include "utils.h"
#include "termio.h"
#include "term_container.h"
typedef struct _Sel Sel;
typedef struct _Entry Entry;
@ -41,7 +41,8 @@ struct _Sel
struct _Entry
{
Evas_Object *obj, *bg, *termio;
Evas_Object *obj, *bg;
Term_Container *tc;
unsigned char selected : 1;
unsigned char selected_before : 1;
unsigned char selected_orig : 1;
@ -476,39 +477,40 @@ _label_redo(Entry *en)
{
const char *s;
if (!en->obj) return;
if (!en->termio) return;
s = termio_title_get(en->termio);
if (!s) s = termio_icon_name_get(en->termio);
if (s) edje_object_part_text_set(en->bg, "terminology.label", s);
if (!en->obj || !en->tc)
return;
s = en->tc->title;
if (!s)
s = "Terminology";
edje_object_part_text_set(en->bg, "terminology.label", s);
}
static void
_title_cb(void *data, Evas_Object *obj EINA_UNUSED, void *info EINA_UNUSED)
void
sel_entry_title_set(void *entry, const char *title)
{
_label_redo(data);
}
Entry *en = entry;
static void
_icon_cb(void *data, Evas_Object *obj EINA_UNUSED, void *info EINA_UNUSED)
{
_label_redo(data);
edje_object_part_text_set(en->bg, "terminology.label", title);
}
static void
_bell_cb(void *data, Evas_Object *obj EINA_UNUSED, void *info EINA_UNUSED)
void
sel_entry_close(void *data)
{
Entry *en = data;
edje_object_signal_emit(en->bg, "bell", "terminology");
en->tc = NULL;
}
static void
_entry_termio_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *info EINA_UNUSED)
void
sel_entry_update(void *data)
{
Entry *en = data;
if (en->termio) evas_object_event_callback_del_full
(en->termio, EVAS_CALLBACK_DEL, _entry_termio_del_cb, en);
en->termio = NULL;
en->tc = evas_object_data_get(en->obj, "tc");
if (en->tc)
{
_label_redo(en);
}
}
static void
@ -518,10 +520,9 @@ _entry_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, voi
if (en->obj) evas_object_event_callback_del_full
(en->obj, EVAS_CALLBACK_DEL, _entry_del_cb, en);
en->obj = NULL;
/*
if (en->termio)
{
evas_object_event_callback_del_full(en->termio, EVAS_CALLBACK_DEL,
_entry_termio_del_cb, en);
evas_object_smart_callback_del_full(en->termio, "title,change",
_title_cb, en);
evas_object_smart_callback_del_full(en->termio, "icon,change",
@ -530,6 +531,7 @@ _entry_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, voi
_bell_cb, en);
en->termio = NULL;
}
*/
}
static void
@ -562,17 +564,6 @@ _smart_del(Evas_Object *obj)
if (sd->autozoom_timeout) ecore_timer_del(sd->autozoom_timeout);
EINA_LIST_FREE(sd->items, en)
{
if (en->termio)
{
evas_object_event_callback_del_full(en->termio, EVAS_CALLBACK_DEL,
_entry_termio_del_cb, en);
evas_object_smart_callback_del_full(en->termio, "title,change",
_title_cb, en);
evas_object_smart_callback_del_full(en->termio, "icon,change",
_icon_cb, en);
evas_object_smart_callback_del_full(en->termio, "bell",
_bell_cb, en);
}
if (en->obj) evas_object_event_callback_del_full
(en->obj, EVAS_CALLBACK_DEL, _entry_del_cb, en);
if (en->obj) evas_object_del(en->obj);
@ -669,12 +660,13 @@ sel_add(Evas_Object *parent)
return obj;
}
void
sel_entry_add(Evas_Object *obj, Evas_Object *entry, Eina_Bool selected, Eina_Bool bell, Config *config)
void *
sel_entry_add(Evas_Object *obj, Evas_Object *entry,
Eina_Bool selected, Eina_Bool bell, Config *config)
{
Sel *sd = evas_object_smart_data_get(obj);
Entry *en = calloc(1, sizeof(Entry));
if (!en) return;
if (!en) return NULL;
sd->items = eina_list_append(sd->items, en);
sd->config = config;
en->obj = entry;
@ -703,21 +695,15 @@ sel_entry_add(Evas_Object *obj, Evas_Object *entry, Eina_Bool selected, Eina_Boo
edje_object_message_signal_process(en->bg);
}
sd->interp = 1.0;
en->termio = evas_object_data_get(en->obj, "termio");
if (en->termio)
en->tc = evas_object_data_get(en->obj, "tc");
if (en->tc)
{
evas_object_smart_callback_add(en->termio, "title,change",
_title_cb, en);
evas_object_smart_callback_add(en->termio, "icon,change",
_icon_cb, en);
evas_object_smart_callback_add(en->termio, "bell",
_bell_cb, en);
_label_redo(en);
evas_object_event_callback_add(en->termio, EVAS_CALLBACK_DEL,
_entry_termio_del_cb, en);
}
evas_object_event_callback_add(en->obj, EVAS_CALLBACK_DEL,
_entry_del_cb, en);
return en;
}
void

@ -4,7 +4,10 @@
#include "config.h"
Evas_Object *sel_add(Evas_Object *parent);
void sel_entry_add(Evas_Object *obj, Evas_Object *entry, Eina_Bool selected, Eina_Bool bell, Config *config);
void *sel_entry_add(Evas_Object *obj, Evas_Object *entry, Eina_Bool selected, Eina_Bool bell, Config *config);
void sel_entry_title_set(void *entry, const char *title);
void sel_entry_close(void *entry);
void sel_entry_update(void *entry);
void sel_go(Evas_Object *obj);
void sel_entry_selected_set(Evas_Object *obj, Evas_Object *entry, Eina_Bool keep_before);
void sel_zoom(Evas_Object *obj, double zoom);

@ -0,0 +1,61 @@
#ifndef _TERM_CONTAINER_H__
#define _TERM_CONTAINER_H__ 1
typedef struct _Term_Container Term_Container;
typedef struct _Term Term;
typedef struct _Win Win;
typedef struct _Sizeinfo Sizeinfo;
struct _Sizeinfo
{
int min_w;
int min_h;
int step_x;
int step_y;
int req_w;
int req_h;
int bg_min_w;
int bg_min_h;
int req;
};
typedef enum _Term_Container_Type
{
TERM_CONTAINER_TYPE_UNKNOWN,
TERM_CONTAINER_TYPE_SOLO,
TERM_CONTAINER_TYPE_SPLIT,
TERM_CONTAINER_TYPE_TABS,
TERM_CONTAINER_TYPE_WIN
} Term_Container_Type;
struct _Term_Container {
Term_Container_Type type;
Term_Container *parent;
Win *wn;
Evas_Object *selector_img;
Eina_Bool is_focused;
const char *title;
Term *(*term_next)(Term_Container *tc, Term_Container *child);
Term *(*term_prev)(Term_Container *tc, Term_Container *child);
Term *(*term_first)(Term_Container *tc);
Term *(*term_last)(Term_Container *tc);
Term *(*focused_term_get)(Term_Container *tc);
Evas_Object* (*get_evas_object)(Term_Container *container);
Term *(*find_term_at_coords)(Term_Container *container,
Evas_Coord mx, Evas_Coord my);
void (*split)(Term_Container *tc, Term_Container *child,
const char *cmd, Eina_Bool is_horizontal);
void (*size_eval)(Term_Container *container, Sizeinfo *info);
void (*swallow)(Term_Container *container, Term_Container *orig,
Term_Container *new_child);
void (*focus)(Term_Container *tc, Term_Container *relative);
void (*unfocus)(Term_Container *tc, Term_Container *relative);
void (*set_title)(Term_Container *tc, Term_Container *child, const char *title);
void (*bell)(Term_Container *tc, Term_Container *child);
void (*close)(Term_Container *container, Term_Container *child);
void (*update)(Term_Container *tc);
};
#endif

File diff suppressed because it is too large Load Diff

@ -16,6 +16,9 @@ Evas_Object *term_miniview_get(Term *term);
void term_miniview_toggle(Term *term);
void term_miniview_hide(Term *term);
void split_horizontally(Evas_Object *win, Evas_Object *term, const char *cmd);
void split_vertically(Evas_Object *win, Evas_Object *term, const char *cmd);
Win *
win_new(const char *name, const char *role, const char *title,
@ -28,6 +31,7 @@ void windows_free(void);
void windows_update(void);
Term *term_new(Win *wn, Config *config, const char *cmd, Eina_Bool login_shell, const char *cd, int size_w, int size_h, Eina_Bool hold);
int win_term_set(Win *wn, Term *term);
Eina_List *
terms_from_win_object(Evas_Object *win);

Loading…
Cancel
Save