From b265717d397e190684652329e6fd28e7ae482a0d Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Tue, 18 Dec 2001 23:22:36 +0000 Subject: Setup the new-mail-notification widgets. (notify_command_changed): Update 2001-12-18 Jeffrey Stedfast * mail-accounts.c (construct): Setup the new-mail-notification widgets. (notify_command_changed): Update the command-line for new mail notification. (notify_radio_toggled): Update the new-mail-notification type. * mail-ops.c (filter_folder_free): See if we got any new mail and "sound the alarm" if we did. svn path=/trunk/; revision=15168 --- mail/ChangeLog | 11 +++++ mail/mail-accounts.c | 50 ++++++++++++++++++++- mail/mail-accounts.h | 4 ++ mail/mail-config.c | 14 +++--- mail/mail-config.glade | 118 +++++++++++++++++++++++++++++++++++++++++++++++++ mail/mail-config.h | 16 +++---- mail/mail-ops.c | 18 +++++++- 7 files changed, 213 insertions(+), 18 deletions(-) diff --git a/mail/ChangeLog b/mail/ChangeLog index 9a080da8ce..ece98ae751 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,14 @@ +2001-12-18 Jeffrey Stedfast + + * mail-accounts.c (construct): Setup the new-mail-notification + widgets. + (notify_command_changed): Update the command-line for new mail + notification. + (notify_radio_toggled): Update the new-mail-notification type. + + * mail-ops.c (filter_folder_free): See if we got any new mail and + "sound the alarm" if we did. + 2001-12-17 Jon Trowbridge * mail-format.c (handle_text_plain_flowed): Set citation color to diff --git a/mail/mail-accounts.c b/mail/mail-accounts.c index 2b386e1b11..ea82a1b815 100644 --- a/mail/mail-accounts.c +++ b/mail/mail-accounts.c @@ -682,6 +682,31 @@ images_radio_toggled (GtkWidget *radio, gpointer data) mail_config_set_http_mode (MAIL_CONFIG_HTTP_NEVER); } +static void +notify_radio_toggled (GtkWidget *radio, gpointer data) +{ + MailAccountsDialog *dialog = data; + + if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio))) + return; + + if (radio == (GtkWidget *) dialog->notify_not) + mail_config_set_new_mail_notify (MAIL_CONFIG_NOTIFY_NOT); + else if (radio == (GtkWidget *) dialog->notify_beep) + mail_config_set_new_mail_notify (MAIL_CONFIG_NOTIFY_BEEP); + else + mail_config_set_new_mail_notify (MAIL_CONFIG_NOTIFY_EXEC); +} + +static void +notify_command_changed (GtkWidget *file_entry, gpointer data) +{ + char *command; + + command = gnome_file_entry_get_full_path (GNOME_FILE_ENTRY (file_entry), FALSE); + mail_config_set_new_mail_notify_command (command); +} + static void empty_trash_toggled (GtkWidget *toggle, gpointer data) { @@ -782,7 +807,7 @@ static void construct (MailAccountsDialog *dialog) { GladeXML *gui; - GtkWidget *notebook, *menu; + GtkWidget *notebook, *menu, *entry; int num; gui = glade_xml_new (EVOLUTION_GLADEDIR "/mail-config.glade", NULL); @@ -914,7 +939,7 @@ construct (MailAccountsDialog *dialog) gtk_toggle_button_set_active (dialog->prompt_bcc_only, mail_config_get_prompt_only_bcc ()); gtk_signal_connect (GTK_OBJECT (dialog->prompt_bcc_only), "toggled", GTK_SIGNAL_FUNC (prompt_bcc_only_toggled), dialog); - + dialog->prompt_unwanted_html = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkPromptWantHTML")); gtk_toggle_button_set_active (dialog->prompt_unwanted_html, mail_config_get_confirm_unwanted_html ()); gtk_signal_connect (GTK_OBJECT (dialog->prompt_unwanted_html), "toggled", @@ -956,6 +981,27 @@ construct (MailAccountsDialog *dialog) gtk_signal_connect (GTK_OBJECT (dialog->confirm_expunge), "toggled", GTK_SIGNAL_FUNC (confirm_expunge_toggled), dialog); + dialog->notify_not = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "radioNotifyNot")); + gtk_toggle_button_set_active (dialog->notify_not, mail_config_get_new_mail_notify () == MAIL_CONFIG_NOTIFY_NOT); + gtk_signal_connect (GTK_OBJECT (dialog->notify_not), "toggled", + GTK_SIGNAL_FUNC (notify_radio_toggled), dialog); + + dialog->notify_beep = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "radioNotifyBeep")); + gtk_toggle_button_set_active (dialog->notify_beep, mail_config_get_new_mail_notify () == MAIL_CONFIG_NOTIFY_BEEP); + gtk_signal_connect (GTK_OBJECT (dialog->notify_beep), "toggled", + GTK_SIGNAL_FUNC (notify_radio_toggled), dialog); + + dialog->notify_exec = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "radioNotifyExec")); + gtk_toggle_button_set_active (dialog->notify_exec, mail_config_get_new_mail_notify () == MAIL_CONFIG_NOTIFY_EXEC); + gtk_signal_connect (GTK_OBJECT (dialog->notify_exec), "toggled", + GTK_SIGNAL_FUNC (notify_radio_toggled), dialog); + + dialog->command_line = GNOME_FILE_ENTRY (glade_xml_get_widget (gui, "fileNotifyCommandLine")); + gtk_entry_set_text (GTK_ENTRY (gnome_file_entry_gtk_entry (dialog->command_line)), + mail_config_get_new_mail_notify_command ()); + gtk_signal_connect (GTK_OBJECT (dialog->command_line), "changed", + GTK_SIGNAL_FUNC (notify_command_changed), dialog); + /* now to fill in the clists */ dialog->accounts_row = -1; dialog->accounts = mail_config_get_accounts (); diff --git a/mail/mail-accounts.h b/mail/mail-accounts.h index f2580874d3..bb29819343 100644 --- a/mail/mail-accounts.h +++ b/mail/mail-accounts.h @@ -93,6 +93,10 @@ struct _MailAccountsDialog { GtkToggleButton *filter_log; GnomeFileEntry *filter_log_path; GtkToggleButton *confirm_expunge; + GtkToggleButton *notify_not; + GtkToggleButton *notify_beep; + GtkToggleButton *notify_exec; + GnomeFileEntry *command_line; /* PGP page */ GnomeFileEntry *pgp_path; diff --git a/mail/mail-config.c b/mail/mail-config.c index 184f4fb281..a21af27d17 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -107,7 +107,7 @@ typedef struct { gboolean filter_log; char *filter_log_path; - MailConfigNewMailNotification notify; + MailConfigNewMailNotify notify; char *notify_command; } MailConfig; @@ -614,7 +614,7 @@ config_read (void) /* New Mail Notification */ config->notify = bonobo_config_get_long_with_default ( config->db, "/Mail/Notify/new_mail_notification", - MAIL_CONFIG_NEW_MAIL_NOTIFICATION_NONE, NULL); + MAIL_CONFIG_NOTIFY_NOT, NULL); config->notify_command = bonobo_config_get_string ( config->db, "/Mail/Notify/new_mail_notification_command", NULL); @@ -1628,26 +1628,26 @@ mail_config_set_default_charset (const char *charset) config->default_charset = g_strdup (charset); } -MailConfigNewMailNotification -mail_config_get_new_mail_notification (void) +MailConfigNewMailNotify +mail_config_get_new_mail_notify (void) { return config->notify; } void -mail_config_set_new_mail_notification (MailConfigNewMailNotification type) +mail_config_set_new_mail_notify (MailConfigNewMailNotify type) { config->notify = type; } const char * -mail_config_get_new_mail_notification_command (void) +mail_config_get_new_mail_notify_command (void) { return config->notify_command; } void -mail_config_set_new_mail_notification_command (const char *command) +mail_config_set_new_mail_notify_command (const char *command) { g_free (config->notify_command); config->notify_command = g_strdup (command); diff --git a/mail/mail-config.glade b/mail/mail-config.glade index 4f53b4c583..7e1953cf01 100644 --- a/mail/mail-config.glade +++ b/mail/mail-config.glade @@ -3125,6 +3125,124 @@ Quoted False + + + GtkFrame + frame + + 0 + GTK_SHADOW_ETCHED_IN + + 0 + True + True + + + + GtkVBox + vbox66 + False + 0 + + + GtkRadioButton + radioNotifyNot + True + + True + True + new_mail_notify + + 0 + False + False + + + + + GtkRadioButton + radioNotifyBeep + True + + False + True + new_mail_notify + + 0 + False + False + + + + + GtkRadioButton + radioNotifyExec + True + + False + True + new_mail_notify + + 0 + False + False + + + + + GtkHBox + hbox60 + False + 0 + + 0 + True + True + + + + GtkLabel + label54 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + 0 + False + False + + + + + GnomeFileEntry + fileNotifyExecCommand + 10 + False + False + + 0 + True + True + + + + GtkEntry + GnomeEntry:entry + combo-entry3 + True + True + True + 0 + + + + + + diff --git a/mail/mail-config.h b/mail/mail-config.h index 82f863dba3..c54fef4eba 100644 --- a/mail/mail-config.h +++ b/mail/mail-config.h @@ -88,10 +88,10 @@ typedef enum { } MailConfigDisplayStyle; typedef enum { - MAIL_CONFIG_NEW_MAIL_NOTIFICATION_NONE, - MAIL_CONFIG_NEW_MAIL_NOTIFICATION_BEEP, - MAIL_CONFIG_NEW_MAIL_NOTIFICATION_COMMAND, -} MailConfigNewMailNotification; + MAIL_CONFIG_NOTIFY_NOT, + MAIL_CONFIG_NOTIFY_BEEP, + MAIL_CONFIG_NOTIFY_EXEC, +} MailConfigNewMailNotify; /* Identities */ MailConfigIdentity *identity_copy (const MailConfigIdentity *id); @@ -181,10 +181,10 @@ void mail_config_set_default_forward_style (MailConfigForwardS MailConfigDisplayStyle mail_config_get_message_display_style (void); void mail_config_set_message_display_style (MailConfigDisplayStyle style); -MailConfigNewMailNotification mail_config_get_new_mail_notification (void); -void mail_config_set_new_mail_notification (MailConfigNewMailNotification type); -const char *mail_config_get_new_mail_notification_command (void); -void mail_config_set_new_mail_notification_command (const char *command); +MailConfigNewMailNotify mail_config_get_new_mail_notify (void); +void mail_config_set_new_mail_notify (MailConfigNewMailNotify type); +const char *mail_config_get_new_mail_notify_command (void); +void mail_config_set_new_mail_notify_command (const char *command); const char *mail_config_get_default_charset (void); void mail_config_set_default_charset (const char *charset); diff --git a/mail/mail-ops.c b/mail/mail-ops.c index 023d1781d1..cbccb274db 100644 --- a/mail/mail-ops.c +++ b/mail/mail-ops.c @@ -145,7 +145,7 @@ static void filter_folder_free (struct _mail_msg *mm) { struct _filter_mail_msg *m = (struct _filter_mail_msg *)mm; - int i; + int count, i; if (m->source_folder) camel_object_unref (CAMEL_OBJECT (m->source_folder)); @@ -163,6 +163,22 @@ filter_folder_free (struct _mail_msg *mm) if (m->destination) camel_object_unref (CAMEL_OBJECT (m->destination)); + count = camel_filter_driver_get_filtered_count (m->driver); + camel_filter_driver_reset_filtered_count (m->driver); + + if (count > 0) { + switch (mail_config_get_new_mail_notify ()) { + case MAIL_CONFIG_NOTIFY_BEEP: + gdk_beep (); + break; + case MAIL_CONFIG_NOTIFY_EXEC: + mail_execute_shell_command (m->driver, mail_config_get_new_mail_notify_command (), NULL); + break; + default: + break; + } + } + if (m->driver) camel_object_unref (CAMEL_OBJECT (m->driver)); } -- cgit