medit/moo/mooutils/mooutils-gobject.h

171 lines
6.3 KiB
C
Raw Normal View History

2005-09-15 22:13:44 +00:00
/*
* mooutils-gobject.h
*
* Copyright (C) 2004-2006 by Yevgen Muntyan <muntyan@math.tamu.edu>
2005-09-15 22:13:44 +00:00
*
* This program 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 of the License, or
* (at your option) any later version.
*
* See COPYING file that comes with this distribution.
*/
#ifndef __MOO_UTILS_GOBJECT_H__
#define __MOO_UTILS_GOBJECT_H__
#include <gtk/gtkwidget.h>
2006-05-08 23:57:16 -05:00
#include <mooutils/mooclosure.h>
2005-09-15 22:13:44 +00:00
#ifndef G_GNUC_NULL_TERMINATED
#if __GNUC__ >= 4
#define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
#else
#define G_GNUC_NULL_TERMINATED
#endif
#endif
2005-09-15 22:13:44 +00:00
G_BEGIN_DECLS
/*****************************************************************************/
/* GType type
*/
2006-08-15 03:21:44 -05:00
#define MOO_TYPE_GTYPE (_moo_gtype_get_type())
GType _moo_gtype_get_type (void) G_GNUC_CONST;
GType _moo_value_get_gtype (const GValue *value);
2005-09-15 22:13:44 +00:00
/*****************************************************************************/
/* Converting values forth and back
*/
2006-08-15 03:21:44 -05:00
gboolean _moo_value_type_supported (GType type);
gboolean _moo_value_convert (const GValue *src,
2005-09-15 22:13:44 +00:00
GValue *dest);
2006-08-15 03:21:44 -05:00
gboolean _moo_value_equal (const GValue *a,
2005-09-15 22:13:44 +00:00
const GValue *b);
2006-08-15 03:21:44 -05:00
gboolean _moo_value_change_type (GValue *val,
2005-09-15 22:13:44 +00:00
GType new_type);
2006-08-15 03:21:44 -05:00
double _moo_value_convert_to_double (const GValue *val);
const char *_moo_value_convert_to_string (const GValue *val);
gboolean _moo_value_convert_from_string (const char *string,
GValue *val);
2005-09-15 22:13:44 +00:00
2006-08-15 03:21:44 -05:00
gboolean _moo_convert_string_to_bool (const char *string,
gboolean default_val);
2006-08-15 03:21:44 -05:00
int _moo_convert_string_to_int (const char *string,
int default_val);
2006-08-15 03:21:44 -05:00
const char *_moo_convert_bool_to_string (gboolean value);
const char *_moo_convert_int_to_string (int value);
2005-09-15 22:13:44 +00:00
/*****************************************************************************/
/* GParameter array manipulation
*/
2006-08-15 03:21:44 -05:00
void _moo_param_array_free (GParameter *array,
2005-09-15 22:13:44 +00:00
guint len);
/*****************************************************************************/
/* Signal that does not require class method
*/
2006-08-15 03:21:44 -05:00
guint _moo_signal_new_cb (const gchar *signal_name,
GType itype,
GSignalFlags signal_flags,
GCallback handler,
GSignalAccumulator accumulator,
gpointer accu_data,
GSignalCMarshaller c_marshaller,
GType return_type,
guint n_params,
...);
2005-09-15 22:13:44 +00:00
2006-05-08 23:57:16 -05:00
2005-09-15 22:13:44 +00:00
/*****************************************************************************/
2006-05-08 23:57:16 -05:00
/* Property watch
2005-09-15 22:13:44 +00:00
*/
2006-05-08 23:57:16 -05:00
typedef struct _MooObjectWatch MooObjectWatch;
typedef struct _MooObjectWatchClass MooObjectWatchClass;
typedef void (*MooObjectWatchNotify) (MooObjectWatch *watch);
struct _MooObjectWatch {
MooObjectWatchClass *klass;
MooObjectPtr *source;
MooObjectPtr *target;
GDestroyNotify notify;
gpointer notify_data;
guint id;
2005-09-15 22:13:44 +00:00
};
2006-05-08 23:57:16 -05:00
struct _MooObjectWatchClass {
MooObjectWatchNotify source_notify;
MooObjectWatchNotify target_notify;
MooObjectWatchNotify destroy;
2005-09-15 22:13:44 +00:00
};
2006-08-15 03:21:44 -05:00
MooObjectWatch *_moo_object_watch_alloc (gsize size,
MooObjectWatchClass *klass,
gpointer source,
gpointer target,
GDestroyNotify notify,
gpointer notify_data);
#define _moo_object_watch_new(Type_,klass_,src_,tgt_,notify_,data_) \
((Type_*) _moo_object_watch_alloc (sizeof (Type_), klass_, src_, tgt_, notify_, data_))
2005-11-20 03:59:01 +00:00
void moo_bind_sensitive (GtkWidget *toggle_btn,
GtkWidget **dependent,
int num_dependent,
gboolean invert);
2005-09-17 03:53:25 +00:00
guint moo_bind_bool_property (gpointer target,
const char *target_prop,
2005-09-17 03:53:25 +00:00
gpointer source,
const char *source_prop,
gboolean invert);
/*****************************************************************************/
/* Data store
*/
typedef struct _MooData MooData;
2006-08-15 03:21:44 -05:00
MooData *_moo_data_new (GHashFunc hash_func,
GEqualFunc key_equal_func,
GDestroyNotify key_destroy_func);
/* these accept NULL */
2006-08-15 03:21:44 -05:00
void _moo_data_unref (MooData *data);
#define _moo_data_destroy _moo_data_unref
2006-08-15 03:21:44 -05:00
void _moo_data_insert_value (MooData *data,
gpointer key,
const GValue *value);
2006-08-15 03:21:44 -05:00
void _moo_data_insert_ptr (MooData *data,
gpointer key,
gpointer value,
GDestroyNotify destroy);
2006-08-15 03:21:44 -05:00
void _moo_data_remove (MooData *data,
gpointer key);
2006-08-15 03:21:44 -05:00
void _moo_data_clear (MooData *data);
/* dest must not be initialized */
2006-08-15 03:21:44 -05:00
gboolean _moo_data_get_value (MooData *data,
gpointer key,
GValue *dest);
2006-08-15 03:21:44 -05:00
gpointer _moo_data_get_ptr (MooData *data,
gpointer key);
2005-09-15 22:13:44 +00:00
G_END_DECLS
#endif /* __MOO_UTILS_GOBJECT_H__ */