Re: Message titles



On 08/01/2004 10:32:26 AM, Darko Obradovic wrote:
Hi all,

Currently, the title for the message window is taken from a format of the preferences, which turns it to be not localized by default. All other window titles are taken from a localized default format. So I patched balsa to be consistent in this.

Any points against this? Nice effects: prefs window needs less height.

Looks good to me!  Corresponding patch for HEAD attached.

Unrelated issue: `selected headers' somehow finds itself under `Encoding', which seems quite inappropriate! I believe this belongs on the Message sub-page...but that would make the window taller again...any thoughts?

Peter
Index: libbalsa/message.c
===================================================================
RCS file: /cvs/gnome/balsa/libbalsa/message.c,v
retrieving revision 1.173
diff -u -r1.173 message.c
--- libbalsa/message.c	31 Jul 2004 08:44:37 -0000	1.173
+++ libbalsa/message.c	1 Aug 2004 15:55:05 -0000
@@ -1170,92 +1170,6 @@
     }
 }
 
-/* libbalsa_message_title:
- * create a title (for a message window, for instance)
- *
- * Arguments
- *   message    the message
- *   format     the format string
- *
- * Value
- *   pointer to a newly allocated string containing the title
- *
- * the title consists of the format string, with conversions specified
- * in one of the forms
- *   %c
- *   %wc
- *   %w.dc
- * where:
- *   c specifies the string to be inserted; current choices are:
- *     F        `From' header;
- *     f        `From' mailbox;
- *     s        subject;
- *     %        literal '%' character
- *   w specifies the maximum field width; 
- *   d specifies a number trailing dots to indicate truncation.
- */
-gchar *
-libbalsa_message_title(LibBalsaMessage * message, const gchar * format)
-{
-    GString *string = g_string_new("");
-    gchar *tmp;
-    gchar *tmp1;
-
-    while ((tmp = strchr(format, '%')) != NULL) {
-        gint c;
-        gint length = 0;
-        gint dots = 0;
-
-        while (format < tmp)
-            g_string_append_c(string, *format++);
-
-        while (isdigit(c = *++format))
-            length = 10 * length + (c - '0');
-
-        if (c == '.')
-            while (isdigit(c = *++format))
-                dots = 10 * dots + (c - '0');
-
-        switch (c) {
-        case 'f':
-            tmp = g_strdup(message->headers->from ?
-                           libbalsa_address_get_mailbox(message->headers->from, 0)
-                           : "");
-            break;
-        case 'F':
-            tmp = message->headers->from ?
-                  libbalsa_address_to_gchar(message->headers->from, 0) : g_strdup("");
-            break;
-        case 's':
-            tmp = g_strdup(LIBBALSA_MESSAGE_GET_SUBJECT(message));
-            break;
-        case '%':
-            tmp = g_strdup("%");
-            break;
-        default:
-            tmp = g_strdup("???");
-            break;
-        }
-
-        tmp1 = libbalsa_truncate_string(tmp, length, dots);
-        g_free(tmp);
-        if (tmp1) {
-            g_string_append(string, tmp1);
-            g_free(tmp1);
-        }
-
-        if (c)
-            ++format;
-    }
-
-    if (*format)
-        g_string_append(string, format);
-
-    tmp = string->str;
-    g_string_free(string, FALSE);
-    return tmp;
-}
-
 /* set a header, if (all) or if it's needed all the time:
  *   headers->from
  *   headers->date
Index: libbalsa/message.h
===================================================================
RCS file: /cvs/gnome/balsa/libbalsa/message.h,v
retrieving revision 1.74
diff -u -r1.74 message.h
--- libbalsa/message.h	28 Jul 2004 11:16:16 -0000	1.74
+++ libbalsa/message.h	1 Aug 2004 15:55:05 -0000
@@ -333,8 +333,6 @@
 /*
  * misc message releated functions
  */
-gchar *libbalsa_message_title(LibBalsaMessage * message,
-                              const gchar * format);
 gchar **libbalsa_create_hdr_pair(const gchar * name, gchar * value);
 
 const gchar *libbalsa_message_pathname(LibBalsaMessage * message);
Index: src/balsa-app.h
===================================================================
RCS file: /cvs/gnome/balsa/src/balsa-app.h,v
retrieving revision 1.206
diff -u -r1.206 balsa-app.h
--- src/balsa-app.h	31 Jul 2004 19:19:22 -0000	1.206
+++ src/balsa-app.h	1 Aug 2004 15:55:05 -0000
@@ -273,7 +273,6 @@
     ShownHeaders shown_headers;
     gboolean show_all_headers;
     gchar *selected_headers;
-    gchar *message_title_format;
     gboolean expand_tree;
     gboolean show_mblist;
     gboolean show_notebook_tabs;
Index: src/message-window.c
===================================================================
RCS file: /cvs/gnome/balsa/src/message-window.c,v
retrieving revision 1.73
diff -u -r1.73 message-window.c
--- src/message-window.c	23 Jul 2004 17:18:19 -0000	1.73
+++ src/message-window.c	1 Aug 2004 15:55:06 -0000
@@ -263,15 +263,20 @@
     BalsaMessage *msg = BALSA_MESSAGE(mw->bmessage);
     LibBalsaMessage *message = mw->message;
     gchar *title;
