2006-09-01 [colin] 2.4.0cvs127
authorColin Leroy <colin@colino.net>
Fri, 1 Sep 2006 17:13:59 +0000 (17:13 +0000)
committerColin Leroy <colin@colino.net>
Fri, 1 Sep 2006 17:13:59 +0000 (17:13 +0000)
* src/codeconv.c
Don't uselessly use iconv to convert from
us-ascii
* src/alertpanel.c
* src/mainwindow.c
* src/mainwindow.h
* src/inc.c
Fix certain log cases, disable warning icon
for now, the correct way to display it when
necessary and only when necessary is probably
to do it manually rather than use error logs
* src/etpan/imap-thread.c
Clean up UID logging a bit
* src/gtk/logwindow.c
* src/gtk/logwindow.h
Make logging faster when the window's closed

ChangeLog
PATCHSETS
configure.ac
src/alertpanel.c
src/codeconv.c
src/etpan/imap-thread.c
src/gtk/logwindow.c
src/gtk/logwindow.h
src/inc.c
src/mainwindow.c
src/mainwindow.h

index 1929df26000037329b4d1787977670783482ca60..bf4259fd788533745086c35e8589232504abc338 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2006-09-01 [colin]     2.4.0cvs127
+
+       * src/codeconv.c
+               Don't uselessly use iconv to convert from
+               us-ascii
+       * src/alertpanel.c
+       * src/mainwindow.c
+       * src/mainwindow.h
+       * src/inc.c
+               Fix certain log cases, disable warning icon
+               for now, the correct way to display it when
+               necessary and only when necessary is probably
+               to do it manually rather than use error logs
+       * src/etpan/imap-thread.c
+               Clean up UID logging a bit
+       * src/gtk/logwindow.c
+       * src/gtk/logwindow.h
+               Make logging faster when the window's closed
+
 2006-09-01 [wwp]       2.4.0cvs126
 
        * manual/fr/account.xml
index f9599557cc1bfdb79bd3d07ca467c8ae486da477..6f87f7c9307fa48adbfe15386fe76a16d261d7a1 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.1.2.31 -r 1.1.2.32 commitHelper;  ) > 2.4.0cvs124.patchset
 ( cvs diff -u -r 1.1.2.5 -r 1.1.2.6 manual/fr/plugins.xml;  ) > 2.4.0cvs125.patchset
 ( cvs diff -u -r 1.1.2.5 -r 1.1.2.6 manual/fr/account.xml;  ) > 2.4.0cvs126.patchset
