~ubuntu-branches/ubuntu/maverick/nautilus-actions/maverick

« back to all changes in this revision

Viewing changes to src/test/test-virtuals-without-test.c

  • Committer: Bazaar Package Importer
  • Author(s): Christine Spang
  • Date: 2009-10-25 14:04:13 UTC
  • mfrom: (1.1.7 upstream) (3.1.5 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091025140413-okqdth1kvcx8ko3o
Tags: 2.29.1-1
* New upstream version.
  - implements full API as defined for use by Nautilus menu
    extensions : this let the user define items which will be
    available when there is no selection, and will apply to
    current folder, either in the 'File' menu or in the
    toolbar ;
  - the ability for the user to define a full hierarchy of
    actions with menus, submenus, and so on ;
  - drag and drop ;
  - full cut/copy/paste clipboard support.
  - Gnome bugs fixed:
    - #325528 reported by Frederic Ruaudel
              (bloated  contextual menu)
    - #325587 reported by Frederic Ruaudel
              (drag & drop support)
    - #326699 reported by Frederic Ruaudel
              (action items do not remain in user defined order)
    - #353353 reported by Frederic Ruaudel
              (check if command exist and if not warn user)
    - #588482 reported by Sean
            (ordering in actions list)
    - #326699 reported by Frederic Ruaudel
            (action items do not remain in user defined order)
    - #353353 reported by Frederic Ruaudel
              (check if command exist and if not warn user)
    - #588482 reported by Sean
              (ordering in actions list)
    - #590400 reported by Pierre Wieser
              (have some sort of warnings in the ui)
    - #599520 reported by António Lima
              (do not mark authors names and emails for translating)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Nautilus Actions
 
3
 * A Nautilus extension which offers configurable context menu actions.
 
4
 *
 
5
 * Copyright (C) 2005 The GNOME Foundation
 
6
 * Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
 
7
 * Copyright (C) 2009 Pierre Wieser and others (see AUTHORS)
 
8
 *
 
9
 * This Program is free software; you can redistribute it and/or
 
10
 * modify it under the terms of the GNU General Public License as
 
11
 * published by the Free Software Foundation; either version 2 of
 
12
 * the License, or (at your option) any later version.
 
13
 *
 
14
 * This Program is distributed in the hope that it will be useful,
 
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
 * GNU General Public License for more details.
 
18
 *
 
19
 * You should have received a copy of the GNU General Public
 
20
 * License along with this Library; see the file COPYING.  If not,
 
21
 * write to the Free Software Foundation, Inc., 59 Temple Place,
 
22
 * Suite 330, Boston, MA 02111-1307, USA.
 
23
 *
 
24
 * Authors:
 
25
 *   Frederic Ruaudel <grumz@grumz.net>
 
26
 *   Rodrigo Moya <rodrigo@gnome-db.org>
 
27
 *   Pierre Wieser <pwieser@trychlos.org>
 
28
 *   ... and many others (see AUTHORS)
 
29
 */
 
30
 
 
31
/* We want test here what is the exact behavior of virtual functions in
 
32
 * derived classes, whether or not base class has implemented them or
 
33
 * not.
 
34
 *
 
35
 * We define three classes, and some virtual functions :
 
36
 * class A: fn1, fn2, fn3
 
37
 * class AB: implements fn1, fn2
 
38
 * class ABC: implements fn1, fn3
 
39
 *
 
40
 * Public entry points are defined in class A: we check that calling
 
41
 * public entry points with an object of each class actually calls the
 
42
 * relevant virtual function.
 
43
 *
 
44
 * Also we check that calling the parent class is possible even if the
 
45
 * parent class has not explicitely defined the virtual function.
 
46
 *
 
47
 * Same as test-virtuals.c, without the test for existance of function.
 
48
 */
 
49
 
 
50
#include <glib-object.h>
 
51
#include <glib.h>
 
52
 
 
53
#define PWI_FIRST_TYPE                  ( pwi_first_get_type())
 
54
#define PWI_FIRST( object )             ( G_TYPE_CHECK_INSTANCE_CAST( object, PWI_FIRST_TYPE, PwiFirst ))
 
55
#define PWI_FIRST_CLASS( klass )        ( G_TYPE_CHECK_CLASS_CAST( klass, PWI_FIRST_TYPE, PwiFirstClass ))
 
56
#define PWI_IS_FIRST( object )          ( G_TYPE_CHECK_INSTANCE_TYPE( object, PWI_FIRST_TYPE ))
 
57
#define PWI_IS_FIRST_CLASS( klass )     ( G_TYPE_CHECK_CLASS_TYPE(( klass ), PWI_FIRST_TYPE ))
 
58
#define PWI_FIRST_GET_CLASS( object )   ( G_TYPE_INSTANCE_GET_CLASS(( object ), PWI_FIRST_TYPE, PwiFirstClass ))
 
59
 
 
60
typedef struct PwiFirstPrivate PwiFirstPrivate;
 
61
 
 
62
typedef struct {
 
63
        GObject          parent;
 
64
        PwiFirstPrivate *private;
 
65
}
 
66
        PwiFirst;
 
67
 
 
68
typedef struct PwiFirstClassPrivate PwiFirstClassPrivate;
 
69
 
 
70
typedef struct {
 
71
        GObjectClass          parent;
 
72
        PwiFirstClassPrivate *private;
 
73
 
 
74
        /* virtual functions */
 
75
        void ( *fn_a )( PwiFirst *instance );
 
76
        void ( *fn_b )( PwiFirst *instance );
 
77
        void ( *fn_c )( PwiFirst *instance );
 
78
}
 
79
        PwiFirstClass;
 
80
 
 
81
GType pwi_first_get_type( void );
 
82
 
 
83
void pwi_first_fn_a( PwiFirst *instance );
 
84
void pwi_first_fn_b( PwiFirst *instance );
 
85
void pwi_first_fn_c( PwiFirst *instance );
 
86
 
 
87
#define PWI_FIRST_SECOND_TYPE                   ( pwi_first_second_get_type())
 
88
#define PWI_FIRST_SECOND( object )              ( G_TYPE_CHECK_INSTANCE_CAST( object, PWI_FIRST_SECOND_TYPE, PwiFirstSecond ))
 
89
#define PWI_FIRST_SECOND_CLASS( klass )         ( G_TYPE_CHECK_CLASS_CAST( klass, PWI_FIRST_SECOND_TYPE, PwiFirstSecondClass ))
 
90
#define PWI_IS_FIRST_SECOND( object )           ( G_TYPE_CHECK_INSTANCE_TYPE( object, PWI_FIRST_SECOND_TYPE ))
 
91
#define PWI_IS_FIRST_SECOND_CLASS( klass )      ( G_TYPE_CHECK_CLASS_TYPE(( klass ), PWI_FIRST_SECOND_TYPE ))
 
92
#define PWI_FIRST_SECOND_GET_CLASS( object )    ( G_TYPE_INSTANCE_GET_CLASS(( object ), PWI_FIRST_SECOND_TYPE, PwiFirstSecondClass ))
 
93
 
 
94
typedef struct PwiFirstSecondPrivate PwiFirstSecondPrivate;
 
95
 
 
96
typedef struct {
 
97
        PwiFirst               parent;
 
98
        PwiFirstSecondPrivate *private;
 
99
}
 
100
        PwiFirstSecond;
 
101
 
 
102
typedef struct PwiFirstSecondClassPrivate PwiFirstSecondClassPrivate;
 
103
 
 
104
typedef struct {
 
105
        PwiFirstClass               parent;
 
106
        PwiFirstSecondClassPrivate *private;
 
107
}
 
108
        PwiFirstSecondClass;
 
109
 
 
110
GType pwi_first_second_get_type( void );
 
111
 
 
112
#define PWI_FIRST_SECOND_THREE_TYPE                     ( pwi_first_second_three_get_type())
 
113
#define PWI_FIRST_SECOND_THREE( object )                ( G_TYPE_CHECK_INSTANCE_CAST( object, PWI_FIRST_SECOND_THREE_TYPE, PwiFirstSecondThree ))
 
114
#define PWI_FIRST_SECOND_THREE_CLASS( klass )           ( G_TYPE_CHECK_CLASS_CAST( klass, PWI_FIRST_SECOND_THREE_TYPE, PwiFirstSecondThreeClass ))
 
115
#define PWI_IS_FIRST_SECOND_THREE( object )             ( G_TYPE_CHECK_INSTANCE_TYPE( object, PWI_FIRST_SECOND_THREE_TYPE ))
 
116
#define PWI_IS_FIRST_SECOND_THREE_CLASS( klass )        ( G_TYPE_CHECK_CLASS_TYPE(( klass ), PWI_FIRST_SECOND_THREE_TYPE ))
 
117
#define PWI_FIRST_SECOND_THREE_GET_CLASS( object )      ( G_TYPE_INSTANCE_GET_CLASS(( object ), PWI_FIRST_SECOND_THREE_TYPE, PwiFirstSecondThreeClass ))
 
118
 
 
119
typedef struct PwiFirstSecondThreePrivate PwiFirstSecondThreePrivate;
 
120
 
 
121
typedef struct {
 
122
        PwiFirstSecond              parent;
 
123
        PwiFirstSecondThreePrivate *private;
 
124
}
 
125
        PwiFirstSecondThree;
 
126
 
 
127
typedef struct PwiFirstSecondThreeClassPrivate PwiFirstSecondThreeClassPrivate;
 
128
 
 
129
typedef struct {
 
130
        PwiFirstSecondClass              parent;
 
131
        PwiFirstSecondThreeClassPrivate *private;
 
132
}
 
133
        PwiFirstSecondThreeClass;
 
134
 
 
135
GType pwi_first_second_three_get_type( void );
 
136
 
 
137
struct PwiFirstClassPrivate {
 
138
        void *empty;                                            /* so that gcc -pedantic is happy */
 
139
};
 
140
 
 
141
struct PwiFirstPrivate {
 
142
        void *empty;                                            /* so that gcc -pedantic is happy */
 
143
};
 
144
 
 
145
static GObjectClass *st_first_parent_class = NULL;
 
146
 
 
147
static GType first_register_type( void );
 
148
static void  first_class_init( PwiFirstClass *klass );
 
149
static void  first_instance_init( GTypeInstance *instance, gpointer klass );
 
150
static void  first_instance_dispose( GObject *application );
 
151
static void  first_instance_finalize( GObject *application );
 
152
 
 
153
static void  do_first_fn_a( PwiFirst *instance );
 
154
static void  do_first_fn_b( PwiFirst *instance );
 
155
static void  do_first_fn_c( PwiFirst *instance );
 
156
 
 
157
GType
 
158
pwi_first_get_type( void )
 
159
{
 
160
        static GType type = 0;
 
161
 
 
162
        if( !type ){
 
163
                type = first_register_type();
 
164
        }
 
165
 
 
166
        return( type );
 
167
}
 
168
 
 
169
static GType
 
170
first_register_type( void )
 
171
{
 
172
        static const gchar *thisfn = "first_register_type";
 
173
 
 
174
        static GTypeInfo info = {
 
175
                sizeof( PwiFirstClass ),
 
176
                ( GBaseInitFunc ) NULL,
 
177
                ( GBaseFinalizeFunc ) NULL,
 
178
                ( GClassInitFunc ) first_class_init,
 
179
                NULL,
 
180
                NULL,
 
181
                sizeof( PwiFirst ),
 
182
                0,
 
183
                ( GInstanceInitFunc ) first_instance_init
 
184
        };
 
185
 
 
186
        g_debug( "%s", thisfn );
 
187
        return( g_type_register_static( G_TYPE_OBJECT, "PwiFirst", &info, 0 ));
 
188
}
 
189
 
 
190
static void
 
191
first_class_init( PwiFirstClass *klass )
 
192
{
 
193
        static const gchar *thisfn = "first_class_init";
 
194
        GObjectClass *object_class;
 
195
 
 
196
        g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
 
197
 
 
198
        st_first_parent_class = g_type_class_peek_parent( klass );
 
199
 
 
200
        object_class = G_OBJECT_CLASS( klass );
 
201
        object_class->dispose = first_instance_dispose;
 
202
        object_class->finalize = first_instance_finalize;
 
203
 
 
204
        klass->private = g_new0( PwiFirstClassPrivate, 1 );
 
205
 
 
206
        klass->fn_a = do_first_fn_a;
 
207
        klass->fn_b = do_first_fn_b;
 
208
        klass->fn_c = do_first_fn_c;
 
209
}
 
210
 
 
211
static void
 
212
first_instance_init( GTypeInstance *instance, gpointer klass )
 
213
{
 
214
        static const gchar *thisfn = "first_instance_init";
 
215
        PwiFirst *self;
 
216
 
 
217
        g_debug( "%s: instance=%p, klass=%p", thisfn, ( void * ) instance, ( void * ) klass );
 
218
        g_assert( PWI_IS_FIRST( instance ));
 
219
        self = PWI_FIRST( instance );
 
220
 
 
221
        self->private = g_new0( PwiFirstPrivate, 1 );
 
222
}
 
223
 
 
224
static void
 
225
first_instance_dispose( GObject *instance )
 
226
{
 
227
        static const gchar *thisfn = "first_instance_dispose";
 
228
        PwiFirst *self;
 
229
 
 
230
        g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
 
231
        g_assert( PWI_IS_FIRST( instance ));
 
232
        self = PWI_FIRST( instance );
 
233
 
 
234
        /* chain up to the parent class */
 
235
        G_OBJECT_CLASS( st_first_parent_class )->dispose( instance );
 
236
}
 
237
 
 
238
static void
 
239
first_instance_finalize( GObject *instance )
 
240
{
 
241
        static const gchar *thisfn = "first_instance_finalize";
 
242
        PwiFirst *self;
 
243
 
 
244
        g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
 
245
        g_assert( PWI_IS_FIRST( instance ));
 
246
        self = PWI_FIRST( instance );
 
247
 
 
248
        g_free( self->private );
 
249
 
 
250
        /* chain call to parent class */
 
251
        G_OBJECT_CLASS( st_first_parent_class )->finalize( instance );
 
252
}
 
253
 
 
254
void
 
255
pwi_first_fn_a( PwiFirst *instance )
 
256
{
 
257
        g_debug( "pwi_first_fn_a: instance=%p", ( void * ) instance );
 
258
        g_assert( PWI_IS_FIRST( instance ));
 
259
 
 
260
        PWI_FIRST_GET_CLASS( instance )->fn_a( instance );
 
261
}
 
262
 
 
263
static void
 
264
do_first_fn_a( PwiFirst *instance )
 
265
{
 
266
        g_debug( "do_first_fn_a: instance=%p", ( void * ) instance );
 
267
}
 
268
 
 
269
void
 
270
pwi_first_fn_b( PwiFirst *instance )
 
271
{
 
272
        g_debug( "pwi_first_fn_b: instance=%p", ( void * ) instance );
 
273
        g_assert( PWI_IS_FIRST( instance ));
 
274
 
 
275
        PWI_FIRST_GET_CLASS( instance )->fn_b( instance );
 
276
}
 
277
 
 
278
static void
 
279
do_first_fn_b( PwiFirst *instance )
 
280
{
 
281
        g_debug( "do_first_fn_b: instance=%p", ( void * ) instance );
 
282
}
 
283
 
 
284
void
 
285
pwi_first_fn_c( PwiFirst *instance )
 
286
{
 
287
        g_debug( "pwi_first_fn_c: instance=%p", ( void * ) instance );
 
288
        g_assert( PWI_IS_FIRST( instance ));
 
289
 
 
290
        PWI_FIRST_GET_CLASS( instance )->fn_c( instance );
 
291
}
 
292
 
 
293
static void
 
294
do_first_fn_c( PwiFirst *instance )
 
295
{
 
296
        g_debug( "do_first_fn_c: instance=%p", ( void * ) instance );
 
297
}
 
298
 
 
299
struct PwiFirstSecondClassPrivate {
 
300
        void *empty;                                            /* so that gcc -pedantic is happy */
 
301
};
 
302
 
 
303
struct PwiFirstSecondPrivate {
 
304
        void *empty;                                            /* so that gcc -pedantic is happy */
 
305
};
 
306
 
 
307
static PwiFirstClass *st_first_second_parent_class = NULL;
 
308
 
 
309
static GType first_second_register_type( void );
 
310
static void  first_second_class_init( PwiFirstSecondClass *klass );
 
311
static void  first_second_instance_init( GTypeInstance *instance, gpointer klass );
 
312
static void  first_second_instance_dispose( GObject *application );
 
313
static void  first_second_instance_finalize( GObject *application );
 
314
 
 
315
static void  do_first_second_fn_a( PwiFirst *instance );
 
316
static void  do_first_second_fn_b( PwiFirst *instance );
 
317
 
 
318
GType
 
319
pwi_first_second_get_type( void )
 
320
{
 
321
        static GType type = 0;
 
322
 
 
323
        if( !type ){
 
324
                type = first_second_register_type();
 
325
        }
 
326
 
 
327
        return( type );
 
328
}
 
329
 
 
330
static GType
 
331
first_second_register_type( void )
 
332
{
 
333
        static const gchar *thisfn = "first_second_register_type";
 
334
 
 
335
        static GTypeInfo info = {
 
336
                sizeof( PwiFirstSecondClass ),
 
337
                ( GBaseInitFunc ) NULL,
 
338
                ( GBaseFinalizeFunc ) NULL,
 
339
                ( GClassInitFunc ) first_second_class_init,
 
340
                NULL,
 
341
                NULL,
 
342
                sizeof( PwiFirstSecond ),
 
343
                0,
 
344
                ( GInstanceInitFunc ) first_second_instance_init
 
345
        };
 
346
 
 
347
        g_debug( "%s", thisfn );
 
348
        return( g_type_register_static( PWI_FIRST_TYPE, "PwiFirstSecond", &info, 0 ));
 
349
}
 
350
 
 
351
static void
 
352
first_second_class_init( PwiFirstSecondClass *klass )
 
353
{
 
354
        static const gchar *thisfn = "first_second_class_init";
 
355
        GObjectClass *object_class;
 
356
        PwiFirstClass *first_class;
 
357
 
 
358
        g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
 
359
 
 
360
        st_first_second_parent_class = g_type_class_peek_parent( klass );
 
361
 
 
362
        object_class = G_OBJECT_CLASS( klass );
 
363
        object_class->dispose = first_second_instance_dispose;
 
364
        object_class->finalize = first_second_instance_finalize;
 
365
 
 
366
        klass->private = g_new0( PwiFirstSecondClassPrivate, 1 );
 
367
 
 
368
        first_class = PWI_FIRST_CLASS( klass );
 
369
        first_class->fn_a = do_first_second_fn_a;
 
370
        first_class->fn_b = do_first_second_fn_b;
 
371
        first_class->fn_c = NULL;
 
372
}
 
373
 
 
374
static void
 
375
first_second_instance_init( GTypeInstance *instance, gpointer klass )
 
376
{
 
377
        static const gchar *thisfn = "first_second_instance_init";
 
378
        PwiFirstSecond *self;
 
379
 
 
380
        g_debug( "%s: instance=%p, klass=%p", thisfn, ( void * ) instance, ( void * ) klass );
 
381
        g_assert( PWI_IS_FIRST_SECOND( instance ));
 
382
        self = PWI_FIRST_SECOND( instance );
 
383
 
 
384
        self->private = g_new0( PwiFirstSecondPrivate, 1 );
 
385
}
 
386
 
 
387
static void
 
388
first_second_instance_dispose( GObject *instance )
 
389
{
 
390
        static const gchar *thisfn = "first_second_instance_dispose";
 
391
        PwiFirstSecond *self;
 
392
 
 
393
        g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
 
394
        g_assert( PWI_IS_FIRST_SECOND( instance ));
 
395
        self = PWI_FIRST_SECOND( instance );
 
396
 
 
397
        /* chain up to the parent class */
 
398
        G_OBJECT_CLASS( st_first_second_parent_class )->dispose( instance );
 
399
}
 
400
 
 
401
static void
 
402
first_second_instance_finalize( GObject *instance )
 
403
{
 
404
        static const gchar *thisfn = "first_second_instance_finalize";
 
405
        PwiFirstSecond *self;
 
406
 
 
407
        g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
 
408
        g_assert( PWI_IS_FIRST_SECOND( instance ));
 
409
        self = PWI_FIRST_SECOND( instance );
 
410
 
 
411
        g_free( self->private );
 
412
 
 
413
        /* chain call to parent class */
 
414
        G_OBJECT_CLASS( st_first_second_parent_class )->finalize( instance );
 
415
}
 
416
 
 
417
static void
 
418
do_first_second_fn_a( PwiFirst *instance )
 
419
{
 
420
        g_debug( "do_first_second_fn_a: instance=%p", ( void * ) instance );
 
421
        PWI_FIRST_CLASS( st_first_second_parent_class )->fn_a( instance );
 
422
}
 
423
 
 
424
static void
 
425
do_first_second_fn_b( PwiFirst *instance )
 
426
{
 
427
        g_debug( "do_first_second_fn_b: instance=%p", ( void * ) instance );
 
428
        PWI_FIRST_CLASS( st_first_second_parent_class )->fn_b( instance );
 
429
}
 
430
 
 
431
struct PwiFirstSecondThreeClassPrivate {
 
432
        void *empty;                                            /* so that gcc -pedantic is happy */
 
433
};
 
434
 
 
435
struct PwiFirstSecondThreePrivate {
 
436
        void *empty;                                            /* so that gcc -pedantic is happy */
 
437
};
 
438
 
 
439
static PwiFirstSecondClass *st_first_second_three_parent_class = NULL;
 
440
 
 
441
static GType first_second_three_register_type( void );
 
442
static void  first_second_three_class_init( PwiFirstSecondThreeClass *klass );
 
443
static void  first_second_three_instance_init( GTypeInstance *instance, gpointer klass );
 
444
static void  first_second_three_instance_dispose( GObject *application );
 
445
static void  first_second_three_instance_finalize( GObject *application );
 
446
 
 
447
static void  do_first_second_three_fn_a( PwiFirst *instance );
 
448
static void  do_first_second_three_fn_c( PwiFirst *instance );
 
449
 
 
450
GType
 
451
pwi_first_second_three_get_type( void )
 
452
{
 
453
        static GType type = 0;
 
454
 
 
455
        if( !type ){
 
456
                type = first_second_three_register_type();
 
457
        }
 
458
 
 
459
        return( type );
 
460
}
 
461
 
 
462
static GType
 
463
first_second_three_register_type( void )
 
464
{
 
465
        static const gchar *thisfn = "first_second_three_register_type";
 
466
 
 
467
        static GTypeInfo info = {
 
468
                sizeof( PwiFirstSecondThreeClass ),
 
469
                ( GBaseInitFunc ) NULL,
 
470
                ( GBaseFinalizeFunc ) NULL,
 
471
                ( GClassInitFunc ) first_second_three_class_init,
 
472
                NULL,
 
473
                NULL,
 
474
                sizeof( PwiFirstSecondThree ),
 
475
                0,
 
476
                ( GInstanceInitFunc ) first_second_three_instance_init
 
477
        };
 
478
 
 
479
        g_debug( "%s", thisfn );
 
480
        return( g_type_register_static( PWI_FIRST_SECOND_TYPE, "PwiFirstSecondThree", &info, 0 ));
 
481
}
 
482
 
 
483
static void
 
484
first_second_three_class_init( PwiFirstSecondThreeClass *klass )
 
485
{
 
486
        static const gchar *thisfn = "first_second_three_class_init";
 
487
        GObjectClass *object_class;
 
488
        PwiFirstClass *first_class;
 
489
 
 
490
        g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
 
491
 
 
492
        st_first_second_three_parent_class = g_type_class_peek_parent( klass );
 
493
 
 
494
        object_class = G_OBJECT_CLASS( klass );
 
495
        object_class->dispose = first_second_three_instance_dispose;
 
496
        object_class->finalize = first_second_three_instance_finalize;
 
497
 
 
498
        klass->private = g_new0( PwiFirstSecondThreeClassPrivate, 1 );
 
499
 
 
500
        first_class = PWI_FIRST_CLASS( klass );
 
501
        first_class->fn_a = do_first_second_three_fn_a;
 
502
        first_class->fn_b = NULL;
 
503
        first_class->fn_c = do_first_second_three_fn_c;
 
504
}
 
505
 
 
506
static void
 
507
first_second_three_instance_init( GTypeInstance *instance, gpointer klass )
 
508
{
 
509
        static const gchar *thisfn = "first_second_three_instance_init";
 
510
        PwiFirstSecondThree *self;
 
511
 
 
512
        g_debug( "%s: instance=%p, klass=%p", thisfn, ( void * ) instance, ( void * ) klass );
 
513
        g_assert( PWI_IS_FIRST_SECOND_THREE( instance ));
 
514
        self = PWI_FIRST_SECOND_THREE( instance );
 
515
 
 
516
        self->private = g_new0( PwiFirstSecondThreePrivate, 1 );
 
517
}
 
518
 
 
519
static void
 
520
first_second_three_instance_dispose( GObject *instance )
 
521
{
 
522
        static const gchar *thisfn = "first_second_three_instance_dispose";
 
523
        PwiFirstSecondThree *self;
 
524
 
 
525
        g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
 
526
        g_assert( PWI_IS_FIRST_SECOND_THREE( instance ));
 
527
        self = PWI_FIRST_SECOND_THREE( instance );
 
528
 
 
529
        /* chain up to the parent class */
 
530
        G_OBJECT_CLASS( st_first_second_three_parent_class )->dispose( instance );
 
531
}
 
532
 
 
533
static void
 
534
first_second_three_instance_finalize( GObject *instance )
 
535
{
 
536
        static const gchar *thisfn = "first_second_three_instance_finalize";
 
537
        PwiFirstSecondThree *self;
 
538
 
 
539
        g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
 
540
        g_assert( PWI_IS_FIRST_SECOND_THREE( instance ));
 
541
        self = PWI_FIRST_SECOND_THREE( instance );
 
542
 
 
543
        g_free( self->private );
 
544
 
 
545
        /* chain call to parent class */
 
546
        G_OBJECT_CLASS( st_first_second_three_parent_class )->finalize( instance );
 
547
}
 
548
 
 
549
static void
 
550
do_first_second_three_fn_a( PwiFirst *instance )
 
551
{
 
552
        g_debug( "do_first_second_three_fn_a: instance=%p", ( void * ) instance );
 
553
        PWI_FIRST_CLASS( st_first_second_three_parent_class )->fn_a( instance );
 
554
}
 
555
 
 
556
static void
 
557
do_first_second_three_fn_c( PwiFirst *instance )
 
558
{
 
559
        g_debug( "do_first_second_three_fn_c: instance=%p", ( void * ) instance );
 
560
        PWI_FIRST_CLASS( st_first_second_three_parent_class )->fn_c( instance );
 
561
}
 
562
 
 
563
int
 
564
main( int argc, char **argv )
 
565
{
 
566
        PwiFirst *a;
 
567
        PwiFirstSecond *b;
 
568
        PwiFirstSecondThree *c;
 
569
 
 
570
        g_type_init();
 
571
 
 
572
        a = g_object_new( PWI_FIRST_TYPE, NULL );
 
573
        b = g_object_new( PWI_FIRST_SECOND_TYPE, NULL );
 
574
        c = g_object_new( PWI_FIRST_SECOND_THREE_TYPE, NULL );
 
575
 
 
576
        g_debug( "expected pwi_first_fn_a, do_first_fn_a" );
 
577
        pwi_first_fn_a( PWI_FIRST( a ));
 
578
        g_debug( "expected pwi_first_fn_a, do_first_second_fn_a, do_first_fn_a" );
 
579
        pwi_first_fn_a( PWI_FIRST( b ));
 
580
        g_debug( "expected pwi_first_fn_a, do_first_second_three_fn_a, do_first_second_fn_a, do_first_fn_a" );
 
581
        pwi_first_fn_a( PWI_FIRST( c ));
 
582
 
 
583
        g_debug( "%s", "" );
 
584
 
 
585
        g_debug( "expected pwi_first_fn_b, do_first_fn_b" );
 
586
        pwi_first_fn_b( PWI_FIRST( a ));
 
587
        g_debug( "expected pwi_first_fn_b, do_first_second_fn_b, do_first_fn_b" );
 
588
        pwi_first_fn_b( PWI_FIRST( b ));
 
589
        g_debug( "expected pwi_first_fn_b, do_first_second_fn_b, do_first_fn_b" );
 
590
        /* NOT OK
 
591
         * segmentation fault after pwi_first_fn_b */
 
592
        pwi_first_fn_b( PWI_FIRST( c ));
 
593
 
 
594
        g_debug( "%s", "" );
 
595
 
 
596
        g_debug( "expected pwi_first_fn_c, do_first_fn_c" );
 
597
        pwi_first_fn_c( PWI_FIRST( a ));
 
598
        g_debug( "expected pwi_first_fn_c, do_first_fn_c" );
 
599
        pwi_first_fn_c( PWI_FIRST( b ));
 
600
        g_debug( "expected pwi_first_fn_c, do_first_second_three_fn_c, do_first_fn_c" );
 
601
        pwi_first_fn_c( PWI_FIRST( c ));
 
602
 
 
603
        return( 0 );
 
604
}