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

« back to all changes in this revision

Viewing changes to src/test/test-iface-base.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
#ifdef HAVE_CONFIG_H
 
32
#include <config.h>
 
33
#endif
 
34
 
 
35
#include "test-iface-base.h"
 
36
#include "test-iface-iface.h"
 
37
 
 
38
/* private class data
 
39
 */
 
40
struct TestBaseClassPrivate {
 
41
        void *empty;                                            /* so that gcc -pedantic is happy */
 
42
};
 
43
 
 
44
/* private instance data
 
45
 */
 
46
struct TestBasePrivate {
 
47
        gboolean dispose_has_run;
 
48
};
 
49
 
 
50
static GObjectClass *st_parent_class = NULL;
 
51
 
 
52
static GType register_type( void );
 
53
static void  class_init( TestBaseClass *klass );
 
54
static void  iface_iface_init( TestIFaceInterface *iface );
 
55
static void  instance_init( GTypeInstance *instance, gpointer klass );
 
56
static void  instance_dispose( GObject *object );
 
57
static void  instance_finalize( GObject *object );
 
58
 
 
59
static void  iface_fna( TestIFace *object );
 
60
static void  iface_fnb( TestIFace *object );
 
61
 
 
62
GType
 
63
test_base_get_type( void )
 
64
{
 
65
        static GType object_type = 0;
 
66
 
 
67
        if( !object_type ){
 
68
                object_type = register_type();
 
69
        }
 
70
 
 
71
        return( object_type );
 
72
}
 
73
 
 
74
static GType
 
75
register_type( void )
 
76
{
 
77
        static const gchar *thisfn = "test_iface_base_register_type";
 
78
        GType type;
 
79
 
 
80
        static GTypeInfo info = {
 
81
                sizeof( TestBaseClass ),
 
82
                ( GBaseInitFunc ) NULL,
 
83
                ( GBaseFinalizeFunc ) NULL,
 
84
                ( GClassInitFunc ) class_init,
 
85
                NULL,
 
86
                NULL,
 
87
                sizeof( TestBase ),
 
88
                0,
 
89
                ( GInstanceInitFunc ) instance_init
 
90
        };
 
91
 
 
92
        static const GInterfaceInfo iface_iface_info = {
 
93
                ( GInterfaceInitFunc ) iface_iface_init,
 
94
                NULL,
 
95
                NULL
 
96
        };
 
97
 
 
98
        g_debug( "%s", thisfn );
 
99
 
 
100
        type = g_type_register_static( G_TYPE_OBJECT, "TestBase", &info, 0 );
 
101
 
 
102
        g_type_add_interface_static( type, TEST_IFACE_TYPE, &iface_iface_info );
 
103
 
 
104
        return( type );
 
105
}
 
106
 
 
107
static void
 
108
class_init( TestBaseClass *klass )
 
109
{
 
110
        static const gchar *thisfn = "test_iface_base_class_init";
 
111
        GObjectClass *object_class;
 
112
 
 
113
        g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
 
114
 
 
115
        st_parent_class = g_type_class_peek_parent( klass );
 
116
 
 
117
        object_class = G_OBJECT_CLASS( klass );
 
118
        object_class->dispose = instance_dispose;
 
119
        object_class->finalize = instance_finalize;
 
120
 
 
121
        klass->private = g_new0( TestBaseClassPrivate, 1 );
 
122
}
 
123
 
 
124
static void
 
125
iface_iface_init( TestIFaceInterface *iface )
 
126
{
 
127
        static const gchar *thisfn = "test_iface_base_iface_iface_init";
 
128
 
 
129
        g_debug( "%s: iface=%p", thisfn, ( void * ) iface );
 
130
 
 
131
        iface->fna = iface_fna;
 
132
        iface->fnb = iface_fnb;
 
133
}
 
134
 
 
135
static void
 
136
instance_init( GTypeInstance *instance, gpointer klass )
 
137
{
 
138
        static const gchar *thisfn = "test_iface_base_instance_init";
 
139
        TestBase *self;
 
140
 
 
141
        g_debug( "%s: instance=%p, klass=%p", thisfn, ( void * ) instance, ( void * ) klass );
 
142
        g_assert( TEST_IS_BASE( instance ));
 
143
        self = TEST_BASE( instance );
 
144
 
 
145
        self->private = g_new0( TestBasePrivate, 1 );
 
146
 
 
147
        self->private->dispose_has_run = FALSE;
 
148
}
 
149
 
 
150
static void
 
151
instance_dispose( GObject *object )
 
152
{
 
153
        static const gchar *thisfn = "test_iface_base_instance_dispose";
 
154
        TestBase *self;
 
155
 
 
156
        g_debug( "%s: object=%p", thisfn, ( void * ) object );
 
157
        g_assert( TEST_IS_BASE( object ));
 
158
        self = TEST_BASE( object );
 
159
 
 
160
        if( !self->private->dispose_has_run ){
 
161
 
 
162
                self->private->dispose_has_run = TRUE;
 
163
 
 
164
                /* chain up to the parent class */
 
165
                if( G_OBJECT_CLASS( st_parent_class )->dispose ){
 
166
                        G_OBJECT_CLASS( st_parent_class )->dispose( object );
 
167
                }
 
168
        }
 
169
}
 
170
 
 
171
static void
 
172
instance_finalize( GObject *object )
 
173
{
 
174
        TestBase *self;
 
175
 
 
176
        g_assert( TEST_IS_BASE( object ));
 
177
        self = ( TestBase * ) object;
 
178
 
 
179
        g_free( self->private );
 
180
 
 
181
        /* chain call to parent class */
 
182
        if( G_OBJECT_CLASS( st_parent_class )->finalize ){
 
183
                G_OBJECT_CLASS( st_parent_class )->finalize( object );
 
184
        }
 
185
}
 
186
 
 
187
TestBase *
 
188
test_base_new( void )
 
189
{
 
190
        TestBase *object = g_object_new( TEST_BASE_TYPE, NULL );
 
191
 
 
192
        return( object );
 
193
}
 
194
 
 
195
static void
 
196
iface_fna( TestIFace *object )
 
197
{
 
198
        static const gchar *thisfn = "test_iface_base_iface_fna";
 
199
        g_debug( "%s: %s at %p", thisfn, G_OBJECT_TYPE_NAME( object ), ( void * ) object );
 
200
}
 
201
 
 
202
static void
 
203
iface_fnb( TestIFace *object )
 
204
{
 
205
        static const gchar *thisfn = "test_iface_base_iface_fnb";
 
206
        g_debug( "%s: %s at %p", thisfn, G_OBJECT_TYPE_NAME( object ), ( void * ) object );
 
207
}