debian: build from GIT requires gtk-doc-tools so adding it to debian/control.
[lxde/lxpanel.git] / plugins / test.c
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 */
6
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
14 #include "panel.h"
15 #include "misc.h"
16 #include "private.h"
17
18 #include "dbg.h"
19
20 #define WID_NUM 80
21
22 typedef struct {
23 GtkWidget *main;
24 int count;
25 int delta;
26 int timer;
27 GtkWidget *wid[WID_NUM];
28 } test;
29
30 static gint
31 clock_update(gpointer data )
32 {
33 test *dc = (test *)data;
34
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
50 static int
51 test_constructor(Plugin *p)
52 {
53 test *dc;
54 line s;
55
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;
62 while (lxpanel_get_line(p->fp, &s) != LINE_BLOCK_END) {
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);
67 p->pwid = dc->main;
68
69 dc->timer = g_timeout_add(200, clock_update, (gpointer)dc);
70
71 RET(1);
72 }
73
74
75 static void
76 test_destructor(Plugin *p)
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
88 PluginClass test_plugin_class = {
89 .fname = NULL,
90 .count = 0,
91
92 .type = "test",
93 .name = "Test Plugin",
94 .version = "1.0",
95 .description = "Dispaly Digital clock and Tooltip",
96
97 .constructor = test_constructor,
98 .destructor = test_destructor,
99 };