1 /* * Copyright (C) 2009 Collabora Ltd.
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 * Authors: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
23 #include <libnotify/notification.h>
24 #include <libnotify/notify.h>
25 #include <telepathy-glib/telepathy-glib.h>
27 #include <libempathy-gtk/empathy-notify-manager.h>
29 #include "empathy-event-manager.h"
31 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
32 #include <libempathy/empathy-debug.h>
34 #include "empathy-notifications-approver.h"
36 struct _EmpathyNotificationsApproverPrivate
38 EmpathyEventManager *event_mgr;
39 EmpathyNotifyManager *notify_mgr;
42 G_DEFINE_TYPE (EmpathyNotificationsApprover, empathy_notifications_approver,
45 static EmpathyNotificationsApprover *notifications_approver = NULL;
48 notifications_approver_constructor (GType type,
49 guint n_construct_params,
50 GObjectConstructParam *construct_params)
54 if (notifications_approver != NULL)
55 return g_object_ref (notifications_approver);
57 retval = G_OBJECT_CLASS (empathy_notifications_approver_parent_class)->
58 constructor (type, n_construct_params, construct_params);
60 notifications_approver = EMPATHY_NOTIFICATIONS_APPROVER (retval);
61 g_object_add_weak_pointer (retval, (gpointer) ¬ifications_approver);
67 notifications_approver_dispose (GObject *object)
69 EmpathyNotificationsApprover *self = (EmpathyNotificationsApprover *) object;
71 tp_clear_object (&self->priv->event_mgr);
72 tp_clear_object (&self->priv->notify_mgr);
74 G_OBJECT_CLASS (empathy_notifications_approver_parent_class)->dispose (
79 empathy_notifications_approver_class_init (
80 EmpathyNotificationsApproverClass *klass)
82 GObjectClass *object_class = G_OBJECT_CLASS (klass);
84 object_class->dispose = notifications_approver_dispose;
85 object_class->constructor = notifications_approver_constructor;
87 g_type_class_add_private (object_class,
88 sizeof (EmpathyNotificationsApproverPrivate));
92 empathy_notifications_approver_init (EmpathyNotificationsApprover *self)
94 EmpathyNotificationsApproverPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
95 EMPATHY_TYPE_NOTIFICATIONS_APPROVER, EmpathyNotificationsApproverPrivate);
99 self->priv->event_mgr = empathy_event_manager_dup_singleton ();
100 self->priv->notify_mgr = empathy_notify_manager_dup_singleton ();
103 EmpathyNotificationsApprover *
104 empathy_notifications_approver_dup_singleton (void)
106 return g_object_new (EMPATHY_TYPE_NOTIFICATIONS_APPROVER, NULL);