New file.

2000-11-22  Martin Baulig  <martin@home-of-linux.org>

	* lib/glibtop-server.c: New file.

	* lib/test-backends.c: New file.
	* lib/Makefile.am: Build test-backends test program.

	* lib/init-backends.c: Port this to libxml 2.

	* configure.in: Make this really work.
	* acinclude.m4: Removed the xml stuff.
	* Makefile.am (SUBDIRS): Put lib in front of sysdeps and backends.
This commit is contained in:
Martin Baulig
2000-11-22 20:58:15 +00:00
committed by Martin Baulig
parent 81b009733e
commit cee38c53bc
10 changed files with 323 additions and 84 deletions

View File

@@ -25,6 +25,9 @@
#include <glibtop.h>
#include <gobject/gsignal.h>
#include <gobject/gvaluetypes.h>
static void glibtop_client_class_init (glibtop_client_class *klass);
static void glibtop_client_init (glibtop_client *client);
static void glibtop_client_finalize (GObject *object);
@@ -38,6 +41,14 @@ struct _glibtop_client_private
{
};
enum {
GLIBTOP_CLIENT_SIGNAL_ERROR,
GLIBTOP_CLIENT_SIGNAL_WARNING,
LAST_SIGNAL
};
static guint glibtop_client_signals [LAST_SIGNAL] = { 0 };
GType
glibtop_client_get_type (void)
{
@@ -63,14 +74,103 @@ glibtop_client_get_type (void)
return glibtop_client_type;
}
static void
glibtop_client_error_handler (glibtop_client *client, GError *error)
{
g_return_if_fail (GLIBTOP_IS_CLIENT (client));
if (error == NULL)
return;
g_error ("%s (%d): %s", g_quark_to_string (error->domain),
error->code, error->message);
}
static void
glibtop_client_warning_handler (glibtop_client *client, GError *error)
{
g_return_if_fail (GLIBTOP_IS_CLIENT (client));
if (error == NULL)
return;
g_warning ("%s (%d): %s", g_quark_to_string (error->domain),
error->code, error->message);
}
void
glibtop_client_marshal_VOID__POINTER (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data)
{
typedef void (*GSignalFunc_VOID__POINTER) (gpointer data1,
gpointer arg_1,
gpointer data2);
register GSignalFunc_VOID__POINTER callback;
register GCClosure *cc = (GCClosure*) closure;
register gpointer data1, data2;
g_return_if_fail (n_param_values >= 2);
if (G_CCLOSURE_SWAP_DATA (closure))
{
data1 = closure->data;
data2 = g_value_get_as_pointer (param_values + 0);
}
else
{
data1 = g_value_get_as_pointer (param_values + 0);
data2 = closure->data;
}
callback = (GSignalFunc_VOID__POINTER) (marshal_data ? marshal_data : cc->callback);
callback (data1,
g_value_get_as_pointer (param_values + 1),
data2);
}
static void
glibtop_client_class_init (glibtop_client_class *class)
{
GObjectClass *gobject_class;
GType *param_types;
GClosure *closure;
gobject_class = (GObjectClass *) class;
parent_class = g_type_class_ref (G_TYPE_OBJECT);
closure = g_signal_type_closure_new (G_TYPE_FROM_CLASS (class),
G_STRUCT_OFFSET (glibtop_client_class,
error));
param_types = g_new0 (GType, 1);
param_types [0] = G_TYPE_POINTER;
glibtop_client_signals [GLIBTOP_CLIENT_SIGNAL_ERROR] =
g_signal_newv ("error", G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST, closure, NULL,
glibtop_client_marshal_VOID__POINTER,
G_TYPE_NONE, 1, param_types);
closure = g_signal_type_closure_new (G_TYPE_FROM_CLASS (class),
G_STRUCT_OFFSET (glibtop_client_class,
warning));
glibtop_client_signals [GLIBTOP_CLIENT_SIGNAL_WARNING] =
g_signal_newv ("warning", G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST, closure, NULL,
glibtop_client_marshal_VOID__POINTER,
G_TYPE_NONE, 1, param_types);
g_free (param_types);
class->error = glibtop_client_error_handler;
class->warning = glibtop_client_warning_handler;
gobject_class->finalize = glibtop_client_finalize;
}
@@ -104,3 +204,51 @@ glibtop_client_new (void)
{
return g_object_new (GLIBTOP_TYPE_CLIENT, NULL);
}
void
glibtop_client_propagate_error (glibtop_client *client, GError *error)
{
GValue params [2] = { { 0, }, { 0, } };
g_return_if_fail (GLIBTOP_IS_CLIENT (client));
if (error == NULL)
return;
g_value_init (params, GLIBTOP_CLIENT_TYPE (client));
g_value_set_object (params, G_OBJECT (client));
g_value_init (params + 1, G_TYPE_POINTER);
g_value_set_pointer (params + 1, error);
g_signal_emitv (params,
glibtop_client_signals [GLIBTOP_CLIENT_SIGNAL_ERROR],
0, NULL);
g_value_unset (params + 1);
g_value_unset (params + 0);
}
void
glibtop_client_propagate_warning (glibtop_client *client, GError *error)
{
GValue params [2] = { { 0, }, { 0, } };
g_return_if_fail (GLIBTOP_IS_CLIENT (client));
if (error == NULL)
return;
g_value_init (params, GLIBTOP_CLIENT_TYPE (client));
g_value_set_object (params, G_OBJECT (client));
g_value_init (params + 1, G_TYPE_POINTER);
g_value_set_pointer (params + 1, error);
g_signal_emitv (params,
glibtop_client_signals [GLIBTOP_CLIENT_SIGNAL_WARNING],
0, NULL);
g_value_unset (params + 1);
g_value_unset (params + 0);
}