Revision 3211

View differences:

src/inc.c
1 1
/*
2 2
 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3
 * Copyright (C) 1999-2012 Hiroyuki Yamamoto
3
 * Copyright (C) 1999-2013 Hiroyuki Yamamoto
4 4
 *
5 5
 * This program is free software; you can redistribute it and/or modify
6 6
 * it under the terms of the GNU General Public License as published by
......
58 58
#include "progressdialog.h"
59 59
#include "alertpanel.h"
60 60
#include "trayicon.h"
61
#include "notificationwindow.h"
61 62
#include "filter.h"
62 63
#include "folder.h"
63 64
#include "procheader.h"
......
70 71
	gint new_messages;
71 72
} IncAccountNewMsgCount;
72 73

  
74
typedef struct _IncMsgSummary
75
{
76
	gchar *subject;
77
	gchar *from;
78
} IncMsgSummary;
73 79

  
80
struct _IncResult
81
{
82
	GSList *count_list;
83
	GSList *msg_summaries;
84
};
85

  
86

  
74 87
static GList *inc_dialog_list = NULL;
75 88

  
76 89
static gboolean inc_is_running = FALSE;
......
84 97

  
85 98

  
86 99
static void inc_finished		(MainWindow		*mainwin,
87
					 GSList			*msg_counts);
100
					 IncResult		*result);
88 101
static GSList *inc_add_message_count	(GSList			*list,
89 102
					 PrefsAccount		*account,
90 103
					 gint			 new_messages);
104
static void inc_result_free		(IncResult		*result,
105
					 gboolean		 free_self);
91 106

  
92 107
static gint inc_remote_account_mail	(MainWindow		*mainwin,
93 108
					 PrefsAccount		*account);
94 109
static gint inc_account_mail_real	(MainWindow		*mainwin,
95
					 PrefsAccount		*account);
110
					 PrefsAccount		*account,
111
					 IncResult		*result);
96 112

  
97 113
static IncProgressDialog *inc_progress_dialog_create
98 114
					(gboolean		 autocheck);
......
101 117

  
102 118
static IncSession *inc_session_new	(PrefsAccount		*account);
103 119
static void inc_session_destroy		(IncSession		*session);
104
static gint inc_start			(IncProgressDialog	*inc_dialog,
105
					 GSList		       **count_list);
120
static gint inc_start			(IncProgressDialog	*inc_dialog);
106 121
static IncState inc_pop3_session_do	(IncSession		*session);
107 122

  
108 123
static void inc_progress_dialog_update	(IncProgressDialog	*inc_dialog,
......
161 176
/**
162 177
 * inc_finished:
163 178
 * @mainwin: Main window.
164
 * @msg_counts: GSList of Number of received messages for each account.
179
 * @result: Information of incorporation result.
165 180
 * @new_messages: Number of received messages.
166 181
 * 
167 182
 * Update the folder view and the summary view after receiving
168 183
 * messages.  If @new_messages is 0, this function avoids unneeded
169 184
 * updating.
170 185
 **/
