[E-devel] E_CONFIG_SUB

2006-05-13 Thread Aleksej Struk

Hi Raster,

Please find two files attached : e_mod_main.c and e_mod_main.h
To see the peace of code where E_CONFIG_SUB is used, please refer to
function _lang_load_config.

As I said in IRC, E_CONFIG_SUB works if the config file is already
exist. Otherwise eet crashes.

BTW. If u would require all the module code, in order to do testings,
then please let me know :)

Waiting for comments.

aleksej

--
Aleksej Struk
Master Degree Student
Free University of Bozen-Bolzano
Faculty of Computer Science
phone: +39-0471-061749
cell phone: +39-3204627049
[EMAIL PROTECTED] [EMAIL PROTECTED] - http://www.
#include e.h
#include e_mod_main.h
#include e_mod_config.h
#include e_mod_keybind.h
#include e_mod_lang.h
#include config.h

#define LANG_MODULE_CONFIG_FILE module.language

Lang   *_lang_init(E_Module *m);
static void   _lang_shutdown(Lang *l);

static void   _lang_config_menu_new(Lang *l);

static int_lang_face_init(Lang_Face *lf);
static void   _lang_face_menu_new(Lang_Face *lf);
static void   _lang_face_enable(Lang_Face *lf);
static void   _lang_face_disable(Lang_Face *lf);
static void   _lang_face_free(Lang_Face *lf);

static void   _lang_face_cb_gmc_change(void *data, E_Gadman_Client *gmc, E_Gadman_Change change);
static void   _lang_face_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info);
static void   _lang_face_cb_menu_edit(void *data, E_Menu *mn, E_Menu_Item *mi);
static void   _lang_face_cb_menu_configure(void *data, E_Menu *mn, E_Menu_Item *mi);

void   _lang_load_config(Lang *l);

static int lang_count;

Lang  *lang = NULL;

EAPI E_Module_Api e_modapi = {
   E_MODULE_API_VERSION,
   Language
};

EAPI void *
e_modapi_init(E_Module *m)
{
   Lang	*l;

   l = _lang_init(m);

   if (!l)
 return NULL;

   lang = l;

   m-config_menu = l-config_menu;
   return l;
}

EAPI int
e_modapi_shutdown(E_Module *m)
{
   Lang	*l;

   l = m-data;
   if (!l)
 return 0;

   if (m-config_menu)
 {
	e_menu_deactivate(m-config_menu);
	e_object_del(E_OBJECT(m-config_menu));
	m-config_menu = NULL;
 }
   if (l-cfd)
 {
	e_object_del(E_OBJECT(l-cfd));
	l-cfd = NULL;
 }
   _lang_shutdown(l);
   return 1;
}

EAPI int
e_modapi_save(E_Module *m)
{
   Lang *l;

   l = m-data;
   if (!l)
 return 0;
   e_config_domain_save(LANG_MODULE_CONFIG_FILE, l-conf_edd, l-conf);
   return 1;
}

EAPI 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;
}

EAPI int
e_modapi_about(E_Module *m)
{
   e_module_dialog_show( _(Enlightenment Language Enhancment Module),
			 _(This module is used to switch between input languages.));
   return 1;
}

EAPI int
e_modapi_config(E_Module *m)
{
   Lang *l;
   E_Container *con;

   l = m-data;
   if (!l)
 return 0;
   if (!l-face)
 return 0;

   con = e_container_current_get(e_manager_current_get());
   if (l-face-con == con)
 _lang_configure_lang_module(con, l);

   return 1;
}

Lang *
_lang_init(E_Module *m)
{
   Lang		*l;
   E_Menu_Item	*mi;
   Evas_List	*managers, *l1, *l2;

   lang_load_kbd_models();
   lang_load_xfree_languages();

   l = E_NEW(Lang, 1);

   if (!l)
 return NULL;

   l-module   = m;
   l-current_lang_selector = 0;

   _lang_load_config(l);
   _lang_config_menu_new(l);

   managers = e_manager_list();
   for (l1 = managers; l1; l1 = l1-next)
 {
	E_Manager *man;

	man = l1-data;
	for (l2 = man-containers; l2; l2 = l2-next)
	  {
	 E_Container *con;
	 Lang_Face	 *lf;

	 con = l2-data;
	 lf = E_NEW(Lang_Face, 1);

	 if (lf)
	   {
		  lf-conf_face_edd = E_CONFIG_DD_NEW(Lang_Face_Config, Config_Face);
#undef T
#undef D
#define T Config_Face
#define D lf-conf_face_edd
		  E_CONFIG_VAL(D, T, enabled, UCHAR);

		  l-face   = lf;
		  lf-lang  = l;
		  lf-con   = con;
		  lf-evas  = con-bg_evas;

		  lf-conf = E_NEW(Config_Face, 1);
		  lf-conf-enabled = 1;

		  if (!_lang_face_init(lf))
		return NULL;

		  lang_face_language_indicator_set(l);

		  _lang_face_menu_new(lf);

		  mi = e_menu_item_new(l-config_menu);
		  e_menu_item_label_set(mi, con-name);
		  e_menu_item_submenu_set(mi, lf-menu);

		  if (!lf-conf-enabled)
		_lang_face_disable(lf);
		  else
		_lang_face_enable(lf);
	   }
	  }
 }

   _lang_register_module_actions();
   _lang_register_module_keybindings(l);


   return l;
}

