1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398
|
/* $Id: help.cc,v 1.21 2003/11/22 04:55:28 bergo Exp $ */
/*
eboard - chess client
http://eboard.sourceforge.net
Copyright (C) 2000-2003 Felipe Paulo Guazzi Bergo
bergo@seul.org
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
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include <time.h>
#include "util.h"
#include "tstring.h"
#include "global.h"
#include "help.h"
#include "mainwindow.h"
#include "eboard.h"
#include "widgetproxy.h"
#include "gnupiece.xpm"
namespace Help {
AboutDialog::AboutDialog() : ModalDialog(N_("About eboard")) {
GtkWidget *v,*hb,*label,*bhb,*hs,*ok,*gnup;
GtkStyle *style;
GdkPixmap *gnud;
GdkBitmap *gnub;
char z[1024];
v=gtk_vbox_new(FALSE,4);
gtk_container_add(GTK_CONTAINER(widget),v);
hb=gtk_hbox_new(FALSE,4);
gtk_box_pack_start(GTK_BOX(v),hb,TRUE,TRUE,0);
style=gtk_widget_get_style(widget);
gnud=gdk_pixmap_create_from_xpm_d(widget->window,&gnub,
&style->bg[GTK_STATE_NORMAL],
(gchar **)gnupiece_xpm);
gnup=gtk_pixmap_new(gnud,gnub);
gtk_box_pack_start(GTK_BOX(hb),gnup,FALSE,TRUE,4);
sprintf(z,
_("eboard version %s\n"\
"(c) 2000-%d Felipe Bergo\n"\
"<bergo@seul.org>\n"\
"http://eboard.sourceforge.net\n\n"\
"This program is free software; you can redistribute\n"\
"it and/or modify it under the terms of the GNU General\n"\
"Public License as published by the Free Software\n"\
"Foundation; either version 2 of the License, or\n"\
"(at your option) any later version.\n"),
global.Version, 2003);
label=gtk_label_new(z);
gtk_label_set_justify(GTK_LABEL(label),GTK_JUSTIFY_LEFT);
gtk_box_pack_start(GTK_BOX(hb),label,TRUE,TRUE,4);
hs=gtk_hseparator_new();
gtk_box_pack_start(GTK_BOX(v),hs,FALSE,FALSE,4);
bhb=gtk_hbutton_box_new();
gtk_button_box_set_layout(GTK_BUTTON_BOX(bhb), GTK_BUTTONBOX_END);
gtk_button_box_set_spacing(GTK_BUTTON_BOX(bhb), 5);
gtk_box_pack_start(GTK_BOX(v),bhb,FALSE,FALSE,4);
ok=gtk_button_new_with_label(_("Close"));
GTK_WIDGET_SET_FLAGS(ok,GTK_CAN_DEFAULT);
gtk_box_pack_start(GTK_BOX(bhb),ok,TRUE,TRUE,0);
gtk_widget_grab_default(ok);
Gtk::show(ok,bhb,hs,label,gnup,hb,v,0);
setDismiss(GTK_OBJECT(ok),"clicked");
}
KeysDialog::KeysDialog() : ModalDialog(N_("Help: Keys")) {
GtkWidget *v,*label,*bhb,*hs,*ok;
char z[1024];
v=gtk_vbox_new(FALSE,4);
gtk_container_add(GTK_CONTAINER(widget),v);
strcpy(z,
_("Anywhere:\n"\
"F3: Go to previous pane.\n"\
"F4: Go to next pane.\n"\
"F5: Go to the main board pane.\n"\
"F6: Go to the console pane.\n"\
"F7: Go to the seek graph pane (if available).\n"\
"F8: Toggle Shortcut Bar visilibity.\n"\
"Page Up/Page Down: scrolls the text console (must be visible)\n"\
"Ctrl+(Left Arrow): Backward 1 halfmove\n"\
"Ctrl+(Right Arrow): Forward 1 halfmove\n"\
"Ctrl+F: Find Upwards(main console buffer)\n"\
"Ctrl+G: Find Previous\n"\
"\nInput box:\n"\
"Up/Down (arrows): move thru input history\n"\
"Enter: send text line\n"\
"Esc: switch Chat/Command Mode\n"\
"\nSyntaxisms:\n"\
"In main window's input box:\n"\
".. entering %prefix text will set the chat prefix to text.\n"\
".. entering %do scriptname will run scriptname."));
label=gtk_label_new(z);
gtk_label_set_justify(GTK_LABEL(label),GTK_JUSTIFY_LEFT);
gtk_box_pack_start(GTK_BOX(v),label,TRUE,TRUE,4);
hs=gtk_hseparator_new();
gtk_box_pack_start(GTK_BOX(v),hs,FALSE,FALSE,4);
bhb=gtk_hbutton_box_new();
gtk_button_box_set_layout(GTK_BUTTON_BOX(bhb), GTK_BUTTONBOX_END);
gtk_button_box_set_spacing(GTK_BUTTON_BOX(bhb), 5);
gtk_box_pack_start(GTK_BOX(v),bhb,FALSE,FALSE,4);
ok=gtk_button_new_with_label(_("Close"));
GTK_WIDGET_SET_FLAGS(ok,GTK_CAN_DEFAULT);
gtk_box_pack_start(GTK_BOX(bhb),ok,TRUE,TRUE,0);
gtk_widget_grab_default(ok);
Gtk::show(ok,bhb,hs,label,v,0);
setDismiss(GTK_OBJECT(ok),"clicked");
}
DebugDialog::DebugDialog() : ModalDialog(N_("Help: Debug Info")) {
GtkWidget *v,*label,*hs,*bhb,*ok,*txt;
char z[2048],y[256],x[256],w[256];
struct stat s;
EboardFileFinder eff;
v=gtk_vbox_new(FALSE,4);
gtk_container_add(GTK_CONTAINER(widget),v);
z[0]=0;
// gtk
sprintf(y,"GTK+ version %d.%d.%d\n",
gtk_major_version,
gtk_minor_version,
gtk_micro_version);
strcat(z,y);
// imlib
sprintf(y,"Imlib version %s\n",grabOutput("imlib-config --version"));
strcat(z,y);
// gcc (c++) if any
sprintf(y,"GCC says: %s\n",
grabOutput("c++ --version 2>&1"));
strcat(z,y);
// perl
sprintf(y,"Perl says: %s\n",
grabOutput("perl -v | grep version"));
strcat(z,y);
// expect
sprintf(y,"expect says: %s\n",
grabOutput("expect -d -c exit 2>&1"));
strcat(z,y);
// kernel
sprintf(y,"kernel info: %s\n",
grabOutput("uname -srm"));
strcat(z,y);
// timeseal
sprintf(x,"timeseal.%s",global.SystemType);
if (!eff.find(x,y)) strcpy(y,x);
if (lstat(y,&s)==0) {
sprintf(w,"Found %s\n",y); strcpy(x,w);
sprintf(w,"Size %lu bytes, Last Modified %s",
s.st_size, ctime(&(s.st_mtime)) );
strcat(x,w);
sprintf(w,"Mode %.4o. (seems it i%s enough to be run by eboard)\n",
s.st_mode,
( S_ISREG(s.st_mode)
&&
(
( S_IXUSR&s.st_mode && s.st_uid==getuid() )
||
( S_IXGRP&s.st_mode && s.st_gid==getgid() )
||
( S_IXOTH&s.st_mode )
)
) ? "s" : "s NOT"
);
strcat(x,w);
} else {
sprintf(x,"%s Not Found (errno %d)",y,errno);
}
sprintf(y,"\nFICS timeseal:\n%s\n",x);
strcat(z,y);
label=gtk_label_new(z);
gtk_label_set_justify(GTK_LABEL(label),GTK_JUSTIFY_LEFT);
gtk_box_pack_start(GTK_BOX(v),label,TRUE,TRUE,4);
hs=gtk_hseparator_new();
gtk_box_pack_start(GTK_BOX(v),hs,FALSE,FALSE,4);
bhb=gtk_hbutton_box_new();
gtk_button_box_set_layout(GTK_BUTTON_BOX(bhb), GTK_BUTTONBOX_END);
gtk_button_box_set_spacing(GTK_BUTTON_BOX(bhb), 5);
gtk_box_pack_start(GTK_BOX(v),bhb,FALSE,FALSE,4);
ok=gtk_button_new_with_label(_("Close"));
txt=gtk_button_new_with_label(_("Write to Console"));
GTK_WIDGET_SET_FLAGS(ok,GTK_CAN_DEFAULT);
GTK_WIDGET_SET_FLAGS(txt,GTK_CAN_DEFAULT);
gtk_box_pack_start(GTK_BOX(bhb),txt,TRUE,TRUE,0);
gtk_box_pack_start(GTK_BOX(bhb),ok,TRUE,TRUE,0);
gtk_widget_grab_default(ok);
Gtk::show(ok,txt,bhb,hs,label,v,0);
setDismiss(GTK_OBJECT(ok),"clicked");
gtk_signal_connect(GTK_OBJECT(txt),"clicked",
GTK_SIGNAL_FUNC(debugdlg_writecons),
(gpointer) this);
strcpy(pipedata,z);
}
char * DebugDialog::grabOutput(char *cmdline) {
FILE *f;
bool ok = false;
char *c;
f=popen(cmdline,"r");
if (f) {
if (fgets(pipedata,127,f))
ok=true;
pclose(f);
}
if (!ok)
strcpy(pipedata,"unable to retrieve");
else
while( (c=index(pipedata,'\n'))!=NULL)
*c=0;
return pipedata;
}
void debugdlg_writecons(GtkWidget *w, gpointer data) {
DebugDialog *me;
tstring t;
string *c;
char z[512];
me = (DebugDialog *) data;
t.set(me->pipedata);
global.output->append("=== START DEBUG INFO ===",0xc0ff00);
while( (c=t.token("\n")) != 0) {
memset(z,0,512);
c->copy(z,511);
global.output->append(z, global.Colors.TextBright);
}
global.output->append("=== END DEBUG INFO ===",0xc0ff00);
}
GettingStarted::GettingStarted() : NonModalDialog(N_("Help: Getting Started ")) {
GtkWidget *v, *bhb, *ok;
gtk_window_set_default_size(GTK_WINDOW(widget),580,520);
v=gtk_vbox_new(FALSE,4);
gtk_container_add(GTK_CONTAINER(widget),v);
text=gtk_text_new(0,0);
gtk_box_pack_start(GTK_BOX(v),text,TRUE,TRUE,0);
bhb=gtk_hbutton_box_new();
gtk_button_box_set_layout(GTK_BUTTON_BOX(bhb), GTK_BUTTONBOX_END);
gtk_button_box_set_spacing(GTK_BUTTON_BOX(bhb), 5);
gtk_box_pack_start(GTK_BOX(v),bhb,FALSE,FALSE,4);
ok=gtk_button_new_with_label(_("Close"));
GTK_WIDGET_SET_FLAGS(ok,GTK_CAN_DEFAULT);
gtk_box_pack_start(GTK_BOX(bhb),ok,TRUE,TRUE,0);
gtk_widget_grab_default(ok);
Gtk::show(ok,bhb,text,v,0);
setDismiss(GTK_OBJECT(ok),"clicked");
compose();
}
void GettingStarted::compose() {
GdkFont *fl, *fm, *fs, *f;
GdkColor blue, *pc;
char *T,*p,*q;
static char *tags="\200\201\202\203\204";
blue.red=0;
blue.green=0;
blue.blue=0xffff;
fl=global.loadFont(EF_ClockFont);
fm=global.loadFont(EF_PlayerFont);
fs=global.loadFont(EF_InfoFont);
// codes: 200 large 201 medium 202 small 203 blue 204 black
T=_("\200Getting Started\n"\
"\201Common Tasks in eboard\n\n"\
"Playing against the computer\n"\
"\202eboard does not \"play chess\" itself, but rather is works as interface to programs that do,\n"\
"called \"engines\", which don't have a graphical interface themselves. You need an engine to\n"\
"play against the computer. GNU Chess, Crafty and Sjeng are chess engines that are available at\n"\
"no cost.\n"\
"Once you have one of them installed, open the \203Peer\204 menu, then the \203Play against\n"\
"engine\204 submenu, and select the appropriate option depending on which engine you have\n"\
"installed.\n\n"\
"\201Playing Chess on the Internet\n"\
"\202Eboard supports the FICS protocol. FICS runs at freechess.org, but other servers, such as\n"\
"US Chess Live, use FICS's software and should work with eboard too. ICC is not supported.\n"\
"To connect to FICS, open the \203Peer\204 menu, click \203Connect to FICS\204. To connect to\n"\
"other servers, open the \203Peer\204 menu, click \203Connect to Other Server...\204.\n"\
"While you can login as guest on FICS, you'll enjoy it better as a registered user. Registration\n"\
"is done through FICS's site at \203http://www.freechess.org\204, and it's free.\n\n"\
"\201Browsing PGN Games\n"\
"\202PGN is the most common file format to store chess games. It can store moves and comments\n"\
"(annotations). To open this kind of file within eboard, open the \203Windows\204 menu, click\n"\
"\203Games on Client\204. In the Local Game List dialog, click \203Load PGN...\204. To browse a\n"\
"game, \203select it\204 and click \203Display\204. A new tab will be created in the main window\n"\
"with the game."\
"\200");
f = fs;
pc = 0;
q = T;
for(p=T;*p;p++) {
if (strchr(tags, *p)) {
if (p-q) gtk_text_insert(GTK_TEXT(text),f,pc,0,q,p-q);
q = p + 1;
switch(*p) {
case '\200': f=fl; break;
case '\201': f=fm; break;
case '\202': f=fs; break;
case '\203': pc=&blue; break;
case '\204': pc=0; break;
}
}
}
if (fs) gdk_font_unref(fs);
if (fm) gdk_font_unref(fm);
if (fl) gdk_font_unref(fl);
}
} // namespace Help
|