Fixed log clipping bug #616795
authorMelvin Hadasht <melvin.hadasht@free.fr>
Tue, 5 Nov 2002 14:58:09 +0000 (14:58 +0000)
committerMelvin Hadasht <melvin.hadasht@free.fr>
Tue, 5 Nov 2002 14:58:09 +0000 (14:58 +0000)
ChangeLog.claws
configure.in
src/logwindow.c
src/prefs_common.c

index f070fa11d64478f52b9f0330b1d74fd64836a148..fb1c2cfc0dda0baa634f77049a4bbda727d567b5 100644 (file)
@@ -1,3 +1,11 @@
+2002-11-05 [melvin]    0.8.5claws72
+
+       * src/logwindow.c
+               Fixed log-clipping bug #616795.
+               To stop logging in the log window use 0 length.
+       * src/prefs_common.c
+               Added a label to inform about the 0 log length behaviour.
+
 2002-11-05 [paul]      0.8.5claws71
 
        * sync with 0.8.5cvs17
index 32d4bff0c678b8a09d4e3f5c27b130dc50003f11..c75264aed4608b10b9ddff33a0d5a2623237c542 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=5
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws71
+EXTRA_VERSION=claws72
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 87b5e429ef5efce9666269adc8e856b0074f426a..0013ed9e68cc7715013961d02a5beb5573a7ed53 100644 (file)
@@ -141,6 +141,8 @@ void log_window_append(const gchar *str, LogType type)
        gchar *head = NULL;
 
        g_return_if_fail(logwindow != NULL);
+       if (prefs_common.cliplog && !prefs_common.loglength)
+               return;
 
        text = GTK_TEXT(logwindow->text);
 
@@ -180,13 +182,14 @@ static void key_pressed(GtkWidget *widget, GdkEventKey *event,
                gtk_widget_hide(logwin->window);
 }
 
-#define LOG_AVG_LINE_LEN 80
-void log_window_clear(GtkWidget *text)
+void log_window_clear(GtkWidget *textw)
 {
         guint length;
        guint point;
+       gboolean was_frozen = FALSE;
+       GtkText *text = GTK_TEXT(textw);
        
-       length = gtk_text_get_length (GTK_TEXT (text));
+       length = gtk_text_get_length (text);
        debug_print("Log window length: %u\n", length);
        
        if (length > prefs_common.loglength) {
@@ -194,30 +197,23 @@ void log_window_clear(GtkWidget *text)
                /* find the end of the first line after the cut off
                 * point */
                        point = length - prefs_common.loglength;
-               
-               do {
-                       gchar *str;
-                       if ((str = gtk_editable_get_chars (GTK_EDITABLE (text),
-                                       point, point + LOG_AVG_LINE_LEN))) {
-                               if ((lf = strchr(str, '\n')) != NULL)
-                                       point += lf - str;
-                               else 
-                                       point += strlen(str);
-                               g_free(str);
-                       } else
-                               break;
-               } while (lf == NULL);
-                               
+               while (point < length && GTK_TEXT_INDEX(text, point) != '\n')
+                       point++;
                /* erase the text */
-               gtk_text_set_point (GTK_TEXT (text), 0);
-               gtk_text_freeze (GTK_TEXT (text));
-               if (!gtk_text_forward_delete (GTK_TEXT (text), point + 1))
+               if (text->freeze_count) {
+                       was_frozen = TRUE;
+                       gtk_text_thaw(text);
+               }
+               gtk_text_set_point (text, 0);
+               gtk_text_freeze(text);
+               if (!gtk_text_forward_delete (text, point + 1))
                        debug_print("Error clearing log\n");
-               gtk_text_thaw (GTK_TEXT (text));
-               gtk_text_set_point (GTK_TEXT (text),
-                                   gtk_text_get_length (GTK_TEXT (text)));
+               gtk_text_thaw(text);
+               gtk_text_set_point(text,
+                                  gtk_text_get_length (GTK_TEXT (text)));
+               if (was_frozen)
+                       gtk_text_freeze(text);
        }
-       
 }
 
 
index 07360a3324acce222cb663858ab173282e8ca23a..fb47a04d5def58ec3277ecc525909ef93b30151b 100644 (file)
@@ -2957,6 +2957,9 @@ static void prefs_other_create(void)
        gtk_box_pack_start (GTK_BOX (hbox_cliplog), loglength_entry,
                            FALSE, TRUE, 0);
        gtk_widget_show (GTK_WIDGET (loglength_entry));
+       loglength_label = gtk_label_new (_("(0 to stop logging in the log window)"));
+       gtk_box_pack_start (GTK_BOX (hbox_cliplog), loglength_label,
+                           FALSE, TRUE, 0);
        SET_TOGGLE_SENSITIVITY(checkbtn_cliplog, loglength_entry);
 
        /* On Exit */