| 209 } |
209 } |
| 210 |
210 |
| 211 static void |
211 static void |
| 212 pounce_response_dismiss() |
212 pounce_response_dismiss() |
| 213 { |
213 { |
| |
214 GtkTreeModel *model = GTK_TREE_MODEL(pounce_dialog->treemodel); |
| 214 GtkTreeSelection *selection; |
215 GtkTreeSelection *selection; |
| 215 GtkTreeIter iter; |
216 GtkTreeIter iter; |
| |
217 GtkTreeIter new_selection; |
| 216 GList *list = NULL; |
218 GList *list = NULL; |
| |
219 gboolean found_selection = FALSE; |
| 217 |
220 |
| 218 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(pounce_dialog->treeview)); |
221 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(pounce_dialog->treeview)); |
| 219 gtk_tree_selection_selected_foreach(selection, delete_foreach, pounce_dialog); |
222 gtk_tree_selection_selected_foreach(selection, delete_foreach, pounce_dialog); |
| 220 gtk_tree_selection_selected_foreach(selection, append_to_list, &list); |
223 gtk_tree_selection_selected_foreach(selection, append_to_list, &list); |
| 221 |
224 |
| |
225 g_return_if_fail(list != NULL); |
| |
226 |
| |
227 if (list->next == NULL) { |
| |
228 gtk_tree_model_get_iter(model, &new_selection, list->data); |
| |
229 if (gtk_tree_model_iter_next(model, &new_selection)) |
| |
230 found_selection = TRUE; |
| |
231 else { |
| |
232 /* This is the last thing in the list */ |
| |
233 GtkTreePath *path; |
| |
234 |
| |
235 /* Because gtk_tree_model_iter_prev doesn't exist... */ |
| |
236 gtk_tree_model_get_iter(model, &new_selection, list->data); |
| |
237 path = gtk_tree_model_get_path(model, &new_selection); |
| |
238 if (gtk_tree_path_prev(path)) { |
| |
239 gtk_tree_model_get_iter(model, &new_selection, path); |
| |
240 found_selection = TRUE; |
| |
241 } |
| |
242 |
| |
243 gtk_tree_path_free(path); |
| |
244 } |
| |
245 } |
| |
246 |
| 222 while (list) { |
247 while (list) { |
| 223 GtkTreeIter iter; |
248 if (gtk_tree_model_get_iter(model, &iter, list->data)) { |
| 224 if (gtk_tree_model_get_iter(GTK_TREE_MODEL(pounce_dialog->treemodel), &iter, |
|
| 225 list->data)) { |
|
| 226 gtk_tree_store_remove(GTK_TREE_STORE(pounce_dialog->treemodel), &iter); |
249 gtk_tree_store_remove(GTK_TREE_STORE(pounce_dialog->treemodel), &iter); |
| 227 } |
250 } |
| 228 gtk_tree_path_free(list->data); |
251 gtk_tree_path_free(list->data); |
| 229 list = g_list_delete_link(list, list); |
252 list = g_list_delete_link(list, list); |
| 230 } |
253 } |
| 231 |
254 |
| 232 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(pounce_dialog->treemodel), &iter)) |
255 if (gtk_tree_model_get_iter_first(model, &iter)) { |
| |
256 if (found_selection) |
| |
257 gtk_tree_selection_select_iter(selection, &new_selection); |
| |
258 else |
| |
259 gtk_tree_selection_select_iter(selection, &iter); |
| |
260 } else |
| 233 pounce_response_close(pounce_dialog); |
261 pounce_response_close(pounce_dialog); |
| 234 } |
262 } |
| 235 |
263 |
| 236 static void |
264 static void |
| 237 pounce_response_open_ims() |
265 pounce_response_open_ims() |
| 238 { |
266 { |
| 239 GtkTreeSelection *selection; |
267 GtkTreeSelection *selection; |
| 240 |
268 |
| 241 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(pounce_dialog->treeview)); |
269 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(pounce_dialog->treeview)); |
| 242 gtk_tree_selection_selected_foreach(selection, open_im_foreach, pounce_dialog); |
270 gtk_tree_selection_selected_foreach(selection, open_im_foreach, pounce_dialog); |
| 243 |
271 |
| 244 pounce_response_dismiss(); |
272 pounce_response_dismiss(); |
| 245 } |
273 } |
| 246 |
274 |
| 247 static void |
275 static void |
| 248 pounce_response_edit_cb(GtkTreeModel *model, GtkTreePath *path, |
276 pounce_response_edit_cb(GtkTreeModel *model, GtkTreePath *path, |
| 1398 const char *alias, const char *event, const char *message, const char *date) |
1426 const char *alias, const char *event, const char *message, const char *date) |
| 1399 { |
1427 { |
| 1400 GdkPixbuf *icon; |
1428 GdkPixbuf *icon; |
| 1401 GtkTreeIter iter; |
1429 GtkTreeIter iter; |
| 1402 PidginNotifyPounceData *pounce_data; |
1430 PidginNotifyPounceData *pounce_data; |
| |
1431 gboolean first = (pounce_dialog == NULL); |
| 1403 |
1432 |
| 1404 if (pounce_dialog == NULL) |
1433 if (pounce_dialog == NULL) |
| 1405 pounce_dialog = pidgin_create_notification_dialog(PIDGIN_NOTIFY_POUNCE); |
1434 pounce_dialog = pidgin_create_notification_dialog(PIDGIN_NOTIFY_POUNCE); |
| 1406 |
1435 |
| 1407 icon = pidgin_create_prpl_icon(account, PIDGIN_PRPL_ICON_SMALL); |
1436 icon = pidgin_create_prpl_icon(account, PIDGIN_PRPL_ICON_SMALL); |
| 1420 PIDGIN_POUNCE_EVENT, event, |
1449 PIDGIN_POUNCE_EVENT, event, |
| 1421 PIDGIN_POUNCE_TEXT, (message != NULL)? message : _("No message"), |
1450 PIDGIN_POUNCE_TEXT, (message != NULL)? message : _("No message"), |
| 1422 PIDGIN_POUNCE_DATE, date, |
1451 PIDGIN_POUNCE_DATE, date, |
| 1423 PIDGIN_POUNCE_DATA, pounce_data, |
1452 PIDGIN_POUNCE_DATA, pounce_data, |
| 1424 -1); |
1453 -1); |
| |
1454 |
| |
1455 if (first) { |
| |
1456 GtkTreeSelection *selection = |
| |
1457 gtk_tree_view_get_selection(GTK_TREE_VIEW(pounce_dialog->treeview)); |
| |
1458 gtk_tree_selection_select_iter(selection, &iter); |
| |
1459 } |
| 1425 |
1460 |
| 1426 if (icon) |
1461 if (icon) |
| 1427 g_object_unref(icon); |
1462 g_object_unref(icon); |
| 1428 |
1463 |
| 1429 gtk_widget_show_all(pounce_dialog->dialog); |
1464 gtk_widget_show_all(pounce_dialog->dialog); |