control size of log text in log window; closes patch #569155 submitted by Mitko Haralanov.

This commit is contained in:
Alfons Hoogervorst 2002-06-16 00:16:34 +00:00
parent 350e661d48
commit 62b7fa5926
5 changed files with 94 additions and 2 deletions

View file

@ -1,3 +1,11 @@
2002-06-16 [alfons] 0.7.8claws1
* AUTHORS
* src/logwindow.c
* src/prefscommon.[ch]
control size of log text in log window;
closes patch #569155 submitted by Mitko Haralanov.
2002-06-15 [paul] 0.7.8claws
* release of 0.7.8claws

View file

@ -8,7 +8,7 @@ MINOR_VERSION=7
MICRO_VERSION=8
INTERFACE_AGE=0
BINARY_AGE=0
EXTRA_VERSION=claws
EXTRA_VERSION=claws1
VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
dnl set $target

View file

@ -34,11 +34,13 @@
#include "logwindow.h"
#include "utils.h"
#include "gtkutils.h"
#include "prefs_common.h"
static LogWindow *logwindow;
static void key_pressed(GtkWidget *widget, GdkEventKey *event,
LogWindow *logwin);
void log_window_clear(GtkWidget *text);
LogWindow *log_window_create(void)
{
@ -147,6 +149,8 @@ void log_window_append(const gchar *str, LogType type)
if (head) gtk_text_insert(text, NULL, color, NULL, head, -1);
gtk_text_insert(text, NULL, color, NULL, str, -1);
if (prefs_common.cliplog)
log_window_clear (GTK_WIDGET (text));
}
static void key_pressed(GtkWidget *widget, GdkEventKey *event,
@ -155,3 +159,37 @@ static void key_pressed(GtkWidget *widget, GdkEventKey *event,
if (event && event->keyval == GDK_Escape)
gtk_widget_hide(logwin->window);
}
void log_window_clear(GtkWidget *text)
{
guint length;
guint point;
gchar *str;
length = gtk_text_get_length (GTK_TEXT (text));
debug_print(_("Log window length: %u"), length);
if (length > prefs_common.loglength) {
/* find the end of the first line after the cut off
* point */
point = length - prefs_common.loglength;
gtk_text_set_point (GTK_TEXT (text), point);
str = gtk_editable_get_chars (GTK_EDITABLE (text),
point, point + 1);
gtk_text_freeze (GTK_TEXT (text));
while(str && *str != '\n')
str = gtk_editable_get_chars (GTK_EDITABLE (text),
++point, point + 2);
/* erase the text */
gtk_text_set_point (GTK_TEXT (text), 0);
if (!gtk_text_forward_delete (GTK_TEXT (text), point + 1))
debug_print (_("Error clearing log"));
gtk_text_thaw (GTK_TEXT (text));
gtk_text_set_point (GTK_TEXT (text),
gtk_text_get_length (GTK_TEXT (text)));
}
}

View file

@ -230,6 +230,9 @@ static struct Other {
GtkWidget *checkbtn_cleanonexit;
GtkWidget *checkbtn_askonclean;
GtkWidget *checkbtn_warnqueued;
GtkWidget *checkbtn_cliplog;
GtkWidget *loglength_entry;
} other;
static struct MessageColorButtons {
@ -772,6 +775,12 @@ static PrefParam param[] = {
NULL, NULL, NULL},
{"important_score", "1", &prefs_common.important_score, P_INT,
NULL, NULL, NULL},
{"clip_log", "FALSE", &prefs_common.cliplog, P_BOOL,
&other.checkbtn_cliplog,
prefs_set_data_from_toggle, prefs_set_toggle},
{"log_length", "1000", &prefs_common.loglength, P_INT,
&other.loglength_entry,
prefs_set_data_from_entry, prefs_set_entry},
{NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
};
@ -2814,6 +2823,13 @@ static void prefs_other_create(void)
GtkWidget *exteditor_combo;
GtkWidget *exteditor_entry;
GtkWidget *frame_cliplog;
GtkWidget *vbox_cliplog;
GtkWidget *hbox_cliplog;
GtkWidget *checkbtn_cliplog;
GtkWidget *loglength_label;
GtkWidget *loglength_entry;
GtkWidget *frame_exit;
GtkWidget *vbox_exit;
GtkWidget *checkbtn_confonexit;
@ -2889,6 +2905,30 @@ static void prefs_other_create(void)
NULL);
exteditor_entry = GTK_COMBO (exteditor_combo)->entry;
/* Clip Log */
PACK_FRAME (vbox1, frame_cliplog, _("Log Size"));
vbox_cliplog = gtk_vbox_new (FALSE, 0);
gtk_widget_show (vbox_cliplog);
gtk_container_add (GTK_CONTAINER (frame_cliplog), vbox_cliplog);
gtk_container_set_border_width (GTK_CONTAINER (vbox_cliplog), 8);
PACK_CHECK_BUTTON (vbox_cliplog, checkbtn_cliplog,
_("Clip the log size"));
hbox_cliplog = gtk_hbox_new (FALSE, 3);
gtk_container_add (GTK_CONTAINER (vbox_cliplog), hbox_cliplog);
gtk_widget_show (hbox_cliplog);
loglength_label = gtk_label_new (_("Log window length"));
gtk_box_pack_start (GTK_BOX (hbox_cliplog), loglength_label,
FALSE, TRUE, 0);
gtk_widget_show (GTK_WIDGET (loglength_label));
loglength_entry = gtk_entry_new ();
gtk_widget_set_usize (GTK_WIDGET (loglength_entry), 64, -1);
gtk_box_pack_start (GTK_BOX (hbox_cliplog), loglength_entry,
FALSE, TRUE, 0);
gtk_widget_show (GTK_WIDGET (loglength_entry));
SET_TOGGLE_SENSITIVITY(checkbtn_cliplog, loglength_entry);
/* On Exit */
PACK_FRAME (vbox1, frame_exit, _("On exit"));
@ -2920,6 +2960,9 @@ static void prefs_other_create(void)
other.exteditor_combo = exteditor_combo;
other.exteditor_entry = exteditor_entry;
other.checkbtn_cliplog = checkbtn_cliplog;
other.loglength_entry = loglength_entry;
other.checkbtn_confonexit = checkbtn_confonexit;
other.checkbtn_cleanonexit = checkbtn_cleanonexit;
other.checkbtn_askonclean = checkbtn_askonclean;

View file

@ -226,7 +226,10 @@ struct _PrefsCommon
gchar *print_cmd;
gchar *ext_editor_cmd;
gboolean confirm_on_exit;
gboolean cliplog;
guint loglength;
gboolean confirm_on_exit;
gboolean clean_on_exit;
gboolean ask_on_clean;
gboolean warn_queued_on_exit;