Statistics
| Revision:

root / src / statusbar.c @ 1677

History | View | Annotate | Download (2.6 kB)

1
/*
2
 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3
 * Copyright (C) 1999-2006 Hiroyuki Yamamoto
4
 *
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.
9
 *
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.
14
 *
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.
18
 */
19
20
#ifdef HAVE_CONFIG_H
21
#  include "config.h"
22
#endif
23
24
#include <glib.h>
25
#include <glib/gi18n.h>
26
#include <gtk/gtkstatusbar.h>
27
#include <stdarg.h>
28
29
#include "statusbar.h"
30
#include "gtkutils.h"
31
#include "utils.h"
32
33
#define BUFFSIZE 1024
34
35
static GList *statusbar_list = NULL;
36
37
GtkWidget *statusbar_create(void)
38
{
39
        GtkWidget *statusbar;
40
41
        statusbar = gtk_statusbar_new();
42
        gtk_widget_set_size_request(statusbar, 1, -1);
43
        statusbar_list = g_list_append(statusbar_list, statusbar);
44
45
        set_log_show_status_func(statusbar_puts_all);
46
47
        return statusbar;
48
}
49
50
void statusbar_puts(GtkStatusbar *statusbar, const gchar *str)
51
{
52
        gint cid;
53
        gchar *buf;
54
55
        buf = g_strdup(str);
56
        strretchomp(buf);
57
58
        cid = gtk_statusbar_get_context_id(statusbar, "Standard Output");
59
        gtk_statusbar_pop(statusbar, cid);
60
        gtk_statusbar_push(statusbar, cid, buf);
61
        gtkut_widget_draw_now(GTK_WIDGET(statusbar));
62
63
        g_free(buf);
64
}
65
66
void statusbar_puts_all(const gchar *str)
67
{
68
        GList *cur;
69
70
        for (cur = statusbar_list; cur != NULL; cur = cur->next)
71
                statusbar_puts(GTK_STATUSBAR(cur->data), str);
72
}
73
74
void statusbar_print(GtkStatusbar *statusbar, const gchar *format, ...)
75
{
76
        va_list args;
77
        gchar buf[BUFFSIZE];
78
79
        va_start(args, format);
80
        g_vsnprintf(buf, sizeof(buf), format, args);
81
        va_end(args);
82
83
        statusbar_puts(statusbar, buf);
84
}
85
86
void statusbar_print_all(const gchar *format, ...)
87
{
88
        va_list args;
89
        gchar buf[BUFFSIZE];
90
        GList *cur;
91
92
        va_start(args, format);
93
        g_vsnprintf(buf, sizeof(buf), format, args);
94
        va_end(args);
95
96
        for (cur = statusbar_list; cur != NULL; cur = cur->next)
97
                statusbar_puts(GTK_STATUSBAR(cur->data), buf);
98
}
99
100
void statusbar_pop_all(void)
101
{
102
        GList *cur;
103
        gint cid;
104
105
        for (cur = statusbar_list; cur != NULL; cur = cur->next) {
106
                cid = gtk_statusbar_get_context_id(GTK_STATUSBAR(cur->data),
107
                                                   "Standard Output");
108
                gtk_statusbar_pop(GTK_STATUSBAR(cur->data), cid);
109
        }
110
}