use the gadcon popup

SVN revision: 31434
This commit is contained in:
Viktor Kojouharov 2007-08-20 19:03:03 +00:00
parent 313ebefbee
commit 37a5b2094a
3 changed files with 29 additions and 150 deletions

32
net.edc
View File

@ -266,35 +266,15 @@ collections
part part
{ {
name: "base"; name: "base";
type: RECT;
mouse_events: 0; mouse_events: 0;
type: RECT;
description description
{ {
state: "default" 0.0; state: "default" 0.0;
rel1.offset: 1 1; color: 0 0 0 0;
rel2.offset: -2 -2;
color: 221 221 221 255;
min: 125 50; min: 125 50;
} }
} }
part
{
name: "bd";
mouse_events: 0;
description
{
state: "default" 0.0;
rel1.offset: 0 0;
rel2.offset: -1 -1;
image
{
normal: "bd.png";
border: 1 1 1 1;
middle: 0;
}
fill.smooth: 0;
}
}
part part
{ {
name: "e.text.title"; name: "e.text.title";
@ -363,7 +343,7 @@ collections
rel1 rel1
{ {
relative: 1.0 0.0; relative: 1.0 0.0;
offset: 8 6; offset: 10 6;
to: "icon"; to: "icon";
} }
rel2 rel2
@ -382,7 +362,7 @@ collections
size: 10; size: 10;
min: 1 1; min: 1 1;
align: 0.0 0.5; align: 0.0 0.5;
text_class: "menu_item"; text_class: "module_normal";
elipsis: 0.0; elipsis: 0.0;
} }
} }
@ -400,7 +380,7 @@ collections
rel1 rel1
{ {
relative: 1.0 1.0; relative: 1.0 1.0;
offset: 8 -6; offset: 10 -6;
to: "icon"; to: "icon";
} }
rel2 rel2
@ -419,7 +399,7 @@ collections
size: 10; size: 10;
min: 1 1; min: 1 1;
align: 0.0 0.5; align: 0.0 0.5;
text_class: "menu_item"; text_class: "module_normal";
elipsis: 0.0; elipsis: 0.0;
} }
} }

View File

@ -4,22 +4,17 @@
#define E_MOD_MAIN_H #define E_MOD_MAIN_H
typedef struct _Instance Instance; typedef struct _Instance Instance;
typedef struct _Popup Popup; typedef unsigned long bytes_t;
struct _Instance struct _Instance
{ {
E_Gadcon_Client *gcc; E_Gadcon_Client *gcc;
Evas_Object *o_net; Evas_Object *o_net, *pop_bg;
Ecore_Timer *timer; Ecore_Timer *timer;
Popup *popup; E_Gadcon_Popup *popup;
short popup_locked;
unsigned long in, out;
};
struct _Popup short popup_locked;
{ bytes_t in, out;
E_Popup *win;
Evas_Object *o_bg;
}; };
EAPI extern E_Module_Api e_modapi; EAPI extern E_Module_Api e_modapi;

View File

