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(-) 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(+) 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(-) 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(-) 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(-) 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 From 70697a6c0c3906e4825dadaf4d37ec6f2d0ab557 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 10 Apr 2009 14:07:43 -0500 Subject: Marking the dev branch as such. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index b86656d..15e4110 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,7 @@ AC_INIT(src/applet-main.c) AC_PREREQ(2.53) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(indicator-applet, 0.1.5) +AM_INIT_AUTOMAKE(indicator-applet, 0.2.0dev) AM_MAINTAINER_MODE -- cgit v1.2.3 From f4bfa1ff71ef925907901dc0c438328891daca1c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 10 Apr 2009 14:32:37 -0500 Subject: Create the virtual function for checking interest. --- libindicate/server.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libindicate/server.c b/libindicate/server.c index 9e33516..1378a0d 100644 --- a/libindicate/server.c +++ b/libindicate/server.c @@ -1202,6 +1202,19 @@ _indicate_server_remove_interest (IndicateServer * server, gchar * interest, DBu return FALSE; } +gboolean +indicate_server_check_interest (IndicateServer * server, IndicateInterests interest) +{ + IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server); + + if (class != NULL && class->check_interest != NULL) { + return class->check_interest (server, interest); + } + + g_warning("check_interest function not implemented in this server class: %s", G_OBJECT_TYPE_NAME(server)); + return FALSE; +} + /* Signal emission functions for sub-classes of the server */ void indicate_server_emit_indicator_added (IndicateServer *server, guint id, const gchar *type) -- cgit v1.2.3 -- cgit v1.2.3 From 20836b86feb5aad4c938a4af26e57f544e75a69c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 10 Apr 2009 15:51:26 -0500 Subject: Adding in libxml linking --- configure.ac | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 15e4110..ca46ff9 100644 --- a/configure.ac +++ b/configure.ac @@ -50,11 +50,13 @@ AM_GCONF_SOURCE_2 GLIB_REQUIRED_VERSION=2.18 GIO_REQUIRED_VERSION=2.18 GDK_PIXBUF_REQUIRED_VERSION=2.12 +XML_REQUIRED_VERSION=2.6 PKG_CHECK_MODULES(LIBINDICATE, glib-2.0 >= $GLIB_REQUIRED_VERSION gio-2.0 >= $GIO_REQUIRED_VERSION gdk-pixbuf-2.0 >= $GDK_PIXBUF_REQUIRED_VERSION - dbus-glib-1 >= $DBUS_REQUIRED_VERSION) + dbus-glib-1 >= $DBUS_REQUIRED_VERSION + libxml-2.0 >= $XML_REQUIRED_VERSION) AC_SUBST(LIBINDICATE_CFLAGS) AC_SUBST(LIBINDICATE_LIBS) -- cgit v1.2.3 From ce664599c72dcb80f9e0427a2a49fc3c26fb79c8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sun, 12 Apr 2009 21:41:48 -0500 Subject: Proto-pseudo-code for the introspection functions that are going to be needed --- libindicate/listener.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/libindicate/listener.c b/libindicate/listener.c index 0646e81..8ae3973 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -1046,3 +1046,34 @@ indicate_listener_indicator_get_gtype (void) return our_type; } +static const gchar * _introspector_path[] = ["", "org", "freedesktop", "indicate", NULL]; +static const gchar * _introspector_interface = "org.freedesktop.indicator"; + +void +introspect_this (gchar * xml, IndicateServer * server) +{ + if (xml != NULL) { + /* Parse the XML */ + + /* Check for root being "node" */ + + const gchar * nodename = NULL; + const gchar * nameval = NULL; + if (_introspector_path[server->introspect_level] == NULL) { + /* We're looking for our interface */ + nodename = "interface"; + nameval = _introspector_interface; + } else { + /* We're looking for our next node */ + nodename = "node"; + nameval = _introspector_path[server->introspect_level]; + } + + } else { + server->introspect_level = 0; + } + + dbus_proxy_create(); + dbus_proxy_call(intropsect_this); + +} -- cgit v1.2.3 From bde7e27a7b972017f16ebf40ad173896d22bec25 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 13 Apr 2009 13:30:31 -0500 Subject: Whoa, it like builds and stuff --- libindicate/listener.c | 61 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 55 insertions(+), 6 deletions(-) diff --git a/libindicate/listener.c b/libindicate/listener.c index b647f0a..6613e3d 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -27,6 +27,9 @@ License version 3 and version 2.1 along with this program. If not, see */ +#include +#include + #include "listener.h" #include "listener-marshal.h" #include @@ -89,6 +92,7 @@ typedef struct { gchar * type; IndicateListener * listener; GHashTable * indicators; + guint introspect_level; IndicateListenerServer server; } proxy_t; @@ -1046,17 +1050,29 @@ indicate_listener_indicator_get_gtype (void) return our_type; } -static const gchar * _introspector_path[] = ["", "org", "freedesktop", "indicate", NULL]; +static const gchar * _introspector_path[] = {"", "org", "freedesktop", "indicate", NULL}; +static const gchar * _introspector_fullpath[] = {"/", "/org", "/org/freedesktop", "/org/freedesktop/indicate", NULL}; static const gchar * _introspector_interface = "org.freedesktop.indicator"; -void -introspect_this (gchar * xml, IndicateServer * server) +static void +introspect_this (DBusGProxy * proxy, char * OUT_data, GError * error, gpointer data) { - if (xml != NULL) { + g_debug("Introspect this:\n%s", OUT_data); + proxy_t * server = (proxy_t *)data; + if (OUT_data != NULL) { + xmlDocPtr xmldoc; /* Parse the XML */ + xmldoc = xmlReadMemory(OUT_data, g_utf8_strlen(OUT_data, 16*1024), "introspection.xml", NULL, 0); /* Check for root being "node" */ + xmlNodePtr root = xmlDocGetRootElement(xmldoc); + if (g_strcmp(root->name, "node") != 0) { + xmlFreeDoc(xmldoc); + g_warning("Introspection data from %s is not valid: %s", server->name, OUT_data); + return; + } + server->introspect_level += 1; const gchar * nodename = NULL; const gchar * nameval = NULL; if (_introspector_path[server->introspect_level] == NULL) { @@ -1069,11 +1085,44 @@ introspect_this (gchar * xml, IndicateServer * server) nameval = _introspector_path[server->introspect_level]; } + gboolean found = FALSE; + xmlNodePtr children; + for (children = root->children; children != NULL; children = children->next) { + gchar * xmlnameval = NULL; + if (g_strcmp0(children->name, nodename) == 0) { + xmlAttrPtr attrib; + for (attrib = children->properties; attrib != NULL; attrib = attrib->next) { + if (g_strcmp0(attrib->name, "name") == 0) { + if (attrib->children != NULL) { + xmlnameval = attrib->children->content; + } + break; + } + } + + if (!g_strcmp0(nameval, xmlnameval)) { + found = TRUE; + break; + } + } + } + + xmlFreeDoc(xmldoc); + + if (!found) { + /* Ah, nothing we're interested in */ + return; + } } else { server->introspect_level = 0; } - dbus_proxy_create(); - dbus_proxy_call(intropsect_this); + DBusGProxy * newproxy = dbus_g_proxy_new_for_name(server->connection, + server->name, + _introspector_fullpath[server->introspect_level], + DBUS_INTERFACE_INTROSPECTABLE); + org_freedesktop_DBus_Introspectable_introspect_async(newproxy, introspect_this, server); + + return; } -- cgit v1.2.3 From 24e268d166ef026a3f1c4e7b09ae13d15bf427eb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 13 Apr 2009 14:07:46 -0500 Subject: Fleshing out some --- libindicate/listener.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libindicate/listener.c b/libindicate/listener.c index 6613e3d..420d8cd 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -1059,6 +1059,16 @@ introspect_this (DBusGProxy * proxy, char * OUT_data, GError * error, gpointer d { g_debug("Introspect this:\n%s", OUT_data); proxy_t * server = (proxy_t *)data; + if (proxy != NULL) { + g_object_unref(proxy); + } + if (error != NULL) { + /* We probably couldn't introspect that far up. That's + life, it happens. */ + g_debug("Introspection error on %s object %s: %s", server->name, _introspector_fullpath[server->introspect_level], error->message); + return; + } + if (OUT_data != NULL) { xmlDocPtr xmldoc; /* Parse the XML */ -- cgit v1.2.3 From dec69be399365590e8bc5140f470aafd805ff17d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 13 Apr 2009 14:15:01 -0500 Subject: Okay, connected into that other there code... let's see what happens. --- libindicate/listener.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/libindicate/listener.c b/libindicate/listener.c index 420d8cd..fd35d66 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -133,6 +133,7 @@ static void proxy_indicator_modified (DBusGProxy * proxy, guint id, const gchar static void proxy_get_indicator_list (DBusGProxy * proxy, GArray * indicators, GError * error, gpointer data); static void proxy_get_indicator_type (DBusGProxy * proxy, gchar * type, GError * error, gpointer data); static void proxy_indicators_free (gpointer data); +static void introspect_this (DBusGProxy * proxy, char * OUT_data, GError * error, gpointer data); /* DBus interface */ gboolean _indicate_listener_get_indicator_servers (IndicateListener * listener, GList * servers); @@ -502,13 +503,9 @@ todo_idle (gpointer data) priv->proxies_possible = g_list_prepend(priv->proxies_possible, proxyt); - /* I think that we need to have this as there is a race - * condition here. If someone comes on the bus and we get - * that message, but before we set up the handler for the ServerShow - * signal it gets sent, we wouldn't get it. So then we would - * miss an indicator server coming on the bus. I'd like to not - * generate a warning in every app with DBus though. */ - indicate_listener_server_get_type(listener, &proxyt->server, get_type_cb, proxyt); + /* Look through the introspection data to see if this + is already a server */ + introspect_this (NULL, NULL, NULL, proxyt); return TRUE; } @@ -1123,6 +1120,13 @@ introspect_this (DBusGProxy * proxy, char * OUT_data, GError * error, gpointer d /* Ah, nothing we're interested in */ return; } + + if (_introspector_path[server->introspect_level] == NULL) { + /* If we've found the interface at the end of the tree, whoo! hoo! */ + /* Now we know it's safe to get the type on it */ + indicate_listener_server_get_type(server->listener, &server->server, get_type_cb, server); + return; + } } else { server->introspect_level = 0; } -- cgit v1.2.3 From 135906b4b250f8c5be3a1a157d77c689313f381a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 13 Apr 2009 14:16:25 -0500 Subject: Ah, a typo. Bother. --- libindicate/listener.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libindicate/listener.c b/libindicate/listener.c index fd35d66..5ae3e09 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -1073,7 +1073,7 @@ introspect_this (DBusGProxy * proxy, char * OUT_data, GError * error, gpointer d /* Check for root being "node" */ xmlNodePtr root = xmlDocGetRootElement(xmldoc); - if (g_strcmp(root->name, "node") != 0) { + if (g_strcmp0(root->name, "node") != 0) { xmlFreeDoc(xmldoc); g_warning("Introspection data from %s is not valid: %s", server->name, OUT_data); return; -- cgit v1.2.3 From 46a050c2eac7bc12566339cbdea6bdb3376ccecf Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 13 Apr 2009 14:41:33 -0500 Subject: Less debug --- libindicate/listener.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libindicate/listener.c b/libindicate/listener.c index 5ae3e09..20a3278 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -1054,7 +1054,7 @@ static const gchar * _introspector_interface = "org.freedesktop.indicator"; static void introspect_this (DBusGProxy * proxy, char * OUT_data, GError * error, gpointer data) { - g_debug("Introspect this:\n%s", OUT_data); + /* g_debug("Introspect this:\n%s", OUT_data); */ proxy_t * server = (proxy_t *)data; if (proxy != NULL) { g_object_unref(proxy); -- cgit v1.2.3 From e32b37d049968231cb19129654fd3be997efb48b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 13 Apr 2009 14:47:35 -0500 Subject: Commenting out some debug messages --- libindicate/listener.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libindicate/listener.c b/libindicate/listener.c index 20a3278..a314ea8 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -1061,8 +1061,9 @@ introspect_this (DBusGProxy * proxy, char * OUT_data, GError * error, gpointer d } if (error != NULL) { /* We probably couldn't introspect that far up. That's - life, it happens. */ - g_debug("Introspection error on %s object %s: %s", server->name, _introspector_fullpath[server->introspect_level], error->message); + life, it happens. Or there's a timeout, that happens + too, I guess some apps are too busy for us. */ + /* g_debug("Introspection error on %s object %s: %s", server->name, _introspector_fullpath[server->introspect_level], error->message); */ return; } -- cgit v1.2.3 From 43cf92a1e3306bf142f98ebc0cc4b2c636271c0d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 20 Apr 2009 12:10:58 -0500 Subject: Chaning the include so that it works for make distcheck --- libindicate/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libindicate/Makefile.am b/libindicate/Makefile.am index 91072f7..3ad6247 100644 --- a/libindicate/Makefile.am +++ b/libindicate/Makefile.am @@ -121,7 +121,7 @@ $(ENUM_FILE).c: s-enum-types-c @true s-enum-types-c: $(indicate_headers) Makefile ( cd $(srcdir) && glib-mkenums \ - --fhead "#include \n#include " \ + --fhead "#include \"interests.h\"\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@\" }," \ -- cgit v1.2.3 From 61bc03afdadb206839db4c0eb0631104a1a2ff3b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 21 Apr 2009 14:15:22 -0500 Subject: Creating an indicator lib to make sure we can attach all these things together. --- .bzrignore | 1 + Makefile.am | 1 + configure.ac | 2 ++ libindicator/Makefile.am | 14 ++++++++++++++ libindicator/indicator.h | 17 +++++++++++++++++ libindicator/indicator.pc.in | 16 ++++++++++++++++ 6 files changed, 51 insertions(+) create mode 100644 libindicator/Makefile.am create mode 100644 libindicator/indicator.h create mode 100644 libindicator/indicator.pc.in diff --git a/.bzrignore b/.bzrignore index 2e5dd36..a8561af 100644 --- a/.bzrignore +++ b/.bzrignore @@ -60,3 +60,4 @@ libindicate/indicate-enum-types.h libindicate/libindicate_la-indicate-enum-types.lo libindicate/s-enum-types-c libindicate/s-enum-types-h +indicator.pc diff --git a/Makefile.am b/Makefile.am index d4f7ca2..a523c3a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,6 +2,7 @@ SUBDIRS = \ src \ libindicate \ + libindicator \ tests \ data \ po \ diff --git a/configure.ac b/configure.ac index ca46ff9..3df81f5 100644 --- a/configure.ac +++ b/configure.ac @@ -161,6 +161,8 @@ Makefile src/Makefile libindicate/Makefile libindicate/indicate.pc +libindicator/Makefile +libindicator/indicator.pc tests/Makefile data/Makefile po/Makefile.in diff --git a/libindicator/Makefile.am b/libindicator/Makefile.am new file mode 100644 index 0000000..be68721 --- /dev/null +++ b/libindicator/Makefile.am @@ -0,0 +1,14 @@ +EXTRA_DIST = \ + indicator.pc.in + +libindicatorincludedir=$(includedir)/libindicator-0.1/libindicator + +indicator_headers = \ + indicator.h + +libindicatorinclude_HEADERS = \ + $(indicator_headers) + +pkgconfig_DATA = indicator.pc +pkgconfigdir = $(libdir)/pkgconfig + diff --git a/libindicator/indicator.h b/libindicator/indicator.h new file mode 100644 index 0000000..9afaa4f --- /dev/null +++ b/libindicator/indicator.h @@ -0,0 +1,17 @@ + +#ifndef __LIBINDICATOR_INDICATOR_H_SEEN__ +#define __LIBINDICATOR_INDICATOR_H_SEEN__ 1 + +#include + +#define INDICATOR_GET_LABEL_S "get_label" +GtkLabel * get_label (void); + +#define INDICATOR_GET_ICON_S "get_icon" +GtkImage * get_icon (void); + +#define INDICATOR_GET_MENU_S "get_menu" +GtkMenu * get_menu (void); + +#endif /* __LIBINDICATOR_INDICATOR_H_SEEN__ */ + diff --git a/libindicator/indicator.pc.in b/libindicator/indicator.pc.in new file mode 100644 index 0000000..32f865d --- /dev/null +++ b/libindicator/indicator.pc.in @@ -0,0 +1,16 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +bindir=@bindir@ +includedir=@includedir@ + +indicatordir=@indicatordir@ + +Cflags: -I${includedir}/libindicator-0.1 +Requires: gtk-2.0 +Libs: + +Name: libindicator +Description: libindicator. +Version: @VERSION@ + -- cgit v1.2.3 From 292b04ef54580b79c105a9403f25cd385c2a4c62 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 21 Apr 2009 14:34:19 -0500 Subject: Setting the indicators directory manually --- libindicator/indicator.pc.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libindicator/indicator.pc.in b/libindicator/indicator.pc.in index 32f865d..fa1c697 100644 --- a/libindicator/indicator.pc.in +++ b/libindicator/indicator.pc.in @@ -4,7 +4,7 @@ libdir=@libdir@ bindir=@bindir@ includedir=@includedir@ -indicatordir=@indicatordir@ +indicatordir=${libdir}/indicators/2/ Cflags: -I${includedir}/libindicator-0.1 Requires: gtk-2.0 -- cgit v1.2.3 From b0c9eb5bd9000d8f743c6a72f3312a7df587f264 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 21 Apr 2009 14:35:49 -0500 Subject: Moving the indicators directory to match libindicator --- src/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index 818bdd9..02b70c1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -5,7 +5,7 @@ libexec_PROGRAMS = \ indicator_applet_CFLAGS = \ -DG_LOG_DOMAIN=\""Indicator-Applet"\" \ -DDATADIR=\""$(datadir)"\" \ - -DINDICATOR_DIR=\""$(libdir)/indicators/1"\" \ + -DINDICATOR_DIR=\""$(libdir)/indicators/2"\" \ $(APPLET_CFLAGS) indicator_applet_SOURCES = \ -- cgit v1.2.3 From 4023d350d22120cd8405307f0e0465bdb95fbae6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 21 Apr 2009 14:49:57 -0500 Subject: Fixing and using the new indicator header. This will help to connect things together and make them actually work in a reasonably type safe way. --- libindicator/indicator.h | 9 ++++++--- src/applet-main.c | 19 ++++++++++++++----- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/libindicator/indicator.h b/libindicator/indicator.h index 9afaa4f..daee3c8 100644 --- a/libindicator/indicator.h +++ b/libindicator/indicator.h @@ -5,13 +5,16 @@ #include #define INDICATOR_GET_LABEL_S "get_label" -GtkLabel * get_label (void); +typedef GtkLabel * (*get_label_t)(void); +get_label_t get_label; #define INDICATOR_GET_ICON_S "get_icon" -GtkImage * get_icon (void); +typedef GtkImage * (*get_icon_t) (void); +get_icon_t get_icon; #define INDICATOR_GET_MENU_S "get_menu" -GtkMenu * get_menu (void); +typedef GtkMenu * (*get_menu_t) (void); +get_menu_t get_menu; #endif /* __LIBINDICATOR_INDICATOR_H_SEEN__ */ diff --git a/src/applet-main.c b/src/applet-main.c index 310cfe9..795c2fb 100644 --- a/src/applet-main.c +++ b/src/applet-main.c @@ -24,7 +24,8 @@ with this program. If not, see . #include #include -#define SYMBOL_NAME "get_menu_item" +#include "libindicator/indicator.h" + #define ICONS_DIR (DATADIR G_DIR_SEPARATOR_S "indicator-applet" G_DIR_SEPARATOR_S "icons") static gboolean applet_fill_cb (PanelApplet * applet, const gchar * iid, gpointer data); @@ -79,11 +80,19 @@ load_module (const gchar * name, GtkWidget * menu) g_free(fullpath); g_return_val_if_fail(module != NULL, FALSE); - GtkWidget * (*make_item)(void); - g_return_val_if_fail(g_module_symbol(module, SYMBOL_NAME, (gpointer *)(&make_item)), FALSE); - g_return_val_if_fail(make_item != NULL, FALSE); + get_label_t lget_label; + g_return_val_if_fail(g_module_symbol(module, INDICATOR_GET_LABEL_S, (gpointer *)(&lget_label)), FALSE); + g_return_val_if_fail(lget_label != NULL, FALSE); + + get_icon_t lget_icon; + g_return_val_if_fail(g_module_symbol(module, INDICATOR_GET_LABEL_S, (gpointer *)(&lget_icon)), FALSE); + g_return_val_if_fail(lget_icon != NULL, FALSE); + + get_menu_t lget_menu; + g_return_val_if_fail(g_module_symbol(module, INDICATOR_GET_LABEL_S, (gpointer *)(&lget_menu)), FALSE); + g_return_val_if_fail(lget_menu != NULL, FALSE); - GtkWidget * menuitem = make_item(); + GtkWidget * menuitem = GTK_WIDGET(lget_menu()); g_return_val_if_fail(GTK_MENU_ITEM(menuitem), FALSE); gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); -- cgit v1.2.3 From ae2689289232bb1237f7d37e591fc8c610d069e1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 21 Apr 2009 15:01:19 -0500 Subject: Putting in and checking version information to ensure we all agree about the header version --- libindicator/indicator.h | 5 +++++ src/applet-main.c | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/libindicator/indicator.h b/libindicator/indicator.h index daee3c8..6940dfb 100644 --- a/libindicator/indicator.h +++ b/libindicator/indicator.h @@ -16,5 +16,10 @@ get_icon_t get_icon; typedef GtkMenu * (*get_menu_t) (void); get_menu_t get_menu; +#define INDICATOR_VERSION "0.2.0" +#define INDICATOR_SET_VERSION static gchar * indicator_version_symbol = INDICATOR_VERSION; +#define INDICATOR_VERSION_S "indicator_version_symbol" +#define INDICATOR_VERSION_CHECK(x) (!g_strcmp0(x, INDICATOR_VERSION)) + #endif /* __LIBINDICATOR_INDICATOR_H_SEEN__ */ diff --git a/src/applet-main.c b/src/applet-main.c index 795c2fb..e28009d 100644 --- a/src/applet-main.c +++ b/src/applet-main.c @@ -80,6 +80,10 @@ load_module (const gchar * name, GtkWidget * menu) g_free(fullpath); g_return_val_if_fail(module != NULL, FALSE); + gchar * version; + g_return_val_if_fail(g_module_symbol(module, INDICATOR_VERSION_S, (gpointer *)(&version)), FALSE); + g_return_val_if_fail(INDICATOR_VERSION_CHECK(version), FALSE); + get_label_t lget_label; g_return_val_if_fail(g_module_symbol(module, INDICATOR_GET_LABEL_S, (gpointer *)(&lget_label)), FALSE); g_return_val_if_fail(lget_label != NULL, FALSE); -- cgit v1.2.3 From 8c6656e5d6a05ad14fe41c12bc2d159c5b3e22ca Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 21 Apr 2009 15:14:52 -0500 Subject: Changing to an icon and a lable and building our own item --- src/applet-main.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/applet-main.c b/src/applet-main.c index e28009d..74d948a 100644 --- a/src/applet-main.c +++ b/src/applet-main.c @@ -87,17 +87,36 @@ load_module (const gchar * name, GtkWidget * menu) get_label_t lget_label; g_return_val_if_fail(g_module_symbol(module, INDICATOR_GET_LABEL_S, (gpointer *)(&lget_label)), FALSE); g_return_val_if_fail(lget_label != NULL, FALSE); + GtkLabel * label = lget_label(); get_icon_t lget_icon; g_return_val_if_fail(g_module_symbol(module, INDICATOR_GET_LABEL_S, (gpointer *)(&lget_icon)), FALSE); g_return_val_if_fail(lget_icon != NULL, FALSE); + GtkImage * icon = lget_icon(); get_menu_t lget_menu; g_return_val_if_fail(g_module_symbol(module, INDICATOR_GET_LABEL_S, (gpointer *)(&lget_menu)), FALSE); g_return_val_if_fail(lget_menu != NULL, FALSE); + GtkMenu * lmenu = lget_menu(); - GtkWidget * menuitem = GTK_WIDGET(lget_menu()); - g_return_val_if_fail(GTK_MENU_ITEM(menuitem), FALSE); + if (label == NULL && icon == NULL) { + /* This is the case where there is nothing to display, + kinda odd that we'd have a module with nothing. */ + return FALSE; + } + + GtkWidget * menuitem = gtk_menu_item_new(); + GtkWidget * hbox = gtk_hbox_new(FALSE, 3); + if (icon != NULL) { + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(icon), FALSE, FALSE, 0); + } + if (label != NULL) { + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(label), FALSE, FALSE, 0); + } + + if (menu != NULL) { + gtk_menu_shell_append(GTK_MENU_SHELL(menuitem), GTK_WIDGET(lmenu)); + } gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); -- cgit v1.2.3