Added image click handler
This commit is contained in:
parent
70dcc379d5
commit
9698885de4
|
@ -2,15 +2,15 @@
|
||||||
<!-- Generated with glade 3.20.0 -->
|
<!-- Generated with glade 3.20.0 -->
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="3.12"/>
|
<requires lib="gtk+" version="3.12"/>
|
||||||
<object class="GtkEventBox" id="evBox">
|
<object class="GtkBox" id="previewWidget">
|
||||||
|
<property name="width_request">200</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox" id="previewWidget">
|
<object class="GtkEventBox" id="evBox">
|
||||||
<property name="width_request">200</property>
|
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="orientation">vertical</property>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage" id="image">
|
<object class="GtkImage" id="image">
|
||||||
<property name="height_request">150</property>
|
<property name="height_request">150</property>
|
||||||
|
@ -18,53 +18,53 @@
|
||||||
<property name="icon_name">applications-graphics</property>
|
<property name="icon_name">applications-graphics</property>
|
||||||
<property name="use_fallback">True</property>
|
<property name="use_fallback">True</property>
|
||||||
</object>
|
</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>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</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>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</interface>
|
</interface>
|
||||||
|
|
|
@ -52,6 +52,7 @@ int buildWindow() {
|
||||||
kona_image_meta meta;
|
kona_image_meta meta;
|
||||||
meta.height = 100;
|
meta.height = 100;
|
||||||
meta.width = 200;
|
meta.width = 200;
|
||||||
|
meta.id = 42;
|
||||||
meta.image_url = "http://meow.cat/fullpic.png";
|
meta.image_url = "http://meow.cat/fullpic.png";
|
||||||
|
|
||||||
g_value_init(&sval, G_TYPE_STRING);
|
g_value_init(&sval, G_TYPE_STRING);
|
||||||
|
|
|
@ -6,17 +6,25 @@ G_DEFINE_TYPE(PreviewWidget, PreviewWidget, GTK_TYPE_BIN)
|
||||||
|
|
||||||
// widget = PreviewWidget
|
// widget = PreviewWidget
|
||||||
// data = KonaImage
|
// data = KonaImage
|
||||||
void kona_download_image( GtkWidget *widget, KonaImage* ki )
|
void PreviewWidget_download_clicked( GtkWidget *widget, KonaImage* ki )
|
||||||
{
|
{
|
||||||
kona_image_meta *meta;
|
kona_image_meta *meta;
|
||||||
meta = kona_image_get_meta_from_konaimage(ki);
|
meta = kona_image_get_meta_from_konaimage(ki);
|
||||||
|
|
||||||
printf("DOWNLOAD %s!\n", meta->image_url);
|
printf("DOWNLOAD %s!\n", meta->image_url);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
//PreviewWidget_set_image(data, "/home/markus/Pictures/ba5431ccdc292f920692d17bdfc2758d.png"); // DEBUG ONLY!
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PreviewWidget_image_clicked( GtkWidget *widget, gint event, KonaImage* ki )
|
||||||
|
{
|
||||||
|
kona_image_meta *meta;
|
||||||
|
meta = kona_image_get_meta_from_konaimage(ki);
|
||||||
|
|
||||||
|
printf("IMAGE CLICKED: %d\n", meta->id);
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void PreviewWidget_set_image(PreviewWidget *widget, gchar *url) {
|
void PreviewWidget_set_image(PreviewWidget *widget, gchar *url) {
|
||||||
int height, width;
|
int height, width;
|
||||||
float iheight, iwidth;
|
float iheight, iwidth;
|
||||||
|
@ -93,17 +101,19 @@ void PreviewWidget_init(PreviewWidget *klass)
|
||||||
builder = gtk_builder_new();
|
builder = gtk_builder_new();
|
||||||
gtk_builder_add_from_file(builder, "glade/previewWidget.glade", NULL);
|
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_builder_connect_signals(builder, NULL);
|
||||||
|
|
||||||
gtk_container_add(GTK_CONTAINER(klass), widget);
|
gtk_container_add(GTK_CONTAINER(klass), widget);
|
||||||
|
|
||||||
klass->evBox = widget;
|
klass->evBox = GTK_WIDGET(gtk_builder_get_object(builder, "evBox"));;
|
||||||
gtk_widget_set_events (klass->evBox, GDK_BUTTON_PRESS_MASK); // TODO: Click event foo here
|
gtk_widget_set_events (GTK_WIDGET(klass->evBox), GDK_DOUBLE_BUTTON_PRESS); // TODO: Does not work
|
||||||
klass->image = GTK_WIDGET(gtk_builder_get_object(builder, "image"));
|
klass->image = GTK_WIDGET(gtk_builder_get_object(builder, "image"));
|
||||||
klass->button = GTK_WIDGET(gtk_builder_get_object(builder, "button"));
|
klass->button = GTK_WIDGET(gtk_builder_get_object(builder, "button"));
|
||||||
klass->spinner = GTK_WIDGET(gtk_builder_get_object(builder, "spinner"));
|
klass->spinner = GTK_WIDGET(gtk_builder_get_object(builder, "spinner"));
|
||||||
|
|
||||||
|
//gdk_window_set_cursor(gtk_widget_get_window(klass->evBox), GDK_HAND1); // TODO: Does not work
|
||||||
|
|
||||||
g_object_unref(G_OBJECT(builder));
|
g_object_unref(G_OBJECT(builder));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,8 +125,8 @@ GtkWidget *PreviewWidget_new(KonaImage* ki)
|
||||||
g_signal_connect_swapped(ki, "notify::meta", (GCallback)previewImage_update_meta_from_konaImage, w);
|
g_signal_connect_swapped(ki, "notify::meta", (GCallback)previewImage_update_meta_from_konaImage, w);
|
||||||
|
|
||||||
// Connect UI handlers
|
// Connect UI handlers
|
||||||
g_signal_connect(w->button, "clicked", (GCallback)kona_download_image, ki);
|
g_signal_connect(w->button, "clicked", (GCallback)PreviewWidget_download_clicked, ki);
|
||||||
g_signal_connect(w->evBox, "button_press_event", (GCallback)kona_download_image, ki); // TODO: Click event foo here
|
g_signal_connect(w->evBox, "button_press_event", (GCallback)PreviewWidget_image_clicked, ki); // TODO: Click event foo here
|
||||||
|
|
||||||
return GTK_WIDGET(w);
|
return GTK_WIDGET(w);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue