home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2007 January, February, March & April
/
Chip-Cover-CD-2007-02.iso
/
boot
/
i386
/
root
/
usr
/
share
/
YaST2
/
modules
/
AutoinstX11.ycp
< prev
next >
Wrap
Text File
|
2006-11-29
|
7KB
|
200 lines
/**
* File: autoyast/modules/AutoinstX11.ycp
* Module: Auto-Installation
* Summary: X11
* Authors: Marcus Schäfer <ms@suse.de>
*
*/
{ // begin
module "AutoinstX11";
textdomain "x11";
import "Summary";
import "Directory";
import "XLib";
//=======================================
// Globals
//---------------------------------------
global map x11 = $[];
global map monitor = $[];
global map display = $[];
global string current_vendor = "";
global string current_model = "";
global boolean modified = false;
global list vendors = [];
global list models = [];
global list<map> all_monitors = [];
//=======================================
// SetModified
//---------------------------------------
global define void SetModified () {
modified = true;
}
//=======================================
// GetModified
//---------------------------------------
global define boolean GetModified () {
return modified;
}
//=======================================
// Import
//---------------------------------------
global define boolean Import (map settings) {
x11 = settings;
monitor = x11["monitor"]:$[];
display = monitor["display"]:$[];
current_vendor = monitor["monitor_vendor"]:"" ;
current_model = monitor["monitor_device"]:"" ;
return true;
}
//=======================================
// Export
//---------------------------------------
global define map Export () {
monitor["display"] = display;
monitor["monitor_device"] = current_model;
monitor["monitor_vendor"] = current_vendor;
x11["monitor"] = monitor;
return x11;
}
//=======================================
// Summary
//---------------------------------------
global define string Summary() {
string summary = "";
map m = x11["monitor"]:$[];
map d = m["display"]:$[];
string my_current_vendor = m["monitor_vendor"]:"";
string my_current_model = m["monitor_device"]:"";
string my_monitor = Summary::NotConfigured();
if (size(my_current_vendor) > 0) {
my_monitor = sformat("%1 %2", my_current_vendor, my_current_model);
}
string horizontal = sformat("%1 - %2",d["min_hsync"]:0 , d["max_hsync"]:0);
string vertical = sformat("%1 - %2", d["min_vsync"]:0 , d["max_vsync"]:0);
string nc = Summary::NotConfigured ();
string depth = sformat ("%1",
(x11["color_depth"]:-1 != -1) ? x11["color_depth"]:-1 : nc
);
summary = Summary::AddHeader (summary, _("Enable 3D Support If Possible"));
summary = Summary::AddLine (summary,
(x11["enable_3d"]:false) ? _("Yes") : nc
);
summary = Summary::AddHeader (summary, _("Color Depth"));
summary = Summary::AddLine (summary, depth );
summary = Summary::AddHeader (summary, _("Resolution"));
summary = Summary::AddLine (summary,
(x11["resolution"]:"" != "") ? x11["resolution"]:"" : nc
);
summary = Summary::AddHeader (summary, _("Display Manager"));
summary = Summary::AddLine (summary,
(x11["display_manager"]:"" != "") ? x11["display_manager"]:"" : nc
);
summary = Summary::AddHeader (summary, _("Window Manager"));
summary = Summary::AddLine (summary,
(x11["window_manager"]:"" != "") ? x11["window_manager"]:"" : nc
);
summary = Summary::AddHeader (summary, _("Monitor"));
summary = Summary::AddLine (summary, my_monitor);
summary = Summary::AddHeader (summary, _("Horizontal frequency"));
summary = Summary::AddLine (summary, horizontal);
summary = Summary::AddHeader (summary, _("Vertical frequency"));
summary = Summary::AddLine (summary, vertical);
return summary;
}
//=======================================
// readMonitorDB
//---------------------------------------
global define void readMonitorDB() {
string static_monitors = Directory::datadir + "/monitors.ycp";
all_monitors = (list<map>)SCR::Read( .target.ycp, [ static_monitors, [] ]);
vendors = toset(
maplist( map monitor, all_monitors,``( monitor["vendor"]:"" ))
);
}
//=======================================
// Read
//---------------------------------------
global define boolean Read() {
x11["display_manager"] = (string) eval (SCR::Read(
.sysconfig.displaymanager.DISPLAYMANAGER
));
x11["window_manager"] = (string) eval (SCR::Read(
.sysconfig.windowmanager.DEFAULT_WM
));
x11["enable_3d"] = false;
if (! (boolean)XLib::isInitialized()) {
y2milestone ("X11-Auto: Loading library cache...");
XLib::loadApplication();
}
current_vendor = (string) XLib::getMonitorVendor();
current_model = (string) XLib::getMonitorModel();
x11["color_depth"] = (string) XLib::getActiveColorDepth();
x11["resolution"] = (string) XLib::getActiveResolutionString();
display["min_hsync"] = tointeger(XLib::getHsyncMin());
display["max_hsync"] = tointeger(XLib::getHsyncMax());
display["min_vsync"] = tointeger(XLib::getVsyncMin());
display["max_vsync"] = tointeger(XLib::getVsyncMax());
return true;
}
//=======================================
// Write
//---------------------------------------
global define boolean Write() {
if (! (boolean)XLib::isInitialized()) {
y2milestone ("X11-Auto: Loading library cache...");
XLib::loadApplication();
}
string displayManager = x11["display_manager"]:"";
string windowManager = x11["window_manager"]:"";
if (size(displayManager) > 0) {
y2milestone("X11-Auto: setup display manager <%1>",displayManager);
SCR::Write (.sysconfig.displaymanager.DISPLAYMANAGER, displayManager);
SCR::Write (.sysconfig.displaymanager, nil);
}
if (size(windowManager) > 0) {
y2milestone("X11-Auto: setup window manager <%1>",windowManager);
SCR::Write (.sysconfig.windowmanager.DEFAULT_WM, windowManager);
SCR::Write (.sysconfig.windowmanager, nil);
}
integer hstart = display["min_hsync"]:30;
integer hstop = display["max_hsync"]:60;
integer vstart = display["min_vsync"]:60;
integer vstop = display["max_vsync"]:75;
y2milestone("X11-Auto: setup monitor <%1:%2>",current_vendor,current_model);
XLib::setMonitorCDB ( [current_vendor,current_model] );
XLib::setHsyncRange (hstart,hstop);
XLib::setVsyncRange (vstart,vstop);
string resolution = x11["resolution"]:"800x600 (SVGA)";
y2milestone("X11-Auto: setup resolution <%1>",resolution);
XLib::setResolution ( resolution );
integer colors = x11["color_depth"]:16;
y2milestone("X11-Auto: setup color depth <%1>",colors);
XLib::setDefaultColorDepth ( tostring(colors) );
boolean enable3D = x11["enable_3d"]:false;
y2milestone("X11-Auto: setup 3D <%1>",enable3D);
boolean has3D = XLib::hasOpenGLFeatures();
if ((enable3D) && (has3D)) {
XLib::activate3D();
} else {
XLib::deactivate3D();
}
boolean status = XLib::writeConfiguration();
return status;
}
} // end