diff options
author | Ted Gould <ted@canonical.com> | 2009-07-26 23:47:27 -0500 |
---|---|---|
committer | Ted Gould <ted@canonical.com> | 2009-07-26 23:47:27 -0500 |
commit | 9b7303cd469357b2d17cb87313d83d47ffc16470 (patch) | |
tree | 3248af69a8fb6f5791ff48aa1cd30d24146ec556 /src/status-provider.c | |
parent | f5cec7c3e6dc602772642bd390ec632450709145 (diff) | |
parent | 0417e7049a32ceb45e19705992dfccef5d858893 (diff) | |
download | ayatana-indicator-session-9b7303cd469357b2d17cb87313d83d47ffc16470.tar.gz ayatana-indicator-session-9b7303cd469357b2d17cb87313d83d47ffc16470.tar.bz2 ayatana-indicator-session-9b7303cd469357b2d17cb87313d83d47ffc16470.zip |
Merging in the branch to port everything to libindicator and fleshing thigns out.
Diffstat (limited to 'src/status-provider.c')
-rw-r--r-- | src/status-provider.c | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/src/status-provider.c b/src/status-provider.c new file mode 100644 index 0000000..97f1798 --- /dev/null +++ b/src/status-provider.c @@ -0,0 +1,86 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "status-provider.h" + +/* Signals */ +enum { + STATUS_CHANGED, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + +/* GObject Boilerplate */ +static void status_provider_class_init (StatusProviderClass *klass); +static void status_provider_init (StatusProvider *self); + +G_DEFINE_TYPE (StatusProvider, status_provider, G_TYPE_OBJECT); + +static void +status_provider_class_init (StatusProviderClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + klass->status_changed = NULL; + + klass->set_status = NULL; + klass->get_status = NULL; + + /** + StatusProvider::status-changed: + @arg0: The #StatusProvider object. + @arg1: The new status #StatusProviderStatus + + Should be emitted by subclasses everytime that the status + changes externally to us. + */ + signals[STATUS_CHANGED] = g_signal_new(STATUS_PROVIDER_SIGNAL_STATUS_CHANGED, + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET(StatusProviderClass, status_changed), + NULL, NULL, + g_cclosure_marshal_VOID__UINT, + G_TYPE_NONE, 1, G_TYPE_UINT); + + return; +} + +static void +status_provider_init (StatusProvider *self) +{ + + return; +} + +void +status_provider_set_status (StatusProvider * sp, StatusProviderStatus status) +{ + g_return_if_fail(IS_STATUS_PROVIDER(sp)); + + StatusProviderClass * class = STATUS_PROVIDER_GET_CLASS(sp); + g_return_if_fail(class != NULL); + g_return_if_fail(class->set_status != NULL); + + return class->set_status(sp, status); +} + +StatusProviderStatus +status_provider_get_status (StatusProvider * sp) +{ + g_return_val_if_fail(IS_STATUS_PROVIDER(sp), STATUS_PROVIDER_STATUS_OFFLINE); + + StatusProviderClass * class = STATUS_PROVIDER_GET_CLASS(sp); + g_return_val_if_fail(class->get_status != NULL, STATUS_PROVIDER_STATUS_OFFLINE); + + return class->get_status(sp); +} + +void +status_provider_emit_status_changed (StatusProvider * sp, StatusProviderStatus newstatus) +{ + g_return_if_fail(IS_STATUS_PROVIDER(sp)); + g_signal_emit(sp, signals[STATUS_CHANGED], 0, newstatus, TRUE); + return; +} |