4
* Copyright (C) 2001 Havoc Pennington
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License as
8
* published by the Free Software Foundation; either version 2 of the
9
* License, or (at your option) any later version.
11
* This program is distributed in the hope that it will be useful, but
12
* WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, see <http://www.gnu.org/licenses/>.
23
#include <sys/types.h>
28
static void set_up_the_evil (void);
29
static void set_up_icon_windows (void);
34
g_print ("wm-tester [--evil] [--icon-windows]\n");
39
main (int argc, char **argv)
43
gboolean do_icon_windows;
45
gtk_init (&argc, &argv);
48
do_icon_windows = FALSE;
53
const char *arg = argv[i];
55
if (strcmp (arg, "--help") == 0 ||
56
strcmp (arg, "-h") == 0 ||
57
strcmp (arg, "-?") == 0)
59
else if (strcmp (arg, "--evil") == 0)
61
else if (strcmp (arg, "--icon-windows") == 0)
62
do_icon_windows = TRUE;
69
/* Be sure some option was provided */
70
if (! (do_evil || do_icon_windows))
77
set_up_icon_windows ();
84
static GSList *evil_windows = NULL;
87
evil_timeout (gpointer data)
95
len = g_slist_length (evil_windows);
108
/* Create some windows */
109
n_windows = g_random_int_range (0, create_count);
112
while (i < n_windows)
119
w = gtk_window_new (GTK_WINDOW_TOPLEVEL);
121
gtk_window_move (GTK_WINDOW (w),
122
g_random_int_range (0,
123
gdk_screen_width ()),
124
g_random_int_range (0,
125
gdk_screen_height ()));
129
/* set transient for random window (may create all kinds of weird cycles) */
132
t = g_random_int_range (- (len / 3), len);
135
parent = g_slist_nth_data (evil_windows, t);
138
gtk_window_set_transient_for (GTK_WINDOW (w), GTK_WINDOW (parent));
143
c = gtk_button_new_with_label ("Evil Transient!");
145
c = gtk_button_new_with_label ("Evil Window!");
146
gtk_container_add (GTK_CONTAINER (w), c);
148
gtk_widget_show_all (w);
150
evil_windows = g_slist_prepend (evil_windows, w);
155
/* Destroy some windows */
156
if (len > destroy_count)
158
n_windows = g_random_int_range (0, destroy_count);
160
while (i < n_windows)
164
w = g_slist_nth_data (evil_windows,
165
g_random_int_range (0, len));
169
evil_windows = g_slist_remove (evil_windows, w);
170
gtk_widget_destroy (w);
181
set_up_the_evil (void)
183
g_timeout_add (400, evil_timeout, NULL);
187
set_up_icon_windows (void)
192
/* Create some windows */
196
while (i < n_windows)
204
w = gtk_window_new (GTK_WINDOW_TOPLEVEL);
205
c = gtk_button_new_with_label ("Icon window");
206
gtk_container_add (GTK_CONTAINER (w), c);
210
gtk_icon_size_lookup (GTK_ICON_SIZE_LARGE_TOOLBAR, NULL, &size);
211
pix = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), "gtk-save", size, 0, NULL);
213
icons = g_list_append (icons, pix);
217
gtk_icon_size_lookup (GTK_ICON_SIZE_DIALOG, NULL, &size);
218
pix = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), "gtk-save", size, 0, NULL);
219
icons = g_list_append (icons, pix);
224
gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, NULL, &size);
225
pix = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), "gtk-save", size, 0, NULL);
226
icons = g_list_append (icons, pix);
229
gtk_window_set_icon_list (GTK_WINDOW (w), icons);
231
g_list_foreach (icons, (GFunc) g_object_unref, NULL);
234
gtk_widget_show_all (w);