annotate finch/gntprefs.c @ 15979:2c81ebc7bf0b

Add a way to get a list of bindings for a widget. This can be used by, eg, a window-manager to show helpful messages to the user.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Wed, 04 Apr 2007 03:47:13 +0000
parents 66dff3dfdea6
children 0f0832c13fcb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /**
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * @file gntprefs.c GNT Preferences API
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 * @ingroup gntui
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 *
15870
66dff3dfdea6 Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents: 15822
diff changeset
5 * finch
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 *
15870
66dff3dfdea6 Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents: 15822
diff changeset
7 * Finch is the legal property of its developers, whose names are too numerous
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * to list here. Please refer to the COPYRIGHT file distributed with this
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * source distribution.
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 *
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * (at your option) any later version.
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 *
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * This program is distributed in the hope that it will be useful,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 * GNU General Public License for more details.
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 *
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 * along with this program; if not, write to the Free Software
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24 */
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25 #include <prefs.h>
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26 #include <savedstatuses.h>
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
28 #include "finch.h"
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 #include "gntprefs.h"
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 #include "gntrequest.h"
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 #include <string.h>
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 static GList *freestrings; /* strings to be freed when the pref-window is closed */
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 void finch_prefs_init()
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
38 purple_prefs_add_none("/purple");
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
39 purple_prefs_add_none("/purple/gnt");
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
41 purple_prefs_add_none("/purple/gnt/plugins");
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
42 purple_prefs_add_path_list("/purple/gnt/plugins/loaded", NULL);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
44 purple_prefs_add_none("/purple/gnt/conversations");
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
45 purple_prefs_add_bool("/purple/gnt/conversations/timestamps", TRUE);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
46 purple_prefs_add_bool("/purple/gnt/conversations/notify_typing", FALSE); /* XXX: Not functional yet */
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 typedef struct
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
51 PurplePrefType type;
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52 const char *pref;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 const char *label;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 GList *(*lv)(); /* If the value is to be selected from a number of choices */
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 } Prefs;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57 static GList *
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58 get_log_options()
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
60 return purple_log_logger_get_options();
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63 static GList *
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64 get_idle_options()
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 GList *list = NULL;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67 list = g_list_append(list, "Based on keyboard use"); /* XXX: string freeze */
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68 list = g_list_append(list, "system");
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 list = g_list_append(list, (char*)_("From last sent message"));
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
70 list = g_list_append(list, "purple");
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71 list = g_list_append(list, (char*)_("Never"));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72 list = g_list_append(list, "never");
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73 return list;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76 static GList *
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77 get_status_titles()
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 GList *list = NULL;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 const GList *iter;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
81 for (iter = purple_savedstatuses_get_all(); iter; iter = iter->next) {
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82 char *str;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
83 if (purple_savedstatus_is_transient(iter->data))
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 continue;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
85 str = g_strdup_printf("%ld", purple_savedstatus_get_creation_time(iter->data));
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
86 list = g_list_append(list, (char*)purple_savedstatus_get_title(iter->data));
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87 list = g_list_append(list, str);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88 freestrings = g_list_prepend(freestrings, str);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
90 return list;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
93 static PurpleRequestField *
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94 get_pref_field(Prefs *prefs)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
96 PurpleRequestField *field = NULL;
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98 if (prefs->lv == NULL)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100 switch (prefs->type)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
101 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
102 case PURPLE_PREF_BOOLEAN:
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
103 field = purple_request_field_bool_new(prefs->pref, _(prefs->label),
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
104 purple_prefs_get_bool(prefs->pref));
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
105 break;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
106 case PURPLE_PREF_INT:
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
107 field = purple_request_field_int_new(prefs->pref, _(prefs->label),
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
108 purple_prefs_get_int(prefs->pref));
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109 break;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
110 case PURPLE_PREF_STRING:
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
111 field = purple_request_field_string_new(prefs->pref, _(prefs->label),
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
112 purple_prefs_get_string(prefs->pref), FALSE);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113 break;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
114 default:
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115 break;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118 else
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120 GList *list = prefs->lv(), *iter;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121 if (list)
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
122 field = purple_request_field_list_new(prefs->pref, _(prefs->label));
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123 for (iter = list; iter; iter = iter->next)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125 gboolean select = FALSE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126 const char *data = iter->data;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127 int idata;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128 iter = iter->next;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129 switch (prefs->type)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
131 case PURPLE_PREF_BOOLEAN:
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132 sscanf(iter->data, "%d", &idata);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
133 if (purple_prefs_get_bool(prefs->pref) == idata)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134 select = TRUE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135 break;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
136 case PURPLE_PREF_INT:
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 sscanf(iter->data, "%d", &idata);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
138 if (purple_prefs_get_int(prefs->pref) == idata)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139 select = TRUE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140 break;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
141 case PURPLE_PREF_STRING:
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
142 if (strcmp(purple_prefs_get_string(prefs->pref), iter->data) == 0)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143 select = TRUE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
144 break;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145 default:
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146 break;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
147 }
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
148 purple_request_field_list_add(field, data, iter->data);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149 if (select)
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
150 purple_request_field_list_add_selected(field, data);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
152 g_list_free(list);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
153 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
154 return field;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
155 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157 static Prefs blist[] =
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
159 {PURPLE_PREF_BOOLEAN, "/purple/gnt/blist/idletime", N_("Show Idle Time"), NULL},
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
160 {PURPLE_PREF_BOOLEAN, "/purple/gnt/blist/showoffline", N_("Show Offline Buddies"), NULL},
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
161 {PURPLE_PREF_NONE, NULL, NULL, NULL}
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162 };
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164 static Prefs convs[] =
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
166 {PURPLE_PREF_BOOLEAN, "/purple/gnt/conversations/timestamps", N_("Show Timestamps"), NULL},
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
167 {PURPLE_PREF_BOOLEAN, "/purple/gnt/conversations/notify_typing", N_("Notify buddies when you are typing"), NULL},
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
168 {PURPLE_PREF_NONE, NULL, NULL, NULL}
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169 };
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171 static Prefs logging[] =
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
173 {PURPLE_PREF_STRING, "/core/logging/format", N_("Log format"), get_log_options},
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
174 {PURPLE_PREF_BOOLEAN, "/core/logging/log_ims", N_("Log IMs"), NULL},
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
175 {PURPLE_PREF_BOOLEAN, "/core/logging/log_chats", N_("Log chats"), NULL},
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
176 {PURPLE_PREF_BOOLEAN, "/core/logging/log_system", N_("Log status change events"), NULL},
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
177 {PURPLE_PREF_NONE, NULL, NULL, NULL},
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
178 };
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180 /* XXX: Translate after the freeze */
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181 static Prefs idle[] =
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
183 {PURPLE_PREF_STRING, "/core/away/idle_reporting", "Report Idle time", get_idle_options},
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
184 {PURPLE_PREF_BOOLEAN, "/core/away/away_when_idle", "Change status when idle", NULL},
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
185 {PURPLE_PREF_INT, "/core/away/mins_before_away", "Minutes before changing status", NULL},
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
186 {PURPLE_PREF_INT, "/core/savedstatus/idleaway", "Change status to", get_status_titles},
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
187 {PURPLE_PREF_NONE, NULL, NULL, NULL},
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
188 };
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
189
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
190 static void
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
191 free_strings()
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
192 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193 g_list_foreach(freestrings, (GFunc)g_free, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
194 g_list_free(freestrings);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
195 freestrings = NULL;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
196 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
197
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
198 static void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
199 save_cb(void *data, PurpleRequestFields *allfields)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
200 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
201 GList *list;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
202 for (list = purple_request_fields_get_groups(allfields); list; list = list->next)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
203 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
204 PurpleRequestFieldGroup *group = list->data;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
205 GList *fields = purple_request_field_group_get_fields(group);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207 for (; fields ; fields = fields->next)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
209 PurpleRequestField *field = fields->data;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
210 PurpleRequestFieldType type = purple_request_field_get_type(field);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
211 PurplePrefType pt;
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212 gpointer val = NULL;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
213 const char *id = purple_request_field_get_id(field);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215 switch (type)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
217 case PURPLE_REQUEST_FIELD_LIST:
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
218 val = purple_request_field_list_get_selected(field)->data;
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
219 break;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
220 case PURPLE_REQUEST_FIELD_BOOLEAN:
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
221 val = GINT_TO_POINTER(purple_request_field_bool_get_value(field));
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
222 break;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
223 case PURPLE_REQUEST_FIELD_INTEGER:
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
224 val = GINT_TO_POINTER(purple_request_field_int_get_value(field));
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225 break;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
226 case PURPLE_REQUEST_FIELD_STRING:
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
227 val = (gpointer)purple_request_field_string_get_value(field);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228 break;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 default:
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230 break;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
233 pt = purple_prefs_get_type(id);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234 switch (pt)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
236 case PURPLE_PREF_INT:
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
237 if (type == PURPLE_REQUEST_FIELD_LIST) /* Lists always return string */
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
238 sscanf(val, "%ld", (long int *)&val);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
239 purple_prefs_set_int(id, GPOINTER_TO_INT(val));
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
240 break;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
241 case PURPLE_PREF_BOOLEAN:
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
242 purple_prefs_set_bool(id, GPOINTER_TO_INT(val));
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
243 break;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
244 case PURPLE_PREF_STRING:
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
245 purple_prefs_set_string(id, val);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
246 break;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
247 default:
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
248 break;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
249 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
250 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
251 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
252 free_strings();
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
254
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
255 static void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
256 add_pref_group(PurpleRequestFields *fields, const char *title, Prefs *prefs)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
257 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
258 PurpleRequestField *field;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
259 PurpleRequestFieldGroup *group;
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
260 int i;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
261
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
262 group = purple_request_field_group_new(title);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
263 purple_request_fields_add_group(fields, group);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
264 for (i = 0; prefs[i].pref; i++)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
265 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
266 field = get_pref_field(prefs + i);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
267 if (field)
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
268 purple_request_field_group_add_field(group, field);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
269 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
270 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
271
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
272 void finch_prefs_show_all()
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
273 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
274 PurpleRequestFields *fields;
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
275
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
276 fields = purple_request_fields_new();
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
277
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278 add_pref_group(fields, _("Buddy List"), blist);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
279 add_pref_group(fields, _("Conversations"), convs);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
280 add_pref_group(fields, _("Logging"), logging);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
281 add_pref_group(fields, _("Idle"), idle);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
282
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
283 purple_request_fields(NULL, _("Preferences"), NULL, NULL, fields,
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
284 _("Save"), G_CALLBACK(save_cb), _("Cancel"), free_strings, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
285 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
286