/**
 * @return Returns no value
 * @brief Called when the icon theme is changed so we can clean up any
 * caching we have in place
 */
void
ewl_icon_theme_theme_change(void)
{
        const char *icon_theme;

        DENTER_FUNCTION(DLEVEL_STABLE);

        icon_theme = ewl_config_string_get(ewl_config, EWL_CONFIG_THEME_ICON_THEME);

        /* check if this is an edje theme */
        if (icon_theme && (!strncasecmp(icon_theme + (strlen(icon_theme) - 4),
                                              ".edj", 4)))
                ewl_icon_theme_is_edje = 1;
        else
                ewl_icon_theme_is_edje = 0;

        /* destroy the cache and re-create it */
        IF_FREE_HASH(ewl_icon_theme_cache);

        ewl_icon_theme_cache = ecore_hash_new(ecore_str_hash, ecore_str_compare);
        ecore_hash_free_key_cb_set(ewl_icon_theme_cache, ewl_icon_theme_cb_free);
        ecore_hash_free_value_cb_set(ewl_icon_theme_cache, free);

        DLEAVE_FUNCTION(DLEVEL_STABLE);
}
/**
 * @return Returns TRUE on success or FALSE on failure
 * @brief Initializes the icon theme system
 */
int
ewl_icon_theme_init(void)
{
        DENTER_FUNCTION(DLEVEL_STABLE);

        if (!ewl_icon_theme_cache)
        {
                ewl_icon_theme_cache = ecore_hash_new(ecore_str_hash, ecore_str_compare);
                ecore_hash_free_key_cb_set(ewl_icon_theme_cache, ewl_icon_theme_cb_free);
                ecore_hash_free_value_cb_set(ewl_icon_theme_cache, free);

                ewl_icon_fallback_theme_cache = ecore_hash_new(
                                                ecore_str_hash, ecore_str_compare);
                ecore_hash_free_key_cb_set(ewl_icon_fallback_theme_cache,
                                                ewl_icon_theme_cb_free);
                ecore_hash_free_value_cb_set(ewl_icon_fallback_theme_cache,
                                                free);
        }

        DRETURN_INT(TRUE, DLEVEL_STABLE);
}
Exemple #3
0
/**
 * Initialize an XML_Node to starting values
 * @param   node The node to initialize
 * @return  @c TRUE if successful, @c FALSE if an error occurs.
 * @ingroup EXML_Creation_Group
 */
int exml_node_init(EXML_Node *node)
{
	CHECK_PARAM_POINTER_RETURN("node", node, FALSE);

	node->attributes = ecore_hash_new( ecore_str_hash, ecore_str_compare );
	ecore_hash_free_value_cb_set( node->attributes, free );
	ecore_hash_free_key_cb_set( node->attributes, free );
	node->children = ecore_list_new();
	ecore_list_free_cb_set( node->children, _exml_node_destroy );

	return TRUE;
}
Exemple #4
0
static void
eina_bench_lookup_ecore(int request)
{
   Ecore_Hash *hash = NULL;
   Eina_Bench_Ecore *elm;
   unsigned int i;
   unsigned int j;

   hash = ecore_hash_new(ecore_str_hash, ecore_str_compare);

   ecore_hash_free_key_cb_set(hash, NULL);
   ecore_hash_free_value_cb_set(hash, free);

   for (i = 0; i < (unsigned int)request; ++i)
     {
        elm = malloc(sizeof (Eina_Bench_Ecore) + 10);
        if (!elm)
           continue;

        elm->key = (char *)(elm + 1);
        eina_convert_itoa(i, elm->key);
        elm->value = i;

        ecore_hash_set(hash, elm->key, elm);
     }

   srand(time(NULL));

   for (j = 0; j < 200; ++j)
      for (i = 0; i < (unsigned int)request; ++i)
        {
           char tmp_key[10];

           eina_convert_itoa(rand() % request, tmp_key);

           elm = ecore_hash_get(hash, tmp_key);
        }

   ecore_hash_destroy(hash);
}
/**
 * @return Returns TRUE on successful initialization, FALSE otherwise
 * @brief Initializes the IO manager system.
 */
