From dd0f8bf0fd244e2b6e7ffdccc0293baeffcf2eee Mon Sep 17 00:00:00 2001 From: rephorm Date: Sat, 26 Jan 2002 02:01:42 +0000 Subject: [PATCH] move the background usage over to edb. background.c,h are no longer used. so if you haven't installed ebg, go get it. SVN revision: 5860 --- configure.ac | 13 ++ configure.in | 13 ++ src/Makefile.am | 5 +- src/desktops.c | 1 - src/e.h | 1 + src/view.c | 28 ++-- src/view.h | 4 +- tools/Makefile.am | 4 +- tools/e_setup.c | 323 +--------------------------------------------- 9 files changed, 55 insertions(+), 337 deletions(-) diff --git a/configure.ac b/configure.ac index 28c6aa3ad..1e9e5fb44 100644 --- a/configure.ac +++ b/configure.ac @@ -168,6 +168,19 @@ AC_PATH_GENERIC(efsd,, [ efsd_libs=`efsd-config --libs` efsd_cflags=`efsd-config --cflags` +dnl Check for Edb. +AC_ARG_WITH(ebg, + [ --with-ebg=DIR use ebg in ], + [CFLAGS="$CFLAGS -I$withval/include" + LIBS="-L$withval/lib $LIBS"]) + +AC_PATH_GENERIC(ebg,, [ + AC_SUBST(ebg_libs) + AC_SUBST(ebg_cflags)], + AC_MSG_ERROR(Cannot find ebg: Is ebg-config in path?)) +ebg_libs=`ebg-config --libs` +ebg_cflags=`ebg-config --cflags` + dnl Check for ferite. AC_ARG_WITH(ferite, [ --with-ferite=DIR use ferite in ], diff --git a/configure.in b/configure.in index 31582ec6f..9ddfc92da 100644 --- a/configure.in +++ b/configure.in @@ -167,6 +167,19 @@ AC_PATH_GENERIC(efsd,, [ efsd_libs=`efsd-config --libs` efsd_cflags=`efsd-config --cflags` +dnl Check for Edb. +AC_ARG_WITH(ebg, + [ --with-ebg=DIR use ebg in ], + [CFLAGS="$CFLAGS -I$withval/include" + LIBS="-L$withval/lib $LIBS"]) + +AC_PATH_GENERIC(ebg,, [ + AC_SUBST(ebg_libs) + AC_SUBST(ebg_cflags)], + AC_MSG_ERROR(Cannot find ebg: Is ebg-config in path?)) +ebg_libs=`ebg-config --libs` +ebg_cflags=`ebg-config --cflags` + dnl Check for ferite. AC_ARG_WITH(ferite, [ --with-ferite=DIR use ferite in ], diff --git a/src/Makefile.am b/src/Makefile.am index 929a514f9..f15284970 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -9,7 +9,7 @@ DEBUGFLAGS = -W -Wall -g -DDEBUG #-DDEBUG_NEST INCLUDES = \ -I$(top_srcdir)/intl \ - @evas_cflags@ @edb_cflags@ @ebits_cflags@ @ecore_cflags@ @efsd_cflags@ @ferite_cflags@ $(DEBUGFLAGS) + @evas_cflags@ @edb_cflags@ @ebits_cflags@ @ecore_cflags@ @efsd_cflags@ @ebg_cflags@ @ferite_cflags@ $(DEBUGFLAGS) EXTRA_DIST = e_ferite.fec @@ -47,7 +47,6 @@ bin_PROGRAMS = enlightenment $(E_FERITE_GEN_E_C) enlightenment_SOURCES = \ actions.h actions.c \ - background.h background.c \ block.c block.h \ border.h border.c \ bordermenu.h bordermenu.c \ @@ -87,4 +86,4 @@ enlightenment_SOURCES = \ view.h view.c \ e.h -enlightenment_LDADD = @evas_libs@ @edb_libs@ @ebits_libs@ @ecore_libs@ @efsd_libs@ @ferite_libs@ -lm -lc $(INTLLIBS) +enlightenment_LDADD = @evas_libs@ @edb_libs@ @ebits_libs@ @ecore_libs@ @efsd_libs@ @ebg_libs@ @ferite_libs@ -lm -lc $(INTLLIBS) diff --git a/src/desktops.c b/src/desktops.c index 78c7f0959..76a8cb6c3 100644 --- a/src/desktops.c +++ b/src/desktops.c @@ -3,7 +3,6 @@ #include "config.h" #include "actions.h" #include "border.h" -#include "background.h" #include "view.h" #include "icccm.h" #include "util.h" diff --git a/src/e.h b/src/e.h index dfd816d5f..bc937a640 100644 --- a/src/e.h +++ b/src/e.h @@ -25,6 +25,7 @@ #include #include #include +#include #ifndef PATH_MAX #define PATH_MAX 4096 diff --git a/src/view.c b/src/view.c index aead77779..678a0717a 100644 --- a/src/view.c +++ b/src/view.c @@ -669,7 +669,7 @@ e_view_scroll_to(E_View *v, int sx, int sy) v->scroll.x = sx; v->scroll.y = sy; e_view_icons_apply_xy(v); - if (v->bg) e_background_set_scroll(v->bg, v->scroll.x, v->scroll.y); + if (v->bg) e_bg_set_scroll(v->bg, v->scroll.x, v->scroll.y); D_RETURN; } @@ -709,7 +709,7 @@ e_view_scroll_to_percent(E_View *v, double psx, double psy) v->scroll.x = sx; v->scroll.y = sy; e_view_icons_apply_xy(v); - if (v->bg) e_background_set_scroll(v->bg, v->scroll.x, v->scroll.y); + if (v->bg) e_bg_set_scroll(v->bg, v->scroll.x, v->scroll.y); D_RETURN; } @@ -916,7 +916,7 @@ e_configure(Ecore_Event * ev) ecore_window_set_background_pixmap(v->win.main, v->pmap); ecore_window_clear(v->win.main); } - if (v->bg) e_background_set_size(v->bg, v->size.w, v->size.h); + if (v->bg) e_bg_resize(v->bg, v->size.w, v->size.h); D("evas_set_output_viewpor(%p)\n", v->evas); evas_set_output_viewport(v->evas, 0, 0, v->size.w, v->size.h); evas_set_output_size(v->evas, v->size.w, v->size.h); @@ -1972,8 +1972,9 @@ e_view_realize(E_View *v) } if (v->bg) { - e_background_realize(v->bg, v->evas); - e_background_set_size(v->bg, v->size.w, v->size.h); + e_bg_add_to_evas(v->bg, v->evas); + e_bg_resize(v->bg, v->size.w, v->size.h); + e_bg_show(v->bg); } v->obj_bg = evas_add_rectangle(v->evas); evas_callback_add(v->evas, v->obj_bg, CALLBACK_MOUSE_DOWN, e_bg_down_cb, v); @@ -2410,7 +2411,7 @@ e_view_handle_fs(EfsdEvent *ev) v->geom_get.busy = 0; if (v->bg) - e_background_set_size(v->bg, v->size.w, v->size.h); + e_bg_resize(v->bg, v->size.w, v->size.h); if (v->options.back_pixmap) e_view_update(v); b = e_border_adopt(v->win.base, 1); b->client.internal = 1; @@ -2447,7 +2448,7 @@ e_view_handle_fs(EfsdEvent *ev) void e_view_bg_load(E_View *v) { - E_Background *bg; + E_Background bg; char buf[PATH_MAX]; D_ENTER; @@ -2470,13 +2471,13 @@ e_view_bg_load(E_View *v) e_strdup(v->bg_file, buf); } } - bg = e_background_load(v->bg_file); + bg = e_bg_load(v->bg_file); if (!bg) { snprintf(buf, PATH_MAX, "%s/.e_background.bg.db", v->dir); FREE(v->bg_file); e_strdup(v->bg_file, buf); - bg = e_background_load(v->bg_file); + bg = e_bg_load(v->bg_file); if (!bg) { if (v->is_desktop) @@ -2485,7 +2486,7 @@ e_view_bg_load(E_View *v) snprintf(buf, PATH_MAX, "%s/view.bg.db", e_config_get("backgrounds")); FREE(v->bg_file); e_strdup(v->bg_file, buf); - bg = e_background_load(v->bg_file); + bg = e_bg_load(v->bg_file); } } if (bg) @@ -2494,9 +2495,10 @@ e_view_bg_load(E_View *v) v->bg_mod = e_file_mod_time(v->bg_file); if (v->evas) { - e_background_realize(v->bg, v->evas); - e_background_set_scroll(v->bg, v->scroll.x, v->scroll.y); - e_background_set_size(v->bg, v->size.w, v->size.h); + e_bg_add_to_evas(v->bg, v->evas); + e_bg_set_scroll(v->bg, v->scroll.x, v->scroll.y); + e_bg_resize(v->bg, v->size.w, v->size.h); + e_bg_show(v->bg); } } diff --git a/src/view.h b/src/view.h index 73ffb3b00..c7d90a3a4 100644 --- a/src/view.h +++ b/src/view.h @@ -2,7 +2,7 @@ #define E_VIEW_H #include "e.h" -#include "background.h" +/*#include "background.h"*/ #include "scrollbar.h" #include "fs.h" #include "iconbar.h" @@ -146,7 +146,7 @@ struct _E_View char *bg_file; char *prev_bg_file; time_t bg_mod; - E_Background *bg; + E_Background bg; struct { E_Scrollbar *h, *v; diff --git a/tools/Makefile.am b/tools/Makefile.am index 27fa8ba45..990e6498a 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -2,7 +2,7 @@ INCLUDES = \ -I$(top_srcdir)/intl \ - @evas_cflags@ @edb_cflags@ @ebits_cflags@ @ecore_cflags@ @efsd_cflags@ @ferite_cflags@ + @evas_cflags@ @edb_cflags@ @ebits_cflags@ @ecore_cflags@ @efsd_cflags@ @ebg_cflags@ @ferite_cflags@ bin_PROGRAMS = e_img_import e_img_export e_setup @@ -19,4 +19,4 @@ e_img_export_LDADD = @evas_libs@ @edb_libs@ @ebits_libs@ @ecore_libs@ @ferite_li e_setup_SOURCES = \ e_setup.c -e_setup_LDADD = @evas_libs@ @edb_libs@ @ebits_libs@ @ecore_libs@ @ferite_libs@ -lm -lc $(INTLLIBS) +e_setup_LDADD = @evas_libs@ @edb_libs@ @ebits_libs@ @ecore_libs@ @ebg_libs@ @ferite_libs@ -lm -lc $(INTLLIBS) diff --git a/tools/e_setup.c b/tools/e_setup.c index 40903e9e3..d4597b2eb 100644 --- a/tools/e_setup.c +++ b/tools/e_setup.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -47,318 +48,6 @@ __dest = malloc(strlen(__var) + 1); \ if (__dest) strcpy(__dest, __var); \ } } -typedef struct _E_Background E_Background; -typedef struct _E_Background_Layer E_Background_Layer; - -struct _E_Background -{ - OBJ_PROPERTIES; - - Evas evas; - char *file; - - struct { - int sx, sy; - int w, h; - } geom; - - Evas_List layers; - - Evas_Object base_obj; -}; - - -struct _E_Background_Layer -{ - int mode; - int type; - int inlined; - struct { - float x, y; - } scroll; - struct { - float x, y; - } pos; - struct { - float w, h; - struct { - int w, h; - } orig; - } size, fill; - char *color_class; - char *file; - double angle; - struct { - int r, g, b, a; - } fg, bg; - - double x, y, w, h, fw, fh; - - Evas_Object obj; -}; - - -void e_background_free(E_Background *bg); -E_Background *e_background_new(void); -E_Background *e_background_load(char *file); -void e_background_realize(E_Background *bg, Evas evas); -void e_background_set_scroll(E_Background *bg, int sx, int sy); -void e_background_set_size(E_Background *bg, int w, int h); -void e_background_set_color_class(E_Background *bg, char *cc, int r, int g, int b, int a); - -void -e_background_free(E_Background *bg) -{ - Evas_List l; - - if (bg->layers) - { - for (l = bg->layers; l; l = l->next) - { - E_Background_Layer *bl; - - bl = l->data; - if (bl->color_class) FREE(bl->color_class); - if (bl->file) FREE(bl->file); - if (bl->obj) evas_del_object(bg->evas, bl->obj); - FREE(bl); - } - evas_list_free(bg->layers); - } - if (bg->file) FREE (bg->file); - if (bg->base_obj) evas_del_object(bg->evas, bg->base_obj); - FREE(bg); -} - -E_Background * -e_background_new(void) -{ - E_Background *bg; - - bg = NEW(E_Background, 1); - ZERO(bg, E_Background, 1); - OBJ_INIT(bg, e_background_free); - - return bg; -} - -E_Background * -e_background_load(char *file) -{ - E_Background *bg; - E_DB_File *db; - int i, num; - - db = e_db_open_read(file); - if (!db) return NULL; - num = 0; - e_db_int_get(db, "/type/bg", &num); - if (num != 1) - { - e_db_close(db); - e_db_flush(); - return NULL; - } - e_db_int_get(db, "/layers/count", &num); - - bg = e_background_new(); - e_strdup(bg->file, file); - for (i = 0; i < num; i++) - { - E_Background_Layer *bl; - char buf[4096]; - - bl = NEW(E_Background_Layer, 1); - ZERO(bl, E_Background_Layer, 1); - bg->layers = evas_list_append(bg->layers, bl); - - sprintf(buf, "/layers/%i/type", i); e_db_int_get(db, buf, &(bl->type)); - sprintf(buf, "/layers/%i/inlined", i); e_db_int_get(db, buf, &(bl->inlined)); - sprintf(buf, "/layers/%i/color_class", i); bl->color_class = e_db_str_get(db, buf); - if (bl->inlined) - { - sprintf(buf, "%s:/layers/%i/image", file, i); e_strdup(bl->file, buf); - } - else - { - sprintf(buf, "/layers/%i/file", i); bl->file = e_db_str_get(db, buf); - } - sprintf(buf, "/layers/%i/scroll.x", i); e_db_float_get(db, buf, &(bl->scroll.x)); - sprintf(buf, "/layers/%i/scroll.y", i); e_db_float_get(db, buf, &(bl->scroll.y)); - sprintf(buf, "/layers/%i/pos.x", i); e_db_float_get(db, buf, &(bl->pos.x)); - sprintf(buf, "/layers/%i/pos.y", i); e_db_float_get(db, buf, &(bl->pos.y)); - sprintf(buf, "/layers/%i/size.w", i); e_db_float_get(db, buf, &(bl->size.w)); - sprintf(buf, "/layers/%i/size.h", i); e_db_float_get(db, buf, &(bl->size.h)); - sprintf(buf, "/layers/%i/size.orig.w", i); e_db_int_get(db, buf, &(bl->size.orig.w)); - sprintf(buf, "/layers/%i/size.orig.h", i); e_db_int_get(db, buf, &(bl->size.orig.h)); - sprintf(buf, "/layers/%i/fill.w", i); e_db_float_get(db, buf, &(bl->fill.w)); - sprintf(buf, "/layers/%i/fill.h", i); e_db_float_get(db, buf, &(bl->fill.h)); - sprintf(buf, "/layers/%i/fill.orig.w", i); e_db_int_get(db, buf, &(bl->fill.orig.w)); - sprintf(buf, "/layers/%i/fill.orig.h", i); e_db_int_get(db, buf, &(bl->fill.orig.h)); - sprintf(buf, "/layers/%i/angle", i); e_db_float_get(db, buf, (float*)&(bl->angle)); - sprintf(buf, "/layers/%i/fg.r", i); e_db_int_get(db, buf, &(bl->fg.r)); - sprintf(buf, "/layers/%i/fg.g", i); e_db_int_get(db, buf, &(bl->fg.g)); - sprintf(buf, "/layers/%i/fg.b", i); e_db_int_get(db, buf, &(bl->fg.b)); - sprintf(buf, "/layers/%i/fg.a", i); e_db_int_get(db, buf, &(bl->fg.a)); - sprintf(buf, "/layers/%i/bg.r", i); e_db_int_get(db, buf, &(bl->bg.r)); - sprintf(buf, "/layers/%i/bg.g", i); e_db_int_get(db, buf, &(bl->bg.g)); - sprintf(buf, "/layers/%i/bg.b", i); e_db_int_get(db, buf, &(bl->bg.b)); - sprintf(buf, "/layers/%i/bg.a", i); e_db_int_get(db, buf, &(bl->bg.a)); - } - return bg; -} - -void -e_background_realize(E_Background *bg, Evas evas) -{ - Evas_List l; - int ww, hh, count; - - if (bg->evas) return; - bg->evas = evas; - if (!bg->evas) return; - for (count = 0, l = bg->layers; l; l = l->next, count++) - { - E_Background_Layer *bl; - - bl = l->data; - if (bl->type == 0) /* 0 == image */ - { - bl->obj = evas_add_image_from_file(bg->evas, bl->file); - evas_set_layer(bg->evas, bl->obj, 0); - evas_show(bg->evas, bl->obj); -#if 0 /* dont need this... do we? */ - if (evas_get_image_alpha(bg->evas, bl->obj)) - { - printf("Adding rectangle to bg!\n"); - bg->base_obj = evas_add_rectangle(bg->evas); - evas_lower(bg->evas, bg->base_obj); - evas_move(bg->evas, bg->base_obj, 0, 0); - evas_resize(bg->evas, bg->base_obj, 999999999, 999999999); - evas_set_color(bg->evas, bg->base_obj, 255, 255, 255, 255); - evas_show(bg->evas, bg->base_obj); - } -#endif - } - else if (bl->type == 1) /* 1 == gradient */ - { - } - else if (bl->type == 2) /* 2 == solid */ - { - } - } - ww = bg->geom.w; - hh = bg->geom.h; - bg->geom.w = 0; - bg->geom.h = 0; - e_background_set_size(bg, ww, hh); - -} - -void -e_background_set_scroll(E_Background *bg, int sx, int sy) -{ - Evas_List l; - - if ((bg->geom.sx == sx) && (bg->geom.sy == sy)) return; - bg->geom.sx = sx; - bg->geom.sy = sy; - if (!bg->evas) return; - for (l = bg->layers; l; l = l->next) - { - E_Background_Layer *bl; - - bl = l->data; - if (bl->type == 0) /* 0 == image */ - { - evas_set_image_fill(bg->evas, bl->obj, - (double)bg->geom.sx * bl->scroll.x, - (double)bg->geom.sy * bl->scroll.y, - bl->fw, bl->fh); - } - } -} - -void -e_background_set_size(E_Background *bg, int w, int h) -{ - Evas_List l; - - if ((bg->geom.w == w) && (bg->geom.h == h)) return; - bg->geom.w = w; - bg->geom.h = h; - for (l = bg->layers; l; l = l->next) - { - E_Background_Layer *bl; - double x, y, w, h, fw, fh; - int iw, ih; - - bl = l->data; - iw = 0; - ih = 0; - if (bg->evas) evas_get_image_size(bg->evas, bl->obj, &iw, &ih); - w = bl->size.w * (double)bg->geom.w; - h = bl->size.h * (double)bg->geom.h; - if (bl->size.orig.w) w = (double)iw * bl->size.w; - if (bl->size.orig.h) h = (double)ih * bl->size.h; - fw = bl->fill.w * w; - fh = bl->fill.h * h; - if (bl->fill.orig.w) fw = (double)iw * bl->fill.w; - if (bl->fill.orig.h) fh = (double)ih * bl->fill.h; - x = ((double)bg->geom.w - w + 1) * bl->pos.x; - y = ((double)bg->geom.h - h + 1) * bl->pos.y; - bl->x = x; - bl->y = y; - bl->w = w; - bl->h = h; - bl->fw = fw; - bl->fh = fh; - if (bg->evas) - { - evas_move(bg->evas, bl->obj, bl->x, bl->y); - evas_resize(bg->evas, bl->obj, bl->w, bl->h); - if (bl->type == 0) /* 0 == image */ - { - evas_set_image_fill(bg->evas, bl->obj, - (double)bg->geom.sx * bl->scroll.x, - (double)bg->geom.sy * bl->scroll.y, - bl->fw, bl->fh); - } - else if (bl->type == 1) /* 1 == gradient */ - { - evas_set_angle(bg->evas, bl->obj, bl->angle); - } - else if (bl->type == 2) /* 2 == solid */ - { - } - } - } -} - -void -e_background_set_color_class(E_Background *bg, char *cc, int r, int g, int b, int a) -{ - Evas_List l; - - for (l = bg->layers; l; l = l->next) - { - E_Background_Layer *bl; - - bl = l->data; - if ((bl->color_class) && (cc) && (!strcmp(bl->color_class, cc))) - { - if (bg->evas) - { - if ((l == bg->layers) && (bg->base_obj)) - evas_set_color(bg->evas, bl->obj, r, g, b, 255); - else - evas_set_color(bg->evas, bl->obj, r, g, b, a); - } - } - } -} - -/* */ /* */ /* */ /* */ @@ -736,7 +425,7 @@ void setup(void) { int root_w, root_h; - E_Background *bg; + E_Background bg; ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_EXPOSE, window_expose); ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_MOVE, mouse_move); @@ -756,15 +445,16 @@ setup(void) 216, 1024 * 1024, 16 * 1024 * 1024, PACKAGE_DATA_DIR"/data/fonts/"); - bg = e_background_load(PACKAGE_DATA_DIR"/data/setup/setup.bg.db"); + bg = e_bg_load(PACKAGE_DATA_DIR"/data/setup/setup.bg.db"); if (!bg) { /* FIXME: must detect this error better and tell user */ printf("ERROR: Enlightenment not installed properly\n"); exit(-1); } - e_background_realize(bg, evas); - e_background_set_size(bg, root_w, root_h); + e_bg_add_to_evas(bg, evas); + e_bg_resize(bg, root_w, root_h); + e_bg_show(bg); pointer = evas_add_image_from_file(evas, PACKAGE_DATA_DIR"/data/setup/pointer.png"); evas_set_pass_events(evas, pointer, 1); @@ -810,6 +500,7 @@ setup(void) ); txz_button(txz, "OK", NULL, NULL); txz_button(txz, "Cancel", NULL, NULL); + } { Evas_Object o;