~ubuntu-branches/debian/sid/link-monitor-applet/sid

« back to all changes in this revision

Viewing changes to build/src/lm-line-graph-icon.c

  • Committer: Bazaar Package Importer
  • Author(s): Adriaan Peeters
  • Date: 2008-03-30 22:26:13 UTC
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20080330222613-5aubcuo9mgg2n7st
Tags: upstream-3.0
ImportĀ upstreamĀ versionĀ 3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Generated by GOB (v2.0.15)   (do not edit directly) */
 
2
 
 
3
/* End world hunger, donate to the World Food Programme, http://www.wfp.org */
 
4
 
 
5
#define GOB_VERSION_MAJOR 2
 
6
#define GOB_VERSION_MINOR 0
 
7
#define GOB_VERSION_PATCHLEVEL 15
 
8
 
 
9
#define selfp (self->_priv)
 
10
 
 
11
#include <string.h> /* memset() */
 
12
 
 
13
#include "lm-line-graph-icon.h"
 
14
 
 
15
#include "lm-line-graph-icon-private.h"
 
16
 
 
17
#ifdef G_LIKELY
 
18
#define ___GOB_LIKELY(expr) G_LIKELY(expr)
 
19
#define ___GOB_UNLIKELY(expr) G_UNLIKELY(expr)
 
20
#else /* ! G_LIKELY */
 
21
#define ___GOB_LIKELY(expr) (expr)
 
22
#define ___GOB_UNLIKELY(expr) (expr)
 
23
#endif /* G_LIKELY */
 
24
 
 
25
#line 25 "src/lm-line-graph-icon.gob"
 
26
 
 
27
#define WIDTH           36
 
28
#define HEIGHT          24
 
29
 
 
30
#define XALIGN          0.5
 
31
#define YALIGN          0.5
 
32
 
 
33
#define LINE_WIDTH      3.0
 
34
 
 
35
typedef struct
 
36
{
 
37
  double x;
 
38
  double y;
 
39
} Point;
 
40
 
 
41
static const Point points[] = {
 
42
  { 0.1, 0.5 },
 
43
  { 0.2, 0.7 },
 
44
  { 0.4, 0.2 },
 
45
  { 0.5, 0.7 },
 
46
  { 0.7, 0.3 },
 
47
  { 0.9, 0.6 }
 
48
};
 
49
 
 
50
#line 51 "lm-line-graph-icon.c"
 
51
/* self casting macros */
 
52
#define SELF(x) LM_LINE_GRAPH_ICON(x)
 
53
#define SELF_CONST(x) LM_LINE_GRAPH_ICON_CONST(x)
 
54
#define IS_SELF(x) LM_IS_LINE_GRAPH_ICON(x)
 
55
#define TYPE_SELF LM_TYPE_LINE_GRAPH_ICON
 
56
#define SELF_CLASS(x) LM_LINE_GRAPH_ICON_CLASS(x)
 
57
 
 
58
#define SELF_GET_CLASS(x) LM_LINE_GRAPH_ICON_GET_CLASS(x)
 
59
 
 
60
/* self typedefs */
 
61
typedef LMLineGraphIcon Self;
 
62
typedef LMLineGraphIconClass SelfClass;
 
63
 
 
64
/* here are local prototypes */
 
65
static void ___object_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
 
66
static void ___object_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
 
67
#line 0 "src/lm-line-graph-icon.gob"
 
68
static void lm_line_graph_icon_init (LMLineGraphIcon * o);
 
69
#line 70 "lm-line-graph-icon.c"
 
70
#line 0 "src/lm-line-graph-icon.gob"
 
71
static void lm_line_graph_icon_class_init (LMLineGraphIconClass * c);
 
72
#line 73 "lm-line-graph-icon.c"
 
73
#line 55 "src/lm-line-graph-icon.gob"
 
74
static void lm_line_graph_icon_constructor (LMLineGraphIcon * self);
 
75
#line 76 "lm-line-graph-icon.c"
 
76
#line 64 "src/lm-line-graph-icon.gob"
 
