Re: Patches applied



On 28 Feb, Peter Williams wrote:
> BTW, it looks like you can make your message from more than
> one address. That's probably not RFC-compliant :-)

Not really. You can enter more than one address in the From: field but
make_address_from_string will fetch only first one. Remaining ones will
be ignored.

I enclose yet another patch against current CVS (I hope I will get the
CVS write acces soon and stop bothering you guys) that saves favorite
shown headers between sessions - as suggested by Barry Haddow - and
pre-fills the "reply-to" field with the value from the Preferences.
Apply with patch -p1 < headers.patch 

I also grow tired with GtkText and I think I will try to replace it with
something else (I can't make my mind what annoys me more: GtkText in the
Compose window or GnomeCanvas in the message browsing window: I do need
option to copy some text from mails, at least damn URLs).

Pawel

diff -cr balsa.orig/src/balsa-app.c balsa/src/balsa-app.c
*** balsa.orig/src/balsa-app.c	Tue Feb 29 02:36:11 2000
--- balsa/src/balsa-app.c	Tue Feb 29 09:14:45 2000
***************
*** 149,154 ****
--- 149,158 ----
    balsa_app.charset = NULL;
  
    balsa_app.checkbox = 0;
+ 
+   /* compose: shown headers */
+   balsa_app.compose_headers = NULL;
+ 
    balsa_app.PrintCommand.breakline = FALSE;
    balsa_app.PrintCommand.linesize = 78;
    balsa_app.PrintCommand.PrintCommand = NULL;
diff -cr balsa.orig/src/balsa-app.h balsa/src/balsa-app.h
*** balsa.orig/src/balsa-app.h	Tue Feb 29 02:36:11 2000
--- balsa/src/balsa-app.h	Tue Feb 29 09:14:45 2000
***************
*** 175,180 ****
--- 175,183 ----
    /* printing */
    Printing_t PrintCommand;
  
+   /* compose: shown headers */
+   gchar* compose_headers; 
+ 
    /* appbar */
    GnomeAppBar* appbar;
    GtkWidget* notebook;
diff -cr balsa.orig/src/save-restore.c balsa/src/save-restore.c
*** balsa.orig/src/save-restore.c	Tue Feb 29 02:36:12 2000
--- balsa/src/save-restore.c	Tue Feb 29 09:14:45 2000
***************
*** 859,864 ****
--- 859,871 ----
    else
        balsa_app.encoding_style = atoi(field);
  
+   /* shown headers in the compose window */
+   g_free (balsa_app.compose_headers);
+   if ((field = pl_dict_get_str (globals, "ComposeHeaders")) == NULL)
+      balsa_app.compose_headers = g_strdup("to subject cc");
+   else
+     balsa_app.compose_headers = g_strdup (field);
+ 
    if (( field = pl_dict_get_str (globals, "PrintCommand")) == NULL) 
        balsa_app.PrintCommand.PrintCommand = g_strdup("a2ps -d -q %s");
    else 
***************
*** 1038,1043 ****
--- 1045,1052 ----
    else
        pl_dict_add_str_str(globals, "Charset", DEFAULT_CHARSET);
  
+   if (balsa_app.compose_headers != NULL)
+      pl_dict_add_str_str (globals, "ComposeHeaders",balsa_app.compose_headers);
  
    if (balsa_app.PrintCommand.PrintCommand != NULL)
        pl_dict_add_str_str(globals, "PrintCommand", balsa_app.PrintCommand.PrintCommand);
diff -cr balsa.orig/src/sendmsg-window.c balsa/src/sendmsg-window.c
*** balsa.orig/src/sendmsg-window.c	Tue Feb 29 02:36:12 2000
--- balsa/src/sendmsg-window.c	Tue Feb 29 09:50:55 2000
***************
*** 191,196 ****
--- 191,206 ----
     "ISO-8859-9",
  };
  
+ typedef struct {
+       gchar * name;
+       guint length; 
+       
+ } headerMenuDesc;
+ 
+ headerMenuDesc headerDescs[] = { {"to", 3}, {"from", 3}, {"subject",2},
+ 				  {"cc", 3}, {"bcc",  3}, {"fcc",    2},
+ 				  {"replyto", 3}, {"attachments", 4} };
+ 
  static GnomeUIInfo iso_menu[] = {
    { GNOME_APP_UI_RADIOITEMS, NULL, NULL, iso_charset_menu, NULL, NULL,
      GNOME_APP_PIXMAP_NONE, NULL, 0, 0, NULL },
***************
*** 221,232 ****
    return TRUE;
  }
  
