]> git.pld-linux.org Git - packages/dillo.git/blob - dillo-0.7.0-alt-asp-charset-encodings-sysconfdir.patch
- some pld.org.pl->pld-linux.org cosmetics
[packages/dillo.git] / dillo-0.7.0-alt-asp-charset-encodings-sysconfdir.patch
1 --- dillo-0.7.0~/dillorc        2003-02-13 23:59:30 +0300
2 +++ dillo-0.7.0/dillorc 2003-02-21 03:15:45 +0300
3 @@ -35,6 +35,9 @@
4  # If you prefer oblique over italic fonts, uncoment next line
5  #use_oblique=YES
6  
7 +# Use this value as charset part of font for loading. (default is iso8859-1)
8 +# font_charset=iso8859-5
9 +
10  # Show tooltip popup for images?
11  # Note: We use the "title" attribute and not "alt".
12  #       More info at: http://bugzilla.mozilla.org/show_bug.cgi?id=25537
13 --- dillo-0.7.0~/encodings      1970-01-01 03:00:00 +0300
14 +++ dillo-0.7.0/encodings       2003-02-21 03:15:46 +0300
15 @@ -0,0 +1,18 @@
16 +<enc value="ASCII">7-bit ASCII</enc>
17 +<enc value="ISO8859-1">Western European (ISO 8859-1)</enc>
18 +<enc value="ISO8859-15">Western European (ISO 8859-15)</enc>
19 +<enc value="CP1252">Western European (CodePage1252)</enc>
20 +<enc value="ISO8859-2">Central European (ISO 8859-2)</enc>
21 +<enc value="CP1250">Central European (CodePage1250)</enc>
22 +<enc value="ISO8859-3">Southern European (ISO 8859-3)</enc>
23 +<enc value="KOI8-R">Cyrillic (KOI8-R)</enc>
24 +<enc value="CP1251">Cyrillic (CodePage1251)</enc>
25 +<enc value="IBM866">Cyrillic (IBM866)</enc>
26 +<enc value="ISO8859-13">Baltic (ISO 8859-13)</enc>
27 +<enc value="ISO8859-4">Baltic (ISO 8859-4)</enc>
28 +<enc value="CP1257">Baltic (CodePage1257)</enc>
29 +<enc value="ISO8859-10">Nordic (ISO 8859-10)</enc>
30 +<enc value="ISO8859-14">Celtic (ISO 8859-14)</enc>
31 +<enc value="KOI8-U">Ukraine (KOI8-U)</enc>
32 +<enc value="UTF-8">Unicode (UTF-8)</enc>
33 +<enc value="UTF-16">Unicode (UTF-16)</enc>
34 --- dillo-0.7.0~/src/browser.h  2003-02-10 16:10:30 +0300
35 +++ dillo-0.7.0/src/browser.h   2003-02-21 03:15:46 +0300
36 @@ -4,10 +4,8 @@
37  #include <sys/types.h>
38  #include <gdk/gdk.h>
39  #include <gtk/gtk.h>
40 -
41  #include "url.h"     /* for DilloUrl */
42 -
43 -
44 +#include "encodings-types.h"
45  typedef struct _BrowserWindow BrowserWindow;
46  typedef struct _DilloMenuPopup DilloMenuPopup;
47  
48 @@ -61,6 +59,9 @@
49     /* The bookmarks menu so that we can add things to it. */
50     GtkWidget *bookmarks_menu;
51  
52 +   /* The encoding menu */
53 +   GtkWidget *enc_menu;
54 +
55     /* The "Headings" and "Anchors" menus */
56     GtkWidget *pagemarks_menuitem;
57     GtkWidget *pagemarks_menu;
58 @@ -121,6 +122,10 @@
59  
60     /* The tag for the idle function that sets button sensitivity. */
61     guint sens_idle_tag;
62 +
63 +   /* encodings variable */
64 +   gchar*   encoding;     /* the selected character set (pointer to static content -don't free it*/
65 +   deConversion dcv;      /* handle for character set conversion */
66  };
67  
68  
69 --- dillo-0.7.0~/src/dillo.c    2003-02-09 03:22:14 +0300
70 +++ dillo-0.7.0/src/dillo.c     2003-02-21 03:15:46 +0300
71 @@ -22,6 +22,13 @@
72  #include <stdio.h>
73  #include <gtk/gtk.h>
74  
75 +#ifdef HAVE_LANGINFO
76 +#include <langinfo.h>
77 +#if ! defined(CODESET) && defined (_NL_CTYPE_CODESET_NAME)
78 +#define CODESET _NL_CTYPE_CODESET_NAME
79 +#endif
80 +#endif
81 +
82  #include <sys/types.h>
83  #include <sys/stat.h>
84  #include <string.h>
85 @@ -39,6 +46,7 @@
86  #include "nav.h"
87  #include "history.h"
88  #include "bookmark.h"
89 +#include "encodings.h"
90  #include "dicache.h"
91  #include "dns.h"
92  #include "IO/mime.h"
93 @@ -194,7 +194,7 @@
94   */
95  gint main(int argc, char *argv[])
96  {
97 -   gchar *dir, *curr_locale;
98 +   gchar *dir, *loctmp;
99     DilloUrl *start_url;
100     BrowserWindow *bw;
101     guint32 xid = 0;
102 @@ -181,9 +189,6 @@
103     gint i;
104     char **opt_argv = NULL;
105  
106 -   /* set locale */
107 -   curr_locale = g_strdup(setlocale(LC_ALL, NULL));
108 -   gtk_set_locale();
109     /* Initialize GUI and parse GTK related args */
110     gtk_init(&argc, &argv);
111     gdk_rgb_init();
112 @@ -219,9 +224,21 @@
113       }
114     }
115  
116 -   /* Send a delayed locale-related message */
117 -   g_print("Setting locale to %s...\n", curr_locale);
118 -   g_free(curr_locale);
119 +   curr_locale=gtk_set_locale();
120 +#ifdef HAVE_LANGINFO
121 +   curr_locale = nl_langinfo(CODESET);
122 +#else
123 +    loctmp = strchr(curr_locale, '.');
124 +    if (loctmp != NULL) {
125 +        gchar** trk = g_strsplit(++loctmp, ";", 1);
126 +        curr_locale = g_strdup(trk[0]);
127 +        g_strfreev(trk);
128 +    } else {
129 +        curr_locale = "ASCII";
130 +    }
131 +#endif
132 +
133 +   g_print("Setting locale to %s\n",curr_locale);
134  
135     /* This lets threads in the file module end peacefully when aborted
136      * todo: implement a cleaner mechanism (in file.c) */
137 @@ -255,6 +272,7 @@
138     bw = a_Interface_browser_window_new(prefs.width, prefs.height, xid);
139  
140     a_Bookmarks_init();
141 +   a_Encodings_init();
142  
143     /* Send dillo startup screen */
144     start_url = a_Url_new("splash", "about:", 0, 0);
145 --- dillo-0.7.0~/src/dillo.h    2002-11-28 19:42:22 +0300
146 +++ dillo-0.7.0/src/dillo.h     2003-02-21 03:15:46 +0300
147 @@ -4,4 +4,5 @@
148  #include "browser.h"
149  #include "web.h"
150  
151 +char* curr_locale;
152  #endif /* __DILLO_H__ */
153 diff -ubBdr -N dillo-0.7.0~/src/dillo.h.orig dillo-0.7.0/src/dillo.h.orig
154 --- dillo-0.7.0~/src/dw_style.c 2003-01-05 22:24:06 +0300
155 +++ dillo-0.7.0/src/dw_style.c  2003-02-21 03:15:45 +0300
156 @@ -245,42 +245,39 @@
157     char fontname[256], *ItalicChar;
158  
159     ItalicChar = prefs.use_oblique ? "o" : "i";
160 -   sprintf (fontname, "-*-%s-%s-%s-*-*-%d-*-75-75-*-*-iso8859-1",
161 +   sprintf (fontname, "-*-%s-%s-%s-*-*-%d-*-75-75-*-*-%s",
162              font->name,
163              font->bold ? "bold" : "medium",
164              font->italic ? ItalicChar : "r",
165 -            font->size);
166 +            font->size,prefs.font_charset);
167     font->font = gdk_font_load (fontname);
168  
169     if (font->font == NULL && font->italic) {
170 -      sprintf (fontname, "-*-%s-%s-%s-*-*-%d-*-75-75-*-*-iso8859-1",
171 +      sprintf (fontname, "-*-%s-%s-%s-*-*-%d-*-75-75-*-*-%s",
172                 font->name,
173                 font->bold ? "bold" : "medium",
174                 (*ItalicChar == 'o') ? "i" : "o",
175 -               font->size);
176 +               font->size,prefs.font_charset);
177        font->font = gdk_font_load (fontname);
178     }
179  
180     if (try_all) {
181        if (font->font == NULL) {
182           /* Can't load the font - substitute the default instead. */
183 -         font->font =
184 -            gdk_font_load
185 -            ("-adobe-helvetica-medium-r-normal--*-100-*-*-*-*-iso8859-1");
186 +         sprintf(fontname,"-adobe-helvetica-medium-r-normal--*-100-*-*-*-*-%s",prefs.font_charset);
187 +         font->font = gdk_font_load (fontname);
188        }
189  
190        if (font->font == NULL) {
191           /* Try another platform-font that should be available. (iPaq) */
192 -         font->font =
193 -            gdk_font_load
194 -            ("-misc-fixed-medium-r-normal--13-120-75-75-c-80-iso8859-1");
195 +         sprintf(fontname,"-misc-fixed-medium-r-normal--13-120-75-75-c-80-%s",prefs.font_charset);
196 +         font->font = gdk_font_load (fontname);
197        }
198  
199        if (font->font == NULL) {
200           /* Can't load any suitable font!  */
201 -         g_warning ("Can't load any ISO8859-1 font!?! :(");
202 -         font->font =
203 -            gdk_font_load ("-adobe-helvetica-*-*-*--*-*-*-*-*-*-*-*");
204 +         g_warning ("Can't load any font with charset '%s'!?! :(",prefs.font_charset);
205 +         font->font = gdk_fontset_load("-adobe-helvetica-*-*-*--*-*-*-*-*-*-*-*,-misc-fixed-*,*");
206        }
207     }
208  
209 --- dillo-0.7.0~/src/encodings.c        1970-01-01 03:00:00 +0300
210 +++ dillo-0.7.0/src/encodings.c 2003-02-21 03:15:46 +0300
211 @@ -0,0 +1,383 @@
212 +/* cruelty :) */
213 +
214 +/* Copyright (C) 2002 Grigory Bakunov <black@asplinux.ru> */
215 +
216 +/* Copyright (C) 1997 Ian Main
217 + *
218 + * This program is free software; you can redistribute it and/or modify
219 + * it under the terms of the GNU General Public License as published by
220 + * the Free Software Foundation; either version 2 of the License, or
221 + * (at your option) any later version.
222 + *
223 + * This program is distributed in the hope that it will be useful,
224 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
225 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
226 + * GNU General Public License for more details.
227 + *
228 + * You should have received a copy of the GNU General Public License
229 + * along with this program; if not, write to the Free Software
230 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
231 + */
232 +
233 +#include <gtk/gtk.h>
234 +
235 +#include <errno.h>
236 +#include <stdio.h>
237 +#include <unistd.h>
238 +#include <stdlib.h>
239 +#include <string.h>
240 +
241 +#include "list.h"
242 +#include "interface.h"
243 +#include "dillo.h"
244 +#include "nav.h"
245 +#include "browser.h"
246 +#include "menu.h"
247 +#include "misc.h"
248 +#include "url.h"
249 +
250 +#define LOAD_ENCODINGS 1
251 +#define SAVE_ENCODING 2
252 +#define CLOSE_ENCODINGS 3
253 +
254 +/* this #define will cut page title if > 39 chars */
255 +#define TITLE39
256 +
257 +/* double quote */
258 +#define D_QUOTE 0x22
259 +
260 +/* Data types */
261 +
262 +typedef struct _Encoding Encoding;
263 +typedef struct _CallbackInfo CallbackInfo;
264 +
265 +struct _Encoding {
266 +   char *title;
267 +   char *iconv_name;
268 +   GtkWidget *menuitem;
269 +};
270 +
271 +struct _CallbackInfo {
272 +   BrowserWindow *bw;
273 +   guint index;
274 +};
275 +
276 +/*
277 + * Forward declarations
278 + */
279 +static void
280 +   Encodings_load_to_menu(FILE *fp),
281 +   Encodings_file_op(gint operation, const char *title, const char *iconv_name),
282 +   Encodings_save_to_file(FILE *fp, const char *title,  const char *iconv_name);
283 +
284 +static char*
285 +   Encodings_search_line(char *line, char *start_text, char *end_text);
286 +
287 +extern BrowserWindow **browser_window;
288 +
289 +/*
290 + * Local data
291 + */
292 +static Encoding *encodings = NULL;
293 +static gint num_encodings = 0;
294 +static gint num_encodings_max = 16;
295 +
296 +
297 +/*
298 + * Allocate memory and load the encodings list
299 + */
300 +void a_Encodings_init(void)
301 +{
302 +   gchar *file;
303 +
304 +   /* Here we load and set the encodings */
305 +   file = a_Misc_prepend_user_home(".dillo/encodings");
306 +   if (access(file, R_OK))
307 +       Encodings_file_op(LOAD_ENCODINGS, "/etc/dillo/encodings", NULL);
308 +   else
309 +   Encodings_file_op(LOAD_ENCODINGS, file, NULL);
310 +   g_free(file);
311 +}
312 +
313 +/*
314 + * ?
315 + */
316 +void Encodings_set_encoding(GtkWidget *widget, CallbackInfo *CbInfo)
317 +{
318 +   if (CbInfo->index >= num_encodings) {
319 +      g_warning("encoding not found!\n");
320 +      return;
321 +   }
322 +   g_print("Selected encoding: %s\n",encodings[CbInfo->index].iconv_name);
323 +   CbInfo->bw->encoding=encodings[CbInfo->index].iconv_name;
324 +   a_Nav_reload(CbInfo->bw);
325 +   /*HERE!!! LOOKOUT!!!! */
326 +}
327 +
328 +/*
329 + * Add a encoding to the encodings menu of a particular browser window
330 + */
331 +void Encodings_add_to_menu(BrowserWindow *bw, GtkWidget *menuitem, guint index)
332 +{
333 +   CallbackInfo *CbInfo;
334 +
335 +   gtk_menu_append(GTK_MENU(bw->enc_menu), menuitem);
336 +
337 +   CbInfo = g_new(CallbackInfo, 1);
338 +   CbInfo->bw = bw;
339 +   CbInfo->index = index;
340 +
341 +   /* accelerator goes here */
342 +   gtk_signal_connect(GTK_OBJECT (menuitem), "activate",
343 +                      (GtkSignalFunc)Encodings_set_encoding, CbInfo);
344 +}
345 +
346 +/*
347 + * ?
348 + */
349 +static GtkWidget *Encodings_insert(const char *title, const char *iconv_name)
350 +{
351 +   GtkWidget *menuitem;
352 +
353 +   menuitem = gtk_menu_item_new_with_label(title);
354 +   gtk_widget_show(menuitem);
355 +
356 +   a_List_add(encodings, num_encodings, num_encodings_max);
357 +   encodings[num_encodings].title = g_strdup(title);
358 +   encodings[num_encodings].iconv_name = g_strdup(iconv_name);
359 +   encodings[num_encodings].menuitem = menuitem;
360 +   num_encodings++;
361 +   return menuitem;
362 +}
363 +
364 +/*
365 + * Add the new encoding to encodings menu of _all_ browser windows and then
366 + * write the new encoding to file
367 + */
368 +/*
369 +void a_Encodings_add(GtkWidget *widget, gpointer client_data)
370 +{
371 +   BrowserWindow *bw = (BrowserWindow *)client_data;
372 +   gint i;
373 +#ifdef TITLE39
374 +   gboolean allocated = FALSE;
375 +#endif
376 +   char *title;
377 +   char *iconv_name;
378 +   GtkWidget *menuitem;
379 +
380 +   title = bw->menu_popup.info.title;
381 +   iconv_name = bw->menu_popup.info.iconv_name;
382 +
383 +#ifdef TITLE39
384 +   if (strlen (title) > 39) {
385 +      char buf1[20];
386 +      char buf2[20];
387 +
388 +      memcpy (buf1, title, 18);
389 +      buf1[18] = '\0';
390 +      strcpy (buf2, title + strlen (title) - 18);
391 +      buf2[18] = '\0';
392 +      title = g_strconcat (buf1, "...", buf2, NULL);
393 +      allocated = TRUE;
394 +   }
395 +#endif
396 +
397 +   menuitem = Encodings_insert(title, iconv_name);
398 +   Encodings_add_to_menu(browser_window[0], menuitem, num_encodings-1);
399 +   for (i = 1; i < num_bw; i++) {
400 +      menuitem= gtk_menu_item_new_with_label(encodings[num_encodings-1].title);
401 +      gtk_widget_show(menuitem);
402 +      Encodings_add_to_menu(browser_window[i], menuitem, num_encodings-1);
403 +   }
404 +
405 +   Encodings_file_op(SAVE_ENCODING, title, iconv_name);
406 +
407 +#ifdef TITLE39
408 +   if (allocated)
409 +      g_free (title);
410 +#endif
411 +}
412 +*/
413 +/*
414 + * Never called (the file remains open all the time)  --Jcid
415 + */
416 +void Encodings_close(void)
417 +{
418 +   Encodings_file_op(CLOSE_ENCODINGS, NULL, NULL);
419 +}
420 +
421 +/*
422 + * Performs operations on the encoding file..
423 + * for first call, title is the filename
424 + */
425 +static void
426 + Encodings_file_op(gint operation, const char *title, const char *iconv_name)
427 +{
428 +   static FILE *fp;
429 +   static gint initialized = 0;
430 +
431 +   if (!initialized) {
432 +      if (operation == LOAD_ENCODINGS) {
433 +         /* SAVE_ENCODINGS is broken anyway, better make use of /etc/dillo/encodings */
434 +         if ((fp = fopen(title, "r")) == NULL)
435 +            g_print("dillo: opening encoding file %s: %s\n",
436 +                    title, strerror(errno));
437 +         else
438 +            initialized = 1;
439 +      } else
440 +         g_print("Error: invalid call to Encodings_file_op.\n");
441 +   }
442 +
443 +   g_return_if_fail( initialized );
444 +
445 +   switch (operation) {
446 +   case LOAD_ENCODINGS:
447 +      Encodings_load_to_menu(fp);
448 +      break;
449 +
450 +   case SAVE_ENCODING:
451 +      Encodings_save_to_file(fp, title, iconv_name);
452 +      break;
453 +
454 +   case CLOSE_ENCODINGS:
455 +      fclose(fp);
456 +      break;
457 +
458 +   default:
459 +      break;
460 +   }
461 +}
462 +
463 +/*
464 + * Save encodings to ~/.dillo/encodings
465 + */
466 +static void
467 + Encodings_save_to_file(FILE *fp, const char *title, const char* iconv_name)
468 +{
469 +   fseek(fp, 0L, SEEK_END);
470 +   fprintf(fp, "<enc value=\"%s\">%s</a>\n", iconv_name,title);
471 +   fflush(fp);
472 +}
473 +
474 +/*
475 + * Load encodings
476 + */
477 +static void Encodings_load_to_menu(FILE *fp)
478 +{
479 +   gchar *title=NULL;
480 +   gchar *iconv_name=NULL;
481 +   char buf[4096];
482 +   gint i = 0;
483 +   GtkWidget *menuitem;
484 +
485 +   rewind(fp);
486 +
487 +   g_print("Loading encodings...\n");
488 +   while (1) {
489 +      /* Read a whole line from the file */
490 +      if ((fgets(buf, 4096, fp)) == NULL)
491 +          break;
492 +
493 +      /* get url from line */
494 +      if ( !(iconv_name = Encodings_search_line(buf, "=\"", "\">")) )
495 +         continue;
496 +
497 +      /* get title from line */
498 +      if ( !(title = Encodings_search_line(buf, "\">", "</")) ){
499 +         g_free(iconv_name);
500 +         continue;
501 +      }
502 +      printf("%s = %s\n",title,iconv_name);
503 +      menuitem = Encodings_insert(title, iconv_name);
504 +      Encodings_add_to_menu(browser_window[0], menuitem, i);
505 +      g_free(iconv_name);
506 +      g_free(title);
507 +      i++;
508 +   }
509 +}
510 +
511 +/*
512 + * Copy encodings when new browser windows are opened.
513 + * Called by 'a_Menu_mainbar_new()'
514 + */
515 +void a_Encodings_fill_new_menu(BrowserWindow *bw)
516 +{
517 +   gint i;
518 +   GtkWidget *menuitem;
519 +
520 +   for (i = 0; i < num_encodings; i++) {
521 +     menuitem = gtk_menu_item_new_with_label(encodings[i].title);
522 +     gtk_widget_show(menuitem);
523 +     Encodings_add_to_menu(bw, menuitem, i);
524 +   }
525 +}
526 +
527 +static char *
528 + Encodings_search_line(char *line, char *start_text, char *end_text) {
529 +   gint segment_length;
530 +   char *start_index, *end_index;
531 +
532 +   /* if string is not found, return NULL */
533 +   if ((start_index = strstr(line, start_text)) == NULL)
534 +      return (NULL);
535 +   if ((end_index = strstr(line, end_text)) == NULL)
536 +      return (NULL);
537 +
538 +   /* adjustment cause strstr returns the start of the text */
539 +   start_index += strlen(start_text);
540 +
541 +   /* find length of text segment */
542 +   segment_length = end_index - start_index;
543 +   return g_strndup(start_index, segment_length);
544 +};
545 +
546 +void   a_Encoding_get_conversion(BrowserWindow *bw, char* charset) {
547 +    bw->dcv.c_from=iconv_open(curr_locale,charset);
548 +    bw->dcv.c_to=iconv_open(charset,curr_locale);
549 +    if (bw->dcv.c_from == (iconv_t)-1 || bw->dcv.c_to == (iconv_t)-1)
550 +       g_warning ("could not allocate character encoding converter.");
551 +    return;
552 +};
553 +
554 +#define MAX_CHAR_SIZE 4
555 +gchar *a_Encoding_translate_encoding(deConversion dcv, gchar *buf, gint bufsize,deDirection dir) {
556 +    char *result, *source, *dest; 
557 +    size_t s_left, d_left;
558 +    iconv_t conversion;
559 +    if (dir==DE_DECODE)
560 +       conversion=dcv.c_from;
561 +    else 
562 +       conversion=dcv.c_to;
563 +    /* no conversion is needed, or none is available */
564 +    if (conversion == (iconv_t)-1)
565 +       return g_strndup(buf, bufsize);
566 +
567 +    /* Note that for some conversions, the translated buffer can be larger
568 +     * than the input buffer. This is particularly important for conversions
569 +     * to UTF8 (check the unicode standard to find out the scale factor). */
570 +    result = g_malloc((bufsize + 1)*MAX_CHAR_SIZE);
571 +    
572 +    source = buf;
573 +    dest = result;
574 +    s_left =  bufsize;
575 +    d_left = bufsize*MAX_CHAR_SIZE;
576 +    if (iconv(conversion, &source, &s_left, &dest, &d_left)
577 +       == (size_t)-1) {
578 +       g_warning ("unable to fully convert page to native character set");
579 +       /* This just skips past unconvertable characters, putting "?" in the
580 +        * output, then retries the conversion. This is a hack, but it seems
581 +        * like the best course of action in the circumstances. */
582 +       while (s_left > 0 && d_left > 0 && errno == EILSEQ) {
583 +           source++;
584 +           s_left--;
585 +           *dest = '?';
586 +           dest++;
587 +           d_left--;
588 +           if (s_left > 0 && d_left > 0)
589 +               iconv(conversion, &source, &s_left, &dest, &d_left);
590 +       }
591 +    }
592 +    *dest = 0; /* terminate the string */
593 +    return result;
594 +}
595 --- dillo-0.7.0~/src/encodings.h        1970-01-01 03:00:00 +0300
596 +++ dillo-0.7.0/src/encodings.h 2003-02-21 03:15:46 +0300
597 @@ -0,0 +1,18 @@
598 +#ifndef __DILLO_ENCODING_H__
599 +#define __DILLO_ENCODING_H__
600 +#include <gtk/gtk.h>
601 +#include <iconv.h>
602 +#include "browser.h"
603 +#include "encodings-types.h"
604 +
605 +
606 +/* Copyright (C) 2002 Grigory Bakunov <black@asplinux.ru> */
607 +
608 +void   a_Encodings_init();
609 +void   a_Encodings_add(GtkWidget *widget, gpointer client_data);
610 +void   a_Encodings_fill_new_menu(BrowserWindow *bw);
611 +void   a_Encoding_get_conversion(BrowserWindow *bw, char* charset);
612 +char   *a_Encoding_translate_encoding(deConversion dcv, char *buf, 
613 +                                    gint bufsize,deDirection dir);
614 +
615 +#endif /* __DILLO_ENCODING_H__ */
616 diff -ubBdr -N dillo-0.7.0~/src/encodings-types.h dillo-0.7.0/src/encodings-types.h
617 --- dillo-0.7.0~/src/encodings-types.h  1970-01-01 03:00:00 +0300
618 +++ dillo-0.7.0/src/encodings-types.h   2003-02-21 03:15:46 +0300
619 @@ -0,0 +1,19 @@
620 +#ifndef __DILLO_ENCODING_TYPES_H__
621 +#define __DILLO_ENCODING_TYPES_H__
622 +#include <iconv.h>
623 +/* Copyright (C) 2002 Grigory Bakunov <black@asplinux.ru> */
624 +
625 +typedef struct _deConversion deConversion;
626 +
627 +struct _deConversion {
628 +    iconv_t c_from;
629 +    iconv_t c_to;
630 +};
631 +
632 +
633 +typedef enum {
634 +    DE_DECODE,
635 +    DE_ENCODE
636 +} deDirection;
637 +
638 +#endif /*  __DILLO_ENCODING_TYPES_H__ */
639 diff -ubBdr -N dillo-0.7.0~/src/html.c dillo-0.7.0/src/html.c
640 --- dillo-0.7.0~/src/html.c     2003-02-14 00:01:02 +0300
641 +++ dillo-0.7.0/src/html.c      2003-02-21 03:15:46 +0300
642 @@ -21,6 +21,7 @@
643  #include <stdlib.h>
644  #include <stdio.h>      /* for sprintf */
645  #include <math.h>      /* for rint */
646 +#include <errno.h>      /* for iconv error codes */
647  
648  #include <gtk/gtk.h>
649  
650 @@ -48,6 +49,7 @@
651  #include "progressbar.h"
652  #include "prefs.h"
653  #include "misc.h"
654 +#include "encodings.h"
655  #include "capi.h"
656  #include "html.h"
657  
658 @@ -2847,7 +2849,7 @@
659     if ((form->method == DILLO_HTML_METHOD_GET) ||
660         (form->method == DILLO_HTML_METHOD_POST)) {
661        GString *DataStr = g_string_sized_new(4096);
662 -
663 +      GString *DataStrEnc;
664        DEBUG_MSG(3,"Html_submit_form form->action=%s\n",URL_STR_(form->action));
665  
666        for (input_index = 0; input_index < form->num_inputs; input_index++) {
667 @@ -2911,6 +2913,12 @@
668              break;
669           } /* switch */
670        } /* for (inputs) */
671 +      DataStrEnc = g_string_new(a_Encoding_translate_encoding(html_lb->bw->dcv,
672 +                                                                DataStr -> str,
673 +                                                                DataStr -> len,
674 +                                                                DE_ENCODE));
675 +      g_string_free(DataStr,TRUE);
676 +      DataStr = DataStrEnc;
677  
678        if ( DataStr->str[DataStr->len - 1] == '&' )
679           g_string_truncate(DataStr, DataStr->len - 1);
680 @@ -3992,6 +4000,22 @@
681        Html_write(Client->CbData, Client->Buf, Client->BufSize, 0);
682  }
683  
684 +static void Html_set_encoding(DilloHtml *html, char *buf, gint bufsize) {
685 +   /* only do _anything_ if told so */
686 +   if (html->bw->encoding != NULL)
687 +       a_Encoding_get_conversion(html->bw, html->bw->encoding);
688 +   return;
689 +}
690 +
691 +static char *Html_translate_encoding(DilloHtml *html, char *buf,
692 +                                   gint bufsize) {
693 +    char* result=a_Encoding_translate_encoding(html->bw->dcv,
694 +                                              buf, bufsize,
695 +                                              DE_DECODE);
696 +    return result;
697 +
698 +}
699 +
700  /*
701   * Here's where we parse the html and put it into the page structure.
702   * Return value: number of bytes parsed
703 @@ -4147,7 +4147,11 @@
704  
705     g_return_if_fail ( (page = DW_PAGE (html->dw)) != NULL );
706  
707 +   Html_set_encoding(html, buf, bufsize);
708 +   buf = Html_translate_encoding(html, buf, bufsize);
709 +
710     token_start = Html_write_raw(html, buf, bufsize, Eof);
711 +   g_free(buf);
712     html->Start_Ofs += token_start;
713  
714     if ( html->bw ) {
715 --- dillo-0.7.0~/src/interface.c        2003-02-11 04:09:59 +0300
716 +++ dillo-0.7.0/src/interface.c 2003-02-21 03:15:46 +0300
717 @@ -19,6 +19,7 @@
718  #include <sys/stat.h>
719  #include <sys/time.h>
720  #include <fcntl.h>
721 +#include <iconv.h>
722  
723  #include "list.h"
724  #include "misc.h"
725 @@ -54,7 +55,7 @@
726   */
727  /* BrowserWindow holds all the widgets (and perhaps more)
728   * for each new_browser.*/
729 -static BrowserWindow **browser_window;
730 +BrowserWindow **browser_window;
731  static gint num_bw, num_bw_max;
732  
733  
734 @@ -822,6 +823,9 @@
735     bw->question_dialog_window = NULL;
736     bw->question_dialog_data = NULL;
737     bw->viewsource_window = NULL;
738 +   bw->encoding=NULL;
739 +   bw->dcv.c_from  = (iconv_t)-1; /* no conversion yet */
740 +   bw->dcv.c_to  = (iconv_t)-1;
741  
742     /* now that the bw is made, let's customize it.. */
743     Interface_browser_window_customize(bw);
744 diff -ubBdr -N dillo-0.7.0~/src/Makefile.am.orig dillo-0.7.0/src/Makefile.am.orig
745 --- dillo-0.7.0~/src/menu.c     2003-02-11 00:30:13 +0300
746 +++ dillo-0.7.0/src/menu.c      2003-02-21 03:15:46 +0300
747 @@ -33,6 +33,7 @@
748  #include "bookmark.h"
749  #include "interface.h"
750  #include "menu.h"
751 +#include "encodings.h"
752  
753  /*
754   * Forward declarations
755 @@ -124,6 +125,7 @@
756     GtkWidget *file_menu;
757     /* GtkWidget *bookmarks_menu; */
758     /* GtkWidget *help_menu; */
759 +   GtkWidget *enc_menu;
760  
761     bw->menubar = menubar = gtk_menu_bar_new();
762  
763 @@ -160,6 +162,10 @@
764     Menu_add(help_menu, "Dillo _Manual", NULL, bw,
765              a_Commands_manual_callback, bw);
766     */
767 +   enc_menu = Menu_new(menubar, tiny ? "_E" : "_Encodings", FALSE, bw);
768 +   bw->enc_menu = enc_menu;
769 +   a_Encodings_fill_new_menu(bw);
770 +
771     return menubar;
772  }
773  
774 --- dillo-0.7.0~/src/prefs.c    2003-02-11 00:40:13 +0300
775 +++ dillo-0.7.0/src/prefs.c     2003-02-21 03:15:46 +0300
776 @@ -51,6 +51,7 @@
777     { "small_icons", DRC_TOKEN_SMALL_ICONS },
778     { "limit_text_width", DRC_TOKEN_LIMIT_TEXT_WIDTH },
779     { "font_factor", DRC_TOKEN_FONT_FACTOR },
780 +   { "font_charset", DRC_TOKEN_FONT_CHARSET },
781     { "use_dicache", DRC_TOKEN_USE_DICACHE },
782     { "show_back", DRC_TOKEN_SHOW_BACK },
783     { "show_forw", DRC_TOKEN_SHOW_FORW },
784 @@ -173,6 +174,10 @@
785     case DRC_TOKEN_FONT_FACTOR:
786        prefs.font_factor = strtod(scanner->value.v_string, NULL);
787        break;
788 +   case DRC_TOKEN_FONT_CHARSET:
789 +       if (prefs.font_charset) g_free(prefs.font_charset);
790 +       prefs.font_charset = g_strdup(scanner->value.v_string);
791 +      break;
792     case DRC_TOKEN_LIMIT_TEXT_WIDTH:
793        prefs.limit_text_width = (strcmp(scanner->value.v_string, "YES") == 0);
794        break;
795 @@ -347,6 +352,7 @@
796     prefs.small_icons = FALSE;
797     prefs.limit_text_width = FALSE;
798     prefs.font_factor = 1.0;
799 +   prefs.font_charset = g_strdup("iso8859-1");
800     prefs.use_dicache = FALSE;
801     prefs.show_back=TRUE;
802     prefs.show_forw=TRUE;
803 @@ -385,6 +391,8 @@
804     g_free(prefs.no_proxy);
805     if (prefs.no_proxy_vec)
806        g_strfreev(prefs.no_proxy_vec);
807 +   if (prefs.font_charset)
808 +      g_free (prefs.font_charset);
809     a_Url_free(prefs.http_proxy);
810     g_free(prefs.fw_fontname);
811     g_free(prefs.vw_fontname);
812 --- dillo-0.7.0~/src/prefs.h    2003-02-11 00:42:09 +0300
813 +++ dillo-0.7.0/src/prefs.h     2003-02-21 03:15:45 +0300
814 @@ -41,6 +41,7 @@
815     DRC_TOKEN_PANEL_SIZE,
816     DRC_TOKEN_SMALL_ICONS,
817     DRC_TOKEN_FONT_FACTOR,
818 +   DRC_TOKEN_FONT_CHARSET,
819     DRC_TOKEN_SHOW_TOOLTIP,
820     DRC_TOKEN_LIMIT_TEXT_WIDTH,
821     DRC_TOKEN_USE_DICACHE,
822 @@ -87,6 +88,7 @@
823     gboolean small_icons;
824     gboolean limit_text_width;
825     gdouble font_factor;
826 +   char *font_charset;
827     gboolean use_dicache;
828     gboolean show_back;
829     gboolean show_forw;
830 --- dillo-0.7.2/src/Makefile.am.orig    Sun May  4 14:08:25 2003
831 +++ dillo-0.7.2/src/Makefile.am Sun May  4 14:11:41 2003
832 @@ -59,6 +59,9 @@
833         dw_tooltip.h \
834         dw_widget.c \
835         dw_widget.h \
836 +       encodings.c \
837 +       encodings.h \
838 +       encoding-types.h \
839         findtext.c \
840         findtext.h \
841         selection.c \
This page took 0.202844 seconds and 3 git commands to generate.