testheightforwidth: Remove deprecations & clean up
cherry-pick of master commit bf0ea7b7bc8de1c39923d4976f6e1aafd23b92c7
This commit is contained in:
@ -32,18 +32,19 @@ typedef struct {
|
|||||||
*
|
*
|
||||||
* IFS=""; while read line; do echo -n \"; echo -n $line | sed -e 's|\"|\\"|g'; echo \"; done < file.glade
|
* IFS=""; while read line; do echo -n \"; echo -n $line | sed -e 's|\"|\\"|g'; echo \"; done < file.glade
|
||||||
*/
|
*/
|
||||||
TestInterface interfaces[] = {
|
static TestInterface interfaces[] = {
|
||||||
{
|
{
|
||||||
"Ellipsizing Labels",
|
"Ellipsizing Labels",
|
||||||
"Demonstrates how labels will request a natural size in a horizontal space",
|
"Demonstrates how labels will request a natural size in a horizontal space",
|
||||||
"<interface>"
|
"<interface>"
|
||||||
" <requires lib=\"gtk+\" version=\"2.20\"/>"
|
" <requires lib=\"gtk+\" version=\"3.22\"/>"
|
||||||
" <!-- interface-naming-policy project-wide -->"
|
" <!-- interface-naming-policy project-wide -->"
|
||||||
" <object class=\"GtkWindow\" id=\"window\">"
|
" <object class=\"GtkWindow\" id=\"window\">"
|
||||||
" <property name=\"default_width\">450</property>"
|
" <property name=\"default_width\">450</property>"
|
||||||
" <property name=\"default_height\">50</property>"
|
" <property name=\"default_height\">50</property>"
|
||||||
" <child>"
|
" <child>"
|
||||||
" <object class=\"GtkHBox\" id=\"hbox5\">"
|
" <object class=\"GtkBox\" id=\"hbox5\">"
|
||||||
|
" <property name=\"orientation\">horizontal</property>"
|
||||||
" <property name=\"visible\">True</property>"
|
" <property name=\"visible\">True</property>"
|
||||||
" <child>"
|
" <child>"
|
||||||
" <object class=\"GtkLabel\" id=\"label9\">"
|
" <object class=\"GtkLabel\" id=\"label9\">"
|
||||||
@ -98,17 +99,19 @@ TestInterface interfaces[] = {
|
|||||||
"Wrapping Label",
|
"Wrapping Label",
|
||||||
"Demonstrates how a wrapping label can require a height contextual to its allocated width",
|
"Demonstrates how a wrapping label can require a height contextual to its allocated width",
|
||||||
"<interface>"
|
"<interface>"
|
||||||
" <requires lib=\"gtk+\" version=\"2.18\"/>"
|
" <requires lib=\"gtk+\" version=\"3.22\"/>"
|
||||||
" <!-- interface-naming-policy project-wide -->"
|
" <!-- interface-naming-policy project-wide -->"
|
||||||
" <object class=\"GtkWindow\" id=\"window\">"
|
" <object class=\"GtkWindow\" id=\"window\">"
|
||||||
" <property name=\"border_width\">12</property>"
|
" <property name=\"border_width\">12</property>"
|
||||||
" <property name=\"default_width\">300</property>"
|
" <property name=\"default_width\">300</property>"
|
||||||
" <child>"
|
" <child>"
|
||||||
" <object class=\"GtkHPaned\" id=\"hpaned1\">"
|
" <object class=\"GtkPaned\" id=\"hpaned1\">"
|
||||||
|
" <property name=\"orientation\">horizontal</property>"
|
||||||
" <property name=\"visible\">True</property>"
|
" <property name=\"visible\">True</property>"
|
||||||
" <property name=\"can_focus\">True</property>"
|
" <property name=\"can_focus\">True</property>"
|
||||||
" <child>"
|
" <child>"
|
||||||
" <object class=\"GtkVBox\" id=\"vbox2\">"
|
" <object class=\"GtkBox\" id=\"vbox2\">"
|
||||||
|
" <property name=\"orientation\">vertical</property>"
|
||||||
" <property name=\"visible\">True</property>"
|
" <property name=\"visible\">True</property>"
|
||||||
" <child>"
|
" <child>"
|
||||||
" <object class=\"GtkLabel\" id=\"label3\">"
|
" <object class=\"GtkLabel\" id=\"label3\">"
|
||||||
@ -198,27 +201,29 @@ TestInterface interfaces[] = {
|
|||||||
"Horizontal Box",
|
"Horizontal Box",
|
||||||
"Demonstrates how a horizontal box can calculate the collective height for an allocated width",
|
"Demonstrates how a horizontal box can calculate the collective height for an allocated width",
|
||||||
"<interface>"
|
"<interface>"
|
||||||
" <requires lib=\"gtk+\" version=\"2.20\"/>"
|
" <requires lib=\"gtk+\" version=\"3.22\"/>"
|
||||||
" <!-- interface-naming-policy project-wide -->"
|
" <!-- interface-naming-policy project-wide -->"
|
||||||
" <object class=\"GtkWindow\" id=\"window\">"
|
" <object class=\"GtkWindow\" id=\"window\">"
|
||||||
" <property name=\"default_height\">200</property>"
|
" <property name=\"default_height\">200</property>"
|
||||||
" <property name=\"default_width\">600</property>"
|
" <property name=\"default_width\">600</property>"
|
||||||
" <child>"
|
" <child>"
|
||||||
" <object class=\"GtkHPaned\" id=\"hpaned1\">"
|
" <object class=\"GtkPaned\" id=\"hpaned1\">"
|
||||||
|
" <property name=\"orientation\">horizontal</property>"
|
||||||
" <property name=\"visible\">True</property>"
|
" <property name=\"visible\">True</property>"
|
||||||
" <property name=\"can_focus\">True</property>"
|
" <property name=\"can_focus\">True</property>"
|
||||||
" <child>"
|
" <child>"
|
||||||
" <object class=\"GtkVBox\" id=\"vbox1\">"
|
" <object class=\"GtkBox\" id=\"vbox1\">"
|
||||||
|
" <property name=\"orientation\">vertical</property>"
|
||||||
" <property name=\"visible\">True</property>"
|
" <property name=\"visible\">True</property>"
|
||||||
" <child>"
|
" <child>"
|
||||||
" <object class=\"GtkHBox\" id=\"hbox1\">"
|
" <object class=\"GtkBox\" id=\"hbox1\">"
|
||||||
|
" <property name=\"orientation\">horizontal</property>"
|
||||||
" <property name=\"visible\">True</property>"
|
" <property name=\"visible\">True</property>"
|
||||||
" <child>"
|
" <child>"
|
||||||
" <object class=\"GtkButton\" id=\"button1\">"
|
" <object class=\"GtkButton\" id=\"button1\">"
|
||||||
" <property name=\"visible\">True</property>"
|
" <property name=\"visible\">True</property>"
|
||||||
" <property name=\"can_focus\">True</property>"
|
" <property name=\"can_focus\">True</property>"
|
||||||
" <property name=\"receives_default\">True</property>"
|
" <property name=\"receives_default\">True</property>"
|
||||||
" <property name=\"use_action_appearance\">False</property>"
|
|
||||||
" <child>"
|
" <child>"
|
||||||
" <object class=\"GtkLabel\" id=\"label2\">"
|
" <object class=\"GtkLabel\" id=\"label2\">"
|
||||||
" <property name=\"visible\">True</property>"
|
" <property name=\"visible\">True</property>"
|
||||||
@ -262,7 +267,6 @@ TestInterface interfaces[] = {
|
|||||||
" <property name=\"visible\">True</property>"
|
" <property name=\"visible\">True</property>"
|
||||||
" <property name=\"can_focus\">True</property>"
|
" <property name=\"can_focus\">True</property>"
|
||||||
" <property name=\"receives_default\">True</property>"
|
" <property name=\"receives_default\">True</property>"
|
||||||
" <property name=\"use_action_appearance\">False</property>"
|
|
||||||
" </object>"
|
" </object>"
|
||||||
" <packing>"
|
" <packing>"
|
||||||
" <property name=\"position\">1</property>"
|
" <property name=\"position\">1</property>"
|
||||||
@ -303,17 +307,19 @@ TestInterface interfaces[] = {
|
|||||||
"Demonstrates how a horizontal box will consider width-for-height when allocating children "
|
"Demonstrates how a horizontal box will consider width-for-height when allocating children "
|
||||||
"even if the toplevel window is requested as height-for-width.",
|
"even if the toplevel window is requested as height-for-width.",
|
||||||
"<interface>"
|
"<interface>"
|
||||||
" <requires lib=\"gtk+\" version=\"2.20\"/>"
|
" <requires lib=\"gtk+\" version=\"3.22\"/>"
|
||||||
" <!-- interface-naming-policy project-wide -->"
|
" <!-- interface-naming-policy project-wide -->"
|
||||||
" <object class=\"GtkWindow\" id=\"window\">"
|
" <object class=\"GtkWindow\" id=\"window\">"
|
||||||
" <property name=\"default_width\">400</property>"
|
" <property name=\"default_width\">400</property>"
|
||||||
" <property name=\"default_height\">300</property>"
|
" <property name=\"default_height\">300</property>"
|
||||||
" <child>"
|
" <child>"
|
||||||
" <object class=\"GtkVPaned\" id=\"vpaned1\">"
|
" <object class=\"GtkPaned\" id=\"vpaned1\">"
|
||||||
|
" <property name=\"orientation\">vertical</property>"
|
||||||
" <property name=\"visible\">True</property>"
|
" <property name=\"visible\">True</property>"
|
||||||
" <property name=\"can_focus\">True</property>"
|
" <property name=\"can_focus\">True</property>"
|
||||||
" <child>"
|
" <child>"
|
||||||
" <object class=\"GtkHBox\" id=\"hbox1\">"
|
" <object class=\"GtkBox\" id=\"hbox1\">"
|
||||||
|
" <property name=\"orientation\">horizontal</property>"
|
||||||
" <property name=\"visible\">True</property>"
|
" <property name=\"visible\">True</property>"
|
||||||
" <child>"
|
" <child>"
|
||||||
" <object class=\"GtkLabel\" id=\"label1\">"
|
" <object class=\"GtkLabel\" id=\"label1\">"
|
||||||
@ -364,7 +370,8 @@ TestInterface interfaces[] = {
|
|||||||
" </packing>"
|
" </packing>"
|
||||||
" </child>"
|
" </child>"
|
||||||
" <child>"
|
" <child>"
|
||||||
" <object class=\"GtkHBox\" id=\"hbox2\">"
|
" <object class=\"GtkBox\" id=\"hbox2\">"
|
||||||
|
" <property name=\"orientation\">horizontal</property>"
|
||||||
" <property name=\"visible\">True</property>"
|
" <property name=\"visible\">True</property>"
|
||||||
" <child>"
|
" <child>"
|
||||||
" <object class=\"GtkFrame\" id=\"frame2\">"
|
" <object class=\"GtkFrame\" id=\"frame2\">"
|
||||||
@ -426,19 +433,22 @@ TestInterface interfaces[] = {
|
|||||||
"This test demonstrates how \"width-chars\" and \"max-width-chars\" can be used "
|
"This test demonstrates how \"width-chars\" and \"max-width-chars\" can be used "
|
||||||
"to effect minimum and natural widths in wrapping labels.",
|
"to effect minimum and natural widths in wrapping labels.",
|
||||||
"<interface>"
|
"<interface>"
|
||||||
" <requires lib=\"gtk+\" version=\"2.20\"/>"
|
" <requires lib=\"gtk+\" version=\"3.22\"/>"
|
||||||
" <!-- interface-naming-policy project-wide -->"
|
" <!-- interface-naming-policy project-wide -->"
|
||||||
" <object class=\"GtkWindow\" id=\"window\">"
|
" <object class=\"GtkWindow\" id=\"window\">"
|
||||||
" <property name=\"default_width\">900</property>"
|
" <property name=\"default_width\">900</property>"
|
||||||
" <child>"
|
" <child>"
|
||||||
" <object class=\"GtkHPaned\" id=\"hpaned1\">"
|
" <object class=\"GtkPaned\" id=\"hpaned1\">"
|
||||||
|
" <property name=\"orientation\">horizontal</property>"
|
||||||
" <property name=\"visible\">True</property>"
|
" <property name=\"visible\">True</property>"
|
||||||
" <property name=\"can_focus\">True</property>"
|
" <property name=\"can_focus\">True</property>"
|
||||||
" <child>"
|
" <child>"
|
||||||
" <object class=\"GtkVBox\" id=\"vbox1\">"
|
" <object class=\"GtkBox\" id=\"vbox1\">"
|
||||||
|
" <property name=\"orientation\">vertical</property>"
|
||||||
" <property name=\"visible\">True</property>"
|
" <property name=\"visible\">True</property>"
|
||||||
" <child>"
|
" <child>"
|
||||||
" <object class=\"GtkHBox\" id=\"hbox1\">"
|
" <object class=\"GtkBox\" id=\"hbox1\">"
|
||||||
|
" <property name=\"orientation\">horizontal</property>"
|
||||||
" <property name=\"visible\">True</property>"
|
" <property name=\"visible\">True</property>"
|
||||||
" <property name=\"spacing\">6</property>"
|
" <property name=\"spacing\">6</property>"
|
||||||
" <child>"
|
" <child>"
|
||||||
@ -550,12 +560,13 @@ TestInterface interfaces[] = {
|
|||||||
"and also trade height for width.",
|
"and also trade height for width.",
|
||||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
||||||
"<interface>"
|
"<interface>"
|
||||||
" <requires lib=\"gtk+\" version=\"2.20\"/>"
|
" <requires lib=\"gtk+\" version=\"3.22\"/>"
|
||||||
" <!-- interface-naming-policy project-wide -->"
|
" <!-- interface-naming-policy project-wide -->"
|
||||||
" <object class=\"GtkWindow\" id=\"window\">"
|
" <object class=\"GtkWindow\" id=\"window\">"
|
||||||
" <property name=\"default_width\">500</property>"
|
" <property name=\"default_width\">500</property>"
|
||||||
" <child>"
|
" <child>"
|
||||||
" <object class=\"GtkHPaned\" id=\"hpaned1\">"
|
" <object class=\"GtkPaned\" id=\"hpaned1\">"
|
||||||
|
" <property name=\"orientation\">horizontal</property>"
|
||||||
" <property name=\"visible\">True</property>"
|
" <property name=\"visible\">True</property>"
|
||||||
" <property name=\"can_focus\">True</property>"
|
" <property name=\"can_focus\">True</property>"
|
||||||
" <child>"
|
" <child>"
|
||||||
@ -620,7 +631,7 @@ TestInterface interfaces[] = {
|
|||||||
"and also trade height for width.",
|
"and also trade height for width.",
|
||||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
||||||
"<interface>"
|
"<interface>"
|
||||||
" <requires lib=\"gtk+\" version=\"2.20\"/>"
|
" <requires lib=\"gtk+\" version=\"3.22\"/>"
|
||||||
" <!-- interface-naming-policy project-wide -->"
|
" <!-- interface-naming-policy project-wide -->"
|
||||||
" <object class=\"GtkWindow\" id=\"window\">"
|
" <object class=\"GtkWindow\" id=\"window\">"
|
||||||
" <property name=\"default_width\">400</property>"
|
" <property name=\"default_width\">400</property>"
|
||||||
@ -631,15 +642,10 @@ TestInterface interfaces[] = {
|
|||||||
" <property name=\"border_width\">8</property>"
|
" <property name=\"border_width\">8</property>"
|
||||||
" <property name=\"label_xalign\">0</property>"
|
" <property name=\"label_xalign\">0</property>"
|
||||||
" <child>"
|
" <child>"
|
||||||
" <object class=\"GtkAlignment\" id=\"alignment1\">"
|
|
||||||
" <property name=\"visible\">True</property>"
|
|
||||||
" <property name=\"left_padding\">12</property>"
|
|
||||||
" <child>"
|
|
||||||
" <object class=\"GtkLabel\" id=\"label2\">"
|
" <object class=\"GtkLabel\" id=\"label2\">"
|
||||||
" <property name=\"visible\">True</property>"
|
" <property name=\"visible\">True</property>"
|
||||||
" <property name=\"label\" translatable=\"yes\">some content</property>"
|
" <property name=\"label\" translatable=\"yes\">some content</property>"
|
||||||
" </object>"
|
" <property name=\"margin_start\">12</property>"
|
||||||
" </child>"
|
|
||||||
" </object>"
|
" </object>"
|
||||||
" </child>"
|
" </child>"
|
||||||
" <child type=\"label\">"
|
" <child type=\"label\">"
|
||||||
@ -662,21 +668,24 @@ TestInterface interfaces[] = {
|
|||||||
"This test shows wrapping and ellipsizing text in combo boxes (and consequently in menu items).",
|
"This test shows wrapping and ellipsizing text in combo boxes (and consequently in menu items).",
|
||||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
||||||
"<interface>"
|
"<interface>"
|
||||||
" <requires lib=\"gtk+\" version=\"2.20\"/>"
|
" <requires lib=\"gtk+\" version=\"3.22\"/>"
|
||||||
" <!-- interface-naming-policy project-wide -->"
|
" <!-- interface-naming-policy project-wide -->"
|
||||||
" <object class=\"GtkWindow\" id=\"window\">"
|
" <object class=\"GtkWindow\" id=\"window\">"
|
||||||
" <property name=\"border_width\">8</property>"
|
" <property name=\"border_width\">8</property>"
|
||||||
" <property name=\"default_width\">600</property>"
|
" <property name=\"default_width\">600</property>"
|
||||||
" <child>"
|
" <child>"
|
||||||
" <object class=\"GtkHPaned\" id=\"hpaned1\">"
|
" <object class=\"GtkPaned\" id=\"hpaned1\">"
|
||||||
|
" <property name=\"orientation\">horizontal</property>"
|
||||||
" <property name=\"visible\">True</property>"
|
" <property name=\"visible\">True</property>"
|
||||||
" <property name=\"can_focus\">True</property>"
|
" <property name=\"can_focus\">True</property>"
|
||||||
" <child>"
|
" <child>"
|
||||||
" <object class=\"GtkVBox\" id=\"vbox1\">"
|
" <object class=\"GtkBox\" id=\"vbox1\">"
|
||||||
|
" <property name=\"orientation\">vertical</property>"
|
||||||
" <property name=\"visible\">True</property>"
|
" <property name=\"visible\">True</property>"
|
||||||
" <property name=\"spacing\">5</property>"
|
" <property name=\"spacing\">5</property>"
|
||||||
" <child>"
|
" <child>"
|
||||||
" <object class=\"GtkHBox\" id=\"hbox1\">"
|
" <object class=\"GtkBox\" id=\"hbox1\">"
|
||||||
|
" <property name=\"orientation\">horizontal</property>"
|
||||||
" <property name=\"visible\">True</property>"
|
" <property name=\"visible\">True</property>"
|
||||||
" <property name=\"spacing\">5</property>"
|
" <property name=\"spacing\">5</property>"
|
||||||
" <child>"
|
" <child>"
|
||||||
@ -777,7 +786,8 @@ TestInterface interfaces[] = {
|
|||||||
" </packing>"
|
" </packing>"
|
||||||
" </child>"
|
" </child>"
|
||||||
" <child>"
|
" <child>"
|
||||||
" <object class=\"GtkHBox\" id=\"hbox2\">"
|
" <object class=\"GtkBox\" id=\"hbox2\">"
|
||||||
|
" <property name=\"orientation\">horizontal</property>"
|
||||||
" <property name=\"visible\">True</property>"
|
" <property name=\"visible\">True</property>"
|
||||||
" <property name=\"spacing\">5</property>"
|
" <property name=\"spacing\">5</property>"
|
||||||
" <child>"
|
" <child>"
|
||||||
@ -921,12 +931,24 @@ test_clicked (GtkWidget *button,
|
|||||||
if (!interface->window)
|
if (!interface->window)
|
||||||
{
|
{
|
||||||
GtkBuilder *builder = gtk_builder_new ();
|
GtkBuilder *builder = gtk_builder_new ();
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
gtk_builder_add_from_string (builder, interface->interface, -1, &error);
|
||||||
|
|
||||||
|
if (error)
|
||||||
|
{
|
||||||
|
g_printerr ("GtkBuilder for interface \"%s\" returned error \"%s\"\n",
|
||||||
|
interface->name, error->message);
|
||||||
|
g_error_free (error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
gtk_builder_add_from_string (builder, interface->interface, -1, NULL);
|
|
||||||
interface->window = (GtkWidget *)gtk_builder_get_object (builder, "window");
|
interface->window = (GtkWidget *)gtk_builder_get_object (builder, "window");
|
||||||
|
|
||||||
g_signal_connect (interface->window, "delete_event",
|
g_signal_connect (interface->window, "delete_event",
|
||||||
G_CALLBACK (gtk_widget_hide_on_delete), NULL);
|
G_CALLBACK (gtk_widget_hide_on_delete), NULL);
|
||||||
|
|
||||||
|
g_object_unref (builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_widget_show (interface->window);
|
gtk_widget_show (interface->window);
|
||||||
@ -963,7 +985,19 @@ create_window (void)
|
|||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
main_window_delete_cb (GtkWidget *widget, GdkEvent *event, gpointer user_data)
|
||||||
|
{
|
||||||
|
for (gsize i = 0; i < sizeof(interfaces) / sizeof(TestInterface); ++i)
|
||||||
|
{
|
||||||
|
if (interfaces[i].window)
|
||||||
|
{
|
||||||
|
gtk_widget_destroy (interfaces[i].window);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_main_quit ();
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
@ -975,7 +1009,7 @@ main (int argc, char *argv[])
|
|||||||
window = create_window ();
|
window = create_window ();
|
||||||
|
|
||||||
g_signal_connect (window, "delete-event",
|
g_signal_connect (window, "delete-event",
|
||||||
G_CALLBACK (gtk_main_quit), window);
|
G_CALLBACK (main_window_delete_cb), window);
|
||||||
|
|
||||||
gtk_widget_show (window);
|
gtk_widget_show (window);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user