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

« back to all changes in this revision

Viewing changes to build/src/lm-bar-graph.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-bar-graph.h"
 
14
 
 
15
#include "lm-bar-graph-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 33 "src/lm-bar-graph.gob"
 
26
 
 
27
#include "lm-util.h"
 
28
#include "lm-applet.h"
 
29
#include "lm-host-frontend.h"
 
30
 
 
31
#define BAR_THICKNESS                   6
 
32
 
 
33
#define BAR_PADDING                     2
 
34
 
 
35
#define LINE_WIDTH                      1.0
 
36
 
 
37
#define ALIGN                           0.5
 
38
 
 
39
#line 40 "lm-bar-graph.c"
 
40
/* self casting macros */
 
41
#define SELF(x) LM_BAR_GRAPH(x)
 
42
#define SELF_CONST(x) LM_BAR_GRAPH_CONST(x)
 
43
#define IS_SELF(x) LM_IS_BAR_GRAPH(x)
 
44
#define TYPE_SELF LM_TYPE_BAR_GRAPH
 
45
#define SELF_CLASS(x) LM_BAR_GRAPH_CLASS(x)
 
46
 
 
47
#define SELF_GET_CLASS(x) LM_BAR_GRAPH_GET_CLASS(x)
 
48
 
 
49
/* self typedefs */
 
50
typedef LMBarGraph Self;
 
51
typedef LMBarGraphClass SelfClass;
 
52
 
 
53
/* here are local prototypes */
 
54
static void ___object_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
 
55
static void ___object_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
 
56
#line 0 "src/lm-bar-graph.gob"
 
57
static void lm_bar_graph_init (LMBarGraph * o);
 
58
#line 59 "lm-bar-graph.c"
 
59
#line 0 "src/lm-bar-graph.gob"
 
60
static void lm_bar_graph_class_init (LMBarGraphClass * c);
 
61
#line 62 "lm-bar-graph.c"
 
62
#line 60 "src/lm-bar-graph.gob"
 
63
static void lm_bar_graph_constructor (LMBarGraph * self);
 
64
#line 65 "lm-bar-graph.c"
 
65
#line 82 "src/lm-bar-graph.gob"
 
66
static void ___3_lm_bar_graph_size_request (GtkWidget * widget, GtkRequisition * requisition);
 
67
#line 68 "lm-bar-graph.c"
 
68
#line 113 "src/lm-bar-graph.gob"
 
69
static gboolean ___4_lm_bar_graph_expose_event (GtkWidget * widget, GdkEventExpose * event);
 
70
#line 71 "lm-bar-graph.c"
 
71
#line 210 "src/lm-bar-graph.gob"
 
72
static void lm_bar_graph_draw_bar (LMBarGraph * self, LMHostFrontend * host, cairo_t * cr, int bar_x, int bar_y, int graph_width, int graph_height);
 
73
#line 74 "lm-bar-graph.c"
 
74
 
 
75
enum {
 
76
        PROP_0,
 
77
        PROP_APPLET,
 
78
        PROP_ORIENTATION
 
79
};
 
80
 
 
81
/* pointer to the class of our parent */
 
82
static GtkWidgetClass *parent_class = NULL;
 
83
 
 
84
/* Short form macros */
 
85
#define self_set_orientation lm_bar_graph_set_orientation
 
86
#define self_draw_bar lm_bar_graph_draw_bar
 
87
#define self_new lm_bar_graph_new
 
88
GType
 
89
lm_bar_graph_get_type (void)
 
90
{
 
91
        static GType type = 0;
 
92
 
 
93
        if ___GOB_UNLIKELY(type == 0) {
 
94
                static const GTypeInfo info = {
 
95
                        sizeof (LMBarGraphClass),
 
96
                        (GBaseInitFunc) NULL,
 
97
                        (GBaseFinalizeFunc) NULL,
 
98
                        (GClassInitFunc) lm_bar_graph_class_init,
 
99
                        (GClassFinalizeFunc) NULL,
 
100
                        NULL /* class_data */,
 
101
                        sizeof (LMBarGraph),
 
102
                        0 /* n_preallocs */,
 
103
                        (GInstanceInitFunc) lm_bar_graph_init,
 
104
                        NULL
 
105
                };
 
106
 
 
107
                type = g_type_register_static (GTK_TYPE_WIDGET, "LMBarGraph", &info, (GTypeFlags)0);
 
108
        }
 
109
 
 
110
        return type;
 
111
}
 