static void
_lang_shutdown(Lang *l)
{
   _lang_unregister_module_actions();
   _lang_unregister_module_keybindings(l);

   lang_free_kbd_models();
   lang_free_xfree_languages();

   while (l-conf-languages)
 {
	Language  *lang = l-conf-languages-data;
	if (lang-lang_name) evas_stringshare_del(lang-lang_name);
	if (lang-lang_shortcut) evas_stringshare_del(lang-lang_shortcut);
	if (lang-lang_flag) evas_stringshare_del(lang-lang_flag);
	if (lang-kbd_model) evas_stringshare_del(lang-kbd_model);
	if (lang-kbd_layout) evas_stringshare_del(lang-kbd_layout);
	if (lang-kbd_variant) 

Re: [E-devel] E_CONFIG_SUB

2006-05-13 Thread The Rasterman
On Sat, 13 May 2006 11:22:12 + Aleksej Struk [EMAIL PROTECTED] babbled:

 Hi Raster,
 
 Please find two files attached : e_mod_main.c and e_mod_main.h
 To see the peace of code where E_CONFIG_SUB is used, please refer to
 function _lang_load_config.
 
 As I said in IRC, E_CONFIG_SUB works if the config file is already
 exist. Otherwise eet crashes.
 
 BTW. If u would require all the module code, in order to do testings,
 then please let me know :)

umm.. bk_next and bk_prev are not pointers.. they are literal structs. that's
why its not working. SUB expects a SUB struct POINTED to. otherwise you can
just declare the struct values directly as bk_next.key, bk_next.params etc.
etc. (instead of just the plain struct member - have it parent.child).

 Waiting for comments.
 
 aleksej
 
 -- 
 Aleksej Struk
 Master Degree Student
 Free University of Bozen-Bolzano
 Faculty of Computer Science
 phone: +39-0471-061749
 cell phone: +39-3204627049
 [EMAIL PROTECTED] [EMAIL PROTECTED] - http://www.
 


-- 
- Codito, ergo sum - I code, therefore I am --
The Rasterman (Carsten Haitzler)[EMAIL PROTECTED]
裸好多
Tokyo, Japan (東京 日本)


---
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


[E-devel] E_CONFIG_SUB

2006-05-08 Thread Aleksej Struk
Hi everybody,

Currently I'm trying to create a new module for E. Doing this I faced
with the following problem. I have the following module header:

typedef _Extra Extra;
typedef _Config Config;

struct _Extra
{
   int a;
   char *b;
};

stuct _Config
{
   int a;
   Extra *e;
};


I need to store the Config into the config file. The question is how to
deal with the sub-structure in the _Config structure. I tried to use
E_CONFIG_SUB, but I did not get any result. Unfortunatelly I did not
find any examples of using it. So, probably, I just incorectly used it.
But for me it seems to be as easy as with E_CONFIG_LIST :-\
THe following code illustrate the steps I do to load the data from
the confgi file :

E_Config_DD conf_edd;
E_Config_DD conf_extra_edd;



// Loading config :

   conf_extra_edd = E_CONFIG_DD_NEW(Extra_Config, Extra);
#undef T
#undef D
#define T Extra
#define D conf_extra_edd
   E_CONFIG_VAL(T, D, a, INT);
   E_CONFIG_VAL(T, D, b, STR);

   conf_edd = E_CONFIG_DD_NEW(Module_Config, Config);
#undef T
#undef D
#define T Config
#define D conf_edd
   E_CONFIG_VAL(T, D, a, INT);
   E_CONFIG_SUB(T, D, e, conf_extra_edd);

   m-conf = e_config_domain_load(module.somemodule, conf_edd);
   if (!m-conf)
 {
...
 }
...


What can be wrong with this code ?  Please help :)

sn


---
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel