Mercurial > pidgin.yaz
annotate finch/gntprefs.c @ 18308:4c3a24270114
Removes the 'remove all buffer tags' function from gtkimhtml's close_tags() function. The problem was that the BACKGROUND tag is always at the end iter, and we don't want to remove that. The toggle functions called above it should do the trick of properly resetting everything, and it does seem to. Fixes #1034
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Wed, 27 Jun 2007 18:52:12 +0000 |
parents | b8572b937c09 |
children | 65fedb03ac05 1cb69ea47a6e |
rev | line source |
---|---|
15818 | 1 /** |
2 * @file gntprefs.c GNT Preferences API | |
16194
0f0832c13fcb
Rename the Doxygen group from gntui to finch and define the finch group
Richard Laager <rlaager@wiktel.com>
parents:
15871
diff
changeset
|
3 * @ingroup finch |
15818 | 4 * |
15871
66dff3dfdea6
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
5 * finch |
15818 | 6 * |
15871
66dff3dfdea6
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
7 * Finch is the legal property of its developers, whose names are too numerous |
15818 | 8 * to list here. Please refer to the COPYRIGHT file distributed with this |
9 * source distribution. | |
10 * | |
11 * This program is free software; you can redistribute it and/or modify | |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 */ | |
18210
b8572b937c09
#include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents:
18118
diff
changeset
|
25 #include "finch.h" |
b8572b937c09
#include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents:
18118
diff
changeset
|
26 |
15818 | 27 #include <prefs.h> |
28 #include <savedstatuses.h> | |
29 | |
30 #include "gntprefs.h" | |
31 #include "gntrequest.h" | |
32 | |
33 #include <string.h> | |
34 | |
35 static GList *freestrings; /* strings to be freed when the pref-window is closed */ | |
36 | |
37 void finch_prefs_init() | |
38 { | |
16427
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16310
diff
changeset
|
39 purple_prefs_add_none("/finch"); |
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16310
diff
changeset
|
40 |
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16310
diff
changeset
|
41 purple_prefs_add_none("/finch/plugins"); |
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16310
diff
changeset
|
42 purple_prefs_add_path_list("/finch/plugins/loaded", NULL); |
16952
beb960114f7d
I liked Etan's suggestion in devel. Now, Finch will bold unseen plugins in the plugin dialog. A plugin is considered 'seen' only after the details of the plugin is viewed by the user.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16573
diff
changeset
|
43 purple_prefs_add_path_list("/finch/plugins/seen", NULL); |
15818 | 44 |
16427
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16310
diff
changeset
|
45 purple_prefs_add_none("/finch/conversations"); |
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16310
diff
changeset
|
46 purple_prefs_add_bool("/finch/conversations/timestamps", TRUE); |
16573
ac0d07c7fd90
Pref migration for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16442
diff
changeset
|
47 purple_prefs_add_bool("/finch/conversations/notify_typing", FALSE); |
ac0d07c7fd90
Pref migration for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16442
diff
changeset
|
48 } |
ac0d07c7fd90
Pref migration for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16442
diff
changeset
|
49 |
ac0d07c7fd90
Pref migration for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16442
diff
changeset
|
50 void finch_prefs_update_old() |
ac0d07c7fd90
Pref migration for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16442
diff
changeset
|
51 { |
ac0d07c7fd90
Pref migration for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16442
diff
changeset
|
52 const char *str = NULL; |
ac0d07c7fd90
Pref migration for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16442
diff
changeset
|
53 |
16427
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16310
diff
changeset
|
54 purple_prefs_rename("/gaim/gnt", "/finch"); |
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16310
diff
changeset
|
55 purple_prefs_rename("/purple/gnt", "/finch"); |
16573
ac0d07c7fd90
Pref migration for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16442
diff
changeset
|
56 |
ac0d07c7fd90
Pref migration for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16442
diff
changeset
|
57 if ((str = purple_prefs_get_string("/purple/away/idle_reporting")) && |
ac0d07c7fd90
Pref migration for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16442
diff
changeset
|
58 strcmp(str, "gaim") == 0) |
ac0d07c7fd90
Pref migration for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16442
diff
changeset
|
59 purple_prefs_set_string("/purple/away/idle_reporting", "purple"); |
15818 | 60 } |
61 | |
62 typedef struct | |
63 { | |
15823 | 64 PurplePrefType type; |
15818 | 65 const char *pref; |
66 const char *label; | |
67 GList *(*lv)(); /* If the value is to be selected from a number of choices */ | |
68 } Prefs; | |
69 | |
70 static GList * | |
71 get_log_options() | |
72 { | |
15823 | 73 return purple_log_logger_get_options(); |
15818 | 74 } |
75 | |
76 static GList * | |
77 get_idle_options() | |
78 { | |
79 GList *list = NULL; | |
17171
c61187e0c752
Fix a compiler warning.
Richard Laager <rlaager@wiktel.com>
parents:
17160
diff
changeset
|
80 list = g_list_append(list, (char *)_("Based on keyboard use")); |
15818 | 81 list = g_list_append(list, "system"); |
82 list = g_list_append(list, (char*)_("From last sent message")); | |
15823 | 83 list = g_list_append(list, "purple"); |
15818 | 84 list = g_list_append(list, (char*)_("Never")); |
85 list = g_list_append(list, "never"); | |
86 return list; | |
87 } | |
88 | |
89 static GList * | |
90 get_status_titles() | |
91 { | |
92 GList *list = NULL; | |
18118
ab6d2763b8d8
Re-fix the DBus list handling code by killing const GList* / const GSList*
Richard Laager <rlaager@wiktel.com>
parents:
17171
diff
changeset
|
93 GList *iter; |
15823 | 94 for (iter = purple_savedstatuses_get_all(); iter; iter = iter->next) { |
15818 | 95 char *str; |
15823 | 96 if (purple_savedstatus_is_transient(iter->data)) |
15818 | 97 continue; |
15823 | 98 str = g_strdup_printf("%ld", purple_savedstatus_get_creation_time(iter->data)); |
99 list = g_list_append(list, (char*)purple_savedstatus_get_title(iter->data)); | |
15818 | 100 list = g_list_append(list, str); |
101 freestrings = g_list_prepend(freestrings, str); | |
102 } | |
103 return list; | |
104 } | |
105 | |
15823 | 106 static PurpleRequestField * |
15818 | 107 get_pref_field(Prefs *prefs) |
108 { | |
15823 | 109 PurpleRequestField *field = NULL; |
15818 | 110 |
111 if (prefs->lv == NULL) | |
112 { | |
113 switch (prefs->type) | |
114 { | |
15823 | 115 case PURPLE_PREF_BOOLEAN: |
116 field = purple_request_field_bool_new(prefs->pref, _(prefs->label), | |
117 purple_prefs_get_bool(prefs->pref)); | |
15818 | 118 break; |
15823 | 119 case PURPLE_PREF_INT: |
120 field = purple_request_field_int_new(prefs->pref, _(prefs->label), | |
121 purple_prefs_get_int(prefs->pref)); | |
15818 | 122 break; |
15823 | 123 case PURPLE_PREF_STRING: |
124 field = purple_request_field_string_new(prefs->pref, _(prefs->label), | |
125 purple_prefs_get_string(prefs->pref), FALSE); | |
15818 | 126 break; |
127 default: | |
128 break; | |
129 } | |
130 } | |
131 else | |
132 { | |
133 GList *list = prefs->lv(), *iter; | |
134 if (list) | |
15823 | 135 field = purple_request_field_list_new(prefs->pref, _(prefs->label)); |
15818 | 136 for (iter = list; iter; iter = iter->next) |
137 { | |
138 gboolean select = FALSE; | |
139 const char *data = iter->data; | |
140 int idata; | |
141 iter = iter->next; | |
142 switch (prefs->type) | |
143 { | |
15823 | 144 case PURPLE_PREF_BOOLEAN: |
15818 | 145 sscanf(iter->data, "%d", &idata); |
15823 | 146 if (purple_prefs_get_bool(prefs->pref) == idata) |
15818 | 147 select = TRUE; |
148 break; | |
15823 | 149 case PURPLE_PREF_INT: |
15818 | 150 sscanf(iter->data, "%d", &idata); |
15823 | 151 if (purple_prefs_get_int(prefs->pref) == idata) |
15818 | 152 select = TRUE; |
153 break; | |
15823 | 154 case PURPLE_PREF_STRING: |
155 if (strcmp(purple_prefs_get_string(prefs->pref), iter->data) == 0) | |
15818 | 156 select = TRUE; |
157 break; | |
158 default: | |
159 break; | |
160 } | |
15823 | 161 purple_request_field_list_add(field, data, iter->data); |
15818 | 162 if (select) |
15823 | 163 purple_request_field_list_add_selected(field, data); |
15818 | 164 } |
165 g_list_free(list); | |
166 } | |
167 return field; | |
168 } | |
169 | |
170 static Prefs blist[] = | |
171 { | |
16427
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16310
diff
changeset
|
172 {PURPLE_PREF_BOOLEAN, "/finch/blist/idletime", N_("Show Idle Time"), NULL}, |
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16310
diff
changeset
|
173 {PURPLE_PREF_BOOLEAN, "/finch/blist/showoffline", N_("Show Offline Buddies"), NULL}, |
15823 | 174 {PURPLE_PREF_NONE, NULL, NULL, NULL} |
15818 | 175 }; |
176 | |
177 static Prefs convs[] = | |
178 { | |
16427
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16310
diff
changeset
|
179 {PURPLE_PREF_BOOLEAN, "/finch/conversations/timestamps", N_("Show Timestamps"), NULL}, |
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16310
diff
changeset
|
180 {PURPLE_PREF_BOOLEAN, "/finch/conversations/notify_typing", N_("Notify buddies when you are typing"), NULL}, |
15823 | 181 {PURPLE_PREF_NONE, NULL, NULL, NULL} |
15818 | 182 }; |
183 | |
184 static Prefs logging[] = | |
185 { | |
16427
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16310
diff
changeset
|
186 {PURPLE_PREF_STRING, "/purple/logging/format", N_("Log format"), get_log_options}, |
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16310
diff
changeset
|
187 {PURPLE_PREF_BOOLEAN, "/purple/logging/log_ims", N_("Log IMs"), NULL}, |
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16310
diff
changeset
|
188 {PURPLE_PREF_BOOLEAN, "/purple/logging/log_chats", N_("Log chats"), NULL}, |
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16310
diff
changeset
|
189 {PURPLE_PREF_BOOLEAN, "/purple/logging/log_system", N_("Log status change events"), NULL}, |
15823 | 190 {PURPLE_PREF_NONE, NULL, NULL, NULL}, |
15818 | 191 }; |
192 | |
193 /* XXX: Translate after the freeze */ | |
194 static Prefs idle[] = | |
195 { | |
16427
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16310
diff
changeset
|
196 {PURPLE_PREF_STRING, "/purple/away/idle_reporting", "Report Idle time", get_idle_options}, |
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16310
diff
changeset
|
197 {PURPLE_PREF_BOOLEAN, "/purple/away/away_when_idle", "Change status when idle", NULL}, |
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16310
diff
changeset
|
198 {PURPLE_PREF_INT, "/purple/away/mins_before_away", "Minutes before changing status", NULL}, |
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16310
diff
changeset
|
199 {PURPLE_PREF_INT, "/purple/savedstatus/idleaway", "Change status to", get_status_titles}, |
15823 | 200 {PURPLE_PREF_NONE, NULL, NULL, NULL}, |
15818 | 201 }; |
202 | |
203 static void | |
204 free_strings() | |
205 { | |
206 g_list_foreach(freestrings, (GFunc)g_free, NULL); | |
207 g_list_free(freestrings); | |
208 freestrings = NULL; | |
209 } | |
210 | |
211 static void | |
15823 | 212 save_cb(void *data, PurpleRequestFields *allfields) |
15818 | 213 { |
16310
8c89913276b3
Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
214 finch_request_save_in_prefs(data, allfields); |
15818 | 215 free_strings(); |
216 } | |
217 | |
218 static void | |
15823 | 219 add_pref_group(PurpleRequestFields *fields, const char *title, Prefs *prefs) |
15818 | 220 { |
15823 | 221 PurpleRequestField *field; |
222 PurpleRequestFieldGroup *group; | |
15818 | 223 int i; |
224 | |
15823 | 225 group = purple_request_field_group_new(title); |
226 purple_request_fields_add_group(fields, group); | |
15818 | 227 for (i = 0; prefs[i].pref; i++) |
228 { | |
229 field = get_pref_field(prefs + i); | |
230 if (field) | |
15823 | 231 purple_request_field_group_add_field(group, field); |
15818 | 232 } |
233 } | |
234 | |
235 void finch_prefs_show_all() | |
236 { | |
15823 | 237 PurpleRequestFields *fields; |
15818 | 238 |
15823 | 239 fields = purple_request_fields_new(); |
15818 | 240 |
241 add_pref_group(fields, _("Buddy List"), blist); | |
242 add_pref_group(fields, _("Conversations"), convs); | |
243 add_pref_group(fields, _("Logging"), logging); | |
244 add_pref_group(fields, _("Idle"), idle); | |
245 | |
15823 | 246 purple_request_fields(NULL, _("Preferences"), NULL, NULL, fields, |
16442
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16427
diff
changeset
|
247 _("Save"), G_CALLBACK(save_cb), _("Cancel"), free_strings, |
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16427
diff
changeset
|
248 NULL, NULL, NULL, |
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16427
diff
changeset
|
249 NULL); |
15818 | 250 } |
251 |