📄 new-message-callbacks.c
字号:
#endif#if 1 /* This needs further investigation to find out why it's not valid to do this */ free( msgText ) ;#endif#endif free (recp_line); return ;}void destroy_new_message_window (GtkWidget *widget, gpointer data) { GtkWidget *parent=lookup_widget (widget, "new_message_window"); GtkCList *clist=GTK_CLIST (lookup_widget (parent, "attachment_clist")); AFS *afs=NULL; int i=0; for (i=0;i<clist->rows;i++) { afs=gtk_clist_get_row_data (clist, i);#if 0 /* XXX */ if (afs) { if (afs->filename) free (afs->filename); if (afs->data) free (afs->data); if (afs->type) free (afs->type); free (afs); }#endif } gtk_widget_destroy (parent); for (i=0;i<20;i++) { if (parent==tm_globs->new_messages[i]) tm_globs->new_messages[i]=NULL; }#if 0 if( data ) { if( ((RecipSignalData *)data) -> email ) free( ((RecipSignalData *)data) -> email ) ;#if DEBUG > 6 printf( "Destroying RecipSignalData %p.\n", data ) ;#endif free( data ) ; }#endif}void new_message_save (GtkWidget *widget, gpointer data) { GtkWidget *window=lookup_widget (widget, "new_message_window"); char *filename; char *subject=gtk_entry_get_text (GTK_ENTRY (lookup_widget (window, "subject_entry"))); char *to, *cc, *bcc; char *full_message=new_message_generate_full (window, &to, &cc, &bcc); if (strlen (subject)<=0) { subject=strdup (_("Untitled")); } filename=(char *)calloc (strlen (subject)+5, sizeof(char)); sprintf (filename, "%s.eml", subject); if (full_message) save_string (full_message, strlen (full_message), filename); free (filename);}void new_message_print (GtkWidget *widget, gpointer data) { char *to, *cc, *bcc; char *full_message=new_message_generate_full (lookup_widget (widget, "new_message_window"), &to, &cc, &bcc); insert_message ("Printing Message... "); message_print_stream (full_message); free (full_message); insert_message ("Done!\n");}void new_message_add_attachment (GtkWidget *widget, gpointer data) { GtkWidget *message=lookup_widget (widget, "new_message_window"); GtkWidget *fs=file_selector_new (NULL, NULL, GTK_SIGNAL_FUNC (new_message_accept_add_attachment), GTK_SIGNAL_FUNC (do_something), message); gtk_widget_show (fs);}void new_message_accept_add_attachment (GtkWidget *fs, char *filename, gpointer data) { GtkWidget *message=(GtkWidget *)data; GtkCList *clist=GTK_CLIST (lookup_widget (message, "attachment_clist")); struct stat buf; char *cl_data[3]; int row; AFS *afs=(AFS *)calloc (1, sizeof (AFS)); gtk_widget_destroy (fs); afs->filename=filename;// afs->type=strdup ("message/rfc822");// printf ("Got %s\n", filename); stat (filename, &buf); cl_data[0]=NULL; cl_data[1]=filename; cl_data[2]=(char *)calloc (20, sizeof (char)); sprintf (cl_data[2], "%d", (int)buf.st_size); row=gtk_clist_append (clist, cl_data); free (cl_data[2]);#if DEBUG > 7 printf ("0afs: <%p>\nafs->filename: <%p> '%s'\n", afs, afs->filename, afs->filename);#endif gtk_clist_set_row_data (clist, row, (gpointer)afs);}void new_message_attachment_selected (GtkWidget *widget, gint row, gint column, GdkEventButton *event, gpointer data) {// char *filename=gtk_clist_get_row_data (GTK_CLIST (widget), row); gtk_widget_set_sensitive (lookup_widget (widget, "remove_attachment"), TRUE);// printf ("Filename: %s\n", filename);}void new_message_attachment_unselected (GtkWidget *widget, gint row, gint column, GdkEventButton *event, gpointer data) { gtk_widget_set_sensitive (lookup_widget (widget, "remove_attachment"), FALSE);}void new_message_delete_attachment (GtkWidget *widget, gpointer data) { GtkCList *clist=GTK_CLIST (lookup_widget (widget, "attachment_clist")); free (gtk_clist_get_row_data (clist, clist->focus_row)); gtk_clist_remove (clist, clist->focus_row);}void new_message_drag_data_received (GtkWidget *widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *data, guint info, guint time) {// printf ("Info=%d data->data=%s\n", info, data->data);}void new_message_check_names (GtkWidget *widget, gpointer data) { char *tmp ; GList *list ; GList *seek ; int count=0; /* * Now, walk through the list of recipients to make sure they are valid. * Substitute as we go. */ list = new_message_get_recipients (GTK_TREE (lw (widget, "recip_tree"))) ; for (seek=list;seek;seek=seek->next) { Recipient *recip=seek->data; if (strlen (recip->email) > 0) { /* If the alias is found, plug in the new name - use that to check */ if( !is_email( recip -> email ) ) { tmp = strdup( nemail_fix( recip -> email ) ) ; if( tmp ) { free( recip -> email ) ; recip -> email = tmp ; } } if (!abook_entry_seek_by_email (NULL, recip->email)) { if (!validate_email (recip->email)) count++; } } } new_message_destroy_reciplist (list); if (count==0) insert_message( "All email addresses are valid.\n" ) ;}void new_message_recip_check (GtkWidget *entry, gpointer data) { char *oldline=gtk_entry_get_text(GTK_ENTRY(entry)); char *newline; if (strlen(oldline)) { if(!is_email(oldline)) { newline=strdup(nemail_fix(oldline)); gtk_entry_set_text(GTK_ENTRY(entry),newline); } }}voidnew_message_recip_changed (GtkWidget *widget, gpointer data){#if 0 GtkEntry *entry = GTK_ENTRY (GTK_WIDGET (widget)); char *original = strdup (gtk_entry_get_text (entry)); char *possible; static int ignore = FALSE; if (ignore) { ignore = FALSE; } else { possible = abook_entry_seek_in_part2 (original); if (possible) { ignore = TRUE; gtk_entry_set_text (entry, possible); gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1); } } if (original) free (original);#endif}void new_message_select_recipients_accept (GList *recips, GtkTree *tree) { /*GtkTree *tree=GTK_TREE (lw (widget, "recip_tree"));*/ GList *seek; Recipient *recp; RecipSignalData *recip ; gtk_tree_clear_items (tree, 0, g_list_length (tree->children)); /* Notice that there isn't a free for this! */ recip = calloc( 1, sizeof(RecipSignalData) ) ; for (seek=recips;seek;seek=seek->next) { recp=seek->data; recip -> type = recp -> type ; recip -> email = recp -> email ; recip -> tree = tree ; new_message_window_add_recip (NULL, recip ) ; } /* We must NULL Terminate the recip in the list */ recip -> type = 0 ; recip -> email = NULL ; recip -> tree = tree ; if (!tree->children) { new_message_window_add_recip (NULL, recip ) ; } return ;}void new_message_select_recipients (GtkWidget *widget, gpointer data) {#if 1#if 1 static char *send_types[]={ "To:", "Cc:", "Bcc:", NULL};#else static char *send_types[]={ "Add To:", "Add Cc:", "Add Bcc:", NULL};#endif#else char *send_types[]= { "To:", "CC:", "BCC:", NULL } ;#endif GtkTree *tree=GTK_TREE (lw (widget, "recip_tree")); GList *types=NULL; GList *recips=new_message_get_recipients (tree); int i; for (i=0;send_types[i];i++) { types=g_list_append (types, send_types[i]); } abook_selector_create (types, recips, GTK_SIGNAL_FUNC (new_message_select_recipients_accept), tree); new_message_destroy_reciplist (recips);}/* * This function takes a char * and word wraps the whole buffer, * allocating and returning a new word wrapped buffer. The caller * becomes the owner of this allocated memory. */char *word_wrap_body( char *msg, int wl ){ char *ret ; int length ; int loffset ; int moffset ; int lloffset ; ret = NULL ; /* First, let's make sure we have a reasonable value to wrap with! */ if( (wl >= 20) && (wl <=160) ) { if( msg ) { if( (length = strlen( msg )) > wl ) { /* We'll allocate enough to add a newline for every line * plus a null plus one for rounding up. Remember, if * everyline isn't going to wrap, then it just means we * wind up with room to spare! Whew... */ if( (ret = malloc( length + (length / wl) + 2 )) ) { moffset = 0 ; loffset = 0 ; ret[0] = 0x00 ; /* This is so it can append to the very start! */ /* Now, here's were the magic happens */ while( moffset < length ) { while( (msg[moffset+loffset] != (char)0x00) && (msg[moffset+loffset] != '\n') && (loffset < wl) ) loffset++ ; /* * Okay, if we are here, it's because one of three reasons. * 1) We found the end of the message. * 2) We found a new line which means we need to adjust some. * 3) We hit the max word wrap size and need to find the last word boundry. */ /* Okay, #1. We are at the end of the message, so just copy what's left. */ if( msg[moffset+loffset] == (char)0x00 ) { strcat( ret, &msg[moffset] ) ; moffset += loffset ; /* This let's us drop out of our loop */ } /* end #1 */ /* Okay, #2. If we found a new line, we need only copy verbatium and adjust our index past. */ if ( msg[moffset+loffset] == '\n' ) { /* Copy only up to the newline to the buffer */ strncat( ret, &msg[moffset], loffset + 1 ) ; moffset += loffset + 1 ; /* Need to get past this new line */ loffset = 0 ; } /* end #2 */ /* Okay, #3. This means we are forced to find the last word so we can insert the wrap */ if( loffset >= wl ) { lloffset = loffset ; while( lloffset > 0 ) { if( msg[moffset+lloffset] == 0x20 ) { /* * Okay, we found our first word gap, copy up to that point, * add a new line, and result the indexs to start from the * beginning of the word on the right. */ strncat( ret, &msg[moffset], lloffset ) ; strcat( ret, "\n" ) ; moffset += lloffset + 1 ; loffset = 0 ; lloffset = 0 ; /* This is to make us break out from the loop */ } else { /* Make sure that lines that CAN'T wrap don't hang us up! */ if( lloffset == 1 ) { strncat( ret, &msg[moffset], wl ) ; strcat( ret, "\n" ) ; moffset += wl ; loffset = 0 ; } lloffset-- ; } } /* End of while */ } } /* outer while */ } /* if allocation */ } /* if we have enough to worry about wraping */ } /* if there is even a message to wrap on */ } /* Make sure was have reasonable values to start with */ return ret ;}void msgexp_cal(GtkWidget *widget, gpointer data){GtkWidget *nmwindow=lookup_widget(widget, "new_message_window");create_calendar(1,nmwindow);}void replyto_cal(GtkWidget *widget, gpointer data){GtkWidget *nmwindow=lookup_widget(widget, "new_message_window");create_calendar(2,nmwindow);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -