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

/* local subsystem functions */
typedef struct _E_Theme_Result E_Theme_Result;

struct _E_Theme_Result
{
   char *file;
   char *cache;
};

static Evas_Bool _e_theme_mappings_free_cb(Evas_Hash *hash, const char *key, void *data, void *fdata);
static void      _e_theme_category_register(const char *category);
static void      _e_theme_transition_register(const char *transition);

/* local subsystem globals */
static Evas_Hash *mappings = NULL;
static Evas_Hash *group_cache = NULL;

static Evas_List *categories = NULL;
static Evas_List *transitions = NULL;

/* externally accessible functions */

int
e_theme_init(void)
{
   Evas_List *l;
   E_Theme_Result *res;
   char *category, *p;
   
   /* this is a fallback that is ALWAYS there - if all fails things will */
   /* always fall back to the default theme. the rest after this are config */
   /* values users can set */
   e_theme_file_set("base", "default.edj");
   
   for (l = e_config->themes; l; l = l->next)
     {
	E_Config_Theme *et;
	char buf[256];
	
	et = l->data;
	snprintf(buf, sizeof(buf), "base/%s", et->category);
	e_theme_file_set(buf, et->file);
     }

   /* Find transitions */
   category = strdup("base/theme/transitions");
   if (category)
     {
	do
	  {
	     res = evas_hash_find(mappings, category);
	     if (res)
	       {
		  char *str;

		  /* if found check cached path */
		  str = res->cache;
		  if (!str)
		    {
		       /* no cached path */
		       str = res->file;
		       /* if its not an absolute path find it */
		       if (str[0] != '/')
			 str = e_path_find(path_themes, str);
		       /* save cached value */
		       if (str) res->cache = str;
		    }
		  if (str)
		    {
		       Evas_List *coll, *l;
		       coll = edje_file_collection_list(str);
		       if (coll)
			 {
			    for (l = coll; l; l = l->next)
			      {
				 if (!strncmp(l->data, "transitions", 11))
				   {
				      char *trans;

				      trans = strdup(l->data);
				      p = strchr(trans, '/');
				      if (p)
					{
					   p++;
					   _e_theme_transition_register(p);
					}
				      free(trans);
				   }
			      }
			    edje_file_collection_list_free(coll);
			 }
		    }
	       }
	     p = strrchr(category, '/');
	     if (p) *p = 0;
	  }
	while (p);
	free(category);
     }

   return 1;
}

/*
 * this is used to sewt the theme for a CATEGORY of e17. "base" is always set
 * to the default theme - because if a selected theme for lest say base/theme
 * does not provide theme elements it can default back to the default theme.
 * 
 * the idea is you can actually set a different theme for different parts of
 * the desktop... :)
 * 
 * other possible categories...
 *  e_theme_file_set("base/theme/borders", "default.edj");
 *  e_theme_file_set("base/theme/background", "default.edj");
 *  e_theme_file_set("base/theme/menus", "default.edj");
 *  e_theme_file_set("base/theme/error", "default.edj");
 *  e_theme_file_set("base/theme/gadman", "default.edj");
 *  e_theme_file_set("base/theme/dnd", "default.edj");
 *  e_theme_file_set("base/theme/icons", "default.edj");
 *  e_theme_file_set("base/theme/modules", "default.edj");
 *  e_theme_file_set("base/theme/modules/pager", "default.edj");
 *  e_theme_file_set("base/theme/modules/ibar", "default.edj");
 *  e_theme_file_set("base/theme/modules/clock", "default.edj");
 *  e_theme_file_set("base/theme/modules/battery", "default.edj");
 *  e_theme_file_set("base/theme/modules/cpufreq", "default.edj");
 *  e_theme_file_set("base/theme/modules/temperature", "default.edj");
 */

