Am 20.01.06 00:50 schrieb(en) Peter Bloomfield:
4) Balsa, please be nice and ask me before sending a mail with an empty Subject header...Yes, that would be kind!
I must admit that this bothered me since a while, too. Never took the time to fix it, but as Mişu also thinks it would be nice... so here's a simple quick hack to ask for a subject if it's empty (against the cvs). Hope the dialog is hig compliant...
Opinions?
Cheers, Albrecht.
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Albrecht Dreß - Johanna-Kirchner-Straße 13 - D-53123 Bonn (Germany)
Phone (+49) 228 6199571 - mailto:albrecht dress arcor de
GnuPG public key: http://www.mynetcologne.de/~nc-dreszal/pubkey.asc
_________________________________________________________________________
? libbalsa/imap/.deps
? po/.intltool-merge-cache
Index: src/sendmsg-window.c
===================================================================
RCS file: /cvs/gnome/balsa/src/sendmsg-window.c,v
retrieving revision 1.568
diff -u -r1.568 sendmsg-window.c
--- src/sendmsg-window.c 20 Jan 2006 16:15:07 -0000 1.568
+++ src/sendmsg-window.c 20 Jan 2006 19:53:16 -0000
@@ -4872,6 +4872,98 @@
return TRUE;
}
+
+/* ask the user for a subject */
+static gboolean
+subject_not_empty(BalsaSendmsg * bsmsg)
+{
+ const gchar *subj;
+ GtkWidget *no_subj_dialog;
+ GtkWidget *dialog_vbox1;
+ GtkWidget *hbox;
+ GtkWidget *image;
+ GtkWidget *vbox;
+ gchar *text_str;
+ GtkWidget *label;
+ GtkWidget *subj_entry;
+ GtkWidget *dialog_action_area;
+ GtkWidget *cnclbutton;
+ GtkWidget *okbutton;
+ gint response;
+
+ /* read the subject widget and verify that it is contains something else
+ than spaces */
+ subj = gtk_entry_get_text(GTK_ENTRY(bsmsg->subject[1]));
+ if (subj) {
+ const gchar *p = subj;
+
+ while (*p && g_unichar_isspace(g_utf8_get_char(p)))
+ p = g_utf8_next_char(p);
+ if (*p != '\0')
+ return TRUE;
+ }
+
+ /* build the dialog */
+ no_subj_dialog = gtk_dialog_new ();
+ gtk_container_set_border_width (GTK_CONTAINER (no_subj_dialog), 6);
+ gtk_window_set_modal (GTK_WINDOW (no_subj_dialog), TRUE);
+ gtk_window_set_resizable (GTK_WINDOW (no_subj_dialog), FALSE);
+ gtk_window_set_type_hint (GTK_WINDOW (no_subj_dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
+ gtk_dialog_set_has_separator (GTK_DIALOG (no_subj_dialog), FALSE);
+
+ dialog_vbox1 = GTK_DIALOG (no_subj_dialog)->vbox;
+
+ hbox = gtk_hbox_new (FALSE, 12);
+ gtk_box_pack_start (GTK_BOX (dialog_vbox1), hbox, TRUE, TRUE, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (hbox), 6);
+
+ image = gtk_image_new_from_stock ("gtk-dialog-question", GTK_ICON_SIZE_DIALOG);
+ gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
+ gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0);
+
+ vbox = gtk_vbox_new (FALSE, 12);
+ gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
+
+ text_str = g_strdup_printf("<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s",
+ _("You did not specify a subject for this message"),
+ _("If you would like to provide one, enter it below."));
+ label = gtk_label_new (text_str);
+ g_free(text_str);
+ gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+ gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
+
+ subj_entry = gtk_entry_new ();
+ gtk_entry_set_text(GTK_ENTRY(subj_entry), _("(no subject)"));
+ gtk_box_pack_start (GTK_BOX (vbox), subj_entry, FALSE, FALSE, 0);
+ gtk_entry_set_activates_default (GTK_ENTRY (subj_entry), TRUE);
+
+ dialog_action_area = GTK_DIALOG (no_subj_dialog)->action_area;
+ gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area), GTK_BUTTONBOX_END);
+
+ cnclbutton = gtk_button_new_from_stock ("gtk-cancel");
+ gtk_dialog_add_action_widget (GTK_DIALOG (no_subj_dialog), cnclbutton, GTK_RESPONSE_CANCEL);
+ GTK_WIDGET_SET_FLAGS (cnclbutton, GTK_CAN_DEFAULT);
+
+ okbutton = gtk_button_new_from_stock ("gtk-ok");
+ gtk_dialog_add_action_widget (GTK_DIALOG (no_subj_dialog), okbutton, GTK_RESPONSE_OK);
+ GTK_WIDGET_SET_FLAGS (okbutton, GTK_CAN_DEFAULT);
+
+ gtk_widget_grab_focus (subj_entry);
+ gtk_widget_show_all(dialog_vbox1);
+
+ response = gtk_dialog_run(GTK_DIALOG(no_subj_dialog));
+
+ /* always set the current string in the subject entry */
+ gtk_entry_set_text(GTK_ENTRY(bsmsg->subject[1]),
+ gtk_entry_get_text(GTK_ENTRY(subj_entry)));
+ gtk_widget_destroy(no_subj_dialog);
+
+ return response == GTK_RESPONSE_OK;
+}
+
+
/* "send message" menu and toolbar callback.
*/
static gint
@@ -4892,6 +4984,9 @@
if(!is_charset_ok(bsmsg))
return FALSE;
+
+ if(!subject_not_empty(bsmsg))
+ return FALSE;
#ifdef HAVE_GPGME
if ((bsmsg->gpg_mode & LIBBALSA_PROTECT_OPENPGP) != 0 &&
Attachment:
pgpCWsGrYrrqt.pgp
Description: PGP signature