! /* the balsa_sendmsg destructor */
  static void
  balsa_sendmsg_destroy (BalsaSendmsg * bsm)
  {
     g_assert(bsm != NULL);
     
     gtk_widget_destroy (bsm->window);
     if(balsa_app.debug) printf("balsa_sendmsg_destroy: Freeing bsm\n");
     g_free (bsm);
--- 231,259 ----
    return TRUE;
  }
  
! /* the balsa_sendmsg destructor; copies first the shown headers setting
!    to the balsa_app structure.
! */
  static void
  balsa_sendmsg_destroy (BalsaSendmsg * bsm)
  {
+    int i;
+    gchar  newStr[sizeof(headerDescs)/sizeof(headerDescs[0])*20];
+ 
     g_assert(bsm != NULL);
     
+    newStr[0] = '\0';
+ 
+    for(i=0; i<sizeof(headerDescs)/sizeof(headerDescs[0]); i++)
+       if(GTK_CHECK_MENU_ITEM(view_menu[i].widget)->active) {
+ 	 strcat(newStr, headerDescs[i].name);
+ 	 strcat(newStr, " ");
+       }
+    if(balsa_app.compose_headers) // should never fail...
+       g_free(balsa_app.compose_headers);
+    
+    balsa_app.compose_headers = g_strdup(newStr);
+ 
     gtk_widget_destroy (bsm->window);
     if(balsa_app.debug) printf("balsa_sendmsg_destroy: Freeing bsm\n");
     g_free (bsm);
***************
*** 242,248 ****
    gtk_object_remove_data (GTK_OBJECT (ilist), "selectednumbertoremove");
  }
  
! /* the menu is createn on right-button click an an attachement */
  static GtkWidget *
  create_popup_menu (GnomeIconList * ilist, gint num)
  {
--- 269,275 ----
    gtk_object_remove_data (GTK_OBJECT (ilist), "selectednumbertoremove");
  }
  
! /* the menu is created on right-button click on an attachement */
  static GtkWidget *
  create_popup_menu (GnomeIconList * ilist, gint num)
  {
***************
*** 465,521 ****
    gtk_table_set_row_spacings (GTK_TABLE (table), 2);
    gtk_table_set_col_spacings (GTK_TABLE (table), 2);
  
-   /* To: */
-   create_email_entry(table, _("To:"), 0, GNOME_STOCK_MENU_BOOK_RED, msg->to );
- 
- #if 0
-   msg->to[0] = gtk_label_new (_("To:"));
-   gtk_misc_set_alignment (GTK_MISC (msg->to[0]), 0.0, 0.5);
-   gtk_table_attach (GTK_TABLE (table), msg->to[0], 0, 1, 0, 1,
- 		    GTK_FILL, GTK_FILL | GTK_SHRINK, 0, 0);
- 
-   msg->to[1] = gtk_entry_new ();
-   gtk_table_attach (GTK_TABLE (table), msg->to[1], 1, 2, 0, 1,
- 		    GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_SHRINK, 0, 0);
- 
-   msg->to[2] = gtk_button_new ();
-   gtk_button_set_relief (GTK_BUTTON (msg->to[2]), GTK_RELIEF_NONE);
-   GTK_WIDGET_UNSET_FLAGS (msg->to[2], GTK_CAN_FOCUS);
-   gtk_container_add (GTK_CONTAINER (msg->to[2]),
- 	       gnome_stock_pixmap_widget (NULL, GNOME_STOCK_MENU_BOOK_RED));
-   gtk_table_attach (GTK_TABLE (table), msg->to[2], 2, 3, 0, 1,
- 		    0, 0, 0, 0);
-   gtk_signal_connect(GTK_OBJECT(msg->to[2]), "clicked", 
- 		     GTK_SIGNAL_FUNC(address_book_cb),
- 		     (gpointer) msg->to[1]);
-   gtk_signal_connect (GTK_OBJECT (msg->to[1]), "drag_data_received",
- 		      GTK_SIGNAL_FUNC (to_add), NULL);
-   gtk_drag_dest_set (GTK_WIDGET (msg->to[1]), GTK_DEST_DEFAULT_ALL,
- 		     email_field_drop_types, ELEMENTS (email_field_drop_types),
- 		     GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK);
- #endif
- 
    /* From: */
!   create_email_entry(table, _("From:"), 1, GNOME_STOCK_MENU_BOOK_BLUE, msg->from );
! 
! #if 0
!   msg->from[0] = gtk_label_new (_("From:"));
!   gtk_misc_set_alignment (GTK_MISC (msg->from[0]), 0.0, 0.5);
!   gtk_table_attach (GTK_TABLE (table), msg->from[0], 0, 1, 1, 2,
! 		    GTK_FILL, GTK_FILL | GTK_SHRINK, 0, 0);
! 
!   msg->from[1] = gtk_entry_new ();
!   gtk_table_attach (GTK_TABLE (table), msg->from[1], 1, 2, 1, 2,
! 		    GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_SHRINK, 0, 0);
! 
!   msg->from[2] = gtk_button_new ();
!   gtk_button_set_relief (GTK_BUTTON (msg->from[2]), GTK_RELIEF_NONE);
!   GTK_WIDGET_UNSET_FLAGS (msg->from[2], GTK_CAN_FOCUS);
!   gtk_container_add (GTK_CONTAINER (msg->from[2]),
! 	      gnome_stock_pixmap_widget (NULL, GNOME_STOCK_MENU_BOOK_BLUE));
!   gtk_table_attach (GTK_TABLE (table), msg->from[2], 2, 3, 1, 2,
! 		    0, 0, 0, 0);
! #endif
  
    /* Subject: */
    msg->subject[0] = gtk_label_new (_("Subject:"));
--- 492,501 ----
    gtk_table_set_row_spacings (GTK_TABLE (table), 2);
    gtk_table_set_col_spacings (GTK_TABLE (table), 2);
  
    /* From: */
!   create_email_entry(table, _("From:"),0,GNOME_STOCK_MENU_BOOK_BLUE,msg->from);
!   /* To: */
!   create_email_entry(table, _("To:"), 1, GNOME_STOCK_MENU_BOOK_RED, msg->to );
  
    /* Subject: */
    msg->subject[0] = gtk_label_new (_("Subject:"));
***************
*** 813,818 ****
--- 793,802 ----
      g_free (from);
    }
  