int
e_theme_shutdown(void)
{
   if (mappings)
     {
	evas_hash_foreach(mappings, _e_theme_mappings_free_cb, NULL);
	evas_hash_free(mappings);
	mappings = NULL;
     }
   if (group_cache)
     {
	evas_hash_free(group_cache);<commit_msg>Update list with known groups.<commit_after>/*
 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
 */
#include "e.h"

/* local subsystem functions */
typedef struct _E_Theme_Result E_Theme_Result;

struct _E_Theme_Result
{
   char *file;
   char *cache;
};

static Evas_Bool _e_theme_mappings_free_cb(Evas_Hash *hash, const char *key, void *data, void *fdata);
static void      _e_theme_category_register(const char *category);
static void      _e_theme_transition_register(const char *transition);

/* local subsystem globals */
static Evas_Hash *mappings = NULL;
static Evas_Hash *group_cache = NULL;

static Evas_List *categories = NULL;
static Evas_List *transitions = NULL;

/* externally accessible functions */

int
e_theme_init(void)
{
   Evas_List *l;
   E_Theme_Result *res;
   char *category, *p;
   
   /* this is a fallback that is ALWAYS there - if all fails things will */
   /* always fall back to the default theme. the rest after this are config */
   /* values users can set */
   e_theme_file_set("base", "default.edj");
   
   for (l = e_config->themes; l; l = l->next)
     {
	E_Config_Theme *et;
	char buf[256];
	
	et = l->data;
	snprintf(buf, sizeof(buf), "base/%s", et->category);
	e_theme_file_set(buf, et->file);
     }

   /* Find transitions */
   category = strdup("base/theme/transitions");
   if (category)
     {
	do
	  {
	     res = evas_hash_find(mappings, category);
	     if (res)
	       {
		  char *str;

		  /* if found check cached path */
		  str = res->cache;
		  if (!str)
		    {
		       /* no cached path */
		       str = res->file;
		       /* if its not an absolute path find it */
		       if (str[0] != '/')
			 str = e_path_find(path_themes, str);
		       /* save cached value */
		       if (str) res->cache = str;
		    }
		  if (str)
		    {
		       Evas_List *coll, *l;
		       coll = edje_file_collection_list(str);
		       if (coll)
			 {
			    for (l = coll; l; l = l->next)
			      {
				 if (!strncmp(l->data, "transitions", 11))
				   {
				      char *trans;

				      trans = strdup(l->data);
				      p = strchr(trans, '/');
				      if (p)
					{
					   p++;
					   _e_theme_transition_register(p);
					}
				      free(trans);
				   }
			      }
			    edje_file_collection_list_free(coll);
			 }
		    }
	       }
	     p = strrchr(category, '/');
	     if (p) *p = 0;
	  }
	while (p);
	free(category);
     }

   return 1;
}

/*
 * this is used to sewt the theme for a CATEGORY of e17. "base" is always set
 * to the default theme - because if a selected theme for lest say base/theme
 * does not provide theme elements it can default back to the default theme.
 * 
 * the idea is you can actually set a different theme for different parts of
 * the desktop... :)
 * 
 * other possible categories...
 *  e_theme_file_set("base/theme/about", "default.edj");
 *  e_theme_file_set("base/theme/borders", "default.edj");
 *  e_theme_file_set("base/theme/background", "default.edj");
 *  e_theme_file_set("base/theme/configure", "default.edj");
 *  e_theme_file_set("base/theme/dialog", "default.edj");
 *  e_theme_file_set("base/theme/menus", "default.edj");
 *  e_theme_file_set("base/theme/error", "default.edj");
 *  e_theme_file_set("base/theme/gadman", "default.edj");
 *  e_theme_file_set("base/theme/dnd", "default.edj");
 *  e_theme_file_set("base/theme/icons", "default.edj");
 *  e_theme_file_set("base/theme/pointer", "default.edj");
 *  e_theme_file_set("base/theme/transitions", "default.edj");
 *  e_theme_file_set("base/theme/widgets", "default.edj");
 *  e_theme_file_set("base/theme/winlist", "default.edj");
 *  e_theme_file_set("base/theme/modules", "default.edj");
 *  e_theme_file_set("base/theme/modules/pager", "default.edj");
 *  e_theme_file_set("base/theme/modules/ibar", "default.edj");
 *  e_theme_file_set("base/theme/modules/ibox", "default.edj");
 *  e_theme_file_set("base/theme/modules/clock", "default.edj");
 *  e_theme_file_set("base/theme/modules/battery", "default.edj");
 *  e_theme_file_set("base/theme/modules/cpufreq", "default.edj");
 *  e_theme_file_set("base/theme/modules/start", "default.edj");
 *  e_theme_file_set("base/theme/modules/temperature", "default.edj");
 */

int
e_theme_shutdown(void)
{
   if (mappings)
     {
	evas_hash_foreach(mappings, _e_theme_mappings_free_cb, NULL);
	evas_hash_free(mappings);
	mappings = NULL;
     }
   if (group_cache)
     {
	evas_hash_free(group_cache);
{'fraction_non_alphanumeric': 0.14473684210526316, 'fraction_numerical': 0.0043457267020762915, 'mean_word_length': 2.983173076923077, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, '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': '6154878', 'n_tokens_mistral': 3230, 'n_tokens_neox': 2948, 'n_words': 643}