Simplify 'cpufreq' plugin using lxpanel_button_new_for_icon().
[lxde/lxpanel.git] / plugins / test.c
CommitLineData
a52c2257
HJYP
1/*
2 * test - test module. its purpose to continuously change its size by
3 * allocating and destroying widgets. It helps in debuging panels's
4 * geometry engine (panel.c )
5 */
4542c20d 6
a52c2257
HJYP
7#include <time.h>
8#include <sys/time.h>
9#include <sys/types.h>
10#include <stdio.h>
11#include <stdlib.h>
12#include <string.h>
13
a52c2257
HJYP
14#include "panel.h"
15#include "misc.h"
b31cb1d2 16#include "private.h"
a52c2257 17
a52c2257
HJYP
18#include "dbg.h"
19
a52c2257
HJYP
20#define WID_NUM 80
21
22typedef struct {
23 GtkWidget *main;
24 int count;
25 int delta;
26 int timer;
27 GtkWidget *wid[WID_NUM];
28} test;
29
a52c2257
HJYP
30static gint
31clock_update(gpointer data )
32{
33 test *dc = (test *)data;
4542c20d 34
a52c2257
HJYP
35 ENTER;
36 if (dc->count >= WID_NUM-1)
37 dc->delta = -1;
38 else if (dc->count <= 0)
39 dc->delta = 1;
40 if (dc->delta == 1) {
41 dc->wid[dc->count] = gtk_button_new_with_label(" wwwww ");
42 gtk_widget_show( dc->wid[dc->count] );
43 gtk_box_pack_start(GTK_BOX(dc->main), dc->wid[dc->count], TRUE, FALSE, 0);
44 } else
45 gtk_widget_destroy(dc->wid[dc->count]);
46 dc->count += dc->delta;
47 RET(TRUE);
48}
49
a52c2257 50static int
22242ed4 51test_constructor(Plugin *p)
a52c2257
HJYP
52{
53 test *dc;
54 line s;
4542c20d 55
a52c2257
HJYP
56 ENTER;
57 dc = g_new0(test, 1);
58 g_return_val_if_fail(dc != NULL, 0);
59 p->priv = dc;
60 dc->delta = 1;
61 s.len = 256;
c69ac68e 62 while (lxpanel_get_line(p->fp, &s) != LINE_BLOCK_END) {
a52c2257
HJYP
63 ERR( "test: illegal in this context %s\n", s.str);
64 }
65 dc->main = p->panel->my_box_new(TRUE, 1);
66 gtk_widget_show(dc->main);
4542c20d 67 p->pwid = dc->main;
a52c2257
HJYP
68
69 dc->timer = g_timeout_add(200, clock_update, (gpointer)dc);
70
71 RET(1);
72}
73
74
75static void
22242ed4 76test_destructor(Plugin *p)
a52c2257
HJYP
77{
78 test *dc = (test *)p->priv;
79
80 ENTER;
81 dc = (test *) p->priv;
82 if (dc->timer)
83 g_source_remove(dc->timer);
84 gtk_widget_destroy(dc->main);
85 RET();
86}
87
22242ed4 88PluginClass test_plugin_class = {
3c3e9c9e
HG
89 .fname = NULL,
90 .count = 0,
a52c2257 91
3c3e9c9e
HG
92 .type = "test",
93 .name = "Test Plugin",
94 .version = "1.0",
95 .description = "Dispaly Digital clock and Tooltip",
a52c2257 96
3c3e9c9e
HG
97 .constructor = test_constructor,
98 .destructor = test_destructor,
a52c2257 99};