+    gchar *from;
 
     gdk_threads_enter();
 
     mw->idle_handler_id = 0;
 
-    title = libbalsa_message_title(message,
-                                   balsa_app.message_title_format);
+    /* set window title */
+    from = libbalsa_address_to_gchar(message->headers->from, 0);
+    title = g_strdup_printf(_("Message from %s: %s"), from,
+                            LIBBALSA_MESSAGE_GET_SUBJECT(message));
+    g_free(from);
     gtk_window_set_title(GTK_WINDOW(mw->window), title);
     g_free(title);
+
     balsa_message_set(msg, message);
     balsa_message_set_close(msg, TRUE);
 
Index: src/pref-manager.c
===================================================================
RCS file: /cvs/gnome/balsa/src/pref-manager.c,v
retrieving revision 1.221
diff -u -r1.221 pref-manager.c
--- src/pref-manager.c	31 Jul 2004 19:19:22 -0000	1.221
+++ src/pref-manager.c	1 Aug 2004 15:55:07 -0000
@@ -38,7 +38,6 @@
 #include <libesmtp.h>
 #endif
 
-#define NUM_TOOLBAR_MODES 3
 #define NUM_ENCODING_MODES 3
 #define NUM_PWINDOW_MODES 3
 #define NUM_THREADING_STYLES 3
@@ -127,7 +126,6 @@
     GtkWidget *date_format;
 
     GtkWidget *selected_headers;
-    GtkWidget *message_title_format;
 
     /* colours */
     GtkWidget *quoted_color[MAX_QUOTED_COLOR];
@@ -599,10 +597,6 @@
     g_signal_connect(G_OBJECT(pui->selected_headers), "changed",
 		     G_CALLBACK(properties_modified_cb), property_box);
 
-    /* Format for the title of the message window */
-    g_signal_connect(G_OBJECT(pui->message_title_format), "changed",
-		     G_CALLBACK(properties_modified_cb), property_box);
-
     /* Colour */
     for(i=0;i<MAX_QUOTED_COLOR;i++)
 	g_signal_connect(G_OBJECT(pui->quoted_color[i]), "released",
@@ -857,12 +851,6 @@
 	g_ascii_strdown(gtk_entry_get_text(GTK_ENTRY(pui->selected_headers)),
                         -1);
 
-    /* message window title format */
-    g_free(balsa_app.message_title_format);
-    balsa_app.message_title_format =
-        gtk_editable_get_chars(GTK_EDITABLE(pui->message_title_format),
-                               0, -1);
-
     /* quoted text color */
     for(i=0;i<MAX_QUOTED_COLOR;i++) {
 	gdk_colormap_free_colors(gdk_drawable_get_colormap
@@ -1145,11 +1133,6 @@
 	gtk_entry_set_text(GTK_ENTRY(pui->selected_headers),
 			   balsa_app.selected_headers);
 
-    /* message window title format */
-    if (balsa_app.message_title_format)
-	gtk_entry_set_text(GTK_ENTRY(pui->message_title_format),
-			   balsa_app.message_title_format);
-
     /* Colour */
     for(i=0;i<MAX_QUOTED_COLOR;i++)
 	gnome_color_picker_set_i16(GNOME_COLOR_PICKER(pui->quoted_color[i]),
@@ -2072,8 +2055,6 @@
         attach_entry(_("Date encoding (for strftime):"), 0, GTK_TABLE(table));
     pui->selected_headers =
         attach_entry(_("Selected headers:"), 1, GTK_TABLE(table));
-    pui->message_title_format =
-        attach_entry(_("Message window title format:"), 2, GTK_TABLE(table));
 
     return group;
 }
Index: src/save-restore.c
===================================================================
RCS file: /cvs/gnome/balsa/src/save-restore.c,v
retrieving revision 1.283
diff -u -r1.283 save-restore.c
--- src/save-restore.c	31 Jul 2004 19:19:22 -0000	1.283
+++ src/save-restore.c	1 Aug 2004 15:55:08 -0000
@@ -668,12 +668,6 @@
         g_free(tmp);
     }
 
-    /* ... Message window title format */
-    g_free(balsa_app.message_title_format);
-    balsa_app.message_title_format =
-        gnome_config_get_string("MessageTitleFormat="
-                                DEFAULT_MESSAGE_TITLE_FORMAT);
-
     balsa_app.expand_tree = gnome_config_get_bool("ExpandTree=false");
 
     {                             /* scope */
@@ -1094,8 +1088,6 @@
     gnome_config_set_string("DateFormat", balsa_app.date_string);
     gnome_config_set_int("ShownHeaders", balsa_app.shown_headers);
     gnome_config_set_string("SelectedHeaders", balsa_app.selected_headers);
-    gnome_config_set_string("MessageTitleFormat",
-                            balsa_app.message_title_format);
     gnome_config_set_bool("ExpandTree", balsa_app.expand_tree);
     gnome_config_set_int("ThreadingType",
 			 libbalsa_mailbox_get_threading_type(NULL));



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