Compare commits
No commits in common. "70dcc379d562e5885584341de81493bcc161858b" and "bef6d005ce32b20b48f97f4f5618e0028bf61abb" have entirely different histories.
70dcc379d5
...
bef6d005ce
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.20.0 -->
|
||||
<!-- Generated with glade 3.18.3 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.12"/>
|
||||
<object class="GtkEntryCompletion" id="searchCompletion"/>
|
||||
|
@ -2,69 +2,64 @@
|
||||
<!-- Generated with glade 3.20.0 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.12"/>
|
||||
<object class="GtkEventBox" id="evBox">
|
||||
<object class="GtkBox" id="previewWidget">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="previewWidget">
|
||||
<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="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>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkImage" id="image">
|
||||
<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">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSpinner" id="spinner">
|
||||
<property name="height_request">150</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="active">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button">
|
||||
<property name="label" translatable="yes">Download @ 0000 x 0000</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label" translatable="yes">Debug</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<signal name="clicked" handler="debugfoo" object="image" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<property name="active">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button">
|
||||
<property name="label" translatable="yes">Download @ 0000 x 0000</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label" translatable="yes">button</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<signal name="clicked" handler="debugfoo" object="image" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
|
@ -26,8 +26,7 @@ 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 < 4; ++i) {
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
// CUSTOM!!!!!
|
||||
ki = kona_image_new();
|
||||
temp = PreviewWidget_new(ki);
|
||||
@ -39,28 +38,57 @@ 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));
|
||||
|
||||
gtk_widget_show(GTK_WIDGET(mainWindow));
|
||||
g_object_unref(G_OBJECT(builder));
|
||||
|
||||
|
||||
/* 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 = "http://meow.cat/fullpic.png";
|
||||
gtk_widget_show(GTK_WIDGET(mainWindow));
|
||||
|
||||
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);
|
||||
|
||||
g_value_init(&val, G_TYPE_POINTER);
|
||||
g_value_set_pointer(&val, (gpointer) &meta);
|
||||
g_object_set_property((GObject*) ki, "meta", &val);
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
@ -4,17 +4,9 @@
|
||||
G_DEFINE_TYPE(PreviewWidget, PreviewWidget, GTK_TYPE_BIN)
|
||||
|
||||
|
||||
// widget = PreviewWidget
|
||||
// data = KonaImage
|
||||
void kona_download_image( GtkWidget *widget, KonaImage* ki )
|
||||
void kona_download_image( GtkWidget *widget, gpointer data )
|
||||
{
|
||||
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!
|
||||
PreviewWidget_set_image(data, "/home/markus/Pictures/ba5431ccdc292f920692d17bdfc2758d.png"); // DEBUG ONLY!
|
||||
}
|
||||
|
||||
void PreviewWidget_set_image(PreviewWidget *widget, gchar *url) {
|
||||
@ -47,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) {
|
||||
@ -93,13 +85,11 @@ void PreviewWidget_init(PreviewWidget *klass)
|
||||
builder = gtk_builder_new();
|
||||
gtk_builder_add_from_file(builder, "glade/previewWidget.glade", NULL);
|
||||
|
||||
widget = GTK_WIDGET(gtk_builder_get_object(GTK_BUILDER(builder), "evBox"));
|
||||
widget = GTK_WIDGET(gtk_builder_get_object(GTK_BUILDER(builder), "previewWidget"));
|
||||
gtk_builder_connect_signals(builder, NULL);
|
||||
|
||||
gtk_container_add(GTK_CONTAINER(klass), widget);
|
||||
|
||||
klass->evBox = widget;
|
||||
gtk_widget_set_events (klass->evBox, GDK_BUTTON_PRESS_MASK); // TODO: Click event foo here
|
||||
klass->image = GTK_WIDGET(gtk_builder_get_object(builder, "image"));
|
||||
klass->button = GTK_WIDGET(gtk_builder_get_object(builder, "button"));
|
||||
klass->spinner = GTK_WIDGET(gtk_builder_get_object(builder, "spinner"));
|
||||
@ -110,14 +100,7 @@ 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);
|
||||
g_signal_connect(w->evBox, "button_press_event", (GCallback)kona_download_image, ki); // TODO: Click event foo here
|
||||
|
||||
g_signal_connect(ki, "notify::previewFile", (GCallback)previewImage_update_preview_from_konaImage, w);
|
||||
return GTK_WIDGET(w);
|
||||
}
|
||||
|
||||
@ -131,27 +114,11 @@ void debugfoo(GtkButton *widget, GtkImage *img)
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------ *
|
||||
* CALLBACKS FROM KONAIMAGE *
|
||||
* ------------------------ */
|
||||
|
||||
void previewImage_update_preview_from_konaImage(PreviewWidget *pv, guint propId, KonaImage *ki)
|
||||
// CALLBACKS FROM KONAIMAGE
|
||||
void previewImage_update_preview_from_konaImage( KonaImage *ki, guint propId, PreviewWidget *pv)
|
||||
{
|
||||
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, (gchar*) g_value_get_string(&val));
|
||||
}
|
||||
|
||||
void previewImage_update_meta_from_konaImage(PreviewWidget *pv, guint propId, KonaImage *ki)
|
||||
{
|
||||
kona_image_meta *meta;
|
||||
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);
|
||||
g_free(text);
|
||||
|
||||
fflush(stdout);
|
||||
PreviewWidget_set_image(pv, g_value_get_string(&val));
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ typedef struct _PreviewWidgetClass PreviewWidgetClass;
|
||||
|
||||
struct _PreviewWidget {
|
||||
GtkBin bin;
|
||||
GtkWidget *evBox;
|
||||
GtkWidget *image;
|
||||
GtkWidget *button;
|
||||
GtkWidget *spinner;
|
||||
@ -38,11 +37,8 @@ void PreviewWidget_set_image(PreviewWidget *widget, gchar *url);
|
||||
void debugfoo(GtkButton *widget, GtkImage* img);
|
||||
|
||||
|
||||
/* ------------------------ *
|
||||
* 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);
|
||||
// CALLBACKS FROM KONAIMAGE
|
||||
void previewImage_update_preview_from_konaImage(KonaImage *ki, guint propId, PreviewWidget *pv);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -103,13 +103,3 @@ 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,10 +21,6 @@ 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