libpurple/countingnode.c

Thu, 25 Aug 2022 21:34:53 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 25 Aug 2022 21:34:53 -0500
branch
gtk4
changeset 41591
ad6f5ffc2825
parent 40195
fb4b0ae193c0
child 41685
ca22b00972d4
permissions
-rw-r--r--

Port the invite dialog to GTK4

Testing Done:
Opened the dialog via conversations -> invite and made sure it worked as expected.

Reviewed at https://reviews.imfreedom.org/r/1644/

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 "countingnode.h"
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26 typedef struct _PurpleCountingNodePrivate PurpleCountingNodePrivate;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28 /* Private data of a counting node */
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 struct _PurpleCountingNodePrivate {
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 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
31 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
32 corresponding to online accounts */
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 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
34 currently online */
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 };
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 /* Counting node property enums */
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 enum
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 PROP_0,
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 PROP_TOTAL_SIZE,
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 PROP_CURRENT_SIZE,
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 PROP_ONLINE_COUNT,
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 PROP_LAST
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 };
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 static GParamSpec *properties[PROP_LAST];
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48
39364
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 37945
diff changeset
49 G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE(PurpleCountingNode, purple_counting_node,
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 37945
diff changeset
50 PURPLE_TYPE_BLIST_NODE);
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 37945
diff changeset
51
37945
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 * API
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 *****************************************************************************/
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 int
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 purple_counting_node_get_total_size(PurpleCountingNode *counter)
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
58 PurpleCountingNodePrivate *priv = NULL;
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
60 g_return_val_if_fail(PURPLE_IS_COUNTING_NODE(counter), -1);
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
62 priv = purple_counting_node_get_instance_private(counter);
37945
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 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
69 PurpleCountingNodePrivate *priv = NULL;
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
71 g_return_val_if_fail(PURPLE_IS_COUNTING_NODE(counter), -1);
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
73 priv = purple_counting_node_get_instance_private(counter);
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 return priv->currentsize;
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
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 int
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 purple_counting_node_get_online_count(PurpleCountingNode *counter)
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
80 PurpleCountingNodePrivate *priv = NULL;
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
82 g_return_val_if_fail(PURPLE_IS_COUNTING_NODE(counter), -1);
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
84 priv = purple_counting_node_get_instance_private(counter);
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 return priv->onlinecount;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 }
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 void
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 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
90 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
91 PurpleCountingNodePrivate *priv = NULL;
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
93 g_return_if_fail(PURPLE_IS_COUNTING_NODE(counter));
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
95 priv = purple_counting_node_get_instance_private(counter);
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 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
97 }
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 void
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 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
101 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
102 PurpleCountingNodePrivate *priv = NULL;
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
104 g_return_if_fail(PURPLE_IS_COUNTING_NODE(counter));
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
106 priv = purple_counting_node_get_instance_private(counter);
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107 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
108 }
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110 void
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111 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
112 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
113 PurpleCountingNodePrivate *priv = NULL;
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
115 g_return_if_fail(PURPLE_IS_COUNTING_NODE(counter));
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
117 priv = purple_counting_node_get_instance_private(counter);
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 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
119 }
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 void
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122 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
123 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
124 PurpleCountingNodePrivate *priv = NULL;
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
126 g_return_if_fail(PURPLE_IS_COUNTING_NODE(counter));
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
128 priv = purple_counting_node_get_instance_private(counter);
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129 priv->totalsize = totalsize;
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 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
132 }
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134 void
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135 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
136 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
137 PurpleCountingNodePrivate *priv = NULL;
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
138
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
139 g_return_if_fail(PURPLE_IS_COUNTING_NODE(counter));
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
141 priv = purple_counting_node_get_instance_private(counter);
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142 priv->currentsize = currentsize;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144 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
145 }
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 void
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
148 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
149 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
150 PurpleCountingNodePrivate *priv = NULL;
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
151
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
152 g_return_if_fail(PURPLE_IS_COUNTING_NODE(counter));
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
153
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39364
diff changeset
154 priv = purple_counting_node_get_instance_private(counter);
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155 priv->onlinecount = onlinecount;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
156
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157 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
158 }
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 /**************************************************************************
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161 * GObject Stuff
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162 **************************************************************************/
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163 /* Set method for GObject properties */
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
164 static void
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
165 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
166 GParamSpec *pspec)
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
167 {
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
168 PurpleCountingNode *node = PURPLE_COUNTING_NODE(obj);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
169
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
170 switch (param_id) {
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
171 case PROP_TOTAL_SIZE:
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
172 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
173 break;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
174 case PROP_CURRENT_SIZE:
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
175 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
176 break;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177 case PROP_ONLINE_COUNT:
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
178 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
179 break;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
180 default:
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
181 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
182 break;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183 }
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
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
186 /* Get method for GObject properties */
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
187 static void
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
188 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
189 GParamSpec *pspec)
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
190 {
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
191 PurpleCountingNode *node = PURPLE_COUNTING_NODE(obj);
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
192
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
193 switch (param_id) {
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
194 case PROP_TOTAL_SIZE:
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
195 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
196 break;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
197 case PROP_CURRENT_SIZE:
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
198 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
199 break;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
200 case PROP_ONLINE_COUNT:
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
201 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
202 break;
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
203 default:
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
204 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
205 break;
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 }
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
208
39364
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 37945
diff changeset
209 static void
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 37945
diff changeset
210 purple_counting_node_init(PurpleCountingNode *counter)
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 37945
diff changeset
211 {
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 37945
diff changeset
212 }
54439db24429 libpurple: Port self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 37945
diff changeset
213
37945
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
214 /* Class initializer function */
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
215 static void
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
216 purple_counting_node_class_init(PurpleCountingNodeClass *klass)
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
217 {
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
218 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
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 /* Setup properties */
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
221 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
222 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
223
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
224 properties[PROP_TOTAL_SIZE] = g_param_spec_int(
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
225 "total-size",
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
226 "Total size",
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
227 "The number of children under this node.",
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
228 G_MININT, G_MAXINT, 0,
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
229 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
230 );
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
231
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
232 properties[PROP_CURRENT_SIZE] = g_param_spec_int(
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
233 "current-size",
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
234 "Current size",
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
235 "The number of children with online accounts.",
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
236 G_MININT, G_MAXINT, 0,
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
237 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS
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 properties[PROP_ONLINE_COUNT] = g_param_spec_int(
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
241 "online-count",
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
242 "Online count",
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
243 "The number of children that are online.",
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
244 G_MININT, G_MAXINT, 0,
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
245 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
246 );
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
247
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
248 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
249 }
49ac171ebe26 move CountingNode to it's own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
250

mercurial