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