77
static void ___2_lm_line_graph_icon_size_request (GtkWidget * widget, GtkRequisition * requisition);
 
78
#line 79 "lm-line-graph-icon.c"
 
79
#line 76 "src/lm-line-graph-icon.gob"
 
80
static void lm_line_graph_icon_get_absolute_point (LMLineGraphIcon * self, const Point * in, Point * out);
 
81
#line 82 "lm-line-graph-icon.c"
 
82
#line 91 "src/lm-line-graph-icon.gob"
 
83
static gboolean ___4_lm_line_graph_icon_expose_event (GtkWidget * widget, GdkEventExpose * event);
 
84
#line 85 "lm-line-graph-icon.c"
 
85
 
 
86
enum {
 
87
        PROP_0,
 
88
        PROP_HOST
 
89
};
 
90
 
 
91
/* pointer to the class of our parent */
 
92
static GtkWidgetClass *parent_class = NULL;
 
93
 
 
94
/* Short form macros */
 
95
#define self_get_absolute_point lm_line_graph_icon_get_absolute_point
 
96
#define self_new lm_line_graph_icon_new
 
97
GType
 
98
lm_line_graph_icon_get_type (void)
 
99
{
 
100
        static GType type = 0;
 
101
 
 
102
        if ___GOB_UNLIKELY(type == 0) {
 
103
                static const GTypeInfo info = {
 
104
                        sizeof (LMLineGraphIconClass),
 
105
                        (GBaseInitFunc) NULL,
 
106
                        (GBaseFinalizeFunc) NULL,
 
107
                        (GClassInitFunc) lm_line_graph_icon_class_init,
 
108
                        (GClassFinalizeFunc) NULL,
 
109
                        NULL /* class_data */,
 
110
                        sizeof (LMLineGraphIcon),
 
111
                        0 /* n_preallocs */,
 
112
                        (GInstanceInitFunc) lm_line_graph_icon_init,
 
113
                        NULL
 
114
                };
 
115
 
 
116
                type = g_type_register_static (GTK_TYPE_WIDGET, "LMLineGraphIcon", &info, (GTypeFlags)0);
 
117
        }
 
118
 
 
119
        return type;
 
120
}
 
121
 
 
122
/* a macro for creating a new object of our type */
 
123
#define GET_NEW ((LMLineGraphIcon *)g_object_new(lm_line_graph_icon_get_type(), NULL))
 
124
 
 
125
/* a function for creating a new object of our type */
 
126
#include <stdarg.h>
 
127
static LMLineGraphIcon * GET_NEW_VARG (const char *first, ...) G_GNUC_UNUSED;
 
128
static LMLineGraphIcon *
 
129
GET_NEW_VARG (const char *first, ...)
 
130
{
 
131
        LMLineGraphIcon *ret;
 
132
        va_list ap;
 
133
        va_start (ap, first);
 
134
        ret = (LMLineGraphIcon *)g_object_new_valist (lm_line_graph_icon_get_type (), first, ap);
 
135
        va_end (ap);
 
136
        return ret;
 
137
}
 
138
 
 
139
 
 
140
static GObject *
 
141
___constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_properties)
 
142
{
 
143
#define __GOB_FUNCTION__ "LM:Line:Graph:Icon::constructor"
 
144
        GObject *obj_self;
 
145
        LMLineGraphIcon *self;
 
146
        obj_self = G_OBJECT_CLASS (parent_class)->constructor (type, n_construct_properties, construct_properties);
 
147
        self = LM_LINE_GRAPH_ICON (obj_self);
 
148
#line 55 "src/lm-line-graph-icon.gob"
 
149
        lm_line_graph_icon_constructor (self);
 
150
#line 151 "lm-line-graph-icon.c"
 
151
        return obj_self;
 
152
}
 
153
#undef __GOB_FUNCTION__
 
154
 
 
155
 
 
156
static void
 
157
___finalize(GObject *obj_self)
 
