2 * This file Copyright (C) 2005 Paul Mangan <claws@thewildbeast.co.uk>
3 * and 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27 #include <glib/gi18n.h>
29 #include <gdk/gdkkeysyms.h>
30 #include <gtk/gtkwidget.h>
31 #include <gtk/gtkwindow.h>
32 #include <gtk/gtksignal.h>
33 #include <gtk/gtkvbox.h>
34 #include <gtk/gtkhbox.h>
35 #include <gtk/gtklabel.h>
38 #include "stock_pixmap.h"
39 #include "prefs_gtk.h"
43 StockPixmap legend_icons[ICONS] = {
47 STOCK_PIXMAP_FORWARDED,
49 STOCK_PIXMAP_GPG_SIGNED,
51 STOCK_PIXMAP_CLIP_GPG_SIGNED,
52 STOCK_PIXMAP_CLIP_KEY,
55 STOCK_PIXMAP_IGNORETHREAD,
57 STOCK_PIXMAP_DIR_OPEN,
58 STOCK_PIXMAP_DIR_OPEN_HRM,
59 STOCK_PIXMAP_DIR_OPEN_MARK,
62 static gchar *legend_icon_desc[] = {
65 N_("Message has been replied to"),
66 N_("Message has been forwarded"),
67 N_("Message has attachment(s)"),
68 N_("Digitally signed message"),
69 N_("Encrypted message"),
70 N_("Message is signed and has attachment(s)"),
71 N_("Message is encrypted and has attachment(s)"),
74 N_("Message is in an ignored thread"),
75 N_("Message is spam"),
76 N_("Folder (normal, opened)"),
77 N_("Folder with read messages hidden"),
78 N_("Folder contains marked emails"),
81 static struct LegendDialog {
85 static void legend_create(void);
86 static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event);
87 static void legend_close(void);
89 void legend_show(void)
94 gtk_window_present(GTK_WINDOW(legend.window));
97 static void legend_create(void)
101 GtkWidget *confirm_area;
102 GtkWidget *close_button;
105 GtkWidget *icon_label;
106 GtkWidget *desc_label;
109 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
110 gtk_window_set_title(GTK_WINDOW(window), _("Icon Legend"));
111 gtk_container_set_border_width(GTK_CONTAINER(window), 8);
112 gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
113 gtk_widget_set_size_request(window, -1, -1);
114 g_signal_connect(G_OBJECT(window), "delete_event",
115 G_CALLBACK(legend_close), NULL);
116 g_signal_connect(G_OBJECT(window), "key_press_event",
117 G_CALLBACK(key_pressed), NULL);
118 gtk_widget_realize(window);
120 vbox = gtk_vbox_new(FALSE, 8);
121 gtk_container_add(GTK_CONTAINER(window), vbox);
122 gtk_container_set_border_width(GTK_CONTAINER(vbox), 2);
124 hbox = gtk_hbox_new(FALSE, 8);
125 gtk_widget_show(hbox);
126 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
128 label = gtk_label_new(_("<span weight=\"bold\">The following icons are used to show the status of messages and folders:</span>"));
129 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
130 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
131 gtk_widget_show(label);
132 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
134 for (i = 0; i < ICONS; ++i) {
135 icon_label = stock_pixmap_widget(window, legend_icons[i]);
136 desc_label = gtk_label_new(gettext(legend_icon_desc[i]));
137 gtk_label_set_line_wrap(GTK_LABEL(desc_label), TRUE);
139 hbox = gtk_hbox_new(FALSE, 4);
140 gtk_widget_show(hbox);
141 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
142 gtk_box_pack_start(GTK_BOX(hbox), icon_label, FALSE, FALSE, 0);
143 gtk_box_pack_start(GTK_BOX(hbox), desc_label, FALSE, FALSE, 0);
146 gtkut_stock_button_set_create(&confirm_area, &close_button, GTK_STOCK_CLOSE,
147 NULL, NULL, NULL, NULL);
148 gtk_box_pack_end(GTK_BOX(vbox), confirm_area, FALSE, FALSE, 4);
149 gtk_widget_grab_default(close_button);
150 g_signal_connect_closure
151 (G_OBJECT(close_button), "clicked",
152 g_cclosure_new_swap(G_CALLBACK(legend_close),
153 window, NULL), FALSE);
155 gtk_widget_show_all(window);
157 legend.window = window;
160 static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event)
162 if (event && event->keyval == GDK_Escape) {
168 static void legend_close(void)
170 gtk_widget_destroy(legend.window);
171 legend.window = NULL;