diff options
Diffstat (limited to 'src/statistics/gtk_statistics_demo.c')
-rw-r--r-- | src/statistics/gtk_statistics_demo.c | 70 |
1 files changed, 29 insertions, 41 deletions
diff --git a/src/statistics/gtk_statistics_demo.c b/src/statistics/gtk_statistics_demo.c index cdd61cd0..efd98e07 100644 --- a/src/statistics/gtk_statistics_demo.c +++ b/src/statistics/gtk_statistics_demo.c | |||
@@ -7,63 +7,51 @@ | |||
7 | * Update view (add more points). | 7 | * Update view (add more points). |
8 | */ | 8 | */ |
9 | static gboolean | 9 | static gboolean |
10 | update (GtkWidget *widget, GdkEvent *event, gpointer user_data) | 10 | update (GtkWidget * widget, GdkEvent * event, gpointer user_data) |
11 | { | 11 | { |
12 | static unsigned int i = 600; | 12 | static unsigned int i = 600; |
13 | struct GtkStatistics *statistics = user_data; | 13 | struct GtkStatistics *statistics = user_data; |
14 | 14 | ||
15 | gtk_statistics_update_value (GTK_STATISTICS (statistics), | 15 | gtk_statistics_update_value (GTK_STATISTICS (statistics), "sin", i, |
16 | "sin", | 16 | (uint64_t) (500 * (1.0 + sin (i / 100.0)))); |
17 | i, | 17 | gtk_statistics_update_value (GTK_STATISTICS (statistics), "cos", i * 2, |
18 | (uint64_t) (500 * (1.0 + sin(i/100.0)))); | 18 | (uint64_t) (i * (1.0 + cos (i / 100.0)))); |
19 | gtk_statistics_update_value (GTK_STATISTICS (statistics), | ||
20 | "cos", | ||
21 | i * 2, | ||
22 | (uint64_t) (i * (1.0 + cos(i/100.0)))); | ||
23 | i++; | 19 | i++; |
24 | return FALSE; | 20 | return FALSE; |
25 | } | 21 | } |
26 | 22 | ||
27 | 23 | ||
28 | int main (int argc, char ** argv) | 24 | int |
25 | main (int argc, char **argv) | ||
29 | { | 26 | { |
30 | GtkWidget *window; | 27 | GtkWidget *window; |
31 | GtkWidget *statistics; | 28 | GtkWidget *statistics; |
32 | unsigned int i; | 29 | unsigned int i; |
33 | 30 | ||
34 | gtk_init(&argc, &argv); | 31 | gtk_init (&argc, &argv); |
35 | window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | 32 | window = gtk_window_new (GTK_WINDOW_TOPLEVEL); |
36 | gtk_window_set_title(GTK_WINDOW(window), "STATISTICS widget"); | 33 | gtk_window_set_title (GTK_WINDOW (window), "STATISTICS widget"); |
37 | gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); | 34 | gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER); |
38 | gtk_window_set_default_size(GTK_WINDOW(window), 400, 200); | 35 | gtk_window_set_default_size (GTK_WINDOW (window), 400, 200); |
39 | g_signal_connect(G_OBJECT(window), "destroy", | 36 | g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), |
40 | G_CALLBACK(gtk_main_quit), NULL); | 37 | NULL); |
41 | statistics = gtk_statistics_new(); | 38 | statistics = gtk_statistics_new (); |
42 | gtk_statistics_add_line (GTK_STATISTICS (statistics), | 39 | gtk_statistics_add_line (GTK_STATISTICS (statistics), "sin", "sin", "red"); |
43 | "sin", | 40 | for (i = 0; i < 600; i++) |
44 | "sin", | 41 | gtk_statistics_update_value (GTK_STATISTICS (statistics), "sin", i, |
45 | "red"); | 42 | (uint64_t) (500 * (1.0 + sin (i / 100.0)))); |
46 | for (i=0;i<600;i++) | 43 | gtk_statistics_add_line (GTK_STATISTICS (statistics), "cos", "cos", "blue"); |
47 | gtk_statistics_update_value (GTK_STATISTICS (statistics), | 44 | for (i = 0; i < 600; i++) |
48 | "sin", | 45 | gtk_statistics_update_value (GTK_STATISTICS (statistics), "cos", i * 2, |
49 | i, | 46 | (uint64_t) (i * (1.0 + cos (i / 100.0)))); |
50 | (uint64_t) (500 * (1.0 + sin(i/100.0)))); | 47 | g_signal_connect (G_OBJECT (window), "motion-notify-event", |
51 | gtk_statistics_add_line (GTK_STATISTICS (statistics), | 48 | G_CALLBACK (update), statistics); |
52 | "cos", | 49 | gtk_container_add (GTK_CONTAINER (window), statistics); |
53 | "cos", | ||
54 | "blue"); | ||
55 | for (i=0;i<600;i++) | ||
56 | gtk_statistics_update_value (GTK_STATISTICS (statistics), | ||
57 | "cos", | ||
58 | i * 2, | ||
59 | (uint64_t) (i * (1.0 + cos(i/100.0)))); | ||
60 | g_signal_connect (G_OBJECT(window), "motion-notify-event", G_CALLBACK (update), statistics); | ||
61 | gtk_container_add(GTK_CONTAINER(window), statistics); | ||
62 | gtk_widget_add_events (GTK_WIDGET (window), GDK_POINTER_MOTION_MASK); | 50 | gtk_widget_add_events (GTK_WIDGET (window), GDK_POINTER_MOTION_MASK); |
63 | 51 | ||
64 | gtk_widget_show(statistics); | 52 | gtk_widget_show (statistics); |
65 | gtk_widget_show_all(window); | 53 | gtk_widget_show_all (window); |
66 | gtk_main(); | 54 | gtk_main (); |
67 | 55 | ||
68 | return 0; | 56 | return 0; |
69 | } | 57 | } |