112
 
 
113
/* a macro for creating a new object of our type */
 
114
#define GET_NEW ((LMBarGraph *)g_object_new(lm_bar_graph_get_type(), NULL))
 
115
 
 
116
/* a function for creating a new object of our type */
 
117
#include <stdarg.h>
 
118
static LMBarGraph * GET_NEW_VARG (const char *first, ...) G_GNUC_UNUSED;
 
119
static LMBarGraph *
 
120
GET_NEW_VARG (const char *first, ...)
 
121
{
 
122
        LMBarGraph *ret;
 
123
        va_list ap;
 
124
        va_start (ap, first);
 
125
        ret = (LMBarGraph *)g_object_new_valist (lm_bar_graph_get_type (), first, ap);
 
126
        va_end (ap);
 
127
        return ret;
 
128
}
 
129
 
 
130
 
 
131
static GObject *
 
132
___constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_properties)
 
133
{
 
134
#define __GOB_FUNCTION__ "LM:Bar:Graph::constructor"
 
135
        GObject *obj_self;
 
136
        LMBarGraph *self;
 
137
        obj_self = G_OBJECT_CLASS (parent_class)->constructor (type, n_construct_properties, construct_properties);
 
138
        self = LM_BAR_GRAPH (obj_self);
 
139
#line 60 "src/lm-bar-graph.gob"
 
140
        lm_bar_graph_constructor (self);
 
141
#line 142 "lm-bar-graph.c"
 
142
        return obj_self;
 
143
}
 
144
#undef __GOB_FUNCTION__
 
145
 
 
146
 
 
147
static void
 
148
___finalize(GObject *obj_self)
 
149
{
 
150
#define __GOB_FUNCTION__ "LM:Bar:Graph::finalize"
 
151
        LMBarGraph *self G_GNUC_UNUSED = LM_BAR_GRAPH (obj_self);
 
152
        gpointer priv G_GNUC_UNUSED = self->_priv;
 
153
        if(G_OBJECT_CLASS(parent_class)->finalize) \
 
154
                (* G_OBJECT_CLASS(parent_class)->finalize)(obj_self);
 
155
}
 
156
#undef __GOB_FUNCTION__
 
157
 
 
158
static void 
 
159
lm_bar_graph_init (LMBarGraph * o G_GNUC_UNUSED)
 
160
{
 
161
#define __GOB_FUNCTION__ "LM:Bar:Graph::init"
 
162
        o->_priv = G_TYPE_INSTANCE_GET_PRIVATE(o,LM_TYPE_BAR_GRAPH,LMBarGraphPrivate);
 
163
}
 
164
#undef __GOB_FUNCTION__
 
165
static void 
 
166
lm_bar_graph_class_init (LMBarGraphClass * c G_GNUC_UNUSED)
 
