| 1 |
/* Gtk+ property notify tests |
| 2 |
* Copyright (C) 2014 Matthias Clasen |
| 3 |
* |
| 4 |
* This library is free software; you can redistribute it and/or |
| 5 |
* modify it under the terms of the GNU Library General Public |
| 6 |
* License as published by the Free Software Foundation; either |
| 7 |
* version 2 of the License, or (at your option) any later version. |
| 8 |
* |
| 9 |
* This library is distributed in the hope that it will be useful, |
| 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 |
* Library General Public License for more details. |
| 13 |
* |
| 14 |
* You should have received a copy of the GNU Library General Public |
| 15 |
* License along with this library. If not, see <http://www.gnu.org/licenses/>. |
| 16 |
*/ |
| 17 |
|
| 18 |
#include <math.h> |
| 19 |
#include <string.h> |
| 20 |
#include <gtk/gtk.h> |
| 21 |
#include <gtk/gtkunixprint.h> |
| 22 |
#ifdef GDK_WINDOWING_X11 |
| 23 |
#include <gtk/gtkx.h> |
| 24 |
#endif |
| 25 |
#ifdef GDK_WINDOWING_WAYLAND |
| 26 |
#include "gdk/wayland/gdkwayland.h" |
| 27 |
#endif |
| 28 |
|
| 29 |
typedef struct |
| 30 |
{ |
| 31 |
const gchar *name; |
| 32 |
gint count; |
| 33 |
} NotifyData; |
| 34 |
|
| 35 |
static void |
| 36 |
count_notify (GObject *obj, GParamSpec *pspec, NotifyData *data) |
| 37 |
{ |
| 38 |
if (g_strcmp0 (data->name, pspec->name) == 0) |
| 39 |
data->count++; |
| 40 |
} |
| 41 |
|
| 42 |
/* Check that we get notifications when properties change. |
| 43 |
* Also check that we don't emit redundant notifications for |
| 44 |
* enum, flags, booleans, ints. We allow redundant notifications |
| 45 |
* for strings, and floats |
| 46 |
*/ |
| 47 |
static void |
| 48 |
check_property (GObject *instance, GParamSpec *pspec) |
| 49 |
{ |
| 50 |
if (G_TYPE_IS_ENUM (pspec->value_type)) |
| 51 |
{ |
| 52 |
GEnumClass *class; |
| 53 |
gint i; |
| 54 |
NotifyData data; |
| 55 |
gulong id; |
| 56 |
gint first; |
| 57 |
gint value; |
| 58 |
gint current_count; |
| 59 |
|
| 60 |
class = g_type_class_ref (pspec->value_type); |
| 61 |
|
| 62 |
data.name = pspec->name; |
| 63 |
data.count = 0; |
| 64 |
id = g_signal_connect (instance, "notify", G_CALLBACK (count_notify), &data); |
| 65 |
|
| 66 |
g_object_get (instance, pspec->name, &value, NULL); |
| 67 |
g_object_set (instance, pspec->name, value, NULL); |
| 68 |
|
| 69 |
g_assert_cmpint (data.count, ==, 0); |
| 70 |
|
| 71 |
if (class->values[0].value == value) |
| 72 |
first = 1; |
| 73 |
else |
| 74 |
first = 0; |
| 75 |
|
| 76 |
for (i = first; i < class->n_values; i++) |
| 77 |
{ |
| 78 |
current_count = data.count + 1; |
| 79 |
g_object_set (instance, pspec->name, class->values[i].value, NULL); |
| 80 |
g_assert_cmpint (data.count, ==, current_count); |
| 81 |
|
| 82 |
if (current_count == 10) /* just test a few */ |
| 83 |
break; |
| 84 |
} |
| 85 |
|
| 86 |
g_signal_handler_disconnect (instance, id); |
| 87 |
g_type_class_unref (class); |
| 88 |
} |
| 89 |
else if (G_TYPE_IS_FLAGS (pspec->value_type)) |
| 90 |
{ |
| 91 |
GFlagsClass *class; |
| 92 |
gint i; |
| 93 |
NotifyData data; |
| 94 |
gulong id; |
| 95 |
guint value; |
| 96 |
gint current_count; |
| 97 |
|
| 98 |
class = g_type_class_ref (pspec->value_type); |
| 99 |
|
| 100 |
data.name = pspec->name; |
| 101 |
data.count = 0; |
| 102 |
id = g_signal_connect (instance, "notify", G_CALLBACK (count_notify), &data); |
| 103 |
|
| 104 |
g_object_get (instance, pspec->name, &value, NULL); |
| 105 |
g_object_set (instance, pspec->name, value, NULL); |
| 106 |
|
| 107 |
g_assert_cmpint (data.count, ==, 0); |
| 108 |
|
| 109 |
for (i = 0; i < class->n_values; i++) |
| 110 |
{ |
| 111 |
/* some flags have a 'none' member, skip it */ |
| 112 |
if (class->values[i].value == 0) |
| 113 |
continue; |
| 114 |
|
| 115 |
if ((value & class->values[i].value) != 0) |
| 116 |
continue; |
| 117 |
|
| 118 |
value |= class->values[i].value; |
| 119 |
current_count = data.count + 1; |
| 120 |
g_object_set (instance, pspec->name, value, NULL); |
| 121 |
g_assert_cmpint (data.count, ==, current_count); |
| 122 |
|
| 123 |
if (current_count == 10) /* just test a few */ |
| 124 |
break; |
| 125 |
} |
| 126 |
|
| 127 |
g_signal_handler_disconnect (instance, id); |
| 128 |
g_type_class_unref (class); |
| 129 |
} |
| 130 |
else if (pspec->value_type == G_TYPE_BOOLEAN) |
| 131 |
{ |
| 132 |
NotifyData data; |
| 133 |
gboolean value; |
| 134 |
gulong id; |
| 135 |
|
| 136 |
data.name = pspec->name; |
| 137 |
data.count = 0; |
| 138 |
id = g_signal_connect (instance, "notify", G_CALLBACK (count_notify), &data); |
| 139 |
|
| 140 |
g_object_get (instance, pspec->name, &value, NULL); |
| 141 |
g_object_set (instance, pspec->name, value, NULL); |
| 142 |
|
| 143 |
g_assert_cmpint (data.count, ==, 0); |
| 144 |
|
| 145 |
g_object_set (instance, pspec->name, 1 - value, NULL); |
| 146 |
|
| 147 |
g_assert_cmpint (data.count, ==, 1); |
| 148 |
|
| 149 |
g_signal_handler_disconnect (instance, id); |
| 150 |
} |
| 151 |
else if (pspec->value_type == G_TYPE_INT) |
| 152 |
{ |
| 153 |
GParamSpecInt *p = G_PARAM_SPEC_INT (pspec); |
| 154 |
gint i; |
| 155 |
NotifyData data; |
| 156 |
gulong id; |
| 157 |
gint value; |
| 158 |
gint current_count; |
| 159 |
|
| 160 |
data.name = pspec->name; |
| 161 |
data.count = 0; |
| 162 |
id = g_signal_connect (instance, "notify", G_CALLBACK (count_notify), &data); |
| 163 |
|
| 164 |
g_object_get (instance, pspec->name, &value, NULL); |
| 165 |
g_object_set (instance, pspec->name, value, NULL); |
| 166 |
|
| 167 |
g_assert_cmpint (data.count, ==, 0); |
| 168 |
|
| 169 |
for (i = p->minimum; i <= p->maximum; i++) |
| 170 |
{ |
| 171 |
g_object_get (instance, pspec->name, &value, NULL); |
| 172 |
if (value == i) |
| 173 |
continue; |
| 174 |
|
| 175 |
current_count = data.count + 1; |
| 176 |
g_object_set (instance, pspec->name, i, NULL); |
| 177 |
g_assert_cmpint (data.count, ==, current_count); |
| 178 |
|
| 179 |
if (current_count == 10) /* just test a few */ |
| 180 |
break; |
| 181 |
} |
| 182 |
|
| 183 |
g_signal_handler_disconnect (instance, id); |
| 184 |
} |
| 185 |
else if (pspec->value_type == G_TYPE_UINT) |
| 186 |
{ |
| 187 |
guint i; |
| 188 |
NotifyData data; |
| 189 |
gulong id; |
| 190 |
guint value; |
| 191 |
gint current_count; |
| 192 |
guint minimum, maximum; |
| 193 |
|
| 194 |
if (G_IS_PARAM_SPEC_UINT (pspec)) |
| 195 |
{ |
| 196 |
minimum = G_PARAM_SPEC_UINT (pspec)->minimum; |
| 197 |
maximum = G_PARAM_SPEC_UINT (pspec)->maximum; |
| 198 |
} |
| 199 |
else /* random */ |
| 200 |
{ |
| 201 |
minimum = 0; |
| 202 |
maximum = 1000; |
| 203 |
} |
| 204 |
|
| 205 |
data.name = pspec->name; |
| 206 |
data.count = 0; |
| 207 |
id = g_signal_connect (instance, "notify", G_CALLBACK (count_notify), &data); |
| 208 |
|
| 209 |
g_object_get (instance, pspec->name, &value, NULL); |
| 210 |
g_object_set (instance, pspec->name, value, NULL); |
| 211 |
|
| 212 |
g_assert_cmpint (data.count, ==, 0); |
| 213 |
|
| 214 |
for (i = minimum; i <= maximum; i++) |
| 215 |
{ |
| 216 |
g_object_get (instance, pspec->name, &value, NULL); |
| 217 |
if (value == i) |
| 218 |
continue; |
| 219 |
|
| 220 |
current_count = data.count + 1; |
| 221 |
g_object_set (instance, pspec->name, i, NULL); |
| 222 |
g_assert_cmpint (data.count, ==, current_count); |
| 223 |
|
| 224 |
if (current_count == 10) /* just test a few */ |
| 225 |
break; |
| 226 |
} |
| 227 |
|
| 228 |
g_signal_handler_disconnect (instance, id); |
| 229 |
} |
| 230 |
else if (pspec->value_type == G_TYPE_STRING) |
| 231 |
{ |
| 232 |
NotifyData data; |
| 233 |
gulong id; |
| 234 |
gchar *value; |
| 235 |
gchar *new_value; |
| 236 |
|
| 237 |
data.name = pspec->name; |
| 238 |
data.count = 0; |
| 239 |
id = g_signal_connect (instance, "notify", G_CALLBACK (count_notify), &data); |
| 240 |
|
| 241 |
g_object_get (instance, pspec->name, &value, NULL); |
| 242 |
/* don't check redundant notifications */ |
| 243 |
|
| 244 |
new_value = g_strconcat ("(", value, ".", value, ")", NULL); |
| 245 |
|
| 246 |
g_object_set (instance, pspec->name, new_value, NULL); |
| 247 |
|
| 248 |
g_assert_cmpint (data.count, ==, 1); |
| 249 |
|
| 250 |
g_free (value); |
| 251 |
g_free (new_value); |
| 252 |
|
| 253 |
g_signal_handler_disconnect (instance, id); |
| 254 |
} |
| 255 |
else if (pspec->value_type == G_TYPE_DOUBLE) |
| 256 |
{ |
| 257 |
GParamSpecDouble *p = G_PARAM_SPEC_DOUBLE (pspec); |
| 258 |
guint i; |
| 259 |
NotifyData data; |
| 260 |
gulong id; |
| 261 |
gdouble value; |
| 262 |
gdouble new_value; |
| 263 |
gint current_count; |
| 264 |
gdouble delta; |
| 265 |
|
| 266 |
data.name = pspec->name; |
| 267 |
data.count = 0; |
| 268 |
id = g_signal_connect (instance, "notify", G_CALLBACK (count_notify), &data); |
| 269 |
|
| 270 |
/* don't check redundant notifications */ |
| 271 |
g_object_get (instance, pspec->name, &value, NULL); |
| 272 |
|
| 273 |
if (p->maximum > 100 || p->minimum < -100) |
| 274 |
delta = M_PI; |
| 275 |
else |
| 276 |
delta = (p->maximum - p->minimum) / 10.0; |
| 277 |
|
| 278 |
new_value = p->minimum; |
| 279 |
for (i = 0; i < 10; i++) |
| 280 |
{ |
| 281 |
new_value += delta; |
| 282 |
|
| 283 |
if (fabs (value - new_value) < p->epsilon) |
| 284 |
continue; |
| 285 |
|
| 286 |
if (new_value > p->maximum) |
| 287 |
break; |
| 288 |
|
| 289 |
current_count = data.count + 1; |
| 290 |
g_object_set (instance, pspec->name, new_value, NULL); |
| 291 |
g_assert_cmpint (data.count, ==, current_count); |
| 292 |
} |
| 293 |
|
| 294 |
g_signal_handler_disconnect (instance, id); |
| 295 |
} |
| 296 |
else if (pspec->value_type == G_TYPE_FLOAT) |
| 297 |
{ |
| 298 |
GParamSpecFloat *p = G_PARAM_SPEC_FLOAT (pspec); |
| 299 |
guint i; |
| 300 |
NotifyData data; |
| 301 |
gulong id; |
| 302 |
gfloat value; |
| 303 |
gfloat new_value; |
| 304 |
gint current_count; |
| 305 |
|
| 306 |
data.name = pspec->name; |
| 307 |
data.count = 0; |
| 308 |
id = g_signal_connect (instance, "notify", G_CALLBACK (count_notify), &data); |
| 309 |
|
| 310 |
/* don't check redundant notifications */ |
| 311 |
g_object_get (instance, pspec->name, &value, NULL); |
| 312 |
|
| 313 |
new_value = p->minimum; |
| 314 |
for (i = 0; i < 10; i++) |
| 315 |
{ |
| 316 |
if (fabs (value - new_value) < p->epsilon) |
| 317 |
continue; |
| 318 |
|
| 319 |
current_count = data.count + 1; |
| 320 |
new_value += (p->maximum - p->minimum) / 10.0; |
| 321 |
|
| 322 |
if (new_value > p->maximum) |
| 323 |
break; |
| 324 |
|
| 325 |
g_object_set (instance, pspec->name, new_value, NULL); |
| 326 |
g_assert_cmpint (data.count, ==, current_count); |
| 327 |
} |
| 328 |
|
| 329 |
g_signal_handler_disconnect (instance, id); |
| 330 |
} |
| 331 |
else |
| 332 |
{ |
| 333 |
if (g_test_verbose ()) |
| 334 |
g_print ("Skipping property %s.%s of type %s\n", g_type_name (pspec->owner_type), pspec->name, g_type_name (pspec->value_type)); |
| 335 |
} |
| 336 |
} |
| 337 |
|
| 338 |
static void |
| 339 |
test_type (gconstpointer data) |
| 340 |
{ |
| 341 |
GObjectClass *klass; |
| 342 |
GObject *instance; |
| 343 |
GParamSpec **pspecs; |
| 344 |
guint n_pspecs, i; |
| 345 |
GType type; |
| 346 |
GdkDisplay *display; |
| 347 |
|
| 348 |
type = * (GType *) data; |
| 349 |
|
| 350 |
display = gdk_display_get_default (); |
| 351 |
|
| 352 |
if (!G_TYPE_IS_CLASSED (type)) |
| 353 |
return; |
| 354 |
|
| 355 |
if (G_TYPE_IS_ABSTRACT (type)) |
| 356 |
return; |
| 357 |
|
| 358 |
if (!g_type_is_a (type, G_TYPE_OBJECT)) |
| 359 |
return; |
| 360 |
|
| 361 |
/* non-GTK+ */ |
| 362 |
if (g_str_equal (g_type_name (type), "AtkObject") || |
| 363 |
g_str_equal (g_type_name (type), "GdkPixbufSimpleAnim")) |
| 364 |
return; |
| 365 |
|
| 366 |
/* Deprecated, not getting fixed */ |
| 367 |
if (g_str_equal (g_type_name (type), "GtkColorSelection") || |
| 368 |
g_str_equal (g_type_name (type), "GtkHandleBox") || |
| 369 |
g_str_equal (g_type_name (type), "GtkHPaned") || |
| 370 |
g_str_equal (g_type_name (type), "GtkVPaned") || |
| 371 |
g_str_equal (g_type_name (type), "GtkHScale") || |
| 372 |
g_str_equal (g_type_name (type), "GtkVScale") || |
| 373 |
g_str_equal (g_type_name (type), "GtkHScrollbar") || |
| 374 |
g_str_equal (g_type_name (type), "GtkVScrollbar") || |
| 375 |
g_str_equal (g_type_name (type), "GtkHSeparator") || |
| 376 |
g_str_equal (g_type_name (type), "GtkVSeparator") || |
| 377 |
g_str_equal (g_type_name (type), "GtkHBox") || |
| 378 |
g_str_equal (g_type_name (type), "GtkVBox") || |
| 379 |
g_str_equal (g_type_name (type), "GtkArrow") || |
| 380 |
g_str_equal (g_type_name (type), "GtkNumerableIcon") || |
| 381 |
g_str_equal (g_type_name (type), "GtkRadioAction") || |
| 382 |
g_str_equal (g_type_name (type), "GtkToggleAction") || |
| 383 |
g_str_equal (g_type_name (type), "GtkTable") || |
| 384 |
g_str_equal (g_type_name (type), "GtkUIManager") || |
| 385 |
g_str_equal (g_type_name (type), "GtkImageMenuItem")) |
| 386 |
return; |
| 387 |
|
| 388 |
/* These can't be freely constructed/destroyed */ |
| 389 |
if (g_type_is_a (type, GTK_TYPE_APPLICATION) || |
| 390 |
g_type_is_a (type, GDK_TYPE_PIXBUF_LOADER) || |
| 391 |
g_type_is_a (type, GDK_TYPE_DRAWING_CONTEXT) || |
| 392 |
#ifdef G_OS_UNIX |
| 393 |
g_type_is_a (type, GTK_TYPE_PRINT_JOB) || |
| 394 |
#endif |
| 395 |
g_type_is_a (type, gdk_pixbuf_simple_anim_iter_get_type ()) || |
| 396 |
g_str_equal (g_type_name (type), "GdkX11DeviceManagerXI2") || |
| 397 |
g_str_equal (g_type_name (type), "GdkX11DeviceManagerCore") || |
| 398 |
g_str_equal (g_type_name (type), "GdkX11Display") || |
| 399 |
g_str_equal (g_type_name (type), "GdkX11DisplayManager") || |
| 400 |
g_str_equal (g_type_name (type), "GdkX11Screen") || |
| 401 |
g_str_equal (g_type_name (type), "GdkX11GLContext")) |
| 402 |
return; |
| 403 |
|
| 404 |
/* This throws a critical when the connection is dropped */ |
| 405 |
if (g_type_is_a (type, GTK_TYPE_APP_CHOOSER_DIALOG)) |
| 406 |
return; |
| 407 |
|
| 408 |
/* These leak their GDBusConnections */ |
| 409 |
if (g_type_is_a (type, GTK_TYPE_FILE_CHOOSER_BUTTON) || |
| 410 |
g_type_is_a (type, GTK_TYPE_FILE_CHOOSER_DIALOG) || |
| 411 |
g_type_is_a (type, GTK_TYPE_FILE_CHOOSER_WIDGET) || |
| 412 |
g_type_is_a (type, GTK_TYPE_FILE_CHOOSER_NATIVE) || |
| 413 |
g_type_is_a (type, GTK_TYPE_PLACES_SIDEBAR)) |
| 414 |
return; |
| 415 |
|
| 416 |
/* These rely on a d-bus session bus */ |
| 417 |
if (g_type_is_a (type, GTK_TYPE_MOUNT_OPERATION)) |
| 418 |
return; |
| 419 |
|
| 420 |
/* Backend-specific */ |
| 421 |
#ifdef GDK_WINDOWING_X11 |
| 422 |
if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) ; |
| 423 |
else if (g_type_is_a (type, GTK_TYPE_PLUG) || |
| 424 |
g_type_is_a (type, GTK_TYPE_SOCKET)) |
| 425 |
return; |
| 426 |
#endif |
| 427 |
|
| 428 |
if (g_type_is_a (type, GTK_TYPE_STATUS_ICON)) |
| 429 |
return; |
| 430 |
|
| 431 |
klass = g_type_class_ref (type); |
| 432 |
|
| 433 |
if (g_type_is_a (type, GTK_TYPE_SETTINGS)) |
| 434 |
instance = G_OBJECT (g_object_ref (gtk_settings_get_default ())); |
| 435 |
else if (g_type_is_a (type, GDK_TYPE_WINDOW)) |
| 436 |
{ |
| 437 |
GdkWindowAttr attributes; |
| 438 |
attributes.wclass = GDK_INPUT_OUTPUT; |
| 439 |
attributes.window_type = GDK_WINDOW_TEMP; |
| 440 |
attributes.event_mask = 0; |
| 441 |
attributes.width = 100; |
| 442 |
attributes.height = 100; |
| 443 |
instance = G_OBJECT (g_object_ref (gdk_window_new (NULL, &attributes, 0))); |
| 444 |
} |
| 445 |
else if (g_str_equal (g_type_name (type), "GdkX11Cursor")) |
| 446 |
instance = g_object_new (type, "display", display, NULL); |
| 447 |
else |
| 448 |
instance = g_object_new (type, NULL); |
| 449 |
|
| 450 |
if (g_type_is_a (type, G_TYPE_INITIALLY_UNOWNED)) |
| 451 |
g_object_ref_sink (instance); |
| 452 |
|
| 453 |
pspecs = g_object_class_list_properties (klass, &n_pspecs); |
| 454 |
for (i = 0; i < n_pspecs; ++i) |
| 455 |
{ |
| 456 |
GParamSpec *pspec = pspecs[i]; |
| 457 |
|
| 458 |
if ((pspec->flags & G_PARAM_READABLE) == 0) |
| 459 |
continue; |
| 460 |
|
| 461 |
if ((pspec->flags & G_PARAM_WRITABLE) == 0) |
| 462 |
continue; |
| 463 |
|
| 464 |
if ((pspec->flags & G_PARAM_CONSTRUCT_ONLY) != 0) |
| 465 |
continue; |
| 466 |
|
| 467 |
/* non-GTK+ */ |
| 468 |
if (g_str_equal (g_type_name (pspec->owner_type), "AtkObject") || |
| 469 |
g_str_equal (g_type_name (pspec->owner_type), "GdkPixbufSimpleAnim") || |
| 470 |
g_str_equal (g_type_name (pspec->owner_type), "GMountOperation")) |
| 471 |
continue; |
| 472 |
|
| 473 |
/* set properties are best skipped */ |
| 474 |
if (pspec->value_type == G_TYPE_BOOLEAN && |
| 475 |
g_str_has_suffix (pspec->name, "-set")) |
| 476 |
continue; |
| 477 |
|
| 478 |
/* These are special */ |
| 479 |
if (g_type_is_a (pspec->owner_type, GTK_TYPE_WIDGET) && |
| 480 |
(g_str_equal (pspec->name, "has-focus") || |
| 481 |
g_str_equal (pspec->name, "has-default") || |
| 482 |
g_str_equal (pspec->name, "is-focus") || |
| 483 |
g_str_equal (pspec->name, "margin") || |
| 484 |
g_str_equal (pspec->name, "hexpand") || |
| 485 |
g_str_equal (pspec->name, "vexpand") || |
| 486 |
g_str_equal (pspec->name, "expand") |
| 487 |
)) |
| 488 |
continue; |
| 489 |
|
| 490 |
if (pspec->owner_type == GTK_TYPE_ENTRY && |
| 491 |
g_str_equal (pspec->name, "im-module")) |
| 492 |
continue; |
| 493 |
|
| 494 |
if (type == GTK_TYPE_SETTINGS) |
| 495 |
continue; |
| 496 |
|
| 497 |
if (g_type_is_a (pspec->owner_type, GTK_TYPE_ENTRY_COMPLETION) && |
| 498 |
g_str_equal (pspec->name, "text-column")) |
| 499 |
continue; |
| 500 |
|
| 501 |
if (g_type_is_a (pspec->owner_type, GTK_TYPE_MENU_ITEM) && |
| 502 |
g_str_equal (pspec->name, "accel-path")) |
| 503 |
continue; |
| 504 |
|
| 505 |
if (g_type_is_a (pspec->owner_type, GTK_TYPE_MENU) && |
| 506 |
(g_str_equal (pspec->name, "accel-path") || |
| 507 |
g_str_equal (pspec->name, "active"))) |
| 508 |
continue; |
| 509 |
|
| 510 |
if (g_type_is_a (pspec->owner_type, GTK_TYPE_CHECK_MENU_ITEM) && |
| 511 |
g_str_equal (pspec->name, "active")) |
| 512 |
continue; |
| 513 |
|
| 514 |
if (g_type_is_a (pspec->owner_type, GTK_TYPE_COLOR_CHOOSER) && |
| 515 |
g_str_equal (pspec->name, "show-editor")) |
| 516 |
continue; |
| 517 |
|
| 518 |
if (g_type_is_a (pspec->owner_type, GTK_TYPE_NOTEBOOK) && |
| 519 |
g_str_equal (pspec->name, "page")) |
| 520 |
continue; |
| 521 |
|
| 522 |
if (g_type_is_a (pspec->owner_type, GTK_TYPE_TOGGLE_BUTTON) && |
| 523 |
g_str_equal (pspec->name, "draw-indicator")) |
| 524 |
continue; |
| 525 |
|
| 526 |
/* Not supported in subclass */ |
| 527 |
if (g_str_equal (g_type_name (type), "GtkRecentAction") && |
| 528 |
g_str_equal (pspec->name, "select-multiple")) |
| 529 |
continue; |
| 530 |
|
| 531 |
if (g_str_equal (g_type_name (type), "GtkRecentChooserMenu") && |
| 532 |
g_str_equal (pspec->name, "select-multiple")) |
| 533 |
continue; |
| 534 |
|
| 535 |
/* Really a bug in the way GtkButton and its subclasses interact: |
| 536 |
* setting label etc on a subclass destroys the content, breaking |
| 537 |
* e.g. GtkColorButton pretty badly |
| 538 |
*/ |
| 539 |
if (type == GTK_TYPE_COLOR_BUTTON && pspec->owner_type == GTK_TYPE_BUTTON) |
| 540 |
continue; |
| 541 |
|
| 542 |
/* GdkOffscreenWindow is missing many implementations */ |
| 543 |
if (type == GTK_TYPE_OFFSCREEN_WINDOW) |
| 544 |
continue; |
| 545 |
|
| 546 |
/* Too many special cases involving -set properties */ |
| 547 |
if (g_str_equal (g_type_name (pspec->owner_type), "GtkCellRendererText") || |
| 548 |
g_str_equal (g_type_name (pspec->owner_type), "GtkTextTag")) |
| 549 |
continue; |
| 550 |
|
| 551 |
/* Most things assume a model is set */ |
| 552 |
if (g_str_equal (g_type_name (pspec->owner_type), "GtkComboBox")) |
| 553 |
continue; |
| 554 |
|
| 555 |
/* Deprecated, not getting fixed */ |
| 556 |
if (g_str_equal (g_type_name (pspec->owner_type), "GtkActivatable") || |
| 557 |
g_str_equal (g_type_name (pspec->owner_type), "GtkActionGroup") || |
| 558 |
g_str_equal (g_type_name (pspec->owner_type), "GtkAction")) |
| 559 |
continue; |
| 560 |
|
| 561 |
if (g_type_is_a (pspec->owner_type, GTK_TYPE_CONTAINER) && |
| 562 |
g_str_equal (pspec->name, "resize-mode")) |
| 563 |
continue; |
| 564 |
|
| 565 |
if (g_type_is_a (pspec->owner_type, GTK_TYPE_COLOR_BUTTON) && |
| 566 |
g_str_equal (pspec->name, "alpha")) |
| 567 |
continue; |
| 568 |
|
| 569 |
if (g_type_is_a (pspec->owner_type, GTK_TYPE_CELL_RENDERER_PIXBUF) && |
| 570 |
(g_str_equal (pspec->name, "follow-state") || |
| 571 |
g_str_equal (pspec->name, "stock-id") || |
| 572 |
g_str_equal (pspec->name, "stock-size") || |
| 573 |
g_str_equal (pspec->name, "stock-detail"))) |
| 574 |
continue; |
| 575 |
|
| 576 |
if (g_str_equal (g_type_name (pspec->owner_type), "GtkArrow") || |
| 577 |
g_str_equal (g_type_name (pspec->owner_type), "GtkAlignment") || |
| 578 |
g_str_equal (g_type_name (pspec->owner_type), "GtkMisc")) |
| 579 |
continue; |
| 580 |
|
| 581 |
if (g_type_is_a (pspec->owner_type, GTK_TYPE_MENU) && |
| 582 |
g_str_equal (pspec->name, "tearoff-state")) |
| 583 |
continue; |
| 584 |
|
| 585 |
if (g_type_is_a (pspec->owner_type, GTK_TYPE_WIDGET) && |
| 586 |
g_str_equal (pspec->name, "double-buffered")) |
| 587 |
continue; |
| 588 |
|
| 589 |
if (g_type_is_a (pspec->owner_type, GTK_TYPE_WINDOW) && |
| 590 |
g_str_equal (pspec->name, "has-resize-grip")) |
| 591 |
continue; |
| 592 |
|
| 593 |
/* Can only be set on window widgets */ |
| 594 |
if (pspec->owner_type == GTK_TYPE_WIDGET && |
| 595 |
g_str_equal (pspec->name, "events")) |
| 596 |
continue; |
| 597 |
|
| 598 |
/* Can only be set on unmapped windows */ |
| 599 |
if (pspec->owner_type == GTK_TYPE_WINDOW && |
| 600 |
g_str_equal (pspec->name, "type-hint")) |
| 601 |
continue; |
| 602 |
|
| 603 |
/* Special restrictions on allowed values */ |
| 604 |
if (pspec->owner_type == GTK_TYPE_COMBO_BOX && |
| 605 |
(g_str_equal (pspec->name, "row-span-column") || |
| 606 |
g_str_equal (pspec->name, "column-span-column") || |
| 607 |
g_str_equal (pspec->name, "id-column") || |
| 608 |
g_str_equal (pspec->name, "active-id") || |
| 609 |
g_str_equal (pspec->name, "entry-text-column"))) |
| 610 |
continue; |
| 611 |
|
| 612 |
if (pspec->owner_type == GTK_TYPE_ENTRY_COMPLETION && |
| 613 |
g_str_equal (pspec->name, "text-column")) |
| 614 |
continue; |
| 615 |
|
| 616 |
if (pspec->owner_type == GTK_TYPE_PRINT_OPERATION && |
| 617 |
(g_str_equal (pspec->name, "current-page") || |
| 618 |
g_str_equal (pspec->name, "n-pages"))) |
| 619 |
continue; |
| 620 |
|
| 621 |
if (pspec->owner_type == GTK_TYPE_RANGE && |
| 622 |
g_str_equal (pspec->name, "fill-level")) |
| 623 |
continue; |
| 624 |
|
| 625 |
if (pspec->owner_type == GTK_TYPE_SPIN_BUTTON && |
| 626 |
g_str_equal (pspec->name, "value")) |
| 627 |
continue; |
| 628 |
|
| 629 |
if (pspec->owner_type == GTK_TYPE_STACK && |
| 630 |
g_str_equal (pspec->name, "visible-child-name")) |
| 631 |
continue; |
| 632 |
|
| 633 |
if (pspec->owner_type == GTK_TYPE_POPOVER_MENU && |
| 634 |
g_str_equal (pspec->name, "visible-submenu")) |
| 635 |
continue; |
| 636 |
|
| 637 |
if (pspec->owner_type == GTK_TYPE_TEXT_VIEW && |
| 638 |
g_str_equal (pspec->name, "im-module")) |
| 639 |
continue; |
| 640 |
|
| 641 |
if (pspec->owner_type == GTK_TYPE_TOOLBAR && |
| 642 |
g_str_equal (pspec->name, "icon-size")) |
| 643 |
continue; |
| 644 |
|
| 645 |
if (pspec->owner_type == GTK_TYPE_TREE_SELECTION && |
| 646 |
g_str_equal (pspec->name, "mode")) /* requires a treeview */ |
| 647 |
continue; |
| 648 |
|
| 649 |
if (pspec->owner_type == GTK_TYPE_TREE_VIEW && |
| 650 |
g_str_equal (pspec->name, "headers-clickable")) /* requires columns */ |
| 651 |
continue; |
| 652 |
|
| 653 |
/* This one has a special-purpose default value */ |
| 654 |
if (g_type_is_a (type, GTK_TYPE_DIALOG) && |
| 655 |
g_str_equal (pspec->name, "use-header-bar")) |
| 656 |
continue; |
| 657 |
|
| 658 |
if (g_type_is_a (type, GTK_TYPE_ASSISTANT) && |
| 659 |
g_str_equal (pspec->name, "use-header-bar")) |
| 660 |
continue; |
| 661 |
|
| 662 |
if (type == GTK_TYPE_MODEL_BUTTON && |
| 663 |
pspec->owner_type == GTK_TYPE_BUTTON) |
| 664 |
continue; |
| 665 |
|
| 666 |
if (g_type_is_a (type, GTK_TYPE_SHORTCUTS_SHORTCUT) && |
| 667 |
g_str_equal (pspec->name, "accelerator")) |
| 668 |
continue; |
| 669 |
|
| 670 |
if (g_type_is_a (type, GTK_TYPE_SHORTCUT_LABEL) && |
| 671 |
g_str_equal (pspec->name, "accelerator")) |
| 672 |
continue; |
| 673 |
|
| 674 |
if (g_type_is_a (type, GTK_TYPE_FONT_CHOOSER) && |
| 675 |
g_str_equal (pspec->name, "font")) |
| 676 |
continue; |
| 677 |
|
| 678 |
if (g_type_is_a (type, GTK_TYPE_FONT_BUTTON) && |
| 679 |
g_str_equal (pspec->name, "font-name")) |
| 680 |
continue; |
| 681 |
|
| 682 |
/* these depend on the min-content- properties in a way that breaks our test */ |
| 683 |
if (g_type_is_a (type, GTK_TYPE_SCROLLED_WINDOW) && |
| 684 |
(g_str_equal (pspec->name, "max-content-width") || |
| 685 |
g_str_equal (pspec->name, "max-content-height"))) |
| 686 |
continue; |
| 687 |
|
| 688 |
if (g_test_verbose ()) |
| 689 |
g_print ("Property %s.%s\n", g_type_name (pspec->owner_type), pspec->name); |
| 690 |
|
| 691 |
check_property (instance, pspec); |
| 692 |
} |
| 693 |
g_free (pspecs); |
| 694 |
|
| 695 |
if (g_type_is_a (type, GDK_TYPE_WINDOW)) |
| 696 |
gdk_window_destroy (GDK_WINDOW (instance)); |
| 697 |
else |
| 698 |
g_object_unref (instance); |
| 699 |
|
| 700 |
g_type_class_unref (klass); |
| 701 |
} |
| 702 |
|
| 703 |
int |
| 704 |
main (int argc, char **argv) |
| 705 |
{ |
| 706 |
const GType *otypes; |
| 707 |
guint i; |
| 708 |
gchar *schema_dir; |
| 709 |
gint result; |
| 710 |
|
| 711 |
gtk_test_init (&argc, &argv); |
| 712 |
gtk_test_register_all_types(); |
| 713 |
|
| 714 |
/* g_test_build_filename must be called after gtk_test_init */ |
| 715 |
schema_dir = g_test_build_filename (G_TEST_BUILT, "", NULL); |
| 716 |
if (g_getenv ("GTK_TEST_MESON") == NULL) |
| 717 |
g_setenv ("GSETTINGS_SCHEMA_DIR", schema_dir, TRUE); |
| 718 |
|
| 719 |
otypes = gtk_test_list_all_types (NULL); |
| 720 |
for (i = 0; otypes[i]; i++) |
| 721 |
{ |
| 722 |
gchar *testname; |
| 723 |
|
| 724 |
testname = g_strdup_printf ("/Notification/%s", g_type_name (otypes[i])); |
| 725 |
g_test_add_data_func (testname, &otypes[i], test_type); |
| 726 |
g_free (testname); |
| 727 |
} |
| 728 |
|
| 729 |
result = g_test_run (); |
| 730 |
|
| 731 |
g_free (schema_dir); |
| 732 |
|
| 733 |
return result; |
| 734 |
} |