correction to English
[claws.git] / src / about.c
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2001 Hiroyuki Yamamoto
4  *
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.
9  *
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.
14  *
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.
18  */
19
20 #ifdef HAVE_CONFIG_H
21 #  include "config.h"
22 #endif
23
24 #include "defs.h"
25
26 #include <glib.h>
27 #include <gdk/gdkkeysyms.h>
28 #include <gtk/gtkwidget.h>
29 #include <gtk/gtkwindow.h>
30 #include <gtk/gtksignal.h>
31 #include <gtk/gtkvbox.h>
32 #include <gtk/gtkhbox.h>
33 #include <gtk/gtkpixmap.h>
34 #include <gtk/gtklabel.h>
35 #include <gtk/gtkhseparator.h>
36 #include <gtk/gtkscrolledwindow.h>
37 #include <gtk/gtktext.h>
38 #include <gtk/gtkbutton.h>
39 #if HAVE_SYS_UTSNAME_H
40 #  include <sys/utsname.h>
41 #endif
42
43 #include "intl.h"
44 #include "about.h"
45 #include "gtkutils.h"
46 #include "prefs_common.h"
47 #include "utils.h"
48 #include "version.h"
49
50 #include "pixmaps/sylpheed-logo.xpm"
51
52 static GtkWidget *window;
53
54 static void about_create(void);
55 static void key_pressed(GtkWidget *widget, GdkEventKey *event);
56 static void about_uri_clicked(GtkButton *button, gpointer data);
57
58 void about_show(void)
59 {
60         if (!window)
61                 about_create();
62         else
63                 gtk_widget_show(window);
64 }
65
66 static void about_create(void)
67 {
68         GtkWidget *vbox;
69         GdkPixmap *logoxpm = NULL;
70         GdkBitmap *logoxpmmask;
71         GtkWidget *pixmap;
72         GtkWidget *label;
73         GtkWidget *hbox;
74         GtkWidget *button;
75         GtkWidget *scrolledwin;
76         GtkWidget *text;
77         GtkWidget *confirm_area;
78         GtkWidget *ok_button;
79         GtkStyle *style;
80         GdkColormap *cmap;
81         GdkColor uri_color[2] = {{0, 0, 0, 0xffff}, {0, 0xffff, 0, 0}};
82         gboolean success[2];
83
84 #if HAVE_SYS_UTSNAME_H
85         struct utsname utsbuf;
86 #endif
87         gchar buf[1024];
88         gint i;
89
90         window = gtk_window_new(GTK_WINDOW_DIALOG);
91         gtk_window_set_title(GTK_WINDOW(window), _("About"));
92         gtk_container_set_border_width(GTK_CONTAINER(window), 8);
93         gtk_widget_set_usize(window, 518, 358);
94         gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
95         gtk_signal_connect(GTK_OBJECT(window), "delete_event",
96                            GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete), NULL);
97         gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
98                            GTK_SIGNAL_FUNC(key_pressed), NULL);
99         gtk_widget_realize(window);
100
101         vbox = gtk_vbox_new(FALSE, 6);
102         gtk_container_add(GTK_CONTAINER(window), vbox);
103
104         PIXMAP_CREATE(window, logoxpm, logoxpmmask, sylpheed_logo_xpm);
105         pixmap = gtk_pixmap_new(logoxpm, logoxpmmask);
106         gtk_box_pack_start(GTK_BOX(vbox), pixmap, FALSE, FALSE, 0);
107
108         label = gtk_label_new("version "VERSION);
109         gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
110
111 #if HAVE_SYS_UTSNAME_H
112         uname(&utsbuf);
113         g_snprintf(buf, sizeof(buf),
114                    "GTK+ version %d.%d.%d\n"
115                    "Operating System: %s %s (%s)",
116                    gtk_major_version, gtk_minor_version, gtk_micro_version,
117                    utsbuf.sysname, utsbuf.release, utsbuf.machine);
118 #else
119         g_snprintf(buf, sizeof(buf),
120                    "GTK+ version %d.%d.%d\n"
121                    "Operating System: Windoze",
122                    gtk_major_version, gtk_minor_version, gtk_micro_version);
123 #endif
124
125         label = gtk_label_new(buf);
126         gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
127
128         g_snprintf(buf, sizeof(buf),
129                    "Compiled-in features:%s",
130 #if HAVE_GDK_IMLIB
131                    " gdk_imlib"
132 #endif
133 #if HAVE_GDK_PIXBUF
134                    " gdk-pixbuf"
135 #endif
136 #if USE_THREADS
137                    " gthread"
138 #endif
139 #if INET6
140                    " IPv6"
141 #endif
142 #if HAVE_LIBCOMPFACE
143                    " libcompface"
144 #endif
145 #if HAVE_LIBJCONV
146                    " libjconv"
147 #endif
148 #if USE_GPGME
149                    " GPGME"
150 #endif
151 #if USE_SSL
152                    " SSL"
153 #endif
154 #if USE_LDAP
155                    " LDAP"
156 #endif
157 #if USE_JPILOT
158                    " JPilot"
159 #endif
160 #if USE_PSPELL
161                    " pspell"
162 #endif
163         "");
164
165         label = gtk_label_new(buf);
166         gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
167
168         label = gtk_label_new
169                 ("Copyright (C) 1999-2001 Hiroyuki Yamamoto <hiro-y@kcn.ne.jp>");
170         gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
171
172         hbox = gtk_hbox_new(FALSE, 0);
173         gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
174
175         button = gtk_button_new_with_label(" "HOMEPAGE_URI" ");
176         gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, FALSE, 0);
177         gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
178         gtk_signal_connect(GTK_OBJECT(button), "clicked",
179                            GTK_SIGNAL_FUNC(about_uri_clicked), NULL);
180         buf[0] = ' ';
181         for (i = 1; i <= strlen(HOMEPAGE_URI); i++) buf[i] = '_';
182         strcpy(buf + i, " ");
183         gtk_label_set_pattern(GTK_LABEL(GTK_BIN(button)->child), buf);
184         cmap = gdk_window_get_colormap(window->window);
185         gdk_colormap_alloc_colors(cmap, uri_color, 2, FALSE, TRUE, success);
186         if (success[0] == TRUE && success[1] == TRUE) {
187                 gtk_widget_ensure_style(GTK_BIN(button)->child);
188                 style = gtk_style_copy
189                         (gtk_widget_get_style(GTK_BIN(button)->child));
190                 style->fg[GTK_STATE_NORMAL]   = uri_color[0];
191                 style->fg[GTK_STATE_ACTIVE]   = uri_color[1];
192                 style->fg[GTK_STATE_PRELIGHT] = uri_color[0];
193                 gtk_widget_set_style(GTK_BIN(button)->child, style);
194         } else
195                 g_warning("about_create(): color allocation failed.\n");
196
197         scrolledwin = gtk_scrolled_window_new(NULL, NULL);
198         gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
199                                        GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
200         gtk_box_pack_start(GTK_BOX(vbox), scrolledwin, TRUE, TRUE, 0);
201
202         text = gtk_text_new(gtk_scrolled_window_get_hadjustment
203                             (GTK_SCROLLED_WINDOW(scrolledwin)),
204                             gtk_scrolled_window_get_vadjustment
205                             (GTK_SCROLLED_WINDOW(scrolledwin)));
206         gtk_text_set_word_wrap(GTK_TEXT(text), TRUE);
207         gtk_container_add(GTK_CONTAINER(scrolledwin), text);
208
209         gtk_text_freeze(GTK_TEXT(text));
210
211         gtk_text_insert(GTK_TEXT(text), NULL, NULL, NULL,
212                 _("The portions applied from fetchmail is Copyright 1997 by Eric S. "
213                   "Raymond.  Portions of those are also copyrighted by Carl Harris, "
214                   "1993 and 1995.  Copyright retained for the purpose of protecting free "
215                   "redistribution of source.\n\n"), -1);
216
217         gtk_text_insert(GTK_TEXT(text), NULL, NULL, NULL,
218                 _("Kcc is copyright by Yasuhiro Tonooka <tonooka@msi.co.jp>, "
219                   "and libkcc is copyright by takeshi@SoftAgency.co.jp.\n\n"), -1);
220
221 #if USE_GPGME
222         gtk_text_insert(GTK_TEXT(text), NULL, NULL, NULL,
223                 _("GPGME is copyright 2001 by Werner Koch <dd9jn@gnu.org>\n\n"), -1);
224 #endif /* USE_GPGME */
225
226         gtk_text_insert(GTK_TEXT(text), NULL, NULL, NULL,
227                 _("This program is free software; you can redistribute it and/or modify "
228                   "it under the terms of the GNU General Public License as published by "
229                   "the Free Software Foundation; either version 2, or (at your option) "
230                   "any later version.\n\n"), -1);
231
232         gtk_text_insert(GTK_TEXT(text), NULL, NULL, NULL,
233                 _("This program is distributed in the hope that it will be useful, "
234                   "but WITHOUT ANY WARRANTY; without even the implied warranty of "
235                   "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. "
236                   "See the GNU General Public License for more details.\n\n"), -1);
237
238         gtk_text_insert(GTK_TEXT(text), NULL, NULL, NULL,
239                 _("You should have received a copy of the GNU General Public License "
240                   "along with this program; if not, write to the Free Software "
241                   "Foundation, Inc., 59 Temple Place - Suite 330, Boston, "
242                   "MA 02111-1307, USA."), -1);
243
244         gtk_text_thaw(GTK_TEXT(text));
245
246         gtkut_button_set_create(&confirm_area, &ok_button, _("OK"),
247                                 NULL, NULL, NULL, NULL);
248         gtk_box_pack_end(GTK_BOX(vbox), confirm_area, FALSE, FALSE, 0);
249         gtk_widget_grab_default(ok_button);
250         gtk_signal_connect_object(GTK_OBJECT(ok_button), "clicked",
251                                   GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
252                                   GTK_OBJECT(window));
253
254         gtk_widget_show_all(window);
255 }
256
257 static void key_pressed(GtkWidget *widget, GdkEventKey *event)
258 {
259         if (event && event->keyval == GDK_Escape)
260                 gtk_widget_hide(window);
261 }
262
263 static void about_uri_clicked(GtkButton *button, gpointer data)
264 {
265         open_uri(HOMEPAGE_URI, prefs_common.uri_cmd);
266 }