From 31f519d7984a80d702154240aa4708560a8faada Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 16 Oct 2009 15:53:59 -0500 Subject: Set and get properties --- src/libcustomindicator/custom-indicator.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/libcustomindicator/custom-indicator.c b/src/libcustomindicator/custom-indicator.c index e0fecbb..6608437 100644 --- a/src/libcustomindicator/custom-indicator.c +++ b/src/libcustomindicator/custom-indicator.c @@ -16,6 +16,8 @@ static void custom_indicator_class_init (CustomIndicatorClass *klass); static void custom_indicator_init (CustomIndicator *self); static void custom_indicator_dispose (GObject *object); static void custom_indicator_finalize (GObject *object); +static void custom_indicator_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); +static void custom_indicator_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); G_DEFINE_TYPE (CustomIndicator, custom_indicator, G_TYPE_OBJECT); @@ -29,6 +31,9 @@ custom_indicator_class_init (CustomIndicatorClass *klass) object_class->dispose = custom_indicator_dispose; object_class->finalize = custom_indicator_finalize; + object_class->set_property = custom_indicator_set_property; + object_class->get_property = custom_indicator_get_property; + return; } @@ -55,3 +60,18 @@ custom_indicator_finalize (GObject *object) return; } +static void +custom_indicator_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) +{ + + + return; +} + +static void +custom_indicator_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec) +{ + + + return; +} -- cgit v1.2.3 From 63e10a66964e2cecf813e4feb6d155ac47674ca7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 16 Oct 2009 15:54:32 -0500 Subject: Forgot to change the package name --- autogen.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autogen.sh b/autogen.sh index 3483322..5bdd6c1 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,6 +1,6 @@ #!/bin/sh -PKG_NAME="upanel" +PKG_NAME="indicator-custom" which gnome-autogen.sh || { echo "You need gnome-common from GNOME SVN" -- cgit v1.2.3 From 85b61a412d9cfafd73422f5e021bc315ed30c805 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 16 Oct 2009 16:22:04 -0500 Subject: Putting in our first property, status. Woo hoo! --- src/libcustomindicator/custom-indicator.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/libcustomindicator/custom-indicator.c b/src/libcustomindicator/custom-indicator.c index 6608437..25b0424 100644 --- a/src/libcustomindicator/custom-indicator.c +++ b/src/libcustomindicator/custom-indicator.c @@ -2,13 +2,19 @@ #include "config.h" #endif -#include "custom-indicator.h" +#include "libcustomindicator/custom-indicator.h" +#include "libcustomindicator/custom-indicator-enum-types.h" typedef struct _CustomIndicatorPrivate CustomIndicatorPrivate; struct _CustomIndicatorPrivate { int placeholder; }; +enum properties { + PROP_0, + PROP_STATUS +}; + #define CUSTOM_INDICATOR_GET_PRIVATE(o) \ (G_TYPE_INSTANCE_GET_PRIVATE ((o), CUSTOM_INDICATOR_TYPE, CustomIndicatorPrivate)) @@ -34,6 +40,14 @@ custom_indicator_class_init (CustomIndicatorClass *klass) object_class->set_property = custom_indicator_set_property; object_class->get_property = custom_indicator_get_property; + g_object_class_install_property(object_class, PROP_STATUS, + g_param_spec_enum("status", + "Indicator Status", + "Whether the indicator is shown or requests attention.", + CUSTOM_INDICATOR_TYPE_CUSTOM_INDICATOR_STATUS_T, + CUSTOM_INDICATOR_STATUS_OFF, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + return; } -- cgit v1.2.3 From a49c64388e891a46f03ebaf5c8c76d9309de372f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sat, 17 Oct 2009 21:42:00 -0500 Subject: Filling out the property list. --- src/libcustomindicator/custom-indicator.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/libcustomindicator/custom-indicator.c b/src/libcustomindicator/custom-indicator.c index 25b0424..320b6e9 100644 --- a/src/libcustomindicator/custom-indicator.c +++ b/src/libcustomindicator/custom-indicator.c @@ -12,7 +12,12 @@ struct _CustomIndicatorPrivate { enum properties { PROP_0, - PROP_STATUS + PROP_ID, + PROP_CATEGORY, + PROP_STATUS, + PROP_ICON_NAME, + PROP_ATTENTION_ICON_NAME, + PROP_MENU }; #define CUSTOM_INDICATOR_GET_PRIVATE(o) \ @@ -77,7 +82,11 @@ custom_indicator_finalize (GObject *object) static void custom_indicator_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { + CustomIndicator * self = CUSTOM_INDICATOR(object); + g_return_if_fail(self != NULL); + CustomIndicatorPrivate * priv = CUSTOM_INDICATOR_GET_PRIVATE(self); + g_return_if_fail(priv != NULL); return; } -- cgit v1.2.3 From 7b45f659ffad3db1d40b06dfba3e33fc42fc9eb3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sat, 17 Oct 2009 21:46:45 -0500 Subject: Making sure to get the property names into defines so that we can ensure they're all the same. --- src/libcustomindicator/custom-indicator.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libcustomindicator/custom-indicator.c b/src/libcustomindicator/custom-indicator.c index 320b6e9..c547166 100644 --- a/src/libcustomindicator/custom-indicator.c +++ b/src/libcustomindicator/custom-indicator.c @@ -20,6 +20,13 @@ enum properties { PROP_MENU }; +#define PROP_ID_S "id" +#define PROP_CATEGORY_S "category" +#define PROP_STATUS_S "status" +#define PROP_ICON_NAME_S "icon-name" +#define PROP_ATTENTION_ICON_NAME_S "attention-icon-name" +#define PROP_MENU_S "menu" + #define CUSTOM_INDICATOR_GET_PRIVATE(o) \ (G_TYPE_INSTANCE_GET_PRIVATE ((o), CUSTOM_INDICATOR_TYPE, CustomIndicatorPrivate)) @@ -46,7 +53,7 @@ custom_indicator_class_init (CustomIndicatorClass *klass) object_class->get_property = custom_indicator_get_property; g_object_class_install_property(object_class, PROP_STATUS, - g_param_spec_enum("status", + g_param_spec_enum(PROP_STATUS_S, "Indicator Status", "Whether the indicator is shown or requests attention.", CUSTOM_INDICATOR_TYPE_CUSTOM_INDICATOR_STATUS_T, -- cgit v1.2.3 From 9e25a774c4efc46057eecb1b5c38340691df71ed Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sat, 17 Oct 2009 22:27:34 -0500 Subject: Changing the name to match the changes in the previous commit. --- src/libcustomindicator/custom-indicator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcustomindicator/custom-indicator.c b/src/libcustomindicator/custom-indicator.c index c547166..bbf5210 100644 --- a/src/libcustomindicator/custom-indicator.c +++ b/src/libcustomindicator/custom-indicator.c @@ -56,7 +56,7 @@ custom_indicator_class_init (CustomIndicatorClass *klass) g_param_spec_enum(PROP_STATUS_S, "Indicator Status", "Whether the indicator is shown or requests attention.", - CUSTOM_INDICATOR_TYPE_CUSTOM_INDICATOR_STATUS_T, + CUSTOM_INDICATOR_TYPE_INDICATOR_STATUS, CUSTOM_INDICATOR_STATUS_OFF, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); -- cgit v1.2.3 From 6da6b6b7cef68a66cfd0b382e68df462d7b4eb8d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 19 Oct 2009 14:03:12 -0500 Subject: Wow, properties. The properties system in gobject is a little insane. --- src/libcustomindicator/custom-indicator.c | 52 +++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/src/libcustomindicator/custom-indicator.c b/src/libcustomindicator/custom-indicator.c index bbf5210..7fb8fb8 100644 --- a/src/libcustomindicator/custom-indicator.c +++ b/src/libcustomindicator/custom-indicator.c @@ -2,6 +2,8 @@ #include "config.h" #endif +#include "libdbusmenu-glib/server.h" + #include "libcustomindicator/custom-indicator.h" #include "libcustomindicator/custom-indicator-enum-types.h" @@ -10,6 +12,8 @@ struct _CustomIndicatorPrivate { int placeholder; }; +/* Enum for the properties so that they can be quickly + found and looked up. */ enum properties { PROP_0, PROP_ID, @@ -20,6 +24,7 @@ enum properties { PROP_MENU }; +/* The strings so that they can be slowly looked up. */ #define PROP_ID_S "id" #define PROP_CATEGORY_S "category" #define PROP_STATUS_S "status" @@ -27,16 +32,20 @@ enum properties { #define PROP_ATTENTION_ICON_NAME_S "attention-icon-name" #define PROP_MENU_S "menu" +/* Private macro, shhhh! */ #define CUSTOM_INDICATOR_GET_PRIVATE(o) \ -(G_TYPE_INSTANCE_GET_PRIVATE ((o), CUSTOM_INDICATOR_TYPE, CustomIndicatorPrivate)) + (G_TYPE_INSTANCE_GET_PRIVATE ((o), CUSTOM_INDICATOR_TYPE, CustomIndicatorPrivate)) +/* Boiler plate */ static void custom_indicator_class_init (CustomIndicatorClass *klass); static void custom_indicator_init (CustomIndicator *self); static void custom_indicator_dispose (GObject *object); static void custom_indicator_finalize (GObject *object); +/* Property functions */ static void custom_indicator_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); static void custom_indicator_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); +/* GObject type */ G_DEFINE_TYPE (CustomIndicator, custom_indicator, G_TYPE_OBJECT); static void @@ -46,20 +55,59 @@ custom_indicator_class_init (CustomIndicatorClass *klass) g_type_class_add_private (klass, sizeof (CustomIndicatorPrivate)); + /* Clean up */ object_class->dispose = custom_indicator_dispose; object_class->finalize = custom_indicator_finalize; + /* Property funcs */ object_class->set_property = custom_indicator_set_property; object_class->get_property = custom_indicator_get_property; + /* Properties */ + g_object_class_install_property(object_class, PROP_ID, + g_param_spec_string(PROP_ID_S, + "The ID for this indicator", + "An ID that should be unique, but used consistently by this program and it's indicator.", + NULL, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property(object_class, PROP_CATEGORY, + g_param_spec_enum(PROP_CATEGORY_S, + "Indicator Category", + "The type of indicator that this represents. Please don't use 'other'. Defaults to 'Application Status'.", + CUSTOM_INDICATOR_TYPE_INDICATOR_CATEGORY, + CUSTOM_INDICATOR_CATEGORY_APPLICATION_STATUS, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property(object_class, PROP_STATUS, g_param_spec_enum(PROP_STATUS_S, "Indicator Status", - "Whether the indicator is shown or requests attention.", + "Whether the indicator is shown or requests attention. Defaults to 'off'.", CUSTOM_INDICATOR_TYPE_INDICATOR_STATUS, CUSTOM_INDICATOR_STATUS_OFF, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property(object_class, PROP_ICON_NAME, + g_param_spec_string(PROP_ICON_NAME_S, + "An icon for the indicator", + "The default icon that is shown for the indicator.", + NULL, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property(object_class, PROP_ATTENTION_ICON_NAME, + g_param_spec_string(PROP_ATTENTION_ICON_NAME_S, + "An icon to show when the indicator request attention.", + "If the indicator sets it's status to 'attention' then this icon is shown.", + NULL, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property(object_class, PROP_MENU, + g_param_spec_object(PROP_MENU_S, + "The Menu for the indicator", + "A DBus Menu Server object that can have a menu attached to it. The object from this menu will be sent across the bus for the client to connect to and signal.", + DBUSMENU_TYPE_SERVER, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + return; } -- cgit v1.2.3 From bf1efc1c4c15401798a7d3a3b8ebb9533a9e79a5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 19 Oct 2009 14:11:58 -0500 Subject: Header comments and a new signal that we'll need to deal with. --- src/libcustomindicator/custom-indicator.h | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/libcustomindicator/custom-indicator.h b/src/libcustomindicator/custom-indicator.h index 0ac8808..a311c63 100644 --- a/src/libcustomindicator/custom-indicator.h +++ b/src/libcustomindicator/custom-indicator.h @@ -52,12 +52,46 @@ typedef enum { /*< prefix=CUSTOM_INDICATOR_STATUS >*/ typedef struct _CustomIndicator CustomIndicator; typedef struct _CustomIndicatorClass CustomIndicatorClass; +/** + CustomIndicatorClass: + @parent_class: Mia familia + @connection_changed: Slot for #CustomIndicator::connection-changed. + @custom_indicator_reserved_1: Reserved for future use. + @custom_indicator_reserved_2: Reserved for future use. + @custom_indicator_reserved_3: Reserved for future use. + @custom_indicator_reserved_4: Reserved for future use. + + The signals and external functions that make up the #CustomIndicator + class object. +*/ struct _CustomIndicatorClass { + /* Parent */ GObjectClass parent_class; + + /* Signals */ + void (* connection_changed) (CustomIndicator * indicator, + gboolean connected, + gpointer user_data); + + /* Reserved */ + void (*custom_indicator_reserved_1)(void); + void (*custom_indicator_reserved_2)(void); + void (*custom_indicator_reserved_3)(void); + void (*custom_indicator_reserved_4)(void); }; +/** + CustomIndicator: + @parent: Parent object. + + A custom indicator represents the values that are needed to show a + unique status in the panel for an application. In general, applications + should try to fit in the other indicators that are available on the + panel before using this. But, sometimes it is necissary. +*/ struct _CustomIndicator { GObject parent; + /* None. We're a very private object. */ }; /* GObject Stuff */ -- cgit v1.2.3 From 6587e75ac6f1c20b53b37afd49c936c59eaa99d1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 19 Oct 2009 14:35:26 -0500 Subject: Adding in the dbus signals from that interface. --- src/libcustomindicator/custom-indicator.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/libcustomindicator/custom-indicator.h b/src/libcustomindicator/custom-indicator.h index a311c63..d9322e7 100644 --- a/src/libcustomindicator/custom-indicator.h +++ b/src/libcustomindicator/custom-indicator.h @@ -55,6 +55,9 @@ typedef struct _CustomIndicatorClass CustomIndicatorClass; /** CustomIndicatorClass: @parent_class: Mia familia + @new_icon: Slot for #CustomIndicator::new-icon. + @new_attention_icon: Slot for #CustomIndicator::new-attention-icon. + @new_status: Slot for #CustomIndicator::new-status. @connection_changed: Slot for #CustomIndicator::connection-changed. @custom_indicator_reserved_1: Reserved for future use. @custom_indicator_reserved_2: Reserved for future use. @@ -68,7 +71,16 @@ struct _CustomIndicatorClass { /* Parent */ GObjectClass parent_class; - /* Signals */ + /* DBus Signals */ + void (* new_icon) (CustomIndicator * indicator, + gpointer user_data); + void (* new_attention_icon) (CustomIndicator * indicator, + gpointer user_data); + void (* new_status) (CustomIndicator * indicator, + gchar * status_string, + gpointer user_data); + + /* Local Signals */ void (* connection_changed) (CustomIndicator * indicator, gboolean connected, gpointer user_data); -- cgit v1.2.3 From 9dbe19dd59b0d42a4b4c33150bed0db4c31295f2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 19 Oct 2009 16:22:24 -0500 Subject: Boom, there are some signals. --- src/libcustomindicator/custom-indicator.c | 82 ++++++++++++++++++++++++++++++- src/libcustomindicator/custom-indicator.h | 5 ++ 2 files changed, 86 insertions(+), 1 deletion(-) diff --git a/src/libcustomindicator/custom-indicator.c b/src/libcustomindicator/custom-indicator.c index 7fb8fb8..314493f 100644 --- a/src/libcustomindicator/custom-indicator.c +++ b/src/libcustomindicator/custom-indicator.c @@ -7,14 +7,31 @@ #include "libcustomindicator/custom-indicator.h" #include "libcustomindicator/custom-indicator-enum-types.h" +/** + CustomIndicatorPrivate: + + All of the private data in an instance of a + custom indicator. +*/ typedef struct _CustomIndicatorPrivate CustomIndicatorPrivate; struct _CustomIndicatorPrivate { int placeholder; }; +/* Signals Stuff */ +enum { + NEW_ICON, + NEW_ATTENTION_ICON, + NEW_STATUS, + CONNECTION_CHANGED, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + /* Enum for the properties so that they can be quickly found and looked up. */ -enum properties { +enum { PROP_0, PROP_ID, PROP_CATEGORY, @@ -108,6 +125,69 @@ custom_indicator_class_init (CustomIndicatorClass *klass) DBUSMENU_TYPE_SERVER, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + /* Signals */ + + /** + CustomIndicator::new-icon: + @arg0: The #CustomIndicator object + + Signaled when there is a new icon set for the + object. + */ + signals[NEW_ICON] = g_signal_new (CUSTOM_INDICATOR_SIGNAL_NEW_ICON, + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (CustomIndicatorClass, new_icon), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0, G_TYPE_NONE); + + /** + CustomIndicator::new-attention-icon: + @arg0: The #CustomIndicator object + + Signaled when there is a new attention icon set for the + object. + */ + signals[NEW_ATTENTION_ICON] = g_signal_new (CUSTOM_INDICATOR_SIGNAL_NEW_ATTENTION_ICON, + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (CustomIndicatorClass, new_attention_icon), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0, G_TYPE_NONE); + + /** + CustomIndicator::new-status: + @arg0: The #CustomIndicator object + @arg1: The string value of the #CustomIndicatorStatus enum. + + Signaled when the status of the indicator changes. + */ + signals[NEW_STATUS] = g_signal_new (CUSTOM_INDICATOR_SIGNAL_NEW_STATUS, + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (CustomIndicatorClass, new_status), + NULL, NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, 1, G_TYPE_STRING, G_TYPE_NONE); + + /** + CustomIndicator::connection-changed: + @arg0: The #CustomIndicator object + @arg1: Whether we're connected or not + + Signaled when we connect to a watcher, or when it drops + away. + */ + signals[CONNECTION_CHANGED] = g_signal_new (CUSTOM_INDICATOR_SIGNAL_CONNECTION_CHANGED, + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (CustomIndicatorClass, connection_changed), + NULL, NULL, + g_cclosure_marshal_VOID__BOOLEAN, + G_TYPE_NONE, 1, G_TYPE_BOOLEAN, G_TYPE_NONE); + return; } diff --git a/src/libcustomindicator/custom-indicator.h b/src/libcustomindicator/custom-indicator.h index d9322e7..a4fc3f1 100644 --- a/src/libcustomindicator/custom-indicator.h +++ b/src/libcustomindicator/custom-indicator.h @@ -13,6 +13,11 @@ G_BEGIN_DECLS #define IS_CUSTOM_INDICATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CUSTOM_INDICATOR_TYPE)) #define CUSTOM_INDICATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CUSTOM_INDICATOR_TYPE, CustomIndicatorClass)) +#define CUSTOM_INDICATOR_SIGNAL_NEW_ICON "new-icon" +#define CUSTOM_INDICATOR_SIGNAL_NEW_ATTENTION_ICON "new-attention-icon" +#define CUSTOM_INDICATOR_SIGNAL_NEW_STATUS "new-status" +#define CUSTOM_INDICATOR_SIGNAL_CONNECTION_CHANGED "connection-changed" + /** CustomIndicatorCategory: @CUSTOM_INDICATOR_CATEGORY_APPLICATION_STATUS: The indicator is used to display the status of the application. -- cgit v1.2.3 From b82c8da3f4ace3aa62097f2c3ea2b92c7d553191 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 19 Oct 2009 16:44:59 -0500 Subject: Creating a connected property to check easily. --- src/libcustomindicator/custom-indicator.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/libcustomindicator/custom-indicator.c b/src/libcustomindicator/custom-indicator.c index 314493f..d59e1c5 100644 --- a/src/libcustomindicator/custom-indicator.c +++ b/src/libcustomindicator/custom-indicator.c @@ -38,7 +38,8 @@ enum { PROP_STATUS, PROP_ICON_NAME, PROP_ATTENTION_ICON_NAME, - PROP_MENU + PROP_MENU, + PROP_CONNECTED }; /* The strings so that they can be slowly looked up. */ @@ -48,6 +49,7 @@ enum { #define PROP_ICON_NAME_S "icon-name" #define PROP_ATTENTION_ICON_NAME_S "attention-icon-name" #define PROP_MENU_S "menu" +#define PROP_CONNECTED_S "connected" /* Private macro, shhhh! */ #define CUSTOM_INDICATOR_GET_PRIVATE(o) \ @@ -125,6 +127,14 @@ custom_indicator_class_init (CustomIndicatorClass *klass) DBUSMENU_TYPE_SERVER, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property(object_class, PROP_CONNECTED, + g_param_spec_boolean(PROP_CONNECTED_S, + "Whether we're conneced to a watcher", + "Pretty simple, true if we have a reasonable expectation of being displayed through this object. You should hide your TrayIcon if so.", + FALSE, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + + /* Signals */ /** -- cgit v1.2.3 From 56cd30a60f5629f6d4afa5642c351b27838afa2d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Oct 2009 09:59:57 -0500 Subject: Basic property case statements. --- src/libcustomindicator/custom-indicator.c | 44 +++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/libcustomindicator/custom-indicator.c b/src/libcustomindicator/custom-indicator.c index d59e1c5..4ac2014 100644 --- a/src/libcustomindicator/custom-indicator.c +++ b/src/libcustomindicator/custom-indicator.c @@ -233,13 +233,57 @@ custom_indicator_set_property (GObject * object, guint prop_id, const GValue * v CustomIndicatorPrivate * priv = CUSTOM_INDICATOR_GET_PRIVATE(self); g_return_if_fail(priv != NULL); + switch (prop_id) { + case PROP_ID: + break; + case PROP_CATEGORY: + break; + case PROP_STATUS: + break; + case PROP_ICON_NAME: + break; + case PROP_ATTENTION_ICON_NAME: + break; + case PROP_MENU: + break; + case PROP_CONNECTED: + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } + return; } static void custom_indicator_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec) { + CustomIndicator * self = CUSTOM_INDICATOR(object); + g_return_if_fail(self != NULL); + + CustomIndicatorPrivate * priv = CUSTOM_INDICATOR_GET_PRIVATE(self); + g_return_if_fail(priv != NULL); + switch (prop_id) { + case PROP_ID: + break; + case PROP_CATEGORY: + break; + case PROP_STATUS: + break; + case PROP_ICON_NAME: + break; + case PROP_ATTENTION_ICON_NAME: + break; + case PROP_MENU: + break; + case PROP_CONNECTED: + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } return; } -- cgit v1.2.3 From b52ac88ee82bfb37898f52df8ab22d7b9a25b87e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Oct 2009 13:23:13 -0500 Subject: Adding in a bunch of things to the private struct. We now have data! --- src/libcustomindicator/custom-indicator.c | 32 +++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/libcustomindicator/custom-indicator.c b/src/libcustomindicator/custom-indicator.c index 4ac2014..706d749 100644 --- a/src/libcustomindicator/custom-indicator.c +++ b/src/libcustomindicator/custom-indicator.c @@ -2,20 +2,37 @@ #include "config.h" #endif -#include "libdbusmenu-glib/server.h" +#include +#include #include "libcustomindicator/custom-indicator.h" #include "libcustomindicator/custom-indicator-enum-types.h" /** CustomIndicatorPrivate: + @id: The ID of the indicator. Maps to CustomIndicator::id. + @category: Which category the indicator is. Maps to CustomIndicator::category. + @status: The status of the indicator. Maps to CustomIndicator::status. + @icon_name: The name of the icon to use. Maps to CustomIndicator::icon-name. + @attention_icon_name: The name of the attention icon to use. Maps to CustomIndicator::attention-icon-name. + @menu: The menu for this indicator. Maps to CustomIndicator::menu + @watcher_proxy: The proxy connection to the watcher we're connected to. If we're not connected to one this will be #NULL. All of the private data in an instance of a custom indicator. */ typedef struct _CustomIndicatorPrivate CustomIndicatorPrivate; struct _CustomIndicatorPrivate { - int placeholder; + /* Properties */ + gchar * id; + CustomIndicatorCategory category; + CustomIndicatorStatus status; + gchar * icon_name; + gchar * attention_icon_name; + DbusmenuServer * menu; + + /* Fun stuff */ + DBusGProxy * watcher_proxy; }; /* Signals Stuff */ @@ -204,6 +221,17 @@ custom_indicator_class_init (CustomIndicatorClass *klass) static void custom_indicator_init (CustomIndicator *self) { + CustomIndicatorPrivate * priv = CUSTOM_INDICATOR_GET_PRIVATE(self); + g_return_if_fail(priv != NULL); + + priv->id = NULL; + priv->category = CUSTOM_INDICATOR_CATEGORY_OTHER; + priv->status = CUSTOM_INDICATOR_STATUS_OFF; + priv->icon_name = NULL; + priv->attention_icon_name = NULL; + priv->menu = NULL; + + priv->watcher_proxy = NULL; return; } -- cgit v1.2.3 From 23fdc8658b5c0c2ad6900b85975b1b758604ce11 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Oct 2009 14:16:22 -0500 Subject: Fleshing out get parameters... --- src/libcustomindicator/custom-indicator.c | 77 +++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/src/libcustomindicator/custom-indicator.c b/src/libcustomindicator/custom-indicator.c index 706d749..56bc28f 100644 --- a/src/libcustomindicator/custom-indicator.c +++ b/src/libcustomindicator/custom-indicator.c @@ -80,6 +80,8 @@ static void custom_indicator_finalize (GObject *object); /* Property functions */ static void custom_indicator_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); static void custom_indicator_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); +/* Other stuff */ +static void check_connect (CustomIndicator * self); /* GObject type */ G_DEFINE_TYPE (CustomIndicator, custom_indicator, G_TYPE_OBJECT); @@ -263,6 +265,7 @@ custom_indicator_set_property (GObject * object, guint prop_id, const GValue * v switch (prop_id) { case PROP_ID: + check_connect(self); break; case PROP_CATEGORY: break; @@ -284,6 +287,8 @@ custom_indicator_set_property (GObject * object, guint prop_id, const GValue * v return; } +#define WARN_BAD_TYPE(prop, value) g_warning("Can not get property '%s' with value of type '%s'.", prop, G_VALUE_TYPE_NAME(value)) +/* Function to fill our value with the property it's requesting. */ static void custom_indicator_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec) { @@ -294,20 +299,81 @@ custom_indicator_get_property (GObject * object, guint prop_id, GValue * value, g_return_if_fail(priv != NULL); switch (prop_id) { + /* *********************** */ case PROP_ID: + if (G_VALUE_HOLDS_STRING(value)) { + g_value_set_string(value, priv->id); + } else { + WARN_BAD_TYPE(PROP_ID_S, value); + } break; + /* *********************** */ case PROP_CATEGORY: + if (G_VALUE_HOLDS_INT(value)) { + /* We want the enum value */ + g_value_set_int(value, priv->category); + } else if (G_VALUE_HOLDS_STRING(value)) { + GParamSpecEnum * enumspec = G_PARAM_SPEC_ENUM(pspec); + if (enumspec != NULL) { + GEnumValue * enumval = g_enum_get_value(enumspec->enum_class, priv->category); + g_value_set_string(value, enumval->value_nick); + } else { + g_assert_not_reached(); + } + } else { + WARN_BAD_TYPE(PROP_CATEGORY_S, value); + } break; + /* *********************** */ case PROP_STATUS: + if (G_VALUE_HOLDS_INT(value)) { + /* We want the enum value */ + g_value_set_int(value, priv->status); + } else if (G_VALUE_HOLDS_STRING(value)) { + GParamSpecEnum * enumspec = G_PARAM_SPEC_ENUM(pspec); + if (enumspec != NULL) { + GEnumValue * enumval = g_enum_get_value(enumspec->enum_class, priv->status); + g_value_set_string(value, enumval->value_nick); + } else { + g_assert_not_reached(); + } + } else { + WARN_BAD_TYPE(PROP_STATUS_S, value); + } break; + /* *********************** */ case PROP_ICON_NAME: + if (G_VALUE_HOLDS_STRING(value)) { + g_value_set_string(value, priv->icon_name); + } else { + WARN_BAD_TYPE(PROP_ICON_NAME_S, value); + } break; + /* *********************** */ case PROP_ATTENTION_ICON_NAME: + if (G_VALUE_HOLDS_STRING(value)) { + g_value_set_string(value, priv->attention_icon_name); + } else { + WARN_BAD_TYPE(PROP_ATTENTION_ICON_NAME_S, value); + } break; + /* *********************** */ case PROP_MENU: + if (G_VALUE_HOLDS_OBJECT(value)) { + g_value_set_object(value, priv->menu); + } else { + WARN_BAD_TYPE(PROP_MENU_S, value); + } break; + /* *********************** */ case PROP_CONNECTED: + if (G_VALUE_HOLDS_BOOLEAN(value)) { + g_value_set_boolean(value, priv->watcher_proxy != NULL ? TRUE : FALSE); + } else { + WARN_BAD_TYPE(PROP_CONNECTED_S, value); + } break; + /* *********************** */ default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -315,3 +381,14 @@ custom_indicator_get_property (GObject * object, guint prop_id, GValue * value, return; } + +/* This function is used to see if we have enough information to + connect to things. If we do, and we're not connected, it + connects for us. */ +static void +check_connect (CustomIndicator * self) +{ + + + +} -- cgit v1.2.3 From 59d8fbd0166729a3272a39a1197b29d9b898ee36 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Oct 2009 16:42:08 -0500 Subject: Now for some 'set' code. Bringin' it. --- src/libcustomindicator/custom-indicator.c | 104 +++++++++++++++++++++++++++++- 1 file changed, 101 insertions(+), 3 deletions(-) diff --git a/src/libcustomindicator/custom-indicator.c b/src/libcustomindicator/custom-indicator.c index 56bc28f..229eaef 100644 --- a/src/libcustomindicator/custom-indicator.c +++ b/src/libcustomindicator/custom-indicator.c @@ -254,6 +254,9 @@ custom_indicator_finalize (GObject *object) return; } +#define WARN_BAD_TYPE(prop, value) g_warning("Can not work with property '%s' with value of type '%s'.", prop, G_VALUE_TYPE_NAME(value)) + +/* Set some properties */ static void custom_indicator_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { @@ -264,21 +267,117 @@ custom_indicator_set_property (GObject * object, guint prop_id, const GValue * v g_return_if_fail(priv != NULL); switch (prop_id) { + /* *********************** */ case PROP_ID: + if (G_VALUE_HOLDS_STRING(value)) { + if (priv->id != NULL) { + g_warning("Resetting ID value when I already had a value of: %s", priv->id); + g_free(priv->id); + priv->id = NULL; + } + priv->id = g_strdup(g_value_get_string(value)); + } else { + WARN_BAD_TYPE(PROP_ID_S, value); + } check_connect(self); break; + /* *********************** */ case PROP_CATEGORY: + if (G_VALUE_HOLDS_INT(value)) { + priv->category = g_value_get_int(value); + } else if (G_VALUE_HOLDS_STRING(value)) { + GParamSpecEnum * enumspec = G_PARAM_SPEC_ENUM(pspec); + if (enumspec != NULL) { + GEnumValue * enumval = g_enum_get_value_by_nick(enumspec->enum_class, g_value_get_string(value)); + if (enumval != NULL) { + priv->category = enumval->value; + } else { + g_error("Value '%s' is not in the '%s' property enum.", g_value_get_string(value), PROP_CATEGORY_S); + } + } else { + g_assert_not_reached(); + } + } else { + WARN_BAD_TYPE(PROP_CATEGORY_S, value); + } break; + /* *********************** */ case PROP_STATUS: + if (G_VALUE_HOLDS_INT(value)) { + priv->status = g_value_get_int(value); + } else if (G_VALUE_HOLDS_STRING(value)) { + GParamSpecEnum * enumspec = G_PARAM_SPEC_ENUM(pspec); + if (enumspec != NULL) { + GEnumValue * enumval = g_enum_get_value_by_nick(enumspec->enum_class, g_value_get_string(value)); + if (enumval != NULL) { + priv->status = enumval->value; + } else { + g_error("Value '%s' is not in the '%s' property enum.", g_value_get_string(value), PROP_STATUS_S); + } + } else { + g_assert_not_reached(); + } + } else { + WARN_BAD_TYPE(PROP_STATUS_S, value); + } break; + /* *********************** */ case PROP_ICON_NAME: + if (G_VALUE_HOLDS_STRING(value)) { + const gchar * instr = g_value_get_string(value); + gboolean changed = FALSE; + if (priv->icon_name == NULL) { + priv->icon_name = g_strdup(instr); + changed = TRUE; + } else if (!g_strcmp0(instr, priv->icon_name)) { + changed = FALSE; + } else { + g_free(priv->icon_name); + priv->icon_name = g_strdup(instr); + changed = TRUE; + } + if (changed) { + g_signal_emit(object, signals[NEW_ICON], 0, TRUE); + } + } else { + WARN_BAD_TYPE(PROP_ICON_NAME_S, value); + } break; + /* *********************** */ case PROP_ATTENTION_ICON_NAME: + if (G_VALUE_HOLDS_STRING(value)) { + const gchar * instr = g_value_get_string(value); + gboolean changed = FALSE; + if (priv->attention_icon_name == NULL) { + priv->attention_icon_name = g_strdup(instr); + changed = TRUE; + } else if (!g_strcmp0(instr, priv->attention_icon_name)) { + changed = FALSE; + } else { + g_free(priv->attention_icon_name); + priv->attention_icon_name = g_strdup(instr); + changed = TRUE; + } + if (changed) { + g_signal_emit(object, signals[NEW_ATTENTION_ICON], 0, TRUE); + } + } else { + WARN_BAD_TYPE(PROP_ATTENTION_ICON_NAME_S, value); + } break; + /* *********************** */ case PROP_MENU: + if (G_VALUE_HOLDS_OBJECT(value)) { + if (priv->menu != NULL) { + g_object_unref(G_OBJECT(priv->menu)); + } + priv->menu = DBUSMENU_SERVER(g_value_get_object(value)); + g_object_ref(G_OBJECT(priv->menu)); + } else { + WARN_BAD_TYPE(PROP_MENU_S, value); + } break; - case PROP_CONNECTED: - break; + /* *********************** */ default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -287,7 +386,6 @@ custom_indicator_set_property (GObject * object, guint prop_id, const GValue * v return; } -#define WARN_BAD_TYPE(prop, value) g_warning("Can not get property '%s' with value of type '%s'.", prop, G_VALUE_TYPE_NAME(value)) /* Function to fill our value with the property it's requesting. */ static void custom_indicator_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec) -- cgit v1.2.3 From 484b489a81fcfa902bee346b8c158274de8a44f4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Oct 2009 16:57:57 -0500 Subject: Making sure to free and unref all of our private variables. --- src/libcustomindicator/custom-indicator.c | 49 +++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/libcustomindicator/custom-indicator.c b/src/libcustomindicator/custom-indicator.c index 229eaef..82abd0e 100644 --- a/src/libcustomindicator/custom-indicator.c +++ b/src/libcustomindicator/custom-indicator.c @@ -238,17 +238,66 @@ custom_indicator_init (CustomIndicator *self) return; } +/* Free all objects, make sure that all the dbus + signals are sent out before we shut this down. */ static void custom_indicator_dispose (GObject *object) { + CustomIndicator * self = CUSTOM_INDICATOR(object); + g_return_if_fail(self != NULL); + + CustomIndicatorPrivate * priv = CUSTOM_INDICATOR_GET_PRIVATE(self); + g_return_if_fail(priv != NULL); + + if (priv->status != CUSTOM_INDICATOR_STATUS_OFF) { + custom_indicator_set_status(self, CUSTOM_INDICATOR_STATUS_OFF); + } + + if (priv->menu != NULL) { + g_object_unref(G_OBJECT(priv->menu)); + priv->menu = NULL; + } + + if (priv->watcher_proxy != NULL) { + DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); + dbus_g_connection_flush(session_bus); + g_object_unref(G_OBJECT(priv->watcher_proxy)); + priv->watcher_proxy = NULL; + } G_OBJECT_CLASS (custom_indicator_parent_class)->dispose (object); return; } +/* Free all of the memory that we could be using in + the object. */ static void custom_indicator_finalize (GObject *object) { + CustomIndicator * self = CUSTOM_INDICATOR(object); + g_return_if_fail(self != NULL); + + CustomIndicatorPrivate * priv = CUSTOM_INDICATOR_GET_PRIVATE(self); + g_return_if_fail(priv != NULL); + + if (priv->status != CUSTOM_INDICATOR_STATUS_OFF) { + g_warning("Finalizing Custom Status with the status set to: %d", priv->status); + } + + if (priv->id != NULL) { + g_free(priv->id); + priv->id = NULL; + } + + if (priv->icon_name != NULL) { + g_free(priv->icon_name); + priv->icon_name = NULL; + } + + if (priv->attention_icon_name != NULL) { + g_free(priv->attention_icon_name); + priv->attention_icon_name = NULL; + } G_OBJECT_CLASS (custom_indicator_parent_class)->finalize (object); return; -- cgit v1.2.3 From 81afbd1f77b832d8ebef880a5ae6f8869b6a663c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Oct 2009 17:06:34 -0500 Subject: Okay, connecting this little thing into DBus already. --- src/libcustomindicator/custom-indicator.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/libcustomindicator/custom-indicator.c b/src/libcustomindicator/custom-indicator.c index 82abd0e..a4081cd 100644 --- a/src/libcustomindicator/custom-indicator.c +++ b/src/libcustomindicator/custom-indicator.c @@ -8,6 +8,9 @@ #include "libcustomindicator/custom-indicator.h" #include "libcustomindicator/custom-indicator-enum-types.h" +#include "notification-item-server.h" +#include "notification-watcher-client.h" + /** CustomIndicatorPrivate: @id: The ID of the indicator. Maps to CustomIndicator::id. @@ -216,6 +219,10 @@ custom_indicator_class_init (CustomIndicatorClass *klass) NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN, G_TYPE_NONE, 1, G_TYPE_BOOLEAN, G_TYPE_NONE); + + /* Initialize the object as a DBus type */ + dbus_g_object_type_install_info(CUSTOM_INDICATOR_TYPE, + &dbus_glib__notification_item_server_object_info); return; } @@ -235,6 +242,18 @@ custom_indicator_init (CustomIndicator *self) priv->watcher_proxy = NULL; + /* Put the object on DBus */ + GError * error = NULL; + DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error); + if (error != NULL) { + g_error("Unable to connect to the session bus when creating custom indicator: %s", error->message); + g_error_free(error); + return; + } + dbus_g_connection_register_g_object(connection, + "/need/a/path", + G_OBJECT(self)); + return; } -- cgit v1.2.3 From 08c19ed67d51834c079f4f1ccf12393628740731 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Oct 2009 17:18:48 -0500 Subject: Filling out some prototypes. --- src/libcustomindicator/custom-indicator.c | 90 +++++++++++++++++++++++++++++++ src/libcustomindicator/custom-indicator.h | 3 +- 2 files changed, 92 insertions(+), 1 deletion(-) diff --git a/src/libcustomindicator/custom-indicator.c b/src/libcustomindicator/custom-indicator.c index a4081cd..127084d 100644 --- a/src/libcustomindicator/custom-indicator.c +++ b/src/libcustomindicator/custom-indicator.c @@ -558,3 +558,93 @@ check_connect (CustomIndicator * self) } + + +/* ************************* */ +/* Public Functions */ +/* ************************* */ + +void +custom_indicator_set_id (CustomIndicator * ci, const gchar * id) +{ + + return; +} + +void +custom_indicator_set_category (CustomIndicator * ci, CustomIndicatorCategory category) +{ + + return; +} + +void +custom_indicator_set_status (CustomIndicator * ci, CustomIndicatorStatus status) +{ + + return; +} + +void custom_indicator_set_icon (CustomIndicator * ci, const gchar * icon_name) +{ + + return; +} + +void +custom_indicator_set_attention_icon (CustomIndicator * ci, const gchar * icon_name) +{ + + return; +} + +void +custom_indicator_set_menu (CustomIndicator * ci, void * menu) +{ + + return; +} + +const gchar * +custom_indicator_get_id (CustomIndicator * ci) +{ + + return NULL; +} + +CustomIndicatorCategory +custom_indicator_get_category (CustomIndicator * ci) +{ + + return CUSTOM_INDICATOR_CATEGORY_OTHER; +} + +CustomIndicatorStatus +custom_indicator_get_status (CustomIndicator * ci) +{ + + return CUSTOM_INDICATOR_STATUS_OFF; +} + +const gchar * +custom_indicator_get_icon (CustomIndicator * ci) +{ + + return NULL; +} + +const gchar * +custom_indicator_get_attention_icon (CustomIndicator * ci) +{ + + return NULL; +} + +DbusmenuServer * +custom_indicator_get_menu (CustomIndicator * ci) +{ + + return NULL; +} + + diff --git a/src/libcustomindicator/custom-indicator.h b/src/libcustomindicator/custom-indicator.h index a4fc3f1..b6bb228 100644 --- a/src/libcustomindicator/custom-indicator.h +++ b/src/libcustomindicator/custom-indicator.h @@ -3,6 +3,7 @@ #include #include +#include G_BEGIN_DECLS @@ -134,7 +135,7 @@ CustomIndicatorCategory custom_indicator_get_category (CustomIndic CustomIndicatorStatus custom_indicator_get_status (CustomIndicator * ci); const gchar * custom_indicator_get_icon (CustomIndicator * ci); const gchar * custom_indicator_get_attention_icon (CustomIndicator * ci); -void * custom_indicator_get_menu (CustomIndicator * ci); +DbusmenuServer * custom_indicator_get_menu (CustomIndicator * ci); G_END_DECLS -- cgit v1.2.3 From e932bfa4e6ba766d12fb4193cd4d2e7c24645784 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Oct 2009 22:07:29 -0500 Subject: Fleshing out the set functions. --- src/libcustomindicator/custom-indicator.c | 74 ++++++++++++++++++++++++++++--- src/libcustomindicator/custom-indicator.h | 2 +- 2 files changed, 68 insertions(+), 8 deletions(-) diff --git a/src/libcustomindicator/custom-indicator.c b/src/libcustomindicator/custom-indicator.c index 127084d..530f035 100644 --- a/src/libcustomindicator/custom-indicator.c +++ b/src/libcustomindicator/custom-indicator.c @@ -564,44 +564,104 @@ check_connect (CustomIndicator * self) /* Public Functions */ /* ************************* */ +/** + custom_indicator_set_id: + @ci: The #CustomIndicator object to use + @id: ID to set for this indicator + + Wrapper function for property #CustomIndicator::id. +*/ void custom_indicator_set_id (CustomIndicator * ci, const gchar * id) { - + GValue value = {0}; + g_value_init(&value, G_TYPE_STRING); + g_value_set_string(&value, id); + g_object_set_property(G_OBJECT(ci), PROP_ID_S, &value); return; } +/** + custom_indicator_set_category: + @ci: The #CustomIndicator object to use + @category: The category to set for this indicator + + Wrapper function for property #CustomIndicator::category. +*/ void custom_indicator_set_category (CustomIndicator * ci, CustomIndicatorCategory category) { - + GValue value = {0}; + g_value_init(&value, G_TYPE_ENUM); + g_value_set_enum(&value, category); + g_object_set_property(G_OBJECT(ci), PROP_CATEGORY_S, &value); return; } +/** + custom_indicator_set_status: + @ci: The #CustomIndicator object to use + @status: The status to set for this indicator + + Wrapper function for property #CustomIndicator::status. +*/ void custom_indicator_set_status (CustomIndicator * ci, CustomIndicatorStatus status) { - + GValue value = {0}; + g_value_init(&value, G_TYPE_ENUM); + g_value_set_enum(&value, status); + g_object_set_property(G_OBJECT(ci), PROP_STATUS_S, &value); return; } +/** + custom_indicator_set_icon: + @ci: The #CustomIndicator object to use + @icon_name: The name of the icon to set for this indicator + + Wrapper function for property #CustomIndicator::icon. +*/ void custom_indicator_set_icon (CustomIndicator * ci, const gchar * icon_name) { - + GValue value = {0}; + g_value_init(&value, G_TYPE_STRING); + g_value_set_string(&value, icon_name); + g_object_set_property(G_OBJECT(ci), PROP_ICON_NAME_S, &value); return; } +/** + custom_indicator_set_attention_icon: + @ci: The #CustomIndicator object to use + @icon_name: The name of the attention icon to set for this indicator + + Wrapper function for property #CustomIndicator::attention-icon. +*/ void custom_indicator_set_attention_icon (CustomIndicator * ci, const gchar * icon_name) { - + GValue value = {0}; + g_value_init(&value, G_TYPE_STRING); + g_value_set_string(&value, icon_name); + g_object_set_property(G_OBJECT(ci), PROP_ATTENTION_ICON_NAME_S, &value); return; } +/** + custom_indicator_set_menu: + @ci: The #CustomIndicator object to use + @menu: The object with the menu for the indicator + + Wrapper function for property #CustomIndicator::menu. +*/ void -custom_indicator_set_menu (CustomIndicator * ci, void * menu) +custom_indicator_set_menu (CustomIndicator * ci, DbusmenuServer * menu) { - + GValue value = {0}; + g_value_init(&value, G_TYPE_OBJECT); + g_value_set_object(&value, G_OBJECT(menu)); + g_object_set_property(G_OBJECT(ci), PROP_MENU_S, &value); return; } diff --git a/src/libcustomindicator/custom-indicator.h b/src/libcustomindicator/custom-indicator.h index b6bb228..fd2ddc7 100644 --- a/src/libcustomindicator/custom-indicator.h +++ b/src/libcustomindicator/custom-indicator.h @@ -127,7 +127,7 @@ void custom_indicator_set_icon (CustomIndic void custom_indicator_set_attention_icon (CustomIndicator * ci, const gchar * icon_name); void custom_indicator_set_menu (CustomIndicator * ci, - void * menu); + DbusmenuServer * menu); /* Get properties */ const gchar * custom_indicator_get_id (CustomIndicator * ci); -- cgit v1.2.3 From ada3399cdf75c37fbd5485f44a714e82b888b245 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Oct 2009 22:39:45 -0500 Subject: Fleshing out the get functions. --- src/libcustomindicator/custom-indicator.c | 84 ++++++++++++++++++++++++++----- 1 file changed, 72 insertions(+), 12 deletions(-) diff --git a/src/libcustomindicator/custom-indicator.c b/src/libcustomindicator/custom-indicator.c index 530f035..d28f60e 100644 --- a/src/libcustomindicator/custom-indicator.c +++ b/src/libcustomindicator/custom-indicator.c @@ -665,46 +665,106 @@ custom_indicator_set_menu (CustomIndicator * ci, DbusmenuServer * menu) return; } +/** + custom_indicator_get_id: + @ci: The #CustomIndicator object to use + + Wrapper function for property #CustomIndicator::id. + + Return value: The current ID +*/ const gchar * custom_indicator_get_id (CustomIndicator * ci) { - - return NULL; + GValue value = {0}; + g_value_init(&value, G_TYPE_STRING); + g_object_get_property(G_OBJECT(ci), PROP_ID_S, &value); + return g_value_get_string(&value); } +/** + custom_indicator_get_category: + @ci: The #CustomIndicator object to use + + Wrapper function for property #CustomIndicator::category. + + Return value: The current category. +*/ CustomIndicatorCategory custom_indicator_get_category (CustomIndicator * ci) { - - return CUSTOM_INDICATOR_CATEGORY_OTHER; + GValue value = {0}; + g_value_init(&value, G_TYPE_ENUM); + g_object_get_property(G_OBJECT(ci), PROP_CATEGORY_S, &value); + return g_value_get_enum(&value); } +/** + custom_indicator_get_status: + @ci: The #CustomIndicator object to use + + Wrapper function for property #CustomIndicator::status. + + Return value: The current status. +*/ CustomIndicatorStatus custom_indicator_get_status (CustomIndicator * ci) { - - return CUSTOM_INDICATOR_STATUS_OFF; + GValue value = {0}; + g_value_init(&value, G_TYPE_ENUM); + g_object_get_property(G_OBJECT(ci), PROP_STATUS_S, &value); + return g_value_get_enum(&value); } +/** + custom_indicator_get_icon: + @ci: The #CustomIndicator object to use + + Wrapper function for property #CustomIndicator::icon-name. + + Return value: The current icon name. +*/ const gchar * custom_indicator_get_icon (CustomIndicator * ci) { - - return NULL; + GValue value = {0}; + g_value_init(&value, G_TYPE_STRING); + g_object_get_property(G_OBJECT(ci), PROP_ICON_NAME_S, &value); + return g_value_get_string(&value); } +/** + custom_indicator_get_attention_icon: + @ci: The #CustomIndicator object to use + + Wrapper function for property #CustomIndicator::attention-icon-name. + + Return value: The current attention icon name. +*/ const gchar * custom_indicator_get_attention_icon (CustomIndicator * ci) { - - return NULL; + GValue value = {0}; + g_value_init(&value, G_TYPE_STRING); + g_object_get_property(G_OBJECT(ci), PROP_ATTENTION_ICON_NAME_S, &value); + return g_value_get_string(&value); } +/** + custom_indicator_get_menu: + @ci: The #CustomIndicator object to use + + Wrapper function for property #CustomIndicator::menu. + + Return value: The current menu being used. +*/ DbusmenuServer * custom_indicator_get_menu (CustomIndicator * ci) { - - return NULL; + GValue value = {0}; + g_value_init(&value, G_TYPE_OBJECT); + g_object_get_property(G_OBJECT(ci), PROP_MENU_S, &value); + return DBUSMENU_SERVER(g_value_get_object(&value)); } -- cgit v1.2.3 From d28010e3f12c8d7e03fa6ef9233b3f1d3ebfaac2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Oct 2009 23:23:31 -0500 Subject: Tests directory. --- Makefile.am | 3 ++- configure.ac | 1 + tests/Makefile.am | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 tests/Makefile.am diff --git a/Makefile.am b/Makefile.am index fb738a5..4eb69d7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,6 @@ SUBDIRS = data \ - src + src \ + tests DISTCHECK_CONFIGURE_FLAGS = --enable-localinstall diff --git a/configure.ac b/configure.ac index ae39426..015677c 100644 --- a/configure.ac +++ b/configure.ac @@ -80,6 +80,7 @@ AC_OUTPUT([ Makefile src/Makefile data/Makefile +tests/Makefile ]) ########################### diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..82ec364 --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,3 @@ + +# Something here + -- cgit v1.2.3 From 5e928c9ce0cbeaa1a1050a7c0e8f10fb7027514c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Oct 2009 23:47:20 -0500 Subject: Now we're building a test, woot! --- .bzrignore | 5 +++++ tests/Makefile.am | 25 ++++++++++++++++++++++++- tests/test-libcustomindicator.c | 14 ++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 tests/test-libcustomindicator.c diff --git a/.bzrignore b/.bzrignore index 8470e82..d413452 100644 --- a/.bzrignore +++ b/.bzrignore @@ -15,3 +15,8 @@ src/libcustomindicator/custom-indicator-enum-types.h src/libcustomindicator/custom-indicator-enum-types.c src/stamp-enum-types src/libcustomindicator_la-custom-indicator-enum-types.lo +tests/.deps +tests/.libs +tests/libcustomindicator-check-results.xml +tests/libcustomindicator-check-results.html +tests/test-libcustomindicator diff --git a/tests/Makefile.am b/tests/Makefile.am index 82ec364..4044617 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,3 +1,26 @@ -# Something here +check_PROGRAMS = \ + test-libcustomindicator + +test_libcustomindicator_SOURCES = \ + test-libcustomindicator.c + +test_libcustomindicator_CFLAGS = \ + $(INDICATOR_CFLAGS) \ + -Wall -Werror \ + -I$(top_srcdir)/src + +test_libcustomindicator_LDADD = \ + $(INDICATOR_LIBS) \ + $(top_builddir)/src/libcustomindicator.la + +XML_REPORT = libcustomindicator-check-results.xml +HTML_REPORT = libcustomindicator-check-results.html + +libcustomindicator-tester: test-libcustomindicator + gtester -o=$(XML_REPORT) ./test-libcustomindicator + +check-local: libcustomindicator-tester + +DISTCLEANFILES = $(XML_REPORT) $(HTML_REPORT) diff --git a/tests/test-libcustomindicator.c b/tests/test-libcustomindicator.c new file mode 100644 index 0000000..fab411d --- /dev/null +++ b/tests/test-libcustomindicator.c @@ -0,0 +1,14 @@ + +#include +#include + +gint +main (gint argc, gchar * argv[]) +{ + g_type_init(); + g_test_init(&argc, &argv, NULL); + + /* Test suites */ + + return g_test_run (); +} -- cgit v1.2.3 From 10e95506d81335d394b9cd955b7728b528c0fe4e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 21 Oct 2009 09:23:21 -0500 Subject: Woot! We can build a custom indicator, and it exists. --- tests/test-libcustomindicator.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/test-libcustomindicator.c b/tests/test-libcustomindicator.c index fab411d..6dc9fe9 100644 --- a/tests/test-libcustomindicator.c +++ b/tests/test-libcustomindicator.c @@ -2,6 +2,25 @@ #include #include +#include + +void +test_libcustomindicator_init (void) +{ + CustomIndicator * ci = CUSTOM_INDICATOR(g_object_new(CUSTOM_INDICATOR_TYPE, NULL)); + g_assert(ci != NULL); + g_object_unref(G_OBJECT(ci)); +} + +void +test_libcustomindicator_props_suite (void) +{ + g_test_add_func ("/indicator-custom/libcustomindicator/init", test_libcustomindicator_init); + + + return; +} + gint main (gint argc, gchar * argv[]) { @@ -9,6 +28,8 @@ main (gint argc, gchar * argv[]) g_test_init(&argc, &argv, NULL); /* Test suites */ + test_libcustomindicator_props_suite(); + return g_test_run (); } -- cgit v1.2.3 From 0093c378498e9d203012a143e49137f72d8168ce Mon Sep 17 00:00:00 2001 From: Cody Russell Date: Wed, 21 Oct 2009 09:33:57 -0500 Subject: Ah, forgot a return. Cody would kill me! Oh, no. --- tests/test-libcustomindicator.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test-libcustomindicator.c b/tests/test-libcustomindicator.c index 6dc9fe9..c264bfa 100644 --- a/tests/test-libcustomindicator.c +++ b/tests/test-libcustomindicator.c @@ -10,6 +10,7 @@ test_libcustomindicator_init (void) CustomIndicator * ci = CUSTOM_INDICATOR(g_object_new(CUSTOM_INDICATOR_TYPE, NULL)); g_assert(ci != NULL); g_object_unref(G_OBJECT(ci)); + return; } void -- cgit v1.2.3 From 795f7d94377f9093e8b3b064e7e020c4f753293d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 21 Oct 2009 11:14:09 -0500 Subject: Adding a test that sets a bunch of properties. --- tests/test-libcustomindicator.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/tests/test-libcustomindicator.c b/tests/test-libcustomindicator.c index c264bfa..1736efa 100644 --- a/tests/test-libcustomindicator.c +++ b/tests/test-libcustomindicator.c @@ -4,6 +4,28 @@ #include +void +test_libcustomindicator_init_with_props (void) +{ + CustomIndicator * ci = CUSTOM_INDICATOR(g_object_new(CUSTOM_INDICATOR_TYPE, + "id", "my-id", + "category", CUSTOM_INDICATOR_CATEGORY_APPLICATION_STATUS, + "status", CUSTOM_INDICATOR_STATUS_ON, + "icon-name", "my-name", + "attention-icon-name", "my-attention-name", + NULL)); + g_assert(ci != NULL); + + g_assert(!g_strcmp0("my-id", custom_indicator_get_id(ci))); + g_assert(!g_strcmp0("my-name", custom_indicator_get_icon(ci))); + g_assert(!g_strcmp0("my-attention-name", custom_indicator_get_attention_icon(ci))); + g_assert(custom_indicator_get_status(ci) == CUSTOM_INDICATOR_STATUS_ON); + g_assert(custom_indicator_get_category(ci) == CUSTOM_INDICATOR_CATEGORY_APPLICATION_STATUS); + + g_object_unref(G_OBJECT(ci)); + return; +} + void test_libcustomindicator_init (void) { @@ -16,7 +38,8 @@ test_libcustomindicator_init (void) void test_libcustomindicator_props_suite (void) { - g_test_add_func ("/indicator-custom/libcustomindicator/init", test_libcustomindicator_init); + g_test_add_func ("/indicator-custom/libcustomindicator/init", test_libcustomindicator_init); + g_test_add_func ("/indicator-custom/libcustomindicator/init_props", test_libcustomindicator_init_with_props); return; -- cgit v1.2.3 From fdd9a5da2db6332c63f005d964cf6466a3735c4d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 21 Oct 2009 11:31:44 -0500 Subject: Silly, these are enums not ints. --- src/libcustomindicator/custom-indicator.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libcustomindicator/custom-indicator.c b/src/libcustomindicator/custom-indicator.c index d28f60e..d1e95ac 100644 --- a/src/libcustomindicator/custom-indicator.c +++ b/src/libcustomindicator/custom-indicator.c @@ -351,8 +351,8 @@ custom_indicator_set_property (GObject * object, guint prop_id, const GValue * v break; /* *********************** */ case PROP_CATEGORY: - if (G_VALUE_HOLDS_INT(value)) { - priv->category = g_value_get_int(value); + if (G_VALUE_HOLDS_ENUM(value)) { + priv->category = g_value_get_enum(value); } else if (G_VALUE_HOLDS_STRING(value)) { GParamSpecEnum * enumspec = G_PARAM_SPEC_ENUM(pspec); if (enumspec != NULL) { @@ -371,8 +371,8 @@ custom_indicator_set_property (GObject * object, guint prop_id, const GValue * v break; /* *********************** */ case PROP_STATUS: - if (G_VALUE_HOLDS_INT(value)) { - priv->status = g_value_get_int(value); + if (G_VALUE_HOLDS_ENUM(value)) { + priv->status = g_value_get_enum(value); } else if (G_VALUE_HOLDS_STRING(value)) { GParamSpecEnum * enumspec = G_PARAM_SPEC_ENUM(pspec); if (enumspec != NULL) { @@ -475,9 +475,9 @@ custom_indicator_get_property (GObject * object, guint prop_id, GValue * value, break; /* *********************** */ case PROP_CATEGORY: - if (G_VALUE_HOLDS_INT(value)) { + if (G_VALUE_HOLDS_ENUM(value)) { /* We want the enum value */ - g_value_set_int(value, priv->category); + g_value_set_enum(value, priv->category); } else if (G_VALUE_HOLDS_STRING(value)) { GParamSpecEnum * enumspec = G_PARAM_SPEC_ENUM(pspec); if (enumspec != NULL) { @@ -492,9 +492,9 @@ custom_indicator_get_property (GObject * object, guint prop_id, GValue * value, break; /* *********************** */ case PROP_STATUS: - if (G_VALUE_HOLDS_INT(value)) { + if (G_VALUE_HOLDS_ENUM(value)) { /* We want the enum value */ - g_value_set_int(value, priv->status); + g_value_set_enum(value, priv->status); } else if (G_VALUE_HOLDS_STRING(value)) { GParamSpecEnum * enumspec = G_PARAM_SPEC_ENUM(pspec); if (enumspec != NULL) { -- cgit v1.2.3 From d11f7e6d29609b8d36d834cf9ff229a576c1fe89 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 21 Oct 2009 11:35:30 -0500 Subject: Switching from doing the GValues as enums to the more specific types. --- src/libcustomindicator/custom-indicator.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libcustomindicator/custom-indicator.c b/src/libcustomindicator/custom-indicator.c index d1e95ac..c16f052 100644 --- a/src/libcustomindicator/custom-indicator.c +++ b/src/libcustomindicator/custom-indicator.c @@ -592,7 +592,7 @@ void custom_indicator_set_category (CustomIndicator * ci, CustomIndicatorCategory category) { GValue value = {0}; - g_value_init(&value, G_TYPE_ENUM); + g_value_init(&value, CUSTOM_INDICATOR_TYPE_INDICATOR_CATEGORY); g_value_set_enum(&value, category); g_object_set_property(G_OBJECT(ci), PROP_CATEGORY_S, &value); return; @@ -609,7 +609,7 @@ void custom_indicator_set_status (CustomIndicator * ci, CustomIndicatorStatus status) { GValue value = {0}; - g_value_init(&value, G_TYPE_ENUM); + g_value_init(&value, CUSTOM_INDICATOR_TYPE_INDICATOR_STATUS); g_value_set_enum(&value, status); g_object_set_property(G_OBJECT(ci), PROP_STATUS_S, &value); return; @@ -694,7 +694,7 @@ CustomIndicatorCategory custom_indicator_get_category (CustomIndicator * ci) { GValue value = {0}; - g_value_init(&value, G_TYPE_ENUM); + g_value_init(&value, CUSTOM_INDICATOR_TYPE_INDICATOR_CATEGORY); g_object_get_property(G_OBJECT(ci), PROP_CATEGORY_S, &value); return g_value_get_enum(&value); } @@ -711,7 +711,7 @@ CustomIndicatorStatus custom_indicator_get_status (CustomIndicator * ci) { GValue value = {0}; - g_value_init(&value, G_TYPE_ENUM); + g_value_init(&value, CUSTOM_INDICATOR_TYPE_INDICATOR_STATUS); g_object_get_property(G_OBJECT(ci), PROP_STATUS_S, &value); return g_value_get_enum(&value); } -- cgit v1.2.3 From dc43af9a9e3aa1965bf3d9994f8733cdaf588912 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 21 Oct 2009 11:40:23 -0500 Subject: Checking all the set functions. --- tests/test-libcustomindicator.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/test-libcustomindicator.c b/tests/test-libcustomindicator.c index 1736efa..ecc187b 100644 --- a/tests/test-libcustomindicator.c +++ b/tests/test-libcustomindicator.c @@ -4,6 +4,28 @@ #include +void +test_libcustomindicator_init_set_props (void) +{ + CustomIndicator * ci = CUSTOM_INDICATOR(g_object_new(CUSTOM_INDICATOR_TYPE, NULL)); + g_assert(ci != NULL); + + custom_indicator_set_id(ci, "my-id"); + custom_indicator_set_category(ci, CUSTOM_INDICATOR_CATEGORY_APPLICATION_STATUS); + custom_indicator_set_status(ci, CUSTOM_INDICATOR_STATUS_ON); + custom_indicator_set_icon(ci, "my-name"); + custom_indicator_set_attention_icon(ci, "my-attention-name"); + + g_assert(!g_strcmp0("my-id", custom_indicator_get_id(ci))); + g_assert(!g_strcmp0("my-name", custom_indicator_get_icon(ci))); + g_assert(!g_strcmp0("my-attention-name", custom_indicator_get_attention_icon(ci))); + g_assert(custom_indicator_get_status(ci) == CUSTOM_INDICATOR_STATUS_ON); + g_assert(custom_indicator_get_category(ci) == CUSTOM_INDICATOR_CATEGORY_APPLICATION_STATUS); + + g_object_unref(G_OBJECT(ci)); + return; +} + void test_libcustomindicator_init_with_props (void) { @@ -40,6 +62,7 @@ test_libcustomindicator_props_suite (void) { g_test_add_func ("/indicator-custom/libcustomindicator/init", test_libcustomindicator_init); g_test_add_func ("/indicator-custom/libcustomindicator/init_props", test_libcustomindicator_init_with_props); + g_test_add_func ("/indicator-custom/libcustomindicator/init_set_props", test_libcustomindicator_init_set_props); return; -- cgit v1.2.3 From 5e1d1d9aee14f8771f89c98004299575a35e89b7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 21 Oct 2009 12:06:19 -0500 Subject: Adding test to test the property change signals. --- tests/test-libcustomindicator.c | 83 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 82 insertions(+), 1 deletion(-) diff --git a/tests/test-libcustomindicator.c b/tests/test-libcustomindicator.c index ecc187b..1bda8b4 100644 --- a/tests/test-libcustomindicator.c +++ b/tests/test-libcustomindicator.c @@ -4,6 +4,87 @@ #include +void +test_libcustomindicator_prop_signals_status_helper (CustomIndicator * ci, CustomIndicatorStatus status, gboolean * signalactivated) +{ + *signalactivated = TRUE; + return; +} + +void +test_libcustomindicator_prop_signals_helper (CustomIndicator * ci, gboolean * signalactivated) +{ + *signalactivated = TRUE; + return; +} + +void +test_libcustomindicator_prop_signals (void) +{ + CustomIndicator * ci = CUSTOM_INDICATOR(g_object_new(CUSTOM_INDICATOR_TYPE, NULL)); + g_assert(ci != NULL); + + gboolean signaled = FALSE; + gulong handlerid; + + handlerid = 0; + handlerid = g_signal_connect(G_OBJECT(ci), "new-icon", G_CALLBACK(test_libcustomindicator_prop_signals_helper), &signaled); + g_assert(handlerid != 0); + + handlerid = 0; + handlerid = g_signal_connect(G_OBJECT(ci), "new-attention-icon", G_CALLBACK(test_libcustomindicator_prop_signals_helper), &signaled); + g_assert(handlerid != 0); + + handlerid = 0; + handlerid = g_signal_connect(G_OBJECT(ci), "new-status", G_CALLBACK(test_libcustomindicator_prop_signals_status_helper), &signaled); + g_assert(handlerid != 0); + + + signaled = FALSE; + custom_indicator_set_icon(ci, "bob"); + g_assert(signaled); + + signaled = FALSE; + custom_indicator_set_icon(ci, "bob"); + g_assert(!signaled); + + signaled = FALSE; + custom_indicator_set_icon(ci, "al"); + g_assert(signaled); + + + signaled = FALSE; + custom_indicator_set_attention_icon(ci, "bob"); + g_assert(signaled); + + signaled = FALSE; + custom_indicator_set_attention_icon(ci, "bob"); + g_assert(!signaled); + + signaled = FALSE; + custom_indicator_set_attention_icon(ci, "al"); + g_assert(signaled); + + + signaled = FALSE; + custom_indicator_set_status(ci, CUSTOM_INDICATOR_STATUS_OFF); + g_assert(!signaled); + + signaled = FALSE; + custom_indicator_set_status(ci, CUSTOM_INDICATOR_STATUS_ON); + g_assert(signaled); + + signaled = FALSE; + custom_indicator_set_status(ci, CUSTOM_INDICATOR_STATUS_ON); + g_assert(!signaled); + + signaled = FALSE; + custom_indicator_set_status(ci, CUSTOM_INDICATOR_STATUS_ATTENTION); + g_assert(signaled); + + return; +} + void test_libcustomindicator_init_set_props (void) { @@ -63,7 +144,7 @@ test_libcustomindicator_props_suite (void) g_test_add_func ("/indicator-custom/libcustomindicator/init", test_libcustomindicator_init); g_test_add_func ("/indicator-custom/libcustomindicator/init_props", test_libcustomindicator_init_with_props); g_test_add_func ("/indicator-custom/libcustomindicator/init_set_props", test_libcustomindicator_init_set_props); - + g_test_add_func ("/indicator-custom/libcustomindicator/prop_signals", test_libcustomindicator_prop_signals); return; } -- cgit v1.2.3 From b08b15860537896f3605c0c701957966995f014c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 21 Oct 2009 12:10:38 -0500 Subject: Making sure to signal if we change the status. --- src/libcustomindicator/custom-indicator.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/libcustomindicator/custom-indicator.c b/src/libcustomindicator/custom-indicator.c index c16f052..07c0f68 100644 --- a/src/libcustomindicator/custom-indicator.c +++ b/src/libcustomindicator/custom-indicator.c @@ -370,14 +370,21 @@ custom_indicator_set_property (GObject * object, guint prop_id, const GValue * v } break; /* *********************** */ - case PROP_STATUS: + case PROP_STATUS: { + gboolean changed = FALSE; if (G_VALUE_HOLDS_ENUM(value)) { + if (priv->status != g_value_get_enum(value)) { + changed = TRUE; + } priv->status = g_value_get_enum(value); } else if (G_VALUE_HOLDS_STRING(value)) { GParamSpecEnum * enumspec = G_PARAM_SPEC_ENUM(pspec); if (enumspec != NULL) { GEnumValue * enumval = g_enum_get_value_by_nick(enumspec->enum_class, g_value_get_string(value)); if (enumval != NULL) { + if (priv->status != enumval->value) { + changed = TRUE; + } priv->status = enumval->value; } else { g_error("Value '%s' is not in the '%s' property enum.", g_value_get_string(value), PROP_STATUS_S); @@ -388,7 +395,11 @@ custom_indicator_set_property (GObject * object, guint prop_id, const GValue * v } else { WARN_BAD_TYPE(PROP_STATUS_S, value); } + if (changed) { + g_signal_emit(object, signals[NEW_STATUS], 0, priv->status, TRUE); + } break; + } /* *********************** */ case PROP_ICON_NAME: if (G_VALUE_HOLDS_STRING(value)) { -- cgit v1.2.3 From 02cb52522a944ae27d9cf0e771eb7c2ae2bb8e53 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 21 Oct 2009 13:23:56 -0500 Subject: The signal should have a string not a enum value. --- src/libcustomindicator/custom-indicator.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libcustomindicator/custom-indicator.c b/src/libcustomindicator/custom-indicator.c index 07c0f68..002db14 100644 --- a/src/libcustomindicator/custom-indicator.c +++ b/src/libcustomindicator/custom-indicator.c @@ -396,7 +396,11 @@ custom_indicator_set_property (GObject * object, guint prop_id, const GValue * v WARN_BAD_TYPE(PROP_STATUS_S, value); } if (changed) { - g_signal_emit(object, signals[NEW_STATUS], 0, priv->status, TRUE); + GParamSpecEnum * enumspec = G_PARAM_SPEC_ENUM(pspec); + if (enumspec != NULL) { + GEnumValue * enumval = g_enum_get_value(enumspec->enum_class, priv->status); + g_signal_emit(object, signals[NEW_STATUS], 0, enumval->value_nick, TRUE); + } } break; } -- cgit v1.2.3 From 5aeff27144282c008771e3f049b2f5ba0398a532 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 21 Oct 2009 13:24:21 -0500 Subject: Getting the prototype right. --- tests/test-libcustomindicator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-libcustomindicator.c b/tests/test-libcustomindicator.c index 1bda8b4..b4b4084 100644 --- a/tests/test-libcustomindicator.c +++ b/tests/test-libcustomindicator.c @@ -5,7 +5,7 @@ #include void -test_libcustomindicator_prop_signals_status_helper (CustomIndicator * ci, CustomIndicatorStatus status, gboolean * signalactivated) +test_libcustomindicator_prop_signals_status_helper (CustomIndicator * ci, gchar * status, gboolean * signalactivated) { *signalactivated = TRUE; return; -- cgit v1.2.3 From 5e34573c2cff345a2aa3c972ec4a0150f4c4183e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 21 Oct 2009 14:03:18 -0500 Subject: Turning on verbose output and showing the status of all tests. --- tests/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 4044617..865573b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -18,7 +18,7 @@ XML_REPORT = libcustomindicator-check-results.xml HTML_REPORT = libcustomindicator-check-results.html libcustomindicator-tester: test-libcustomindicator - gtester -o=$(XML_REPORT) ./test-libcustomindicator + gtester -k --verbose -o=$(XML_REPORT) ./test-libcustomindicator check-local: libcustomindicator-tester -- cgit v1.2.3 From 0df50d723494e795aa7447c02ac0f15611b2bfd8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 21 Oct 2009 15:42:13 -0500 Subject: Change the enums to match the KDE ones to make life simpler even though I dislike the names. --- src/libcustomindicator/custom-indicator.c | 10 +++++----- src/libcustomindicator/custom-indicator.h | 8 ++++---- tests/test-libcustomindicator.c | 14 +++++++------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/libcustomindicator/custom-indicator.c b/src/libcustomindicator/custom-indicator.c index 002db14..6efccc0 100644 --- a/src/libcustomindicator/custom-indicator.c +++ b/src/libcustomindicator/custom-indicator.c @@ -125,7 +125,7 @@ custom_indicator_class_init (CustomIndicatorClass *klass) "Indicator Status", "Whether the indicator is shown or requests attention. Defaults to 'off'.", CUSTOM_INDICATOR_TYPE_INDICATOR_STATUS, - CUSTOM_INDICATOR_STATUS_OFF, + CUSTOM_INDICATOR_STATUS_PASSIVE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property(object_class, PROP_ICON_NAME, @@ -235,7 +235,7 @@ custom_indicator_init (CustomIndicator *self) priv->id = NULL; priv->category = CUSTOM_INDICATOR_CATEGORY_OTHER; - priv->status = CUSTOM_INDICATOR_STATUS_OFF; + priv->status = CUSTOM_INDICATOR_STATUS_PASSIVE; priv->icon_name = NULL; priv->attention_icon_name = NULL; priv->menu = NULL; @@ -268,8 +268,8 @@ custom_indicator_dispose (GObject *object) CustomIndicatorPrivate * priv = CUSTOM_INDICATOR_GET_PRIVATE(self); g_return_if_fail(priv != NULL); - if (priv->status != CUSTOM_INDICATOR_STATUS_OFF) { - custom_indicator_set_status(self, CUSTOM_INDICATOR_STATUS_OFF); + if (priv->status != CUSTOM_INDICATOR_STATUS_PASSIVE) { + custom_indicator_set_status(self, CUSTOM_INDICATOR_STATUS_PASSIVE); } if (priv->menu != NULL) { @@ -299,7 +299,7 @@ custom_indicator_finalize (GObject *object) CustomIndicatorPrivate * priv = CUSTOM_INDICATOR_GET_PRIVATE(self); g_return_if_fail(priv != NULL); - if (priv->status != CUSTOM_INDICATOR_STATUS_OFF) { + if (priv->status != CUSTOM_INDICATOR_STATUS_PASSIVE) { g_warning("Finalizing Custom Status with the status set to: %d", priv->status); } diff --git a/src/libcustomindicator/custom-indicator.h b/src/libcustomindicator/custom-indicator.h index fd2ddc7..2e9045c 100644 --- a/src/libcustomindicator/custom-indicator.h +++ b/src/libcustomindicator/custom-indicator.h @@ -40,8 +40,8 @@ typedef enum { /*< prefix=CUSTOM_INDICATOR_CATEGORY >*/ /** CustomIndicatorStatus: - @CUSTOM_INDICATOR_STATUS_OFF: The indicator should not be shown to the user. - @CUSTOM_INDICATOR_STATUS_ON: The indicator should be shown in it's default state. + @CUSTOM_INDICATOR_STATUS_PASSIVE: The indicator should not be shown to the user. + @CUSTOM_INDICATOR_STATUS_ACTIVE: The indicator should be shown in it's default state. @CUSTOM_INDICATOR_STATUS_ATTENTION: The indicator should show it's attention icon. These are the states that the indicator can be on in @@ -50,8 +50,8 @@ typedef enum { /*< prefix=CUSTOM_INDICATOR_CATEGORY >*/ shown by setting it to @CUSTOM_INDICATOR_STATUS_ON. */ typedef enum { /*< prefix=CUSTOM_INDICATOR_STATUS >*/ - CUSTOM_INDICATOR_STATUS_OFF, - CUSTOM_INDICATOR_STATUS_ON, + CUSTOM_INDICATOR_STATUS_PASSIVE, + CUSTOM_INDICATOR_STATUS_ACTIVE, CUSTOM_INDICATOR_STATUS_ATTENTION } CustomIndicatorStatus; diff --git a/tests/test-libcustomindicator.c b/tests/test-libcustomindicator.c index b4b4084..b3ead63 100644 --- a/tests/test-libcustomindicator.c +++ b/tests/test-libcustomindicator.c @@ -67,15 +67,15 @@ test_libcustomindicator_prop_signals (void) signaled = FALSE; - custom_indicator_set_status(ci, CUSTOM_INDICATOR_STATUS_OFF); + custom_indicator_set_status(ci, CUSTOM_INDICATOR_STATUS_PASSIVE); g_assert(!signaled); signaled = FALSE; - custom_indicator_set_status(ci, CUSTOM_INDICATOR_STATUS_ON); + custom_indicator_set_status(ci, CUSTOM_INDICATOR_STATUS_ACTIVE); g_assert(signaled); signaled = FALSE; - custom_indicator_set_status(ci, CUSTOM_INDICATOR_STATUS_ON); + custom_indicator_set_status(ci, CUSTOM_INDICATOR_STATUS_ACTIVE); g_assert(!signaled); signaled = FALSE; @@ -93,14 +93,14 @@ test_libcustomindicator_init_set_props (void) custom_indicator_set_id(ci, "my-id"); custom_indicator_set_category(ci, CUSTOM_INDICATOR_CATEGORY_APPLICATION_STATUS); - custom_indicator_set_status(ci, CUSTOM_INDICATOR_STATUS_ON); + custom_indicator_set_status(ci, CUSTOM_INDICATOR_STATUS_ACTIVE); custom_indicator_set_icon(ci, "my-name"); custom_indicator_set_attention_icon(ci, "my-attention-name"); g_assert(!g_strcmp0("my-id", custom_indicator_get_id(ci))); g_assert(!g_strcmp0("my-name", custom_indicator_get_icon(ci))); g_assert(!g_strcmp0("my-attention-name", custom_indicator_get_attention_icon(ci))); - g_assert(custom_indicator_get_status(ci) == CUSTOM_INDICATOR_STATUS_ON); + g_assert(custom_indicator_get_status(ci) == CUSTOM_INDICATOR_STATUS_ACTIVE); g_assert(custom_indicator_get_category(ci) == CUSTOM_INDICATOR_CATEGORY_APPLICATION_STATUS); g_object_unref(G_OBJECT(ci)); @@ -113,7 +113,7 @@ test_libcustomindicator_init_with_props (void) CustomIndicator * ci = CUSTOM_INDICATOR(g_object_new(CUSTOM_INDICATOR_TYPE, "id", "my-id", "category", CUSTOM_INDICATOR_CATEGORY_APPLICATION_STATUS, - "status", CUSTOM_INDICATOR_STATUS_ON, + "status", CUSTOM_INDICATOR_STATUS_ACTIVE, "icon-name", "my-name", "attention-icon-name", "my-attention-name", NULL)); @@ -122,7 +122,7 @@ test_libcustomindicator_init_with_props (void) g_assert(!g_strcmp0("my-id", custom_indicator_get_id(ci))); g_assert(!g_strcmp0("my-name", custom_indicator_get_icon(ci))); g_assert(!g_strcmp0("my-attention-name", custom_indicator_get_attention_icon(ci))); - g_assert(custom_indicator_get_status(ci) == CUSTOM_INDICATOR_STATUS_ON); + g_assert(custom_indicator_get_status(ci) == CUSTOM_INDICATOR_STATUS_ACTIVE); g_assert(custom_indicator_get_category(ci) == CUSTOM_INDICATOR_CATEGORY_APPLICATION_STATUS); g_object_unref(G_OBJECT(ci)); -- cgit v1.2.3 From bca9b7ee96632e7c89092184c174b45722e0511c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 22 Oct 2009 09:20:36 -0500 Subject: Adding in two little client server binaries for testing the custom indicator. --- .bzrignore | 2 ++ tests/Makefile.am | 46 ++++++++++++++++++++++++++++- tests/test-defines.h | 7 +++++ tests/test-libcustomindicator-dbus-client.c | 11 +++++++ tests/test-libcustomindicator-dbus-server.c | 11 +++++++ 5 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 tests/test-defines.h create mode 100644 tests/test-libcustomindicator-dbus-client.c create mode 100644 tests/test-libcustomindicator-dbus-server.c diff --git a/.bzrignore b/.bzrignore index d413452..6c0da1f 100644 --- a/.bzrignore +++ b/.bzrignore @@ -20,3 +20,5 @@ tests/.libs tests/libcustomindicator-check-results.xml tests/libcustomindicator-check-results.html tests/test-libcustomindicator +tests/test-libcustomindicator-dbus-client +tests/test-libcustomindicator-dbus-server diff --git a/tests/Makefile.am b/tests/Makefile.am index 865573b..8327a79 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,6 +1,12 @@ check_PROGRAMS = \ - test-libcustomindicator + test-libcustomindicator \ + test-libcustomindicator-dbus-client \ + test-libcustomindicator-dbus-server + +######################################### +## test-libcustomindicator +######################################### test_libcustomindicator_SOURCES = \ test-libcustomindicator.c @@ -14,6 +20,44 @@ test_libcustomindicator_LDADD = \ $(INDICATOR_LIBS) \ $(top_builddir)/src/libcustomindicator.la +######################################### +## test-libcustomindicator-dbus-client +######################################### + +test_libcustomindicator_dbus_client_SOURCES = \ + test-defines.h \ + test-libcustomindicator-dbus-client.c + +test_libcustomindicator_dbus_client_CFLAGS = \ + $(INDICATOR_CFLAGS) \ + -Wall -Werror \ + -I$(top_srcdir)/src + +test_libcustomindicator_dbus_client_LDADD = \ + $(INDICATOR_LIBS) \ + $(top_builddir)/src/libcustomindicator.la + +######################################### +## test-libcustomindicator-dbus-server +######################################### + +test_libcustomindicator_dbus_server_SOURCES = \ + test-defines.h \ + test-libcustomindicator-dbus-server.c + +test_libcustomindicator_dbus_server_CFLAGS = \ + $(INDICATOR_CFLAGS) \ + -Wall -Werror \ + -I$(top_srcdir)/src + +test_libcustomindicator_dbus_server_LDADD = \ + $(INDICATOR_LIBS) \ + $(top_builddir)/src/libcustomindicator.la + +######################################### +## Actual tests +######################################### + XML_REPORT = libcustomindicator-check-results.xml HTML_REPORT = libcustomindicator-check-results.html diff --git a/tests/test-defines.h b/tests/test-defines.h new file mode 100644 index 0000000..b68d9fc --- /dev/null +++ b/tests/test-defines.h @@ -0,0 +1,7 @@ + +#define TEST_ID "my-id" +#define TEST_ICON_NAME "my-icon-name" +#define TEST_ATTENTION_ICON_NAME "my-attention-icon-name" +#define TEST_STATE CUSTOM_INDICATOR_STATE_ACTIVE +#define TEST_CATEGORY CUSTOM_INDICATOR_CATEGORY_APPLICATION_STATUS + diff --git a/tests/test-libcustomindicator-dbus-client.c b/tests/test-libcustomindicator-dbus-client.c new file mode 100644 index 0000000..7c3de86 --- /dev/null +++ b/tests/test-libcustomindicator-dbus-client.c @@ -0,0 +1,11 @@ + +#include +#include +#include "test-defines.h" + +gint +main (gint argc, gchar * argv[]) +{ + + return 0; +} diff --git a/tests/test-libcustomindicator-dbus-server.c b/tests/test-libcustomindicator-dbus-server.c new file mode 100644 index 0000000..7c3de86 --- /dev/null +++ b/tests/test-libcustomindicator-dbus-server.c @@ -0,0 +1,11 @@ + +#include +#include +#include "test-defines.h" + +gint +main (gint argc, gchar * argv[]) +{ + + return 0; +} -- cgit v1.2.3 From 23b72422d828dd77909f6cc11947f9fb5e8cee2c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 22 Oct 2009 09:30:59 -0500 Subject: Switching to using a little autotest as well. --- .bzrignore | 2 ++ tests/Makefile.am | 22 ++++++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/.bzrignore b/.bzrignore index 6c0da1f..7121e6e 100644 --- a/.bzrignore +++ b/.bzrignore @@ -22,3 +22,5 @@ tests/libcustomindicator-check-results.html tests/test-libcustomindicator tests/test-libcustomindicator-dbus-client tests/test-libcustomindicator-dbus-server +tests/libcustomindicator-tests +tests/test-libcustomindicator-dbus diff --git a/tests/Makefile.am b/tests/Makefile.am index 8327a79..f6a0525 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -4,6 +4,9 @@ check_PROGRAMS = \ test-libcustomindicator-dbus-client \ test-libcustomindicator-dbus-server +TESTS = +DISTCLEANFILES = $(TESTS) + ######################################### ## test-libcustomindicator ######################################### @@ -61,10 +64,21 @@ test_libcustomindicator_dbus_server_LDADD = \ XML_REPORT = libcustomindicator-check-results.xml HTML_REPORT = libcustomindicator-check-results.html -libcustomindicator-tester: test-libcustomindicator - gtester -k --verbose -o=$(XML_REPORT) ./test-libcustomindicator +libcustomindicator-tests: test-libcustomindicator + @echo "#!/bin/sh" > libcustomindicator-tests + @echo gtester -k --verbose -o=$(XML_REPORT) ./test-libcustomindicator >> libcustomindicator-tests + @chmod +x libcustomindicator-tests + +TESTS += libcustomindicator-tests +DISTCLEANFILES += $(XML_REPORT) $(HTML_REPORT) + + +DBUS_RUNNER=dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.conf -check-local: libcustomindicator-tester +test-libcustomindicator-dbus: test-libcustomindicator-dbus-client test-libcustomindicator-dbus-server Makefile.am + @echo "#!/bin/sh" > test-libcustomindicator-dbus + @echo $(DBUS_RUNNER) --task ./test-libcustomindicator-dbus-client --task-name Client --task ./test-libcustomindicator-dbus-server --task-name Server --ignore-return >> test-libcustomindicator-dbus + @chmod +x test-libcustomindicator-dbus -DISTCLEANFILES = $(XML_REPORT) $(HTML_REPORT) +TESTS += test-libcustomindicator-dbus -- cgit v1.2.3 From 83a3d84ea6e0bb8a9ce7927b08658307becbb186 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 22 Oct 2009 09:46:17 -0500 Subject: Fleshing out the server to setup a simple custom indicator. --- tests/test-defines.h | 2 +- tests/test-libcustomindicator-dbus-server.c | 30 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/tests/test-defines.h b/tests/test-defines.h index b68d9fc..73ab316 100644 --- a/tests/test-defines.h +++ b/tests/test-defines.h @@ -2,6 +2,6 @@ #define TEST_ID "my-id" #define TEST_ICON_NAME "my-icon-name" #define TEST_ATTENTION_ICON_NAME "my-attention-icon-name" -#define TEST_STATE CUSTOM_INDICATOR_STATE_ACTIVE +#define TEST_STATE CUSTOM_INDICATOR_STATUS_ACTIVE #define TEST_CATEGORY CUSTOM_INDICATOR_CATEGORY_APPLICATION_STATUS diff --git a/tests/test-libcustomindicator-dbus-server.c b/tests/test-libcustomindicator-dbus-server.c index 7c3de86..444706f 100644 --- a/tests/test-libcustomindicator-dbus-server.c +++ b/tests/test-libcustomindicator-dbus-server.c @@ -1,11 +1,41 @@ +#include +#include #include #include #include "test-defines.h" +static GMainLoop * mainloop = NULL; + +gboolean +kill_func (gpointer userdata) +{ + g_main_loop_quit(mainloop); + return FALSE; +} + gint main (gint argc, gchar * argv[]) { + g_type_init(); + + g_debug("DBus ID: %s", dbus_connection_get_server_id(dbus_g_connection_get_connection(dbus_g_bus_get(DBUS_BUS_SESSION, NULL)))); + + CustomIndicator * ci = CUSTOM_INDICATOR(g_object_new(CUSTOM_INDICATOR_TYPE, + "id", TEST_ID, + "category", TEST_CATEGORY, + "status", TEST_STATE, + "icon-name", TEST_ICON_NAME, + "attention-icon-name", TEST_ATTENTION_ICON_NAME, + NULL)); + + g_timeout_add_seconds(2, kill_func, NULL); + + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + g_object_unref(G_OBJECT(ci)); + g_debug("Quiting"); return 0; } -- cgit v1.2.3 From a8b100939f7473874d858683229c2021b8ce6be6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 22 Oct 2009 11:24:06 -0500 Subject: Basic code calling all the properties. --- tests/test-libcustomindicator-dbus-client.c | 147 ++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) diff --git a/tests/test-libcustomindicator-dbus-client.c b/tests/test-libcustomindicator-dbus-client.c index 7c3de86..8e49059 100644 --- a/tests/test-libcustomindicator-dbus-client.c +++ b/tests/test-libcustomindicator-dbus-client.c @@ -1,11 +1,158 @@ #include +#include #include #include "test-defines.h" +static GMainLoop * mainloop = NULL; +static gboolean passed = TRUE; +static int propcount = 0; + +static void +check_propcount (void) +{ + + return; +} + + +static void +prop_id_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) +{ + propcount++; + + GError * error = NULL; + GValue value = {0}; + + if (!dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_VALUE, &value, G_TYPE_INVALID)) { + g_warning("Getting ID failed: %s", error->message); + g_error_free(error); + passed = FALSE; + check_propcount(); + return; + } + + if (g_strcmp0(TEST_ID, g_value_get_string(&value))) { + g_debug("Property ID Returned: FAILED"); + passed = FALSE; + } else { + g_debug("Property ID Returned: PASSED"); + } + + return; +} + +static void +prop_category_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) +{ + + return; +} + +static void +prop_status_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) +{ + + return; +} + +static void +prop_icon_name_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) +{ + + return; +} + +static void +prop_attention_icon_name_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) +{ + + return; +} + +static void +prop_menu_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) +{ + + return; +} + gint main (gint argc, gchar * argv[]) { + g_type_init(); + + g_usleep(500000); + + GError * error = NULL; + DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error); + if (error != NULL) { + g_error("Unable to get session bus: %s", error->message); + return 1; + } + + DBusGProxy * props = dbus_g_proxy_new_for_name_owner(session_bus, + ":1.0", + "/test", + DBUS_INTERFACE_PROPERTIES, + &error); + if (error != NULL) { + g_error("Unable to get property proxy: %s", error->message); + return 1; + } + + dbus_g_proxy_begin_call (props, + "Get", + prop_id_cb, + NULL, NULL, + G_TYPE_STRING, "org.ayatana.indicator.custom.NotificationItem", + G_TYPE_STRING, "Id", + G_TYPE_INVALID); + dbus_g_proxy_begin_call (props, + "Get", + prop_category_cb, + NULL, NULL, + G_TYPE_STRING, "org.ayatana.indicator.custom.NotificationItem", + G_TYPE_STRING, "Category", + G_TYPE_INVALID); + dbus_g_proxy_begin_call (props, + "Get", + prop_status_cb, + NULL, NULL, + G_TYPE_STRING, "org.ayatana.indicator.custom.NotificationItem", + G_TYPE_STRING, "Status", + G_TYPE_INVALID); + dbus_g_proxy_begin_call (props, + "Get", + prop_icon_name_cb, + NULL, NULL, + G_TYPE_STRING, "org.ayatana.indicator.custom.NotificationItem", + G_TYPE_STRING, "IconName", + G_TYPE_INVALID); + dbus_g_proxy_begin_call (props, + "Get", + prop_attention_icon_name_cb, + NULL, NULL, + G_TYPE_STRING, "org.ayatana.indicator.custom.NotificationItem", + G_TYPE_STRING, "AttentionIconName", + G_TYPE_INVALID); + dbus_g_proxy_begin_call (props, + "Get", + prop_menu_cb, + NULL, NULL, + G_TYPE_STRING, "org.ayatana.indicator.custom.NotificationItem", + G_TYPE_STRING, "Menu", + G_TYPE_INVALID); + + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + if (passed) { + g_debug("Quiting"); + return 0; + } else { + g_debug("Quiting as we're a failure"); + return 0; + } return 0; } -- cgit v1.2.3 From e0d35fcfc64134af45aa4da81e6a8e9cd2007d16 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 22 Oct 2009 11:30:41 -0500 Subject: Adding a kill function, just in case. --- tests/test-libcustomindicator-dbus-client.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/test-libcustomindicator-dbus-client.c b/tests/test-libcustomindicator-dbus-client.c index 8e49059..c6c31f0 100644 --- a/tests/test-libcustomindicator-dbus-client.c +++ b/tests/test-libcustomindicator-dbus-client.c @@ -77,6 +77,15 @@ prop_menu_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) return; } +gboolean +kill_func (gpointer userdata) +{ + g_main_loop_quit(mainloop); + g_warning("Forced to Kill"); + passed = FALSE; + return FALSE; +} + gint main (gint argc, gchar * argv[]) { @@ -144,6 +153,8 @@ main (gint argc, gchar * argv[]) G_TYPE_STRING, "Menu", G_TYPE_INVALID); + g_timeout_add_seconds(2, kill_func, NULL); + mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); -- cgit v1.2.3 From 9db2ce55c3f314f6547a00e592f0caf8a45f8f01 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 22 Oct 2009 11:31:22 -0500 Subject: If we fail, we need to really fail. --- tests/test-libcustomindicator-dbus-client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-libcustomindicator-dbus-client.c b/tests/test-libcustomindicator-dbus-client.c index c6c31f0..0ac1071 100644 --- a/tests/test-libcustomindicator-dbus-client.c +++ b/tests/test-libcustomindicator-dbus-client.c @@ -163,7 +163,7 @@ main (gint argc, gchar * argv[]) return 0; } else { g_debug("Quiting as we're a failure"); - return 0; + return 1; } return 0; } -- cgit v1.2.3 From 199365d6ddaa30851c0a291fdfa288a8bc8ecb5f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 22 Oct 2009 14:15:53 -0500 Subject: Settng the right path --- tests/test-libcustomindicator-dbus-client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-libcustomindicator-dbus-client.c b/tests/test-libcustomindicator-dbus-client.c index 0ac1071..a506760 100644 --- a/tests/test-libcustomindicator-dbus-client.c +++ b/tests/test-libcustomindicator-dbus-client.c @@ -102,7 +102,7 @@ main (gint argc, gchar * argv[]) DBusGProxy * props = dbus_g_proxy_new_for_name_owner(session_bus, ":1.0", - "/test", + "/need/a/path", DBUS_INTERFACE_PROPERTIES, &error); if (error != NULL) { -- cgit v1.2.3 From e99a6fee70b515e68a5eda0d9e5d3e0db311d490 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 22 Oct 2009 14:21:49 -0500 Subject: Fleshing out the property counting. --- tests/test-libcustomindicator-dbus-client.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/test-libcustomindicator-dbus-client.c b/tests/test-libcustomindicator-dbus-client.c index a506760..0f3ebb9 100644 --- a/tests/test-libcustomindicator-dbus-client.c +++ b/tests/test-libcustomindicator-dbus-client.c @@ -11,7 +11,9 @@ static int propcount = 0; static void check_propcount (void) { - + if (propcount >= 6) { + g_main_loop_quit(mainloop); + } return; } @@ -39,41 +41,52 @@ prop_id_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) g_debug("Property ID Returned: PASSED"); } + check_propcount(); return; } static void prop_category_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) { + propcount++; + check_propcount(); return; } static void prop_status_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) { + propcount++; + check_propcount(); return; } static void prop_icon_name_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) { + propcount++; + check_propcount(); return; } static void prop_attention_icon_name_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) { + propcount++; + check_propcount(); return; } static void prop_menu_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) { + propcount++; + check_propcount(); return; } -- cgit v1.2.3 From af102359a5d71fa5ddfad14d3e6d3063c1801578 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 22 Oct 2009 14:26:53 -0500 Subject: All strings work. --- tests/test-libcustomindicator-dbus-client.c | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/test-libcustomindicator-dbus-client.c b/tests/test-libcustomindicator-dbus-client.c index 0f3ebb9..66922dc 100644 --- a/tests/test-libcustomindicator-dbus-client.c +++ b/tests/test-libcustomindicator-dbus-client.c @@ -68,6 +68,24 @@ prop_icon_name_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) { propcount++; + GError * error = NULL; + GValue value = {0}; + + if (!dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_VALUE, &value, G_TYPE_INVALID)) { + g_warning("Getting icon name failed: %s", error->message); + g_error_free(error); + passed = FALSE; + check_propcount(); + return; + } + + if (g_strcmp0(TEST_ICON_NAME, g_value_get_string(&value))) { + g_debug("Property icon name Returned: FAILED"); + passed = FALSE; + } else { + g_debug("Property icon name Returned: PASSED"); + } + check_propcount(); return; } @@ -77,6 +95,24 @@ prop_attention_icon_name_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * d { propcount++; + GError * error = NULL; + GValue value = {0}; + + if (!dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_VALUE, &value, G_TYPE_INVALID)) { + g_warning("Getting attention icon name failed: %s", error->message); + g_error_free(error); + passed = FALSE; + check_propcount(); + return; + } + + if (g_strcmp0(TEST_ATTENTION_ICON_NAME, g_value_get_string(&value))) { + g_debug("Property attention icon name Returned: FAILED"); + passed = FALSE; + } else { + g_debug("Property attention icon name Returned: PASSED"); + } + check_propcount(); return; } -- cgit v1.2.3 From b04e0deb68b1e245eba4bcbbf80b8d706d0250b8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 22 Oct 2009 14:30:40 -0500 Subject: Checking the category and state --- tests/test-defines.h | 2 ++ tests/test-libcustomindicator-dbus-client.c | 36 +++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/tests/test-defines.h b/tests/test-defines.h index 73ab316..2afe4f4 100644 --- a/tests/test-defines.h +++ b/tests/test-defines.h @@ -3,5 +3,7 @@ #define TEST_ICON_NAME "my-icon-name" #define TEST_ATTENTION_ICON_NAME "my-attention-icon-name" #define TEST_STATE CUSTOM_INDICATOR_STATUS_ACTIVE +#define TEST_STATE_S "active" #define TEST_CATEGORY CUSTOM_INDICATOR_CATEGORY_APPLICATION_STATUS +#define TEST_CATEGORY_S "application-status" diff --git a/tests/test-libcustomindicator-dbus-client.c b/tests/test-libcustomindicator-dbus-client.c index 66922dc..bdc0fa6 100644 --- a/tests/test-libcustomindicator-dbus-client.c +++ b/tests/test-libcustomindicator-dbus-client.c @@ -50,6 +50,24 @@ prop_category_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) { propcount++; + GError * error = NULL; + GValue value = {0}; + + if (!dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_VALUE, &value, G_TYPE_INVALID)) { + g_warning("Getting category failed: %s", error->message); + g_error_free(error); + passed = FALSE; + check_propcount(); + return; + } + + if (g_strcmp0(TEST_CATEGORY_S, g_value_get_string(&value))) { + g_debug("Property category Returned: FAILED"); + passed = FALSE; + } else { + g_debug("Property category Returned: PASSED"); + } + check_propcount(); return; } @@ -59,6 +77,24 @@ prop_status_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) { propcount++; + GError * error = NULL; + GValue value = {0}; + + if (!dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_VALUE, &value, G_TYPE_INVALID)) { + g_warning("Getting status failed: %s", error->message); + g_error_free(error); + passed = FALSE; + check_propcount(); + return; + } + + if (g_strcmp0(TEST_STATE_S, g_value_get_string(&value))) { + g_debug("Property status Returned: FAILED"); + passed = FALSE; + } else { + g_debug("Property status Returned: PASSED"); + } + check_propcount(); return; } -- cgit v1.2.3 From 00f4a538c3a3fce2aa7c8aaec5589c58f104fe4f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 22 Oct 2009 15:29:05 -0500 Subject: Adding a set of read-only properties that deal with the strings for dbus, and let the other properties do the real work. --- src/libcustomindicator/custom-indicator.c | 117 ++++++++++++++++++------------ 1 file changed, 69 insertions(+), 48 deletions(-) diff --git a/src/libcustomindicator/custom-indicator.c b/src/libcustomindicator/custom-indicator.c index 6efccc0..d37b649 100644 --- a/src/libcustomindicator/custom-indicator.c +++ b/src/libcustomindicator/custom-indicator.c @@ -55,20 +55,26 @@ enum { PROP_0, PROP_ID, PROP_CATEGORY, + PROP_CATEGORY_ENUM, PROP_STATUS, + PROP_STATUS_ENUM, PROP_ICON_NAME, PROP_ATTENTION_ICON_NAME, PROP_MENU, + PROP_MENU_OBJECT, PROP_CONNECTED }; /* The strings so that they can be slowly looked up. */ #define PROP_ID_S "id" #define PROP_CATEGORY_S "category" +#define PROP_CATEGORY_ENUM_S "category-enum" #define PROP_STATUS_S "status" +#define PROP_STATUS_ENUM_S "status-enum" #define PROP_ICON_NAME_S "icon-name" #define PROP_ATTENTION_ICON_NAME_S "attention-icon-name" #define PROP_MENU_S "menu" +#define PROP_MENU_OBJECT_S "menu-object" #define PROP_CONNECTED_S "connected" /* Private macro, shhhh! */ @@ -113,7 +119,14 @@ custom_indicator_class_init (CustomIndicatorClass *klass) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property(object_class, PROP_CATEGORY, - g_param_spec_enum(PROP_CATEGORY_S, + g_param_spec_string(PROP_CATEGORY_S, + "Indicator Category as a string", + "The type of indicator that this represents as a string. For DBus.", + NULL, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property(object_class, PROP_CATEGORY_ENUM, + g_param_spec_enum(PROP_CATEGORY_ENUM_S, "Indicator Category", "The type of indicator that this represents. Please don't use 'other'. Defaults to 'Application Status'.", CUSTOM_INDICATOR_TYPE_INDICATOR_CATEGORY, @@ -121,7 +134,14 @@ custom_indicator_class_init (CustomIndicatorClass *klass) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property(object_class, PROP_STATUS, - g_param_spec_enum(PROP_STATUS_S, + g_param_spec_string(PROP_STATUS_S, + "Indicator Status as a string", + "The status of the indicator represented as a string. For DBus.", + NULL, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property(object_class, PROP_STATUS_ENUM, + g_param_spec_enum(PROP_STATUS_ENUM_S, "Indicator Status", "Whether the indicator is shown or requests attention. Defaults to 'off'.", CUSTOM_INDICATOR_TYPE_INDICATOR_STATUS, @@ -143,7 +163,14 @@ custom_indicator_class_init (CustomIndicatorClass *klass) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property(object_class, PROP_MENU, - g_param_spec_object(PROP_MENU_S, + g_param_spec_string(PROP_MENU_S, + "The object path of the menu on DBus.", + "A method for getting the menu path as a string for DBus.", + NULL, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property(object_class, PROP_MENU_OBJECT, + g_param_spec_object(PROP_MENU_OBJECT_S, "The Menu for the indicator", "A DBus Menu Server object that can have a menu attached to it. The object from this menu will be sent across the bus for the client to connect to and signal.", DBUSMENU_TYPE_SERVER, @@ -350,50 +377,23 @@ custom_indicator_set_property (GObject * object, guint prop_id, const GValue * v check_connect(self); break; /* *********************** */ - case PROP_CATEGORY: + case PROP_CATEGORY_ENUM: if (G_VALUE_HOLDS_ENUM(value)) { priv->category = g_value_get_enum(value); - } else if (G_VALUE_HOLDS_STRING(value)) { - GParamSpecEnum * enumspec = G_PARAM_SPEC_ENUM(pspec); - if (enumspec != NULL) { - GEnumValue * enumval = g_enum_get_value_by_nick(enumspec->enum_class, g_value_get_string(value)); - if (enumval != NULL) { - priv->category = enumval->value; - } else { - g_error("Value '%s' is not in the '%s' property enum.", g_value_get_string(value), PROP_CATEGORY_S); - } - } else { - g_assert_not_reached(); - } } else { - WARN_BAD_TYPE(PROP_CATEGORY_S, value); + WARN_BAD_TYPE(PROP_CATEGORY_ENUM_S, value); } break; /* *********************** */ - case PROP_STATUS: { + case PROP_STATUS_ENUM: { gboolean changed = FALSE; if (G_VALUE_HOLDS_ENUM(value)) { if (priv->status != g_value_get_enum(value)) { changed = TRUE; } priv->status = g_value_get_enum(value); - } else if (G_VALUE_HOLDS_STRING(value)) { - GParamSpecEnum * enumspec = G_PARAM_SPEC_ENUM(pspec); - if (enumspec != NULL) { - GEnumValue * enumval = g_enum_get_value_by_nick(enumspec->enum_class, g_value_get_string(value)); - if (enumval != NULL) { - if (priv->status != enumval->value) { - changed = TRUE; - } - priv->status = enumval->value; - } else { - g_error("Value '%s' is not in the '%s' property enum.", g_value_get_string(value), PROP_STATUS_S); - } - } else { - g_assert_not_reached(); - } } else { - WARN_BAD_TYPE(PROP_STATUS_S, value); + WARN_BAD_TYPE(PROP_STATUS_ENUM_S, value); } if (changed) { GParamSpecEnum * enumspec = G_PARAM_SPEC_ENUM(pspec); @@ -490,10 +490,7 @@ custom_indicator_get_property (GObject * object, guint prop_id, GValue * value, break; /* *********************** */ case PROP_CATEGORY: - if (G_VALUE_HOLDS_ENUM(value)) { - /* We want the enum value */ - g_value_set_enum(value, priv->category); - } else if (G_VALUE_HOLDS_STRING(value)) { + if (G_VALUE_HOLDS_STRING(value)) { GParamSpecEnum * enumspec = G_PARAM_SPEC_ENUM(pspec); if (enumspec != NULL) { GEnumValue * enumval = g_enum_get_value(enumspec->enum_class, priv->category); @@ -506,11 +503,16 @@ custom_indicator_get_property (GObject * object, guint prop_id, GValue * value, } break; /* *********************** */ - case PROP_STATUS: + case PROP_CATEGORY_ENUM: if (G_VALUE_HOLDS_ENUM(value)) { /* We want the enum value */ - g_value_set_enum(value, priv->status); - } else if (G_VALUE_HOLDS_STRING(value)) { + g_value_set_enum(value, priv->category); + } else { + WARN_BAD_TYPE(PROP_CATEGORY_ENUM_S, value); + } + /* *********************** */ + case PROP_STATUS: + if (G_VALUE_HOLDS_STRING(value)) { GParamSpecEnum * enumspec = G_PARAM_SPEC_ENUM(pspec); if (enumspec != NULL) { GEnumValue * enumval = g_enum_get_value(enumspec->enum_class, priv->status); @@ -523,6 +525,15 @@ custom_indicator_get_property (GObject * object, guint prop_id, GValue * value, } break; /* *********************** */ + case PROP_STATUS_ENUM: + if (G_VALUE_HOLDS_ENUM(value)) { + /* We want the enum value */ + g_value_set_enum(value, priv->status); + } else { + WARN_BAD_TYPE(PROP_STATUS_ENUM_S, value); + } + break; + /* *********************** */ case PROP_ICON_NAME: if (G_VALUE_HOLDS_STRING(value)) { g_value_set_string(value, priv->icon_name); @@ -540,10 +551,20 @@ custom_indicator_get_property (GObject * object, guint prop_id, GValue * value, break; /* *********************** */ case PROP_MENU: + if (G_VALUE_HOLDS_STRING(value)) { + if (priv->menu != NULL) { + g_object_get_property(G_OBJECT(priv->menu), DBUSMENU_SERVER_PROP_DBUS_OBJECT, value); + } + } else { + WARN_BAD_TYPE(PROP_MENU_S, value); + } + break; + /* *********************** */ + case PROP_MENU_OBJECT: if (G_VALUE_HOLDS_OBJECT(value)) { g_value_set_object(value, priv->menu); } else { - WARN_BAD_TYPE(PROP_MENU_S, value); + WARN_BAD_TYPE(PROP_MENU_OBJECT_S, value); } break; /* *********************** */ @@ -609,7 +630,7 @@ custom_indicator_set_category (CustomIndicator * ci, CustomIndicatorCategory cat GValue value = {0}; g_value_init(&value, CUSTOM_INDICATOR_TYPE_INDICATOR_CATEGORY); g_value_set_enum(&value, category); - g_object_set_property(G_OBJECT(ci), PROP_CATEGORY_S, &value); + g_object_set_property(G_OBJECT(ci), PROP_CATEGORY_ENUM_S, &value); return; } @@ -626,7 +647,7 @@ custom_indicator_set_status (CustomIndicator * ci, CustomIndicatorStatus status) GValue value = {0}; g_value_init(&value, CUSTOM_INDICATOR_TYPE_INDICATOR_STATUS); g_value_set_enum(&value, status); - g_object_set_property(G_OBJECT(ci), PROP_STATUS_S, &value); + g_object_set_property(G_OBJECT(ci), PROP_STATUS_ENUM_S, &value); return; } @@ -676,7 +697,7 @@ custom_indicator_set_menu (CustomIndicator * ci, DbusmenuServer * menu) GValue value = {0}; g_value_init(&value, G_TYPE_OBJECT); g_value_set_object(&value, G_OBJECT(menu)); - g_object_set_property(G_OBJECT(ci), PROP_MENU_S, &value); + g_object_set_property(G_OBJECT(ci), PROP_MENU_OBJECT_S, &value); return; } @@ -710,7 +731,7 @@ custom_indicator_get_category (CustomIndicator * ci) { GValue value = {0}; g_value_init(&value, CUSTOM_INDICATOR_TYPE_INDICATOR_CATEGORY); - g_object_get_property(G_OBJECT(ci), PROP_CATEGORY_S, &value); + g_object_get_property(G_OBJECT(ci), PROP_CATEGORY_ENUM_S, &value); return g_value_get_enum(&value); } @@ -727,7 +748,7 @@ custom_indicator_get_status (CustomIndicator * ci) { GValue value = {0}; g_value_init(&value, CUSTOM_INDICATOR_TYPE_INDICATOR_STATUS); - g_object_get_property(G_OBJECT(ci), PROP_STATUS_S, &value); + g_object_get_property(G_OBJECT(ci), PROP_STATUS_ENUM_S, &value); return g_value_get_enum(&value); } @@ -778,7 +799,7 @@ custom_indicator_get_menu (CustomIndicator * ci) { GValue value = {0}; g_value_init(&value, G_TYPE_OBJECT); - g_object_get_property(G_OBJECT(ci), PROP_MENU_S, &value); + g_object_get_property(G_OBJECT(ci), PROP_MENU_OBJECT_S, &value); return DBUSMENU_SERVER(g_value_get_object(&value)); } -- cgit v1.2.3 From 0256208e255eb3aeabc21838d7eaf788cfcf190f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 22 Oct 2009 15:43:28 -0500 Subject: Gimme a break --- src/libcustomindicator/custom-indicator.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libcustomindicator/custom-indicator.c b/src/libcustomindicator/custom-indicator.c index d37b649..d7148f6 100644 --- a/src/libcustomindicator/custom-indicator.c +++ b/src/libcustomindicator/custom-indicator.c @@ -510,6 +510,7 @@ custom_indicator_get_property (GObject * object, guint prop_id, GValue * value, } else { WARN_BAD_TYPE(PROP_CATEGORY_ENUM_S, value); } + break; /* *********************** */ case PROP_STATUS: if (G_VALUE_HOLDS_STRING(value)) { -- cgit v1.2.3 From 6a255c63e5030a5ab992184dec39f791eedaa3a7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 22 Oct 2009 15:45:26 -0500 Subject: Changes due to the properties changes. --- tests/test-libcustomindicator.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test-libcustomindicator.c b/tests/test-libcustomindicator.c index b3ead63..c4342e8 100644 --- a/tests/test-libcustomindicator.c +++ b/tests/test-libcustomindicator.c @@ -112,8 +112,8 @@ test_libcustomindicator_init_with_props (void) { CustomIndicator * ci = CUSTOM_INDICATOR(g_object_new(CUSTOM_INDICATOR_TYPE, "id", "my-id", - "category", CUSTOM_INDICATOR_CATEGORY_APPLICATION_STATUS, - "status", CUSTOM_INDICATOR_STATUS_ACTIVE, + "category-enum", CUSTOM_INDICATOR_CATEGORY_APPLICATION_STATUS, + "status-enum", CUSTOM_INDICATOR_STATUS_ACTIVE, "icon-name", "my-name", "attention-icon-name", "my-attention-name", NULL)); -- cgit v1.2.3 From 603044567814b8a5bc895bb22a1bf3ea35e788a2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 22 Oct 2009 15:47:31 -0500 Subject: Property name changes. Boo. --- tests/test-libcustomindicator-dbus-server.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test-libcustomindicator-dbus-server.c b/tests/test-libcustomindicator-dbus-server.c index 444706f..4c9dcb9 100644 --- a/tests/test-libcustomindicator-dbus-server.c +++ b/tests/test-libcustomindicator-dbus-server.c @@ -23,8 +23,8 @@ main (gint argc, gchar * argv[]) CustomIndicator * ci = CUSTOM_INDICATOR(g_object_new(CUSTOM_INDICATOR_TYPE, "id", TEST_ID, - "category", TEST_CATEGORY, - "status", TEST_STATE, + "category-enum", TEST_CATEGORY, + "status-enum", TEST_STATE, "icon-name", TEST_ICON_NAME, "attention-icon-name", TEST_ATTENTION_ICON_NAME, NULL)); -- cgit v1.2.3 From 20caa2fd37e681b8a6682a0ab3535767902256e6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 22 Oct 2009 16:04:52 -0500 Subject: We can't get the enum values from the string param spec, we need to find the enum one and then use that. --- src/libcustomindicator/custom-indicator.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libcustomindicator/custom-indicator.c b/src/libcustomindicator/custom-indicator.c index d7148f6..fc8b3da 100644 --- a/src/libcustomindicator/custom-indicator.c +++ b/src/libcustomindicator/custom-indicator.c @@ -491,7 +491,8 @@ custom_indicator_get_property (GObject * object, guint prop_id, GValue * value, /* *********************** */ case PROP_CATEGORY: if (G_VALUE_HOLDS_STRING(value)) { - GParamSpecEnum * enumspec = G_PARAM_SPEC_ENUM(pspec); + GParamSpec * spec_for_enum = g_object_class_find_property(G_OBJECT_GET_CLASS(object), PROP_CATEGORY_ENUM_S); + GParamSpecEnum * enumspec = G_PARAM_SPEC_ENUM(spec_for_enum); if (enumspec != NULL) { GEnumValue * enumval = g_enum_get_value(enumspec->enum_class, priv->category); g_value_set_string(value, enumval->value_nick); @@ -514,7 +515,8 @@ custom_indicator_get_property (GObject * object, guint prop_id, GValue * value, /* *********************** */ case PROP_STATUS: if (G_VALUE_HOLDS_STRING(value)) { - GParamSpecEnum * enumspec = G_PARAM_SPEC_ENUM(pspec); + GParamSpec * spec_for_enum = g_object_class_find_property(G_OBJECT_GET_CLASS(object), PROP_STATUS_ENUM_S); + GParamSpecEnum * enumspec = G_PARAM_SPEC_ENUM(spec_for_enum); if (enumspec != NULL) { GEnumValue * enumval = g_enum_get_value(enumspec->enum_class, priv->status); g_value_set_string(value, enumval->value_nick); -- cgit v1.2.3 From d6cc9393161f536e479ab8ec2c175c7237b40df4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 22 Oct 2009 16:19:24 -0500 Subject: Looking for the wrong property, we can only set the object. --- src/libcustomindicator/custom-indicator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcustomindicator/custom-indicator.c b/src/libcustomindicator/custom-indicator.c index fc8b3da..a4835cc 100644 --- a/src/libcustomindicator/custom-indicator.c +++ b/src/libcustomindicator/custom-indicator.c @@ -449,7 +449,7 @@ custom_indicator_set_property (GObject * object, guint prop_id, const GValue * v } break; /* *********************** */ - case PROP_MENU: + case PROP_MENU_OBJECT: if (G_VALUE_HOLDS_OBJECT(value)) { if (priv->menu != NULL) { g_object_unref(G_OBJECT(priv->menu)); -- cgit v1.2.3 From 1b71a85918d149eb4fdd8f3213ddc52dabc6b684 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 22 Oct 2009 16:19:40 -0500 Subject: Adding in testing the location of the dbusmenuserver --- tests/test-defines.h | 1 + tests/test-libcustomindicator-dbus-client.c | 18 ++++++++++++++++++ tests/test-libcustomindicator-dbus-server.c | 3 +++ 3 files changed, 22 insertions(+) diff --git a/tests/test-defines.h b/tests/test-defines.h index 2afe4f4..9d1fc26 100644 --- a/tests/test-defines.h +++ b/tests/test-defines.h @@ -6,4 +6,5 @@ #define TEST_STATE_S "active" #define TEST_CATEGORY CUSTOM_INDICATOR_CATEGORY_APPLICATION_STATUS #define TEST_CATEGORY_S "application-status" +#define TEST_OBJECT "/an/object/path/to/use" diff --git a/tests/test-libcustomindicator-dbus-client.c b/tests/test-libcustomindicator-dbus-client.c index bdc0fa6..e0203c0 100644 --- a/tests/test-libcustomindicator-dbus-client.c +++ b/tests/test-libcustomindicator-dbus-client.c @@ -158,6 +158,24 @@ prop_menu_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) { propcount++; + GError * error = NULL; + GValue value = {0}; + + if (!dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_VALUE, &value, G_TYPE_INVALID)) { + g_warning("Getting menu object failed: %s", error->message); + g_error_free(error); + passed = FALSE; + check_propcount(); + return; + } + + if (g_strcmp0(TEST_OBJECT, g_value_get_string(&value))) { + g_debug("Property menu object Returned: FAILED"); + passed = FALSE; + } else { + g_debug("Property menu object Returned: PASSED"); + } + check_propcount(); return; } diff --git a/tests/test-libcustomindicator-dbus-server.c b/tests/test-libcustomindicator-dbus-server.c index 4c9dcb9..2d61776 100644 --- a/tests/test-libcustomindicator-dbus-server.c +++ b/tests/test-libcustomindicator-dbus-server.c @@ -21,12 +21,15 @@ main (gint argc, gchar * argv[]) g_debug("DBus ID: %s", dbus_connection_get_server_id(dbus_g_connection_get_connection(dbus_g_bus_get(DBUS_BUS_SESSION, NULL)))); + DbusmenuServer * dms = dbusmenu_server_new(TEST_OBJECT); + CustomIndicator * ci = CUSTOM_INDICATOR(g_object_new(CUSTOM_INDICATOR_TYPE, "id", TEST_ID, "category-enum", TEST_CATEGORY, "status-enum", TEST_STATE, "icon-name", TEST_ICON_NAME, "attention-icon-name", TEST_ATTENTION_ICON_NAME, + "menu-object", dms, NULL)); g_timeout_add_seconds(2, kill_func, NULL); -- cgit v1.2.3 From cd7ec27751fbaaae47fc1ddf560f88e5921ce80d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Nov 2009 10:51:12 -0600 Subject: Removing the checks on private being NULL when we're already testing the object. --- src/libcustomindicator/custom-indicator.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/libcustomindicator/custom-indicator.c b/src/libcustomindicator/custom-indicator.c index a4835cc..639d304 100644 --- a/src/libcustomindicator/custom-indicator.c +++ b/src/libcustomindicator/custom-indicator.c @@ -258,7 +258,6 @@ static void custom_indicator_init (CustomIndicator *self) { CustomIndicatorPrivate * priv = CUSTOM_INDICATOR_GET_PRIVATE(self); - g_return_if_fail(priv != NULL); priv->id = NULL; priv->category = CUSTOM_INDICATOR_CATEGORY_OTHER; @@ -293,7 +292,6 @@ custom_indicator_dispose (GObject *object) g_return_if_fail(self != NULL); CustomIndicatorPrivate * priv = CUSTOM_INDICATOR_GET_PRIVATE(self); - g_return_if_fail(priv != NULL); if (priv->status != CUSTOM_INDICATOR_STATUS_PASSIVE) { custom_indicator_set_status(self, CUSTOM_INDICATOR_STATUS_PASSIVE); @@ -324,7 +322,6 @@ custom_indicator_finalize (GObject *object) g_return_if_fail(self != NULL); CustomIndicatorPrivate * priv = CUSTOM_INDICATOR_GET_PRIVATE(self); - g_return_if_fail(priv != NULL); if (priv->status != CUSTOM_INDICATOR_STATUS_PASSIVE) { g_warning("Finalizing Custom Status with the status set to: %d", priv->status); @@ -359,7 +356,6 @@ custom_indicator_set_property (GObject * object, guint prop_id, const GValue * v g_return_if_fail(self != NULL); CustomIndicatorPrivate * priv = CUSTOM_INDICATOR_GET_PRIVATE(self); - g_return_if_fail(priv != NULL); switch (prop_id) { /* *********************** */ @@ -477,7 +473,6 @@ custom_indicator_get_property (GObject * object, guint prop_id, GValue * value, g_return_if_fail(self != NULL); CustomIndicatorPrivate * priv = CUSTOM_INDICATOR_GET_PRIVATE(self); - g_return_if_fail(priv != NULL); switch (prop_id) { /* *********************** */ -- cgit v1.2.3