patch: reading signature file when needed



I've changed Balsa to read the signature file every time the signature
is needed, to allow the user to edit the file without restarting
Balsa. The included patch, which was diffed against the 1999-12-26 CVS
version, will apply the changes.

I still miss an answer to whether patches are welcome here. Does
someone apply patches that are mailed to this list to the CVS tree?
Who decides what patches goes in there? (I tried mailing my first
patch to peter@newton.cx, but it bounced back after a couple of days.)


Sverre.

-- 
<URL:mailto:sverrehu@online.no>
<URL:http://home.sol.no/~sverrehu/>
diff -rc balsa.shh.bcc/ChangeLog balsa.shh.signature/ChangeLog
*** balsa.shh.bcc/ChangeLog	Sun Dec 26 22:48:48 1999
--- balsa.shh.signature/ChangeLog	Sun Dec 26 23:16:25 1999
***************
*** 1,3 ****
--- 1,9 ----
+ 1999-12-26  Sverre H. Huseby  <sverrehu@online.no>
+ 
+ 	* src/balsa-app.h, src/balsa-app.c, src/sendmsg-window.c: Changed
+ 	to read signature file every time it is needed, to let the user
+ 	edit the signature without restarting Balsa.
+ 
  1999-12-24  Héctor García Álvarez <hector@scouts-es.org>
  	* libbalsa/send.c: Now Balsa send queued messages as it should.
   
diff -rc balsa.shh.bcc/src/balsa-app.c balsa.shh.signature/src/balsa-app.c
*** balsa.shh.bcc/src/balsa-app.c	Tue Dec 21 20:21:39 1999
--- balsa.shh.signature/src/balsa-app.c	Sun Dec 26 22:57:35 1999
***************
*** 42,48 ****
  
  /* prototypes */
  static void special_mailboxes (void);
- static gint read_signature (void);
  
  
  static void
--- 42,47 ----
***************
*** 145,151 ****
  do_load_mailboxes (void)
  {
    load_local_mailboxes ();
-   read_signature ();
    special_mailboxes ();
  
    if (!balsa_app.inbox)
--- 144,149 ----
***************
*** 171,200 ****
        break;
      }
  
-   return TRUE;
- }
- 
- static gint
- read_signature (void)
- {
-   FILE *fp;
-   size_t len;
- 
-   g_free (balsa_app.signature);
- 
-   if (!(fp = fopen (balsa_app.signature_path, "r")))
-     return FALSE;
-   len = readfile (fp, &balsa_app.signature);
-   if (len != 0) {
- /*    balsa_app.signature[len - 1] = '\0'; This may strip the last 
-       character of the user's sig if it does not end with a newline.
-  */
-       if( balsa_app.signature[len - 1] == '\n' ) 
- 	  balsa_app.signature[len - 1] = '\0';
-       else
- 	  balsa_app.signature[len] = '\0';
-   }
-   fclose (fp);
    return TRUE;
  }
  
--- 169,174 ----
diff -rc balsa.shh.bcc/src/balsa-app.h balsa.shh.signature/src/balsa-app.h
*** balsa.shh.bcc/src/balsa-app.h	Tue Dec 21 20:05:25 1999
--- balsa.shh.signature/src/balsa-app.h	Sun Dec 26 22:55:35 1999
***************
*** 82,88 ****
    gboolean sig_whenforward;
    gboolean sig_whenreply;
    gchar *signature_path;
-   gchar *signature;
    
    BalsaMBList *mblist;
    
--- 82,87 ----
diff -rc balsa.shh.bcc/src/sendmsg-window.c balsa.shh.signature/src/sendmsg-window.c
*** balsa.shh.bcc/src/sendmsg-window.c	Sun Dec 26 22:47:02 1999
--- balsa.shh.signature/src/sendmsg-window.c	Sun Dec 26 23:12:49 1999
***************
*** 41,46 ****
--- 41,47 ----
  #include "sendmsg-window.h"
  #include "address-book.h"
  
+ static gchar *read_signature (void);
  static gint send_message_cb (GtkWidget *, BalsaSendmsg *);
  static gint postpone_message_cb (GtkWidget *, BalsaSendmsg *);
  static gint attach_clicked (GtkWidget *, gpointer);
***************
*** 550,555 ****
--- 551,557 ----
    GtkWidget *window;
    GtkWidget *paned = gtk_vpaned_new ();
    gchar *newsubject = NULL;
+   gchar *signature;
  
    BalsaSendmsg *msg = NULL;
  
***************
*** 790,800 ****
        message_body_unref (message);
      }
  
!   if (balsa_app.signature && type != SEND_CONTINUE) {
       if ( ((type == SEND_REPLY || type == SEND_REPLY_ALL) && balsa_app.sig_whenreply) ||
  	  ( (type == SEND_FORWARD) && balsa_app.sig_whenforward) ||
  	  ( (type == SEND_NORMAL) && balsa_app.sig_sending) )
! 	      gtk_text_insert (GTK_TEXT (msg->text), NULL, NULL, NULL, balsa_app.signature, strlen (balsa_app.signature));
      }
    gtk_text_set_point (GTK_TEXT (msg->text), 0);
    gtk_text_thaw (GTK_TEXT (msg->text));
--- 792,803 ----
        message_body_unref (message);
      }
  
!   if ((signature = read_signature()) != NULL && type != SEND_CONTINUE) {
       if ( ((type == SEND_REPLY || type == SEND_REPLY_ALL) && balsa_app.sig_whenreply) ||
  	  ( (type == SEND_FORWARD) && balsa_app.sig_whenforward) ||
  	  ( (type == SEND_NORMAL) && balsa_app.sig_sending) )
! 	      gtk_text_insert (GTK_TEXT (msg->text), NULL, NULL, NULL, signature, strlen (signature));
!      g_free (signature);
      }
    gtk_text_set_point (GTK_TEXT (msg->text), 0);
    gtk_text_thaw (GTK_TEXT (msg->text));
***************
*** 813,818 ****
--- 816,842 ----
  
    /* display the window */
    gtk_widget_show_all (window);
+ }
+ 
+ static gchar *
+ read_signature (void)
+ {
+   FILE *fp;
+   size_t len;
+   gchar *ret;
+ 
+   if (balsa_app.signature_path == NULL
+       || !(fp = fopen (balsa_app.signature_path, "r")))
+     return NULL;
+   len = readfile (fp, &ret);
+   fclose (fp);
+   if (len > 0) {
+     if (ret[len - 1] == '\n')
+       ret[len - 1] = '\0';
+     else
+       ret[len] = '\0';
+   }
+   return ret;
  }
  
  static gint


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