Added more params
This commit is contained in:
parent
5244701c7b
commit
bdd19cf4b8
|
@ -46,6 +46,8 @@ int buildWindow() {
|
||||||
|
|
||||||
/*** TESTING LIB ***/
|
/*** TESTING LIB ***/
|
||||||
GValue val = G_VALUE_INIT;
|
GValue val = G_VALUE_INIT;
|
||||||
|
GValue sval = G_VALUE_INIT;
|
||||||
|
|
||||||
KonaImage *ki;
|
KonaImage *ki;
|
||||||
kona_image_meta meta;
|
kona_image_meta meta;
|
||||||
ki = kona_image_new();
|
ki = kona_image_new();
|
||||||
|
@ -60,7 +62,14 @@ int buildWindow() {
|
||||||
g_object_set_property((GObject*) ki, "meta", &val);
|
g_object_set_property((GObject*) ki, "meta", &val);
|
||||||
|
|
||||||
|
|
||||||
|
g_value_init(&sval, G_TYPE_STRING);
|
||||||
|
g_value_set_string(&sval, "Hello world!");
|
||||||
|
g_object_set_property((GObject*) ki, "fullFile", &sval);
|
||||||
|
|
||||||
|
|
||||||
g_value_reset(&val);
|
g_value_reset(&val);
|
||||||
|
g_value_reset(&sval);
|
||||||
|
|
||||||
meta.height = 0;
|
meta.height = 0;
|
||||||
meta.width = 1;
|
meta.width = 1;
|
||||||
|
|
||||||
|
@ -70,6 +79,10 @@ int buildWindow() {
|
||||||
metret = g_value_get_pointer(&val);
|
metret = g_value_get_pointer(&val);
|
||||||
printf("WIDTH=%i\n", metret->width);
|
printf("WIDTH=%i\n", metret->width);
|
||||||
printf("HEIGHT=%i\n", metret->height);
|
printf("HEIGHT=%i\n", metret->height);
|
||||||
|
|
||||||
|
g_object_get_property((GObject*) ki, "fullFile", &sval);
|
||||||
|
printf("STRING=%s\n", g_value_get_string(&sval));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "konaimage.h"
|
#include "konaimage.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
guint64 test;
|
guint64 test;
|
||||||
|
@ -7,18 +8,18 @@ typedef struct {
|
||||||
|
|
||||||
struct _KonaImage {
|
struct _KonaImage {
|
||||||
GObject parent_instance; // struct of parent (inherit)
|
GObject parent_instance; // struct of parent (inherit)
|
||||||
guint64 id;
|
kona_image_meta meta;
|
||||||
GList *tags;
|
GString* preview_url;
|
||||||
GString *url;
|
GString* full_url;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_PRIVATE(KonaImage, kona_image, G_TYPE_OBJECT)
|
G_DEFINE_TYPE_WITH_PRIVATE(KonaImage, kona_image, G_TYPE_OBJECT)
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
PROP_ID = 1,
|
PROP_META=1,
|
||||||
PROP_TAGS,
|
PROP_FILE_PREVIEW,
|
||||||
PROP_URL,
|
PROP_FILE_FULL,
|
||||||
PROP_COUNT
|
PROP_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -28,14 +29,15 @@ static void kona_image_get_property(GObject *object, guint prop_id, GValue *valu
|
||||||
KonaImage *self = (KonaImage*)object;
|
KonaImage *self = (KonaImage*)object;
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_ID:
|
case PROP_FILE_PREVIEW:
|
||||||
g_value_set_uint64(value, *kona_image_get_id(self));
|
g_value_set_string(value, (const gchar*) self->preview_url);
|
||||||
break;
|
break;
|
||||||
case PROP_TAGS:
|
case PROP_FILE_FULL:
|
||||||
g_value_set_gtype(value, (GType) self->tags); // Returning the pointer itself may be dangerous... Rather copy it to the target value?
|
g_value_set_string(value, (const gchar*) self->full_url);
|
||||||
|
break;
|
||||||
|
case PROP_META:
|
||||||
|
g_value_set_pointer(value, &self->meta);
|
||||||
break;
|
break;
|
||||||
case PROP_URL:
|
|
||||||
g_value_set_string(value, (const gchar*) self->url);
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -45,16 +47,16 @@ static void kona_image_set_property(GObject *object, guint prop_id, const GValue
|
||||||
KonaImage *self = (KonaImage*)object;
|
KonaImage *self = (KonaImage*)object;
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_ID:
|
case PROP_FILE_FULL:
|
||||||
kona_image_set_id(self, g_value_get_uint64(value));
|
g_free(self->full_url);
|
||||||
|
self->full_url = (GString*) g_strdup(g_value_get_string(value));
|
||||||
break;
|
break;
|
||||||
case PROP_TAGS:
|
case PROP_FILE_PREVIEW:
|
||||||
g_list_free(self->tags);
|
g_free(self->preview_url);
|
||||||
self->tags = g_list_copy((GList*) g_value_get_gtype(value));
|
self->preview_url = (GString*) g_strdup(g_value_get_string(value));
|
||||||
break;
|
break;
|
||||||
case PROP_URL:
|
case PROP_META:
|
||||||
g_free(self->url);
|
memcpy(&self->meta, g_value_get_pointer(value), sizeof(kona_image_meta));
|
||||||
self->url = (GString*) g_strdup(g_value_get_string(value));
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -67,14 +69,14 @@ static void kona_image_class_init(KonaImageClass *klass) {
|
||||||
object_class->set_property = kona_image_set_property;
|
object_class->set_property = kona_image_set_property;
|
||||||
object_class->get_property = kona_image_get_property;
|
object_class->get_property = kona_image_get_property;
|
||||||
|
|
||||||
properties [PROP_ID] =
|
properties [PROP_META] =
|
||||||
g_param_spec_uint64("id", "id", "The ID of the image.", 0, G_MAXINT64, 22, G_PARAM_READWRITE);
|
g_param_spec_pointer("meta", "meta", "Meta info struct", G_PARAM_READWRITE);
|
||||||
|
|
||||||
properties [PROP_TAGS] =
|
properties [PROP_FILE_FULL] =
|
||||||
g_param_spec_gtype("tags", "tags", "A list of tags.", G_TYPE_NONE, G_PARAM_READWRITE); // TODO: G_TYPE_NONE for a GList(GString) a parameter?
|
g_param_spec_string("fullFile", "fullFile", "Local URL to the file", "", G_PARAM_READWRITE);
|
||||||
|
|
||||||
properties [PROP_URL] =
|
properties [PROP_FILE_PREVIEW] =
|
||||||
g_param_spec_string("url", "url", "The URL to the full picture.", "", G_PARAM_READWRITE);
|
g_param_spec_string("previewFile", "previewFile", "Local URL to the preview file", "", G_PARAM_READWRITE);
|
||||||
|
|
||||||
g_object_class_install_properties(object_class, PROP_COUNT, properties);
|
g_object_class_install_properties(object_class, PROP_COUNT, properties);
|
||||||
}
|
}
|
||||||
|
@ -90,20 +92,12 @@ static void kona_image_dispose(KonaImage *self) {
|
||||||
|
|
||||||
static void kona_image_finalize(KonaImage *self) {
|
static void kona_image_finalize(KonaImage *self) {
|
||||||
// Clear public vars here
|
// Clear public vars here
|
||||||
g_free(self->tags);
|
g_free(self->meta.image_url);
|
||||||
|
g_free(self->meta.preview_url);
|
||||||
|
g_free(self->meta.tags);
|
||||||
G_OBJECT_CLASS (kona_image_parent_class)->finalize ((GObject*) self);
|
G_OBJECT_CLASS (kona_image_parent_class)->finalize ((GObject*) self);
|
||||||
}
|
}
|
||||||
|
|
||||||
const guint64 *kona_image_get_id(KonaImage *self)
|
|
||||||
{
|
|
||||||
return &(self->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
void kona_image_set_id(KonaImage *self, const guint64 id)
|
|
||||||
{
|
|
||||||
self->id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
KonaImage *kona_image_new()
|
KonaImage *kona_image_new()
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,8 +11,15 @@ G_DECLARE_FINAL_TYPE (KonaImage, kona_image, KONA, IMAGE, GObject) // Struct nam
|
||||||
|
|
||||||
KonaImage *kona_image_new (void);
|
KonaImage *kona_image_new (void);
|
||||||
|
|
||||||
const guint64 *kona_image_get_id(KonaImage *self);
|
struct kona_image_meta_struct {
|
||||||
void kona_image_set_id(KonaImage *self, const guint64 id);
|
int id;
|
||||||
|
GList *tags;
|
||||||
|
char* preview_url;
|
||||||
|
char* image_url;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
};
|
||||||
|
typedef struct kona_image_meta_struct kona_image_meta;
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue