<commit_before>/*
 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
 */
#include "e.h"
#include "e_mod_main.h"
#include "e_mod_config.h"
#include <math.h>

/* TODO List:
 *
 * * Create separate config for each box
 * * Fix menu
 *
 * * icon labels & label tooltips supported for the name of the app
 * * use part list to know how many icons & where to put in the overlay of an icon
 * * description bubbles/tooltips for icons
 * * support dynamic iconsize change on the fly
 * * app subdirs - need to somehow handle these...
 * * use overlay object and repeat events for doing auto hide/show
 * * emit signals on hide/show due to autohide/show
 * * virtualise autoshow/hide to later allow for key bindings, mouse events elsewhere, ipc and other singals to show/hide
 *
 * BONUS Features (maybe do this later):
 *
 * * allow ibox icons to be dragged around to re-order/delete
 *
 */

static int box_count;
static E_Config_DD *conf_edd;
static E_Config_DD *conf_box_edd;

/* const strings */
static const char *_ibox_main_orientation[] =
{"left", "right", "top", "bottom"};

/* module private routines */
static IBox   *_ibox_new();
static void    _ibox_free(IBox *ib);
static void    _ibox_config_menu_new(IBox *ib);

static IBox_Box *_ibox_box_new(IBox *ib, E_Container *con);
static void    _ibox_box_free(IBox_Box *ibb);
static void    _ibox_box_menu_new(IBox_Box *ibb);
static void    _ibox_box_enable(IBox_Box *ibb);
static void    _ibox_box_disable(IBox_Box *ibb);
static void    _ibox_box_frame_resize(IBox_Box *ibb);
static void    _ibox_box_edge_change(IBox_Box *ibb, int edge);
static void    _ibox_box_update_policy(IBox_Box *ibb);
static void    _ibox_box_motion_handle(IBox_Box *ibb, Evas_Coord mx, Evas_Coord my);
static void    _ibox_box_timer_handle(IBox_Box *ibb);
static void    _ibox_box_follower_reset(IBox_Box *ibb);

static IBox_Icon *_ibox_icon_new(IBox_Box *ibb, E_Border *bd);
static void    _ibox_icon_free(IBox_Icon *ic);
static IBox_Icon *_ibox_icon_find(IBox_Box *ibb, E_Border *bd);

static void    _ibox_box_cb_gmc_change(void *data, E_Gadman_Client *gmc, E_Gadman_Change change);
static void    _ibox_box_cb_intercept_move(void *data, Evas_Object *o, Evas_Coord x, Evas_Coord y);
static void    _ibox_box_cb_intercept_resize(void *data, Evas_Object *o, Evas_Coord w, Evas_Coord h);
static void    _ibox_box_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void    _ibox_box_cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void    _ibox_box_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void    _ibox_box_cb_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void    _ibox_box_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info);
static int     _ibox_box_cb_timer(void *data);
static int     _ibox_box_cb_animator(void *data);

static int     _ibox_box_cb_event_border_iconify(void *data, int type, void *event);
static int     _ibox_box_cb_event_border_uniconify(void *data, int type, void *event);
static int     _ibox_box_cb_event_border_remove(void *data, int type, void *event);

static void    _ibox_icon_cb_intercept_move(void *data, Evas_Object *o, Evas_Coord x, Evas_Coord y);
static void    _ibox_icon_cb_intercept_resize(void *data, Evas_Object *o, Evas_Coord w, Evas_Coord h);
static void    _ibox_icon_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void    _ibox_icon_cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void    _ibox_icon_cb_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info);

static void    _ibox_box_cb_menu_edit(void *data, E_Menu *m, E_Menu_Item *mi);
static void    _ibox_box_cb_menu_configure(void *data, E_Menu *m, E_Menu_Item *mi);

/* Config Updated Function Protos */
static void    _ibox_box_cb_width_auto(void *data);
static void    _ibox_box_cb_follower(void *data);
static void    _ibox_box_cb_iconsize_change(void *data);

