tests: don't test for specific device labels
[pygobject.git] / tests / test-thread.c
blob438cb970a80f178cd8815844a01b62ed1c6686dc
1 #include "test-thread.h"
3 enum
5 /* methods */
6 SIGNAL_EMIT_SIGNAL,
7 SIGNAL_FROM_THREAD,
8 LAST_SIGNAL
9 };
11 static guint test_thread_signals[LAST_SIGNAL] = { 0 };
13 typedef enum {
14 TEST_THREAD_A,
15 TEST_THREAD_B
16 } ThreadEnumType;
18 static GType
19 test_thread_enum_get_type (void)
21 static GType enum_type = 0;
22 static GEnumValue enum_values[] = {
23 {TEST_THREAD_A, "TEST_THREAD_A", "a as in apple"},
24 {0, NULL, NULL},
27 if (!enum_type) {
28 enum_type =
29 g_enum_register_static ("TestThreadEnum", enum_values);
31 return enum_type;
34 G_DEFINE_TYPE(TestThread, test_thread, G_TYPE_OBJECT);
36 static void
37 other_thread_cb (TestThread *self)
39 g_signal_emit_by_name (self, "from-thread", 0, NULL);
40 g_thread_exit (0);
43 static void
44 test_thread_emit_signal (TestThread *self)
46 self->thread = g_thread_new ("t", (GThreadFunc)other_thread_cb, self);
49 static void test_thread_init (TestThread *self) {}
50 static void test_thread_class_init (TestThreadClass *klass)
52 test_thread_signals[SIGNAL_EMIT_SIGNAL] =
53 g_signal_new ("emit-signal", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
54 G_STRUCT_OFFSET (TestThreadClass, emit_signal),
55 NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
56 test_thread_signals[SIGNAL_FROM_THREAD] =
57 g_signal_new ("from-thread", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
58 G_STRUCT_OFFSET (TestThreadClass, from_thread),
59 NULL, NULL, g_cclosure_marshal_VOID__BOXED, G_TYPE_NONE, 1,
60 test_thread_enum_get_type ());
62 klass->emit_signal = test_thread_emit_signal;