mirror of
https://github.com/edeproject/ede.git
synced 2023-08-10 21:13:03 +03:00
Importing new code. Not finished yet
This commit is contained in:
parent
0e76d586ca
commit
fea5d1bc19
292
ede-screensaver-conf/XScreenSaver.cpp
Normal file
292
ede-screensaver-conf/XScreenSaver.cpp
Normal file
@ -0,0 +1,292 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h> // toupper
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xresource.h>
|
||||
|
||||
#include <edelib/File.h>
|
||||
#include <edelib/Run.h>
|
||||
#include <edelib/Directory.h>
|
||||
|
||||
#include "XScreenSaver.h"
|
||||
|
||||
EDELIB_NS_USING(String)
|
||||
EDELIB_NS_USING(file_path)
|
||||
EDELIB_NS_USING(run_program)
|
||||
EDELIB_NS_USING(dir_home)
|
||||
|
||||
static Atom XA_SCREENSAVER;
|
||||
static Atom XA_SCREENSAVER_VERSION;
|
||||
static Atom XA_DEMO;
|
||||
static Atom XA_SELECT;
|
||||
|
||||
static XErrorHandler old_handler = 0;
|
||||
static Bool got_bad_window = False;
|
||||
static int atoms_loaded = 0;
|
||||
|
||||
static int bad_window_handler(Display *dpy, XErrorEvent *xevent) {
|
||||
if(xevent->error_code == BadWindow) {
|
||||
got_bad_window = True;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(!old_handler)
|
||||
return 0;
|
||||
|
||||
return (*old_handler)(dpy, xevent);
|
||||
}
|
||||
|
||||
/*
|
||||
* convert "xx:xx:xx" to minutes
|
||||
* TODO: a better code would be great
|
||||
*/
|
||||
static int time_to_min(const char *t) {
|
||||
char nb[64];
|
||||
const char *p = t;
|
||||
unsigned int i = 0;
|
||||
int ret = 0;
|
||||
|
||||
for(; *p && *p != ':' && i < sizeof(nb); p++, i++)
|
||||
nb[i] = *p;
|
||||
p++;
|
||||
nb[i] = '\0';
|
||||
|
||||
ret = atoi(nb) * 60;
|
||||
|
||||
i = 0;
|
||||
if(*p) {
|
||||
for(i = 0; *p && *p != ':' && i < sizeof(nb); p++, i++)
|
||||
nb[i] = *p;
|
||||
p++;
|
||||
}
|
||||
|
||||
nb[i] = '\0';
|
||||
ret += atoi(nb);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void xscreensaver_init_atoms_once(Display *dpy) {
|
||||
if(atoms_loaded)
|
||||
return;
|
||||
|
||||
XA_SCREENSAVER = XInternAtom(dpy, "SCREENSAVER", False);
|
||||
XA_SCREENSAVER_VERSION = XInternAtom(dpy, "_SCREENSAVER_VERSION", False);
|
||||
XA_DEMO = XInternAtom(dpy, "DEMO", False);
|
||||
XA_SELECT = XInternAtom(dpy, "SELECT", False);
|
||||
XSync(dpy, 0);
|
||||
|
||||
atoms_loaded = 1;
|
||||
}
|
||||
|
||||
static Window xscreensaver_find_own_window(Display *dpy) {
|
||||
Window root = RootWindow(dpy, DefaultScreen(dpy));
|
||||
Window root2, parent, *childs;
|
||||
unsigned int nchilds;
|
||||
|
||||
if(!XQueryTree(dpy, root, &root2, &parent, &childs, &nchilds))
|
||||
return 0;
|
||||
if(root != root2)
|
||||
return 0;
|
||||
|
||||
for(unsigned int i = 0; i < nchilds; i++) {
|
||||
Atom type;
|
||||
int format;
|
||||
unsigned long nitems, bytesafter;
|
||||
char *v;
|
||||
int status;
|
||||
|
||||
XSync(dpy, False);
|
||||
got_bad_window = False;
|
||||
old_handler = XSetErrorHandler(bad_window_handler);
|
||||
|
||||
status = XGetWindowProperty(dpy, childs[i], XA_SCREENSAVER_VERSION, 0, 200, False, XA_STRING,
|
||||
&type, &format, &nitems, &bytesafter,
|
||||
(unsigned char**)&v);
|
||||
|
||||
XSync(dpy, False);
|
||||
XSetErrorHandler(old_handler);
|
||||
old_handler = 0;
|
||||
|
||||
if(got_bad_window) {
|
||||
status = BadWindow;
|
||||
got_bad_window = False;
|
||||
}
|
||||
|
||||
if(status == Success && type != None) {
|
||||
/* TODO: check if XFree(v) is needed */
|
||||
Window ret = childs[i];
|
||||
XFree(childs);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
XFree(childs);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void xscreensaver_run_hack(Display *dpy, Window id, long hack) {
|
||||
XEvent ev;
|
||||
|
||||
ev.xany.type = ClientMessage;
|
||||
ev.xclient.display = dpy;
|
||||
ev.xclient.window = id;
|
||||
ev.xclient.message_type = XA_SCREENSAVER;
|
||||
ev.xclient.format = 32;
|
||||
ev.xclient.data.l[0] = XA_SELECT;
|
||||
ev.xclient.data.l[1] = hack;
|
||||
ev.xclient.data.l[2] = 0;
|
||||
|
||||
/*
|
||||
ev.xclient.data.l[0] = XA_DEMO;
|
||||
ev.xclient.data.l[1] = 5000; // XA_DEMO protocol version
|
||||
ev.xclient.data.l[2] = hack;
|
||||
*/
|
||||
|
||||
if(XSendEvent(dpy, id, False, 0, &ev) == 0)
|
||||
puts("XSendEvent() failed");
|
||||
else
|
||||
XSync(dpy, 0);
|
||||
}
|
||||
|
||||
bool xscreensaver_run(Display *dpy) {
|
||||
xscreensaver_init_atoms_once(dpy);
|
||||
|
||||
Window id = xscreensaver_find_own_window(dpy);
|
||||
|
||||
/* if not running, try to manualy start it */
|
||||
if(id == 0) {
|
||||
String p = file_path("xscreensaver");
|
||||
if(p.empty())
|
||||
return false;
|
||||
|
||||
/* run 'xscreensaver -nosplash' */
|
||||
p += " -nosplash";
|
||||
run_program(p.c_str());
|
||||
|
||||
/* check again */
|
||||
id = xscreensaver_find_own_window(dpy);
|
||||
if(id == 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
SaverPrefs *xscreensaver_read_config(void) {
|
||||
XrmDatabase db;
|
||||
XrmValue xrmv;
|
||||
char *type;
|
||||
|
||||
/*
|
||||
* Luckily, xscreensaver uses X resource for storage
|
||||
* which saves me from parsing... jwz thanx !!!
|
||||
*/
|
||||
String path = dir_home();
|
||||
path += "/.xscreensaver";
|
||||
|
||||
XrmInitialize();
|
||||
|
||||
db = XrmGetFileDatabase(path.c_str());
|
||||
if(!db) {
|
||||
puts("Unable to open xscreensaver config file");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SaverPrefs *ret = new SaverPrefs;
|
||||
ret->curr_hack = 0;
|
||||
ret->timeout = 2; // in minutes
|
||||
ret->dpms_enabled = false;
|
||||
ret->dpms_standby = ret->dpms_suspend = ret->dpms_off = 30; // in minutes
|
||||
|
||||
if(XrmGetResource(db, "selected", "*", &type, &xrmv) == True && xrmv.addr != NULL) {
|
||||
/*
|
||||
* safe without checks since 0 (if atoi() fails) is first hack
|
||||
* in the list
|
||||
*/
|
||||
ret->curr_hack = atoi(xrmv.addr);
|
||||
}
|
||||
|
||||
if(XrmGetResource(db, "timeout", "*", &type, &xrmv) == True && xrmv.addr != NULL)
|
||||
ret->timeout = time_to_min(xrmv.addr);
|
||||
|
||||
if(XrmGetResource(db, "dpmsEnabled", "*", &type, &xrmv) == True && xrmv.addr != NULL) {
|
||||
const char *v = xrmv.addr;
|
||||
|
||||
if(!strcasecmp(v, "true") || !strcasecmp(v, "on") || !strcasecmp(v, "yes"))
|
||||
ret->dpms_enabled = true;
|
||||
}
|
||||
|
||||
if(XrmGetResource(db, "dpmsStandby", "*", &type, &xrmv) == True && xrmv.addr != NULL)
|
||||
ret->dpms_standby = time_to_min(xrmv.addr);
|
||||
|
||||
if(XrmGetResource(db, "dpmsSuspend", "*", &type, &xrmv) == True && xrmv.addr != NULL)
|
||||
ret->dpms_suspend = time_to_min(xrmv.addr);
|
||||
|
||||
if(XrmGetResource(db, "dpmsOff", "*", &type, &xrmv) == True && xrmv.addr != NULL)
|
||||
ret->dpms_off = time_to_min(xrmv.addr);
|
||||
|
||||
/*
|
||||
* Parse hacks (screensavers), skipping those that starts with '-'. Also, check if hack
|
||||
* contains name beside command (e.g. '"Qix (solid)" qix -root') and use it; otherwise use
|
||||
* capitalized command name.
|
||||
*
|
||||
* Note that to the each hack will be given index number; in the final GUI list they
|
||||
* will be ordered, but xscreensaver keeps own order for selecting that must be preserved.
|
||||
*/
|
||||
int nhacks = 0;
|
||||
|
||||
if(XrmGetResource(db, "programs", "*", &type, &xrmv) == True) {
|
||||
char *programs = strdup(xrmv.addr);
|
||||
char *c = NULL;
|
||||
char *p = NULL;
|
||||
char buf[256];
|
||||
unsigned int i;
|
||||
|
||||
for(c = strtok(programs, "\n"); c; c = strtok(NULL, "\n"), nhacks++) {
|
||||
if(c[0] == '-')
|
||||
continue;
|
||||
|
||||
if((p = strstr(c, "GL:")) != NULL) {
|
||||
p += 3;
|
||||
c = p;
|
||||
}
|
||||
|
||||
/* eat spaces */
|
||||
while(*c && (*c == ' ' || *c == '\t'))
|
||||
c++;
|
||||
|
||||
if(*c == '"') {
|
||||
/* extract name from '"' */
|
||||
c++;
|
||||
|
||||
for(i = 0; i < sizeof(buf) && *c && *c != '"'; c++, i++)
|
||||
buf[i] = *c;
|
||||
|
||||
buf[i] = '\0';
|
||||
} else {
|
||||
/* or read command and capitalize it */
|
||||
for(i = 0; i < sizeof(buf) && *c && *c != ' '; c++, i++)
|
||||
buf[i] = *c;
|
||||
|
||||
buf[i] = '\0';
|
||||
buf[0] = toupper(buf[0]);
|
||||
}
|
||||
|
||||
SaverHack *h = new SaverHack;
|
||||
h->name = buf;
|
||||
h->sindex = nhacks;
|
||||
|
||||
ret->hacks.push_back(h);
|
||||
}
|
||||
|
||||
free(programs);
|
||||
}
|
||||
|
||||
XrmDestroyDatabase(db);
|
||||
return ret;
|
||||
}
|
29
ede-screensaver-conf/XScreenSaver.h
Normal file
29
ede-screensaver-conf/XScreenSaver.h
Normal file
@ -0,0 +1,29 @@
|
||||
#ifndef __XSCREENSAVER_H__
|
||||
#define __XSCREENSAVER_H__
|
||||
|
||||
#include <edelib/List.h>
|
||||
#include <edelib/String.h>
|
||||
|
||||
struct SaverHack {
|
||||
edelib::String name;
|
||||
int sindex;
|
||||
};
|
||||
|
||||
typedef edelib::list<SaverHack*> HackList;
|
||||
typedef edelib::list<SaverHack*>::iterator HackListIter;
|
||||
|
||||
struct SaverPrefs {
|
||||
HackList hacks;
|
||||
int curr_hack;
|
||||
int timeout;
|
||||
|
||||
bool dpms_enabled;
|
||||
int dpms_standby;
|
||||
int dpms_suspend;
|
||||
int dpms_off;
|
||||
};
|
||||
|
||||
bool xscreensaver_run(void);
|
||||
SaverPrefs *xscreensaver_read_config(void);
|
||||
|
||||
#endif
|
115
ede-screensaver-conf/ede-screensaver-conf.cpp
Normal file
115
ede-screensaver-conf/ede-screensaver-conf.cpp
Normal file
@ -0,0 +1,115 @@
|
||||
#include <FL/Fl.H>
|
||||
#include <FL/Fl_Double_Window.H>
|
||||
#include <FL/Fl_Box.H>
|
||||
#include <FL/Fl_Group.H>
|
||||
#include <FL/Fl_Choice.H>
|
||||
#include <FL/Fl_Spinner.H>
|
||||
#include <FL/Fl_Check_Button.H>
|
||||
#include <FL/Fl_Button.H>
|
||||
#include <FL/Fl_Pixmap.H>
|
||||
|
||||
#include <edelib/Nls.h>
|
||||
#include <edelib/Debug.h>
|
||||
|
||||
#include "XScreenSaver.h"
|
||||
#include "icons/energy.xpm"
|
||||
|
||||
static Fl_Pixmap image_energy(energy_star_xpm);
|
||||
|
||||
static Fl_Spinner* standby_val;
|
||||
static Fl_Spinner* suspend_val;
|
||||
static Fl_Spinner* off_val;
|
||||
|
||||
static void dpms_enable_cb(Fl_Widget* w, void*) {
|
||||
Fl_Check_Button* o = (Fl_Check_Button*)w;
|
||||
if(o->value()) {
|
||||
standby_val->activate();
|
||||
suspend_val->activate();
|
||||
off_val->activate();
|
||||
} else {
|
||||
standby_val->deactivate();
|
||||
suspend_val->deactivate();
|
||||
off_val->deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
static void close_cb(Fl_Widget*, void* w) {
|
||||
Fl_Double_Window* win = (Fl_Double_Window*)w;
|
||||
win->hide();
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
SaverPrefs* sp = xscreensaver_read_config();
|
||||
E_ASSERT(sp != NULL);
|
||||
|
||||
Fl_Double_Window* win = new Fl_Double_Window(340, 445, _("Screensaver options"));
|
||||
win->begin();
|
||||
/* monitor */
|
||||
Fl_Box* b1 = new Fl_Box(120, 163, 100, 15);
|
||||
b1->box(FL_BORDER_BOX);
|
||||
Fl_Box* b2 = new Fl_Box(65, 10, 210, 158);
|
||||
b2->box(FL_THIN_UP_BOX);
|
||||
/* box size is intentionaly odd so preserve aspect ratio */
|
||||
Fl_Box* b3 = new Fl_Box(78, 20, 184, 138);
|
||||
b3->box(FL_DOWN_BOX);
|
||||
b3->color(FL_BLACK);
|
||||
Fl_Box* b4 = new Fl_Box(95, 173, 146, 14);
|
||||
b4->box(FL_THIN_UP_BOX);
|
||||
|
||||
Fl_Group* g1 = new Fl_Group(10, 215, 320, 45, _("Screensaver"));
|
||||
g1->box(FL_ENGRAVED_BOX);
|
||||
g1->align(FL_ALIGN_TOP_LEFT);
|
||||
g1->begin();
|
||||
Fl_Choice* saver_list = new Fl_Choice(19, 225, 180, 25);
|
||||
saver_list->down_box(FL_BORDER_BOX);
|
||||
|
||||
HackListIter it = sp->hacks.begin(), it_end = sp->hacks.end();
|
||||
for(; it != it_end; ++it) {
|
||||
saver_list->add((*it)->name.c_str(), 0, 0);
|
||||
delete *it;
|
||||
}
|
||||
|
||||
Fl_Spinner* timeout = new Fl_Spinner(275, 226, 45, 25, _("Timeout:"));
|
||||
timeout->tooltip(_("Idle time in minutes after screensaver is started"));
|
||||
timeout->value(sp->timeout);
|
||||
g1->end();
|
||||
|
||||
Fl_Group* g2 = new Fl_Group(10, 290, 320, 110, _("DPMS"));
|
||||
g2->box(FL_ENGRAVED_BOX);
|
||||
g2->align(FL_ALIGN_TOP_LEFT);
|
||||
g2->begin();
|
||||
Fl_Check_Button* denabled = new Fl_Check_Button(20, 299, 180, 26, _("Enabled"));
|
||||
denabled->down_box(FL_DOWN_BOX);
|
||||
denabled->tooltip(_("Enable or disable Display Power Management Signaling support"));
|
||||
denabled->callback((Fl_Callback*)dpms_enable_cb);
|
||||
denabled->value(sp->dpms_enabled);
|
||||
|
||||
Fl_Box* energy_image = new Fl_Box(20, 341, 75, 49);
|
||||
energy_image->image(image_energy);
|
||||
|
||||
standby_val = new Fl_Spinner(275, 301, 45, 24, _("Standby:"));
|
||||
standby_val->tooltip(_("Minutes for standby"));
|
||||
standby_val->value(sp->dpms_standby);
|
||||
|
||||
suspend_val = new Fl_Spinner(275, 331, 45, 24, _("Suspend:"));
|
||||
suspend_val->tooltip(_("Minutes for suspend"));
|
||||
suspend_val->value(sp->dpms_suspend);
|
||||
|
||||
off_val = new Fl_Spinner(275, 360, 45, 24, _("Off:"));
|
||||
off_val->tooltip(_("Minutes to turn off the screen"));
|
||||
off_val->value(sp->dpms_off);
|
||||
|
||||
/* execute callback to apply changes before window is shown */
|
||||
denabled->do_callback();
|
||||
g2->end();
|
||||
|
||||
Fl_Button* ok_button = new Fl_Button(145, 410, 90, 25, _("&OK"));
|
||||
|
||||
Fl_Button* close_button = new Fl_Button(240, 410, 90, 25, _("&Cancel"));
|
||||
close_button->callback(close_cb, win);
|
||||
win->end();
|
||||
delete sp;
|
||||
|
||||
win->show(argc, argv);
|
||||
return Fl::run();
|
||||
}
|
68
ede-screensaver-conf/ede-screensaver-conf.fl
Normal file
68
ede-screensaver-conf/ede-screensaver-conf.fl
Normal file
@ -0,0 +1,68 @@
|
||||
# data file for the Fltk User Interface Designer (fluid)
|
||||
version 1.0108
|
||||
header_name {.h}
|
||||
code_name {.cxx}
|
||||
Function {} {} {
|
||||
Fl_Window {} {
|
||||
label {Screensaver options} open
|
||||
xywh {266 111 340 445} type Double visible
|
||||
} {
|
||||
Fl_Box {} {
|
||||
xywh {120 163 100 15} box BORDER_BOX
|
||||
}
|
||||
Fl_Box {} {
|
||||
xywh {65 10 210 158} box THIN_UP_BOX
|
||||
}
|
||||
Fl_Box {} {
|
||||
xywh {78 20 184 138} box DOWN_BOX color 56
|
||||
code0 {/* box size is intentionaly odd so preserve aspect ratio */}
|
||||
}
|
||||
Fl_Box {} {
|
||||
xywh {95 173 146 14} box THIN_UP_BOX
|
||||
}
|
||||
Fl_Group {} {
|
||||
label Screensaver open
|
||||
xywh {10 215 320 45} box ENGRAVED_BOX align 5
|
||||
} {
|
||||
Fl_Choice {} {
|
||||
xywh {19 225 180 25} down_box BORDER_BOX labelsize 14 textsize 14
|
||||
} {}
|
||||
Fl_Spinner {} {
|
||||
label {Timeout:}
|
||||
tooltip {Idle time in minutes after screensaver is started} xywh {275 226 45 25} value 1
|
||||
}
|
||||
}
|
||||
Fl_Group {} {
|
||||
label DPMS open
|
||||
xywh {10 290 320 110} box ENGRAVED_BOX align 5
|
||||
} {
|
||||
Fl_Check_Button {} {
|
||||
label Enabled
|
||||
xywh {20 299 180 26} down_box DOWN_BOX
|
||||
}
|
||||
Fl_Box {} {selected
|
||||
image {icons/energy.xpm} xywh {20 341 75 49} labelsize 14
|
||||
}
|
||||
Fl_Spinner {} {
|
||||
label {Standby:}
|
||||
tooltip {Minutes for standby} xywh {275 301 45 24} value 1
|
||||
}
|
||||
Fl_Spinner {} {
|
||||
label {Suspend:}
|
||||
tooltip {Minutes for suspend} xywh {275 331 45 24} value 1
|
||||
}
|
||||
Fl_Spinner {} {
|
||||
label {Off:}
|
||||
tooltip {Minutes to turn off the screen} xywh {275 360 45 24} value 1
|
||||
}
|
||||
}
|
||||
Fl_Button {} {
|
||||
label {&OK}
|
||||
xywh {145 410 90 25}
|
||||
}
|
||||
Fl_Button {} {
|
||||
label {&Cancel}
|
||||
xywh {240 410 90 25}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,207 +0,0 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Screensaver configuration
|
||||
* Part of Equinox Desktop Environment (EDE).
|
||||
* Copyright (c) 2000-2006 EDE Authors.
|
||||
*
|
||||
* This program is licenced under terms of the
|
||||
* GNU General Public Licence version 2 or newer.
|
||||
* See COPYING for details.
|
||||
*/
|
||||
|
||||
|
||||
// This is from xscreensaver 4.0 XScreenSaver.ad
|
||||
|
||||
char hacks[] = " \
|
||||
\"Qix (solid)\" qix -root -solid -segments 100 \n\
|
||||
\"Qix (transparent)\" qix -root -count 4 -solid -transparent \n\
|
||||
\"Qix (linear)\" qix -root -count 5 -solid -transparent \
|
||||
-linear -segments 250 -size 100 \n\
|
||||
- mono: \"Qix (xor)\" qix -root -linear -count 5 -size 200 \
|
||||
-spread 30 -segments 75 -solid -xor \n\
|
||||
\
|
||||
\"Attraction (balls)\" attraction -root -mode balls \n\
|
||||
\"Attraction (lines)\" attraction -root -mode lines -points 3\
|
||||
-segments 200 \n\
|
||||
- \"Attraction (poly)\" attraction -root -mode polygons \n\
|
||||
\"Attraction (splines)\" attraction -root -mode splines -segments \
|
||||
300 \n\
|
||||
\"Attraction (orbital)\" attraction -root -mode lines -radius 300 \
|
||||
-orbit -vmult 0.5 \n\
|
||||
\
|
||||
pyro -root \n\
|
||||
rocks -root \n\
|
||||
helix -root \n\
|
||||
pedal -root \n\
|
||||
rorschach -root -offset 7 \n\
|
||||
hopalong -root \n\
|
||||
greynetic -root \n\
|
||||
imsmap -root \n\
|
||||
slidescreen -root \n\
|
||||
decayscreen -root \n\
|
||||
jigsaw -root \n\
|
||||
blitspin -root -grab \n\
|
||||
slip -root \n\
|
||||
distort -root \n\
|
||||
spotlight -root \n\
|
||||
\"Ripples (oily)\" ripples -root -oily -light 2 \n\
|
||||
\"Ripples (stir)\" ripples -root -oily -light 2 -stir \n\
|
||||
\"Ripples (desktop)\" ripples -root -water -light 6 \n\
|
||||
hypercube -root \n\
|
||||
hyperball -root \n\
|
||||
halo -root \n\
|
||||
maze -root \n\
|
||||
noseguy -root \n\
|
||||
flame -root \n\
|
||||
lmorph -root \n\
|
||||
deco -root \n\
|
||||
moire -root \n\
|
||||
moire2 -root \n\
|
||||
lightning -root \n\
|
||||
strange -root \n\
|
||||
spiral -root \n\
|
||||
laser -root \n\
|
||||
grav -root \n\
|
||||
\"Grav (trails)\" grav -root -trail -decay \n\
|
||||
drift -root \n\
|
||||
ifs -root \n\
|
||||
julia -root \n\
|
||||
penrose -root \n\
|
||||
sierpinski -root \n\
|
||||
braid -root \n\
|
||||
galaxy -root \n\
|
||||
bouboule -root \n\
|
||||
swirl -root \n\
|
||||
flag -root \n\
|
||||
sphere -root \n\
|
||||
forest -root \n\
|
||||
lisa -root \n\
|
||||
lissie -root \n\
|
||||
goop -root -max-velocity 0.5 -elasticity \
|
||||
0.9 \n\
|
||||
starfish -root \n\
|
||||
\"Starfish (blob)\" starfish -root -blob \n\
|
||||
munch -root \n\
|
||||
fadeplot -root \n\
|
||||
coral -root -delay 0 \n\
|
||||
mountain -root \n\
|
||||
triangle -root -delay 1 \n\
|
||||
worm -root \n\
|
||||
rotor -root \n\
|
||||
ant -root \n\
|
||||
demon -root \n\
|
||||
loop -root \n\
|
||||
vines -root \n\
|
||||
kaleidescope -root \n\
|
||||
xjack -root \n\
|
||||
xlyap -root -randomize \n\
|
||||
cynosure -root \n\
|
||||
flow -root \n\
|
||||
epicycle -root \n\
|
||||
interference -root \n\
|
||||
truchet -root -randomize \n\
|
||||
bsod -root \n\
|
||||
crystal -root \n\
|
||||
discrete -root \n\
|
||||
kumppa -root \n\
|
||||
rd-bomb -root \n\
|
||||
\"RD-Bomb (mobile)\" rd-bomb -root -speed 1 -size 0.1 \n\
|
||||
sonar -root \n\
|
||||
t3d -root \n\
|
||||
penetrate -root \n\
|
||||
deluxe -root \n\
|
||||
compass -root \n\
|
||||
squiral -root \n\
|
||||
xflame -root \n\
|
||||
wander -root \n\
|
||||
\"Wander (spots)\" wander -root -advance 0 -size 10 -circles \
|
||||
-length 10000 -reset 100000 \n\
|
||||
critical -root \n\
|
||||
phosphor -root \n\
|
||||
xmatrix -root \n\
|
||||
petri -root -size 2 -count 20 \n\
|
||||
\"Petri 2\" petri -root -minlifespeed 0.02 \
|
||||
-maxlifespeed 0.03 -minlifespan 1 \
|
||||
-maxlifespan 1 -instantdeathchan 0 \
|
||||
-minorchan 0 -anychan 0.3 \n\
|
||||
shadebobs -root \n\
|
||||
ccurve -root \n\
|
||||
blaster -root \n\
|
||||
bumps -root \n\
|
||||
xteevee -root \n\
|
||||
xspirograph -root \n\
|
||||
nerverot -root \n\
|
||||
- \"NerveRot (dense)\" nerverot -root -count 1000 \n\
|
||||
- \"NerveRot (thick)\" nerverot -root -count 100 -line-width 4 \
|
||||
-max-nerve-radius 0.8 -nervousness 0.5 -db \n\
|
||||
xrayswarm -root \n\
|
||||
- \"Zoom (Fatbits)\" zoom -root \n\
|
||||
\"Zoom (Lenses)\" zoom -root -lenses \n\
|
||||
rotzoomer -root \n\
|
||||
- \"RotZoomer (mobile)\" rotzoomer -root -move \n\
|
||||
- \"RotZoomer (sweep)\" rotzoomer -root -sweep \n\
|
||||
whirlwindwarp -root \n\
|
||||
\"WhirlyGig\" whirlygig -root \n\
|
||||
\"SpeedMine\" speedmine -root \n\
|
||||
\"SpeedWorm\" speedmine -root -worm \n\
|
||||
vermiculate -root \n\
|
||||
color: bubbles -root \n\
|
||||
default-n: webcollage -root \n\
|
||||
default-n: \"WebCollage (whacked)\" \
|
||||
webcollage -root -filter \
|
||||
'vidwhacker -stdin -stdout' \n\
|
||||
- default-n: vidwhacker -root \n\
|
||||
\
|
||||
GL: gears -root \n\
|
||||
GL: \"Gears (planetary)\" gears -root -planetary \n\
|
||||
GL: superquadrics -root \n\
|
||||
GL: morph3d -root \n\
|
||||
GL: cage -root \n\
|
||||
GL: moebius -root \n\
|
||||
GL: stairs -root \n\
|
||||
GL: pipes -root \n\
|
||||
GL: sproingies -root \n\
|
||||
GL: rubik -root \n\
|
||||
GL: atlantis -root \n\
|
||||
GL: lament -root \n\
|
||||
GL: bubble3d -root \n\
|
||||
GL: glplanet -root \n\
|
||||
GL: pulsar -root \n\
|
||||
- GL: \"Pulsar (textures)\" \
|
||||
pulsar -root -texture -mipmap \
|
||||
-texture_quality -light -fog \n\
|
||||
- GL: extrusion -root \n\
|
||||
GL: sierpinski3d -root \n\
|
||||
GL: menger -root \n\
|
||||
GL: \"GFlux\" gflux -root \n\
|
||||
GL: \"GFlux (grab)\" gflux -root -mode grab \n\
|
||||
GL: stonerview -root \n\
|
||||
GL: starwars -root \n\
|
||||
GL: gltext -root \n\
|
||||
GL: \"GLText (clock)\" gltext -text \"%A%n%d %b %Y%n%r\" -root \n\
|
||||
GL: \"Molecule\" molecule -root \n\
|
||||
GL: \"Molecule (lumpy)\" molecule -root -no-bonds -no-labels \n\
|
||||
GL: dangerball -root \n\
|
||||
GL: circuit -root \n\
|
||||
GL: engine -root \n\
|
||||
GL: flipscreen3d -root \n\
|
||||
\
|
||||
- xdaliclock -root -builtin3 -cycle \n\
|
||||
- default-n: xearth -nofork -nostars -ncolors 50 \
|
||||
-night 3 -wait 0 -timewarp 400.0 -pos \
|
||||
sunrel/38/-30 \n\
|
||||
- xplanetbg -xscreensaver -moonside \
|
||||
-markerfile earth -wait 1 -timewarp 400 \n\
|
||||
- ssystem -fullscreen :32 \n\
|
||||
- xmountains -b -M -Z 0 -r 1 \n\
|
||||
- \"XMountains (top)\" xmountains -b -M -Z 0 -r 1 -m \n\
|
||||
- xaos -fullscreen -autopilot \
|
||||
-incoloring -1 -outcoloring -1 \n\
|
||||
- xfishtank -d -s \n\
|
||||
- xsnow \n\
|
||||
- goban -root \n\
|
||||
- electricsheep \n\
|
||||
- cosmos -root \n\
|
||||
- GL: sphereEversion --root \n";
|
||||
|
@ -1,514 +0,0 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Screensaver configuration
|
||||
* Part of Equinox Desktop Environment (EDE).
|
||||
* Copyright (c) 2000-2006 EDE Authors.
|
||||
*
|
||||
* This program is licenced under terms of the
|
||||
* GNU General Public Licence version 2 or newer.
|
||||
* See COPYING for details.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/stat.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../edeconf.h"
|
||||
// blah
|
||||
|
||||
/*#include <efltk/fl_ask.h>
|
||||
#include <efltk/Fl_Util.h>
|
||||
#include <efltk/Fl_Input_Browser.h>
|
||||
#include <efltk/Fl_Config.h>*/
|
||||
|
||||
#include <fltk/ask.h>
|
||||
//#include <efltk/Fl_Util.h>
|
||||
#include <fltk/InputBrowser.h>
|
||||
#include <fltk/Window.h>
|
||||
#include <fltk/x.h>
|
||||
#include "../edelib2/Config.h"
|
||||
|
||||
#include "escreensaver.h"
|
||||
#include "escrsaverconf.h"
|
||||
#include "ehacklist.h"
|
||||
|
||||
|
||||
using namespace fltk;
|
||||
using namespace edelib;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int running_saver = 0;
|
||||
pid_t running_preview_pid = 0;
|
||||
int default_saver = 0;
|
||||
|
||||
typedef struct screenhack screenhack;
|
||||
struct screenhack
|
||||
{
|
||||
bool enabled_p;
|
||||
char *visual;
|
||||
char *name;
|
||||
char *command;
|
||||
};
|
||||
|
||||
struct saver_preferences
|
||||
{
|
||||
screenhack **screenhacks; /* the scrsavers to run */
|
||||
int screenhacks_count;
|
||||
};
|
||||
|
||||
char* format_command(const char *cmd, bool wrap_p);
|
||||
|
||||
/* Returns a new string describing the shell command.
|
||||
This may be just the name of the program, capitalized.
|
||||
It also may be something from the resource database (gotten
|
||||
by looking for "hacks.XYZ.name", where XYZ is the program.)
|
||||
*/
|
||||
char* make_hack_name(const char *shell_command)
|
||||
{
|
||||
char *s = strdup (shell_command);
|
||||
char *s2;
|
||||
|
||||
for (s2 = s; *s2; s2++) /* truncate at first whitespace */
|
||||
if (isspace (*s2))
|
||||
{
|
||||
*s2 = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
s2 = strrchr (s, '/'); /* if pathname, take last component */
|
||||
if (s2)
|
||||
{
|
||||
s2 = strdup (s2+1);
|
||||
free (s);
|
||||
s = s2;
|
||||
}
|
||||
|
||||
if (strlen (s) > 50) /* 51 is hereby defined as "unreasonable" */
|
||||
s[50] = 0;
|
||||
|
||||
for (s2 = s; *s2; s2++) /* if it has any capitals, return it */
|
||||
if (*s2 >= 'A' && *s2 <= 'Z')
|
||||
return s;
|
||||
|
||||
/* else cap it */
|
||||
if (s[0] >= 'a' && s[0] <= 'z')
|
||||
s[0] -= 'a'-'A';
|
||||
/* (magic leading X) */
|
||||
if (s[0] == 'X' && s[1] >= 'a' && s[1] <= 'z')
|
||||
s[1] -= 'a'-'A';
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
//Parsing scrsavers
|
||||
|
||||
screenhack* parse_screenhack(const char *line)
|
||||
{
|
||||
screenhack *h = (screenhack *) calloc (1, sizeof(*h));
|
||||
const char *s;
|
||||
|
||||
h->enabled_p = true;
|
||||
|
||||
/* skip whitespace */
|
||||
while (isspace(*line)) line++;
|
||||
if (*line == '-') /* handle "-" */
|
||||
{
|
||||
h->enabled_p = false;
|
||||
line++;
|
||||
/* skip whitespace */
|
||||
while (isspace(*line)) line++;
|
||||
}
|
||||
|
||||
s = line; /* handle "visual:" */
|
||||
while (*line && *line != ':' && *line != '"' && !isspace(*line))
|
||||
line++;
|
||||
if (*line != ':')
|
||||
line = s;
|
||||
else
|
||||
{
|
||||
h->visual = (char *) malloc (line-s+1);
|
||||
strncpy (h->visual, s, line-s);
|
||||
h->visual[line-s] = 0;
|
||||
if (*line == ':') line++;/* skip ":" */
|
||||
/* skip whitespace */
|
||||
while (isspace(*line)) line++;
|
||||
}
|
||||
|
||||
if (*line == '"') /* handle "name" */
|
||||
{
|
||||
line++;
|
||||
s = line;
|
||||
while (*line && *line != '"')
|
||||
line++;
|
||||
h->name = (char *) malloc (line-s+1);
|
||||
strncpy(h->name, s, line-s);
|
||||
h->name[line-s] = 0;
|
||||
if (*line == '"') line++;/* skip "\"" */
|
||||
/* skip whitespace */
|
||||
while (isspace(*line)) line++;
|
||||
}
|
||||
|
||||
/* handle command */
|
||||
h->command = format_command(line, false);
|
||||
return h;
|
||||
}
|
||||
|
||||
|
||||
char* format_command(const char *cmd, bool wrap_p)
|
||||
{
|
||||
int tab = 30;
|
||||
int col = tab;
|
||||
char *cmd2 = (char *) calloc (1, 2 * (strlen (cmd) + 1));
|
||||
const char *in = cmd;
|
||||
char *out = cmd2;
|
||||
while (*in)
|
||||
{
|
||||
/* shrink all whitespace to one space, for the benefit of the "demo"
|
||||
mode display. We only do this when we can easily tell that the
|
||||
whitespace is not significant (no shell metachars).
|
||||
*/
|
||||
switch (*in)
|
||||
{
|
||||
case '\'': case '"': case '`': case '\\':
|
||||
/* Metachars are scary. Copy the rest of the line unchanged. */
|
||||
while (*in)
|
||||
*out++ = *in++, col++;
|
||||
break;
|
||||
|
||||
case ' ': case '\t':
|
||||
/* Squeeze all other whitespace down to one space. */
|
||||
while (*in == ' ' || *in == '\t')
|
||||
in++;
|
||||
*out++ = ' ', col++;
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Copy other chars unchanged. */
|
||||
*out++ = *in++, col++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
*out = 0;
|
||||
|
||||
/* Strip trailing whitespace */
|
||||
while (out > cmd2 && isspace (out[-1]))
|
||||
*(--out) = 0;
|
||||
|
||||
return cmd2;
|
||||
}
|
||||
|
||||
|
||||
static struct saver_preferences p;
|
||||
|
||||
void getScreenhacks()
|
||||
{
|
||||
int i, j;
|
||||
int start = 0;
|
||||
int end = 0;
|
||||
int size;
|
||||
char *d = hacks;
|
||||
|
||||
p.screenhacks = 0;
|
||||
p.screenhacks_count = 0;
|
||||
|
||||
if (!d || !*d)
|
||||
return;
|
||||
|
||||
size = strlen (d);
|
||||
|
||||
/* Count up the number of newlines (which will be equal to or larger than
|
||||
one less than the number of hacks.)
|
||||
*/
|
||||
|
||||
for (i = j = 0; d[i]; i++)
|
||||
{
|
||||
if (d[i] == '\n') j++;
|
||||
}
|
||||
|
||||
j++;
|
||||
|
||||
p.screenhacks = (screenhack **) calloc (j + 1, sizeof (screenhack *));
|
||||
|
||||
/* Iterate over the lines in `d' (the string with newlines)
|
||||
and make new strings to stuff into the `screenhacks' array.
|
||||
*/
|
||||
p.screenhacks_count = 0;
|
||||
while (start < size)
|
||||
{
|
||||
// skip forward over whitespace.
|
||||
while (d[start] == ' ' || d[start] == '\t' || d[start] == '\n')
|
||||
start++;
|
||||
|
||||
// skip forward to newline or end of string.
|
||||
end = start;
|
||||
while (d[end] != 0 && d[end] != '\n')
|
||||
end++;
|
||||
|
||||
// null terminate
|
||||
d[end] = '\0';
|
||||
|
||||
p.screenhacks[p.screenhacks_count++] = parse_screenhack (d + start);
|
||||
if (p.screenhacks_count >= i)
|
||||
abort();
|
||||
|
||||
start = end+1;
|
||||
}
|
||||
|
||||
if (p.screenhacks_count == 0)
|
||||
{
|
||||
free(p.screenhacks);
|
||||
p.screenhacks = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void free_screenhack(screenhack *hack)
|
||||
{
|
||||
if (hack->visual) free (hack->visual);
|
||||
if (hack->name) free (hack->name);
|
||||
free(hack->command);
|
||||
memset(hack, 0, sizeof(*hack));
|
||||
free (hack);
|
||||
}
|
||||
|
||||
static void free_screenhack_list(screenhack **list, int count)
|
||||
{
|
||||
int i;
|
||||
if (!list) return;
|
||||
for (i = 0; i < count; i++)
|
||||
if (list[i]) free_screenhack (list[i]);
|
||||
free (list);
|
||||
}
|
||||
|
||||
Config config("EDE Team", "escrsaver");
|
||||
|
||||
void readConfiguration()
|
||||
{
|
||||
int cdefserver = 0;
|
||||
config.get("Saver", "Active", cdefserver);
|
||||
|
||||
if (!config.error())
|
||||
{
|
||||
default_saver = cdefserver;
|
||||
saversList->text(saversList->child(default_saver)->label());
|
||||
}
|
||||
|
||||
int ctimeout = 0;
|
||||
config.get("Saver", "Timeout", ctimeout, 1);
|
||||
if (!config.error()) timeoutSlider->value(ctimeout);
|
||||
|
||||
int cdpmsOn = 0;
|
||||
config.get("DPMS", "On", cdpmsOn);
|
||||
if (!config.error()) {enableDPMSCheck->value(cdpmsOn); enableDPMSCheck->do_callback();}
|
||||
|
||||
int cdpmsStandby = 0; config.get("DPMS", "Standby", cdpmsStandby);
|
||||
if (!config.error()) standbySlider->value(cdpmsStandby);
|
||||
|
||||
int cdpmsSuspend = 0;
|
||||
config.get("DPMS", "Suspend", cdpmsSuspend);
|
||||
if (!config.error()) suspendSlider->value(cdpmsSuspend);
|
||||
|
||||
int cdpmsOff = 0;
|
||||
config.get("DPMS", "Off", cdpmsOff);
|
||||
if (!config.error()) offSlider->value(cdpmsOff);
|
||||
}
|
||||
|
||||
|
||||
void writeConfiguration()
|
||||
{
|
||||
// FLE_Config config(fle_find_config_file("apps/escrsaver.conf", 1));
|
||||
config.create_section("Saver");
|
||||
config.set_section("Saver");
|
||||
|
||||
config.write("Active", saversList->item() ? (int)saversList->item()->user_data() : default_saver);
|
||||
|
||||
config.write("Timeout", timeoutSlider->value());
|
||||
config.create_section("DPMS");
|
||||
config.set_section("DPMS");
|
||||
config.write("On", enableDPMSCheck->value());
|
||||
config.write("Standby", standbySlider->value());
|
||||
config.write("Suspend", suspendSlider->value());
|
||||
config.write("Off", offSlider->value());
|
||||
|
||||
writeConfigurationSaver();
|
||||
}
|
||||
|
||||
|
||||
void writeConfigurationSaver()
|
||||
{
|
||||
char *home = getenv("HOME");
|
||||
char *path = (char*)malloc(200);
|
||||
snprintf(path,200,"%s/.xscreensaver", home);
|
||||
delete [] home;
|
||||
|
||||
FILE *config = fopen(path, "w+");
|
||||
|
||||
delete [] path;
|
||||
|
||||
fprintf(config, "timeout: 0:%d:00\n", (int) timeoutSlider->value());
|
||||
fprintf(config, "dpmsEnabled: %s\n", enableDPMSCheck->value() ? "True" : "False");
|
||||
|
||||
fprintf(config, "dpmsStandby: 0:%d:00\n", (int) standbySlider->value());
|
||||
fprintf(config, "dpmsSuspend: 0:%d:00\n", (int) suspendSlider->value());
|
||||
fprintf(config, "dpmsOff: 0:%d:00\n", (int) offSlider->value());
|
||||
|
||||
fprintf(config, "mode: one\n");
|
||||
|
||||
|
||||
fprintf(config, "selected: %d\n", 0);
|
||||
|
||||
fprintf(config, "programs: \"%s\" %s\n", saversList->item() ?
|
||||
(char*)p.screenhacks[(int)saversList->item()->user_data()]->name :
|
||||
(char*)p.screenhacks[default_saver]->name,
|
||||
saversList->item() ?
|
||||
(char*)p.screenhacks[(int)saversList->item()->user_data()]->command :
|
||||
(char*)p.screenhacks[default_saver]->command
|
||||
);
|
||||
|
||||
fclose(config);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void clearOnExit()
|
||||
{
|
||||
free_screenhack_list(p.screenhacks, p.screenhacks_count);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
static void killPreviewSubproc()
|
||||
{
|
||||
if (running_preview_pid)
|
||||
{
|
||||
kill(running_preview_pid, SIGTERM);
|
||||
running_preview_pid = 0;
|
||||
}
|
||||
running_saver = 0;
|
||||
}
|
||||
|
||||
|
||||
void launchPreviewSubprocess(char *new_cmd)
|
||||
{
|
||||
extern char **environ;
|
||||
pid_t forked;
|
||||
|
||||
if (running_preview_pid)
|
||||
{
|
||||
killPreviewSubproc();
|
||||
}
|
||||
|
||||
switch ((int) (forked = fork ()))
|
||||
{
|
||||
case -1:
|
||||
{
|
||||
alert(_("Couldn't fork screensaver subprocess."));
|
||||
return;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
usleep(250000);
|
||||
char *argv[4];
|
||||
argv[0] = "sh";
|
||||
argv[1] = "-c";
|
||||
argv[2] = new_cmd;
|
||||
argv[3] = NULL;
|
||||
if (execve("/bin/sh", argv, environ) == -1)
|
||||
alert(_("Couldn't fork shell subprocess."));
|
||||
exit(1);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
running_preview_pid = forked;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// fill combo box with scrsavers names
|
||||
// TODO: read screensavers actually installed on the system
|
||||
void fillSaversList(InputBrowser *browser)
|
||||
{
|
||||
for (int i = 0; i < p.screenhacks_count; i++)
|
||||
{
|
||||
browser->begin();
|
||||
Item *item = 0;
|
||||
if (!(p.screenhacks[i]->name)) // if scrsaver do not have the name
|
||||
{
|
||||
item = new Item(make_hack_name(p.screenhacks[i]->command));
|
||||
}
|
||||
else item = new Item(p.screenhacks[i]->name);
|
||||
|
||||
item->user_data((void*) i);
|
||||
item->activate(p.screenhacks[i]->enabled_p);
|
||||
browser->end();
|
||||
}
|
||||
browser->text(browser->child(0)->label());
|
||||
}
|
||||
|
||||
// preview
|
||||
void startSaverPreview()
|
||||
{
|
||||
static XWindow id;
|
||||
static int wid = 0;
|
||||
static bool warned = false;
|
||||
|
||||
if (!wid)
|
||||
{
|
||||
id = xid(saverWindow);
|
||||
wid=1;
|
||||
}
|
||||
saverWindow->show();
|
||||
|
||||
if (id==0)
|
||||
return;
|
||||
killPreviewSubproc();
|
||||
|
||||
char *location = 0;
|
||||
if (access(PREFIX"/X11R6/lib/xscreensaver/", F_OK)==0)
|
||||
location = PREFIX"/X11R6/lib/xscreensaver/";
|
||||
else if (access(PREFIX"/lib/xscreensaver/", F_OK)==0)
|
||||
location = PREFIX"/lib/xscreensaver/";
|
||||
else if (access("/usr/X11R6/lib/xscreensaver/", F_OK)==0)
|
||||
location = "/usr/X11R6/lib/xscreensaver/";
|
||||
else if (access("/lib/xscreensaver/",F_OK)==0)
|
||||
location = "/lib/xscreensaver/";
|
||||
else {
|
||||
location = "";
|
||||
if (!warned) {
|
||||
alert(_("xscreensaver wasn't found on your system.\n\nEquinox Desktop Environment uses xscreensaver to display screen savers. Please install this package if you wish to use graphical screen savers."));
|
||||
warned=true;
|
||||
}
|
||||
}
|
||||
|
||||
// no need to continue now...
|
||||
if (strlen(location)<1) return;
|
||||
|
||||
|
||||
char cmd[4096] = {0};
|
||||
char* savercmd;
|
||||
// all sorts of stuff can be undefined (zero), so we need to check thoroughly
|
||||
if (saversList->item()) {
|
||||
int saverno = (int)saversList->item()->user_data();
|
||||
fprintf (stderr, " ++ screenhack %d\n", saverno);
|
||||
if (p.screenhacks && p.screenhacks[saverno] && p.screenhacks[saverno]->command) {
|
||||
savercmd = (char*)p.screenhacks[(int)saversList->item()->user_data()]->command;
|
||||
} else {
|
||||
// no preview
|
||||
return;
|
||||
}
|
||||
} else
|
||||
savercmd = (char*)p.screenhacks[default_saver]->command;
|
||||
snprintf(cmd, 4096, "%s%s -window-id 0x%X", location, savercmd, (int)id);
|
||||
launchPreviewSubprocess(cmd);
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Screensaver configuration
|
||||
* Part of Equinox Desktop Environment (EDE).
|
||||
* Copyright (c) 2000-2006 EDE Authors.
|
||||
*
|
||||
* This program is licenced under terms of the
|
||||
* GNU General Public Licence version 2 or newer.
|
||||
* See COPYING for details.
|
||||
*/
|
||||
|
||||
#ifndef escreensaver_h
|
||||
#define escreensaver_h
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/*#include <efltk/Fl_Window.h>
|
||||
#include <efltk/Fl_Item.h>
|
||||
#include <efltk/x.h>
|
||||
#include <efltk/Fl_Input_Browser.h>
|
||||
#include <efltk/Fl_Locale.h>*/
|
||||
|
||||
#include <fltk/Window.h>
|
||||
#include <fltk/Item.h>
|
||||
#include <fltk/InputBrowser.h>
|
||||
#include "../edelib2/NLS.h"
|
||||
|
||||
void fillSaversList(fltk::InputBrowser *);
|
||||
void startSaverPreview();
|
||||
void readConfiguration();
|
||||
void writeConfiguration();
|
||||
void writeConfigurationSaver();
|
||||
void getScreenhacks();
|
||||
void clearOnExit();
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -1,176 +0,0 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Screensaver configuration
|
||||
* Part of Equinox Desktop Environment (EDE).
|
||||
* Copyright (c) 2000-2006 EDE Authors.
|
||||
*
|
||||
* This program is licenced under terms of the
|
||||
* GNU General Public Licence version 2 or newer.
|
||||
* See COPYING for details.
|
||||
*/
|
||||
|
||||
#include "escrsaverconf.h"
|
||||
#include "escreensaver.h"
|
||||
#include "../edelib2/NLS.h"
|
||||
|
||||
#include <fltk/Symbol.h>
|
||||
#include <fltk/xpmImage.h>
|
||||
#include <fltk/run.h>
|
||||
#include "icons/energy.xpm"
|
||||
|
||||
fltk::Window* mainWindow;
|
||||
|
||||
static void cb_mainWindow(fltk::Window*, void*) {
|
||||
clearOnExit();
|
||||
}
|
||||
|
||||
fltk::InputBrowser* saversList;
|
||||
|
||||
static void cb_saversList(fltk::InputBrowser*, void*) {
|
||||
startSaverPreview();
|
||||
}
|
||||
|
||||
fltk::ValueInput* timeoutSlider;
|
||||
|
||||
static void cb_OK(fltk::Button*, void*) {
|
||||
writeConfiguration(); clearOnExit();
|
||||
}
|
||||
|
||||
static void cb_Cancel(fltk::Button*, void*) {
|
||||
clearOnExit();
|
||||
}
|
||||
|
||||
fltk::Group* dpmsGroup;
|
||||
fltk::ValueInput* standbySlider;
|
||||
fltk::ValueInput* suspendSlider;
|
||||
fltk::ValueInput* offSlider;
|
||||
fltk::CheckButton* enableDPMSCheck;
|
||||
|
||||
static void cb_enableDPMSCheck(fltk::CheckButton*, void*) {
|
||||
if (enableDPMSCheck->value()) dpmsGroup->activate(); else dpmsGroup->deactivate();
|
||||
enableDPMSCheck->redraw();
|
||||
}
|
||||
|
||||
|
||||
static void cb_Apply(fltk::Button*, void*) {
|
||||
writeConfiguration();
|
||||
}
|
||||
|
||||
fltk::Window* saverWindow;
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
fltk::Window* w;
|
||||
//fl_init_locale_support("escrsaverconf", PREFIX"/share/locale");
|
||||
{fltk::Window* o = mainWindow = new fltk::Window(300, 420, _("Screensaver settings"));
|
||||
w = o;
|
||||
o->set_vertical();
|
||||
o->callback((fltk::Callback*)cb_mainWindow);
|
||||
o->begin();
|
||||
{fltk::Group* o = new fltk::Group(10, 185, 280, 45, "Screensaver");
|
||||
o->box(fltk::ENGRAVED_BOX);
|
||||
o->align(fltk::ALIGN_TOP|fltk::ALIGN_LEFT);
|
||||
o->begin();
|
||||
{fltk::InputBrowser* o = saversList = new fltk::InputBrowser(10, 10, 155, 25);
|
||||
o->callback((fltk::Callback*)cb_saversList);
|
||||
o->align(fltk::ALIGN_TOP|fltk::ALIGN_LEFT);
|
||||
//o->type(1);
|
||||
getScreenhacks();
|
||||
fillSaversList(o);
|
||||
}
|
||||
{fltk::Group* o = new fltk::Group(165, 5, 105, 35);
|
||||
o->begin();
|
||||
{fltk::ValueInput* o = timeoutSlider = new fltk::ValueInput(65, 5, 40, 25, "Timeout:");
|
||||
o->maximum(60);
|
||||
o->step(1);
|
||||
o->value(1);
|
||||
o->align(fltk::ALIGN_LEFT|fltk::ALIGN_CLIP|fltk::ALIGN_WRAP);
|
||||
}
|
||||
o->end();
|
||||
}
|
||||
o->end();
|
||||
}
|
||||
{fltk::Group* o = new fltk::Group(10, 255, 280, 115, "DPMS");
|
||||
o->box(fltk::ENGRAVED_BOX);
|
||||
o->align(fltk::ALIGN_TOP|fltk::ALIGN_LEFT);
|
||||
o->begin();
|
||||
{fltk::Group* o = dpmsGroup = new fltk::Group(70, 0, 205, 108);
|
||||
o->deactivate();
|
||||
o->begin();
|
||||
{fltk::ValueInput* o = standbySlider = new fltk::ValueInput(160, 10, 40, 25, "Standby:");
|
||||
o->maximum(60);
|
||||
o->step(1);
|
||||
o->value(10);
|
||||
o->align(fltk::ALIGN_LEFT|fltk::ALIGN_WRAP);
|
||||
}
|
||||
{fltk::ValueInput* o = suspendSlider = new fltk::ValueInput(160, 45, 40, 25, "Suspend:");
|
||||
o->maximum(60);
|
||||
o->step(1);
|
||||
o->value(15);
|
||||
o->align(fltk::ALIGN_LEFT|fltk::ALIGN_WRAP);
|
||||
}
|
||||
{fltk::ValueInput* o = offSlider = new fltk::ValueInput(160, 80, 40, 25, "Off:");
|
||||
o->maximum(60);
|
||||
o->step(1);
|
||||
o->value(20);
|
||||
o->align(fltk::ALIGN_LEFT|fltk::ALIGN_WRAP);
|
||||
}
|
||||
o->end();
|
||||
}
|
||||
{fltk::CheckButton* o = enableDPMSCheck = new fltk::CheckButton(10, 45, 145, 25, "Enabled");
|
||||
o->callback((fltk::Callback*)cb_enableDPMSCheck);
|
||||
o->align(fltk::ALIGN_LEFT|fltk::ALIGN_INSIDE|fltk::ALIGN_WRAP);
|
||||
}
|
||||
{fltk::InvisibleBox* o = new fltk::InvisibleBox(10, 10, 55, 35);
|
||||
fltk::xpmImage *img = new fltk::xpmImage((const char**)energy_xpm);
|
||||
o->image(img);
|
||||
}
|
||||
o->end();
|
||||
}
|
||||
// {fltk::Button* o = new fltk::Button(0, 380, 90, 25, "&OK");
|
||||
// o->callback((fltk::Callback*)cb_OK);
|
||||
// }
|
||||
{fltk::Button* o = new fltk::Button(100, 380, 90, 25, "&Apply");
|
||||
o->callback((fltk::Callback*)cb_Apply);
|
||||
}
|
||||
{fltk::Button* o = new fltk::Button(200, 380, 90, 25, "&Close");
|
||||
o->callback((fltk::Callback*)cb_Cancel);
|
||||
}
|
||||
{fltk::Group* o = new fltk::Group(45, 5, 200, 165);
|
||||
o->begin();
|
||||
{fltk::InvisibleBox* o = new fltk::InvisibleBox(10, 6, 180, 131);
|
||||
o->box(fltk::UP_BOX);
|
||||
}
|
||||
{fltk::InvisibleBox* o = new fltk::InvisibleBox(20, 15, 160, 110);
|
||||
o->box(fltk::DOWN_BOX);
|
||||
}
|
||||
{fltk::InvisibleBox* o = new fltk::InvisibleBox(70, 137, 59, 3);
|
||||
o->box(fltk::THIN_UP_BOX);
|
||||
}
|
||||
{fltk::InvisibleBox* o = new fltk::InvisibleBox(52, 140, 95, 12);
|
||||
o->box(fltk::UP_BOX);
|
||||
}
|
||||
{fltk::InvisibleBox* o = new fltk::InvisibleBox(164, 127, 15, 6);
|
||||
o->box(fltk::THIN_UP_BOX);
|
||||
}
|
||||
{fltk::InvisibleBox* o = new fltk::InvisibleBox(157, 128, 2, 4);
|
||||
o->set_vertical();
|
||||
o->box(fltk::FLAT_BOX);
|
||||
o->color(fltk::GREEN);
|
||||
}
|
||||
{fltk::Window* o = saverWindow = new fltk::Window(22, 17, 156, 106);
|
||||
o->box(fltk::FLAT_BOX);
|
||||
o->color(fltk::BLACK);
|
||||
o->end();
|
||||
}
|
||||
o->end();
|
||||
}
|
||||
o->end();
|
||||
}
|
||||
readConfiguration();
|
||||
cb_enableDPMSCheck(enableDPMSCheck, 0); //deactivate controls if it's off
|
||||
mainWindow->end();
|
||||
mainWindow->show();
|
||||
startSaverPreview(); //preview active saver
|
||||
return fltk::run();
|
||||
}
|
@ -1,117 +0,0 @@
|
||||
# data file for the FLTK User Interface Designer (FLUID)
|
||||
version 2.0100
|
||||
images_dir ./
|
||||
header_name {.h}
|
||||
code_name {.cpp}
|
||||
gridx 5
|
||||
gridy 5
|
||||
snap 3
|
||||
decl {\#include "escreensaver.h"} {}
|
||||
|
||||
Function {main(int argc, char **argv)} {open return_type int
|
||||
} {
|
||||
code {//fl_init_locale_support("escrsaverconf", PREFIX"/share/locale");} {}
|
||||
{fltk::Window} mainWindow {
|
||||
label {Screensaver settings}
|
||||
callback {clearOnExit();} open
|
||||
xywh {401 74 300 420} visible
|
||||
} {
|
||||
{fltk::Group} {} {
|
||||
label Screensaver open
|
||||
xywh {10 185 280 45} align 5 box ENGRAVED_BOX
|
||||
} {
|
||||
{fltk::Choice} saversList {
|
||||
callback {startSaverPreview();}
|
||||
xywh {10 10 155 25} align 5
|
||||
extra_code {o->type(1); getScreenhacks();
|
||||
fillSaversList(o);}
|
||||
class {fltk::InputBrowser}
|
||||
} {}
|
||||
{fltk::Group} {} {open
|
||||
xywh {165 5 105 35}
|
||||
} {
|
||||
{fltk::ValueInput} timeoutSlider {
|
||||
label {Timeout:}
|
||||
xywh {65 5 40 25} align 196 maximum 60 step 1 value 1
|
||||
}
|
||||
}
|
||||
}
|
||||
{fltk::Button} {} {
|
||||
label {&OK}
|
||||
callback {writeConfiguration(); clearOnExit();}
|
||||
xywh {0 380 90 25}
|
||||
}
|
||||
{fltk::Button} {} {
|
||||
label {&Cancel}
|
||||
callback {clearOnExit();}
|
||||
xywh {200 380 90 25}
|
||||
}
|
||||
{fltk::Group} {} {
|
||||
label DPMS open
|
||||
xywh {10 255 280 115} align 5 box ENGRAVED_BOX
|
||||
} {
|
||||
{fltk::Group} dpmsGroup {open
|
||||
xywh {70 0 205 108} deactivate
|
||||
} {
|
||||
{fltk::ValueInput} standbySlider {
|
||||
label {Standby:}
|
||||
xywh {160 10 40 25} align 132 maximum 60 step 1 value 10
|
||||
}
|
||||
{fltk::ValueInput} suspendSlider {
|
||||
label {Suspend:}
|
||||
xywh {160 45 40 25} align 132 maximum 60 step 1 value 15
|
||||
}
|
||||
{fltk::ValueInput} offSlider {
|
||||
label {Off:}
|
||||
xywh {160 80 40 25} align 132 maximum 60 step 1 value 20
|
||||
}
|
||||
}
|
||||
{fltk::CheckButton} enableDPMSCheck {
|
||||
label Enabled
|
||||
callback {if (enableDPMSCheck->value()) dpmsGroup->activate(); else dpmsGroup->deactivate();}
|
||||
xywh {10 45 145 25} align 148
|
||||
}
|
||||
{fltk::InvisibleBox} {} {
|
||||
xywh {10 10 55 35} image {icons/energy.xpm}
|
||||
}
|
||||
}
|
||||
{fltk::Button} {} {
|
||||
label {&Apply}
|
||||
callback {writeConfiguration();}
|
||||
xywh {100 380 90 25}
|
||||
}
|
||||
{fltk::Group} {} {open
|
||||
xywh {45 5 200 165}
|
||||
} {
|
||||
{fltk::InvisibleBox} {} {
|
||||
xywh {10 6 180 131} box UP_BOX
|
||||
}
|
||||
{fltk::InvisibleBox} {} {
|
||||
xywh {20 15 160 110} box DOWN_BOX
|
||||
}
|
||||
{fltk::InvisibleBox} {} {
|
||||
xywh {70 137 59 3} box THIN_UP_BOX
|
||||
}
|
||||
{fltk::InvisibleBox} {} {
|
||||
xywh {52 140 95 12} box UP_BOX
|
||||
}
|
||||
{fltk::InvisibleBox} {} {
|
||||
xywh {164 127 15 6} box THIN_UP_BOX
|
||||
}
|
||||
{fltk::InvisibleBox} {} {
|
||||
xywh {157 128 2 4} box FLAT_BOX color 2
|
||||
}
|
||||
{fltk::InvisibleBox} saverWindow {
|
||||
xywh {22 17 156 106} box FLAT_BOX color 32
|
||||
extra_code {o->end();}
|
||||
class Fl_Window
|
||||
}
|
||||
}
|
||||
}
|
||||
code {readConfiguration();
|
||||
mainWindow->end();
|
||||
mainWindow->show();
|
||||
startSaverPreview(); //preview active saver
|
||||
//return fltk::run();} {selected
|
||||
}
|
||||
}
|
@ -1,128 +0,0 @@
|
||||
# data file for the FLTK User Interface Designer (FLUID)
|
||||
version 2.0030
|
||||
images_dir ./
|
||||
header_name {.h}
|
||||
code_name {.cpp}
|
||||
gridx 5
|
||||
gridy 5
|
||||
snap 3
|
||||
decl {\#include "escreensaver.h"} {}
|
||||
|
||||
Function {main(int argc, char **argv)} {open return_type int
|
||||
} {
|
||||
code {fl_init_locale_support("escrsaverconf", PREFIX"/share/locale");} {}
|
||||
Fl_Window mainWindow {
|
||||
label {Screensaver settings}
|
||||
callback {clearOnExit();} open
|
||||
xywh {329 68 285 374} hide
|
||||
extra_code {o->label(_(o->label()));}
|
||||
} {
|
||||
Fl_Group {} {
|
||||
label Screensaver open
|
||||
xywh {5 185 275 55} align 5 box ENGRAVED_BOX
|
||||
extra_code {o->label(_(o->label()));}
|
||||
} {
|
||||
Fl_Choice saversList {
|
||||
callback {startSaverPreview();} open
|
||||
xywh {7 15 158 23} align 5
|
||||
extra_code {\#include <efltk/Fl_Input_Browser.h>
|
||||
o->type(1); getScreenhacks();
|
||||
fillSaversList(o);}
|
||||
class Fl_Input_Browser
|
||||
} {}
|
||||
Fl_Group {} {open
|
||||
xywh {175 5 95 45}
|
||||
} {
|
||||
Fl_Value_Input timeoutSlider {
|
||||
label {Timeout:}
|
||||
xywh {55 9 40 25} align 196 maximum 60 step 1 value 1
|
||||
extra_code {o->label(_(o->label()));}
|
||||
}
|
||||
}
|
||||
}
|
||||
Fl_Button {} {
|
||||
label {&OK}
|
||||
callback {writeConfiguration(); clearOnExit();}
|
||||
xywh {30 345 80 25}
|
||||
extra_code {o->label(_(o->label()));}
|
||||
}
|
||||
Fl_Button {} {
|
||||
label {&Cancel}
|
||||
callback {clearOnExit();} selected
|
||||
xywh {200 345 80 25}
|
||||
extra_code {o->label(_(o->label()));}
|
||||
}
|
||||
Fl_Group {} {
|
||||
label DPMS open
|
||||
xywh {5 260 275 80} align 5 box ENGRAVED_BOX
|
||||
extra_code {o->label(_(o->label()));}
|
||||
} {
|
||||
Fl_Group dpmsGroup {open
|
||||
xywh {130 2 140 74} deactivate
|
||||
} {
|
||||
Fl_Value_Input standbySlider {
|
||||
label {Standby:}
|
||||
xywh {100 2 40 20} align 132 maximum 60 step 1 value 10
|
||||
extra_code {o->label(_(o->label()));}
|
||||
}
|
||||
Fl_Value_Input suspendSlider {
|
||||
label {Suspend:}
|
||||
xywh {100 27 40 20} align 132 maximum 60 step 1 value 15
|
||||
extra_code {o->label(_(o->label()));}
|
||||
}
|
||||
Fl_Value_Input offSlider {
|
||||
label {Off:}
|
||||
xywh {100 52 40 20} align 132 maximum 60 step 1 value 20
|
||||
extra_code {o->label(_(o->label()));}
|
||||
}
|
||||
}
|
||||
Fl_Check_Button enableDPMSCheck {
|
||||
label Enabled
|
||||
callback {if (enableDPMSCheck->value()) dpmsGroup->activate(); else dpmsGroup->deactivate();}
|
||||
xywh {60 25 105 25} align 148
|
||||
extra_code {o->label(_(o->label()));}
|
||||
}
|
||||
Fl_Box {} {
|
||||
xywh {5 15 55 35} image {icons/energy.xpm}
|
||||
}
|
||||
}
|
||||
Fl_Button {} {
|
||||
label {&Apply}
|
||||
callback {writeConfiguration();}
|
||||
xywh {115 345 80 25}
|
||||
extra_code {o->label(_(o->label()));}
|
||||
}
|
||||
Fl_Group {} {open
|
||||
xywh {40 5 205 165}
|
||||
} {
|
||||
Fl_Box {} {
|
||||
xywh {10 6 180 131} box UP_BOX
|
||||
}
|
||||
Fl_Box {} {
|
||||
xywh {20 15 160 110} box DOWN_BOX
|
||||
}
|
||||
Fl_Box {} {
|
||||
xywh {70 137 59 3} box THIN_UP_BOX
|
||||
}
|
||||
Fl_Box {} {
|
||||
xywh {52 140 95 12} box UP_BOX
|
||||
}
|
||||
Fl_Box {} {
|
||||
xywh {164 127 15 6} box THIN_UP_BOX
|
||||
}
|
||||
Fl_Box {} {
|
||||
xywh {157 128 2 4} box FLAT_BOX color 2
|
||||
}
|
||||
Fl_Box saverWindow {
|
||||
xywh {22 17 156 106} box FLAT_BOX color 32
|
||||
extra_code {o->end();}
|
||||
class Fl_Window
|
||||
}
|
||||
}
|
||||
}
|
||||
code {readConfiguration();
|
||||
mainWindow->end();
|
||||
mainWindow->show();
|
||||
startSaverPreview(); //preview active saver
|
||||
return Fl::run();} {}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Screensaver configuration
|
||||
* Part of Equinox Desktop Environment (EDE).
|
||||
* Copyright (c) 2000-2006 EDE Authors.
|
||||
*
|
||||
* This program is licenced under terms of the
|
||||
* GNU General Public Licence version 2 or newer.
|
||||
* See COPYING for details.
|
||||
*/
|
||||
|
||||
#ifndef escrsaverconf_h
|
||||
#define escrsaverconf_h
|
||||
#include <fltk/Menu.h>
|
||||
#include <fltk/Window.h>
|
||||
extern fltk::Window* mainWindow;
|
||||
#include <fltk/Group.h>
|
||||
#include <fltk/InputBrowser.h>
|
||||
extern fltk::InputBrowser* saversList;
|
||||
#include <fltk/ValueInput.h>
|
||||
extern fltk::ValueInput* timeoutSlider;
|
||||
#include <fltk/Button.h>
|
||||
extern fltk::Group* dpmsGroup;
|
||||
extern fltk::ValueInput* standbySlider;
|
||||
extern fltk::ValueInput* suspendSlider;
|
||||
extern fltk::ValueInput* offSlider;
|
||||
#include <fltk/CheckButton.h>
|
||||
extern fltk::CheckButton* enableDPMSCheck;
|
||||
#include <fltk/InvisibleBox.h>
|
||||
extern fltk::Window* saverWindow;
|
||||
int main(int argc, char **argv);
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user