+   /* Reply To */
+   if(balsa_app.replyto) 
+     gtk_entry_set_text (GTK_ENTRY (msg->reply_to[1]), balsa_app.replyto);
+ 
    /* Bcc: */
    {
      if (balsa_app.bcc)
***************
*** 953,959 ****
  
    /* set the menus  - and charset index - and display the window */
    /* FIXME: this will also reset the font, copying the text back and 
!      forth which is sub-optimal
    */
    set_menus(msg); 
    gtk_widget_show (window);
--- 937,943 ----
  
    /* set the menus  - and charset index - and display the window */
    /* FIXME: this will also reset the font, copying the text back and 
!      forth which is sub-optimal.
    */
    set_menus(msg); 
    gtk_widget_show (window);
***************
*** 1066,1072 ****
    Body *body;
    gchar *tmp;
    gchar *def_charset;
-   GList * from_list;
  
    tmp = gtk_entry_get_text (GTK_ENTRY (bsmsg->to[1]));
    {
--- 1050,1055 ----
***************
*** 1091,1103 ****
  
    message = message_new ();
  
!   /* we should just copy balsa_app.address */
!   message->from = address_new ();
!   from_list =  make_list_from_string (gtk_entry_get_text 
! 			       (GTK_ENTRY (bsmsg->from[1])));
!   message->from = from_list->data;
!   from_list = g_list_remove(from_list,message->from);
!   if(from_list) address_list_free(from_list);
  
    message->subject = g_strdup (gtk_entry_get_text 
  			       (GTK_ENTRY (bsmsg->subject[1])));
--- 1074,1081 ----
  
    message = message_new ();
  
!   message->from = make_address_from_string(gtk_entry_get_text 
! 					   (GTK_ENTRY (bsmsg->from[1])));
  
    message->subject = g_strdup (gtk_entry_get_text 
  			       (GTK_ENTRY (bsmsg->subject[1])));
***************
*** 1134,1149 ****
      }
    }
  
!   if( (tmp = gtk_entry_get_text( GTK_ENTRY( bsmsg->reply_to[1] ) )) != NULL &&
!       strlen( tmp ) > 0 ) {
! 	  message->reply_to = make_address_from_string( tmp );
!   }
! 
!   message->reply_to = address_new ();
! 
!   message->reply_to->personal = g_strdup (balsa_app.address->personal);
!   message->reply_to->mailbox = g_strdup (balsa_app.replyto);
! 
  
    body = body_new ();
  
--- 1112,1120 ----
      }
    }
  
