gnome-libs patches
- From: Havoc Pennington <hp redhat com>
- To: gnome-libs-devel gnome org
- Cc: gnome-hackers gnome org
- Subject: gnome-libs patches
- Date: 28 Aug 2001 18:54:27 -0400
Hi,
Here we go for gnome-libs. Some of these are _old_. We also have some
very bad hacks. Some of them may already be in GNOME CVS.
- turn off login/logout sounds. this one is so old I have no idea
what the motivation was. since we have desktop sounds off
by default in RH anyway, I'm not sure we actually even care
about this patch. Anyhow, for your enjoyment.
- Do something I don't understand in gnome-pty-helper. (set ECHOK)
Presumably someone understood this, and no one has complained about
it in 1.5 years or so, so it must be harmless at minimum. ;-)
- Move gtkrc's that we parse from /usr/share to /etc/gnome.
Again, so old I have no idea what's up with it. Presumably
just FHS-compliance.
- I don't have a clue in hell what this next one does. Something
about zvt transparency.
- this one avoids one of the more annoying zvt redraw bugs by always
using the slow scrolling mode. If someone knows how to fix the
actual bug, please be my guest. ;-) (And fix the others in bugzilla
too...)
- Zvt multibyte support. I have no idea what this does.
It is however necessary for things to work in CJK.
(Requires gnome-terminal patches I haven't posted yet.
I'd kind of like to sort out all the multibyte after merging the
other fixes we plan to merge.)
- some random XmHTML fixage (also for multibyte I think)
- fixage for the XmHTML fixage
- use pixels instead of points to get XmHTML fonts,
and randomly change font sizes, just happens to make CJK
look better
- gtk_widget_ensure_style() in gnome-about to be sure we've
applied the per-locale gtkrc information before using it
- god-awful broken-as-all-hell unportable code to load
.desktop files in UTF-8 format
- make GnomeCanvasSuckFont work better in multibyte
- fix for handling KDE desktop files
- turn off xalf by default; it's too unreliable and generally broken
- turn off tearoff menus/menubars by default; an advanced feature
that adds clutter
- fix a dangling pointer to master SM client
- fix some Imlib mis-usage (crashed stuff during theme switch)
- handle em dash in XmHTML
- fix URL show to return the proper handler for ghelp/info/man the
first time it was run (previously you always got the http handler,
basically)
- some fixes to what escape sequence zvt sends for certain keys
Also, we have John Harper's fix to work with KDE session manager, I
think that's in CVS already, and we have a gruesome hack to assist Eel
in redrawing the Nautilus background more efficiently. Background hack
to get sorted out and posted together with the eel patch.
Havoc
--- gnome-libs-1.0.10/gnome-data/gnome.soundlist.rhsnddefs Mon May 31 07:04:03 1999
+++ gnome-libs-1.0.10/gnome-data/gnome.soundlist Mon Jun 7 11:57:18 1999
@@ -8,7 +8,7 @@
description[it]=Eventi di sistema GNOME
[login]
-file=login.wav
+file=
description=Login
description[ca]=Entrada al sistema
description[es]=Apertura de sesión
@@ -18,7 +18,7 @@
description[it]=Login
[logout]
-file=logout.wav
+file=
description=Logout
description[ca]=Eixida del sistema
description[es]=Salida de sesión
--- gnome-libs-1.0.55/zvt/gnome-pty-helper.c.echok Thu Feb 3 18:35:38 2000
+++ gnome-libs-1.0.55/zvt/gnome-pty-helper.c Thu Feb 3 18:36:01 2000
@@ -442,6 +442,7 @@
#ifdef ECHOKE
| ECHOKE
#endif
+ | ECHOK
#ifdef ECHOCTL
| ECHOCTL
#endif
--- gnome-libs-1.0.55/libgnomeui/Makefile.am.gtkrc Wed Oct 20 08:44:29 1999
+++ gnome-libs-1.0.55/libgnomeui/Makefile.am Fri Feb 11 16:34:15 2000
@@ -20,6 +20,7 @@
$(AUDIOFILE_CFLAGS) $(ESD_CFLAGS) \
-DGNOMELIBDIR=\""$(libdir)"\" \
-DGNOMEDATADIR=\""$(datadir)"\" \
+ -DGNOMECONFDIR=\""$(sysconfdir)/gnome"\" \
-DGNOMEBINDIR=\""$(bindir)"\" \
-DGNOMELOCALSTATEDIR=\""$(localstatedir)"\" \
-DGNOMELOCALEDIR=\""$(gnomelocaledir)"\" \
@@ -241,7 +242,7 @@
SGML = \
gtk-ted.sgml
-gtkrcdir = $(datadir)
+gtkrcdir = $(sysconfdir)/gnome
gtkrc_DATA = gtkrc gtkrc.el gtkrc.eo gtkrc.he gtkrc.hy gtkrc.ja \
gtkrc.ko gtkrc.ru gtkrc.tr gtkrc.th gtkrc.uk \
gtkrc.iso88592 gtkrc.iso88595 gtkrc.zh_CN gtkrc.zh_TW.Big5 \
--- gnome-libs-1.0.55/libgnomeui/gnome-init.c.gtkrc Thu Jan 6 18:07:03 2000
+++ gnome-libs-1.0.55/libgnomeui/gnome-init.c Fri Feb 11 16:34:15 2000
@@ -48,6 +48,79 @@
#include <locale.h>
#endif
+#define TEMPORARY_CUT_AND_PASTE_HACK
+#ifdef TEMPORARY_CUT_AND_PASTE_HACK
+/* This is cut-and-pasted from libgnome to avoid adding
+ API in the stable branch. */
+
+static char *
+gnome_dirrelative_file (const char *base, const char *sub, const char *filename, int unconditional)
+{
+ static char *gnomedir = NULL;
+ char *dir = NULL, *fil = NULL, *odir = NULL, *ofil = NULL;
+ char *retval = NULL;
+
+ /* First try the env GNOMEDIR relative path */
+ if(!gnomedir)
+ gnomedir = getenv ("GNOMEDIR");
+
+ if (gnomedir) {
+ dir = g_concat_dir_and_file (gnomedir, sub);
+ fil = g_concat_dir_and_file (dir, filename);
+
+ if (g_file_exists (fil)) {
+ retval = fil; fil = NULL; goto out;
+ }
+
+ odir = dir; ofil = fil;
+ dir = g_concat_dir_and_file (gnome_util_user_home (), sub);
+ fil = g_concat_dir_and_file (dir, filename);
+
+ if (strcmp (odir, dir) != 0 && g_file_exists (fil)) {
+ retval = fil; fil = NULL; goto out;
+ }
+
+ if (unconditional) {
+ retval = ofil; ofil = NULL; goto out;
+ }
+ }
+
+ if ((!dir || strcmp (base, dir) != 0)
+ && (!odir || strcmp (base, odir) != 0)) {
+ /* Then try the hardcoded path */
+ g_free (fil);
+ fil = g_concat_dir_and_file (base, filename);
+
+ if (unconditional || g_file_exists (fil)) {
+ retval = fil; fil = NULL; goto out;
+ }
+ }
+
+ /* Finally, attempt to find it in the current directory */
+ g_free (fil);
+ fil = g_concat_dir_and_file (".", filename);
+
+ if (g_file_exists (fil)) {
+ retval = fil; fil = NULL; goto out;
+ }
+
+out:
+ g_assert(retval || !unconditional);
+
+ g_free (dir); g_free (odir); g_free (fil); g_free (ofil);
+
+ return retval;
+}
+
+static gchar*
+gnome_unconditional_gnomeconf_file(const gchar* filename)
+{
+ return (gnome_dirrelative_file (GNOMECONFDIR, "gnome", filename, TRUE));
+}
+
+#endif /* TEMPORARY_CUT_AND_PASTE_HACK */
+
+
static void initialize_gtk_signal_relay(void);
static gboolean
relay_gtk_signal(GtkObject *object,
@@ -531,8 +604,8 @@
g_free(buf);
- /* <gnomedatadir>/gtkrc */
- file = gnome_unconditional_datadir_file("gtkrc");
+ /* <sysconfdir>/gnome/gtkrc */
+ file = gnome_unconditional_gnomeconf_file("gtkrc");
if (file){
gtk_rc_add_default_file (file);
g_free (file);
--- gnome-libs-1.0.55/zvt/zvtterm.c.safeprop Tue Feb 15 13:43:14 2000
+++ gnome-libs-1.0.55/zvt/zvtterm.c Tue Feb 15 14:06:51 2000
@@ -304,7 +304,6 @@
zp->fonttype=0;
zp->default_char=0;
zp->bold_save = 0;
- zp->transpix = 0;
zp->paste_id = -1;
zp->paste = 0;
}
@@ -472,23 +471,6 @@
return GTK_WIDGET (term);
}
-/* free's the tranparenxy pixmap */
-/* make special care any call to this also overrides or
- clears the background gc to which the transparency pixmap
- has been set as the tile */
-static void
-free_transpix(ZvtTerm *term)
-{
- struct _zvtprivate *zp;
- zp = gtk_object_get_data (GTK_OBJECT (term), "_zvtprivate");
- if (zp && zp->transpix) {
- gdk_xid_table_remove (GDK_WINDOW_XWINDOW(zp->transpix));
- g_dataset_destroy (zp->transpix);
- g_free (zp->transpix);
- zp->transpix = 0;
- }
-}
-
static void
zvt_term_destroy (GtkObject *object)
@@ -536,7 +518,6 @@
g_free(zp->text_expand);
if (zp->bold_save)
gdk_pixmap_unref(zp->bold_save);
- free_transpix(term);
if (zp->paste)
g_free(zp->paste);
if (zp->paste_id != -1)
@@ -3655,8 +3636,7 @@
} else if (term->background.pix) {
GdkWindowPrivate *wp = (GdkWindowPrivate *)term->background.pix;
- /* free the transparency pixmap, if it exists */
- free_transpix(term);
+ zp->transpix = FALSE;
term->background.w = wp->width;
term->background.h = wp->height;
@@ -3677,14 +3657,8 @@
}
p = get_pixmap_prop (GDK_WINDOW_XWINDOW(GTK_WIDGET(widget)->window), "_XROOTPMAP_ID");
- if (p == None) {
- GdkColor pen;
- term->transparent = 0;
- gdk_gc_set_fill (bgc, GDK_SOLID);
- pen.pixel = term->colors[17];
- gdk_gc_set_foreground (term->back_gc, &pen);
- return;
- }
+ if (p == None)
+ goto failure;
XTranslateCoordinates (
GDK_WINDOW_XDISPLAY (GTK_WIDGET(widget)->window),
@@ -3703,7 +3677,7 @@
}
if ((term->background.pix == NULL && term->shaded)
- || (zp->transpix == NULL && !term->shaded)
+ || (zp->transpix == FALSE && !term->shaded) /* FIXFIX */
|| term->background.x != x
|| term->background.y != y
|| term->background.w != width
@@ -3719,30 +3693,56 @@
gdk_pixmap_unref(term->background.pix);
term->background.pix = 0;
}
- free_transpix(term);
if (term->shaded) {
+ /* In theory, gdk_imlib_create_image_from_drawable should
+ * catch most errors, but it doesn't look 100% reliable
+ */
+ gdk_error_trap_push();
term->background.pix = create_shaded_pixmap (p, x, y, width, height);
+ if (gdk_error_trap_pop() || !term->background.pix)
+ goto failure;
+
gdk_gc_set_ts_origin (term->back_gc, 0, 0);
gdk_gc_set_tile (bgc, term->background.pix);
gdk_gc_set_fill (bgc, GDK_TILED);
} else {
- GdkPixmap *pp;
-
d(printf("loading background at %d,%d\n", x, y));
- /*non-shaded is simple?*/
- pp = gdk_pixmap_foreign_new(p);
+ /* We unconditionally set this TRUE, instead of setting
+ * it after the operation succeeds so we don't waste
+ * too much effort trying to access unaccessable pixmaps
+ */
+ zp->transpix = TRUE;
- gdk_gc_set_tile (bgc, pp);
- gdk_gc_set_ts_origin(bgc,-x,-y);
- zp->transpix = pp;
+ /*non-shaded is simple?*/
+ /* Luckily XSetTile always flushes the GC Cache, so if
+ * this and the following XSync() succeed, we are safe.
+ */
+ gdk_error_trap_push();
+ XSetTile (GDK_DISPLAY(), GDK_GC_XGC (bgc), p);
+ XSync (GDK_DISPLAY(), False);
+ if (gdk_error_trap_pop())
+ goto failure;
+
+ gdk_gc_set_ts_origin (bgc,-x,-y);
gdk_gc_set_fill (bgc, GDK_TILED);
}
} else {
d(printf("background hasn't moved, leaving\n"));
+ }
+ return;
+
+ failure:
+ {
+ GdkColor pen;
+ term->transparent = 0;
+ gdk_gc_set_fill (bgc, GDK_SOLID);
+ pen.pixel = term->colors[17];
+ gdk_gc_set_foreground (term->back_gc, &pen);
+ return;
}
}
--- gnome-libs-1.0.55/zvt/zvtterm.h.safeprop Tue Feb 15 13:59:17 2000
+++ gnome-libs-1.0.55/zvt/zvtterm.h Tue Feb 15 13:59:51 2000
@@ -160,9 +160,7 @@
int scroll_position; /* offset for background pixmap when scrolling */
GdkPixmap *bold_save; /* when drawing bold, use this to save the
maybe-overwritten line. */
- GdkPixmap *transpix; /* transparency pixmap. Must be treated
- differently so we dont blow away the root
- pixmap! */
+ gboolean transpix; /* TRUE if we have a transparency pixmap set. */
char *paste; /* where paste overflow is stored temporarily */
int paste_len; /* how much left to write */
int paste_offset; /* how much written so far */
--- gnome-libs-1.2.4/zvt/zvtterm.c.scrolling Sat Aug 19 13:07:41 2000
+++ gnome-libs-1.2.4/zvt/zvtterm.c Sat Aug 19 13:08:09 2000
@@ -2878,11 +2878,11 @@
terminal->vx->scroll_type=VT_SCROLL_NEVER;
else if (terminal->pixmap_filename) {
if (flags & ZVT_BACKGROUND_SCROLL)
- terminal->vx->scroll_type=VT_SCROLL_SOMETIMES;
+ terminal->vx->scroll_type=VT_SCROLL_NEVER;
else
terminal->vx->scroll_type=VT_SCROLL_NEVER;
} else
- terminal->vx->scroll_type=VT_SCROLL_ALWAYS;
+ terminal->vx->scroll_type=VT_SCROLL_NEVER;
}
/*
--- gnome-libs-1.2.13/zvt/update.c.zvtmb Sun Aug 27 12:22:23 2000
+++ gnome-libs-1.2.13/zvt/update.c Wed Apr 18 17:42:18 2001
@@ -170,6 +170,11 @@
run++;
} else {
/* render 'run so far' */
+#ifdef ZVT_MB
+ run = vt_query_line_mbchar(runstart + run, bl);
+ runstart = vt_query_line_mbchar(runstart, bl);
+ run -= runstart;
+#endif
vx->draw_text(vx->vt.user_data, bl,
line, runstart, run, attr);
vx->back_match = always?0:
@@ -197,6 +202,11 @@
/* check for runs of common characters, if they are short, then
use them */
if (commonrun>VT_THRESHHOLD || (newattr!=attr)) {
+#ifdef ZVT_MB
+ run = vt_query_line_mbchar(runstart + run, bl);
+ runstart = vt_query_line_mbchar(runstart, bl);
+ run -= runstart;
+#endif
vx->draw_text(vx->vt.user_data, bl,
line, runstart, run, attr);
run=0;
@@ -205,6 +215,11 @@
commonrun++;
}
#else
+#ifdef ZVT_MB
+ run = vt_query_line_mbchar(runstart + run, bl);
+ runstart = vt_query_line_mbchar(runstart, bl);
+ run -= runstart;
+#endif
vx->draw_text(vx->vt.user_data, bl,
line, runstart, run, attr);
run=0;
@@ -215,6 +230,11 @@
}
if (run) {
+#ifdef ZVT_MB
+ run = vt_query_line_mbchar(runstart + run, bl);
+ runstart = vt_query_line_mbchar(runstart, bl);
+ run -= runstart;
+#endif
vx->draw_text(vx->vt.user_data, bl,
line, runstart, run, attr);
}
@@ -677,7 +697,14 @@
while (nn && line<vx->vt.height) {
d(printf("%p: scanning line %d, was %d\n", wn, line, wn->line));
if (wn->line==-1) {
+#ifdef ZVT_MB
+ /* FIXME:
+ Current vt_line_update() have a problem for multibyte character,
+ so, we must update with a force argument. */
+ vt_line_update(vx, wn, bl, line, 1, 0, bl->width);
+#else
vt_line_update(vx, wn, bl, line, 0, 0, bl->width);
+#endif
d(printf("manual: updating line %d\n", line));
} else if (wn->modcount || update_state) {
vt_line_update(vx, wn, bl, line, force, 0, bl->width);
@@ -772,6 +799,12 @@
if (wn) {
nn = wn->next;
+#ifdef ZVT_MB
+ /* query start/end range for multibyte */
+ csx = vt_query_line_mbchar(csx, wn);
+ cex = vt_query_line_mbchar(cex, wn);
+#endif
+
while ((csy<=cey) && nn) {
d(printf("updating line %d\n", csy));
@@ -965,6 +998,12 @@
ex++;
}
+#ifdef ZVT_MB
+ /* arranged selection columns (sx and ex) for multibyte character */
+ sx = vt_query_line_mbchar(sx,s);
+ ex = vt_query_line_mbchar(ex,e);
+#endif
+
if ( ((vx->selstarty == vx->selendy) && (vx->selstartx > vx->selendx)) ||
(vx->selstarty > vx->selendy) ) {
vx->selstartx = ex; /* swap end/start values */
@@ -998,6 +1037,9 @@
}
}
+#ifdef ZVT_MB
+ if (!(l->data[dataend] & VTATTR_MULTIBYTE))
+#endif
if (end>dataend) {
lf = 1; /* we selected past the end of the line */
end = dataend;
@@ -1011,6 +1053,9 @@
case 2: {
unsigned short *o = (unsigned short *)out;
for (i=start;i<end;i++) {
+#ifdef ZVT_MB
+ if ((l->data[i] & VTATTR_MULTIBYTE)) continue;
+#endif
c = l->data[i] & VTATTR_DATAMASK;
if (state==0) {
if (c==0x09)
@@ -1037,6 +1082,9 @@
case 4: {
unsigned int *o = (unsigned int *)out;
for (i=start;i<end;i++) {
+#ifdef ZVT_MB
+ if ((l->data[i] & VTATTR_MULTIBYTE)) continue;
+#endif
c = l->data[i] & VTATTR_DATAMASK;
if (state==0) {
if (c==0x09)
@@ -1062,6 +1110,9 @@
default: {
unsigned char *o = out;
for (i=start;i<end;i++) {
+#ifdef ZVT_MB
+ if ((l->data[i] & VTATTR_MULTIBYTE)) continue;
+#endif
c = l->data[i] & VTATTR_DATAMASK;
if (state==0) {
if (c==0x09)
@@ -1288,9 +1339,13 @@
void vt_draw_cursor(struct _vtx *vx, int state)
{
uint32 attr;
+ gint len = 1;
if (vx->vt.scrollbackold == 0 && vx->vt.cursorx<vx->vt.width) {
attr = vx->vt.this_line->data[vx->vt.cursorx];
+#ifdef ZVT_MB
+ len = vt_line_mblen(vx->vt.cursorx, vx->vt.this_line);
+#endif /* ZVT_MB */
if (state && (vx->vt.mode & VTMODE_BLANK_CURSOR)==0) { /* must swap fore/background colour */
attr = (((attr & VTATTR_FORECOLOURM) >> VTATTR_FORECOLOURB) << VTATTR_BACKCOLOURB)
| (((attr & VTATTR_BACKCOLOURM) >> VTATTR_BACKCOLOURB) << VTATTR_FORECOLOURB)
@@ -1299,7 +1354,7 @@
vx->back_match=0; /* forces re-draw? */
vx->draw_text(vx->vt.user_data,
vx->vt.this_line,
- vx->vt.cursory, vx->vt.cursorx, 1, attr);
+ vx->vt.cursory, vx->vt.cursorx, len, attr);
}
}
--- gnome-libs-1.2.13/zvt/vt.c.zvtmb Sat Nov 25 13:49:08 2000
+++ gnome-libs-1.2.13/zvt/vt.c Wed Apr 18 17:42:18 2001
@@ -109,6 +109,62 @@
#endif
+#ifdef ZVT_MB
+/*
+ return multibyte character length in vt line
+*/
+int vt_line_mblen(int x, struct vt_line *l)
+{
+ unsigned char ctmp[MB_CUR_MAX];
+ int len = 1, i;
+
+ /* arranged selection columns (sx and ex) for multibyte character */
+ if (MB_CUR_MAX >= 2) {
+ for (i = 0; i < MB_CUR_MAX; i++)
+ if (x+i <= l->width)
+ ctmp[i] = l->data[x+i] & 0xff;
+ else
+ ctmp[i] = 0;
+ len = mblen(ctmp, MB_CUR_MAX);
+ if (len <= 0) len = 1;
+ }
+
+ return(len);
+}
+
+int vt_query_line_mbchar(int x, struct vt_line *l)
+{
+ unsigned char ctmp[MB_CUR_MAX];
+ int xx = x, len = 1, i;
+
+ if (x == 0 || x == l->width) return(x);
+
+ /* arranged selection columns (sx and ex) for multibyte character */
+ if (MB_CUR_MAX >= 2) {
+ if (x > l->width) x = l->width;
+ if (x < 0) x = 0;
+ for (xx = 0; xx < x; xx += len) {
+ if ((l->data[xx] & VTATTR_DATAMASK) <= 0x1f)
+ len = 1; /* control code character */
+ else {
+ for (i = 0; i < MB_CUR_MAX && xx+i < x; i++)
+ ctmp[i] = l->data[xx+i] & VTATTR_DATAMASK;
+ for ( ; i < MB_CUR_MAX; i++)
+ ctmp[i] = 0;
+ len = mblen(ctmp, MB_CUR_MAX);
+ if (len <= 0) {
+ if (xx + 1 != x)
+ len = 1;
+ else
+ break;
+ }
+ }
+ }
+ }
+ return(xx);
+}
+#endif
+
/***********************************************************************
* Update functions
*/
@@ -1444,6 +1500,10 @@
struct vt_jump *modes = vtjumps;
char *ptr_end;
void (*process)(struct vt_em *vt); /* process function */
+#ifdef ZVT_MB
+ unsigned char ctmp[MB_CUR_MAX];
+ int ctmp_num;
+#endif
/* states:
* 0: normal escape mode
@@ -1521,7 +1581,26 @@
switch (state) {
+#if defined(ZVT_JIS) && defined(ZVT_MB)
+ case 100: /* enter JIS mode */
+ state = (c == 'B')? 101: 0;
+ break;
+ case 110: /* exit JIS mode */
+ state = 0;
+ break;
+ case 101:
+ if (c > 0x1f && c < 0x80 && MB_CUR_MAX >= 2)
+ c += 0x80;
+#endif
case 0:
+#ifdef ZVT_MB
+ /* prevent to be into alt mode for half katakana character in EUC-JP */
+ if ((mode & VT_CON) && process == vt_alt_start && (*ptr & 0xff) >= 0xa0) {
+ mode = VT_LIT;
+ process = NULL;
+ }
+#endif
+
if (mode & VT_LIT) {
/* remap character? */
if (vt->remaptable && c<=0xff)
@@ -1531,17 +1610,43 @@
if (vt->mode & VTMODE_INSERT)
vt_insert_chars(vt, 1);
+#ifdef ZVT_MB
+ ctmp_num = 0;
+#endif
/* need to wrap? */
if (vt->cursorx>=vt->width) {
if (vt->mode&VTMODE_WRAPOFF)
vt->cursorx = vt->width-1;
else {
+#ifdef ZVT_MB
+ /* check of a boundary of multi byte character */
+ int x = vt_query_line_mbchar(vt->width+1, vt->this_line);
+ if (x < vt->width && vt->width - x < sizeof(ctmp) ) {
+ for(ctmp_num=0; ctmp_num < vt->width - x; ctmp_num++) {
+ int i = vt->width - 1 - ctmp_num;
+ ctmp[ctmp_num] = vt->this_line->data[i] & 0xff;
+ vt->this_line->data[i] =
+ ((vt->attr) & VTATTR_CLEARMASK) |VTATTR_MULTIBYTE;
+ vt->this_line->modcount++;
+ }
+ }
+#endif
vt_lf(vt);
vt->cursorx=0;
}
}
/* output character */
+#ifdef ZVT_MB
+ if (ctmp_num) {
+ while(ctmp_num) {
+ vt->this_line->data[vt->cursorx++] =
+ ((vt->attr) & VTATTR_MASK) | ctmp[ctmp_num-1];
+ ctmp_num--;
+ vt->this_line->modcount++;
+ }
+ }
+#endif
vt->this_line->data[vt->cursorx] = ((vt->attr) & VTATTR_MASK) | c;
vt->this_line->modcount++;
/* d(printf("literal %c\n", c)); */
@@ -1571,6 +1676,12 @@
} else if (c==']') { /* set text parameters, read parameters */
state = 4;
vt->arg.txt.outptr = vt->arg.txt.args_mem;
+#if defined(ZVT_JIS) && defined(ZVT_MB)
+ } else if (c=='$') { /* in JIS code */
+ state = 100;
+ } else if (c=='(') { /* out JIS mode */
+ state = 110;
+#endif
} else if (mode & VT_EXA) {
vt->arg.num.intargs[0] = c & 0x7f;
state = 5;
--- gnome-libs-1.2.13/zvt/vt.h.zvtmb Fri Oct 29 14:35:49 1999
+++ gnome-libs-1.2.13/zvt/vt.h Wed Apr 18 17:42:18 2001
@@ -28,6 +28,10 @@
/* for utf-8 input support */
#define ZVT_UTF 1
+/* for multibyte support */
+#define ZVT_MB 1
+#define ZVT_JIS 1
+
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
@@ -71,6 +75,7 @@
#define VTATTR_BLINK 0x10000000
#define VTATTR_REVERSE 0x08000000
#define VTATTR_CONCEALED 0x04000000
+#define VTATTR_MULTIBYTE 0x80000000 /* for multibyte charater */
/* all attributes mask, and no-attributes mask */
#define VTATTR_MASK 0xffff0000
@@ -207,6 +212,10 @@
int vt_killchild (struct vt_em *vt, int signal);
int vt_closepty (struct vt_em *vt);
void vt_reset_terminal (struct vt_em *vt, int hard);
+#ifdef ZVT_MB
+int vt_line_mblen(int x, struct vt_line *l);
+int vt_query_line_mbchar(int x, struct vt_line *l);
+#endif
#ifdef __cplusplus
}
--- gnome-libs-1.2.13/zvt/zterm.c.zvtmb Sat Mar 18 02:57:13 2000
+++ gnome-libs-1.2.13/zvt/zterm.c Wed Apr 18 17:42:18 2001
@@ -41,7 +41,12 @@
#include "zvtterm.h"
-#define FONT "-misc-fixed-medium-r-normal--12-200-75-75-c-100-iso8859-1"
+
+#ifdef ZVT_MB
+#define FONT "-misc-fixed-medium-r-normal--14-*-*-*-*-*-*-*"
+#else
+#define FONT "-misc-fixed-medium-r-normal--14-*-*-*-*-*-iso8859-1"
+#endif
extern char **environ;
static char **env;
@@ -153,6 +158,7 @@
env_copy [winid_pos] = "TEST";
env_copy [i] = NULL;
+ gtk_set_locale();
gtk_init(&argc, &argv);
/* process arguments */
--- gnome-libs-1.2.13/zvt/zvtterm.c.zvtmb Wed Apr 18 17:42:18 2001
+++ gnome-libs-1.2.13/zvt/zvtterm.c Wed Apr 18 17:45:04 2001
@@ -49,12 +49,15 @@
#include <X11/Xatom.h>
#include <X11/Xos.h>
-
/* define to 'x' to enable copious debug output */
#define d(x)
/* default font */
+#ifndef ZVT_MB
#define DEFAULT_FONT "-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1"
+#else
+#define DEFAULT_FONT "-misc-fixed-medium-r-normal--14-*-*-*-*-*-*-1"
+#endif
#define PADDING 2
@@ -115,6 +118,12 @@
/* load the "current" background, from file or from system */
static void load_background (ZvtTerm *term);
+#ifdef ZVT_IM_ON_THE_SPOT
+static void zvt_im_preedit_set_spot(ZvtTerm *term, int col, int row, int offx, int offy);
+static void zvt_im_preedit_set_foreground(ZvtTerm *term, GdkColor *color);
+static void zvt_im_preedit_set_background(ZvtTerm *term, GdkColor *color);
+static void zvt_im_preedit_set_font(ZvtTerm *term, GdkFont *font);
+#endif
/* static data */
@@ -146,6 +155,13 @@
};
static guint term_signals[LAST_SIGNAL] = { 0 };
+/* values for selection info */
+enum {
+ TARGET_STRING,
+ TARGET_UTF8,
+ TARGET_TEXT,
+ TARGET_COMPOUND_TEXT
+};
/* GTK parent class */
static GtkWidgetClass *parent_class = NULL;
@@ -237,6 +253,17 @@
zvt_term_init (ZvtTerm *term)
{
struct _zvtprivate *zp;
+ static const GtkTargetEntry targets[] = {
+ { "STRING", 0, TARGET_STRING },
+#ifdef ZVT_UTF
+ { "UTF-8", 0, TARGET_UTF8 },
+#endif
+#ifdef ZVT_MB
+ { "TEXT", 0, TARGET_TEXT },
+ { "COMPOUND_TEXT", 0, TARGET_COMPOUND_TEXT }
+#endif
+ };
+ static const gint n_targets = sizeof(targets) / sizeof(targets[0]);
GTK_WIDGET_SET_FLAGS (term, GTK_CAN_FOCUS);
@@ -328,19 +355,9 @@
term);
/* selection received */
- gtk_selection_add_target (
- GTK_WIDGET (term),
- GDK_SELECTION_PRIMARY,
- GDK_SELECTION_TYPE_STRING,
- 0);
-#ifdef ZVT_UTF
- gtk_selection_add_target (
- GTK_WIDGET (term),
- GDK_SELECTION_PRIMARY,
- gdk_atom_intern ("UTF-8", FALSE),
- 1);
-#endif
-
+ gtk_selection_add_targets (GTK_WIDGET (term),
+ GDK_SELECTION_PRIMARY,
+ targets, n_targets);
}
/**
@@ -647,6 +664,11 @@
clone_col(&zp->queue_red, 0);
clone_col(&zp->queue_green, 0);
clone_col(&zp->queue_blue, 0);
+#ifdef ZVT_IM_ON_THE_SPOT
+ zvt_im_preedit_set_background(term, &c);
+ c.pixel = term->colors [16];
+ zvt_im_preedit_set_foreground(term, &c);
+#endif /* ZVT_IM_ON_THE_SPOT */
}
/**
@@ -782,6 +804,9 @@
term_force_size(term);
/* input context */
+#ifdef ZVT_IM_ON_THE_SPOT
+ zvt_term_set_open_im (term, True);
+#else
if (gdk_im_ready () && !term->ic) {
GdkICAttr attr;
@@ -794,6 +819,7 @@
g_warning("Can't create input context.");
}
}
+#endif
}
static void
@@ -1261,7 +1287,11 @@
case GDK_FONT_FONTSET: {
XFontSet fontset = (XFontSet) ((GdkFontPrivate *)font)->xfont;
XFontSetExtents *extents = XExtentsOfFontSet(fontset);
+#ifdef ZVT_MB /* This is look bug..., isn't it? */
+ term->charwidth = gdk_string_width (font, "M");
+#else
term->charwidth = extents->max_logical_extent.width;
+#endif
term->charheight = extents->max_logical_extent.height;
zp->fonttype = ZVT_FONT_FONTSET;
}
@@ -1276,6 +1306,9 @@
if (term->font)
gdk_font_unref (term->font);
term->font = font;
+#ifdef ZVT_IM_ON_THE_SPOT
+ zvt_im_preedit_set_font(term, font);
+#endif
if (term->font_bold)
gdk_font_unref (term->font_bold);
@@ -1376,16 +1409,28 @@
if (rest) {
g_string_sprintf (outname, "%s-medium-r%s", newname->str, rest);
+#ifndef ZVT_MB
font = gdk_font_load (outname->str);
+#else
+ font = gdk_fontset_load (outname->str);
+#endif
d( printf("loading normal font %s\n", outname->str) );
g_string_sprintf (outname, "%s-bold-r%s", newname->str, rest);
+#ifndef ZVT_MB
font_bold = gdk_font_load (outname->str);
+#else
+ font_bold = gdk_fontset_load (outname->str);
+#endif
d( printf("loading bold font %s\n", outname->str) );
zvt_term_set_fonts_internal (term, font, font_bold);
} else {
+#ifndef ZVT_MB
font = gdk_font_load (name);
+#else
+ font = gdk_fontset_load (name);
+#endif
zvt_term_set_fonts_internal (term, font, 0);
}
@@ -1425,7 +1470,11 @@
{
GdkAtom string_atom;
#ifdef ZVT_UTF
+#ifdef ZVT_MB
+ char *types[] = {"UTF-8", "COMPOUND_TEXT"};
+#else
char *types[] = {"UTF-8", "STRING"};
+#endif /* ZVT_MB */
int index;
struct _zvtprivate *zp = _ZVT_PRIVATE(widget);
@@ -1445,7 +1494,11 @@
d(printf(" %s atom = %d\n", types[index], (int)string_atom));
#else
/* Get the atom corresonding to the target "STRING" */
+#ifdef ZVT_MB
+ string_atom = gdk_atom_intern ("COMPOUND_TEXT", FALSE);
+#else
string_atom = gdk_atom_intern ("STRING", FALSE);
+#endif /* ZVT_MB */
#endif
if (string_atom == GDK_NONE) {
@@ -1871,10 +1924,15 @@
switch (type) {
default:
- case 0: { /* this is ascii/isolatin1 */
+
+#ifdef ZVT_MB
+ case TARGET_COMPOUND_TEXT:
+ case TARGET_TEXT:
+#endif
+ case TARGET_STRING: { /* this is ascii/isolatin1 */
unsigned char *o;
d(printf("converting selection to ISOLATIN1\n"));
- out = g_malloc(term->vx->selection_size);
+ out = g_malloc(term->vx->selection_size+1);
o = out;
for(i=0;i<term->vx->selection_size;i++) {
c = term->vx->selection_data[i];
@@ -1883,7 +1941,7 @@
*outlen = term->vx->selection_size;
break;
}
- case 1: { /* this is utf-8, basically a local implementation of wcstombs() */
+ case TARGET_UTF8: { /* this is utf-8, basically a local implementation of wcstombs() */
unsigned char *o;
unsigned int len=0;
d(printf("converting selection to UTF-8\n"));
@@ -1972,10 +2030,34 @@
term = ZVT_TERM (widget);
vx = term->vx;
+#ifdef ZVT_MB
+ if (info == TARGET_COMPOUND_TEXT||info == TARGET_TEXT) {
+ GdkAtom encoding;
+ gint format;
+ guchar *str, *new_str;
+ gint new_len;
+#ifdef ZVT_UTF
+ str = zvt_term_convert_selection(term, info, &len);
+#else
+ int len = vx->selection_size;
+ str = (guchar*)vx->selection_data;
+#endif
+ str[len] = '\0';
+ gdk_string_to_compound_text (str, &encoding, &format, &new_str, &new_len);
+ gtk_selection_data_set (selection_data_ptr, encoding, format,
+ new_str, new_len);
+ gdk_free_compound_text (new_str);
+#if ZVT_UTF
+ g_free(str);
+#endif
+ return;
+ }
+#endif /* ZVT_MB */
+
#ifdef ZVT_UTF
/* convert selection based on info */
/* the selection is actually stored in 32 bit chars */
- if (info==1)
+ if (info==TARGET_UTF8)
atom = gdk_atom_intern ("UTF-8", FALSE);
else
atom = GDK_SELECTION_TYPE_STRING;
@@ -2026,6 +2108,7 @@
/* Make sure we got the data in the expected form */
if (selection_data->type != GDK_SELECTION_TYPE_STRING
+ && selection_data->type != gdk_atom_intern("COMPOUND_TEXT", FALSE)
&& selection_data->type != gdk_atom_intern("UTF-8", FALSE)) {
g_print ("Selection \"STRING\" was not returned as strings!\n");
return;
@@ -2036,13 +2119,40 @@
{
int i;
char *ctmp = selection_data->data;
+ gint length = selection_data->length;
- for(i = 0; i < selection_data->length; i++)
- if(ctmp[i] == '\n') ctmp[i] = '\r';
-
- if (term->scroll_on_keystroke)
- zvt_term_scroll (term, 0);
- zvt_term_writechild(term, selection_data->data, selection_data->length);
+ if (selection_data->type == gdk_atom_intern("COMPOUND_TEXT",FALSE)) {
+ gchar **list;
+ gint count;
+
+ count = gdk_text_property_to_text_list (selection_data->type,
+ selection_data->format,
+ selection_data->data,
+ selection_data->length,
+ &list);
+ if (count > 0) {
+ gint n;
+ length = 0;
+ for (n=0; n<count; n++) {
+ ctmp = list[n];
+ length = strlen (list[n]);
+ for(i = 0; i < length; i++)
+ if(ctmp[i] == '\n') ctmp[i] = '\r';
+
+ if (term->scroll_on_keystroke)
+ zvt_term_scroll (term, 0);
+ vt_writechild(&vx->vt, ctmp, length);
+ }
+ gdk_free_text_list (list);
+ }
+ } else {
+ for (i = 0; i < length; i++)
+ if(ctmp[i] == '\n') ctmp[i] = '\r';
+
+ if (term->scroll_on_keystroke)
+ zvt_term_scroll (term, 0);
+ vt_writechild(&vx->vt, ctmp, length);
+ }
}
}
@@ -2094,6 +2204,141 @@
return length;
}
+#ifdef ZVT_IM_ON_THE_SPOT
+/**
+ * zvt_term_set_open_im:
+ * @term: A &ZvtTerm widget.
+ * @state: if True, open IM, else close.
+ **/
+void
+zvt_term_set_open_im (ZvtTerm *term, int state)
+{
+ if(!state)
+ {
+ if (term->ic)
+ {
+ gdk_ic_destroy(term->ic);
+ term->ic = NULL;
+ }
+ return;
+ }
+
+ if (gdk_im_ready () && !term->ic)
+ {
+ gint width, height;
+ GdkICAttr attr;
+ GdkColormap *colormap;
+ GdkICAttributesType attrmask = GDK_IC_ALL_REQ;
+ GdkIMStyle style;
+ GdkIMStyle supported_style = GDK_IM_PREEDIT_NONE |
+ GDK_IM_PREEDIT_NOTHING |
+ GDK_IM_PREEDIT_POSITION |
+ GDK_IM_STATUS_NONE |
+ GDK_IM_STATUS_NOTHING;
+
+ if (GTK_WIDGET (term)->style &&
+ GTK_WIDGET (term)->style->font->type != GDK_FONT_FONTSET)
+ supported_style &= ~GDK_IM_PREEDIT_POSITION;
+
+ attr.style = style = gdk_im_decide_style (supported_style);
+ attr.client_window = attr.focus_window = term->term_window;
+
+ if ((colormap = gtk_widget_get_colormap (GTK_WIDGET (term)))
+ != gtk_widget_get_default_colormap ())
+ {
+ attrmask |= GDK_IC_PREEDIT_COLORMAP;
+ attr.preedit_colormap = colormap;
+ }
+
+ switch (style & GDK_IM_PREEDIT_MASK)
+ {
+ case GDK_IM_PREEDIT_POSITION:
+ if (term->font && term->font->type != GDK_FONT_FONTSET)
+ {
+ g_warning ("over-the-spot style requires fontset");
+ break;
+ }
+#if 0
+ gdk_window_get_size (term->term_window, &width, &height);
+#else
+ width = term->vx->vt.width* term->charwidth;
+ height = term->vx->vt.height* term->charheight;
+#endif
+ attrmask |= GDK_IC_PREEDIT_POSITION_REQ|GDK_IC_PREEDIT_FONTSET;
+ attr.spot_location.x = 0;
+ attr.spot_location.y = 0;
+ attr.preedit_area.x = 0;
+ attr.preedit_area.y = 0;
+ attr.preedit_area.width = width;
+ attr.preedit_area.height = height;
+ attr.preedit_fontset = term->font;
+ break;
+ }
+
+ term->ic = gdk_ic_new(&attr, attrmask);
+
+ if (!term->ic)
+ {
+ g_warning("Can't create input context.");
+ }
+ }
+}
+
+
+static void
+zvt_im_preedit_set_spot(ZvtTerm *term, int col, int row, int offx, int offy)
+{
+ if (term->ic &&
+ (gdk_ic_get_style (term->ic) & GDK_IM_PREEDIT_POSITION))
+ {
+ GdkICAttr attr;
+ attr.spot_location.x = col * term->charwidth + offx;
+ attr.spot_location.y = row * term->charheight
+ + term->font->ascent + offy;
+ gdk_ic_set_attr (term->ic, &attr, GDK_IC_SPOT_LOCATION);
+ }
+}
+
+static void
+zvt_im_preedit_set_foreground(ZvtTerm *term, GdkColor *color)
+{
+ if (term->ic &&
+ (gdk_ic_get_style (term->ic) & GDK_IM_PREEDIT_POSITION))
+ {
+ GdkICAttr attr;
+ attr.preedit_foreground = *color;
+ gdk_ic_set_attr (term->ic, &attr, GDK_IC_PREEDIT_FOREGROUND);
+ }
+}
+
+static void
+zvt_im_preedit_set_background(ZvtTerm *term, GdkColor *color)
+{
+ if (term->ic &&
+ (gdk_ic_get_style (term->ic) & GDK_IM_PREEDIT_POSITION))
+ {
+ GdkICAttr attr;
+ attr.preedit_background = *color;
+ gdk_ic_set_attr (term->ic, &attr, GDK_IC_PREEDIT_BACKGROUND);
+ }
+}
+
+
+static void
+zvt_im_preedit_set_font(ZvtTerm *term, GdkFont *font)
+{
+ if (term->ic &&
+ (gdk_ic_get_style (term->ic) & GDK_IM_PREEDIT_POSITION))
+ {
+ GdkICAttr attr;
+ if (font && font->type != GDK_FONT_FONTSET)
+ g_warning ("over-the-spot style requires fontset");
+ attr.preedit_fontset = font;
+ gdk_ic_set_attr (term->ic, &attr, GDK_IC_PREEDIT_FONTSET);
+ }
+}
+#endif /* ZVT_IM_ON_THE_SPOT */
+
static void
zvt_term_writemore (gpointer data, gint fd, GdkInputCondition condition)
{
@@ -2324,7 +2569,7 @@
static gint
zvt_term_key_press (GtkWidget *widget, GdkEventKey *event)
{
- char buffer[64];
+ char buffer[128];
char *p=buffer;
struct _vtx *vx;
ZvtTerm *term;
@@ -2535,6 +2780,7 @@
break;
default:
if (event->length > 0){
+ gint length = MIN(((buffer+ sizeof(buffer)) - p)/sizeof(char), event->length);
if (event->state & (GDK_MOD1_MASK | GDK_MOD4_MASK)){
*p++ = '\033';
}
@@ -3149,24 +3395,24 @@
break;
/* this is limited to 65535 characters! */
case ZVT_FONT_FONTSET: {
- wchar_t *expandwc = zp->text_expand;
+ char *expand = zp->text_expand;
XFontSet fontset = (XFontSet) font_private->xfont;
for (i=0;i<len;i++) {
- expandwc[i] = VT_ASCII(line->data[i+col]);
+ expand[i] = VT_ASCII(line->data[i+col]) & 0xff;
}
/* render wide characters, with fill if we can */
if (dofill) {
- XwcDrawImageString(drawable_private->xdisplay, drawable_private->xwindow,
- fontset, gc_private->xgc, offx + x, offy + y, expandwc, len);
+ XmbDrawImageString(drawable_private->xdisplay, drawable_private->xwindow,
+ fontset, gc_private->xgc, offx + x, offy + y, expand, len);
} else {
- XwcDrawString(drawable_private->xdisplay, drawable_private->xwindow,
- fontset, gc_private->xgc, offx + x, offy + y, expandwc, len);
+ XmbDrawString(drawable_private->xdisplay, drawable_private->xwindow,
+ fontset, gc_private->xgc, offx + x, offy + y, expand, len);
}
if (overstrike)
- XwcDrawString(drawable_private->xdisplay, drawable_private->xwindow,
- fontset, gc_private->xgc, offx + x + 1, offy + y, expandwc, len);
+ XmbDrawString(drawable_private->xdisplay, drawable_private->xwindow,
+ fontset, gc_private->xgc, offx + x + 1, offy + y, expand, len);
}
}
@@ -3187,6 +3433,10 @@
x + offx + len*term->charwidth, offy + row*term->charheight,
1, term->charheight);
}
+#ifdef ZVT_IM_ON_THE_SPOT
+ if (len <= MB_CUR_MAX)
+ zvt_im_preedit_set_spot(term, col, row, offx, offy);
+#endif
}
@@ -3856,6 +4106,7 @@
gdk_gc_set_foreground (term->back_gc, &pen);
return;
}
+
}
static gint
--- gnome-libs-1.2.13/zvt/zvtterm.h.zvtmb Wed Apr 18 17:42:18 2001
+++ gnome-libs-1.2.13/zvt/zvtterm.h Wed Apr 18 17:42:18 2001
@@ -33,6 +33,7 @@
/* if one doesn't want to compile in transparency one would define this */
/* #define ZVT_NO_TRANSPARENT 1 */
+#define ZVT_IM_ON_THE_SPOT 1
#define ZVT_TERM(obj) GTK_CHECK_CAST (obj, zvt_term_get_type (), ZvtTerm)
#define ZVT_TERM_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, zvt_term_get_type (), ZvtTermClass)
@@ -240,6 +241,10 @@
void zvt_term_set_size (ZvtTerm *term,
guint width,
guint height);
+#if ZVT_IM_ON_THE_SPOT
+void zvt_term_set_open_im (ZvtTerm *term,
+ int state);
+#endif
/* returns an bitmask of the capabilities compiled into ZvtTerm */
guint32 zvt_term_get_capabilities (ZvtTerm *term);
diff -ur gnome-libs/gtk-xmhtml/XmHTMLP.h gnome-libs.new/gtk-xmhtml/XmHTMLP.h
--- gnome-libs/gtk-xmhtml/XmHTMLP.h Tue Sep 21 15:29:53 1999
+++ gnome-libs.new/gtk-xmhtml/XmHTMLP.h Thu Sep 30 16:55:30 1999
@@ -301,6 +301,8 @@
#define TEXT_IMAGE (1<<5) /* indicates an image member */
#define TEXT_FORM (1<<6) /* indicates a form member */
#define TEXT_BREAK (1<<7) /* indicates a linebreak */
+#define TEXT_SPACE_LEAD_ZEROWIDTH (1<<8) /* no spacing, but can break before the word */
+#define TEXT_SPACE_TRAIL_ZEROWIDTH (1<<9) /* no spacing, but can break after the word */
/*****
* HTML list marker enumeration type
@@ -527,7 +529,7 @@
int len; /* string length of word */
XmHTMLfont *font; /* font to use */
Byte line_data; /* line data (underline/strikeout) */
- Byte spacing; /* leading/trailing/nospace allowed */
+ int spacing; /* leading/trailing/nospace allowed */
AllEvents *events; /* events to be served */
struct _XmHTMLImage *image; /* when this is an image */
struct _XmHTMLForm *form; /* when this is a form element */
diff -ur gnome-libs/gtk-xmhtml/format.c gnome-libs.new/gtk-xmhtml/format.c
--- gnome-libs/gtk-xmhtml/format.c Tue Sep 21 15:29:53 1999
+++ gnome-libs.new/gtk-xmhtml/format.c Fri Oct 1 01:32:27 1999
@@ -237,6 +237,14 @@
#include <string.h>
#include <ctype.h> /* isspace, tolower */
+#include <gdk/gdki18n.h>
+#if !defined(G_HAVE_BROKEN_WCTYPE) && (defined(G_HAVE_WCTYPE_H) || defined(G_HAVE_WCHAR_H)) && !defined(X_LOCALE)
+#define is_ideograph(wc) \
+ (!(iswspace(wc) || iswalnum(wc) || iswpunct(wc) || iswcntrl(wc)))
+#else
+#define is_ideograph(wc) FALSE
+#endif
+
/* Local includes */
#include "XmHTMLP.h"
#include "XmHTMLfuncs.h"
@@ -307,14 +315,14 @@
/* copy given text into an internal buffer */
static String CopyText(XmHTMLWidget html, String text, Boolean formatted,
- Byte *text_data, Boolean expand_escapes);
+ int *text_data, Boolean expand_escapes);
/* collapse all consecutive whitespace into a single space */
static void CollapseWhiteSpace(String text);
/* Split raw text into an array of words */
static XmHTMLWord* TextToWords(String text, int *num_words, Dimension *height,
- XmHTMLfont *font, Byte line_data, Byte text_data,
+ XmHTMLfont *font, Byte line_data, int text_data,
XmHTMLObjectTableElement owner);
/* Split an image into an array of words ;-) */
@@ -804,14 +812,16 @@
*****/
static XmHTMLWord*
TextToWords(String text, int *num_words, Dimension *height, XmHTMLfont *font,
- Byte line_data, Byte text_data, XmHTMLObjectTableElement owner)
+ Byte line_data, int text_data, XmHTMLObjectTableElement owner)
{
- int n_words, len, i;
- char *start;
- static XmHTMLWord *words;
- static char *raw;
+ int n_words, n_words_alloc, raw_numwc, i;
+ GdkWChar *raw, *start;
+ XmHTMLWord *words;
register int j;
- register char *chPtr;
+ register GdkWChar *chPtr;
+ int leading_space;
+ char *wordsbuf;
+ int size_wordsbuf;
/* sanity check */
if(text == NULL)
@@ -822,57 +832,109 @@
_XmHTMLFullDebug(2, ("format.c: TextToWords, text in is:\n%s\n", text));
- /* compute how many words we have */
- n_words = 0;
- for(chPtr = text; *chPtr != '\0'; chPtr++)
- if(*chPtr == ' ')
- n_words++;
- /* also pick up the last word */
- n_words++;
-
/* copy text */
- raw = strdup(text);
+ raw = (GdkWChar *)calloc(strlen(text) + 1, sizeof(GdkWChar));
+ raw_numwc = gdk_mbstowcs(raw, text, strlen(text));
+ if (raw_numwc < 1)
+ raw_numwc = 0;
/* allocate memory for all words */
- words = (XmHTMLWord*)calloc(n_words, sizeof(XmHTMLWord));
+ n_words = 0;
+ n_words_alloc = 10;
+ words = (XmHTMLWord*)calloc(n_words_alloc, sizeof(XmHTMLWord));
/* Split the text in words and fill in the appropriate fields */
*height = font->height;
chPtr = start = raw;
- for(i = 0, j = 0, len = 0; ; chPtr++, len++, j++)
+ for(i = 0, j = 0, leading_space = 0; ; chPtr++, j++)
{
- /* also pick up the last word! */
- if(*chPtr == ' ' || *chPtr == '\0')
+ /* expand words[] if needed */
+ if (n_words_alloc < i + 1)
{
- if(*chPtr)
+ n_words_alloc += 10;
+ words = (XmHTMLWord *)realloc(
+ words, n_words_alloc * sizeof(XmHTMLWord));
+ }
+
+ /* also pick up the last word! */
+ if(*chPtr == ' ' || *chPtr == '\0' ||
+ (chPtr > start &&
+ (is_ideograph(*chPtr) || is_ideograph(chPtr[-1]))))
+ {
+ GdkWChar saved_char;
+ int trailing_space = 0;
+ if(*chPtr == ' ')
{
chPtr++; /* nuke the space */
raw[j++] = '\0';
+ trailing_space = 1;
}
+ /* set the first char of the next word 0 temporally.
+ * gdk_wcstombs requires this. */
+ saved_char = raw[j];
+ raw[j] = '\0';
/* fill in required fields */
- words[i].self = &words[i];
- words[i].word = start;
- words[i].len = len;
+ words[i].self = NULL; /* set later */
+ words[i].word = gdk_wcstombs(start);
+ words[i].len = words[i].word ? strlen(words[i].word) : 0;
words[i].height = *height;
- words[i].width = Toolkit_Text_Width(font->xfont, words[i].word, len);
+ words[i].width = Toolkit_Text_Width(
+ font->xfont, words[i].word, strlen(words[i].word));
words[i].owner = owner;
words[i].font = font;
- words[i].spacing = TEXT_SPACE_LEAD | TEXT_SPACE_TRAIL;
+ words[i].spacing = 0; /* set later */
words[i].type = OBJ_TEXT;
words[i].line_data = line_data;
+ if (leading_space)
+ words[i].spacing |= TEXT_SPACE_LEAD;
+ else
+ words[i].spacing |= TEXT_SPACE_LEAD_ZEROWIDTH;
+
+ if (trailing_space)
+ words[i].spacing |= TEXT_SPACE_TRAIL;
+ else
+ words[i].spacing |= TEXT_SPACE_TRAIL_ZEROWIDTH;
+
+ leading_space = trailing_space; /* for the next word */
+
+ raw[j] = saved_char;
+
_XmHTMLFullDebug(2, ("format.c: TextToWords, word is %s, len is "
"%i, width is %i, height is %i\n", words[i].word, words[i].len,
words[i].width, words[i].height));
start = chPtr;
i++;
- len = 0;
}
if(*chPtr == '\0')
break;
}
+ free(raw);
+ n_words = i;
+
+ /* because the pointer 'words' may be realloc()ed, we need to set the
+ * 'self' field here.
+ */
+ for (i = 0; i < n_words; i++)
+ words[i].self = &words[i];
+
+ /* words[0].word must be a malloc()ed pointer, and word[i].word
+ * (for i > 0) a reference (i.e., it should not be freed).
+ */
+ for (size_wordsbuf = 0, i = 0; i < n_words; i++)
+ size_wordsbuf += words[i].len + 1;
+ wordsbuf = (char *)malloc(size_wordsbuf);
+ for (i = j = 0; i < n_words; i++)
+ {
+ /* copies trailing nil also */
+ memcpy(wordsbuf + j, words[i].word, words[i].len + 1);
+ free(words[i].word);
+ words[i].word = wordsbuf + j;
+ j += words[i].len + 1;
+ }
+
/*
* when there is more than one word in this block, the first word
* _always_ has a trailing space.
@@ -880,10 +942,13 @@
*/
if(n_words > 1)
{
- /* unset nospace bit */
- Byte spacing = text_data & ~TEXT_SPACE_NONE;
- words[0].spacing = spacing | TEXT_SPACE_TRAIL;
- words[n_words-1].spacing = spacing | TEXT_SPACE_LEAD;
+ words[0].spacing &= ~TEXT_SPACE_LEAD_ZEROWIDTH;
+ words[n_words-1].spacing &= ~TEXT_SPACE_TRAIL_ZEROWIDTH;
+
+ words[0].spacing |= text_data &
+ (TEXT_SPACE_LEAD | TEXT_SPACE_LEAD_ZEROWIDTH);
+ words[n_words-1].spacing |= text_data &
+ (TEXT_SPACE_TRAIL | TEXT_SPACE_TRAIL_ZEROWIDTH);
}
else
words[0].spacing = text_data;
@@ -1109,7 +1174,7 @@
if(tmp->id == HT_OPTION && !tmp->is_end)
{
XmHTMLObject *sel_start = tmp;
- Byte foo;
+ int foo;
String text = NULL;
/*
@@ -1185,7 +1250,7 @@
static XmHTMLForm *form_entry;
XmHTMLWord *word;
String text = NULL;
- Byte foo;
+ int foo;
*num_words = 0;
*height = *width = 0;
@@ -1633,13 +1698,14 @@
* cleaned up text. Terminates if malloc fails.
*****/
static String
-CopyText(XmHTMLWidget html, String text, Boolean formatted, Byte *text_data,
+CopyText(XmHTMLWidget html, String text, Boolean formatted, int *text_data,
Boolean expand_escapes)
{
static String ret_val;
- char *start = text;
+ GdkWChar *wtext, *start;
int len;
static Boolean have_space = False;
+ static Boolean have_space_zerowidth = False;
/* sanity check */
if(*text == '\0' || !strlen(text))
@@ -1653,23 +1719,30 @@
/* expand all escape sequences in this text */
if(expand_escapes)
_XmHTMLExpandEscapes(ret_val, html->html.bad_html_warnings);
- have_space = False;
+ have_space = have_space_zerowidth = False;
return(ret_val);
}
_XmHTMLFullDebug(2, ("format.c: CopyText, text in is:\n%s\n", text));
- /* initial length of full text */
- len = strlen(text);
+ /* convert to wide characters */
+ wtext = (GdkWChar *)calloc(strlen(text) + 1, sizeof(GdkWChar));
+ len = gdk_mbstowcs(wtext, text, strlen(text));
+ if (len < 0) len = 0;
+ start = wtext;
*text_data = 0;
/* see if we have any leading/trailing spaces */
- if(isspace(*text) || have_space)
+ if(gdk_iswspace(*wtext) || have_space)
*text_data = TEXT_SPACE_LEAD;
+ else if(is_ideograph(*wtext) || have_space_zerowidth)
+ *text_data = TEXT_SPACE_LEAD_ZEROWIDTH;
- if(isspace(text[len-1]))
+ if(len > 0 && gdk_iswspace(wtext[len-1]))
*text_data |= TEXT_SPACE_TRAIL;
+ else if(len > 0 && is_ideograph(wtext[len-1]))
+ *text_data |= TEXT_SPACE_TRAIL_ZEROWIDTH;
/*****
* Remove leading/trailing spaces
@@ -1677,11 +1750,13 @@
* elements must be retained
*****/
/* remove all leading space */
- while(*start != '\0' && isspace(*start))
+ while(*start != '\0' && gdk_iswspace(*start))
+ {
start++;
+ len--;
+ }
/* remove all trailing space */
- len = strlen(start);
- while(len > 0 && isspace(start[len-1]))
+ while(len > 0 && gdk_iswspace(start[len-1]))
len--;
/*****
@@ -1705,16 +1780,14 @@
have_space = True;
return(NULL);
}
- have_space = False;
-
- /*
- * We are a little bit to generous here: consecutive multiple whitespace
- * will be collapsed into a single space, so we may over-allocate.
- * Hey, better to overdo this than to have one byte to short ;-)
- */
- ret_val = (String)malloc((len+1)*sizeof(char));
- strncpy(ret_val, start, len); /* copy it */
- ret_val[len] = '\0'; /* NULL terminate */
+ have_space = have_space_zerowidth = False;
+ if(len > 0 && is_ideograph(wtext[len-1]))
+ have_space_zerowidth = True;
+
+ /* convert to multibyte form */
+ start[len] = '\0';
+ ret_val = gdk_wcstombs(start);
+ free(wtext);
/* expand all escape sequences in this text */
if(expand_escapes)
@@ -3030,7 +3103,8 @@
String text;
int linefeed, n_words, anchor_words, named_anchors;
int x_offset = 0, y_offset = 0;
- Byte text_data, line_data; /* text and line data bits */
+ int text_data; /* text data bits */
+ Byte line_data; /* line data bits */
unsigned long element_data = 0;
XmHTMLWord *words;
XmHTMLAnchor *anchor_data, *form_anchor_data;
diff -ur gnome-libs/gtk-xmhtml/gtk-xmhtml.c gnome-libs.new/gtk-xmhtml/gtk-xmhtml.c
--- gnome-libs/gtk-xmhtml/gtk-xmhtml.c Tue Sep 21 15:29:53 1999
+++ gnome-libs.new/gtk-xmhtml/gtk-xmhtml.c Thu Sep 30 16:55:30 1999
@@ -2262,16 +2262,18 @@
Toolkit_Draw_Shadows(XmHTMLWidget html, TGC top_shadow, TGC bottom_shadow,
gint xs, gint ys, gint w, gint h, gint shadow_thick, gint shadow_type)
{
+ GtkWidget *win;
+ win = GTK_WIDGET(html->html.work_area);
switch (shadow_type)
{
case XmSHADOW_IN:
- gtk_draw_shadow(GTK_WIDGET(html)->style, GTK_WIDGET(html)->window,
+ gtk_draw_shadow(GTK_WIDGET(html)->style, win->window,
GTK_STATE_NORMAL, GTK_SHADOW_IN,
xs, ys,
w, h);
break;
case XmSHADOW_OUT:
- gtk_draw_shadow(GTK_WIDGET(html)->style, GTK_WIDGET(html)->window,
+ gtk_draw_shadow(GTK_WIDGET(html)->style, win->window,
GTK_STATE_NORMAL, GTK_SHADOW_OUT,
xs, ys,
w, h);
diff -ur gnome-libs/gtk-xmhtml/layout.c gnome-libs.new/gtk-xmhtml/layout.c
--- gnome-libs/gtk-xmhtml/layout.c Tue Sep 21 15:29:53 1999
+++ gnome-libs.new/gtk-xmhtml/layout.c Thu Sep 30 23:03:31 1999
@@ -447,7 +447,7 @@
*****/
for(i = 0 ; i < html->html.anchor_words; i++)
html->html.anchors[i].x = html->html.anchors[i].self->x;
- for(i = 0 ; i < html->html.anchor_words; i++)
+ for(i = 0 ; i < html->html.anchor_words - 1; i++)
{
if((html->html.anchors[i].owner == html->html.anchors[i+1].owner) &&
(html->html.anchors[i].line == html->html.anchors[i+1].line))
@@ -1173,19 +1173,30 @@
* which *does* have a trailing space. We then use the total width
* of this word to check against available line width.
*****/
- if(!(words[i]->spacing & TEXT_SPACE_TRAIL) &&
- i+1 < *nwords && !(words[i+1]->spacing & TEXT_SPACE_LEAD))
+ if(
+ !(words[i]->spacing & TEXT_SPACE_TRAIL) &&
+ !(words[i]->spacing & TEXT_SPACE_TRAIL_ZEROWIDTH) &&
+ i+1 < *nwords &&
+ !(words[i+1]->spacing & TEXT_SPACE_LEAD) &&
+ !(words[i+1]->spacing & TEXT_SPACE_LEAD_ZEROWIDTH)
+ )
{
int j = i+1;
word_width = words[i]->width;
while(j < *nwords)
{
- if(!(words[j]->spacing & TEXT_SPACE_LEAD))
+ if(!(words[j]->spacing & TEXT_SPACE_LEAD) &&
+ !(words[j]->spacing & TEXT_SPACE_LEAD_ZEROWIDTH))
word_width += words[j]->width;
/* see if this word has a trail space and the next a leading */
- if(!(words[j]->spacing & TEXT_SPACE_TRAIL) &&
- j+1 < *nwords && !(words[j+1]->spacing & TEXT_SPACE_LEAD))
+ if(
+ !(words[j]->spacing & TEXT_SPACE_TRAIL) &&
+ !(words[j]->spacing & TEXT_SPACE_TRAIL_ZEROWIDTH) &&
+ j+1 < *nwords &&
+ !(words[j+1]->spacing & TEXT_SPACE_LEAD) &&
+ !(words[j+1]->spacing & TEXT_SPACE_LEAD_ZEROWIDTH)
+ )
j++;
else
break;
@@ -1395,8 +1406,13 @@
* save linenumber, x and y positions for this word or for
* multiple words needing to be ``glued'' together.
*****/
- if(!(words[i]->spacing & TEXT_SPACE_TRAIL) &&
- i+1 < *nwords && !(words[i+1]->spacing & TEXT_SPACE_LEAD))
+ if(
+ !(words[i]->spacing & TEXT_SPACE_TRAIL) &&
+ !(words[i]->spacing & TEXT_SPACE_TRAIL_ZEROWIDTH) &&
+ i+1 < *nwords &&
+ !(words[i+1]->spacing & TEXT_SPACE_LEAD) &&
+ !(words[i+1]->spacing & TEXT_SPACE_LEAD_ZEROWIDTH)
+ )
{
/* first word must take spacing into account */
UPDATE_WORD(words[i]);
@@ -1413,8 +1429,13 @@
UPDATE_WORD(words[i])
/* this word has a trailing and the next a leading space? */
- if(!(words[i]->spacing & TEXT_SPACE_TRAIL) &&
- i+1 < *nwords && !(words[i+1]->spacing & TEXT_SPACE_LEAD))
+ if(
+ !(words[i]->spacing & TEXT_SPACE_TRAIL) &&
+ !(words[i]->spacing & TEXT_SPACE_TRAIL_ZEROWIDTH) &&
+ i+1 < *nwords &&
+ !(words[i+1]->spacing & TEXT_SPACE_LEAD) &&
+ !(words[i+1]->spacing & TEXT_SPACE_LEAD_ZEROWIDTH)
+ )
i++;
else
break;
@@ -2972,8 +2993,7 @@
/* store return dimensions, box->x is not touched */
box->y += max_theight;
- table->end->height = box->height = max_theight;
- box->width = box->min_width = full_max_twidth;
+ table->end->height = max_theight;
/*****
* update x position of owning object, it might have shifted due to
diff -ur gnome-libs/gtk-xmhtml/paint.c gnome-libs.new/gtk-xmhtml/paint.c
--- gnome-libs/gtk-xmhtml/paint.c Tue Sep 21 15:29:53 1999
+++ gnome-libs.new/gtk-xmhtml/paint.c Thu Sep 30 17:33:59 1999
@@ -1604,13 +1604,8 @@
xs = data->x - html->html.scroll_x;
/* vertical offset */
-#if 0
dy = (int)(0.75*(html->html.default_font->height));
-#else
- dy = 0;
-#endif
ys = data->y - html->html.scroll_y;
-
if(data->height)
{
if(data->y_offset) /* noshade */
--- gnome-libs-1.2.8/gtk-xmhtml/format.c.alnum Wed Jan 24 05:58:22 2001
+++ gnome-libs-1.2.8/gtk-xmhtml/format.c Wed Jan 24 07:48:43 2001
@@ -240,7 +240,8 @@
#include <gdk/gdki18n.h>
#if !defined(G_HAVE_BROKEN_WCTYPE) && (defined(G_HAVE_WCTYPE_H) || defined(G_HAVE_WCHAR_H)) && !defined(X_LOCALE)
#define is_ideograph(wc) \
- (!(iswspace(wc) || iswalnum(wc) || iswpunct(wc) || iswcntrl(wc)))
+ (iswalpha (wc) && (!iswupper (wc) && !iswlower (wc) )) || \
+ (!(iswalnum(wc) || iswspace(wc) || iswpunct(wc) || iswcntrl(wc)))
#else
#define is_ideograph(wc) FALSE
#endif
--- gnome-libs-1.0.53/gtk-xmhtml/fonts.c.fontsize Thu Jul 29 16:35:55 1999
+++ gnome-libs-1.0.53/gtk-xmhtml/fonts.c Wed Oct 20 13:07:18 1999
@@ -221,8 +221,8 @@
static fontCache *curr_cache; /* current font cache */
/* Backup lists when sizes are not specified */
-static int def_fn_sizes[8] = {140,80,240,180,160,140,120,100};
-static int def_fn_fixed_sizes[2] = {120,80};
+static int def_fn_sizes[8] = {110,80,240,160,160,140,140,140};
+static int def_fn_fixed_sizes[2] = {110,80};
/*****
* Name: makeFontName
@@ -297,13 +297,13 @@
/* FIXME: better way to determine the fontset name? */
sprintf(new_name,
"-%s-%s-%s-%s-%s-*-*-%i-%i-%i-%s-*-%s,"
- "-*-*-%s-%s-%s-*-*-%i-*-*-*-*-*,"
+ "-*-*-%s-%s-%s-*-%i-*-*-*-*-*-*,"
"-*-*-*-*-*-*-%i-*-*-*-*-*-*,*",
foundry != NULL ? foundry : fndry,
family != NULL ? family : fam,
weight, slant, wd, points,
curr_cache->res_x, curr_cache->res_y, sp, charset,
- weight, slant, wd, points,
+ weight, slant, wd, points / 10,
points / 10);
} else {
sprintf(new_name,
--- gnome-libs-1.0.53/gtk-xmhtml/XmHTMLfuncs.h.fontsize Tue Dec 8 15:05:14 1998
+++ gnome-libs-1.0.53/gtk-xmhtml/XmHTMLfuncs.h Wed Oct 20 13:01:08 1999
@@ -190,8 +190,8 @@
* Scalable size array: default,sub/superscript,h1,h2,h3,h4,h5,h6
* Fixed size array : default,sub/superscript
*****/
-#define XmHTML_DEFAULT_FONT_SCALABLE_SIZES "14,8,24,18,14,12,10,8"
-#define XmHTML_DEFAULT_FONT_FIXED_SIZES "12,8"
+#define XmHTML_DEFAULT_FONT_SCALABLE_SIZES "14,8,24,16,16,14,14,8"
+#define XmHTML_DEFAULT_FONT_FIXED_SIZES "14,8"
/*****
* Default Table boder width, cell & row spacing.
--- gnome-libs-1.0.53/libgnomeui/gnome-about.c.fontset Thu Oct 21 10:09:51 1999
+++ gnome-libs-1.0.53/libgnomeui/gnome-about.c Thu Oct 21 10:10:09 1999
@@ -413,6 +413,7 @@
/* Create fonts */
/* FIXME: dirty hack, but it solves i18n problem without rewriting the
drawing code.. */
+ gtk_widget_ensure_style (widget);
style = gtk_style_ref (widget->style);
gtk_widget_set_name (widget, "Title");
--- gnome-libs-1.2.13/libgnome/gnome-dentry.c.utf8menu Tue Jan 23 20:09:46 2001
+++ gnome-libs-1.2.13/libgnome/gnome-dentry.c Wed Aug 1 19:54:48 2001
@@ -13,6 +13,12 @@
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
+#include <locale.h>
+#include <iconv.h>
+#include <langinfo.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
#include "gnome-defs.h"
#include "gnome-util.h"
#include "gnome-url.h"
@@ -20,6 +26,9 @@
#include "gnome-dentry.h"
#include "gnome-exec.h"
+static char *utf8tolocalechar (const char *value);
+static gboolean file_looks_utf8 (const char *filename);
+
/* g_free already checks if x is NULL */
#define free_if_empty(x) g_free (x)
@@ -133,17 +142,20 @@
{
GnomeDesktopEntry *newitem;
char *prefix;
- char *name, *type;
+ char *name, *type, *comment;
char *try_file;
char **exec_vector;
int exec_length;
char *icon_base;
char *p = NULL;
gboolean is_kde = FALSE;
+ gboolean is_utf8;
GList *i18n_list = NULL;
g_assert (file != NULL);
+
+ is_utf8 = file_looks_utf8 (file);
prefix = g_strconcat ("=", file, "=/Desktop Entry/", NULL);
gnome_config_push_prefix (prefix);
@@ -193,8 +210,25 @@
newitem = g_new0 (GnomeDesktopEntry, 1);
- newitem->name = name;
- newitem->comment = gnome_config_get_translated_string ("Comment");
+ comment = gnome_config_get_translated_string ("Comment");
+
+ if (is_utf8) {
+ if (name) {
+ newitem->name = utf8tolocalechar (name);
+ g_free (name);
+ } else
+ newitem->name = NULL;
+
+ if (comment) {
+ newitem->comment = utf8tolocalechar (comment);
+ g_free (comment);
+ } else
+ newitem->comment = NULL;
+ } else {
+ newitem->name = name;
+ newitem->comment = comment;
+ }
+
newitem->exec_length = exec_length;
newitem->exec = exec_vector;
newitem->tryexec = try_file;
@@ -808,4 +852,239 @@
g_free(e);
}
if(list) g_list_free(list);
+}
+
+static gboolean
+get_contents_regfile (const gchar *filename,
+ struct stat *stat_buf,
+ gint fd,
+ gchar **contents,
+ gsize *length)
+{
+ gchar *buf;
+ size_t bytes_read;
+ size_t size;
+
+ size = stat_buf->st_size;
+
+ buf = g_new (gchar, size + 1);
+
+ bytes_read = 0;
+ while (bytes_read < size)
+ {
+ gssize rc;
+
+ rc = read (fd, buf + bytes_read, size - bytes_read);
+
+ if (rc < 0)
+ {
+ if (errno != EINTR)
+ {
+ close (fd);
+
+ g_free (buf);
+
+ return FALSE;
+ }
+ }
+ else if (rc == 0)
+ break;
+ else
+ bytes_read += rc;
+ }
+
+ buf[bytes_read] = '\0';
+
+ if (length)
+ *length = bytes_read;
+
+ *contents = buf;
+
+ close (fd);
+
+ return TRUE;
+}
+
+/* Cut and paste from Glib-2.0
+ */
+static gboolean
+g_file_get_contents (const gchar *filename,
+ gchar **contents,
+ gsize *length)
+{
+ struct stat stat_buf;
+ gint fd;
+
+ g_return_val_if_fail (filename != NULL, FALSE);
+ g_return_val_if_fail (contents != NULL, FALSE);
+
+ *contents = NULL;
+ if (length)
+ *length = 0;
+
+ fd = open (filename, O_RDONLY);
+
+ if (fd < 0)
+ return FALSE;
+
+ /* I don't think this will ever fail, aside from ENOMEM, but. */
+ if (fstat (fd, &stat_buf) < 0)
+ {
+ close (fd);
+
+ return FALSE;
+ }
+
+ if (stat_buf.st_size > 0 && S_ISREG (stat_buf.st_mode))
+ {
+ return get_contents_regfile (filename,
+ &stat_buf,
+ fd,
+ contents,
+ length);
+ }
+ else
+ {
+ /* Glib-2.0 includes fallback to stdio in this case, but this shouldn't
+ * happen for desktop files
+ */
+
+ return FALSE;
+ }
+}
+
+#define F 0 /* character never appears in text */
+#define T 1 /* character appears in plain ASCII text */
+#define I 2 /* character appears in ISO-8859 text */
+#define X 3 /* character appears in non-ISO extended ASCII (Mac, IBM PC) */
+
+static char text_chars[256] = {
+ /* BEL BS HT LF FF CR */
+ F, F, F, F, F, F, F, T, T, T, T, F, T, T, F, F, /* 0x0X */
+ /* ESC */
+ F, F, F, F, F, F, F, F, F, F, F, T, F, F, F, F, /* 0x1X */
+ T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x2X */
+ T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x3X */
+ T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x4X */
+ T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x5X */
+ T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x6X */
+ T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, F, /* 0x7X */
+ /* NEL */
+ X, X, X, X, X, T, X, X, X, X, X, X, X, X, X, X, /* 0x8X */
+ X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, /* 0x9X */
+ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xaX */
+ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xbX */
+ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xcX */
+ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xdX */
+ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xeX */
+ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I /* 0xfX */
+};
+
+static gboolean
+file_looks_utf8 (const char *filename)
+{
+ int i, n;
+ unsigned long c;
+ char *buf;
+ size_t nbytes;
+ gboolean gotone = FALSE;
+ gboolean result = TRUE;
+
+ if (!g_file_get_contents (filename, &buf, &nbytes))
+ return FALSE;
+
+ for (i = 0; result && i < nbytes; i++) {
+ if ((buf[i] & 0x80) == 0) { /* 0xxxxxxx is plain ASCII */
+ /*
+ * Even if the whole file is valid UTF-8 sequences,
+ * still reject it if it uses weird control characters.
+ */
+
+ if (text_chars[((guchar *)buf)[i]] != T)
+ result = FALSE;
+ } else if ((buf[i] & 0x40) == 0) { /* 10xxxxxx never 1st byte */
+ result = FALSE;
+ } else { /* 11xxxxxx begins UTF-8 */
+ int following;
+
+ if ((buf[i] & 0x20) == 0) { /* 110xxxxx */
+ c = buf[i] & 0x1f;
+ following = 1;
+ } else if ((buf[i] & 0x10) == 0) { /* 1110xxxx */
+ c = buf[i] & 0x0f;
+ following = 2;
+ } else if ((buf[i] & 0x08) == 0) { /* 11110xxx */
+ c = buf[i] & 0x07;
+ following = 3;
+ } else if ((buf[i] & 0x04) == 0) { /* 111110xx */
+ c = buf[i] & 0x03;
+ following = 4;
+ } else if ((buf[i] & 0x02) == 0) { /* 1111110x */
+ c = buf[i] & 0x01;
+ following = 5;
+ } else {
+ result = FALSE;
+ goto done;
+ }
+
+ for (n = 0; n < following; n++) {
+ i++;
+ if (i >= nbytes) {
+ result = FALSE;
+ goto done;
+ }
+
+ if ((buf[i] & 0x80) == 0 || (buf[i] & 0x40)) {
+ result = FALSE;
+ goto done;
+ }
+
+ c = (c << 6) + (buf[i] & 0x3f);
+ }
+
+ gotone = TRUE;
+ }
+ }
+done:
+ g_free (buf);
+
+ return result && gotone; /* don't claim it's UTF-8 if it's all 7-bit */
+}
+
+static char *
+utf8tolocalechar (const char *value)
+{
+ static gboolean initialized = FALSE;
+ static iconv_t fd = (iconv_t)-1;
+
+ if (!initialized) {
+ gchar *locale;
+
+ setlocale (LC_CTYPE, "");
+ locale = nl_langinfo (CODESET);
+
+ if (g_strcasecmp (locale, "utf8") != 0 && g_strcasecmp (locale, "utf8") != 0) {
+ fd = iconv_open (locale, "UTF-8");
+ if (fd == (iconv_t)-1) {
+ g_warning ("gnome-dentry.c: Cannot open converter from UTF-8 to locale");
+ }
+ }
+
+ initialized = TRUE;
+ }
+ if (fd != (iconv_t)-1) {
+ gchar *pout, *pin, *str;
+ gint len, ib, ob;
+
+ len = strlen (value);
+
+ ib = len;
+ ob = ib * 3;
+ pout = str = g_new0 (gchar, ob);
+ pin = (char *)value;
+ iconv (fd, NULL, NULL, &pout, &ob);
+ iconv (fd, &pin, &ib, &pout, &ob);
+ return str;
+ } else
+ return g_strdup (value);
}
diff -ruN gnome-libs-1.2.8.orig/libgnomeui/gnome-canvas-text.c gnome-libs-1.2.8/libgnomeui/gnome-canvas-text.c
--- gnome-libs-1.2.8.orig/libgnomeui/gnome-canvas-text.c Thu Feb 1 06:16:37 2001
+++ gnome-libs-1.2.8/libgnomeui/gnome-canvas-text.c Thu Feb 1 06:17:21 2001
@@ -1089,11 +1089,27 @@
for (j = 0; j < lines->length; j++) {
GnomeCanvasTextSuckChar *ch;
+ int len;
- ch = &suckfont->chars[(unsigned char)((lines->text)[j])];
+ if (suckfont != NULL && suckfont != text->suckfont)
+ g_free (suckfont);
+ if (item->canvas->aa && MB_CUR_MAX >= 2 && (len = mblen (&lines->text[j], MB_CUR_MAX)) >= 2) {
+ gchar str[3];
+
+ str[0] = lines->text[j];
+ str[1] = lines->text[j+1];
+ str[2] = 0;
+ j += len - 1;
+ suckfont = gnome_canvas_suck_font_multibyte (text->font, str);
+ ch = &suckfont->chars[0];
+ } else {
+ suckfont = text->suckfont;
+ ch = &suckfont->chars[(unsigned char)((lines->text)[j])];
+ }
affine[4] = xpos;
affine[5] = ypos;
+
art_rgb_bitmap_affine (
buf->buf,
buf->rect.x0, buf->rect.y0, buf->rect.x1, buf->rect.y1,
@@ -1341,6 +1357,87 @@
font->ascent,
text, 1);
}
+
+ /* The handling of the image leaves me with distinct unease. But this
+ * is more or less copied out of gimp/app/text_tool.c, so it _ought_ to
+ * work. -RLL
+ */
+
+ image = gdk_image_get (pixmap, 0, 0, width, height);
+ suckfont->bitmap = g_malloc0 ((width >> 3) * height);
+
+ line = suckfont->bitmap;
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++) {
+ pixel = gdk_image_get_pixel (image, x, y);
+ if (pixel == black_pixel)
+ line[x >> 3] |= 128 >> (x & 7);
+ }
+ line += width >> 3;
+ }
+
+ gdk_image_destroy (image);
+
+ /* free the pixmap */
+ gdk_pixmap_unref (pixmap);
+
+ /* free the gc */
+ gdk_gc_destroy (gc);
+
+ return suckfont;
+}
+
+static GnomeCanvasTextSuckFont *
+gnome_canvas_suck_font_multibyte (GdkFont *font, gchar *text)
+{
+ GnomeCanvasTextSuckFont *suckfont;
+ int i;
+ int x, y;
+ int lbearing, rbearing, ch_width, ascent, descent;
+ GdkPixmap *pixmap;
+ GdkColor black, white;
+ GdkImage *image;
+ GdkGC *gc;
+ guchar *bitmap, *line;
+ int width, height;
+ int black_pixel, pixel;
+
+ if (!font)
+ return NULL;
+
+ suckfont = g_new (GnomeCanvasTextSuckFont, 1);
+
+ height = font->ascent + font->descent;
+ gdk_text_extents (font, text, strlen (text),
+ &lbearing, &rbearing, &ch_width, &ascent, &descent);
+ suckfont->chars[0].left_sb = lbearing;
+ suckfont->chars[0].right_sb = ch_width - rbearing;
+ suckfont->chars[0].width = rbearing - lbearing;
+ suckfont->chars[0].ascent = ascent;
+ suckfont->chars[0].descent = descent;
+ suckfont->chars[0].bitmap_offset = 0;
+ width = (ch_width + 31) & -32;
+
+ suckfont->bitmap_width = width;
+ suckfont->bitmap_height = height;
+ suckfont->ascent = font->ascent;
+
+ pixmap = gdk_pixmap_new (NULL, suckfont->bitmap_width,
+ suckfont->bitmap_height, 1);
+ gc = gdk_gc_new (pixmap);
+ gdk_gc_set_font (gc, font);
+
+ black_pixel = BlackPixel (gdk_display, DefaultScreen (gdk_display));
+ black.pixel = black_pixel;
+ white.pixel = WhitePixel (gdk_display, DefaultScreen (gdk_display));
+ gdk_gc_set_foreground (gc, &white);
+ gdk_draw_rectangle (pixmap, gc, 1, 0, 0, width, height);
+
+ gdk_gc_set_foreground (gc, &black);
+ gdk_draw_text (pixmap, font, gc,
+ suckfont->chars[0].bitmap_offset - suckfont->chars[0].left_sb,
+ font->ascent,
+ text, strlen (text));
/* The handling of the image leaves me with distinct unease. But this
* is more or less copied out of gimp/app/text_tool.c, so it _ought_ to
--- gnome-libs-1.2.13/libgnome/gnome-dentry.c.kdemenus Wed Aug 1 19:45:35 2001
+++ gnome-libs-1.2.13/libgnome/gnome-dentry.c Wed Aug 1 19:46:17 2001
@@ -149,6 +149,7 @@
char *icon_base;
char *p = NULL;
gboolean is_kde = FALSE;
+ gboolean is_dot_directory = FALSE;
gboolean is_utf8;
GList *i18n_list = NULL;
@@ -184,7 +185,11 @@
* entries, we will later need to make this code smarter.
*/
- type = gnome_config_get_string (is_kde ? "Type=Directory" : "Type");
+ if (strlen (file) >= strlen (".directory") &&
+ strcmp (file + strlen (file) - strlen (".directory"), ".directory") == 0)
+ is_dot_directory = TRUE;
+
+ type = gnome_config_get_string (is_dot_directory ? "Type=Directory" : "Type");
gnome_config_get_vector ("Exec", &exec_length, &exec_vector);
try_file = gnome_config_get_string ("TryExec");
@@ -248,8 +253,23 @@
g_free (iconname);
newitem->icon = NULL;
}
- } else
+ } else {
newitem->icon = gnome_pixmap_file (icon_base);
+ /* If it wasn't found, look in kde */
+ if (!newitem->icon) {
+ gchar *iconname = g_concat_dir_and_file (KDE_ICONDIR "/hicolor/32x32/apps", icon_base);
+ if (g_file_exists (iconname))
+ newitem->icon = iconname;
+ else { /* Maybe it didn't have an extension? */
+ gchar *icon2 = g_strconcat (iconname, ".png", NULL);
+ if (g_file_exists (icon2))
+ newitem->icon = icon2;
+ else
+ g_free (icon2);
+ g_free (iconname);
+ }
+ }
+ }
g_free (icon_base);
} else
newitem->icon = icon_base;
@@ -565,9 +585,7 @@
g_assert (item != NULL);
- if (!item->terminal && the_argc == 0 && !item->is_kde)
- exec_str = g_strjoinv (" ", (char **)(item->exec));
- else {
+ {
if (item->terminal) {
gnome_config_get_vector ("/Gnome/Applications/Terminal",
&term_argc, &term_argv);
@@ -599,13 +617,10 @@
/* ... arguments from the desktop file */
for (i = 0; i < item->exec_length; ++i) {
- if (item->is_kde) {
- sub_arg = gnome_desktop_entry_sub_kde_arg (item, item->exec[i]);
- if (sub_arg) {
- args_to_free = g_slist_prepend (args_to_free, sub_arg);
- argv[term_argc + i] = sub_arg;
- } else
- argv[term_argc + i] = item->exec[i];
+ sub_arg = gnome_desktop_entry_sub_kde_arg (item, item->exec[i]);
+ if (sub_arg) {
+ args_to_free = g_slist_prepend (args_to_free, sub_arg);
+ argv[term_argc + i] = sub_arg;
} else
argv[term_argc + i] = item->exec[i];
}
--- gnome-libs-1.2.13/libgnome/gnome-dentry.c.noxalf Fri Jul 13 16:23:06 2001
+++ gnome-libs-1.2.13/libgnome/gnome-dentry.c Fri Jul 13 16:24:29 2001
@@ -624,7 +624,7 @@
no_xalf = TRUE;
if ( ! no_xalf &&
- gnome_config_get_bool("/xalf/settings/enabled=true")) {
+ gnome_config_get_bool("/xalf/settings/enabled=false")) {
xalf = gnome_is_program_in_path ("xalf");
if (xalf != NULL) {
--- gnome-libs-1.2.13/libgnomeui/gnome-preferences.c.notearoffs Fri Jul 13 17:48:46 2001
+++ gnome-libs-1.2.13/libgnomeui/gnome-preferences.c Fri Jul 13 18:27:50 2001
@@ -36,7 +36,7 @@
TRUE, /* PropertyBox has Help */
FALSE, /* Use dialogs, not the statusbar */
FALSE, /* Statusbar isn't interactive */
- TRUE, /* Menubars are detachable */
+ FALSE, /* Menubars are detachable */
TRUE, /* Menubars are relieved */
TRUE, /* Toolbars are detachable */
TRUE, /* Toolbars are relieved */
@@ -44,7 +44,7 @@
TRUE, /* Toolbars show lines for separators */
TRUE, /* Toolbars show labels */
TRUE, /* Center dialogs over apps when possible */
- TRUE, /* Menus have a tearoff bar */
+ FALSE, /* Menus have a tearoff bar */
TRUE, /* Menu items have icons in them */
TRUE, /* Disable the Imlib cache */
GTK_WINDOW_DIALOG, /* Dialogs are treated specially */
@@ -268,7 +268,7 @@
gnome_config_pop_prefix();
gnome_config_push_prefix(APP);
- b = gnome_config_get_bool_with_default(MENUBAR_DETACHABLE_KEY"=true",
+ b = gnome_config_get_bool_with_default(MENUBAR_DETACHABLE_KEY"=false",
NULL);
settings->menubar_detachable = b;
@@ -296,7 +296,7 @@
NULL);
settings->toolbar_labels = b;
- b = gnome_config_get_bool_with_default (MENUS_HAVE_TEAROFF_KEY"=true",
+ b = gnome_config_get_bool_with_default (MENUS_HAVE_TEAROFF_KEY"=false",
NULL);
settings->menus_have_tearoff = b;
--- gnome-libs-1.2.13/libgnomeui/gnome-client.c.mastercleanup Mon Jul 23 18:41:16 2001
+++ gnome-libs-1.2.13/libgnomeui/gnome-client.c Mon Jul 23 18:48:17 2001
@@ -961,6 +961,8 @@
/* Create the master client. */
master_client= gnome_client_new_without_connection ();
g_assert (master_client);
+ gtk_signal_connect (GTK_OBJECT (master_client), "destroy",
+ GTK_SIGNAL_FUNC (gtk_widget_destroyed), &master_client);
/* Initialise ICE */
gnome_ice_init ();
--- gnome-libs-1.2.13/libgnomeui/gnome-init.c.imlibref Sun Aug 12 19:04:41 2001
+++ gnome-libs-1.2.13/libgnomeui/gnome-init.c Sun Aug 12 19:09:50 2001
@@ -761,8 +761,21 @@
{
GdkPixmap *retval;
- if (gdk_imlib_load_file_to_pixmap ((char *) filename, &retval, mask))
+ if (gdk_imlib_load_file_to_pixmap ((char *) filename, &retval, mask)) {
+ if (retval) {
+ if (mask && *mask)
+ gdk_pixmap_ref (*mask);
+ gdk_pixmap_ref (retval);
+ gdk_imlib_free_pixmap (retval);
+ } else {
+ /* Paranoia */
+ if (mask && *mask) {
+ gdk_imlib_free_pixmap (*mask);
+ *mask = NULL;
+ }
+ }
return retval;
+ }
else
return NULL;
}
--- gnome-libs-1.2.13/gtk-xmhtml/escapes.h.mdash Tue Jul 28 05:39:55 1998
+++ gnome-libs-1.2.13/gtk-xmhtml/escapes.h Mon Aug 13 15:13:45 2001
@@ -62,7 +62,7 @@
* The first part of this table contains the hash escapes, the second part
* contains the named entity escapes.
*/
-#define NUM_ESCAPES 198
+#define NUM_ESCAPES 202
static escape_data escapes[NUM_ESCAPES] = {
{"#160;", '\240', 5},
{"#161;", '\241', 5},
@@ -160,6 +160,9 @@
{"#253;", '\375', 5},
{"#254;", '\376', 5},
{"#255;", '\377', 5},
+ {"#8211;", '-', 6}, /* EN DASH */
+ {"#8212;", '-', 6}, /* EM DASH */
+ {"#8230;", '-', 6}, /* HORIZONTAL ELLIPSIS */
{"AElig;", '\306', 6},
{"Aacute;", '\301', 7},
{"Acirc;", '\302', 6},
@@ -226,6 +229,7 @@
{"laquo;", '\253', 6},
{"lt;", '<', 3},
{"macr;", '\257', 5},
+ {"mdash;", '-', 6},
{"micro;", '\265', 6},
{"middot;", '\267', 7},
{"nbsp;", '\240', 5},
--- gnome-libs-1.2.13/libgnome/gnome-url.c.initialurl Mon Aug 13 16:08:07 2001
+++ gnome-libs-1.2.13/libgnome/gnome-url.c Mon Aug 13 16:34:52 2001
@@ -31,10 +31,10 @@
#define DEFAULT_HANDLER "gnome-moz-remote --newwin \"%s\""
static gchar *
-gnome_url_default_handler ()
+gnome_url_default_handler (const char *protocol)
{
static gchar *default_handler = 0;
-
+
if (!default_handler) {
gchar *str, *app;
gboolean def;
@@ -62,10 +62,18 @@
gnome_config_set_string ("/Gnome/URL Handlers/man-show", app);
g_free (gnome_config_get_string_with_default(
"/Gnome/URL Handlers/ghelp-show", &def));
- if (def)
+ if (def)
gnome_config_set_string ("/Gnome/URL Handlers/ghelp-show", app);
gnome_config_sync_file ("/Gnome/");
+
+ if (protocol &&
+ (strcmp (protocol, "ghelp") == 0 ||
+ strcmp (protocol, "info") == 0 ||
+ strcmp (protocol, "man") == 0)) {
+ return app;
+ }
+
} else
default_handler = str;
}
@@ -120,12 +128,12 @@
template = gnome_config_get_string_with_default (path, &def);
g_free (path);
if (def)
- template = gnome_url_default_handler ();
+ template = gnome_url_default_handler (protocol);
else
free_template = TRUE;
g_free (protocol);
} else /* no : ? -- this shouldn't happen. Use default handler */
- template = gnome_url_default_handler ();
+ template = gnome_url_default_handler (NULL);
/* we use a popt function as it does exactly what we want to do and
gnome already uses popt */
--- gnome-libs-1.2.13/zvt/zvtterm.c.zvthomeend Wed Aug 22 16:13:56 2001
+++ gnome-libs-1.2.13/zvt/zvtterm.c Wed Aug 22 16:14:15 2001
@@ -2563,8 +2563,8 @@
*/
/* remapping table for function keys 5-20 */
-static unsigned char f5_f20_remap[] =
- {15,17,18,19,20,21,23,24,25,26,28,29,31,32,33,34};
+static unsigned char f1_f20_remap[] =
+ {11,12,13,14,15,17,18,19,20,21,23,24,25,26,28,29,31,32,33,34};
static gint
zvt_term_key_press (GtkWidget *widget, GdkEventKey *event)
@@ -2646,11 +2646,11 @@
break;
case GDK_KP_Home:
case GDK_Home:
- p+=sprintf (p, "\033OH");
+ p+=sprintf (p, "\033[1~");
break;
case GDK_KP_End:
case GDK_End:
- p+=sprintf (p, "\033OF");
+ p+=sprintf (p, "\033[4~");
break;
case GDK_KP_Page_Up:
case GDK_Page_Up:
@@ -2667,27 +2667,29 @@
p+=sprintf (p, "\033[6~");
break;
- case GDK_KP_F1:
- case GDK_F1:
- p+=sprintf (p, "\033OP");
- break;
- case GDK_KP_F2:
- case GDK_F2:
- p+=sprintf (p, "\033OQ");
- break;
- case GDK_KP_F3:
- case GDK_F3:
- p+=sprintf (p, "\033OR");
- break;
- case GDK_KP_F4:
- case GDK_F4:
- p+=sprintf (p, "\033OS");
+ case GDK_KP_F1: case GDK_KP_F2: case GDK_KP_F3: case GDK_KP_F4:
+ if (event->state & GDK_SHIFT_MASK){
+ p+=sprintf (p, "\033[%d~", f1_f20_remap[10+event->keyval-GDK_KP_F1]);
+ } else
+ p+=sprintf (p, "\033[%d~", f1_f20_remap[event->keyval-GDK_KP_F1]);
+ break;
+
+ case GDK_F1: case GDK_F2: case GDK_F3: case GDK_F4:
+ if (event->state & GDK_SHIFT_MASK){
+ p+=sprintf (p, "\033[%d~", f1_f20_remap[10+event->keyval-GDK_F1]);
+ } else
+ p+=sprintf (p, "\033O%c", 'P' + (event->keyval-GDK_F1));
break;
+
case GDK_F5: case GDK_F6: case GDK_F7: case GDK_F8:
case GDK_F9: case GDK_F10: case GDK_F11: case GDK_F12:
case GDK_F13: case GDK_F14: case GDK_F15: case GDK_F16:
case GDK_F17: case GDK_F18: case GDK_F19: case GDK_F20:
- p+=sprintf (p, "\033[%d~", f5_f20_remap[event->keyval-GDK_F5]);
+ if ( (event->state & GDK_SHIFT_MASK) &&
+ ((event->keyval-GDK_F1) < 10) ){
+ p+=sprintf (p, "\033[%d~", f1_f20_remap[10+event->keyval-GDK_F1]);
+ } else
+ p+=sprintf (p, "\033[%d~", f1_f20_remap[event->keyval-GDK_F1]);
break;
case GDK_KP_0: case GDK_KP_1: case GDK_KP_2: case GDK_KP_3:
@@ -2718,6 +2720,20 @@
p+=sprintf (p, "\033Om");
} else {
*p++ = '-';
+ }
+ break;
+ case GDK_KP_Multiply:
+ if (appl_keypad) {
+ p+=sprintf (p, "\033Oj");
+ } else {
+ *p++ = '*';
+ }
+ break;
+ case GDK_KP_Divide:
+ if (appl_keypad) {
+ p+=sprintf (p, "\033Oo");
+ } else {
+ *p++ = '/';
}
break;
case GDK_KP_Separator: /* aka KP Comma */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]