pidgin/pidginaccountfilterprotocol.c

Sat, 29 Oct 2022 01:14:13 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Sat, 29 Oct 2022 01:14:13 -0500
changeset 41859
ed82ab63d15a
parent 41479
3d2e114380f6
child 41864
6f490dec468f
permissions
-rw-r--r--

Convert PidginProxyPrefs to Adwaita 1.2

Testing Done:
Set all the values via the ui and the config file and tested bad values in the port in both as well. Bad values in the ui will store whatever atoi returned, but bad values in the config file will fallback to the default.

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

40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Pidgin - Internet Messenger
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * Pidgin is the legal property of its developers, whose names are too numerous
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * source distribution.
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 *
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * (at your option) any later version.
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 *
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 * GNU General Public License for more details.
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 *
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
40539
2941deda6d8d Use an https link to gnu.org in the license file headers
Gary Kramlich <grim@reaperworld.com>
parents: 40534
diff changeset
20 * along with this program; if not, see <https://www.gnu.org/licenses/>.
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include "pidgin/pidginaccountfilterprotocol.h"
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 #include "pidgin/pidginaccountstore.h"
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 #include <purple.h>
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 struct _PidginAccountFilterProtocol {
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 GtkTreeModelFilter parent;
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 gchar *protocol_id;
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 };
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 enum {
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 PROP_0,
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 PROP_PROTOCOL_ID,
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 N_PROPERTIES
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 };
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 static GParamSpec *properties[N_PROPERTIES] = { NULL, };
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 /******************************************************************************
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 * Helpers
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 *****************************************************************************/
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 static void
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 pidgin_account_filter_protocol_set_protocol_id(PidginAccountFilterProtocol *filter,
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 const gchar *protocol_id)
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 {
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 g_free(filter->protocol_id);
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 filter->protocol_id = g_strdup(protocol_id);
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 }
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 static gboolean
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 pidgin_account_filter_protocol_func(GtkTreeModel *model, GtkTreeIter *iter,
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 gpointer data)
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 {
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 PidginAccountFilterProtocol *filter = NULL;
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 PurpleAccount *account = NULL;
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 gboolean ret = FALSE;
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 g_return_val_if_fail(PIDGIN_IS_ACCOUNT_FILTER_PROTOCOL(data), FALSE);
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 g_return_val_if_fail(GTK_IS_TREE_MODEL(model), FALSE);
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 g_return_val_if_fail(iter != NULL, FALSE);
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 filter = PIDGIN_ACCOUNT_FILTER_PROTOCOL(data);
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 gtk_tree_model_get(model, iter, PIDGIN_ACCOUNT_STORE_COLUMN_ACCOUNT,
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 &account, -1);
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 if(!PURPLE_IS_ACCOUNT(account)) {
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 return FALSE;
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 }
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 ret = purple_strequal(purple_account_get_protocol_id(account),
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 filter->protocol_id);
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 g_object_unref(G_OBJECT(account));
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 return ret;
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 }
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 /******************************************************************************
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 * GObject Implementation
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 *****************************************************************************/
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 G_DEFINE_TYPE(PidginAccountFilterProtocol, pidgin_account_filter_protocol,
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 GTK_TYPE_TREE_MODEL_FILTER)
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 static void
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 pidgin_account_filter_protocol_get_property(GObject *obj, guint param_id,
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 GValue *value, GParamSpec *pspec)
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 {
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 PidginAccountFilterProtocol *filter = PIDGIN_ACCOUNT_FILTER_PROTOCOL(obj);
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 switch(param_id) {
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 case PROP_PROTOCOL_ID:
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 g_value_set_string(
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 value, pidgin_account_filter_protocol_get_protocol_id(filter));
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 break;
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 default:
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 break;
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102 }
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 }
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105 static void
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 pidgin_account_filter_protocol_set_property(GObject *obj, guint param_id,
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107 const GValue *value,
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108 GParamSpec *pspec)
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 {
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110 PidginAccountFilterProtocol *filter = PIDGIN_ACCOUNT_FILTER_PROTOCOL(obj);
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112 switch(param_id) {
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113 case PROP_PROTOCOL_ID:
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114 pidgin_account_filter_protocol_set_protocol_id(
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 filter, g_value_get_string(value));
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116 break;
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117 default:
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119 break;
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120 }
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121 }
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123 static void
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124 pidgin_account_filter_protocol_finalize(GObject *obj) {
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125 PidginAccountFilterProtocol *filter = PIDGIN_ACCOUNT_FILTER_PROTOCOL(obj);
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127 g_free(filter->protocol_id);
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129 G_OBJECT_CLASS(pidgin_account_filter_protocol_parent_class)->finalize(obj);
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130 }
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132 static void
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133 pidgin_account_filter_protocol_init(PidginAccountFilterProtocol *filter) {
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134 gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(filter),
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135 pidgin_account_filter_protocol_func,
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
136 filter, NULL);
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
137 }
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
138
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139 static void
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 pidgin_account_filter_protocol_class_init(PidginAccountFilterProtocolClass *klass) {
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
141 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143 obj_class->get_property = pidgin_account_filter_protocol_get_property;
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144 obj_class->set_property = pidgin_account_filter_protocol_set_property;
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
145 obj_class->finalize = pidgin_account_filter_protocol_finalize;
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
146
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147 /**
41479
3d2e114380f6 Add source files to GObject introspection
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40539
diff changeset
148 * PidginAccountFilterProtocol:protocol-id:
40534
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
149 *
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150 * The protocol id that will be filtered for.
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
151 */
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
152 properties[PROP_PROTOCOL_ID] = g_param_spec_string(
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
153 "protocol-id", "protocol-id", "The id of the protocol to filter",
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
154 NULL,
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
156
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157 g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158 }
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
159
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160 /******************************************************************************
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161 * API
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162 *****************************************************************************/
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163 GtkTreeModel *
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
164 pidgin_account_filter_protocol_new(const gchar *protocol_id,
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
165 GtkTreeModel *child_model,
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
166 GtkTreePath *root)
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
167 {
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
168 g_return_val_if_fail(GTK_IS_TREE_MODEL(child_model), NULL);
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
169
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
170 return g_object_new(
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
171 PIDGIN_TYPE_ACCOUNT_FILTER_PROTOCOL,
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
172 "protocol-id", protocol_id,
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
173 "child-model", child_model,
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
174 "virtual-root", root,
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
175 NULL);
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
176 }
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
178 const gchar *
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
179 pidgin_account_filter_protocol_get_protocol_id(PidginAccountFilterProtocol *filter) {
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
180 g_return_val_if_fail(PIDGIN_IS_ACCOUNT_FILTER_PROTOCOL(filter), NULL);
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
181
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
182 return filter->protocol_id;
8dad2981fb86 Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183 }

mercurial