/** * 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; }
/** * Initialize an xml stylesheet structure to some sane starting values. * @param xsl The stylesheet to initialize. * @return @c TRUE if successful, @c FALSE if an error occurs. * @ingroup EXML_XSLT_Group */ int exml_xsl_init( EXML_XSL *xsl, char *filename ) { CHECK_PARAM_POINTER_RETURN("xsl", xsl, FALSE); xmlSubstituteEntitiesDefault(1); xmlLoadExtDtdDefaultValue = 1; xsl->buffers = ecore_list_new(); ecore_list_free_cb_set(xsl->buffers, ECORE_FREE_CB(xmlFree)); xsl->cur = xsltParseStylesheetFile((const xmlChar *) filename); if( !xsl->cur ) return FALSE; return TRUE; }
int main (int argc, char *argv[]) { Ecore_List *str_data = NULL; Ewl_Widget *window; Ewl_Widget *hbox; Ewl_Widget *list; Ewl_Model *model; Ewl_View *view; Ewl_Widget *dvi; Ewl_Widget *sp; const Edvi_Document *document; int page_count; int i; if (argc == 1) { printf ("Usage: %s dvi_file\n", argv[0]); return EXIT_FAILURE; } printf ("[DVI] version : %s\n", edvi_version_get ()); if (!edvi_init (300, "cx", 4, 1.0, 1.0, 0, 255, 255, 255, 0, 0, 0)) return EXIT_FAILURE; ewl_init (&argc, (char **)argv); str_data = ecore_list_new(); ecore_list_free_cb_set (str_data, free); /* We open the dvi file */ dvi = ewl_dvi_new (); if (!ewl_dvi_file_set (EWL_DVI (dvi), argv[1])) { printf ("Can not load the document %s\nExiting...", argv[1]); ecore_list_destroy (str_data); ewl_main_quit(); return EXIT_FAILURE; } window = ewl_window_new (); ewl_window_title_set (EWL_WINDOW (window), "Ewl Dvi Test Application"); ewl_callback_append (window, EWL_CALLBACK_DELETE_WINDOW, _quit_cb, str_data); hbox = ewl_hbox_new (); ewl_box_homogeneous_set (EWL_BOX (hbox), FALSE); ewl_container_child_append (EWL_CONTAINER (window), hbox); ewl_widget_show (hbox); sp = ewl_scrollpane_new (); ewl_container_child_append (EWL_CONTAINER (hbox), sp); ewl_widget_show (sp); document = ewl_dvi_dvi_document_get (EWL_DVI (dvi)); page_count = edvi_document_page_count_get (document); for (i = 0; i < page_count; i++) { char row_text[64]; char *txt; snprintf (row_text, 64, "%d", i + 1); txt = strdup (row_text); ecore_list_append(str_data, txt); } model = ewl_model_ecore_list_instance(); view = ewl_label_view_get(); list = ewl_list_new (); ewl_mvc_model_set(EWL_MVC(list), model); ewl_mvc_view_set(EWL_MVC(list), view); ewl_mvc_data_set(EWL_MVC(list), str_data); ewl_callback_append (list, EWL_CALLBACK_VALUE_CHANGED, EWL_CALLBACK_FUNCTION (_change_page_cb), dvi); ewl_container_child_append (EWL_CONTAINER (sp), list); ewl_widget_show (list); ewl_dvi_mag_set (EWL_DVI (dvi), 0.5); ewl_container_child_append (EWL_CONTAINER (hbox), dvi); ewl_widget_show (dvi); ewl_widget_show (window); ewl_main (); edvi_shutdown (); return EXIT_SUCCESS; }
/** * @param argc: the argc passed into the main function * @param argv: the argv passed into the main function * @return Returns 1 or greater on success, 0 otherwise. * @brief Initialize the internal variables of ewl to begin the program * * Sets up necessary internal variables for executing ewl * functions. This should be called before any other ewl functions are used. */ int ewl_init(int *argc, char **argv) { const char *locale; DENTER_FUNCTION(DLEVEL_STABLE); /* check if we are already initialized */ if (++ewl_init_count > 1) DRETURN_INT(ewl_init_count, DLEVEL_STABLE); /* set the locale for string collation if it isn't already set */ locale = setlocale(LC_COLLATE, NULL); if (strcmp(locale, "C") || strcmp(locale, "POSIX")) { setlocale(LC_COLLATE, ""); } shutdown_queue = ecore_list_new(); if (!shutdown_queue) { fprintf(stderr, "Could not create Ewl shutdown queue.\n"); goto FAILED; } if (!ecore_init()) { fprintf(stderr, "Could not initialize Ecore.\n"); goto FAILED; } ecore_list_prepend(shutdown_queue, ecore_shutdown); #ifdef BUILD_EFREET_SUPPORT if (!efreet_init()) { fprintf(stderr, "Could not initialize Efreet.\n"); goto FAILED; } ecore_list_prepend(shutdown_queue, efreet_shutdown); if (!efreet_mime_init()) { fprintf(stderr, "Could not initialize Efreet_Mime.\n"); goto FAILED; } ecore_list_prepend(shutdown_queue, efreet_mime_shutdown); #endif if (!ecore_string_init()) { fprintf(stderr, "Could not initialize Ecore Strings.\n"); goto FAILED; } ecore_list_prepend(shutdown_queue, ecore_string_shutdown); reveal_list = ecore_list_new(); obscure_list = ecore_list_new(); configure_active = ecore_list_new(); configure_available = ecore_list_new(); realize_list = ecore_list_new(); destroy_list = ecore_list_new(); free_evas_list = ecore_list_new(); free_evas_object_list = ecore_list_new(); child_add_list = ecore_list_new(); ewl_embed_list = ecore_list_new(); ewl_window_list = ecore_list_new(); shutdown_hooks = ecore_list_new(); if ((!reveal_list) || (!obscure_list) || (!configure_active) || (!configure_available) || (!realize_list) || (!destroy_list) || (!free_evas_list) || (!free_evas_object_list) || (!child_add_list) || (!ewl_embed_list) || (!ewl_window_list) || (!shutdown_hooks)) { fprintf(stderr, "Unable to initialize internal configuration." " Out of memory?\n"); goto FAILED; } /* * Cleanup the queue buffers when the management lists get freed. */ ecore_list_free_cb_set(configure_active, free); ecore_list_free_cb_set(configure_available, free); if (!ewl_system_directories_init()) { fprintf(stderr, "Could not initialize the system" " directories.\n"); goto FAILED; } ecore_list_prepend(shutdown_queue, ewl_system_directories_shutdown); /* now that the directories are init we can also set the text domain */ #ifdef ENABLE_NLS bindtextdomain(PACKAGE, ewl_system_directory_get(EWL_DIRECTORY_LOCALE)); bind_textdomain_codeset(PACKAGE, "UTF-8"); #endif if (!ewl_config_init()) { fprintf(stderr, "Could not initialize Ewl Config.\n"); goto FAILED; } ecore_list_prepend(shutdown_queue, ewl_config_shutdown); if (!ewl_engines_init()) { fprintf(stderr, "Could not intialize Ewl Engines.\n"); goto FAILED; } ecore_list_prepend(shutdown_queue, ewl_engines_shutdown); /* handle any command line options */ ewl_init_parse_options(argc, argv); /* initialize this _after_ we've handled the command line options */ ewl_config_cache_init(); /* we create the engine we will be working with here so that it is * initialized before we start to use it. */ if (!ewl_engine_new(ewl_config_string_get(ewl_config, EWL_CONFIG_ENGINE_NAME), argc, argv)) { fprintf(stderr, "Could not initialize Ewl Engine.\n"); goto FAILED; } if (!ewl_callbacks_init()) { fprintf(stderr, "Could not initialize Ewl Callback system.\n"); goto FAILED; } ecore_list_prepend(shutdown_queue, ewl_callbacks_shutdown); /* allocate the two window callbacks */ EWL_CALLBACK_EXPOSE = ewl_callback_type_add(); EWL_CALLBACK_DELETE_WINDOW = ewl_callback_type_add(); /* allocate the mvc callback */ EWL_CALLBACK_MVC_CLICKED = ewl_callback_type_add(); if (!ewl_theme_init()) { fprintf(stderr, "Could not setup Ewl Theme system.\n"); goto FAILED; } ecore_list_prepend(shutdown_queue, ewl_theme_shutdown); if (!ewl_icon_theme_init()) { fprintf(stderr, "Could not initialize Ewl Icon Theme system.\n"); goto FAILED; } ecore_list_prepend(shutdown_queue, ewl_icon_theme_shutdown); if (!ewl_dnd_init()) { fprintf(stderr, "Could not initialize Ewl DND support.\n"); goto FAILED; } ecore_list_prepend(shutdown_queue, ewl_dnd_shutdown); if (!ewl_io_manager_init()) { fprintf(stderr, "Could not initialize Ewl IO Manager.\n"); goto FAILED; } ecore_list_prepend(shutdown_queue, ewl_io_manager_shutdown); if (!ewl_text_context_init()) { fprintf(stderr, "Could not initialize Ewl Text Context system.\n"); goto FAILED; } ecore_list_prepend(shutdown_queue, ewl_text_context_shutdown); if (!(idle_enterer = ecore_idle_enterer_add(ewl_idle_render, NULL))) { fprintf(stderr, "Could not create Idle Enterer.\n"); goto FAILED; } DRETURN_INT(ewl_init_count, DLEVEL_STABLE); FAILED: ewl_shutdown(); DRETURN_INT(ewl_init_count, DLEVEL_STABLE); }
/** * @param path: The path to the directory to read * @param show_dot: TRUE shows dot files, FALSE does not * @param show_dot_dot: TRUE shows .. for navigating upwards, FALSE does not * @param filter: The Ewl_Filelist_Filter to use * @return Returns an Ewl_Filelist_Directory structure * @brief Retrieves all files in a directory */ Ewl_Filelist_Directory * ewl_filelist_model_directory_new(const char *path, unsigned char show_dot, unsigned int show_dot_dot, Ewl_Filelist_Filter *filter) { Ewl_Filelist_Directory *dir; Ewl_Filelist_File *file; char filename[PATH_MAX], *file_temp; int nf = 0, nd = 0; Eina_List *all_files; Ecore_List *dirs, *files; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR_RET(path, NULL); files = ecore_list_new(); dirs = ecore_list_new(); ecore_list_free_cb_set(files, ECORE_FREE_CB(ewl_filelist_file_destroy)); ecore_list_free_cb_set(dirs, ECORE_FREE_CB(ewl_filelist_file_destroy)); all_files = ecore_file_ls(path); if (!all_files) DRETURN_PTR(NULL, DLEVEL_STABLE); /* Add in the ".." entry for now */ if ((show_dot_dot) && (strcmp(path, "/"))) all_files = eina_list_prepend(all_files, strdup(path)); EINA_LIST_FREE(all_files, file_temp) { /* allocate the memory for the file structure */ file = ewl_filelist_file_new(); if (!file) { ecore_list_destroy(files); ecore_list_destroy(dirs); DRETURN_PTR(NULL, DLEVEL_STABLE); } /* test for .. */ if (strcmp(file_temp, path)) { snprintf(filename, PATH_MAX, "%s/%s", path, file_temp); ewl_filelist_file_name_set(file, file_temp); } else { snprintf(filename, PATH_MAX, "%s", file_temp); ewl_filelist_file_name_set(file, ".."); } /* Generate the file information */ if (!ewl_filelist_file_path_set(file, filename)) { ewl_filelist_file_destroy(file); ecore_list_destroy(files); ecore_list_destroy(dirs); DRETURN_PTR(NULL, DLEVEL_STABLE); } if (ewl_filelist_file_is_dir(file)) { ecore_list_append(dirs, file); nd = nd + 1; } else { ecore_list_append(files, file); nf = nf + 1; } FREE(file_temp); }