medit/moo/moocpp/gobjtypes-glib.h

95 lines
4.2 KiB
C
Raw Normal View History

2016-01-02 04:31:23 -08:00
/*
2016-01-17 01:31:00 -08:00
* moocpp/gobjtypes-glib.h
2016-01-02 04:31:23 -08:00
*
* Copyright (C) 2004-2016 by Yevgen Muntyan <emuntyan@users.sourceforge.net>
*
* 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.
*
* You should have received a copy of the GNU Lesser General Public
* License along with medit. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
2016-01-10 01:12:50 -08:00
#ifdef __cplusplus
2016-01-02 04:31:23 -08:00
#include <glib-object.h>
#include <mooglib/moo-glib.h>
#include "moocpp/gobjptr.h"
#include <stdarg.h>
2016-01-17 01:06:27 -08:00
#define MOO_GOBJ_TYPEDEFS(CppObject, CObject) \
2016-01-17 03:49:15 -08:00
using CppObject = ::moo::gobj_ref<CObject>; \
using CppObject##Ptr = ::moo::gobj_ptr<CObject>; \
using CppObject##RawPtr = ::moo::gobj_raw_ptr<CObject>; \
using Const##CppObject##Ptr = ::moo::gobj_raw_ptr<const CObject>; \
2016-01-17 01:06:27 -08:00
#define MOO_DECLARE_CUSTOM_GOBJ_TYPE(CObject) \
namespace moo { \
template<> class gobj_ref<CObject>; \
}
#define MOO_REGISTER_CUSTOM_GOBJ_TYPE(CObject) \
static_assert(sizeof(moo::gobj_ref<CObject>) == sizeof(void*), \
"gobj_ref must be bit-compatible with a raw pointer, " \
"otherwise operator& will break"); \
2016-01-02 04:31:23 -08:00
namespace moo {
2016-01-04 03:56:42 -08:00
///////////////////////////////////////////////////////////////////////////////////////////
//
// GObject
//
template<>
2016-01-04 09:56:33 -08:00
class gobj_ref<GObject> : public gobj_ref_base
2016-01-04 03:56:42 -08:00
{
public:
2016-01-04 09:56:33 -08:00
MOO_DEFINE_GOBJREF_METHODS_IMPL(GObject, gobj_ref_base)
2016-01-04 03:56:42 -08:00
2016-01-17 01:06:27 -08:00
gulong connect (const char* detailed_signal, GCallback c_handler, void* data);
gulong connect_swapped (const char* detailed_signal, GCallback c_handler, void* data);
void signal_emit_by_name (const char* detailed_signal, ...);
void signal_emit (guint signal_id, GQuark detail, ...);
2016-01-04 03:56:42 -08:00
2016-01-17 00:04:49 -08:00
bool signal_has_handler_pending (guint signal_id, GQuark detail, bool may_be_blocked);
gulong signal_connect_closure_by_id (guint signal_id, GQuark detail, GClosure* closure, bool after);
gulong signal_connect_closure (const char* detailed_signal, GClosure* closure, bool after);
gulong signal_connect_data (const char* detailed_signal, GCallback c_handler, gpointer data, GClosureNotify destroy_data, GConnectFlags connect_flags);
void signal_handler_block (gulong handler_id);
void signal_handler_unblock (gulong handler_id);
void signal_handler_disconnect (gulong handler_id);
bool signal_handler_is_connected (gulong handler_id);
gulong signal_handler_find (GSignalMatchType mask, guint signal_id, GQuark detail, GClosure* closure, gpointer func, gpointer data);
guint signal_handlers_block_matched (GSignalMatchType mask, guint signal_id, GQuark detail, GClosure* closure, gpointer func, gpointer data);
guint signal_handlers_unblock_matched (GSignalMatchType mask, guint signal_id, GQuark detail, GClosure* closure, gpointer func, gpointer data);
guint signal_handlers_disconnect_matched (GSignalMatchType mask, guint signal_id, GQuark detail, GClosure* closure, gpointer func, gpointer data);
2016-01-04 03:56:42 -08:00
void set_data (const char* key, gpointer value);
2016-01-17 00:04:49 -08:00
void set_data_full (const char* key, gpointer data, GDestroyNotify destroy);
2016-01-04 03:56:42 -08:00
void set (const char* first_prop, ...) G_GNUC_NULL_TERMINATED;
void set_property (const char* property_name, const GValue* value);
void notify (const char* property_name);
void freeze_notify ();
void thaw_notify ();
};
2016-01-04 09:56:33 -08:00
namespace g {
MOO_GOBJ_TYPEDEFS(Object, GObject);
} // namespace g
2016-01-02 04:31:23 -08:00
} // namespace moo
2016-01-10 01:12:50 -08:00
#endif // __cplusplus