[balsa/gtk3] Simplify conditional code
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/gtk3] Simplify conditional code
- Date: Sun, 13 Mar 2016 00:38:40 +0000 (UTC)
commit 7649b8da19e2a198f1beeb32938002433107dfce
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Sat Mar 12 19:37:51 2016 -0500
Simplify conditional code
* src/main-window.c (bw_display_new_mail_notification):
duplicate some lines of code to simplify conditional
compilation.
ChangeLog | 6 ++++++
src/main-window.c | 52 ++++++++++++++++++++++++++++++++++++----------------
2 files changed, 42 insertions(+), 16 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a878b46..324ed24 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2016-03-12 Peter Bloomfield <pbloomfield bellsouth net>
+ * src/main-window.c (bw_display_new_mail_notification):
+ duplicate some lines of code to simplify conditional
+ compilation.
+
+2016-03-12 Peter Bloomfield <pbloomfield bellsouth net>
+
* libbalsa/imap/imap-handle.c (imap_message_new): use whitespace
to resolve ambiguous assignment.
diff --git a/src/main-window.c b/src/main-window.c
index 81b701e..7d512b1 100644
--- a/src/main-window.c
+++ b/src/main-window.c
@@ -3894,7 +3894,42 @@ bw_display_new_mail_notification(int num_new, int has_new)
"closed", G_CALLBACK(g_object_unref), NULL);
}
} else {
-#endif
+ if (dlg) {
+ /* the user didn't acknowledge the last info, so we'll
+ * accumulate the count */
+ num_total += num_new;
+ gtk_window_present(GTK_WINDOW(dlg));
+ } else {
+ num_total = num_new;
+ dlg = gtk_message_dialog_new(NULL, /* NOT transient for
+ * Balsa's main window */
+ (GtkDialogFlags) 0,
+ GTK_MESSAGE_INFO,
+ GTK_BUTTONS_OK, "%s", msg);
+ gtk_window_set_title(GTK_WINDOW(dlg), _("Balsa: New mail"));
+ gtk_window_set_wmclass(GTK_WINDOW(dlg), "new_mail_dialog",
+ "Balsa");
+ gtk_window_set_type_hint(GTK_WINDOW(dlg),
+ GDK_WINDOW_TYPE_HINT_NORMAL);
+ g_signal_connect(G_OBJECT(dlg), "response",
+ G_CALLBACK(gtk_widget_destroy), NULL);
+ g_object_add_weak_pointer(G_OBJECT(dlg), (gpointer) & dlg);
+ gtk_widget_show_all(GTK_WIDGET(dlg));
+ }
+ }
+
+ msg = bw_get_new_message_notification_string(num_new, num_total);
+ if (balsa_app.main_window->new_mail_note) {
+ notify_notification_update(balsa_app.main_window->new_mail_note,
+ "Balsa", msg, "dialog-information");
+ /* 30 seconds: */
+ notify_notification_set_timeout(balsa_app.main_window->
+ new_mail_note, 30000);
+ notify_notification_show(balsa_app.main_window->new_mail_note,
+ NULL);
+ } else
+ gtk_message_dialog_set_markup(GTK_MESSAGE_DIALOG(dlg), msg);
+#else
if (dlg) {
/* the user didn't acknowledge the last info, so we'll
* accumulate the count */
@@ -3917,21 +3952,6 @@ bw_display_new_mail_notification(int num_new, int has_new)
g_object_add_weak_pointer(G_OBJECT(dlg), (gpointer) & dlg);
gtk_widget_show_all(GTK_WIDGET(dlg));
}
-#ifdef HAVE_NOTIFY
- }
-
- msg = bw_get_new_message_notification_string(num_new, num_total);
- if (balsa_app.main_window->new_mail_note) {
- notify_notification_update(balsa_app.main_window->new_mail_note,
- "Balsa", msg, "dialog-information");
- /* 30 seconds: */
- notify_notification_set_timeout(balsa_app.main_window->
- new_mail_note, 30000);
- notify_notification_show(balsa_app.main_window->new_mail_note,
- NULL);
- } else
- gtk_message_dialog_set_markup(GTK_MESSAGE_DIALOG(dlg), msg);
-#else
msg = bw_get_new_message_notification_string(num_new, num_total);
gtk_message_dialog_set_markup(GTK_MESSAGE_DIALOG(dlg), msg);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]