[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r18522 - gnunet-gtk/src/statistics
From: |
gnunet |
Subject: |
[GNUnet-SVN] r18522 - gnunet-gtk/src/statistics |
Date: |
Thu, 8 Dec 2011 22:55:58 +0100 |
Author: grothoff
Date: 2011-12-08 22:55:58 +0100 (Thu, 08 Dec 2011)
New Revision: 18522
Added:
gnunet-gtk/src/statistics/gtk_statistics.c
gnunet-gtk/src/statistics/gtk_statistics.h
gnunet-gtk/src/statistics/test.c
Modified:
gnunet-gtk/src/statistics/Makefile.am
gnunet-gtk/src/statistics/gnunet-statistics-gtk-about.c
gnunet-gtk/src/statistics/gnunet-statistics-gtk.c
Log:
towards stats widget
Modified: gnunet-gtk/src/statistics/Makefile.am
===================================================================
--- gnunet-gtk/src/statistics/Makefile.am 2011-12-08 18:01:44 UTC (rev
18521)
+++ gnunet-gtk/src/statistics/Makefile.am 2011-12-08 21:55:58 UTC (rev
18522)
@@ -7,11 +7,12 @@
@GNUNET_CFLAGS@ \
@GLADE_CFLAGS@
-bin_PROGRAMS = gnunet-statistics-gtk
+bin_PROGRAMS = gnunet-statistics-gtk test
gnunet_statistics_gtk_SOURCES = \
gnunet-statistics-gtk.c \
- gnunet-statistics-gtk-about.c
+ gnunet-statistics-gtk-about.c \
+ gtk_statistics.c gtk_statistics.h
gnunet_statistics_gtk_LDADD = \
$(top_builddir)/src/lib/libgnunetgtk.la \
@GTK_LIBS@ \
@@ -19,4 +20,13 @@
-lgnunetutil -lgnunetstatistics -lgnunetcore -lgnunettransport \
$(INTLLIBS)
gnunet_statistics_gtk_LDFLAGS = \
+ -export-dynamic
+
+test_SOURCES = \
+ gtk_statistics.c gtk_statistics.h test.c
+test_LDADD = \
+ @GTK_LIBS@ \
+ @GLADE_LIBS@ @GNUNET_LIBS@ \
+ $(INTLLIBS)
+test_LDFLAGS = \
-export-dynamic
\ No newline at end of file
Modified: gnunet-gtk/src/statistics/gnunet-statistics-gtk-about.c
===================================================================
--- gnunet-gtk/src/statistics/gnunet-statistics-gtk-about.c 2011-12-08
18:01:44 UTC (rev 18521)
+++ gnunet-gtk/src/statistics/gnunet-statistics-gtk-about.c 2011-12-08
21:55:58 UTC (rev 18522)
@@ -35,8 +35,7 @@
GNUNET_STATISTICS_GTK_main_menu_help_about_activate_cb (GtkWidget * dummy,
gpointer data)
{
- GNUNET_GTK_display_about ("gnunet_statistics_gtk_about_dialog.glade",
- "GNUNET_STATISTICS_GTK_about_dialog");
+ GNUNET_GTK_display_about ("gnunet_statistics_gtk_about_dialog.glade");
}
Modified: gnunet-gtk/src/statistics/gnunet-statistics-gtk.c
===================================================================
--- gnunet-gtk/src/statistics/gnunet-statistics-gtk.c 2011-12-08 18:01:44 UTC
(rev 18521)
+++ gnunet-gtk/src/statistics/gnunet-statistics-gtk.c 2011-12-08 21:55:58 UTC
(rev 18522)
@@ -28,61 +28,12 @@
#include <gnunet/gnunet_util_lib.h>
#include <gnunet/gnunet_statistics_service.h>
#include <cairo.h>
+#include "gtk_statistics.h"
#define MAX_HISTORY 1280
/**
- * Information about a value we received.
- */
-struct HistoricValue
-{
- /**
- * A value we recorded.
- */
- uint64_t value;
-
- /**
- * Time when the value was recorded.
- */
- struct GNUNET_TIME_Absolute timestamp;
-};
-
-
-/**
- * Historic information we recorded for a value.
- */
-struct ValueHistory
-{
-
- /**
- * Name of the subsystem.
- */
- char *subsystem;
-
- /**
- * Name of the statistic.
- */
- char *name;
-
- /**
- * Recent values for this number.
- */
- struct HistoricValue history[MAX_HISTORY];
-
- /**
- * Last offset we wrote to in history.
- */
- unsigned int last_history_offset;
-
- /**
- * Number of valid entries in the history.
- */
- unsigned int history_size;
-};
-
-
-/**
* Information about how to plot certain values.
*/
struct PlotInfo
@@ -105,6 +56,13 @@
};
+static const struct PlotInfo connection_data[] =
+ {
+ { "core", "entries in session map", "white" },
+ { NULL, NULL, NULL}
+ };
+
+
/**
* Handle to our main loop.
*/
@@ -121,48 +79,12 @@
static struct GNUNET_STATISTICS_Handle *statistics;
/**
- * Map from keys (subsystem+value) to 'struct ValueHistory'.
- */
-static struct GNUNET_CONTAINER_MultiHashMap *stat_map;
-
-/**
* Task that refreshes connection graphic.
*/
static GNUNET_SCHEDULER_TaskIdentifier connection_task;
-/**
- * Pixmap where we have the connection image.
- */
-static GdkPixmap *connection_pixmap;
/**
- * How often do we refresh?
- */
-static struct GNUNET_TIME_Relative refresh_delay;
-
-
-/**
- * Obtain key for 'stat_map' for a given subsystem and name.
- *
- * @param subsystem subsystem
- * @param name name
- * @param key set to the hash map key
- */
-static void
-get_key (const char *subsystem,
- const char *name,
- GNUNET_HashCode *key)
-{
- GNUNET_HashCode h1;
- GNUNET_HashCode h2;
-
- GNUNET_CRYPTO_hash (subsystem, strlen(subsystem), &h1);
- GNUNET_CRYPTO_hash (name, strlen(name), &h2);
- GNUNET_CRYPTO_hash_xor (&h1, &h2, key);
-}
-
-
-/**
* Callback function to process statistic values.
*
* @param cls the 'struct ValueHistory' to update
@@ -177,54 +99,17 @@
const char *name, uint64_t value,
int is_persistent)
{
- struct ValueHistory *vh = cls;
- GNUNET_HashCode key;
+ GtkStatistics *stats = cls;
- get_key (subsystem, name, &key);
- if (++vh->last_history_offset == MAX_HISTORY)
- vh->last_history_offset = 0;
- if (vh->history_size < MAX_HISTORY)
- vh->history_size++;
- vh->history[vh->last_history_offset].value = value;
- vh->history[vh->last_history_offset].timestamp = GNUNET_TIME_absolute_get
();
+ gtk_statistics_update_value (stats,
+ name,
+ value,
+ GNUNET_TIME_absolute_get().abs_value);
return GNUNET_OK;
}
/**
- * Begin monitoring a particular value.
- *
- * @param subsystem name of subsystem that created the statistic
- * @param name the name of the datum
- */
-static void
-monitor (const char *subsystem,
- const char *name)
-{
- GNUNET_HashCode key;
- struct ValueHistory *vh;
-
- get_key (subsystem, name, &key);
- vh = GNUNET_CONTAINER_multihashmap_get (stat_map, &key);
- if (NULL != vh)
- return;
- vh = GNUNET_malloc (sizeof (struct ValueHistory));
- vh->subsystem = GNUNET_strdup (subsystem);
- vh->name = GNUNET_strdup (name);
- GNUNET_assert (GNUNET_OK ==
- GNUNET_CONTAINER_multihashmap_put (stat_map,
- &key,
- vh,
-
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST));
- GNUNET_STATISTICS_watch (statistics,
- subsystem,
- name,
- &process_value_update,
- vh);
-}
-
-
-/**
* Get an object from the main window.
*
* @param name name of the object
@@ -242,175 +127,31 @@
*
* @param widget size and style information for the plot
* @param info what to draw
- * @return pixmap with the drawing
*/
-static GdkPixmap *
-create_plot (GtkWidget *widget,
- const struct PlotInfo *info)
+/* static */ GtkStatistics *
+create_plot (const struct PlotInfo *info)
{
- GdkPixmap *ret;
- GdkGC *gc;
+ GtkStatistics *ret;
unsigned int i;
- GNUNET_HashCode key;
- struct ValueHistory *vh;
- GdkColor color;
- GdkColormap *colormap;
- ret = gdk_pixmap_new (widget->window,
- widget->allocation.width,
- widget->allocation.height,
- gtk_widget_get_visual (widget)->depth);
- colormap = gdk_window_get_colormap (widget->window);
- gc = gdk_gc_new (widget->window);
- gdk_gc_copy (gc, widget->style->white_gc);
- gdk_color_parse ("black", &color);
- gdk_colormap_alloc_color (colormap, &color, TRUE, TRUE);
- gdk_gc_set_foreground (gc, &color);
- gdk_draw_rectangle (GDK_DRAWABLE (ret),
- widget->style->black_gc,
- TRUE, 0, 0,
- widget->allocation.width,
- widget->allocation.height);
+ ret = GTK_STATISTICS (gtk_statistics_new ());
for (i=0; NULL != info[i].subsystem; i++)
{
- get_key (info[i].subsystem, info[i].name, &key);
- vh = GNUNET_CONTAINER_multihashmap_get (stat_map, &key);
- if (NULL == vh)
- continue;
- gdk_color_parse (info[i].color_name, &color);
- gdk_colormap_alloc_color (colormap, &color, TRUE, TRUE);
- gdk_gc_set_foreground (gc, &color);
-
-
-
+ gtk_statistics_add_line (ret,
+ info[i].name,
+ info[i].color_name);
+ GNUNET_STATISTICS_watch (statistics,
+ info[i].subsystem,
+ info[i].name,
+ &process_value_update,
+ ret);
}
-
- // FIXME
return ret;
}
-/**
- * Redraw the 'connection_pixmap'.
- *
- * @param widget where to render it to in the end (also for size to use)
- */
-static void
-plot_connection_graph (GtkWidget *widget)
-{
- static const struct PlotInfo connection_data[] =
- {
- { "core", "entries in session map", "white" },
- { NULL, NULL, NULL}
- };
- if (NULL != connection_pixmap)
- {
- gdk_pixmap_unref (connection_pixmap);
- connection_pixmap = NULL;
- }
- connection_pixmap = create_plot (widget,
- connection_data);
-}
-
/**
- * Part of the connection graph got re-exposed; refresh the area.
- *
- * @param widget the drawing area of the connection graph
- * @param event expose event
- * @param data_ptr unused
- * @return FALSE
- */
-gint
-GNUNET_STATISTICS_connection_graph_expose (GtkWidget * widget,
- GdkEventExpose * event,
- gpointer data_ptr)
-{
- gdk_draw_pixmap (widget->window,
- widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
- connection_pixmap,
- event->area.x, event->area.y,
- event->area.x, event->area.y,
- event->area.width, event->area.height);
- return FALSE;
-}
-
-
-/**
- * The window size was changed, forcing us to re-draw the connection
- * graph.
- *
- * @param widget the drawing area of the connection graph
- * @param event configure event
- * @param data_ptr unused
- * @return TRUE
- */
-gint
-GNUNET_STATISTICS_connection_graph_configure (GtkWidget * widget,
- GdkEventConfigure * event,
- gpointer data_ptr)
-{
- plot_connection_graph (widget);
- gdk_draw_pixmap (widget->window,
- widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
- connection_pixmap,
- 0, 0,
- 0, 0,
- widget->allocation.width, widget->allocation.height);
- return TRUE;
-}
-
-
-/**
- * Refresh the 'connections' graphic.
- *
- * @param cls closure
- * @param tc scheduler context
- */
-static void
-refresh_connections (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- GtkWidget *area;
-
- connection_task = GNUNET_SCHEDULER_add_delayed (refresh_delay,
- &refresh_connections,
- NULL);
- area = GTK_WIDGET (get_object
("GNUNET_STATISTICS_GTK_main_notebook_connectivity_drawingarea"));
- plot_connection_graph (area);
- gdk_draw_pixmap (area->window,
- area->style->fg_gc[GTK_WIDGET_STATE (area)],
- connection_pixmap,
- 0, 0,
- 0, 0,
- area->allocation.width,
- area->allocation.height);
-}
-
-
-/**
- * Free entries in the value history.
- *
- * @param cls unused
- * @param key unused
- * @param value 'struct ValueHistory' to free
- * @return GNUNET_OK (continue iteration)
- */
-static int
-free_history (void *cls,
- const GNUNET_HashCode *key,
- void *value)
-{
- struct ValueHistory *vh = value;
-
- GNUNET_free (vh->subsystem);
- GNUNET_free (vh->name);
- GNUNET_free (vh);
- return GNUNET_OK;
-}
-
-
-/**
* Task run on shutdown.
*
* @param cls unused
@@ -421,9 +162,6 @@
{
GNUNET_STATISTICS_destroy (statistics, GNUNET_NO);
statistics = NULL;
- GNUNET_CONTAINER_multihashmap_iterate (stat_map, &free_history, NULL);
- GNUNET_CONTAINER_multihashmap_destroy (stat_map);
- stat_map = NULL;
}
@@ -440,11 +178,6 @@
GNUNET_SCHEDULER_cancel (connection_task);
connection_task = GNUNET_SCHEDULER_NO_TASK;
}
- if (NULL != connection_pixmap)
- {
- gdk_pixmap_unref (connection_pixmap);
- connection_pixmap = NULL;
- }
GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
}
@@ -456,17 +189,7 @@
static void
run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- static const struct
- {
- const char *subsystem;
- const char *name;
- } moma[] =
- {
- { "core", "entries in session map" },
- { NULL, NULL }
- };
GtkWidget *main_window;
- unsigned int i;
ml = cls;
statistics = GNUNET_STATISTICS_create ("gnunet-statistics-gtk",
@@ -477,29 +200,15 @@
_("Failed to initiate connection with statistics service\n"));
return;
}
- stat_map = GNUNET_CONTAINER_multihashmap_create (128);
GNUNET_GTK_set_icon_search_path ();
GNUNET_GTK_setup_nls ();
- refresh_delay = GNUNET_TIME_UNIT_SECONDS; /* fixme: make option / cmd-line
option */
- i = 0;
- while (moma[i].subsystem != NULL)
- {
- monitor (moma[i].subsystem,
- moma[i].name);
- i++;
- }
-
/* setup main window */
main_window = GTK_WIDGET (get_object ("GNUNET_STATISTICS_GTK_main_window"));
gtk_window_maximize (GTK_WINDOW (main_window));
GNUNET_GTK_tray_icon_create (GTK_WINDOW (main_window),
"gnunet-gtk" /* FIXME: different icon? */ ,
"gnunet-statistics-gtk");
-
- /* FIXME: only schedule this task if the respective tab is open!? */
- connection_task = GNUNET_SCHEDULER_add_now (&refresh_connections, NULL);
-
/* make GUI visible */
if (!tray_only)
{
Added: gnunet-gtk/src/statistics/gtk_statistics.c
===================================================================
--- gnunet-gtk/src/statistics/gtk_statistics.c (rev 0)
+++ gnunet-gtk/src/statistics/gtk_statistics.c 2011-12-08 21:55:58 UTC (rev
18522)
@@ -0,0 +1,266 @@
+/*
+ This file is part of GNUnet
+ (C) 2011 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+*/
+
+/**
+ * @file src/statistics/gtk_statistics.c
+ * @brief widget to display statistics
+ * @author Christian Grothoff
+ */
+#include "gnunet_gtk.h"
+#include "gtk_statistics.h"
+
+#define MAX_HISTORY 1280
+
+/**
+ * Information about a value we received.
+ */
+struct HistoricValue
+{
+ /**
+ * Time when the value was recorded.
+ */
+ uint64_t x;
+
+ /**
+ * A value we recorded.
+ */
+ uint64_t y;
+
+};
+
+/**
+ * Historic information we recorded for a value.
+ */
+struct ValueHistory
+{
+
+ /**
+ * Label for the subsystem.
+ */
+ char *label;
+
+ /**
+ * Color name.
+ */
+ char *color_name;
+
+ /**
+ * Recent values for this number.
+ */
+ struct HistoricValue history[MAX_HISTORY];
+
+ /**
+ * Last offset we wrote to in history.
+ */
+ unsigned int last_history_offset;
+
+ /**
+ * Number of valid entries in the history.
+ */
+ unsigned int history_size;
+};
+
+
+struct _GtkStatisticsPrivate
+{
+
+ /**
+ * Values we plot.
+ */
+ struct ValueHistory **values;
+
+ /**
+ * Size of the 'values' array.
+ */
+ unsigned int num_values;
+};
+
+
+static gboolean gtk_statistics_draw (GtkWidget *widget,
+ cairo_t *cr);
+
+static void gtk_statistics_finalize (GObject *object);
+
+
+G_DEFINE_TYPE (GtkStatistics, gtk_statistics, GTK_TYPE_MISC)
+
+
+static void
+gtk_statistics_class_init (GtkStatisticsClass *class)
+{
+ GObjectClass *gobject_class;
+ GtkWidgetClass *widget_class;
+
+ gobject_class = (GObjectClass*) class;
+ widget_class = (GtkWidgetClass*) class;
+
+ gobject_class->finalize = gtk_statistics_finalize;
+ widget_class->draw = gtk_statistics_draw;
+ g_type_class_add_private (class, sizeof (GtkStatisticsPrivate));
+}
+
+
+static void
+gtk_statistics_init (GtkStatistics *statistics)
+{
+ GtkStatisticsPrivate *priv;
+
+ statistics->priv = G_TYPE_INSTANCE_GET_PRIVATE (statistics,
+ GTK_TYPE_STATISTICS,
+ GtkStatisticsPrivate);
+ priv = statistics->priv;
+
+ gtk_widget_set_has_window (GTK_WIDGET (statistics), FALSE);
+ priv->values = NULL;
+ priv->num_values = 0;
+}
+
+
+/**
+ * gtk_statistics_new:
+ *
+ * Creates a new #GtkStatistics widget.
+ *
+ * Returns: the new #GtkStatistics widget.
+ */
+GtkWidget*
+gtk_statistics_new ()
+{
+ GtkStatisticsPrivate *priv;
+ GtkStatistics *statistics;
+
+ statistics = g_object_new (GTK_TYPE_STATISTICS, NULL);
+
+ priv = statistics->priv;
+ priv->values = NULL;
+ priv->num_values = 0;
+ return GTK_WIDGET (statistics);
+}
+
+
+/**
+ */
+void
+gtk_statistics_add_line (GtkStatistics *statistics,
+ const char *label,
+ const char *color_name)
+{
+ GtkStatisticsPrivate *priv;
+ struct ValueHistory *vh;
+
+ g_return_if_fail (GTK_IS_STATISTICS (statistics));
+ priv = statistics->priv;
+ priv->values = g_realloc (priv->values,
+ sizeof (struct ValueHistory*) * (1 +
priv->num_values));
+ priv->values[priv->num_values++] = vh = g_malloc (sizeof (struct
ValueHistory));
+ vh->label = strdup (label);
+ vh->color_name = strdup (color_name);
+}
+
+
+/**
+ */
+void
+gtk_statistics_update_value (GtkStatistics *statistics,
+ const char *label,
+ uint64_t x,
+ uint64_t y)
+{
+ GtkStatisticsPrivate *priv;
+ GtkWidget *widget;
+ struct ValueHistory *vh;
+ unsigned int i;
+
+ g_return_if_fail (GTK_IS_STATISTICS (statistics));
+ priv = statistics->priv;
+ for (i=0;i<priv->num_values;i++)
+ {
+ vh = priv->values[i];
+ if (0 != strcmp (label, vh->label))
+ continue;
+ if (++vh->last_history_offset == MAX_HISTORY)
+ vh->last_history_offset = 0;
+ if (vh->history_size < MAX_HISTORY)
+ vh->history_size++;
+ vh->history[vh->last_history_offset].x = x;
+ vh->history[vh->last_history_offset].y = y;
+
+ g_object_freeze_notify (G_OBJECT (statistics));
+ g_object_notify (G_OBJECT (statistics), "statistics-value");
+ g_object_thaw_notify (G_OBJECT (statistics));
+
+ widget = GTK_WIDGET (statistics);
+ if (gtk_widget_is_drawable (widget))
+ gtk_widget_queue_draw (widget);
+ }
+}
+
+
+static gboolean
+gtk_statistics_draw (GtkWidget *widget,
+ cairo_t *cr)
+{
+ GtkStatistics *statistics = GTK_STATISTICS (widget);
+ GtkStatisticsPrivate *priv = statistics->priv;
+
+ fprintf (stderr, "DRAW!\n");
+#if 0
+ gdk_color_parse (info[i].color_name, &color);
+ gdk_gc_set_foreground (gc, &color);
+#endif
+ cairo_translate(cr, 0, 7);
+
+ cairo_set_source_rgb(cr, 0, 0, 0);
+ cairo_paint(cr);
+
+ gint pos = priv->num_values;
+ gint rect = pos / 5;
+
+ cairo_set_source_rgb(cr, 0.2, 0.4, 0);
+
+ gint i;
+ for ( i = 1; i <= 20; i++) {
+ if (i > 20 - rect) {
+ cairo_set_source_rgb(cr, 0.6, 1.0, 0);
+ } else {
+ cairo_set_source_rgb(cr, 0.2, 0.4, 0);
+ }
+ cairo_rectangle(cr, 8, i*4, 30, 3);
+ cairo_rectangle(cr, 42, i*4, 30, 3);
+ cairo_fill(cr);
+ }
+ return FALSE;
+}
+
+
+static void
+gtk_statistics_finalize (GObject *object)
+{
+ GtkStatistics *label = GTK_STATISTICS (object);
+ GtkStatisticsPrivate *priv = label->priv;
+
+ g_free (priv->values);
+
+ G_OBJECT_CLASS (gtk_statistics_parent_class)->finalize (object);
+}
+
+
+/* end of gtk_statistics.c */
Added: gnunet-gtk/src/statistics/gtk_statistics.h
===================================================================
--- gnunet-gtk/src/statistics/gtk_statistics.h (rev 0)
+++ gnunet-gtk/src/statistics/gtk_statistics.h 2011-12-08 21:55:58 UTC (rev
18522)
@@ -0,0 +1,79 @@
+/*
+ This file is part of GNUnet.
+ (C) 2010, 2011 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file src/statistics/gtk_statistics.h
+ * @brief widget to display statistics
+ * @author Christian Grothoff
+ */
+#ifndef GTK_STATISTICS_H
+#define GTK_STATISTICS_H
+
+#include <stdint.h>
+#include <gtk/gtk.h>
+#include <cairo.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_STATISTICS (gtk_statistics_get_type ())
+#define GTK_STATISTICS(obj) (G_TYPE_CHECK_INSTANCE_CAST
((obj), GTK_TYPE_STATISTICS, GtkStatistics))
+#define GTK_STATISTICS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST
((klass), GTK_TYPE_STATISTICS, GtkStatisticsClass))
+#define GTK_IS_STATISTICS(obj) (G_TYPE_CHECK_INSTANCE_TYPE
((obj), GTK_TYPE_STATISTICS))
+#define GTK_IS_STATISTICS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE
((klass), GTK_TYPE_STATISTICS))
+#define GTK_STATISTICS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS
((obj), GTK_TYPE_STATISTICS, GtkStatisticsClass))
+
+typedef struct _GtkStatistics GtkStatistics;
+typedef struct _GtkStatisticsPrivate GtkStatisticsPrivate;
+typedef struct _GtkStatisticsClass GtkStatisticsClass;
+
+struct _GtkStatistics
+{
+ GtkMisc misc;
+
+ /*< private >*/
+ GtkStatisticsPrivate *priv;
+};
+
+struct _GtkStatisticsClass
+{
+ GtkMiscClass parent_class;
+
+ /* Padding for future expansion */
+ void (*_gtk_reserved1) (void);
+ void (*_gtk_reserved2) (void);
+ void (*_gtk_reserved3) (void);
+ void (*_gtk_reserved4) (void);
+};
+
+
+GType gtk_statistics_get_type (void) G_GNUC_CONST;
+GtkWidget* gtk_statistics_new (void);
+void gtk_statistics_add_line (GtkStatistics *statistics,
+ const char *label,
+ const char *color_name);
+void gtk_statistics_update_value (GtkStatistics *statistics,
+ const char *label,
+ uint64_t x,
+ uint64_t y);
+
+
+G_END_DECLS
+
+#endif
Added: gnunet-gtk/src/statistics/test.c
===================================================================
--- gnunet-gtk/src/statistics/test.c (rev 0)
+++ gnunet-gtk/src/statistics/test.c 2011-12-08 21:55:58 UTC (rev 18522)
@@ -0,0 +1,23 @@
+
+#include "gtk_statistics.h"
+
+int main (int argc, char ** argv)
+{
+ GtkWidget *window;
+ GtkWidget *statistics;
+
+ gtk_init(&argc, &argv);
+ window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title(GTK_WINDOW(window), "STATISTICS widget");
+ gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
+ gtk_window_set_default_size(GTK_WINDOW(window), 200, 200);
+ g_signal_connect(G_OBJECT(window), "destroy",
+ G_CALLBACK(gtk_main_quit), NULL);
+ statistics = gtk_statistics_new();
+ gtk_container_add(GTK_CONTAINER(window), statistics);
+ gtk_widget_show(statistics);
+ gtk_widget_show_all(window);
+ gtk_main();
+
+ return 0;
+}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r18522 - gnunet-gtk/src/statistics,
gnunet <=