summaryrefslogtreecommitdiff
path: root/gedit/gedit-message-bus.h
blob: b60eabd0c3901b9f5485a92803d74376e989332f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#ifndef __GEDIT_MESSAGE_BUS_H__
#define __GEDIT_MESSAGE_BUS_H__

#include <glib-object.h>
#include <gedit/gedit-message.h>
#include <gedit/gedit-message-type.h>

G_BEGIN_DECLS

#define GEDIT_TYPE_MESSAGE_BUS			(gedit_message_bus_get_type ())
#define GEDIT_MESSAGE_BUS(obj)			(G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_MESSAGE_BUS, GeditMessageBus))
#define GEDIT_MESSAGE_BUS_CONST(obj)		(G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_MESSAGE_BUS, GeditMessageBus const))
#define GEDIT_MESSAGE_BUS_CLASS(klass)		(G_TYPE_CHECK_CLASS_CAST ((klass), GEDIT_TYPE_MESSAGE_BUS, GeditMessageBusClass))
#define GEDIT_IS_MESSAGE_BUS(obj)		(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEDIT_TYPE_MESSAGE_BUS))
#define GEDIT_IS_MESSAGE_BUS_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_MESSAGE_BUS))
#define GEDIT_MESSAGE_BUS_GET_CLASS(obj)	(G_TYPE_INSTANCE_GET_CLASS ((obj), GEDIT_TYPE_MESSAGE_BUS, GeditMessageBusClass))

typedef struct _GeditMessageBus		GeditMessageBus;
typedef struct _GeditMessageBusClass	GeditMessageBusClass;
typedef struct _GeditMessageBusPrivate	GeditMessageBusPrivate;

struct _GeditMessageBus {
	GObject parent;
	
	GeditMessageBusPrivate *priv;
};

struct _GeditMessageBusClass {
	GObjectClass parent_class;
	
	void (*dispatch)		(GeditMessageBus  *bus,
					 GeditMessage     *message);
	void (*registered)		(GeditMessageBus  *bus,
					 GeditMessageType *message_type);
	void (*unregistered)		(GeditMessageBus  *bus,
					 GeditMessageType *message_type);
};

typedef void (* GeditMessageCallback) 	(GeditMessageBus *bus,
					 GeditMessage	 *message,
					 gpointer	  userdata);

typedef void (* GeditMessageBusForeach) (GeditMessageType *message_type,
					 gpointer	   userdata);

GType gedit_message_bus_get_type (void) G_GNUC_CONST;

GeditMessageBus *gedit_message_bus_get_default	(void);
GeditMessageBus *gedit_message_bus_new		(void);

/* registering messages */
GeditMessageType *gedit_message_bus_lookup	(GeditMessageBus 	*bus,
						 const gchar		*object_path,
						 const gchar		*method);
GeditMessageType *gedit_message_bus_register	(GeditMessageBus		*bus,
					   	 const gchar 		*object_path,
					  	 const gchar		*method,
					  	 guint		 	 num_optional,
					  	 ...) G_GNUC_NULL_TERMINATED;

void gedit_message_bus_unregister	  (GeditMessageBus	*bus,
					   GeditMessageType	*message_type);

void gedit_message_bus_unregister_all	  (GeditMessageBus	*bus,
					   const gchar		*object_path);

gboolean gedit_message_bus_is_registered  (GeditMessageBus	*bus,
					   const gchar		*object_path,
					   const gchar		*method);

void gedit_message_bus_foreach		  (GeditMessageBus        *bus,
					   GeditMessageBusForeach  func,
					   gpointer		   userdata);


/* connecting to message events */		   
guint gedit_message_bus_connect	 	  (GeditMessageBus	*bus, 
					   const gchar		*object_path,
					   const gchar		*method,
					   GeditMessageCallback	 callback,
					   gpointer		 userdata,
					   GDestroyNotify        destroy_data);

void gedit_message_bus_disconnect	  (GeditMessageBus	*bus,
					   guint		 id);

void gedit_message_bus_disconnect_by_func (GeditMessageBus	*bus,
					   const gchar		*object_path,
					   const gchar		*method,
					   GeditMessageCallback	 callback,
					   gpointer		 userdata);

/* blocking message event callbacks */
void gedit_message_bus_block		  (GeditMessageBus	*bus,
					   guint		 id);
void gedit_message_bus_block_by_func	  (GeditMessageBus	*bus,
					   const gchar		*object_path,
					   const gchar		*method,
					   GeditMessageCallback	 callback,
					   gpointer		 userdata);

void gedit_message_bus_unblock		  (GeditMessageBus	*bus,
					   guint		 id);
void gedit_message_bus_unblock_by_func	  (GeditMessageBus	*bus,
					   const gchar		*object_path,
					   const gchar		*method,
					   GeditMessageCallback	 callback,
					   gpointer		 userdata);

/* sending messages */
void gedit_message_bus_send_message	  (GeditMessageBus	*bus,
					   GeditMessage		*message);
void gedit_message_bus_send_message_sync  (GeditMessageBus	*bus,
					   GeditMessage		*message);
					  
void gedit_message_bus_send		  (GeditMessageBus	*bus,
					   const gchar		*object_path,
					   const gchar		*method,
					   ...) G_GNUC_NULL_TERMINATED;
GeditMessage *gedit_message_bus_send_sync (GeditMessageBus	*bus,
					   const gchar		*object_path,
					   const gchar		*method,
					   ...) G_GNUC_NULL_TERMINATED;

G_END_DECLS

#endif /* __GEDIT_MESSAGE_BUS_H__ */

// ex:ts=8:noet: