425
|
1 |
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ |
|
2 |
/* |
|
3 |
* Copyright (C) 2007 Imendio AB |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU Lesser General Public License as |
|
7 |
* published by the Free Software Foundation; either version 2 of the |
|
8 |
* License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 |
* Lesser General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU Lesser General Public |
|
16 |
* License along with this program; if not, write to the |
|
17 |
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|
18 |
* Boston, MA 02111-1307, USA. |
|
19 |
*/ |
|
20 |
|
|
21 |
#include <config.h> |
|
22 |
|
|
23 |
#include "lm-marshal.h" |
|
24 |
#include "lm-simple-io.h" |
|
25 |
|
|
26 |
#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), LM_TYPE_DUMMY, LmSimpleIOPriv)) |
|
27 |
|
|
28 |
typedef struct LmSimpleIOPriv LmSimpleIOPriv; |
|
29 |
struct LmSimpleIOPriv { |
|
30 |
gint my_prop; |
|
31 |
}; |
|
32 |
|
|
33 |
static void simple_io_finalize (GObject *object); |
|
34 |
static void simple_io_get_property (GObject *object, |
|
35 |
guint param_id, |
|
36 |
GValue *value, |
|
37 |
GParamSpec *pspec); |
|
38 |
static void simple_io_set_property (GObject *object, |
|
39 |
guint param_id, |
|
40 |
const GValue *value, |
|
41 |
GParamSpec *pspec); |
|
42 |
|
|
43 |
G_DEFINE_TYPE (LmSimpleIO, lm_simple_io, G_TYPE_OBJECT) |
|
44 |
|
|
45 |
enum { |
|
46 |
PROP_0, |
|
47 |
PROP_MY_PROP |
|
48 |
}; |
|
49 |
|
|
50 |
enum { |
|
51 |
SIGNAL_NAME, |
|
52 |
LAST_SIGNAL |
|
53 |
}; |
|
54 |
|
|
55 |
static guint signals[LAST_SIGNAL] = { 0 }; |
|
56 |
|
|
57 |
static void |
|
58 |
lm_simple_io_class_init (LmSimpleIOClass *class) |
|
59 |
{ |
|
60 |
GObjectClass *object_class = G_OBJECT_CLASS (class); |
|
61 |
|
|
62 |
object_class->finalize = simple_io_finalize; |
|
63 |
object_class->get_property = simple_io_get_property; |
|
64 |
object_class->set_property = simple_io_set_property; |
|
65 |
|
|
66 |
g_object_class_install_property (object_class, |
|
67 |
PROP_MY_PROP, |
|
68 |
g_param_spec_string ("my-prop", |
|
69 |
"My Prop", |
|
70 |
"My Property", |
|
71 |
NULL, |
|
72 |
G_PARAM_READWRITE)); |
|
73 |
|
|
74 |
signals[SIGNAL_NAME] = |
|
75 |
g_signal_new ("signal-name", |
|
76 |
G_OBJECT_CLASS_TYPE (object_class), |
|
77 |
G_SIGNAL_RUN_LAST, |
|
78 |
0, |
|
79 |
NULL, NULL, |
|
80 |
lm_marshal_VOID__INT, |
|
81 |
G_TYPE_NONE, |
|
82 |
1, G_TYPE_INT); |
|
83 |
|
|
84 |
g_type_class_add_private (object_class, sizeof (LmSimpleIOPriv)); |
|
85 |
} |
|
86 |
|
|
87 |
static void |
|
88 |
lm_simple_io_init (LmSimpleIO *simple_io) |
|
89 |
{ |
|
90 |
LmSimpleIOPriv *priv; |
|
91 |
|
|
92 |
priv = GET_PRIV (simple_io); |
|
93 |
|
|
94 |
} |
|
95 |
|
|
96 |
static void |
|
97 |
simple_io_finalize (GObject *object) |
|
98 |
{ |
|
99 |
LmSimpleIOPriv *priv; |
|
100 |
|
|
101 |
priv = GET_PRIV (object); |
|
102 |
|
|
103 |
(G_OBJECT_CLASS (lm_simple_io_parent_class)->finalize) (object); |
|
104 |
} |
|
105 |
|
|
106 |
static void |
|
107 |
simple_io_get_property (GObject *object, |
|
108 |
guint param_id, |
|
109 |
GValue *value, |
|
110 |
GParamSpec *pspec) |
|
111 |
{ |
|
112 |
LmSimpleIOPriv *priv; |
|
113 |
|
|
114 |
priv = GET_PRIV (object); |
|
115 |
|
|
116 |
switch (param_id) { |
|
117 |
case PROP_MY_PROP: |
|
118 |
g_value_set_int (value, priv->my_prop); |
|
119 |
break; |
|
120 |
default: |
|
121 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); |
|
122 |
break; |
|
123 |
}; |
|
124 |
} |
|
125 |
|
|
126 |
static void |
|
127 |
simple_io_set_property (GObject *object, |
|
128 |
guint param_id, |
|
129 |
const GValue *value, |
|
130 |
GParamSpec *pspec) |
|
131 |
{ |
|
132 |
LmSimpleIOPriv *priv; |
|
133 |
|
|
134 |
priv = GET_PRIV (object); |
|
135 |
|
|
136 |
switch (param_id) { |
|
137 |
case PROP_MY_PROP: |
|
138 |
priv->my_prop = g_value_get_int (value); |
|
139 |
break; |
|
140 |
default: |
|
141 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); |
|
142 |
break; |
|
143 |
}; |
|
144 |
} |
|
145 |
|