2004-04-10 12:39:02 -07:00
|
|
|
/*
|
2007-01-13 11:14:29 -08:00
|
|
|
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
|
|
|
|
* Copyright (C) 2004-2007 Kim Woelders
|
2004-04-10 12:39:02 -07:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to
|
|
|
|
* deal in the Software without restriction, including without limitation the
|
|
|
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
* sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies of the Software, its documentation and marketing & publicity
|
|
|
|
* materials, and acknowledgment shall be given in the documentation, materials
|
|
|
|
* and software packages that this Software was used.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
#include <time.h>
|
2004-12-28 15:46:49 -08:00
|
|
|
#include "E.h"
|
2005-10-24 09:05:30 -07:00
|
|
|
#include "backgrounds.h"
|
2005-09-04 00:27:20 -07:00
|
|
|
#include "desktops.h"
|
2005-10-29 01:48:40 -07:00
|
|
|
#include "dialog.h"
|
2006-02-18 00:30:09 -08:00
|
|
|
#include "e16-ecore_list.h"
|
2006-03-29 11:13:17 -08:00
|
|
|
#include "eimage.h"
|
2005-07-16 09:57:45 -07:00
|
|
|
#include "emodule.h"
|
2006-07-24 14:10:59 -07:00
|
|
|
#include "file.h"
|
2005-09-26 10:32:10 -07:00
|
|
|
#include "iclass.h"
|
2007-01-16 17:10:44 -08:00
|
|
|
#include "settings.h"
|
2005-09-26 10:32:10 -07:00
|
|
|
#include "tclass.h"
|
2006-04-16 06:27:38 -07:00
|
|
|
#include "timers.h"
|
2005-07-16 09:57:45 -07:00
|
|
|
#include "xwin.h"
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
char *file;
|
|
|
|
char *real_file;
|
2006-03-29 11:13:17 -08:00
|
|
|
EImage *im;
|
2004-12-28 15:46:49 -08:00
|
|
|
char keep_aspect;
|
|
|
|
int xjust, yjust;
|
|
|
|
int xperc, yperc;
|
|
|
|
} BgPart;
|
|
|
|
|
|
|
|
struct _background
|
|
|
|
{
|
|
|
|
char *name;
|
|
|
|
Pixmap pmap;
|
|
|
|
time_t last_viewed;
|
|
|
|
XColor bg_solid;
|
|
|
|
char bg_tile;
|
|
|
|
BgPart bg;
|
|
|
|
BgPart top;
|
2005-04-15 16:59:59 -07:00
|
|
|
#if ENABLE_COLOR_MODIFIERS
|
2004-12-28 15:46:49 -08:00
|
|
|
ColorModifierClass *cmclass;
|
2005-04-15 16:59:59 -07:00
|
|
|
#endif
|
2006-02-20 10:56:36 -08:00
|
|
|
char external;
|
2004-12-28 15:46:49 -08:00
|
|
|
char keepim;
|
2006-12-26 14:39:13 -08:00
|
|
|
char referenced;
|
2006-02-27 11:14:25 -08:00
|
|
|
unsigned int ref_count;
|
|
|
|
unsigned int seq_no;
|
2004-12-28 15:46:49 -08:00
|
|
|
};
|
2004-04-10 12:39:02 -07:00
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
static Ecore_List *bg_list = NULL;
|
2006-02-27 11:14:25 -08:00
|
|
|
static unsigned int bg_seq_no = 0;
|
2006-02-18 00:30:09 -08:00
|
|
|
|
2006-03-01 13:57:50 -08:00
|
|
|
#define N_BG_ASSIGNED 32
|
|
|
|
static Background *bg_assigned[N_BG_ASSIGNED];
|
|
|
|
|
2004-04-10 12:39:02 -07:00
|
|
|
char *
|
2005-11-27 03:02:05 -08:00
|
|
|
BackgroundGetUniqueString(const Background * bg)
|
2004-04-10 12:39:02 -07:00
|
|
|
{
|
|
|
|
char s[256];
|
|
|
|
const char *chmap =
|
|
|
|
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_";
|
|
|
|
int r, g, b;
|
|
|
|
int n1, n2, n3, n4, n5, f1, f2, f3, f4, f5, f6;
|
|
|
|
|
|
|
|
EGetColor(&(bg->bg_solid), &r, &g, &b);
|
|
|
|
n1 = (r << 24) | (g << 16) | (b << 8) | (bg->bg_tile << 7)
|
|
|
|
| (bg->bg.keep_aspect << 6) | (bg->top.keep_aspect << 5);
|
|
|
|
n2 = (bg->bg.xjust << 16) | (bg->bg.yjust);
|
|
|
|
n3 = (bg->bg.xperc << 16) | (bg->bg.yperc);
|
|
|
|
n4 = (bg->top.xjust << 16) | (bg->top.yjust);
|
|
|
|
n5 = (bg->top.xperc << 16) | (bg->top.yperc);
|
|
|
|
f1 = 0;
|
|
|
|
f2 = 0;
|
|
|
|
f3 = 0;
|
|
|
|
f4 = 0;
|
|
|
|
f5 = 0;
|
|
|
|
f6 = 0;
|
|
|
|
if (bg->bg.file)
|
|
|
|
{
|
|
|
|
char *f;
|
|
|
|
|
2005-07-17 05:55:13 -07:00
|
|
|
f = ThemeFileFind(bg->bg.file, 0);
|
2004-04-10 12:39:02 -07:00
|
|
|
if (f)
|
|
|
|
{
|
|
|
|
f1 = fileinode(f);
|
|
|
|
f2 = filedev(f);
|
|
|
|
f3 = (int)moddate(f);
|
|
|
|
Efree(f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (bg->top.file)
|
|
|
|
{
|
|
|
|
char *f;
|
|
|
|
|
2005-07-17 05:55:13 -07:00
|
|
|
f = ThemeFileFind(bg->top.file, 0);
|
2004-04-10 12:39:02 -07:00
|
|
|
if (f)
|
|
|
|
{
|
|
|
|
f4 = fileinode(f);
|
|
|
|
f5 = filedev(f);
|
|
|
|
f6 = (int)moddate(f);
|
|
|
|
Efree(f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Esnprintf(s, sizeof(s),
|
|
|
|
"%c%c%c%c%c%c" "%c%c%c%c%c%c" "%c%c%c%c%c%c" "%c%c%c%c%c%c"
|
|
|
|
"%c%c%c%c%c%c" "%c%c%c%c%c%c" "%c%c%c%c%c%c" "%c%c%c%c%c%c"
|
|
|
|
"%c%c%c%c%c%c" "%c%c%c%c%c%c" "%c%c%c%c%c%c",
|
|
|
|
chmap[(n1 >> 0) & 0x3f], chmap[(n1 >> 6) & 0x3f],
|
|
|
|
chmap[(n1 >> 12) & 0x3f], chmap[(n1 >> 18) & 0x3f],
|
|
|
|
chmap[(n1 >> 24) & 0x3f], chmap[(n1 >> 28) & 0x3f],
|
|
|
|
chmap[(n2 >> 0) & 0x3f], chmap[(n2 >> 6) & 0x3f],
|
|
|
|
chmap[(n2 >> 12) & 0x3f], chmap[(n2 >> 18) & 0x3f],
|
|
|
|
chmap[(n2 >> 24) & 0x3f], chmap[(n2 >> 28) & 0x3f],
|
|
|
|
chmap[(n3 >> 0) & 0x3f], chmap[(n3 >> 6) & 0x3f],
|
|
|
|
chmap[(n3 >> 12) & 0x3f], chmap[(n3 >> 18) & 0x3f],
|
|
|
|
chmap[(n3 >> 24) & 0x3f], chmap[(n3 >> 28) & 0x3f],
|
|
|
|
chmap[(n4 >> 0) & 0x3f], chmap[(n4 >> 6) & 0x3f],
|
|
|
|
chmap[(n4 >> 12) & 0x3f], chmap[(n4 >> 18) & 0x3f],
|
|
|
|
chmap[(n4 >> 24) & 0x3f], chmap[(n4 >> 28) & 0x3f],
|
|
|
|
chmap[(n5 >> 0) & 0x3f], chmap[(n5 >> 6) & 0x3f],
|
|
|
|
chmap[(n5 >> 12) & 0x3f], chmap[(n5 >> 18) & 0x3f],
|
|
|
|
chmap[(n5 >> 24) & 0x3f], chmap[(n5 >> 28) & 0x3f],
|
|
|
|
chmap[(f1 >> 0) & 0x3f], chmap[(f1 >> 6) & 0x3f],
|
|
|
|
chmap[(f1 >> 12) & 0x3f], chmap[(f1 >> 18) & 0x3f],
|
|
|
|
chmap[(f1 >> 24) & 0x3f], chmap[(f1 >> 28) & 0x3f],
|
|
|
|
chmap[(f2 >> 0) & 0x3f], chmap[(f2 >> 6) & 0x3f],
|
|
|
|
chmap[(f2 >> 12) & 0x3f], chmap[(f2 >> 18) & 0x3f],
|
|
|
|
chmap[(f2 >> 24) & 0x3f], chmap[(f2 >> 28) & 0x3f],
|
|
|
|
chmap[(f3 >> 0) & 0x3f], chmap[(f3 >> 6) & 0x3f],
|
|
|
|
chmap[(f3 >> 12) & 0x3f], chmap[(f3 >> 18) & 0x3f],
|
|
|
|
chmap[(f3 >> 24) & 0x3f], chmap[(f3 >> 28) & 0x3f],
|
|
|
|
chmap[(f4 >> 0) & 0x3f], chmap[(f4 >> 6) & 0x3f],
|
|
|
|
chmap[(f4 >> 12) & 0x3f], chmap[(f4 >> 18) & 0x3f],
|
|
|
|
chmap[(f4 >> 24) & 0x3f], chmap[(f4 >> 28) & 0x3f],
|
|
|
|
chmap[(f5 >> 0) & 0x3f], chmap[(f5 >> 6) & 0x3f],
|
|
|
|
chmap[(f5 >> 12) & 0x3f], chmap[(f5 >> 18) & 0x3f],
|
|
|
|
chmap[(f5 >> 24) & 0x3f], chmap[(f5 >> 28) & 0x3f],
|
|
|
|
chmap[(f6 >> 0) & 0x3f], chmap[(f6 >> 6) & 0x3f],
|
|
|
|
chmap[(f6 >> 12) & 0x3f], chmap[(f6 >> 18) & 0x3f],
|
|
|
|
chmap[(f6 >> 24) & 0x3f], chmap[(f6 >> 28) & 0x3f]);
|
|
|
|
return Estrdup(s);
|
|
|
|
}
|
|
|
|
|
2004-04-12 01:28:34 -07:00
|
|
|
void
|
2005-11-27 03:02:05 -08:00
|
|
|
BackgroundPixmapSet(Background * bg, Pixmap pmap)
|
|
|
|
{
|
2006-02-27 11:14:25 -08:00
|
|
|
if (bg->pmap != None && bg->pmap != pmap)
|
|
|
|
Eprintf("*** BackgroundPixmapSet %s: pmap was set %#lx/%#lx\n",
|
|
|
|
bg->name, bg->pmap, pmap);
|
|
|
|
bg->pmap = pmap;
|
2005-11-27 03:02:05 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-04-12 01:28:34 -07:00
|
|
|
BackgroundPixmapFree(Background * bg)
|
|
|
|
{
|
2005-11-27 03:02:05 -08:00
|
|
|
if (bg->pmap)
|
2004-04-12 01:28:34 -07:00
|
|
|
{
|
2006-03-29 11:13:17 -08:00
|
|
|
EImagePixmapFree(bg->pmap);
|
2005-11-27 03:02:05 -08:00
|
|
|
bg->pmap = None;
|
2004-04-12 01:28:34 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-27 03:02:05 -08:00
|
|
|
static void
|
|
|
|
BackgroundImagesFree(Background * bg)
|
2004-04-10 12:39:02 -07:00
|
|
|
{
|
|
|
|
if (bg->bg.im)
|
|
|
|
{
|
2006-03-29 11:13:17 -08:00
|
|
|
EImageFree(bg->bg.im);
|
2004-04-10 12:39:02 -07:00
|
|
|
bg->bg.im = NULL;
|
|
|
|
}
|
|
|
|
if (bg->top.im)
|
|
|
|
{
|
2006-03-29 11:13:17 -08:00
|
|
|
EImageFree(bg->top.im);
|
2004-04-10 12:39:02 -07:00
|
|
|
bg->top.im = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
static void
|
2004-04-12 01:28:34 -07:00
|
|
|
BackgroundImagesKeep(Background * bg, int onoff)
|
2004-04-10 12:39:02 -07:00
|
|
|
{
|
|
|
|
if (onoff)
|
|
|
|
{
|
|
|
|
bg->keepim = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bg->keepim = 0;
|
2005-11-27 03:02:05 -08:00
|
|
|
BackgroundImagesFree(bg);
|
2004-04-10 12:39:02 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
static void
|
2005-11-27 03:02:05 -08:00
|
|
|
BackgroundFilesRemove(Background * bg)
|
2004-04-10 12:39:02 -07:00
|
|
|
{
|
|
|
|
if (bg->bg.file)
|
|
|
|
Efree(bg->bg.file);
|
|
|
|
bg->bg.file = NULL;
|
|
|
|
|
|
|
|
if (bg->bg.real_file)
|
|
|
|
Efree(bg->bg.real_file);
|
|
|
|
bg->bg.real_file = NULL;
|
|
|
|
|
2004-04-12 01:28:34 -07:00
|
|
|
if (bg->top.file)
|
|
|
|
Efree(bg->top.file);
|
|
|
|
bg->top.file = NULL;
|
|
|
|
|
|
|
|
if (bg->top.real_file)
|
|
|
|
Efree(bg->top.real_file);
|
|
|
|
bg->top.real_file = NULL;
|
|
|
|
|
2005-11-27 03:02:05 -08:00
|
|
|
BackgroundImagesFree(bg);
|
2004-04-10 12:39:02 -07:00
|
|
|
|
|
|
|
bg->keepim = 0;
|
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
static int
|
2004-04-10 12:39:02 -07:00
|
|
|
BackgroundDestroy(Background * bg)
|
|
|
|
{
|
|
|
|
if (!bg)
|
2005-01-25 13:58:28 -08:00
|
|
|
return -1;
|
2004-04-10 12:39:02 -07:00
|
|
|
|
|
|
|
if (bg->ref_count > 0)
|
|
|
|
{
|
2006-12-09 13:32:03 -08:00
|
|
|
DialogOK("Background Error!", _("%u references remain\n"),
|
2004-04-10 12:39:02 -07:00
|
|
|
bg->ref_count);
|
2005-01-25 13:58:28 -08:00
|
|
|
return -1;
|
2004-04-10 12:39:02 -07:00
|
|
|
}
|
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
ecore_list_remove_node(bg_list, bg);
|
|
|
|
|
2005-11-27 03:02:05 -08:00
|
|
|
BackgroundFilesRemove(bg);
|
|
|
|
BackgroundPixmapFree(bg);
|
2004-04-10 12:39:02 -07:00
|
|
|
|
|
|
|
if (bg->name)
|
|
|
|
Efree(bg->name);
|
|
|
|
|
|
|
|
Efree(bg);
|
|
|
|
|
2005-01-25 13:58:28 -08:00
|
|
|
return 0;
|
2004-04-12 01:28:34 -07:00
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
static void
|
2004-04-12 01:28:34 -07:00
|
|
|
BackgroundDelete(Background * bg)
|
|
|
|
{
|
|
|
|
char *f;
|
|
|
|
|
|
|
|
if (BackgroundDestroy(bg))
|
2005-01-25 13:58:28 -08:00
|
|
|
return;
|
2004-04-12 01:28:34 -07:00
|
|
|
|
|
|
|
/* And delete the actual image files */
|
|
|
|
if (bg->bg.file)
|
|
|
|
{
|
2005-07-17 05:55:13 -07:00
|
|
|
f = ThemeFileFind(bg->bg.file, 0);
|
2004-04-12 01:28:34 -07:00
|
|
|
if (f)
|
|
|
|
{
|
|
|
|
E_rm(f);
|
|
|
|
Efree(f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (bg->top.file)
|
|
|
|
{
|
2005-07-17 05:55:13 -07:00
|
|
|
f = ThemeFileFind(bg->top.file, 0);
|
2004-04-12 01:28:34 -07:00
|
|
|
if (f)
|
|
|
|
{
|
|
|
|
E_rm(f);
|
|
|
|
Efree(f);
|
|
|
|
}
|
|
|
|
}
|
2004-04-10 12:39:02 -07:00
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
static Background *
|
2004-04-12 01:28:34 -07:00
|
|
|
BackgroundCreate(const char *name, XColor * solid, const char *bgn, char tile,
|
2004-04-10 12:39:02 -07:00
|
|
|
char keep_aspect, int xjust, int yjust, int xperc,
|
|
|
|
int yperc, const char *top, char tkeep_aspect, int txjust,
|
|
|
|
int tyjust, int txperc, int typerc)
|
|
|
|
{
|
2004-04-12 01:28:34 -07:00
|
|
|
Background *bg;
|
2004-04-10 12:39:02 -07:00
|
|
|
|
2007-01-16 17:10:44 -08:00
|
|
|
bg = ECALLOC(Background, 1);
|
2004-04-12 01:28:34 -07:00
|
|
|
if (!bg)
|
2005-01-25 13:58:28 -08:00
|
|
|
return NULL;
|
|
|
|
|
2004-04-12 01:28:34 -07:00
|
|
|
bg->name = Estrdup(name);
|
2004-04-10 12:39:02 -07:00
|
|
|
|
2004-04-12 01:28:34 -07:00
|
|
|
ESetColor(&(bg->bg_solid), 160, 160, 160);
|
2004-04-10 12:39:02 -07:00
|
|
|
if (solid)
|
2004-04-12 01:28:34 -07:00
|
|
|
bg->bg_solid = *solid;
|
2006-02-20 10:56:36 -08:00
|
|
|
else
|
|
|
|
bg->external = 1;
|
2004-04-12 01:28:34 -07:00
|
|
|
if (bgn)
|
|
|
|
bg->bg.file = Estrdup(bgn);
|
|
|
|
bg->bg_tile = tile;
|
|
|
|
bg->bg.keep_aspect = keep_aspect;
|
|
|
|
bg->bg.xjust = xjust;
|
|
|
|
bg->bg.yjust = yjust;
|
|
|
|
bg->bg.xperc = xperc;
|
|
|
|
bg->bg.yperc = yperc;
|
|
|
|
|
2004-04-10 12:39:02 -07:00
|
|
|
if (top)
|
2004-04-12 01:28:34 -07:00
|
|
|
bg->top.file = Estrdup(top);
|
|
|
|
bg->top.keep_aspect = tkeep_aspect;
|
|
|
|
bg->top.xjust = txjust;
|
|
|
|
bg->top.yjust = tyjust;
|
|
|
|
bg->top.xperc = txperc;
|
|
|
|
bg->top.yperc = typerc;
|
|
|
|
|
2006-02-27 11:14:25 -08:00
|
|
|
bg->seq_no = ++bg_seq_no;
|
|
|
|
|
2006-12-26 14:39:13 -08:00
|
|
|
if (!bg_list)
|
|
|
|
bg_list = ecore_list_new();
|
|
|
|
ecore_list_prepend(bg_list, bg);
|
|
|
|
|
2005-01-25 13:58:28 -08:00
|
|
|
return bg;
|
2004-04-12 01:28:34 -07:00
|
|
|
}
|
|
|
|
|
2006-12-26 14:39:13 -08:00
|
|
|
static int
|
|
|
|
BackgroundCmp(Background * bg, Background * bgx)
|
|
|
|
{
|
|
|
|
if (bg->bg.file && bgx->bg.file)
|
|
|
|
{
|
|
|
|
if ((strcmp(bg->bg.file, bgx->bg.file)) ||
|
|
|
|
(bg->bg.keep_aspect != bgx->bg.keep_aspect) ||
|
|
|
|
(bg->bg.xjust != bgx->bg.xjust || bg->bg.xjust != bgx->bg.xjust) ||
|
|
|
|
(bg->bg.xperc != bgx->bg.xperc || bg->bg.xperc != bgx->bg.xperc))
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if (bg->bg.file || bgx->bg.file)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
if (bg->top.file && bgx->top.file)
|
|
|
|
{
|
|
|
|
if ((strcmp(bg->top.file, bgx->top.file)) ||
|
|
|
|
(bg->top.keep_aspect != bgx->top.keep_aspect) ||
|
|
|
|
(bg->top.xjust != bgx->top.xjust ||
|
|
|
|
bg->top.xjust != bgx->top.xjust) ||
|
|
|
|
(bg->top.xperc != bgx->top.xperc ||
|
|
|
|
bg->top.xperc != bgx->top.xperc))
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if (bg->top.file || bgx->top.file)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
if ((bg->bg_solid.red != bgx->bg_solid.red) ||
|
|
|
|
(bg->bg_solid.green != bgx->bg_solid.green) ||
|
|
|
|
(bg->bg_solid.blue != bgx->bg_solid.blue))
|
|
|
|
return 1;
|
|
|
|
if (bg->bg_tile != bgx->bg_tile)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
static int
|
|
|
|
_BackgroundMatchName(const void *data, const void *match)
|
|
|
|
{
|
2007-01-16 17:10:44 -08:00
|
|
|
return strcmp(((const Background *)data)->name, (const char *)match);
|
2006-02-18 00:30:09 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
Background *
|
|
|
|
BackgroundFind(const char *name)
|
|
|
|
{
|
2007-01-16 17:10:44 -08:00
|
|
|
return (Background *) ecore_list_find(bg_list, _BackgroundMatchName, name);
|
2006-02-18 00:30:09 -08:00
|
|
|
}
|
|
|
|
|
2006-03-01 13:57:50 -08:00
|
|
|
static Background *
|
2006-02-18 00:30:09 -08:00
|
|
|
BackgroundCheck(Background * bg)
|
|
|
|
{
|
2007-01-16 17:10:44 -08:00
|
|
|
return (Background *) ecore_list_goto(bg_list, bg);
|
2006-02-18 00:30:09 -08:00
|
|
|
}
|
|
|
|
|
2004-04-12 01:28:34 -07:00
|
|
|
void
|
|
|
|
BackgroundDestroyByName(const char *name)
|
|
|
|
{
|
2006-02-18 00:30:09 -08:00
|
|
|
BackgroundDestroy(BackgroundFind(name));
|
2004-04-10 12:39:02 -07:00
|
|
|
}
|
|
|
|
|
2005-11-27 03:02:05 -08:00
|
|
|
static void
|
|
|
|
BackgroundInvalidate(Background * bg, int refresh)
|
|
|
|
{
|
|
|
|
BackgroundPixmapFree(bg);
|
2006-02-27 11:14:25 -08:00
|
|
|
bg->seq_no = ++bg_seq_no;
|
|
|
|
if (bg->ref_count && refresh)
|
|
|
|
DesksBackgroundRefresh(bg, DESK_BG_REFRESH);
|
2005-11-27 03:02:05 -08:00
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
static int
|
|
|
|
BackgroundModify(Background * bg, XColor * solid, const char *bgn, char tile,
|
|
|
|
char keep_aspect, int xjust, int yjust, int xperc,
|
|
|
|
int yperc, const char *top, char tkeep_aspect, int txjust,
|
|
|
|
int tyjust, int txperc, int typerc)
|
|
|
|
{
|
|
|
|
int updated = 0;
|
|
|
|
|
|
|
|
if (solid->red != bg->bg_solid.red)
|
|
|
|
updated = 1;
|
|
|
|
if (solid->green != bg->bg_solid.green)
|
|
|
|
updated = 1;
|
|
|
|
if (solid->blue != bg->bg_solid.blue)
|
|
|
|
updated = 1;
|
|
|
|
bg->bg_solid = *solid;
|
|
|
|
|
|
|
|
if ((bg->bg.file) && (bgn))
|
|
|
|
{
|
|
|
|
if (strcmp(bg->bg.file, bgn))
|
|
|
|
updated = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
updated = 1;
|
|
|
|
if (bg->bg.file)
|
|
|
|
Efree(bg->bg.file);
|
|
|
|
bg->bg.file = (bgn[0]) ? Estrdup(bgn) : NULL;
|
|
|
|
if ((int)tile != bg->bg_tile)
|
|
|
|
updated = 1;
|
|
|
|
if ((int)keep_aspect != bg->bg.keep_aspect)
|
|
|
|
updated = 1;
|
|
|
|
if (xjust != bg->bg.xjust)
|
|
|
|
updated = 1;
|
|
|
|
if (yjust != bg->bg.yjust)
|
|
|
|
updated = 1;
|
|
|
|
if (xperc != bg->bg.xperc)
|
|
|
|
updated = 1;
|
|
|
|
if (yperc != bg->bg.yperc)
|
|
|
|
updated = 1;
|
|
|
|
bg->bg_tile = (char)tile;
|
|
|
|
bg->bg.keep_aspect = (char)keep_aspect;
|
|
|
|
bg->bg.xjust = xjust;
|
|
|
|
bg->bg.yjust = yjust;
|
|
|
|
bg->bg.xperc = xperc;
|
|
|
|
bg->bg.yperc = yperc;
|
|
|
|
|
|
|
|
if ((bg->top.file) && (top))
|
|
|
|
{
|
|
|
|
if (strcmp(bg->top.file, top))
|
|
|
|
updated = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
updated = 1;
|
|
|
|
if (bg->top.file)
|
|
|
|
Efree(bg->top.file);
|
|
|
|
bg->top.file = (top[0]) ? Estrdup(top) : NULL;
|
|
|
|
if ((int)tkeep_aspect != bg->top.keep_aspect)
|
|
|
|
updated = 1;
|
|
|
|
if (txjust != bg->top.xjust)
|
|
|
|
updated = 1;
|
|
|
|
if (tyjust != bg->top.yjust)
|
|
|
|
updated = 1;
|
|
|
|
if (txperc != bg->top.xperc)
|
|
|
|
updated = 1;
|
|
|
|
if (typerc != bg->top.yperc)
|
|
|
|
updated = 1;
|
|
|
|
bg->top.keep_aspect = (char)tkeep_aspect;
|
|
|
|
bg->top.xjust = txjust;
|
|
|
|
bg->top.yjust = tyjust;
|
|
|
|
bg->top.xperc = txperc;
|
|
|
|
bg->top.yperc = typerc;
|
|
|
|
|
|
|
|
if (updated)
|
2005-11-27 03:02:05 -08:00
|
|
|
BackgroundInvalidate(bg, 1);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2005-01-25 13:58:28 -08:00
|
|
|
return updated;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
2005-04-15 16:59:59 -07:00
|
|
|
#if ENABLE_COLOR_MODIFIERS
|
2004-12-28 15:46:49 -08:00
|
|
|
static void
|
|
|
|
BackgroundSetColorMofifier(Background * bg, ColorModifierClass * cm)
|
|
|
|
{
|
|
|
|
cm->ref_count++;
|
|
|
|
bg->cmclass = cm;
|
|
|
|
}
|
2005-04-15 16:59:59 -07:00
|
|
|
#endif
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2004-04-10 12:39:02 -07:00
|
|
|
static void
|
2005-07-30 05:11:21 -07:00
|
|
|
BgFindImageSize(BgPart * bgp, unsigned int rw, unsigned int rh,
|
|
|
|
unsigned int *pw, unsigned int *ph)
|
2004-04-10 12:39:02 -07:00
|
|
|
{
|
2006-03-29 11:13:17 -08:00
|
|
|
int w, h, iw, ih;
|
|
|
|
|
|
|
|
EImageGetSize(bgp->im, &iw, &ih);
|
2004-04-10 12:39:02 -07:00
|
|
|
|
2006-01-05 14:20:00 -08:00
|
|
|
if (bgp->keep_aspect)
|
|
|
|
bgp->xperc = bgp->yperc;
|
|
|
|
|
2004-04-10 12:39:02 -07:00
|
|
|
if (bgp->xperc > 0)
|
2005-03-30 14:51:02 -08:00
|
|
|
w = (rw * bgp->xperc) >> 10;
|
2004-04-10 12:39:02 -07:00
|
|
|
else
|
2006-03-29 11:13:17 -08:00
|
|
|
w = (iw * rw) / VRoot.w;
|
2004-04-10 12:39:02 -07:00
|
|
|
|
|
|
|
if (bgp->yperc > 0)
|
2005-03-30 14:51:02 -08:00
|
|
|
h = (rh * bgp->yperc) >> 10;
|
2004-04-10 12:39:02 -07:00
|
|
|
else
|
2006-03-29 11:13:17 -08:00
|
|
|
h = (ih * rh) / VRoot.h;
|
2004-04-10 12:39:02 -07:00
|
|
|
|
|
|
|
if (w <= 0)
|
|
|
|
w = 1;
|
|
|
|
if (h <= 0)
|
|
|
|
h = 1;
|
|
|
|
|
|
|
|
if (bgp->keep_aspect)
|
|
|
|
{
|
|
|
|
if (bgp->yperc <= 0)
|
|
|
|
{
|
2006-03-29 11:13:17 -08:00
|
|
|
if (((w << 10) / h) != ((iw << 10) / ih))
|
|
|
|
h = ((w * ih) / iw);
|
2004-04-10 12:39:02 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-03-29 11:13:17 -08:00
|
|
|
if (((h << 10) / w) != ((ih << 10) / iw))
|
|
|
|
w = ((h * iw) / ih);
|
2004-04-10 12:39:02 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-30 05:11:21 -07:00
|
|
|
*pw = (unsigned int)w;
|
|
|
|
*ph = (unsigned int)h;
|
2004-04-10 12:39:02 -07:00
|
|
|
}
|
|
|
|
|
2005-08-13 01:50:28 -07:00
|
|
|
static Pixmap
|
2006-05-28 04:51:42 -07:00
|
|
|
BackgroundCreatePixmap(Win win, unsigned int w, unsigned int h)
|
2005-08-13 01:50:28 -07:00
|
|
|
{
|
|
|
|
Pixmap pmap;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Stupid hack to avoid that a new root pixmap has the same ID as the now
|
|
|
|
* invalid one from a previous session.
|
|
|
|
*/
|
2006-05-28 04:51:42 -07:00
|
|
|
pmap = ECreatePixmap(win, w, h, 0);
|
|
|
|
if (win == RRoot.win && pmap == Mode.root.ext_pmap)
|
2005-08-13 01:50:28 -07:00
|
|
|
{
|
|
|
|
EFreePixmap(pmap);
|
2006-05-28 04:51:42 -07:00
|
|
|
pmap = ECreatePixmap(win, w, h, 0);
|
2006-02-27 11:14:25 -08:00
|
|
|
Mode.root.ext_pmap = None;
|
|
|
|
Mode.root.ext_pmap_valid = 0;
|
2005-08-13 01:50:28 -07:00
|
|
|
}
|
|
|
|
return pmap;
|
|
|
|
}
|
|
|
|
|
2005-11-22 15:21:47 -08:00
|
|
|
void
|
2006-05-28 04:51:42 -07:00
|
|
|
BackgroundRealize(Background * bg, Win win, Drawable draw, unsigned int rw,
|
2005-11-22 15:21:47 -08:00
|
|
|
unsigned int rh, int is_win, Pixmap * ppmap,
|
|
|
|
unsigned long *ppixel)
|
2005-07-24 05:22:19 -07:00
|
|
|
{
|
|
|
|
Pixmap pmap;
|
|
|
|
GC gc;
|
2006-03-29 11:13:17 -08:00
|
|
|
int x, y, ww, hh;
|
|
|
|
unsigned int w, h;
|
2005-07-24 05:22:19 -07:00
|
|
|
char hasbg, hasfg;
|
2006-03-29 11:13:17 -08:00
|
|
|
EImage *im;
|
2005-04-15 16:59:59 -07:00
|
|
|
|
|
|
|
#if ENABLE_COLOR_MODIFIERS
|
2005-07-24 05:22:19 -07:00
|
|
|
ColorModifierClass *cm;
|
2005-04-15 16:59:59 -07:00
|
|
|
#endif
|
2004-04-10 12:39:02 -07:00
|
|
|
|
2005-07-24 05:22:19 -07:00
|
|
|
if (bg->bg.file && !bg->bg.im)
|
|
|
|
{
|
|
|
|
if (!bg->bg.real_file)
|
|
|
|
bg->bg.real_file = ThemeFileFind(bg->bg.file, 0);
|
2007-02-14 19:30:18 -08:00
|
|
|
if (bg->bg.real_file)
|
|
|
|
bg->bg.im = EImageLoad(bg->bg.real_file);
|
2005-07-24 05:22:19 -07:00
|
|
|
}
|
2004-04-10 12:39:02 -07:00
|
|
|
|
2005-07-24 05:22:19 -07:00
|
|
|
if (bg->top.file && !bg->top.im)
|
|
|
|
{
|
|
|
|
if (!bg->top.real_file)
|
|
|
|
bg->top.real_file = ThemeFileFind(bg->top.file, 0);
|
2007-02-14 19:30:18 -08:00
|
|
|
if (bg->top.real_file)
|
|
|
|
bg->top.im = EImageLoad(bg->top.real_file);
|
2005-07-24 05:22:19 -07:00
|
|
|
}
|
2004-04-10 12:39:02 -07:00
|
|
|
|
2005-04-15 16:59:59 -07:00
|
|
|
#if ENABLE_COLOR_MODIFIERS
|
2005-07-24 05:22:19 -07:00
|
|
|
cm = bg->cmclass;
|
|
|
|
if (cm)
|
|
|
|
cm->ref_count--;
|
|
|
|
else
|
|
|
|
cm = FindItem("BACKGROUND", 0, LIST_FINDBY_NAME, LIST_TYPE_COLORMODIFIER);
|
2004-04-10 12:39:02 -07:00
|
|
|
|
2005-07-24 05:22:19 -07:00
|
|
|
if (cm)
|
|
|
|
{
|
|
|
|
cm->ref_count++;
|
2004-07-25 02:34:43 -07:00
|
|
|
#if 0 /* To be implemented? */
|
2004-04-10 12:39:02 -07:00
|
|
|
if (bg->top.im)
|
2005-07-24 05:22:19 -07:00
|
|
|
{
|
|
|
|
Imlib_set_image_red_curve(pImlib_Context, bg->top.im, cm->red.map);
|
|
|
|
Imlib_set_image_green_curve(pImlib_Context, bg->top.im,
|
|
|
|
cm->green.map);
|
|
|
|
Imlib_set_image_blue_curve(pImlib_Context, bg->top.im,
|
|
|
|
cm->blue.map);
|
|
|
|
}
|
2004-04-10 12:39:02 -07:00
|
|
|
if (bg->bg.im)
|
|
|
|
{
|
2005-07-24 05:22:19 -07:00
|
|
|
Imlib_set_image_red_curve(pImlib_Context, bg->bg.im, cm->red.map);
|
|
|
|
Imlib_set_image_green_curve(pImlib_Context, bg->bg.im,
|
|
|
|
cm->green.map);
|
|
|
|
Imlib_set_image_blue_curve(pImlib_Context, bg->bg.im,
|
|
|
|
cm->blue.map);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif
|
2004-04-10 12:39:02 -07:00
|
|
|
|
2006-05-28 04:51:42 -07:00
|
|
|
if (!draw)
|
|
|
|
draw = WinGetXwin(win);
|
|
|
|
|
2005-07-24 05:22:19 -07:00
|
|
|
hasbg = bg->bg.im != NULL;
|
|
|
|
hasfg = bg->top.im != NULL;
|
2004-04-10 12:39:02 -07:00
|
|
|
|
2005-07-24 05:22:19 -07:00
|
|
|
if (!hasbg && !hasfg)
|
|
|
|
{
|
|
|
|
/* Solid color only */
|
2006-05-14 09:01:17 -07:00
|
|
|
EAllocColor(VRoot.cmap, &bg->bg_solid);
|
2004-04-10 12:39:02 -07:00
|
|
|
|
2005-11-22 15:21:47 -08:00
|
|
|
if (!is_win)
|
2004-04-10 12:39:02 -07:00
|
|
|
{
|
2006-04-17 14:55:34 -07:00
|
|
|
gc = EXCreateGC(draw, 0, NULL);
|
2005-07-24 05:22:19 -07:00
|
|
|
XSetClipMask(disp, gc, 0);
|
|
|
|
XSetFillStyle(disp, gc, FillSolid);
|
|
|
|
XSetForeground(disp, gc, bg->bg_solid.pixel);
|
|
|
|
XFillRectangle(disp, draw, gc, 0, 0, rw, rh);
|
2006-04-17 14:55:34 -07:00
|
|
|
EXFreeGC(gc);
|
2004-04-10 12:39:02 -07:00
|
|
|
}
|
2005-11-22 15:21:47 -08:00
|
|
|
if (ppmap)
|
|
|
|
*ppmap = None;
|
|
|
|
if (ppixel)
|
|
|
|
*ppixel = bg->bg_solid.pixel;
|
|
|
|
return;
|
2005-07-24 05:22:19 -07:00
|
|
|
}
|
2004-04-10 12:39:02 -07:00
|
|
|
|
2005-07-24 05:22:19 -07:00
|
|
|
/* Has either bg or fg image */
|
2004-04-10 12:39:02 -07:00
|
|
|
|
2005-07-24 05:22:19 -07:00
|
|
|
w = h = x = y = 0;
|
2004-04-10 12:39:02 -07:00
|
|
|
|
2005-07-24 05:22:19 -07:00
|
|
|
if (hasbg)
|
|
|
|
{
|
|
|
|
BgFindImageSize(&(bg->bg), rw, rh, &w, &h);
|
2006-01-05 14:20:00 -08:00
|
|
|
x = ((int)(rw - w) * bg->bg.xjust) >> 10;
|
|
|
|
y = ((int)(rh - h) * bg->bg.yjust) >> 10;
|
2005-07-24 05:22:19 -07:00
|
|
|
}
|
2004-04-10 12:39:02 -07:00
|
|
|
|
2005-07-24 05:22:19 -07:00
|
|
|
if (is_win && hasbg && !hasfg && x == 0 && y == 0 &&
|
|
|
|
((w == rw && h == rh) || (bg->bg_tile && !TransparencyEnabled())))
|
|
|
|
{
|
|
|
|
/* Window, no fg, no offset, and scale to 100%, or tiled, no trans */
|
2006-05-28 04:51:42 -07:00
|
|
|
pmap = BackgroundCreatePixmap(win, w, h);
|
|
|
|
EImageRenderOnDrawable(bg->bg.im, win, pmap, 0, 0, w, h, 0);
|
2004-04-10 12:39:02 -07:00
|
|
|
|
2005-11-22 15:21:47 -08:00
|
|
|
#if 0 /* FIXME - Remove? */
|
2005-10-30 11:40:49 -08:00
|
|
|
if (x == 0 && y == 0) /* Hmmm. Always true. */
|
2005-07-24 05:22:19 -07:00
|
|
|
{
|
|
|
|
ESetWindowBackgroundPixmap(draw, pmap);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-04-17 14:55:34 -07:00
|
|
|
gc = EXCreateGC(draw, 0, NULL);
|
2004-04-10 12:39:02 -07:00
|
|
|
XSetTile(disp, gc, pmap);
|
|
|
|
XSetTSOrigin(disp, gc, x, y);
|
|
|
|
XSetFillStyle(disp, gc, FillTiled);
|
2005-07-24 05:22:19 -07:00
|
|
|
XFillRectangle(disp, draw, gc, 0, 0, rw, rh);
|
2006-04-17 14:55:34 -07:00
|
|
|
EXFreeGC(gc);
|
2004-04-10 12:39:02 -07:00
|
|
|
}
|
2005-11-22 15:21:47 -08:00
|
|
|
#endif
|
2005-07-24 05:22:19 -07:00
|
|
|
goto done;
|
2004-04-10 12:39:02 -07:00
|
|
|
}
|
|
|
|
|
2005-07-24 05:22:19 -07:00
|
|
|
/* The rest that require some more work */
|
|
|
|
if (is_win)
|
2006-05-28 04:51:42 -07:00
|
|
|
pmap = BackgroundCreatePixmap(win, rw, rh);
|
2005-07-24 05:22:19 -07:00
|
|
|
else
|
|
|
|
pmap = draw;
|
|
|
|
|
2005-12-25 04:40:38 -08:00
|
|
|
if (hasbg && !hasfg && x == 0 && y == 0 && w == rw && h == rh)
|
2004-04-10 12:39:02 -07:00
|
|
|
{
|
2005-07-24 05:22:19 -07:00
|
|
|
im = bg->bg.im;
|
2004-04-10 12:39:02 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-07-24 05:22:19 -07:00
|
|
|
/* Create full size image */
|
2006-03-29 11:13:17 -08:00
|
|
|
im = EImageCreate(rw, rh);
|
|
|
|
EImageSetHasAlpha(im, 0);
|
2005-07-24 05:22:19 -07:00
|
|
|
if (!hasbg || !bg->bg_tile)
|
2004-04-10 12:39:02 -07:00
|
|
|
{
|
2005-07-24 05:22:19 -07:00
|
|
|
/* Fill solid */
|
2006-03-29 11:13:17 -08:00
|
|
|
EImageFill(im, 0, 0, rw, rh, bg->bg_solid.red, bg->bg_solid.green,
|
|
|
|
bg->bg_solid.blue, 255);
|
2004-04-10 12:39:02 -07:00
|
|
|
}
|
2005-07-24 05:22:19 -07:00
|
|
|
if (hasbg)
|
2004-04-10 12:39:02 -07:00
|
|
|
{
|
2005-07-24 05:22:19 -07:00
|
|
|
if (bg->bg_tile)
|
|
|
|
{
|
2006-03-29 11:13:17 -08:00
|
|
|
EImageTile(im, bg->bg.im, 0, w, h, 0, 0, rw, rh, x, y);
|
2005-07-24 05:22:19 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-03-29 11:13:17 -08:00
|
|
|
EImageGetSize(bg->bg.im, &ww, &hh);
|
|
|
|
EImageBlend(im, bg->bg.im, 0, 0, 0, ww, hh, x, y, w, h, 1, 0);
|
2005-07-24 05:22:19 -07:00
|
|
|
}
|
2004-04-10 12:39:02 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-24 05:22:19 -07:00
|
|
|
if (hasfg)
|
|
|
|
{
|
2006-03-29 11:13:17 -08:00
|
|
|
EImageGetSize(bg->top.im, &ww, &hh);
|
2005-07-24 05:22:19 -07:00
|
|
|
|
|
|
|
BgFindImageSize(&(bg->top), rw, rh, &w, &h);
|
|
|
|
x = ((rw - w) * bg->top.xjust) >> 10;
|
|
|
|
y = ((rh - h) * bg->top.yjust) >> 10;
|
|
|
|
|
2006-03-29 11:13:17 -08:00
|
|
|
EImageBlend(im, bg->top.im, 1, 0, 0, ww, hh, x, y, w, h, 0, 0);
|
2005-07-24 05:22:19 -07:00
|
|
|
}
|
|
|
|
|
2006-05-28 04:51:42 -07:00
|
|
|
EImageRenderOnDrawable(im, win, pmap, 0, 0, rw, rh, 0);
|
2005-07-24 05:22:19 -07:00
|
|
|
if (im != bg->bg.im)
|
2006-03-29 11:13:17 -08:00
|
|
|
EImageFree(im);
|
2005-07-24 05:22:19 -07:00
|
|
|
|
|
|
|
done:
|
|
|
|
if (!bg->keepim)
|
2005-11-27 03:02:05 -08:00
|
|
|
BackgroundImagesFree(bg);
|
2004-04-10 12:39:02 -07:00
|
|
|
|
2005-11-22 15:21:47 -08:00
|
|
|
if (ppmap)
|
|
|
|
*ppmap = pmap;
|
|
|
|
if (ppixel)
|
|
|
|
*ppixel = 0;
|
2005-07-24 05:22:19 -07:00
|
|
|
}
|
|
|
|
|
2005-11-21 09:48:44 -08:00
|
|
|
void
|
2006-05-28 04:51:42 -07:00
|
|
|
BackgroundApplyPmap(Background * bg, Win win, Drawable draw,
|
2005-11-21 09:48:44 -08:00
|
|
|
unsigned int w, unsigned int h)
|
|
|
|
{
|
2006-05-28 04:51:42 -07:00
|
|
|
BackgroundRealize(bg, win, draw, w, h, 0, NULL, NULL);
|
2005-11-22 15:21:47 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-04-29 12:39:21 -07:00
|
|
|
BackgroundApplyWin(Background * bg, Win win)
|
2005-11-22 15:21:47 -08:00
|
|
|
{
|
|
|
|
int w, h;
|
|
|
|
Pixmap pmap;
|
|
|
|
unsigned long pixel;
|
|
|
|
|
|
|
|
if (!EGetGeometry(win, NULL, NULL, NULL, &w, &h, NULL, NULL))
|
|
|
|
return;
|
|
|
|
|
2006-05-28 04:51:42 -07:00
|
|
|
BackgroundRealize(bg, win, None, w, h, 1, &pmap, &pixel);
|
2005-11-22 15:21:47 -08:00
|
|
|
if (pmap != None)
|
2005-11-27 03:02:05 -08:00
|
|
|
{
|
|
|
|
ESetWindowBackgroundPixmap(win, pmap);
|
2006-03-29 11:13:17 -08:00
|
|
|
EImagePixmapFree(pmap);
|
2005-11-27 03:02:05 -08:00
|
|
|
}
|
2005-11-22 15:21:47 -08:00
|
|
|
else
|
2005-11-27 03:02:05 -08:00
|
|
|
{
|
|
|
|
ESetWindowBackground(win, pixel);
|
|
|
|
}
|
2005-11-22 15:21:47 -08:00
|
|
|
EClearWindow(win);
|
2005-11-21 09:48:44 -08:00
|
|
|
}
|
|
|
|
|
2005-07-24 05:22:19 -07:00
|
|
|
/*
|
2005-11-22 15:21:47 -08:00
|
|
|
* Apply a background to window.
|
2005-11-27 03:02:05 -08:00
|
|
|
* The BG pixmap is stored in bg->pmap.
|
2005-07-24 05:22:19 -07:00
|
|
|
*/
|
|
|
|
void
|
2006-04-29 12:39:21 -07:00
|
|
|
BackgroundSet(Background * bg, Win win, unsigned int w, unsigned int h)
|
2005-07-24 05:22:19 -07:00
|
|
|
{
|
2006-04-09 02:26:15 -07:00
|
|
|
Pixmap pmap = None;
|
|
|
|
unsigned long pixel = 0;
|
2005-07-24 05:22:19 -07:00
|
|
|
|
|
|
|
if (bg->pmap)
|
|
|
|
pmap = bg->pmap;
|
|
|
|
else
|
2006-05-28 04:51:42 -07:00
|
|
|
BackgroundRealize(bg, win, None, w, h, 1, &pmap, &pixel);
|
2005-07-24 05:22:19 -07:00
|
|
|
|
|
|
|
bg->pmap = pmap;
|
|
|
|
if (pmap != None)
|
|
|
|
ESetWindowBackgroundPixmap(win, pmap);
|
|
|
|
else
|
2005-11-22 15:21:47 -08:00
|
|
|
ESetWindowBackground(win, pixel);
|
2005-07-24 05:22:19 -07:00
|
|
|
EClearWindow(win);
|
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
Background *
|
|
|
|
BrackgroundCreateFromImage(const char *bgid, const char *file,
|
|
|
|
char *thumb, int thlen)
|
|
|
|
{
|
|
|
|
Background *bg;
|
2006-03-29 11:13:17 -08:00
|
|
|
EImage *im, *im2;
|
2004-12-28 15:46:49 -08:00
|
|
|
XColor xclr;
|
|
|
|
char tile = 1, keep_asp = 0;
|
|
|
|
int width, height;
|
|
|
|
int scalex = 0, scaley = 0;
|
|
|
|
int scr_asp, im_asp;
|
|
|
|
int w2, h2;
|
|
|
|
int maxw = 48, maxh = 48;
|
|
|
|
int justx = 512, justy = 512;
|
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
bg = BackgroundFind(bgid);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2005-01-28 16:07:20 -08:00
|
|
|
if (thumb)
|
|
|
|
{
|
2005-07-24 11:29:50 -07:00
|
|
|
Esnprintf(thumb, thlen, "%s/cached/img/%s.png", EDirUserCache(), bgid);
|
2005-01-28 16:07:20 -08:00
|
|
|
if (bg && exists(thumb) && moddate(thumb) > moddate(file))
|
|
|
|
return bg;
|
|
|
|
/* The thumbnail is gone or outdated - regererate */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (bg)
|
|
|
|
return bg;
|
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2006-03-29 11:13:17 -08:00
|
|
|
im = EImageLoad(file);
|
2004-12-28 15:46:49 -08:00
|
|
|
if (!im)
|
|
|
|
return NULL;
|
|
|
|
|
2006-03-29 11:13:17 -08:00
|
|
|
EImageGetSize(im, &width, &height);
|
2005-01-28 16:07:20 -08:00
|
|
|
|
|
|
|
if (thumb)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2005-01-28 16:07:20 -08:00
|
|
|
h2 = maxh;
|
|
|
|
w2 = (width * h2) / height;
|
|
|
|
if (w2 > maxw)
|
|
|
|
{
|
|
|
|
w2 = maxw;
|
|
|
|
h2 = (height * w2) / width;
|
|
|
|
}
|
2006-03-29 11:13:17 -08:00
|
|
|
im2 = EImageCreateScaled(im, 0, 0, width, height, w2, h2);
|
|
|
|
EImageSave(im2, thumb);
|
|
|
|
EImageDecache(im2);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
2006-03-29 11:13:17 -08:00
|
|
|
EImageDecache(im);
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
/* Quit if the background itself already exists */
|
|
|
|
if (bg)
|
|
|
|
return bg;
|
|
|
|
|
|
|
|
scr_asp = (VRoot.w << 16) / VRoot.h;
|
|
|
|
im_asp = (width << 16) / height;
|
|
|
|
if (width == height)
|
|
|
|
{
|
|
|
|
justx = 0;
|
|
|
|
justy = 0;
|
|
|
|
scalex = 0;
|
|
|
|
scaley = 0;
|
|
|
|
tile = 1;
|
|
|
|
keep_asp = 0;
|
|
|
|
}
|
|
|
|
else if ((!(IN_RANGE(scr_asp, im_asp, 16000)))
|
|
|
|
&& ((width < 480) && (height < 360)))
|
|
|
|
{
|
|
|
|
justx = 0;
|
|
|
|
justy = 0;
|
|
|
|
scalex = 0;
|
|
|
|
scaley = 0;
|
|
|
|
tile = 1;
|
|
|
|
keep_asp = 0;
|
|
|
|
}
|
|
|
|
else if (IN_RANGE(scr_asp, im_asp, 16000))
|
|
|
|
{
|
|
|
|
justx = 0;
|
|
|
|
justy = 0;
|
|
|
|
scalex = 1024;
|
|
|
|
scaley = 1024;
|
|
|
|
tile = 0;
|
|
|
|
keep_asp = 0;
|
|
|
|
}
|
|
|
|
else if (im_asp > scr_asp)
|
|
|
|
{
|
|
|
|
justx = 512;
|
|
|
|
justy = 512;
|
|
|
|
scalex = 1024;
|
|
|
|
scaley = 0;
|
|
|
|
tile = 0;
|
|
|
|
keep_asp = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
justx = 512;
|
|
|
|
justy = 512;
|
|
|
|
scalex = 0;
|
|
|
|
scaley = 1024;
|
|
|
|
tile = 0;
|
|
|
|
keep_asp = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ESetColor(&xclr, 0, 0, 0);
|
|
|
|
|
|
|
|
bg = BackgroundCreate(bgid, &xclr, file, tile,
|
|
|
|
keep_asp, justx, justy,
|
|
|
|
scalex, scaley, NULL, 0, 0, 0, 0, 0);
|
|
|
|
|
|
|
|
return bg;
|
|
|
|
}
|
|
|
|
|
2004-04-12 01:28:34 -07:00
|
|
|
void
|
|
|
|
BackgroundIncRefcount(Background * bg)
|
|
|
|
{
|
|
|
|
if (bg == NULL)
|
|
|
|
return;
|
|
|
|
bg->ref_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
BackgroundDecRefcount(Background * bg)
|
|
|
|
{
|
|
|
|
if (bg == NULL)
|
|
|
|
return;
|
|
|
|
bg->ref_count--;
|
|
|
|
if (bg->ref_count <= 0)
|
|
|
|
bg->last_viewed = 0; /* Clean out asap */
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
BackgroundTouch(Background * bg)
|
|
|
|
{
|
|
|
|
if (bg == NULL)
|
|
|
|
return;
|
|
|
|
bg->last_viewed = time(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
BackgroundGetName(const Background * bg)
|
|
|
|
{
|
2004-12-28 15:46:49 -08:00
|
|
|
return bg->name;
|
2004-04-12 01:28:34 -07:00
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
static const char *
|
2004-08-08 14:32:19 -07:00
|
|
|
BackgroundGetBgFile(const Background * bg)
|
|
|
|
{
|
|
|
|
return bg->bg.file;
|
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
static const char *
|
|
|
|
BackgroundGetFgFile(const Background * bg)
|
|
|
|
{
|
|
|
|
return bg->top.file;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
BackgroundGetColor(const Background * bg)
|
|
|
|
{
|
|
|
|
return (bg->pmap) ? 0 : bg->bg_solid.pixel;
|
|
|
|
}
|
|
|
|
|
2004-04-12 01:28:34 -07:00
|
|
|
Pixmap
|
|
|
|
BackgroundGetPixmap(const Background * bg)
|
|
|
|
{
|
|
|
|
return (bg) ? bg->pmap : None;
|
|
|
|
}
|
|
|
|
|
2006-02-27 11:14:25 -08:00
|
|
|
unsigned int
|
|
|
|
BackgroundGetSeqNo(const Background * bg)
|
|
|
|
{
|
|
|
|
return bg->seq_no;
|
|
|
|
}
|
|
|
|
|
2005-10-24 09:05:30 -07:00
|
|
|
int
|
|
|
|
BackgroundIsNone(const Background * bg)
|
|
|
|
{
|
2006-02-20 10:56:36 -08:00
|
|
|
return (bg) ? bg->external : 1;
|
2005-10-24 09:05:30 -07:00
|
|
|
}
|
|
|
|
|
2006-03-29 11:13:17 -08:00
|
|
|
static EImage *
|
2005-07-26 09:58:31 -07:00
|
|
|
BackgroundCacheMini(Background * bg, int keep, int nuke)
|
2005-07-24 05:22:19 -07:00
|
|
|
{
|
|
|
|
char s[4096];
|
2006-03-29 11:13:17 -08:00
|
|
|
EImage *im;
|
2005-07-24 05:22:19 -07:00
|
|
|
Pixmap pmap;
|
|
|
|
|
2005-07-24 11:29:50 -07:00
|
|
|
Esnprintf(s, sizeof(s), "%s/cached/bgsel/%s.png", EDirUserCache(),
|
2005-07-24 05:22:19 -07:00
|
|
|
BackgroundGetName(bg));
|
2005-07-26 09:58:31 -07:00
|
|
|
|
2006-03-29 11:13:17 -08:00
|
|
|
im = EImageLoad(s);
|
2005-07-26 09:58:31 -07:00
|
|
|
if (im)
|
|
|
|
{
|
|
|
|
if (nuke)
|
2006-03-29 11:13:17 -08:00
|
|
|
EImageDecache(im);
|
2005-07-26 09:58:31 -07:00
|
|
|
else
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create new cached bg mini image */
|
2006-05-07 09:21:37 -07:00
|
|
|
pmap = ECreatePixmap(VRoot.win, 64, 48, 0);
|
2006-05-28 04:51:42 -07:00
|
|
|
BackgroundApplyPmap(bg, VRoot.win, pmap, 64, 48);
|
2006-03-29 11:13:17 -08:00
|
|
|
im = EImageGrabDrawable(pmap, None, 0, 0, 64, 48, 0);
|
|
|
|
EImageSave(im, s);
|
2005-07-26 09:58:31 -07:00
|
|
|
EFreePixmap(pmap);
|
2005-07-24 05:22:19 -07:00
|
|
|
|
2005-07-26 09:58:31 -07:00
|
|
|
done:
|
2005-07-24 05:22:19 -07:00
|
|
|
if (keep)
|
2005-07-26 09:58:31 -07:00
|
|
|
return im;
|
2006-03-29 11:13:17 -08:00
|
|
|
EImageFree(im);
|
2005-07-26 09:58:31 -07:00
|
|
|
return NULL;
|
2005-07-24 05:22:19 -07:00
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
#define S(str) ((str) ? str : "(null)")
|
|
|
|
static void
|
|
|
|
BackgroundGetInfoString1(const Background * bg, char *buf, int len)
|
|
|
|
{
|
|
|
|
int r, g, b;
|
|
|
|
|
|
|
|
EGetColor(&(bg->bg_solid), &r, &g, &b);
|
|
|
|
Esnprintf(buf, len,
|
|
|
|
"%s ref_count %u keepim %u\n"
|
|
|
|
" bg.solid\t %i %i %i \n"
|
|
|
|
" bg.file\t %s\n"
|
|
|
|
" top.file\t %s \n"
|
|
|
|
" bg.tile\t %i \n"
|
|
|
|
" bg.keep_aspect\t %i \ttop.keep_aspect\t %i \n"
|
|
|
|
" bg.xjust\t %i \ttop.xjust\t %i \n"
|
|
|
|
" bg.yjust\t %i \ttop.yjust\t %i \n"
|
|
|
|
" bg.xperc\t %i \ttop.xperc\t %i \n"
|
|
|
|
" bg.yperc\t %i \ttop.yperc\t %i \n", bg->name,
|
|
|
|
bg->ref_count, bg->keepim, r, g, b,
|
|
|
|
bg->bg.file, bg->top.file, bg->bg_tile,
|
|
|
|
bg->bg.keep_aspect, bg->top.keep_aspect,
|
|
|
|
bg->bg.xjust, bg->top.xjust, bg->bg.yjust,
|
|
|
|
bg->top.yjust, bg->bg.xperc, bg->top.xperc,
|
|
|
|
bg->bg.yperc, bg->top.yperc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
BackgroundGetInfoString2(const Background * bg, char *buf, int len)
|
|
|
|
{
|
|
|
|
int r, g, b;
|
|
|
|
|
|
|
|
EGetColor(&(bg->bg_solid), &r, &g, &b);
|
|
|
|
Esnprintf(buf, len,
|
|
|
|
"%s %i %i %i %s %i %i %i %i %i %i %s %i %i %i %i %i",
|
|
|
|
bg->name, r, g, b, S(bg->bg.file), bg->bg_tile,
|
|
|
|
bg->bg.keep_aspect, bg->bg.xjust, bg->bg.yjust,
|
|
|
|
bg->bg.xperc, bg->bg.yperc, S(bg->top.file),
|
|
|
|
bg->top.keep_aspect, bg->top.xjust, bg->top.yjust,
|
|
|
|
bg->top.xperc, bg->top.yperc);
|
|
|
|
}
|
|
|
|
|
2005-11-22 15:21:47 -08:00
|
|
|
void
|
2005-11-27 03:02:05 -08:00
|
|
|
BackgroundsInvalidate(int refresh)
|
2005-11-22 15:21:47 -08:00
|
|
|
{
|
2006-02-18 00:30:09 -08:00
|
|
|
Background *bg;
|
2005-11-22 15:21:47 -08:00
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
ECORE_LIST_FOR_EACH(bg_list, bg) BackgroundInvalidate(bg, refresh);
|
|
|
|
}
|
|
|
|
|
2006-03-01 13:57:50 -08:00
|
|
|
static Background *
|
2006-02-18 00:30:09 -08:00
|
|
|
BackgroundGetRandom(void)
|
|
|
|
{
|
|
|
|
Background *bg;
|
|
|
|
int num;
|
|
|
|
unsigned int rnd;
|
|
|
|
|
|
|
|
num = ecore_list_nodes(bg_list);
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
rnd = rand();
|
2007-01-16 17:10:44 -08:00
|
|
|
bg = (Background *) ecore_list_goto_index(bg_list, rnd % num);
|
2006-02-18 00:30:09 -08:00
|
|
|
if (num <= 1 || !BackgroundIsNone(bg))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return bg;
|
2005-11-22 15:21:47 -08:00
|
|
|
}
|
|
|
|
|
2006-03-01 13:57:50 -08:00
|
|
|
void
|
|
|
|
BackgroundSetForDesk(Background * bg, unsigned int desk)
|
|
|
|
{
|
|
|
|
if (desk >= N_BG_ASSIGNED)
|
|
|
|
return;
|
|
|
|
|
|
|
|
bg_assigned[desk] = bg;
|
|
|
|
}
|
|
|
|
|
|
|
|
Background *
|
|
|
|
BackgroundGetForDesk(unsigned int desk)
|
|
|
|
{
|
|
|
|
Background *bg;
|
|
|
|
|
|
|
|
if (desk >= N_BG_ASSIGNED)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
bg = bg_assigned[desk];
|
|
|
|
if (bg)
|
|
|
|
bg = BackgroundCheck(bg);
|
|
|
|
if (!bg)
|
|
|
|
bg = BackgroundGetRandom();
|
|
|
|
|
|
|
|
return bg;
|
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
/*
|
|
|
|
* Config load/save
|
|
|
|
*/
|
|
|
|
#include "conf.h"
|
|
|
|
|
2004-05-30 06:09:16 -07:00
|
|
|
int
|
2004-12-28 15:46:49 -08:00
|
|
|
BackgroundsConfigLoad(FILE * fs)
|
2004-05-30 06:09:16 -07:00
|
|
|
{
|
2004-12-28 15:46:49 -08:00
|
|
|
int err = 0;
|
|
|
|
Background *bg = 0;
|
|
|
|
XColor xclr;
|
|
|
|
char s[FILEPATH_LEN_MAX];
|
|
|
|
char s2[FILEPATH_LEN_MAX];
|
|
|
|
int ii1;
|
|
|
|
int r, g, b;
|
|
|
|
int i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0;
|
|
|
|
int j1 = 0, j2 = 0, j3 = 0, j4 = 0, j5 = 0;
|
|
|
|
char *bg1 = 0;
|
|
|
|
char *bg2 = 0;
|
|
|
|
char *name = 0;
|
|
|
|
char ignore = 0;
|
|
|
|
int fields;
|
2005-09-04 00:27:20 -07:00
|
|
|
unsigned int desk;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2005-04-15 16:59:59 -07:00
|
|
|
#if ENABLE_COLOR_MODIFIERS
|
|
|
|
ColorModifierClass *cm = NULL;
|
|
|
|
#endif
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
ESetColor(&xclr, 0, 0, 0);
|
|
|
|
|
|
|
|
while (GetLine(s, sizeof(s), fs))
|
|
|
|
{
|
|
|
|
s2[0] = 0;
|
|
|
|
ii1 = CONFIG_INVALID;
|
|
|
|
fields = sscanf(s, "%i %4000s", &ii1, s2);
|
|
|
|
|
|
|
|
if (fields < 1)
|
|
|
|
{
|
|
|
|
ii1 = CONFIG_INVALID;
|
|
|
|
}
|
|
|
|
else if (ii1 == CONFIG_CLOSE)
|
|
|
|
{
|
|
|
|
if (fields != 1)
|
|
|
|
{
|
|
|
|
RecoverUserConfig();
|
|
|
|
Alert(_("CONFIG: ignoring extra data in \"%s\"\n"), s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ii1 != CONFIG_INVALID)
|
|
|
|
{
|
|
|
|
if (fields != 2)
|
|
|
|
{
|
|
|
|
RecoverUserConfig();
|
|
|
|
Alert(_("CONFIG: missing required data in \"%s\"\n"), s);
|
|
|
|
ii1 = CONFIG_INVALID;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
switch (ii1)
|
|
|
|
{
|
|
|
|
case CONFIG_CLOSE:
|
|
|
|
if (!ignore)
|
|
|
|
{
|
|
|
|
if ((!bg) && (name))
|
|
|
|
{
|
|
|
|
char *tmp;
|
|
|
|
char ok = 1;
|
|
|
|
|
|
|
|
/* check first if we can actually find the files */
|
|
|
|
if (bg1)
|
|
|
|
{
|
2005-07-17 05:55:13 -07:00
|
|
|
tmp = ThemeFileFind(bg1, 0);
|
2004-12-28 15:46:49 -08:00
|
|
|
if (!tmp)
|
2005-07-24 05:22:19 -07:00
|
|
|
ok = 0;
|
2004-12-28 15:46:49 -08:00
|
|
|
else
|
2005-07-24 05:22:19 -07:00
|
|
|
Efree(tmp);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
if (bg2)
|
|
|
|
{
|
2005-07-17 05:55:13 -07:00
|
|
|
tmp = ThemeFileFind(bg2, 0);
|
2004-12-28 15:46:49 -08:00
|
|
|
if (!tmp)
|
2005-07-24 05:22:19 -07:00
|
|
|
ok = 0;
|
2004-12-28 15:46:49 -08:00
|
|
|
else
|
2005-07-24 05:22:19 -07:00
|
|
|
Efree(tmp);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
bg = BackgroundCreate(name, &xclr, bg1, i1, i2, i3,
|
|
|
|
i4, i5, i6, bg2, j1, j2, j3,
|
|
|
|
j4, j5);
|
2005-04-15 16:59:59 -07:00
|
|
|
#if ENABLE_COLOR_MODIFIERS
|
2004-12-28 15:46:49 -08:00
|
|
|
if (cm)
|
|
|
|
BackgroundSetColorMofifier(bg, cm);
|
2005-04-15 16:59:59 -07:00
|
|
|
#endif
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
case CONFIG_COLORMOD:
|
|
|
|
case ICLASS_COLORMOD:
|
2005-04-15 16:59:59 -07:00
|
|
|
#if ENABLE_COLOR_MODIFIERS
|
2004-12-28 15:46:49 -08:00
|
|
|
cm = FindItem(s2, 0, LIST_FINDBY_NAME, LIST_TYPE_COLORMODIFIER);
|
2005-04-15 16:59:59 -07:00
|
|
|
#endif
|
2004-12-28 15:46:49 -08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CONFIG_CLASSNAME:
|
|
|
|
case BG_NAME:
|
2006-02-18 00:30:09 -08:00
|
|
|
bg = BackgroundFind(s2);
|
2005-10-30 11:40:49 -08:00
|
|
|
if (bg)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
|
|
|
ignore = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (name)
|
|
|
|
Efree(name);
|
|
|
|
name = Estrdup(s2);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BG_DESKNUM:
|
2005-09-04 00:27:20 -07:00
|
|
|
desk = atoi(s2);
|
2006-03-01 13:57:50 -08:00
|
|
|
if (desk >= N_BG_ASSIGNED)
|
|
|
|
break;
|
|
|
|
if (!bg_assigned[desk] || Conf.backgrounds.user)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2006-03-01 13:57:50 -08:00
|
|
|
if (!ignore)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2006-03-01 13:57:50 -08:00
|
|
|
if (!bg)
|
|
|
|
bg = BackgroundCreate(name, &xclr, bg1, i1, i2,
|
|
|
|
i3, i4, i5, i6, bg2, j1,
|
|
|
|
j2, j3, j4, j5);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
2006-03-01 13:57:50 -08:00
|
|
|
bg_assigned[desk] = bg;
|
2006-12-26 14:39:13 -08:00
|
|
|
bg->referenced = 1;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BG_RGB:
|
|
|
|
r = g = b = 0;
|
|
|
|
sscanf(s, "%*s %d %d %d", &r, &g, &b);
|
|
|
|
ESetColor(&xclr, r, g, b);
|
|
|
|
if (ignore)
|
|
|
|
bg->bg_solid = xclr;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BG_BG1:
|
|
|
|
sscanf(s, "%*s %4000s %d %d %d %d %d %d", s2, &i1, &i2,
|
|
|
|
&i3, &i4, &i5, &i6);
|
|
|
|
if (!ignore)
|
|
|
|
{
|
|
|
|
if (bg1)
|
|
|
|
Efree(bg1);
|
|
|
|
bg1 = Estrdup(s2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (bg->bg.file)
|
|
|
|
Efree(bg->bg.file);
|
|
|
|
if (bg->top.file)
|
|
|
|
{
|
|
|
|
Efree(bg->top.file);
|
|
|
|
bg->top.file = NULL;
|
|
|
|
}
|
|
|
|
bg->bg.file = Estrdup(s2);
|
|
|
|
bg->bg_tile = i1;
|
|
|
|
bg->bg.keep_aspect = i2;
|
|
|
|
bg->bg.xjust = i3;
|
|
|
|
bg->bg.yjust = i4;
|
|
|
|
bg->bg.xperc = i5;
|
|
|
|
bg->bg.yperc = i6;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BG_BG2:
|
|
|
|
sscanf(s, "%*s %4000s %d %d %d %d %d", s2, &j1, &j2, &j3,
|
|
|
|
&j4, &j5);
|
|
|
|
if (!ignore)
|
|
|
|
{
|
|
|
|
if (bg2)
|
|
|
|
Efree(bg2);
|
|
|
|
bg2 = Estrdup(s2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bg->top.file = Estrdup(s2);
|
|
|
|
bg->top.keep_aspect = j1;
|
|
|
|
bg->top.xjust = j2;
|
|
|
|
bg->top.yjust = j3;
|
|
|
|
bg->top.xperc = j4;
|
|
|
|
bg->top.yperc = j5;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
err = -1;
|
|
|
|
|
|
|
|
done:
|
|
|
|
if (name)
|
|
|
|
Efree(name);
|
|
|
|
if (bg1)
|
|
|
|
Efree(bg1);
|
|
|
|
if (bg2)
|
|
|
|
Efree(bg2);
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2005-03-05 04:19:48 -08:00
|
|
|
static void
|
|
|
|
BackgroundsConfigLoadUser(void)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2005-03-05 04:19:48 -08:00
|
|
|
char s[4096];
|
|
|
|
|
|
|
|
Esnprintf(s, sizeof(s), "%s.backgrounds", EGetSavePrefix());
|
2005-04-23 01:07:32 -07:00
|
|
|
ConfigFileLoad(s, NULL, ConfigFileRead, 0);
|
2005-03-05 04:19:48 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
BackgroundsConfigSave(void)
|
|
|
|
{
|
|
|
|
char s[FILEPATH_LEN_MAX], st[FILEPATH_LEN_MAX];
|
|
|
|
FILE *fs;
|
2006-02-18 00:30:09 -08:00
|
|
|
Background *bg;
|
2005-09-04 00:27:20 -07:00
|
|
|
unsigned int j;
|
2006-02-18 00:30:09 -08:00
|
|
|
int i, num, r, g, b;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
num = ecore_list_nodes(bg_list);
|
2004-12-28 15:46:49 -08:00
|
|
|
if (num <= 0)
|
2005-03-05 04:19:48 -08:00
|
|
|
return;
|
|
|
|
|
|
|
|
Etmp(st);
|
|
|
|
fs = fopen(st, "w");
|
|
|
|
if (!fs)
|
|
|
|
return;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
for (i = num - 1; i >= 0; i--)
|
|
|
|
{
|
2007-01-16 17:10:44 -08:00
|
|
|
bg = (Background *) ecore_list_goto_index(bg_list, i);
|
2006-02-18 00:30:09 -08:00
|
|
|
if (!bg)
|
|
|
|
continue;
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
fprintf(fs, "5 999\n");
|
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
fprintf(fs, "100 %s\n", bg->name);
|
|
|
|
EGetColor(&(bg->bg_solid), &r, &g, &b);
|
2004-12-28 15:46:49 -08:00
|
|
|
fprintf(fs, "560 %d %d %d\n", r, g, b);
|
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
if ((bg->bg.file) && (!bg->bg.real_file))
|
|
|
|
bg->bg.real_file = ThemeFileFind(bg->bg.file, 0);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
if ((bg->top.file) && (!bg->top.real_file))
|
|
|
|
bg->top.real_file = ThemeFileFind(bg->top.file, 0);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
if ((bg->bg.file) && (bg->bg.real_file))
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
|
|
|
fprintf(fs, "561 %s %d %d %d %d %d %d\n",
|
2006-02-18 00:30:09 -08:00
|
|
|
bg->bg.real_file, bg->bg_tile,
|
|
|
|
bg->bg.keep_aspect, bg->bg.xjust,
|
|
|
|
bg->bg.yjust, bg->bg.xperc, bg->bg.yperc);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
2006-02-18 00:30:09 -08:00
|
|
|
else if (bg->bg.file)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
|
|
|
fprintf(fs, "561 %s %d %d %d %d %d %d\n",
|
2006-02-18 00:30:09 -08:00
|
|
|
bg->bg.file, bg->bg_tile,
|
|
|
|
bg->bg.keep_aspect, bg->bg.xjust,
|
|
|
|
bg->bg.yjust, bg->bg.xperc, bg->bg.yperc);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
if ((bg->top.file) && (bg->top.real_file))
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
|
|
|
fprintf(fs, "562 %s %d %d %d %d %d\n",
|
2006-02-18 00:30:09 -08:00
|
|
|
bg->top.real_file,
|
|
|
|
bg->top.keep_aspect, bg->top.xjust,
|
|
|
|
bg->top.yjust, bg->top.xperc, bg->top.yperc);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
2006-02-18 00:30:09 -08:00
|
|
|
else if (bg->top.file)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
|
|
|
fprintf(fs, "562 %s %d %d %d %d %d\n",
|
2006-02-18 00:30:09 -08:00
|
|
|
bg->top.file, bg->top.keep_aspect,
|
|
|
|
bg->top.xjust, bg->top.yjust, bg->top.xperc,
|
|
|
|
bg->top.yperc);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
2005-04-15 16:59:59 -07:00
|
|
|
#if ENABLE_COLOR_MODIFIERS
|
2006-02-18 00:30:09 -08:00
|
|
|
if (bg->cmclass)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2006-02-18 00:30:09 -08:00
|
|
|
fprintf(fs, "370 %s\n", bg->cmclass->name);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
2005-04-15 16:59:59 -07:00
|
|
|
#endif
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2006-03-01 13:57:50 -08:00
|
|
|
for (j = 0; j < N_BG_ASSIGNED; j++)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2006-03-01 13:57:50 -08:00
|
|
|
if (bg == bg_assigned[j])
|
2004-12-28 15:46:49 -08:00
|
|
|
fprintf(fs, "564 %d\n", j);
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(fs, "1000\n");
|
|
|
|
}
|
|
|
|
|
2005-03-05 04:19:48 -08:00
|
|
|
fclose(fs);
|
|
|
|
|
|
|
|
Esnprintf(s, sizeof(s), "%s.backgrounds", EGetSavePrefix());
|
|
|
|
E_mv(st, s);
|
2004-05-30 06:09:16 -07:00
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
/*
|
|
|
|
* Backgrounds module
|
|
|
|
*/
|
|
|
|
|
2006-12-26 14:39:13 -08:00
|
|
|
static void
|
|
|
|
BackgroundsCheckDups(void)
|
|
|
|
{
|
|
|
|
int ix;
|
|
|
|
Background *bg, *bgx;
|
|
|
|
|
|
|
|
for (ix = 0;; ix++)
|
|
|
|
{
|
|
|
|
ecore_list_goto_index(bg_list, ix);
|
2007-01-16 17:10:44 -08:00
|
|
|
bg = (Background *) ecore_list_next(bg_list);
|
2006-12-26 14:39:13 -08:00
|
|
|
if (!bg)
|
|
|
|
break;
|
2007-01-16 17:10:44 -08:00
|
|
|
for (; (bgx = (Background *) ecore_list_next(bg_list)) != NULL;)
|
2006-12-26 14:39:13 -08:00
|
|
|
{
|
|
|
|
if (bgx->ref_count > 0 || bgx->referenced)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (BackgroundCmp(bg, bgx))
|
|
|
|
continue;
|
|
|
|
#if 1 /* Remove? */
|
|
|
|
Eprintf("Remove duplicate background %s (==%s)\n", bgx->name,
|
|
|
|
bg->name);
|
|
|
|
#endif
|
|
|
|
BackgroundDestroy(bgx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
static void
|
2004-04-10 12:39:02 -07:00
|
|
|
BackgroundsAccounting(void)
|
|
|
|
{
|
2006-02-18 00:30:09 -08:00
|
|
|
Background *bg;
|
|
|
|
time_t now;
|
2004-04-12 01:28:34 -07:00
|
|
|
|
2006-02-27 11:14:25 -08:00
|
|
|
DesksBackgroundRefresh(NULL, DESK_BG_TIMEOUT);
|
2004-04-10 12:39:02 -07:00
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
now = time(NULL);
|
|
|
|
ECORE_LIST_FOR_EACH(bg_list, bg)
|
|
|
|
{
|
|
|
|
/* Skip if no pixmap or not timed out */
|
2006-02-27 11:14:25 -08:00
|
|
|
if (bg->pmap == None ||
|
|
|
|
((now - bg->last_viewed) <= Conf.backgrounds.timeout))
|
2006-02-18 00:30:09 -08:00
|
|
|
continue;
|
|
|
|
|
2006-04-16 11:34:57 -07:00
|
|
|
DesksBackgroundRefresh(bg, DESK_BG_FREE);
|
2006-02-18 00:30:09 -08:00
|
|
|
BackgroundPixmapFree(bg);
|
|
|
|
}
|
2004-04-10 12:39:02 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
BackgroundsTimeout(int val __UNUSED__, void *data __UNUSED__)
|
|
|
|
{
|
2006-02-11 09:05:08 -08:00
|
|
|
if (Conf.backgrounds.timeout <= 0)
|
|
|
|
Conf.backgrounds.timeout = 1;
|
|
|
|
|
2004-04-10 12:39:02 -07:00
|
|
|
BackgroundsAccounting();
|
2006-02-11 09:05:08 -08:00
|
|
|
|
2005-11-27 03:02:05 -08:00
|
|
|
DoIn("BACKGROUND_ACCOUNTING_TIMEOUT", 1.0 * Conf.backgrounds.timeout,
|
|
|
|
BackgroundsTimeout, 0, NULL);
|
2004-04-10 12:39:02 -07:00
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
static void
|
|
|
|
BackgroundsSighan(int sig, void *prm __UNUSED__)
|
2004-04-10 12:39:02 -07:00
|
|
|
{
|
2004-12-28 15:46:49 -08:00
|
|
|
switch (sig)
|
|
|
|
{
|
|
|
|
case ESIGNAL_INIT:
|
|
|
|
EDirMake(EDirUserCache(), "cached/bgsel");
|
|
|
|
EDirMake(EDirUserCache(), "cached/img");
|
|
|
|
/* create a fallback background in case no background is found */
|
|
|
|
BackgroundCreate("NONE", NULL, NULL, 0, 0, 0, 0, 0, 0, NULL, 0, 0, 0, 0,
|
|
|
|
0);
|
|
|
|
break;
|
2005-03-05 04:19:48 -08:00
|
|
|
|
|
|
|
case ESIGNAL_CONFIGURE:
|
|
|
|
BackgroundsConfigLoadUser();
|
2006-12-26 14:39:13 -08:00
|
|
|
BackgroundsCheckDups();
|
2005-03-05 04:19:48 -08:00
|
|
|
break;
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
case ESIGNAL_START:
|
|
|
|
DoIn("BACKGROUND_ACCOUNTING_TIMEOUT", 30.0, BackgroundsTimeout, 0,
|
|
|
|
NULL);
|
|
|
|
break;
|
2005-03-05 04:19:48 -08:00
|
|
|
|
|
|
|
case ESIGNAL_EXIT:
|
2005-03-19 03:10:12 -08:00
|
|
|
if (Mode.wm.save_ok)
|
|
|
|
BackgroundsConfigSave();
|
2005-03-05 04:19:48 -08:00
|
|
|
break;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Configuration dialog
|
|
|
|
*/
|
|
|
|
static Dialog *bg_sel_dialog;
|
|
|
|
static DItem *bg_sel;
|
|
|
|
static DItem *bg_sel_slider;
|
|
|
|
static DItem *bg_mini_disp;
|
|
|
|
static DItem *bg_filename;
|
|
|
|
static DItem *tmp_w[10];
|
|
|
|
|
|
|
|
static Background *tmp_bg; /* The background being configured */
|
2005-07-24 05:22:19 -07:00
|
|
|
static Pixmap tmp_bg_mini_pixmap = None;
|
2006-09-02 07:33:14 -07:00
|
|
|
static int tmp_bg_sel_sliderval;
|
|
|
|
static int tmp_bg_sel_sliderval_old;
|
2004-12-28 15:46:49 -08:00
|
|
|
static int tmp_bg_r;
|
|
|
|
static int tmp_bg_g;
|
|
|
|
static int tmp_bg_b;
|
|
|
|
static char tmp_bg_image;
|
|
|
|
static char tmp_bg_tile;
|
|
|
|
static char tmp_bg_keep_aspect;
|
|
|
|
static int tmp_bg_xjust;
|
|
|
|
static int tmp_bg_yjust;
|
|
|
|
static int tmp_bg_xperc;
|
|
|
|
static int tmp_bg_yperc;
|
|
|
|
static char tmp_hiq;
|
|
|
|
static char tmp_userbg;
|
2006-05-28 04:09:46 -07:00
|
|
|
static char tmp_root_hint;
|
2004-12-28 15:46:49 -08:00
|
|
|
static int tmp_bg_timeout;
|
|
|
|
|
2005-07-26 09:58:31 -07:00
|
|
|
static void BG_RedrawView(void);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
static void
|
|
|
|
CB_ConfigureBG(Dialog * d __UNUSED__, int val, void *data __UNUSED__)
|
|
|
|
{
|
2006-09-02 07:33:14 -07:00
|
|
|
if (val == 2)
|
2005-07-24 05:22:19 -07:00
|
|
|
{
|
2006-09-02 07:33:14 -07:00
|
|
|
bg_sel = bg_sel_slider = bg_mini_disp = bg_filename = NULL;
|
|
|
|
memset(tmp_w, 0, sizeof(tmp_w));
|
2005-07-24 05:22:19 -07:00
|
|
|
BackgroundImagesKeep(tmp_bg, 0);
|
|
|
|
tmp_bg = NULL;
|
|
|
|
if (tmp_bg_mini_pixmap != None)
|
|
|
|
EFreePixmap(tmp_bg_mini_pixmap);
|
|
|
|
tmp_bg_mini_pixmap = None;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
if (val < 2)
|
|
|
|
{
|
|
|
|
Conf.backgrounds.timeout = tmp_bg_timeout;
|
|
|
|
Conf.backgrounds.hiquality = tmp_hiq;
|
|
|
|
Conf.backgrounds.user = tmp_userbg;
|
2006-05-28 04:09:46 -07:00
|
|
|
Conf.hints.set_xroot_info_on_root_window = tmp_root_hint;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
ESetColor(&(tmp_bg->bg_solid), tmp_bg_r, tmp_bg_g, tmp_bg_b);
|
|
|
|
tmp_bg->bg_tile = tmp_bg_tile;
|
|
|
|
tmp_bg->bg.keep_aspect = tmp_bg_keep_aspect;
|
|
|
|
tmp_bg->bg.xjust = tmp_bg_xjust;
|
|
|
|
tmp_bg->bg.yjust = 1024 - tmp_bg_yjust;
|
|
|
|
tmp_bg->bg.xperc = tmp_bg_xperc;
|
|
|
|
tmp_bg->bg.yperc = 1024 - tmp_bg_yperc;
|
2005-11-27 03:02:05 -08:00
|
|
|
if (!tmp_bg_image)
|
|
|
|
BackgroundFilesRemove(tmp_bg);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2005-11-27 03:02:05 -08:00
|
|
|
BackgroundInvalidate(tmp_bg, 1);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2005-07-26 09:58:31 -07:00
|
|
|
BackgroundCacheMini(tmp_bg, 0, 1);
|
|
|
|
BG_RedrawView();
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
autosave();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Draw the background preview image */
|
|
|
|
static void
|
2005-07-24 05:22:19 -07:00
|
|
|
CB_DesktopMiniDisplayRedraw(Dialog * d __UNUSED__, int val, void *data)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
|
|
|
Background *bg;
|
2005-07-24 05:22:19 -07:00
|
|
|
Pixmap pmap;
|
2004-12-28 15:46:49 -08:00
|
|
|
int w, h;
|
|
|
|
DItem *di;
|
2006-04-29 12:39:21 -07:00
|
|
|
Win win;
|
2004-12-28 15:46:49 -08:00
|
|
|
XColor xclr;
|
|
|
|
const char *fbg, *ffg;
|
|
|
|
|
|
|
|
if (!tmp_bg)
|
|
|
|
return;
|
|
|
|
|
|
|
|
di = (DItem *) data;
|
|
|
|
win = DialogItemAreaGetWindow(di);
|
|
|
|
DialogItemAreaGetSize(di, &w, &h);
|
|
|
|
|
2005-07-24 05:22:19 -07:00
|
|
|
if (tmp_bg_mini_pixmap == None)
|
2006-05-07 09:21:37 -07:00
|
|
|
tmp_bg_mini_pixmap = ECreatePixmap(win, w, h, 0);
|
2005-07-24 05:22:19 -07:00
|
|
|
pmap = tmp_bg_mini_pixmap;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2005-07-24 05:22:19 -07:00
|
|
|
if (val == 1)
|
|
|
|
{
|
|
|
|
ESetWindowBackgroundPixmap(win, pmap);
|
2006-05-28 04:51:42 -07:00
|
|
|
BackgroundApplyPmap(tmp_bg, win, pmap, w, h);
|
2005-07-24 05:22:19 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fbg = (tmp_bg_image) ? BackgroundGetBgFile(tmp_bg) : NULL;
|
|
|
|
ffg = (tmp_bg_image) ? BackgroundGetFgFile(tmp_bg) : NULL;
|
|
|
|
ESetColor(&xclr, tmp_bg_r, tmp_bg_g, tmp_bg_b);
|
|
|
|
bg = BackgroundCreate("TEMP", &xclr, fbg, tmp_bg_tile,
|
|
|
|
tmp_bg_keep_aspect, tmp_bg_xjust,
|
|
|
|
1024 - tmp_bg_yjust, tmp_bg_xperc,
|
|
|
|
1024 - tmp_bg_yperc, ffg,
|
|
|
|
tmp_bg->top.keep_aspect, tmp_bg->top.xjust,
|
|
|
|
tmp_bg->top.yjust, tmp_bg->top.xperc,
|
|
|
|
tmp_bg->top.yperc);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2006-05-28 04:51:42 -07:00
|
|
|
BackgroundApplyPmap(bg, win, pmap, w, h);
|
2005-07-24 05:22:19 -07:00
|
|
|
BackgroundDestroy(bg);
|
|
|
|
}
|
|
|
|
EClearWindow(win);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Update tmp vars according to the current tmp_bg */
|
|
|
|
static void
|
|
|
|
BG_GetValues(void)
|
|
|
|
{
|
|
|
|
tmp_bg_image = (tmp_bg->bg.file) ? 1 : 0;
|
|
|
|
|
|
|
|
EGetColor(&(tmp_bg->bg_solid), &tmp_bg_r, &tmp_bg_g, &tmp_bg_b);
|
|
|
|
tmp_bg_tile = tmp_bg->bg_tile;
|
|
|
|
tmp_bg_keep_aspect = tmp_bg->bg.keep_aspect;
|
|
|
|
tmp_bg_xjust = tmp_bg->bg.xjust;
|
|
|
|
tmp_bg_yjust = 1024 - tmp_bg->bg.yjust;
|
|
|
|
tmp_bg_xperc = tmp_bg->bg.xperc;
|
|
|
|
tmp_bg_yperc = 1024 - tmp_bg->bg.yperc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
BG_DialogSetFileName(DItem * di)
|
|
|
|
{
|
2005-10-30 11:40:49 -08:00
|
|
|
char *stmp = NULL;
|
2004-12-28 15:46:49 -08:00
|
|
|
char s[1024];
|
|
|
|
|
|
|
|
if (BackgroundGetBgFile(tmp_bg))
|
|
|
|
stmp = fullfileof(BackgroundGetBgFile(tmp_bg));
|
|
|
|
Esnprintf(s, sizeof(s),
|
|
|
|
_("Background definition information:\nName: %s\nFile: %s\n"),
|
2005-10-30 11:40:49 -08:00
|
|
|
BackgroundGetName(tmp_bg), (stmp) ? stmp : _("-NONE-"));
|
|
|
|
_EFREE(stmp);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, s);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
BgDialogSetNewCurrent(Background * bg)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2005-07-24 05:22:19 -07:00
|
|
|
if (tmp_bg && tmp_bg != bg)
|
|
|
|
BackgroundImagesKeep(tmp_bg, 0);
|
2004-12-28 15:46:49 -08:00
|
|
|
tmp_bg = bg;
|
2005-07-24 05:22:19 -07:00
|
|
|
BackgroundImagesKeep(tmp_bg, 1);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
/* Fetch new BG values */
|
|
|
|
BG_GetValues();
|
|
|
|
|
|
|
|
/* Update dialog items */
|
|
|
|
BG_DialogSetFileName(bg_filename);
|
|
|
|
DialogDrawItems(bg_sel_dialog, bg_filename, 0, 0, 99999, 99999);
|
|
|
|
|
|
|
|
DialogItemSliderSetVal(tmp_w[0], tmp_bg_r);
|
|
|
|
DialogItemCheckButtonSetState(tmp_w[1], tmp_bg_image);
|
|
|
|
DialogItemSliderSetVal(tmp_w[2], tmp_bg_g);
|
|
|
|
DialogItemCheckButtonSetState(tmp_w[3], tmp_bg_keep_aspect);
|
|
|
|
DialogItemSliderSetVal(tmp_w[4], tmp_bg_b);
|
|
|
|
DialogItemCheckButtonSetState(tmp_w[5], tmp_bg_tile);
|
|
|
|
DialogItemSliderSetVal(tmp_w[6], tmp_bg_xjust);
|
|
|
|
DialogItemSliderSetVal(tmp_w[7], tmp_bg_yjust);
|
|
|
|
DialogItemSliderSetVal(tmp_w[8], tmp_bg_yperc);
|
|
|
|
DialogItemSliderSetVal(tmp_w[9], tmp_bg_xperc);
|
|
|
|
|
|
|
|
/* Redraw preview image */
|
2005-07-24 05:22:19 -07:00
|
|
|
CB_DesktopMiniDisplayRedraw(NULL, 1, bg_mini_disp);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
/* Redraw scrolling BG list */
|
2005-07-26 09:58:31 -07:00
|
|
|
BG_RedrawView();
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
for (i = 0; i < 10; i++)
|
|
|
|
DialogDrawItems(bg_sel_dialog, tmp_w[i], 0, 0, 99999, 99999);
|
2004-04-10 12:39:02 -07:00
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
/* Duplicate current (tmp_bg) to new */
|
|
|
|
static void
|
|
|
|
CB_ConfigureNewBG(Dialog * d __UNUSED__, int val __UNUSED__,
|
|
|
|
void *data __UNUSED__)
|
|
|
|
{
|
|
|
|
char s[1024];
|
|
|
|
XColor xclr;
|
|
|
|
int lower, upper;
|
|
|
|
|
|
|
|
Esnprintf(s, sizeof(s), "__NEWBG_%i", (unsigned)time(NULL));
|
|
|
|
|
|
|
|
ESetColor(&xclr, tmp_bg_r, tmp_bg_g, tmp_bg_b);
|
|
|
|
|
|
|
|
tmp_bg = BackgroundCreate(s, &xclr, tmp_bg->bg.file, tmp_bg_tile,
|
|
|
|
tmp_bg_keep_aspect, tmp_bg_xjust,
|
|
|
|
1024 - tmp_bg_yjust, tmp_bg_xperc,
|
|
|
|
1024 - tmp_bg_yperc, tmp_bg->top.file,
|
|
|
|
tmp_bg->top.keep_aspect, tmp_bg->top.xjust,
|
|
|
|
tmp_bg->top.yjust, tmp_bg->top.xperc,
|
|
|
|
tmp_bg->top.yperc);
|
|
|
|
|
|
|
|
DialogItemSliderGetBounds(bg_sel_slider, &lower, &upper);
|
|
|
|
upper += 4;
|
|
|
|
DialogItemSliderSetBounds(bg_sel_slider, lower, upper);
|
|
|
|
|
|
|
|
DialogItemSliderSetVal(bg_sel_slider, 0);
|
|
|
|
DialogDrawItems(bg_sel_dialog, bg_sel_slider, 0, 0, 99999, 99999);
|
|
|
|
|
2005-11-27 03:02:05 -08:00
|
|
|
DeskBackgroundSet(DesksGetCurrent(), tmp_bg);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2005-07-26 09:58:31 -07:00
|
|
|
BG_RedrawView();
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
autosave();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
CB_ConfigureDelBG(Dialog * d __UNUSED__, int val, void *data __UNUSED__)
|
|
|
|
{
|
2006-02-18 00:30:09 -08:00
|
|
|
Background *bg;
|
2004-12-28 15:46:49 -08:00
|
|
|
int i, num;
|
|
|
|
int slider, lower, upper;
|
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
num = ecore_list_nodes(bg_list);
|
|
|
|
if (num <= 1)
|
|
|
|
return;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2007-01-16 17:10:44 -08:00
|
|
|
bg = (Background *) ecore_list_goto(bg_list, tmp_bg);
|
2006-02-18 00:30:09 -08:00
|
|
|
if (!bg)
|
|
|
|
return;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
i = ecore_list_index(bg_list);
|
2007-01-16 17:10:44 -08:00
|
|
|
bg =
|
|
|
|
(Background *) ecore_list_goto_index(bg_list,
|
|
|
|
(i < num - 1) ? i + 1 : i - 1);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2005-11-27 03:02:05 -08:00
|
|
|
DeskBackgroundSet(DesksGetCurrent(), bg);
|
2006-02-18 00:30:09 -08:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
if (val == 0)
|
|
|
|
BackgroundDestroy(tmp_bg);
|
|
|
|
else
|
|
|
|
BackgroundDelete(tmp_bg);
|
2005-07-24 05:22:19 -07:00
|
|
|
tmp_bg = NULL;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
DialogItemSliderGetBounds(bg_sel_slider, &lower, &upper);
|
|
|
|
slider = DialogItemSliderGetVal(bg_sel_slider);
|
|
|
|
upper -= 4;
|
|
|
|
DialogItemSliderSetBounds(bg_sel_slider, lower, upper);
|
|
|
|
if (slider > upper)
|
|
|
|
DialogItemSliderSetVal(bg_sel_slider, upper);
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
BgDialogSetNewCurrent(bg);
|
|
|
|
|
|
|
|
autosave();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Move current background to first position in list */
|
|
|
|
static void
|
|
|
|
CB_ConfigureFrontBG(Dialog * d __UNUSED__, int val __UNUSED__,
|
|
|
|
void *data __UNUSED__)
|
|
|
|
{
|
2006-02-18 00:30:09 -08:00
|
|
|
ecore_list_prepend(bg_list, ecore_list_remove_node(bg_list, tmp_bg));
|
2005-07-26 09:58:31 -07:00
|
|
|
BG_RedrawView();
|
2004-12-28 15:46:49 -08:00
|
|
|
autosave();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Draw the scrolling background image window */
|
|
|
|
static void
|
2005-07-26 09:58:31 -07:00
|
|
|
BG_RedrawView(void)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2006-02-18 00:30:09 -08:00
|
|
|
Background *bg;
|
|
|
|
int x, w, h, num;
|
2006-04-29 12:39:21 -07:00
|
|
|
Win win;
|
2004-12-28 15:46:49 -08:00
|
|
|
Pixmap pmap;
|
|
|
|
GC gc;
|
2005-08-04 15:05:31 -07:00
|
|
|
ImageClass *ic_button;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
num = ecore_list_nodes(bg_list);
|
|
|
|
if (num <= 0)
|
2005-07-24 05:22:19 -07:00
|
|
|
return;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
win = DialogItemAreaGetWindow(bg_sel);
|
|
|
|
DialogItemAreaGetSize(bg_sel, &w, &h);
|
|
|
|
|
2006-05-07 09:21:37 -07:00
|
|
|
pmap = ECreatePixmap(win, w, h, 0);
|
2006-04-17 14:55:34 -07:00
|
|
|
gc = EXCreateGC(pmap, 0, NULL);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2005-11-01 09:15:51 -08:00
|
|
|
ic_button = ImageclassFind("DIALOG_BUTTON", 0);
|
2005-08-04 15:05:31 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
XSetForeground(disp, gc, BlackPixel(disp, VRoot.scr));
|
|
|
|
XFillRectangle(disp, pmap, gc, 0, 0, w, h);
|
2005-02-02 09:12:07 -08:00
|
|
|
ESetWindowBackgroundPixmap(win, pmap);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2005-07-24 05:22:19 -07:00
|
|
|
x = -(num * (64 + 8) - w) * tmp_bg_sel_sliderval / (4 * num);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
ECORE_LIST_FOR_EACH(bg_list, bg)
|
|
|
|
{
|
|
|
|
if (((x + 64 + 8) >= 0) && (x < w))
|
|
|
|
{
|
2006-03-29 11:13:17 -08:00
|
|
|
EImage *im;
|
2006-02-18 00:30:09 -08:00
|
|
|
|
|
|
|
if (ic_button)
|
|
|
|
ImageclassApplySimple(ic_button, win, pmap,
|
|
|
|
(bg == tmp_bg) ?
|
|
|
|
STATE_CLICKED : STATE_NORMAL,
|
|
|
|
x, 0, 64 + 8, 48 + 8);
|
|
|
|
|
|
|
|
if (BackgroundIsNone(bg))
|
|
|
|
{
|
|
|
|
TextClass *tc;
|
|
|
|
|
|
|
|
tc = TextclassFind("DIALOG", 1);
|
|
|
|
if (tc)
|
|
|
|
{
|
|
|
|
int tw, th;
|
|
|
|
|
|
|
|
TextSize(tc, 0, 0, STATE_NORMAL,
|
|
|
|
_("No\nBackground"), &tw, &th, 17);
|
2006-05-08 09:26:22 -07:00
|
|
|
TextDraw(tc, win, pmap, 0, 0, STATE_NORMAL,
|
2006-02-18 00:30:09 -08:00
|
|
|
_("No\nBackground"), x + 4,
|
|
|
|
4 + ((48 - th) / 2), 64, 48, 17, 512);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
im = BackgroundCacheMini(bg, 1, 0);
|
|
|
|
if (im)
|
|
|
|
{
|
2006-07-24 18:29:26 -07:00
|
|
|
EImageRenderOnDrawable(im, win, pmap, x + 4, 4, 64, 48, 0);
|
2006-03-29 11:13:17 -08:00
|
|
|
EImageFree(im);
|
2006-02-18 00:30:09 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
x += (64 + 8);
|
|
|
|
}
|
2006-04-17 14:55:34 -07:00
|
|
|
EXFreeGC(gc);
|
2005-02-22 13:45:25 -08:00
|
|
|
EFreePixmap(pmap);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2005-02-02 09:12:07 -08:00
|
|
|
EClearWindow(win);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
CB_BGAreaSlide(Dialog * d __UNUSED__, int val __UNUSED__, void *data __UNUSED__)
|
|
|
|
{
|
2005-07-26 09:58:31 -07:00
|
|
|
if (tmp_bg_sel_sliderval == tmp_bg_sel_sliderval_old)
|
|
|
|
return;
|
|
|
|
BG_RedrawView();
|
|
|
|
tmp_bg_sel_sliderval_old = tmp_bg_sel_sliderval;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
CB_BGScan(Dialog * d, int val __UNUSED__, void *data __UNUSED__)
|
|
|
|
{
|
|
|
|
int slider, lower, upper;
|
|
|
|
|
|
|
|
SoundPlay("SOUND_WAIT");
|
|
|
|
|
|
|
|
DialogItemSliderGetBounds(bg_sel_slider, &lower, &upper);
|
|
|
|
|
|
|
|
for (slider = lower; slider <= upper; slider += 8)
|
|
|
|
{
|
|
|
|
DialogItemSliderSetVal(bg_sel_slider, slider);
|
|
|
|
DialogDrawItems(bg_sel_dialog, bg_sel_slider, 0, 0, 99999, 99999);
|
|
|
|
DialogItemCallCallback(d, bg_sel_slider);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-07-20 20:17:18 -07:00
|
|
|
CB_BGAreaEvent(DItem * di __UNUSED__, int val __UNUSED__, void *data)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
|
|
|
int x, num, w, h;
|
2006-02-18 00:30:09 -08:00
|
|
|
Background *bg;
|
2004-12-28 15:46:49 -08:00
|
|
|
XEvent *ev = (XEvent *) data;
|
|
|
|
|
|
|
|
DialogItemAreaGetSize(bg_sel, &w, &h);
|
|
|
|
|
|
|
|
switch (ev->type)
|
|
|
|
{
|
|
|
|
case ButtonPress:
|
2006-02-18 00:30:09 -08:00
|
|
|
num = ecore_list_nodes(bg_list);
|
2005-07-24 05:22:19 -07:00
|
|
|
x = (num * (64 + 8) - w) * tmp_bg_sel_sliderval / (4 * num) +
|
|
|
|
ev->xbutton.x;
|
2007-01-16 17:10:44 -08:00
|
|
|
bg = (Background *) ecore_list_goto_index(bg_list, x / (64 + 8));
|
2006-02-18 00:30:09 -08:00
|
|
|
if (!bg || bg == DeskBackgroundGet(DesksGetCurrent()))
|
|
|
|
break;
|
|
|
|
BgDialogSetNewCurrent(bg);
|
|
|
|
DeskBackgroundSet(DesksGetCurrent(), bg);
|
|
|
|
autosave();
|
2004-12-28 15:46:49 -08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
CB_DesktopTimeout(Dialog * d __UNUSED__, int val __UNUSED__, void *data)
|
|
|
|
{
|
|
|
|
DItem *di;
|
|
|
|
char s[256];
|
|
|
|
|
|
|
|
di = (DItem *) data;
|
|
|
|
Esnprintf(s, sizeof(s), _("Unused backgrounds freed after %2i:%02i:%02i"),
|
|
|
|
tmp_bg_timeout / 3600,
|
|
|
|
(tmp_bg_timeout / 60) - (60 * (tmp_bg_timeout / 3600)),
|
|
|
|
(tmp_bg_timeout) - (60 * (tmp_bg_timeout / 60)));
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, s);
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogDrawItems(bg_sel_dialog, di, 0, 0, 99999, 99999);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
BGSettingsGoTo(Background * bg)
|
|
|
|
{
|
|
|
|
int i, num;
|
|
|
|
|
2006-09-02 07:33:14 -07:00
|
|
|
if (!bg_sel_slider)
|
2004-12-28 15:46:49 -08:00
|
|
|
return;
|
|
|
|
|
2007-01-16 17:10:44 -08:00
|
|
|
bg = (Background *) ecore_list_goto(bg_list, bg);
|
2006-02-18 00:30:09 -08:00
|
|
|
if (!bg)
|
2004-12-28 15:46:49 -08:00
|
|
|
return;
|
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
i = ecore_list_index(bg_list);
|
|
|
|
num = ecore_list_nodes(bg_list);
|
|
|
|
i = ((4 * num + 20) * i) / num - 8;
|
|
|
|
if (i < 0)
|
|
|
|
i = 0;
|
|
|
|
else if (i > 4 * num)
|
|
|
|
i = 4 * num;
|
|
|
|
DialogItemSliderSetVal(bg_sel_slider, i);
|
|
|
|
DialogDrawItems(bg_sel_dialog, bg_sel_slider, 0, 0, 99999, 99999);
|
|
|
|
BgDialogSetNewCurrent(bg);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-02-18 00:30:09 -08:00
|
|
|
CB_BGNext(Dialog * d __UNUSED__, int val, void *data __UNUSED__)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2006-02-18 00:30:09 -08:00
|
|
|
Background *bg;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2007-01-16 17:10:44 -08:00
|
|
|
bg = (Background *) ecore_list_goto(bg_list, tmp_bg);
|
2006-02-18 00:30:09 -08:00
|
|
|
if (!bg)
|
|
|
|
return;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2007-01-16 17:10:44 -08:00
|
|
|
bg =
|
|
|
|
(Background *) ecore_list_goto_index(bg_list,
|
|
|
|
ecore_list_index(bg_list) + val);
|
2006-02-18 00:30:09 -08:00
|
|
|
if (!bg)
|
|
|
|
return;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
BGSettingsGoTo(bg);
|
|
|
|
DeskBackgroundSet(DesksGetCurrent(), bg);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
BG_SortFileCompare(Background * bg1, Background * bg2)
|
|
|
|
{
|
|
|
|
const char *name1, *name2;
|
|
|
|
|
|
|
|
/* return < 0 is b1 < b2 */
|
|
|
|
/* return > 0 is b1 > b2 */
|
|
|
|
/* return 0 is b1 == b2 */
|
|
|
|
|
|
|
|
name1 = BackgroundGetBgFile(bg1);
|
|
|
|
name2 = BackgroundGetBgFile(bg2);
|
|
|
|
if (name1 && name2)
|
|
|
|
return strcmp(name1, name2);
|
|
|
|
|
|
|
|
name1 = BackgroundGetFgFile(bg1);
|
|
|
|
name2 = BackgroundGetFgFile(bg2);
|
|
|
|
if (name1 && name2)
|
|
|
|
return strcmp(name1, name2);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
CB_BGSortFile(Dialog * d __UNUSED__, int val __UNUSED__, void *data __UNUSED__)
|
|
|
|
{
|
|
|
|
Background **bglist;
|
|
|
|
int i, num;
|
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
bglist = (Background **) ecore_list_items_get(bg_list, &num);
|
2004-12-28 15:46:49 -08:00
|
|
|
if (!bglist)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* remove them all from the list */
|
|
|
|
for (i = 0; i < num; i++)
|
2006-02-18 00:30:09 -08:00
|
|
|
ecore_list_remove_node(bg_list, bglist[i]);
|
2004-12-28 15:46:49 -08:00
|
|
|
Quicksort((void **)bglist, 0, num - 1,
|
|
|
|
(int (*)(void *d1, void *d2))BG_SortFileCompare);
|
|
|
|
for (i = 0; i < num; i++)
|
2006-02-18 00:30:09 -08:00
|
|
|
ecore_list_prepend(bg_list, bglist[i]);
|
2004-12-28 15:46:49 -08:00
|
|
|
Efree(bglist);
|
|
|
|
|
|
|
|
BGSettingsGoTo(tmp_bg);
|
|
|
|
|
|
|
|
autosave();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
CB_BGSortAttrib(Dialog * d __UNUSED__, int val __UNUSED__,
|
|
|
|
void *data __UNUSED__)
|
|
|
|
{
|
|
|
|
Background **bglist;
|
|
|
|
int i, num;
|
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
bglist = (Background **) ecore_list_items_get(bg_list, &num);
|
2004-12-28 15:46:49 -08:00
|
|
|
if (!bglist)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* remove them all from the list */
|
|
|
|
for (i = 0; i < num; i++)
|
2006-02-18 00:30:09 -08:00
|
|
|
ecore_list_remove_node(bg_list, bglist[i]);
|
2004-12-28 15:46:49 -08:00
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
{
|
|
|
|
Background *bg;
|
|
|
|
|
|
|
|
bg = bglist[i];
|
|
|
|
if ((bg) && (bg->bg_tile) && (bg->bg.xperc == 0) && (bg->bg.yperc == 0))
|
|
|
|
{
|
2006-02-18 00:30:09 -08:00
|
|
|
ecore_list_prepend(bg_list, bg);
|
2004-12-28 15:46:49 -08:00
|
|
|
bglist[i] = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
{
|
|
|
|
Background *bg;
|
|
|
|
|
|
|
|
bg = bglist[i];
|
|
|
|
if (bg)
|
|
|
|
{
|
2006-02-18 00:30:09 -08:00
|
|
|
ecore_list_prepend(bg_list, bg);
|
2004-12-28 15:46:49 -08:00
|
|
|
bglist[i] = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Efree(bglist);
|
|
|
|
|
|
|
|
BGSettingsGoTo(tmp_bg);
|
|
|
|
|
|
|
|
autosave();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
CB_BGSortContent(Dialog * d __UNUSED__, int val __UNUSED__,
|
|
|
|
void *data __UNUSED__)
|
|
|
|
{
|
|
|
|
Background **bglist;
|
|
|
|
int i, num;
|
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
bglist = (Background **) ecore_list_items_get(bg_list, &num);
|
|
|
|
if (!bglist)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* remove them all from the list */
|
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
ecore_list_remove_node(bg_list, bglist[i]);
|
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
ecore_list_prepend(bg_list, bglist[i]);
|
|
|
|
Efree(bglist);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
autosave();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-09-02 07:33:14 -07:00
|
|
|
CB_DesktopMiniDisplayAreaInit(DItem * di, int val __UNUSED__,
|
|
|
|
void *data __UNUSED__)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2006-07-20 20:17:18 -07:00
|
|
|
CB_DesktopMiniDisplayRedraw(DialogItemGetDialog(di), 1, di);
|
2006-09-02 07:33:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
CB_InitView(DItem * di __UNUSED__, int val __UNUSED__, void *data __UNUSED__)
|
|
|
|
{
|
|
|
|
tmp_bg_sel_sliderval_old = tmp_bg_sel_sliderval = -1;
|
2006-07-20 20:17:18 -07:00
|
|
|
BGSettingsGoTo(tmp_bg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_DlgFillBackground(Dialog * d, DItem * table, void *data)
|
|
|
|
{
|
2007-01-16 17:10:44 -08:00
|
|
|
Background *bg = (Background *) data;
|
2006-07-20 20:17:18 -07:00
|
|
|
DItem *di, *table2, *area, *slider, *slider2, *label;
|
2004-12-28 15:46:49 -08:00
|
|
|
DItem *w1, *w2, *w3, *w4, *w5, *w6;
|
|
|
|
int num;
|
|
|
|
char s[1024];
|
|
|
|
|
2007-02-24 17:38:30 -08:00
|
|
|
ScanBackgroundMenu();
|
|
|
|
|
2006-09-02 07:33:14 -07:00
|
|
|
if (!bg)
|
|
|
|
bg = DeskBackgroundGet(DesksGetCurrent());
|
2006-02-20 10:56:36 -08:00
|
|
|
if (!bg)
|
|
|
|
bg = BackgroundFind("NONE");
|
2004-12-28 15:46:49 -08:00
|
|
|
tmp_bg = bg;
|
|
|
|
|
|
|
|
BG_GetValues();
|
|
|
|
|
|
|
|
tmp_hiq = Conf.backgrounds.hiquality;
|
|
|
|
tmp_userbg = Conf.backgrounds.user;
|
2006-05-28 04:09:46 -07:00
|
|
|
tmp_root_hint = Conf.hints.set_xroot_info_on_root_window;
|
2004-12-28 15:46:49 -08:00
|
|
|
tmp_bg_timeout = Conf.backgrounds.timeout;
|
|
|
|
|
2006-07-20 20:17:18 -07:00
|
|
|
bg_sel_dialog = d;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
DialogItemTableSetOptions(table, 3, 0, 0, 0);
|
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_TEXT);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("BG Colour\n"));
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_NONE);
|
|
|
|
|
|
|
|
table2 = DialogAddItem(table, DITEM_TABLE);
|
|
|
|
DialogItemTableSetOptions(table2, 4, 0, 0, 0);
|
|
|
|
|
|
|
|
di = DialogAddItem(table2, DITEM_BUTTON);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("Move to Front\n"));
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemSetCallback(di, CB_ConfigureFrontBG, 0, NULL);
|
2006-08-20 10:39:32 -07:00
|
|
|
DialogBindKey(d, "F", CB_ConfigureFrontBG, 0, NULL);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
di = DialogAddItem(table2, DITEM_BUTTON);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("Duplicate\n"));
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemSetCallback(di, CB_ConfigureNewBG, 0, NULL);
|
|
|
|
|
|
|
|
di = DialogAddItem(table2, DITEM_BUTTON);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("Unlist\n"));
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemSetCallback(di, CB_ConfigureDelBG, 0, NULL);
|
|
|
|
|
|
|
|
di = DialogAddItem(table2, DITEM_BUTTON);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("Delete File\n"));
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemSetCallback(di, CB_ConfigureDelBG, 0, NULL);
|
2006-08-20 10:39:32 -07:00
|
|
|
DialogBindKey(d, "D", CB_ConfigureDelBG, 0, NULL);
|
|
|
|
DialogBindKey(d, "Delete", CB_ConfigureDelBG, 1, NULL);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_TEXT);
|
|
|
|
DialogItemSetFill(di, 0, 0);
|
|
|
|
DialogItemSetAlign(di, 1024, 512);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("Red:\n"));
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
di = w1 = tmp_w[0] = DialogAddItem(table, DITEM_SLIDER);
|
|
|
|
DialogItemSliderSetBounds(di, 0, 255);
|
|
|
|
DialogItemSliderSetUnits(di, 1);
|
|
|
|
DialogItemSliderSetJump(di, 16);
|
|
|
|
DialogItemSliderSetValPtr(di, &tmp_bg_r);
|
|
|
|
|
|
|
|
di = w2 = tmp_w[1] = DialogAddItem(table, DITEM_CHECKBUTTON);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("Use background image"));
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemCheckButtonSetPtr(di, &tmp_bg_image);
|
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_TEXT);
|
|
|
|
DialogItemSetFill(di, 0, 0);
|
|
|
|
DialogItemSetAlign(di, 1024, 512);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("Green:\n"));
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
di = w3 = tmp_w[2] = DialogAddItem(table, DITEM_SLIDER);
|
|
|
|
DialogItemSliderSetBounds(di, 0, 255);
|
|
|
|
DialogItemSliderSetUnits(di, 1);
|
|
|
|
DialogItemSliderSetJump(di, 16);
|
|
|
|
DialogItemSliderSetValPtr(di, &tmp_bg_g);
|
|
|
|
|
|
|
|
di = w4 = tmp_w[3] = DialogAddItem(table, DITEM_CHECKBUTTON);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("Keep aspect on scale"));
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemCheckButtonSetPtr(di, &tmp_bg_keep_aspect);
|
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_TEXT);
|
|
|
|
DialogItemSetFill(di, 0, 0);
|
|
|
|
DialogItemSetAlign(di, 1024, 512);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("Blue:\n"));
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
di = w5 = tmp_w[4] = DialogAddItem(table, DITEM_SLIDER);
|
|
|
|
DialogItemSliderSetBounds(di, 0, 255);
|
|
|
|
DialogItemSliderSetUnits(di, 1);
|
|
|
|
DialogItemSliderSetJump(di, 16);
|
|
|
|
DialogItemSliderSetValPtr(di, &tmp_bg_b);
|
|
|
|
|
|
|
|
di = w6 = tmp_w[5] = DialogAddItem(table, DITEM_CHECKBUTTON);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("Tile image across background"));
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemCheckButtonSetPtr(di, &tmp_bg_tile);
|
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_SEPARATOR);
|
|
|
|
DialogItemSetColSpan(di, 3);
|
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_TEXT);
|
|
|
|
DialogItemSetFill(di, 0, 0);
|
|
|
|
DialogItemSetAlign(di, 512, 512);
|
|
|
|
DialogItemSetColSpan(di, 2);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di,
|
|
|
|
_("Background\n" "Image\n" "Scaling\n" "and\n"
|
|
|
|
"Alignment\n"));
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
table2 = DialogAddItem(table, DITEM_TABLE);
|
|
|
|
DialogItemTableSetOptions(table2, 3, 0, 0, 0);
|
|
|
|
|
|
|
|
di = DialogAddItem(table2, DITEM_NONE);
|
|
|
|
|
|
|
|
di = slider = tmp_w[6] = DialogAddItem(table2, DITEM_SLIDER);
|
|
|
|
DialogItemSliderSetMinLength(di, 10);
|
|
|
|
DialogItemSliderSetBounds(di, 0, 1024);
|
|
|
|
DialogItemSliderSetUnits(di, 1);
|
|
|
|
DialogItemSliderSetJump(di, 64);
|
|
|
|
DialogItemSliderSetValPtr(di, &tmp_bg_xjust);
|
|
|
|
|
|
|
|
di = DialogAddItem(table2, DITEM_NONE);
|
|
|
|
|
|
|
|
di = slider2 = tmp_w[7] = DialogAddItem(table2, DITEM_SLIDER);
|
|
|
|
DialogItemSliderSetMinLength(di, 10);
|
|
|
|
DialogItemSliderSetOrientation(di, 0);
|
|
|
|
DialogItemSetFill(di, 0, 1);
|
|
|
|
DialogItemSliderSetBounds(di, 0, 1024);
|
|
|
|
DialogItemSliderSetUnits(di, 1);
|
|
|
|
DialogItemSliderSetJump(di, 64);
|
|
|
|
DialogItemSliderSetValPtr(di, &tmp_bg_yjust);
|
|
|
|
|
|
|
|
di = bg_mini_disp = area = DialogAddItem(table2, DITEM_AREA);
|
|
|
|
DialogItemAreaSetSize(di, 64, 48);
|
2006-09-02 07:33:14 -07:00
|
|
|
DialogItemAreaSetInitFunc(di, CB_DesktopMiniDisplayAreaInit);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
DialogItemSetCallback(w1, CB_DesktopMiniDisplayRedraw, 0, (void *)area);
|
|
|
|
DialogItemSetCallback(w2, CB_DesktopMiniDisplayRedraw, 0, (void *)area);
|
|
|
|
DialogItemSetCallback(w3, CB_DesktopMiniDisplayRedraw, 0, (void *)area);
|
|
|
|
DialogItemSetCallback(w4, CB_DesktopMiniDisplayRedraw, 0, (void *)area);
|
|
|
|
DialogItemSetCallback(w5, CB_DesktopMiniDisplayRedraw, 0, (void *)area);
|
|
|
|
DialogItemSetCallback(w6, CB_DesktopMiniDisplayRedraw, 0, (void *)area);
|
|
|
|
DialogItemSetCallback(slider, CB_DesktopMiniDisplayRedraw, 0, (void *)area);
|
|
|
|
DialogItemSetCallback(slider2, CB_DesktopMiniDisplayRedraw, 0, (void *)area);
|
|
|
|
|
|
|
|
di = slider = tmp_w[8] = DialogAddItem(table2, DITEM_SLIDER);
|
|
|
|
DialogItemSliderSetMinLength(di, 10);
|
|
|
|
DialogItemSliderSetOrientation(di, 0);
|
|
|
|
DialogItemSetFill(di, 0, 1);
|
|
|
|
DialogItemSliderSetBounds(di, 0, 1024);
|
|
|
|
DialogItemSliderSetUnits(di, 1);
|
|
|
|
DialogItemSliderSetJump(di, 64);
|
|
|
|
DialogItemSliderSetValPtr(di, &tmp_bg_yperc);
|
|
|
|
DialogItemSetCallback(slider, CB_DesktopMiniDisplayRedraw, 0, (void *)area);
|
|
|
|
|
|
|
|
di = DialogAddItem(table2, DITEM_NONE);
|
|
|
|
|
|
|
|
di = slider = tmp_w[9] = DialogAddItem(table2, DITEM_SLIDER);
|
|
|
|
DialogItemSliderSetMinLength(di, 10);
|
|
|
|
DialogItemSliderSetBounds(di, 0, 1024);
|
|
|
|
DialogItemSliderSetUnits(di, 1);
|
|
|
|
DialogItemSliderSetJump(di, 64);
|
|
|
|
DialogItemSliderSetValPtr(di, &tmp_bg_xperc);
|
|
|
|
DialogItemSetCallback(slider, CB_DesktopMiniDisplayRedraw, 0, (void *)area);
|
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_SEPARATOR);
|
|
|
|
DialogItemSetColSpan(di, 3);
|
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_CHECKBUTTON);
|
|
|
|
DialogItemSetColSpan(di, 2);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("Use dithering in Hi-Colour"));
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemCheckButtonSetPtr(di, &tmp_hiq);
|
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_CHECKBUTTON);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("Background overrides theme"));
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemCheckButtonSetPtr(di, &tmp_userbg);
|
|
|
|
|
|
|
|
di = label = DialogAddItem(table, DITEM_TEXT);
|
|
|
|
DialogItemSetColSpan(di, 3);
|
|
|
|
DialogItemSetAlign(di, 512, 512);
|
|
|
|
Esnprintf(s, sizeof(s), _("Unused backgrounds freed after %2i:%02i:%02i"),
|
|
|
|
tmp_bg_timeout / 3600,
|
|
|
|
(tmp_bg_timeout / 60) - (60 * (tmp_bg_timeout / 3600)),
|
|
|
|
(tmp_bg_timeout) - (60 * (tmp_bg_timeout / 60)));
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, s);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_SLIDER);
|
|
|
|
DialogItemSetColSpan(di, 3);
|
|
|
|
DialogItemSliderSetMinLength(di, 10);
|
|
|
|
DialogItemSliderSetBounds(di, 0, 60 * 60 * 4);
|
|
|
|
DialogItemSliderSetUnits(di, 30);
|
|
|
|
DialogItemSliderSetJump(di, 60);
|
|
|
|
DialogItemSliderSetValPtr(di, &tmp_bg_timeout);
|
|
|
|
DialogItemSetCallback(di, CB_DesktopTimeout, 0, (void *)label);
|
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_SEPARATOR);
|
|
|
|
DialogItemSetColSpan(di, 3);
|
|
|
|
|
|
|
|
table2 = DialogAddItem(table, DITEM_TABLE);
|
|
|
|
DialogItemTableSetOptions(table2, 2, 0, 0, 0);
|
|
|
|
|
|
|
|
di = DialogAddItem(table2, DITEM_BUTTON);
|
|
|
|
DialogItemSetFill(di, 0, 0);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, "<-");
|
2006-02-18 00:30:09 -08:00
|
|
|
DialogItemSetCallback(di, CB_BGNext, -1, NULL);
|
2006-08-20 10:39:32 -07:00
|
|
|
DialogBindKey(d, "Left", CB_BGNext, -1, NULL);
|
|
|
|
DialogBindKey(d, "BackSpace", CB_BGNext, -1, NULL);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
di = DialogAddItem(table2, DITEM_BUTTON);
|
|
|
|
DialogItemSetFill(di, 0, 0);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, "->");
|
2006-02-18 00:30:09 -08:00
|
|
|
DialogItemSetCallback(di, CB_BGNext, 1, NULL);
|
2006-08-20 10:39:32 -07:00
|
|
|
DialogBindKey(d, "Right", CB_BGNext, 1, NULL);
|
|
|
|
DialogBindKey(d, "space", CB_BGNext, 1, NULL);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_BUTTON);
|
|
|
|
DialogItemSetFill(di, 0, 0);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("Pre-scan BG's"));
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemSetCallback(di, CB_BGScan, 0, NULL);
|
|
|
|
|
|
|
|
table2 = DialogAddItem(table, DITEM_TABLE);
|
|
|
|
DialogItemTableSetOptions(table2, 3, 0, 0, 0);
|
|
|
|
|
|
|
|
di = DialogAddItem(table2, DITEM_BUTTON);
|
|
|
|
DialogItemSetFill(di, 0, 0);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("Sort by File"));
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemSetCallback(di, CB_BGSortFile, 0, NULL);
|
|
|
|
|
|
|
|
di = DialogAddItem(table2, DITEM_BUTTON);
|
|
|
|
DialogItemSetFill(di, 0, 0);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("Sort by Attr."));
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemSetCallback(di, CB_BGSortAttrib, 0, NULL);
|
|
|
|
|
|
|
|
di = DialogAddItem(table2, DITEM_BUTTON);
|
|
|
|
DialogItemSetFill(di, 0, 0);
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, _("Sort by Image"));
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemSetCallback(di, CB_BGSortContent, 0, NULL);
|
|
|
|
|
|
|
|
di = bg_sel = DialogAddItem(table, DITEM_AREA);
|
|
|
|
DialogItemSetColSpan(di, 3);
|
|
|
|
DialogItemAreaSetSize(di, 160, 56);
|
|
|
|
DialogItemAreaSetEventFunc(di, CB_BGAreaEvent);
|
2006-09-02 07:33:14 -07:00
|
|
|
DialogItemAreaSetInitFunc(di, CB_InitView);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
num = ecore_list_nodes(bg_list);
|
2004-12-28 15:46:49 -08:00
|
|
|
di = bg_sel_slider = DialogAddItem(table, DITEM_SLIDER);
|
|
|
|
DialogItemSetColSpan(di, 3);
|
|
|
|
DialogItemSliderSetBounds(di, 0, num * 4);
|
|
|
|
DialogItemSliderSetUnits(di, 1);
|
|
|
|
DialogItemSliderSetJump(di, 9);
|
|
|
|
DialogItemSliderSetValPtr(di, &tmp_bg_sel_sliderval);
|
|
|
|
DialogItemSetCallback(bg_sel_slider, CB_BGAreaSlide, 0, NULL);
|
|
|
|
|
|
|
|
di = bg_filename = DialogAddItem(table, DITEM_TEXT);
|
|
|
|
DialogItemSetColSpan(di, 3);
|
|
|
|
DialogItemSetAlign(di, 512, 512);
|
|
|
|
BG_DialogSetFileName(bg_filename);
|
2006-05-28 04:09:46 -07:00
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_SEPARATOR);
|
|
|
|
DialogItemSetColSpan(di, 3);
|
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_CHECKBUTTON);
|
|
|
|
DialogItemSetColSpan(di, 3);
|
|
|
|
DialogItemSetText(di,
|
|
|
|
_("Enable background transparency compatibility mode"));
|
|
|
|
DialogItemCheckButtonSetPtr(di, &tmp_root_hint);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
2006-07-20 20:17:18 -07:00
|
|
|
const DialogDef DlgBackground = {
|
|
|
|
"CONFIGURE_BG",
|
|
|
|
N_("Background"),
|
|
|
|
N_("Desktop Background Settings"),
|
|
|
|
"SOUND_SETTINGS_BG",
|
2006-07-26 21:52:50 -07:00
|
|
|
"pix/bg.png",
|
|
|
|
N_("Enlightenment Desktop\n" "Background Settings Dialog\n"),
|
2006-08-07 20:58:42 -07:00
|
|
|
_DlgFillBackground,
|
|
|
|
DLG_OAC, CB_ConfigureBG,
|
2006-07-20 20:17:18 -07:00
|
|
|
};
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
/*
|
|
|
|
* IPC functions
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
BackgroundSet1(const char *name, const char *params)
|
|
|
|
{
|
|
|
|
const char *p = params;
|
|
|
|
char type[FILEPATH_LEN_MAX];
|
|
|
|
char valu[FILEPATH_LEN_MAX];
|
|
|
|
int len;
|
|
|
|
Background *bg;
|
2006-02-20 10:56:36 -08:00
|
|
|
XColor xclr;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2007-02-25 10:05:53 -08:00
|
|
|
if (!p || !p[0])
|
2005-06-06 10:46:14 -07:00
|
|
|
return;
|
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
bg = BackgroundFind(name);
|
2004-12-28 15:46:49 -08:00
|
|
|
if (!bg)
|
|
|
|
{
|
2006-02-20 10:56:36 -08:00
|
|
|
ESetColor(&xclr, 0, 0, 0);
|
|
|
|
bg = BackgroundCreate(name, &xclr, NULL, 0, 0, 0,
|
2004-12-28 15:46:49 -08:00
|
|
|
0, 0, 0, NULL, 0, 0, 0, 0, 0);
|
|
|
|
if (!bg)
|
|
|
|
{
|
|
|
|
IpcPrintf("Error: could not create background '%s'.", name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type[0] = valu[0] = '\0';
|
|
|
|
len = 0;
|
|
|
|
sscanf(p, "%400s %4000s %n", type, valu, &len);
|
|
|
|
p += len;
|
|
|
|
|
|
|
|
if (!strcmp(type, "bg.solid"))
|
|
|
|
{
|
|
|
|
int r, b, g;
|
|
|
|
|
|
|
|
r = g = b = 0;
|
|
|
|
sscanf(p, "%i %i %i", &r, &g, &b);
|
|
|
|
ESetColor(&(bg->bg_solid), r, g, b);
|
|
|
|
}
|
|
|
|
else if (!strcmp(type, "bg.file"))
|
|
|
|
{
|
|
|
|
if (bg->bg.file)
|
|
|
|
Efree(bg->bg.file);
|
|
|
|
bg->bg.file = Estrdup(valu);
|
|
|
|
}
|
|
|
|
else if (!strcmp(type, "bg.tile"))
|
|
|
|
{
|
|
|
|
bg->bg_tile = atoi(valu);
|
|
|
|
}
|
|
|
|
else if (!strcmp(type, "bg.keep_aspect"))
|
|
|
|
{
|
|
|
|
bg->bg.keep_aspect = atoi(valu);
|
|
|
|
}
|
|
|
|
else if (!strcmp(type, "bg.xjust"))
|
|
|
|
{
|
|
|
|
bg->bg.xjust = atoi(valu);
|
|
|
|
}
|
|
|
|
else if (!strcmp(type, "bg.yjust"))
|
|
|
|
{
|
|
|
|
bg->bg.yjust = atoi(valu);
|
|
|
|
}
|
|
|
|
else if (!strcmp(type, "bg.xperc"))
|
|
|
|
{
|
|
|
|
bg->bg.xperc = atoi(valu);
|
|
|
|
}
|
|
|
|
else if (!strcmp(type, "bg.yperc"))
|
|
|
|
{
|
|
|
|
bg->bg.yperc = atoi(valu);
|
|
|
|
}
|
|
|
|
else if (!strcmp(type, "top.file"))
|
|
|
|
{
|
|
|
|
if (bg->top.file)
|
|
|
|
Efree(bg->top.file);
|
|
|
|
bg->top.file = Estrdup(valu);
|
|
|
|
}
|
|
|
|
else if (!strcmp(type, "top.keep_aspect"))
|
|
|
|
{
|
|
|
|
bg->top.keep_aspect = atoi(valu);
|
|
|
|
}
|
|
|
|
else if (!strcmp(type, "top.xjust"))
|
|
|
|
{
|
|
|
|
bg->top.xjust = atoi(valu);
|
|
|
|
}
|
|
|
|
else if (!strcmp(type, "top.yjust"))
|
|
|
|
{
|
|
|
|
bg->top.yjust = atoi(valu);
|
|
|
|
}
|
|
|
|
else if (!strcmp(type, "top.xperc"))
|
|
|
|
{
|
|
|
|
bg->top.xperc = atoi(valu);
|
|
|
|
}
|
|
|
|
else if (!strcmp(type, "top.yperc"))
|
|
|
|
{
|
|
|
|
bg->top.yperc = atoi(valu);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
IpcPrintf("Error: unknown background value type '%s'.", type);
|
|
|
|
}
|
2005-02-01 12:35:59 -08:00
|
|
|
autosave();
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
BackgroundSet2(const char *name, const char *params)
|
|
|
|
{
|
|
|
|
Background *bg;
|
|
|
|
XColor xclr;
|
2005-09-04 00:27:20 -07:00
|
|
|
unsigned int i;
|
|
|
|
int r, g, b;
|
2004-12-28 15:46:49 -08:00
|
|
|
char bgf[FILEPATH_LEN_MAX], topf[FILEPATH_LEN_MAX];
|
2005-11-27 03:02:05 -08:00
|
|
|
int tile, keep_aspect, tkeep_aspect;
|
2004-12-28 15:46:49 -08:00
|
|
|
int xjust, yjust, xperc, yperc;
|
|
|
|
int txjust, tyjust, txperc, typerc;
|
|
|
|
|
|
|
|
if (params == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
bgf[0] = topf[0] = '\0';
|
|
|
|
r = g = b = 99;
|
|
|
|
i = sscanf(params,
|
|
|
|
"%i %i %i %4000s %i %i %i %i %i %i %4000s %i %i %i %i %i",
|
|
|
|
&r, &g, &b,
|
|
|
|
bgf, &tile, &keep_aspect, &xjust, &yjust, &xperc, &yperc,
|
|
|
|
topf, &tkeep_aspect, &txjust, &tyjust, &txperc, &typerc);
|
|
|
|
ESetColor(&xclr, r, g, b);
|
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
bg = BackgroundFind(name);
|
2004-12-28 15:46:49 -08:00
|
|
|
if (bg)
|
|
|
|
{
|
2005-11-27 03:02:05 -08:00
|
|
|
BackgroundModify(bg, &xclr, bgf, tile, keep_aspect, xjust,
|
|
|
|
yjust, xperc, yperc, topf, tkeep_aspect,
|
|
|
|
txjust, tyjust, txperc, typerc);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bg = BackgroundCreate(name, &xclr, bgf, tile, keep_aspect, xjust,
|
|
|
|
yjust, xperc, yperc, topf, tkeep_aspect,
|
|
|
|
txjust, tyjust, txperc, typerc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
BackgroundsIpc(const char *params, Client * c __UNUSED__)
|
|
|
|
{
|
|
|
|
const char *p;
|
|
|
|
char cmd[128], prm[128], buf[4096];
|
2007-02-25 10:05:53 -08:00
|
|
|
int i, len, num, len2;
|
2004-12-28 15:46:49 -08:00
|
|
|
Background *bg;
|
|
|
|
|
|
|
|
cmd[0] = prm[0] = '\0';
|
|
|
|
p = params;
|
|
|
|
if (p)
|
|
|
|
{
|
|
|
|
len = 0;
|
2007-02-25 10:05:53 -08:00
|
|
|
sscanf(p, "%100s %n%100s %n", cmd, &len2, prm, &len);
|
2004-12-28 15:46:49 -08:00
|
|
|
p += len;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p || cmd[0] == '?')
|
|
|
|
{
|
2005-09-04 00:27:20 -07:00
|
|
|
for (i = 0; i < (int)DesksGetNumber(); i++)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2005-11-21 09:48:44 -08:00
|
|
|
bg = DeskBackgroundGet(DeskGet(i));
|
2005-09-04 00:27:20 -07:00
|
|
|
if (bg)
|
|
|
|
IpcPrintf("%i %s\n", i, BackgroundGetName(bg));
|
2006-01-08 15:51:07 -08:00
|
|
|
else
|
|
|
|
IpcPrintf("%i %s\n", i, "-NONE-");
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!strncmp(cmd, "apply", 2))
|
|
|
|
{
|
2006-04-29 12:39:21 -07:00
|
|
|
Window xwin;
|
|
|
|
Win win;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
bg = BackgroundFind(prm);
|
2006-04-29 12:39:21 -07:00
|
|
|
if (!bg)
|
|
|
|
return;
|
|
|
|
|
|
|
|
xwin = None;
|
|
|
|
sscanf(p, "%lx", &xwin);
|
|
|
|
|
|
|
|
win = ECreateWinFromXwin(xwin);
|
|
|
|
if (!win)
|
|
|
|
return;
|
|
|
|
BackgroundApplyWin(bg, win);
|
|
|
|
EDestroyWin(win);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
else if (!strncmp(cmd, "cfg", 2))
|
|
|
|
{
|
2006-07-20 20:17:18 -07:00
|
|
|
DialogShowSimple(&DlgBackground, DeskBackgroundGet(DesksGetCurrent()));
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
else if (!strncmp(cmd, "del", 2))
|
|
|
|
{
|
|
|
|
BackgroundDestroyByName(prm);
|
|
|
|
}
|
|
|
|
else if (!strncmp(cmd, "list", 2))
|
|
|
|
{
|
2006-02-18 00:30:09 -08:00
|
|
|
ECORE_LIST_FOR_EACH(bg_list, bg) IpcPrintf("%s\n", bg->name);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
2005-01-28 16:07:20 -08:00
|
|
|
else if (!strncmp(cmd, "load", 2))
|
|
|
|
{
|
2006-02-18 00:30:09 -08:00
|
|
|
bg = BackgroundFind(prm);
|
2005-01-28 16:07:20 -08:00
|
|
|
if (bg)
|
|
|
|
{
|
|
|
|
IpcPrintf("Background already defined\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bg = BrackgroundCreateFromImage(prm, p, NULL, 0);
|
|
|
|
}
|
|
|
|
}
|
2005-02-01 12:35:59 -08:00
|
|
|
else if (!strncmp(cmd, "set", 2))
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
|
|
|
BackgroundSet1(prm, p);
|
|
|
|
}
|
|
|
|
else if (!strncmp(cmd, "show", 2))
|
|
|
|
{
|
2006-02-18 00:30:09 -08:00
|
|
|
bg = BackgroundFind(prm);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
if (bg)
|
|
|
|
{
|
|
|
|
BackgroundGetInfoString1(bg, buf, sizeof(buf));
|
|
|
|
IpcPrintf("%s\n", buf);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
IpcPrintf("Error: background '%s' does not exist.", prm);
|
|
|
|
}
|
|
|
|
else if (!strcmp(cmd, "use"))
|
|
|
|
{
|
|
|
|
if (!strcmp(prm, "-"))
|
|
|
|
bg = NULL;
|
|
|
|
else
|
2006-02-18 00:30:09 -08:00
|
|
|
bg = BackgroundFind(prm);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2005-09-04 00:27:20 -07:00
|
|
|
num = DesksGetCurrentNum();
|
2004-12-28 15:46:49 -08:00
|
|
|
sscanf(p, "%d %n", &num, &len);
|
2005-11-27 03:02:05 -08:00
|
|
|
DeskBackgroundSet(DeskGet(num), bg);
|
2004-12-28 15:46:49 -08:00
|
|
|
autosave();
|
|
|
|
}
|
|
|
|
else if (!strncmp(cmd, "xget", 2))
|
|
|
|
{
|
2006-02-18 00:30:09 -08:00
|
|
|
bg = BackgroundFind(prm);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
if (bg)
|
|
|
|
{
|
|
|
|
BackgroundGetInfoString2(bg, buf, sizeof(buf));
|
|
|
|
IpcPrintf("%s\n", buf);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
IpcPrintf("Error: background '%s' does not exist.", prm);
|
|
|
|
}
|
|
|
|
else if (!strncmp(cmd, "xset", 2))
|
|
|
|
{
|
|
|
|
BackgroundSet2(prm, p);
|
|
|
|
}
|
2005-02-01 12:35:59 -08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Compatibility with pre- 0.16.8 clients */
|
2007-02-25 10:05:53 -08:00
|
|
|
BackgroundSet1(cmd, params + len2);
|
2005-02-01 12:35:59 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
IPC_BackgroundUse(const char *params, Client * c __UNUSED__)
|
|
|
|
{
|
2007-02-25 10:05:53 -08:00
|
|
|
char name[1024];
|
|
|
|
const char *p;
|
2005-02-01 12:35:59 -08:00
|
|
|
Background *bg;
|
2007-02-25 10:05:53 -08:00
|
|
|
int i, l;
|
2005-02-01 12:35:59 -08:00
|
|
|
|
2007-02-25 10:05:53 -08:00
|
|
|
p = params;
|
|
|
|
name[0] = '\0';
|
|
|
|
l = 0;
|
|
|
|
sscanf(p, "%1000s %n", name, &l);
|
|
|
|
p += l;
|
2005-02-01 12:35:59 -08:00
|
|
|
|
2007-02-25 10:05:53 -08:00
|
|
|
bg = BackgroundFind(name);
|
2005-02-01 12:35:59 -08:00
|
|
|
if (!bg)
|
|
|
|
return;
|
|
|
|
|
2007-02-25 10:05:53 -08:00
|
|
|
for (;;)
|
2005-02-01 12:35:59 -08:00
|
|
|
{
|
2007-02-25 10:05:53 -08:00
|
|
|
i = l = -1;
|
|
|
|
sscanf(p, "%d %n", &i, &l);
|
|
|
|
p += l;
|
|
|
|
if (i < 0)
|
2005-02-01 12:35:59 -08:00
|
|
|
break;
|
2005-11-27 03:02:05 -08:00
|
|
|
DeskBackgroundSet(DeskGet(i), bg);
|
2005-02-01 12:35:59 -08:00
|
|
|
}
|
2007-02-25 10:05:53 -08:00
|
|
|
|
2005-02-01 12:35:59 -08:00
|
|
|
autosave();
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
2005-04-15 16:59:59 -07:00
|
|
|
#if ENABLE_COLOR_MODIFIERS
|
2004-12-28 15:46:49 -08:00
|
|
|
static void
|
|
|
|
IPC_BackgroundColormodifierSet(const char *params, Client * c __UNUSED__)
|
|
|
|
{
|
|
|
|
Background *bg;
|
|
|
|
ColorModifierClass *cm;
|
|
|
|
int i;
|
|
|
|
char buf[FILEPATH_LEN_MAX], buf2[FILEPATH_LEN_MAX];
|
|
|
|
|
|
|
|
if (params == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
sscanf(params, "%1000s %1000s", buf, buf2);
|
2006-02-18 00:30:09 -08:00
|
|
|
bg = BackgroundFind(buf);
|
2004-12-28 15:46:49 -08:00
|
|
|
cm = FindItem(buf2, 0, LIST_FINDBY_NAME, LIST_TYPE_COLORMODIFIER);
|
|
|
|
if ((bg) && (bg->cmclass != cm))
|
|
|
|
{
|
|
|
|
if (!strcmp(buf, "(null)"))
|
|
|
|
{
|
|
|
|
bg->cmclass->ref_count--;
|
|
|
|
bg->cmclass = NULL;
|
|
|
|
}
|
|
|
|
else if (cm)
|
|
|
|
{
|
|
|
|
bg->cmclass->ref_count--;
|
|
|
|
bg->cmclass = cm;
|
|
|
|
}
|
2005-11-21 09:48:44 -08:00
|
|
|
|
2005-11-27 03:02:05 -08:00
|
|
|
BackgroundInvalidate(bg, 1);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
IPC_BackgroundColormodifierGet(const char *params, Client * c)
|
|
|
|
{
|
|
|
|
char param1[FILEPATH_LEN_MAX], buf[FILEPATH_LEN_MAX];
|
|
|
|
Background *bg;
|
|
|
|
|
|
|
|
if (params == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
sscanf(params, "%1000s", param1);
|
2006-02-18 00:30:09 -08:00
|
|
|
bg = BackgroundFind(param1);
|
2004-12-28 15:46:49 -08:00
|
|
|
Esnprintf(buf, sizeof(buf), "(null)");
|
|
|
|
if ((bg) && (bg->cmclass))
|
|
|
|
Esnprintf(buf, sizeof(buf), "%s", bg->cmclass->name);
|
|
|
|
CommsSend(c, buf);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2005-10-30 11:40:49 -08:00
|
|
|
static const IpcItem BackgroundsIpcArray[] = {
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
|
|
|
BackgroundsIpc,
|
|
|
|
"background", "bg",
|
|
|
|
"Background commands",
|
|
|
|
" background Show current background\n"
|
|
|
|
" background apply <name> <win> Apply background to window\n"
|
|
|
|
" background cfg Configure backgrounds\n"
|
|
|
|
" background del <name> Delete background\n"
|
|
|
|
" background list Show all background\n"
|
2005-01-28 16:07:20 -08:00
|
|
|
" background load <name> <file> Load new wallpaper from file\n"
|
2004-12-28 15:46:49 -08:00
|
|
|
" background set <name> ... Set background parameters\n"
|
|
|
|
" background show <name> Show background info\n"
|
|
|
|
" background use <name> <desks...> Switch to background <name>\n"
|
|
|
|
" background xget <name> Special show background parameters\n"
|
|
|
|
" background xset <name> ... Special set background parameters\n"}
|
|
|
|
,
|
2005-02-01 12:35:59 -08:00
|
|
|
{
|
|
|
|
IPC_BackgroundUse, "use_bg", NULL, "Deprecated - do not use", NULL}
|
|
|
|
,
|
2005-04-15 16:59:59 -07:00
|
|
|
#if ENABLE_COLOR_MODIFIERS
|
2004-12-28 15:46:49 -08:00
|
|
|
{IPC_BackgroundColormodifierSet, "set_bg_colmod", NULL, "TBD", NULL}
|
|
|
|
,
|
|
|
|
{IPC_BackgroundColormodifierGet, "get_bg_colmod", NULL, "TBD", NULL}
|
|
|
|
,
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
#define N_IPC_FUNCS (sizeof(BackgroundsIpcArray)/sizeof(IpcItem))
|
|
|
|
|
2005-03-20 15:28:59 -08:00
|
|
|
/*
|
|
|
|
* Configuration items
|
|
|
|
*/
|
|
|
|
static const CfgItem BackgroundsCfgItems[] = {
|
|
|
|
CFG_ITEM_BOOL(Conf.backgrounds, hiquality, 1),
|
|
|
|
CFG_ITEM_BOOL(Conf.backgrounds, user, 1),
|
|
|
|
CFG_ITEM_INT(Conf.backgrounds, timeout, 240),
|
|
|
|
};
|
|
|
|
#define N_CFG_ITEMS (sizeof(BackgroundsCfgItems)/sizeof(CfgItem))
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
/*
|
|
|
|
* Module descriptor
|
|
|
|
*/
|
2007-01-16 17:10:44 -08:00
|
|
|
extern const EModule ModBackgrounds;
|
2006-04-21 15:52:59 -07:00
|
|
|
const EModule ModBackgrounds = {
|
2004-12-28 15:46:49 -08:00
|
|
|
"backgrounds", "bg",
|
|
|
|
BackgroundsSighan,
|
2005-03-20 15:28:59 -08:00
|
|
|
{N_IPC_FUNCS, BackgroundsIpcArray},
|
|
|
|
{N_CFG_ITEMS, BackgroundsCfgItems}
|
2004-12-28 15:46:49 -08:00
|
|
|
};
|