ACC SHELL

Path : /proc/self/root/usr/share/YaST2/clients/
File Upload :
Current File : //proc/self/root/usr/share/YaST2/clients/mouse.ycp

/**************
FILE          : mouse.ycp
***************
PROJECT       : YaST2 - Yet another Setup Tool
              :
AUTHOR        : Marcus Schäfer <ms@suse.de>
              :
BELONGS TO    : YaST2 - GPM mouse configuration
              :
DESCRIPTION   : mouse.ycp is the first instance called in
              : front of the inst_mouse.ycp configuration module
              : we will handle the reprobe case here and the
              : return value from the configuration module which
              : is needed to restore the mouse in special cases
              :
              :
STATUS        : Development
**************/
/*! \brief YaST2 - GPM configuration interface
*
* File:	clients/mouse.ycp
* Package:	Mouse configuration
* Summary:	Main client
* Authors:	Marcus Schäfer <ms@suse.de>
*
*/
{ // begin
textdomain "mouse";

//==========================================
// Import...
//------------------------------------------
import "CommandLine";
import "Confirm";
import "Label";
import "Stage";
import "Mouse";
import "Popup";
import "Wizard";

//==========================================
// Memorize the current mouse.
//------------------------------------------
string mouse_on_entry = "";

//==========================================
// MouseRead
//------------------------------------------
define boolean MouseRead () {
	mouse_on_entry = Mouse::mouse;
	y2milestone( "Stage::reprobe %1 Mouse:%2", Stage::reprobe(), Mouse::mouse);
	return true;
}

//==========================================
// MouseWrite
//------------------------------------------
define boolean MouseWrite () {
	Mouse::Save();
	return true;
}

//==========================================
// print mouse configuration summary
//------------------------------------------
define boolean MouseSummaryHandler (map options) {
	foreach (string mouse_code, string name, Mouse::Selection (), {
	if (mouse_on_entry == mouse_code) {
		CommandLine::Print (sformat (_("Current Mouse Type: %1"), name));
	}});
	return false;
}

//==========================================
// MouseSequence
//------------------------------------------
define any MouseSequence () {

	map display_info	= (map) UI::GetDisplayInfo ();
	if (!display_info["TextMode"]:true)
	{
            // disable mouse module in non-Textmode (bnc#441404)
            y2milestone("YaST2 gpm (formerly known as 'mouse') was started in GUI mode. It is intended to configure the mouse for the console only. Mouse configuration for X is configured automatically by the X-Server.");
	    //if (Confirm::MustBeRoot ())
	    //{
	    //  // call sax
	    //  SCR::Execute (.target.bash, "/usr/sbin/sax2 -O Mouse");
	    //  return `finish;
	    //}
	    //return `cancel;
	}

	MouseRead ();
	//==========================================
	// Check if this is a reconfiguration run.
	//------------------------------------------
	if((Stage::reprobe()) || (mouse_on_entry == "none")) {
		string mouseID = Mouse::Probe();
		if (mouseID == "none") {
		    Mouse::mouse = "none";
		}
		Mouse::Set( Mouse::mouse );
	}
	any result = `cancel;
	//==========================================
	// create the wizard dialog
	//------------------------------------------
	Wizard::CreateDialog();

	//==========================================
	// check if no mouse is connected
	//------------------------------------------
	if( Stage::reprobe() && (Mouse::mouse=="none") ) {
		Popup::TimedMessage( _("No mouse connected to the system..."), 10);
		y2milestone ( "No mouse detected --> unchanged" );
		return UI::CloseDialog();
	}

	//==========================================
	// call inst_mouse and init mouse list
	//------------------------------------------
	result = WFM::CallFunction ( "inst_mouse", [ true, true ] );

	//==========================================
	// handle result value from the config
	//------------------------------------------
	if( result == `next ) {
		// ...
		// User accepted the the setting.
		// Only if the user has chosen a different mouse change the
		// system configuration.
		// ---
		y2milestone("User selected new mouse: <%1>", Mouse::mouse );
		MouseWrite ();
	} else {
		// ...
		// `cancel or `back selected
		// ---
		y2milestone( "User cancelled --> no change" );
	}
	UI::CloseDialog();
	return result;
}

//==========================================
// the command line description
//------------------------------------------
map cmdline = $[
	"id"		: "mouse",
	"help"		: _("Mouse configuration."),
	"guihandler"	: MouseSequence,
	"initialize"	: MouseRead,
	"finish"		: MouseWrite,
	"actions"		: $[
		"summary" :$[
			"handler"	: MouseSummaryHandler,
			"help"	: _("Mouse configuration summary."),
		],
	],
];

//==========================================
// Run the module
//------------------------------------------
CommandLine::Run (cmdline);
return true;
} // end

ACC SHELL 2018