!   if( (tmp = gtk_entry_get_text (GTK_ENTRY (bsmsg->reply_to[1]))) != NULL &&
!       strlen(tmp)>0) 
!      message->reply_to = make_address_from_string(tmp);
  
    body = body_new ();
  
***************
*** 1495,1535 ****
     return toggle_entry(bsmsg->attachments, MENU_TOGGLE_ATTACHMENTS_POS,4);
  }
  
! /* note that hiding the entries must be done seperately */
  static void set_menus(BalsaSendmsg *msg)
  {
     unsigned i;
-    gtk_check_menu_item_set_active(
-       GTK_CHECK_MENU_ITEM(view_menu[MENU_TOGGLE_TO_POS].widget), TRUE );
- 
-    gtk_check_menu_item_set_active(
-       GTK_CHECK_MENU_ITEM(view_menu[MENU_TOGGLE_FROM_POS].widget), FALSE);
-    toggle_entry(msg->from,  MENU_TOGGLE_FROM_POS,3); 
  
!    gtk_check_menu_item_set_active(
!       GTK_CHECK_MENU_ITEM(view_menu[MENU_TOGGLE_SUBJECT_POS].widget), TRUE );
! 
!    gtk_check_menu_item_set_active(
!       GTK_CHECK_MENU_ITEM(view_menu[MENU_TOGGLE_CC_POS].widget), TRUE );
! 
!    gtk_check_menu_item_set_active(
!       GTK_CHECK_MENU_ITEM(view_menu[MENU_TOGGLE_BCC_POS].widget), FALSE );
!    toggle_entry(msg->bcc,  MENU_TOGGLE_BCC_POS,3); 
! 
!    gtk_check_menu_item_set_active(
!       GTK_CHECK_MENU_ITEM(view_menu[MENU_TOGGLE_FCC_POS].widget), FALSE );
!    toggle_entry(msg->fcc,  MENU_TOGGLE_BCC_POS,2); 
! 
!    gtk_check_menu_item_set_active(
!       GTK_CHECK_MENU_ITEM(view_menu[MENU_TOGGLE_REPLY_POS].widget), FALSE );
!    toggle_entry(msg->reply_to, MENU_TOGGLE_BCC_POS,3); 
! 
!    gtk_check_menu_item_set_active(
!       GTK_CHECK_MENU_ITEM(view_menu[MENU_TOGGLE_ATTACHMENTS_POS].widget),
!       FALSE);
!    toggle_entry(msg->attachments,  MENU_TOGGLE_ATTACHMENTS_POS,4); 
  
!    /* this should be read from the preferences set up. If not found, 
        set to the 0th set.
     */
     i = sizeof(iso_charset_names)/sizeof(iso_charset_names[0])-1;
--- 1466,1498 ----
     return toggle_entry(bsmsg->attachments, MENU_TOGGLE_ATTACHMENTS_POS,4);
  }
  
! static gint
! findWord(const gchar * word, const gchar* str) {
!    char* ptr;
!    int len = strlen(word);
! 
!    if( (ptr=strstr(str, word)) != NULL) {
!       return (ptr==str || *(ptr-1)==' ') && 
! 	 ( *(ptr+len)==' ' || *(ptr+len)=='\0');
!    } return FALSE;
! }
! 
  static void set_menus(BalsaSendmsg *msg)
  {
     unsigned i;
  
!    for(i=0; i<sizeof(headerDescs)/sizeof(headerDescs[0]); i++)
!       if(findWord(headerDescs[i].name, balsa_app.compose_headers) ) {
! 	 // show... (well, it's already been shown).
! 	    gtk_check_menu_item_set_active(
! 	    GTK_CHECK_MENU_ITEM(view_menu[i].widget), TRUE );
!       } else {
! 	 // or hide...
! 	 GTK_SIGNAL_FUNC(view_menu[i].moreinfo)(view_menu[i].widget,msg);
!       }
  
!    /* set the charset:
!       read from the preferences set up. If not found, 
        set to the 0th set.
     */
     i = sizeof(iso_charset_names)/sizeof(iso_charset_names[0])-1;
***************
*** 1545,1551 ****
  }
  
  /* create_font_name returns iso8859 font name based on given font 
!    wildcard 'base' and given charmap (PS: verify the name).
     Algorithm: copy max first 12 fields, cutting additionally 
     at most two last, if they are constant.
  */
--- 1508,1514 ----
  }
  
  /* create_font_name returns iso8859 font name based on given font 
!    wildcard 'base' and given character set encoding.
     Algorithm: copy max first 12 fields, cutting additionally 
     at most two last, if they are constant.
  */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]