2007-12-21 01:01:17 +00:00
|
|
|
/* Gtk+ default value tests
|
|
|
|
* Copyright (C) 2007 Christian Persch
|
|
|
|
* 2007 Johan Dahlin
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2007-12-21 01:01:17 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <gtk/gtk.h>
|
2008-05-29 09:34:53 +00:00
|
|
|
#include <gtk/gtkunixprint.h>
|
2007-12-21 01:01:17 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
check_property (const char *output,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GValue *value)
|
|
|
|
{
|
2011-09-30 15:31:04 +00:00
|
|
|
GValue default_value = G_VALUE_INIT;
|
2007-12-21 01:01:17 +00:00
|
|
|
char *v, *dv, *msg;
|
|
|
|
|
|
|
|
if (g_param_value_defaults (pspec, value))
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_value_init (&default_value, G_PARAM_SPEC_VALUE_TYPE (pspec));
|
|
|
|
g_param_value_set_default (pspec, &default_value);
|
2013-06-15 23:47:19 +00:00
|
|
|
|
2007-12-21 01:01:17 +00:00
|
|
|
v = g_strdup_value_contents (value);
|
|
|
|
dv = g_strdup_value_contents (&default_value);
|
2013-06-15 23:47:19 +00:00
|
|
|
|
2007-12-21 01:01:17 +00:00
|
|
|
msg = g_strdup_printf ("%s %s.%s: %s != %s\n",
|
|
|
|
output,
|
|
|
|
g_type_name (pspec->owner_type),
|
|
|
|
pspec->name,
|
|
|
|
dv, v);
|
|
|
|
g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__,
|
|
|
|
G_STRFUNC, msg);
|
|
|
|
g_free (msg);
|
2013-06-15 23:47:19 +00:00
|
|
|
|
2007-12-21 01:01:17 +00:00
|
|
|
g_free (v);
|
|
|
|
g_free (dv);
|
|
|
|
g_value_unset (&default_value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_type (gconstpointer data)
|
|
|
|
{
|
|
|
|
GObjectClass *klass;
|
|
|
|
GObject *instance;
|
|
|
|
GParamSpec **pspecs;
|
|
|
|
guint n_pspecs, i;
|
|
|
|
GType type;
|
2013-06-15 23:47:19 +00:00
|
|
|
GdkDisplay *display;
|
2008-01-05 18:56:47 +00:00
|
|
|
|
|
|
|
type = * (GType *) data;
|
|
|
|
|
2013-06-15 23:47:19 +00:00
|
|
|
display = gdk_display_get_default ();
|
|
|
|
|
2007-12-21 01:01:17 +00:00
|
|
|
if (!G_TYPE_IS_CLASSED (type))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (G_TYPE_IS_ABSTRACT (type))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!g_type_is_a (type, G_TYPE_OBJECT))
|
|
|
|
return;
|
|
|
|
|
2007-12-28 21:19:11 +00:00
|
|
|
/* These can't be freely constructed/destroyed */
|
2013-07-13 20:54:09 +00:00
|
|
|
if (g_type_is_a (type, GTK_TYPE_APPLICATION) ||
|
2008-01-03 08:51:03 +00:00
|
|
|
g_type_is_a (type, GDK_TYPE_PIXBUF_LOADER) ||
|
2019-03-26 18:05:48 +00:00
|
|
|
g_type_is_a (type, GTK_TYPE_LAYOUT_CHILD) ||
|
2013-07-13 20:54:09 +00:00
|
|
|
#ifdef G_OS_UNIX
|
|
|
|
g_type_is_a (type, GTK_TYPE_PRINT_JOB) ||
|
|
|
|
#endif
|
2013-06-15 23:47:19 +00:00
|
|
|
g_type_is_a (type, gdk_pixbuf_simple_anim_iter_get_type ()) ||
|
|
|
|
g_str_equal (g_type_name (type), "GdkX11DeviceManagerXI2") ||
|
2016-01-03 21:14:43 +00:00
|
|
|
g_str_equal (g_type_name (type), "GdkX11DeviceManagerCore") ||
|
2013-06-15 23:47:19 +00:00
|
|
|
g_str_equal (g_type_name (type), "GdkX11Display") ||
|
2014-10-22 20:20:52 +00:00
|
|
|
g_str_equal (g_type_name (type), "GdkX11Screen") ||
|
|
|
|
g_str_equal (g_type_name (type), "GdkX11GLContext"))
|
2007-12-28 21:19:11 +00:00
|
|
|
return;
|
|
|
|
|
2013-11-09 00:15:33 +00:00
|
|
|
/* This throws a critical when the connection is dropped */
|
|
|
|
if (g_type_is_a (type, GTK_TYPE_APP_CHOOSER_DIALOG))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* These leak their GDBusConnections */
|
|
|
|
if (g_type_is_a (type, GTK_TYPE_FILE_CHOOSER_BUTTON) ||
|
|
|
|
g_type_is_a (type, GTK_TYPE_FILE_CHOOSER_DIALOG) ||
|
|
|
|
g_type_is_a (type, GTK_TYPE_FILE_CHOOSER_WIDGET) ||
|
2018-06-29 19:00:06 +00:00
|
|
|
g_str_equal (g_type_name (type), "GtkPlacesSidebar"))
|
2013-11-09 00:15:33 +00:00
|
|
|
return;
|
2014-01-17 22:03:00 +00:00
|
|
|
|
2020-03-20 15:19:45 +00:00
|
|
|
if (g_type_is_a (type, GTK_TYPE_SHORTCUT_TRIGGER) ||
|
|
|
|
g_type_is_a (type, GTK_TYPE_SHORTCUT_ACTION))
|
2020-03-19 15:57:02 +00:00
|
|
|
return;
|
|
|
|
|
2020-06-06 13:40:04 +00:00
|
|
|
if (g_type_is_a (type, GTK_TYPE_PROPERTY_SELECTION))
|
|
|
|
return;
|
|
|
|
|
2007-12-21 01:01:17 +00:00
|
|
|
klass = g_type_class_ref (type);
|
2013-06-15 23:47:19 +00:00
|
|
|
|
2007-12-28 21:19:11 +00:00
|
|
|
if (g_type_is_a (type, GTK_TYPE_SETTINGS))
|
2018-06-29 19:00:06 +00:00
|
|
|
instance = G_OBJECT (g_object_ref (gtk_settings_get_default ()));
|
2018-03-20 10:40:08 +00:00
|
|
|
else if (g_type_is_a (type, GDK_TYPE_SURFACE))
|
2008-01-03 08:51:03 +00:00
|
|
|
{
|
2019-12-30 06:23:26 +00:00
|
|
|
instance = G_OBJECT (g_object_ref (gdk_surface_new_toplevel (display, 100, 100)));
|
2008-01-03 08:51:03 +00:00
|
|
|
}
|
2019-10-07 04:36:25 +00:00
|
|
|
else if (g_type_is_a (type, GTK_TYPE_FILTER_LIST_MODEL) ||
|
2019-10-07 04:28:28 +00:00
|
|
|
g_type_is_a (type, GTK_TYPE_NO_SELECTION) ||
|
2019-12-09 06:19:38 +00:00
|
|
|
g_type_is_a (type, GTK_TYPE_SINGLE_SELECTION) ||
|
|
|
|
g_type_is_a (type, GTK_TYPE_MULTI_SELECTION))
|
2018-08-31 03:34:18 +00:00
|
|
|
{
|
|
|
|
GListStore *list_store = g_list_store_new (G_TYPE_OBJECT);
|
|
|
|
instance = g_object_new (type,
|
|
|
|
"model", list_store,
|
|
|
|
NULL);
|
|
|
|
g_object_unref (list_store);
|
|
|
|
}
|
2018-06-29 19:00:06 +00:00
|
|
|
else if (g_type_is_a (type, GDK_TYPE_CLIPBOARD) ||
|
|
|
|
g_str_equal (g_type_name (type), "GdkX11Cursor"))
|
2013-06-15 23:47:19 +00:00
|
|
|
instance = g_object_new (type, "display", display, NULL);
|
2007-12-28 21:19:11 +00:00
|
|
|
else
|
|
|
|
instance = g_object_new (type, NULL);
|
|
|
|
|
2007-12-21 01:01:17 +00:00
|
|
|
if (g_type_is_a (type, G_TYPE_INITIALLY_UNOWNED))
|
2007-12-28 21:19:11 +00:00
|
|
|
g_object_ref_sink (instance);
|
2007-12-21 01:01:17 +00:00
|
|
|
|
|
|
|
pspecs = g_object_class_list_properties (klass, &n_pspecs);
|
|
|
|
for (i = 0; i < n_pspecs; ++i)
|
|
|
|
{
|
|
|
|
GParamSpec *pspec = pspecs[i];
|
2011-09-30 15:31:04 +00:00
|
|
|
GValue value = G_VALUE_INIT;
|
2013-06-15 23:47:19 +00:00
|
|
|
|
2007-12-21 01:01:17 +00:00
|
|
|
if (pspec->owner_type != type)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if ((pspec->flags & G_PARAM_READABLE) == 0)
|
|
|
|
continue;
|
|
|
|
|
2019-11-30 00:17:10 +00:00
|
|
|
/* This is set via construct property */
|
|
|
|
if (g_type_is_a (type, GTK_TYPE_BUILDER) &&
|
|
|
|
strcmp (pspec->name, "scope") == 0)
|
|
|
|
continue;
|
|
|
|
|
2018-06-29 19:00:06 +00:00
|
|
|
if (g_type_is_a (type, GDK_TYPE_CLIPBOARD) &&
|
|
|
|
strcmp (pspec->name, "display") == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* These are set in init() */
|
|
|
|
if ((g_type_is_a (type, GDK_TYPE_CLIPBOARD) ||
|
2020-02-29 02:47:17 +00:00
|
|
|
g_type_is_a (type, GDK_TYPE_CONTENT_PROVIDER) ||
|
|
|
|
g_type_is_a (type, GTK_TYPE_DROP_TARGET)) &&
|
2018-06-29 19:00:06 +00:00
|
|
|
strcmp (pspec->name, "formats") == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (g_type_is_a (type, GDK_TYPE_CONTENT_PROVIDER) &&
|
|
|
|
strcmp (pspec->name, "storable-formats") == 0)
|
|
|
|
continue;
|
|
|
|
|
2014-01-17 22:03:00 +00:00
|
|
|
/* This one has a special-purpose default value */
|
|
|
|
if (g_type_is_a (type, GTK_TYPE_DIALOG) &&
|
|
|
|
(strcmp (pspec->name, "use-header-bar") == 0))
|
|
|
|
continue;
|
|
|
|
|
2014-02-02 22:57:07 +00:00
|
|
|
if (g_type_is_a (type, GTK_TYPE_ASSISTANT) &&
|
2019-02-13 23:14:48 +00:00
|
|
|
(strcmp (pspec->name, "use-header-bar") == 0 ||
|
|
|
|
strcmp (pspec->name, "pages") == 0)) /* pages always gets a non-NULL value */
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (g_type_is_a (type, GTK_TYPE_STACK) &&
|
|
|
|
(strcmp (pspec->name, "pages") == 0)) /* pages always gets a non-NULL value */
|
2014-02-02 22:57:07 +00:00
|
|
|
continue;
|
|
|
|
|
2019-02-21 05:29:09 +00:00
|
|
|
if (g_type_is_a (type, GTK_TYPE_NOTEBOOK) &&
|
|
|
|
(strcmp (pspec->name, "pages") == 0)) /* pages always gets a non-NULL value */
|
|
|
|
continue;
|
|
|
|
|
2020-05-03 16:04:23 +00:00
|
|
|
if (g_type_is_a (type, GTK_TYPE_COMBO_BOX) &&
|
|
|
|
(strcmp (pspec->name, "child") == 0))
|
|
|
|
continue;
|
|
|
|
|
2014-01-25 19:20:51 +00:00
|
|
|
if (g_type_is_a (type, GTK_TYPE_POPOVER) &&
|
|
|
|
(strcmp (pspec->name, "pointing-to") == 0))
|
|
|
|
continue;
|
|
|
|
|
2008-01-03 08:51:03 +00:00
|
|
|
if (g_type_is_a (type, GDK_TYPE_DISPLAY_MANAGER) &&
|
|
|
|
(strcmp (pspec->name, "default-display") == 0))
|
|
|
|
continue;
|
|
|
|
|
2016-05-02 16:40:51 +00:00
|
|
|
if (g_type_is_a (type, GDK_TYPE_MONITOR) &&
|
|
|
|
(strcmp (pspec->name, "geometry") == 0 ||
|
|
|
|
strcmp (pspec->name, "workarea") == 0))
|
|
|
|
continue;
|
|
|
|
|
2008-01-02 17:26:17 +00:00
|
|
|
if (g_type_is_a (type, GTK_TYPE_ABOUT_DIALOG) &&
|
|
|
|
(strcmp (pspec->name, "program-name") == 0))
|
|
|
|
continue;
|
2013-06-15 23:47:19 +00:00
|
|
|
|
2007-12-28 21:19:11 +00:00
|
|
|
/* These are set to the current date */
|
|
|
|
if (g_type_is_a (type, GTK_TYPE_CALENDAR) &&
|
|
|
|
(strcmp (pspec->name, "year") == 0 ||
|
|
|
|
strcmp (pspec->name, "month") == 0 ||
|
|
|
|
strcmp (pspec->name, "day") == 0))
|
|
|
|
continue;
|
|
|
|
|
2013-06-15 23:47:19 +00:00
|
|
|
if (g_type_is_a (type, GTK_TYPE_CELL_AREA_CONTEXT) &&
|
|
|
|
(strcmp (pspec->name, "minimum-width") == 0 ||
|
|
|
|
strcmp (pspec->name, "minimum-height") == 0 ||
|
|
|
|
strcmp (pspec->name, "natural-width") == 0 ||
|
|
|
|
strcmp (pspec->name, "natural-height") == 0))
|
|
|
|
continue;
|
|
|
|
|
2007-12-28 21:19:11 +00:00
|
|
|
if (g_type_is_a (type, GTK_TYPE_CELL_RENDERER_TEXT) &&
|
|
|
|
(strcmp (pspec->name, "background-gdk") == 0 ||
|
|
|
|
strcmp (pspec->name, "foreground-gdk") == 0 ||
|
2013-06-15 23:47:19 +00:00
|
|
|
strcmp (pspec->name, "background-rgba") == 0 ||
|
|
|
|
strcmp (pspec->name, "foreground-rgba") == 0 ||
|
2007-12-28 21:19:11 +00:00
|
|
|
strcmp (pspec->name, "font") == 0 ||
|
|
|
|
strcmp (pspec->name, "font-desc") == 0))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (g_type_is_a (type, GTK_TYPE_CELL_VIEW) &&
|
|
|
|
(strcmp (pspec->name, "background-gdk") == 0 ||
|
2013-06-15 23:47:19 +00:00
|
|
|
strcmp (pspec->name, "foreground-gdk") == 0 ||
|
|
|
|
strcmp (pspec->name, "foreground-rgba") == 0 ||
|
|
|
|
strcmp (pspec->name, "background-rgba") == 0 ||
|
|
|
|
strcmp (pspec->name, "cell-area") == 0 ||
|
|
|
|
strcmp (pspec->name, "cell-area-context") == 0))
|
2007-12-28 21:19:11 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if (g_type_is_a (type, GTK_TYPE_COLOR_BUTTON) &&
|
2013-06-15 23:47:19 +00:00
|
|
|
(strcmp (pspec->name, "color") == 0 ||
|
|
|
|
strcmp (pspec->name, "rgba") == 0))
|
2007-12-28 21:19:11 +00:00
|
|
|
continue;
|
|
|
|
|
2019-10-30 17:03:23 +00:00
|
|
|
if (g_type_is_a (type, GTK_TYPE_COLUMN_VIEW) &&
|
2019-12-04 13:13:13 +00:00
|
|
|
(strcmp (pspec->name, "columns") == 0 ||
|
|
|
|
strcmp (pspec->name, "sorter") == 0))
|
2019-10-30 17:03:23 +00:00
|
|
|
continue;
|
|
|
|
|
2013-06-15 23:47:19 +00:00
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
|
|
|
|
|
|
if (g_type_is_a (type, GTK_TYPE_COMBO_BOX) &&
|
|
|
|
(strcmp (pspec->name, "cell-area") == 0 ||
|
|
|
|
strcmp (pspec->name, "cell-area-context") == 0))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
G_GNUC_END_IGNORE_DEPRECATIONS
|
|
|
|
|
2019-02-17 20:50:59 +00:00
|
|
|
/* Default invisible char is determined at runtime,
|
|
|
|
* and buffer gets created on-demand
|
|
|
|
*/
|
2008-11-12 15:48:51 +00:00
|
|
|
if (g_type_is_a (type, GTK_TYPE_ENTRY) &&
|
2009-09-30 11:09:22 +00:00
|
|
|
(strcmp (pspec->name, "invisible-char") == 0 ||
|
|
|
|
strcmp (pspec->name, "buffer") == 0))
|
2008-11-12 15:48:51 +00:00
|
|
|
continue;
|
|
|
|
|
2019-02-17 20:50:59 +00:00
|
|
|
if (g_type_is_a (type, GTK_TYPE_TEXT) &&
|
|
|
|
(strcmp (pspec->name, "invisible-char") == 0 ||
|
|
|
|
strcmp (pspec->name, "buffer") == 0))
|
|
|
|
continue;
|
|
|
|
|
2013-06-15 23:47:19 +00:00
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
|
|
|
|
|
|
if (g_type_is_a (type, GTK_TYPE_ENTRY_COMPLETION) &&
|
|
|
|
(strcmp (pspec->name, "cell-area") == 0 ||
|
|
|
|
strcmp (pspec->name, "cell-area-context") == 0))
|
|
|
|
continue;
|
|
|
|
|
2018-06-29 19:00:06 +00:00
|
|
|
G_GNUC_END_IGNORE_DEPRECATIONS
|
|
|
|
|
2019-10-07 04:36:25 +00:00
|
|
|
if ((g_type_is_a (type, GTK_TYPE_FILTER_LIST_MODEL) ||
|
2019-10-07 04:28:28 +00:00
|
|
|
g_type_is_a (type, GTK_TYPE_NO_SELECTION) ||
|
2019-12-09 06:19:38 +00:00
|
|
|
g_type_is_a (type, GTK_TYPE_SINGLE_SELECTION) ||
|
|
|
|
g_type_is_a (type, GTK_TYPE_MULTI_SELECTION)) &&
|
2018-08-31 03:34:18 +00:00
|
|
|
strcmp (pspec->name, "model") == 0)
|
|
|
|
continue;
|
|
|
|
|
2018-06-29 19:00:06 +00:00
|
|
|
/* This is set in init() */
|
|
|
|
if (g_type_is_a (type, GTK_TYPE_FONT_CHOOSER_WIDGET) &&
|
|
|
|
strcmp (pspec->name, "tweak-action") == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
|
|
|
2013-06-15 23:47:19 +00:00
|
|
|
if (g_type_is_a (type, GTK_TYPE_ICON_VIEW) &&
|
|
|
|
(strcmp (pspec->name, "cell-area") == 0 ||
|
|
|
|
strcmp (pspec->name, "cell-area-context") == 0))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
G_GNUC_END_IGNORE_DEPRECATIONS
|
|
|
|
|
2007-12-28 21:19:11 +00:00
|
|
|
if (g_type_is_a (type, GTK_TYPE_MESSAGE_DIALOG) &&
|
2010-06-22 20:26:18 +00:00
|
|
|
(strcmp (pspec->name, "image") == 0 ||
|
|
|
|
strcmp (pspec->name, "message-area") == 0))
|
2007-12-28 21:19:11 +00:00
|
|
|
continue;
|
|
|
|
|
2010-05-25 23:27:42 +00:00
|
|
|
if (g_type_is_a (type, GTK_TYPE_PANED) &&
|
|
|
|
strcmp (pspec->name, "max-position") == 0)
|
|
|
|
continue;
|
|
|
|
|
2007-12-28 21:19:11 +00:00
|
|
|
if (g_type_is_a (type, GTK_TYPE_PRINT_OPERATION) &&
|
|
|
|
strcmp (pspec->name, "job-name") == 0)
|
|
|
|
continue;
|
|
|
|
|
2013-07-13 20:54:09 +00:00
|
|
|
#ifdef G_OS_UNIX
|
2007-12-28 21:19:11 +00:00
|
|
|
if (g_type_is_a (type, GTK_TYPE_PRINT_UNIX_DIALOG) &&
|
|
|
|
(strcmp (pspec->name, "page-setup") == 0 ||
|
|
|
|
strcmp (pspec->name, "print-settings") == 0))
|
|
|
|
continue;
|
2013-07-13 20:54:09 +00:00
|
|
|
#endif
|
2007-12-28 21:19:11 +00:00
|
|
|
|
|
|
|
if (g_type_is_a (type, GTK_TYPE_PROGRESS_BAR) &&
|
|
|
|
strcmp (pspec->name, "adjustment") == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* filename value depends on $HOME */
|
|
|
|
if (g_type_is_a (type, GTK_TYPE_RECENT_MANAGER) &&
|
2008-01-02 17:26:17 +00:00
|
|
|
(strcmp (pspec->name, "filename") == 0 ||
|
|
|
|
strcmp (pspec->name, "size") == 0))
|
2007-12-28 21:19:11 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if (g_type_is_a (type, GTK_TYPE_SCALE_BUTTON) &&
|
|
|
|
strcmp (pspec->name, "adjustment") == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (g_type_is_a (type, GTK_TYPE_SCROLLED_WINDOW) &&
|
|
|
|
(strcmp (pspec->name, "hadjustment") == 0 ||
|
|
|
|
strcmp (pspec->name, "vadjustment") == 0))
|
|
|
|
continue;
|
|
|
|
|
2013-06-15 23:47:19 +00:00
|
|
|
if (g_type_is_a (type, GTK_TYPE_SETTINGS))
|
2007-12-28 21:19:11 +00:00
|
|
|
continue;
|
|
|
|
|
2020-03-15 13:49:50 +00:00
|
|
|
if (g_type_is_a (type, GTK_TYPE_SHORTCUT) &&
|
2018-08-18 05:32:11 +00:00
|
|
|
(strcmp (pspec->name, "action") == 0 ||
|
|
|
|
strcmp (pspec->name, "trigger") == 0))
|
2020-03-15 13:49:50 +00:00
|
|
|
continue;
|
|
|
|
|
2007-12-28 21:19:11 +00:00
|
|
|
if (g_type_is_a (type, GTK_TYPE_SPIN_BUTTON) &&
|
|
|
|
(strcmp (pspec->name, "adjustment") == 0))
|
|
|
|
continue;
|
|
|
|
|
2013-06-15 23:47:19 +00:00
|
|
|
if (g_type_is_a (type, GTK_TYPE_STYLE_CONTEXT) &&
|
2017-10-31 18:00:56 +00:00
|
|
|
strcmp (pspec->name, "display") == 0)
|
2013-06-15 23:47:19 +00:00
|
|
|
continue;
|
|
|
|
|
2007-12-28 21:19:11 +00:00
|
|
|
if (g_type_is_a (type, GTK_TYPE_TEXT_BUFFER) &&
|
|
|
|
(strcmp (pspec->name, "tag-table") == 0 ||
|
|
|
|
strcmp (pspec->name, "copy-target-list") == 0 ||
|
|
|
|
strcmp (pspec->name, "paste-target-list") == 0))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* language depends on the current locale */
|
|
|
|
if (g_type_is_a (type, GTK_TYPE_TEXT_TAG) &&
|
|
|
|
(strcmp (pspec->name, "background-gdk") == 0 ||
|
|
|
|
strcmp (pspec->name, "foreground-gdk") == 0 ||
|
|
|
|
strcmp (pspec->name, "language") == 0 ||
|
|
|
|
strcmp (pspec->name, "font") == 0 ||
|
|
|
|
strcmp (pspec->name, "font-desc") == 0))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (g_type_is_a (type, GTK_TYPE_TEXT_VIEW) &&
|
|
|
|
strcmp (pspec->name, "buffer") == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (g_type_is_a (type, GTK_TYPE_TREE_VIEW) &&
|
|
|
|
(strcmp (pspec->name, "hadjustment") == 0 ||
|
|
|
|
strcmp (pspec->name, "vadjustment") == 0))
|
|
|
|
continue;
|
|
|
|
|
2013-06-15 23:47:19 +00:00
|
|
|
if (g_type_is_a (type, GTK_TYPE_TREE_VIEW_COLUMN) &&
|
|
|
|
(strcmp (pspec->name, "cell-area") == 0 ||
|
|
|
|
strcmp (pspec->name, "cell-area-context") == 0))
|
|
|
|
continue;
|
|
|
|
|
2007-12-28 21:19:11 +00:00
|
|
|
if (g_type_is_a (type, GTK_TYPE_VIEWPORT) &&
|
|
|
|
(strcmp (pspec->name, "hadjustment") == 0 ||
|
|
|
|
strcmp (pspec->name, "vadjustment") == 0))
|
|
|
|
continue;
|
|
|
|
|
2008-01-03 08:51:03 +00:00
|
|
|
if (g_type_is_a (type, GTK_TYPE_WIDGET) &&
|
|
|
|
(strcmp (pspec->name, "name") == 0 ||
|
2017-10-31 18:00:56 +00:00
|
|
|
strcmp (pspec->name, "display") == 0 ||
|
2008-01-03 08:51:03 +00:00
|
|
|
strcmp (pspec->name, "style") == 0))
|
|
|
|
continue;
|
|
|
|
|
2010-10-12 17:08:34 +00:00
|
|
|
/* resize-grip-visible is determined at runtime */
|
|
|
|
if (g_type_is_a (type, GTK_TYPE_WINDOW) &&
|
2013-06-15 23:47:19 +00:00
|
|
|
strcmp (pspec->name, "resize-grip-visible") == 0)
|
2010-10-12 17:08:34 +00:00
|
|
|
continue;
|
|
|
|
|
2013-11-15 14:32:19 +00:00
|
|
|
/* show-desktop depends on desktop environment */
|
2018-06-29 19:00:06 +00:00
|
|
|
if (g_str_equal (g_type_name (type), "GtkPlacesSidebar") &&
|
2013-11-15 14:32:19 +00:00
|
|
|
strcmp (pspec->name, "show-desktop") == 0)
|
|
|
|
continue;
|
|
|
|
|
2017-07-13 14:28:49 +00:00
|
|
|
/* GtkRange constructs an adjustment on its own if NULL is set and
|
|
|
|
* the property is a CONSTRUCT one, so the returned value is never NULL. */
|
|
|
|
if (g_type_is_a (type, GTK_TYPE_RANGE) &&
|
|
|
|
strcmp (pspec->name, "adjustment") == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* ... and GtkScrollbar wraps that property. */
|
|
|
|
if (g_type_is_a (type, GTK_TYPE_SCROLLBAR) &&
|
|
|
|
strcmp (pspec->name, "adjustment") == 0)
|
|
|
|
continue;
|
|
|
|
|
2019-12-09 01:22:06 +00:00
|
|
|
if (g_type_is_a (type, GTK_TYPE_DROP_DOWN) &&
|
|
|
|
strcmp (pspec->name, "factory") == 0)
|
|
|
|
continue;
|
|
|
|
|
2020-06-10 21:03:13 +00:00
|
|
|
if (g_type_is_a (type, GTK_TYPE_BOOKMARK_LIST) &&
|
|
|
|
(strcmp (pspec->name, "filename") == 0 ||
|
|
|
|
strcmp (pspec->name, "loading") == 0))
|
|
|
|
continue;
|
|
|
|
|
2020-02-18 05:56:37 +00:00
|
|
|
/* All the icontheme properties depend on the environment */
|
|
|
|
if (g_type_is_a (type, GTK_TYPE_ICON_THEME))
|
|
|
|
continue;
|
|
|
|
|
2008-07-04 21:20:25 +00:00
|
|
|
if (g_test_verbose ())
|
2018-06-29 19:00:06 +00:00
|
|
|
{
|
|
|
|
g_print ("Property %s:%s\n",
|
|
|
|
g_type_name (pspec->owner_type),
|
|
|
|
pspec->name);
|
|
|
|
}
|
|
|
|
|
2007-12-21 01:01:17 +00:00
|
|
|
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
|
|
|
|
g_object_get_property (instance, pspec->name, &value);
|
|
|
|
check_property ("Property", pspec, &value);
|
|
|
|
g_value_unset (&value);
|
|
|
|
}
|
2008-01-05 18:56:47 +00:00
|
|
|
g_free (pspecs);
|
2007-12-21 01:01:17 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
if (g_type_is_a (type, GDK_TYPE_SURFACE))
|
|
|
|
gdk_surface_destroy (GDK_SURFACE (instance));
|
2008-01-03 08:51:03 +00:00
|
|
|
else
|
|
|
|
g_object_unref (instance);
|
2013-06-15 23:47:19 +00:00
|
|
|
|
2007-12-21 01:01:17 +00:00
|
|
|
g_type_class_unref (klass);
|
|
|
|
}
|
|
|
|
|
2020-02-06 03:24:39 +00:00
|
|
|
static gboolean
|
|
|
|
dbind_warning_handler (const char *log_domain,
|
|
|
|
GLogLevelFlags log_level,
|
|
|
|
const char *message,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
if (strcmp (log_domain, "dbind") == 0 &&
|
|
|
|
log_level == (G_LOG_LEVEL_WARNING|G_LOG_FLAG_FATAL))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-12-21 01:01:17 +00:00
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
2008-01-02 17:26:17 +00:00
|
|
|
const GType *otypes;
|
2007-12-21 01:01:17 +00:00
|
|
|
guint i;
|
2013-11-09 00:15:33 +00:00
|
|
|
GTestDBus *bus;
|
2015-11-20 00:56:19 +00:00
|
|
|
GMainLoop *loop;
|
2013-11-09 00:15:33 +00:00
|
|
|
gint result;
|
2020-02-04 13:13:33 +00:00
|
|
|
const char *display, *x_r_d;
|
2013-11-09 00:15:33 +00:00
|
|
|
|
2020-05-28 08:00:03 +00:00
|
|
|
/* These must be set before gtk_test_init */
|
2013-11-09 00:15:33 +00:00
|
|
|
g_setenv ("GIO_USE_VFS", "local", TRUE);
|
|
|
|
g_setenv ("GSETTINGS_BACKEND", "memory", TRUE);
|
2014-07-03 19:22:39 +00:00
|
|
|
g_setenv ("G_ENABLE_DIAGNOSTIC", "0", TRUE);
|
2007-12-21 01:01:17 +00:00
|
|
|
|
2020-02-04 13:13:33 +00:00
|
|
|
/* g_test_dbus_up() helpfully clears these, so we have to re-set it */
|
|
|
|
display = g_getenv ("DISPLAY");
|
|
|
|
x_r_d = g_getenv ("XDG_RUNTIME_DIR");
|
2013-06-15 23:47:19 +00:00
|
|
|
|
2013-11-09 00:15:33 +00:00
|
|
|
/* Create one test bus for all tests, as we have a lot of very small
|
|
|
|
* and quick tests.
|
|
|
|
*/
|
|
|
|
bus = g_test_dbus_new (G_TEST_DBUS_NONE);
|
|
|
|
g_test_dbus_up (bus);
|
|
|
|
|
2020-02-04 13:13:33 +00:00
|
|
|
if (display)
|
|
|
|
g_setenv ("DISPLAY", display, TRUE);
|
|
|
|
if (x_r_d)
|
|
|
|
g_setenv ("XDG_RUNTIME_DIR", x_r_d, TRUE);
|
|
|
|
|
2020-02-06 03:24:39 +00:00
|
|
|
g_test_log_set_fatal_handler (dbind_warning_handler, NULL);
|
|
|
|
|
2020-02-04 13:13:33 +00:00
|
|
|
gtk_test_init (&argc, &argv);
|
|
|
|
gtk_test_register_all_types();
|
|
|
|
|
2008-01-02 17:26:17 +00:00
|
|
|
otypes = gtk_test_list_all_types (NULL);
|
|
|
|
for (i = 0; otypes[i]; i++)
|
2007-12-21 01:01:17 +00:00
|
|
|
{
|
|
|
|
gchar *testname;
|
2013-06-15 23:47:19 +00:00
|
|
|
|
2015-11-20 02:55:29 +00:00
|
|
|
if (otypes[i] == GTK_TYPE_FILE_CHOOSER_NATIVE)
|
|
|
|
continue;
|
|
|
|
|
2007-12-21 01:01:17 +00:00
|
|
|
testname = g_strdup_printf ("/Default Values/%s",
|
2008-01-02 17:26:17 +00:00
|
|
|
g_type_name (otypes[i]));
|
2007-12-21 01:01:17 +00:00
|
|
|
g_test_add_data_func (testname,
|
2008-01-05 18:56:47 +00:00
|
|
|
&otypes[i],
|
2007-12-21 01:01:17 +00:00
|
|
|
test_type);
|
|
|
|
g_free (testname);
|
|
|
|
}
|
2013-06-15 23:47:19 +00:00
|
|
|
|
2013-11-09 00:15:33 +00:00
|
|
|
result = g_test_run();
|
|
|
|
|
2015-11-20 00:56:19 +00:00
|
|
|
/* Work around the annoying issue that g_test_dbus_down is giving
|
|
|
|
* us an "Error while sending AddMatch" that comes out of an idle
|
|
|
|
*/
|
|
|
|
loop = g_main_loop_new (NULL, FALSE);
|
|
|
|
g_timeout_add (1000, (GSourceFunc)g_main_loop_quit, loop);
|
|
|
|
g_main_loop_run (loop);
|
|
|
|
g_main_loop_unref (loop);
|
|
|
|
|
2013-11-09 00:15:33 +00:00
|
|
|
g_test_dbus_down (bus);
|
|
|
|
g_object_unref (bus);
|
|
|
|
|
|
|
|
return result;
|
2007-12-21 01:01:17 +00:00
|
|
|
}
|