int
ewl_io_manager_init(void)
{
        DENTER_FUNCTION(DLEVEL_STABLE);

        if (!ewl_io_manager_ext_icon_map)
        {
                /* XXX this is a dumb way to do this.... */
                ewl_io_manager_ext_icon_map = ecore_hash_new(ecore_str_hash,
                                                ewl_io_manager_strcasecompare);
                /* Images */
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".png",
                                                EWL_ICON_IMAGE_X_GENERIC);
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".jpg",
                                                EWL_ICON_IMAGE_X_GENERIC);
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".gif",
                                                EWL_ICON_IMAGE_X_GENERIC);

                /* Videos */
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".wmv",
                                                EWL_ICON_VIDEO_X_GENERIC);
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".mpg",
                                                EWL_ICON_VIDEO_X_GENERIC);
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".mpeg",
                                                EWL_ICON_VIDEO_X_GENERIC);
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".avi",
                                                EWL_ICON_VIDEO_X_GENERIC);
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".mov",
                                                EWL_ICON_VIDEO_X_GENERIC);
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".asf",
                                                EWL_ICON_VIDEO_X_GENERIC);
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".mp4",
                                                EWL_ICON_VIDEO_X_GENERIC);
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".mkv",
                                                EWL_ICON_VIDEO_X_GENERIC);
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".ogm",
                                                EWL_ICON_VIDEO_X_GENERIC);

                /* Audio */
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".mp3",
                                                EWL_ICON_AUDIO_X_GENERIC);
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".mka",
                                                EWL_ICON_AUDIO_X_GENERIC);
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".ogg",
                                                EWL_ICON_AUDIO_X_GENERIC);

                /* HTML */
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".html",
                                                EWL_ICON_TEXT_HTML);
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".htm",
                                                EWL_ICON_TEXT_HTML);

                /* Scirpts */
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".pl",
                                                EWL_ICON_TEXT_X_SCRIPT);
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".sh",
                                                EWL_ICON_TEXT_X_SCRIPT);
                ecore_hash_set(ewl_io_manager_ext_icon_map, ".ksh",
                                                EWL_ICON_TEXT_X_SCRIPT);

                ewl_io_manager_plugins = ecore_hash_new(ecore_str_hash,
                                                        ecore_str_compare);
                ecore_hash_free_key_cb_set(ewl_io_manager_plugins, free);
                ecore_hash_free_value_cb_set(ewl_io_manager_plugins,
                                                ewl_io_manager_cb_free_plugin);
        }

        DRETURN_INT(TRUE, DLEVEL_STABLE);
}
Exemple #6
0
/**
 * initialize this project manager.  called from main
 */
