diff options
Diffstat (limited to 'libindicate/indicator.c')
-rw-r--r-- | libindicate/indicator.c | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/libindicate/indicator.c b/libindicate/indicator.c index 2db8468..e16492d 100644 --- a/libindicate/indicator.c +++ b/libindicate/indicator.c @@ -1,9 +1,12 @@ #include "glib.h" +#include "glib/gmessages.h" #include "indicator.h" /* Signals */ enum { + HIDE, + SHOW, USER_DISPLAY, LAST_SIGNAL }; @@ -19,6 +22,8 @@ static void indicate_indicator_finalize (GObject * object); static void indicate_indicator_class_init (IndicateIndicatorClass * class) { + g_debug("Indicator Class Initialized."); + GObjectClass * gobj; gobj = G_OBJECT_CLASS(class); @@ -31,6 +36,20 @@ indicate_indicator_class_init (IndicateIndicatorClass * class) NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + signals[HIDE] = g_signal_new(INDICATE_INDICATOR_SIGNAL_HIDE, + G_TYPE_FROM_CLASS(class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET(IndicateIndicatorClass, hide), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + signals[SHOW] = g_signal_new(INDICATE_INDICATOR_SIGNAL_SHOW, + G_TYPE_FROM_CLASS(class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET(IndicateIndicatorClass, show), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); return; } @@ -38,7 +57,10 @@ indicate_indicator_class_init (IndicateIndicatorClass * class) static void indicate_indicator_init (IndicateIndicator * indicator) { + g_debug("Indicator Object Initialized."); + indicator->id = 0; + indicator->is_visible = FALSE; indicator->server = indicate_server_ref_default(); indicate_server_add_indicator(indicator->server, indicator); @@ -65,3 +87,56 @@ indicate_indicator_new (void) return indicator; } +void +indicate_indicator_show (IndicateIndicator * indicator) +{ + if (indicator->is_visible) { + return; + } + + if (indicator->server) { + indicate_server_show(indicator->server); + } + + indicator->is_visible = TRUE; + g_signal_emit(indicator, signals[SHOW], 0, TRUE); +} + +void +indicate_indicator_hide (IndicateIndicator * indicator) +{ + if (!indicator->is_visible) { + return; + } + + indicator->is_visible = FALSE; + g_signal_emit(indicator, signals[HIDE], 0, TRUE); +} + +gboolean +indicate_indicator_is_visible (IndicateIndicator * indicator) +{ + return indicator->is_visible; +} + +guint +indicate_indicator_get_id (IndicateIndicator * indicator) +{ + g_return_val_if_fail(INDICATE_IS_INDICATOR(indicator), 0); + return indicator->id; +} + +const gchar * +indicate_indicator_get_indicator_type (IndicateIndicator * indicator) +{ + g_return_val_if_fail(INDICATE_IS_INDICATOR(indicator), NULL); + IndicateIndicatorClass * class = INDICATE_INDICATOR_GET_CLASS(indicator); + + if (class->get_type != NULL) { + return INDICATE_INDICATOR_GET_CLASS(indicator)->get_type(indicator); + } + + return NULL; +} + + |