Added meta callback
This commit is contained in:
parent
bef6d005ce
commit
ebf28dc49c
@ -26,10 +26,11 @@ int buildWindow() {
|
||||
|
||||
previewLayout = gtk_flow_box_new();
|
||||
gtk_flow_box_set_max_children_per_line(GTK_FLOW_BOX(previewLayout), 200);
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
// CUSTOM!!!!!
|
||||
ki = kona_image_new();
|
||||
temp = PreviewWidget_new(ki);
|
||||
printf("KI=%p\nPV=%p\n", ki,temp);
|
||||
gtk_flow_box_insert(GTK_FLOW_BOX(previewLayout),temp,0);
|
||||
gtk_widget_show(temp);
|
||||
// -------------------
|
||||
@ -38,57 +39,28 @@ int buildWindow() {
|
||||
|
||||
|
||||
gtk_widget_show(previewLayout);
|
||||
gtk_container_add(GTK_CONTAINER(previewContainer), previewLayout);
|
||||
gtk_container_add(GTK_CONTAINER(previewContainer), previewLayout);
|
||||
|
||||
g_object_unref(G_OBJECT(builder));
|
||||
g_object_unref(G_OBJECT(builder));
|
||||
|
||||
gtk_widget_show(GTK_WIDGET(mainWindow));
|
||||
|
||||
|
||||
gtk_widget_show(GTK_WIDGET(mainWindow));
|
||||
/* Testing callbacks */
|
||||
GValue val = G_VALUE_INIT;
|
||||
GValue sval = G_VALUE_INIT;
|
||||
kona_image_meta meta;
|
||||
meta.height = 100;
|
||||
meta.width = 200;
|
||||
meta.image_url = "MEOWMEOWMEOW";
|
||||
|
||||
g_value_init(&sval, G_TYPE_STRING);
|
||||
g_value_set_string(&sval, "/home/markus/Pictures/FFT-an.png");
|
||||
g_object_set_property((GObject*) ki, "previewFile", &sval);
|
||||
|
||||
GValue sval = G_VALUE_INIT;
|
||||
g_value_init(&sval, G_TYPE_STRING);
|
||||
g_value_set_string(&sval, "/home/markus/Pictures/FFT-an.png");
|
||||
g_object_set_property((GObject*) ki, "previewFile", &sval);
|
||||
|
||||
if (0) {
|
||||
/*** TESTING LIB ***/
|
||||
GValue val = G_VALUE_INIT;
|
||||
|
||||
kona_image_meta meta;
|
||||
ki = kona_image_new();
|
||||
g_value_init(&val, G_TYPE_POINTER);
|
||||
|
||||
|
||||
meta.height = 100;
|
||||
meta.width = 200;
|
||||
meta.image_url = "MEOWMEOWMEOW";
|
||||
|
||||
g_value_set_pointer(&val, (gpointer) &meta);
|
||||
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(&sval);
|
||||
|
||||
meta.height = 0;
|
||||
meta.width = 1;
|
||||
|
||||
// Read back
|
||||
g_object_get_property((GObject*) ki, "meta", &val);
|
||||
kona_image_meta *metret;
|
||||
metret = g_value_get_pointer(&val);
|
||||
printf("WIDTH=%i\n", metret->width);
|
||||
printf("HEIGHT=%i\n", metret->height);
|
||||
|
||||
g_object_get_property((GObject*) ki, "fullFile", &sval);
|
||||
printf("STRING=%s\n", g_value_get_string(&sval));
|
||||
}
|
||||
g_value_init(&val, G_TYPE_POINTER);
|
||||
g_value_set_pointer(&val, (gpointer) &meta);
|
||||
g_object_set_property((GObject*) ki, "meta", &val);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
@ -39,7 +39,7 @@ void PreviewWidget_set_image(PreviewWidget *widget, gchar *url) {
|
||||
|
||||
enum {
|
||||
PROP_KI=1,
|
||||
PROP_COUNT
|
||||
PROP_COUNT
|
||||
};
|
||||
static GParamSpec *properties [PROP_COUNT];
|
||||
static void preview_widget_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) {
|
||||
@ -100,7 +100,8 @@ void PreviewWidget_init(PreviewWidget *klass)
|
||||
GtkWidget *PreviewWidget_new(KonaImage* ki)
|
||||
{
|
||||
PreviewWidget* w = g_object_new (TYPE_PREVIEWWIDGET, "ki", ki, NULL);
|
||||
g_signal_connect(ki, "notify::previewFile", (GCallback)previewImage_update_preview_from_konaImage, w);
|
||||
g_signal_connect_swapped(ki, "notify::previewFile", (GCallback)previewImage_update_preview_from_konaImage, w);
|
||||
g_signal_connect_swapped(ki, "notify::meta", (GCallback)previewImage_update_meta_from_konaImage, w);
|
||||
return GTK_WIDGET(w);
|
||||
}
|
||||
|
||||
@ -114,11 +115,31 @@ void debugfoo(GtkButton *widget, GtkImage *img)
|
||||
}
|
||||
|
||||
|
||||
// CALLBACKS FROM KONAIMAGE
|
||||
void previewImage_update_preview_from_konaImage( KonaImage *ki, guint propId, PreviewWidget *pv)
|
||||
/* ------------------------ *
|
||||
* CALLBACKS FROM KONAIMAGE *
|
||||
* ------------------------ */
|
||||
|
||||
void previewImage_update_preview_from_konaImage(PreviewWidget *pv, guint propId, KonaImage *ki)
|
||||
{
|
||||
GValue val = G_VALUE_INIT;
|
||||
g_value_init(&val, G_TYPE_STRING);
|
||||
g_object_get_property(G_OBJECT(ki), "previewFile", &val);
|
||||
PreviewWidget_set_image(pv, g_value_get_string(&val));
|
||||
PreviewWidget_set_image(pv, (gchar*) g_value_get_string(&val));
|
||||
}
|
||||
|
||||
void previewImage_update_meta_from_konaImage(PreviewWidget *pv, guint propId, KonaImage *ki)
|
||||
{
|
||||
kona_image_meta *meta;
|
||||
GValue val = G_VALUE_INIT;
|
||||
gchar *text;
|
||||
g_value_init(&val, G_TYPE_POINTER);
|
||||
g_object_get_property(G_OBJECT(ki), "meta", &val);
|
||||
meta = g_value_get_pointer(&val);
|
||||
|
||||
text = g_strdup_printf("Download @ %dx%d", meta->width, meta->height);
|
||||
gtk_button_set_label(GTK_BUTTON(pv->button), text);
|
||||
printf("WIDTH=%d\n", meta->width);
|
||||
g_free(text);
|
||||
|
||||
fflush(stdout);
|
||||
}
|
||||
|
@ -37,8 +37,11 @@ void PreviewWidget_set_image(PreviewWidget *widget, gchar *url);
|
||||
void debugfoo(GtkButton *widget, GtkImage* img);
|
||||
|
||||
|
||||
// CALLBACKS FROM KONAIMAGE
|
||||
void previewImage_update_preview_from_konaImage(KonaImage *ki, guint propId, PreviewWidget *pv);
|
||||
/* ------------------------ *
|
||||
* CALLBACKS FROM KONAIMAGE *
|
||||
* ------------------------ */
|
||||
void previewImage_update_preview_from_konaImage(PreviewWidget *pv, guint propId, KonaImage *ki);
|
||||
void previewImage_update_meta_from_konaImage(PreviewWidget *pv, guint propId, KonaImage *ki);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user