Re: [PATCH] compose window



Use this patch, It should apply fine in src/

Christophe

Le 2001.07.07 01:00:21 +0200, christophe barbe a écrit :
> Hello,
> 
> I attach to this mail a patch to save/restore the sendmsg (compose)
> window.
> 
> Actually the size is set by the text widget size which is set to display
> 20
> lines and the width of the outgoing wrapped size. This is not really good
> because you don't need to display 75 chars if you wrap outgoing mail to
> 75
> chars. The text widget wrap displayed text.
> It could sound as a good idea but If you set  a big font size or have a
> little display (like me) you cannot see the full compose window. And
> because the size is set with the texxt widget size you cannot decrease it
> to fit your screen. So this patch is really required.
> 
> So this patch set the initial size to 640x480 (like for the main window)
> and save the user choice.
> 
> Hope this patch will be commited in cvs.
> 
> Friendly,
> Christophe
> diff -u -b -B -r ../../balsa/src/balsa-app.c ./balsa-app.c
> --- ../../balsa/src/balsa-app.c	Tue Jun 19 10:50:05 2001
> +++ ./balsa-app.c	Sat Jul  7 00:02:37 2001
> @@ -242,6 +242,8 @@
>      balsa_app.mblist_width = 100;
>      balsa_app.mw_width = MW_DEFAULT_WIDTH;
>      balsa_app.mw_height = MW_DEFAULT_HEIGHT;
> +    balsa_app.sw_width = 0;
> +    balsa_app.sw_height = 0;
>      balsa_app.toolbar_style = GTK_TOOLBAR_BOTH;
>      balsa_app.pwindow_option = WHILERETR;
>      balsa_app.wordwrap = TRUE;
> diff -u -b -B -r ../../balsa/src/balsa-app.h ./balsa-app.h
> --- ../../balsa/src/balsa-app.h	Sun Jul  1 17:11:06 2001
> +++ ./balsa-app.h	Sat Jul  7 00:01:35 2001
> @@ -205,6 +205,8 @@
>      gint mw_width;
>      gint mw_height;
>      gint mblist_width;
> +	 gint sw_width; /* sendmsg window */
> +	 gint sw_height;
>  
>      /* file paths */
>      gchar *attach_dir;
> diff -u -b -B -r ../../balsa/src/save-restore.c ./save-restore.c
> --- ../../balsa/src/save-restore.c	Fri Jul  6 22:06:43 2001
> +++ ./save-restore.c	Sat Jul  7 00:24:24 2001
> @@ -391,6 +391,9 @@
>      balsa_app.mw_width = gnome_config_get_int("MainWindowWidth=640");
>      balsa_app.mw_height = gnome_config_get_int("MainWindowHeight=480");
>      balsa_app.mblist_width = gnome_config_get_int("MailboxListWidth=100");
> +    /* sendmsg window sizes */
> +    balsa_app.sw_width = gnome_config_get_int("SendMsgWindowWidth=640");
> +    balsa_app.sw_height = gnome_config_get_int("SendMsgWindowHeight=480");
>      /* FIXME: PKGW: why comment this out? Breaks my Transfer context
> menu. */
>      if (balsa_app.mblist_width < 100)
>  	balsa_app.mblist_width = 170;
> @@ -672,6 +675,8 @@
>      gnome_config_set_int("MainWindowWidth", balsa_app.mw_width);
>      gnome_config_set_int("MainWindowHeight", balsa_app.mw_height);
>      gnome_config_set_int("MailboxListWidth", balsa_app.mblist_width);
> +    gnome_config_set_int("SendMsgWindowWidth", balsa_app.sw_width);
> +    gnome_config_set_int("SendMsgWindowHeight", balsa_app.sw_height);
>      gnome_config_set_int("NotebookHeight", balsa_app.notebook_height);
>  
>      gnome_config_pop_prefix();
> diff -u -b -B -r ../../balsa/src/sendmsg-window.c ./sendmsg-window.c
> --- ../../balsa/src/sendmsg-window.c	Fri Jul  6 22:06:43 2001
> +++ ./sendmsg-window.c	Sat Jul  7 00:27:10 2001
> @@ -113,6 +113,8 @@
>  static void change_identity_dialog_cb(GtkWidget*, BalsaSendmsg*);
>  static void update_msg_identity(BalsaSendmsg*, BalsaIdentity*);
>  
> +static void sw_size_alloc_cb(GtkWidget * window, GtkAllocation * alloc);
> +
>  /* Standard DnD types */
>  enum {
>      TARGET_URI_LIST,
> @@ -640,6 +642,14 @@
>  }
>  
>  
> +static void
> +sw_size_alloc_cb(GtkWidget * window, GtkAllocation * alloc)
> +{
> +    balsa_app.sw_height = alloc->height;
> +    balsa_app.sw_width = alloc->width;
> +}
> +
> +
>  
>  /* remove_attachment - right mouse button callback */
>  static void
> @@ -1340,7 +1350,6 @@
>      BalsaSendmsg *msg = NULL;
>      GList *list;
>      gint i;
> -    gint width;
>  
>      msg = g_malloc(sizeof(BalsaSendmsg));
>      msg->font     = NULL;
> @@ -1390,6 +1399,9 @@
>      gtk_signal_connect(GTK_OBJECT(msg->window), "destroy_event",
>  		       GTK_SIGNAL_FUNC(delete_event_cb), msg);
>  
> +	 gtk_signal_connect(GTK_OBJECT(msg->window), "size_allocate",
> +		       GTK_SIGNAL_FUNC(sw_size_alloc_cb), msg);
> +
>      fill_language_menu();
>  
>      gnome_app_create_menus_with_data(GNOME_APP(window), main_menu, msg);
> @@ -1621,23 +1633,12 @@
>      gtk_notebook_set_page(GTK_NOTEBOOK(msg->notebook),
> mail_headers_page);
>  
>      /*
> -     * Set the size of the text widget according to the user
> -     * preferences (font and line_wrap).
> +     * restore the SendMsg window size
>       */
> -    if (balsa_app.wordwrap && (balsa_app.wraplength > 0))
> -	/* Text of wrap + text of gtk_text next-line character */
> -	width = balsa_app.wraplength + 2;
> -    else
> -	width = 82;
> -    gtk_widget_set_usize(msg->text,
> -	    		 /* Width of the text. */
> -			 (width * gdk_char_width(msg->font, 'M')) +
> -			 /* Width of the borders inside/outside box */
> -			 (2 * msg->text->style->klass->xthickness),
> -	    		 /* Height of the text. */
> -			 (20 * gdk_char_height(msg->font, 'M')) +
> -			 /* Height of the borders inside/outside box */
> -			 (2 * msg->text->style->klass->ythickness));
> +    gtk_window_set_default_size(GTK_WINDOW(window), 
> +			balsa_app.sw_width,
> +			balsa_app.sw_height);
> +
>      gtk_window_set_wmclass(GTK_WINDOW(window), "compose", "Balsa");
>  
>      gtk_widget_show(window);
> 
diff -u -b -B -r balsa-app.c balsa-app.c
--- balsa-app.c	Tue Jun 19 10:50:05 2001
+++ balsa-app.c	Sat Jul  7 00:02:37 2001
@@ -242,6 +242,8 @@
     balsa_app.mblist_width = 100;
     balsa_app.mw_width = MW_DEFAULT_WIDTH;
     balsa_app.mw_height = MW_DEFAULT_HEIGHT;
