aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-08-29 09:47:39 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-08-29 09:47:39 +0000
commit1895dda4b0fc535741c9aaca412b41571bec5e53 (patch)
treedc548c3210f88817250fc00da9c11b568b5a7db9
parent464950f90834aeea209d45eabcd42c82c19bdecf (diff)
separate LogWindow from utils.c.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@523 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r--ChangeLog5
-rw-r--r--ChangeLog.ja5
-rw-r--r--src/logwindow.c28
-rw-r--r--src/utils.c27
-rw-r--r--src/utils.h2
5 files changed, 62 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 08815a15..06148d9f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2005-08-29
+ * src/logwindow.c
+ src/utils.[ch]: separate LogWindow from utils.c.
+
+2005-08-29
+
* src/main.[ch]
src/xml.c
src/utils.[ch]: made debug_mode static variable in utils.c.
diff --git a/ChangeLog.ja b/ChangeLog.ja
index e1bb438f..f7b77994 100644
--- a/ChangeLog.ja
+++ b/ChangeLog.ja
@@ -1,5 +1,10 @@
2005-08-29
+ * src/logwindow.c
+ src/utils.[ch]: LogWindow を utils.c から分離。
+
+2005-08-29
+
* src/main.[ch]
src/xml.c
src/utils.[ch]: debug_mode を utils.c 内の static な変数にした。
diff --git a/src/logwindow.c b/src/logwindow.c
index 277adfe3..ccd6b987 100644
--- a/src/logwindow.c
+++ b/src/logwindow.c
@@ -40,6 +40,11 @@
static LogWindow *logwindow;
+static void log_window_print_func (const gchar *str);
+static void log_window_message_func (const gchar *str);
+static void log_window_warning_func (const gchar *str);
+static void log_window_error_func (const gchar *str);
+
static void hide_cb (GtkWidget *widget,
LogWindow *logwin);
static gboolean key_pressed (GtkWidget *widget,
@@ -136,6 +141,9 @@ void log_window_init(LogWindow *logwin)
gtk_text_buffer_create_tag(buffer, "error",
"foreground-gdk", &logwindow->error_color,
NULL);
+
+ set_log_ui_func(log_window_print_func, log_window_message_func,
+ log_window_warning_func, log_window_error_func);
}
void log_window_show(LogWindow *logwin)
@@ -214,6 +222,26 @@ void log_window_append(const gchar *str, LogType type)
logwindow->lines++;
}
+static void log_window_print_func(const gchar *str)
+{
+ log_window_append(str, LOG_NORMAL);
+}
+
+static void log_window_message_func(const gchar *str)
+{
+ log_window_append(str, LOG_MSG);
+}
+
+static void log_window_warning_func(const gchar *str)
+{
+ log_window_append(str, LOG_WARN);
+}
+
+static void log_window_error_func(const gchar *str)
+{
+ log_window_append(str, LOG_ERROR);
+}
+
static void hide_cb(GtkWidget *widget, LogWindow *logwin)
{
}
diff --git a/src/utils.c b/src/utils.c
index f35f9075..7bc8e8a5 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -53,7 +53,6 @@
#include "utils.h"
#include "socket.h"
#include "statusbar.h"
-#include "logwindow.h"
#define BUFFSIZE 8192
@@ -3303,6 +3302,24 @@ void set_debug_mode(gboolean enable)
debug_mode = enable;
}
+void log_dummy_func(const gchar *str)
+{
+}
+
+static LogFunc log_print_ui_func = log_dummy_func;
+static LogFunc log_message_ui_func = log_dummy_func;
+static LogFunc log_warning_ui_func = log_dummy_func;
+static LogFunc log_error_ui_func = log_dummy_func;
+
+void set_log_ui_func(LogFunc print_func, LogFunc message_func,
+ LogFunc warning_func, LogFunc error_func)
+{
+ log_print_ui_func = print_func;
+ log_message_ui_func = message_func;
+ log_warning_ui_func = warning_func;
+ log_error_ui_func = error_func;
+}
+
void debug_print(const gchar *format, ...)
{
va_list args;
@@ -3333,7 +3350,7 @@ void log_print(const gchar *format, ...)
va_end(args);
if (debug_mode) fputs(buf, stdout);
- log_window_append(buf, LOG_NORMAL);
+ log_print_ui_func(buf);
if (log_fp) {
fputs(buf, log_fp);
fflush(log_fp);
@@ -3356,7 +3373,7 @@ void log_message(const gchar *format, ...)
va_end(args);
if (debug_mode) g_message("%s", buf + TIME_LEN);
- log_window_append(buf + TIME_LEN, LOG_MSG);
+ log_message_ui_func(buf + TIME_LEN);
if (log_fp) {
fwrite(buf, TIME_LEN, 1, log_fp);
fputs("* message: ", log_fp);
@@ -3380,7 +3397,7 @@ void log_warning(const gchar *format, ...)
va_end(args);
g_warning("%s", buf);
- log_window_append(buf + TIME_LEN, LOG_WARN);
+ log_warning_ui_func(buf + TIME_LEN);
if (log_fp) {
fwrite(buf, TIME_LEN, 1, log_fp);
fputs("** warning: ", log_fp);
@@ -3403,7 +3420,7 @@ void log_error(const gchar *format, ...)
va_end(args);
g_warning("%s", buf);
- log_window_append(buf + TIME_LEN, LOG_ERROR);
+ log_error_ui_func(buf + TIME_LEN);
if (log_fp) {
fwrite(buf, TIME_LEN, 1, log_fp);
fputs("*** error: ", log_fp);
diff --git a/src/utils.h b/src/utils.h
index 4e0c03aa..0ccf2fbf 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -176,6 +176,8 @@ gint g_chmod (const gchar *path,
perror(func); \
}
+typedef void (*LogFunc) (const gchar *str);
+
/* for macro expansion */
#define Str(x) #x
#define Xstr(x) Str(x)