Mercurial > pidgin
annotate finch/gntprefs.c @ 18016:33da621d4b1f
propagate from branch 'org.maemo.garage.pidgin.pidgin.pidgin-create-window' (head a6aaab6e6f2d91496d8d55a77000e33d0914749e)
to branch 'im.pidgin.rlaager.merging.for_2_1_0' (head 1fb0f0a3d73311d3ad68b718e7eca4c57fabf1b0)
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Sun, 20 May 2007 14:55:19 +0000 |
parents | c61187e0c752 |
children | ab6d2763b8d8 6ccd66add326 |
rev | line source |
---|---|
15817 | 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:
15870
diff
changeset
|
3 * @ingroup finch |
15817 | 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 | 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 | 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 */ | |
25 #include <prefs.h> | |
26 #include <savedstatuses.h> | |
27 | |
15822 | 28 #include "finch.h" |
15817 | 29 #include "gntprefs.h" |
30 #include "gntrequest.h" | |
31 | |
32 #include <string.h> | |
33 | |
34 static GList *freestrings; /* strings to be freed when the pref-window is closed */ | |
35 | |
36 void finch_prefs_init() | |
37 { | |
16424
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
|
38 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
|
39 |
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 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
|
41 purple_prefs_add_path_list("/finch/plugins/loaded", NULL); |
16941
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:
16565
diff
changeset
|
42 purple_prefs_add_path_list("/finch/plugins/seen", NULL); |
15817 | 43 |
16424
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
|
44 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
|
45 purple_prefs_add_bool("/finch/conversations/timestamps", TRUE); |
16565
ac0d07c7fd90
Pref migration for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16439
diff
changeset
|
46 purple_prefs_add_bool("/finch/conversations/notify_typing", FALSE); |
ac0d07c7fd90
Pref migration for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16439
diff
changeset
|
47 } |
ac0d07c7fd90
Pref migration for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16439
diff
changeset
|
48 |
ac0d07c7fd90
Pref migration for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16439
diff
changeset
|
49 void finch_prefs_update_old() |
ac0d07c7fd90
Pref migration for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16439
diff
changeset
|
50 { |
ac0d07c7fd90
Pref migration for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16439
diff
changeset
|
51 const char *str = NULL; |
ac0d07c7fd90
Pref migration for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16439
diff
changeset
|
52 |
16424
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
|
53 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
|
54 purple_prefs_rename("/purple/gnt", "/finch"); |
16565
ac0d07c7fd90
Pref migration for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16439
diff
changeset
|
55 |
ac0d07c7fd90
Pref migration for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16439
diff
changeset
|
56 if ((str = purple_prefs_get_string("/purple/away/idle_reporting")) && |
ac0d07c7fd90
Pref migration for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16439
diff
changeset
|
57 strcmp(str, "gaim") == 0) |
ac0d07c7fd90
Pref migration for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16439
diff
changeset
|
58 purple_prefs_set_string("/purple/away/idle_reporting", "purple"); |
15817 | 59 } |
60 | |
61 typedef struct | |
62 { | |
15822 | 63 PurplePrefType type; |
15817 | 64 const char *pref; |
65 const char *label; | |
66 GList *(*lv)(); /* If the value is to be selected from a number of choices */ | |
67 } Prefs; | |
68 | |
69 static GList * | |
70 get_log_options() | |
71 { | |
15822 | 72 return purple_log_logger_get_options(); |
15817 | 73 } |
74 | |
75 static GList * | |
76 get_idle_options() | |
77 { | |
78 GList *list = NULL; | |
17144
c61187e0c752
Fix a compiler warning.
Richard Laager <rlaager@wiktel.com>
parents:
17137
diff
changeset
|
79 list = g_list_append(list, (char *)_("Based on keyboard use")); |
15817 | 80 list = g_list_append(list, "system"); |
81 list = g_list_append(list, (char*)_("From last sent message")); | |
15822 | 82 list = g_list_append(list, "purple"); |
15817 | 83 list = g_list_append(list, (char*)_("Never")); |
84 list = g_list_append(list, "never"); | |
85 return list; | |
86 } | |
87 | |
88 static GList * | |
89 get_status_titles() | |
90 { | |
91 GList *list = NULL; | |
92 const GList *iter; | |
15822 | 93 for (iter = purple_savedstatuses_get_all(); iter; iter = iter->next) { |
15817 | 94 char *str; |
15822 | 95 if (purple_savedstatus_is_transient(iter->data)) |
15817 | 96 continue; |
15822 | 97 str = g_strdup_printf("%ld", purple_savedstatus_get_creation_time(iter->data)); |
98 list = g_list_append(list, (char*)purple_savedstatus_get_title(iter->data)); | |
15817 | 99 list = g_list_append(list, str); |
100 freestrings = g_list_prepend(freestrings, str); | |
101 } | |
102 return list; | |
103 } | |
104 | |
15822 | 105 static PurpleRequestField * |
15817 | 106 get_pref_field(Prefs *prefs) |
107 { | |
15822 | 108 PurpleRequestField *field = NULL; |
15817 | 109 |
110 if (prefs->lv == NULL) | |
111 { | |
112 switch (prefs->type) | |
113 { | |
15822 | 114 case PURPLE_PREF_BOOLEAN: |
115 field = purple_request_field_bool_new(prefs->pref, _(prefs->label), | |
116 purple_prefs_get_bool(prefs->pref)); | |
15817 | 117 break; |
15822 | 118 case PURPLE_PREF_INT: |
119 field = purple_request_field_int_new(prefs->pref, _(prefs->label), | |
120 purple_prefs_get_int(prefs->pref)); | |
15817 | 121 break; |
15822 | 122 case PURPLE_PREF_STRING: |
123 field = purple_request_field_string_new(prefs->pref, _(prefs->label), | |
124 purple_prefs_get_string(prefs->pref), FALSE); | |
15817 | 125 break; |
126 default: | |
127 break; | |
128 } | |
129 } | |
130 else | |
131 { | |
132 GList *list = prefs->lv(), *iter; | |
133 if (list) | |
15822 | 134 field = purple_request_field_list_new(prefs->pref, _(prefs->label)); |
15817 | 135 for (iter = list; iter; iter = iter->next) |
136 { | |
137 gboolean select = FALSE; | |
138 const char *data = iter->data; | |
139 int idata; | |
140 iter = iter->next; | |
141 switch (prefs->type) | |
142 { | |
15822 | 143 case PURPLE_PREF_BOOLEAN: |
15817 | 144 sscanf(iter->data, "%d", &idata); |
15822 | 145 if (purple_prefs_get_bool(prefs->pref) == idata) |
15817 | 146 select = TRUE; |
147 break; | |
15822 | 148 case PURPLE_PREF_INT: |
15817 | 149 sscanf(iter->data, "%d", &idata); |
15822 | 150 if (purple_prefs_get_int(prefs->pref) == idata) |
15817 | 151 select = TRUE; |
152 break; | |
15822 | 153 case PURPLE_PREF_STRING: |
154 if (strcmp(purple_prefs_get_string(prefs->pref), iter->data) == 0) | |
15817 | 155 select = TRUE; |
156 break; | |
157 default: | |
158 break; | |
159 } | |
15822 | 160 purple_request_field_list_add(field, data, iter->data); |
15817 | 161 if (select) |
15822 | 162 purple_request_field_list_add_selected(field, data); |
15817 | 163 } |
164 g_list_free(list); | |
165 } | |
166 return field; | |
167 } | |
168 | |
169 static Prefs blist[] = | |
170 { | |
16424
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
|
171 {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
|
172 {PURPLE_PREF_BOOLEAN, "/finch/blist/showoffline", N_("Show Offline Buddies"), NULL}, |
15822 | 173 {PURPLE_PREF_NONE, NULL, NULL, NULL} |
15817 | 174 }; |
175 | |
176 static Prefs convs[] = | |
177 { | |
16424
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
|
178 {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
|
179 {PURPLE_PREF_BOOLEAN, "/finch/conversations/notify_typing", N_("Notify buddies when you are typing"), NULL}, |
15822 | 180 {PURPLE_PREF_NONE, NULL, NULL, NULL} |
15817 | 181 }; |
182 | |
183 static Prefs logging[] = | |
184 { | |
16424
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
|
185 {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
|
186 {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
|
187 {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
|
188 {PURPLE_PREF_BOOLEAN, "/purple/logging/log_system", N_("Log status change events"), NULL}, |
15822 | 189 {PURPLE_PREF_NONE, NULL, NULL, NULL}, |
15817 | 190 }; |
191 | |
192 /* XXX: Translate after the freeze */ | |
193 static Prefs idle[] = | |
194 { | |
16424
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
|
195 {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
|
196 {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
|
197 {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
|
198 {PURPLE_PREF_INT, "/purple/savedstatus/idleaway", "Change status to", get_status_titles}, |
15822 | 199 {PURPLE_PREF_NONE, NULL, NULL, NULL}, |
15817 | 200 }; |
201 | |
202 static void | |
203 free_strings() | |
204 { | |
205 g_list_foreach(freestrings, (GFunc)g_free, NULL); | |
206 g_list_free(freestrings); | |
207 freestrings = NULL; | |
208 } | |
209 | |
210 static void | |
15822 | 211 save_cb(void *data, PurpleRequestFields *allfields) |
15817 | 212 { |
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
|
213 finch_request_save_in_prefs(data, allfields); |
15817 | 214 free_strings(); |
215 } | |
216 | |
217 static void | |
15822 | 218 add_pref_group(PurpleRequestFields *fields, const char *title, Prefs *prefs) |
15817 | 219 { |
15822 | 220 PurpleRequestField *field; |
221 PurpleRequestFieldGroup *group; | |
15817 | 222 int i; |
223 | |
15822 | 224 group = purple_request_field_group_new(title); |
225 purple_request_fields_add_group(fields, group); | |
15817 | 226 for (i = 0; prefs[i].pref; i++) |
227 { | |
228 field = get_pref_field(prefs + i); | |
229 if (field) | |
15822 | 230 purple_request_field_group_add_field(group, field); |
15817 | 231 } |
232 } | |
233 | |
234 void finch_prefs_show_all() | |
235 { | |
15822 | 236 PurpleRequestFields *fields; |
15817 | 237 |
15822 | 238 fields = purple_request_fields_new(); |
15817 | 239 |
240 add_pref_group(fields, _("Buddy List"), blist); | |
241 add_pref_group(fields, _("Conversations"), convs); | |
242 add_pref_group(fields, _("Logging"), logging); | |
243 add_pref_group(fields, _("Idle"), idle); | |
244 | |
15822 | 245 purple_request_fields(NULL, _("Preferences"), NULL, NULL, fields, |
16439
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:
16424
diff
changeset
|
246 _("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:
16424
diff
changeset
|
247 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:
16424
diff
changeset
|
248 NULL); |
15817 | 249 } |
250 |