<commit_before>#include "e.h"
#include "e_mod_main.h"
#include "e_mod_parse.h"

/* GADCON */
static E_Gadcon_Client *_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style);
static void             _gc_shutdown(E_Gadcon_Client *gcc);
static void             _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient);
static const char      *_gc_label(const E_Gadcon_Client_Class *client_class);
static const char      *_gc_id_new(const E_Gadcon_Client_Class *client_class __UNUSED__);
static Evas_Object     *_gc_icon(const E_Gadcon_Client_Class *client_class, Evas *evas);

/* EVENTS */
static Eina_Bool        _xkb_changed(void *data, int type, void *event_info);
static Eina_Bool        _xkb_changed_state(void *data __UNUSED__, int type __UNUSED__, void *event);
static void             _e_xkb_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event);
static void             _e_xkb_cb_menu_configure(void *data, E_Menu *mn, E_Menu_Item *mi __UNUSED__);
static void             _e_xkb_cb_lmenu_post(void *data, E_Menu *menu __UNUSED__);
static void             _e_xkb_cb_lmenu_set(void *data, E_Menu *mn __UNUSED__, E_Menu_Item *mi __UNUSED__);

/* Static variables
 * The static variables specific to the current code unit.
 */

/* GADGET INSTANCE */

typedef struct _Instance
{
   E_Gadcon_Client *gcc;

   Evas_Object     *o_xkbswitch;
   Evas_Object     *o_xkbflag;

   E_Menu          *lmenu;
} Instance;

/* LIST OF INSTANCES */
static Eina_List *instances = NULL;

/* Global variables
 * Global variables shared across the module.
 */

/* CONFIG STRUCTURE */
Xkb _xkb = { NULL, NULL, NULL };

static const E_Gadcon_Client_Class _gc_class =
{
   GADCON_CLIENT_CLASS_VERSION,
   "xkbswitch",
   {
      _gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon, _gc_id_new, NULL, NULL
   },
   E_GADCON_CLIENT_STYLE_PLAIN
};

EAPI E_Module_Api e_modapi =
{
   E_MODULE_API_VERSION,
   "XKB Switcher"
};

static void
_e_xkb_default_add(void)
{
   E_Config_XKB_Layout *nl;

   CRI("No kbd layouts found! Probably hit super-annoying-xkb-module bug!");

   nl = E_NEW(E_Config_XKB_Layout, 1);
   nl->name = eina_stringshare_add("default");
   nl->model = eina_stringshare_add("default");
   nl->variant = eina_stringshare_add("basic");

   e_config->xkb.used_layouts =
     eina_list_append(e_config->xkb.used_layouts, nl);
}

/* Module initializer
 * Initializes the configuration file, checks its versions, populates
 * menus, finds the rules file, initializes gadget icon.
 */
EAPI void *
e_modapi_init(E_Module *m)
{
   /* Menus and dialogs */
   e_configure_registry_category_add("keyboard_and_mouse", 80, _("Input"),
                                     NULL, "preferences-behavior");
   e_configure_registry_item_add("keyboard_and_mouse/xkbswitch", 110,
                                 _("Keyboard"), NULL,
                                 "preferences-desktop-keyboard",
                                 _xkb_cfg_dialog);
   _xkb.module = m;
   _xkb.evh = ecore_event_handler_add(E_EVENT_XKB_CHANGED, _xkb_changed, NULL);
   ecore_event_handler_add(ECORE_X_EVENT_XKB_STATE_NOTIFY, _xkb_changed_state, NULL);
   if (!e_config->xkb.default_model) e_config->xkb.default_model = eina_stringshare_add("default");
   if (!e_config->xkb.used_layouts) _e_xkb_default_add();
     {
        E_Config_XKB_Layout *nl;

        nl = E_NEW(E_Config_XKB_Layout, 1);
        nl->name = eina_stringshare_add("default");
        nl->model = eina_stringshare_add("default");
        nl->variant = eina_stringshare_add("basic");

        e_config->xkb.used_layouts =
          eina_list_append(e_config->xkb.used_layouts, nl);
     }
   /* Gadcon */
   e_gadcon_provider_register(&_gc_class);
   return m;
}

