[RI] add testri test
Currently tests RI support in GtkBuilder using 3 GtkImages
This commit is contained in:
@@ -59,6 +59,7 @@ noinst_PROGRAMS = $(TEST_PROGS) \
|
||||
testrgb \
|
||||
testrecentchooser \
|
||||
testrecentchoosermenu \
|
||||
testri \
|
||||
testrichtext \
|
||||
testscale \
|
||||
testselection \
|
||||
@@ -137,6 +138,7 @@ testprint_DEPENDENCIES = $(TEST_DEPS)
|
||||
testrecentchooser_DEPENDENCIES = $(TEST_DEPS)
|
||||
testrecentchoosermenu_DEPENDENCIES = $(TEST_DEPS)
|
||||
testrgb_DEPENDENCIES = $(TEST_DEPS)
|
||||
testri_DEPENDENCIES = $(TEST_DEPS)
|
||||
testrichtext_DEPENDENCIES = $(TEST_DEPS)
|
||||
testscale_DEPENDENCIES = $(TEST_DEPS)
|
||||
testselection_DEPENDENCIES = $(TEST_DEPS)
|
||||
@@ -195,6 +197,7 @@ testprint_LDADD = $(LDADDS)
|
||||
testrecentchooser_LDADD = $(LDADDS)
|
||||
testrecentchoosermenu_LDADD = $(LDADDS)
|
||||
testrgb_LDADD = $(LDADDS)
|
||||
testri_LDADD = $(LDADDS)
|
||||
testrichtext_LDADD = $(LDADDS)
|
||||
testscale_LDADD = $(LDADDS)
|
||||
testselection_LDADD = $(LDADDS)
|
||||
@@ -270,6 +273,9 @@ testprint_SOURCES = \
|
||||
testprintfileoperation.h \
|
||||
testprintfileoperation.c
|
||||
|
||||
testri_SOURCES = \
|
||||
testri.c
|
||||
|
||||
testsocket_SOURCES = \
|
||||
testsocket.c \
|
||||
testsocket_common.c
|
||||
@@ -336,6 +342,7 @@ EXTRA_DIST += \
|
||||
merge-1.ui \
|
||||
merge-2.ui \
|
||||
merge-3.ui \
|
||||
testri.ui
|
||||
gnome-textfile.png \
|
||||
makefile.msc \
|
||||
file-chooser-test-dir/empty \
|
||||
|
||||
51
tests/testri.c
Normal file
51
tests/testri.c
Normal file
@@ -0,0 +1,51 @@
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
gtk_enable_resolution_independence ();
|
||||
gtk_init (&argc, &argv);
|
||||
|
||||
GtkBuilder *ui = gtk_builder_new ();
|
||||
gtk_builder_add_from_file (ui, "testri.ui", &error);
|
||||
if (error)
|
||||
{
|
||||
g_error ("%s:%i: %s", __FILE__, __LINE__, error->message);
|
||||
}
|
||||
|
||||
GtkWidget *window = GTK_WIDGET (gtk_builder_get_object (ui, "testri-window"));
|
||||
|
||||
gtk_widget_show (window);
|
||||
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (gtk_main_quit), NULL);
|
||||
|
||||
/* get the image sizes */
|
||||
GtkWidget *image1 = GTK_WIDGET (gtk_builder_get_object (ui, "image1"));
|
||||
GtkWidget *image2 = GTK_WIDGET (gtk_builder_get_object (ui, "image2"));
|
||||
GtkWidget *image3 = GTK_WIDGET (gtk_builder_get_object (ui, "image3"));
|
||||
|
||||
GtkSize size;
|
||||
char *str;
|
||||
|
||||
gtk_widget_get_unit (image1, "pixel-size", &size, NULL);
|
||||
str = gtk_size_to_string (size);
|
||||
g_print ("image1 size = %s\n", str);
|
||||
g_free (str);
|
||||
|
||||
gtk_widget_get_unit (image2, "pixel-size", &size, NULL);
|
||||
str = gtk_size_to_string (size);
|
||||
g_print ("image2 size = %s\n", str);
|
||||
g_free (str);
|
||||
|
||||
gtk_widget_get_unit (image3, "pixel-size", &size, NULL);
|
||||
str = gtk_size_to_string (size);
|
||||
g_print ("image3 size = %s\n", str);
|
||||
g_free (str);
|
||||
|
||||
gtk_main ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
42
tests/testri.ui
Normal file
42
tests/testri.ui
Normal file
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0"?>
|
||||
<interface>
|
||||
<requires lib="gtk+" version="2.16"/>
|
||||
<!-- interface-naming-policy project-wide -->
|
||||
<object class="GtkWindow" id="testri-window">
|
||||
<child>
|
||||
<object class="GtkHBox" id="hbox1">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<object class="GtkImage" id="image1">
|
||||
<property name="visible">True</property>
|
||||
<property name="icon-name">gtk-about</property>
|
||||
<property name="pixel-size">48</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImage" id="image2">
|
||||
<property name="visible">True</property>
|
||||
<property name="icon-name">gtk-about</property>
|
||||
<property name="pixel-size">4em</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImage" id="image3">
|
||||
<property name="visible">True</property>
|
||||
<property name="icon-name">gtk-about</property>
|
||||
<property name="pixel-size">20mm</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
Reference in New Issue
Block a user