1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2007-2021 Nicola Fontana <ntd at entidi.it>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser 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.
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 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
24 #if GTK_CHECK_VERSION(2, 18, 0)
27 /* Backward compatible fallback */
29 gtk_widget_get_visible(GtkWidget
*widget
)
31 g_return_val_if_fail(GTK_IS_WIDGET(widget
));
32 return GTK_WIDGET_VISIBLE(widget
);
39 _adg_method_widget_get_window(void)
41 GtkWidget
*window
= gtk_window_new(GTK_WINDOW_TOPLEVEL
);
42 g_assert_null(gtk_widget_get_window(window
));
46 _adg_method_widget_get_realized(void)
48 GtkWidget
*window
= gtk_window_new(GTK_WINDOW_TOPLEVEL
);
49 g_assert_false(gtk_widget_get_realized(window
));
50 gtk_widget_destroy(window
);
54 _adg_method_window_hide_here(void)
56 GtkWidget
*window
= gtk_window_new(GTK_WINDOW_TOPLEVEL
);
58 /* I cannot call gtk_widget_show because there likely be no screens
59 * for realizing window. Just commenting for now.
60 * gtk_widget_show(window);
61 * g_assert_true(gtk_widget_get_visible(window));
64 adg_gtk_window_hide_here(GTK_WINDOW(window
));
65 g_assert_false(gtk_widget_get_visible(window
));
67 gtk_widget_destroy(window
);
71 _adg_method_toggle_button_sensitivize(void)
73 GtkToggleButton
*button
= (GtkToggleButton
*) gtk_toggle_button_new();
74 GtkWidget
*widget
= gtk_toggle_button_new();
76 gtk_toggle_button_set_active(button
, FALSE
);
77 adg_gtk_toggle_button_sensitivize(button
, widget
);
78 g_assert_false(gtk_widget_get_sensitive(widget
));
80 gtk_toggle_button_set_active(button
, TRUE
);
81 adg_gtk_toggle_button_sensitivize(button
, widget
);
82 g_assert_true(gtk_widget_get_sensitive(widget
));
84 g_object_ref_sink(button
);
85 g_object_unref(button
);
87 g_object_ref_sink(widget
);
88 g_object_unref(widget
);
92 _adg_method_use_default_icons(void)
96 list
= gtk_window_get_default_icon_list();
99 /* Check it does not crash passing NULL */
100 adg_gtk_use_default_icons(NULL
);
102 list
= gtk_window_get_default_icon_list();
105 /* Set to the demo directory, where the real icons *must* be presents */
106 adg_gtk_use_default_icons(SRCDIR
"/../../../demo/icons");
108 list
= gtk_window_get_default_icon_list();
109 g_assert_nonnull(list
);
115 main(int argc
, char *argv
[])
117 adg_test_init(&argc
, &argv
);
118 gtk_init_check(&argc
, &argv
);
120 g_test_add_func("/adg/method/widget-get-window", _adg_method_widget_get_window
);
121 g_test_add_func("/adg/method/widget-get-realized", _adg_method_widget_get_realized
);
122 g_test_add_func("/adg/method/window-hide-here", _adg_method_window_hide_here
);
123 g_test_add_func("/adg/method/toggle-button-sensitivize", _adg_method_toggle_button_sensitivize
);
124 g_test_add_func("/adg/method/use-default-icons", _adg_method_use_default_icons
);