Updated Friulian translation
[empathy-mirror.git] / libempathy-gtk / empathy-roster-model.c
blob994ab9896435704e67196468d7a48ebce9d3b410
1 /*
2 * empathy-roster-model.c
4 * Copyright (C) 2012 Collabora Ltd. <http://www.collabora.co.uk/>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #include "config.h"
21 #include "empathy-roster-model.h"
23 G_DEFINE_INTERFACE (EmpathyRosterModel, empathy_roster_model, G_TYPE_OBJECT)
25 enum
27 SIG_INDIVIDUAL_ADDED,
28 SIG_INDIVIDUAL_REMOVED,
29 SIG_GROUPS_CHANGED,
30 LAST_SIGNAL
33 static guint signals[LAST_SIGNAL];
35 static void
36 empathy_roster_model_default_init (EmpathyRosterModelInterface *iface)
38 signals[SIG_INDIVIDUAL_ADDED] =
39 g_signal_new ("individual-added",
40 EMPATHY_TYPE_ROSTER_MODEL,
41 G_SIGNAL_RUN_LAST,
42 0, NULL, NULL, NULL,
43 G_TYPE_NONE, 1,
44 FOLKS_TYPE_INDIVIDUAL);
46 signals[SIG_INDIVIDUAL_REMOVED] =
47 g_signal_new ("individual-removed",
48 EMPATHY_TYPE_ROSTER_MODEL,
49 G_SIGNAL_RUN_LAST,
50 0, NULL, NULL, NULL,
51 G_TYPE_NONE, 1,
52 FOLKS_TYPE_INDIVIDUAL);
54 signals[SIG_GROUPS_CHANGED] =
55 g_signal_new ("groups-changed",
56 EMPATHY_TYPE_ROSTER_MODEL,
57 G_SIGNAL_RUN_LAST,
58 0, NULL, NULL, NULL,
59 G_TYPE_NONE, 3,
60 FOLKS_TYPE_INDIVIDUAL,
61 G_TYPE_STRING,
62 G_TYPE_BOOLEAN);
65 /***** Restricted *****/
67 void
68 empathy_roster_model_fire_individual_added (EmpathyRosterModel *self,
69 FolksIndividual *individual)
71 g_signal_emit (self, signals[SIG_INDIVIDUAL_ADDED], 0, individual);
74 void
75 empathy_roster_model_fire_individual_removed (EmpathyRosterModel *self,
76 FolksIndividual *individual)
78 g_signal_emit (self, signals[SIG_INDIVIDUAL_REMOVED], 0, individual);
81 void
82 empathy_roster_model_fire_groups_changed (EmpathyRosterModel *self,
83 FolksIndividual *individual,
84 const gchar *group,
85 gboolean is_member)
87 g_signal_emit (self, signals[SIG_GROUPS_CHANGED], 0, individual, group,
88 is_member);
91 /***** Public *****/
93 /**
94 * empathy_roster_model_get_individuals:
95 * @self: a #EmpathyRosterModel
97 * Returns all the individuals stored by @self.
99 * Returns: (transfer container): a #GList of #FolksIndividual
101 GList *
102 empathy_roster_model_get_individuals (EmpathyRosterModel *self)
104 EmpathyRosterModelInterface *iface;
106 g_return_val_if_fail (EMPATHY_IS_ROSTER_MODEL (self), NULL);
108 iface = EMPATHY_ROSTER_MODEL_GET_IFACE (self);
109 g_return_val_if_fail (iface->get_individuals != NULL, NULL);
111 return (* iface->get_individuals) (self);
115 * empathy_roster_model_dup_groups_for_individual:
116 * @self: a #EmpathyRosterModel
117 * @individual: a #FolksIndidivual
119 * Returns the groups of which @individual is a member of.
121 * Returns: (transfer full): a #GList of (gchar *) representing the
122 * groups of @individual
124 GList *
125 empathy_roster_model_dup_groups_for_individual (EmpathyRosterModel *self,
126 FolksIndividual *individual)
128 EmpathyRosterModelInterface *iface;
130 g_return_val_if_fail (EMPATHY_IS_ROSTER_MODEL (self), NULL);
132 iface = EMPATHY_ROSTER_MODEL_GET_IFACE (self);
133 g_return_val_if_fail (iface->dup_groups_for_individual != NULL, NULL);
135 return (* iface->dup_groups_for_individual) (self, individual);