From b9ca7b1ef5cd1f96ae6e28ae78d12c1e3258c23f Mon Sep 17 00:00:00 2001 From: hiro Date: Wed, 12 Jan 2005 11:22:08 +0000 Subject: Initial import of Sylpheed (GTK2 version). git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1 ee746299-78ed-0310-b773-934348b2243d --- src/about.c | 251 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 251 insertions(+) create mode 100644 src/about.c (limited to 'src/about.c') diff --git a/src/about.c b/src/about.c new file mode 100644 index 00000000..47758d5d --- /dev/null +++ b/src/about.c @@ -0,0 +1,251 @@ +/* + * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client + * Copyright (C) 1999-2004 Hiroyuki Yamamoto + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "defs.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if HAVE_SYS_UTSNAME_H +# include +#endif + +#include "intl.h" +#include "about.h" +#include "gtkutils.h" +#include "stock_pixmap.h" +#include "prefs_common.h" +#include "utils.h" +#include "version.h" + +static GtkWidget *window; + +static void about_create(void); +static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event); +static void about_uri_clicked(GtkButton *button, gpointer data); + +void about_show(void) +{ + if (!window) + about_create(); + else { + gtk_widget_hide(window); + gtk_widget_show(window); + } +} + +static void about_create(void) +{ + GtkWidget *vbox; + GtkWidget *pixmap; + GtkWidget *label; + GtkWidget *hbox; + GtkWidget *button; + GtkWidget *scrolledwin; + GtkWidget *text; + GtkWidget *confirm_area; + GtkWidget *ok_button; + GtkTextBuffer *buffer; + GtkTextIter iter; + GtkStyle *style; + GdkColormap *cmap; + GdkColor uri_color[2] = {{0, 0, 0, 0xffff}, {0, 0xffff, 0, 0}}; + gboolean success[2]; + +#if HAVE_SYS_UTSNAME_H + struct utsname utsbuf; +#endif + gchar buf[1024]; + gint i; + + window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_title(GTK_WINDOW(window), _("About")); + gtk_container_set_border_width(GTK_CONTAINER(window), 8); + gtk_widget_set_size_request(window, 518, 358); + gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); + g_signal_connect(G_OBJECT(window), "delete_event", + G_CALLBACK(gtk_widget_hide_on_delete), NULL); + g_signal_connect(G_OBJECT(window), "key_press_event", + G_CALLBACK(key_pressed), NULL); + gtk_widget_realize(window); + + vbox = gtk_vbox_new(FALSE, 6); + gtk_container_add(GTK_CONTAINER(window), vbox); + + pixmap = stock_pixmap_widget(window, STOCK_PIXMAP_SYLPHEED_LOGO); + gtk_box_pack_start(GTK_BOX(vbox), pixmap, FALSE, FALSE, 0); + + label = gtk_label_new("version "VERSION); + gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); + +#if HAVE_SYS_UTSNAME_H + uname(&utsbuf); + g_snprintf(buf, sizeof(buf), + "GTK+ version %d.%d.%d\n" + "Operating System: %s %s (%s)", + gtk_major_version, gtk_minor_version, gtk_micro_version, + utsbuf.sysname, utsbuf.release, utsbuf.machine); +#else + g_snprintf(buf, sizeof(buf), + "GTK+ version %d.%d.%d\n" + "Operating System: Windoze", + gtk_major_version, gtk_minor_version, gtk_micro_version); +#endif + + label = gtk_label_new(buf); + gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); + + g_snprintf(buf, sizeof(buf), + "Compiled-in features:%s", +#if HAVE_GDK_IMLIB + " gdk_imlib" +#endif +#if HAVE_GDK_PIXBUF + " gdk-pixbuf" +#endif +#if USE_THREADS + " gthread" +#endif +#if INET6 + " IPv6" +#endif +#if HAVE_ICONV + " iconv" +#endif +#if HAVE_LIBCOMPFACE + " compface" +#endif +#if USE_GPGME + " GnuPG" +#endif +#if USE_SSL + " OpenSSL" +#endif +#if USE_LDAP + " LDAP" +#endif +#if USE_JPILOT + " JPilot" +#endif + ""); + + label = gtk_label_new(buf); + gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); + + label = gtk_label_new + ("Copyright (C) 1999-2004 Hiroyuki Yamamoto "); + gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); + + hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); + + button = gtk_button_new_with_label(" "HOMEPAGE_URI" "); + gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, FALSE, 0); + gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); + g_signal_connect(G_OBJECT(button), "clicked", + G_CALLBACK(about_uri_clicked), NULL); + buf[0] = ' '; + for (i = 1; i <= strlen(HOMEPAGE_URI); i++) buf[i] = '_'; + strcpy(buf + i, " "); + gtk_label_set_pattern(GTK_LABEL(GTK_BIN(button)->child), buf); + cmap = gdk_window_get_colormap(window->window); + gdk_colormap_alloc_colors(cmap, uri_color, 2, FALSE, TRUE, success); + if (success[0] == TRUE && success[1] == TRUE) { + gtk_widget_ensure_style(GTK_BIN(button)->child); + style = gtk_style_copy + (gtk_widget_get_style(GTK_BIN(button)->child)); + style->fg[GTK_STATE_NORMAL] = uri_color[0]; + style->fg[GTK_STATE_ACTIVE] = uri_color[1]; + style->fg[GTK_STATE_PRELIGHT] = uri_color[0]; + gtk_widget_set_style(GTK_BIN(button)->child, style); + } else + g_warning("about_create(): color allocation failed.\n"); + + scrolledwin = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin), + GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); + gtk_box_pack_start(GTK_BOX(vbox), scrolledwin, TRUE, TRUE, 0); + + text = gtk_text_view_new(); + gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE); + gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD); + gtk_container_add(GTK_CONTAINER(scrolledwin), text); + + buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)); + gtk_text_buffer_get_iter_at_offset(buffer, &iter, 0); + +#if USE_GPGME + gtk_text_buffer_insert(buffer, &iter, + _("GPGME is copyright 2001 by Werner Koch \n\n"), -1); +#endif /* USE_GPGME */ + + gtk_text_buffer_insert(buffer, &iter, + _("This program is free software; you can redistribute it and/or modify " + "it under the terms of the GNU General Public License as published by " + "the Free Software Foundation; either version 2, or (at your option) " + "any later version.\n\n"), -1); + + gtk_text_buffer_insert(buffer, &iter, + _("This program is distributed in the hope that it will be useful, " + "but WITHOUT ANY WARRANTY; without even the implied warranty of " + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. " + "See the GNU General Public License for more details.\n\n"), -1); + + gtk_text_buffer_insert(buffer, &iter, + _("You should have received a copy of the GNU General Public License " + "along with this program; if not, write to the Free Software " + "Foundation, Inc., 59 Temple Place - Suite 330, Boston, " + "MA 02111-1307, USA."), -1); + + gtkut_button_set_create(&confirm_area, &ok_button, _("OK"), + NULL, NULL, NULL, NULL); + gtk_box_pack_end(GTK_BOX(vbox), confirm_area, FALSE, FALSE, 0); + gtk_widget_grab_default(ok_button); + g_signal_connect_closure + (G_OBJECT(ok_button), "clicked", + g_cclosure_new_swap(G_CALLBACK(gtk_widget_hide_on_delete), + window, NULL), FALSE); + + gtk_widget_show_all(window); +} + +static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event) +{ + if (event && event->keyval == GDK_Escape) + gtk_widget_hide(window); + return FALSE; +} + +static void about_uri_clicked(GtkButton *button, gpointer data) +{ + open_uri(HOMEPAGE_URI, prefs_common.uri_cmd); +} -- cgit v1.2.3