From 03077752f8a7b86e1008ca85d726690b0c8fac2f Mon Sep 17 00:00:00 2001 From: Eitan Isaacson Date: Wed, 8 Apr 2009 14:25:50 +0300 Subject: gtypified the interests enum. --- libindicate/Makefile.am | 44 ++++++++++++++++++++++++++++++++++++++++++-- libindicate/interests.h | 5 ++--- libindicate/server.h | 4 ---- 3 files changed, 44 insertions(+), 9 deletions(-) (limited to 'libindicate') diff --git a/libindicate/Makefile.am b/libindicate/Makefile.am index c1900a6..91072f7 100644 --- a/libindicate/Makefile.am +++ b/libindicate/Makefile.am @@ -1,3 +1,6 @@ +MARSHAL_PREFIX = indicate_marshal +MARSHAL_FILE = indicate-marshal +ENUM_FILE = indicate-enum-types INCLUDES= \ -DG_LOG_DOMAIN=\"libindicate\" @@ -14,7 +17,9 @@ BUILT_SOURCES = \ dbus-listener-server.h \ dbus-listener-client.h \ listener-marshal.c \ - listener-marshal.h + listener-marshal.h \ + $(ENUM_FILE).h \ + $(ENUM_FILE).c lib_LTLIBRARIES = \ libindicate.la @@ -26,7 +31,8 @@ indicate_headers = \ indicator-message.h \ listener.h \ server.h \ - interests.h + interests.h \ + $(ENUM_FILE).h libindicateinclude_HEADERS = \ $(indicate_headers) @@ -37,6 +43,7 @@ libindicate_la_SOURCES = \ dbus-indicate-client.h \ dbus-listener-server.h \ dbus-listener-client.h \ + indicate-enum-types.c \ server.c \ listener.c \ listener-marshal.c \ @@ -97,6 +104,39 @@ listener-marshal.c: $(srcdir)/listener-marshal.list pkgconfig_DATA = indicate.pc pkgconfigdir = $(libdir)/pkgconfig +$(ENUM_FILE).h: s-enum-types-h + @true +s-enum-types-h: $(indicate_headers) Makefile + ( cd $(srcdir) && glib-mkenums \ + --fhead "#ifndef _INDICATE_ENUM_TYPES_H_\n#define _INDICATE_ENUM_TYPES_H_\n\n#include \n\nG_BEGIN_DECLS\n" \ + --fprod "/* enumerations from \"@filename@\" */\n" \ + --vhead "GType @enum_name@_get_type(void);\n#define INDICATE_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\n" \ + --ftail "G_END_DECLS\n\n#endif /* _INDICATE_ENUM_TYPES_H_ */" \ + interests.h ) > tmp-$(ENUM_FILE).h \ + && (cmp -s tmp-$(ENUM_FILE).h $(ENUM_FILE).h || cp tmp-$(ENUM_FILE).h $(ENUM_FILE).h ) \ + && rm -f tmp-$(ENUM_FILE).h \ + && echo timestamp > $(@F) + +$(ENUM_FILE).c: s-enum-types-c + @true +s-enum-types-c: $(indicate_headers) Makefile + ( cd $(srcdir) && glib-mkenums \ + --fhead "#include \n#include " \ + --fprod "\n/* enumerations from \"@filename@\" */" \ + --vhead "GType\n@enum_name@_get_type (void)\n{\n static GType etype = 0;\n if (etype == 0) {\n static const G@Type@Value values[] = {" \ + --vprod " { @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" }," \ + --vtail " { 0, NULL, NULL }\n };\n etype = g_@type@_register_static (\"@EnumName@\", values);\n }\n return etype;\n}\n" \ + interests.h ) > tmp-$(ENUM_FILE).c \ + && (cmp -s tmp-$(ENUM_FILE).c $(ENUM_FILE).c || cp tmp-$(ENUM_FILE).c $(ENUM_FILE).c ) \ + && rm -f tmp-$(ENUM_FILE).c \ + && echo timestamp > $(@F) + +CLEANFILES = \ + $(ENUM_FILE).c \ + $(ENUM_FILE).h \ + s-enum-types-c \ + s-enum-types-h + if USE_GIR gobjectintrospection_gir_DATA = \ diff --git a/libindicate/interests.h b/libindicate/interests.h index 70c52d9..1c6215a 100644 --- a/libindicate/interests.h +++ b/libindicate/interests.h @@ -34,8 +34,7 @@ License version 3 and version 2.1 along with this program. If not, see G_BEGIN_DECLS -typedef enum _IndicateInterests IndicateInterests; -enum _IndicateInterests { +typedef enum { INDICATE_INTEREST_NONE, /**< We're of no interest */ INDICATE_INTEREST_SERVER_DISPLAY, /**< Displays the server's existance to the user */ INDICATE_INTEREST_SERVER_SIGNAL, /**< Will send signals to the server to be displayed */ @@ -43,7 +42,7 @@ enum _IndicateInterests { INDICATE_INTEREST_INDICATOR_SIGNAL, /**< Will return signals based on individual indicators being responded to */ INDICATE_INTEREST_INDICATOR_COUNT, /**< Only displays a count of the indicators */ INDICATE_INTEREST_LAST /**< Makes merges and counting easier */ -}; +} IndicateInterests; G_END_DECLS diff --git a/libindicate/server.h b/libindicate/server.h index cfb4334..5db46f9 100644 --- a/libindicate/server.h +++ b/libindicate/server.h @@ -124,10 +124,6 @@ void indicate_server_remove_indicator (IndicateServer * server, IndicateIndicato IndicateServer * indicate_server_ref_default (void); void indicate_server_set_default (IndicateServer * server); -/* Check to see if there is someone, out there, who likes this */ -gboolean indicate_server_check_interest (IndicateServer * server, IndicateInterests interest); - - /* Signal emission functions for sub-classes of the server */ void indicate_server_emit_indicator_added (IndicateServer *server, guint id, const gchar *type); void indicate_server_emit_indicator_removed (IndicateServer *server, guint id, const gchar *type); -- cgit v1.2.3 From a300f6cd4ed76fbc68c379bcc6729aa71cfc1759 Mon Sep 17 00:00:00 2001 From: Eitan Isaacson Date: Wed, 8 Apr 2009 16:47:46 +0300 Subject: GBoxed IndicateListenerServer --- libindicate/listener.c | 37 +++++++++++++++++++++++++++++++++++++ libindicate/listener.h | 5 +++++ 2 files changed, 42 insertions(+) (limited to 'libindicate') diff --git a/libindicate/listener.c b/libindicate/listener.c index 381a5f9..aa36d18 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -1024,3 +1024,40 @@ indicate_listener_server_check_interest (IndicateListener * listener, IndicateLi return server->interests[interest]; } +GType +indicate_listener_server_get_gtype (void) +{ + static GType our_type = 0; + + if (our_type == 0) + our_type = g_boxed_type_register_static ("IndicateListenerServer", + (GBoxedCopyFunc) indicate_listener_server_copy, + (GBoxedFreeFunc) indicate_listener_server_free); + + return our_type; +} + +IndicateListenerServer * +indicate_listener_server_copy (const IndicateListenerServer *listener_server) +{ + IndicateListenerServer *retval; + retval = (IndicateListenerServer *)g_memdup ( + listener_server, + sizeof (IndicateListenerServer)); + + g_object_ref (retval->proxy); + dbus_g_connection_ref (retval->connection); + g_stpcpy (retval->name, listener_server->name); + + return retval; +} + +void +indicate_listener_server_free (IndicateListenerServer *listener_server) +{ + g_free (listener_server->name); + g_object_unref (listener_server->proxy); + dbus_g_connection_unref (listener_server->connection); + + g_free (listener_server); +} diff --git a/libindicate/listener.h b/libindicate/listener.h index 0fdaa9b..5a1e991 100644 --- a/libindicate/listener.h +++ b/libindicate/listener.h @@ -59,6 +59,11 @@ G_BEGIN_DECLS #define INDICATE_LISTENER_INDICATOR_ID(indicator) (indicate_listener_indicator_get_id(indicator)) typedef struct _IndicateListenerServer IndicateListenerServer; +#define INDICATE_TYPE_LISTENER_SERVER (indicate_listener_server_get_gtype ()) +GType indicate_listener_server_get_gtype (void) G_GNUC_CONST; +IndicateListenerServer *indicate_listener_server_copy (const IndicateListenerServer *listener_server); +void indicate_listener_server_free (IndicateListenerServer *listener_server); + typedef struct _IndicateListenerIndicator IndicateListenerIndicator; typedef struct _IndicateListener IndicateListener; -- cgit v1.2.3 From 8f4019b3cc4f01cc2f37473c548dc8986d151586 Mon Sep 17 00:00:00 2001 From: Eitan Isaacson Date: Wed, 8 Apr 2009 18:14:27 +0300 Subject: Changed marshallers to GBoxed for IndicatorListenerServer. Make copy/free functions empty for now. --- libindicate/listener-marshal.list | 6 +++--- libindicate/listener.c | 38 ++++++++++++-------------------------- 2 files changed, 15 insertions(+), 29 deletions(-) (limited to 'libindicate') diff --git a/libindicate/listener-marshal.list b/libindicate/listener-marshal.list index a3d20a9..37dade3 100644 --- a/libindicate/listener-marshal.list +++ b/libindicate/listener-marshal.list @@ -28,8 +28,8 @@ # IndicatorAdded, IndicatorRemoved, IndicatorModified VOID:UINT,STRING # Local indicator_added, indicator_removed -VOID:POINTER,POINTER,STRING +VOID:BOXED,POINTER,STRING # Local indicator_modified -VOID:POINTER,POINTER,STRING,STRING +VOID:BOXED,POINTER,STRING,STRING # Local server_added and server_removed -VOID:POINTER,STRING +VOID:BOXED,STRING diff --git a/libindicate/listener.c b/libindicate/listener.c index aa36d18..3a3c34b 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -153,36 +153,36 @@ indicate_listener_class_init (IndicateListenerClass * class) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (IndicateListenerClass, indicator_added), NULL, NULL, - _indicate_listener_marshal_VOID__POINTER_POINTER_STRING, - G_TYPE_NONE, 3, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_STRING); + _indicate_listener_marshal_VOID__BOXED_POINTER_STRING, + G_TYPE_NONE, 3, INDICATE_TYPE_LISTENER_SERVER, G_TYPE_POINTER, G_TYPE_STRING); signals[INDICATOR_REMOVED] = g_signal_new(INDICATE_LISTENER_SIGNAL_INDICATOR_REMOVED, G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (IndicateListenerClass, indicator_removed), NULL, NULL, - _indicate_listener_marshal_VOID__POINTER_POINTER_STRING, - G_TYPE_NONE, 3, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_STRING); + _indicate_listener_marshal_VOID__BOXED_POINTER_STRING, + G_TYPE_NONE, 3, INDICATE_TYPE_LISTENER_SERVER, G_TYPE_POINTER, G_TYPE_STRING); signals[INDICATOR_MODIFIED] = g_signal_new(INDICATE_LISTENER_SIGNAL_INDICATOR_MODIFIED, G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (IndicateListenerClass, indicator_modified), NULL, NULL, - _indicate_listener_marshal_VOID__POINTER_POINTER_STRING_STRING, - G_TYPE_NONE, 4, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_STRING); + _indicate_listener_marshal_VOID__BOXED_POINTER_STRING_STRING, + G_TYPE_NONE, 4, INDICATE_TYPE_LISTENER_SERVER, G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_STRING); signals[SERVER_ADDED] = g_signal_new(INDICATE_LISTENER_SIGNAL_SERVER_ADDED, G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (IndicateListenerClass, server_added), NULL, NULL, - _indicate_listener_marshal_VOID__POINTER_STRING, - G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_STRING); + _indicate_listener_marshal_VOID__BOXED_STRING, + G_TYPE_NONE, 2, INDICATE_TYPE_LISTENER_SERVER, G_TYPE_STRING); signals[SERVER_REMOVED] = g_signal_new(INDICATE_LISTENER_SIGNAL_SERVER_REMOVED, G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (IndicateListenerClass, server_removed), NULL, NULL, - _indicate_listener_marshal_VOID__POINTER_STRING, - G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_STRING); + _indicate_listener_marshal_VOID__BOXED_STRING, + G_TYPE_NONE, 2, INDICATE_TYPE_LISTENER_SERVER, G_TYPE_STRING); dbus_g_object_register_marshaller(_indicate_listener_marshal_VOID__UINT_STRING, G_TYPE_NONE, @@ -686,7 +686,7 @@ proxy_indicator_modified (DBusGProxy * proxy, guint id, const gchar * property, return; } - g_signal_emit(proxyt->listener, signals[INDICATOR_MODIFIED], 0, &proxyt->server, GUINT_TO_POINTER(id), type, property, TRUE); + g_signal_emit(proxyt->listener, signals[INDICATOR_MODIFIED], 0, proxyt->server, GUINT_TO_POINTER(id), type, property, TRUE); return; } @@ -1040,24 +1040,10 @@ indicate_listener_server_get_gtype (void) IndicateListenerServer * indicate_listener_server_copy (const IndicateListenerServer *listener_server) { - IndicateListenerServer *retval; - retval = (IndicateListenerServer *)g_memdup ( - listener_server, - sizeof (IndicateListenerServer)); - - g_object_ref (retval->proxy); - dbus_g_connection_ref (retval->connection); - g_stpcpy (retval->name, listener_server->name); - - return retval; + return listener_server; } void indicate_listener_server_free (IndicateListenerServer *listener_server) { - g_free (listener_server->name); - g_object_unref (listener_server->proxy); - dbus_g_connection_unref (listener_server->connection); - - g_free (listener_server); } -- cgit v1.2.3 From a3188d21d2682bf371e9e76638c26550d95a84c9 Mon Sep 17 00:00:00 2001 From: Eitan Isaacson Date: Fri, 10 Apr 2009 12:51:16 +0300 Subject: changed IndicateListenerServer to a gtyped pointer instead of a gboxed. --- libindicate/listener-marshal.list | 6 +++--- libindicate/listener.c | 26 +++++++------------------- 2 files changed, 10 insertions(+), 22 deletions(-) (limited to 'libindicate') diff --git a/libindicate/listener-marshal.list b/libindicate/listener-marshal.list index 37dade3..a3d20a9 100644 --- a/libindicate/listener-marshal.list +++ b/libindicate/listener-marshal.list @@ -28,8 +28,8 @@ # IndicatorAdded, IndicatorRemoved, IndicatorModified VOID:UINT,STRING # Local indicator_added, indicator_removed -VOID:BOXED,POINTER,STRING +VOID:POINTER,POINTER,STRING # Local indicator_modified -VOID:BOXED,POINTER,STRING,STRING +VOID:POINTER,POINTER,STRING,STRING # Local server_added and server_removed -VOID:BOXED,STRING +VOID:POINTER,STRING diff --git a/libindicate/listener.c b/libindicate/listener.c index 3a3c34b..13c9e81 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -153,35 +153,35 @@ indicate_listener_class_init (IndicateListenerClass * class) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (IndicateListenerClass, indicator_added), NULL, NULL, - _indicate_listener_marshal_VOID__BOXED_POINTER_STRING, + _indicate_listener_marshal_VOID__POINTER_POINTER_STRING, G_TYPE_NONE, 3, INDICATE_TYPE_LISTENER_SERVER, G_TYPE_POINTER, G_TYPE_STRING); signals[INDICATOR_REMOVED] = g_signal_new(INDICATE_LISTENER_SIGNAL_INDICATOR_REMOVED, G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (IndicateListenerClass, indicator_removed), NULL, NULL, - _indicate_listener_marshal_VOID__BOXED_POINTER_STRING, + _indicate_listener_marshal_VOID__POINTER_POINTER_STRING, G_TYPE_NONE, 3, INDICATE_TYPE_LISTENER_SERVER, G_TYPE_POINTER, G_TYPE_STRING); signals[INDICATOR_MODIFIED] = g_signal_new(INDICATE_LISTENER_SIGNAL_INDICATOR_MODIFIED, G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (IndicateListenerClass, indicator_modified), NULL, NULL, - _indicate_listener_marshal_VOID__BOXED_POINTER_STRING_STRING, + _indicate_listener_marshal_VOID__POINTER_POINTER_STRING_STRING, G_TYPE_NONE, 4, INDICATE_TYPE_LISTENER_SERVER, G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_STRING); signals[SERVER_ADDED] = g_signal_new(INDICATE_LISTENER_SIGNAL_SERVER_ADDED, G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (IndicateListenerClass, server_added), NULL, NULL, - _indicate_listener_marshal_VOID__BOXED_STRING, + _indicate_listener_marshal_VOID__POINTER_STRING, G_TYPE_NONE, 2, INDICATE_TYPE_LISTENER_SERVER, G_TYPE_STRING); signals[SERVER_REMOVED] = g_signal_new(INDICATE_LISTENER_SIGNAL_SERVER_REMOVED, G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (IndicateListenerClass, server_removed), NULL, NULL, - _indicate_listener_marshal_VOID__BOXED_STRING, + _indicate_listener_marshal_VOID__POINTER_STRING, G_TYPE_NONE, 2, INDICATE_TYPE_LISTENER_SERVER, G_TYPE_STRING); dbus_g_object_register_marshaller(_indicate_listener_marshal_VOID__UINT_STRING, @@ -686,7 +686,7 @@ proxy_indicator_modified (DBusGProxy * proxy, guint id, const gchar * property, return; } - g_signal_emit(proxyt->listener, signals[INDICATOR_MODIFIED], 0, proxyt->server, GUINT_TO_POINTER(id), type, property, TRUE); + g_signal_emit(proxyt->listener, signals[INDICATOR_MODIFIED], 0, &proxyt->server, GUINT_TO_POINTER(id), type, property, TRUE); return; } @@ -1030,20 +1030,8 @@ indicate_listener_server_get_gtype (void) static GType our_type = 0; if (our_type == 0) - our_type = g_boxed_type_register_static ("IndicateListenerServer", - (GBoxedCopyFunc) indicate_listener_server_copy, - (GBoxedFreeFunc) indicate_listener_server_free); + our_type = g_pointer_type_register_static ("IndicateListenerServer"); return our_type; } -IndicateListenerServer * -indicate_listener_server_copy (const IndicateListenerServer *listener_server) -{ - return listener_server; -} - -void -indicate_listener_server_free (IndicateListenerServer *listener_server) -{ -} -- cgit v1.2.3 From bcdeb139acbff6d15d442f2bac3b1bb751413645 Mon Sep 17 00:00:00 2001 From: Eitan Isaacson Date: Fri, 10 Apr 2009 13:16:39 +0300 Subject: gtypify IndicateListenerIndicator --- libindicate/listener.c | 17 ++++++++++++++--- libindicate/listener.h | 4 ++-- 2 files changed, 16 insertions(+), 5 deletions(-) (limited to 'libindicate') diff --git a/libindicate/listener.c b/libindicate/listener.c index 13c9e81..0646e81 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -154,21 +154,21 @@ indicate_listener_class_init (IndicateListenerClass * class) G_STRUCT_OFFSET (IndicateListenerClass, indicator_added), NULL, NULL, _indicate_listener_marshal_VOID__POINTER_POINTER_STRING, - G_TYPE_NONE, 3, INDICATE_TYPE_LISTENER_SERVER, G_TYPE_POINTER, G_TYPE_STRING); + G_TYPE_NONE, 3, INDICATE_TYPE_LISTENER_SERVER, INDICATE_TYPE_LISTENER_INDICATOR, G_TYPE_STRING); signals[INDICATOR_REMOVED] = g_signal_new(INDICATE_LISTENER_SIGNAL_INDICATOR_REMOVED, G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (IndicateListenerClass, indicator_removed), NULL, NULL, _indicate_listener_marshal_VOID__POINTER_POINTER_STRING, - G_TYPE_NONE, 3, INDICATE_TYPE_LISTENER_SERVER, G_TYPE_POINTER, G_TYPE_STRING); + G_TYPE_NONE, 3, INDICATE_TYPE_LISTENER_SERVER, INDICATE_TYPE_LISTENER_INDICATOR, G_TYPE_STRING); signals[INDICATOR_MODIFIED] = g_signal_new(INDICATE_LISTENER_SIGNAL_INDICATOR_MODIFIED, G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (IndicateListenerClass, indicator_modified), NULL, NULL, _indicate_listener_marshal_VOID__POINTER_POINTER_STRING_STRING, - G_TYPE_NONE, 4, INDICATE_TYPE_LISTENER_SERVER, G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_STRING); + G_TYPE_NONE, 4, INDICATE_TYPE_LISTENER_SERVER, INDICATE_TYPE_LISTENER_INDICATOR, G_TYPE_STRING, G_TYPE_STRING); signals[SERVER_ADDED] = g_signal_new(INDICATE_LISTENER_SIGNAL_SERVER_ADDED, G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, @@ -1035,3 +1035,14 @@ indicate_listener_server_get_gtype (void) return our_type; } +GType +indicate_listener_indicator_get_gtype (void) +{ + static GType our_type = 0; + + if (our_type == 0) + our_type = g_pointer_type_register_static ("IndicateListenerIndicator"); + + return our_type; +} + diff --git a/libindicate/listener.h b/libindicate/listener.h index 5a1e991..5bfd298 100644 --- a/libindicate/listener.h +++ b/libindicate/listener.h @@ -61,10 +61,10 @@ G_BEGIN_DECLS typedef struct _IndicateListenerServer IndicateListenerServer; #define INDICATE_TYPE_LISTENER_SERVER (indicate_listener_server_get_gtype ()) GType indicate_listener_server_get_gtype (void) G_GNUC_CONST; -IndicateListenerServer *indicate_listener_server_copy (const IndicateListenerServer *listener_server); -void indicate_listener_server_free (IndicateListenerServer *listener_server); typedef struct _IndicateListenerIndicator IndicateListenerIndicator; +#define INDICATE_TYPE_LISTENER_INDICATOR (indicate_listener_indicator_get_gtype ()) +GType indicate_listener_indicator_get_gtype (void) G_GNUC_CONST; typedef struct _IndicateListener IndicateListener; struct _IndicateListener { -- cgit v1.2.3