[gtk+/gtk-3-22] testheightforwidth: Remove deprecations & clean up
- From: Daniel Boles <dboles src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-3-22] testheightforwidth: Remove deprecations & clean up
- Date: Mon, 6 Mar 2017 20:56:01 +0000 (UTC)
commit 77f01c374bbba433b3a1fdfefae1e398adb912aa
Author: Daniel Boles <dboles src gnome org>
Date: Mon Mar 6 20:48:01 2017 +0000
testheightforwidth: Remove deprecations & clean up
cherry-pick of master commit bf0ea7b7bc8de1c39923d4976f6e1aafd23b92c7
tests/testheightforwidth.c | 110 +++++++++++++++++++++++++++++---------------
1 files changed, 72 insertions(+), 38 deletions(-)
---
diff --git a/tests/testheightforwidth.c b/tests/testheightforwidth.c
index fe47ed3..4eb2222 100644
--- a/tests/testheightforwidth.c
+++ b/tests/testheightforwidth.c
@@ -32,18 +32,19 @@ typedef struct {
*
* 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",
"Demonstrates how labels will request a natural size in a horizontal space",
"<interface>"
- " <requires lib=\"gtk+\" version=\"2.20\"/>"
+ " <requires lib=\"gtk+\" version=\"3.22\"/>"
" <!-- interface-naming-policy project-wide -->"
" <object class=\"GtkWindow\" id=\"window\">"
" <property name=\"default_width\">450</property>"
" <property name=\"default_height\">50</property>"
" <child>"
- " <object class=\"GtkHBox\" id=\"hbox5\">"
+ " <object class=\"GtkBox\" id=\"hbox5\">"
+ " <property name=\"orientation\">horizontal</property>"
" <property name=\"visible\">True</property>"
" <child>"
" <object class=\"GtkLabel\" id=\"label9\">"
@@ -98,17 +99,19 @@ TestInterface interfaces[] = {
"Wrapping Label",
"Demonstrates how a wrapping label can require a height contextual to its allocated width",
"<interface>"
- " <requires lib=\"gtk+\" version=\"2.18\"/>"
+ " <requires lib=\"gtk+\" version=\"3.22\"/>"
" <!-- interface-naming-policy project-wide -->"
" <object class=\"GtkWindow\" id=\"window\">"
" <property name=\"border_width\">12</property>"
" <property name=\"default_width\">300</property>"
" <child>"
- " <object class=\"GtkHPaned\" id=\"hpaned1\">"
+ " <object class=\"GtkPaned\" id=\"hpaned1\">"
+ " <property name=\"orientation\">horizontal</property>"
" <property name=\"visible\">True</property>"
" <property name=\"can_focus\">True</property>"
" <child>"
- " <object class=\"GtkVBox\" id=\"vbox2\">"
+ " <object class=\"GtkBox\" id=\"vbox2\">"
+ " <property name=\"orientation\">vertical</property>"
" <property name=\"visible\">True</property>"
" <child>"
" <object class=\"GtkLabel\" id=\"label3\">"
@@ -198,27 +201,29 @@ TestInterface interfaces[] = {
"Horizontal Box",
"Demonstrates how a horizontal box can calculate the collective height for an allocated width",
"<interface>"
- " <requires lib=\"gtk+\" version=\"2.20\"/>"
+ " <requires lib=\"gtk+\" version=\"3.22\"/>"
" <!-- interface-naming-policy project-wide -->"
" <object class=\"GtkWindow\" id=\"window\">"
" <property name=\"default_height\">200</property>"
" <property name=\"default_width\">600</property>"
" <child>"
- " <object class=\"GtkHPaned\" id=\"hpaned1\">"
+ " <object class=\"GtkPaned\" id=\"hpaned1\">"
+ " <property name=\"orientation\">horizontal</property>"
" <property name=\"visible\">True</property>"
" <property name=\"can_focus\">True</property>"
" <child>"
- " <object class=\"GtkVBox\" id=\"vbox1\">"
+ " <object class=\"GtkBox\" id=\"vbox1\">"
+ " <property name=\"orientation\">vertical</property>"
" <property name=\"visible\">True</property>"
" <child>"
- " <object class=\"GtkHBox\" id=\"hbox1\">"
+ " <object class=\"GtkBox\" id=\"hbox1\">"
+ " <property name=\"orientation\">horizontal</property>"
" <property name=\"visible\">True</property>"
" <child>"
" <object class=\"GtkButton\" id=\"button1\">"
" <property name=\"visible\">True</property>"
" <property name=\"can_focus\">True</property>"
" <property name=\"receives_default\">True</property>"
- " <property name=\"use_action_appearance\">False</property>"
" <child>"
" <object class=\"GtkLabel\" id=\"label2\">"
" <property name=\"visible\">True</property>"
@@ -262,7 +267,6 @@ TestInterface interfaces[] = {
" <property name=\"visible\">True</property>"
" <property name=\"can_focus\">True</property>"
" <property name=\"receives_default\">True</property>"
- " <property name=\"use_action_appearance\">False</property>"
" </object>"
" <packing>"
" <property name=\"position\">1</property>"
@@ -303,17 +307,19 @@ TestInterface interfaces[] = {
"Demonstrates how a horizontal box will consider width-for-height when allocating children "
"even if the toplevel window is requested as height-for-width.",
"<interface>"
- " <requires lib=\"gtk+\" version=\"2.20\"/>"
+ " <requires lib=\"gtk+\" version=\"3.22\"/>"
" <!-- interface-naming-policy project-wide -->"
" <object class=\"GtkWindow\" id=\"window\">"
" <property name=\"default_width\">400</property>"
" <property name=\"default_height\">300</property>"
" <child>"
- " <object class=\"GtkVPaned\" id=\"vpaned1\">"
+ " <object class=\"GtkPaned\" id=\"vpaned1\">"
+ " <property name=\"orientation\">vertical</property>"
" <property name=\"visible\">True</property>"
" <property name=\"can_focus\">True</property>"
" <child>"
- " <object class=\"GtkHBox\" id=\"hbox1\">"
+ " <object class=\"GtkBox\" id=\"hbox1\">"
+ " <property name=\"orientation\">horizontal</property>"
" <property name=\"visible\">True</property>"
" <child>"
" <object class=\"GtkLabel\" id=\"label1\">"
@@ -364,7 +370,8 @@ TestInterface interfaces[] = {
" </packing>"
" </child>"
" <child>"
- " <object class=\"GtkHBox\" id=\"hbox2\">"
+ " <object class=\"GtkBox\" id=\"hbox2\">"
+ " <property name=\"orientation\">horizontal</property>"
" <property name=\"visible\">True</property>"
" <child>"
" <object class=\"GtkFrame\" id=\"frame2\">"
@@ -426,19 +433,22 @@ TestInterface interfaces[] = {
"This test demonstrates how \"width-chars\" and \"max-width-chars\" can be used "
"to effect minimum and natural widths in wrapping labels.",
"<interface>"
- " <requires lib=\"gtk+\" version=\"2.20\"/>"
+ " <requires lib=\"gtk+\" version=\"3.22\"/>"
" <!-- interface-naming-policy project-wide -->"
" <object class=\"GtkWindow\" id=\"window\">"
" <property name=\"default_width\">900</property>"
" <child>"
- " <object class=\"GtkHPaned\" id=\"hpaned1\">"
+ " <object class=\"GtkPaned\" id=\"hpaned1\">"
+ " <property name=\"orientation\">horizontal</property>"
" <property name=\"visible\">True</property>"
" <property name=\"can_focus\">True</property>"
" <child>"
- " <object class=\"GtkVBox\" id=\"vbox1\">"
+ " <object class=\"GtkBox\" id=\"vbox1\">"
+ " <property name=\"orientation\">vertical</property>"
" <property name=\"visible\">True</property>"
" <child>"
- " <object class=\"GtkHBox\" id=\"hbox1\">"
+ " <object class=\"GtkBox\" id=\"hbox1\">"
+ " <property name=\"orientation\">horizontal</property>"
" <property name=\"visible\">True</property>"
" <property name=\"spacing\">6</property>"
" <child>"
@@ -550,12 +560,13 @@ TestInterface interfaces[] = {
"and also trade height for width.",
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
"<interface>"
- " <requires lib=\"gtk+\" version=\"2.20\"/>"
+ " <requires lib=\"gtk+\" version=\"3.22\"/>"
" <!-- interface-naming-policy project-wide -->"
" <object class=\"GtkWindow\" id=\"window\">"
" <property name=\"default_width\">500</property>"
" <child>"
- " <object class=\"GtkHPaned\" id=\"hpaned1\">"
+ " <object class=\"GtkPaned\" id=\"hpaned1\">"
+ " <property name=\"orientation\">horizontal</property>"
" <property name=\"visible\">True</property>"
" <property name=\"can_focus\">True</property>"
" <child>"
@@ -620,7 +631,7 @@ TestInterface interfaces[] = {
"and also trade height for width.",
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
"<interface>"
- " <requires lib=\"gtk+\" version=\"2.20\"/>"
+ " <requires lib=\"gtk+\" version=\"3.22\"/>"
" <!-- interface-naming-policy project-wide -->"
" <object class=\"GtkWindow\" id=\"window\">"
" <property name=\"default_width\">400</property>"
@@ -631,15 +642,10 @@ TestInterface interfaces[] = {
" <property name=\"border_width\">8</property>"
" <property name=\"label_xalign\">0</property>"
" <child>"
- " <object class=\"GtkAlignment\" id=\"alignment1\">"
+ " <object class=\"GtkLabel\" id=\"label2\">"
" <property name=\"visible\">True</property>"
- " <property name=\"left_padding\">12</property>"
- " <child>"
- " <object class=\"GtkLabel\" id=\"label2\">"
- " <property name=\"visible\">True</property>"
- " <property name=\"label\" translatable=\"yes\">some content</property>"
- " </object>"
- " </child>"
+ " <property name=\"label\" translatable=\"yes\">some content</property>"
+ " <property name=\"margin_start\">12</property>"
" </object>"
" </child>"
" <child type=\"label\">"
@@ -662,21 +668,24 @@ TestInterface interfaces[] = {
"This test shows wrapping and ellipsizing text in combo boxes (and consequently in menu items).",
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
"<interface>"
- " <requires lib=\"gtk+\" version=\"2.20\"/>"
+ " <requires lib=\"gtk+\" version=\"3.22\"/>"
" <!-- interface-naming-policy project-wide -->"
" <object class=\"GtkWindow\" id=\"window\">"
" <property name=\"border_width\">8</property>"
" <property name=\"default_width\">600</property>"
" <child>"
- " <object class=\"GtkHPaned\" id=\"hpaned1\">"
+ " <object class=\"GtkPaned\" id=\"hpaned1\">"
+ " <property name=\"orientation\">horizontal</property>"
" <property name=\"visible\">True</property>"
" <property name=\"can_focus\">True</property>"
" <child>"
- " <object class=\"GtkVBox\" id=\"vbox1\">"
+ " <object class=\"GtkBox\" id=\"vbox1\">"
+ " <property name=\"orientation\">vertical</property>"
" <property name=\"visible\">True</property>"
" <property name=\"spacing\">5</property>"
" <child>"
- " <object class=\"GtkHBox\" id=\"hbox1\">"
+ " <object class=\"GtkBox\" id=\"hbox1\">"
+ " <property name=\"orientation\">horizontal</property>"
" <property name=\"visible\">True</property>"
" <property name=\"spacing\">5</property>"
" <child>"
@@ -777,7 +786,8 @@ TestInterface interfaces[] = {
" </packing>"
" </child>"
" <child>"
- " <object class=\"GtkHBox\" id=\"hbox2\">"
+ " <object class=\"GtkBox\" id=\"hbox2\">"
+ " <property name=\"orientation\">horizontal</property>"
" <property name=\"visible\">True</property>"
" <property name=\"spacing\">5</property>"
" <child>"
@@ -921,12 +931,24 @@ test_clicked (GtkWidget *button,
if (!interface->window)
{
GtkBuilder *builder = gtk_builder_new ();
+ GError *error = NULL;
- gtk_builder_add_from_string (builder, interface->interface, -1, 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;
+ }
+
interface->window = (GtkWidget *)gtk_builder_get_object (builder, "window");
g_signal_connect (interface->window, "delete_event",
G_CALLBACK (gtk_widget_hide_on_delete), NULL);
+
+ g_object_unref (builder);
}
gtk_widget_show (interface->window);
@@ -963,7 +985,19 @@ create_window (void)
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
main (int argc, char *argv[])
@@ -975,7 +1009,7 @@ main (int argc, char *argv[])
window = create_window ();
g_signal_connect (window, "delete-event",
- G_CALLBACK (gtk_main_quit), window);
+ G_CALLBACK (main_window_delete_cb), window);
gtk_widget_show (window);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]