forked from AuroraMiddleware/gtk
Add a simple color chooser test
This commit is contained in:
parent
3b6e316e74
commit
759765114f
@ -39,6 +39,7 @@ noinst_PROGRAMS = $(TEST_PROGS) \
|
|||||||
testcairo \
|
testcairo \
|
||||||
testcalendar \
|
testcalendar \
|
||||||
testclipboard \
|
testclipboard \
|
||||||
|
testcolorchooser \
|
||||||
testcombo \
|
testcombo \
|
||||||
testcombochange \
|
testcombochange \
|
||||||
testcellrenderertext \
|
testcellrenderertext \
|
||||||
@ -158,6 +159,7 @@ testbuttons_DEPENDENCIES = $(TEST_DEPS)
|
|||||||
testcairo_DEPENDENCIES = $(TEST_DEPS)
|
testcairo_DEPENDENCIES = $(TEST_DEPS)
|
||||||
testcalendar_DEPENDENCIES = $(TEST_DEPS)
|
testcalendar_DEPENDENCIES = $(TEST_DEPS)
|
||||||
testclipboard_DEPENDENCIES = $(TEST_DEPS)
|
testclipboard_DEPENDENCIES = $(TEST_DEPS)
|
||||||
|
testcolorchooser_DEPENDENCIES = $(TEST_DEPS)
|
||||||
testcombo_DEPENDENCIES = $(TEST_DEPS)
|
testcombo_DEPENDENCIES = $(TEST_DEPS)
|
||||||
testcombochange_DEPENDENCIES = $(TEST_DEPS)
|
testcombochange_DEPENDENCIES = $(TEST_DEPS)
|
||||||
testcellrenderertext_DEPENDENCIES = $(TEST_DEPS)
|
testcellrenderertext_DEPENDENCIES = $(TEST_DEPS)
|
||||||
@ -252,6 +254,7 @@ testbuttons_LDADD = $(LDADDS)
|
|||||||
testcairo_LDADD = $(LDADDS)
|
testcairo_LDADD = $(LDADDS)
|
||||||
testcalendar_LDADD = $(LDADDS)
|
testcalendar_LDADD = $(LDADDS)
|
||||||
testclipboard_LDADD = $(LDADDS)
|
testclipboard_LDADD = $(LDADDS)
|
||||||
|
testcolorchooser_LDADD = $(LDADDS)
|
||||||
testcombo_LDADD = $(LDADDS)
|
testcombo_LDADD = $(LDADDS)
|
||||||
testcombochange_LDADD = $(LDADDS)
|
testcombochange_LDADD = $(LDADDS)
|
||||||
testcellrenderertext_LDADD = $(LDADDS)
|
testcellrenderertext_LDADD = $(LDADDS)
|
||||||
@ -519,6 +522,7 @@ testpixbuf_color_SOURCES = testpixbuf-color.c
|
|||||||
|
|
||||||
testpixbuf_save_SOURCES = testpixbuf-save.c
|
testpixbuf_save_SOURCES = testpixbuf-save.c
|
||||||
|
|
||||||
|
testcolorchooser_SOURCES = testcolorchooser.c
|
||||||
|
|
||||||
EXTRA_DIST += \
|
EXTRA_DIST += \
|
||||||
gradient1.png \
|
gradient1.png \
|
||||||
|
50
tests/testcolorchooser.c
Normal file
50
tests/testcolorchooser.c
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
static void
|
||||||
|
color_changed (GObject *o, GParamSpec *pspect, gpointer data)
|
||||||
|
{
|
||||||
|
GdkRGBA color;
|
||||||
|
|
||||||
|
gtk_color_chooser_get_color (GTK_COLOR_CHOOSER (o), &color);
|
||||||
|
g_print ("color changed: %g %g %g %g\n",
|
||||||
|
color.red, color.green, color.blue, color.alpha);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
dialog_response (GtkDialog *dialog, gint response)
|
||||||
|
{
|
||||||
|
GdkRGBA color;
|
||||||
|
|
||||||
|
switch (response)
|
||||||
|
{
|
||||||
|
case GTK_RESPONSE_OK:
|
||||||
|
gtk_color_chooser_get_color (GTK_COLOR_CHOOSER (dialog), &color);
|
||||||
|
g_print ("color accepted: %g %g %g %g\n",
|
||||||
|
color.red, color.green, color.blue, color.alpha);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
g_print ("canceled\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_main_quit ();
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char *argv[])
|
||||||
|
{
|
||||||
|
GtkWidget *dialog;
|
||||||
|
|
||||||
|
gtk_init (NULL, NULL);
|
||||||
|
|
||||||
|
dialog = gtk_color_chooser_dialog_new ("Select a color", NULL);
|
||||||
|
g_signal_connect (dialog, "notify::color", G_CALLBACK (color_changed), NULL);
|
||||||
|
g_signal_connect (dialog, "response", G_CALLBACK (dialog_response), NULL);
|
||||||
|
|
||||||
|
gtk_widget_show_all (dialog);
|
||||||
|
|
||||||
|
gtk_main ();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user