iconbar code.. and some work i was doing on click to focus... having a


			
			
				devs/princeamd/enlightenment-0.17-elive
			
			
		
Carsten Haitzler 21 years ago
parent c89e94b735
commit c8e0c7f7be
  1. 3
      src/Makefile.am
  2. 1
      src/background.c
  3. 50
      src/border.c
  4. 58
      src/config.c
  5. 36
      src/config.h
  6. 2
      src/guides.c
  7. 588
      src/iconbar.c
  8. 113
      src/iconbar.h
  9. 7
      src/main.c
  10. 14
      src/view.c
  11. 14
      src/view.h

@ -48,6 +48,7 @@ enlightenment_SOURCES = \
text.h text.c \
util.h util.c \
view.h view.c \
e.h
e.h \
iconbar.c
enlightenment_LDADD = @evas_libs@ @edb_libs@ @ebits_libs@ @ecore_libs@ @efsd_libs@ @ferite_libs@ -lm -lc $(INTLLIBS)

@ -147,6 +147,7 @@ e_background_realize(E_Background *bg, Evas evas)
bg->geom.w = 0;
bg->geom.h = 0;
e_background_set_size(bg, ww, hh);
}
void

@ -405,7 +405,7 @@ e_focus_in(Eevent * ev)
E_Border *b;
b = e_border_find_by_window(e->win);
if (b)
if ((b) && (b->win.client == e->win))
{
b->current.selected = 1;
e_border_focus_grab_ended();
@ -428,19 +428,17 @@ e_focus_out(Eevent * ev)
E_Border *b;
b = e_border_find_by_window(e->win);
if (b)
if ((b) && (b->win.client == e->win))
{
/* char *settings_db; */
/* E_DB_File *db; */
int focus_mode;
/* char buf[PATH_MAX]; */
E_CFG_INT(cfg_focus_mode, "settings", "/focus/mode", 0);
E_CONFIG_INT_GET(cfg_focus_mode, focus_mode);
b->current.selected = 0;
if (e->key_grab) b->current.select_lost_from_grab = 1;
if (e->key_grab) b->current.select_lost_from_grab = 1;
/* settings - click to focus would affect grabs */
if (!b->current.selected)
if ((e->key_grab) &&
(!b->current.selected))
{
if (focus_mode == 2) /* click to focus */
{
@ -449,12 +447,14 @@ e_focus_out(Eevent * ev)
g = NEW(E_Grab, 1);
ZERO(g, E_Grab, 1);
g->button = 0;
g->mods = 0;
g->mods = EV_KEY_MODIFIER_NONE;
g->any_mod = 1;
g->remove_after = 1;
b->grabs = evas_list_append(b->grabs, g);
printf("grab me baaaybe %s\n", b->client.title);
e_button_grab(b->win.main, 0,
XEV_BUTTON | XEV_MOUSE_MOVE, EV_KEY_MODIFIER_NONE, 1);
XEV_BUTTON_PRESS, EV_KEY_MODIFIER_NONE, 1);
e_window_button_grab_auto_replay_set(b->win.main, 1);
}
}
b->changed = 1;
@ -908,10 +908,16 @@ e_cb_border_mouse_in(E_Border *b, Eevent *e)
{
int x, y;
char *class = "Window_Grab";
int focus_mode;
E_CFG_INT(cfg_focus_mode, "settings", "/focus/mode", 0);
if (border_mouse_buttons) return;
E_CONFIG_INT_GET(cfg_focus_mode, focus_mode);
/* pointer focus stuff */
if (b->client.takes_focus) e_focus_to_window(b->win.client);
if (focus_mode == 0)
{
if (b->client.takes_focus) e_focus_to_window(b->win.client);
}
border_mouse_x = mouse_x;
border_mouse_y = mouse_y;
@ -957,8 +963,11 @@ e_cb_border_mouse_down(E_Border *b, Eevent *e)
{
int x, y, bt;
char *class = "Window_Grab";
int focus_mode;
E_CFG_INT(cfg_focus_mode, "settings", "/focus/mode", 0);
e_pointer_grab(b->win.main, CurrentTime);
E_CONFIG_INT_GET(cfg_focus_mode, focus_mode);
/* e_pointer_grab(b->win.main, CurrentTime);*/
border_mouse_x = mouse_x;
border_mouse_y = mouse_y;
if (border_mouse_buttons) return;
@ -977,15 +986,19 @@ e_cb_border_mouse_down(E_Border *b, Eevent *e)
g = l->data;
/* find a grab that triggered this */
if ((((Ev_Mouse_Down *)(e->event))->button == g->button) &&
if (((((Ev_Mouse_Down *)(e->event))->button == g->button) ||
(g->button == 0)) &&
((g->any_mod) ||
(((Ev_Mouse_Down *)(e->event))->mods == g->mods)))
{
if (g->allow)
e_pointer_replay(((Ev_Mouse_Down *)(e->event))->time);
if (g->remove_after)
{
if (focus_mode == 2)
e_focus_to_window(b->win.client);
printf("ungrab %s\n", b->client.title);
e_button_ungrab(b->win.main, g->button, g->mods, g->any_mod);
e_window_button_grab_auto_replay_set(b->win.main, 0);
/* e_pointer_ungrab(((Ev_Mouse_Up *)(e->event))->time);*/
free(g);
b->grabs = evas_list_remove(b->grabs, g);
goto again;
@ -1588,6 +1601,7 @@ e_border_remove_mouse_grabs(E_Border *b)
E_Grab *g;
g = l->data;
printf("nooo grabs\n");
e_button_ungrab(b->win.main, g->button, g->mods, g->any_mod);
FREE(g);
}
@ -1618,11 +1632,13 @@ e_border_attach_mouse_grabs(E_Border *b)
g = NEW(E_Grab, 1);
ZERO(g, E_Grab, 1);
g->button = 0;
g->mods = 0;
g->mods = EV_KEY_MODIFIER_NONE;
g->any_mod = 1;
g->remove_after = 1;
b->grabs = evas_list_append(b->grabs, g);
e_button_grab(b->win.main, 0, XEV_BUTTON | XEV_MOUSE_MOVE, EV_KEY_MODIFIER_NONE, 1);
printf("grab me baaaybe %s\n", b->client.title);
e_button_grab(b->win.main, 0, XEV_BUTTON_PRESS, EV_KEY_MODIFIER_NONE, 1);
e_window_button_grab_auto_replay_set(b->win.main, 1);
}
}
@ -1664,7 +1680,7 @@ e_border_attach_mouse_grabs(E_Border *b)
g->any_mod = any_mod;
g->remove_after = 0;
b->grabs = evas_list_append(b->grabs, g);
e_button_grab(b->win.main, button, XEV_BUTTON | XEV_MOUSE_MOVE, mods, 0);
e_button_grab(b->win.main, button, XEV_BUTTON_PRESS, mods, 0);
}
}
e_db_close(db);

@ -150,18 +150,26 @@ e_config_user_dir(void)
void
e_config_type_add_node(E_Config_Base_Type *base, char *prefix,
E_Config_Datatype type, E_Config_Base_Type *list_type,
int offset)
int offset,
int def_int,
float def_float,
char *def_str)
{
E_Config_Node *cfg_node;
cfg_node = NEW(E_Config_Node, 1);
ZERO(cfg_node, E_Config_Node, 1);
cfg_node->prefix = strdup(prefix);
cfg_node->type = type;
cfg_node->sub_type = list_type;
cfg_node->offset = offset;
cfg_node->prefix = strdup(prefix);
cfg_node->type = type;
cfg_node->sub_type = list_type;
cfg_node->offset = offset;
cfg_node->def_int = def_int;
cfg_node->def_float = def_float;
if (cfg_node->def_str)
{
e_strdup(cfg_node->def_str, def_str);
}
base->nodes = evas_list_append(base->nodes, cfg_node);
}
@ -202,17 +210,21 @@ e_config_load(char *file, char *prefix, E_Config_Base_Type *type)
val = 0;
sprintf(buf, "%s/%s", prefix, node->prefix);
e_db_int_get(db, buf, &val);
(*((int *)(&(data[node->offset])))) = val;
if (e_db_int_get(db, buf, &val))
(*((int *)(&(data[node->offset])))) = val;
else
(*((int *)(&(data[node->offset])))) = node->def_int;
}
break;
case E_CFG_TYPE_STR:
{
char * val;
char *val;
sprintf(buf, "%s/%s", prefix, node->prefix);
val = e_db_str_get(db, buf);
(*((char **)(&(data[node->offset])))) = val;
if ((val = e_db_str_get(db, buf)))
(*((char **)(&(data[node->offset])))) = val;
else
e_strdup((*((char **)(&(data[node->offset])))), node->def_str);
}
break;
case E_CFG_TYPE_FLOAT:
@ -221,8 +233,10 @@ e_config_load(char *file, char *prefix, E_Config_Base_Type *type)
val = 0;
sprintf(buf, "%s/%s", prefix, node->prefix);
e_db_float_get(db, buf, &val);
(*((float *)(&(data[node->offset])))) = val;
if (e_db_float_get(db, buf, &val))
(*((float *)(&(data[node->offset])))) = val;
else
(*((float *)(&(data[node->offset])))) = node->def_float;
}
break;
case E_CFG_TYPE_LIST:
@ -253,6 +267,7 @@ e_config_load(char *file, char *prefix, E_Config_Base_Type *type)
return data;
}
#if 0
typedef struct _list_base List_Base;
typedef struct _list_element List_Element;
@ -271,26 +286,31 @@ struct _list_element
/* eg: */
void ts(void)
{
{
/* define the different config types and structs to the config engine */
E_Config_Base_Type *cf_list;
E_Config_Base_Type *cf_element;
cf_element = e_config_type_new();
E_CONFIG_NODE(cf_element, "name", E_CFG_TYPE_STR, NULL, List_Element, name);
E_CONFIG_NODE(cf_element, "size", E_CFG_TYPE_INT, NULL, List_Element, size);
E_CONFIG_NODE(cf_element, "perc", E_CFG_TYPE_FLOAT, NULL, List_Element, perc);
E_CONFIG_NODE(cf_element, "name", E_CFG_TYPE_STR, NULL, List_Element, name, 0, 0, "DEFAULT_NAME");
E_CONFIG_NODE(cf_element, "size", E_CFG_TYPE_INT, NULL, List_Element, size, 777, 0, NULL);
E_CONFIG_NODE(cf_element, "perc", E_CFG_TYPE_FLOAT, NULL, List_Element, perc, 0, 3.1415, NULL);
cf_list = e_config_type_new();
E_CONFIG_NODE(cf_list, "list", E_CFG_TYPE_LIST, cf_element, List_Base, elements);
E_CONFIG_NODE(cf_list, "list", E_CFG_TYPE_LIST, cf_element, List_Base, elements, 0, 0, NULL);
/* now test it */
{
List_Base *cfg_data;
/* load the base data type from the base of the test db file */
cfg_data = e_config_load("test.db", "", cf_list);
/* no data file? */
if (!cfg_data)
{
printf("no load!\n");
}
/* got data */
else
{
Evas_List l;

@ -153,8 +153,9 @@ void e_config_set_user_dir(char *dir);
char *e_config_user_dir(void);
typedef struct _e_config_base_type E_Config_Base_Type;
typedef struct _e_config_node E_Config_Node;
typedef enum _e_config_datatype E_Config_Datatype;
typedef struct _e_config_node E_Config_Node;
typedef struct _e_config_value E_Config_Value;
typedef enum _e_config_datatype E_Config_Datatype;
enum _e_config_datatype
{
@ -176,9 +177,12 @@ struct _e_config_node
E_Config_Datatype type;
int offset;
E_Config_Base_Type *sub_type;
int def_int;
float def_float;
char *def_str;
};
#define E_CONFIG_NODE(var, prefix, type, sub, struct_type, struct_member) \
#define E_CONFIG_NODE(var, prefix, type, sub, struct_type, struct_member, def_int, def_float, def_str) \
{ \
struct_type _cfg_dummy; \
char *_cfg_p1, *_cfg_p2; \
@ -188,14 +192,30 @@ struct _e_config_node
_cfg_p2 = (char *)(&(_cfg_dummy.struct_member)); \
_cfg_offset = (int)(_cfg_p2 - _cfg_p1); \
\
e_config_type_add_node(var, prefix, type, sub, _cfg_offset); \
e_config_type_add_node(var, prefix, type, sub, _cfg_offset, def_int, def_float, def_str); \
var->size = sizeof(struct_type); \
}
E_Config_Value *e_config_value_get_int(E_Config_Value *handle, char *file,
char *prefix, char *key,
int *val_ret, int default_val);
E_Config_Value *e_config_value_get_str(E_Config_Value *handle, char *file,
char *prefix, char *key,
char **val_ret, char *default_val);
E_Config_Value *e_config_value_get_float(E_Config_Value *handle, char *file,
char *prefix, char *key,
float *val_ret, float default_val);
E_Config_Base_Type *e_config_type_new(void);
void e_config_type_add_node(E_Config_Base_Type *base, char *prefix,
E_Config_Datatype type, E_Config_Base_Type *list_type,
int offset);
void *e_config_load(char *file, char *prefix, E_Config_Base_Type *type);
void e_config_type_add_node(E_Config_Base_Type *base,
char *prefix,
E_Config_Datatype type,
E_Config_Base_Type *list_type,
int offset,
int def_int,
float def_float,
char *def_str);
void *e_config_load(char *file,
char *prefix,
E_Config_Base_Type *type);
#endif

@ -568,7 +568,7 @@ void e_guides_init(void)
guides.current.display.loc = E_GUIDES_DISPLAY_LOCATION_SCREEN_MIDDLE;
guides.current.display.text = NULL;
guides.current.display.icon = NULL;
guides.current.display.icon = NULL;
guides.current.display.align.x = 0.5;
guides.current.display.align.y = 0.5;
guides.current.x = 0;

@ -0,0 +1,588 @@
#include "iconbar.h"
static void e_idle(void *);
static Evas_List iconbars;
E_Iconbar *
e_ib_new(E_View *v)
{
/* vertical lines (left, center, right) and title */
// Evas_Object ovl, ovc, ovr, ot;
E_Iconbar *ib;
ib = NEW(E_Iconbar, 1);
ZERO(ib, E_Iconbar, 1);
OBJ_INIT(ib, e_ib_free);
printf("in ib_new()\n");
ib->v = v;
ib->e = v->evas;
// ib->name = strdup(v->dir);
//e_ib_draw(ib);
iconbars = evas_list_append(iconbars, ib);
if(e_ib_config(ib) == 0) return NULL;
return ib;
}
void
e_ib_realize(E_Iconbar *ib)
{
printf("in e_ib_realize()\n");
if(ib->geom.conf.left < 0)
ib->geom.left = ib->geom.conf.left + ib->v->size.w;
if(ib->geom.conf.top < 0)
ib->geom.top = ib->geom.conf.top + ib->v->size.h;
if(ib->geom.conf.w == 0)
ib->geom.w = ib->v->size.w;
if(ib->geom.conf.h == 0)
ib->geom.h = ib->v->size.h;
printf("w: %i, h: %i\nt: %i, l: %i\n", ib->geom.w, ib->geom.h, ib->geom.top, ib->geom.left);
/* horizontal */
if (ib->geom.horizontal)
{
ib->obj.scroll = evas_add_rectangle(ib->e);
ib->obj.line_l = evas_add_image_from_file(ib->e, ib->image.hline);
ib->obj.line_c = evas_add_image_from_file(ib->e, ib->image.hline);
ib->obj.line_r = evas_add_image_from_file(ib->e, ib->image.hline);
ib->obj.title = evas_add_image_from_file(ib->e, ib->image.title);
ib->obj.clip = evas_add_rectangle(ib->e);
evas_get_image_size(ib->e, ib->obj.title, &ib->geom.title_w, &ib->geom.title_h);
evas_get_image_size(ib->e, ib->obj.line_l, &ib->geom.line_w, &ib->geom.line_h);
evas_set_layer(ib->e, ib->obj.scroll, 400);
evas_resize(ib->e, ib->obj.scroll, ib->geom.w, ib->geom.scroll_w);
evas_resize(ib->e, ib->obj.line_l, ib->geom.w, ib->geom.line_h);
evas_resize(ib->e, ib->obj.line_c, ib->geom.w, ib->geom.line_h);
evas_resize(ib->e, ib->obj.line_r, ib->geom.w, ib->geom.line_h);
evas_resize(ib->e, ib->obj.clip, ib->geom.w, ib->geom.h);
evas_set_image_fill(ib->e, ib->obj.line_l, 0, 0, ib->geom.line_w, ib->geom.line_h);
evas_set_image_fill(ib->e, ib->obj.line_c, 0, 0, ib->geom.line_w, ib->geom.line_h);
evas_set_image_fill(ib->e, ib->obj.line_r, 0, 0, ib->geom.line_w, ib->geom.line_h);
evas_move(ib->e, ib->obj.scroll, ib->geom.left, ib->geom.top + ib->geom.h - ib->geom.scroll_w);
evas_move(ib->e, ib->obj.line_l, ib->geom.left, ib->geom.top);
evas_move(ib->e, ib->obj.line_c, ib->geom.left, ib->geom.top + ib->geom.h - ib->geom.scroll_w);
evas_move(ib->e, ib->obj.line_r, ib->geom.left, ib->geom.top + ib->geom.h);
evas_move(ib->e, ib->obj.title, ib->geom.left - ib->geom.title_w - 5, ib->geom.top + (ib->geom.h - ib->geom.title_h) / 2);
evas_move(ib->e, ib->obj.clip, ib->geom.left, ib->geom.top);
evas_set_color(ib->e, ib->obj.scroll, 129, 129, 129, 0);
evas_set_color(ib->e, ib->obj.clip, 255, 255, 255, 255);
}
/* vertical */
if (!ib->geom.horizontal)
{
ib->obj.scroll = evas_add_rectangle(ib->e);
ib->obj.line_l = evas_add_image_from_file(ib->e, ib->image.vline);
ib->obj.line_c = evas_add_image_from_file(ib->e, ib->image.vline);
ib->obj.line_r = evas_add_image_from_file(ib->e, ib->image.vline);
ib->obj.title = evas_add_image_from_file(ib->e, ib->image.title);
ib->obj.clip = evas_add_rectangle(ib->e);
evas_get_image_size(ib->e, ib->obj.title, &ib->geom.title_w, &ib->geom.title_h);
evas_get_image_size(ib->e, ib->obj.line_l, &ib->geom.line_w, &ib->geom.line_h);
evas_set_layer(ib->e, ib->obj.scroll, 400);
evas_resize(ib->e, ib->obj.scroll, ib->geom.scroll_w, ib->geom.h);
evas_resize(ib->e, ib->obj.line_l, ib->geom.line_w, ib->geom.h);
evas_resize(ib->e, ib->obj.line_c, ib->geom.line_w, ib->geom.h);
evas_resize(ib->e, ib->obj.line_r, ib->geom.line_w, ib->geom.h);
evas_resize(ib->e, ib->obj.clip, ib->geom.w, ib->geom.h);
evas_set_image_fill(ib->e, ib->obj.line_l, 0, 0, ib->geom.line_w, ib->geom.line_h);
evas_set_image_fill(ib->e, ib->obj.line_c, 0, 0, ib->geom.line_w, ib->geom.line_h);
evas_set_image_fill(ib->e, ib->obj.line_r, 0, 0, ib->geom.line_w, ib->geom.line_h);
evas_move(ib->e, ib->obj.scroll, ib->geom.left + ib->geom.w - ib->geom.scroll_w, ib->geom.top);
evas_move(ib->e, ib->obj.line_l, ib->geom.left, ib->geom.top);
evas_move(ib->e, ib->obj.line_c, ib->geom.left + ib->geom.w - ib->geom.scroll_w, ib->geom.top);
evas_move(ib->e, ib->obj.line_r, ib->geom.left + ib->geom.w, ib->geom.top);
evas_move(ib->e, ib->obj.title, ib->geom.left + ((ib->geom.w - ib->geom.title_w - ib->geom.scroll_w) / 2 ), ib->geom.top - ib->geom.title_h - 5);
evas_move(ib->e, ib->obj.clip, ib->geom.left, ib->geom.top);
evas_set_color(ib->e, ib->obj.scroll, 129, 129, 129, 0);
evas_set_color(ib->e, ib->obj.clip, 255, 255, 255, 255);
}
/* Clip icons */
{
Evas_List l;
for (l = ib->icons; l; l = l->next)
{
E_IB_Icon *i;
i = l->data;
evas_set_clip(ib->e, i->image, ib->obj.clip);
}
}
/* show the iconbar */
evas_show(ib->e, ib->obj.scroll);
evas_show(ib->e, ib->obj.line_l);
evas_show(ib->e, ib->obj.line_c);
evas_show(ib->e, ib->obj.line_r);
evas_show(ib->e, ib->obj.title);
evas_show(ib->e, ib->obj.clip);
evas_callback_add(ib->e, ib->obj.scroll, CALLBACK_MOUSE_MOVE, s_mouse_move, ib);
evas_callback_add(ib->e, ib->obj.scroll, CALLBACK_MOUSE_IN, s_mouse_in, ib);
evas_callback_add(ib->e, ib->obj.scroll, CALLBACK_MOUSE_OUT, s_mouse_out, ib);
e_ib_fix_icons(ib);
printf("realized!\n");
}
E_IB_Icon *
e_ib_new_icon(E_Iconbar *ib, char *image, char *exec)
{
E_IB_Icon *i;
// printf("before addimage\n");
i = NEW(E_IB_Icon, 1);
i->image = evas_add_image_from_file(ib->e, image);
i->exec = strdup(exec);
evas_get_image_size(ib->e, i->image, &(i->w), &(i->h));
if (ib->geom.horizontal)
{
i->x = 0;
i->y = (ib->geom.h - i->h - ib->geom.scroll_w) / 2 + ib->geom.top;
}
else
{
i->x = (ib->geom.w - i->w - ib->geom.scroll_w) / 2 + ib->geom.left;
i->y = 0;
}
printf("x: %f, y: %f\n", i->x, i->y);
evas_callback_add(ib->e, i->image, CALLBACK_MOUSE_IN, i_mouse_in, NULL);
evas_callback_add(ib->e, i->image, CALLBACK_MOUSE_OUT, i_mouse_out, NULL);
evas_callback_add(ib->e, i->image, CALLBACK_MOUSE_DOWN, i_mouse_down, i->exec);
evas_set_color(ib->e, i->image, 255, 255, 255, 128);
evas_set_layer(ib->e, i->image, 400);
//evas_set_clip(ib->e, i->image, ib->obj.clip);
//printf("before ib->icons set\n");
ib->icons = evas_list_append(ib->icons, i);
//printf("after set\n");
return i;
}
int
e_ib_config(E_Iconbar *ib)
{
E_DB_File *db;
char buf[4096], *userdir;
// userdir = e_config_user_dir();
// sprintf(buf, "%sbehavior/iconbar.db", userdir);
sprintf(buf, "%s/.e_iconbar.db", ib->v->dir);
ib->db = strdup(buf);
db = e_db_open_read(ib->db);
if(!db)
{
/*// ib->no_show = 1;
db = e_db_open(ib->db);
e_db_int_set(db, "/ib/num", 0);
e_db_int_set(db, "/ib/geom/w", 75);
e_db_int_set(db, "/ib/geom/h", 620);
e_db_int_set(db, "/ib/geom/top", 165);
e_db_int_set(db, "/ib/geom/left", -150);
e_db_int_set(db, "/ib/geom/scroll_w", 16);
e_db_int_set(db, "/ib/geom/horizontal", 0);
e_db_int_set(db, "/ib/scroll_when_less", 0);
e_db_str_set(db, "/ib/image/title", "/usr/local/share/enlightenment/data/ib_title.png");
e_db_str_set(db, "/ib/image/vline", "/usr/local/share/enlightenment/data/vline.png");
e_db_str_set(db, "/ib/image/hline", "/usr/local/share/enlightenment/data/hline.png");
*/
return 0;
}
e_db_int_get(db, "/ib/geom/w", &(ib->geom.conf.w) );
e_db_int_get(db, "/ib/geom/h", &(ib->geom.conf.h));
e_db_int_get(db, "/ib/geom/top", &(ib->geom.conf.top));
e_db_int_get(db, "/ib/geom/left", &(ib->geom.conf.left));
e_db_int_get(db, "/ib/geom/scroll_w", &(ib->geom.scroll_w));
e_db_int_get(db, "/ib/geom/horizontal", &(ib->geom.horizontal));
e_db_int_get(db, "/ib/scroll_when_less", &(ib->scroll_when_less));
ib->image.title = e_db_str_get(db, "/ib/image/title");
ib->image.vline = e_db_str_get(db, "/ib/image/vline");
ib->image.hline = e_db_str_get(db, "/ib/image/hline");
ib->start = 0.0;
ib->icons = NULL;
ib->geom.left = ib->geom.conf.left;
ib->geom.top = ib->geom.conf.top;
ib->geom.w = ib->geom.conf.w;
ib->geom.h = ib->geom.conf.h;
/*
{
double w, h;
evas_get_viewport(ib->e, NULL, NULL, &w, &h);
if(ib->geom.conf.left < 0)
ib->geom.left = ib->geom.conf.left + w;
else
ib->geom.left = ib->geom.conf.left;
if(ib->geom.conf.top < 0)
ib->geom.top = ib->geom.conf.top + h;
else
ib->geom.top = ib->geom.conf.top;
}
*/
printf("w: %i, h: %i\nt: %i, l: %i\n", ib->geom.w, ib->geom.h, ib->geom.top, ib->geom.left);
{
int i, num;
if (e_db_int_get(db, "/ib/num", &num))
{
printf("making %i icons...\n", num);
for ( i = 0; i < num; i++)
{
char *icon, *exec, buf[4096];
sprintf(buf, "/ib/%i/icon", i);
//printf("reading #%i's icon...\n", i);
icon = e_db_str_get(db, buf);
//printf("icon: %s, reading #%i's exec...\n", icon, i);
sprintf(buf, "/ib/%i/exec", i);
exec = e_db_str_get(db, buf);
printf("exec: %s... creating icon\n", exec, i);
//printf("creating icon, %s, %s\n", icon, exec);
e_ib_new_icon(ib, icon, exec);
printf("created...\n", i);
}
}
}
//printf("created icon.\n");
e_db_close(db);
return 1;
}
void
e_ib_fix_icons(E_Iconbar *ib)
{
Evas_List l;
double cur, spacer;
spacer = 20.0;
if (!ib->geom.horizontal)
{
cur = ib->geom.top + ib->start + spacer;
for (l = ib->icons; l; l = l->next)
{
E_IB_Icon *i;
i = l->data;
i->y = cur;
i->x = (ib->geom.w - i->w - ib->geom.scroll_w) / 2 + ib->geom.left;
cur = cur + i->h + spacer;
evas_move(ib->e, i->image, i->x, i->y);
evas_show(ib->e, i->image);
}
ib->length = cur - ib->start - ib->geom.top;
}
else
{
cur = ib->geom.left + ib->start + spacer;
for (l = ib->icons; l; l = l->next)
{
E_IB_Icon *i;
i = l->data;
i->x = cur;
i->y = (ib->geom.h - i->h - ib->geom.scroll_w) / 2 + ib->geom.top;
cur = cur + i->w + spacer;
evas_move(ib->e, i->image, i->x, i->y);
evas_show(ib->e, i->image);
}
ib->length = cur - ib->start - ib->geom.left;
}
}
void
e_ib_scroll(int val, void *data)
{
E_Iconbar *ib;
double vis_length;
//printf("before scroll data to ib set\n");
ib = data;
//printf("after data set\n");
//printf("start: %f, speed: %f\n", ib->start, ib->speed);
ib->start = ib->start - ib->speed;
if (ib->geom.horizontal) vis_length = ib->geom.w;
else vis_length = ib->geom.h;
if (ib->length > vis_length)
{
if (ib->start > 0)
ib->start = 0;
else if (ib->start < vis_length - ib->length)
ib->start = vis_length - ib->length;
}
else if (ib->scroll_when_less)
{
/* icons scroll even if they don't fill the bar */
if (ib->start < 0)
ib->start = 0;
else if (ib->start > vis_length - ib->length)
ib->start = vis_length - ib->length;
}
else
{
ib->start = 0;
}
//printf("before fix\n");
e_ib_fix_icons(ib);
//printf("after fix\n");
if (ib->scrolling)
{
//printf("before timer\n");
e_add_event_timer("e_ib_scroll()", 0.01, e_ib_scroll, 1, ib);
//printf("after timer\n");
}
}
void
i_mouse_in(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
{
evas_set_color(_e, _o, 255, 255, 255, 255);
}
void
i_mouse_out(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
{
evas_set_color(_e, _o, 255, 255, 255, 128);
}
void
i_mouse_down(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
{
char *file = _data;
e_exec_run(file);
}
void
s_mouse_move(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
{
E_Iconbar *ib;
double center;
int top_speed;
double r;
//printf("set ib in s_mouse_move\n");
ib = _data;
top_speed = 5;
if (ib->geom.horizontal)
{
center = ib->geom.left + (.5 * ib->geom.w);
r = (_x - center) / (.5 * ib->geom.w);
}
else
{
center = ib->geom.top + (.5 * ib->geom.h);
r = (_y - center) / (.5 * ib->geom.h);
}
ib->speed = r * (double)top_speed;
e_ib_scroll(1, ib);
}
void
s_mouse_in(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
{
E_Iconbar *ib;
ib = _data;
//printf("setting scrolling\n");
ib->scrolling = 1;
//printf("set scrolling\n");
}
void
s_mouse_out(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
{
E_Iconbar *ib;
ib = _data;
ib->scrolling = 0;
}
void
e_ib_free(E_Iconbar *ib)
{
Evas_List l;
printf("in e_ib_clean_up()\n");
iconbars = evas_list_remove(iconbars, ib);
for (l = ib->icons; l; l = l->next)
{
E_IB_Icon *i;
i = l->data;
FREE(i);
}
FREE(ib->icons);
FREE(ib);
e_db_runtime_flush();
printf("e_ib_clean_up() run successfully\n");
}
static void
e_ib_idle(void *data)
{
Evas_List l;
for (l = iconbars; l; l = l->next)
{
E_Iconbar *ib;
ib = l->data;
e_ib_update(ib);
//e_ib_redraw(ib);
}
}
void
e_ib_update(E_Iconbar *ib)
{
if (ib->v->changed)
{
e_ib_redraw(ib);
}
}
void
e_ib_redraw(E_Iconbar *ib)
{
if(ib->geom.conf.left < 0)
ib->geom.left = ib->geom.conf.left + ib->v->size.w;
if(ib->geom.conf.top < 0)
ib->geom.top = ib->geom.conf.top + ib->v->size.h;
if(ib->geom.conf.w == 0)
ib->geom.w = ib->v->size.w;
if(ib->geom.conf.h == 0)
ib->geom.h = ib->v->size.h;
/* horizontal */
if (ib->geom.horizontal)
{
evas_move(ib->e, ib->obj.scroll, ib->geom.left, ib->geom.top + ib->geom.h - ib->geom.scroll_w);
evas_move(ib->e, ib->obj.line_l, ib->geom.left, ib->geom.top);
evas_move(ib->e, ib->obj.line_c, ib->geom.left, ib->geom.top + ib->geom.h - ib->geom.scroll_w);
evas_move(ib->e, ib->obj.line_r, ib->geom.left, ib->geom.top + ib->geom.h);
evas_move(ib->e, ib->obj.title, ib->geom.left - ib->geom.title_w - 5, ib->geom.top + (ib->geom.h - ib->geom.title_h) / 2);
evas_move(ib->e, ib->obj.clip, ib->geom.left, ib->geom.top);
}
/* vertical */
if (!ib->geom.horizontal)
{
evas_move(ib->e, ib->obj.scroll, ib->geom.left + ib->geom.w - ib->geom.scroll_w, ib->geom.top);
evas_move(ib->e, ib->obj.line_l, ib->geom.left, ib->geom.top);
evas_move(ib->e, ib->obj.line_c, ib->geom.left + ib->geom.w - ib->geom.scroll_w, ib->geom.top);
evas_move(ib->e, ib->obj.line_r, ib->geom.left + ib->geom.w, ib->geom.top);
evas_move(ib->e, ib->obj.title, ib->geom.left + ((ib->geom.w - ib->geom.title_w - ib->geom.scroll_w) / 2 ), ib->geom.top - ib->geom.title_h - 5);
evas_move(ib->e, ib->obj.clip, ib->geom.left, ib->geom.top);
}
/* Clip icons */
{
Evas_List l;
for (l = ib->icons; l; l = l->next)
{
E_IB_Icon *i;
i = l->data;
evas_set_clip(ib->e, i->image, ib->obj.clip);
}
}
/* show the iconbar */
evas_show(ib->e, ib->obj.scroll);
evas_show(ib->e, ib->obj.line_l);
evas_show(ib->e, ib->obj.line_c);
evas_show(ib->e, ib->obj.line_r);
evas_show(ib->e, ib->obj.title);
evas_show(ib->e, ib->obj.clip);
evas_callback_add(ib->e, ib->obj.scroll, CALLBACK_MOUSE_MOVE, s_mouse_move, ib);
evas_callback_add(ib->e, ib->obj.scroll, CALLBACK_MOUSE_IN, s_mouse_in, ib);
evas_callback_add(ib->e, ib->obj.scroll, CALLBACK_MOUSE_OUT, s_mouse_out, ib);
e_ib_fix_icons(ib);
}
void
e_iconbar_init()
{
e_event_filter_idle_handler_add(e_ib_idle, NULL);
}

@ -0,0 +1,113 @@
#ifndef IB_ICONBAR_H
#define IB_ICONBAR_H
#include "e.h"
#include "config.h"
#include "exec.h"
#include "view.h"
#define SCROLL_W 16
#define SCREEN_W 1280
// structs
typedef struct _ib_icon E_IB_Icon;
#ifndef E_ICONBAR_TYPEDEF
#define E_ICONBAR_TYPEDEF
typedef struct _E_Iconbar E_Iconbar;
#endif
#ifndef E_VIEW_TYPEDEF
#define E_VIEW_TYPEDEF
typedef struct _E_View E_View;
#endif
struct _ib_icon
{
OBJ_PROPERTIES;
Evas_Object image;
char *exec;
int w, h;
double x, y;
int selected;
};
struct _E_Iconbar
{
OBJ_PROPERTIES;
char *name;
E_View *v;
Evas e;
Evas_List icons;
char *db;
// E_DB_File *db;
struct {
Evas_Object clip;
Evas_Object scroll;
Evas_Object line_l;
Evas_Object line_c;
Evas_Object line_r;
Evas_Object title;
} obj;
struct {
char *title;
char *vline;
char *hline;
} image;
double start, speed, length;
int scrolling, scroll_when_less;
struct {
int w;
int h;
int top;
int left;
int scroll_w;
int title_w, title_h, line_w, line_h;
int horizontal; // 1 - horiz, 0 - vert
struct {
int top;
int left;
int h;
int w;
} conf;
} geom;
};
// functions
//static void e_idle(void *);
E_Iconbar *e_ib_new(E_View *);
int e_ib_config(E_Iconbar *);
void e_ib_realize(E_Iconbar *);
void e_ib_redraw(E_Iconbar *);
E_IB_Icon *e_ib_new_icon(E_Iconbar *, char *, char *);
void e_ib_fix_icons(E_Iconbar *);
void e_ib_create_icons_from_db(E_Iconbar *);
void e_ib_free(E_Iconbar *);
void e_ib_update(E_Iconbar *);
//void ib_set_scroll_when_less(int);
void i_mouse_in(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y);
void i_mouse_out(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y);
void i_mouse_down(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y);
//void mouse_up(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y);
void s_mouse_move(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y);
void s_mouse_in(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y);
void s_mouse_out(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y);
#endif

@ -12,6 +12,7 @@
#include "menu.h"
#include "view.h"
#include "place.h"
#include "iconbar.h"
#ifdef USE_FERITE
# include "e_ferite.h"
@ -115,7 +116,7 @@ main(int argc, char **argv)
e_sync();
e_reset_error_handler();
e_ungrab();
e_fs_init();
e_desktops_init();
e_border_init();
@ -127,6 +128,7 @@ main(int argc, char **argv)
e_guides_init();
e_place_init();
e_cursors_init();
e_iconbar_init();
#ifdef USE_FERITE
e_ferite_init();
@ -141,6 +143,7 @@ main(int argc, char **argv)
#ifdef USE_FERITE
e_ferite_deinit();
#endif
return 0;
}

@ -1547,9 +1547,6 @@ e_mouse_in(Eevent * ev)
{
if (v->is_desktop)
{
/* FIXME: temporary for now- should only do this if its a deskop */
/* view and desktops accept focus on mouse. */
e_focus_to_window(e->win);
evas_event_enter(v->evas);
}
current_ev = NULL;
@ -2187,6 +2184,7 @@ e_view_free(E_View *v)
{
char name[PATH_MAX];
sprintf(name, "resort_timer.%s", v->dir);
e_del_event_timer(name);
sprintf(name, "geometry_record.%s", v->dir);
@ -2200,6 +2198,9 @@ e_view_free(E_View *v)
e_fs_del_restart_handler(v->restarter);
v->restarter = NULL;
e_window_destroy(v->win.base);
if (v->iconbar) e_ib_free(v->iconbar);
FREE(v);
}
@ -2251,6 +2252,8 @@ _member.r = _r; _member.g = _g; _member.b = _b; _member.a = _a;
v->spacing.icon.s = 7;
v->spacing.icon.g = 7;
v->spacing.icon.b = 7;
// v->iconbar = e_ib_new(v);
views = evas_list_append(views, v);
return v;
}
@ -2375,6 +2378,7 @@ e_view_realize(E_View *v)
e_scrollbar_resize(v->scrollbar.v, 12, v->size.h - 12);
e_scrollbar_move(v->scrollbar.h, 0, v->size.h - 12);
e_scrollbar_resize(v->scrollbar.h, v->size.w - 12, 12);
e_window_show(v->win.main);
@ -2386,6 +2390,10 @@ e_view_realize(E_View *v)
e_view_set_dir(v, dir);
IF_FREE(dir);
}
v->iconbar = e_ib_new(v);
if(v->iconbar) e_ib_realize(v->iconbar);
v->changed = 1;
}

@ -6,10 +6,22 @@
#include "scrollbar.h"
#include "fs.h"
#include "text.h"
#include "iconbar.h"
#ifndef E_VIEW_TYPEDEF
#define E_VIEW_TYPEDEF
typedef struct _E_View E_View;
#endif
typedef struct _E_Icon E_Icon;
#ifndef E_ICONBAR_TYPEDEF
#define E_ICONBAR_TYPEDEF
typedef struct _E_Iconbar E_Iconbar;
#endif
struct _E_View
{
OBJ_PROPERTIES;
@ -127,6 +139,8 @@ struct _E_View
int sel_count;
int changed;
E_Iconbar *iconbar;
};

Loading…
Cancel
Save