comparison src/notify.c @ 11359:9480e0d0f563

[gaim-migrate @ 13581] Search results notification extended so that any column can be added. committer: Tailor Script <tailor@pidgin.im>
author Bartoz Oler <bartosz@pidgin.im>
date Sun, 28 Aug 2005 22:21:24 +0000
parents 911530134bf8
children bf763a1b2454
comparison
equal deleted inserted replaced
11358:fb702c34794b 11359:9480e0d0f563
156 } 156 }
157 157
158 void * 158 void *
159 gaim_notify_searchresults(GaimConnection *gc, const char *title, 159 gaim_notify_searchresults(GaimConnection *gc, const char *title,
160 const char *primary, const char *secondary, 160 const char *primary, const char *secondary,
161 const char **results, GCallback cb, void *user_data) 161 GaimNotifySearchResults *results, GCallback cb, void *user_data)
162 { 162 {
163 GaimNotifyUiOps *ops; 163 GaimNotifyUiOps *ops;
164 164
165 ops = gaim_notify_get_ui_ops(); 165 ops = gaim_notify_get_ui_ops();
166 166
180 } 180 }
181 181
182 return NULL; 182 return NULL;
183 } 183 }
184 184
185 void
186 gaim_notify_searchresults_free(GaimNotifySearchResults *results)
187 {
188 GList *l, *m;
189
190 g_return_if_fail(results != NULL);
191
192 for (l = results->buttons; l != NULL; l = l->next) {
193 GaimNotifySearchButton *button = l->data;
194
195 results->buttons = g_list_remove(results->buttons, button);
196 g_free(button);
197 }
198 g_list_free(results->buttons);
199
200 for (l = results->rows; l != NULL; l = l->next) {
201 GList *row = l->data;
202
203 for (m = row; m != NULL; m = m->next) {
204 gchar *str = m->data;
205
206 m = g_list_remove(m, str);
207 g_free(str);
208 }
209
210 results->rows = g_list_remove(results->rows, row);
211 g_list_free(row);
212 }
213 g_list_free(results->rows);
214
215 for (l = results->columns; l != NULL; l = l->next) {
216 GaimNotifySearchColumn *column = l->data;
217
218 results->columns = g_list_remove(results->columns, column);
219 g_free(column->title);
220 g_free(column);
221 }
222 g_list_free(results->columns);
223 }
224
225 void
226 gaim_notify_searchresults_new_rows(GaimConnection *gc,
227 GaimNotifySearchResults *results,
228 void *data, void *user_data)
229 {
230 GaimNotifyUiOps *ops;
231
232 ops = gaim_notify_get_ui_ops();
233
234 if (ops != NULL && ops->notify_searchresults != NULL) {
235 ops->notify_searchresults_new_rows(gc, results, data, user_data);
236 }
237 }
238
239 void
240 gaim_notify_searchresults_button_add(GaimNotifySearchResults *results,
241 GaimNotifySearchButtonType type,
242 GaimNotifySearchResultsCallback cb)
243 {
244 GaimNotifySearchButton *button;
245
246 g_return_if_fail(results != NULL);
247 g_return_if_fail(cb != NULL);
248
249 button = g_new0(GaimNotifySearchButton, 1);
250 button->callback = cb;
251 button->type = type;
252
253 results->buttons = g_list_append(results->buttons, button);
254 }
255
256 GaimNotifySearchResults *
257 gaim_notify_searchresults_new()
258 {
259 GaimNotifySearchResults *rs = g_new0(GaimNotifySearchResults, 1);
260
261 return rs;
262 }
263
264 void
265 gaim_notify_searchresults_column_add(GaimNotifySearchResults *results,
266 GaimNotifySearchColumn *column)
267 {
268 g_return_if_fail(results != NULL);
269 g_return_if_fail(column != NULL);
270
271 results->columns = g_list_append(results->columns, column);
272 }
273
274 void gaim_notify_searchresults_row_add(GaimNotifySearchResults *results,
275 GList *row)
276 {
277 g_return_if_fail(results != NULL);
278 g_return_if_fail(row != NULL);
279
280 results->rows = g_list_append(results->rows, row);
281 }
282
283 GaimNotifySearchColumn *
284 gaim_notify_searchresults_column_new(const char *title)
285 {
286 GaimNotifySearchColumn *sc;
287
288 g_return_val_if_fail(title != NULL, NULL);
289
290 sc = g_new0(GaimNotifySearchColumn, 1);
291 sc->title = g_strdup(title);
292
293 return sc;
294 }
295
296 int
297 gaim_notify_searchresults_get_columns_count(GaimNotifySearchResults *results)
298 {
299 g_return_val_if_fail(results != NULL, -1);
300
301 return g_list_length(results->columns);
302 }
303
304 int
305 gaim_notify_searchresults_get_rows_count(GaimNotifySearchResults *results)
306 {
307 g_return_val_if_fail(results != NULL, -1);
308
309 return g_list_length(results->rows);
310 }
311
312 char *
313 gaim_notify_searchresults_column_get_title(GaimNotifySearchResults *results,
314 unsigned int column_id)
315 {
316 g_return_val_if_fail(results != NULL, NULL);
317
318 return ((GaimNotifySearchColumn *)g_list_nth_data(results->columns, column_id))->title;
319 }
320
321 GList *
322 gaim_notify_searchresults_row_get(GaimNotifySearchResults *results,
323 unsigned int row_id)
324 {
325 g_return_val_if_fail(results != NULL, NULL);
326
327 return g_list_nth_data(results->rows, row_id);
328 }
329
185 void * 330 void *
186 gaim_notify_userinfo(GaimConnection *gc, const char *who, const char *title, 331 gaim_notify_userinfo(GaimConnection *gc, const char *who, const char *title,
187 const char *primary, const char *secondary, 332 const char *primary, const char *secondary,
188 const char *text, GCallback cb, void *user_data) 333 const char *text, GCallback cb, void *user_data)
189 { 334 {