+    balsa_app.sw_width = 0;
+    balsa_app.sw_height = 0;
     balsa_app.toolbar_style = GTK_TOOLBAR_BOTH;
     balsa_app.pwindow_option = WHILERETR;
     balsa_app.wordwrap = TRUE;
diff -u -b -B -r balsa-app.h balsa-app.h
--- balsa-app.h	Sun Jul  1 17:11:06 2001
+++ balsa-app.h	Sat Jul  7 00:01:35 2001
@@ -205,6 +205,8 @@
     gint mw_width;
     gint mw_height;
     gint mblist_width;
+	 gint sw_width; /* sendmsg window */
+	 gint sw_height;
 
     /* file paths */
     gchar *attach_dir;
diff -u -b -B -r save-restore.c save-restore.c
--- save-restore.c	Fri Jul  6 22:06:43 2001
+++ save-restore.c	Sat Jul  7 00:24:24 2001
@@ -391,6 +391,9 @@
     balsa_app.mw_width = gnome_config_get_int("MainWindowWidth=640");
     balsa_app.mw_height = gnome_config_get_int("MainWindowHeight=480");
     balsa_app.mblist_width = gnome_config_get_int("MailboxListWidth=100");
+    /* sendmsg window sizes */
+    balsa_app.sw_width = gnome_config_get_int("SendMsgWindowWidth=640");
+    balsa_app.sw_height = gnome_config_get_int("SendMsgWindowHeight=480");
     /* FIXME: PKGW: why comment this out? Breaks my Transfer context menu. */
     if (balsa_app.mblist_width < 100)
 	balsa_app.mblist_width = 170;
