annotate src/pluginpref.c @ 10007:267a2b69e36e

[gaim-migrate @ 10924] Better i18nability and more uniform code? committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Fri, 10 Sep 2004 04:30:37 +0000
parents 1ae82c0c24ee
children 26eac2362c32
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8713
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
1 /**
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
2 * gaim
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
3 *
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
4 * Gaim is the legal property of its developers, whose names are too numerous
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
6 * source distribution.
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
7 *
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
11 * (at your option) any later version.
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
12 *
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
16 * GNU General Public License for more details.
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
17 *
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
21 */
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
22 #ifdef HAVE_CONFIG_H
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
23 # include <config.h>
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
24 #endif
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
25
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
26 #include <glib.h>
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
27
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
28 #include "debug.h"
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
29 #include "internal.h"
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
30 #include "pluginpref.h"
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
31 #include "prefs.h"
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
32
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
33 struct _GaimPluginPrefFrame {
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
34 GList *prefs;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
35 };
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
36
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
37 struct _GaimPluginPref {
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
38 char *name;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
39 char *label;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
40
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
41 GaimPluginPrefType type;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
42
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
43 int min;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
44 int max;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
45 GList *choices;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
46 unsigned int max_length;
9841
1ae82c0c24ee [gaim-migrate @ 10718]
Mark Doliner <mark@kingant.net>
parents: 8757
diff changeset
47 gboolean masked;
8713
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
48 };
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
49
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
50 GaimPluginPrefFrame *
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
51 gaim_plugin_pref_frame_new() {
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
52 GaimPluginPrefFrame *frame;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
53
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
54 frame = g_new0(GaimPluginPrefFrame, 1);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
55
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
56 return frame;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
57 }
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
58
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
59 void
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
60 gaim_plugin_pref_frame_destroy(GaimPluginPrefFrame *frame) {
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
61 GaimPluginPref *pref;
8745
6c0fae7a4f1a [gaim-migrate @ 9500]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
62 GList *l;
8713
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
63
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
64 g_return_if_fail(frame);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
65
8745
6c0fae7a4f1a [gaim-migrate @ 9500]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
66 for(l = frame->prefs; l != NULL; l = l->next) {
8713
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
67 pref = (GaimPluginPref *)l->data;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
68 gaim_plugin_pref_destroy(pref);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
69 }
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
70
8745
6c0fae7a4f1a [gaim-migrate @ 9500]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
71 g_list_free(frame->prefs);
6c0fae7a4f1a [gaim-migrate @ 9500]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
72 frame->prefs = NULL;
6c0fae7a4f1a [gaim-migrate @ 9500]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
73
6c0fae7a4f1a [gaim-migrate @ 9500]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
74 g_free(frame);
8713
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
75 frame = NULL;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
76 }
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
77
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
78 void
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
79 gaim_plugin_pref_frame_add(GaimPluginPrefFrame *frame, GaimPluginPref *pref) {
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
80 g_return_if_fail(frame);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
81 g_return_if_fail(pref);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
82
8745
6c0fae7a4f1a [gaim-migrate @ 9500]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
83 frame->prefs = g_list_append(frame->prefs, pref);
8713
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
84 }
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
85
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
86 GList *
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
87 gaim_plugin_pref_frame_get_prefs(GaimPluginPrefFrame *frame) {
8745
6c0fae7a4f1a [gaim-migrate @ 9500]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
88 g_return_val_if_fail(frame, NULL);
6c0fae7a4f1a [gaim-migrate @ 9500]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
89 g_return_val_if_fail(frame->prefs, NULL);
6c0fae7a4f1a [gaim-migrate @ 9500]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
90
8713
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
91 return frame->prefs;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
92 }
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
93
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
94 GaimPluginPref *
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
95 gaim_plugin_pref_new() {
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
96 GaimPluginPref *pref;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
97
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
98 pref = g_new0(GaimPluginPref, 1);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
99
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
100 return pref;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
101 }
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
102
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
103 GaimPluginPref *
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
104 gaim_plugin_pref_new_with_name(char *name) {
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
105 GaimPluginPref *pref;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
106
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
107 g_return_val_if_fail(name, NULL);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
108
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
109 pref = g_new0(GaimPluginPref, 1);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
110 pref->name = g_strdup(name);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
111
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
112 return pref;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
113 }
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
114
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
115 GaimPluginPref *
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
116 gaim_plugin_pref_new_with_label(char *label) {
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
117 GaimPluginPref *pref;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
118
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
119 g_return_val_if_fail(label, NULL);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
120
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
121 pref = g_new0(GaimPluginPref, 1);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
122 pref->label = g_strdup(label);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
123
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
124 return pref;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
125 }
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
126
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
127 GaimPluginPref *
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
128 gaim_plugin_pref_new_with_name_and_label(char *name, char *label) {
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
129 GaimPluginPref *pref;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
130
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
131 g_return_val_if_fail(name, NULL);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
132 g_return_val_if_fail(label, NULL);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
133
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
134 pref = g_new0(GaimPluginPref, 1);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
135 pref->name = g_strdup(name);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
136 pref->label = g_strdup(label);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
137
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
138 return pref;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
139 }
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
140
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
141 void
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
142 gaim_plugin_pref_destroy(GaimPluginPref *pref) {
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
143 g_return_if_fail(pref);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
144
8745
6c0fae7a4f1a [gaim-migrate @ 9500]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
145 if(pref->name) {
8713
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
146 g_free(pref->name);
8745
6c0fae7a4f1a [gaim-migrate @ 9500]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
147 pref->name = NULL;
6c0fae7a4f1a [gaim-migrate @ 9500]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
148 }
8713
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
149
8745
6c0fae7a4f1a [gaim-migrate @ 9500]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
150 if(pref->label) {
6c0fae7a4f1a [gaim-migrate @ 9500]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
151 g_free(pref->label);
6c0fae7a4f1a [gaim-migrate @ 9500]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
152 pref->label = NULL;
6c0fae7a4f1a [gaim-migrate @ 9500]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
153 }
8713
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
154
8745
6c0fae7a4f1a [gaim-migrate @ 9500]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
155 if(pref->choices) {
6c0fae7a4f1a [gaim-migrate @ 9500]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
156 g_list_free(pref->choices);
6c0fae7a4f1a [gaim-migrate @ 9500]
Luke Schierer <lschiere@pidgin.im>
parents: 8713
diff changeset
157 pref->choices = NULL;
8713
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
158 }
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
159
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
160 g_free(pref);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
161 }
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
162
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
163 void
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
164 gaim_plugin_pref_set_name(GaimPluginPref *pref, char *name) {
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
165 g_return_if_fail(pref);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
166 g_return_if_fail(name);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
167
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
168 if(pref->name)
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
169 g_free(pref->name);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
170
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
171 pref->name = g_strdup(name);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
172 }
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
173
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
174 char *
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
175 gaim_plugin_pref_get_name(GaimPluginPref *pref) {
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
176 g_return_val_if_fail(pref, NULL);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
177
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
178 return pref->name;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
179 }
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
180
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
181 void
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
182 gaim_plugin_pref_set_label(GaimPluginPref *pref, char *label) {
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
183 g_return_if_fail(pref);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
184 g_return_if_fail(label);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
185
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
186 if(pref->label)
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
187 g_free(pref->label);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
188
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
189 pref->label = g_strdup(label);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
190 }
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
191
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
192 char *
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
193 gaim_plugin_pref_get_label(GaimPluginPref *pref) {
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
194 g_return_val_if_fail(pref, NULL);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
195
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
196 return pref->label;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
197 }
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
198
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
199 void
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
200 gaim_plugin_pref_set_bounds(GaimPluginPref *pref, int min, int max) {
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
201 int tmp;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
202
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
203 g_return_if_fail(pref);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
204 g_return_if_fail(pref->name);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
205
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
206 if(gaim_prefs_get_type(pref->name) != GAIM_PREF_INT) {
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
207 gaim_debug(GAIM_DEBUG_INFO, "pluginpref",
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
208 "gaim_plugin_pref_set_bounds: %s is not an integer pref\n",
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
209 pref->name);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
210 return;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
211 }
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
212
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
213 if(min > max) {
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
214 tmp = min;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
215 min = max;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
216 max = tmp;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
217 }
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
218
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
219 pref->min = min;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
220 pref->max = max;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
221 }
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
222
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
223 void gaim_plugin_pref_get_bounds(GaimPluginPref *pref, int *min, int *max) {
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
224 g_return_if_fail(pref);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
225 g_return_if_fail(pref->name);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
226
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
227 if(gaim_prefs_get_type(pref->name) != GAIM_PREF_INT) {
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
228 gaim_debug(GAIM_DEBUG_INFO, "pluginpref",
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
229 "gaim_plugin_pref_get_bounds: %s is not an integer pref\n",
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
230 pref->name);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
231 return;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
232 }
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
233
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
234 *min = pref->min;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
235 *max = pref->max;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
236 }
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
237
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
238 void
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
239 gaim_plugin_pref_set_type(GaimPluginPref *pref, GaimPluginPrefType type) {
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
240 g_return_if_fail(pref);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
241
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
242 pref->type = type;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
243 }
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
244
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
245 GaimPluginPrefType
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
246 gaim_plugin_pref_get_type(GaimPluginPref *pref) {
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
247 g_return_val_if_fail(pref, GAIM_PLUGIN_PREF_NONE);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
248
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
249 return pref->type;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
250 }
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
251
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
252 void
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
253 gaim_plugin_pref_add_choice(GaimPluginPref *pref, char *label, gpointer choice) {
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
254 g_return_if_fail(pref);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
255 g_return_if_fail(label);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
256 g_return_if_fail(choice);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
257
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
258 pref->choices = g_list_append(pref->choices, label);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
259 pref->choices = g_list_append(pref->choices, choice);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
260 }
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
261
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
262 GList *
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
263 gaim_plugin_pref_get_choices(GaimPluginPref *pref) {
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
264 g_return_val_if_fail(pref, NULL);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
265
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
266 return pref->choices;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
267 }
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
268
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
269 void
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
270 gaim_plugin_pref_set_max_length(GaimPluginPref *pref, unsigned int max_length) {
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
271 g_return_if_fail(pref);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
272
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
273 pref->max_length = max_length;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
274 }
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
275
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
276 unsigned int
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
277 gaim_plugin_pref_get_max_length(GaimPluginPref *pref) {
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
278 g_return_val_if_fail(pref, 0);
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
279
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
280 return pref->max_length;
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents:
diff changeset
281 }
9841
1ae82c0c24ee [gaim-migrate @ 10718]
Mark Doliner <mark@kingant.net>
parents: 8757
diff changeset
282
1ae82c0c24ee [gaim-migrate @ 10718]
Mark Doliner <mark@kingant.net>
parents: 8757
diff changeset
283 void
1ae82c0c24ee [gaim-migrate @ 10718]
Mark Doliner <mark@kingant.net>
parents: 8757
diff changeset
284 gaim_plugin_pref_set_masked(GaimPluginPref *pref, gboolean masked) {
1ae82c0c24ee [gaim-migrate @ 10718]
Mark Doliner <mark@kingant.net>
parents: 8757
diff changeset
285 g_return_if_fail(pref);
1ae82c0c24ee [gaim-migrate @ 10718]
Mark Doliner <mark@kingant.net>
parents: 8757
diff changeset
286
1ae82c0c24ee [gaim-migrate @ 10718]
Mark Doliner <mark@kingant.net>
parents: 8757
diff changeset
287 pref->masked = masked;
1ae82c0c24ee [gaim-migrate @ 10718]
Mark Doliner <mark@kingant.net>
parents: 8757
diff changeset
288 }
1ae82c0c24ee [gaim-migrate @ 10718]
Mark Doliner <mark@kingant.net>
parents: 8757
diff changeset
289
1ae82c0c24ee [gaim-migrate @ 10718]
Mark Doliner <mark@kingant.net>
parents: 8757
diff changeset
290 gboolean
1ae82c0c24ee [gaim-migrate @ 10718]
Mark Doliner <mark@kingant.net>
parents: 8757
diff changeset
291 gaim_plugin_pref_get_masked(GaimPluginPref *pref) {
1ae82c0c24ee [gaim-migrate @ 10718]
Mark Doliner <mark@kingant.net>
parents: 8757
diff changeset
292 g_return_val_if_fail(pref, FALSE);
1ae82c0c24ee [gaim-migrate @ 10718]
Mark Doliner <mark@kingant.net>
parents: 8757
diff changeset
293
1ae82c0c24ee [gaim-migrate @ 10718]
Mark Doliner <mark@kingant.net>
parents: 8757
diff changeset
294 return pref->masked;
1ae82c0c24ee [gaim-migrate @ 10718]
Mark Doliner <mark@kingant.net>
parents: 8757
diff changeset
295 }