~ubuntu-branches/ubuntu/oneiric/dbus-glib/oneiric-updates

« back to all changes in this revision

Viewing changes to test/interfaces/test-interfaces.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2006-11-01 10:51:01 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061101105101-2dbr969h8k05n1b2
Tags: 0.72-0ubuntu1
* Sync with pkg-utopia SVN. This is infact 0.72-1 which sits in NEW
* New upstream release
* debian/control:
  + Require libdbus-1-dev (>= 0.94) and libglib2.0-dev (>= 2.6)
  + Add build dependency on gtk-doc-tools (>= 1.4)
* debian/control,
  debian/libdbus-glib-1-doc.install:
  + Add libdbus-glib-1-doc package

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifdef HAVE_CONFIG_H
 
2
#       include <config.h>
 
3
#endif
 
4
#include "test-interfaces.h"
 
5
 
 
6
static gboolean
 
7
test_hello_dbus_say_hello (TestHello  *hello,
 
8
                           gchar     **message,
 
9
                           GError    **error)
 
10
{
 
11
        *message = test_hello_say_hello (hello);
 
12
        return TRUE;
 
13
}
 
14
 
 
15
static gboolean
 
16
test_goodbye_dbus_say_goodbye (TestGoodbye  *goodbye,
 
17
                               gchar       **message,
 
18
                               GError      **error)
 
19
{
 
20
        *message = test_goodbye_say_goodbye (goodbye);
 
21
        return TRUE;
 
22
}
 
23
 
 
24
#include "test-hello-glue.h"
 
25
#include "test-goodbye-glue.h"
 
26
 
 
27
enum {
 
28
        GREETINGS,
 
29
        LAST_SIGNAL
 
30
};
 
31
 
 
32
static guint signals[LAST_SIGNAL];
 
33
 
 
34
static void
 
35
test_hello_class_init (gpointer g_iface)
 
36
{
 
37
        GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
 
38
 
 
39
        signals[GREETINGS] =
 
40
                g_signal_new ("greetings",
 
41
                              iface_type,
 
42
                              G_SIGNAL_RUN_LAST,
 
43
                              G_STRUCT_OFFSET (TestHelloIface, greetings),
 
44
                              NULL, NULL,
 
45
                              g_cclosure_marshal_VOID__VOID,
 
46
                              G_TYPE_NONE,
 
47
                              0);
 
48
 
 
49
        dbus_g_object_type_install_info (iface_type,
 
50
                                         &dbus_glib_test_hello_object_info);
 
51
}
 
52
 
 
53
GType
 
54
test_hello_get_type (void)
 
55
{
 
56
        static GType the_type = 0;
 
57
        
 
58
        if (G_UNLIKELY (the_type == 0)) {
 
59
                static const GTypeInfo info = {
 
60
                        sizeof (TestHelloIface),
 
61
                        NULL, NULL,
 
62
                        (GClassInitFunc) test_hello_class_init,
 
63
                        NULL, NULL, 0, 0, NULL
 
64
                };
 
65
                
 
66
                the_type = g_type_register_static (G_TYPE_INTERFACE,
 
67
                                                   g_intern_static_string ("TestHello"),
 
68
                                                   &info, 0);
 
69
                g_type_interface_add_prerequisite (the_type, G_TYPE_OBJECT);
 
70
        }
 
71
        return the_type;
 
72
}
 
73
 
 
74
gchar *
 
75
test_hello_say_hello (TestHello *hello)
 
76
{
 
77
        g_return_val_if_fail (TEST_IS_HELLO (hello), NULL);
 
78
 
 
79
        return (* TEST_HELLO_GET_IFACE (hello)->say_hello) (hello);
 
80
}
 
81
 
 
82
void
 
83
test_hello_greetings (TestHello *hello)
 
84
{
 
85
        g_return_if_fail (TEST_IS_HELLO (hello));
 
86
 
 
87
        g_signal_emit (hello, signals[GREETINGS], 0);
 
88
}
 
89
 
 
90
static void
 
91
test_goodbye_class_init (gpointer g_iface)
 
92
{
 
93
        GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
 
94
 
 
95
        dbus_g_object_type_install_info (iface_type,
 
96
                                         &dbus_glib_test_goodbye_object_info);
 
97
}
 
98
 
 
99
GType
 
100
test_goodbye_get_type (void)
 
101
{
 
102
        static GType the_type = 0;
 
103
        
 
104
        if (G_UNLIKELY (the_type == 0)) {
 
105
                static const GTypeInfo info = {
 
106
                        sizeof (TestGoodbyeIface),
 
107
                        NULL, NULL,
 
108
                        (GClassInitFunc) test_goodbye_class_init,
 
109
                        NULL, NULL, 0, 0, NULL
 
110
                };
 
111
                
 
112
                the_type = g_type_register_static (G_TYPE_INTERFACE,
 
113
                                                   g_intern_static_string ("TestGoodbye"),
 
114
                                                   &info, 0);
 
115
                g_type_interface_add_prerequisite (the_type, G_TYPE_OBJECT);
 
116
        }
 
117
        return the_type;
 
118
}
 
119
 
 
120
gchar *
 
121
test_goodbye_say_goodbye (TestGoodbye *goodbye)
 
122
{
 
123
        g_return_val_if_fail (TEST_IS_GOODBYE (goodbye), NULL);
 
124
 
 
125
        return (* TEST_GOODBYE_GET_IFACE (goodbye)->say_goodbye) (goodbye);
 
126
}