File: test.c

package info (click to toggle)
lxpanel 0.11.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,136 kB
  • sloc: ansic: 33,536; makefile: 541; xml: 310; python: 62; sh: 26
file content (99 lines) | stat: -rw-r--r-- 2,024 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
 *  test - test module. its purpose to continuously change its size by
 *  allocating and destroying widgets. It helps in debuging panels's
 *  geometry engine (panel.c )
 */

#include <time.h>
#include <sys/time.h>
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "panel.h"
#include "misc.h"
#include "private.h"

#include "dbg.h"

#define WID_NUM 80

typedef struct {
    GtkWidget *main;
    int count;
    int delta;
    int timer;
    GtkWidget *wid[WID_NUM];
} test;

static gint
clock_update(gpointer data )
{
    test *dc = (test *)data;

    ENTER;
    if (dc->count >= WID_NUM-1)
        dc->delta = -1;
    else if (dc->count <= 0)
        dc->delta = 1;
    if (dc->delta == 1) {
        dc->wid[dc->count] = gtk_button_new_with_label("  wwwww  ");
        gtk_widget_show( dc->wid[dc->count] );
        gtk_box_pack_start(GTK_BOX(dc->main), dc->wid[dc->count], TRUE, FALSE, 0);
     } else
        gtk_widget_destroy(dc->wid[dc->count]);
    dc->count += dc->delta;
    RET(TRUE);
}

static int
test_constructor(Plugin *p)
{
    test *dc;
    line s;

    ENTER;
    dc = g_new0(test, 1);
    g_return_val_if_fail(dc != NULL, 0);
    p->priv = dc;
    dc->delta = 1;
    s.len = 256;
    while (lxpanel_get_line(p->fp, &s) != LINE_BLOCK_END) {
        ERR( "test: illegal in this context %s\n", s.str);
    }
    dc->main = p->panel->my_box_new(TRUE, 1);
    gtk_widget_show(dc->main);
    p->pwid = dc->main;

    dc->timer = g_timeout_add(200, clock_update, (gpointer)dc);

    RET(1);
}


static void
test_destructor(Plugin *p)
{
  test *dc = (test *)p->priv;

  ENTER;
  dc = (test *) p->priv;
  if (dc->timer)
      g_source_remove(dc->timer);
  gtk_widget_destroy(dc->main);
  RET();
}

PluginClass test_plugin_class = {
    .fname = NULL,
    .count = 0,

    .type = "test",
    .name = "Test Plugin",
    .version = "1.0",
    .description = "Dispaly Digital clock and Tooltip",

    .constructor = test_constructor,
    .destructor  = test_destructor,
};