1 /* Copyright (C) 2001-2004 Kenichi Suto 2 * 3 * This program is free software; you can redistribute it and/or modify 4 * it under the terms of the GNU General Public License as published by 5 * the Free Software Foundation; either version 2 of the License, or 6 * (at your option) any later version. 7 * 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU General Public License for more details. 12 * 13 * You should have received a copy of the GNU General Public License 14 * along with this program; if not, write to the Free Software 15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 */ 17 18 #ifndef __DEFS_H__ 19 #define __DEFS_H__ 20 21 /* Disable old GTK+ functions */ 22 //#define GTK_DISABLE_DEPRECATED 1 23 24 #include "../config.h" 25 #include <sys/stat.h> 26 #include <fcntl.h> 27 #include <sys/types.h> 28 #include <sys/time.h> 29 #include <stdio.h> 30 #include <stdlib.h> 31 #include <string.h> 32 #include <gtk/gtk.h> 33 #include <gdk/gdkprivate.h> 34 #include <locale.h> 35 #include <ctype.h> 36 #include <unistd.h> 37 #include <dirent.h> 38 #include <errno.h> 39 40 #ifdef __WIN32__ 41 #define ENABLE_NLS 1 42 #endif 43 #include "intl.h" 44 45 /* Platform specific includes */ 46 #ifdef __WIN32__ 47 48 #include <windows.h> 49 #include <gdk/gdkwin32.h> 50 51 #else 52 53 #include <X11/X.h> 54 #include <X11/Xatom.h> 55 #include <gdk/gdkx.h> 56 57 #endif /* __WIN32__ */ 58 59 /* EB Library includes */ 60 #define ENABLE_EBNET 61 //#define EBCONF_EHABLE_PTHREAD 62 63 #include <eb/eb.h> 64 #include <eb/defs.h> 65 #include <eb/text.h> 66 #include <eb/font.h> 67 #include <eb/appendix.h> 68 #include <eb/error.h> 69 #include <eb/binary.h> 70 71 #define eb_uint1(p) (*(const unsigned char *)(p)) 72 73 #define eb_uint2(p) ((*(const unsigned char *)(p) << 8) \ 74 + (*(const unsigned char *)((p) + 1))) 75 76 #define eb_uint3(p) ((*(const unsigned char *)(p) << 16) \ 77 + (*(const unsigned char *)((p) + 1) << 8) \ 78 + (*(const unsigned char *)((p) + 2))) 79 80 #define eb_uint4(p) ((*(const unsigned char *)(p) << 24) \ 81 + (*(const unsigned char *)((p) + 1) << 16) \ 82 + (*(const unsigned char *)((p) + 2) << 8) \ 83 + (*(const unsigned char *)((p) + 3))) 84 85 #define eb_uint4_le(p) ((*(const unsigned char *)(p)) \ 86 + (*(const unsigned char *)((p) + 1) << 8) \ 87 + (*(const unsigned char *)((p) + 2) << 16) \ 88 + (*(const unsigned char *)((p) + 3) << 24)) 89 90 91 92 #define MAX_BUFF 512 93 #define MAX_BOOKS 128 94 #define MAX_MULTI_SEARCH 10 95 96 #define SEARCH_METHOD_AUTOMATIC 50 97 #define SEARCH_METHOD_WORD 0 98 #define SEARCH_METHOD_ENDWORD 1 99 #define SEARCH_METHOD_EXACTWORD 2 100 #define SEARCH_METHOD_KEYWORD 3 101 #define SEARCH_METHOD_MULTI 4 102 #define SEARCH_METHOD_MENU 10 103 #define SEARCH_METHOD_COPYRIGHT 11 104 #define SEARCH_METHOD_FULL_TEXT 12 105 #define SEARCH_METHOD_FULL_HEADING 13 106 #define SEARCH_METHOD_INTERNET 14 107 #define SEARCH_METHOD_GREP 15 108 #define SEARCH_METHOD_UNKNOWN 99 109 110 #define SEARCH_METHOD_MIN 0 111 #define SEARCH_METHOD_MAX 4 112 113 114 #define CURSOR_LINK GDK_HAND2 115 #define CURSOR_NORMAL GDK_LEFT_PTR 116 #define CURSOR_BUSY GDK_CLOCK 117 #define CURSOR_SOUND GDK_CLOCK 118 119 #define TAG_TYPE_NONE 0 120 #define TAG_TYPE_LINK 1 << 1 121 #define TAG_TYPE_SOUND 1 << 2 122 #define TAG_TYPE_MOVIE 1 << 3 123 #define TAG_TYPE_EMPHASIS 1 << 4 124 #define TAG_TYPE_SUBSCRIPT 1 << 5 125 #define TAG_TYPE_SUPERSCRIPT 1 << 6 126 #define TAG_TYPE_KEYWORD 1 << 7 127 #define TAG_TYPE_ITALIC 1 << 8 128 #define TAG_TYPE_CENTER 1 << 9 129 #define TAG_TYPE_REVERSE 1 << 10 130 #define TAG_TYPE_COLORED 1 << 11 131 132 #define MAX_INDENT 16 133 #define INDENT_LEFT_MARGIN 16 134 #define INITIAL_LEFT_MARGIN 10 135 136 #define DATA_TEXT 0 137 #define DATA_NOENDTAG 1 138 #define DATA_SPECIAL 2 139 #define DATA_BRANCH 3 140 141 #define COLOR_LINK 0 142 #define COLOR_KEYWORD 1 143 #define COLOR_SOUND 2 144 #define COLOR_MOVIE 3 145 #define COLOR_EMPHASIS 4 146 #define COLOR_REVERSE_BG 5 147 #define NUM_COLORS 6 148 149 #define SELECTION_DO_NOTHING 0 150 #define SELECTION_COPY_ONLY 1 151 #define SELECTION_SEARCH 2 152 #define SELECTION_SEARCH_TOP 3 153 #define SELECTION_POPUP 4 154 155 156 #define HEADING_WIDTH 1024 157 #define HEADING_HEIGHT 18 158 #define HEADING_PIXMAP_WIDTH 2048 159 #define HEADING_PIXMAP_HEIGHT 18 160 #define LINE_HEIGHT 18 161 #define DICT_WIDTH 500 162 #define DICT_HEIGHT 1024*10 163 164 #define PIXMAP_BUFFER_WIDTH 1280 165 #define PIXMAP_BUFFER_HEIGHT 1024*10 166 #define GAIJI_ADJUSTMENT 2 167 168 #define MODE_PLAIN 0 169 #define MODE_REDRAW 1 170 #define MODE_LINK 2 171 172 #define DIRECTION_FORWARD 0 173 #define DIRECTION_BACKWARD 1 174 175 enum 176 { 177 RESULT_TYPE_EB, 178 RESULT_TYPE_GREP 179 }; 180 181 182 #define MAX_DICT_GROUP 255 183 #define MAX_GROUP_MEMBER 255 184 #define MAX_KEYWORD_LENGTH 255 185 186 #define FILENAME_PREFERENCE "preference.xml" 187 #define FILENAME_DICTGROUP "dictgroup.xml" 188 #define FILENAME_STEMMING_EN "endinglist.xml" 189 #define FILENAME_STEMMING_JA "endinglist-ja.xml" 190 #define FILENAME_SHORTCUT "shortcut.xml" 191 #define FILENAME_WEBLIST "searchengines.xml" 192 #define FILENAME_HISTORY "history.xml" 193 #define FILENAME_DIRLIST "dirlist.xml" 194 #define FILENAME_FILTER "filter.xml" 195 #define FILENAME_DIRGROUP "dirgroup.xml" 196 #define FILENAME_GTKRC "gtkrc" 197 198 #ifdef __WIN32__ 199 #define DIR_DELIMITER "\\" 200 #else 201 #define DIR_DELIMITER "/" 202 #endif 203 204 #define DEFAULT_DICT_BGCOLOR "#80d0b0" 205 #define DEFAULT_DICT_FGCOLOR "#000000" 206 207 typedef struct { 208 gint code; 209 gchar **data; 210 gint width; 211 gint height; 212 } GAIJI_CACHE; 213 214 typedef struct { 215 gboolean available; 216 EB_Book *book; 217 EB_Appendix *appendix; 218 char *book_path; 219 char *appendix_path; 220 char *fg; 221 char *bg; 222 EB_Subbook_Code subbook_no; 223 EB_Subbook_Code appendix_subbook_no; 224 char *subbook_dir; 225 char *subbook_title; 226 GList *gaiji_narrow16; 227 GList *gaiji_narrow24; 228 GList *gaiji_narrow30; 229 GList *gaiji_narrow48; 230 GList *gaiji_wide16; 231 GList *gaiji_wide24; 232 GList *gaiji_wide30; 233 GList *gaiji_wide48; 234 gboolean search_method[20]; 235 } BOOK_INFO; 236 237 struct _search_method { 238 int code; 239 char *name; 240 }; 241 242 typedef struct { 243 gint type; 244 guint start; 245 guint end; 246 gint page; 247 gint offset; 248 gint size; 249 gchar filename[256]; 250 } TAG; 251 252 typedef struct _result_eb { 253 BOOK_INFO *book_info; 254 gint search_method; 255 gchar *plain_heading; 256 gchar *dict_title; 257 EB_Position pos_heading; 258 EB_Position pos_text; 259 } RESULT_EB; 260 261 typedef struct _result_grep{ 262 gchar *filename; 263 gint page; 264 gint line; 265 gint offset; 266 } RESULT_GREP; 267 268 typedef struct { 269 gchar *heading; 270 gchar *word; 271 gint type; 272 union { 273 RESULT_EB eb; 274 RESULT_GREP grep; 275 // struct _result_eb eb; 276 // struct _result_grep grep; 277 } data ; 278 } RESULT; 279 280 typedef struct { 281 BOOK_INFO *book_info; 282 gint code; 283 gchar *text; 284 } MULTI_SEARCH; 285 286 typedef struct { 287 gchar *text; 288 gint length; 289 } DRAW_TEXT; 290 291 typedef struct { 292 GtkTextBuffer *buffer; 293 GtkTextIter *iter; 294 gint indent; 295 } CANVAS; 296 297 298 // Enums for GtkTreeStore 299 300 enum 301 { 302 WEB_TYPE_COLUMN, 303 WEB_TITLE_COLUMN, 304 WEB_HOME_COLUMN, 305 WEB_PRE_COLUMN, 306 WEB_POST_COLUMN, 307 WEB_GLUE_COLUMN, 308 WEB_CODE_COLUMN, 309 WEB_N_COLUMNS 310 }; 311 312 enum 313 { 314 DICT_TYPE_COLUMN, 315 DICT_TITLE_COLUMN, 316 DICT_PATH_COLUMN, 317 DICT_SUBBOOK_NO_COLUMN, 318 DICT_APPENDIX_PATH_COLUMN, 319 DICT_APPENDIX_SUBBOOK_NO_COLUMN, 320 DICT_ACTIVE_COLUMN, 321 DICT_MEMBER_COLUMN, 322 DICT_EDITABLE_COLUMN, 323 DICT_BGCOLOR_COLUMN, 324 DICT_FGCOLOR_COLUMN, 325 DICT_N_COLUMNS 326 }; 327 328 // Enums for GtkListStore 329 330 enum 331 { 332 STEMMING_PATTERN_COLUMN, 333 STEMMING_NORMAL_COLUMN, 334 STEMMING_N_COLUMNS 335 }; 336 337 enum 338 { 339 SHORTCUT_STATE_COLUMN, // guint 340 SHORTCUT_KEYVAL_COLUMN, // guint 341 SHORTCUT_NAME_COLUMN, 342 SHORTCUT_DESCRIPTION_COLUMN, 343 SHORTCUT_KEYSTR_COLUMN, 344 SHORTCUT_COMMAND_COLUMN, // struct _shortcut_command * 345 SHORTCUT_N_COLUMNS 346 }; 347 348 enum 349 { 350 MULTI_TYPE_COLUMN, 351 MULTI_TITLE_COLUMN, 352 MULTI_CODE_COLUMN, 353 MULTI_BOOK_COLUMN, 354 MULTI_N_COLUMNS 355 }; 356 357 enum 358 { 359 FILTER_EXT_COLUMN, 360 FILTER_FILTER_COMMAND_COLUMN, 361 FILTER_OPEN_COMMAND_COLUMN, 362 FILTER_EDITABLE_COLUMN, 363 FILTER_N_COLUMNS 364 }; 365 366 enum 367 { 368 DIRGROUP_TITLE_COLUMN, 369 DIRGROUP_LIST_COLUMN, 370 DIRGROUP_ACTIVE_COLUMN, 371 DIRGROUP_N_COLUMNS 372 }; 373 374 375 376 struct _shortcut_command { 377 gchar *name; 378 void (* func)(); 379 }; 380 381 #include "log.h" 382 383 #endif /* __DEFS_H__ */ 384 385