claws-mail/src/noticeview.c

218 lines
5.7 KiB
C
Raw Normal View History

/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
* Copyright (C) 2002 Hiroyuki Yamamoto & The Sylpheed Claws Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "defs.h"
#include <glib.h>
2005-02-10 [paul] 1.0.1cvs3.2 * AUTHORS * Makefile.am * autogen.sh * configure.ac * config/mkinstalldirs * intl/.cvsignore * intl/ChangeLog * intl/VERSION * intl/bindtextdom.c * intl/config.charset * intl/dcgettext.c * intl/dcigettext.c * intl/dcngettext.c * intl/dgettext.c * intl/dngettext.c * intl/eval-plural.h * intl/explodename.c * intl/finddomain.c * intl/gettext.c * intl/gettextP.h * intl/gmo.h * intl/hash-string.h * intl/intl-compat.c * intl/l10nflist.c * intl/libgnuintl.h.in * intl/loadinfo.h * intl/loadmsgcat.c * intl/localcharset.c * intl/localcharset.h * intl/locale.alias * intl/localealias.c * intl/localename.c * intl/log.c * intl/ngettext.c * intl/os2compat.c * intl/os2compat.h * intl/osdep.c * intl/plural-exp.c * intl/plural-exp.h * intl/plural.c * intl/plural.y * intl/ref-add.sin * intl/ref-del.sin * intl/relocatable.c * intl/relocatable.h * intl/textdomain.c * m4/Makefile.am * po/Makefile.in.in * src/Makefile.am * src/account.c * src/action.c * src/addr_compl.c * src/addressadd.c * src/addressbook.c * src/addrgather.c * src/addrindex.c * src/alertpanel.c * src/browseldap.c * src/codeconv.c * src/codeconv.h * src/compose.c * src/compose.h * src/crash.c * src/editaddress.c * src/editbook.c * src/editgroup.c * src/editjpilot.c * src/editldap.c * src/editldap_basedn.c * src/editvcard.c * src/exphtmldlg.c * src/expldifdlg.c * src/export.c * src/exporthtml.c * src/filtering.c * src/folder.c * src/folder_item_prefs.c * src/foldersel.c * src/folderview.c * src/grouplistdialog.c * src/headerview.c * src/imap.c * src/imap_gtk.c * src/import.c * src/importldif.c * src/importmutt.c * src/importpine.c * src/inc.c * src/ldif.c * src/main.c * src/mainwindow.c * src/matcher.c * src/mbox.c * src/message_search.c * src/messageview.c * src/mh.c * src/mh_gtk.c * src/mimeview.c * src/msgcache.c * src/news.c * src/news_gtk.c * src/noticeview.c * src/partial_download.c * src/pop.c * src/prefs_account.c * src/prefs_actions.c * src/prefs_common.c * src/prefs_customheader.c * src/prefs_display_header.c * src/prefs_ext_prog.c * src/prefs_filtering.c * src/prefs_filtering_action.c * src/prefs_folder_item.c * src/prefs_fonts.c * src/prefs_gtk.c * src/prefs_matcher.c * src/prefs_msg_colors.c * src/prefs_spelling.c * src/prefs_summary_column.c * src/prefs_template.c * src/prefs_themes.c * src/prefs_toolbar.c * src/prefs_wrapping.c * src/privacy.c * src/procheader.c * src/procmime.c * src/procmsg.c * src/quote_fmt.c * src/recv.c * src/send_message.c * src/setup.c * src/sourcewindow.c * src/ssl_manager.c * src/statusbar.c * src/summary_search.c * src/summaryview.c * src/textview.c * src/toolbar.c * src/wizard.c * src/common/nntp.c * src/common/plugin.c * src/common/smtp.c * src/common/ssl.c * src/common/ssl_certificate.c * src/common/string_match.c * src/common/sylpheed.c * src/common/template.c * src/common/utils.c * src/gtk/about.c * src/gtk/colorlabel.c * src/gtk/description_window.c * src/gtk/filesel.c * src/gtk/foldersort.c * src/gtk/gtkaspell.c * src/gtk/gtkutils.c * src/gtk/inputdialog.c * src/gtk/logwindow.c * src/gtk/menu.c * src/gtk/pluginwindow.c * src/gtk/prefswindow.c * src/gtk/progressdialog.c * src/gtk/quicksearch.c * src/gtk/sslcertwindow.c * src/plugins/clamav/clamav_plugin.c * src/plugins/clamav/clamav_plugin_gtk.c * src/plugins/demo/demo.c * src/plugins/dillo_viewer/dillo_prefs.c * src/plugins/dillo_viewer/dillo_viewer.c * src/plugins/image_viewer/plugin.c * src/plugins/image_viewer/viewer.c * src/plugins/image_viewer/viewerprefs.c * src/plugins/mathml_viewer/mathml_viewer.c * src/plugins/pgpmime/passphrase.c * src/plugins/pgpmime/plugin.c * src/plugins/pgpmime/prefs_gpg.c * src/plugins/pgpmime/select-keys.c * src/plugins/pgpmime/sgpgme.c * src/plugins/spamassassin/spamassassin.c * src/plugins/spamassassin/spamassassin_gtk.c * src/plugins/trayicon/trayicon.c sync with main (revision 104)
2005-02-10 13:06:07 +01:00
#include <glib/gi18n.h>
#include <gtk/gtkwidget.h>
#include <gtk/gtkhbox.h>
#include <gtk/gtkvbox.h>
#include <gtk/gtklabel.h>
#include <gtk/gtkpixmap.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#if HAVE_LIBCOMPFACE
# include <compface.h>
#endif
#include "prefs_common.h"
#include "gtkutils.h"
#include "utils.h"
#include "stock_pixmap.h"
#include "noticeview.h"
static void noticeview_button_pressed (GtkButton *button, NoticeView *noticeview);
static void noticeview_2ndbutton_pressed(GtkButton *button, NoticeView *noticeview);
2002-08-23 08:52:15 +02:00
NoticeView *noticeview_create(MainWindow *mainwin)
{
NoticeView *noticeview;
GtkWidget *vbox;
GtkWidget *hsep;
GtkWidget *hbox;
GtkWidget *icon;
GtkWidget *text;
GtkWidget *widget;
GtkWidget *widget2;
2002-08-15 09:38:17 +02:00
debug_print("Creating notice view...\n");
noticeview = g_new0(NoticeView, 1);
2004-01-12 22:28:31 +01:00
noticeview->window = mainwin->window;
vbox = gtk_vbox_new(FALSE, 4);
gtk_widget_show(vbox);
hsep = gtk_hseparator_new();
2004-07-09 23:17:00 +02:00
gtk_box_pack_start(GTK_BOX(vbox), hsep, FALSE, TRUE, 1);
hbox = gtk_hbox_new(FALSE, 4);
gtk_widget_show(hbox);
2004-07-09 23:17:00 +02:00
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 1);
2004-01-12 22:28:31 +01:00
icon = stock_pixmap_widget(noticeview->window, STOCK_PIXMAP_NOTICE_WARN);
#if 0
/* also possible... */
icon = gtk_pixmap_new(NULL, NULL);
#endif
gtk_widget_show(icon);
gtk_box_pack_start(GTK_BOX(hbox), icon, FALSE, TRUE, 0);
text = gtk_label_new("");
gtk_widget_show(text);
gtk_box_pack_start(GTK_BOX(hbox), text, FALSE, FALSE, 0);
widget = gtk_button_new_with_label("");
gtk_widget_set_size_request(widget, 120, -1);
g_signal_connect(G_OBJECT(widget), "clicked",
G_CALLBACK(noticeview_button_pressed),
(gpointer) noticeview);
gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, FALSE, 4);
widget2 = gtk_button_new_with_label("");
gtk_widget_set_size_request(widget2, 120, -1);
g_signal_connect(G_OBJECT(widget2), "clicked",
G_CALLBACK(noticeview_2ndbutton_pressed),
(gpointer) noticeview);
2004-07-09 23:17:00 +02:00
gtk_box_pack_start(GTK_BOX(hbox), widget2, FALSE, FALSE, 0);
noticeview->vbox = vbox;
noticeview->hsep = hsep;
noticeview->hbox = hbox;
noticeview->icon = icon;
noticeview->text = text;
noticeview->button = widget;
noticeview->button2 = widget2;
noticeview->visible = TRUE;
return noticeview;
}
void noticeview_destroy(NoticeView *noticeview)
{
g_free(noticeview);
}
gboolean noticeview_is_visible(NoticeView *noticeview)
{
return noticeview->visible;
}
void noticeview_show(NoticeView *noticeview)
{
if (!noticeview->visible) {
2004-01-12 22:28:31 +01:00
gtk_widget_show(GTK_WIDGET_PTR(noticeview));
noticeview->visible = TRUE;
}
}
void noticeview_hide(NoticeView *noticeview)
{
if (noticeview->visible) {
gtk_widget_hide(GTK_WIDGET_PTR(noticeview));
noticeview->visible = FALSE;
}
}
void noticeview_set_text(NoticeView *noticeview, const char *text)
{
g_return_if_fail(noticeview);
gtk_label_set_text(GTK_LABEL(noticeview->text), text);
}
void noticeview_set_button_text(NoticeView *noticeview, const char *text)
{
g_return_if_fail(noticeview);
2004-01-12 22:28:31 +01:00
if (text != NULL) {
gtk_label_set_text
(GTK_LABEL(GTK_BIN(noticeview->button)->child), text);
gtk_widget_show(noticeview->button);
} else
gtk_widget_hide(noticeview->button);
2004-07-09 23:17:00 +02:00
/* Callers defining only one button don't have to mind
* resetting the second one. Callers defining two have
* to define the second button after the first one.
*/
gtk_widget_hide(noticeview->button2);
}
void noticeview_set_button_press_callback(NoticeView *noticeview,
GtkSignalFunc callback,
gpointer *user_data)
{
noticeview->press = (void (*) (NoticeView *, gpointer)) callback;
noticeview->user_data = user_data;
}
static void noticeview_button_pressed(GtkButton *button, NoticeView *noticeview)
{
if (noticeview->press) {
noticeview->press(noticeview, noticeview->user_data);
}
}
void noticeview_set_2ndbutton_text(NoticeView *noticeview, const char *text)
{
g_return_if_fail(noticeview);
if (text != NULL) {
gtk_label_set_text
(GTK_LABEL(GTK_BIN(noticeview->button2)->child), text);
gtk_widget_show(noticeview->button2);
} else
gtk_widget_hide(noticeview->button2);
}
void noticeview_set_2ndbutton_press_callback(NoticeView *noticeview,
GtkSignalFunc callback,
gpointer *user_data)
{
noticeview->press2 = (void (*) (NoticeView *, gpointer)) callback;
noticeview->user_data2 = user_data;
}
static void noticeview_2ndbutton_pressed(GtkButton *button, NoticeView *noticeview)
{
if (noticeview->press2) {
noticeview->press2(noticeview, noticeview->user_data2);
}
}
2004-01-12 22:28:31 +01:00
void noticeview_set_icon(NoticeView *noticeview, StockPixmap icon)
{
GdkPixmap *pixmap;
GdkBitmap *bitmap;
if (stock_pixmap_gdk(noticeview->window, icon, &pixmap, &bitmap) < 0)
return;
2004-06-25 10:05:09 +02:00
gtk_image_set_from_pixmap(GTK_IMAGE(noticeview->icon), pixmap, bitmap);
2004-01-12 22:28:31 +01:00
}