/* public module routines. all modules must have these */
E_Module_Api e_modapi =
{
   E_MODULE_API_VERSION,
     "IBox"
};

void *
e_modapi_init(E_Module *m)
{
   IBox *ib;

   /* actually init ibox */
   ib = _ibox_new();
   m->config_menu = ib->config_menu;
   return ib;
}

int
e_modapi_shutdown(E_Module *m)
{
   IBox *ib;

   if (m->config_menu)
     m->config_menu = NULL;

   ib = m->data;
   if (ib)
     _ibox_free(ib);
   return 1;
}

int
e_modapi_save(E_Module *m)
{
   IBox *ib;

   ib = m->data;
   e_config_domain_save("module.ibox", conf_edd, ib->conf);
   return 1;
}

int
e_modapi_info(E_Module *m)
{
   char buf[4096];

   snprintf(buf, sizeof(buf), "%s/module_icon.png", e_module_dir_get(m));
   m->icon_file = strdup(buf);
   return 1;
}

int
e_modapi_about(E_Module *m)
{
   e_module_dialog_show(_("Enlightenment IBox Module"),
			_("This is the IBox Iconified Application module for Enlightenment.<br>"
			  "It will hold minimized applications"));
   return 1;
}

int
e_modapi_config(E_Module *m)
{
   IBox *e;
   Evas_List *l;
   
   e = m->data;
   if (!e) return 0;
   if (!e->boxes) return 0;
   
   for (l = e->boxes; l; l = l->next) 
     {
	IBox_Box *face;
	face = l->data;
	if (!face) return 0;
	if (face->con == e_container_current_get(e_manager_current_get()))
	  _config_ibox_module(face->con, face->ibox);	
     }
   evas_list_free(l);
   return 1;
}<commit_msg>Remove the list free. May cause segfault when unloading module<commit_after>/*
 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
 */
#include "e.h"
#include "e_mod_main.h"
#include "e_mod_config.h"
#include <math.h>

/* TODO List:
 *
 * * Create separate config for each box
 * * Fix menu
 *
 * * icon labels & label tooltips supported for the name of the app
 * * use part list to know how many icons & where to put in the overlay of an icon
 * * description bubbles/tooltips for icons
 * * support dynamic iconsize change on the fly
 * * app subdirs - need to somehow handle these...
 * * use overlay object and repeat events for doing auto hide/show
 * * emit signals on hide/show due to autohide/show
 * * virtualise autoshow/hide to later allow for key bindings, mouse events elsewhere, ipc and other singals to show/hide
 *
 * BONUS Features (maybe do this later):
 *
 * * allow ibox icons to be dragged around to re-order/delete
 *
 */

static int box_count;
static E_Config_DD *conf_edd;
static E_Config_DD *conf_box_edd;

/* const strings */
static const char *_ibox_main_orientation[] =
{"left", "right", "top", "bottom"};

/* module private routines */
static IBox   *_ibox_new();
static void    _ibox_free(IBox *ib);
static void    _ibox_config_menu_new(IBox *ib);

static IBox_Box *_ibox_box_new(IBox *ib, E_Container *con);
static void    _ibox_box_free(IBox_Box *ibb);
static void    _ibox_box_menu_new(IBox_Box *ibb);
static void    _ibox_box_enable(IBox_Box *ibb);
static void    _ibox_box_disable(IBox_Box *ibb);
static void    _ibox_box_frame_resize(IBox_Box *ibb);
static void    _ibox_box_edge_change(IBox_Box *ibb, int edge);
static void    _ibox_box_update_policy(IBox_Box *ibb);
static void    _ibox_box_motion_handle(IBox_Box *ibb, Evas_Coord mx, Evas_Coord my);
static void    _ibox_box_timer_handle(IBox_Box *ibb);
static void    _ibox_box_follower_reset(IBox_Box *ibb);

