comparison pidgin/gtknotify.c @ 27936:1688f7e15530

propagate from branch 'im.pidgin.pidgin' (head f71e0a5c7eff9c53c7641ad6c6b135a3dfec040f) to branch 'im.pidgin.pidgin.yaz' (head 06f54c4daa5abaa96e6a740e3aa88a8bc377bff5)
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Tue, 31 Mar 2009 11:18:23 +0000
parents a063901a5499 3d997c09b94e
children e0bcdc2bad7d
comparison
equal deleted inserted replaced
27935:f33f4ddbf01a 27936:1688f7e15530
26 #include "internal.h" 26 #include "internal.h"
27 #include "pidgin.h" 27 #include "pidgin.h"
28 28
29 #include <gdk/gdkkeysyms.h> 29 #include <gdk/gdkkeysyms.h>
30 30
31 #include "account.h"
31 #include "connection.h" 32 #include "connection.h"
32 #include "debug.h" 33 #include "debug.h"
33 #include "prefs.h" 34 #include "prefs.h"
34 #include "pidginstock.h" 35 #include "pidginstock.h"
35 #include "util.h" 36 #include "util.h"
36 37
37 #include "gtkblist.h" 38 #include "gtkblist.h"
38 #include "gtkimhtml.h" 39 #include "gtkimhtml.h"
39 #include "gtknotify.h" 40 #include "gtknotify.h"
41 #include "gtkpounce.h"
40 #include "gtkutils.h" 42 #include "gtkutils.h"
41 43
42 typedef struct 44 typedef struct
43 { 45 {
44 GtkWidget *window; 46 GtkWidget *window;
55 } PidginNotifyMailData; 57 } PidginNotifyMailData;
56 58
57 typedef struct 59 typedef struct
58 { 60 {
59 PurpleAccount *account; 61 PurpleAccount *account;
62 PurplePounce *pounce;
63 } PidginNotifyPounceData;
64
65
66 typedef struct
67 {
68 PurpleAccount *account;
60 GtkListStore *model; 69 GtkListStore *model;
61 GtkWidget *treeview; 70 GtkWidget *treeview;
62 GtkWidget *window; 71 GtkWidget *window;
63 gpointer user_data; 72 gpointer user_data;
64 PurpleNotifySearchResults *results; 73 PurpleNotifySearchResults *results;
78 PIDGIN_MAIL_TEXT, 87 PIDGIN_MAIL_TEXT,
79 PIDGIN_MAIL_DATA, 88 PIDGIN_MAIL_DATA,
80 COLUMNS_PIDGIN_MAIL 89 COLUMNS_PIDGIN_MAIL
81 }; 90 };
82 91
83 typedef struct _PidginMailDialog PidginMailDialog; 92 enum
84 93 {
85 struct _PidginMailDialog 94 PIDGIN_POUNCE_ICON,
95 PIDGIN_POUNCE_ALIAS,
96 PIDGIN_POUNCE_EVENT,
97 PIDGIN_POUNCE_TEXT,
98 PIDGIN_POUNCE_DATE,
99 PIDGIN_POUNCE_DATA,
100 PIDGIN_POUNCE_COLUMNS
101 };
102
103 typedef struct _PidginNotifyDialog PidginNotifyDialog;
104 typedef PidginNotifyDialog PidginMailDialog;
105
106 struct _PidginNotifyDialog
86 { 107 {
87 GtkWidget *dialog; 108 GtkWidget *dialog;
88 GtkWidget *treeview; 109 GtkWidget *treeview;
89 GtkTreeStore *treemodel; 110 GtkTreeStore *treemodel;
90 GtkLabel *label; 111 GtkLabel *label;
91 GtkWidget *open_button; 112 GtkWidget *open_button;
113 GtkWidget *dismiss_button;
114 GtkWidget *edit_button;
92 int total_count; 115 int total_count;
93 gboolean in_use; 116 gboolean in_use;
94 }; 117 };
95 118
96 static PidginMailDialog *mail_dialog = NULL; 119 typedef enum
97 120 {
121 PIDGIN_NOTIFY_MAIL,
122 PIDGIN_NOTIFY_POUNCE,
123 PIDGIN_NOTIFY_TYPES
124 } PidginNotifyType;
125
126 static PidginNotifyDialog *mail_dialog = NULL;
127 static PidginNotifyDialog *pounce_dialog = NULL;
128
129 static GtkWidget *pidgin_get_notification_dialog(PidginNotifyType type);
98 static void *pidgin_notify_emails(PurpleConnection *gc, size_t count, gboolean detailed, 130 static void *pidgin_notify_emails(PurpleConnection *gc, size_t count, gboolean detailed,
99 const char **subjects, 131 const char **subjects,
100 const char **froms, const char **tos, 132 const char **froms, const char **tos,
101 const char **urls); 133 const char **urls);
102 134
104 136
105 static void 137 static void
106 message_response_cb(GtkDialog *dialog, gint id, GtkWidget *widget) 138 message_response_cb(GtkDialog *dialog, gint id, GtkWidget *widget)
107 { 139 {
108 purple_notify_close(PURPLE_NOTIFY_MESSAGE, widget); 140 purple_notify_close(PURPLE_NOTIFY_MESSAGE, widget);
141 }
142
143 static void
144 pounce_response_close(PidginNotifyDialog *dialog)
145 {
146 GtkTreeIter iter;
147 PidginNotifyPounceData *pounce_data;
148
149 while (gtk_tree_model_get_iter_first(
150 GTK_TREE_MODEL(pounce_dialog->treemodel), &iter)) {
151 gtk_tree_model_get(GTK_TREE_MODEL(pounce_dialog->treemodel), &iter,
152 PIDGIN_POUNCE_DATA, &pounce_data,
153 -1);
154 gtk_tree_store_remove(dialog->treemodel, &iter);
155
156 g_free(pounce_data);
157 }
158
159 gtk_widget_destroy(pounce_dialog->dialog);
160 g_free(pounce_dialog);
161 pounce_dialog = NULL;
162 }
163
164 static void
165 delete_foreach(GtkTreeModel *model, GtkTreePath *path,
166 GtkTreeIter *iter, gpointer data)
167 {
168 PidginNotifyPounceData *pounce_data;
169
170 gtk_tree_model_get(model, iter,
171 PIDGIN_POUNCE_DATA, &pounce_data,
172 -1);
173
174 if (pounce_data != NULL)
175 g_free(pounce_data);
176 }
177
178 static void
179 append_to_list(GtkTreeModel *model, GtkTreePath *path,
180 GtkTreeIter *iter, gpointer data)
181 {
182 GList **list = data;
183 *list = g_list_prepend(*list, gtk_tree_path_copy(path));
184 }
185 static void
186 pounce_response_dismiss()
187 {
188 GtkTreeSelection *selection;
189 GList *list = NULL;
190
191 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(pounce_dialog->treeview));
192 gtk_tree_selection_selected_foreach(selection, delete_foreach, pounce_dialog);
193 gtk_tree_selection_selected_foreach(selection, append_to_list, &list);
194
195 while (list) {
196 GtkTreeIter iter;
197 if (gtk_tree_model_get_iter(GTK_TREE_MODEL(pounce_dialog->treemodel), &iter,
198 list->data)) {
199 gtk_tree_store_remove(GTK_TREE_STORE(pounce_dialog->treemodel), &iter);
200 }
201 gtk_tree_path_free(list->data);
202 list = g_list_delete_link(list, list);
203 }
204 }
205
206 static void
207 pounce_response_edit_cb(GtkTreeModel *model, GtkTreePath *path,
208 GtkTreeIter *iter, gpointer data)
209 {
210 PidginNotifyPounceData *pounce_data;
211 PidginNotifyDialog *dialog = (PidginNotifyDialog*)data;
212 PurplePounce *pounce;
213 GList *list;
214
215 list = purple_pounces_get_all();
216
217 gtk_tree_model_get(GTK_TREE_MODEL(dialog->treemodel), iter,
218 PIDGIN_POUNCE_DATA, &pounce_data,
219 -1);
220
221 for (; list != NULL; list = list->next) {
222 pounce = list->data;
223 if (pounce == pounce_data->pounce) {
224 pidgin_pounce_editor_show(pounce_data->account, NULL, pounce_data->pounce);
225 return;
226 }
227 }
228
229 purple_debug_warning("gtknotify", "Pounce was destroyed.\n");
230 }
231
232 static void
233 pounce_response_cb(GtkDialog *dlg, gint id, PidginNotifyDialog *dialog)
234 {
235 GtkTreeSelection *selection = NULL;
236
237 switch (id) {
238 case GTK_RESPONSE_CLOSE:
239 case GTK_RESPONSE_DELETE_EVENT:
240 pounce_response_close(dialog);
241 break;
242 case GTK_RESPONSE_NO:
243 pounce_response_dismiss();
244 break;
245 case GTK_RESPONSE_APPLY:
246 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->treeview));
247 gtk_tree_selection_selected_foreach(selection, pounce_response_edit_cb,
248 dialog);
249 break;
250 }
251 }
252
253 static void
254 pounce_row_selected_cb(GtkTreeView *tv, GtkTreePath *path,
255 GtkTreeViewColumn *col, gpointer data)
256 {
257 GtkTreeIter iter;
258 GtkTreeSelection *selection;
259 gboolean selected;
260 GList *list;
261
262 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(pounce_dialog->treeview));
263
264 selected = gtk_tree_selection_get_selected(selection,
265 NULL, &iter);
266
267 if (selected) {
268 PurplePounce *pounce;
269 PidginNotifyPounceData *pounce_data;
270
271 list = purple_pounces_get_all();
272
273 gtk_tree_model_get(GTK_TREE_MODEL(pounce_dialog->treemodel), &iter,
274 PIDGIN_POUNCE_DATA, &pounce_data,
275 -1);
276
277 gtk_widget_set_sensitive(pounce_dialog->edit_button, FALSE);
278
279 for (; list != NULL; list = list->next) {
280 pounce = list->data;
281 if (pounce == pounce_data->pounce) {
282 gtk_widget_set_sensitive(pounce_dialog->edit_button, TRUE);
283 break;
284 }
285 }
286
287 gtk_widget_set_sensitive(pounce_dialog->dismiss_button, TRUE);
288 } else {
289 gtk_widget_set_sensitive(pounce_dialog->edit_button, FALSE);
290 gtk_widget_set_sensitive(pounce_dialog->dismiss_button, FALSE);
291 }
292
293
109 } 294 }
110 295
111 static void 296 static void
112 email_response_cb(GtkDialog *dlg, gint id, PidginMailDialog *dialog) 297 email_response_cb(GtkDialog *dlg, gint id, PidginMailDialog *dialog)
113 { 298 {
340 } 525 }
341 526
342 static GtkWidget * 527 static GtkWidget *
343 pidgin_get_mail_dialog(void) 528 pidgin_get_mail_dialog(void)
344 { 529 {
345 if (mail_dialog == NULL) { 530 return pidgin_get_notification_dialog(PIDGIN_NOTIFY_MAIL);
346 GtkWidget *dialog = NULL;
347 GtkWidget *label;
348 GtkWidget *sw;
349 GtkCellRenderer *rend;
350 GtkTreeViewColumn *column;
351 GtkWidget *button = NULL;
352 GtkWidget *vbox = NULL;
353
354 dialog = gtk_dialog_new_with_buttons(_("New Mail"), NULL, 0,
355 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
356 NULL);
357 gtk_window_set_role(GTK_WINDOW(dialog), "new_mail_detailed");
358 g_signal_connect(G_OBJECT(dialog), "focus-in-event",
359 G_CALLBACK(mail_window_focus_cb), NULL);
360
361 gtk_dialog_add_button(GTK_DIALOG(dialog),
362 _("Open All Messages"), GTK_RESPONSE_ACCEPT);
363
364 button = gtk_dialog_add_button(GTK_DIALOG(dialog),
365 PIDGIN_STOCK_OPEN_MAIL, GTK_RESPONSE_YES);
366
367 /* make "Open All Messages" the default response */
368 gtk_dialog_set_default_response(GTK_DIALOG(dialog),
369 GTK_RESPONSE_ACCEPT);
370
371 /* Setup the dialog */
372 gtk_container_set_border_width(GTK_CONTAINER(dialog), PIDGIN_HIG_BOX_SPACE);
373 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), PIDGIN_HIG_BOX_SPACE);
374 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
375 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), PIDGIN_HIG_BORDER);
376
377 /* Vertical box */
378 vbox = GTK_DIALOG(dialog)->vbox;
379
380 /* Golden ratio it up! */
381 gtk_widget_set_size_request(dialog, 550, 400);
382
383 sw = gtk_scrolled_window_new(NULL, NULL);
384 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN);
385 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
386
387 mail_dialog = g_new0(PidginMailDialog, 1);
388 mail_dialog->dialog = dialog;
389 mail_dialog->open_button = button;
390
391 mail_dialog->treemodel = gtk_tree_store_new(COLUMNS_PIDGIN_MAIL,
392 GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_POINTER);
393 mail_dialog->treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(mail_dialog->treemodel));
394 g_object_unref(G_OBJECT(mail_dialog->treemodel));
395 gtk_tree_view_set_search_column(GTK_TREE_VIEW(mail_dialog->treeview), PIDGIN_MAIL_TEXT);
396 gtk_tree_view_set_search_equal_func(GTK_TREE_VIEW(mail_dialog->treeview),
397 pidgin_tree_view_search_equal_func, NULL, NULL);
398
399 g_signal_connect(G_OBJECT(dialog), "response",
400 G_CALLBACK(email_response_cb), mail_dialog);
401 g_signal_connect(G_OBJECT(gtk_tree_view_get_selection(GTK_TREE_VIEW(mail_dialog->treeview))),
402 "changed", G_CALLBACK(selection_changed_cb), mail_dialog);
403 g_signal_connect(G_OBJECT(mail_dialog->treeview), "row-activated", G_CALLBACK(email_row_activated_cb), NULL);
404
405 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(mail_dialog->treeview), FALSE);
406 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(mail_dialog->treeview), TRUE);
407 gtk_container_add(GTK_CONTAINER(sw), mail_dialog->treeview);
408
409 column = gtk_tree_view_column_new();
410 gtk_tree_view_column_set_resizable(column, TRUE);
411 rend = gtk_cell_renderer_pixbuf_new();
412 gtk_tree_view_column_pack_start(column, rend, FALSE);
413 gtk_tree_view_column_set_attributes(column, rend, "pixbuf", PIDGIN_MAIL_ICON, NULL);
414 rend = gtk_cell_renderer_text_new();
415 gtk_tree_view_column_pack_start(column, rend, TRUE);
416 gtk_tree_view_column_set_attributes(column, rend, "markup", PIDGIN_MAIL_TEXT, NULL);
417 gtk_tree_view_append_column(GTK_TREE_VIEW(mail_dialog->treeview), column);
418
419 label = gtk_label_new(NULL);
420 gtk_label_set_markup(GTK_LABEL(label), _("<span weight=\"bold\" size=\"larger\">You have mail!</span>"));
421 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
422 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
423 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
424 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0);
425 }
426
427 return mail_dialog->dialog;
428 } 531 }
429 532
430 /* count == 0 means this is a detailed mail notification. 533 /* count == 0 means this is a detailed mail notification.
431 * count > 0 mean non-detailed. 534 * count > 0 mean non-detailed.
432 */ 535 */
999 { 1102 {
1000 if (type == PURPLE_NOTIFY_EMAIL || type == PURPLE_NOTIFY_EMAILS) 1103 if (type == PURPLE_NOTIFY_EMAIL || type == PURPLE_NOTIFY_EMAILS)
1001 { 1104 {
1002 PidginNotifyMailData *data = (PidginNotifyMailData *)ui_handle; 1105 PidginNotifyMailData *data = (PidginNotifyMailData *)ui_handle;
1003 1106
1004 g_free(data->url); 1107 if (data) {
1005 g_free(data); 1108 g_free(data->url);
1109 g_free(data);
1110 }
1006 } 1111 }
1007 else if (type == PURPLE_NOTIFY_SEARCHRESULTS) 1112 else if (type == PURPLE_NOTIFY_SEARCHRESULTS)
1008 { 1113 {
1009 PidginNotifySearchResultsData *data = (PidginNotifySearchResultsData *)ui_handle; 1114 PidginNotifySearchResultsData *data = (PidginNotifySearchResultsData *)ui_handle;
1010 1115
1233 #else /* !_WIN32 */ 1338 #else /* !_WIN32 */
1234 winpidgin_notify_uri(uri); 1339 winpidgin_notify_uri(uri);
1235 #endif /* !_WIN32 */ 1340 #endif /* !_WIN32 */
1236 1341
1237 return NULL; 1342 return NULL;
1343 }
1344
1345 static GtkWidget *
1346 pidgin_get_dialog(PidginNotifyType type, GtkTreeStore *treemodel)
1347 {
1348 GtkWidget *dialog = NULL;
1349 GtkWidget *label = NULL;
1350 GtkWidget *sw;
1351 GtkCellRenderer *rend;
1352 GtkTreeViewColumn *column;
1353 GtkWidget *button = NULL;
1354 GtkWidget *vbox = NULL;
1355 GtkTreeSelection *sel;
1356 PidginNotifyDialog *spec_dialog = NULL;
1357
1358 g_return_val_if_fail(type < PIDGIN_NOTIFY_TYPES, NULL);
1359
1360 dialog = gtk_dialog_new_with_buttons(NULL, NULL, 0,
1361 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
1362 NULL);
1363
1364 /* Setup the dialog */
1365 gtk_container_set_border_width(GTK_CONTAINER(dialog), PIDGIN_HIG_BOX_SPACE);
1366 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), PIDGIN_HIG_BOX_SPACE);
1367 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
1368 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), PIDGIN_HIG_BORDER);
1369
1370 /* Vertical box */
1371 vbox = GTK_DIALOG(dialog)->vbox;
1372
1373 /* Golden ratio it up! */
1374 gtk_widget_set_size_request(dialog, 550, 400);
1375
1376 sw = gtk_scrolled_window_new(NULL, NULL);
1377 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN);
1378 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
1379
1380 spec_dialog = g_new0(PidginNotifyDialog, 1);
1381 spec_dialog->dialog = dialog;
1382 spec_dialog->open_button = button;
1383
1384 spec_dialog->treemodel = treemodel;
1385 spec_dialog->treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(spec_dialog->treemodel));
1386 g_object_unref(G_OBJECT(spec_dialog->treemodel));
1387
1388 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(spec_dialog->treeview), TRUE);
1389 gtk_container_add(GTK_CONTAINER(sw), spec_dialog->treeview);
1390
1391 if (type == PIDGIN_NOTIFY_MAIL) {
1392 gtk_window_set_title(GTK_WINDOW(dialog), _("New Mail"));
1393 gtk_window_set_role(GTK_WINDOW(dialog), "new_mail_detailed");
1394 g_signal_connect(G_OBJECT(dialog), "focus-in-event",
1395 G_CALLBACK(mail_window_focus_cb), NULL);
1396
1397 gtk_dialog_add_button(GTK_DIALOG(dialog),
1398 _("Open All Messages"), GTK_RESPONSE_ACCEPT);
1399
1400 button = gtk_dialog_add_button(GTK_DIALOG(dialog),
1401 PIDGIN_STOCK_OPEN_MAIL, GTK_RESPONSE_YES);
1402
1403 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(spec_dialog->treeview), FALSE);
1404
1405 gtk_tree_view_set_search_column(GTK_TREE_VIEW(spec_dialog->treeview), PIDGIN_MAIL_TEXT);
1406 gtk_tree_view_set_search_equal_func(GTK_TREE_VIEW(spec_dialog->treeview),
1407 pidgin_tree_view_search_equal_func, NULL, NULL);
1408
1409 g_signal_connect(G_OBJECT(dialog), "response",
1410 G_CALLBACK(email_response_cb), spec_dialog);
1411 g_signal_connect(G_OBJECT(gtk_tree_view_get_selection(GTK_TREE_VIEW(spec_dialog->treeview))),
1412 "changed", G_CALLBACK(selection_changed_cb), spec_dialog);
1413 g_signal_connect(G_OBJECT(spec_dialog->treeview), "row-activated", G_CALLBACK(email_row_activated_cb), NULL);
1414
1415 column = gtk_tree_view_column_new();
1416 gtk_tree_view_column_set_resizable(column, TRUE);
1417 rend = gtk_cell_renderer_pixbuf_new();
1418 gtk_tree_view_column_pack_start(column, rend, FALSE);
1419
1420 gtk_tree_view_column_set_attributes(column, rend, "pixbuf", PIDGIN_MAIL_ICON, NULL);
1421 rend = gtk_cell_renderer_text_new();
1422 gtk_tree_view_column_pack_start(column, rend, TRUE);
1423 gtk_tree_view_column_set_attributes(column, rend, "markup", PIDGIN_MAIL_TEXT, NULL);
1424 gtk_tree_view_append_column(GTK_TREE_VIEW(spec_dialog->treeview), column);
1425
1426 label = gtk_label_new(NULL);
1427 gtk_label_set_markup(GTK_LABEL(label), _("<span weight=\"bold\" size=\"larger\">You have mail!</span>"));
1428
1429 } else if (type == PIDGIN_NOTIFY_POUNCE) {
1430 gtk_window_set_title(GTK_WINDOW(dialog), _("New Pounces"));
1431
1432 button = gtk_dialog_add_button(GTK_DIALOG(dialog),
1433 _("Dismiss"), GTK_RESPONSE_NO);
1434 gtk_widget_set_sensitive(button, FALSE);
1435 spec_dialog->dismiss_button = button;
1436
1437 button = gtk_dialog_add_button(GTK_DIALOG(dialog),
1438 PIDGIN_STOCK_EDIT, GTK_RESPONSE_APPLY);
1439 gtk_widget_set_sensitive(button, FALSE);
1440 spec_dialog->edit_button = button;
1441
1442 g_signal_connect(G_OBJECT(dialog), "response",
1443 G_CALLBACK(pounce_response_cb), spec_dialog);
1444
1445 column = gtk_tree_view_column_new();
1446 gtk_tree_view_column_set_title(column, _("Buddy"));
1447 gtk_tree_view_column_set_resizable(column, TRUE);
1448 rend = gtk_cell_renderer_pixbuf_new();
1449 gtk_tree_view_column_pack_start(column, rend, FALSE);
1450
1451 gtk_tree_view_column_set_attributes(column, rend, "pixbuf", PIDGIN_POUNCE_ICON, NULL);
1452 rend = gtk_cell_renderer_text_new();
1453 gtk_tree_view_column_pack_start(column, rend, FALSE);
1454 gtk_tree_view_column_add_attribute(column, rend, "text", PIDGIN_POUNCE_ALIAS);
1455 gtk_tree_view_append_column(GTK_TREE_VIEW(spec_dialog->treeview), column);
1456
1457 column = gtk_tree_view_column_new();
1458 gtk_tree_view_column_set_title(column, _("Event"));
1459 gtk_tree_view_column_set_resizable(column, TRUE);
1460 rend = gtk_cell_renderer_text_new();
1461 gtk_tree_view_column_pack_start(column, rend, FALSE);
1462 gtk_tree_view_column_add_attribute(column, rend, "text", PIDGIN_POUNCE_EVENT);
1463 gtk_tree_view_append_column(GTK_TREE_VIEW(spec_dialog->treeview), column);
1464
1465 column = gtk_tree_view_column_new();
1466 gtk_tree_view_column_set_title(column, _("Message"));
1467 gtk_tree_view_column_set_resizable(column, TRUE);
1468 rend = gtk_cell_renderer_text_new();
1469 gtk_tree_view_column_pack_start(column, rend, FALSE);
1470 gtk_tree_view_column_add_attribute(column, rend, "text", PIDGIN_POUNCE_TEXT);
1471 gtk_tree_view_append_column(GTK_TREE_VIEW(spec_dialog->treeview), column);
1472
1473 column = gtk_tree_view_column_new();
1474 gtk_tree_view_column_set_title(column, _("Date"));
1475 gtk_tree_view_column_set_resizable(column, TRUE);
1476 rend = gtk_cell_renderer_text_new();
1477 gtk_tree_view_column_pack_start(column, rend, FALSE);
1478 gtk_tree_view_column_add_attribute(column, rend, "text", PIDGIN_POUNCE_DATE);
1479 gtk_tree_view_append_column(GTK_TREE_VIEW(spec_dialog->treeview), column);
1480
1481 label = gtk_label_new(NULL);
1482 gtk_label_set_markup(GTK_LABEL(label), _("<span weight=\"bold\" size=\"larger\">You have pounced!</span>"));
1483
1484 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(spec_dialog->treeview));
1485 gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);
1486 g_signal_connect(G_OBJECT(sel), "changed",
1487 G_CALLBACK(pounce_row_selected_cb), NULL);
1488 }
1489
1490 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
1491 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
1492 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
1493 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 2);
1494
1495 if (type == PIDGIN_NOTIFY_MAIL)
1496 mail_dialog = spec_dialog;
1497 else if (type == PIDGIN_NOTIFY_POUNCE) {
1498 pounce_dialog = spec_dialog;
1499 }
1500
1501 return spec_dialog->dialog;
1502
1503 }
1504
1505 void
1506 pidgin_notify_pounce_add(PurpleAccount *account, PurplePounce *pounce,
1507 const char *alias, const char *event, const char *message, const char *date)
1508 {
1509 GtkWidget *dialog;
1510 GdkPixbuf *icon;
1511 GtkTreeIter iter;
1512 PidginNotifyPounceData *pounce_data;
1513
1514 dialog = pidgin_get_notification_dialog(PIDGIN_NOTIFY_POUNCE);
1515
1516 icon = pidgin_create_prpl_icon(account, PIDGIN_PRPL_ICON_SMALL);
1517
1518 pounce_data = g_new(PidginNotifyPounceData, 1);
1519
1520 pounce_data->account = account;
1521 pounce_data->pounce = pounce;
1522
1523 gtk_tree_store_append(pounce_dialog->treemodel, &iter, NULL);
1524
1525 gtk_tree_store_set(pounce_dialog->treemodel, &iter,
1526 PIDGIN_POUNCE_ICON, icon,
1527 PIDGIN_POUNCE_ALIAS, alias,
1528 PIDGIN_POUNCE_EVENT, event,
1529 PIDGIN_POUNCE_TEXT, (message != NULL)? message : _("No message"),
1530 PIDGIN_POUNCE_DATE, date,
1531 PIDGIN_POUNCE_DATA, pounce_data,
1532 -1);
1533
1534 if (icon)
1535 g_object_unref(icon);
1536
1537 gtk_widget_show_all(dialog);
1538
1539 return;
1540 }
1541
1542 static GtkWidget *
1543 pidgin_get_notification_dialog(PidginNotifyType type)
1544 {
1545 GtkTreeStore *model = NULL;
1546
1547 if (type == PIDGIN_NOTIFY_MAIL) {
1548 if (mail_dialog != NULL)
1549 return mail_dialog->dialog;
1550
1551 model = gtk_tree_store_new(COLUMNS_PIDGIN_MAIL,
1552 GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_POINTER);
1553
1554 } else if (type == PIDGIN_NOTIFY_POUNCE) {
1555
1556 if (pounce_dialog != NULL)
1557 return pounce_dialog->dialog;
1558
1559 model = gtk_tree_store_new(PIDGIN_POUNCE_COLUMNS,
1560 GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
1561 G_TYPE_STRING, G_TYPE_POINTER);
1562 }
1563
1564 return pidgin_get_dialog(type, model);
1238 } 1565 }
1239 1566
1240 static PurpleNotifyUiOps ops = 1567 static PurpleNotifyUiOps ops =
1241 { 1568 {
1242 pidgin_notify_message, 1569 pidgin_notify_message,