Mercurial > pidgin
annotate finch/gntrequest.c @ 18383:9eb2f4d27990
Use the completion-signal to append a ': ' after a tab-completed nick.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 30 Jun 2007 06:45:59 +0000 |
parents | a90f9a0b90c8 |
children | 719f73b9a593 576edd9c4f72 |
rev | line source |
---|---|
15817 | 1 /** |
2 * @file gntrequest.c GNT Request API | |
16194
0f0832c13fcb
Rename the Doxygen group from gntui to finch and define the finch group
Richard Laager <rlaager@wiktel.com>
parents:
16164
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:
15843
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:
15843
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 <gnt.h> | |
26 #include <gntbox.h> | |
27 #include <gntbutton.h> | |
28 #include <gntcheckbox.h> | |
29 #include <gntcombobox.h> | |
30 #include <gntentry.h> | |
15927
846a00760176
use file select dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
31 #include <gntfilesel.h> |
15817 | 32 #include <gntlabel.h> |
33 #include <gntline.h> | |
34 #include <gnttree.h> | |
35 | |
15822 | 36 #include "finch.h" |
15817 | 37 #include "gntrequest.h" |
16164
87019c619be0
Include header files, not source files. Bah.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15936
diff
changeset
|
38 #include "util.h" |
15817 | 39 |
40 typedef struct | |
41 { | |
42 void *user_data; | |
15927
846a00760176
use file select dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
43 GntWidget *dialog; |
15817 | 44 GCallback *cbs; |
15822 | 45 } PurpleGntFileRequest; |
15817 | 46 |
47 static GntWidget * | |
48 setup_request_window(const char *title, const char *primary, | |
15822 | 49 const char *secondary, PurpleRequestType type) |
15817 | 50 { |
51 GntWidget *window; | |
52 | |
53 window = gnt_vbox_new(FALSE); | |
54 gnt_box_set_toplevel(GNT_BOX(window), TRUE); | |
55 gnt_box_set_title(GNT_BOX(window), title); | |
56 gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID); | |
57 | |
58 if (primary) | |
59 gnt_box_add_widget(GNT_BOX(window), | |
60 gnt_label_new_with_format(primary, GNT_TEXT_FLAG_BOLD)); | |
61 if (secondary) | |
62 gnt_box_add_widget(GNT_BOX(window), gnt_label_new(secondary)); | |
63 | |
15822 | 64 g_signal_connect_swapped(G_OBJECT(window), "destroy", G_CALLBACK(purple_request_close), |
15817 | 65 GINT_TO_POINTER(type)); |
66 | |
67 return window; | |
68 } | |
69 | |
18333
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
70 /** |
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
71 * If the window is closed by the wm (ie, without triggering any of |
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
72 * the buttons, then do some default callback. |
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
73 */ |
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
74 static void |
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
75 setup_default_callback(GntWidget *window, gpointer default_cb, gpointer data) |
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
76 { |
18347
a90f9a0b90c8
Update search-api to not crash. Searching for users in xmpp/oscar works now.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18333
diff
changeset
|
77 g_object_set_data(G_OBJECT(window), "default-callback", default_cb); |
18333
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
78 g_signal_connect_swapped(G_OBJECT(window), "destroy", G_CALLBACK(default_cb), data); |
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
79 } |
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
80 |
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
81 static void |
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
82 action_performed(GntWidget *button, gpointer data) |
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
83 { |
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
84 g_signal_handlers_disconnect_matched(data, G_SIGNAL_MATCH_FUNC, |
18347
a90f9a0b90c8
Update search-api to not crash. Searching for users in xmpp/oscar works now.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18333
diff
changeset
|
85 0, 0, NULL, |
a90f9a0b90c8
Update search-api to not crash. Searching for users in xmpp/oscar works now.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18333
diff
changeset
|
86 g_object_get_data(data, "default-callback"), |
a90f9a0b90c8
Update search-api to not crash. Searching for users in xmpp/oscar works now.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18333
diff
changeset
|
87 NULL); |
18333
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
88 } |
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
89 |
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
90 /** |
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
91 * window: this is the window |
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
92 * userdata: the userdata to pass to the primary callbacks |
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
93 * cb: the callback |
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
94 * data: data for the callback |
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
95 * (text, primary-callback) pairs, ended by a NULL |
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
96 */ |
15817 | 97 static GntWidget * |
18333
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
98 setup_button_box(GntWidget *win, gpointer userdata, gpointer cb, gpointer data, ...) |
15817 | 99 { |
100 GntWidget *box, *button; | |
101 va_list list; | |
102 const char *text; | |
103 gpointer callback; | |
104 | |
105 box = gnt_hbox_new(FALSE); | |
106 | |
107 va_start(list, data); | |
108 | |
109 while ((text = va_arg(list, const char *))) | |
110 { | |
111 callback = va_arg(list, gpointer); | |
112 button = gnt_button_new(text); | |
113 gnt_box_add_widget(GNT_BOX(box), button); | |
114 g_object_set_data(G_OBJECT(button), "activate-callback", callback); | |
115 g_object_set_data(G_OBJECT(button), "activate-userdata", userdata); | |
18347
a90f9a0b90c8
Update search-api to not crash. Searching for users in xmpp/oscar works now.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18333
diff
changeset
|
116 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(action_performed), win); |
15817 | 117 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(cb), data); |
118 } | |
119 | |
120 va_end(list); | |
121 return box; | |
122 } | |
123 | |
124 static void | |
125 notify_input_cb(GntWidget *button, GntWidget *entry) | |
126 { | |
15822 | 127 PurpleRequestInputCb callback = g_object_get_data(G_OBJECT(button), "activate-callback"); |
15817 | 128 gpointer data = g_object_get_data(G_OBJECT(button), "activate-userdata"); |
129 const char *text = gnt_entry_get_text(GNT_ENTRY(entry)); | |
130 | |
131 if (callback) | |
132 callback(data, text); | |
133 | |
134 while (button->parent) | |
135 button = button->parent; | |
136 | |
15822 | 137 purple_request_close(PURPLE_REQUEST_INPUT, button); |
15817 | 138 } |
139 | |
140 static void * | |
141 finch_request_input(const char *title, const char *primary, | |
142 const char *secondary, const char *default_value, | |
143 gboolean multiline, gboolean masked, gchar *hint, | |
144 const char *ok_text, GCallback ok_cb, | |
145 const char *cancel_text, GCallback cancel_cb, | |
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:
16310
diff
changeset
|
146 PurpleAccount *account, const char *who, PurpleConversation *conv, |
15817 | 147 void *user_data) |
148 { | |
149 GntWidget *window, *box, *entry; | |
150 | |
15822 | 151 window = setup_request_window(title, primary, secondary, PURPLE_REQUEST_INPUT); |
15817 | 152 |
153 entry = gnt_entry_new(default_value); | |
154 if (masked) | |
155 gnt_entry_set_masked(GNT_ENTRY(entry), TRUE); | |
156 gnt_box_add_widget(GNT_BOX(window), entry); | |
157 | |
18333
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
158 box = setup_button_box(window, user_data, notify_input_cb, entry, |
15817 | 159 ok_text, ok_cb, cancel_text, cancel_cb, NULL); |
160 gnt_box_add_widget(GNT_BOX(window), box); | |
161 | |
18333
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
162 setup_default_callback(window, cancel_cb, user_data); |
15817 | 163 gnt_widget_show(window); |
164 | |
165 return window; | |
166 } | |
167 | |
168 static void | |
15822 | 169 finch_close_request(PurpleRequestType type, gpointer ui_handle) |
15817 | 170 { |
171 GntWidget *widget = GNT_WIDGET(ui_handle); | |
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
|
172 if (type == PURPLE_REQUEST_FIELDS) { |
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
|
173 PurpleRequestFields *fields = g_object_get_data(G_OBJECT(widget), "fields"); |
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
|
174 purple_request_fields_destroy(fields); |
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
|
175 } |
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
|
176 |
15817 | 177 while (widget->parent) |
178 widget = widget->parent; | |
179 gnt_widget_destroy(widget); | |
180 } | |
181 | |
182 static void | |
183 request_choice_cb(GntWidget *button, GntComboBox *combo) | |
184 { | |
15822 | 185 PurpleRequestChoiceCb callback = g_object_get_data(G_OBJECT(button), "activate-callback"); |
15817 | 186 gpointer data = g_object_get_data(G_OBJECT(button), "activate-userdata"); |
187 int choice = GPOINTER_TO_INT(gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo))) - 1; | |
188 | |
189 if (callback) | |
190 callback(data, choice); | |
191 | |
192 while (button->parent) | |
193 button = button->parent; | |
194 | |
15822 | 195 purple_request_close(PURPLE_REQUEST_INPUT, button); |
15817 | 196 } |
197 | |
198 static void * | |
199 finch_request_choice(const char *title, const char *primary, | |
200 const char *secondary, unsigned int default_value, | |
201 const char *ok_text, GCallback ok_cb, | |
202 const char *cancel_text, GCallback cancel_cb, | |
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:
16310
diff
changeset
|
203 PurpleAccount *account, const char *who, PurpleConversation *conv, |
15817 | 204 void *user_data, va_list choices) |
205 { | |
206 GntWidget *window, *combo, *box; | |
207 const char *text; | |
208 int val; | |
209 | |
15822 | 210 window = setup_request_window(title, primary, secondary, PURPLE_REQUEST_CHOICE); |
15817 | 211 |
212 combo = gnt_combo_box_new(); | |
213 gnt_box_add_widget(GNT_BOX(window), combo); | |
214 while ((text = va_arg(choices, const char *))) | |
215 { | |
216 val = va_arg(choices, int); | |
217 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), GINT_TO_POINTER(val + 1), text); | |
218 } | |
219 gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), GINT_TO_POINTER(default_value + 1)); | |
220 | |
18333
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
221 box = setup_button_box(window, user_data, request_choice_cb, combo, |
15817 | 222 ok_text, ok_cb, cancel_text, cancel_cb, NULL); |
223 gnt_box_add_widget(GNT_BOX(window), box); | |
224 | |
18333
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
225 setup_default_callback(window, cancel_cb, user_data); |
15817 | 226 gnt_widget_show(window); |
227 | |
228 return window; | |
229 } | |
230 | |
231 static void | |
232 request_action_cb(GntWidget *button, GntWidget *window) | |
233 { | |
15822 | 234 PurpleRequestActionCb callback = g_object_get_data(G_OBJECT(button), "activate-callback"); |
15817 | 235 gpointer data = g_object_get_data(G_OBJECT(button), "activate-userdata"); |
236 int id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(button), "activate-id")); | |
237 | |
238 if (callback) | |
239 callback(data, id); | |
240 | |
15822 | 241 purple_request_close(PURPLE_REQUEST_ACTION, window); |
15817 | 242 } |
243 | |
244 static void* | |
245 finch_request_action(const char *title, const char *primary, | |
246 const char *secondary, unsigned int default_value, | |
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:
16310
diff
changeset
|
247 PurpleAccount *account, const char *who, PurpleConversation *conv, |
15817 | 248 void *user_data, size_t actioncount, |
249 va_list actions) | |
250 { | |
251 GntWidget *window, *box, *button; | |
252 int i; | |
253 | |
15822 | 254 window = setup_request_window(title, primary, secondary, PURPLE_REQUEST_ACTION); |
15817 | 255 |
256 box = gnt_hbox_new(FALSE); | |
257 gnt_box_add_widget(GNT_BOX(window), box); | |
258 for (i = 0; i < actioncount; i++) | |
259 { | |
260 const char *text = va_arg(actions, const char *); | |
15822 | 261 PurpleRequestActionCb callback = va_arg(actions, PurpleRequestActionCb); |
15817 | 262 |
263 button = gnt_button_new(text); | |
264 gnt_box_add_widget(GNT_BOX(box), button); | |
265 | |
266 g_object_set_data(G_OBJECT(button), "activate-callback", callback); | |
267 g_object_set_data(G_OBJECT(button), "activate-userdata", user_data); | |
268 g_object_set_data(G_OBJECT(button), "activate-id", GINT_TO_POINTER(i)); | |
269 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(request_action_cb), window); | |
270 } | |
271 | |
272 gnt_widget_show(window); | |
273 | |
274 return window; | |
275 } | |
276 | |
277 static void | |
15822 | 278 request_fields_cb(GntWidget *button, PurpleRequestFields *fields) |
15817 | 279 { |
15822 | 280 PurpleRequestFieldsCb callback = g_object_get_data(G_OBJECT(button), "activate-callback"); |
15817 | 281 gpointer data = g_object_get_data(G_OBJECT(button), "activate-userdata"); |
282 GList *list; | |
283 | |
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
|
284 /* Update the data of the fields. Pidgin does this differently. Instead of |
15817 | 285 * updating the fields at the end like here, it updates the appropriate field |
286 * instantly whenever a change is made. That allows it to make sure the | |
287 * 'required' fields are entered before the user can hit OK. It's not the case | |
288 * here, althought it can be done. I am not honouring the 'required' fields | |
289 * for the moment. */ | |
15822 | 290 for (list = purple_request_fields_get_groups(fields); list; list = list->next) |
15817 | 291 { |
15822 | 292 PurpleRequestFieldGroup *group = list->data; |
293 GList *fields = purple_request_field_group_get_fields(group); | |
15817 | 294 |
295 for (; fields ; fields = fields->next) | |
296 { | |
15822 | 297 PurpleRequestField *field = fields->data; |
298 PurpleRequestFieldType type = purple_request_field_get_type(field); | |
299 if (type == PURPLE_REQUEST_FIELD_BOOLEAN) | |
15817 | 300 { |
301 GntWidget *check = field->ui_data; | |
302 gboolean value = gnt_check_box_get_checked(GNT_CHECK_BOX(check)); | |
15822 | 303 purple_request_field_bool_set_value(field, value); |
15817 | 304 } |
15822 | 305 else if (type == PURPLE_REQUEST_FIELD_STRING) |
15817 | 306 { |
307 GntWidget *entry = field->ui_data; | |
308 const char *text = gnt_entry_get_text(GNT_ENTRY(entry)); | |
15822 | 309 purple_request_field_string_set_value(field, (text && *text) ? text : NULL); |
15817 | 310 } |
15822 | 311 else if (type == PURPLE_REQUEST_FIELD_INTEGER) |
15817 | 312 { |
313 GntWidget *entry = field->ui_data; | |
314 const char *text = gnt_entry_get_text(GNT_ENTRY(entry)); | |
315 int value = (text && *text) ? atoi(text) : 0; | |
15822 | 316 purple_request_field_int_set_value(field, value); |
15817 | 317 } |
15822 | 318 else if (type == PURPLE_REQUEST_FIELD_CHOICE) |
15817 | 319 { |
320 GntWidget *combo = field->ui_data; | |
321 int id; | |
322 id = GPOINTER_TO_INT(gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo))); | |
15822 | 323 purple_request_field_choice_set_value(field, id); |
15817 | 324 } |
15822 | 325 else if (type == PURPLE_REQUEST_FIELD_LIST) |
15817 | 326 { |
327 GList *list = NULL; | |
15822 | 328 if (purple_request_field_list_get_multi_select(field)) |
15817 | 329 { |
18118
ab6d2763b8d8
Re-fix the DBus list handling code by killing const GList* / const GSList*
Richard Laager <rlaager@wiktel.com>
parents:
18063
diff
changeset
|
330 GList *iter; |
15817 | 331 GntWidget *tree = field->ui_data; |
332 | |
15822 | 333 iter = purple_request_field_list_get_items(field); |
15817 | 334 for (; iter; iter = iter->next) |
335 { | |
336 const char *text = iter->data; | |
15822 | 337 gpointer key = purple_request_field_list_get_data(field, text); |
15817 | 338 if (gnt_tree_get_choice(GNT_TREE(tree), key)) |
339 list = g_list_prepend(list, key); | |
340 } | |
341 } | |
342 else | |
343 { | |
344 GntWidget *combo = field->ui_data; | |
345 gpointer data = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo)); | |
346 list = g_list_append(list, data); | |
347 } | |
348 | |
15822 | 349 purple_request_field_list_set_selected(field, list); |
15817 | 350 g_list_free(list); |
351 } | |
15822 | 352 else if (type == PURPLE_REQUEST_FIELD_ACCOUNT) |
15817 | 353 { |
354 GntWidget *combo = field->ui_data; | |
15822 | 355 PurpleAccount *acc = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo)); |
356 purple_request_field_account_set_value(field, acc); | |
15817 | 357 } |
358 } | |
359 } | |
360 | |
361 if (callback) | |
362 callback(data, fields); | |
363 | |
364 while (button->parent) | |
365 button = button->parent; | |
366 | |
15822 | 367 purple_request_close(PURPLE_REQUEST_FIELDS, button); |
15817 | 368 } |
369 | |
370 static void * | |
371 finch_request_fields(const char *title, const char *primary, | |
15822 | 372 const char *secondary, PurpleRequestFields *allfields, |
15817 | 373 const char *ok, GCallback ok_cb, |
374 const char *cancel, GCallback cancel_cb, | |
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:
16310
diff
changeset
|
375 PurpleAccount *account, const char *who, PurpleConversation *conv, |
15817 | 376 void *userdata) |
377 { | |
378 GntWidget *window, *box; | |
379 GList *grlist; | |
380 | |
15822 | 381 window = setup_request_window(title, primary, secondary, PURPLE_REQUEST_FIELDS); |
15817 | 382 |
383 /* This is how it's going to work: the request-groups are going to be | |
384 * stacked vertically one after the other. A GntLine will be separating | |
385 * the groups. */ | |
386 box = gnt_vbox_new(FALSE); | |
387 gnt_box_set_pad(GNT_BOX(box), 0); | |
388 gnt_box_set_fill(GNT_BOX(box), TRUE); | |
15822 | 389 for (grlist = purple_request_fields_get_groups(allfields); grlist; grlist = grlist->next) |
15817 | 390 { |
15822 | 391 PurpleRequestFieldGroup *group = grlist->data; |
392 GList *fields = purple_request_field_group_get_fields(group); | |
15817 | 393 GntWidget *hbox; |
15822 | 394 const char *title = purple_request_field_group_get_title(group); |
15817 | 395 |
396 if (title) | |
397 gnt_box_add_widget(GNT_BOX(box), | |
398 gnt_label_new_with_format(title, GNT_TEXT_FLAG_BOLD)); | |
399 | |
400 for (; fields ; fields = fields->next) | |
401 { | |
402 /* XXX: Break each of the fields into a separate function? */ | |
15822 | 403 PurpleRequestField *field = fields->data; |
404 PurpleRequestFieldType type = purple_request_field_get_type(field); | |
405 const char *label = purple_request_field_get_label(field); | |
15817 | 406 |
407 hbox = gnt_hbox_new(TRUE); /* hrm */ | |
408 gnt_box_add_widget(GNT_BOX(box), hbox); | |
409 | |
15822 | 410 if (type != PURPLE_REQUEST_FIELD_BOOLEAN && label) |
15817 | 411 { |
412 GntWidget *l = gnt_label_new(label); | |
413 gnt_widget_set_size(l, 0, 1); | |
414 gnt_box_add_widget(GNT_BOX(hbox), l); | |
415 } | |
416 | |
15822 | 417 if (type == PURPLE_REQUEST_FIELD_BOOLEAN) |
15817 | 418 { |
419 GntWidget *check = gnt_check_box_new(label); | |
420 gnt_check_box_set_checked(GNT_CHECK_BOX(check), | |
15822 | 421 purple_request_field_bool_get_default_value(field)); |
15817 | 422 gnt_box_add_widget(GNT_BOX(hbox), check); |
423 field->ui_data = check; | |
424 } | |
15822 | 425 else if (type == PURPLE_REQUEST_FIELD_STRING) |
15817 | 426 { |
15829 | 427 const char *hint = purple_request_field_get_type_hint(field); |
15817 | 428 GntWidget *entry = gnt_entry_new( |
15822 | 429 purple_request_field_string_get_default_value(field)); |
15817 | 430 gnt_entry_set_masked(GNT_ENTRY(entry), |
15822 | 431 purple_request_field_string_is_masked(field)); |
18222
ef65d43190e5
Fix a few runtime warnings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18118
diff
changeset
|
432 if (hint && purple_str_has_prefix(hint, "screenname")) { |
15829 | 433 PurpleBlistNode *node = purple_blist_get_root(); |
434 gboolean offline = purple_str_has_suffix(hint, "all"); | |
435 for (; node; node = purple_blist_node_next(node, offline)) { | |
436 if (!PURPLE_BLIST_NODE_IS_BUDDY(node)) | |
15826
f59cfcce68a8
Add auto-complete support in request-entries that have 'screenname' hint set. This can be useful in, for example, 'send im' dialog etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
437 continue; |
15829 | 438 gnt_entry_add_suggest(GNT_ENTRY(entry), purple_buddy_get_name((PurpleBuddy*)node)); |
15826
f59cfcce68a8
Add auto-complete support in request-entries that have 'screenname' hint set. This can be useful in, for example, 'send im' dialog etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
439 } |
f59cfcce68a8
Add auto-complete support in request-entries that have 'screenname' hint set. This can be useful in, for example, 'send im' dialog etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
440 gnt_entry_set_always_suggest(GNT_ENTRY(entry), TRUE); |
15843
e74c2488448b
Group autocomplete for buddy adding
Richard Nelson <wabz@pidgin.im>
parents:
15829
diff
changeset
|
441 } else if (hint && !strcmp(hint, "group")) { |
e74c2488448b
Group autocomplete for buddy adding
Richard Nelson <wabz@pidgin.im>
parents:
15829
diff
changeset
|
442 PurpleBlistNode *node; |
e74c2488448b
Group autocomplete for buddy adding
Richard Nelson <wabz@pidgin.im>
parents:
15829
diff
changeset
|
443 for (node = purple_blist_get_root(); node; node = node->next) { |
e74c2488448b
Group autocomplete for buddy adding
Richard Nelson <wabz@pidgin.im>
parents:
15829
diff
changeset
|
444 if (PURPLE_BLIST_NODE_IS_GROUP(node)) |
e74c2488448b
Group autocomplete for buddy adding
Richard Nelson <wabz@pidgin.im>
parents:
15829
diff
changeset
|
445 gnt_entry_add_suggest(GNT_ENTRY(entry), ((PurpleGroup *)node)->name); |
e74c2488448b
Group autocomplete for buddy adding
Richard Nelson <wabz@pidgin.im>
parents:
15829
diff
changeset
|
446 } |
15826
f59cfcce68a8
Add auto-complete support in request-entries that have 'screenname' hint set. This can be useful in, for example, 'send im' dialog etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
447 } |
15817 | 448 gnt_box_add_widget(GNT_BOX(hbox), entry); |
449 field->ui_data = entry; | |
450 } | |
15822 | 451 else if (type == PURPLE_REQUEST_FIELD_INTEGER) |
15817 | 452 { |
453 char str[256]; | |
15822 | 454 int val = purple_request_field_int_get_default_value(field); |
15817 | 455 GntWidget *entry; |
456 | |
457 snprintf(str, sizeof(str), "%d", val); | |
458 entry = gnt_entry_new(str); | |
459 gnt_entry_set_flag(GNT_ENTRY(entry), GNT_ENTRY_FLAG_INT); | |
460 gnt_box_add_widget(GNT_BOX(hbox), entry); | |
461 field->ui_data = entry; | |
462 } | |
15822 | 463 else if (type == PURPLE_REQUEST_FIELD_CHOICE) |
15817 | 464 { |
465 int id; | |
18118
ab6d2763b8d8
Re-fix the DBus list handling code by killing const GList* / const GSList*
Richard Laager <rlaager@wiktel.com>
parents:
18063
diff
changeset
|
466 GList *list; |
15817 | 467 GntWidget *combo = gnt_combo_box_new(); |
468 gnt_box_add_widget(GNT_BOX(hbox), combo); | |
469 field->ui_data = combo; | |
470 | |
15822 | 471 list = purple_request_field_choice_get_labels(field); |
15817 | 472 for (id = 1; list; list = list->next, id++) |
473 { | |
474 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), | |
475 GINT_TO_POINTER(id), list->data); | |
476 } | |
477 gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), | |
15822 | 478 GINT_TO_POINTER(purple_request_field_choice_get_default_value(field))); |
15817 | 479 } |
15822 | 480 else if (type == PURPLE_REQUEST_FIELD_LIST) |
15817 | 481 { |
18118
ab6d2763b8d8
Re-fix the DBus list handling code by killing const GList* / const GSList*
Richard Laager <rlaager@wiktel.com>
parents:
18063
diff
changeset
|
482 GList *list; |
15822 | 483 gboolean multi = purple_request_field_list_get_multi_select(field); |
15817 | 484 if (multi) |
485 { | |
486 GntWidget *tree = gnt_tree_new(); | |
487 gnt_box_add_widget(GNT_BOX(hbox), tree); | |
488 field->ui_data = tree; | |
489 | |
15822 | 490 list = purple_request_field_list_get_items(field); |
15817 | 491 for (; list; list = list->next) |
492 { | |
493 const char *text = list->data; | |
15822 | 494 gpointer key = purple_request_field_list_get_data(field, text); |
15817 | 495 gnt_tree_add_choice(GNT_TREE(tree), key, |
496 gnt_tree_create_row(GNT_TREE(tree), text), NULL, NULL); | |
15822 | 497 if (purple_request_field_list_is_selected(field, text)) |
15817 | 498 gnt_tree_set_choice(GNT_TREE(tree), key, TRUE); |
499 } | |
500 } | |
501 else | |
502 { | |
503 GntWidget *combo = gnt_combo_box_new(); | |
504 gnt_box_set_alignment(GNT_BOX(hbox), GNT_ALIGN_MID); | |
505 gnt_box_add_widget(GNT_BOX(hbox), combo); | |
506 field->ui_data = combo; | |
507 | |
15822 | 508 list = purple_request_field_list_get_items(field); |
15817 | 509 for (; list; list = list->next) |
510 { | |
511 const char *text = list->data; | |
15822 | 512 gpointer key = purple_request_field_list_get_data(field, text); |
15817 | 513 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), key, text); |
15822 | 514 if (purple_request_field_list_is_selected(field, text)) |
15817 | 515 gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), key); |
516 } | |
517 } | |
518 } | |
15822 | 519 else if (type == PURPLE_REQUEST_FIELD_ACCOUNT) |
15817 | 520 { |
521 gboolean all; | |
15822 | 522 PurpleAccount *def; |
18063
926ccb104da0
disapproval of revision '1411afd7660760db59966c3a9f18e2adab8eb27e'
Richard Laager <rlaager@wiktel.com>
parents:
18058
diff
changeset
|
523 GList *list; |
15817 | 524 GntWidget *combo = gnt_combo_box_new(); |
525 gnt_box_set_alignment(GNT_BOX(hbox), GNT_ALIGN_MID); | |
526 gnt_box_add_widget(GNT_BOX(hbox), combo); | |
527 field->ui_data = combo; | |
528 | |
15822 | 529 all = purple_request_field_account_get_show_all(field); |
16927
43abb4942a6d
Select the right account when adding a buddy after authorizing her.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16439
diff
changeset
|
530 def = purple_request_field_account_get_value(field); |
43abb4942a6d
Select the right account when adding a buddy after authorizing her.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16439
diff
changeset
|
531 if (!def) |
43abb4942a6d
Select the right account when adding a buddy after authorizing her.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16439
diff
changeset
|
532 def = purple_request_field_account_get_default_value(field); |
15817 | 533 |
534 if (all) | |
15822 | 535 list = purple_accounts_get_all(); |
15817 | 536 else |
15822 | 537 list = purple_connections_get_all(); |
15817 | 538 |
539 for (; list; list = list->next) | |
540 { | |
15822 | 541 PurpleAccount *account; |
15817 | 542 char *text; |
543 | |
544 if (all) | |
545 account = list->data; | |
546 else | |
15822 | 547 account = purple_connection_get_account(list->data); |
15817 | 548 |
549 text = g_strdup_printf("%s (%s)", | |
15822 | 550 purple_account_get_username(account), |
551 purple_account_get_protocol_name(account)); | |
15817 | 552 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), account, text); |
553 g_free(text); | |
554 if (account == def) | |
555 gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), account); | |
556 } | |
557 gnt_widget_set_size(combo, 20, 3); /* ew */ | |
558 } | |
559 else | |
560 { | |
561 gnt_box_add_widget(GNT_BOX(hbox), | |
562 gnt_label_new_with_format(_("Not implemented yet."), | |
563 GNT_TEXT_FLAG_BOLD)); | |
564 } | |
565 } | |
566 if (grlist->next) | |
567 gnt_box_add_widget(GNT_BOX(box), gnt_hline_new()); | |
568 } | |
569 gnt_box_add_widget(GNT_BOX(window), box); | |
570 | |
18333
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
571 box = setup_button_box(window, userdata, request_fields_cb, allfields, |
15817 | 572 ok, ok_cb, cancel, cancel_cb, NULL); |
573 gnt_box_add_widget(GNT_BOX(window), box); | |
574 | |
18333
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
575 setup_default_callback(window, cancel_cb, userdata); |
15817 | 576 gnt_widget_show(window); |
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
|
577 |
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
|
578 g_object_set_data(G_OBJECT(window), "fields", allfields); |
15817 | 579 |
580 return window; | |
581 } | |
582 | |
583 static void | |
584 file_cancel_cb(GntWidget *wid, gpointer fq) | |
585 { | |
15822 | 586 PurpleGntFileRequest *data = fq; |
15817 | 587 if (data->cbs[1] != NULL) |
15822 | 588 ((PurpleRequestFileCb)data->cbs[1])(data->user_data, NULL); |
15817 | 589 |
15822 | 590 purple_request_close(PURPLE_REQUEST_FILE, data->dialog); |
15817 | 591 } |
592 | |
593 static void | |
594 file_ok_cb(GntWidget *wid, gpointer fq) | |
595 { | |
15822 | 596 PurpleGntFileRequest *data = fq; |
15927
846a00760176
use file select dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
597 char *file = gnt_file_sel_get_selected_file(GNT_FILE_SEL(data->dialog)); |
15817 | 598 if (data->cbs[0] != NULL) |
15927
846a00760176
use file select dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
599 ((PurpleRequestFileCb)data->cbs[0])(data->user_data, file); |
846a00760176
use file select dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
600 g_free(file); |
15817 | 601 |
15822 | 602 purple_request_close(PURPLE_REQUEST_FILE, data->dialog); |
15817 | 603 } |
604 | |
605 static void | |
15822 | 606 file_request_destroy(PurpleGntFileRequest *data) |
15817 | 607 { |
608 g_free(data->cbs); | |
609 g_free(data); | |
610 } | |
611 | |
612 static void * | |
613 finch_request_file(const char *title, const char *filename, | |
614 gboolean savedialog, | |
615 GCallback ok_cb, GCallback cancel_cb, | |
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:
16310
diff
changeset
|
616 PurpleAccount *account, const char *who, PurpleConversation *conv, |
15817 | 617 void *user_data) |
618 { | |
15927
846a00760176
use file select dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
619 GntWidget *window = gnt_file_sel_new(); |
846a00760176
use file select dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
620 GntFileSel *sel = GNT_FILE_SEL(window); |
15822 | 621 PurpleGntFileRequest *data = g_new0(PurpleGntFileRequest, 1); |
15817 | 622 |
623 data->user_data = user_data; | |
624 data->cbs = g_new0(GCallback, 2); | |
625 data->cbs[0] = ok_cb; | |
626 data->cbs[1] = cancel_cb; | |
627 data->dialog = window; | |
628 gnt_box_set_title(GNT_BOX(window), title ? title : (savedialog ? _("Save File...") : _("Open File..."))); | |
15927
846a00760176
use file select dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
629 gnt_file_sel_set_current_location(sel, purple_home_dir()); /* XXX: */ |
15936 | 630 if (savedialog) |
631 gnt_file_sel_set_suggested_filename(sel, filename); | |
15927
846a00760176
use file select dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
632 g_signal_connect(G_OBJECT(sel->cancel), "activate", |
846a00760176
use file select dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
633 G_CALLBACK(file_cancel_cb), data); |
846a00760176
use file select dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
634 g_signal_connect(G_OBJECT(sel->select), "activate", |
846a00760176
use file select dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15924
diff
changeset
|
635 G_CALLBACK(file_ok_cb), data); |
15817 | 636 g_signal_connect_swapped(G_OBJECT(window), "destroy", |
637 G_CALLBACK(file_request_destroy), data); | |
638 | |
639 gnt_widget_show(window); | |
640 | |
641 return window; | |
642 } | |
643 | |
15822 | 644 static PurpleRequestUiOps uiops = |
15817 | 645 { |
17091
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16927
diff
changeset
|
646 finch_request_input, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16927
diff
changeset
|
647 finch_request_choice, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16927
diff
changeset
|
648 finch_request_action, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16927
diff
changeset
|
649 finch_request_fields, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16927
diff
changeset
|
650 finch_request_file, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16927
diff
changeset
|
651 finch_close_request, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16927
diff
changeset
|
652 NULL, /* No plans for request_folder */ |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16927
diff
changeset
|
653 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16927
diff
changeset
|
654 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16927
diff
changeset
|
655 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16927
diff
changeset
|
656 NULL |
15817 | 657 }; |
658 | |
15822 | 659 PurpleRequestUiOps *finch_request_get_ui_ops() |
15817 | 660 { |
661 return &uiops; | |
662 } | |
663 | |
664 void finch_request_init() | |
665 { | |
666 } | |
667 | |
668 void finch_request_uninit() | |
669 { | |
670 } | |
671 | |
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
|
672 void finch_request_save_in_prefs(gpointer null, PurpleRequestFields *allfields) |
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
|
673 { |
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
|
674 GList *list; |
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
|
675 for (list = purple_request_fields_get_groups(allfields); list; list = list->next) { |
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
|
676 PurpleRequestFieldGroup *group = list->data; |
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
|
677 GList *fields = purple_request_field_group_get_fields(group); |
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
|
678 |
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
|
679 for (; fields ; fields = fields->next) { |
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
|
680 PurpleRequestField *field = fields->data; |
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
|
681 PurpleRequestFieldType type = purple_request_field_get_type(field); |
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
|
682 PurplePrefType pt; |
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
|
683 gpointer val = NULL; |
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
|
684 const char *id = purple_request_field_get_id(field); |
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
|
685 |
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
|
686 switch (type) { |
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
|
687 case PURPLE_REQUEST_FIELD_LIST: |
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
|
688 val = purple_request_field_list_get_selected(field)->data; |
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
|
689 break; |
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
|
690 case PURPLE_REQUEST_FIELD_BOOLEAN: |
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
|
691 val = GINT_TO_POINTER(purple_request_field_bool_get_value(field)); |
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
|
692 break; |
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
|
693 case PURPLE_REQUEST_FIELD_INTEGER: |
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
|
694 val = GINT_TO_POINTER(purple_request_field_int_get_value(field)); |
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
|
695 break; |
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
|
696 case PURPLE_REQUEST_FIELD_STRING: |
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
|
697 val = (gpointer)purple_request_field_string_get_value(field); |
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
|
698 break; |
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
|
699 default: |
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
|
700 break; |
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
|
701 } |
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
|
702 |
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
|
703 pt = purple_prefs_get_type(id); |
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
|
704 switch (pt) { |
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
|
705 case PURPLE_PREF_INT: |
17392
a236c67e39b6
A change from o_sukhodolsky:
Richard Laager <rlaager@wiktel.com>
parents:
17091
diff
changeset
|
706 { |
18222
ef65d43190e5
Fix a few runtime warnings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18118
diff
changeset
|
707 long int tmp = GPOINTER_TO_INT(val); |
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
|
708 if (type == PURPLE_REQUEST_FIELD_LIST) /* Lists always return string */ |
17392
a236c67e39b6
A change from o_sukhodolsky:
Richard Laager <rlaager@wiktel.com>
parents:
17091
diff
changeset
|
709 sscanf(val, "%ld", &tmp); |
a236c67e39b6
A change from o_sukhodolsky:
Richard Laager <rlaager@wiktel.com>
parents:
17091
diff
changeset
|
710 purple_prefs_set_int(id, (gint)tmp); |
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
|
711 break; |
17392
a236c67e39b6
A change from o_sukhodolsky:
Richard Laager <rlaager@wiktel.com>
parents:
17091
diff
changeset
|
712 } |
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
|
713 case PURPLE_PREF_BOOLEAN: |
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
|
714 purple_prefs_set_bool(id, GPOINTER_TO_INT(val)); |
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
|
715 break; |
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
|
716 case PURPLE_PREF_STRING: |
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
|
717 purple_prefs_set_string(id, val); |
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
|
718 break; |
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
|
719 default: |
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
|
720 break; |
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
|
721 } |
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
|
722 } |
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
|
723 } |
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
|
724 } |
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
|
725 |