Stuff
This commit is contained in:
parent
ebf28dc49c
commit
477585cd2d
@ -3,26 +3,25 @@
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.12"/>
|
||||
<object class="GtkBox" id="previewWidget">
|
||||
<property name="width_request">200</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkImage" id="image">
|
||||
<property name="width_request">200</property>
|
||||
<property name="height_request">150</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="icon_name">applications-graphics</property>
|
||||
<property name="use_fallback">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSpinner" id="spinner">
|
||||
<property name="width_request">200</property>
|
||||
<property name="height_request">150</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
@ -30,7 +29,7 @@
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
@ -49,7 +48,7 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label" translatable="yes">button</property>
|
||||
<property name="label" translatable="yes">Debug</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
|
@ -26,11 +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 < 3; ++i) {
|
||||
|
||||
for (int i = 0; i < 4; ++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);
|
||||
// -------------------
|
||||
@ -52,7 +52,7 @@ int buildWindow() {
|
||||
kona_image_meta meta;
|
||||
meta.height = 100;
|
||||
meta.width = 200;
|
||||
meta.image_url = "MEOWMEOWMEOW";
|
||||
meta.image_url = "http://meow.cat/fullpic.png";
|
||||
|
||||
g_value_init(&sval, G_TYPE_STRING);
|
||||
g_value_set_string(&sval, "/home/markus/Pictures/FFT-an.png");
|
||||
|
@ -4,9 +4,17 @@
|
||||
G_DEFINE_TYPE(PreviewWidget, PreviewWidget, GTK_TYPE_BIN)
|
||||
|
||||
|
||||
void kona_download_image( GtkWidget *widget, gpointer data )
|
||||
// widget = PreviewWidget
|
||||
// data = KonaImage
|
||||
void kona_download_image( GtkWidget *widget, KonaImage* ki )
|
||||
{
|
||||
PreviewWidget_set_image(data, "/home/markus/Pictures/ba5431ccdc292f920692d17bdfc2758d.png"); // DEBUG ONLY!
|
||||
kona_image_meta *meta;
|
||||
meta = kona_image_get_meta_from_konaimage(ki);
|
||||
|
||||
printf("DOWNLOAD %s!\n", meta->image_url);
|
||||
fflush(stdout);
|
||||
|
||||
//PreviewWidget_set_image(data, "/home/markus/Pictures/ba5431ccdc292f920692d17bdfc2758d.png"); // DEBUG ONLY!
|
||||
}
|
||||
|
||||
void PreviewWidget_set_image(PreviewWidget *widget, gchar *url) {
|
||||
@ -100,8 +108,13 @@ void PreviewWidget_init(PreviewWidget *klass)
|
||||
GtkWidget *PreviewWidget_new(KonaImage* ki)
|
||||
{
|
||||
PreviewWidget* w = g_object_new (TYPE_PREVIEWWIDGET, "ki", ki, NULL);
|
||||
// Connect KonaImage callbacks
|
||||
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);
|
||||
|
||||
// Connect UI handlers
|
||||
g_signal_connect(w->button, "clicked", (GCallback)kona_download_image, ki);
|
||||
|
||||
return GTK_WIDGET(w);
|
||||
}
|
||||
|
||||
@ -130,15 +143,11 @@ void previewImage_update_preview_from_konaImage(PreviewWidget *pv, guint propId,
|
||||
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);
|
||||
gchar* text;
|
||||
meta = kona_image_get_meta_from_konaimage(ki);
|
||||
|
||||
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);
|
||||
|
@ -103,3 +103,13 @@ KonaImage *kona_image_new()
|
||||
{
|
||||
return g_object_new(KONA_TYPE_IMAGE, 0);
|
||||
}
|
||||
|
||||
kona_image_meta* kona_image_get_meta_from_konaimage(KonaImage *ki) {
|
||||
kona_image_meta *meta;
|
||||
GValue val = G_VALUE_INIT;
|
||||
g_value_init(&val, G_TYPE_POINTER);
|
||||
g_object_get_property(G_OBJECT(ki), "meta", &val);
|
||||
meta = g_value_get_pointer(&val);
|
||||
g_value_reset(&val);
|
||||
return meta;
|
||||
}
|
||||
|
@ -21,6 +21,10 @@ struct kona_image_meta_struct {
|
||||
};
|
||||
typedef struct kona_image_meta_struct kona_image_meta;
|
||||
|
||||
|
||||
// Access functions for parameters (read only)
|
||||
kona_image_meta* kona_image_get_meta_from_konaimage(KonaImage *ki);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif // KONAIMAGE_H
|
||||
|
Loading…
Reference in New Issue
Block a user