/* Module shutdown
 * Called when the module gets unloaded. Deregisters the menu state<commit_msg>whoops, forgot to remove original default layout add code<commit_after>#include "e.h"
#include "e_mod_main.h"
#include "e_mod_parse.h"

/* GADCON */
static E_Gadcon_Client *_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style);
static void             _gc_shutdown(E_Gadcon_Client *gcc);
static void             _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient);
static const char      *_gc_label(const E_Gadcon_Client_Class *client_class);
static const char      *_gc_id_new(const E_Gadcon_Client_Class *client_class __UNUSED__);
static Evas_Object     *_gc_icon(const E_Gadcon_Client_Class *client_class, Evas *evas);

/* EVENTS */
static Eina_Bool        _xkb_changed(void *data, int type, void *event_info);
static Eina_Bool        _xkb_changed_state(void *data __UNUSED__, int type __UNUSED__, void *event);
static void             _e_xkb_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event);
static void             _e_xkb_cb_menu_configure(void *data, E_Menu *mn, E_Menu_Item *mi __UNUSED__);
static void             _e_xkb_cb_lmenu_post(void *data, E_Menu *menu __UNUSED__);
static void             _e_xkb_cb_lmenu_set(void *data, E_Menu *mn __UNUSED__, E_Menu_Item *mi __UNUSED__);

/* Static variables
 * The static variables specific to the current code unit.
 */

/* GADGET INSTANCE */

typedef struct _Instance
{
   E_Gadcon_Client *gcc;

   Evas_Object     *o_xkbswitch;
   Evas_Object     *o_xkbflag;

   E_Menu          *lmenu;
} Instance;

/* LIST OF INSTANCES */
static Eina_List *instances = NULL;

/* Global variables
 * Global variables shared across the module.
 */

/* CONFIG STRUCTURE */
Xkb _xkb = { NULL, NULL, NULL };

static const E_Gadcon_Client_Class _gc_class =
{
   GADCON_CLIENT_CLASS_VERSION,
   "xkbswitch",
   {
      _gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon, _gc_id_new, NULL, NULL
   },
   E_GADCON_CLIENT_STYLE_PLAIN
};

EAPI E_Module_Api e_modapi =
{
   E_MODULE_API_VERSION,
   "XKB Switcher"
};

static void
_e_xkb_default_add(void)
{
   E_Config_XKB_Layout *nl;

   CRI("No kbd layouts found! Probably hit super-annoying-xkb-module bug!");

   nl = E_NEW(E_Config_XKB_Layout, 1);
   nl->name = eina_stringshare_add("default");
   nl->model = eina_stringshare_add("default");
   nl->variant = eina_stringshare_add("basic");

   e_config->xkb.used_layouts =
     eina_list_append(e_config->xkb.used_layouts, nl);
}

/* Module initializer
 * Initializes the configuration file, checks its versions, populates
 * menus, finds the rules file, initializes gadget icon.
 */
EAPI void *
e_modapi_init(E_Module *m)
{
   /* Menus and dialogs */
   e_configure_registry_category_add("keyboard_and_mouse", 80, _("Input"),
                                     NULL, "preferences-behavior");
   e_configure_registry_item_add("keyboard_and_mouse/xkbswitch", 110,
                                 _("Keyboard"), NULL,
                                 "preferences-desktop-keyboard",
                                 _xkb_cfg_dialog);
   _xkb.module = m;
   _xkb.evh = ecore_event_handler_add(E_EVENT_XKB_CHANGED, _xkb_changed, NULL);
   ecore_event_handler_add(ECORE_X_EVENT_XKB_STATE_NOTIFY, _xkb_changed_state, NULL);
   if (!e_config->xkb.default_model) e_config->xkb.default_model = eina_stringshare_add("default");
   if (!e_config->xkb.used_layouts) _e_xkb_default_add();
   /* Gadcon */
   e_gadcon_provider_register(&_gc_class);
   return m;
}

/* Module shutdown
 * Called when the module gets unloaded. Deregisters the menu state
{'fraction_non_alphanumeric': 0.09828711256117455, 'fraction_numerical': 0.0017672648178357804, 'mean_word_length': 3.6067626800250467, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4421403', 'n_tokens_mistral': 2671, 'n_tokens_neox': 2657, 'n_words': 553}