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