This commit is contained in:
nemunaire 2025-12-28 22:38:39 +07:00
commit 7a6e205002

View file

@ -63,20 +63,8 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
inst = E_NEW(Instance, 1);
if (!inst) return NULL;
/* Create gadcon client */
gcc = e_gadcon_client_new(gc, name, id, style, NULL);
if (!gcc)
{
E_FREE(inst);
return NULL;
}
gcc->data = inst;
inst->gcc = gcc;
/* Create icon */
o = edje_object_add(gcc->gadcon->evas);
inst->icon = o;
/* Create edje object */
o = edje_object_add(gc->evas);
/* Load theme */
char theme_path[PATH_MAX];
@ -92,19 +80,24 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
evas_object_show(o);
/* Pass the object directly to e_gadcon_client_new */
gcc = e_gadcon_client_new(gc, name, id, style, o);
if (!gcc)
{
evas_object_del(o);
E_FREE(inst);
return NULL;
}
gcc->data = inst;
inst->gcc = gcc;
inst->icon = o;
inst->gadget = o;
/* Add mouse event handler */
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
_gadget_mouse_down_cb, inst);
/* Set the icon as the gadcon's visual object */
inst->gadget = o;
gcc->o_base = o;
/* Set size constraints */
e_gadcon_client_min_size_set(gcc, 16, 16);
e_gadcon_client_aspect_set(gcc, 16, 16);
e_gadcon_client_show(gcc);
/* Get first available device */
Eina_List *devices = iwd_devices_get();
if (devices && eina_list_count(devices) > 0)
@ -166,8 +159,21 @@ _gc_shutdown(E_Gadcon_Client *gcc)
static void
_gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient EINA_UNUSED)
{
e_gadcon_client_aspect_set(gcc, 16, 16);
e_gadcon_client_min_size_set(gcc, 16, 16);
Instance *inst;
Evas_Coord mw, mh;
inst = gcc->data;
if (!inst || !inst->icon) return;
mw = 0;
mh = 0;
edje_object_size_min_get(inst->icon, &mw, &mh);
if ((mw < 1) || (mh < 1))
edje_object_size_min_calc(inst->icon, &mw, &mh);
if (mw < 4) mw = 4;
if (mh < 4) mh = 4;
e_gadcon_client_aspect_set(gcc, mw, mh);
e_gadcon_client_min_size_set(gcc, mw, mh);
}
/* Gadcon label */
@ -213,10 +219,13 @@ _gc_icon(const E_Gadcon_Client_Class *client_class EINA_UNUSED, Evas *evas)
/* Generate new ID */
static const char *
_gc_id_new(const E_Gadcon_Client_Class *client_class EINA_UNUSED)
_gc_id_new(const E_Gadcon_Client_Class *client_class)
{
static char buf[32];
snprintf(buf, sizeof(buf), "%s.%d", _gc_class.name, rand());
static char buf[128];
Mod *mod = iwd_mod;
snprintf(buf, sizeof(buf), "%s.%d", client_class->name,
mod ? eina_list_count(mod->instances) + 1 : 1);
return buf;
}