Add the Matrix.ImageInfo type
This commit is contained in:
parent
ff2530ed2d
commit
d267b9e110
2
.gitignore
vendored
2
.gitignore
vendored
@ -48,7 +48,7 @@ Makefile.in
|
|||||||
/src/matrix-glib.h
|
/src/matrix-glib.h
|
||||||
/src/matrix-api.c
|
/src/matrix-api.c
|
||||||
/src/matrix-client.c
|
/src/matrix-client.c
|
||||||
/src/matrix-enums.c
|
/src/matrix-types.c
|
||||||
/src/matrix-http-api.c
|
/src/matrix-http-api.c
|
||||||
/src/matrix-http-client.c
|
/src/matrix-http-client.c
|
||||||
/src/matrix-compacts.c
|
/src/matrix-compacts.c
|
||||||
|
@ -19,7 +19,7 @@ libmatrix_glib_0_0_la_VALA_SOURCES = \
|
|||||||
namespace-info.vala \
|
namespace-info.vala \
|
||||||
matrix-api.vala \
|
matrix-api.vala \
|
||||||
matrix-client.vala \
|
matrix-client.vala \
|
||||||
matrix-enums.vala \
|
matrix-types.vala \
|
||||||
matrix-http-api.vala \
|
matrix-http-api.vala \
|
||||||
matrix-http-client.vala \
|
matrix-http-client.vala \
|
||||||
matrix-compacts.vala \
|
matrix-compacts.vala \
|
||||||
|
@ -270,6 +270,37 @@ namespace Matrix {
|
|||||||
WORLD_READABLE;
|
WORLD_READABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public struct ImageInfo {
|
||||||
|
int? size;
|
||||||
|
int? height;
|
||||||
|
int? width;
|
||||||
|
string? mimetype;
|
||||||
|
|
||||||
|
public Json.Node
|
||||||
|
get_json_node()
|
||||||
|
throws Matrix.Error
|
||||||
|
{
|
||||||
|
if ((size == null)
|
||||||
|
|| (height == null)
|
||||||
|
|| (width == null)
|
||||||
|
|| (mimetype == null)) {
|
||||||
|
throw new Matrix.Error.INCOMPLETE(
|
||||||
|
"Won't generate an ImageInfo without all fields set.");
|
||||||
|
}
|
||||||
|
|
||||||
|
var node = new Json.Node(Json.NodeType.OBJECT);
|
||||||
|
var obj = new Json.Object();
|
||||||
|
node.set_object(obj);
|
||||||
|
|
||||||
|
obj.set_int_member("size", size);
|
||||||
|
obj.set_int_member("h", height);
|
||||||
|
obj.set_int_member("w", width);
|
||||||
|
obj.set_string_member("mimetype", mimetype);
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private int?
|
private int?
|
||||||
_g_enum_nick_to_value(Type enum_type, string nick)
|
_g_enum_nick_to_value(Type enum_type, string nick)
|
||||||
{
|
{
|
Loading…
Reference in New Issue
Block a user