Unify GTK's loading APIs
When loading things, our APIs are all over the place and no unified set exists. One basically has to look in the docs what is possible.
It would be nice if our APIs could conform to a common set of functions instead.
Here's a list of all the constructors that take compressed/file data in any form and in what form that data may be provided.
(Note: I did not consider functions for format-specific things, like gdk_gl_texture_new() or gtk_image_set_from_icon_name())
function | preposition | path | GFile | resource | GBytes | memory | other |
---|---|---|---|---|---|---|---|
GdkTexture | new_from | file | resource | ||||
GskRenderNode | deserialize | ||||||
GskGLShader | new_from | resource | bytes | ||||
GtkImage | new_from/set_from | file | resource | ||||
GtkPicture | new_for/set | filename | file | resource | |||
GtkMediaFile | new_for/set | filename | file | resource | input_stream | ||
GtkVideo | new_for/set | filename | file | resource | |||
GtkCssProvider | load_from | path | file | resource | data | ||
GtkBuilder | new_from/add_from | file | resource | string | |||
for comparison: | |||||||
GKeyFile | load_from | file | bytes | data | |||
GBytes | g_file_load_bytes | new_from_bytes | new |
There's a few obvious ideas here:
-
Use "from" instead of "for" everywhere -
Figure out filename vs path terminology (I don't have a preference - anybody does?) and rename all the "file" users. -
Add GFile versions everywhere. -
Do we need GBytes support? Should we even make the CssProvider/Builder versions use GBytes? -
There is no way to load in-memory image data. Should we add that?