Statistics
| Revision:

root / src / statusbar.c @ 92

History | View | Annotate | Download (2.6 kB)

1
/*
2
 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3
 * Copyright (C) 1999-2005 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
        return statusbar;
46
}
47
48
void statusbar_puts(GtkStatusbar *statusbar, const gchar *str)
49
{
50
        gint cid;
51
        gchar *buf;
52
        gchar *tmp;
53
54
        tmp = g_strdup(str);
55
        strretchomp(tmp);
56
        buf = trim_string(tmp, 76);
57
        g_free(tmp);
58
59
        cid = gtk_statusbar_get_context_id(statusbar, "Standard Output");
60
        gtk_statusbar_pop(statusbar, cid);
61
        gtk_statusbar_push(statusbar, cid, buf);
62
        gtkut_widget_wait_for_draw(GTK_WIDGET(statusbar)->parent);
63
64
        g_free(buf);
65
}
66
67
void statusbar_puts_all(const gchar *str)
68
{
69
        GList *cur;
70
71
        for (cur = statusbar_list; cur != NULL; cur = cur->next)
72
                statusbar_puts(GTK_STATUSBAR(cur->data), str);
73
}
74
75
void statusbar_print(GtkStatusbar *statusbar, const gchar *format, ...)
76
{
77
        va_list args;
78
        gchar buf[BUFFSIZE];
79
80
        va_start(args, format);
81
        g_vsnprintf(buf, sizeof(buf), format, args);
82
        va_end(args);
83
84
        statusbar_puts(statusbar, buf);
85
}
86
87
void statusbar_print_all(const gchar *format, ...)
88
{
89
        va_list args;
90
        gchar buf[BUFFSIZE];
91
        GList *cur;
92
93
        va_start(args, format);
94
        g_vsnprintf(buf, sizeof(buf), format, args);
95
        va_end(args);
96
97
        for (cur = statusbar_list; cur != NULL; cur = cur->next)
98
                statusbar_puts(GTK_STATUSBAR(cur->data), buf);
99
}
100
101
void statusbar_pop_all(void)
102
{
103
        GList *cur;
104
        gint cid;
105
106
        for (cur = statusbar_list; cur != NULL; cur = cur->next) {
107
                cid = gtk_statusbar_get_context_id(GTK_STATUSBAR(cur->data),
108
                                                   "Standard Output");
109
                gtk_statusbar_pop(GTK_STATUSBAR(cur->data), cid);
110
        }
111
}