All pastes #171201 Raw Edit

Mine

public text v1 · immutable
·published 2006-09-15 05:11 UTC
rendered paste body
Ewl_Widget      *ewl_io_manager_convert(Ewl_Widget *w,
                                        const char *from_mime, 
                                        const char *to_mime);
unsigned int     ewl_io_manager_can_convert(const char *from_mime, 
                                                const char *to_mime);

void             ewl_io_manager_plugin_mime_register(const char *mime,
                                                Ewl_IO_Manager_Plugin *plugin);

void             ewl_io_manager_plugin_convert_register(const char *from_type, const char *to_mime,
                                                Ewl_IO_Manager_Plugin *plugin);

The _mime_register is used to specify mime types that we load/save. So:

_mime_register("application/pdf", pdf_plugin)
_mime_register("image", image_plugin),
_mime_register("text", text_plain_plugin)
 _mime_register("text/html", html_plugin)

the _convert_register calls are used to register what we can convert. They take the widget type name (the widget type name is widget/<WIDGET_TYPE> so widget/pdf, widget/text etc basically widget/EWL_*_TYPE) and the mime we convert too. so:

_convert_register("widget/text", "application/pdf", pdf_plugin);
_convert_regiseter("application/pdf", "widget/pdf", pdf_plugin);
_convert_register("widget/pdf", "image/jpeg", pdf_plugin,);
_convert_register("widget/pdf", "image/png", pdf_plugin);
_convert_register("widget/text", "text/html", html_plugin);
_convert_type("widget/image", "image/png", image_plugin);

The convert routines in the plugins will return a Ewl_IO_Manager_Convert_Data *.

struct Ewl_IO_Manger_Convert_Data
{
  void *data;
  int length;
  int data_type      (0 == EWL_WIDGET, 1 == other)

  void *extra;
  void (*extra_free)(void *);
}

Anything that says it spits out widget/* _has_ to return the Ewl_Wiget. If it returns a mime type it can either return the widget (which pdf would probalby do) or return just the data (images and text possibly).

Extra can be used for extra information structs. So, image might have:
struct image_extra
{
  int width, height;
};