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.
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>
37 # include <compface.h>
41 #include "prefs_common.h"
44 #include "stock_pixmap.h"
46 #include "noticeview.h"
48 static void noticeview_button_pressed (GtkButton *button, NoticeView *noticeview);
49 static void noticeview_2ndbutton_pressed(GtkButton *button, NoticeView *noticeview);
51 NoticeView *noticeview_create(MainWindow *mainwin)
53 NoticeView *noticeview;
62 debug_print("Creating notice view...\n");
63 noticeview = g_new0(NoticeView, 1);
65 noticeview->window = mainwin->window;
67 vbox = gtk_vbox_new(FALSE, 4);
68 gtk_widget_show(vbox);
69 hsep = gtk_hseparator_new();
70 gtk_box_pack_start(GTK_BOX(vbox), hsep, FALSE, TRUE, 0);
72 hbox = gtk_hbox_new(FALSE, 4);
73 gtk_widget_show(hbox);
74 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
76 icon = stock_pixmap_widget(noticeview->window, STOCK_PIXMAP_NOTICE_WARN);
78 /* also possible... */
79 icon = gtk_pixmap_new(NULL, NULL);
81 gtk_widget_show(icon);
83 gtk_box_pack_start(GTK_BOX(hbox), icon, FALSE, TRUE, 0);
85 text = gtk_label_new("");
86 gtk_widget_show(text);
87 gtk_box_pack_start(GTK_BOX(hbox), text, FALSE, FALSE, 0);
89 widget = gtk_button_new_with_label("");
90 g_signal_connect(G_OBJECT(widget), "clicked",
91 G_CALLBACK(noticeview_button_pressed),
92 (gpointer) noticeview);
93 gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, FALSE, 4);
95 widget2 = gtk_button_new_with_label("");
96 g_signal_connect(G_OBJECT(widget2), "clicked",
97 G_CALLBACK(noticeview_2ndbutton_pressed),
98 (gpointer) noticeview);
99 gtk_box_pack_start(GTK_BOX(hbox), widget2, FALSE, FALSE, 4);
101 noticeview->vbox = vbox;
102 noticeview->hsep = hsep;
103 noticeview->hbox = hbox;
104 noticeview->icon = icon;
105 noticeview->text = text;
106 noticeview->button = widget;
107 noticeview->button2 = widget2;
109 noticeview->visible = TRUE;
114 void noticeview_destroy(NoticeView *noticeview)
119 gboolean noticeview_is_visible(NoticeView *noticeview)
121 return noticeview->visible;
124 void noticeview_show(NoticeView *noticeview)
126 if (!noticeview->visible) {
127 gtk_widget_show(GTK_WIDGET_PTR(noticeview));
128 noticeview->visible = TRUE;
132 void noticeview_hide(NoticeView *noticeview)
134 if (noticeview->visible) {
135 gtk_widget_hide(GTK_WIDGET_PTR(noticeview));
136 noticeview->visible = FALSE;
140 void noticeview_set_text(NoticeView *noticeview, const char *text)
142 g_return_if_fail(noticeview);
143 gtk_label_set_text(GTK_LABEL(noticeview->text), text);
146 void noticeview_set_button_text(NoticeView *noticeview, const char *text)
148 g_return_if_fail(noticeview);
152 (GTK_LABEL(GTK_BIN(noticeview->button)->child), text);
153 gtk_widget_show(noticeview->button);
155 gtk_widget_hide(noticeview->button);
158 void noticeview_set_button_press_callback(NoticeView *noticeview,
159 GtkSignalFunc callback,
162 noticeview->press = (void (*) (NoticeView *, gpointer)) callback;
163 noticeview->user_data = user_data;
166 static void noticeview_button_pressed(GtkButton *button, NoticeView *noticeview)
168 if (noticeview->press) {
169 noticeview->press(noticeview, noticeview->user_data);
173 void noticeview_set_2ndbutton_text(NoticeView *noticeview, const char *text)
175 g_return_if_fail(noticeview);
179 (GTK_LABEL(GTK_BIN(noticeview->button2)->child), text);
180 gtk_widget_show(noticeview->button2);
182 gtk_widget_hide(noticeview->button2);
185 void noticeview_set_2ndbutton_press_callback(NoticeView *noticeview,
186 GtkSignalFunc callback,
189 noticeview->press2 = (void (*) (NoticeView *, gpointer)) callback;
190 noticeview->user_data2 = user_data;
193 static void noticeview_2ndbutton_pressed(GtkButton *button, NoticeView *noticeview)
195 if (noticeview->press2) {
196 noticeview->press2(noticeview, noticeview->user_data2);
200 void noticeview_set_icon(NoticeView *noticeview, StockPixmap icon)
205 if (stock_pixmap_gdk(noticeview->window, icon, &pixmap, &bitmap) < 0)
208 gtk_image_set_from_pixmap(GTK_IMAGE(noticeview->icon), pixmap, bitmap);