@@ -672,6 +675,8 @@
     gnome_config_set_int("MainWindowWidth", balsa_app.mw_width);
     gnome_config_set_int("MainWindowHeight", balsa_app.mw_height);
     gnome_config_set_int("MailboxListWidth", balsa_app.mblist_width);
+    gnome_config_set_int("SendMsgWindowWidth", balsa_app.sw_width);
+    gnome_config_set_int("SendMsgWindowHeight", balsa_app.sw_height);
     gnome_config_set_int("NotebookHeight", balsa_app.notebook_height);
 
     gnome_config_pop_prefix();
diff -u -b -B -r sendmsg-window.c sendmsg-window.c
--- sendmsg-window.c	Fri Jul  6 22:06:43 2001
+++ sendmsg-window.c	Sat Jul  7 00:27:10 2001
@@ -113,6 +113,8 @@
 static void change_identity_dialog_cb(GtkWidget*, BalsaSendmsg*);
 static void update_msg_identity(BalsaSendmsg*, BalsaIdentity*);
 
+static void sw_size_alloc_cb(GtkWidget * window, GtkAllocation * alloc);
+
 /* Standard DnD types */
 enum {
     TARGET_URI_LIST,
@@ -640,6 +642,14 @@
 }
 
 
+static void
+sw_size_alloc_cb(GtkWidget * window, GtkAllocation * alloc)
+{
+    balsa_app.sw_height = alloc->height;
+    balsa_app.sw_width = alloc->width;
+}
+
+
 
 /* remove_attachment - right mouse button callback */
 static void
@@ -1340,7 +1350,6 @@
     BalsaSendmsg *msg = NULL;
     GList *list;
     gint i;
-    gint width;
 
     msg = g_malloc(sizeof(BalsaSendmsg));
     msg->font     = NULL;
@@ -1390,6 +1399,9 @@
     gtk_signal_connect(GTK_OBJECT(msg->window), "destroy_event",
 		       GTK_SIGNAL_FUNC(delete_event_cb), msg);
 
+	 gtk_signal_connect(GTK_OBJECT(msg->window), "size_allocate",
+		       GTK_SIGNAL_FUNC(sw_size_alloc_cb), msg);
+
     fill_language_menu();
 
     gnome_app_create_menus_with_data(GNOME_APP(window), main_menu, msg);
@@ -1621,23 +1633,12 @@
     gtk_notebook_set_page(GTK_NOTEBOOK(msg->notebook), mail_headers_page);
 
     /*
-     * Set the size of the text widget according to the user
-     * preferences (font and line_wrap).
+     * restore the SendMsg window size
      */
-    if (balsa_app.wordwrap && (balsa_app.wraplength > 0))
-	/* Text of wrap + text of gtk_text next-line character */
-	width = balsa_app.wraplength + 2;
-    else
-	width = 82;
-    gtk_widget_set_usize(msg->text,
-	    		 /* Width of the text. */
-			 (width * gdk_char_width(msg->font, 'M')) +
-			 /* Width of the borders inside/outside box */
-			 (2 * msg->text->style->klass->xthickness),
-	    		 /* Height of the text. */
-			 (20 * gdk_char_height(msg->font, 'M')) +
-			 /* Height of the borders inside/outside box */
-			 (2 * msg->text->style->klass->ythickness));
+    gtk_window_set_default_size(GTK_WINDOW(window), 
+			balsa_app.sw_width,
+			balsa_app.sw_height);
+
     gtk_window_set_wmclass(GTK_WINDOW(window), "compose", "Balsa");
 
     gtk_widget_show(window);


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