Mercurial > pidgin.yaz
comparison gtk/gtksavedstatuses.c @ 15340:9ebc7fa9d556
[gaim-migrate @ 18132]
Fix SF bug #1635129 "Deleting several status descriptions shows question for each".
I also noticed that the way that multiples were being deleted was invalid - you can't modify the tree in gtk_tree_selection_selected_foreach(). A quick search revealed that there are other places where this is done; they should also be fixed.
committer: Tailor Script <tailor@pidgin.im>
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Mon, 15 Jan 2007 23:19:12 +0000 |
parents | f54c3349a7aa |
children | 29e9a2373d32 |
comparison
equal
deleted
inserted
replaced
15339:412c2b3b5fc0 | 15340:9ebc7fa9d556 |
---|---|
267 | 267 |
268 gtk_tree_selection_selected_foreach(selection, status_window_modify_foreach, user_data); | 268 gtk_tree_selection_selected_foreach(selection, status_window_modify_foreach, user_data); |
269 } | 269 } |
270 | 270 |
271 static void | 271 static void |
272 status_window_delete_confirm_cb(char *title) | 272 status_window_delete_cancel_cb(gpointer data) |
273 { | |
274 GList *sel_titles = data; | |
275 g_list_foreach(sel_titles, (GFunc) g_free, NULL); | |
276 g_list_free(sel_titles); | |
277 } | |
278 | |
279 static void | |
280 status_window_delete_confirm_cb(gpointer data) | |
273 { | 281 { |
274 GtkTreeIter iter; | 282 GtkTreeIter iter; |
275 | 283 GList *sel_titles = data, *l; |
276 if (status_window_find_savedstatus(&iter, title)) | 284 char *title; |
277 gtk_list_store_remove(status_window->model, &iter); | 285 |
278 | 286 for (l = sel_titles; l != NULL; l = l->next) { |
279 gaim_savedstatus_delete(title); | 287 title = l->data; |
288 if (status_window_find_savedstatus(&iter, title)) | |
289 gtk_list_store_remove(status_window->model, &iter); | |
290 gaim_savedstatus_delete(title); | |
291 g_free(title); | |
292 } | |
293 g_list_free(sel_titles); | |
294 } | |
295 | |
296 static void | |
297 status_window_delete_cb(GtkButton *button, gpointer user_data) | |
298 { | |
299 StatusWindow *dialog = user_data; | |
300 GtkTreeIter iter; | |
301 GtkTreeSelection *selection; | |
302 GList *sel_paths, *l, *sel_titles = NULL; | |
303 GtkTreeModel *model = GTK_TREE_MODEL(dialog->model); | |
304 char *title; | |
305 | |
306 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->treeview)); | |
307 sel_paths = gtk_tree_selection_get_selected_rows(selection, &model); | |
308 | |
309 /* This is ugly because we're not allowed to modify the model from within | |
310 * gtk_tree_selection_selected_foreach() and the GtkTreePaths can become invalid | |
311 * when something is removed from the model. The selection can also change while | |
312 * the request dialog is displayed, so we need to capture the selected rows at this time. */ | |
313 | |
314 for (l = sel_paths; l != NULL; l = l->next) { | |
315 if (gtk_tree_model_get_iter(model, &iter, l->data)) { | |
316 gtk_tree_model_get(model, &iter, STATUS_WINDOW_COLUMN_TITLE, &title, -1); | |
317 sel_titles = g_list_prepend(sel_titles, title); | |
318 } | |
319 gtk_tree_path_free(l->data); | |
320 } | |
321 g_list_free(sel_paths); | |
322 | |
323 if (g_list_length(sel_titles) == 1) | |
324 title = g_strdup_printf(_("Are you sure you want to delete %s?"), sel_titles->data); | |
325 else | |
326 title = g_strdup(_("Are you sure you want to delete the selected saved statuses?")); | |
327 | |
328 gaim_request_action(dialog, NULL, title, | |
329 NULL, 0, sel_titles, 2, | |
330 _("Delete"), status_window_delete_confirm_cb, | |
331 _("Cancel"), status_window_delete_cancel_cb); | |
280 | 332 |
281 g_free(title); | 333 g_free(title); |
282 } | |
283 | |
284 static void | |
285 status_window_delete_foreach(GtkTreeModel *model, GtkTreePath *path, | |
286 GtkTreeIter *iter, gpointer user_data) | |
287 { | |
288 char *title; | |
289 char *buf; | |
290 | |
291 gtk_tree_model_get(model, iter, STATUS_WINDOW_COLUMN_TITLE, &title, -1); | |
292 | |
293 buf = g_strdup_printf(_("Are you sure you want to delete %s?"), title); | |
294 gaim_request_action(status_window, NULL, buf, NULL, 0, title, 2, | |
295 _("Delete"), status_window_delete_confirm_cb, | |
296 _("Cancel"), g_free); | |
297 g_free(buf); | |
298 } | |
299 | |
300 static void | |
301 status_window_delete_cb(GtkButton *button, gpointer user_data) | |
302 { | |
303 StatusWindow *dialog = user_data; | |
304 GtkTreeSelection *selection; | |
305 | |
306 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->treeview)); | |
307 | |
308 gtk_tree_selection_selected_foreach(selection, status_window_delete_foreach, user_data); | |
309 } | 334 } |
310 | 335 |
311 static void | 336 static void |
312 status_window_close_cb(GtkButton *button, gpointer user_data) | 337 status_window_close_cb(GtkButton *button, gpointer user_data) |
313 { | 338 { |