Message titles



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.

This leaves a function in libbalsa unused and removed. By surfing the code I also removed another unused constant from gtk1-days I think.

As I don't use 2.2.x yet the patch is for 2.0.18, no idea if it applies to 2.2 as well, but it should be easy to adapt.

bye,

Darko
diff -ruN balsa-2.0.18/libbalsa/message.c balsa-2.0.18-localizable-messagetitle/libbalsa/message.c
--- balsa-2.0.18/libbalsa/message.c	2004-02-07 14:24:01.000000000 +0100
+++ balsa-2.0.18-localizable-messagetitle/libbalsa/message.c	2004-08-01 15:50:58.369834736 +0200
@@ -1355,89 +1355,3 @@
     }
 }
 
-/* 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;
-}
-
diff -ruN balsa-2.0.18/libbalsa/message.h balsa-2.0.18-localizable-messagetitle/libbalsa/message.h
--- balsa-2.0.18/libbalsa/message.h	2004-02-07 14:24:01.000000000 +0100
+++ balsa-2.0.18-localizable-messagetitle/libbalsa/message.h	2004-08-01 15:51:54.221344016 +0200
@@ -289,8 +289,6 @@
         libbalsa_message_headers_date_to_gchar((m)->headers,s)
 gchar *libbalsa_message_size_to_gchar(LibBalsaMessage * message,
                                       gboolean lines);
-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);
diff -ruN balsa-2.0.18/src/balsa-app.h balsa-2.0.18-localizable-messagetitle/src/balsa-app.h
--- balsa-2.0.18/src/balsa-app.h	2004-02-08 01:14:24.000000000 +0100
+++ balsa-2.0.18-localizable-messagetitle/src/balsa-app.h	2004-08-01 15:09:30.656024720 +0200
@@ -277,7 +277,6 @@
     ShownHeaders shown_headers;
     gboolean show_all_headers;
     gchar *selected_headers;
-    gchar *message_title_format;
     LibBalsaMailboxThreadingType threading_type;
     gboolean expand_tree;
     gboolean show_mblist;
diff -ruN balsa-2.0.18/src/message-window.c balsa-2.0.18-localizable-messagetitle/src/message-window.c
--- balsa-2.0.18/src/message-window.c	2004-05-15 22:19:28.000000000 +0200
+++ balsa-2.0.18-localizable-messagetitle/src/message-window.c	2004-08-01 16:06:47.748507240 +0200
@@ -262,16 +262,25 @@
 {
     BalsaMessage *msg = BALSA_MESSAGE(mw->bmessage);
     LibBalsaMessage *message = mw->message;
+    gchar *title_format;
     gchar *title;
+    gchar *from;
+    gchar *subject;
 
     gdk_threads_enter();
 
     mw->idle_handler_id = 0;
 
-    title = libbalsa_message_title(message,
-				   balsa_app.message_title_format);
+    /* set window title */
+	title_format = _("Message from %s: %s");
+	from = libbalsa_address_to_gchar(message->headers->from, 0);
+	subject = g_strdup(LIBBALSA_MESSAGE_GET_SUBJECT(message));
+	title = g_strdup_printf(title_format, from, subject);
+	g_free(from);
+	g_free(subject);
     gtk_window_set_title(GTK_WINDOW(mw->window), title);
     g_free(title);
+
     balsa_message_set(msg, message);
 
     if(msg && msg->treeview) {
diff -ruN balsa-2.0.18/src/pref-manager.c balsa-2.0.18-localizable-messagetitle/src/pref-manager.c
--- balsa-2.0.18/src/pref-manager.c	2003-11-22 00:53:05.000000000 +0100
+++ balsa-2.0.18-localizable-messagetitle/src/pref-manager.c	2004-08-01 15:16:47.492615464 +0200
@@ -41,7 +41,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
@@ -131,7 +130,6 @@
     GtkWidget *date_format;
 
     GtkWidget *selected_headers;
-    GtkWidget *message_title_format;
 
     /* colours */
     GtkWidget *unread_color;
@@ -613,10 +611,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 */
     g_signal_connect(G_OBJECT(pui->unread_color), "released",
 		     G_CALLBACK(properties_modified_cb), property_box);
@@ -877,13 +871,6 @@
     balsa_app.selected_headers =
 	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);
-
     /* unread mailbox color */
     gdk_colormap_free_colors(gdk_drawable_get_colormap
 			     (GTK_WIDGET(pbox)->window),
@@ -1179,11 +1166,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 */
     gnome_color_picker_set_i16(GNOME_COLOR_PICKER(pui->unread_color),
 			       balsa_app.mblist_unread_color.red,
@@ -2117,8 +2099,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;
 }
diff -ruN balsa-2.0.18/src/save-restore.c balsa-2.0.18-localizable-messagetitle/src/save-restore.c
--- balsa-2.0.18/src/save-restore.c	2004-02-08 01:14:24.000000000 +0100
+++ balsa-2.0.18-localizable-messagetitle/src/save-restore.c	2004-08-01 15:18:11.844791984 +0200
@@ -654,12 +654,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");
     balsa_app.threading_type = d_get_gint("ThreadingType", 
 					  LB_MAILBOX_THREADING_JWZ);
@@ -1072,8 +1066,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", balsa_app.threading_type);
     gnome_config_set_string("QuoteRegex", balsa_app.quote_regex);


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