Exemplo n.º 1
0
char *
EvfsFilereference_to_string(EvfsFilereference * ref)
{
   int length = 0;
   char *uri;
   Ecore_List *parent_list = ecore_list_new();
   EvfsFilereference *parent;

   ecore_list_prepend(parent_list, ref);
   length += strlen(ref->plugin_uri) + strlen("://");
   if (ref->username)
     {
        length +=
           strlen(ref->username) + strlen(ref->password) + strlen(":") +
           strlen("@");
     }
   length += strlen(ref->path);

   while ((parent = ref->parent))
     {
        ecore_list_prepend(parent_list, parent);

        length += strlen(parent->plugin_uri) + strlen("://");
        if (parent->username)
          {
             length +=
                strlen(parent->username) + strlen(parent->password) +
                strlen(":") + strlen("@");

          }

        length += strlen(parent->path);
        length += strlen("#");

     }
   length += 1;
   uri = calloc(length, sizeof(char));

   while ((parent = ecore_list_first_remove(parent_list)))
     {
        strcat(uri, parent->plugin_uri);
        strcat(uri, "://");
        if (parent->username)
          {
             strcat(uri, parent->username);
             strcat(uri, ":");
             strcat(uri, parent->password);
             strcat(uri, "@");
          }
        strcat(uri, parent->path);
        if (ecore_list_next(parent_list))
           strcat(uri, "#");
     }

   ecore_list_destroy(parent_list);

   return uri;

}
Exemplo n.º 2
0
/**
 * Move the current xml document pointer to the indicated node
 * @param   xml The xml document
 * @param   node The position within the document to move to
 * @return  The current xml tag name
 * @ingroup EXML_Traversal_Group
 */
