2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999,2000 Hiroyuki Yamamoto
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 #include <gtk/gtkstatusbar.h>
29 #include "statusbar.h"
37 static GList
*statusbar_list
= NULL
;
38 gint statusbar_puts_all_hook_id
= -1;
40 GtkWidget
*statusbar_create(void)
44 statusbar
= gtk_statusbar_new();
46 statusbar_list
= g_list_append(statusbar_list
, statusbar
);
51 void statusbar_puts(GtkStatusbar
*statusbar
, const gchar
*str
)
58 if (strlen(buf
) > 76) {
61 wbuf
= strdup_mbstowcs(buf
);
63 if (wcslen(wbuf
) > 60) {
67 wbuf
[60] = (wchar_t)0;
68 tmp
= strdup_wcstombs(wbuf
);
69 buf
= g_strconcat(tmp
, "...", NULL
);
76 cid
= gtk_statusbar_get_context_id(statusbar
, "Standard Output");
77 gtk_statusbar_pop(statusbar
, cid
);
78 gtk_statusbar_push(statusbar
, cid
, buf
);
79 gtkut_widget_wait_for_draw(GTK_WIDGET(statusbar
)->parent
);
84 void statusbar_puts_all(const gchar
*str
)
88 for (cur
= statusbar_list
; cur
!= NULL
; cur
= cur
->next
)
89 statusbar_puts(GTK_STATUSBAR(cur
->data
), str
);
92 void statusbar_print(GtkStatusbar
*statusbar
, const gchar
*format
, ...)
97 va_start(args
, format
);
98 g_vsnprintf(buf
, sizeof(buf
), format
, args
);
101 statusbar_puts(statusbar
, buf
);
104 void statusbar_print_all(const gchar
*format
, ...)
110 va_start(args
, format
);
111 g_vsnprintf(buf
, sizeof(buf
), format
, args
);
114 for (cur
= statusbar_list
; cur
!= NULL
; cur
= cur
->next
)
115 statusbar_puts(GTK_STATUSBAR(cur
->data
), buf
);
118 void statusbar_pop_all(void)
123 for (cur
= statusbar_list
; cur
!= NULL
; cur
= cur
->next
) {
124 cid
= gtk_statusbar_get_context_id(GTK_STATUSBAR(cur
->data
),
126 gtk_statusbar_pop(GTK_STATUSBAR(cur
->data
), cid
);
130 gboolean
statusbar_puts_all_hook (gpointer source
, gpointer data
)
132 LogText
*logtext
= (LogText
*) source
;
134 g_return_val_if_fail(logtext
!= NULL
, TRUE
);
135 g_return_val_if_fail(logtext
->text
!= NULL
, TRUE
);
138 if (logtext
->type
== LOG_NORMAL
) {
139 statusbar_puts_all(logtext
->text
+ LOG_TIME_LEN
);
140 } else if (logtext
->type
== LOG_MSG
) {
141 statusbar_puts_all(logtext
->text
);
147 void statusbar_verbosity_set(gboolean verbose
)
149 if (verbose
&& (statusbar_puts_all_hook_id
== -1)) {
150 statusbar_puts_all_hook_id
=
151 hooks_register_hook(LOG_APPEND_TEXT_HOOKLIST
, statusbar_puts_all_hook
, NULL
);
152 } else if (!verbose
&& (statusbar_puts_all_hook_id
!= -1)) {
153 hooks_unregister_hook(LOG_APPEND_TEXT_HOOKLIST
, statusbar_puts_all_hook_id
);
154 statusbar_puts_all_hook_id
= -1;