+( cvs diff -u -r 1.17.2.26 -r 1.17.2.27 src/alertpanel.c;  cvs diff -u -r 1.65.2.48 -r 1.65.2.49 src/codeconv.c;  cvs diff -u -r 1.149.2.56 -r 1.149.2.57 src/inc.c;  cvs diff -u -r 1.274.2.142 -r 1.274.2.143 src/mainwindow.c;  cvs diff -u -r 1.39.2.21 -r 1.39.2.22 src/mainwindow.h;  cvs diff -u -r 1.1.4.48 -r 1.1.4.49 src/etpan/imap-thread.c;  cvs diff -u -r 1.1.4.17 -r 1.1.4.18 src/gtk/logwindow.c;  cvs diff -u -r 1.1.4.4 -r 1.1.4.5 src/gtk/logwindow.h;  ) > 2.4.0cvs127.patchset
index 1d2d1cb8f4fc40681d8672fee2196d307462b60d..b514b38def06d33b031b9999e8022b69944cc4d3 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=4
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=126
+EXTRA_VERSION=127
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index e0918ac003a7380dd12fb245cdf1f81bee29deaa..482fb336ccf5a8d9c70dc3b38f9907d1d0c9ada4 100644 (file)
@@ -186,6 +186,7 @@ void alertpanel_error_log(const gchar *format, ...)
        mainwin = mainwindow_get_mainwindow();
        
        if (mainwin && mainwin->logwin) {
+               mainwindow_clear_error(mainwin);
                val = alertpanel_full(_("Error"), buf, GTK_STOCK_CLOSE,
                                      _("_View log"), NULL, FALSE, NULL,
                                      ALERT_ERROR, G_ALERTDEFAULT);
index 759b798654f72a605426eb6ffb4ad0a9eec3585e..a12632c85168a43004585181d32ce8d8e181e0b9 100644 (file)
@@ -823,7 +823,11 @@ gchar *conv_iconv_strdup(const gchar *inbuf,
        if (!strcasecmp(src_code, dest_code))
                return g_strdup(inbuf);
 
-       /* don't convert if current codeset is US-ASCII */
+       /* don't convert if dest codeset is US-ASCII */
+       if (!strcasecmp(src_code, CS_US_ASCII))
+               return g_strdup(inbuf);
+
+       /* don't convert if dest codeset is US-ASCII */
        if (!strcasecmp(dest_code, CS_US_ASCII))
                return g_strdup(inbuf);
 
index 8154736415eaed976c88c1a4c4838c9f8cf2a121..24e8a4ff0bdd338b2af304dccd82608c733a4726 100644 (file)
@@ -41,7 +41,7 @@ static gboolean thread_manager_event(GIOChannel * source,
        return TRUE;
 }
 
-void imap_logger_cmd(int direction, const char * str, size_t size) 
+static void imap_logger_cmd(int direction, const char * str, size_t size) 
 {
        gchar *buf;
        gchar **lines;
@@ -72,7 +72,7 @@ void imap_logger_cmd(int direction, const char * str, size_t size)
        free(buf);
 }
 
-void imap_logger_fetch(int direction, const char * str, size_t size) 
+static void imap_logger_fetch(int direction, const char * str, size_t size) 
 {
        gchar *buf;
        gchar **lines;
@@ -106,7 +106,7 @@ void imap_logger_fetch(int direction, const char * str, size_t size)
        free(buf);
 }
 
-void imap_logger_uid(int direction, const char * str, size_t size) 
+static void imap_logger_uid(int direction, const char * str, size_t size) 
 {
        gchar *buf;
        gchar **lines;
@@ -128,16 +128,17 @@ void imap_logger_uid(int direction, const char * str, size_t size)
 
        lines = g_strsplit(buf, "\n", -1);
 
-       if (direction == 0 && size > 64) {
-               gchar tmp[32];
-               strncpy2(tmp, lines[0], 31);
-               log_print("IMAP4%c %s[... - %zd bytes more]\n", direction?'>':'<', tmp,
-                       size-32);
-       } else {
-               while (lines[i] && *lines[i]) {
+       while (lines[i] && *lines[i]) {
+               int llen = strlen(lines[i]);
+               if (llen < 64)
                        log_print("IMAP4%c %s\n", direction?'>':'<', lines[i]);
-                       i++;
+               else {
+                       gchar tmp[64];
+                       strncpy2(tmp, lines[i], 63);
+                       log_print("IMAP4%c %s[... - %zd bytes more]\n", direction?'>':'<', tmp,
+                                 llen-64);
                }
+               i++;
        }
        g_strfreev(lines);
        free(buf);
index 38bf49562895ec9cd4697136cdb55c0762619314..28aa814410c6c19d733aa96ad5d1a217bc0a8506 100644 (file)
@@ -49,7 +49,7 @@ static void size_allocate_cb  (GtkWidget *widget,
                                         GtkAllocation *allocation);
 static gboolean log_window_append              (gpointer        source,
                                                 gpointer        data);
-static void log_window_clip                    (GtkWidget      *text,
+static void log_window_clip                    (LogWindow      *logwin,
                                                 guint           glip_length);
 static void log_window_clear                   (GtkWidget      *widget,
                                                 LogWindow      *logwin);
@@ -90,7 +90,7 @@ LogWindow *log_window_create(void)
                         G_CALLBACK(gtk_widget_hide_on_delete), NULL);
        g_signal_connect(G_OBJECT(window), "key_press_event",
                         G_CALLBACK(key_pressed), logwin);
-       g_signal_connect(G_OBJECT(window), "hide",
+       g_signal_connect_after(G_OBJECT(window), "hide",
                         G_CALLBACK(hide_cb), logwin);
        gtk_widget_realize(window);
 
@@ -105,7 +105,8 @@ LogWindow *log_window_create(void)
        text = gtk_text_view_new();
        gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
        gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD);
-       buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
+       logwin->buffer = buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
+
        gtk_text_buffer_get_start_iter(buffer, &iter);
        gtk_text_buffer_create_mark(buffer, "end", &iter, FALSE);
        g_signal_connect(G_OBJECT(text), "populate-popup",
@@ -170,7 +171,7 @@ void log_window_init(LogWindow *logwin)
                }
        }
 
-       buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(logwin->text));
+       buffer = logwin->buffer;
        gtk_text_buffer_create_tag(buffer, "message",
                                   "foreground-gdk", &logwin->msg_color,
                                   NULL);
@@ -186,14 +187,21 @@ void log_window_init(LogWindow *logwin)
        gtk_text_buffer_create_tag(buffer, "output",
                                   "foreground-gdk", &logwin->out_color,
                                   NULL);
+
+       g_object_ref(G_OBJECT(logwin->buffer));
+       gtk_text_view_set_buffer(GTK_TEXT_VIEW(logwin->text), NULL);
+       logwin->hidden = TRUE;
 }
 
 void log_window_show(LogWindow *logwin)
 {
        GtkTextView *text = GTK_TEXT_VIEW(logwin->text);
-       GtkTextBuffer *buffer = gtk_text_view_get_buffer(text);
+       GtkTextBuffer *buffer = logwin->buffer;
        GtkTextMark *mark;
 
+       logwin->hidden = FALSE;
+       gtk_text_view_set_buffer(GTK_TEXT_VIEW(logwin->text), logwin->buffer);
+
        mark = gtk_text_buffer_get_mark(buffer, "end");
        gtk_text_view_scroll_mark_onscreen(text, mark);
 
@@ -226,7 +234,7 @@ static gboolean log_window_append(gpointer source, gpointer data)
                return FALSE;
 
        text = GTK_TEXT_VIEW(logwindow->text);
-       buffer = gtk_text_view_get_buffer(text);
+       buffer = logwindow->buffer;
        gtk_text_buffer_get_iter_at_offset(buffer, &iter, -1);
 
        switch (logtext->type) {
@@ -271,17 +279,21 @@ static gboolean log_window_append(gpointer source, gpointer data)
        gtk_text_buffer_get_start_iter(buffer, &iter);
 
        if (logwindow->clip)
-              log_window_clip (GTK_WIDGET (text), logwindow->clip_length);
+              log_window_clip (logwindow, logwindow->clip_length);
 
        gtk_text_buffer_get_iter_at_offset(buffer, &iter, -1);
-       gtk_text_view_scroll_to_iter(text, &iter, 0, TRUE, 0, 0);
-       gtk_text_buffer_place_cursor(buffer, &iter);
+       if (!logwindow->hidden) {
+               gtk_text_view_scroll_to_iter(text, &iter, 0, TRUE, 0, 0);
+               gtk_text_buffer_place_cursor(buffer, &iter);
+       }
 
        return FALSE;
 }
 
 static void hide_cb(GtkWidget *widget, LogWindow *logwin)
 {
+       gtk_text_view_set_buffer(GTK_TEXT_VIEW(logwin->text), NULL);
+       logwin->hidden = TRUE;
 }
 
 static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event,
@@ -295,12 +307,11 @@ static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event,
        return FALSE;
 }
 
-static void log_window_clip(GtkWidget *textw, guint clip_length)
+static void log_window_clip(LogWindow *logwin, guint clip_length)
 {
         guint length;
        guint point;
-       GtkTextView *textview = GTK_TEXT_VIEW(textw);
-       GtkTextBuffer *textbuf = gtk_text_view_get_buffer(textview);
+       GtkTextBuffer *textbuf = logwin->buffer;
        GtkTextIter start_iter, end_iter;
        
        length = gtk_text_buffer_get_line_count(textbuf);
@@ -320,8 +331,7 @@ static void log_window_clip(GtkWidget *textw, guint clip_length)
 
 static void log_window_clear(GtkWidget *widget, LogWindow *logwin)
 {
-       GtkTextView *textview = GTK_TEXT_VIEW(logwin->text);
-       GtkTextBuffer *textbuf = gtk_text_view_get_buffer(textview);
+       GtkTextBuffer *textbuf = logwin->buffer;
        GtkTextIter start_iter, end_iter;
        
        gtk_text_buffer_get_start_iter(textbuf, &start_iter);
index 2ed713979cb20665b94dc60e1932bf0ea9a6d8df..07a6cf49b6c646596f3880b9509713c6479c7003 100644 (file)
@@ -40,6 +40,8 @@ struct _LogWindow
        gboolean clip;
        guint    clip_length;
        guint    hook_id;
+       GtkTextBuffer *buffer;
+       gboolean hidden;
 };
 
 LogWindow *log_window_create(void);
index 180959208f90ed5bad5e2ac711ff515b2dcde7e7..c474da49365b7f1f45bb245c92be37160aad1c76 100644 (file)
--- a/src/inc.c
+++ b/src/inc.c
@@ -773,8 +773,6 @@ static IncState inc_pop3_session_do(IncSession *session)
                            prefs_common.io_timeout_secs * 1000);
        
        if (session_connect(SESSION(pop3_session), server, port) < 0) {
-               log_warning(_("Can't connect to POP3 server: %s:%d\n"),
-                           server, port);
                if(!prefs_common.no_recv_err_panel) {
                        if((prefs_common.recv_dialog_mode == RECV_DIALOG_ALWAYS) ||
                            ((prefs_common.recv_dialog_mode == RECV_DIALOG_MANUAL) && focus_window)) {
@@ -783,6 +781,9 @@ static IncState inc_pop3_session_do(IncSession *session)
                        alertpanel_error(_("Can't connect to POP3 server: %s:%d"),
                                         server, port);
                        manage_window_focus_out(inc_dialog->dialog->window, NULL, NULL);
+               } else {
+                       log_error(_("Can't connect to POP3 server: %s:%d\n"),
+                           server, port);
                }
                session->inc_state = INC_CONNECT_ERROR;
                statusbar_pop_all();
@@ -1089,14 +1090,17 @@ static void inc_put_error(IncState istate, Pop3Session *session)
        switch (istate) {
        case INC_CONNECT_ERROR:
                log_msg = _("Connection failed.");
+               fatal_error = TRUE;
                if (prefs_common.no_recv_err_panel)
                        break;
                err_msg = g_strdup_printf(_("Connection to %s:%d failed."),
                                          SESSION(session)->server, 
                                          SESSION(session)->port);
+               fatal_error = TRUE;
                break;
        case INC_ERROR:
                log_msg = _("Error occurred while processing mail.");
+               fatal_error = TRUE;
                if (prefs_common.no_recv_err_panel)
                        break;
                if (session->error_msg)
@@ -1118,6 +1122,7 @@ static void inc_put_error(IncState istate, Pop3Session *session)
                break;
        case INC_SOCKET_ERROR:
                log_msg = _("Socket error.");
+               fatal_error = TRUE;
                if (prefs_common.no_recv_err_panel)
                        break;
                err_msg = g_strdup_printf(_("Socket error on connection to %s:%d."),
@@ -1154,6 +1159,7 @@ static void inc_put_error(IncState istate, Pop3Session *session)
                break;
        case INC_TIMEOUT:
                log_msg = _("Session timed out.");
+               fatal_error = TRUE;
                if (prefs_common.no_recv_err_panel)
                        break;
                err_msg = g_strdup_printf(_("Connection to %s:%d timed out."), 
index 8b9f4582403279e46e2208315fb944590d6df407..b7d8e30e0ae05e552d6b78911b1c2b1452779d44 100644 (file)
@@ -1068,6 +1068,11 @@ static gboolean mainwindow_log_error(gpointer source, gpointer data)
        return FALSE;
 }
 
+void mainwindow_clear_error(MainWindow *mainwin)
+{
+       gtk_widget_hide(mainwin->warning_btn);
+}
+
 MainWindow *main_window_create(SeparateType type)
 {
        MainWindow *mainwin;
@@ -1211,7 +1216,9 @@ MainWindow *main_window_create(SeparateType type)
                             _("Some error(s) happened. Click here to view log."), NULL);
        gtk_box_pack_start(GTK_BOX(hbox_stat), warning_btn, FALSE, FALSE, 0);
 
-       hooks_register_hook(LOG_APPEND_TEXT_HOOKLIST, mainwindow_log_error, mainwin);
+       /* Disabled for now 
+        * hooks_register_hook(LOG_APPEND_TEXT_HOOKLIST, mainwindow_log_error, mainwin);
+        */
 
        statusbar = statusbar_create();
        gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
index 05153a0b76b5ad3e4461c136b9e17783211728e7..91d41d530f3084c96eb231b4d9b5ef13bf1017a4 100644 (file)
@@ -216,4 +216,5 @@ MainWindow *mainwindow_get_mainwindow             (void);
 void mainwindow_learn                        (MainWindow *mainwin,
                                               gboolean is_spam);
 void mainwindow_jump_to                              (const gchar       *target);
+void mainwindow_clear_error                  (MainWindow *mainwin);
 #endif /* __MAINWINDOW_H__ */