pidgin/pidginstatusprimitivestore.c

Fri, 26 Aug 2022 00:13:48 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Fri, 26 Aug 2022 00:13:48 -0500
branch
gtk4
changeset 41599
450080e4726a
parent 41479
3d2e114380f6
permissions
-rw-r--r--

Fix up the roomlist to work in GTK4

Testing Done:
Opened the room list and verified it functioned as intended.

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

41268
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Pidgin - Internet Messenger
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * Pidgin is the legal property of its developers, whose names are too numerous
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * source distribution.
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 *
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * (at your option) any later version.
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 *
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 * GNU General Public License for more details.
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 *
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 * along with this program; if not, see <https://www.gnu.org/licenses/>.
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include <pidgin/pidginstatusprimitivestore.h>
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 #include <pidgin/pidginiconname.h>
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 struct _PidginStatusPrimitiveStore {
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28 GtkListStore parent;
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 PurpleAccount *account;
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 };
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 enum {
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 PROP_0,
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 PROP_ACCOUNT,
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 N_PROPERTIES,
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 };
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 static GParamSpec *properties[N_PROPERTIES] = { NULL, };
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 enum {
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 COL_ID,
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 COL_ICON,
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 COL_TEXT,
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 N_COLUMNS,
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 };
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 G_DEFINE_TYPE(PidginStatusPrimitiveStore, pidgin_status_primitive_store,
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 GTK_TYPE_LIST_STORE)
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 /******************************************************************************
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 * Helpers
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 *****************************************************************************/
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 static GList *
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 pidgin_status_primitive_store_get_primitives_from_account(PidginStatusPrimitiveStore *store)
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 {
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 GList *primitives = NULL;
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 GList *list = purple_account_get_status_types(store->account);
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 while(list != NULL) {
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 PurpleStatusType *type = (PurpleStatusType *)list->data;
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 PurpleStatusPrimitive primitive;
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 gboolean user_settable = FALSE, independent = FALSE;
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 /* iterate to the next item as we already have the data in type. */
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 list = list->next;
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 user_settable = purple_status_type_is_user_settable(type);
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 independent = purple_status_type_is_independent(type);
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 if(!user_settable || independent) {
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 continue;
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 }
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 primitive = purple_status_type_get_primitive(type);
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 primitives = g_list_append(primitives, GINT_TO_POINTER(primitive));
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 }
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 return primitives;
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 }
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 static GList *
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 pidgin_status_primitive_store_get_primitives(PidginStatusPrimitiveStore *store)
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 {
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 GList *primitives = NULL;
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 primitives = g_list_append(primitives,
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 GINT_TO_POINTER(PURPLE_STATUS_OFFLINE));
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 primitives = g_list_append(primitives,
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 GINT_TO_POINTER(PURPLE_STATUS_AVAILABLE));
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 primitives = g_list_append(primitives,
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 GINT_TO_POINTER(PURPLE_STATUS_UNAVAILABLE));
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 primitives = g_list_append(primitives,
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 GINT_TO_POINTER(PURPLE_STATUS_INVISIBLE));
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 primitives = g_list_append(primitives,
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 GINT_TO_POINTER(PURPLE_STATUS_AWAY));
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 primitives = g_list_append(primitives,
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 GINT_TO_POINTER(PURPLE_STATUS_EXTENDED_AWAY));
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 return primitives;
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 }
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102 static void
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 pidgin_status_primitive_store_populate(PidginStatusPrimitiveStore *store) {
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104 GList *primitives = NULL;
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 /* clear out the list */
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107 gtk_list_store_clear(GTK_LIST_STORE(store));
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 /* Get all the primitives and add them. */
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110 if(PURPLE_IS_ACCOUNT(store->account)) {
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111 primitives = pidgin_status_primitive_store_get_primitives_from_account(store);
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112 } else {
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113 primitives = pidgin_status_primitive_store_get_primitives(store);
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114 }
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116 while(primitives != NULL) {
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117 PurpleStatusPrimitive primitive = GPOINTER_TO_INT(primitives->data);
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 GtkTreeIter iter;
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120 gtk_list_store_append(GTK_LIST_STORE(store), &iter);
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121 /* clang-format off */
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122 gtk_list_store_set(
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123 GTK_LIST_STORE(store), &iter,
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124 COL_ID, purple_primitive_get_id_from_type(primitive),
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125 COL_ICON, pidgin_icon_name_from_status_primitive(primitive, NULL),
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126 COL_TEXT, purple_primitive_get_name_from_type(primitive),
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127 -1);
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128 /* clang-format on */
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130 primitives = g_list_delete_link(primitives, primitives);
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131 }
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132 }
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134 /******************************************************************************
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135 * GObject Implementation
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
136 *****************************************************************************/
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
137
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
138 static void
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139 pidgin_status_primitive_store_get_property(GObject *obj, guint param_id,
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 GValue *value, GParamSpec *pspec)
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
141 {
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142 PidginStatusPrimitiveStore *store = PIDGIN_STATUS_PRIMITIVE_STORE(obj);
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144 switch(param_id) {
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
145 case PROP_ACCOUNT:
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
146 g_value_set_object(value,
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147 pidgin_status_primitive_store_get_account(store));
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
148 break;
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
149 default:
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
151 break;
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
152 }
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
153 }
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
154
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155 static void
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
156 pidgin_status_primitive_store_set_property(GObject *obj, guint param_id,
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157 const GValue *value,
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158 GParamSpec *pspec)
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
159 {
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160 PidginStatusPrimitiveStore *store = PIDGIN_STATUS_PRIMITIVE_STORE(obj);
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162 switch(param_id) {
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163 case PROP_ACCOUNT:
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
164 pidgin_status_primitive_store_set_account(store,
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
165 g_value_get_object(value));
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
166 break;
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
167 default:
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
168 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
169 break;
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
170 }
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
171 }
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
172
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
173 static void
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
174 pidgin_status_primitive_store_dispose(GObject *obj) {
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
175 PidginStatusPrimitiveStore *store = PIDGIN_STATUS_PRIMITIVE_STORE(obj);
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
176
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177 g_clear_object(&store->account);
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
178
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
179 G_OBJECT_CLASS(pidgin_status_primitive_store_parent_class)->dispose(obj);
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
180 }
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
181
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
182 static void
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183 pidgin_status_primitive_store_constructed(GObject *obj) {
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184 PidginStatusPrimitiveStore *store = PIDGIN_STATUS_PRIMITIVE_STORE(obj);
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
185
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
186 G_OBJECT_CLASS(pidgin_status_primitive_store_parent_class)->constructed(obj);
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
187
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
188 /* This exists to populate the store if it was created without a value for
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
189 * the account property.
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
190 */
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
191 pidgin_status_primitive_store_populate(store);
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
192 }
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
193
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
194 static void
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
195 pidgin_status_primitive_store_init(PidginStatusPrimitiveStore *store) {
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
196 GType types[N_COLUMNS] = { G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING };
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
197
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
198 gtk_list_store_set_column_types(GTK_LIST_STORE(store), N_COLUMNS, types);
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
199 }
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
200
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
201 static void
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
202 pidgin_status_primitive_store_class_init(PidginStatusPrimitiveStoreClass *klass) {
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
203 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
204
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
205 obj_class->get_property = pidgin_status_primitive_store_get_property;
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
206 obj_class->set_property = pidgin_status_primitive_store_set_property;
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
207 obj_class->constructed = pidgin_status_primitive_store_constructed;
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
208 obj_class->dispose = pidgin_status_primitive_store_dispose;
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
209
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
210 /**
41479
3d2e114380f6 Add source files to GObject introspection
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41268
diff changeset
211 * PidginStatusPrimitiveStore:account:
41268
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
212 *
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
213 * The account whose statuses to display.
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
214 *
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
215 * Since: 3.0.0
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
216 */
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
217 /* clang-format off */
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
218 properties[PROP_ACCOUNT] = g_param_spec_object(
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
219 "account", "account",
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
220 "The account whose statuses to display",
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
221 PURPLE_TYPE_ACCOUNT,
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
222 G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
223 /* clang-format on */
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
224
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
225 g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
226 }
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
227
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
228 /******************************************************************************
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
229 * Public API
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
230 *****************************************************************************/
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
231 GtkListStore *
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
232 pidgin_status_primitive_store_new(void) {
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
233 return g_object_new(PIDGIN_TYPE_STATUS_PRIMITIVE_STORE, NULL);
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
234 }
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
235
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
236 void
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
237 pidgin_status_primitive_store_set_account(PidginStatusPrimitiveStore *store,
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
238 PurpleAccount *account)
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
239 {
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
240 g_return_if_fail(PIDGIN_IS_STATUS_PRIMITIVE_STORE(store));
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
241
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
242 if(g_set_object(&store->account, account)) {
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
243 pidgin_status_primitive_store_populate(store);
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
244
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
245 g_object_notify_by_pspec(G_OBJECT(store), properties[PROP_ACCOUNT]);
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
246 }
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
247 }
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
248
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
249 PurpleAccount *
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
250 pidgin_status_primitive_store_get_account(PidginStatusPrimitiveStore *store) {
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
251 g_return_val_if_fail(PIDGIN_IS_STATUS_PRIMITIVE_STORE(store), NULL);
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
252
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
253 return store->account;
4adf517478fc Create new widget and store for choosing status primitives
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
254 }

mercurial