167
{
 
168
#define __GOB_FUNCTION__ "LM:Bar:Graph::class_init"
 
169
        GObjectClass *g_object_class G_GNUC_UNUSED = (GObjectClass*) c;
 
170
        GtkWidgetClass *gtk_widget_class = (GtkWidgetClass *)c;
 
171
 
 
172
        g_type_class_add_private(c,sizeof(LMBarGraphPrivate));
 
173
 
 
174
        parent_class = g_type_class_ref (GTK_TYPE_WIDGET);
 
175
 
 
176
#line 82 "src/lm-bar-graph.gob"
 
177
        gtk_widget_class->size_request = ___3_lm_bar_graph_size_request;
 
178
#line 113 "src/lm-bar-graph.gob"
 
179
        gtk_widget_class->expose_event = ___4_lm_bar_graph_expose_event;
 
180
#line 181 "lm-bar-graph.c"
 
181
        g_object_class->constructor = ___constructor;
 
182
        g_object_class->finalize = ___finalize;
 
183
        g_object_class->get_property = ___object_get_property;
 
184
        g_object_class->set_property = ___object_set_property;
 
185
    {
 
186
        GParamSpec   *param_spec;
 
187
 
 
188
        param_spec = g_param_spec_pointer
 
189
                ("applet" /* name */,
 
190
                 NULL /* nick */,
 
191
                 NULL /* blurb */,
 
192
                 (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
 
193
        g_object_class_install_property (g_object_class,
 
194
                PROP_APPLET,
 
195
                param_spec);
 
196
        param_spec = g_param_spec_int
 
197
                ("orientation" /* name */,
 
198
                 NULL /* nick */,
 
199
                 NULL /* blurb */,
 
200
                 G_MININT /* minimum */,
 
201
                 G_MAXINT /* maximum */,
 
202
                 0 /* default_value */,
 
203
                 (GParamFlags)(G_PARAM_WRITABLE));
 
204
        g_object_class_install_property (g_object_class,
 
205
                PROP_ORIENTATION,
 
206
                param_spec);
 
207
    }
 
208
}
 
209
#undef __GOB_FUNCTION__
 
210
 
 
211
static void
 
212
___object_set_property (GObject *object,
 
213
        guint property_id,
 
214
        const GValue *VAL G_GNUC_UNUSED,
 
215
        GParamSpec *pspec G_GNUC_UNUSED)
 
216
#define __GOB_FUNCTION__ "LM:Bar:Graph::set_property"
 
217
{
 
218
        LMBarGraph *self G_GNUC_UNUSED;
 
219
 
 
220
        self = LM_BAR_GRAPH (object);
 
221
 
 
222
        switch (property_id) {
 
223
        case PROP_APPLET:
 
224
                {
 
225
#line 50 "src/lm-bar-graph.gob"
 
226
self->_priv->applet = g_value_get_pointer (VAL);
 
227
#line 228 "lm-bar-graph.c"
 
228
                }
 
229
                break;
 
230
        case PROP_ORIENTATION:
 
231
                {
 
232
#line 55 "src/lm-bar-graph.gob"
 
233
 
 
234
      selfp->orientation = g_value_get_int(VAL);
 
235
      gtk_widget_queue_resize(GTK_WIDGET(self));
 
236
    
 
237
#line 238 "lm-bar-graph.c"
 
238
                }
 
239
                break;
 
240
        default:
 
241
/* Apparently in g++ this is needed, glib is b0rk */
 
242
#ifndef __PRETTY_FUNCTION__
 
243
#  undef G_STRLOC
 
244
#  define G_STRLOC      __FILE__ ":" G_STRINGIFY (__LINE__)
 
245
#endif
 
246
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 
247
                break;
 
248
        }
 
249
}
 
250
#undef __GOB_FUNCTION__
 
251
 
 
252
static void
 
253
___object_get_property (GObject *object,
 
254
        guint property_id,
 
255
        GValue *VAL G_GNUC_UNUSED,
 
256
        GParamSpec *pspec G_GNUC_UNUSED)
 
257
#define __GOB_FUNCTION__ "LM:Bar:Graph::get_property"
 
258
{
 
259
        LMBarGraph *self G_GNUC_UNUSED;
 
260
 
 
261
        self = LM_BAR_GRAPH (object);
 
262
 
 
263
        switch (property_id) {
 
264
        case PROP_APPLET:
 
265
                {
 
266
#line 50 "src/lm-bar-graph.gob"
 
267
g_value_set_pointer (VAL, self->_priv->applet);
 
268
#line 269 "lm-bar-graph.c"
 
269
                }
 
270
                break;
 
271
        default:
 
272
/* Apparently in g++ this is needed, glib is b0rk */
 
273
#ifndef __PRETTY_FUNCTION__
 
274
#  undef G_STRLOC
 
275
#  define G_STRLOC      __FILE__ ":" G_STRINGIFY (__LINE__)
 
276
#endif
 
277
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 
278
                break;
 
279
        }
 
280
}
 
281
#undef __GOB_FUNCTION__
 
282
 
 
283
 
 
284
 
 
285
#line 55 "src/lm-bar-graph.gob"
 
286
void 
 
287
lm_bar_graph_set_orientation (LMBarGraph * self, LMBarGraphOrientation val)
 
288
{
 
289
#line 290 "lm-bar-graph.c"
 
290
#define __GOB_FUNCTION__ "LM:Bar:Graph::set_orientation"
 
291
{
 
292
#line 53 "src/lm-bar-graph.gob"
 
293
                g_object_set (G_OBJECT (self), "orientation", val, NULL);
 
294
}}
 
295
#line 296 "lm-bar-graph.c"
 
296
#undef __GOB_FUNCTION__
 
297
 
 
298
#line 60 "src/lm-bar-graph.gob"
 
299
static void 
 
300
lm_bar_graph_constructor (LMBarGraph * self)
 
301
{
 
302
#line 303 "lm-bar-graph.c"
 
303
#define __GOB_FUNCTION__ "LM:Bar:Graph::constructor"
 
304
{
 
305
#line 61 "src/lm-bar-graph.gob"
 
306
        
 
307
    int i;
 
308
 
 
309
    GTK_WIDGET_SET_FLAGS(self, GTK_NO_WINDOW);
 
310
 
 
311
    lm_g_object_connect(self, selfp->applet,
 
312
                        "swapped-signal::notify::scale", gtk_widget_queue_draw, self,
 
313
                        NULL);
 
314
 
 
315
    LM_ARRAY_FOREACH(i, selfp->applet->hosts)
 
316
      {
 
317
        LMHostFrontend *host = g_ptr_array_index(selfp->applet->hosts, i);
 
318
 
 
319
        lm_g_object_connect(self, host,
 
320
                            "swapped-signal::notify::color", gtk_widget_queue_draw, self,
 
321
                            "swapped-signal::notify::alive", gtk_widget_queue_draw, self,
 
322
                            "swapped-signal::notify::roundtrip-time", gtk_widget_queue_draw, self,
 
323
                            NULL);
 
324
      }
 
325
  }}
 
326
#line 327 "lm-bar-graph.c"
 
327
#undef __GOB_FUNCTION__
 
328
 
 
329
#line 82 "src/lm-bar-graph.gob"
 
330
static void 
 
331
___3_lm_bar_graph_size_request (GtkWidget * widget G_GNUC_UNUSED, GtkRequisition * requisition)
 
332
#line 333 "lm-bar-graph.c"
 
333
#define PARENT_HANDLER(___widget,___requisition) \
 
334
        { if(GTK_WIDGET_CLASS(parent_class)->size_request) \
 
335
                (* GTK_WIDGET_CLASS(parent_class)->size_request)(___widget,___requisition); }
 
336
{
 
337
#define __GOB_FUNCTION__ "LM:Bar:Graph::size_request"
 
338
{
 
339
#line 84 "src/lm-bar-graph.gob"
 
340
        
 
341
    Self *self = SELF(widget);
 
342
    int num_bars;
 
343
    int thickness;
 
344
 
 
345
    num_bars = selfp->applet->hosts->len;
 
346
    thickness = LM_BOX_BORDER_WIDTH * 2
 
347
      + BAR_PADDING * 2
 
348
      + num_bars * BAR_THICKNESS
 
349
      + (num_bars - 1) * BAR_PADDING;
 
350
 
 
351
    switch (selfp->orientation)
 
352
      {
 
353
      case LM_BAR_GRAPH_ORIENTATION_HORIZONTAL:
 
354
        requisition->width = 0;
 
355
        requisition->height = thickness;
 
356
        break;
 
357
 
 
358
      case LM_BAR_GRAPH_ORIENTATION_VERTICAL:
 
359
        requisition->width = thickness;
 
360
        requisition->height = 0;
 
361
        break;
 
362
 
 
363
      default:
 
364
        g_assert_not_reached();
 
365
        break;
 
366
      }
 
367
  }}
 
368
#line 369 "lm-bar-graph.c"
 
369
#undef __GOB_FUNCTION__
 
370
#undef PARENT_HANDLER
 
371
 
 
372
#line 113 "src/lm-bar-graph.gob"
 
373
static gboolean 
 
374
___4_lm_bar_graph_expose_event (GtkWidget * widget G_GNUC_UNUSED, GdkEventExpose * event)
 
375
#line 376 "lm-bar-graph.c"
 
376
#define PARENT_HANDLER(___widget,___event) \
 
377
        ((GTK_WIDGET_CLASS(parent_class)->expose_event)? \
 
378
                (* GTK_WIDGET_CLASS(parent_class)->expose_event)(___widget,___event): \
 
379
                ((gboolean )0))
 
380
{
 
381
#define __GOB_FUNCTION__ "LM:Bar:Graph::expose_event"
 
382
{
 
383
#line 115 "src/lm-bar-graph.gob"
 
384
        
 
385
    Self *self = SELF(widget);
 
386
    GdkRectangle entire_rect;
 
387
    GdkRectangle contents_rect;
 
388
    int bar_x;
 
389
    int bar_y;
 
390
    int graph_width;
 
391
    int graph_height;
 
392
    cairo_t *cr;
 
393
    int i;
 
394
 
 
395
    if (! GTK_WIDGET_DRAWABLE(widget))
 
396
      return FALSE;
 
397
 
 
398
    switch (selfp->orientation)
 
399
      {
 
400
      case LM_BAR_GRAPH_ORIENTATION_HORIZONTAL:
 
401
        entire_rect.x = widget->allocation.x;
 
402
        lm_widget_get_origin(widget, ALIGN, ALIGN, NULL, &entire_rect.y);
 
403
        entire_rect.width = widget->allocation.width;
 
404
        entire_rect.height = widget->requisition.height;
 
405
        break;
 
406
 
 
407
      case LM_BAR_GRAPH_ORIENTATION_VERTICAL:
 
408
        lm_widget_get_origin(widget, ALIGN, ALIGN, &entire_rect.x, NULL);
 
409
        entire_rect.y = widget->allocation.y;
 
410
        entire_rect.width = widget->requisition.width;
 
411
        entire_rect.height = widget->allocation.height;
 
412
        break;
 
413
 
 
414
      default:
 
415
        g_assert_not_reached();
 
416
        break;
 
417
      }
 
418
 
 
419
    contents_rect.x = entire_rect.x + LM_BOX_BORDER_WIDTH;
 
420
    contents_rect.y = entire_rect.y + LM_BOX_BORDER_WIDTH;
 
421
    contents_rect.width = entire_rect.width - LM_BOX_BORDER_WIDTH * 2;
 
422
    contents_rect.height = entire_rect.height - LM_BOX_BORDER_WIDTH * 2;
 
423
 
 
424
    bar_x = contents_rect.x + BAR_PADDING;
 
425
    bar_y = contents_rect.y + BAR_PADDING;
 
426
    graph_width = contents_rect.width - BAR_PADDING * 2;
 
427
    graph_height = contents_rect.height - BAR_PADDING * 2;
 
428
 
 
429
    lm_paint_box(widget->window,
 
430
                 GTK_WIDGET_STATE(widget),
 
431
                 GTK_SHADOW_IN,
 
432
                 &event->area,
 
433
                 widget,
 
434
                 widget->style->base_gc[GTK_WIDGET_STATE(widget)],
 
435
                 entire_rect.x,
 
436
                 entire_rect.y,
 
437
                 entire_rect.width,
 
438
                 entire_rect.height);
 
439
 
 
440
    cr = gdk_cairo_create(widget->window);
 
441
 
 
442
    cairo_set_line_width(cr, LINE_WIDTH);
 
443
    cairo_set_line_cap(cr, CAIRO_LINE_CAP_BUTT);
 
444
    cairo_set_line_join(cr, CAIRO_LINE_JOIN_MITER);
 
445
 
 
446
    LM_ARRAY_FOREACH(i, selfp->applet->hosts)
 
447
      {
 
448
        LMHostFrontend *host = g_ptr_array_index(selfp->applet->hosts, i);
 
449
 
 
450
        self_draw_bar(self,
 
451
                      host,
 
452
                      cr,
 
453
                      bar_x,
 
454
                      bar_y,
 
455
                      graph_width,
 
456
                      graph_height);
 
457
 
 
458
        switch (selfp->orientation)
 
459
          {
 
460
          case LM_BAR_GRAPH_ORIENTATION_HORIZONTAL:
 
461
            bar_y += BAR_THICKNESS + BAR_PADDING;
 
462
            break;
 
463
 
 
464
          case LM_BAR_GRAPH_ORIENTATION_VERTICAL:
 
465
            bar_x += BAR_THICKNESS + BAR_PADDING;
 
466
            break;
 
467
 
 
468
          default:
 
469
            g_assert_not_reached();
 
470
            break;
 
471
          }
 
472
      }
 
473
 
 
474
    cairo_destroy(cr);
 
475
 
 
476
    return FALSE;
 
477
  }}
 
478
#line 479 "lm-bar-graph.c"
 
479
#undef __GOB_FUNCTION__
 
480
#undef PARENT_HANDLER
 
481
 
 
482
#line 210 "src/lm-bar-graph.gob"
 
483
static void 
 
484
lm_bar_graph_draw_bar (LMBarGraph * self, LMHostFrontend * host, cairo_t * cr, int bar_x, int bar_y, int graph_width, int graph_height)
 
485
{
 
486
#line 487 "lm-bar-graph.c"
 
487
#define __GOB_FUNCTION__ "LM:Bar:Graph::draw_bar"
 
488
#line 210 "src/lm-bar-graph.gob"
 
489
        g_return_if_fail (self != NULL);
 
490
#line 210 "src/lm-bar-graph.gob"
 
491
        g_return_if_fail (LM_IS_BAR_GRAPH (self));
 
492
#line 210 "src/lm-bar-graph.gob"
 
493
        g_return_if_fail (host != NULL);
 
494
#line 210 "src/lm-bar-graph.gob"
 
495
        g_return_if_fail (LM_IS_HOST_FRONTEND (host));
 
496
#line 210 "src/lm-bar-graph.gob"
 
497
        g_return_if_fail (cr != NULL);
 
498
#line 499 "lm-bar-graph.c"
 
499
{
 
500
#line 218 "src/lm-bar-graph.gob"
 
501
        
 
502
    LMHost *base_host = LM_HOST(host);
 
503
    GdkRectangle bar_rect;
 
504
    LMCairoColor fill_color;
 
505
    LMCairoColor border_color;
 
506
    double fraction;
 
507
 
 
508
    if (base_host->alive)
 
509
      {
 
510
        fraction = ((double) base_host->roundtrip_time / 1000) / selfp->applet->scale;
 
511
        fraction = CLAMP(fraction, 0.0, 1.0);
 
512
      }
 
513
    else
 
514
      fraction = 1.0;
 
515
 
 
516
    switch (selfp->orientation)
 
517
      {
 
518
      case LM_BAR_GRAPH_ORIENTATION_HORIZONTAL:
 
519
        bar_rect.width = fraction * graph_width;
 
520
        bar_rect.height = BAR_THICKNESS;
 
521
        bar_rect.x = bar_x;
 
522
        bar_rect.y = bar_y;
 
523
        break;
 
524
 
 
525
      case LM_BAR_GRAPH_ORIENTATION_VERTICAL:
 
526
        bar_rect.width = BAR_THICKNESS;
 
527
        bar_rect.height = fraction * graph_height;
 
528
        bar_rect.x = bar_x;
 
529
        bar_rect.y = bar_y + graph_height - bar_rect.height;
 
530
        break;
 
531
 
 
532
      default:
 
533
        g_assert_not_reached();
 
534
        break;
 
535
      }
 
536
 
 
537
    /* setup a clip rectangle for the bar */
 
538
    cairo_save(cr);
 
539
    cairo_new_path(cr);
 
540
    cairo_rectangle(cr, bar_rect.x, bar_rect.y, bar_rect.width, bar_rect.height);
 
541
    cairo_clip(cr);
 
542
    cairo_translate(cr, bar_rect.x, bar_rect.y);
 
543
 
 
544
    lm_gdk_color_to_cairo_color(&host->color, &fill_color);
 
545
    lm_cairo_color_shade(&fill_color, &border_color, 0.6);
 
546
 
 
547
    /* draw the bar border */
 
548
    lm_cairo_set_source_color(cr, &border_color);
 
549
    cairo_rectangle(cr,
 
550
                    LINE_WIDTH,
 
551
                    LINE_WIDTH,
 
552
                    bar_rect.width - LINE_WIDTH * 2,
 
553
                    bar_rect.height - LINE_WIDTH * 2);
 
554
    cairo_stroke_preserve(cr);
 
555
 
 
556
    /* if the host is alive, fill the bar */
 
557
    if (base_host->alive)
 
558
      {
 
559
        lm_cairo_set_source_color(cr, &fill_color);
 
560
        cairo_fill(cr);
 
561
      }
 
562
 
 
563
    cairo_restore(cr);
 
564
  }}
 
565
#line 566 "lm-bar-graph.c"
 
566
#undef __GOB_FUNCTION__
 
567
 
 
568
#line 283 "src/lm-bar-graph.gob"
 
569
GtkWidget * 
 
570
lm_bar_graph_new (LMApplet * applet)
 
571
{
 
572
#line 573 "lm-bar-graph.c"
 
573
#define __GOB_FUNCTION__ "LM:Bar:Graph::new"
 
574
#line 283 "src/lm-bar-graph.gob"
 
575
        g_return_val_if_fail (applet != NULL, (GtkWidget * )0);
 
576
#line 283 "src/lm-bar-graph.gob"
 
577
        g_return_val_if_fail (LM_IS_APPLET (applet), (GtkWidget * )0);
 
578
#line 579 "lm-bar-graph.c"
 
579
{
 
580
#line 285 "src/lm-bar-graph.gob"
 
581
        
 
582
    return GTK_WIDGET(GET_NEW_VARG(LM_BAR_GRAPH_PROP_APPLET(applet), NULL));
 
583
  }}
 
584
#line 585 "lm-bar-graph.c"
 
585
#undef __GOB_FUNCTION__