This commit was manufactured by cvs2svn to create tag 'LAST_STABLE'.
[claws.git] / src / noticeview.c
blob94a0c3b1467661149f8aec7ad8c54aadd397ca79
1 /*
2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2002 Hiroyuki Yamamoto & The Sylpheed Claws Team
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.
20 #ifdef HAVE_CONFIG_H
21 # include "config.h"
22 #endif
24 #include "defs.h"
26 #include <glib.h>
27 #include <gtk/gtkwidget.h>
28 #include <gtk/gtkhbox.h>
29 #include <gtk/gtkvbox.h>
30 #include <gtk/gtklabel.h>
31 #include <gtk/gtkpixmap.h>
32 #include <stdio.h>
33 #include <string.h>
34 #include <time.h>
36 #if HAVE_LIBCOMPFACE
37 # include <compface.h>
38 #endif
40 #include "intl.h"
41 #include "prefs_common.h"
42 #include "gtkutils.h"
43 #include "utils.h"
44 #include "stock_pixmap.h"
46 #include "noticeview.h"
48 static void noticeview_button_pressed (GtkButton *button, NoticeView *noticeview);
50 NoticeView *noticeview_create(MainWindow *mainwin)
52 NoticeView *noticeview;
53 GtkWidget *vbox;
54 GtkWidget *hsep;
55 GtkWidget *hbox;
56 GtkWidget *icon;
57 GtkWidget *text;
58 GtkWidget *widget;
60 debug_print("Creating notice view...\n");
61 noticeview = g_new0(NoticeView, 1);
63 vbox = gtk_vbox_new(FALSE, 4);
64 gtk_widget_show(vbox);
65 hsep = gtk_hseparator_new();
66 gtk_box_pack_start(GTK_BOX(vbox), hsep, FALSE, TRUE, 0);
68 hbox = gtk_hbox_new(FALSE, 4);
69 gtk_widget_show(hbox);
70 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
72 icon = stock_pixmap_widget(mainwin->window, STOCK_PIXMAP_NOTICE_WARN);
73 #if 0
74 /* also possible... */
75 icon = gtk_pixmap_new(NULL, NULL);
76 #endif
77 gtk_widget_show(icon);
79 gtk_box_pack_start(GTK_BOX(hbox), icon, FALSE, TRUE, 0);
81 text = gtk_label_new("");
82 gtk_widget_show(text);
83 gtk_box_pack_start(GTK_BOX(hbox), text, FALSE, FALSE, 0);
85 widget = gtk_button_new_with_label("");
86 gtk_signal_connect(GTK_OBJECT(widget), "clicked",
87 GTK_SIGNAL_FUNC(noticeview_button_pressed),
88 (gpointer) noticeview);
89 gtk_widget_show(widget);
90 gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, FALSE, 4);
92 noticeview->vbox = vbox;
93 noticeview->hsep = hsep;
94 noticeview->hbox = hbox;
95 noticeview->icon = icon;
96 noticeview->text = text;
97 noticeview->button = widget;
99 noticeview->visible = TRUE;
101 return noticeview;
104 void noticeview_destroy(NoticeView *noticeview)
106 g_free(noticeview);
109 gboolean noticeview_is_visible(NoticeView *noticeview)
111 return noticeview->visible;
114 void noticeview_show(NoticeView *noticeview)
116 if (!noticeview->visible) {
117 gtk_widget_show_all(GTK_WIDGET_PTR(noticeview));
118 noticeview->visible = TRUE;
122 void noticeview_hide(NoticeView *noticeview)
124 if (noticeview->visible) {
125 gtk_widget_hide(GTK_WIDGET_PTR(noticeview));
126 noticeview->visible = FALSE;
130 void noticeview_set_text(NoticeView *noticeview, const char *text)
132 g_return_if_fail(noticeview);
133 gtk_label_set_text(GTK_LABEL(noticeview->text), text);
136 void noticeview_set_button_text(NoticeView *noticeview, const char *text)
138 g_return_if_fail(noticeview);
139 gtk_label_set_text
140 (GTK_LABEL(GTK_BIN(noticeview->button)->child), text);
143 void noticeview_set_button_press_callback(NoticeView *noticeview,
144 GtkSignalFunc callback,
145 gpointer *user_data)
147 noticeview->press = (void (*) (NoticeView *, gpointer)) callback;
148 noticeview->user_data = user_data;
151 static void noticeview_button_pressed(GtkButton *button, NoticeView *noticeview)
153 if (noticeview->press) {
154 noticeview->press(noticeview, noticeview->user_data);