libpurple/countingnode.c

Mon, 26 Sep 2016 15:17:15 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Mon, 26 Sep 2016 15:17:15 -0500
changeset 38059
1baf1f1b10e2
parent 37945
49ac171ebe26
child 39364
54439db24429
permissions
-rw-r--r--

Merged in rw_grim/pidgin (pull request #135)

Add our license spiel to a bunch of files

37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * purple
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 *
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 * Purple is the legal property of its developers, whose names are too numerous
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * source distribution.
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 *
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * (at your option) any later version.
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 *
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * GNU General Public License for more details.
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 *
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 *
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22 */
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include "internal.h"
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24 #include "glibcompat.h"
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 #include "countingnode.h"
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 #define PURPLE_COUNTING_NODE_GET_PRIVATE(obj) \
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28 (G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_COUNTING_NODE, PurpleCountingNodePrivate))
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 typedef struct _PurpleCountingNodePrivate PurpleCountingNodePrivate;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 /* Private data of a counting node */
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 struct _PurpleCountingNodePrivate {
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 int totalsize; /* The number of children under this node */
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 int currentsize; /* The number of children under this node
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 corresponding to online accounts */
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 int onlinecount; /* The number of children under this contact who are
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 currently online */
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 };
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 /* Counting node property enums */
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 enum
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 {
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 PROP_0,
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 PROP_TOTAL_SIZE,
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 PROP_CURRENT_SIZE,
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 PROP_ONLINE_COUNT,
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 PROP_LAST
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 };
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 static GParamSpec *properties[PROP_LAST];
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 /******************************************************************************
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 * API
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 *****************************************************************************/
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 int
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 purple_counting_node_get_total_size(PurpleCountingNode *counter)
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 {
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 PurpleCountingNodePrivate *priv = PURPLE_COUNTING_NODE_GET_PRIVATE(counter);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 g_return_val_if_fail(priv != NULL, -1);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 return priv->totalsize;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 }
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 int
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 purple_counting_node_get_current_size(PurpleCountingNode *counter)
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 {
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 PurpleCountingNodePrivate *priv = PURPLE_COUNTING_NODE_GET_PRIVATE(counter);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 g_return_val_if_fail(priv != NULL, -1);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 return priv->currentsize;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 }
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 int
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 purple_counting_node_get_online_count(PurpleCountingNode *counter)
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 {
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 PurpleCountingNodePrivate *priv = PURPLE_COUNTING_NODE_GET_PRIVATE(counter);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 g_return_val_if_fail(priv != NULL, -1);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 return priv->onlinecount;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 }
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 void
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 purple_counting_node_change_total_size(PurpleCountingNode *counter, int delta)
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 {
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 PurpleCountingNodePrivate *priv = PURPLE_COUNTING_NODE_GET_PRIVATE(counter);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 g_return_if_fail(priv != NULL);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 purple_counting_node_set_total_size(counter, priv->totalsize + delta);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 }
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 void
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 purple_counting_node_change_current_size(PurpleCountingNode *counter, int delta)
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 {
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 PurpleCountingNodePrivate *priv = PURPLE_COUNTING_NODE_GET_PRIVATE(counter);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 g_return_if_fail(priv != NULL);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 purple_counting_node_set_current_size(counter, priv->currentsize + delta);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104 }
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 void
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107 purple_counting_node_change_online_count(PurpleCountingNode *counter, int delta)
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108 {
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 PurpleCountingNodePrivate *priv = PURPLE_COUNTING_NODE_GET_PRIVATE(counter);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111 g_return_if_fail(priv != NULL);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113 purple_counting_node_set_online_count(counter, priv->onlinecount + delta);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114 }
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116 void
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117 purple_counting_node_set_total_size(PurpleCountingNode *counter, int totalsize)
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 {
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119 PurpleCountingNodePrivate *priv = PURPLE_COUNTING_NODE_GET_PRIVATE(counter);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121 g_return_if_fail(priv != NULL);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123 priv->totalsize = totalsize;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125 g_object_notify_by_pspec(G_OBJECT(counter), properties[PROP_TOTAL_SIZE]);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126 }
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128 void
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129 purple_counting_node_set_current_size(PurpleCountingNode *counter, int currentsize)
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130 {
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131 PurpleCountingNodePrivate *priv = PURPLE_COUNTING_NODE_GET_PRIVATE(counter);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133 g_return_if_fail(priv != NULL);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135 priv->currentsize = currentsize;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
136
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
137 g_object_notify_by_pspec(G_OBJECT(counter), properties[PROP_CURRENT_SIZE]);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
138 }
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 void
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
141 purple_counting_node_set_online_count(PurpleCountingNode *counter, int onlinecount)
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142 {
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143 PurpleCountingNodePrivate *priv = PURPLE_COUNTING_NODE_GET_PRIVATE(counter);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
145 g_return_if_fail(priv != NULL);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
146
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147 priv->onlinecount = onlinecount;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
148
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
149 g_object_notify_by_pspec(G_OBJECT(counter), properties[PROP_ONLINE_COUNT]);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150 }
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
151
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
152 /**************************************************************************
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
153 * GObject Stuff
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
154 **************************************************************************/
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155 /* Set method for GObject properties */
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
156 static void
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157 purple_counting_node_set_property(GObject *obj, guint param_id, const GValue *value,
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158 GParamSpec *pspec)
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
159 {
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160 PurpleCountingNode *node = PURPLE_COUNTING_NODE(obj);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162 switch (param_id) {
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163 case PROP_TOTAL_SIZE:
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
164 purple_counting_node_set_total_size(node, g_value_get_int(value));
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
165 break;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
166 case PROP_CURRENT_SIZE:
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
167 purple_counting_node_set_current_size(node, g_value_get_int(value));
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
168 break;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
169 case PROP_ONLINE_COUNT:
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
170 purple_counting_node_set_online_count(node, g_value_get_int(value));
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
171 break;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
172 default:
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
173 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
174 break;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
175 }
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
176 }
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
178 /* Get method for GObject properties */
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
179 static void
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
180 purple_counting_node_get_property(GObject *obj, guint param_id, GValue *value,
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
181 GParamSpec *pspec)
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
182 {
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183 PurpleCountingNode *node = PURPLE_COUNTING_NODE(obj);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
185 switch (param_id) {
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
186 case PROP_TOTAL_SIZE:
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
187 g_value_set_int(value, purple_counting_node_get_total_size(node));
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
188 break;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
189 case PROP_CURRENT_SIZE:
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
190 g_value_set_int(value, purple_counting_node_get_current_size(node));
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
191 break;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
192 case PROP_ONLINE_COUNT:
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
193 g_value_set_int(value, purple_counting_node_get_online_count(node));
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
194 break;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
195 default:
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
196 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
197 break;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
198 }
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
199 }
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
200
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
201 /* Class initializer function */
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
202 static void
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
203 purple_counting_node_class_init(PurpleCountingNodeClass *klass)
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
204 {
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
205 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
206
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
207 /* Setup properties */
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
208 obj_class->get_property = purple_counting_node_get_property;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
209 obj_class->set_property = purple_counting_node_set_property;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
210
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
211 g_type_class_add_private(klass, sizeof(PurpleCountingNodePrivate));
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
212
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
213 properties[PROP_TOTAL_SIZE] = g_param_spec_int(
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
214 "total-size",
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
215 "Total size",
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
216 "The number of children under this node.",
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
217 G_MININT, G_MAXINT, 0,
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
218 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
219 );
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
220
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
221 properties[PROP_CURRENT_SIZE] = g_param_spec_int(
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
222 "current-size",
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
223 "Current size",
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
224 "The number of children with online accounts.",
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
225 G_MININT, G_MAXINT, 0,
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
226 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
227 );
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
228
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
229 properties[PROP_ONLINE_COUNT] = g_param_spec_int(
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
230 "online-count",
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
231 "Online count",
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
232 "The number of children that are online.",
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
233 G_MININT, G_MAXINT, 0,
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
234 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
235 );
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
236
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
237 g_object_class_install_properties(obj_class, PROP_LAST, properties);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
238 }
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
239
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
240 GType
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
241 purple_counting_node_get_type(void)
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
242 {
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
243 static GType type = 0;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
244
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
245 if(type == 0) {
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
246 static const GTypeInfo info = {
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
247 sizeof(PurpleCountingNodeClass),
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
248 NULL,
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
249 NULL,
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
250 (GClassInitFunc)purple_counting_node_class_init,
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
251 NULL,
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
252 NULL,
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
253 sizeof(PurpleCountingNode),
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
254 0,
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
255 NULL,
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
256 NULL,
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
257 };
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
258
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
259 type = g_type_register_static(PURPLE_TYPE_BLIST_NODE,
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
260 "PurpleCountingNode",
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
261 &info, G_TYPE_FLAG_ABSTRACT);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
262 }
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
263
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
264 return type;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
265 }

mercurial