This commit is contained in:
rafspiny 2023-08-25 19:43:37 +02:00 committed by Carsten Haitzler
parent e7fb1684ce
commit bb37914492
3 changed files with 28 additions and 26 deletions

View File

@ -6,8 +6,8 @@
#include "e_mod_config.h"
static Convertible_Config *_config = NULL;
E_Config_DD *edd = NULL;
EINTERN Convertible_Config *convertible_config;
E_Config_DD *config_edd = NULL;
extern Convertible_Config *convertible_config;
/**
* Create the config structure
@ -20,10 +20,10 @@ _econvertible_config_dd_new(void)
// E_CONFIG_VAL(c_zone, Convertible_Zone_Config, follow_rotation, INT);
// TODO Not sure what his line does. Apparently, it is needed to specify the type of the configuration data structure
edd = E_CONFIG_DD_NEW("Convertible_Config", Convertible_Config);
config_edd = E_CONFIG_DD_NEW("Convertible_Config", Convertible_Config);
E_CONFIG_VAL(edd, Convertible_Config, disable_keyboard_on_rotation, INT);
// E_CONFIG_LIST(edd, Convertible_Config, rotatable_screen_configuration, c_zone);
E_CONFIG_VAL(config_edd, Convertible_Config, disable_keyboard_on_rotation, INT);
// E_CONFIG_LIST(config_edd, Convertible_Config, rotatable_screen_configuration, c_zone);
}
/**
@ -35,7 +35,7 @@ _config_set(Convertible_Config *config)
{
DBG("config_set disable_keyboard_on_rotation %d", config->disable_keyboard_on_rotation);
_config->disable_keyboard_on_rotation = config->disable_keyboard_on_rotation;
e_config_domain_save("module.convertible", edd, config);
e_config_domain_save("module.convertible", config_edd, config);
}
/**
@ -142,7 +142,7 @@ void
econvertible_config_init(void)
{
_econvertible_config_dd_new();
_config = e_config_domain_load("module.econvertible", edd);
_config = e_config_domain_load("module.econvertible", config_edd);
if (!_config)
{
_config = E_NEW(Convertible_Config, 1);
@ -155,6 +155,6 @@ econvertible_config_init(void)
void econvertible_config_shutdown(void)
{
E_CONFIG_DD_FREE(edd);
E_CONFIG_DD_FREE(config_edd);
E_FREE(convertible_config);
}

View File

@ -7,22 +7,12 @@
#ifndef E_GADGET_CONVERTIBLE_E_MOD_CONFIG_H
#define E_GADGET_CONVERTIBLE_E_MOD_CONFIG_H
// Definition for a zone configuration
typedef struct _Convertible_Zone_Config Convertible_Zone_Config;
struct _Convertible_Zone_Config
{
char *name;
int follow_rotation;
};
// Definition of the data structure to hold the gadget configuration
typedef struct _Convertible_Config Convertible_Config;
struct _Convertible_Config
{
E_Module *module;
int disable_keyboard_on_rotation;
// Eina_List *rotatable_screen_configuration;
};
// As far as I understand, this structure should hold data useful for the configuration and a pointer to

View File

@ -17,8 +17,9 @@ E_Module *convertible_module;
Instance *inst;
// Configuration
extern Convertible_Config *convertible_config;
extern E_Config_DD *edd;
extern Convertible_Config *convertible_config = NULL;
static E_Config_DD *conf_edd = NULL;
Convertible_Config *conf = NULL;
// Logger
int _convertible_log_dom;
@ -34,6 +35,9 @@ E_API E_Module_Api e_modapi =
/* LIST OF INSTANCES */
static Eina_List *instances = NULL;
/* Other functions for configuration */
static void _conf_new(void);
static void _conf_free(void);
/* gadcon requirements */
static E_Gadcon_Client *_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style);
@ -217,7 +221,7 @@ _gc_icon(const E_Gadcon_Client_Class *client_class EINA_UNUSED, Evas *evas)
o = edje_object_add(evas);
snprintf(buf, sizeof(buf), "%s/e-module-convertible.edj", convertible_module->dir);
edje_object_file_set(o, buf, "main");
edje_object_file_set(o, buf, "icon");
return o;
}
@ -257,8 +261,8 @@ e_modapi_init(E_Module *m)
{
// Initialise the logger
_convertible_log_dom = eina_log_domain_register("convertible", EINA_COLOR_LIGHTBLUE);
convertible_module = m;
char theme_overlay_path[PATH_MAX];
snprintf(theme_overlay_path, sizeof(theme_overlay_path), "%s/e-module-convertible.edj", convertible_module->dir);
elm_theme_extension_add(NULL, theme_overlay_path);
@ -326,8 +330,8 @@ e_modapi_init(E_Module *m)
*
* NB: If the category already exists, this function just returns */
e_configure_registry_category_add("screen", 30, _("Screen"), NULL, "preferences-desktop-display");
e_configure_registry_item_add("screen/convertible", 30, "convertible", theme_overlay_path,
"main", e_int_config_convertible_module);
e_configure_registry_item_add("screen/convertible", 30, "convertible", NULL,
theme_overlay_path, e_int_config_convertible_module);
instances = eina_list_append(instances, inst);
@ -369,7 +373,15 @@ e_modapi_save(E_Module *m EINA_UNUSED)
{
if (convertible_config)
{
e_config_domain_save("module.convertible", edd, convertible_config);
e_config_domain_save("module.convertible", conf_edd, convertible_config);
}
return 1;
}
static void
_conf_new(void)
{
conf = E_NEW(Convertible_Config, 1);
conf->disable_keyboard_on_rotation = 1;
e_config_save_queue();
}