char *exml_goto_node(EXML *xml, EXML_Node *node)
{
	Ecore_List *stack;
	EXML_Node *n, *l;

	CHECK_PARAM_POINTER_RETURN("xml", xml, NULL);

	stack = ecore_list_new();
	n = node;

	while( n->parent != NULL ) {
		ecore_list_prepend(stack, n);
		n = n->parent;
	}

	l = xml->top;

	if (n != l)
		return NULL;

	while( (n = ecore_list_first_remove(stack)) ) {
		l = ecore_list_goto(l->children, n);

		if (!l)
			return NULL;
	}

	xml->current = node;

	return xml->current ? xml->current->tag : NULL;
}
Exemplo n.º 3
0
void
widget_clear_ui_hooks( Ewler_Widget *w )
{
	Ecore_Hash *elems;
	Ecore_List *elems_stack;
	Ecore_List *names, *names_stack;
	char *name;

	names = ecore_hash_keys(w->elems);

	elems = w->elems;

	elems_stack = ecore_list_new();
	names_stack = ecore_list_new();

	while( (name = ecore_list_next(names)) ) {
		Ewler_Widget_Elem *elem;

		elem = ecore_hash_get(elems, name);

		elem->entry = NULL;
		elem->text = NULL;
		if( elem->items )
			ecore_hash_destroy(elem->items);
		elem->items = NULL;

		if( elem->spec->type == EWLER_SPEC_ELEM_STRUCT ) {
			ecore_list_prepend(elems_stack, elems);
			ecore_list_prepend(names_stack, names);

			elems = elem->info.children;
			names = ecore_hash_keys(elems);
		}

		while( !ecore_list_current(names) && elems != w->elems ) {
			ecore_list_destroy(names);
			elems = ecore_list_first_remove(elems_stack);
			names = ecore_list_first_remove(names_stack);
		}
	}

	ecore_list_destroy(names);
	ecore_list_destroy(elems_stack);
	ecore_list_destroy(names_stack);
}
Exemplo n.º 4
0
Arquivo: iclass.c Projeto: Limsik/e17
static ImageClass  *
ImageclassCreate(const char *name)
{
   ImageClass         *ic;

   ic = ECALLOC(ImageClass, 1);
   if (!ic)
      return NULL;

   if (!iclass_list)
      iclass_list = ecore_list_new();
   ecore_list_prepend(iclass_list, ic);

   ic->name = Estrdup(name);

   return ic;
}
Exemplo n.º 5
0
static MenuStyle   *
MenuStyleCreate(const char *name)
{
   MenuStyle          *ms;

   ms = ECALLOC(MenuStyle, 1);
   if (!ms)
      return NULL;

   if (!menu_style_list)
      menu_style_list = ecore_list_new();
   ecore_list_prepend(menu_style_list, ms);

   ms->name = Estrdup(name);
   ms->iconpos = ICON_LEFT;

   return ms;
}
Exemplo n.º 6
0
static ToolTip     *
TooltipCreate(const char *name, const char *ic0, const char *ic1,
	      const char *ic2, const char *ic3, const char *ic4,
	      const char *tclass, int dist, const char *tooltippic)
{
   ToolTip            *tt;
   ImageClass         *ic;

   if (!ic0 || !tclass)
      return NULL;

   ic = ImageclassAlloc(ic0, 0);
   if (!ic)
      return NULL;

   tt = ECALLOC(ToolTip, 1);
   if (!tt)
      return NULL;

   tt->name = Estrdup(name);
   tt->iclass[0] = ImageclassAlloc(ic1, 0);
   tt->iclass[1] = ImageclassAlloc(ic2, 0);
   tt->iclass[2] = ImageclassAlloc(ic3, 0);
   tt->iclass[3] = ImageclassAlloc(ic4, 0);
   tt->iclass[4] = ic;
   tt->tclass = TextclassAlloc(tclass, 1);
   tt->tooltippic = ImageclassAlloc(tooltippic, 0);

   tt->dist = dist;

   if (!tt_list)
      tt_list = ecore_list_new();
   ecore_list_prepend(tt_list, tt);

   return tt;
}
Exemplo n.º 7
0
/**
 * @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);
}
Exemplo n.º 8
0
void
inspector_update( Ecore_List *selected )
{
	Ewl_Widget *prow;
	Ecore_Sheap *slist, *sheap;
	Ecore_Hash *elems;
	Ecore_List *keys;
	Ecore_List *prow_stack, *sheap_stack, *elems_stack;
	Ewler_Widget *w;
	char *key;

	ewl_container_reset(EWL_CONTAINER(tree));

	if( !selected )
		return;
	/* add support for multiple selections later */
	w = ecore_list_first_goto(selected);

	if( !w )
		return;
	
	keys = ecore_hash_keys(w->elems);
	slist = ecore_sheap_new(ecore_str_compare, ecore_list_count(keys));

	while( (key = ecore_list_next(keys)) )
		ecore_sheap_insert(slist, key);

	ecore_list_destroy(keys);
	ecore_sheap_sort(slist);

	sheap = slist;
	elems = w->elems;

	sheap_stack = ecore_list_new();
	elems_stack = ecore_list_new();
	prow_stack = ecore_list_new();
	prow = NULL;

	while( (key = ecore_sheap_extract(sheap)) ) {
		Ewler_Widget_Elem *elem;
		Ewl_Widget *row_items[2], *row;
		Ewl_Widget *text, *entry;
		int len;

		elem = ecore_hash_get(elems, key);
		text = ewl_text_new(key);
		len = ewl_text_length_get(EWL_TEXT(text));
		ewl_text_cursor_position_set(EWL_TEXT(text), 0);
		if( elem->changed )
			ewl_text_color_apply(EWL_TEXT(text), 255, 0, 0, 255, len);

		switch( elem->spec->type ) {
			case EWLER_SPEC_ELEM_STRUCT: entry = NULL; break;
			case EWLER_SPEC_ELEM_ENUM:
				entry = ewl_combo_new(elem_to_s(elem));

				if( elem->items )
					ecore_hash_destroy(elem->items);

				elem->items = ecore_hash_new(ecore_direct_hash, ecore_direct_compare);
				
				keys = ecore_hash_keys(elem->spec->info.edata.map_rev);
				while( (key = ecore_list_next(keys)) ) {
					Ewl_Widget *combo_item;
					int value;

					value = (int) ecore_hash_get(elem->spec->info.edata.map_rev, key);

					combo_item = ewl_menu_item_new(NULL, key);
					ecore_hash_set(elem->items, (void *) value, combo_item);
					ewl_container_child_append(EWL_CONTAINER(entry), combo_item);
					ewl_widget_show(combo_item);
				}

				ecore_list_destroy(keys);

				ewl_callback_append(entry, EWL_CALLBACK_VALUE_CHANGED,
														combo_value_changed, elem);
				break;
			default:
				entry = ewl_entry_new(elem_to_s(elem));
				if( !elem->spec->modifiable )
					ewl_entry_editable_set(EWL_ENTRY(entry), false);

				ewl_callback_append(entry, EWL_CALLBACK_VALUE_CHANGED,
														entry_value_changed, elem);
				ewl_callback_append(entry, EWL_CALLBACK_DESELECT,
														entry_value_changed, elem);
				ewl_callback_append(entry, EWL_CALLBACK_FOCUS_OUT,
														entry_focus_out, elem);
				break;
		}

		elem->text = text;
		elem->entry = entry;

		row_items[0] = text;
		row_items[1] = entry;

		row = ewl_tree_row_add(EWL_TREE(tree), EWL_ROW(prow), row_items);
		ewl_widget_show(text);
		if( entry )
			ewl_widget_show(entry);

		if( elem->spec->type == EWLER_SPEC_ELEM_STRUCT ) {
			ecore_list_prepend(prow_stack, prow);
			ecore_list_prepend(sheap_stack, sheap);
			ecore_list_prepend(elems_stack, elems);

			prow = row;
			elems = elem->info.children;

			/* TODO: check for indexed struct */
			keys = ecore_hash_keys(elems);
			sheap = ecore_sheap_new(ecore_str_compare, ecore_list_count(keys));

			while( (key = ecore_list_next(keys)) )
				ecore_sheap_insert(sheap, key);

			ecore_list_destroy(keys);
			ecore_sheap_sort(sheap);
		}

		if( sheap->size == 0 && ecore_list_count(sheap_stack) ) {
			ecore_sheap_destroy(sheap);

			prow = ecore_list_first_remove(prow_stack);
			sheap = ecore_list_first_remove(sheap_stack);
			elems = ecore_list_first_remove(elems_stack);
		}
	}

	ecore_list_destroy(sheap_stack);
	ecore_list_destroy(elems_stack);
	ecore_sheap_destroy(slist);
}
Exemplo n.º 9
0
evfs_connection *
evfs_connect(void (*callback_func) (EvfsEvent *, void *), void *obj)
{
   ecore_init();
   ecore_ipc_init();
   int connect_attempts = 0;

   evfs_connection *connection = NEW(evfs_connection);

   connection->id = MAX_CLIENT;
   connection->prog_event = NULL;
   connection->callback_func = callback_func;
   connection->obj = obj;

   evfs_io_initialise();
   evfs_vfolder_initialise();

   if (!_libevfs_init)
     {
        _libevfs_init = 1;
	_libevfs_next_command_id = 1;
	evfs_session_servers = ecore_hash_new(ecore_direct_hash, ecore_direct_compare);

	/*Register the callback*/
        ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_DATA, evfs_server_data,
                                NULL);
        client_list = ecore_list_new();

        ecore_list_append(client_list, connection);
     }
   else
     {
        ecore_list_prepend(client_list, connection);
     }

 retry:

   if (connect_attempts > MAX_ATTEMPTS)
     {
        fprintf(stderr, "Could not start server after max attempts\n");
        exit(1);                /*We shouldn't really kill the libraries parent! */
        return NULL;
     }

   if (!
       (connection->server =
        ecore_ipc_server_connect(ECORE_IPC_LOCAL_USER, EVFS_IPC_TITLE,0,
                                 connection)))	   
     {	     
        fprintf(stderr,
                "Cannot connect to evfs server with '%s', making new server and trying again..\n",
                EVFS_IPC_TITLE);

        if (!connect_attempts)
          {
             if (evfs_server_spawn())
               {
                  printf("Failure to start evfs server!\n");
               }
          }

        connect_attempts++;
        usleep(100000 * connect_attempts);
        goto retry;

     } else {
	     ecore_hash_set(evfs_session_servers, connection->server, (int*)1);

	     while (connection->id == MAX_CLIENT) {
		        /*printf("Waiting for connection id..\n");*/
			ecore_main_loop_iterate();
	     }
	     /*printf("Got connection ID: %d\n", connection->id);*/
	     
     }

   return connection;
}