Improve some sieve-related translations
[claws.git] / src / gtk / icon_legend.c
blobd7570ad70b297a296c533ef4fa387e3ef443998d
1 /*
2 * Claws Mail -- a GTK based, lightweight, and fast e-mail client
3 * Copyright (C) 2005-2022 the Claws Mail 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 3 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, see <http://www.gnu.org/licenses/>.
19 #ifdef HAVE_CONFIG_H
20 # include "config.h"
21 #include "claws-features.h"
22 #endif
24 #include "defs.h"
26 #include <glib.h>
27 #include <glib/gi18n.h>
28 #include <gtk/gtk.h>
29 #include <gdk/gdkkeysyms.h>
31 #include "gtkutils.h"
32 #include "stock_pixmap.h"
33 #include "prefs_gtk.h"
35 #define ICONS 23
36 #define ROWS ((ICONS % 2 == 0)? ICONS / 2: (ICONS + 1) / 2)
38 StockPixmap legend_icons[ICONS] = {
39 STOCK_PIXMAP_NEW,
40 STOCK_PIXMAP_UNREAD,
41 STOCK_PIXMAP_REPLIED,
42 STOCK_PIXMAP_FORWARDED,
43 STOCK_PIXMAP_REPLIED_AND_FORWARDED,
44 STOCK_PIXMAP_IGNORETHREAD,
45 STOCK_PIXMAP_WATCHTHREAD,
46 STOCK_PIXMAP_SPAM,
47 STOCK_PIXMAP_CLIP,
48 STOCK_PIXMAP_GPG_SIGNED,
49 STOCK_PIXMAP_KEY,
50 STOCK_PIXMAP_CLIP_GPG_SIGNED,
51 STOCK_PIXMAP_CLIP_KEY,
52 STOCK_PIXMAP_MARK,
53 STOCK_PIXMAP_DELETED,
54 STOCK_PIXMAP_MOVED,
55 STOCK_PIXMAP_COPIED,
56 STOCK_PIXMAP_LOCKED,
57 STOCK_PIXMAP_DIR_OPEN,
58 STOCK_PIXMAP_DIR_OPEN_HRM,
59 STOCK_PIXMAP_DIR_OPEN_MARK,
60 STOCK_PIXMAP_DIR_NOSELECT_OPEN,
61 STOCK_PIXMAP_DIR_SUBS_OPEN,
64 static gchar *legend_icon_desc[] = {
65 /* status column */
66 N_("New message"),
67 N_("Unread message"),
68 N_("Message has been replied to"),
69 N_("Message has been forwarded"),
70 N_("Message has been forwarded and replied to"),
71 N_("Message is in an ignored thread"),
72 N_("Message is in a watched thread"),
73 N_("Message is spam"),
74 /* attachment column */
75 N_("Message has attachment(s)"),
76 N_("Digitally signed message"),
77 N_("Encrypted message"),
78 N_("Message is signed and has attachment(s)"),
79 N_("Message is encrypted and has attachment(s)"),
80 /* mark column */
81 N_("Marked message"),
82 N_("Message is marked for deletion"),
83 N_("Message is marked for moving"),
84 N_("Message is marked for copying"),
85 /* locked column */
86 N_("Locked message"),
87 /* others */
88 N_("Folder (normal, opened)"),
89 N_("Folder with read messages hidden"),
90 N_("Folder contains marked messages"),
91 N_("IMAP folder which contains subfolders only"),
92 N_("IMAP mailbox showing only subscribed folders"),
95 static struct LegendDialog {
96 GtkWidget *window;
97 } legend;
99 static void legend_create(void);
100 static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event);
101 static void legend_close(void);
103 void legend_show(void)
105 if (!legend.window)
106 legend_create();
107 else
108 gtk_window_present(GTK_WINDOW(legend.window));
111 static void legend_create(void)
113 GtkWidget *window;
114 GtkWidget *scrolledwindow;
115 GtkWidget *vbox;
116 GtkWidget *confirm_area;
117 GtkWidget *close_button;
118 GtkWidget *hbox;
119 GtkWidget *label;
120 GtkWidget *icon_label;
121 GtkWidget *desc_label;
122 GtkWidget *table;
123 gint i, j, k;
125 window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "icon_legend");
126 gtk_window_set_title(GTK_WINDOW(window), _("Icon Legend"));
127 gtk_container_set_border_width(GTK_CONTAINER(window), 8);
128 gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
129 gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_DIALOG);
130 gtk_window_set_default_size(GTK_WINDOW(window), 666, 340);
131 g_signal_connect(G_OBJECT(window), "delete_event",
132 G_CALLBACK(legend_close), NULL);
133 g_signal_connect(G_OBJECT(window), "key_press_event",
134 G_CALLBACK(key_pressed), NULL);
135 gtk_widget_realize(window);
137 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 8);
138 gtk_container_add(GTK_CONTAINER(window), vbox);
139 gtk_container_set_border_width(GTK_CONTAINER(vbox), 2);
141 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
142 gtk_widget_show(hbox);
143 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
145 label = gtk_label_new(g_strconcat("<span weight=\"bold\">",_("The following icons "
146 "are used to show the status of messages and "
147 "folders:"), "</span>", NULL));
148 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
149 gtk_widget_show(label);
150 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
152 scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
153 gtk_scrolled_window_set_policy
154 (GTK_SCROLLED_WINDOW(scrolledwindow),
155 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
156 gtk_scrolled_window_set_propagate_natural_height(GTK_SCROLLED_WINDOW(scrolledwindow), TRUE);
157 gtk_widget_show(scrolledwindow);
158 gtk_box_pack_start(GTK_BOX(vbox), scrolledwindow, TRUE, TRUE, 0);
160 table = gtk_grid_new();
161 gtk_container_set_border_width(GTK_CONTAINER(table), 8);
162 gtk_grid_set_row_spacing(GTK_GRID(table), 4);
163 gtk_grid_set_column_spacing(GTK_GRID(table), 8);
165 for (i = 0, j = 0, k = 0; i < ICONS; ++i, ++k) {
166 icon_label = stock_pixmap_widget(legend_icons[i]);
167 gtk_widget_set_halign(icon_label, GTK_ALIGN_CENTER);
168 gtk_widget_set_valign(icon_label, GTK_ALIGN_CENTER);
169 gtk_grid_attach(GTK_GRID(table), icon_label, j, k, 1, 1);
171 desc_label = gtk_label_new(gettext(legend_icon_desc[i]));
172 gtk_label_set_xalign(GTK_LABEL(desc_label), 0.0);
173 gtk_label_set_line_wrap(GTK_LABEL(desc_label), TRUE);
174 gtk_grid_attach(GTK_GRID(table), desc_label, j+1, k, 1, 1);
176 if (i == ICONS / 2) {
177 j = 2;
178 k = -1;
182 gtk_container_add(GTK_CONTAINER(scrolledwindow), GTK_WIDGET(table));
184 gtkut_stock_button_set_create(&confirm_area, &close_button, "window-close", _("_Close"),
185 NULL, NULL, NULL, NULL, NULL, NULL);
186 gtk_box_pack_end(GTK_BOX(vbox), confirm_area, FALSE, FALSE, 4);
187 gtk_widget_grab_default(close_button);
188 g_signal_connect_closure
189 (G_OBJECT(close_button), "clicked",
190 g_cclosure_new_swap(G_CALLBACK(legend_close),
191 window, NULL), FALSE);
193 gtk_widget_show_all(window);
195 legend.window = window;
198 static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event)
200 if (event && event->keyval == GDK_KEY_Escape) {
201 legend_close();
203 return FALSE;
206 static void legend_close(void)
208 gtk_widget_destroy(legend.window);
209 legend.window = NULL;