From 30e6961bb0915ed1a038ef56475e5bf09b224601 Mon Sep 17 00:00:00 2001 From: Kim Woelders Date: Sat, 12 Jul 2003 14:34:14 +0000 Subject: [PATCH] Added possibility to configure not to use fnlib (configure --without-fnlib). SVN revision: 7154 --- configure.in | 5 +++++ dox/dox.c | 14 +++++++++++--- dox/dox.h | 8 +++++++- dox/format.c | 10 ++++++++-- dox/text.c | 32 ++++++++++++++++++++++++++------ src/E.h | 26 +++++++++++++++++++++++++- src/config.c | 12 +++++++++--- src/globals.c | 5 ++++- src/setup.c | 6 ++++-- src/tclass.c | 6 +++++- src/text.c | 42 ++++++++++++++++++++++++++++++++---------- 11 files changed, 136 insertions(+), 30 deletions(-) diff --git a/configure.in b/configure.in index 89b255d2..6e827086 100644 --- a/configure.in +++ b/configure.in @@ -77,6 +77,8 @@ AC_ARG_ENABLE(hints-gnome, [ --enable-hints-gnome compile with GNOME(<2.0) hints support [default=yes]],, enable_hints_gnome=yes) AC_ARG_ENABLE(hints-kde, [ --enable-hints-kde compile with KDE(<2.0) hints support [default=no]],, enable_hints_kde=no) +AC_ARG_WITH(fnlib, + [ --with-fnlib compile with Fnlib support [default=yes]],, with_fnlib=yes) if test "x$enable_hints_ewmh" = "xyes"; then AC_DEFINE(ENABLE_EWMH, 1, [Extended Window Manager Hints]) fi if test "x$enable_hints_gnome" = "xyes"; then AC_DEFINE(ENABLE_GNOME, 1, [GNOME(<2.0) Hints]) fi @@ -131,6 +133,7 @@ LDFLAGS="$LDFLAGS `echo $IMLIB_LIBS | sed 's/\(.*\)-lImlib.*/\1/'`" LDFLAGS="$LDFLAGS `echo $IMLIB_LIBS | sed 's/.*-lImlib.*\(-L[[^ ]]*\).*$/\1/'`" XTST_LIBS="" +if test "x$with_fnlib" = "xyes"; then # AC_CHECK_HEADER(Fnlib.h, ,AC_MSG_ERROR([Fatal Error: no Fnlib header detected.])) AC_CHECK_LIB(Fnlib, Fnlib_init, FNLIB_LIBS=-lFnlib , [ echo "ERROR: Enlightenment needs a system with libFnlib.so (Fnlib)" @@ -140,6 +143,8 @@ echo "ftp://www.rasterman.com/pub/enlightenment/" echo "ftp://ftp.labs.redhat.com/pub/fnlib/" AC_MSG_ERROR([Fatal Error: no Fnlib detected.])], $IMLIB_LIBS) AC_SUBST(FNLIB_LIBS) +AC_DEFINE(USE_FNLIB, 1, [Fnlib support]) +fi if test "x$enable_upgrade" = "xyes"; then AC_CHECK_LIB(ghttp, ghttp_uri_validate, [AC_DEFINE(AUTOUPGRADE, 1, [Automatic upgrading]) diff --git a/dox/dox.c b/dox/dox.c index 1c3a1c61..41e916c3 100644 --- a/dox/dox.c +++ b/dox/dox.c @@ -37,7 +37,9 @@ #endif #include +#if USE_FNLIB #include +#endif #include #include #include @@ -88,7 +90,9 @@ typedef struct _mwmhints { Display *disp; ImlibData *id; -FnlibData *fd; +#if USE_FNLIB +FnlibData *pFnlibData; +#endif Window win_main, win_title, win_exit, win_next, win_prev, win_text, win_cover; int w, h, t; ImlibImage *im_text; @@ -216,7 +220,9 @@ int main(int argc, char **argv) params.pixmapcachesize = (w * h * 3 * 2 * 8); id = Imlib_init_with_params(disp, ¶ms); Imlib_set_render_type(id, RT_DITHER_TRUECOL); - fd = Fnlib_init(id); +#if USE_FNLIB + pFnlibData = Fnlib_init(id); +#endif im_title = Imlib_create_image_from_xpm_data(id, title_xpm); ibd.left = 50; @@ -280,7 +286,9 @@ int main(int argc, char **argv) t = 16; GetObjects(f); fclose(f); - Fnlib_add_dir(fd, docdir); +#if USE_FNLIB + Fnlib_add_dir(pFnlibData, docdir); +#endif wx = (DisplayWidth(disp, DefaultScreen(disp)) - w) / 2; wy = (DisplayHeight(disp, DefaultScreen(disp)) - (h + t)) / 2; #ifdef HAS_XINERAMA diff --git a/dox/dox.h b/dox/dox.h index 441fc4e7..38006fbe 100644 --- a/dox/dox.h +++ b/dox/dox.h @@ -34,7 +34,9 @@ #include #include #include +#if USE_FNLIB #include +#endif #include #include #include @@ -104,8 +106,10 @@ Efont; typedef struct _textstate { char *fontname; +#if USE_FNLIB FnlibStyle style; FnlibFont *font; +#endif ImlibColor fg_col; ImlibColor bg_col; int effect; @@ -249,5 +253,7 @@ Link *RenderPage(Window win, int page_num, int w, int h); extern Display *disp; extern ImlibData *id; -extern FnlibData *fd; +#if USE_FNLIB +extern FnlibData *pFnlibData; +#endif extern char *docdir; diff --git a/dox/format.c b/dox/format.c index 13052339..21f0e392 100644 --- a/dox/format.c +++ b/dox/format.c @@ -519,11 +519,13 @@ RenderPage(Window win, int page_num, int w, int h) int wastext = 0; ts.fontname = NULL; +#if USE_FNLIB ts.style.orientation = FONT_TO_RIGHT; ts.style.mode = MODE_WRAP_WORD; ts.style.justification = 0; ts.style.spacing = 0; ts.font = NULL; +#endif ts.fg_col.r = 0; ts.fg_col.g = 0; ts.fg_col.b = 0; @@ -604,13 +606,15 @@ RenderPage(Window win, int page_num, int w, int h) case FONT: fn = pg->obj[i].object; ts.fontname = NULL; +#if USE_FNLIB ts.style.orientation = FONT_TO_RIGHT; ts.style.mode = MODE_WRAP_WORD; ts.style.justification = 0; ts.style.spacing = 0; if (ts.font) - Fnlib_free_font(fd, ts.font); + Fnlib_free_font(pFnlibData, ts.font); ts.font = NULL; +#endif ts.fg_col.r = 0; ts.fg_col.g = 0; ts.fg_col.b = 0; @@ -980,8 +984,10 @@ RenderPage(Window win, int page_num, int w, int h) } } +#if USE_FNLIB if (ts.font) - Fnlib_free_font(fd, ts.font); + Fnlib_free_font(pFnlibData, ts.font); +#endif if (ts.efont) Efont_free(ts.efont); if (ts.xfont) diff --git a/dox/text.c b/dox/text.c index 847420ba..80c48327 100644 --- a/dox/text.c +++ b/dox/text.c @@ -57,13 +57,23 @@ TextGetLines(char *text, int *count) void TextStateLoadFont(TextState * ts) { +#if USE_FNLIB if ((ts->font) || (ts->efont) || (ts->xfont) || (ts->xfontset)) +#else + if ((ts->efont) || (ts->xfont) || (ts->xfontset)) +#endif return; if (!ts->fontname) return; +#if USE_FNLIB if ((!ts->font) && (!ts->efont)) - ts->font = Fnlib_load_font(fd, ts->fontname); + ts->font = Fnlib_load_font(pFnlibData, ts->fontname); +#endif +#if USE_FNLIB if ((!ts->font) && (!ts->efont)) +#else + if (!ts->efont) +#endif { char s[4096], w[4046], *dup, *ss; @@ -90,7 +100,11 @@ TextStateLoadFont(TextState * ts) if (dup) free(dup); } +#if USE_FNLIB if ((!ts->font) && (!ts->efont)) +#else + if (!ts->efont) +#endif { if ((!ts->xfont) && (strchr(ts->fontname, ',') == NULL)) { @@ -145,13 +159,14 @@ TextSize(TextState * ts, char *text, if (!ts) return; TextStateLoadFont(ts); +#if USE_FNLIB if (ts->font) { for (i = 0; i < num_lines; i++) { int high, wid, dummy; - Fnlib_measure(fd, ts->font, 0, 0, 999999, 999999, + Fnlib_measure(pFnlibData, ts->font, 0, 0, 999999, 999999, 0, 0, fsize, &ts->style, (unsigned char *)lines[i], 0, 0, &dummy, &dummy, &wid, &high, &dummy, &dummy, &dummy, &dummy); @@ -160,7 +175,9 @@ TextSize(TextState * ts, char *text, *width = wid; } } - else if (ts->efont) + else +#endif + if (ts->efont) { for (i = 0; i < num_lines; i++) { @@ -237,13 +254,14 @@ TextDraw(TextState * ts, Window win, char *text, yy = y; if (!gc) gc = XCreateGC(disp, win, 0, &gcv); +#if USE_FNLIB if (ts->font) { for (i = 0; i < num_lines; i++) { int high, wid, dummy; - Fnlib_measure(fd, ts->font, 0, 0, 999999, 999999, + Fnlib_measure(pFnlibData, ts->font, 0, 0, 999999, 999999, 0, 0, fsize, &ts->style, (unsigned char *)lines[i], 0, 0, &dummy, &dummy, &wid, &high, &dummy, &dummy, &dummy, &dummy); @@ -251,12 +269,14 @@ TextDraw(TextState * ts, Window win, char *text, (ts->style.orientation == FONT_TO_DOWN)) fsize = w; xx = x + (((w - wid) * justification) >> 10); - Fnlib_draw(fd, ts->font, win, 0, xx, yy, w, h, + Fnlib_draw(pFnlibData, ts->font, win, 0, xx, yy, w, h, 0, 0, fsize, &ts->style, (unsigned char *)lines[i]); yy += high; } } - else if (ts->efont) + else +#endif + if (ts->efont) { for (i = 0; i < num_lines; i++) { diff --git a/src/E.h b/src/E.h index dac459b5..5bd30b86 100644 --- a/src/E.h +++ b/src/E.h @@ -35,7 +35,9 @@ /*#include */ #include #include +#if USE_FNLIB #include +#endif #define DEBUG_EWMH 0 @@ -675,11 +677,30 @@ typedef struct _efont } Efont; +#if !USE_FNLIB +#define MODE_VERBATIM 0 +#define MODE_WRAP_CHAR 1 +#define MODE_WRAP_WORD 2 + +#define FONT_TO_RIGHT 0 +#define FONT_TO_DOWN 1 +#define FONT_TO_UP 2 +#define FONT_TO_LEFT 3 +#endif + typedef struct _textstate { char *fontname; +#if USE_FNLIB FnlibStyle style; FnlibFont *font; +#else + struct + { + char mode; + char orientation; + } style; +#endif ImlibColor fg_col; ImlibColor bg_col; int effect; @@ -3011,7 +3032,10 @@ extern int single_screen_mode; extern Display *disp; extern ImlibData *id; extern ImlibData *ird; -extern FnlibData *fd; + +#if USE_FNLIB +extern FnlibData *pFnlibData; +#endif extern List *lists; extern int event_base_shape; extern Window comms_win; diff --git a/src/config.c b/src/config.c index 8f695c4d..c9914e4d 100644 --- a/src/config.c +++ b/src/config.c @@ -3665,13 +3665,17 @@ LoadEConfig(char *themelocation) mustdel = 0; Esnprintf(s, sizeof(s), "%s/", UserEDir()); - Fnlib_add_dir(fd, s); +#if USE_FNLIB + Fnlib_add_dir(pFnlibData, s); +#endif #ifndef __EMX__ Esnprintf(s, sizeof(s), "%s/config/", ENLIGHTENMENT_ROOT); #else Esnprintf(s, sizeof(s), "%s/config/", __XOS2RedirRoot(ENLIGHTENMENT_ROOT)); #endif - Fnlib_add_dir(fd, s); +#if USE_FNLIB + Fnlib_add_dir(pFnlibData, s); +#endif /* save the current theme */ if ((themelocation) && (themelocation[0] != 0)) { @@ -3723,7 +3727,9 @@ LoadEConfig(char *themelocation) } strcpy(themepath, theme); Esnprintf(s, sizeof(s), "%s/", theme); - Fnlib_add_dir(fd, s); +#if USE_FNLIB + Fnlib_add_dir(pFnlibData, s); +#endif { Progressbar *p = NULL; int i; diff --git a/src/globals.c b/src/globals.c index 5222b862..08e180ab 100644 --- a/src/globals.c +++ b/src/globals.c @@ -36,7 +36,10 @@ int single_screen_mode; Display *disp; ImlibData *id; ImlibData *ird; -FnlibData *fd; + +#if USE_FNLIB +FnlibData *pFnlibData; +#endif List *lists; int event_base_shape; Window comms_win; diff --git a/src/setup.c b/src/setup.c index d688877a..6f08317f 100644 --- a/src/setup.c +++ b/src/setup.c @@ -331,8 +331,9 @@ SetupX() RESET_ALERT; EExit((void *)1); } - fd = Fnlib_init(id); - if (!fd) +#if USE_FNLIB + pFnlibData = Fnlib_init(id); + if (!pFnlibData) { ASSIGN_ALERT(_("X server setup error"), "", "", _("Quit Enlightenment")); @@ -343,6 +344,7 @@ SetupX() RESET_ALERT; EExit((void *)1); } +#endif root.win = id->x.root; root.vis = Imlib_get_visual(id); root.depth = id->x.depth; diff --git a/src/tclass.c b/src/tclass.c index e44537fb..ce02cc41 100644 --- a/src/tclass.c +++ b/src/tclass.c @@ -53,8 +53,10 @@ FreeTextState(TextState * ts) if (ts->fontname) Efree(ts->fontname); +#if USE_FNLIB if (ts->font) - Fnlib_free_font(fd, ts->font); + Fnlib_free_font(pFnlibData, ts->font); +#endif if (ts->xfont) XFreeFont(disp, ts->xfont); if (ts->efont) @@ -141,9 +143,11 @@ CreateTextState() ts->fontname = NULL; ts->style.mode = MODE_WRAP_CHAR; ts->style.orientation = FONT_TO_RIGHT; +#if USE_FNLIB ts->style.justification = 0; ts->style.spacing = 0; ts->font = NULL; +#endif ts->efont = NULL; ts->xfont = NULL; ts->xfontset = 0; diff --git a/src/text.c b/src/text.c index f2de321e..9b48a21c 100644 --- a/src/text.c +++ b/src/text.c @@ -139,13 +139,23 @@ void TextStateLoadFont(TextState * ts) { EDBUG(5, "TextStateLoadFont"); +#if USE_FNLIB if ((ts->font) || (ts->efont) || (ts->xfont) || (ts->xfontset)) +#else + if ((ts->efont) || (ts->xfont) || (ts->xfontset)) +#endif EDBUG_RETURN_; if (!ts->fontname) EDBUG_RETURN_; +#if USE_FNLIB if ((!ts->font) && (!ts->efont)) - ts->font = Fnlib_load_font(fd, ts->fontname); + ts->font = Fnlib_load_font(pFnlibData, ts->fontname); +#endif +#if USE_FNLIB if ((!ts->font) && (!ts->efont)) +#else + if (!ts->efont) +#endif { char s[4096], w[4046], *dup, *ss; @@ -168,7 +178,11 @@ TextStateLoadFont(TextState * ts) if (dup) Efree(dup); } +#if USE_FNLIB if ((!ts->font) && (!ts->efont)) +#else + if (!ts->efont) +#endif { if ((!ts->xfont) && (strchr(ts->fontname, ',') == NULL)) { @@ -218,21 +232,25 @@ TextSize(TextClass * tclass, int active, int sticky, int state, char *text, if (!ts) EDBUG_RETURN_; TextStateLoadFont(ts); +#if USE_FNLIB if (ts->font) { for (i = 0; i < num_lines; i++) { int high, wid, dummy; - Fnlib_measure(fd, ts->font, 0, 0, 999999, 999999, 0, 0, fsize, - &ts->style, (unsigned char *)lines[i], 0, 0, &dummy, - &dummy, &wid, &high, &dummy, &dummy, &dummy, &dummy); + Fnlib_measure(pFnlibData, ts->font, 0, 0, 999999, 999999, 0, 0, + fsize, &ts->style, (unsigned char *)lines[i], 0, 0, + &dummy, &dummy, &wid, &high, &dummy, &dummy, &dummy, + &dummy); *height += high; if (wid > *width) *width = wid; } } - else if (ts->efont) + else +#endif + if (ts->efont) { for (i = 0; i < num_lines; i++) { @@ -323,25 +341,29 @@ TextDraw(TextClass * tclass, Window win, int active, int sticky, int state, else textwidth_limit = h; +#if USE_FNLIB if (ts->font) { for (i = 0; i < num_lines; i++) { int high, wid, dummy; - Fnlib_measure(fd, ts->font, 0, 0, 999999, 999999, 0, 0, fsize, - &ts->style, (unsigned char *)lines[i], 0, 0, &dummy, - &dummy, &wid, &high, &dummy, &dummy, &dummy, &dummy); + Fnlib_measure(pFnlibData, ts->font, 0, 0, 999999, 999999, 0, 0, + fsize, &ts->style, (unsigned char *)lines[i], 0, 0, + &dummy, &dummy, &wid, &high, &dummy, &dummy, &dummy, + &dummy); if ((ts->style.orientation == FONT_TO_UP) || (ts->style.orientation == FONT_TO_DOWN)) fsize = w; xx = x + (((w - wid) * justification) >> 10); - Fnlib_draw(fd, ts->font, win, 0, xx, yy, w, h, 0, 0, fsize, + Fnlib_draw(pFnlibData, ts->font, win, 0, xx, yy, w, h, 0, 0, fsize, &ts->style, (unsigned char *)lines[i]); yy += high; } } - else if (ts->efont) + else +#endif + if (ts->efont) { for (i = 0; i < num_lines; i++) {