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
|
2014-04-19 22:21:05 -07:00
|
|
|
* Copyright (C) 2004-2014 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-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"
|
2013-06-06 13:37:06 -07:00
|
|
|
#include "list.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
|
|
|
|
2008-03-23 04:54:24 -07:00
|
|
|
typedef struct {
|
2004-12-28 15:46:49 -08:00
|
|
|
char *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;
|
|
|
|
|
2008-03-23 04:54:24 -07:00
|
|
|
struct _background {
|
2013-06-06 13:37:06 -07:00
|
|
|
dlist_t list;
|
2004-12-28 15:46:49 -08:00
|
|
|
char *name;
|
2009-12-03 11:29:30 -08:00
|
|
|
EX_Pixmap pmap;
|
2004-12-28 15:46:49 -08:00
|
|
|
time_t last_viewed;
|
2009-09-13 06:45:34 -07:00
|
|
|
unsigned int bg_solid;
|
2004-12-28 15:46:49 -08:00
|
|
|
char bg_tile;
|
|
|
|
BgPart bg;
|
|
|
|
BgPart top;
|
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
|
|
|
|
2013-06-06 13:37:06 -07:00
|
|
|
static LIST_HEAD(bg_list);
|
|
|
|
|
2008-05-24 11:13:17 -07:00
|
|
|
static Timer *bg_timer = 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];
|
|
|
|
|
2010-02-19 11:30:54 -08:00
|
|
|
static char *
|
|
|
|
_BackgroundGetFile(char **ptr)
|
|
|
|
{
|
|
|
|
char *path = *ptr;
|
|
|
|
|
|
|
|
if (isabspath(path))
|
|
|
|
goto done;
|
|
|
|
|
2010-04-02 08:27:58 -07:00
|
|
|
path = ThemeFileFind(path, FILE_TYPE_BACKGROUND);
|
2010-02-19 11:30:54 -08:00
|
|
|
if (!path)
|
|
|
|
goto done;
|
|
|
|
Efree(*ptr);
|
|
|
|
*ptr = path;
|
|
|
|
done:
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
_BackgroundGetBgFile(Background * bg)
|
|
|
|
{
|
|
|
|
if (!bg || !bg->bg.file)
|
|
|
|
return NULL;
|
|
|
|
return _BackgroundGetFile(&bg->bg.file);
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
_BackgroundGetFgFile(Background * bg)
|
|
|
|
{
|
|
|
|
if (!bg || !bg->top.file)
|
|
|
|
return NULL;
|
|
|
|
return _BackgroundGetFile(&bg->top.file);
|
|
|
|
}
|
|
|
|
|
2004-04-10 12:39:02 -07:00
|
|
|
char *
|
2010-02-19 11:30:54 -08:00
|
|
|
BackgroundGetUniqueString(Background * bg)
|
2004-04-10 12:39:02 -07:00
|
|
|
{
|
2012-10-24 10:20:38 -07:00
|
|
|
static const char chmap[] =
|
2004-04-10 12:39:02 -07:00
|
|
|
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_";
|
2010-02-19 11:30:54 -08:00
|
|
|
char s[256], *f;
|
2004-04-10 12:39:02 -07:00
|
|
|
int r, g, b;
|
|
|
|
int n1, n2, n3, n4, n5, f1, f2, f3, f4, f5, f6;
|
|
|
|
|
2009-09-13 06:45:34 -07:00
|
|
|
COLOR32_TO_RGB(bg->bg_solid, r, g, b);
|
2004-04-10 12:39:02 -07:00
|
|
|
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;
|
|
|
|
|
2010-02-19 11:30:54 -08:00
|
|
|
f = _BackgroundGetBgFile(bg);
|
|
|
|
if (f)
|
|
|
|
{
|
|
|
|
f1 = fileinode(f);
|
|
|
|
f2 = filedev(f);
|
|
|
|
f3 = (int)moddate(f);
|
2004-04-10 12:39:02 -07:00
|
|
|
}
|
2010-02-19 11:30:54 -08:00
|
|
|
f = _BackgroundGetFgFile(bg);
|
|
|
|
if (f)
|
2004-04-10 12:39:02 -07:00
|
|
|
{
|
2010-02-19 11:30:54 -08:00
|
|
|
f4 = fileinode(f);
|
|
|
|
f5 = filedev(f);
|
|
|
|
f6 = (int)moddate(f);
|
2004-04-10 12:39:02 -07:00
|
|
|
}
|
2010-02-19 11:30:54 -08:00
|
|
|
|
2004-04-10 12:39:02 -07:00
|
|
|
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
|
2009-12-03 11:29:30 -08:00
|
|
|
BackgroundPixmapSet(Background * bg, EX_Pixmap pmap)
|
2005-11-27 03:02:05 -08:00
|
|
|
{
|
2013-12-28 09:59:09 -08:00
|
|
|
if (bg->pmap != NoXID && bg->pmap != pmap)
|
2009-12-03 11:29:30 -08:00
|
|
|
Eprintf("*** BackgroundPixmapSet %s: pmap was set %#x/%#x\n",
|
2006-02-27 11:14:25 -08:00
|
|
|
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
|
|
|
{
|
2013-12-28 09:59:09 -08:00
|
|
|
EImagePixmapsFree(bg->pmap, NoXID);
|
|
|
|
bg->pmap = NoXID;
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-24 00:31:50 -08:00
|
|
|
#if ENABLE_DIALOGS
|
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
|
|
|
}
|
|
|
|
}
|
2009-01-24 00:31:50 -08:00
|
|
|
#endif /* ENABLE_DIALOGS */
|
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
|
|
|
{
|
2008-02-23 04:09:38 -08:00
|
|
|
Efree(bg->bg.file);
|
2004-04-10 12:39:02 -07:00
|
|
|
bg->bg.file = NULL;
|
|
|
|
|
2008-02-23 04:09:38 -08:00
|
|
|
Efree(bg->top.file);
|
2004-04-12 01:28:34 -07:00
|
|
|
bg->top.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;
|
2010-02-19 11:30:54 -08:00
|
|
|
#if 0
|
|
|
|
Eprintf("%s: %s\n", __func__, bg->name);
|
|
|
|
#endif
|
2004-04-10 12:39:02 -07:00
|
|
|
if (bg->ref_count > 0)
|
|
|
|
{
|
2010-05-09 12:03:19 -07:00
|
|
|
DialogOK("Background Error!", _("%u references remain"), bg->ref_count);
|
2005-01-25 13:58:28 -08:00
|
|
|
return -1;
|
2004-04-10 12:39:02 -07:00
|
|
|
}
|
|
|
|
|
2013-06-06 13:37:06 -07:00
|
|
|
LIST_REMOVE(Background, &bg_list, bg);
|
2006-02-18 00:30:09 -08:00
|
|
|
|
2005-11-27 03:02:05 -08:00
|
|
|
BackgroundFilesRemove(bg);
|
|
|
|
BackgroundPixmapFree(bg);
|
2004-04-10 12:39:02 -07:00
|
|
|
|
2008-02-23 04:09:38 -08:00
|
|
|
Efree(bg->name);
|
2004-04-10 12:39:02 -07:00
|
|
|
|
|
|
|
Efree(bg);
|
|
|
|
|
2005-01-25 13:58:28 -08:00
|
|
|
return 0;
|
2004-04-12 01:28:34 -07:00
|
|
|
}
|
|
|
|
|
2009-01-24 00:31:50 -08:00
|
|
|
#if ENABLE_DIALOGS
|
2004-12-28 15:46:49 -08:00
|
|
|
static void
|
2004-04-12 01:28:34 -07:00
|
|
|
BackgroundDelete(Background * bg)
|
|
|
|
{
|
|
|
|
char *f;
|
|
|
|
|
2010-02-19 11:30:54 -08:00
|
|
|
if (!bg)
|
|
|
|
return;
|
|
|
|
#if 0
|
|
|
|
Eprintf("%s: %s\n", __func__, bg->name);
|
|
|
|
#endif
|
2010-07-13 19:05:47 -07:00
|
|
|
if (bg->ref_count > 0)
|
2005-01-25 13:58:28 -08:00
|
|
|
return;
|
2004-04-12 01:28:34 -07:00
|
|
|
|
|
|
|
/* And delete the actual image files */
|
2010-02-19 11:30:54 -08:00
|
|
|
f = _BackgroundGetBgFile(bg);
|
|
|
|
if (f)
|
|
|
|
E_rm(f);
|
|
|
|
f = _BackgroundGetFgFile(bg);
|
|
|
|
if (f)
|
|
|
|
E_rm(f);
|
|
|
|
|
|
|
|
BackgroundDestroy(bg);
|
2004-04-10 12:39:02 -07:00
|
|
|
}
|
2009-01-24 00:31:50 -08:00
|
|
|
#endif /* ENABLE_DIALOGS */
|
2004-04-10 12:39:02 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
static Background *
|
2009-09-13 06:45:34 -07:00
|
|
|
BackgroundCreate(const char *name, unsigned int solid, const char *bgn,
|
|
|
|
char tile, char keep_aspect, int xjust, int yjust, int xperc,
|
2004-04-10 12:39:02 -07:00
|
|
|
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;
|
|
|
|
|
2009-09-13 06:45:34 -07:00
|
|
|
if (!name)
|
|
|
|
{
|
|
|
|
name = "NONE";
|
|
|
|
bg->external = 1;
|
|
|
|
}
|
2004-04-12 01:28:34 -07:00
|
|
|
bg->name = Estrdup(name);
|
2004-04-10 12:39:02 -07:00
|
|
|
|
2009-09-13 06:45:34 -07:00
|
|
|
COLOR32_FROM_RGB(bg->bg_solid, 160, 160, 160);
|
|
|
|
bg->bg_solid = solid;
|
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;
|
|
|
|
|
2013-06-06 13:37:06 -07:00
|
|
|
LIST_PREPEND(Background, &bg_list, bg);
|
2006-12-26 14:39:13 -08:00
|
|
|
|
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
|
2010-02-19 11:30:54 -08:00
|
|
|
BackgroundCmp(const Background * bg, const Background * bgx)
|
2006-12-26 14:39:13 -08:00
|
|
|
{
|
2008-11-22 13:16:59 -08:00
|
|
|
if (*bgx->name != '.') /* Discard only generated backgrounds */
|
|
|
|
return 1;
|
|
|
|
|
2006-12-26 14:39:13 -08:00
|
|
|
if (bg->bg.file && bgx->bg.file)
|
|
|
|
{
|
|
|
|
if ((strcmp(bg->bg.file, bgx->bg.file)) ||
|
|
|
|
(bg->bg.keep_aspect != bgx->bg.keep_aspect) ||
|
2010-08-29 06:45:57 -07:00
|
|
|
(bg->bg.xjust != bgx->bg.xjust) ||
|
|
|
|
(bg->bg.yjust != bgx->bg.yjust) ||
|
|
|
|
(bg->bg.xperc != bgx->bg.xperc) || (bg->bg.yperc != bgx->bg.yperc))
|
2006-12-26 14:39:13 -08:00
|
|
|
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) ||
|
2010-08-29 06:45:57 -07:00
|
|
|
(bg->top.xjust != bgx->top.xjust) ||
|
|
|
|
(bg->top.yjust != bgx->top.yjust) ||
|
|
|
|
(bg->top.xperc != bgx->top.xperc) ||
|
|
|
|
(bg->top.yperc != bgx->top.yperc))
|
2006-12-26 14:39:13 -08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if (bg->top.file || bgx->top.file)
|
|
|
|
return 1;
|
|
|
|
|
2009-09-13 06:45:34 -07:00
|
|
|
if (bg->bg_solid != bgx->bg_solid)
|
2006-12-26 14:39:13 -08:00
|
|
|
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)
|
|
|
|
{
|
2013-06-06 13:37:06 -07:00
|
|
|
return LIST_FIND(Background, &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)
|
|
|
|
{
|
2013-06-06 13:37:06 -07:00
|
|
|
return LIST_CHECK(Background, &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
|
2009-09-13 06:45:34 -07:00
|
|
|
BackgroundModify(Background * bg, unsigned int solid, const char *bgn,
|
|
|
|
char tile, char keep_aspect, int xjust, int yjust, int xperc,
|
2004-12-28 15:46:49 -08:00
|
|
|
int yperc, const char *top, char tkeep_aspect, int txjust,
|
|
|
|
int tyjust, int txperc, int typerc)
|
|
|
|
{
|
|
|
|
int updated = 0;
|
|
|
|
|
2009-09-13 06:45:34 -07:00
|
|
|
if (solid != bg->bg_solid)
|
2004-12-28 15:46:49 -08:00
|
|
|
updated = 1;
|
2009-09-13 06:45:34 -07:00
|
|
|
bg->bg_solid = solid;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
if ((bg->bg.file) && (bgn))
|
|
|
|
{
|
|
|
|
if (strcmp(bg->bg.file, bgn))
|
|
|
|
updated = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
updated = 1;
|
2008-02-23 04:09:38 -08:00
|
|
|
Efree(bg->bg.file);
|
2010-05-02 13:26:47 -07:00
|
|
|
bg->bg.file = (bgn && bgn[0]) ? Estrdup(bgn) : NULL;
|
2004-12-28 15:46:49 -08:00
|
|
|
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;
|
2008-02-23 04:09:38 -08:00
|
|
|
Efree(bg->top.file);
|
2010-05-02 13:26:47 -07:00
|
|
|
bg->top.file = (top && top[0]) ? Estrdup(top) : NULL;
|
2004-12-28 15:46:49 -08:00
|
|
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2008-03-26 16:19:42 -07:00
|
|
|
#if 0 /* FIXME - Remove? */
|
2006-01-05 14:20:00 -08:00
|
|
|
if (bgp->keep_aspect)
|
|
|
|
bgp->xperc = bgp->yperc;
|
2008-03-26 16:19:42 -07:00
|
|
|
#endif
|
2006-01-05 14:20:00 -08:00
|
|
|
|
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
|
2008-03-24 04:12:40 -07:00
|
|
|
w = (iw * rw) / WinGetW(VROOT);
|
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
|
2008-03-24 04:12:40 -07:00
|
|
|
h = (ih * rh) / WinGetH(VROOT);
|
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
|
|
|
}
|
|
|
|
|
2009-12-03 11:29:30 -08:00
|
|
|
static EX_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
|
|
|
{
|
2009-12-03 11:29:30 -08:00
|
|
|
EX_Pixmap pmap;
|
2005-08-13 01:50:28 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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);
|
2008-03-24 03:24:28 -07:00
|
|
|
if (win == RROOT && 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);
|
2013-12-28 09:59:09 -08:00
|
|
|
Mode.root.ext_pmap = NoXID;
|
2006-02-27 11:14:25 -08:00
|
|
|
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
|
2009-12-03 11:29:30 -08:00
|
|
|
BackgroundRealize(Background * bg, Win win, EX_Drawable draw,
|
|
|
|
unsigned int rw, unsigned int rh, int is_win,
|
|
|
|
EX_Pixmap * ppmap, unsigned int *ppixel)
|
2005-07-24 05:22:19 -07:00
|
|
|
{
|
2009-12-03 11:29:30 -08:00
|
|
|
EX_Pixmap pmap;
|
2006-03-29 11:13:17 -08:00
|
|
|
int x, y, ww, hh;
|
|
|
|
unsigned int w, h;
|
2010-02-19 11:30:54 -08:00
|
|
|
char *file, hasbg, hasfg;
|
2006-03-29 11:13:17 -08:00
|
|
|
EImage *im;
|
2005-04-15 16:59:59 -07:00
|
|
|
|
2010-02-19 11:30:54 -08:00
|
|
|
if (!bg->bg.im)
|
2005-07-24 05:22:19 -07:00
|
|
|
{
|
2010-02-19 11:30:54 -08:00
|
|
|
file = _BackgroundGetBgFile(bg);
|
|
|
|
if (file)
|
|
|
|
bg->bg.im = EImageLoad(file);
|
2005-07-24 05:22:19 -07:00
|
|
|
}
|
2004-04-10 12:39:02 -07:00
|
|
|
|
2010-02-19 11:30:54 -08:00
|
|
|
if (!bg->top.im)
|
2005-07-24 05:22:19 -07:00
|
|
|
{
|
2010-02-19 11:30:54 -08:00
|
|
|
file = _BackgroundGetFgFile(bg);
|
|
|
|
if (file)
|
|
|
|
bg->top.im = EImageLoad(bg->top.file);
|
2005-07-24 05:22:19 -07:00
|
|
|
}
|
2004-04-10 12:39:02 -07:00
|
|
|
|
2006-05-28 04:51:42 -07:00
|
|
|
if (!draw)
|
|
|
|
draw = WinGetXwin(win);
|
|
|
|
|
2010-08-21 07:39:55 -07:00
|
|
|
hasbg = ! !bg->bg.im;
|
|
|
|
hasfg = ! !bg->top.im;
|
2004-04-10 12:39:02 -07:00
|
|
|
|
2005-07-24 05:22:19 -07:00
|
|
|
if (!hasbg && !hasfg)
|
|
|
|
{
|
2009-09-13 06:45:34 -07:00
|
|
|
unsigned int pixel;
|
|
|
|
|
2005-07-24 05:22:19 -07:00
|
|
|
/* Solid color only */
|
2009-09-13 06:45:34 -07:00
|
|
|
pixel = EAllocColor(WinGetCmap(VROOT), bg->bg_solid);
|
2004-04-10 12:39:02 -07:00
|
|
|
|
2005-11-22 15:21:47 -08:00
|
|
|
if (!is_win)
|
2013-12-28 13:35:10 -08:00
|
|
|
EXFillAreaSolid(draw, 0, 0, rw, rh, pixel);
|
|
|
|
|
2005-11-22 15:21:47 -08:00
|
|
|
if (ppmap)
|
2013-12-28 09:59:09 -08:00
|
|
|
*ppmap = NoXID;
|
2005-11-22 15:21:47 -08:00
|
|
|
if (ppixel)
|
2009-09-13 06:45:34 -07:00
|
|
|
*ppixel = pixel;
|
2005-11-22 15:21:47 -08:00
|
|
|
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);
|
2007-04-07 09:18:53 -07:00
|
|
|
EImageRenderOnDrawable(bg->bg.im, win, pmap, EIMAGE_ANTI_ALIAS,
|
|
|
|
0, 0, w, h);
|
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 */
|
2009-09-13 06:45:34 -07:00
|
|
|
EImageFill(im, 0, 0, rw, rh, bg->bg_solid);
|
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);
|
2007-04-07 09:18:53 -07:00
|
|
|
EImageBlend(im, bg->bg.im, EIMAGE_ANTI_ALIAS, 0, 0, ww, hh,
|
|
|
|
x, y, w, h, 1);
|
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;
|
|
|
|
|
2007-04-07 09:18:53 -07:00
|
|
|
EImageBlend(im, bg->top.im, EIMAGE_BLEND | EIMAGE_ANTI_ALIAS,
|
|
|
|
0, 0, ww, hh, x, y, w, h, 0);
|
2005-07-24 05:22:19 -07:00
|
|
|
}
|
|
|
|
|
2007-04-07 09:18:53 -07:00
|
|
|
EImageRenderOnDrawable(im, win, pmap, EIMAGE_ANTI_ALIAS, 0, 0, rw, rh);
|
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
|
2009-12-03 11:29:30 -08:00
|
|
|
BackgroundApplyPmap(Background * bg, Win win, EX_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;
|
2009-12-03 11:29:30 -08:00
|
|
|
EX_Pixmap pmap;
|
2012-01-08 04:54:08 -08:00
|
|
|
unsigned int pixel;
|
2005-11-22 15:21:47 -08:00
|
|
|
|
|
|
|
if (!EGetGeometry(win, NULL, NULL, NULL, &w, &h, NULL, NULL))
|
|
|
|
return;
|
|
|
|
|
2013-12-28 09:59:09 -08:00
|
|
|
BackgroundRealize(bg, win, NoXID, w, h, 1, &pmap, &pixel);
|
|
|
|
if (pmap != NoXID)
|
2005-11-27 03:02:05 -08:00
|
|
|
{
|
2014-04-19 22:21:05 -07:00
|
|
|
ESetWindowBackgroundPixmap(win, pmap, 0);
|
2013-12-28 09:59:09 -08:00
|
|
|
EImagePixmapsFree(pmap, NoXID);
|
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
|
|
|
{
|
2009-12-03 11:29:30 -08:00
|
|
|
EX_Pixmap pmap = NoXID;
|
2012-01-08 04:54:08 -08:00
|
|
|
unsigned int pixel = 0;
|
2005-07-24 05:22:19 -07:00
|
|
|
|
|
|
|
if (bg->pmap)
|
|
|
|
pmap = bg->pmap;
|
|
|
|
else
|
2013-12-28 09:59:09 -08:00
|
|
|
BackgroundRealize(bg, win, NoXID, w, h, 1, &pmap, &pixel);
|
2005-07-24 05:22:19 -07:00
|
|
|
|
|
|
|
bg->pmap = pmap;
|
2013-12-28 09:59:09 -08:00
|
|
|
if (pmap != NoXID)
|
2014-04-19 22:21:05 -07:00
|
|
|
ESetWindowBackgroundPixmap(win, pmap, 1);
|
2005-07-24 05:22:19 -07:00
|
|
|
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;
|
2009-09-13 06:45:34 -07:00
|
|
|
unsigned int color;
|
2004-12-28 15:46:49 -08:00
|
|
|
char tile = 1, keep_asp = 0;
|
|
|
|
int width, height;
|
|
|
|
int scalex = 0, scaley = 0;
|
|
|
|
int scr_asp, im_asp;
|
|
|
|
int w2, h2;
|
2011-05-01 03:51:59 -07:00
|
|
|
int maxw = Mode.backgrounds.mini_w;
|
|
|
|
int maxh = Mode.backgrounds.mini_h;
|
2004-12-28 15:46:49 -08:00
|
|
|
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;
|
|
|
|
|
2008-03-24 04:12:40 -07:00
|
|
|
scr_asp = (WinGetW(VROOT) << 16) / WinGetH(VROOT);
|
2004-12-28 15:46:49 -08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2009-09-13 06:45:34 -07:00
|
|
|
COLOR32_FROM_RGB(color, 0, 0, 0);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2009-09-13 06:45:34 -07:00
|
|
|
bg = BackgroundCreate(bgid, color, file, tile,
|
2004-12-28 15:46:49 -08:00
|
|
|
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)
|
|
|
|
{
|
2010-08-13 10:04:13 -07:00
|
|
|
if (!bg)
|
2004-04-12 01:28:34 -07:00
|
|
|
return;
|
|
|
|
bg->ref_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
BackgroundDecRefcount(Background * bg)
|
|
|
|
{
|
2010-08-13 10:04:13 -07:00
|
|
|
if (!bg)
|
2004-04-12 01:28:34 -07:00
|
|
|
return;
|
|
|
|
bg->ref_count--;
|
|
|
|
if (bg->ref_count <= 0)
|
|
|
|
bg->last_viewed = 0; /* Clean out asap */
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
BackgroundTouch(Background * bg)
|
|
|
|
{
|
2010-08-13 10:04:13 -07:00
|
|
|
if (!bg)
|
2004-04-12 01:28:34 -07:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2009-01-24 00:31:50 -08:00
|
|
|
#if ENABLE_DIALOGS
|
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;
|
|
|
|
}
|
2009-01-24 00:31:50 -08:00
|
|
|
#endif /* ENABLE_DIALOGS */
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2009-12-03 11:29:30 -08:00
|
|
|
EX_Pixmap
|
2004-04-12 01:28:34 -07:00
|
|
|
BackgroundGetPixmap(const Background * bg)
|
|
|
|
{
|
2013-12-28 09:59:09 -08:00
|
|
|
return (bg) ? bg->pmap : NoXID;
|
2004-04-12 01:28:34 -07:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2009-01-24 00:31:50 -08:00
|
|
|
#if ENABLE_DIALOGS
|
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;
|
2009-12-03 11:29:30 -08:00
|
|
|
EX_Pixmap pmap;
|
2011-05-01 03:51:59 -07:00
|
|
|
int mini_w = Mode.backgrounds.mini_w;
|
|
|
|
int mini_h = Mode.backgrounds.mini_h;
|
2005-07-24 05:22:19 -07:00
|
|
|
|
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 */
|
2011-05-01 03:51:59 -07:00
|
|
|
pmap = ECreatePixmap(VROOT, mini_w, mini_h, 0);
|
|
|
|
BackgroundApplyPmap(bg, VROOT, pmap, mini_w, mini_h);
|
2013-12-28 09:59:09 -08:00
|
|
|
im = EImageGrabDrawable(pmap, NoXID, 0, 0, mini_w, mini_h, 0);
|
2006-03-29 11:13:17 -08:00
|
|
|
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
|
|
|
}
|
2009-01-24 00:31:50 -08:00
|
|
|
#endif /* ENABLE_DIALOGS */
|
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;
|
|
|
|
|
2009-09-13 06:45:34 -07:00
|
|
|
COLOR32_TO_RGB(bg->bg_solid, r, g, b);
|
2004-12-28 15:46:49 -08:00
|
|
|
Esnprintf(buf, len,
|
|
|
|
"%s ref_count %u keepim %u\n"
|
2010-05-09 12:03:16 -07:00
|
|
|
" bg.solid\t %i %i %i\n"
|
2004-12-28 15:46:49 -08:00
|
|
|
" bg.file\t %s\n"
|
2010-05-09 12:03:16 -07:00
|
|
|
" 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,
|
2004-12-28 15:46:49 -08:00
|
|
|
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;
|
|
|
|
|
2009-09-13 06:45:34 -07:00
|
|
|
COLOR32_TO_RGB(bg->bg_solid, r, g, b);
|
2004-12-28 15:46:49 -08:00
|
|
|
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
|
|
|
|
2013-06-06 13:37:06 -07:00
|
|
|
LIST_FOR_EACH(Background, &bg_list, bg) BackgroundInvalidate(bg, refresh);
|
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
|
|
|
BackgroundGetRandom(void)
|
|
|
|
{
|
|
|
|
Background *bg;
|
|
|
|
int num;
|
|
|
|
unsigned int rnd;
|
|
|
|
|
2013-06-06 13:37:06 -07:00
|
|
|
num = LIST_GET_COUNT(&bg_list);
|
2006-02-18 00:30:09 -08:00
|
|
|
for (;;)
|
|
|
|
{
|
2013-06-06 13:37:06 -07:00
|
|
|
rnd = rand() % num;
|
|
|
|
bg = LIST_GET_BY_INDEX(Background, &bg_list, rnd);
|
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;
|
2009-09-13 06:45:34 -07:00
|
|
|
unsigned int color;
|
2004-12-28 15:46:49 -08:00
|
|
|
char s[FILEPATH_LEN_MAX];
|
|
|
|
char s2[FILEPATH_LEN_MAX];
|
2011-05-01 03:52:05 -07:00
|
|
|
char *p2, *p3;
|
2004-12-28 15:46:49 -08:00
|
|
|
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;
|
2008-10-24 12:21:55 -07:00
|
|
|
int desk;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2009-09-13 06:45:34 -07:00
|
|
|
COLOR32_FROM_RGB(color, 0, 0, 0);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
while (GetLine(s, sizeof(s), fs))
|
|
|
|
{
|
2011-05-01 03:52:05 -07:00
|
|
|
ii1 = ConfigParseline1(s, s2, &p2, &p3);
|
2004-12-28 15:46:49 -08:00
|
|
|
switch (ii1)
|
|
|
|
{
|
|
|
|
case CONFIG_CLOSE:
|
2011-05-01 03:52:05 -07:00
|
|
|
if (!bg)
|
|
|
|
goto done;
|
2011-05-10 08:43:37 -07:00
|
|
|
bg->bg_solid = color;
|
2011-05-01 03:52:05 -07:00
|
|
|
bg->bg.file = bg1;
|
|
|
|
bg->top.file = bg2;
|
|
|
|
bg1 = bg2 = NULL;
|
|
|
|
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;
|
|
|
|
bg->top.keep_aspect = j1;
|
|
|
|
bg->top.xjust = j2;
|
|
|
|
bg->top.yjust = j3;
|
|
|
|
bg->top.xperc = j4;
|
|
|
|
bg->top.yperc = j5;
|
2004-12-28 15:46:49 -08:00
|
|
|
goto done;
|
|
|
|
|
|
|
|
case CONFIG_COLORMOD:
|
|
|
|
case ICLASS_COLORMOD:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CONFIG_CLASSNAME:
|
|
|
|
case BG_NAME:
|
2006-02-18 00:30:09 -08:00
|
|
|
bg = BackgroundFind(s2);
|
2011-05-01 03:52:05 -07:00
|
|
|
if (!bg)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2011-05-01 03:52:05 -07:00
|
|
|
bg = BackgroundCreate(s2, color,
|
|
|
|
bg1, i1, i2, i3, i4, i5, i6,
|
|
|
|
bg2, j1, j2, j3, j4, j5);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-05-10 08:43:37 -07:00
|
|
|
color = bg->bg_solid;
|
2011-05-01 03:52:05 -07:00
|
|
|
Efree(bg1);
|
|
|
|
Efree(bg2);
|
|
|
|
bg1 = bg->bg.file;
|
|
|
|
bg2 = bg->top.file;
|
|
|
|
bg->bg.file = NULL;
|
|
|
|
bg->top.file = NULL;
|
|
|
|
i1 = bg->bg_tile;
|
|
|
|
i2 = bg->bg.keep_aspect;
|
|
|
|
i3 = bg->bg.xjust;
|
|
|
|
i4 = bg->bg.yjust;
|
|
|
|
i5 = bg->bg.xperc;
|
|
|
|
i6 = bg->bg.yperc;
|
|
|
|
j1 = bg->top.keep_aspect;
|
|
|
|
j2 = bg->top.xjust;
|
|
|
|
j3 = bg->top.yjust;
|
|
|
|
j4 = bg->top.xperc;
|
|
|
|
j5 = bg->top.yperc;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BG_DESKNUM:
|
2008-10-24 12:16:38 -07:00
|
|
|
if (!bg)
|
|
|
|
break;
|
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;
|
2008-10-24 12:21:55 -07:00
|
|
|
if (desk >= 0)
|
|
|
|
{
|
|
|
|
if (!bg_assigned[desk] || Conf.backgrounds.user)
|
|
|
|
{
|
|
|
|
bg_assigned[desk] = bg;
|
|
|
|
bg->referenced = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2006-12-26 14:39:13 -08:00
|
|
|
bg->referenced = 1;
|
2008-10-24 12:21:55 -07:00
|
|
|
for (ii1 = 0; ii1 < N_BG_ASSIGNED; ii1++)
|
|
|
|
{
|
|
|
|
if (!bg_assigned[ii1])
|
|
|
|
bg_assigned[ii1] = bg;
|
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BG_RGB:
|
|
|
|
r = g = b = 0;
|
2011-05-01 03:52:05 -07:00
|
|
|
sscanf(p2, "%d %d %d", &r, &g, &b);
|
2009-09-13 06:45:34 -07:00
|
|
|
COLOR32_FROM_RGB(color, r, g, b);
|
2004-12-28 15:46:49 -08:00
|
|
|
break;
|
|
|
|
|
2011-05-01 03:52:05 -07:00
|
|
|
case BG_BG_FILE:
|
|
|
|
Efree(bg1);
|
2011-05-10 08:43:34 -07:00
|
|
|
bg1 = Estrdup(p2);
|
2011-05-01 03:52:05 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BG_BG_PARAM:
|
|
|
|
sscanf(p2, "%d %d %d %d %d %d", &i1, &i2, &i3, &i4, &i5, &i6);
|
|
|
|
break;
|
|
|
|
|
|
|
|
#if 1 /* Obsolete - backward compatibility */
|
2004-12-28 15:46:49 -08:00
|
|
|
case BG_BG1:
|
2011-05-01 03:52:05 -07:00
|
|
|
sscanf(p3, "%d %d %d %d %d %d", &i1, &i2, &i3, &i4, &i5, &i6);
|
2011-05-10 08:43:34 -07:00
|
|
|
Efree(bg1);
|
|
|
|
bg1 = Estrdup(s2);
|
|
|
|
break;
|
2011-05-01 03:52:05 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
case BG_TOP_FILE:
|
|
|
|
Efree(bg2);
|
2011-05-10 08:43:34 -07:00
|
|
|
bg2 = Estrdup(p2);
|
2004-12-28 15:46:49 -08:00
|
|
|
break;
|
|
|
|
|
2011-05-01 03:52:05 -07:00
|
|
|
case BG_TOP_PARAM:
|
|
|
|
sscanf(p2, "%d %d %d %d %d", &j1, &j2, &j3, &j4, &j5);
|
2004-12-28 15:46:49 -08:00
|
|
|
break;
|
|
|
|
|
2011-05-01 03:52:05 -07:00
|
|
|
#if 1 /* Obsolete - backward compatibility */
|
|
|
|
case BG_BG2:
|
|
|
|
sscanf(p3, "%d %d %d %d %d", &j1, &j2, &j3, &j4, &j5);
|
2011-05-10 08:43:34 -07:00
|
|
|
Efree(bg2);
|
|
|
|
bg2 = Estrdup(s2);
|
|
|
|
break;
|
2011-05-01 03:52:05 -07:00
|
|
|
#endif
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
err = -1;
|
|
|
|
|
|
|
|
done:
|
2008-02-23 04:09:38 -08:00
|
|
|
Efree(bg1);
|
|
|
|
Efree(bg2);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
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];
|
|
|
|
|
2011-05-01 03:52:05 -07:00
|
|
|
Esnprintf(s, sizeof(s), "%s.bg", EGetSavePrefix());
|
2009-05-06 10:17:31 -07:00
|
|
|
if (!exists(s))
|
2011-05-01 03:52:05 -07:00
|
|
|
{
|
|
|
|
Mode.backgrounds.force_scan = 1;
|
|
|
|
Esnprintf(s, sizeof(s), "%s.backgrounds", EGetSavePrefix());
|
|
|
|
if (!exists(s))
|
|
|
|
return;
|
|
|
|
}
|
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;
|
2013-06-06 13:37:06 -07:00
|
|
|
int r, g, b;
|
2005-03-05 04:19:48 -08:00
|
|
|
|
|
|
|
Etmp(st);
|
|
|
|
fs = fopen(st, "w");
|
|
|
|
if (!fs)
|
|
|
|
return;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2013-07-10 01:38:12 -07:00
|
|
|
/* For obscure reasons, store backgrounds in reverse order. */
|
2013-06-06 13:37:06 -07:00
|
|
|
LIST_FOR_EACH_REV(Background, &bg_list, bg)
|
|
|
|
{
|
|
|
|
/* Get full path to files */
|
|
|
|
_BackgroundGetBgFile(bg);
|
|
|
|
_BackgroundGetFgFile(bg);
|
|
|
|
/* Discard if bg file is given but cannot be found (ignore bad fg) */
|
|
|
|
if (bg->bg.file && !exists(bg->bg.file))
|
|
|
|
{
|
|
|
|
Eprintf("Discard broken background %s (%s)\n",
|
|
|
|
bg->name, bg->bg.file);
|
2006-02-18 00:30:09 -08:00
|
|
|
continue;
|
2013-06-06 13:37:06 -07:00
|
|
|
}
|
2006-02-18 00:30:09 -08:00
|
|
|
|
2013-06-06 13:37:06 -07:00
|
|
|
fprintf(fs, "5 999\n");
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2013-06-06 13:37:06 -07:00
|
|
|
fprintf(fs, "100 %s\n", bg->name);
|
|
|
|
COLOR32_TO_RGB(bg->bg_solid, r, g, b);
|
|
|
|
if (r != 0 || g != 0 || b != 0)
|
|
|
|
fprintf(fs, "%d %d %d %d\n", BG_RGB, r, g, b);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2013-06-06 13:37:06 -07:00
|
|
|
if (bg->bg.file)
|
|
|
|
{
|
|
|
|
fprintf(fs, "%d %s\n", BG_BG_FILE, bg->bg.file);
|
|
|
|
fprintf(fs, "%d %d %d %d %d %d %d\n", BG_BG_PARAM,
|
|
|
|
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
|
|
|
|
2013-06-06 13:37:06 -07:00
|
|
|
if (bg->top.file)
|
|
|
|
{
|
|
|
|
fprintf(fs, "%d %s\n", BG_TOP_FILE, bg->top.file);
|
|
|
|
fprintf(fs, "%d %d %d %d %d %d\n", BG_TOP_PARAM,
|
|
|
|
bg->top.keep_aspect,
|
|
|
|
bg->top.xjust, bg->top.yjust, bg->top.xperc, bg->top.yperc);
|
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2013-06-06 13:37:06 -07:00
|
|
|
for (j = 0; j < N_BG_ASSIGNED; j++)
|
|
|
|
{
|
|
|
|
if (bg == bg_assigned[j])
|
|
|
|
fprintf(fs, "%d %u\n", BG_DESKNUM, j);
|
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2013-06-06 13:37:06 -07:00
|
|
|
fprintf(fs, "1000\n");
|
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2005-03-05 04:19:48 -08:00
|
|
|
fclose(fs);
|
|
|
|
|
2011-05-01 03:52:05 -07:00
|
|
|
Esnprintf(s, sizeof(s), "%s.bg", EGetSavePrefix());
|
2005-03-05 04:19:48 -08:00
|
|
|
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)
|
|
|
|
{
|
2013-06-06 13:37:06 -07:00
|
|
|
Background *bg, *bgx, *btmp;
|
2006-12-26 14:39:13 -08:00
|
|
|
|
2013-06-06 13:37:06 -07:00
|
|
|
LIST_FOR_EACH(Background, &bg_list, bg)
|
|
|
|
{
|
|
|
|
bgx = LIST_NEXT(Background, &bg_list, bg);
|
|
|
|
for (; bgx; bgx = btmp)
|
|
|
|
{
|
|
|
|
btmp = LIST_NEXT(Background, &bg_list, bgx);
|
2006-12-26 14:39:13 -08:00
|
|
|
|
2013-06-06 13:37:06 -07:00
|
|
|
if (bgx->ref_count > 0 || bgx->referenced)
|
|
|
|
continue;
|
|
|
|
if (BackgroundCmp(bg, bgx))
|
|
|
|
continue;
|
2011-06-19 07:36:47 -07:00
|
|
|
#if 0
|
2013-06-06 13:37:06 -07:00
|
|
|
Eprintf("Remove duplicate background %s (==%s)\n", bgx->name,
|
|
|
|
bg->name);
|
2006-12-26 14:39:13 -08:00
|
|
|
#endif
|
2013-06-06 13:37:06 -07:00
|
|
|
BackgroundDestroy(bgx);
|
|
|
|
}
|
|
|
|
}
|
2006-12-26 14:39:13 -08:00
|
|
|
}
|
|
|
|
|
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);
|
2013-06-06 13:37:06 -07:00
|
|
|
LIST_FOR_EACH(Background, &bg_list, bg)
|
2006-02-18 00:30:09 -08:00
|
|
|
{
|
|
|
|
/* Skip if no pixmap or not timed out */
|
2013-12-28 09:59:09 -08:00
|
|
|
if (bg->pmap == NoXID ||
|
2006-02-27 11:14:25 -08:00
|
|
|
((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
|
|
|
}
|
|
|
|
|
2008-05-24 11:13:17 -07:00
|
|
|
static int
|
|
|
|
BackgroundsTimeout(void *data __UNUSED__)
|
2004-04-10 12:39:02 -07:00
|
|
|
{
|
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
|
|
|
|
2011-01-05 10:05:57 -08:00
|
|
|
TimerSetInterval(bg_timer, 1000 * Conf.backgrounds.timeout);
|
2008-05-24 11:13:17 -07:00
|
|
|
|
|
|
|
return 1;
|
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:
|
2013-07-10 01:38:12 -07:00
|
|
|
/* Create the "None" background */
|
2009-09-13 06:45:34 -07:00
|
|
|
BackgroundCreate(NULL, 0, NULL, 0, 0, 0, 0, 0, 0, NULL, 0, 0, 0, 0, 0);
|
2004-12-28 15:46:49 -08:00
|
|
|
break;
|
2005-03-05 04:19:48 -08:00
|
|
|
|
|
|
|
case ESIGNAL_CONFIGURE:
|
|
|
|
BackgroundsConfigLoadUser();
|
2006-12-26 14:39:13 -08:00
|
|
|
BackgroundsCheckDups();
|
2009-05-01 10:14:05 -07:00
|
|
|
StartupBackgroundsDestroy();
|
2005-03-05 04:19:48 -08:00
|
|
|
break;
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
case ESIGNAL_START:
|
2011-01-05 10:05:57 -08:00
|
|
|
TIMER_ADD(bg_timer, 30000, BackgroundsTimeout, NULL);
|
2004-12-28 15:46:49 -08:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-24 00:31:50 -08:00
|
|
|
#if ENABLE_DIALOGS
|
2004-12-28 15:46:49 -08:00
|
|
|
/*
|
|
|
|
* Configuration dialog
|
|
|
|
*/
|
2009-11-01 13:22:39 -08:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
DItem *bg_sel;
|
|
|
|
DItem *bg_sel_slider;
|
|
|
|
DItem *bg_mini_disp;
|
|
|
|
DItem *bg_filename;
|
|
|
|
DItem *di[10]; /* Various dialog items */
|
|
|
|
|
|
|
|
Background *bg; /* The background being configured */
|
|
|
|
int bg_sel_sliderval;
|
|
|
|
int bg_sel_sliderval_old;
|
|
|
|
int bg_r;
|
|
|
|
int bg_g;
|
|
|
|
int bg_b;
|
|
|
|
char bg_image;
|
|
|
|
char bg_tile;
|
|
|
|
char bg_keep_aspect;
|
|
|
|
int bg_xjust;
|
|
|
|
int bg_yjust;
|
|
|
|
int bg_xperc;
|
|
|
|
int bg_yperc;
|
|
|
|
char hiq;
|
|
|
|
char userbg;
|
|
|
|
char root_hint;
|
|
|
|
int bg_timeout;
|
|
|
|
} BgDlgData;
|
|
|
|
|
|
|
|
static void BG_RedrawView(Dialog * d);
|
|
|
|
static void BGSettingsGoTo(Dialog * d, Background * bg);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
static void
|
2009-11-01 13:22:39 -08:00
|
|
|
CB_ConfigureBG(Dialog * d, int val, void *data __UNUSED__)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2009-11-01 13:22:39 -08:00
|
|
|
BgDlgData *dd = DLG_DATA_GET(d, BgDlgData);
|
|
|
|
|
2006-09-02 07:33:14 -07:00
|
|
|
if (val == 2)
|
2005-07-24 05:22:19 -07:00
|
|
|
{
|
2009-11-01 13:22:39 -08:00
|
|
|
BackgroundImagesKeep(dd->bg, 0);
|
2005-07-24 05:22:19 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
if (val < 2)
|
|
|
|
{
|
2009-11-01 13:22:39 -08:00
|
|
|
Conf.backgrounds.timeout = dd->bg_timeout;
|
|
|
|
Conf.backgrounds.hiquality = dd->hiq;
|
|
|
|
Conf.backgrounds.user = dd->userbg;
|
|
|
|
Conf.hints.set_xroot_info_on_root_window = dd->root_hint;
|
|
|
|
|
|
|
|
COLOR32_FROM_RGB(dd->bg->bg_solid, dd->bg_r, dd->bg_g, dd->bg_b);
|
|
|
|
dd->bg->bg_tile = dd->bg_tile;
|
|
|
|
dd->bg->bg.keep_aspect = dd->bg_keep_aspect;
|
|
|
|
dd->bg->bg.xjust = dd->bg_xjust;
|
|
|
|
dd->bg->bg.yjust = dd->bg_yjust;
|
|
|
|
dd->bg->bg.xperc = dd->bg_xperc;
|
|
|
|
dd->bg->bg.yperc = dd->bg_yperc;
|
|
|
|
if (!dd->bg_image)
|
|
|
|
BackgroundFilesRemove(dd->bg);
|
|
|
|
|
|
|
|
BackgroundInvalidate(dd->bg, 1);
|
|
|
|
|
|
|
|
BackgroundCacheMini(dd->bg, 0, 1);
|
|
|
|
BG_RedrawView(d);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
autosave();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Draw the background preview image */
|
|
|
|
static void
|
2009-11-01 13:22:39 -08:00
|
|
|
CB_DesktopMiniDisplayRedraw(Dialog * d,
|
|
|
|
int val __UNUSED__, void *data __UNUSED__)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2009-11-01 13:22:39 -08:00
|
|
|
BgDlgData *dd = DLG_DATA_GET(d, BgDlgData);
|
2004-12-28 15:46:49 -08:00
|
|
|
Background *bg;
|
2009-12-03 11:29:30 -08:00
|
|
|
EX_Pixmap pmap;
|
2004-12-28 15:46:49 -08:00
|
|
|
int w, h;
|
2006-04-29 12:39:21 -07:00
|
|
|
Win win;
|
2009-09-13 06:45:34 -07:00
|
|
|
unsigned int color;
|
2004-12-28 15:46:49 -08:00
|
|
|
const char *fbg, *ffg;
|
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
if (!dd->bg)
|
2004-12-28 15:46:49 -08:00
|
|
|
return;
|
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
win = DialogItemAreaGetWindow(dd->bg_mini_disp);
|
|
|
|
DialogItemAreaGetSize(dd->bg_mini_disp, &w, &h);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2007-07-11 02:35:01 -07:00
|
|
|
pmap = EGetWindowBackgroundPixmap(win);
|
2009-11-01 13:22:39 -08:00
|
|
|
fbg = (dd->bg_image) ? BackgroundGetBgFile(dd->bg) : NULL;
|
|
|
|
ffg = (dd->bg_image) ? BackgroundGetFgFile(dd->bg) : NULL;
|
|
|
|
COLOR32_FROM_RGB(color, dd->bg_r, dd->bg_g, dd->bg_b);
|
2009-09-13 06:45:34 -07:00
|
|
|
bg = BackgroundCreate("TEMP", color,
|
2009-11-01 13:22:39 -08:00
|
|
|
fbg, dd->bg_tile, dd->bg_keep_aspect,
|
|
|
|
dd->bg_xjust, dd->bg_yjust,
|
|
|
|
dd->bg_xperc, dd->bg_yperc,
|
|
|
|
ffg, dd->bg->top.keep_aspect,
|
|
|
|
dd->bg->top.xjust, dd->bg->top.yjust,
|
|
|
|
dd->bg->top.xperc, dd->bg->top.yperc);
|
2007-07-11 02:35:01 -07:00
|
|
|
|
|
|
|
BackgroundApplyPmap(bg, win, pmap, w, h);
|
|
|
|
BackgroundDestroy(bg);
|
|
|
|
EClearWindow(win);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
BG_DialogSetFileName(DItem * di)
|
|
|
|
{
|
2009-11-01 13:22:39 -08:00
|
|
|
Dialog *d = DialogItemGetDialog(di);
|
|
|
|
BgDlgData *dd = DLG_DATA_GET(d, BgDlgData);
|
2008-10-10 12:49:06 -07:00
|
|
|
const char *stmp;
|
2004-12-28 15:46:49 -08:00
|
|
|
char s[1024];
|
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
stmp = fullfileof(BackgroundGetBgFile(dd->bg));
|
2004-12-28 15:46:49 -08:00
|
|
|
Esnprintf(s, sizeof(s),
|
2010-05-09 12:03:19 -07:00
|
|
|
_("Background definition information:\nName: %s\nFile: %s"),
|
2009-11-01 13:22:39 -08:00
|
|
|
BackgroundGetName(dd->bg), (stmp) ? stmp : _("-NONE-"));
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, s);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-11-01 13:22:39 -08:00
|
|
|
BgDialogSetNewCurrent(Dialog * d, Background * bg)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2009-11-01 13:22:39 -08:00
|
|
|
BgDlgData *dd = DLG_DATA_GET(d, BgDlgData);
|
2013-07-11 00:19:06 -07:00
|
|
|
int r, g, b;
|
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
if (dd->bg && dd->bg != bg)
|
|
|
|
BackgroundImagesKeep(dd->bg, 0);
|
|
|
|
dd->bg = bg;
|
|
|
|
BackgroundImagesKeep(dd->bg, 1);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
/* Update dialog items */
|
2009-11-01 13:22:39 -08:00
|
|
|
BG_DialogSetFileName(dd->bg_filename);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2013-07-11 00:19:06 -07:00
|
|
|
COLOR32_TO_RGB(bg->bg_solid, r, g, b);
|
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
DialogItemCheckButtonSetState(dd->di[0], bg->bg.file ? 1 : 0);
|
|
|
|
DialogItemCheckButtonSetState(dd->di[1], bg->bg.keep_aspect);
|
|
|
|
DialogItemCheckButtonSetState(dd->di[2], bg->bg_tile);
|
|
|
|
DialogItemSliderSetVal(dd->di[3], r);
|
|
|
|
DialogItemSliderSetVal(dd->di[4], g);
|
|
|
|
DialogItemSliderSetVal(dd->di[5], b);
|
|
|
|
DialogItemSliderSetVal(dd->di[6], bg->bg.xjust);
|
|
|
|
DialogItemSliderSetVal(dd->di[7], bg->bg.yjust);
|
|
|
|
DialogItemSliderSetVal(dd->di[8], bg->bg.yperc);
|
|
|
|
DialogItemSliderSetVal(dd->di[9], bg->bg.xperc);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2007-07-11 02:35:01 -07:00
|
|
|
/* Redraw mini BG display */
|
2009-11-01 13:22:39 -08:00
|
|
|
CB_DesktopMiniDisplayRedraw(d, 0, NULL);
|
2007-07-11 02:35:01 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
/* Redraw scrolling BG list */
|
2009-11-01 13:22:39 -08:00
|
|
|
BG_RedrawView(d);
|
2004-04-10 12:39:02 -07:00
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
/* Duplicate current (dd->bg) to new */
|
2004-12-28 15:46:49 -08:00
|
|
|
static void
|
2009-11-01 13:22:39 -08:00
|
|
|
CB_ConfigureNewBG(Dialog * d, int val __UNUSED__, void *data __UNUSED__)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2009-11-01 13:22:39 -08:00
|
|
|
BgDlgData *dd = DLG_DATA_GET(d, BgDlgData);
|
2004-12-28 15:46:49 -08:00
|
|
|
char s[1024];
|
2009-09-13 06:45:34 -07:00
|
|
|
unsigned int color;
|
2004-12-28 15:46:49 -08:00
|
|
|
int lower, upper;
|
|
|
|
|
|
|
|
Esnprintf(s, sizeof(s), "__NEWBG_%i", (unsigned)time(NULL));
|
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
COLOR32_FROM_RGB(color, dd->bg_r, dd->bg_g, dd->bg_b);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
dd->bg = BackgroundCreate(s, color,
|
|
|
|
dd->bg->bg.file, dd->bg_tile, dd->bg_keep_aspect,
|
|
|
|
dd->bg_xjust, dd->bg_yjust,
|
|
|
|
dd->bg_xperc, dd->bg_yperc,
|
|
|
|
dd->bg->top.file, dd->bg->top.keep_aspect,
|
|
|
|
dd->bg->top.xjust, dd->bg->top.yjust,
|
|
|
|
dd->bg->top.xperc, dd->bg->top.yperc);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
DialogItemSliderGetBounds(dd->bg_sel_slider, &lower, &upper);
|
2004-12-28 15:46:49 -08:00
|
|
|
upper += 4;
|
2009-11-01 13:22:39 -08:00
|
|
|
DialogItemSliderSetBounds(dd->bg_sel_slider, lower, upper);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
DialogItemSliderSetVal(dd->bg_sel_slider, 0);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
DeskBackgroundSet(DesksGetCurrent(), dd->bg);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
BG_RedrawView(d);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
autosave();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-11-01 13:22:39 -08:00
|
|
|
CB_ConfigureDelBG(Dialog * d, int val, void *data __UNUSED__)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2009-11-01 13:22:39 -08:00
|
|
|
BgDlgData *dd = DLG_DATA_GET(d, BgDlgData);
|
2006-02-18 00:30:09 -08:00
|
|
|
Background *bg;
|
2009-11-12 12:48:21 -08:00
|
|
|
int lower, upper;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
bg = LIST_CHECK(Background, &bg_list, dd->bg);
|
2006-02-18 00:30:09 -08:00
|
|
|
if (!bg)
|
|
|
|
return;
|
2013-06-06 13:37:06 -07:00
|
|
|
if (BackgroundIsNone(bg))
|
|
|
|
return;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
bg = LIST_NEXT(Background, &bg_list, bg);
|
2013-06-06 13:37:06 -07:00
|
|
|
if (!bg)
|
2009-11-01 13:22:39 -08:00
|
|
|
bg = LIST_PREV(Background, &bg_list, bg);
|
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)
|
2009-11-01 13:22:39 -08:00
|
|
|
BackgroundDestroy(dd->bg);
|
2004-12-28 15:46:49 -08:00
|
|
|
else
|
2009-11-01 13:22:39 -08:00
|
|
|
BackgroundDelete(dd->bg);
|
|
|
|
dd->bg = NULL;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
DialogItemSliderGetBounds(dd->bg_sel_slider, &lower, &upper);
|
2006-02-18 00:30:09 -08:00
|
|
|
upper -= 4;
|
2009-11-01 13:22:39 -08:00
|
|
|
DialogItemSliderSetBounds(dd->bg_sel_slider, lower, upper);
|
|
|
|
if (dd->bg_sel_sliderval > upper)
|
|
|
|
DialogItemSliderSetVal(dd->bg_sel_slider, upper);
|
2006-02-18 00:30:09 -08:00
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
BgDialogSetNewCurrent(d, bg);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
autosave();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Move current background to first position in list */
|
|
|
|
static void
|
2009-11-01 13:22:39 -08:00
|
|
|
CB_ConfigureFrontBG(Dialog * d, int val __UNUSED__, void *data __UNUSED__)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2009-11-01 13:22:39 -08:00
|
|
|
BgDlgData *dd = DLG_DATA_GET(d, BgDlgData);
|
2013-07-10 01:38:12 -07:00
|
|
|
Background *bg;
|
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
if (BackgroundIsNone(dd->bg))
|
2013-07-10 01:38:12 -07:00
|
|
|
return; /* Don't move "None" background */
|
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
bg = LIST_REMOVE(Background, &bg_list, dd->bg);
|
2013-06-06 13:37:06 -07:00
|
|
|
LIST_PREPEND(Background, &bg_list, bg);
|
2009-11-01 13:22:39 -08:00
|
|
|
BGSettingsGoTo(d, bg);
|
|
|
|
BG_RedrawView(d);
|
2004-12-28 15:46:49 -08:00
|
|
|
autosave();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Draw the scrolling background image window */
|
|
|
|
static void
|
2009-11-01 13:22:39 -08:00
|
|
|
BG_RedrawView(Dialog * d)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2009-11-01 13:22:39 -08:00
|
|
|
BgDlgData *dd = DLG_DATA_GET(d, BgDlgData);
|
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;
|
2009-12-03 11:29:30 -08:00
|
|
|
EX_Pixmap pmap;
|
2009-10-11 10:54:40 -07:00
|
|
|
ImageClass *ic;
|
2011-05-01 03:51:59 -07:00
|
|
|
int mini_w = Mode.backgrounds.mini_w;
|
|
|
|
int mini_h = Mode.backgrounds.mini_h;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2013-06-06 13:37:06 -07:00
|
|
|
num = LIST_GET_COUNT(&bg_list);
|
2006-02-18 00:30:09 -08:00
|
|
|
if (num <= 0)
|
2005-07-24 05:22:19 -07:00
|
|
|
return;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
win = DialogItemAreaGetWindow(dd->bg_sel);
|
|
|
|
DialogItemAreaGetSize(dd->bg_sel, &w, &h);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2007-05-25 15:40:47 -07:00
|
|
|
pmap = EGetWindowBackgroundPixmap(win);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2009-10-11 10:54:40 -07:00
|
|
|
ic = ImageclassFind("DIALOG_BUTTON", 0);
|
|
|
|
if (!ic)
|
|
|
|
ic = ImageclassFind("DIALOG_WIDGET_BUTTON", 1);
|
2005-08-04 15:05:31 -07:00
|
|
|
|
2009-10-11 10:54:40 -07:00
|
|
|
ImageclassApplySimple(ic, win, pmap, STATE_NORMAL, 0, 0, w, h);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
x = -(num * (mini_w + 8) - w) * dd->bg_sel_sliderval / (4 * num);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2013-06-06 13:37:06 -07:00
|
|
|
LIST_FOR_EACH(Background, &bg_list, bg)
|
2006-02-18 00:30:09 -08:00
|
|
|
{
|
2011-05-01 03:51:59 -07:00
|
|
|
if (((x + mini_w + 8) >= 0) && (x < w))
|
2006-02-18 00:30:09 -08:00
|
|
|
{
|
2006-03-29 11:13:17 -08:00
|
|
|
EImage *im;
|
2006-02-18 00:30:09 -08:00
|
|
|
|
2009-10-11 10:54:40 -07:00
|
|
|
ImageclassApplySimple(ic, win, pmap,
|
2009-11-01 13:22:39 -08:00
|
|
|
(bg == dd->bg) ? STATE_CLICKED : STATE_NORMAL,
|
2014-04-27 11:50:23 -07:00
|
|
|
x, 0, mini_w + 8, mini_h + 8);
|
2006-02-18 00:30:09 -08:00
|
|
|
|
|
|
|
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,
|
2011-05-01 03:51:59 -07:00
|
|
|
4 + ((mini_h - th) / 2), mini_w, mini_h, 17, 512);
|
2006-02-18 00:30:09 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
im = BackgroundCacheMini(bg, 1, 0);
|
|
|
|
if (im)
|
|
|
|
{
|
2011-05-01 03:51:59 -07:00
|
|
|
EImageRenderOnDrawable(im, win, pmap, 0, x + 4, 4,
|
|
|
|
mini_w, mini_h);
|
2006-03-29 11:13:17 -08:00
|
|
|
EImageFree(im);
|
2006-02-18 00:30:09 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-05-01 03:51:59 -07:00
|
|
|
x += (mini_w + 8);
|
2006-02-18 00:30:09 -08:00
|
|
|
}
|
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
|
2009-11-01 13:22:39 -08:00
|
|
|
CB_BGAreaSlide(Dialog * d, int val __UNUSED__, void *data __UNUSED__)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2009-11-01 13:22:39 -08:00
|
|
|
BgDlgData *dd = DLG_DATA_GET(d, BgDlgData);
|
|
|
|
|
|
|
|
if (dd->bg_sel_sliderval == dd->bg_sel_sliderval_old)
|
2005-07-26 09:58:31 -07:00
|
|
|
return;
|
2009-11-01 13:22:39 -08:00
|
|
|
BG_RedrawView(d);
|
|
|
|
dd->bg_sel_sliderval_old = dd->bg_sel_sliderval;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
CB_BGScan(Dialog * d, int val __UNUSED__, void *data __UNUSED__)
|
|
|
|
{
|
2009-11-01 13:22:39 -08:00
|
|
|
BgDlgData *dd = DLG_DATA_GET(d, BgDlgData);
|
2008-11-22 13:17:02 -08:00
|
|
|
int num;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2008-12-14 08:44:45 -08:00
|
|
|
SoundPlay(SOUND_WAIT);
|
2009-05-06 10:17:31 -07:00
|
|
|
|
|
|
|
/* Forcing re-scan should not be necessary but provides the progress bars
|
|
|
|
* so it actually looks like something is going on */
|
|
|
|
Mode.backgrounds.force_scan = 1;
|
2008-11-22 13:17:02 -08:00
|
|
|
ScanBackgroundMenu();
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2013-06-06 13:37:06 -07:00
|
|
|
num = LIST_GET_COUNT(&bg_list);
|
2009-11-01 13:22:39 -08:00
|
|
|
DialogItemSliderSetBounds(dd->bg_sel_slider, 0, num * 4);
|
|
|
|
DialogItemCallCallback(d, dd->bg_sel_slider);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-11-12 12:48:18 -08:00
|
|
|
CB_BGAreaEvent(DItem * di, int val __UNUSED__, void *data)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2009-11-01 13:22:39 -08:00
|
|
|
Dialog *d = DialogItemGetDialog(di);
|
|
|
|
BgDlgData *dd = DLG_DATA_GET(d, BgDlgData);
|
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;
|
2011-05-01 03:51:59 -07:00
|
|
|
int mini_w = Mode.backgrounds.mini_w;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2009-11-12 12:48:18 -08:00
|
|
|
DialogItemAreaGetSize(di, &w, &h);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
switch (ev->type)
|
|
|
|
{
|
|
|
|
case ButtonPress:
|
2007-07-11 02:35:01 -07:00
|
|
|
switch (ev->xbutton.button)
|
|
|
|
{
|
|
|
|
case 1:
|
2013-06-06 13:37:06 -07:00
|
|
|
num = LIST_GET_COUNT(&bg_list);
|
2009-11-01 13:22:39 -08:00
|
|
|
x = (num * (mini_w + 8) - w) * dd->bg_sel_sliderval / (4 * num) +
|
2007-07-11 02:35:01 -07:00
|
|
|
ev->xbutton.x;
|
2013-06-06 13:37:06 -07:00
|
|
|
x = x / (mini_w + 8);
|
|
|
|
bg = LIST_GET_BY_INDEX(Background, &bg_list, x);
|
2007-07-11 02:35:01 -07:00
|
|
|
if (!bg || bg == DeskBackgroundGet(DesksGetCurrent()))
|
|
|
|
break;
|
2009-11-01 13:22:39 -08:00
|
|
|
BgDialogSetNewCurrent(d, bg);
|
2007-07-11 02:35:01 -07:00
|
|
|
DeskBackgroundSet(DesksGetCurrent(), bg);
|
|
|
|
autosave();
|
|
|
|
break;
|
|
|
|
case 4:
|
2009-11-01 13:22:39 -08:00
|
|
|
dd->bg_sel_sliderval += 4;
|
2007-07-11 02:35:01 -07:00
|
|
|
goto do_slide;
|
|
|
|
case 5:
|
2009-11-01 13:22:39 -08:00
|
|
|
dd->bg_sel_sliderval -= 4;
|
2007-07-11 02:35:01 -07:00
|
|
|
goto do_slide;
|
|
|
|
do_slide:
|
2009-11-01 13:22:39 -08:00
|
|
|
DialogItemSliderSetVal(dd->bg_sel_slider, dd->bg_sel_sliderval);
|
2007-07-11 02:35:01 -07:00
|
|
|
CB_BGAreaSlide(NULL, 0, NULL);
|
|
|
|
break;
|
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-11-01 13:22:39 -08:00
|
|
|
CB_DesktopTimeout(Dialog * d, int val __UNUSED__, void *data)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2009-11-01 13:22:39 -08:00
|
|
|
BgDlgData *dd = DLG_DATA_GET(d, BgDlgData);
|
2013-06-05 13:41:36 -07:00
|
|
|
DItem *di = (DItem *) data;
|
2004-12-28 15:46:49 -08:00
|
|
|
char s[256];
|
|
|
|
|
|
|
|
Esnprintf(s, sizeof(s), _("Unused backgrounds freed after %2i:%02i:%02i"),
|
2009-11-01 13:22:39 -08:00
|
|
|
dd->bg_timeout / 3600,
|
|
|
|
(dd->bg_timeout / 60) - (60 * (dd->bg_timeout / 3600)),
|
|
|
|
(dd->bg_timeout) - (60 * (dd->bg_timeout / 60)));
|
2005-08-02 09:50:40 -07:00
|
|
|
DialogItemSetText(di, s);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-11-01 13:22:39 -08:00
|
|
|
BGSettingsGoTo(Dialog * d, Background * bg)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2009-11-01 13:22:39 -08:00
|
|
|
BgDlgData *dd = DLG_DATA_GET(d, BgDlgData);
|
2004-12-28 15:46:49 -08:00
|
|
|
int i, num;
|
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
if (!dd->bg_sel_slider)
|
2004-12-28 15:46:49 -08:00
|
|
|
return;
|
|
|
|
|
2013-06-06 13:37:06 -07:00
|
|
|
num = LIST_GET_COUNT(&bg_list);
|
|
|
|
i = LIST_GET_INDEX(Background, &bg_list, bg);
|
|
|
|
if (i < 0)
|
2004-12-28 15:46:49 -08:00
|
|
|
return;
|
2006-02-18 00:30:09 -08:00
|
|
|
i = ((4 * num + 20) * i) / num - 8;
|
|
|
|
if (i < 0)
|
|
|
|
i = 0;
|
|
|
|
else if (i > 4 * num)
|
|
|
|
i = 4 * num;
|
2009-11-01 13:22:39 -08:00
|
|
|
DialogItemSliderSetVal(dd->bg_sel_slider, i);
|
|
|
|
BgDialogSetNewCurrent(d, bg);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-11-01 13:22:39 -08:00
|
|
|
CB_BGNext(Dialog * d, int val, void *data __UNUSED__)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2009-11-01 13:22:39 -08:00
|
|
|
BgDlgData *dd = DLG_DATA_GET(d, BgDlgData);
|
2006-02-18 00:30:09 -08:00
|
|
|
Background *bg;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
bg = dd->bg;
|
2013-06-06 13:37:06 -07:00
|
|
|
if (val >= 0)
|
|
|
|
{
|
|
|
|
while (bg && val--)
|
|
|
|
bg = LIST_NEXT(Background, &bg_list, bg);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while (bg && val++)
|
|
|
|
bg = LIST_PREV(Background, &bg_list, bg);
|
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
if (!bg)
|
|
|
|
return;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
BGSettingsGoTo(d, bg);
|
2006-02-18 00:30:09 -08:00
|
|
|
DeskBackgroundSet(DesksGetCurrent(), bg);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-12-04 21:38:39 -08:00
|
|
|
BG_SortFileCompare(const void *_bg1, const void *_bg2)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2010-10-27 09:21:55 -07:00
|
|
|
const Background *bg1 = *(const Background **)_bg1;
|
|
|
|
const Background *bg2 = *(const Background **)_bg2;
|
2004-12-28 15:46:49 -08:00
|
|
|
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);
|
2007-07-11 02:35:01 -07:00
|
|
|
if (name1)
|
|
|
|
return 1;
|
|
|
|
if (name2)
|
|
|
|
return -1;
|
|
|
|
return (bg1 < bg2) ? -1 : 1;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-11-01 13:22:39 -08:00
|
|
|
CB_BGSortFile(Dialog * d, int val __UNUSED__, void *data __UNUSED__)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2009-11-01 13:22:39 -08:00
|
|
|
BgDlgData *dd = DLG_DATA_GET(d, BgDlgData);
|
2004-12-28 15:46:49 -08:00
|
|
|
Background **bglist;
|
|
|
|
int i, num;
|
|
|
|
|
2013-06-06 13:37:06 -07:00
|
|
|
bglist = LIST_GET_ITEMS(Background, &bg_list, &num);
|
2004-12-28 15:46:49 -08:00
|
|
|
if (!bglist)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* remove them all from the list */
|
2013-06-06 13:37:06 -07:00
|
|
|
LIST_INIT(Background, &bg_list);
|
2010-10-27 09:21:55 -07:00
|
|
|
qsort(bglist, num - 1, sizeof(Background *), BG_SortFileCompare);
|
2004-12-28 15:46:49 -08:00
|
|
|
for (i = 0; i < num; i++)
|
2013-06-06 13:37:06 -07:00
|
|
|
LIST_APPEND(Background, &bg_list, bglist[i]);
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
Efree(bglist);
|
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
BGSettingsGoTo(d, dd->bg);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
autosave();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-11-01 13:22:39 -08:00
|
|
|
CB_BGSortAttrib(Dialog * d, int val __UNUSED__, void *data __UNUSED__)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2009-11-01 13:22:39 -08:00
|
|
|
BgDlgData *dd = DLG_DATA_GET(d, BgDlgData);
|
2013-06-06 13:37:06 -07:00
|
|
|
Background **bglist, *bg;
|
2004-12-28 15:46:49 -08:00
|
|
|
int i, num;
|
|
|
|
|
2013-06-06 13:37:06 -07:00
|
|
|
bglist = LIST_GET_ITEMS(Background, &bg_list, &num);
|
2004-12-28 15:46:49 -08:00
|
|
|
if (!bglist)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* remove them all from the list */
|
2013-06-06 13:37:06 -07:00
|
|
|
LIST_INIT(Background, &bg_list);
|
2004-12-28 15:46:49 -08:00
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
{
|
|
|
|
bg = bglist[i];
|
|
|
|
if ((bg) && (bg->bg_tile) && (bg->bg.xperc == 0) && (bg->bg.yperc == 0))
|
|
|
|
{
|
2013-06-06 13:37:06 -07:00
|
|
|
LIST_APPEND(Background, &bg_list, bg);
|
2004-12-28 15:46:49 -08:00
|
|
|
bglist[i] = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
{
|
|
|
|
bg = bglist[i];
|
|
|
|
if (bg)
|
|
|
|
{
|
2013-06-06 13:37:06 -07:00
|
|
|
LIST_APPEND(Background, &bg_list, bg);
|
2004-12-28 15:46:49 -08:00
|
|
|
bglist[i] = NULL;
|
|
|
|
}
|
|
|
|
}
|
2013-06-06 13:37:06 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
Efree(bglist);
|
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
BGSettingsGoTo(d, dd->bg);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
autosave();
|
|
|
|
}
|
|
|
|
|
2007-07-11 02:35:01 -07:00
|
|
|
#if 0 /* Doesn't do anything useful */
|
2004-12-28 15:46:49 -08:00
|
|
|
static void
|
|
|
|
CB_BGSortContent(Dialog * d __UNUSED__, int val __UNUSED__,
|
|
|
|
void *data __UNUSED__)
|
|
|
|
{
|
|
|
|
Background **bglist;
|
|
|
|
int i, num;
|
|
|
|
|
2013-06-06 13:37:06 -07:00
|
|
|
bglist = LIST_GET_ITEMS(Background, &bg_list, &num);
|
2006-02-18 00:30:09 -08:00
|
|
|
if (!bglist)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* remove them all from the list */
|
2013-06-06 13:37:06 -07:00
|
|
|
LIST_INIT(Background, &bg_list);
|
2006-02-18 00:30:09 -08:00
|
|
|
for (i = 0; i < num; i++)
|
2013-06-06 13:37:06 -07:00
|
|
|
LIST_PREPEND(Background, &bg_list, bglist[i]);
|
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
Efree(bglist);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
autosave();
|
|
|
|
}
|
2007-07-11 02:35:01 -07:00
|
|
|
#endif
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
static void
|
2009-11-01 13:22:39 -08:00
|
|
|
CB_InitView(DItem * di, int val __UNUSED__, void *data __UNUSED__)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2009-11-01 13:22:39 -08:00
|
|
|
Dialog *d = DialogItemGetDialog(di);
|
|
|
|
BgDlgData *dd = DLG_DATA_GET(d, BgDlgData);
|
2006-09-02 07:33:14 -07:00
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
dd->bg_sel_sliderval_old = dd->bg_sel_sliderval = -1;
|
|
|
|
BGSettingsGoTo(d, dd->bg);
|
2006-07-20 20:17:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_DlgFillBackground(Dialog * d, DItem * table, void *data)
|
|
|
|
{
|
2007-01-16 17:10:44 -08:00
|
|
|
Background *bg = (Background *) data;
|
2009-11-01 13:22:39 -08:00
|
|
|
DItem *di, *table2, *table3, *label;
|
2007-07-11 02:35:01 -07:00
|
|
|
int i, num;
|
2004-12-28 15:46:49 -08:00
|
|
|
char s[1024];
|
2011-05-01 03:51:59 -07:00
|
|
|
int mini_w = Mode.backgrounds.mini_w;
|
|
|
|
int mini_h = Mode.backgrounds.mini_h;
|
2009-11-01 13:22:39 -08:00
|
|
|
BgDlgData *dd;
|
|
|
|
|
|
|
|
dd = DLG_DATA_SET(d, BgDlgData);
|
|
|
|
if (!dd)
|
|
|
|
return;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2008-11-22 13:17:02 -08:00
|
|
|
if (!Conf.backgrounds.no_scan)
|
|
|
|
ScanBackgroundMenu();
|
2007-02-24 17:38:30 -08:00
|
|
|
|
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");
|
2009-11-01 13:22:39 -08:00
|
|
|
dd->bg = bg;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
dd->bg_image = (dd->bg->bg.file) ? 1 : 0;
|
2013-07-11 00:19:06 -07:00
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
COLOR32_TO_RGB(dd->bg->bg_solid, dd->bg_r, dd->bg_g, dd->bg_b);
|
|
|
|
dd->bg_tile = dd->bg->bg_tile;
|
|
|
|
dd->bg_keep_aspect = dd->bg->bg.keep_aspect;
|
|
|
|
dd->bg_xjust = dd->bg->bg.xjust;
|
|
|
|
dd->bg_yjust = dd->bg->bg.yjust;
|
|
|
|
dd->bg_xperc = dd->bg->bg.xperc;
|
|
|
|
dd->bg_yperc = dd->bg->bg.yperc;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
dd->hiq = Conf.backgrounds.hiquality;
|
|
|
|
dd->userbg = Conf.backgrounds.user;
|
|
|
|
dd->root_hint = Conf.hints.set_xroot_info_on_root_window;
|
|
|
|
dd->bg_timeout = Conf.backgrounds.timeout;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2007-07-11 02:35:01 -07:00
|
|
|
DialogItemTableSetOptions(table, 1, 0, 0, 0);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2007-07-11 02:35:01 -07:00
|
|
|
table2 = DialogAddItem(table, DITEM_TABLE);
|
|
|
|
DialogItemTableSetOptions(table2, 2, 0, 1, 0);
|
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
di = dd->bg_filename = DialogAddItem(table2, DITEM_TEXT);
|
2007-07-11 02:35:01 -07:00
|
|
|
DialogItemSetFill(di, 1, 0);
|
2009-11-01 13:22:39 -08:00
|
|
|
BG_DialogSetFileName(dd->bg_filename);
|
2007-07-11 02:35:01 -07:00
|
|
|
|
|
|
|
table3 = DialogAddItem(table2, DITEM_TABLE);
|
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
di = dd->di[0] = DialogAddItem(table3, DITEM_CHECKBUTTON);
|
2007-07-11 02:35:01 -07:00
|
|
|
DialogItemSetText(di, _("Use background image"));
|
2009-11-01 13:22:39 -08:00
|
|
|
DialogItemCheckButtonSetPtr(di, &dd->bg_image);
|
2007-07-11 02:35:01 -07:00
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
di = dd->di[1] = DialogAddItem(table3, DITEM_CHECKBUTTON);
|
2007-07-11 02:35:01 -07:00
|
|
|
DialogItemSetText(di, _("Keep aspect on scale"));
|
2009-11-01 13:22:39 -08:00
|
|
|
DialogItemCheckButtonSetPtr(di, &dd->bg_keep_aspect);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
di = dd->di[2] = DialogAddItem(table3, DITEM_CHECKBUTTON);
|
2007-07-11 02:35:01 -07:00
|
|
|
DialogItemSetText(di, _("Tile image across background"));
|
2009-11-01 13:22:39 -08:00
|
|
|
DialogItemCheckButtonSetPtr(di, &dd->bg_tile);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
table2 = DialogAddItem(table, DITEM_TABLE);
|
2007-07-11 02:35:01 -07:00
|
|
|
DialogItemTableSetOptions(table2, 4, 0, 1, 0);
|
|
|
|
DialogItemSetFill(table2, 0, 0);
|
|
|
|
DialogItemSetAlign(table2, 512, 0);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
di = DialogAddItem(table2, DITEM_BUTTON);
|
2010-05-09 12:03:19 -07:00
|
|
|
DialogItemSetText(di, _("Move to Front"));
|
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);
|
2010-05-09 12:03:19 -07:00
|
|
|
DialogItemSetText(di, _("Duplicate"));
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemSetCallback(di, CB_ConfigureNewBG, 0, NULL);
|
|
|
|
|
|
|
|
di = DialogAddItem(table2, DITEM_BUTTON);
|
2010-05-09 12:03:19 -07:00
|
|
|
DialogItemSetText(di, _("Unlist"));
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemSetCallback(di, CB_ConfigureDelBG, 0, NULL);
|
2007-07-11 02:35:01 -07:00
|
|
|
DialogBindKey(d, "D", CB_ConfigureDelBG, 0, NULL);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
di = DialogAddItem(table2, DITEM_BUTTON);
|
2010-05-09 12:03:19 -07:00
|
|
|
DialogItemSetText(di, _("Delete File"));
|
2007-07-11 02:35:01 -07:00
|
|
|
DialogItemSetCallback(di, CB_ConfigureDelBG, 1, NULL);
|
2006-08-20 10:39:32 -07:00
|
|
|
DialogBindKey(d, "Delete", CB_ConfigureDelBG, 1, NULL);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2007-07-11 02:35:01 -07:00
|
|
|
table2 = DialogAddItem(table, DITEM_TABLE);
|
|
|
|
DialogItemTableSetOptions(table2, 3, 0, 1, 0);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2007-07-11 02:35:01 -07:00
|
|
|
di = DialogAddItem(table2, DITEM_TEXT);
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemSetFill(di, 0, 0);
|
|
|
|
DialogItemSetAlign(di, 512, 512);
|
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
|
|
|
|
2007-07-11 02:35:01 -07:00
|
|
|
table3 = DialogAddItem(table2, DITEM_TABLE);
|
|
|
|
DialogItemTableSetOptions(table3, 3, 0, 0, 0);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2010-01-29 11:45:04 -08:00
|
|
|
DialogAddItem(table3, DITEM_NONE);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
di = dd->di[6] = DialogAddItem(table3, DITEM_SLIDER);
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemSliderSetMinLength(di, 10);
|
|
|
|
DialogItemSliderSetBounds(di, 0, 1024);
|
|
|
|
DialogItemSliderSetUnits(di, 1);
|
2011-05-01 03:51:59 -07:00
|
|
|
DialogItemSliderSetJump(di, mini_w);
|
2009-11-01 13:22:39 -08:00
|
|
|
DialogItemSliderSetValPtr(di, &dd->bg_xjust);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2010-01-29 11:45:04 -08:00
|
|
|
DialogAddItem(table3, DITEM_NONE);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
di = dd->di[7] = DialogAddItem(table3, DITEM_SLIDER);
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemSliderSetMinLength(di, 10);
|
|
|
|
DialogItemSliderSetOrientation(di, 0);
|
|
|
|
DialogItemSetFill(di, 0, 1);
|
|
|
|
DialogItemSliderSetBounds(di, 0, 1024);
|
|
|
|
DialogItemSliderSetUnits(di, 1);
|
2011-05-01 03:51:59 -07:00
|
|
|
DialogItemSliderSetJump(di, mini_w);
|
2009-11-01 13:22:39 -08:00
|
|
|
DialogItemSliderSetValPtr(di, &dd->bg_yjust);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
di = dd->bg_mini_disp = DialogAddItem(table3, DITEM_AREA);
|
2011-05-01 03:51:59 -07:00
|
|
|
DialogItemAreaSetSize(di, mini_w, mini_h);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
di = dd->di[8] = DialogAddItem(table3, DITEM_SLIDER);
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemSliderSetMinLength(di, 10);
|
|
|
|
DialogItemSliderSetOrientation(di, 0);
|
|
|
|
DialogItemSetFill(di, 0, 1);
|
|
|
|
DialogItemSliderSetBounds(di, 0, 1024);
|
|
|
|
DialogItemSliderSetUnits(di, 1);
|
2011-05-01 03:51:59 -07:00
|
|
|
DialogItemSliderSetJump(di, mini_w);
|
2009-11-01 13:22:39 -08:00
|
|
|
DialogItemSliderSetValPtr(di, &dd->bg_yperc);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2010-01-29 11:45:04 -08:00
|
|
|
DialogAddItem(table3, DITEM_NONE);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
di = dd->di[9] = DialogAddItem(table3, DITEM_SLIDER);
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemSliderSetMinLength(di, 10);
|
|
|
|
DialogItemSliderSetBounds(di, 0, 1024);
|
|
|
|
DialogItemSliderSetUnits(di, 1);
|
2011-05-01 03:51:59 -07:00
|
|
|
DialogItemSliderSetJump(di, mini_w);
|
2009-11-01 13:22:39 -08:00
|
|
|
DialogItemSliderSetValPtr(di, &dd->bg_xperc);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2007-07-11 02:35:01 -07:00
|
|
|
table3 = DialogAddItem(table2, DITEM_TABLE);
|
|
|
|
DialogItemTableSetOptions(table3, 2, 0, 0, 0);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2007-07-11 02:35:01 -07:00
|
|
|
di = DialogAddItem(table3, DITEM_TEXT);
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemSetColSpan(di, 2);
|
2007-07-11 02:35:01 -07:00
|
|
|
DialogItemSetFill(di, 0, 0);
|
|
|
|
DialogItemSetAlign(di, 512, 512);
|
2010-05-09 12:03:19 -07:00
|
|
|
DialogItemSetText(di, _("BG Colour"));
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2007-07-11 02:35:01 -07:00
|
|
|
di = DialogAddItem(table3, DITEM_TEXT);
|
|
|
|
DialogItemSetFill(di, 0, 0);
|
|
|
|
DialogItemSetAlign(di, 1024, 512);
|
2010-05-09 12:03:19 -07:00
|
|
|
DialogItemSetText(di, _("Red:"));
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
di = dd->di[3] = DialogAddItem(table3, DITEM_SLIDER);
|
2007-07-11 02:35:01 -07:00
|
|
|
DialogItemSliderSetBounds(di, 0, 255);
|
|
|
|
DialogItemSliderSetUnits(di, 1);
|
|
|
|
DialogItemSliderSetJump(di, 16);
|
2009-11-01 13:22:39 -08:00
|
|
|
DialogItemSliderSetValPtr(di, &dd->bg_r);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2007-07-11 02:35:01 -07:00
|
|
|
di = DialogAddItem(table3, DITEM_TEXT);
|
|
|
|
DialogItemSetFill(di, 0, 0);
|
|
|
|
DialogItemSetAlign(di, 1024, 512);
|
2010-05-09 12:03:19 -07:00
|
|
|
DialogItemSetText(di, _("Green:"));
|
2007-07-11 02:35:01 -07:00
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
di = dd->di[4] = DialogAddItem(table3, DITEM_SLIDER);
|
2007-07-11 02:35:01 -07:00
|
|
|
DialogItemSliderSetBounds(di, 0, 255);
|
|
|
|
DialogItemSliderSetUnits(di, 1);
|
|
|
|
DialogItemSliderSetJump(di, 16);
|
2009-11-01 13:22:39 -08:00
|
|
|
DialogItemSliderSetValPtr(di, &dd->bg_g);
|
2007-07-11 02:35:01 -07:00
|
|
|
|
|
|
|
di = DialogAddItem(table3, DITEM_TEXT);
|
|
|
|
DialogItemSetFill(di, 0, 0);
|
|
|
|
DialogItemSetAlign(di, 1024, 512);
|
2010-05-09 12:03:19 -07:00
|
|
|
DialogItemSetText(di, _("Blue:"));
|
2007-07-11 02:35:01 -07:00
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
di = dd->di[5] = DialogAddItem(table3, DITEM_SLIDER);
|
2007-07-11 02:35:01 -07:00
|
|
|
DialogItemSliderSetBounds(di, 0, 255);
|
|
|
|
DialogItemSliderSetUnits(di, 1);
|
|
|
|
DialogItemSliderSetJump(di, 16);
|
2009-11-01 13:22:39 -08:00
|
|
|
DialogItemSliderSetValPtr(di, &dd->bg_b);
|
2007-07-11 02:35:01 -07:00
|
|
|
|
|
|
|
for (i = 0; i < 10; i++)
|
2009-11-01 13:22:39 -08:00
|
|
|
DialogItemSetCallback(dd->di[i], CB_DesktopMiniDisplayRedraw, 0, NULL);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2010-01-29 11:45:04 -08:00
|
|
|
DialogAddItem(table, DITEM_SEPARATOR);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
table2 = DialogAddItem(table, DITEM_TABLE);
|
2007-07-11 02:35:01 -07:00
|
|
|
DialogItemTableSetOptions(table2, 3, 0, 0, 0);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2007-07-11 02:35:01 -07:00
|
|
|
table3 = DialogAddItem(table2, DITEM_TABLE);
|
|
|
|
DialogItemTableSetOptions(table3, 2, 0, 0, 0);
|
|
|
|
|
|
|
|
di = DialogAddItem(table3, DITEM_BUTTON);
|
2004-12-28 15:46:49 -08:00
|
|
|
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);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2007-07-11 02:35:01 -07:00
|
|
|
di = DialogAddItem(table3, DITEM_BUTTON);
|
2004-12-28 15:46:49 -08:00
|
|
|
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);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2007-07-11 02:35:01 -07:00
|
|
|
di = DialogAddItem(table2, DITEM_BUTTON);
|
2004-12-28 15:46:49 -08:00
|
|
|
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);
|
|
|
|
|
2007-07-11 02:35:01 -07:00
|
|
|
table3 = DialogAddItem(table2, DITEM_TABLE);
|
|
|
|
DialogItemTableSetOptions(table3, 3, 0, 0, 0);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2007-07-11 02:35:01 -07:00
|
|
|
di = DialogAddItem(table3, DITEM_BUTTON);
|
2004-12-28 15:46:49 -08:00
|
|
|
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);
|
|
|
|
|
2007-07-11 02:35:01 -07:00
|
|
|
di = DialogAddItem(table3, DITEM_BUTTON);
|
2004-12-28 15:46:49 -08:00
|
|
|
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);
|
|
|
|
|
2007-07-11 02:35:01 -07:00
|
|
|
#if 0 /* Doesn't do anything useful */
|
|
|
|
di = DialogAddItem(table3, DITEM_BUTTON);
|
2004-12-28 15:46:49 -08:00
|
|
|
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);
|
2007-07-11 02:35:01 -07:00
|
|
|
#endif
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2009-11-01 13:22:39 -08:00
|
|
|
di = dd->bg_sel = DialogAddItem(table, DITEM_AREA);
|
2011-05-01 03:51:59 -07:00
|
|
|
DialogItemAreaSetSize(di, 160, 8 + Mode.backgrounds.mini_h);
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemAreaSetEventFunc(di, CB_BGAreaEvent);
|
2006-09-02 07:33:14 -07:00
|
|
|
DialogItemAreaSetInitFunc(di, CB_InitView);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2013-06-06 13:37:06 -07:00
|
|
|
num = LIST_GET_COUNT(&bg_list);
|
2009-11-01 13:22:39 -08:00
|
|
|
di = dd->bg_sel_slider = DialogAddItem(table, DITEM_SLIDER);
|
2004-12-28 15:46:49 -08:00
|
|
|
DialogItemSliderSetBounds(di, 0, num * 4);
|
|
|
|
DialogItemSliderSetUnits(di, 1);
|
|
|
|
DialogItemSliderSetJump(di, 9);
|
2009-11-01 13:22:39 -08:00
|
|
|
DialogItemSliderSetValPtr(di, &dd->bg_sel_sliderval);
|
|
|
|
DialogItemSetCallback(dd->bg_sel_slider, CB_BGAreaSlide, 0, NULL);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2010-01-29 11:45:04 -08:00
|
|
|
DialogAddItem(table, DITEM_SEPARATOR);
|
2006-05-28 04:09:46 -07:00
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_CHECKBUTTON);
|
2007-07-11 02:35:01 -07:00
|
|
|
DialogItemSetText(di, _("Use dithering in Hi-Colour"));
|
2009-11-01 13:22:39 -08:00
|
|
|
DialogItemCheckButtonSetPtr(di, &dd->hiq);
|
2007-07-11 02:35:01 -07:00
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_CHECKBUTTON);
|
|
|
|
DialogItemSetText(di, _("Background overrides theme"));
|
2009-11-01 13:22:39 -08:00
|
|
|
DialogItemCheckButtonSetPtr(di, &dd->userbg);
|
2007-07-11 02:35:01 -07:00
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_CHECKBUTTON);
|
2006-05-28 04:09:46 -07:00
|
|
|
DialogItemSetText(di,
|
|
|
|
_("Enable background transparency compatibility mode"));
|
2009-11-01 13:22:39 -08:00
|
|
|
DialogItemCheckButtonSetPtr(di, &dd->root_hint);
|
2007-07-11 02:35:01 -07:00
|
|
|
|
2010-01-29 11:45:04 -08:00
|
|
|
DialogAddItem(table, DITEM_SEPARATOR);
|
2007-07-11 02:35:01 -07:00
|
|
|
|
|
|
|
di = label = DialogAddItem(table, DITEM_TEXT);
|
|
|
|
DialogItemSetAlign(di, 512, 512);
|
|
|
|
Esnprintf(s, sizeof(s), _("Unused backgrounds freed after %2i:%02i:%02i"),
|
2009-11-01 13:22:39 -08:00
|
|
|
dd->bg_timeout / 3600,
|
|
|
|
(dd->bg_timeout / 60) - (60 * (dd->bg_timeout / 3600)),
|
|
|
|
(dd->bg_timeout) - (60 * (dd->bg_timeout / 60)));
|
2007-07-11 02:35:01 -07:00
|
|
|
DialogItemSetText(di, s);
|
|
|
|
|
|
|
|
di = DialogAddItem(table, DITEM_SLIDER);
|
|
|
|
DialogItemSliderSetMinLength(di, 10);
|
|
|
|
DialogItemSliderSetBounds(di, 0, 60 * 60 * 4);
|
|
|
|
DialogItemSliderSetUnits(di, 30);
|
|
|
|
DialogItemSliderSetJump(di, 60);
|
2009-11-01 13:22:39 -08:00
|
|
|
DialogItemSliderSetValPtr(di, &dd->bg_timeout);
|
2007-07-11 02:35:01 -07:00
|
|
|
DialogItemSetCallback(di, CB_DesktopTimeout, 0, label);
|
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"),
|
2008-12-14 08:44:45 -08:00
|
|
|
SOUND_SETTINGS_BG,
|
2006-07-26 21:52:50 -07:00
|
|
|
"pix/bg.png",
|
2010-05-09 12:03:19 -07:00
|
|
|
N_("Enlightenment Desktop\n" "Background Settings Dialog"),
|
2006-08-07 20:58:42 -07:00
|
|
|
_DlgFillBackground,
|
|
|
|
DLG_OAC, CB_ConfigureBG,
|
2006-07-20 20:17:18 -07:00
|
|
|
};
|
|
|
|
|
2009-01-24 00:31:50 -08:00
|
|
|
#endif /* ENABLE_DIALOGS */
|
|
|
|
|
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];
|
2007-07-27 09:59:50 -07:00
|
|
|
int len, value;
|
2004-12-28 15:46:49 -08:00
|
|
|
Background *bg;
|
2009-09-13 06:45:34 -07:00
|
|
|
unsigned int color;
|
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)
|
|
|
|
{
|
2009-09-13 06:45:34 -07:00
|
|
|
COLOR32_FROM_RGB(color, 0, 0, 0);
|
|
|
|
bg = BackgroundCreate(name, color, NULL, 0, 0, 0,
|
2004-12-28 15:46:49 -08:00
|
|
|
0, 0, 0, NULL, 0, 0, 0, 0, 0);
|
|
|
|
if (!bg)
|
|
|
|
{
|
2009-09-06 02:59:40 -07:00
|
|
|
IpcPrintf("Error: could not create background '%s'\n", name);
|
2004-12-28 15:46:49 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-27 09:59:50 -07:00
|
|
|
type[0] = '\0';
|
2004-12-28 15:46:49 -08:00
|
|
|
len = 0;
|
2007-07-27 09:59:50 -07:00
|
|
|
sscanf(p, "%400s %n", type, &len);
|
2004-12-28 15:46:49 -08:00
|
|
|
p += len;
|
2007-07-27 09:59:50 -07:00
|
|
|
value = atoi(p);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
if (!strcmp(type, "bg.solid"))
|
|
|
|
{
|
|
|
|
int r, b, g;
|
|
|
|
|
|
|
|
r = g = b = 0;
|
|
|
|
sscanf(p, "%i %i %i", &r, &g, &b);
|
2009-09-13 06:45:34 -07:00
|
|
|
COLOR32_FROM_RGB(bg->bg_solid, r, g, b);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
else if (!strcmp(type, "bg.file"))
|
|
|
|
{
|
2008-02-23 04:09:38 -08:00
|
|
|
Efree(bg->bg.file);
|
2007-07-27 09:59:50 -07:00
|
|
|
bg->bg.file = Estrdup(p);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
else if (!strcmp(type, "bg.tile"))
|
|
|
|
{
|
2007-07-27 09:59:50 -07:00
|
|
|
bg->bg_tile = value;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
else if (!strcmp(type, "bg.keep_aspect"))
|
|
|
|
{
|
2007-07-27 09:59:50 -07:00
|
|
|
bg->bg.keep_aspect = value;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
else if (!strcmp(type, "bg.xjust"))
|
|
|
|
{
|
2007-07-27 09:59:50 -07:00
|
|
|
bg->bg.xjust = value;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
else if (!strcmp(type, "bg.yjust"))
|
|
|
|
{
|
2007-07-27 09:59:50 -07:00
|
|
|
bg->bg.yjust = value;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
else if (!strcmp(type, "bg.xperc"))
|
|
|
|
{
|
2007-07-27 09:59:50 -07:00
|
|
|
bg->bg.xperc = value;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
else if (!strcmp(type, "bg.yperc"))
|
|
|
|
{
|
2007-07-27 09:59:50 -07:00
|
|
|
bg->bg.yperc = value;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
else if (!strcmp(type, "top.file"))
|
|
|
|
{
|
2008-02-23 04:09:38 -08:00
|
|
|
Efree(bg->top.file);
|
2007-07-27 09:59:50 -07:00
|
|
|
bg->top.file = Estrdup(p);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
else if (!strcmp(type, "top.keep_aspect"))
|
|
|
|
{
|
2007-07-27 09:59:50 -07:00
|
|
|
bg->top.keep_aspect = value;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
else if (!strcmp(type, "top.xjust"))
|
|
|
|
{
|
2007-07-27 09:59:50 -07:00
|
|
|
bg->top.xjust = value;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
else if (!strcmp(type, "top.yjust"))
|
|
|
|
{
|
2007-07-27 09:59:50 -07:00
|
|
|
bg->top.yjust = value;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
else if (!strcmp(type, "top.xperc"))
|
|
|
|
{
|
2007-07-27 09:59:50 -07:00
|
|
|
bg->top.xperc = value;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
else if (!strcmp(type, "top.yperc"))
|
|
|
|
{
|
2007-07-27 09:59:50 -07:00
|
|
|
bg->top.yperc = value;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-09-06 02:59:40 -07:00
|
|
|
IpcPrintf("Error: unknown background value type '%s'\n", type);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
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;
|
2009-09-13 06:45:34 -07:00
|
|
|
unsigned int color;
|
2005-09-04 00:27:20 -07:00
|
|
|
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;
|
|
|
|
|
2010-08-13 10:04:13 -07:00
|
|
|
if (!params)
|
2004-12-28 15:46:49 -08:00
|
|
|
return;
|
|
|
|
|
|
|
|
bgf[0] = topf[0] = '\0';
|
|
|
|
r = g = b = 99;
|
2010-01-29 11:45:04 -08:00
|
|
|
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);
|
2009-09-13 06:45:34 -07:00
|
|
|
COLOR32_FROM_RGB(color, r, g, b);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
bg = BackgroundFind(name);
|
2004-12-28 15:46:49 -08:00
|
|
|
if (bg)
|
|
|
|
{
|
2009-09-13 06:45:34 -07:00
|
|
|
BackgroundModify(bg, color, bgf, tile, keep_aspect, xjust,
|
2005-11-27 03:02:05 -08:00
|
|
|
yjust, xperc, yperc, topf, tkeep_aspect,
|
|
|
|
txjust, tyjust, txperc, typerc);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-01-29 11:45:04 -08:00
|
|
|
BackgroundCreate(name, color, bgf, tile, keep_aspect, xjust,
|
|
|
|
yjust, xperc, yperc, topf, tkeep_aspect,
|
|
|
|
txjust, tyjust, txperc, typerc);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-05-18 01:25:06 -07:00
|
|
|
BackgroundsIpc(const char *params)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
2007-09-05 12:12:56 -07:00
|
|
|
len = len2 = 0;
|
2004-12-28 15:46:49 -08:00
|
|
|
cmd[0] = prm[0] = '\0';
|
|
|
|
p = params;
|
|
|
|
if (p)
|
|
|
|
{
|
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))
|
|
|
|
{
|
2009-12-03 11:29:30 -08:00
|
|
|
EX_Window xwin;
|
2006-04-29 12:39:21 -07:00
|
|
|
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;
|
|
|
|
|
2013-12-28 09:59:09 -08:00
|
|
|
xwin = NoXID;
|
2009-12-03 11:29:30 -08:00
|
|
|
sscanf(p, "%x", &xwin);
|
2006-04-29 12:39:21 -07:00
|
|
|
|
|
|
|
win = ECreateWinFromXwin(xwin);
|
|
|
|
if (!win)
|
|
|
|
return;
|
|
|
|
BackgroundApplyWin(bg, win);
|
|
|
|
EDestroyWin(win);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
else if (!strncmp(cmd, "del", 2))
|
|
|
|
{
|
|
|
|
BackgroundDestroyByName(prm);
|
|
|
|
}
|
|
|
|
else if (!strncmp(cmd, "list", 2))
|
|
|
|
{
|
2013-06-06 13:37:06 -07:00
|
|
|
LIST_FOR_EACH(Background, &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
|
|
|
|
{
|
2010-01-29 11:45:04 -08:00
|
|
|
BrackgroundCreateFromImage(prm, p, NULL, 0);
|
2005-01-28 16:07:20 -08:00
|
|
|
}
|
|
|
|
}
|
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
|
2009-09-06 02:59:40 -07:00
|
|
|
IpcPrintf("Error: background '%s' does not exist\n", prm);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
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
|
2009-09-06 02:59:40 -07:00
|
|
|
IpcPrintf("Error: background '%s' does not exist\n", prm);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
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
|
2007-05-18 01:25:06 -07:00
|
|
|
IPC_BackgroundUse(const char *params)
|
2005-02-01 12:35:59 -08:00
|
|
|
{
|
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-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 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}
|
|
|
|
,
|
2004-12-28 15:46:49 -08:00
|
|
|
};
|
|
|
|
#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),
|
2008-11-22 13:17:02 -08:00
|
|
|
CFG_ITEM_BOOL(Conf.backgrounds, no_scan, 0),
|
2005-03-20 15:28:59 -08:00
|
|
|
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;
|
2010-08-08 12:03:34 -07:00
|
|
|
|
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
|
|
|
};
|