int
projects_init( char *filename )
{
	Ewl_Widget *vbox, *menu, *project_menu, *settings_menu, *windows_menu, *item;

	/* ui phase... kick on some phat window action */
	project_win = ewl_window_new();
	ewl_window_title_set(EWL_WINDOW(project_win), "Ewler");
	ewl_object_size_request(EWL_OBJECT(project_win), 200, 320);
	ewl_callback_append(project_win, EWL_CALLBACK_DELETE_WINDOW,
											project_exit, NULL);
	ewl_callback_append(project_win, EWL_CALLBACK_KEY_DOWN,
											project_key_down, NULL);

	vbox = ewl_vbox_new();
	ewl_container_child_append(EWL_CONTAINER(project_win), vbox);

	menu = ewl_hmenubar_new();
	ewl_container_child_append(EWL_CONTAINER(vbox), menu);

	project_menu = ewl_menubar_menu_add(EWL_MENUBAR(menu), NULL, "Project");

	item = ewl_menu_item_new(NULL, "New");
	ewl_container_child_append(EWL_CONTAINER(project_menu), item);
	ewl_widget_show(item);

	item = ewl_menu_item_new(NULL, "New Form");
	ewl_container_child_append(EWL_CONTAINER(project_menu), item);
	ewl_callback_append(item, EWL_CALLBACK_CLICKED, form_new, NULL);
	ewl_widget_show(item);

	item = ewl_menu_item_new(NULL, "Open...");
	ewl_container_child_append(EWL_CONTAINER(project_menu), item);
	ewl_callback_append(item, EWL_CALLBACK_CLICKED, open, NULL);
	ewl_widget_show(item);

	item = ewl_menu_separator_new();
	ewl_container_child_append(EWL_CONTAINER(project_menu), item);
	ewl_widget_show(item);

	item = ewl_menu_item_new(NULL, "Save");
	ewl_callback_append(item, EWL_CALLBACK_CLICKED, save, NULL);
	ewl_container_child_append(EWL_CONTAINER(project_menu), item);
	ewl_widget_show(item);

	item = ewl_menu_separator_new();
	ewl_container_child_append(EWL_CONTAINER(project_menu), item);
	ewl_widget_show(item);

	item = ewl_menu_item_new(NULL, "Exit");
	ewl_callback_append(item, EWL_CALLBACK_CLICKED,
											project_exit, NULL);
	ewl_container_child_append(EWL_CONTAINER(project_menu), item);
	ewl_widget_show(item);

	ewl_widget_show(project_menu);

	settings_menu = ewl_menubar_menu_add(EWL_MENUBAR(menu), NULL, "Settings");

	item = ewl_menu_item_new(NULL, "Options...");
	ewl_container_child_append(EWL_CONTAINER(settings_menu), item);
	ewl_callback_append(item, EWL_CALLBACK_CLICKED,
											options, NULL);
	ewl_widget_show(item);

	ewl_widget_show(settings_menu);

	windows_menu = ewl_menubar_menu_add(EWL_MENUBAR(menu), NULL, "Windows");

	item = ewl_menu_item_new(NULL, "Toolbar");
	ewl_container_child_append(EWL_CONTAINER(windows_menu), item);
	ewl_callback_append(item, EWL_CALLBACK_CLICKED, tools_toggle, NULL);
	ewl_widget_show(item);

	item = ewl_menu_item_new(NULL, "Inspector");
	ewl_container_child_append(EWL_CONTAINER(windows_menu), item);
	ewl_callback_append(item, EWL_CALLBACK_CLICKED, inspector_toggle, NULL);
	ewl_widget_show(item);

	item = ewl_menu_item_new(NULL, "Callbacks");
	ewl_container_child_append(EWL_CONTAINER(windows_menu), item);
	ewl_callback_append(item, EWL_CALLBACK_CLICKED, callbacks_toggle, NULL);
	ewl_widget_show(item);

	ewl_widget_show(windows_menu);

	ewl_widget_show(menu);

	file_tree = ewl_tree_new(1);
	ewl_tree_mode_set(EWL_TREE(file_tree), EWL_TREE_MODE_SINGLE);
	ewl_container_child_append(EWL_CONTAINER(vbox), file_tree);
	ewl_widget_show(file_tree);

	ewl_widget_show(vbox);
	ewl_widget_show(project_win);
	/* end ui phase */

	/* project phase */
	active_project = NEW(Ewler_Project);
	if( !active_project ) {
		ewler_error("projects_init: out of memory!");
		return -1;
	}
	active_project->files = ecore_hash_new(ecore_str_hash, ecore_str_compare);
	ecore_hash_free_key_cb_set(active_project->files, free);
	ecore_hash_free_value_cb_set(active_project->files, free);

	if( !filename || project_open(filename) < 0 ) {
		project_new();
	}
	/* end project phase */

	return 0;
}
Exemple #7
0
void eli_highscore_init(const char * app)
{
    char buffer[1024];
    char * home;
    Eet_File * ef;
    eet_init();

    edd_entry = eet_data_descriptor_new("Eli_Highscore_Entry",
                                        sizeof(Eli_Highscore_Entry),
                                        (list_next) eina_list_next,
                                        (list_append) eina_list_append,
                                        (list_data) eina_list_data_get,
                                        (list_free) eina_list_free,
                                        (hash_foreach) eina_hash_foreach,
                                        (hash_add) eina_hash_add /* FIXME: YOU SHOULD NOT USE EINA_HASH_ADD DIRECTLY */,
                                        (hash_free) eina_hash_free);

    EET_DATA_DESCRIPTOR_ADD_BASIC(edd_entry, Eli_Highscore_Entry,
                                  "username", username, EET_T_STRING);
    EET_DATA_DESCRIPTOR_ADD_BASIC(edd_entry, Eli_Highscore_Entry,
                                  "points", points, EET_T_FLOAT);
    EET_DATA_DESCRIPTOR_ADD_BASIC(edd_entry, Eli_Highscore_Entry,
                                  "type", type, EET_T_INT);

    edd_hiscore = eet_data_descriptor_new("Eli_Highscore",
                                          sizeof(Eli_Highscore),
                                          (list_next) eina_list_next,
                                          (list_append) eina_list_append,
                                          (list_data) eina_list_data_get,
                                          (list_free) eina_list_free,
                                          (hash_foreach) eina_hash_foreach,
                                          (hash_add) eina_hash_add /* FIXME: YOU SHOULD NOT USE EINA_HASH_ADD DIRECTLY */,
                                          (hash_free) eina_hash_free);

    EET_DATA_DESCRIPTOR_ADD_LIST(edd_hiscore, Eli_Highscore,
                                 "entries", entries, edd_entry);

    /* this is just a temporally hack, the right path should be
     * some thing like /var/games/elitaire.score, but
     * for some reasons eet segv when the directory is not
     * writable, although the file is */
    home = getenv("HOME");
    if (!home)
	    home = "/tmp";

    snprintf(buffer, sizeof(buffer), 
		    "%s/.e/apps/%s/score.eet", home, app);
    eet_file_name = strdup(buffer);

    /*
     * setup the hiscore hash
     */
    hiscore_hash = ecore_hash_new(ecore_str_hash, ecore_str_compare);
    ecore_hash_free_key_cb_set(hiscore_hash, free);

    /*
     * fill the hash
     */
    ef = eet_open(eet_file_name, EET_FILE_MODE_READ);

    if (ef) {
        char **list;
	int num, i;

	list = eet_list(ef, "*", &num);
	
	for(i = 0; i < num; i++) {
	    Eli_Highscore * hiscore;

	    hiscore = eet_data_read(ef, edd_hiscore, list[i]);
	    ecore_hash_set(hiscore_hash, strdup(list[i]), hiscore->entries);
	}
	free(list);
	eet_close(ef);
    }
}