root / src / about.c @ 135
History | View | Annotate | Download (7.9 kB)
| 1 | /*
|
|---|---|
| 2 | * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client |
| 3 | * Copyright (C) 1999-2005 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 <glib/gi18n.h> |
| 28 | #include <gdk/gdkkeysyms.h> |
| 29 | #include <gtk/gtkwidget.h> |
| 30 | #include <gtk/gtkwindow.h> |
| 31 | #include <gtk/gtksignal.h> |
| 32 | #include <gtk/gtkvbox.h> |
| 33 | #include <gtk/gtkhbox.h> |
| 34 | #include <gtk/gtklabel.h> |
| 35 | #include <gtk/gtkhseparator.h> |
| 36 | #include <gtk/gtkscrolledwindow.h> |
| 37 | #include <gtk/gtktextview.h> |
| 38 | #include <gtk/gtkbutton.h> |
| 39 | #if HAVE_SYS_UTSNAME_H
|
| 40 | # include <sys/utsname.h> |
| 41 | #endif
|
| 42 | |
| 43 | #include "about.h" |
| 44 | #include "gtkutils.h" |
| 45 | #include "stock_pixmap.h" |
| 46 | #include "prefs_common.h" |
| 47 | #include "utils.h" |
| 48 | #include "version.h" |
| 49 | |
| 50 | static GtkWidget *window;
|
| 51 | |
| 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); |
| 55 | |
| 56 | void about_show(void) |
| 57 | {
|
| 58 | if (!window)
|
| 59 | about_create(); |
| 60 | else
|
| 61 | gtk_window_present(GTK_WINDOW(window)); |
| 62 | } |
| 63 | |
| 64 | static void about_create(void) |
| 65 | {
|
| 66 | GtkWidget *vbox; |
| 67 | GtkWidget *pixmap; |
| 68 | GtkWidget *label; |
| 69 | GtkWidget *hbox; |
| 70 | GtkWidget *button; |
| 71 | GtkWidget *scrolledwin; |
| 72 | GtkWidget *text; |
| 73 | GtkWidget *confirm_area; |
| 74 | GtkWidget *ok_button; |
| 75 | GtkTextBuffer *buffer; |
| 76 | GtkTextIter iter; |
| 77 | GtkStyle *style; |
| 78 | GdkColormap *cmap; |
| 79 | GdkColor uri_color[2] = {{0, 0, 0, 0xffff}, {0, 0xffff, 0, 0}}; |
| 80 | gboolean success[2];
|
| 81 | |
| 82 | #if HAVE_SYS_UTSNAME_H
|
| 83 | struct utsname utsbuf;
|
| 84 | #endif
|
| 85 | gchar buf[1024];
|
| 86 | gint i; |
| 87 | |
| 88 | window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
| 89 | gtk_window_set_title(GTK_WINDOW(window), _("About"));
|
| 90 | gtk_container_set_border_width(GTK_CONTAINER(window), 8);
|
| 91 | gtk_widget_set_size_request(window, 518, 358); |
| 92 | gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); |
| 93 | g_signal_connect(G_OBJECT(window), "delete_event",
|
| 94 | G_CALLBACK(gtk_widget_hide_on_delete), NULL);
|
| 95 | g_signal_connect(G_OBJECT(window), "key_press_event",
|
| 96 | G_CALLBACK(key_pressed), NULL);
|
| 97 | gtk_widget_realize(window); |
| 98 | |
| 99 | vbox = gtk_vbox_new(FALSE, 6);
|
| 100 | gtk_container_add(GTK_CONTAINER(window), vbox); |
| 101 | |
| 102 | pixmap = stock_pixmap_widget(window, STOCK_PIXMAP_SYLPHEED_LOGO); |
| 103 | gtk_box_pack_start(GTK_BOX(vbox), pixmap, FALSE, FALSE, 0);
|
| 104 | |
| 105 | label = gtk_label_new("version "VERSION);
|
| 106 | gtk_label_set_selectable(GTK_LABEL(label), TRUE); |
| 107 | gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
|
| 108 | |
| 109 | #if HAVE_SYS_UTSNAME_H
|
| 110 | uname(&utsbuf); |
| 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); |
| 116 | #else
|
| 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); |
| 121 | #endif
|
| 122 | |
| 123 | label = gtk_label_new(buf); |
| 124 | gtk_label_set_selectable(GTK_LABEL(label), TRUE); |
| 125 | gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER); |
| 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_ICONV
|
| 143 | " iconv"
|
| 144 | #endif
|
| 145 | #if HAVE_LIBCOMPFACE
|
| 146 | " compface"
|
| 147 | #endif
|
| 148 | #if USE_GPGME
|
| 149 | " GnuPG"
|
| 150 | #endif
|
| 151 | #if USE_SSL
|
| 152 | " OpenSSL"
|
| 153 | #endif
|
| 154 | #if USE_LDAP
|
| 155 | " LDAP"
|
| 156 | #endif
|
| 157 | #if USE_JPILOT
|
| 158 | " JPilot"
|
| 159 | #endif
|
| 160 | "");
|
| 161 | |
| 162 | label = gtk_label_new(buf); |
| 163 | gtk_label_set_selectable(GTK_LABEL(label), TRUE); |
| 164 | gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
|
| 165 | |
| 166 | label = gtk_label_new |
| 167 | ("Copyright (C) 1999-2005 Hiroyuki Yamamoto <hiro-y@kcn.ne.jp>");
|
| 168 | gtk_label_set_selectable(GTK_LABEL(label), TRUE); |
| 169 | gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
|
| 170 | |
| 171 | hbox = gtk_hbox_new(FALSE, 0);
|
| 172 | gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
|
| 173 | |
| 174 | button = gtk_button_new_with_label(" "HOMEPAGE_URI" "); |
| 175 | gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, FALSE, 0);
|
| 176 | gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
| 177 | g_signal_connect(G_OBJECT(button), "clicked",
|
| 178 | G_CALLBACK(about_uri_clicked), NULL);
|
| 179 | buf[0] = ' '; |
| 180 | for (i = 1; i <= strlen(HOMEPAGE_URI); i++) buf[i] = '_'; |
| 181 | strcpy(buf + i, " ");
|
| 182 | gtk_label_set_pattern(GTK_LABEL(GTK_BIN(button)->child), buf); |
| 183 | cmap = gdk_window_get_colormap(window->window); |
| 184 | gdk_colormap_alloc_colors(cmap, uri_color, 2, FALSE, TRUE, success);
|
| 185 | if (success[0] == TRUE && success[1] == TRUE) { |
| 186 | gtk_widget_ensure_style(GTK_BIN(button)->child); |
| 187 | style = gtk_style_copy |
| 188 | (gtk_widget_get_style(GTK_BIN(button)->child)); |
| 189 | style->fg[GTK_STATE_NORMAL] = uri_color[0];
|
| 190 | style->fg[GTK_STATE_ACTIVE] = uri_color[1];
|
| 191 | style->fg[GTK_STATE_PRELIGHT] = uri_color[0];
|
| 192 | gtk_widget_set_style(GTK_BIN(button)->child, style); |
| 193 | } else
|
| 194 | g_warning("about_create(): color allocation failed.\n");
|
| 195 | |
| 196 | scrolledwin = gtk_scrolled_window_new(NULL, NULL); |
| 197 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin), |
| 198 | GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); |
| 199 | gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwin), |
| 200 | GTK_SHADOW_IN); |
| 201 | gtk_box_pack_start(GTK_BOX(vbox), scrolledwin, TRUE, TRUE, 0);
|
| 202 | |
| 203 | text = gtk_text_view_new(); |
| 204 | gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE); |
| 205 | gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD); |
| 206 | gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 6);
|
| 207 | gtk_text_view_set_right_margin(GTK_TEXT_VIEW(text), 6);
|
| 208 | gtk_container_add(GTK_CONTAINER(scrolledwin), text); |
| 209 | |
| 210 | buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)); |
| 211 | gtk_text_buffer_get_iter_at_offset(buffer, &iter, 0);
|
| 212 | |
| 213 | #if USE_GPGME
|
| 214 | gtk_text_buffer_insert(buffer, &iter, |
| 215 | _("GPGME is copyright 2001 by Werner Koch <dd9jn@gnu.org>\n\n"), -1); |
| 216 | #endif /* USE_GPGME */ |
| 217 | |
| 218 | gtk_text_buffer_insert(buffer, &iter, |
| 219 | _("This program is free software; you can redistribute it and/or modify "
|
| 220 | "it under the terms of the GNU General Public License as published by "
|
| 221 | "the Free Software Foundation; either version 2, or (at your option) "
|
| 222 | "any later version.\n\n"), -1); |
| 223 | |
| 224 | gtk_text_buffer_insert(buffer, &iter, |
| 225 | _("This program is distributed in the hope that it will be useful, "
|
| 226 | "but WITHOUT ANY WARRANTY; without even the implied warranty of "
|
| 227 | "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. "
|
| 228 | "See the GNU General Public License for more details.\n\n"), -1); |
| 229 | |
| 230 | gtk_text_buffer_insert(buffer, &iter, |
| 231 | _("You should have received a copy of the GNU General Public License "
|
| 232 | "along with this program; if not, write to the Free Software "
|
| 233 | "Foundation, Inc., 59 Temple Place - Suite 330, Boston, "
|
| 234 | "MA 02111-1307, USA."), -1); |
| 235 | |
| 236 | gtkut_stock_button_set_create(&confirm_area, &ok_button, GTK_STOCK_OK, |
| 237 | NULL, NULL, NULL, NULL); |
| 238 | gtk_box_pack_end(GTK_BOX(vbox), confirm_area, FALSE, FALSE, 0);
|
| 239 | gtk_widget_grab_default(ok_button); |
| 240 | g_signal_connect_closure |
| 241 | (G_OBJECT(ok_button), "clicked",
|
| 242 | g_cclosure_new_swap(G_CALLBACK(gtk_widget_hide_on_delete), |
| 243 | window, NULL), FALSE);
|
| 244 | |
| 245 | gtk_widget_show_all(window); |
| 246 | } |
| 247 | |
| 248 | static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event)
|
| 249 | {
|
| 250 | if (event && event->keyval == GDK_Escape)
|
| 251 | gtk_widget_hide(window); |
| 252 | return FALSE;
|
| 253 | } |
| 254 | |
| 255 | static void about_uri_clicked(GtkButton *button, gpointer data) |
| 256 | {
|
| 257 | open_uri(HOMEPAGE_URI, prefs_common.uri_cmd); |
| 258 | } |