@ -13,7 +13,6 @@
#include <net/if_mib.h> #include <net/if_mib.h>
#endif #endif
typedef unsigned long bytes_t;
static void _bytes_to_string(bytes_t bytes, char *string, int size); static void _bytes_to_string(bytes_t bytes, char *string, int size);
static void _cb_post(void *data, E_Menu *m); static void _cb_post(void *data, E_Menu *m);
static void _cb_configure(void *data, E_Menu *m, E_Menu_Item *mi); static void _cb_configure(void *data, E_Menu *m, E_Menu_Item *mi);
@ -122,7 +121,7 @@ _cb_poll(void *data)
{ {
_bytes_to_string(in, tmp, sizeof(tmp)); _bytes_to_string(in, tmp, sizeof(tmp));
snprintf(popbuf, sizeof(popbuf), "Rx: %s", tmp); snprintf(popbuf, sizeof(popbuf), "Rx: %s", tmp);
edje_object_part_text_set(inst->popup->o_bg, "e.text.recv", popbuf); edje_object_part_text_set(inst->pop_bg, "e.text.recv", popbuf);
} }
_bytes_to_string(bout, tmp, sizeof(tmp)); _bytes_to_string(bout, tmp, sizeof(tmp));
@ -132,7 +131,7 @@ _cb_poll(void *data)
{ {
_bytes_to_string(out, tmp, sizeof(tmp)); _bytes_to_string(out, tmp, sizeof(tmp));
snprintf(popbuf, sizeof(popbuf), "Tx: %s", tmp); snprintf(popbuf, sizeof(popbuf), "Tx: %s", tmp);
edje_object_part_text_set(inst->popup->o_bg, "e.text.send", popbuf); edje_object_part_text_set(inst->pop_bg, "e.text.send", popbuf);
} }
return 1; return 1;
@ -158,12 +157,7 @@ _cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event)
} }
} }
else if ((ev->button == 1) && (!cfg->menu)) else if ((ev->button == 1) && (!cfg->menu))
{ e_gadcon_popup_toggle_pinned(inst->popup);
if (inst->popup_locked)
inst->popup_locked = 0;
else
inst->popup_locked = 1;
}
else if ((ev->button == 3) && (!cfg->menu)) else if ((ev->button == 3) && (!cfg->menu))
{ {
E_Menu *mn; E_Menu *mn;
@ -198,124 +192,36 @@ _cb_mouse_in(void *data, Evas_Object *obj, const char *emission, const char *sou
{ {
Instance *inst; Instance *inst;
Config_Item *ci; Config_Item *ci;
E_Container *con;
Evas_Object *bg; Evas_Object *bg;
Evas_Coord cx, cy, cw, ch; Evas_Coord gw, gh;
Evas_Coord ox, oy, ow, oh; char buf[PATH_MAX], tmp[100];
Evas_List *l;
int layer = -1;
int wx, wy, ww, wh;
char buf[PATH_MAX];
inst = data; inst = data;
if (inst->popup != NULL) return; if (inst->popup != NULL) return;
ci = _config_item_get(inst->gcc->id); ci = _config_item_get(inst->gcc->id);
if (!ci->show_popup) return; if (!ci->show_popup) return;
inst->popup = E_NEW(Popup, 1); inst->popup = e_gadcon_popup_new(inst->gcc, NULL);
snprintf(buf, sizeof(buf), "%s/net.edj", e_module_dir_get(cfg->mod)); snprintf(buf, sizeof(buf), "%s/net.edj", e_module_dir_get(cfg->mod));
con = e_container_current_get(e_manager_current_get());
inst->popup->win = e_popup_new(e_zone_current_get(con), 0, 0, 0, 0);
bg = edje_object_add(inst->popup->win->evas); bg = edje_object_add(inst->popup->win->evas);
if (!e_theme_edje_object_set(bg, "base/theme/modules", if (!e_theme_edje_object_set(bg, "base/theme/modules",
"modules/net/popup")) "modules/net/popup"))
edje_object_file_set(bg, buf, "modules/net/popup"); edje_object_file_set(bg, buf, "modules/net/popup");
snprintf(buf, sizeof(buf), D_("Device - %s"), ci->device); snprintf(buf, sizeof(buf), D_("Device - %s"), ci->device);
edje_object_part_text_set(bg, "e.text.title", buf); edje_object_part_text_set(bg, "e.text.title", buf);
evas_object_show(bg); inst->pop_bg = bg;
snprintf(buf, sizeof(buf), "Rx: 0 B"); _bytes_to_string(inst->in, tmp, sizeof(tmp));
snprintf(buf, sizeof(buf), "Rx: %s", tmp);
edje_object_part_text_set(bg, "e.text.recv", buf); edje_object_part_text_set(bg, "e.text.recv", buf);
snprintf(buf, sizeof(buf), "Tx: 0 B");
_bytes_to_string(inst->out, tmp, sizeof(tmp));
snprintf(buf, sizeof(buf), "Tx: %s", tmp);
edje_object_part_text_set(bg, "e.text.send", buf); edje_object_part_text_set(bg, "e.text.send", buf);
edje_object_size_min_calc(bg, &ww, &wh); e_gadcon_popup_content_set(inst->popup, bg);
evas_object_move(bg, 0, 0); e_gadcon_popup_show(inst->popup);
evas_object_resize(bg, ww, wh);
inst->popup->o_bg = bg;
/* Begin Butt Ugly hack for shelf "layer"/position changes */
cx = cy = cw = ch = -1;
for (l = e_shelf_list(); l; l = l->next)
{
E_Shelf *es;
es = l->data;
if (es->gadcon != inst->gcc->gadcon) continue;
layer = es->layer;
cx = es->x;
cy = es->y;
cw = es->w;
ch = es->h;
break;
}
if (cx == -1) return;
evas_object_geometry_get(inst->o_net, &ox, &oy, &ow, &oh);
switch (inst->gcc->gadcon->orient)
{
case E_GADCON_ORIENT_CORNER_RT:
case E_GADCON_ORIENT_CORNER_RB:
case E_GADCON_ORIENT_RIGHT:
wx = (cx - ww);
if (layer == 1)
wy = oy;
else
wy = (cy + oy);
if ((wy + wh) > (cy + ch))
wy = (cy + ch) - wh;
break;
case E_GADCON_ORIENT_LEFT:
case E_GADCON_ORIENT_CORNER_LT:
case E_GADCON_ORIENT_CORNER_LB:
wx = (cx + cw);
if (layer == 1)
wy = oy;
else
wy = (cy + oy);
if ((wy + wh) > (cy + ch))
wy = (cy + ch) - wh;
break;
case E_GADCON_ORIENT_TOP:
case E_GADCON_ORIENT_CORNER_TL:
if (layer == 1)
wx = ox;
else
wx = (cx + ox);
wy = (cy + ch);
break;
case E_GADCON_ORIENT_CORNER_TR:
if (layer == 1)
wx = ox;
else
wx = (cx + ox);
wy = (cy + ch);
if ((wx + ww) > (cx + cw))
wx = (cx + cw) - ww;
break;
case E_GADCON_ORIENT_BOTTOM:
case E_GADCON_ORIENT_CORNER_BL:
if (layer == 1)
wx = ox;
else
wx = (cx + ox);
wy = (cy - wh);
break;
case E_GADCON_ORIENT_CORNER_BR:
if (layer == 1)
wx = ox;
else
wx = (cx + ox);
wy = (cy - wh);
if ((wx + ww) > (cx + cw))
wx = (cx + cw) - ww;
break;
default:
break;
}
e_popup_move_resize(inst->popup->win, wx, wy, ww, wh);
e_popup_show(inst->popup->win);
} }
EAPI void EAPI void
@ -323,12 +229,10 @@ _cb_mouse_out(void *data, Evas_Object *obj, const char *emission, const char *so
{ {
Instance *inst; Instance *inst;
inst = data; if (!(inst = data)) return;
if (!inst->popup) return; if (inst->popup->pinned) return;
if (inst->popup_locked) return; e_object_del(E_OBJECT(inst->popup));
evas_object_del(inst->popup->o_bg); inst->popup = NULL;
e_object_del(E_OBJECT(inst->popup->win));
E_FREE(inst->popup);
} }
static void static void