158
{
 
159
#define __GOB_FUNCTION__ "LM:Line:Graph:Icon::finalize"
 
160
        LMLineGraphIcon *self G_GNUC_UNUSED = LM_LINE_GRAPH_ICON (obj_self);
 
161
        gpointer priv G_GNUC_UNUSED = self->_priv;
 
162
        if(G_OBJECT_CLASS(parent_class)->finalize) \
 
163
                (* G_OBJECT_CLASS(parent_class)->finalize)(obj_self);
 
164
}
 
165
#undef __GOB_FUNCTION__
 
166
 
 
167
static void 
 
168
lm_line_graph_icon_init (LMLineGraphIcon * o G_GNUC_UNUSED)
 
169
{
 
170
#define __GOB_FUNCTION__ "LM:Line:Graph:Icon::init"
 
171
        o->_priv = G_TYPE_INSTANCE_GET_PRIVATE(o,LM_TYPE_LINE_GRAPH_ICON,LMLineGraphIconPrivate);
 
172
}
 
173
#undef __GOB_FUNCTION__
 
174
static void 
 
175
lm_line_graph_icon_class_init (LMLineGraphIconClass * c G_GNUC_UNUSED)
 
176
{
 
177
#define __GOB_FUNCTION__ "LM:Line:Graph:Icon::class_init"
 
178
        GObjectClass *g_object_class G_GNUC_UNUSED = (GObjectClass*) c;
 
179
        GtkWidgetClass *gtk_widget_class = (GtkWidgetClass *)c;
 
180
 
 
181
        g_type_class_add_private(c,sizeof(LMLineGraphIconPrivate));
 
182
 
 
183
        parent_class = g_type_class_ref (GTK_TYPE_WIDGET);
 
184
 
 
185
#line 64 "src/lm-line-graph-icon.gob"
 
186
        gtk_widget_class->size_request = ___2_lm_line_graph_icon_size_request;
 
187
#line 91 "src/lm-line-graph-icon.gob"
 
188
        gtk_widget_class->expose_event = ___4_lm_line_graph_icon_expose_event;
 
189
#line 190 "lm-line-graph-icon.c"
 
190
        g_object_class->constructor = ___constructor;
 
191
        g_object_class->finalize = ___finalize;
 
192
        g_object_class->get_property = ___object_get_property;
 
193
        g_object_class->set_property = ___object_set_property;
 
194
    {
 
195
        GParamSpec   *param_spec;
 
196
 
 
197
        param_spec = g_param_spec_pointer
 
198
                ("host" /* name */,
 
199
                 NULL /* nick */,
 
200
                 NULL /* blurb */,
 
201
                 (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
 
202
        g_object_class_install_property (g_object_class,
 
203
                PROP_HOST,
 
204
                param_spec);
 
205
    }
 
206
}
 
207
#undef __GOB_FUNCTION__
 
208
 
 
209
static void
 
210
___object_set_property (GObject *object,
 
211
        guint property_id,
 
212
        const GValue *VAL G_GNUC_UNUSED,
 
213
        GParamSpec *pspec G_GNUC_UNUSED)
 
214
#define __GOB_FUNCTION__ "LM:Line:Graph:Icon::set_property"
 
215
{
 
216
        LMLineGraphIcon *self G_GNUC_UNUSED;
 
217
 
 
218
        self = LM_LINE_GRAPH_ICON (object);
 
219
 
 
220
        switch (property_id) {
 
221
        case PROP_HOST:
 
222
                {
 
223
#line 53 "src/lm-line-graph-icon.gob"
 
224
self->_priv->host = g_value_get_pointer (VAL);
 
225
#line 226 "lm-line-graph-icon.c"
 
226
                }
 
227
                break;
 
228
        default:
 
229
/* Apparently in g++ this is needed, glib is b0rk */
 
230
#ifndef __PRETTY_FUNCTION__
 
231
#  undef G_STRLOC
 
232
#  define G_STRLOC      __FILE__ ":" G_STRINGIFY (__LINE__)
 
233
#endif
 
234
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 
235
                break;
 
236
        }
 
237
}
 
238
#undef __GOB_FUNCTION__
 
239
 
 
240
static void
 
241
___object_get_property (GObject *object,
 
242
        guint property_id,
 
243
        GValue *VAL G_GNUC_UNUSED,
 
244
        GParamSpec *pspec G_GNUC_UNUSED)
 
245
#define __GOB_FUNCTION__ "LM:Line:Graph:Icon::get_property"
 
246
{
 
247
        LMLineGraphIcon *self G_GNUC_UNUSED;
 
248
 
 
249
        self = LM_LINE_GRAPH_ICON (object);
 
250
 
 
251
        switch (property_id) {
 
252
        case PROP_HOST:
 
253
                {
 
254
#line 53 "src/lm-line-graph-icon.gob"
 
255
g_value_set_pointer (VAL, self->_priv->host);
 
256
#line 257 "lm-line-graph-icon.c"
 
257
                }
 
258
                break;
 
259
        default:
 
260
/* Apparently in g++ this is needed, glib is b0rk */
 
261
#ifndef __PRETTY_FUNCTION__
 
262
#  undef G_STRLOC
 
263
#  define G_STRLOC      __FILE__ ":" G_STRINGIFY (__LINE__)
 
264
#endif
 
265
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 
266
                break;
 
267
        }
 
268
}
 
269
#undef __GOB_FUNCTION__
 
270
 
 
271
 
 
272
 
 
273
#line 55 "src/lm-line-graph-icon.gob"
 
274
static void 
 
275
lm_line_graph_icon_constructor (LMLineGraphIcon * self)
 
276
{
 
277
#line 278 "lm-line-graph-icon.c"
 
278
#define __GOB_FUNCTION__ "LM:Line:Graph:Icon::constructor"
 
279
{
 
280
#line 56 "src/lm-line-graph-icon.gob"
 
281
        
 
282
    GTK_WIDGET_SET_FLAGS(self, GTK_NO_WINDOW);
 
283
 
 
284
    lm_g_object_connect(self, selfp->host,
 
285
                        "swapped-signal::notify::color", gtk_widget_queue_draw, self,
 
286
                        NULL);
 
287
  }}
 
288
#line 289 "lm-line-graph-icon.c"
 
289
#undef __GOB_FUNCTION__
 
290
 
 
291
#line 64 "src/lm-line-graph-icon.gob"
 
292
static void 
 
293
___2_lm_line_graph_icon_size_request (GtkWidget * widget G_GNUC_UNUSED, GtkRequisition * requisition)
 
294
#line 295 "lm-line-graph-icon.c"
 
295
#define PARENT_HANDLER(___widget,___requisition) \
 
296
        { if(GTK_WIDGET_CLASS(parent_class)->size_request) \
 
297
                (* GTK_WIDGET_CLASS(parent_class)->size_request)(___widget,___requisition); }
 
298
{
 
299
#define __GOB_FUNCTION__ "LM:Line:Graph:Icon::size_request"
 
300
{
 
301
#line 66 "src/lm-line-graph-icon.gob"
 
302
        
 
303
    requisition->width = WIDTH;
 
304
    requisition->height = HEIGHT;
 
305
  }}
 
306
#line 307 "lm-line-graph-icon.c"
 
307
#undef __GOB_FUNCTION__
 
308
#undef PARENT_HANDLER
 
309
 
 
310
#line 76 "src/lm-line-graph-icon.gob"
 
311
static void 
 
312
lm_line_graph_icon_get_absolute_point (LMLineGraphIcon * self, const Point * in, Point * out)
 
313
{
 
314
#line 315 "lm-line-graph-icon.c"
 
315
#define __GOB_FUNCTION__ "LM:Line:Graph:Icon::get_absolute_point"
 
316
#line 76 "src/lm-line-graph-icon.gob"
 
317
        g_return_if_fail (self != NULL);
 
318
#line 76 "src/lm-line-graph-icon.gob"
 
319
        g_return_if_fail (LM_IS_LINE_GRAPH_ICON (self));
 
320
#line 76 "src/lm-line-graph-icon.gob"
 
321
        g_return_if_fail (in != NULL);
 
322
#line 76 "src/lm-line-graph-icon.gob"
 
323
        g_return_if_fail (out != NULL);
 
324
#line 325 "lm-line-graph-icon.c"
 
325
{
 
326
#line 80 "src/lm-line-graph-icon.gob"
 
327
        
 
328
    GtkWidget *widget = GTK_WIDGET(self);
 
329
 
 
330
    out->x = widget->allocation.x
 
331
      + ((widget->allocation.width - widget->requisition.width) * XALIGN)
 
332
      + (in->x * widget->requisition.width);
 
333
    out->y = widget->allocation.y
 
334
      + ((widget->allocation.height - widget->requisition.height) * YALIGN)
 
335
      + (in->y * widget->requisition.height);
 
336
  }}
 
337
#line 338 "lm-line-graph-icon.c"
 
338
#undef __GOB_FUNCTION__
 
339
 
 
340
#line 91 "src/lm-line-graph-icon.gob"
 
341
static gboolean 
 
342
___4_lm_line_graph_icon_expose_event (GtkWidget * widget G_GNUC_UNUSED, GdkEventExpose * event)
 
343
#line 344 "lm-line-graph-icon.c"
 
344
#define PARENT_HANDLER(___widget,___event) \
 
345
        ((GTK_WIDGET_CLASS(parent_class)->expose_event)? \
 
346
                (* GTK_WIDGET_CLASS(parent_class)->expose_event)(___widget,___event): \
 
347
                ((gboolean )0))
 
348
{
 
349
#define __GOB_FUNCTION__ "LM:Line:Graph:Icon::expose_event"
 
350
{
 
351
#line 93 "src/lm-line-graph-icon.gob"
 
352
        
 
353
    Self *self = SELF(widget);
 
354
    cairo_t *cr;
 
355
    Point p;
 
356
    int i;
 
357
 
 
358
    if (! GTK_WIDGET_DRAWABLE(widget))
 
359
      return FALSE;
 
360
 
 
361
    cr = gdk_cairo_create(widget->window);
 
362
 
 
363
    gdk_cairo_set_source_color(cr, &selfp->host->color);
 
364
 
 
365
    cairo_set_line_width(cr, LINE_WIDTH);
 
366
    cairo_set_line_cap(cr, CAIRO_LINE_CAP_BUTT);
 
367
    cairo_set_line_join(cr, CAIRO_LINE_JOIN_MITER);
 
368
 
 
369
    self_get_absolute_point(self, &points[0], &p);
 
370
    cairo_move_to(cr, p.x, p.y);
 
371
 
 
372
    for (i = 1; i < G_N_ELEMENTS(points); i++)
 
373
      {
 
374
        self_get_absolute_point(self, &points[i], &p);
 
375
        cairo_line_to(cr, p.x, p.y);
 
376
      }
 
377
 
 
378
    cairo_stroke(cr);
 
379
 
 
380
    cairo_destroy(cr);
 
381
 
 
382
    return FALSE;
 
383
  }}
 
384
#line 385 "lm-line-graph-icon.c"
 
385
#undef __GOB_FUNCTION__
 
386
#undef PARENT_HANDLER
 
387
 
 
388
#line 126 "src/lm-line-graph-icon.gob"
 
389
GtkWidget * 
 
390
lm_line_graph_icon_new (LMHostFrontend * host)
 
391
{
 
392
#line 393 "lm-line-graph-icon.c"
 
393
#define __GOB_FUNCTION__ "LM:Line:Graph:Icon::new"
 
394
#line 126 "src/lm-line-graph-icon.gob"
 
395
        g_return_val_if_fail (host != NULL, (GtkWidget * )0);
 
396
#line 126 "src/lm-line-graph-icon.gob"
 
397
        g_return_val_if_fail (LM_IS_HOST_FRONTEND (host), (GtkWidget * )0);
 
398
#line 399 "lm-line-graph-icon.c"
 
399
{
 
400
#line 128 "src/lm-line-graph-icon.gob"
 
401
        
 
402
    return GTK_WIDGET(GET_NEW_VARG(LM_LINE_GRAPH_ICON_PROP_HOST(host), NULL));
 
403
  }}
 
404
#line 405 "lm-line-graph-icon.c"
 
405
#undef __GOB_FUNCTION__