static void goa_alarm_set_time (GoaAlarm *self, GDateTime *time) { g_rec_mutex_lock (&self->priv->lock); g_date_time_ref (time); self->priv->time = time; if (self->priv->context == NULL) self->priv->context = g_main_context_ref (g_main_context_default ()); schedule_wakeups (self); /* Wake up right away, in case it's already expired leaving the gate */ schedule_immediate_wakeup (self); g_rec_mutex_unlock (&self->priv->lock); g_object_notify (G_OBJECT (self), "time"); }
void goa_alarm_set_time (GoaAlarm *self, GDateTime *time, GCancellable *cancellable) { if (g_cancellable_is_cancelled (cancellable)) return; if (self->priv->cancellable != NULL && self->priv->cancellable != cancellable) g_cancellable_cancel (self->priv->cancellable); if (cancellable != NULL) g_object_ref (cancellable); if (self->priv->cancelled_id != 0) g_cancellable_disconnect (self->priv->cancellable, self->priv->cancelled_id); g_clear_object (&self->priv->cancellable); if (cancellable != NULL) self->priv->cancellable = cancellable; else self->priv->cancellable = g_cancellable_new (); self->priv->cancelled_id = g_cancellable_connect (self->priv->cancellable, G_CALLBACK (on_cancelled), self, NULL); g_date_time_ref (time); if (self->priv->time != NULL) g_date_time_unref (self->priv->time); self->priv->time = time; self->priv->context = g_main_context_ref (g_main_context_default ()); g_object_notify (G_OBJECT (self), "time"); schedule_wakeups (self); /* Wake up right away, in case it's already expired leaving the gate */ schedule_immediate_wakeup (self); }