static IBox_Icon *_ibox_icon_new(IBox_Box *ibb, E_Border *bd);
static void    _ibox_icon_free(IBox_Icon *ic);
static IBox_Icon *_ibox_icon_find(IBox_Box *ibb, E_Border *bd);

static void    _ibox_box_cb_gmc_change(void *data, E_Gadman_Client *gmc, E_Gadman_Change change);
static void    _ibox_box_cb_intercept_move(void *data, Evas_Object *o, Evas_Coord x, Evas_Coord y);
static void    _ibox_box_cb_intercept_resize(void *data, Evas_Object *o, Evas_Coord w, Evas_Coord h);
static void    _ibox_box_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void    _ibox_box_cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void    _ibox_box_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void    _ibox_box_cb_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void    _ibox_box_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info);
static int     _ibox_box_cb_timer(void *data);
static int     _ibox_box_cb_animator(void *data);

static int     _ibox_box_cb_event_border_iconify(void *data, int type, void *event);
static int     _ibox_box_cb_event_border_uniconify(void *data, int type, void *event);
static int     _ibox_box_cb_event_border_remove(void *data, int type, void *event);

static void    _ibox_icon_cb_intercept_move(void *data, Evas_Object *o, Evas_Coord x, Evas_Coord y);
static void    _ibox_icon_cb_intercept_resize(void *data, Evas_Object *o, Evas_Coord w, Evas_Coord h);
static void    _ibox_icon_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void    _ibox_icon_cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void    _ibox_icon_cb_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info);

static void    _ibox_box_cb_menu_edit(void *data, E_Menu *m, E_Menu_Item *mi);
static void    _ibox_box_cb_menu_configure(void *data, E_Menu *m, E_Menu_Item *mi);

/* Config Updated Function Protos */
static void    _ibox_box_cb_width_auto(void *data);
static void    _ibox_box_cb_follower(void *data);
static void    _ibox_box_cb_iconsize_change(void *data);

/* public module routines. all modules must have these */
E_Module_Api e_modapi =
{
   E_MODULE_API_VERSION,
     "IBox"
};

void *
e_modapi_init(E_Module *m)
{
   IBox *ib;

   /* actually init ibox */
   ib = _ibox_new();
   m->config_menu = ib->config_menu;
   return ib;
}

int
e_modapi_shutdown(E_Module *m)
{
   IBox *ib;

   if (m->config_menu)
     m->config_menu = NULL;

   ib = m->data;
   if (ib)
     _ibox_free(ib);
   return 1;
}

int
e_modapi_save(E_Module *m)
{
   IBox *ib;

   ib = m->data;
   e_config_domain_save("module.ibox", conf_edd, ib->conf);
   return 1;
}

int
e_modapi_info(E_Module *m)
{
   char buf[4096];

   snprintf(buf, sizeof(buf), "%s/module_icon.png", e_module_dir_get(m));
   m->icon_file = strdup(buf);
   return 1;
}

int
e_modapi_about(E_Module *m)
{
   e_module_dialog_show(_("Enlightenment IBox Module"),
			_("This is the IBox Iconified Application module for Enlightenment.<br>"
			  "It will hold minimized applications"));
   return 1;
}

int
e_modapi_config(E_Module *m)
{
   IBox *e;
   Evas_List *l;
   
   e = m->data;
   if (!e) return 0;
   if (!e->boxes) return 0;
   
   for (l = e->boxes; l; l = l->next) 
     {
	IBox_Box *face;
	face = l->data;
	if (!face) return 0;
	if (face->con == e_container_current_get(e_manager_current_get()))
	  _config_ibox_module(face->con, face->ibox);	
     }
   return 1;
}
{'fraction_non_alphanumeric': 0.1074296262113521, 'fraction_numerical': 0.0036917397323488694, 'mean_word_length': 4.634945397815913, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3195978', 'n_tokens_mistral': 4271, 'n_tokens_neox': 4176, 'n_words': 1080}