171
static void inc_finished(MainWindow *mainwin, GSList *msg_counts)
186
static void inc_finished(MainWindow *mainwin, IncResult *result)
172 187
{
173 188
	FolderItem *item;
174 189
	gint new_messages = 0;
......
176 191
	IncAccountNewMsgCount *count;
177 192
	GSList *cur;
178 193

  
179
	for (cur = msg_counts; cur != NULL; cur = cur->next) {
180
		count = cur->data;
181
		if (count->new_messages > 0)
182
			new_messages += count->new_messages;
194
	if (result) {
195
		for (cur = result->count_list; cur != NULL; cur = cur->next) {
196
			count = cur->data;
197
			if (count->new_messages > 0)
198
				new_messages += count->new_messages;
199
		}
183 200
	}
184 201

  
185 202
	debug_print("inc_finished: %d new message(s)\n", new_messages);
......
190 207
	}
191 208

  
192 209
	if (new_messages > 0 && !block_notify) {
210
		gchar buf[1024];
193 211
		GString *str;
194 212
		gint c = 0;
195 213

  
196 214
		str = g_string_new("");
197 215
		g_string_printf(str, _("Sylpheed: %d new messages"),
198 216
				new_messages);
199
		if (msg_counts) {
200
			for (cur = msg_counts; cur != NULL; cur = cur->next) {
217
		if (result) {
218
			for (cur = result->count_list; cur != NULL; cur = cur->next) {
201 219
				count = cur->data;
202 220
				if (count->new_messages > 0) {
203 221
					if (c == 0)
......
214 232
		debug_print("inc_finished: %s\n", str->str);
215 233
		trayicon_set_tooltip(str->str);
216 234
		trayicon_set_notify(TRUE);
235

  
236
		g_snprintf(buf, sizeof(buf), _("Sylpheed: %d new messages"), new_messages);
237
		g_string_truncate(str, 0);
238
		if (result) {
239
			for (cur = result->msg_summaries; cur != NULL; cur = cur->next) {
240
				IncMsgSummary *summary = cur->data;
241
				gchar *markup;
242

  
243
				if (str->len > 0)
244
					g_string_append_c(str, '\n');
245
				markup = g_markup_printf_escaped("<b>%s</b>  %s", summary->subject, summary->from);
246
				g_string_append(str, markup);
247
				g_free(markup);
248
			}
249
		}
250

  
251
		notification_window_create(buf, str->str, 5);
252

  
217 253
		g_string_free(str, TRUE);
218 254
	}
219 255

  
......
271 307
	return g_slist_append(list, count);
272 308
}
273 309

  
310
static void inc_result_free(IncResult *result, gboolean free_self)
311
{
312
	GSList *cur;
313

  
314
	slist_free_strings(result->count_list);
315
	g_slist_free(result->count_list);
316
	for (cur = result->msg_summaries; cur != NULL; cur = cur->next) {
317
		IncMsgSummary *sum = cur->data;
318
		g_free(sum->subject);
319
		g_free(sum->from);
320
		g_free(sum);
321
	}
322
	g_slist_free(result->msg_summaries);
323

  
324
	if (free_self)
325
		g_free(result);
326
}
327

  
274 328
void inc_mail(MainWindow *mainwin)
275 329
{
330
	IncResult result = {NULL, NULL};
276 331
	gint new_msgs = 0;
277
	GSList *list = NULL;
278 332

  
279 333
	if (inc_lock_count) return;
280 334
	if (inc_is_active()) return;
......
301 355

  
302 356
		if (prefs_common.inc_local) {
303 357
			new_msgs = inc_spool();
304
			list = inc_add_message_count(list, NULL, new_msgs);
358
			result.count_list = inc_add_message_count(result.count_list, NULL, new_msgs);
305 359
		}
306 360
	} else {
307 361
		if (prefs_common.inc_local) {
308 362
			new_msgs = inc_spool();
309 363
			if (new_msgs < 0)
310 364
				new_msgs = 0;
311
			list = inc_add_message_count(list, NULL, new_msgs);
365
			result.count_list = inc_add_message_count(result.count_list, NULL, new_msgs);
312 366
		}
313 367

  
314
		new_msgs = inc_account_mail_real(mainwin, cur_account);
315
		list = inc_add_message_count(list, cur_account, new_msgs);
368
		new_msgs = inc_account_mail_real(mainwin, cur_account, &result);
316 369
	}
317 370

  
318
	inc_finished(mainwin, list);
319
	slist_free_strings(list);
320
	g_slist_free(list);
371
	inc_finished(mainwin, &result);
372
	inc_result_free(&result, FALSE);
321 373

  
322 374
	inc_is_running = FALSE;
323 375

  
......
455 507
	return new_msgs;
456 508
}
457 509

  
458
static gint inc_account_mail_real(MainWindow *mainwin, PrefsAccount *account)
510
static gint inc_account_mail_real(MainWindow *mainwin, PrefsAccount *account,
511
				  IncResult *result)
459 512
{
460 513
	IncProgressDialog *inc_dialog;
461 514
	IncSession *session;
......
471 524
	inc_dialog = inc_progress_dialog_create(FALSE);
472 525
	inc_dialog->queue_list = g_list_append(inc_dialog->queue_list, session);
473 526
	inc_dialog->mainwin = mainwin;
527
	inc_dialog->result = result;
474 528
	inc_progress_dialog_set_list(inc_dialog);
475 529

  
476 530
	main_window_set_toolbar_sensitive(mainwin);
477 531
	main_window_set_menu_sensitive(mainwin);
478 532

  
479
	return inc_start(inc_dialog, NULL);
533
	return inc_start(inc_dialog);
480 534
}
481 535

  
482 536
gint inc_account_mail(MainWindow *mainwin, PrefsAccount *account)
483 537
{
538
	IncResult result = {NULL, NULL};
484 539
	gint new_msgs;
485
	GSList *list;
486 540

  
487 541
	if (inc_lock_count) return 0;
488 542
	if (inc_is_active()) return 0;
......
498 552

  
499 553
	syl_plugin_signal_emit("inc-mail-start", account);
500 554

  
501
	new_msgs = inc_account_mail_real(mainwin, account);
555
	new_msgs = inc_account_mail_real(mainwin, account, &result);
502 556

  
503
	list = inc_add_message_count(NULL, account, new_msgs);
504
	inc_finished(mainwin, list);
505
	slist_free_strings(list);
506
	g_slist_free(list);
557
	inc_finished(mainwin, &result);
558
	inc_result_free(&result, FALSE);
507 559

  
508 560
	inc_is_running = FALSE;
509 561

  
......
517 569
{
518 570
	GList *list, *queue_list = NULL;
519 571
	IncProgressDialog *inc_dialog;
520
	GSList *count_list = NULL;
572
	IncResult result = {NULL, NULL};
521 573
	gint new_msgs = 0;
522 574

  
523 575
	if (inc_lock_count) return;
......
538 590
		new_msgs = inc_spool();
539 591
		if (new_msgs < 0)
540 592
			new_msgs = 0;
541
		count_list = inc_add_message_count(count_list, NULL, new_msgs);
593
		result.count_list = inc_add_message_count(result.count_list, NULL, new_msgs);
542 594
	}
543 595

  
544 596
	/* check IMAP4 / News folders */
......
547 599
		if ((account->protocol == A_IMAP4 ||
548 600
		     account->protocol == A_NNTP) && account->recv_at_getall) {
549 601
			new_msgs = inc_remote_account_mail(mainwin, account);
550
			count_list = inc_add_message_count(count_list, account, new_msgs);
602
			result.count_list = inc_add_message_count(result.count_list, account, new_msgs);
551 603
		}
552 604
	}
553 605

  
......
567 619
		inc_dialog = inc_progress_dialog_create(autocheck);
568 620
		inc_dialog->queue_list = queue_list;
569 621
		inc_dialog->mainwin = mainwin;
622
		inc_dialog->result = &result;
570 623
		inc_progress_dialog_set_list(inc_dialog);
571 624

  
572 625
		main_window_set_toolbar_sensitive(mainwin);
573 626
		main_window_set_menu_sensitive(mainwin);
574 627

  
575
		inc_start(inc_dialog, &count_list);
628
		inc_start(inc_dialog);
576 629
	}
577 630

  
578
	inc_finished(mainwin, count_list);
579
	slist_free_strings(count_list);
580
	g_slist_free(count_list);
631
	inc_finished(mainwin, &result);
632
	inc_result_free(&result, FALSE);
581 633

  
582 634
	inc_is_running = FALSE;
583 635

  
......
612 664
			     _("Authenticating with POP3"));
613 665
	inc_dialog->queue_list = g_list_append(inc_dialog->queue_list, session);
614 666
	inc_dialog->mainwin = mainwin;
667
	inc_dialog->result = NULL;
615 668
	inc_progress_dialog_set_list(inc_dialog);
616 669
	inc_dialog->show_dialog = TRUE;
617 670

  
618 671
	main_window_set_toolbar_sensitive(mainwin);
619 672
	main_window_set_menu_sensitive(mainwin);
620 673

  
621
	inc_start(inc_dialog, NULL);
674
	inc_start(inc_dialog);
622 675

  
623 676
	inc_is_running = FALSE;
624 677

  
......
776 829
	folderview_update_item_foreach(table, TRUE);
777 830
}
778 831

  
779
static gint inc_start(IncProgressDialog *inc_dialog, GSList **count_list)
832
static gint inc_start(IncProgressDialog *inc_dialog)
780 833
{
781 834
	IncSession *session;
782 835
	GList *qlist;
......
903 956
			break;
904 957
		}
905 958

  
906
		if (count_list)
907
			*count_list = inc_add_message_count(*count_list, pop3_session->ac_prefs, session->new_msgs);
959
		if (inc_dialog->result)
960
			inc_dialog->result->count_list = inc_add_message_count(inc_dialog->result->count_list, pop3_session->ac_prefs, session->new_msgs);
908 961
		new_msgs += session->new_msgs;
909 962

  
910 963
		if (!prefs_common.scan_all_after_inc) {
......
1394 1447
	return 0;
1395 1448
}
1396 1449

  
1450
/**
1451
 * inc_drop_message:
1452
 * @session: Current Pop3Session.
1453
 * @file: Received message file.
1454
 * 
1455
 * Callback function to drop received message into local mailbox.
1456
 *
1457
 * Return value: DROP_OK if succeeded. DROP_ERROR if error occurred.
1458
 *   DROP_DONT_RECEIVE if the message should be skipped.
1459
 *   DROP_DELETE if the message should be deleted.
1460
 **/
1397 1461
static gint inc_drop_message(Pop3Session *session, const gchar *file)
1398 1462
{
1399 1463
	FolderItem *inbox;
......
1404 1468
	gint val;
1405 1469
	gboolean is_junk = FALSE;
1406 1470
	gboolean is_counted = FALSE;
1471
	IncProgressDialog *inc_dialog;
1407 1472

  
1408 1473
	g_return_val_if_fail(inc_session != NULL, DROP_ERROR);
1409 1474

  
1410 1475
	gdk_threads_enter();
1411 1476

  
1477
	inc_dialog = (IncProgressDialog *)inc_session->data;
1478

  
1412 1479
	if (session->ac_prefs->inbox) {
1413 1480
		inbox = folder_find_item_from_identifier
1414 1481
			(session->ac_prefs->inbox);
......
1521 1588
	else {
1522 1589
		val = DROP_OK;
1523 1590
		if (!is_junk && is_counted &&
1524
		    fltinfo->actions[FLT_ACTION_MARK_READ] == FALSE)
1591
		    fltinfo->actions[FLT_ACTION_MARK_READ] == FALSE) {
1525 1592
			inc_session->new_msgs++;
1593

  
1594
			if (inc_dialog->result && msginfo->subject && g_slist_length(inc_dialog->result->msg_summaries) < 5) {
1595
				IncMsgSummary *summary;
1596
				summary = g_new(IncMsgSummary, 1);
1597
				summary->subject = g_strdup(msginfo->subject);
1598
				summary->from = g_strdup(msginfo->fromname);
1599
				inc_dialog->result->msg_summaries = g_slist_append(inc_dialog->result->msg_summaries, summary);
1600
			}
1601
		}
1526 1602
	}
1527 1603

  
1528 1604
	procmsg_msginfo_free(msginfo);
src/inc.h
32 32
#include "session.h"
33 33
#include "pop.h"
34 34

  
35
typedef struct _IncResult		IncResult;
35 36
typedef struct _IncProgressDialog	IncProgressDialog;
36 37
typedef struct _IncSession		IncSession;
37 38

  
......
64 65

  
65 66
	GList *queue_list;	/* list of IncSession */
66 67
	gint cur_row;
68

  
69
	IncResult *result;
67 70
};
68 71

  
69 72
struct _IncSession
src/notificationwindow.c
1
/*
2
 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3
 * Copyright (C) 1999-2013 Hiroyuki Yamamoto
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation; either version 2 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
 */
19

  
20
#ifdef HAVE_CONFIG_H
21
#  include "config.h"
22
#endif
23

  
24
#include <glib.h>
25
#include <glib/gi18n.h>
26
#include <gtk/gtk.h>
27

  
28
#ifdef G_OS_WIN32
29
#  include <windows.h>
30
#endif
31

  
32
#include "notificationwindow.h"
33
#include "mainwindow.h"
34
#include "utils.h"
35

  
36
#define NOTIFICATIONWINDOW_NOTIFY_PERIOD	10000
37
#define NOTIFICATIONWINDOW_WIDTH		280
38
#define NOTIFICATIONWINDOW_HEIGHT		96
39
#define FADE_REFRESH_RATE			50
40
#define FADE_SPEED				5
41

  
42
struct _NotificationWindow
43
{
44
	GtkWidget *window;
45

  
46
	GtkWidget *msglabel;
47
	GtkWidget *sublabel;
48

  
49
	guint notify_tag;
50

  
51
	gint x;
52
	gint y;
53
	gint width;
54
	gint height;
55
	gint fade_length;
56
	gint fade_count;
57
	guint timeout;
58
};
59

  
60
static NotificationWindow notify_window;
61

  
62
static void notification_window_destroy(void);
63

  
64
static gboolean notify_timeout_cb(gpointer	 data);
65

  
66
static gboolean nwin_button_pressed	(GtkWidget	*widget,
67
					 GdkEventButton	*event,
68
					 gpointer	 data);
69
static gboolean nwin_entered		(GtkWidget	*widget,
70
					 GdkEventCrossing *event,
71
					 gpointer	 data);
72
static gboolean nwin_motion_notify	(GtkWidget	*widget,
73
					 GdkEventMotion *event,
74
					 gpointer	 data);
75

  
76
static void nwin_destroy_cb	(GtkWidget	*widget,
77
				 gpointer	 data);
78

  
79

  
80
static void get_work_area(GdkRectangle *rect)
81
{
82
#ifdef G_OS_WIN32
83
	RECT rc;
84

  
85
	SystemParametersInfoW(SPI_GETWORKAREA, 0, &rc, 0);
86
	rect->x = rc.left;
87
	rect->y = rc.top;
88
	rect->width = rc.right - rc.left;
89
	rect->height = rc.bottom - rc.top;
90
#else
91
	rect->x = 0;
92
	rect->y = 0;
93
	rect->width = gdk_screen_width();
94
	rect->height = gdk_screen_height();
95
#endif
96
}
97

  
98
gint notification_window_create(const gchar *message, const gchar *submessage,
99
				guint timeout)
100
{
101
	GtkWidget *window;
102
	GtkWidget *vbox;
103
	GtkWidget *msglabel;
104
	GtkWidget *sublabel;
105
	GdkRectangle rect;
106
	gint x, y;
107
	GtkRequisition requisition;
108

  
109
	if (notify_window.window) {
110
		notification_window_destroy();
111
	}
112

  
113
	window = gtk_window_new(GTK_WINDOW_POPUP);
114
	gtk_window_set_title(GTK_WINDOW(window), _("Notification"));
115
	gtk_window_set_wmclass(GTK_WINDOW(window), "notification", "Sylpheed");
116
	gtk_container_set_border_width(GTK_CONTAINER(window), 4);
117
	gtk_widget_set_events(window, GDK_EXPOSURE_MASK|GDK_BUTTON_MOTION_MASK|GDK_POINTER_MOTION_MASK|GDK_POINTER_MOTION_HINT_MASK|GDK_BUTTON_PRESS_MASK|GDK_BUTTON_RELEASE_MASK|GDK_ENTER_NOTIFY_MASK|GDK_LEAVE_NOTIFY_MASK);
118
	gtk_window_set_skip_taskbar_hint(GTK_WINDOW(window), TRUE);
119
	gtk_window_set_gravity(GTK_WINDOW(window), GDK_GRAVITY_SOUTH_EAST);
120
	gtk_widget_set_size_request(window, NOTIFICATIONWINDOW_WIDTH, -1);
121
	gtk_widget_realize(window);
122
	gdk_window_set_type_hint(window->window, GDK_WINDOW_TYPE_HINT_NOTIFICATION);
123

  
124
	/* move window bottom-right */
125
	get_work_area(&rect);
126
	x = rect.x + rect.width - NOTIFICATIONWINDOW_WIDTH - 2;
127
	if (x < 0) x = 0;
128
	y = rect.y + rect.height - NOTIFICATIONWINDOW_HEIGHT - 2;
129
	if (y < 0) y = 0;
130
	gtk_window_move(GTK_WINDOW(window), x, y);
131

  
132
	g_signal_connect(G_OBJECT(window), "destroy",
133
			 G_CALLBACK(nwin_destroy_cb), NULL);
134
	g_signal_connect(G_OBJECT(window), "button_press_event",
135
			 G_CALLBACK(nwin_button_pressed), NULL);
136
	g_signal_connect(G_OBJECT(window), "enter_notify_event",
137
			 G_CALLBACK(nwin_entered), NULL);
138
	g_signal_connect(G_OBJECT(window), "motion_notify_event",
139
			 G_CALLBACK(nwin_motion_notify), NULL);
140

  
141
	vbox = gtk_vbox_new(FALSE, 4);
142
	gtk_container_add(GTK_CONTAINER(window), vbox);
143

  
144
	msglabel = gtk_label_new(message);
145
	gtk_box_pack_start(GTK_BOX(vbox), msglabel, FALSE, FALSE, 4);
146

  
147
	sublabel = gtk_label_new("");
148
	gtk_label_set_ellipsize(GTK_LABEL(sublabel), PANGO_ELLIPSIZE_END);
149
	gtk_label_set_markup(GTK_LABEL(sublabel), submessage);
150
	gtk_box_pack_start(GTK_BOX(vbox), sublabel, FALSE, FALSE, 4);
151

  
152
	gtk_widget_show_all(window);
153

  
154
	/* adjust window size and position */
155
	gtk_widget_get_child_requisition(window, &requisition);
156
	notify_window.width = NOTIFICATIONWINDOW_WIDTH;
157
	notify_window.height = MAX(requisition.height, NOTIFICATIONWINDOW_HEIGHT);
158
	gtk_widget_set_size_request(window, NOTIFICATIONWINDOW_WIDTH, notify_window.height);
159
	y = rect.y + rect.height - notify_window.height - 2;
160
	if (y < 0) y = 0;
161
	gtk_window_move(GTK_WINDOW(window), x, y);
162

  
163
	notify_window.notify_tag = g_timeout_add(timeout * 1000,
164
						 notify_timeout_cb, NULL);
165

  
166
	debug_print("notification window created\n");
167

  
168
	notify_window.window = window;
169
	notify_window.msglabel = msglabel;
170
	notify_window.sublabel = sublabel;
171
	notify_window.x = x;
172
	notify_window.y = y;
173
	notify_window.fade_length = 0;
174
	notify_window.fade_count = 0;
175
	notify_window.timeout = timeout;
176

  
177
	return 0;
178
}
179

  
180
void notification_window_set_message(const gchar *message,
181
				     const gchar *submessage)
182
{
183
	gtk_label_set_text(GTK_LABEL(notify_window.msglabel), message);
184
	gtk_label_set_markup(GTK_LABEL(notify_window.sublabel), submessage);
185
}
186

  
187
void notification_window_close(void)
188
{
189
	notification_window_destroy();
190
}
191

  
192
static void notification_window_destroy(void)
193
{
194
	if (notify_window.window) {
195
		if (notify_window.notify_tag > 0) {
196
			g_source_remove(notify_window.notify_tag);
197
			notify_window.notify_tag = 0;
198
		}
199

  
200
		gtk_widget_destroy(notify_window.window);
201

  
202
		notify_window.window = NULL;
203
		notify_window.msglabel = NULL;
204
		notify_window.sublabel = NULL;
205

  
206
		debug_print("notification window removed\n");
207
	}
208
}
209

  
210
static gboolean notify_fadeout_timeout_cb(gpointer data)
211
{
212
	gdk_threads_enter();
213
	notify_window.fade_length -= FADE_SPEED;
214
	notify_window.fade_count++;
215

  
216
	gtk_window_move(GTK_WINDOW(notify_window.window),
217
			notify_window.x, notify_window.y + notify_window.fade_count * FADE_SPEED);
218

  
219
	if (notify_window.fade_length <= 0) {
220
		notification_window_destroy();
221
		gdk_threads_leave();
222
		return FALSE;
223
	}
224
	gdk_threads_leave();
225
	return TRUE;
226
}
227

  
228
static gboolean notify_timeout_cb(gpointer data)
229
{
230
	gdk_threads_enter();
231
	notify_window.fade_length = gdk_screen_height() - notify_window.y;
232
	notify_window.notify_tag = g_timeout_add(FADE_REFRESH_RATE,
233
						 notify_fadeout_timeout_cb,
234
						 NULL);
235
	gdk_threads_leave();
236

  
237
	return FALSE;
238
}
239

  
240
static gboolean nwin_button_pressed(GtkWidget *widget, GdkEventButton *event,
241
				    gpointer data)
242
{
243
	if (!event)
244
		return FALSE;
245

  
246
	notification_window_destroy();
247
	main_window_popup(main_window_get());
248

  
249
	return TRUE;
250
}
251

  
252
static gboolean nwin_entered(GtkWidget *widget, GdkEventCrossing *event,
253
			     gpointer data)
254
{
255
	return FALSE;
256
}
257

  
258
static gboolean nwin_motion_notify(GtkWidget *widget, GdkEventMotion *event,
259
				   gpointer data)
260
{
261
	if (notify_window.notify_tag > 0) {
262
		g_source_remove(notify_window.notify_tag);
263
		notify_window.notify_tag = 0;
264
	}
265
	notify_window.fade_count = 0;
266
	gtk_window_move(GTK_WINDOW(notify_window.window),
267
			notify_window.x, notify_window.y);
268
	notify_window.notify_tag = g_timeout_add(notify_window.timeout * 1000,
269
						 notify_timeout_cb, NULL);
270

  
271
	return FALSE;
272
}
273

  
274
static void nwin_destroy_cb(GtkWidget *widget, gpointer data)
275
{
276
}
src/notificationwindow.h
1
/*
2
 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3
 * Copyright (C) 1999-2013 Hiroyuki Yamamoto
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation; either version 2 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
 */
19

  
20
#ifndef __NOTIFICATIONWINDOW_H__
21
#define __NOTIFICATIONWINDOW_H__
22

  
23
#include <glib.h>
24
#include <gtk/gtk.h>
25

  
26
typedef struct _NotificationWindow	NotificationWindow;
27

  
28
gint notification_window_create		(const gchar		*message,
29
					 const gchar		*submessage,
30
					 guint			 timeout);
31
void notification_window_set_message	(const gchar		*message,
32
					 const gchar		*submessage);
33
void notification_window_close		(void);
34

  
35
#endif /* __NOTIFICATIONWINDOW_H__ */
src/Makefile.am
93 93
	update_check.c update_check.h \
94 94
	quote_fmt_lex.l quote_fmt_lex.h \
95 95
	quote_fmt_parse.y quote_fmt.h \
96
	sylpheed-marshal.c sylpheed-marshal.h
96
	sylpheed-marshal.c sylpheed-marshal.h \
97
	notificationwindow.c notificationwindow.h
97 98

  
98 99
BUILT_SOURCES = \
99 100
	quote_fmt_lex.c \
ChangeLog
1
2013-02-08
2

  
3
	* src/inc.[ch]
4
	  src/notificationwindow.[ch]: implemented new message notification
5
	  popup window.
6

  
1 7
2013-02-01
2 8

  
3 9
	* nsis/*.{nsh,nsi}: translate Start Menu shortcuts.

Also available in: Unified diff