2005-09-15 22:13:44 +00:00
|
|
|
/*
|
|
|
|
* mooutils-gobject.h
|
|
|
|
*
|
2010-12-21 20:15:45 -08:00
|
|
|
* Copyright (C) 2004-2010 by Yevgen Muntyan <emuntyan@users.sourceforge.net>
|
2005-09-15 22:13:44 +00:00
|
|
|
*
|
2008-09-05 17:20:50 -05:00
|
|
|
* This file is part of medit. medit is free software; you can
|
|
|
|
* redistribute it and/or modify it under the terms of the
|
|
|
|
* GNU Lesser General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2.1 of the License,
|
|
|
|
* or (at your option) any later version.
|
2005-09-15 22:13:44 +00:00
|
|
|
*
|
2008-09-05 17:20:50 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with medit. If not, see <http://www.gnu.org/licenses/>.
|
2005-09-15 22:13:44 +00:00
|
|
|
*/
|
|
|
|
|
2007-04-12 10:31:28 -05:00
|
|
|
#ifndef MOO_UTILS_GOBJECT_H
|
|
|
|
#define MOO_UTILS_GOBJECT_H
|
2005-09-15 22:13:44 +00:00
|
|
|
|
2011-09-26 00:41:51 -07:00
|
|
|
#include <gtk/gtk.h>
|
2006-05-08 23:57:16 -05:00
|
|
|
#include <mooutils/mooclosure.h>
|
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,
|
2005-11-24 17:36:07 +00:00
|
|
|
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,
|
2005-10-13 14:08:18 +00:00
|
|
|
gboolean default_val);
|
2006-08-15 03:21:44 -05:00
|
|
|
int _moo_convert_string_to_int (const char *string,
|
2005-10-13 14:08:18 +00:00
|
|
|
int default_val);
|
2008-11-06 22:33:06 -06:00
|
|
|
guint _moo_convert_string_to_uint (const char *string,
|
|
|
|
guint 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-10-13 14:08:18 +00:00
|
|
|
|
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
|
|
|
|
2005-10-13 14:08:18 +00:00
|
|
|
void moo_bind_sensitive (GtkWidget *toggle_btn,
|
2008-08-30 03:00:08 -05:00
|
|
|
GtkWidget *dependent,
|
2005-09-17 02:14:10 +00:00
|
|
|
gboolean invert);
|
|
|
|
|
2005-09-17 03:53:25 +00:00
|
|
|
guint moo_bind_bool_property (gpointer target,
|
2005-09-17 02:14:10 +00:00
|
|
|
const char *target_prop,
|
2005-09-17 03:53:25 +00:00
|
|
|
gpointer source,
|
2005-09-17 02:14:10 +00:00
|
|
|
const char *source_prop,
|
|
|
|
gboolean invert);
|
|
|
|
|
|
|
|
|
2005-12-01 22:04:41 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* Data store
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct _MooData MooData;
|
|
|
|
|
2006-08-15 03:21:44 -05:00
|
|
|
MooData *_moo_data_new (GHashFunc hash_func,
|
2005-12-01 22:04:41 +00:00
|
|
|
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
|
2005-12-01 22:04:41 +00:00
|
|
|
|
2006-08-15 03:21:44 -05:00
|
|
|
void _moo_data_insert_value (MooData *data,
|
2005-12-01 22:04:41 +00:00
|
|
|
gpointer key,
|
|
|
|
const GValue *value);
|
2006-08-15 03:21:44 -05:00
|
|
|
void _moo_data_insert_ptr (MooData *data,
|
2005-12-01 22:04:41 +00:00
|
|
|
gpointer key,
|
|
|
|
gpointer value,
|
|
|
|
GDestroyNotify destroy);
|
|
|
|
|
2006-08-15 03:21:44 -05:00
|
|
|
void _moo_data_remove (MooData *data,
|
2005-12-01 22:04:41 +00:00
|
|
|
gpointer key);
|
2006-08-15 03:21:44 -05:00
|
|
|
void _moo_data_clear (MooData *data);
|
2005-12-01 22:04:41 +00:00
|
|
|
|
|
|
|
/* dest must not be initialized */
|
2006-08-15 03:21:44 -05:00
|
|
|
gboolean _moo_data_get_value (MooData *data,
|
2005-12-01 22:04:41 +00:00
|
|
|
gpointer key,
|
|
|
|
GValue *dest);
|
2006-08-15 03:21:44 -05:00
|
|
|
gpointer _moo_data_get_ptr (MooData *data,
|
2005-12-01 22:04:41 +00:00
|
|
|
gpointer key);
|
|
|
|
|
|
|
|
|
2005-09-15 22:13:44 +00:00
|
|
|
G_END_DECLS
|
|
|
|
|
2007-04-12 10:31:28 -05:00
|
|
|
#endif /* MOO_UTILS_GOBJECT_H */
|