konaclient-gtk/libkonaclient-test/main.c

69 lines
1.7 KiB
C

#include <stdio.h>
#include "konaimage.h"
#include "konasearch.h"
#define PRINT_TEST_HEADER() printf("\n========= %s =========\n", __func__)
void cb_meta_changed(KonaImage* ki) {
kona_image_meta *meta;
meta = kona_image_get_meta_from_konaimage(ki);
printf("%s: META.ID = %d\n", __func__, meta->id);
for (GList *l = meta->tags; l; l = l->next) {
printf (" meta.tag = %p: %s\n", l->data, l->data);
}
}
void test_kona_image() {
KonaImage *ki;
PRINT_TEST_HEADER();
ki = kona_image_new();
g_signal_connect(ki, "notify::meta", (GCallback)cb_meta_changed, NULL);
/* Testing callbacks */
GValue val = G_VALUE_INIT;
GValue sval = G_VALUE_INIT;
kona_image_meta meta;
meta.height = 100;
meta.width = 200;
meta.id = 42;
meta.tags = NULL;
meta.image_url = "http://meow.cat/fullpic.png";
meta.preview_url = "http://meow.cat/preview.png";
meta.tags = g_list_append(meta.tags, "hello");
meta.tags = g_list_append(meta.tags, "world");
for (GList *l = meta.tags; l; l = l->next) {
printf ("ADD meta.tag = %p: %s\n", l->data, l->data);
}
printf("\n");
g_value_init(&sval, G_TYPE_STRING);
g_value_set_string(&sval, "/path/to/file.png");
g_object_set_property((GObject*) ki, "previewFile", &sval);
g_value_init(&val, G_TYPE_POINTER);
g_value_set_pointer(&val, (gpointer) &meta);
g_object_set_property((GObject*) ki, "meta", &val);
g_object_unref(ki);
}
void test_kona_search() {
KonaSearch *ks;
PRINT_TEST_HEADER();
ks = kona_search_new();
}
int main(int argc, char *argv[])
{
test_kona_image();
test_kona_search();
return 0;
}