Mercurial > pidgin.yaz
annotate finch/gntrequest.c @ 25545:315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Wed, 05 Sep 2007 00:47:58 +0000 |
parents | 3849776d0f71 |
children | 60f5abc6cf0c |
rev | line source |
---|---|
15818 | 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 |
15818 | 4 * |
15871
66dff3dfdea6
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents:
15844
diff
changeset
|
5 * finch |
15818 | 6 * |
15871
66dff3dfdea6
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents:
15844
diff
changeset
|
7 * Finch is the legal property of its developers, whose names are too numerous |
15818 | 8 * to list here. Please refer to the COPYRIGHT file distributed with this |
9 * source distribution. | |
10 * | |
11 * This program is free software; you can redistribute it and/or modify | |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 */ | |
25545
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18411
diff
changeset
|
25 |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18411
diff
changeset
|
26 #include "util.h" |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18411
diff
changeset
|
27 |
15818 | 28 #include <gnt.h> |
29 #include <gntbox.h> | |
30 #include <gntbutton.h> | |
31 #include <gntcheckbox.h> | |
32 #include <gntcombobox.h> | |
33 #include <gntentry.h> | |
15930
846a00760176
use file select dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15926
diff
changeset
|
34 #include <gntfilesel.h> |
15818 | 35 #include <gntlabel.h> |
36 #include <gntline.h> | |
37 #include <gnttree.h> | |
38 | |
15823 | 39 #include "finch.h" |
15818 | 40 #include "gntrequest.h" |
41 | |
42 typedef struct | |
43 { | |
44 void *user_data; | |
15930
846a00760176
use file select dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15926
diff
changeset
|
45 GntWidget *dialog; |
15818 | 46 GCallback *cbs; |
18410
719f73b9a593
Remember the open/save file locations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18347
diff
changeset
|
47 gboolean save; |
15823 | 48 } PurpleGntFileRequest; |
15818 | 49 |
50 static GntWidget * | |
51 setup_request_window(const char *title, const char *primary, | |
15823 | 52 const char *secondary, PurpleRequestType type) |
15818 | 53 { |
54 GntWidget *window; | |
55 | |
56 window = gnt_vbox_new(FALSE); | |
57 gnt_box_set_toplevel(GNT_BOX(window), TRUE); | |
58 gnt_box_set_title(GNT_BOX(window), title); | |
59 gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID); | |
60 | |
61 if (primary) | |
62 gnt_box_add_widget(GNT_BOX(window), | |
63 gnt_label_new_with_format(primary, GNT_TEXT_FLAG_BOLD)); | |
64 if (secondary) | |
65 gnt_box_add_widget(GNT_BOX(window), gnt_label_new(secondary)); | |
66 | |
15823 | 67 g_signal_connect_swapped(G_OBJECT(window), "destroy", G_CALLBACK(purple_request_close), |
15818 | 68 GINT_TO_POINTER(type)); |
69 | |
70 return window; | |
71 } | |
72 | |
18333
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 * 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
|
75 * 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
|
76 */ |
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
77 static void |
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
78 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
|
79 { |
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
|
80 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
|
81 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
|
82 } |
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 static void |
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
85 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
|
86 { |
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
87 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
|
88 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
|
89 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
|
90 NULL); |
18333
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
91 } |
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
92 |
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
93 /** |
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
94 * 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
|
95 * 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
|
96 * cb: the callback |
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
97 * 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
|
98 * (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
|
99 */ |
15818 | 100 static GntWidget * |
18333
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
101 setup_button_box(GntWidget *win, gpointer userdata, gpointer cb, gpointer data, ...) |
15818 | 102 { |
103 GntWidget *box, *button; | |
104 va_list list; | |
105 const char *text; | |
106 gpointer callback; | |
107 | |
108 box = gnt_hbox_new(FALSE); | |
109 | |
110 va_start(list, data); | |
111 | |
112 while ((text = va_arg(list, const char *))) | |
113 { | |
114 callback = va_arg(list, gpointer); | |
115 button = gnt_button_new(text); | |
116 gnt_box_add_widget(GNT_BOX(box), button); | |
117 g_object_set_data(G_OBJECT(button), "activate-callback", callback); | |
118 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
|
119 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(action_performed), win); |
15818 | 120 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(cb), data); |
121 } | |
122 | |
123 va_end(list); | |
124 return box; | |
125 } | |
126 | |
127 static void | |
128 notify_input_cb(GntWidget *button, GntWidget *entry) | |
129 { | |
15823 | 130 PurpleRequestInputCb callback = g_object_get_data(G_OBJECT(button), "activate-callback"); |
15818 | 131 gpointer data = g_object_get_data(G_OBJECT(button), "activate-userdata"); |
132 const char *text = gnt_entry_get_text(GNT_ENTRY(entry)); | |
133 | |
134 if (callback) | |
135 callback(data, text); | |
136 | |
137 while (button->parent) | |
138 button = button->parent; | |
139 | |
15823 | 140 purple_request_close(PURPLE_REQUEST_INPUT, button); |
15818 | 141 } |
142 | |
143 static void * | |
144 finch_request_input(const char *title, const char *primary, | |
145 const char *secondary, const char *default_value, | |
146 gboolean multiline, gboolean masked, gchar *hint, | |
147 const char *ok_text, GCallback ok_cb, | |
148 const char *cancel_text, GCallback cancel_cb, | |
16442
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16310
diff
changeset
|
149 PurpleAccount *account, const char *who, PurpleConversation *conv, |
15818 | 150 void *user_data) |
151 { | |
152 GntWidget *window, *box, *entry; | |
153 | |
15823 | 154 window = setup_request_window(title, primary, secondary, PURPLE_REQUEST_INPUT); |
15818 | 155 |
156 entry = gnt_entry_new(default_value); | |
157 if (masked) | |
158 gnt_entry_set_masked(GNT_ENTRY(entry), TRUE); | |
159 gnt_box_add_widget(GNT_BOX(window), entry); | |
160 | |
18333
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
161 box = setup_button_box(window, user_data, notify_input_cb, entry, |
15818 | 162 ok_text, ok_cb, cancel_text, cancel_cb, NULL); |
163 gnt_box_add_widget(GNT_BOX(window), box); | |
164 | |
18333
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
165 setup_default_callback(window, cancel_cb, user_data); |
15818 | 166 gnt_widget_show(window); |
167 | |
168 return window; | |
169 } | |
170 | |
171 static void | |
15823 | 172 finch_close_request(PurpleRequestType type, gpointer ui_handle) |
15818 | 173 { |
174 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
|
175 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
|
176 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
|
177 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
|
178 } |
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
|
179 |
15818 | 180 while (widget->parent) |
181 widget = widget->parent; | |
182 gnt_widget_destroy(widget); | |
183 } | |
184 | |
185 static void | |
186 request_choice_cb(GntWidget *button, GntComboBox *combo) | |
187 { | |
15823 | 188 PurpleRequestChoiceCb callback = g_object_get_data(G_OBJECT(button), "activate-callback"); |
15818 | 189 gpointer data = g_object_get_data(G_OBJECT(button), "activate-userdata"); |
190 int choice = GPOINTER_TO_INT(gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo))) - 1; | |
191 | |
192 if (callback) | |
193 callback(data, choice); | |
194 | |
195 while (button->parent) | |
196 button = button->parent; | |
197 | |
15823 | 198 purple_request_close(PURPLE_REQUEST_INPUT, button); |
15818 | 199 } |
200 | |
201 static void * | |
202 finch_request_choice(const char *title, const char *primary, | |
203 const char *secondary, unsigned int default_value, | |
204 const char *ok_text, GCallback ok_cb, | |
205 const char *cancel_text, GCallback cancel_cb, | |
16442
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16310
diff
changeset
|
206 PurpleAccount *account, const char *who, PurpleConversation *conv, |
15818 | 207 void *user_data, va_list choices) |
208 { | |
209 GntWidget *window, *combo, *box; | |
210 const char *text; | |
211 int val; | |
212 | |
15823 | 213 window = setup_request_window(title, primary, secondary, PURPLE_REQUEST_CHOICE); |
15818 | 214 |
215 combo = gnt_combo_box_new(); | |
216 gnt_box_add_widget(GNT_BOX(window), combo); | |
217 while ((text = va_arg(choices, const char *))) | |
218 { | |
219 val = va_arg(choices, int); | |
220 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), GINT_TO_POINTER(val + 1), text); | |
221 } | |
222 gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), GINT_TO_POINTER(default_value + 1)); | |
223 | |
18333
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
224 box = setup_button_box(window, user_data, request_choice_cb, combo, |
15818 | 225 ok_text, ok_cb, cancel_text, cancel_cb, NULL); |
226 gnt_box_add_widget(GNT_BOX(window), box); | |
227 | |
18333
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
228 setup_default_callback(window, cancel_cb, user_data); |
15818 | 229 gnt_widget_show(window); |
230 | |
231 return window; | |
232 } | |
233 | |
234 static void | |
235 request_action_cb(GntWidget *button, GntWidget *window) | |
236 { | |
15823 | 237 PurpleRequestActionCb callback = g_object_get_data(G_OBJECT(button), "activate-callback"); |
15818 | 238 gpointer data = g_object_get_data(G_OBJECT(button), "activate-userdata"); |
239 int id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(button), "activate-id")); | |
240 | |
241 if (callback) | |
242 callback(data, id); | |
243 | |
15823 | 244 purple_request_close(PURPLE_REQUEST_ACTION, window); |
15818 | 245 } |
246 | |
247 static void* | |
248 finch_request_action(const char *title, const char *primary, | |
249 const char *secondary, unsigned int default_value, | |
16442
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16310
diff
changeset
|
250 PurpleAccount *account, const char *who, PurpleConversation *conv, |
15818 | 251 void *user_data, size_t actioncount, |
252 va_list actions) | |
253 { | |
254 GntWidget *window, *box, *button; | |
255 int i; | |
256 | |
15823 | 257 window = setup_request_window(title, primary, secondary, PURPLE_REQUEST_ACTION); |
15818 | 258 |
259 box = gnt_hbox_new(FALSE); | |
260 gnt_box_add_widget(GNT_BOX(window), box); | |
261 for (i = 0; i < actioncount; i++) | |
262 { | |
263 const char *text = va_arg(actions, const char *); | |
15823 | 264 PurpleRequestActionCb callback = va_arg(actions, PurpleRequestActionCb); |
15818 | 265 |
266 button = gnt_button_new(text); | |
267 gnt_box_add_widget(GNT_BOX(box), button); | |
268 | |
269 g_object_set_data(G_OBJECT(button), "activate-callback", callback); | |
270 g_object_set_data(G_OBJECT(button), "activate-userdata", user_data); | |
271 g_object_set_data(G_OBJECT(button), "activate-id", GINT_TO_POINTER(i)); | |
272 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(request_action_cb), window); | |
273 } | |
274 | |
275 gnt_widget_show(window); | |
276 | |
277 return window; | |
278 } | |
279 | |
280 static void | |
15823 | 281 request_fields_cb(GntWidget *button, PurpleRequestFields *fields) |
15818 | 282 { |
15823 | 283 PurpleRequestFieldsCb callback = g_object_get_data(G_OBJECT(button), "activate-callback"); |
15818 | 284 gpointer data = g_object_get_data(G_OBJECT(button), "activate-userdata"); |
285 GList *list; | |
286 | |
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
|
287 /* Update the data of the fields. Pidgin does this differently. Instead of |
15818 | 288 * updating the fields at the end like here, it updates the appropriate field |
289 * instantly whenever a change is made. That allows it to make sure the | |
290 * 'required' fields are entered before the user can hit OK. It's not the case | |
291 * here, althought it can be done. I am not honouring the 'required' fields | |
292 * for the moment. */ | |
15823 | 293 for (list = purple_request_fields_get_groups(fields); list; list = list->next) |
15818 | 294 { |
15823 | 295 PurpleRequestFieldGroup *group = list->data; |
296 GList *fields = purple_request_field_group_get_fields(group); | |
15818 | 297 |
298 for (; fields ; fields = fields->next) | |
299 { | |
15823 | 300 PurpleRequestField *field = fields->data; |
301 PurpleRequestFieldType type = purple_request_field_get_type(field); | |
302 if (type == PURPLE_REQUEST_FIELD_BOOLEAN) | |
15818 | 303 { |
304 GntWidget *check = field->ui_data; | |
305 gboolean value = gnt_check_box_get_checked(GNT_CHECK_BOX(check)); | |
15823 | 306 purple_request_field_bool_set_value(field, value); |
15818 | 307 } |
15823 | 308 else if (type == PURPLE_REQUEST_FIELD_STRING) |
15818 | 309 { |
310 GntWidget *entry = field->ui_data; | |
311 const char *text = gnt_entry_get_text(GNT_ENTRY(entry)); | |
15823 | 312 purple_request_field_string_set_value(field, (text && *text) ? text : NULL); |
15818 | 313 } |
15823 | 314 else if (type == PURPLE_REQUEST_FIELD_INTEGER) |
15818 | 315 { |
316 GntWidget *entry = field->ui_data; | |
317 const char *text = gnt_entry_get_text(GNT_ENTRY(entry)); | |
318 int value = (text && *text) ? atoi(text) : 0; | |
15823 | 319 purple_request_field_int_set_value(field, value); |
15818 | 320 } |
15823 | 321 else if (type == PURPLE_REQUEST_FIELD_CHOICE) |
15818 | 322 { |
323 GntWidget *combo = field->ui_data; | |
324 int id; | |
325 id = GPOINTER_TO_INT(gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo))); | |
15823 | 326 purple_request_field_choice_set_value(field, id); |
15818 | 327 } |
15823 | 328 else if (type == PURPLE_REQUEST_FIELD_LIST) |
15818 | 329 { |
330 GList *list = NULL; | |
15823 | 331 if (purple_request_field_list_get_multi_select(field)) |
15818 | 332 { |
18118
ab6d2763b8d8
Re-fix the DBus list handling code by killing const GList* / const GSList*
Richard Laager <rlaager@wiktel.com>
parents:
18063
diff
changeset
|
333 GList *iter; |
15818 | 334 GntWidget *tree = field->ui_data; |
335 | |
15823 | 336 iter = purple_request_field_list_get_items(field); |
15818 | 337 for (; iter; iter = iter->next) |
338 { | |
339 const char *text = iter->data; | |
15823 | 340 gpointer key = purple_request_field_list_get_data(field, text); |
15818 | 341 if (gnt_tree_get_choice(GNT_TREE(tree), key)) |
342 list = g_list_prepend(list, key); | |
343 } | |
344 } | |
345 else | |
346 { | |
347 GntWidget *combo = field->ui_data; | |
348 gpointer data = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo)); | |
349 list = g_list_append(list, data); | |
350 } | |
351 | |
15823 | 352 purple_request_field_list_set_selected(field, list); |
15818 | 353 g_list_free(list); |
354 } | |
15823 | 355 else if (type == PURPLE_REQUEST_FIELD_ACCOUNT) |
15818 | 356 { |
357 GntWidget *combo = field->ui_data; | |
15823 | 358 PurpleAccount *acc = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo)); |
359 purple_request_field_account_set_value(field, acc); | |
15818 | 360 } |
361 } | |
362 } | |
363 | |
364 if (callback) | |
365 callback(data, fields); | |
366 | |
367 while (button->parent) | |
368 button = button->parent; | |
369 | |
15823 | 370 purple_request_close(PURPLE_REQUEST_FIELDS, button); |
15818 | 371 } |
372 | |
373 static void * | |
374 finch_request_fields(const char *title, const char *primary, | |
15823 | 375 const char *secondary, PurpleRequestFields *allfields, |
15818 | 376 const char *ok, GCallback ok_cb, |
377 const char *cancel, GCallback cancel_cb, | |
16442
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16310
diff
changeset
|
378 PurpleAccount *account, const char *who, PurpleConversation *conv, |
15818 | 379 void *userdata) |
380 { | |
381 GntWidget *window, *box; | |
382 GList *grlist; | |
383 | |
15823 | 384 window = setup_request_window(title, primary, secondary, PURPLE_REQUEST_FIELDS); |
15818 | 385 |
386 /* This is how it's going to work: the request-groups are going to be | |
387 * stacked vertically one after the other. A GntLine will be separating | |
388 * the groups. */ | |
389 box = gnt_vbox_new(FALSE); | |
390 gnt_box_set_pad(GNT_BOX(box), 0); | |
391 gnt_box_set_fill(GNT_BOX(box), TRUE); | |
15823 | 392 for (grlist = purple_request_fields_get_groups(allfields); grlist; grlist = grlist->next) |
15818 | 393 { |
15823 | 394 PurpleRequestFieldGroup *group = grlist->data; |
395 GList *fields = purple_request_field_group_get_fields(group); | |
15818 | 396 GntWidget *hbox; |
15823 | 397 const char *title = purple_request_field_group_get_title(group); |
15818 | 398 |
399 if (title) | |
400 gnt_box_add_widget(GNT_BOX(box), | |
401 gnt_label_new_with_format(title, GNT_TEXT_FLAG_BOLD)); | |
402 | |
403 for (; fields ; fields = fields->next) | |
404 { | |
405 /* XXX: Break each of the fields into a separate function? */ | |
15823 | 406 PurpleRequestField *field = fields->data; |
407 PurpleRequestFieldType type = purple_request_field_get_type(field); | |
408 const char *label = purple_request_field_get_label(field); | |
15818 | 409 |
410 hbox = gnt_hbox_new(TRUE); /* hrm */ | |
411 gnt_box_add_widget(GNT_BOX(box), hbox); | |
412 | |
15823 | 413 if (type != PURPLE_REQUEST_FIELD_BOOLEAN && label) |
15818 | 414 { |
415 GntWidget *l = gnt_label_new(label); | |
416 gnt_widget_set_size(l, 0, 1); | |
417 gnt_box_add_widget(GNT_BOX(hbox), l); | |
418 } | |
419 | |
15823 | 420 if (type == PURPLE_REQUEST_FIELD_BOOLEAN) |
15818 | 421 { |
422 GntWidget *check = gnt_check_box_new(label); | |
423 gnt_check_box_set_checked(GNT_CHECK_BOX(check), | |
15823 | 424 purple_request_field_bool_get_default_value(field)); |
15818 | 425 gnt_box_add_widget(GNT_BOX(hbox), check); |
426 field->ui_data = check; | |
427 } | |
15823 | 428 else if (type == PURPLE_REQUEST_FIELD_STRING) |
15818 | 429 { |
15830 | 430 const char *hint = purple_request_field_get_type_hint(field); |
15818 | 431 GntWidget *entry = gnt_entry_new( |
15823 | 432 purple_request_field_string_get_default_value(field)); |
15818 | 433 gnt_entry_set_masked(GNT_ENTRY(entry), |
15823 | 434 purple_request_field_string_is_masked(field)); |
18222
ef65d43190e5
Fix a few runtime warnings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18118
diff
changeset
|
435 if (hint && purple_str_has_prefix(hint, "screenname")) { |
15830 | 436 PurpleBlistNode *node = purple_blist_get_root(); |
437 gboolean offline = purple_str_has_suffix(hint, "all"); | |
438 for (; node; node = purple_blist_node_next(node, offline)) { | |
439 if (!PURPLE_BLIST_NODE_IS_BUDDY(node)) | |
15827
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:
15818
diff
changeset
|
440 continue; |
15830 | 441 gnt_entry_add_suggest(GNT_ENTRY(entry), purple_buddy_get_name((PurpleBuddy*)node)); |
15827
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:
15818
diff
changeset
|
442 } |
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:
15818
diff
changeset
|
443 gnt_entry_set_always_suggest(GNT_ENTRY(entry), TRUE); |
15844
e74c2488448b
Group autocomplete for buddy adding
Richard Nelson <wabz@pidgin.im>
parents:
15830
diff
changeset
|
444 } else if (hint && !strcmp(hint, "group")) { |
e74c2488448b
Group autocomplete for buddy adding
Richard Nelson <wabz@pidgin.im>
parents:
15830
diff
changeset
|
445 PurpleBlistNode *node; |
e74c2488448b
Group autocomplete for buddy adding
Richard Nelson <wabz@pidgin.im>
parents:
15830
diff
changeset
|
446 for (node = purple_blist_get_root(); node; node = node->next) { |
e74c2488448b
Group autocomplete for buddy adding
Richard Nelson <wabz@pidgin.im>
parents:
15830
diff
changeset
|
447 if (PURPLE_BLIST_NODE_IS_GROUP(node)) |
e74c2488448b
Group autocomplete for buddy adding
Richard Nelson <wabz@pidgin.im>
parents:
15830
diff
changeset
|
448 gnt_entry_add_suggest(GNT_ENTRY(entry), ((PurpleGroup *)node)->name); |
e74c2488448b
Group autocomplete for buddy adding
Richard Nelson <wabz@pidgin.im>
parents:
15830
diff
changeset
|
449 } |
15827
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:
15818
diff
changeset
|
450 } |
15818 | 451 gnt_box_add_widget(GNT_BOX(hbox), entry); |
452 field->ui_data = entry; | |
453 } | |
15823 | 454 else if (type == PURPLE_REQUEST_FIELD_INTEGER) |
15818 | 455 { |
456 char str[256]; | |
15823 | 457 int val = purple_request_field_int_get_default_value(field); |
15818 | 458 GntWidget *entry; |
459 | |
460 snprintf(str, sizeof(str), "%d", val); | |
461 entry = gnt_entry_new(str); | |
462 gnt_entry_set_flag(GNT_ENTRY(entry), GNT_ENTRY_FLAG_INT); | |
463 gnt_box_add_widget(GNT_BOX(hbox), entry); | |
464 field->ui_data = entry; | |
465 } | |
15823 | 466 else if (type == PURPLE_REQUEST_FIELD_CHOICE) |
15818 | 467 { |
468 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
|
469 GList *list; |
15818 | 470 GntWidget *combo = gnt_combo_box_new(); |
471 gnt_box_add_widget(GNT_BOX(hbox), combo); | |
472 field->ui_data = combo; | |
473 | |
15823 | 474 list = purple_request_field_choice_get_labels(field); |
15818 | 475 for (id = 1; list; list = list->next, id++) |
476 { | |
477 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), | |
478 GINT_TO_POINTER(id), list->data); | |
479 } | |
480 gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), | |
15823 | 481 GINT_TO_POINTER(purple_request_field_choice_get_default_value(field))); |
15818 | 482 } |
15823 | 483 else if (type == PURPLE_REQUEST_FIELD_LIST) |
15818 | 484 { |
18118
ab6d2763b8d8
Re-fix the DBus list handling code by killing const GList* / const GSList*
Richard Laager <rlaager@wiktel.com>
parents:
18063
diff
changeset
|
485 GList *list; |
15823 | 486 gboolean multi = purple_request_field_list_get_multi_select(field); |
15818 | 487 if (multi) |
488 { | |
489 GntWidget *tree = gnt_tree_new(); | |
490 gnt_box_add_widget(GNT_BOX(hbox), tree); | |
491 field->ui_data = tree; | |
492 | |
15823 | 493 list = purple_request_field_list_get_items(field); |
15818 | 494 for (; list; list = list->next) |
495 { | |
496 const char *text = list->data; | |
15823 | 497 gpointer key = purple_request_field_list_get_data(field, text); |
15818 | 498 gnt_tree_add_choice(GNT_TREE(tree), key, |
499 gnt_tree_create_row(GNT_TREE(tree), text), NULL, NULL); | |
15823 | 500 if (purple_request_field_list_is_selected(field, text)) |
15818 | 501 gnt_tree_set_choice(GNT_TREE(tree), key, TRUE); |
502 } | |
503 } | |
504 else | |
505 { | |
506 GntWidget *combo = gnt_combo_box_new(); | |
507 gnt_box_set_alignment(GNT_BOX(hbox), GNT_ALIGN_MID); | |
508 gnt_box_add_widget(GNT_BOX(hbox), combo); | |
509 field->ui_data = combo; | |
510 | |
15823 | 511 list = purple_request_field_list_get_items(field); |
15818 | 512 for (; list; list = list->next) |
513 { | |
514 const char *text = list->data; | |
15823 | 515 gpointer key = purple_request_field_list_get_data(field, text); |
15818 | 516 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), key, text); |
15823 | 517 if (purple_request_field_list_is_selected(field, text)) |
15818 | 518 gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), key); |
519 } | |
520 } | |
521 } | |
15823 | 522 else if (type == PURPLE_REQUEST_FIELD_ACCOUNT) |
15818 | 523 { |
524 gboolean all; | |
15823 | 525 PurpleAccount *def; |
18063
926ccb104da0
disapproval of revision '1411afd7660760db59966c3a9f18e2adab8eb27e'
Richard Laager <rlaager@wiktel.com>
parents:
18058
diff
changeset
|
526 GList *list; |
15818 | 527 GntWidget *combo = gnt_combo_box_new(); |
528 gnt_box_set_alignment(GNT_BOX(hbox), GNT_ALIGN_MID); | |
529 gnt_box_add_widget(GNT_BOX(hbox), combo); | |
530 field->ui_data = combo; | |
531 | |
15823 | 532 all = purple_request_field_account_get_show_all(field); |
16938
43abb4942a6d
Select the right account when adding a buddy after authorizing her.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16442
diff
changeset
|
533 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:
16442
diff
changeset
|
534 if (!def) |
43abb4942a6d
Select the right account when adding a buddy after authorizing her.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16442
diff
changeset
|
535 def = purple_request_field_account_get_default_value(field); |
15818 | 536 |
537 if (all) | |
15823 | 538 list = purple_accounts_get_all(); |
15818 | 539 else |
15823 | 540 list = purple_connections_get_all(); |
15818 | 541 |
542 for (; list; list = list->next) | |
543 { | |
15823 | 544 PurpleAccount *account; |
15818 | 545 char *text; |
546 | |
547 if (all) | |
548 account = list->data; | |
549 else | |
15823 | 550 account = purple_connection_get_account(list->data); |
15818 | 551 |
552 text = g_strdup_printf("%s (%s)", | |
15823 | 553 purple_account_get_username(account), |
554 purple_account_get_protocol_name(account)); | |
15818 | 555 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), account, text); |
556 g_free(text); | |
557 if (account == def) | |
558 gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), account); | |
559 } | |
560 gnt_widget_set_size(combo, 20, 3); /* ew */ | |
561 } | |
562 else | |
563 { | |
564 gnt_box_add_widget(GNT_BOX(hbox), | |
565 gnt_label_new_with_format(_("Not implemented yet."), | |
566 GNT_TEXT_FLAG_BOLD)); | |
567 } | |
568 } | |
569 if (grlist->next) | |
570 gnt_box_add_widget(GNT_BOX(box), gnt_hline_new()); | |
571 } | |
572 gnt_box_add_widget(GNT_BOX(window), box); | |
573 | |
18333
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
574 box = setup_button_box(window, userdata, request_fields_cb, allfields, |
15818 | 575 ok, ok_cb, cancel, cancel_cb, NULL); |
576 gnt_box_add_widget(GNT_BOX(window), box); | |
577 | |
18333
f23a7736586f
Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
578 setup_default_callback(window, cancel_cb, userdata); |
15818 | 579 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
|
580 |
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
|
581 g_object_set_data(G_OBJECT(window), "fields", allfields); |
15818 | 582 |
583 return window; | |
584 } | |
585 | |
586 static void | |
18411
3849776d0f71
Fix some crashes resulting from rejecting file-transfer requests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18410
diff
changeset
|
587 file_cancel_cb(gpointer fq, GntWidget *wid) |
15818 | 588 { |
15823 | 589 PurpleGntFileRequest *data = fq; |
15818 | 590 if (data->cbs[1] != NULL) |
15823 | 591 ((PurpleRequestFileCb)data->cbs[1])(data->user_data, NULL); |
15818 | 592 |
15823 | 593 purple_request_close(PURPLE_REQUEST_FILE, data->dialog); |
15818 | 594 } |
595 | |
596 static void | |
18411
3849776d0f71
Fix some crashes resulting from rejecting file-transfer requests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18410
diff
changeset
|
597 file_ok_cb(gpointer fq, GntWidget *widget) |
15818 | 598 { |
15823 | 599 PurpleGntFileRequest *data = fq; |
15930
846a00760176
use file select dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15926
diff
changeset
|
600 char *file = gnt_file_sel_get_selected_file(GNT_FILE_SEL(data->dialog)); |
18410
719f73b9a593
Remember the open/save file locations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18347
diff
changeset
|
601 char *dir = g_path_get_dirname(file); |
15818 | 602 if (data->cbs[0] != NULL) |
15930
846a00760176
use file select dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15926
diff
changeset
|
603 ((PurpleRequestFileCb)data->cbs[0])(data->user_data, file); |
846a00760176
use file select dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15926
diff
changeset
|
604 g_free(file); |
18410
719f73b9a593
Remember the open/save file locations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18347
diff
changeset
|
605 purple_prefs_set_path(data->save ? "/finch/filelocations/last_save_folder" : |
719f73b9a593
Remember the open/save file locations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18347
diff
changeset
|
606 "/finch/filelocations/last_open_folder", dir); |
719f73b9a593
Remember the open/save file locations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18347
diff
changeset
|
607 g_free(dir); |
15818 | 608 |
15823 | 609 purple_request_close(PURPLE_REQUEST_FILE, data->dialog); |
15818 | 610 } |
611 | |
612 static void | |
15823 | 613 file_request_destroy(PurpleGntFileRequest *data) |
15818 | 614 { |
615 g_free(data->cbs); | |
616 g_free(data); | |
617 } | |
618 | |
619 static void * | |
620 finch_request_file(const char *title, const char *filename, | |
621 gboolean savedialog, | |
622 GCallback ok_cb, GCallback cancel_cb, | |
16442
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16310
diff
changeset
|
623 PurpleAccount *account, const char *who, PurpleConversation *conv, |
15818 | 624 void *user_data) |
625 { | |
15930
846a00760176
use file select dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15926
diff
changeset
|
626 GntWidget *window = gnt_file_sel_new(); |
846a00760176
use file select dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15926
diff
changeset
|
627 GntFileSel *sel = GNT_FILE_SEL(window); |
15823 | 628 PurpleGntFileRequest *data = g_new0(PurpleGntFileRequest, 1); |
18410
719f73b9a593
Remember the open/save file locations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18347
diff
changeset
|
629 const char *path; |
15818 | 630 |
631 data->user_data = user_data; | |
632 data->cbs = g_new0(GCallback, 2); | |
633 data->cbs[0] = ok_cb; | |
634 data->cbs[1] = cancel_cb; | |
635 data->dialog = window; | |
18410
719f73b9a593
Remember the open/save file locations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18347
diff
changeset
|
636 data->save = savedialog; |
15818 | 637 gnt_box_set_title(GNT_BOX(window), title ? title : (savedialog ? _("Save File...") : _("Open File..."))); |
18410
719f73b9a593
Remember the open/save file locations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18347
diff
changeset
|
638 |
719f73b9a593
Remember the open/save file locations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18347
diff
changeset
|
639 path = purple_prefs_get_path(savedialog ? "/finch/filelocations/last_save_folder" : "/finch/filelocations/last_open_folder"); |
719f73b9a593
Remember the open/save file locations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18347
diff
changeset
|
640 gnt_file_sel_set_current_location(sel, (path && *path) ? path : purple_home_dir()); |
719f73b9a593
Remember the open/save file locations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18347
diff
changeset
|
641 |
15939 | 642 if (savedialog) |
643 gnt_file_sel_set_suggested_filename(sel, filename); | |
18411
3849776d0f71
Fix some crashes resulting from rejecting file-transfer requests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18410
diff
changeset
|
644 |
15930
846a00760176
use file select dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15926
diff
changeset
|
645 g_signal_connect(G_OBJECT(sel->cancel), "activate", |
18411
3849776d0f71
Fix some crashes resulting from rejecting file-transfer requests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18410
diff
changeset
|
646 G_CALLBACK(action_performed), window); |
3849776d0f71
Fix some crashes resulting from rejecting file-transfer requests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18410
diff
changeset
|
647 g_signal_connect(G_OBJECT(sel->select), "activate", |
3849776d0f71
Fix some crashes resulting from rejecting file-transfer requests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18410
diff
changeset
|
648 G_CALLBACK(action_performed), window); |
3849776d0f71
Fix some crashes resulting from rejecting file-transfer requests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18410
diff
changeset
|
649 g_signal_connect_swapped(G_OBJECT(sel->cancel), "activate", |
15930
846a00760176
use file select dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15926
diff
changeset
|
650 G_CALLBACK(file_cancel_cb), data); |
18411
3849776d0f71
Fix some crashes resulting from rejecting file-transfer requests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18410
diff
changeset
|
651 g_signal_connect_swapped(G_OBJECT(sel->select), "activate", |
15930
846a00760176
use file select dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15926
diff
changeset
|
652 G_CALLBACK(file_ok_cb), data); |
15818 | 653 |
18411
3849776d0f71
Fix some crashes resulting from rejecting file-transfer requests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18410
diff
changeset
|
654 setup_default_callback(window, file_cancel_cb, data); |
3849776d0f71
Fix some crashes resulting from rejecting file-transfer requests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18410
diff
changeset
|
655 g_object_set_data_full(G_OBJECT(window), "filerequestdata", data, |
3849776d0f71
Fix some crashes resulting from rejecting file-transfer requests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18410
diff
changeset
|
656 (GDestroyNotify)file_request_destroy); |
15818 | 657 gnt_widget_show(window); |
658 | |
659 return window; | |
660 } | |
661 | |
15823 | 662 static PurpleRequestUiOps uiops = |
15818 | 663 { |
17104
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16938
diff
changeset
|
664 finch_request_input, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16938
diff
changeset
|
665 finch_request_choice, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16938
diff
changeset
|
666 finch_request_action, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16938
diff
changeset
|
667 finch_request_fields, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16938
diff
changeset
|
668 finch_request_file, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16938
diff
changeset
|
669 finch_close_request, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16938
diff
changeset
|
670 NULL, /* No plans for request_folder */ |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16938
diff
changeset
|
671 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16938
diff
changeset
|
672 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16938
diff
changeset
|
673 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16938
diff
changeset
|
674 NULL |
15818 | 675 }; |
676 | |
15823 | 677 PurpleRequestUiOps *finch_request_get_ui_ops() |
15818 | 678 { |
679 return &uiops; | |
680 } | |
681 | |
682 void finch_request_init() | |
683 { | |
684 } | |
685 | |
686 void finch_request_uninit() | |
687 { | |
688 } | |
689 | |
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
|
690 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
|
691 { |
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 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
|
693 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
|
694 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
|
695 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
|
696 |
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 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
|
698 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
|
699 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
|
700 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
|
701 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
|
702 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
|
703 |
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 (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
|
705 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
|
706 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
|
707 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
|
708 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
|
709 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
|
710 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
|
711 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
|
712 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
|
713 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
|
714 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
|
715 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
|
716 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
|
717 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
|
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 } |
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 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
|
722 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
|
723 case PURPLE_PREF_INT: |
17472
a236c67e39b6
A change from o_sukhodolsky:
Richard Laager <rlaager@wiktel.com>
parents:
17104
diff
changeset
|
724 { |
18222
ef65d43190e5
Fix a few runtime warnings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18118
diff
changeset
|
725 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
|
726 if (type == PURPLE_REQUEST_FIELD_LIST) /* Lists always return string */ |
17472
a236c67e39b6
A change from o_sukhodolsky:
Richard Laager <rlaager@wiktel.com>
parents:
17104
diff
changeset
|
727 sscanf(val, "%ld", &tmp); |
a236c67e39b6
A change from o_sukhodolsky:
Richard Laager <rlaager@wiktel.com>
parents:
17104
diff
changeset
|
728 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
|
729 break; |
17472
a236c67e39b6
A change from o_sukhodolsky:
Richard Laager <rlaager@wiktel.com>
parents:
17104
diff
changeset
|
730 } |
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
|
731 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
|
732 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
|
733 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
|
734 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
|
735 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
|
736 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
|
737 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
|
738 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
|
739 } |
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
|
740 } |
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
|
741 } |
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
|
742 } |
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
|
743 |