diff options
| author | Simeon Simeonov | 2018-02-26 11:23:00 +0100 |
|---|---|---|
| committer | Simeon Simeonov | 2018-02-26 11:23:00 +0100 |
| commit | 0b3cbf57875fd692e4ba0b336fefa4bee1ed00dc (patch) | |
| tree | af916a30553c78ce9d4f2d8658656a175c5b6921 /src/statusbar.c | |
Initial commit for sylpheed 3.7.0
Diffstat (limited to 'src/statusbar.c')
| -rw-r--r-- | src/statusbar.c | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/src/statusbar.c b/src/statusbar.c new file mode 100644 index 0000000..2bd7ff8 --- /dev/null +++ b/src/statusbar.c | |||
| @@ -0,0 +1,112 @@ | |||
| 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 | gdk_threads_enter(); | ||
| 71 | for (cur = statusbar_list; cur != NULL; cur = cur->next) | ||
| 72 | statusbar_puts(GTK_STATUSBAR(cur->data), str); | ||
| 73 | gdk_threads_leave(); | ||
| 74 | } | ||
| 75 | |||
| 76 | void statusbar_print(GtkStatusbar *statusbar, const gchar *format, ...) | ||
| 77 | { | ||
| 78 | va_list args; | ||
| 79 | gchar buf[BUFFSIZE]; | ||
| 80 | |||
| 81 | va_start(args, format); | ||
| 82 | g_vsnprintf(buf, sizeof(buf), format, args); | ||
| 83 | va_end(args); | ||
| 84 | |||
| 85 | statusbar_puts(statusbar, buf); | ||
| 86 | } | ||
| 87 | |||
| 88 | void statusbar_print_all(const gchar *format, ...) | ||
| 89 | { | ||
| 90 | va_list args; | ||
| 91 | gchar buf[BUFFSIZE]; | ||
| 92 | GList *cur; | ||
| 93 | |||
| 94 | va_start(args, format); | ||
| 95 | g_vsnprintf(buf, sizeof(buf), format, args); | ||
| 96 | va_end(args); | ||
| 97 | |||
| 98 | for (cur = statusbar_list; cur != NULL; cur = cur->next) | ||
| 99 | statusbar_puts(GTK_STATUSBAR(cur->data), buf); | ||
| 100 | } | ||
| 101 | |||
| 102 | void statusbar_pop_all(void) | ||
| 103 | { | ||
| 104 | GList *cur; | ||
| 105 | gint cid; | ||
| 106 | |||
| 107 | for (cur = statusbar_list; cur != NULL; cur = cur->next) { | ||
| 108 | cid = gtk_statusbar_get_context_id(GTK_STATUSBAR(cur->data), | ||
| 109 | "Standard Output"); | ||
| 110 | gtk_statusbar_pop(GTK_STATUSBAR(cur->data), cid); | ||
| 111 | } | ||
| 112 | } | ||
