2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2003 Hiroyuki Yamamoto
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
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/gtklabel.h>
34 #include <gtk/gtkhseparator.h>
35 #include <gtk/gtkscrolledwindow.h>
36 #include <gtk/gtktext.h>
37 #include <gtk/gtkbutton.h>
38 #if HAVE_SYS_UTSNAME_H
39 # include <sys/utsname.h>
45 #include "stock_pixmap.h"
46 #include "prefs_common.h"
50 static GtkWidget *window;
52 static void about_create(void);
53 static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event);
54 static void about_uri_clicked(GtkButton *button, gpointer data);
61 gtk_widget_hide(window);
62 gtk_widget_show(window);
66 static void about_create(void)
73 GtkWidget *scrolledwin;
75 GtkWidget *confirm_area;
79 GdkColor uri_color[2] = {{0, 0, 0, 0xffff}, {0, 0xffff, 0, 0}};
81 GtkTextBuffer *buffer;
84 #if HAVE_SYS_UTSNAME_H
85 struct utsname utsbuf;
90 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
91 gtk_window_set_title(GTK_WINDOW(window), _("About"));
92 gtk_container_set_border_width(GTK_CONTAINER(window), 8);
93 gtk_widget_set_size_request(window, 518, 358);
94 g_signal_connect(G_OBJECT(window), "delete_event",
95 G_CALLBACK(gtk_widget_hide_on_delete), NULL);
96 g_signal_connect(G_OBJECT(window), "key_press_event",
97 G_CALLBACK(key_pressed), NULL);
98 gtk_widget_realize(window);
100 vbox = gtk_vbox_new(FALSE, 6);
101 gtk_container_add(GTK_CONTAINER(window), vbox);
103 pixmap = stock_pixmap_widget(window, STOCK_PIXMAP_SYLPHEED_LOGO);
104 gtk_box_pack_start(GTK_BOX(vbox), pixmap, FALSE, FALSE, 0);
106 label = gtk_label_new("version "VERSION);
107 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
109 #if HAVE_SYS_UTSNAME_H
111 g_snprintf(buf, sizeof(buf),
112 _("GTK+ version %d.%d.%d\n"
113 "Operating System: %s %s (%s)"),
114 gtk_major_version, gtk_minor_version, gtk_micro_version,
115 utsbuf.sysname, utsbuf.release, utsbuf.machine);
117 g_snprintf(buf, sizeof(buf),
118 "GTK+ version %d.%d.%d\n"
119 "Operating System: Windoze",
120 gtk_major_version, gtk_minor_version, gtk_micro_version);
123 label = gtk_label_new(buf);
124 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
126 g_snprintf(buf, sizeof(buf),
127 _("Compiled-in features:%s"),
160 label = gtk_label_new(buf);
161 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
163 label = gtk_label_new
164 ("Copyright (C) 1999-2004 Hiroyuki Yamamoto <hiro-y@kcn.ne.jp>");
165 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
167 hbox = gtk_hbox_new(FALSE, 0);
168 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
170 button = gtk_button_new_with_label(" "HOMEPAGE_URI" ");
171 gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, FALSE, 0);
172 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
173 g_signal_connect(G_OBJECT(button), "clicked",
174 G_CALLBACK(about_uri_clicked), NULL);
176 for (i = 1; i <= strlen(HOMEPAGE_URI); i++) buf[i] = '_';
177 strcpy(buf + i, " ");
178 gtk_label_set_pattern(GTK_LABEL(GTK_BIN(button)->child), buf);
179 cmap = gdk_window_get_colormap(window->window);
180 gdk_colormap_alloc_colors(cmap, uri_color, 2, FALSE, TRUE, success);
181 if (success[0] == TRUE && success[1] == TRUE) {
182 gtk_widget_ensure_style(GTK_BIN(button)->child);
183 style = gtk_style_copy
184 (gtk_widget_get_style(GTK_BIN(button)->child));
185 style->fg[GTK_STATE_NORMAL] = uri_color[0];
186 style->fg[GTK_STATE_ACTIVE] = uri_color[1];
187 style->fg[GTK_STATE_PRELIGHT] = uri_color[0];
188 gtk_widget_set_style(GTK_BIN(button)->child, style);
190 g_warning("about_create(): color allocation failed.\n");
192 scrolledwin = gtk_scrolled_window_new(NULL, NULL);
193 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
194 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
195 gtk_box_pack_start(GTK_BOX(vbox), scrolledwin, TRUE, TRUE, 0);
197 text = gtk_text_view_new();
198 gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
199 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD);
200 gtk_container_add(GTK_CONTAINER(scrolledwin), text);
202 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
203 gtk_text_buffer_get_iter_at_offset(buffer, &iter, 0);
205 gtk_text_buffer_insert(buffer, &iter,
206 _("This program is free software; you can redistribute it and/or modify "
207 "it under the terms of the GNU General Public License as published by "
208 "the Free Software Foundation; either version 2, or (at your option) "
209 "any later version.\n\n"), -1);
211 gtk_text_buffer_insert(buffer, &iter,
212 _("This program is distributed in the hope that it will be useful, "
213 "but WITHOUT ANY WARRANTY; without even the implied warranty of "
214 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. "
215 "See the GNU General Public License for more details.\n\n"), -1);
217 gtk_text_buffer_insert(buffer, &iter,
218 _("You should have received a copy of the GNU General Public License "
219 "along with this program; if not, write to the Free Software "
220 "Foundation, Inc., 59 Temple Place - Suite 330, Boston, "
221 "MA 02111-1307, USA."), -1);
223 gtkut_button_set_create(&confirm_area, &ok_button, _("OK"),
224 NULL, NULL, NULL, NULL);
225 gtk_box_pack_end(GTK_BOX(vbox), confirm_area, FALSE, FALSE, 0);
226 gtk_widget_grab_default(ok_button);
227 g_signal_connect_closure
228 (G_OBJECT(ok_button), "clicked",
229 g_cclosure_new_swap(G_CALLBACK(gtk_widget_hide_on_delete),
230 window, NULL), FALSE);
231 gtk_widget_show_all(window);
234 static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event)
236 if (event && event->keyval == GDK_Escape)
237 gtk_widget_hide(window);
241 static void about_uri_clicked(GtkButton *button, gpointer data)
243 open_uri(HOMEPAGE_URI, prefs_common.uri_cmd);