2022-07-06 17:51:51 +00:00
|
|
|
|
/*
|
|
|
|
|
* settings.c
|
|
|
|
|
*
|
|
|
|
|
* Created on: 6 июл. 2022 г.
|
|
|
|
|
* Author: alexander
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <iup.h>
|
2022-07-07 16:35:48 +00:00
|
|
|
|
|
2022-07-06 17:51:51 +00:00
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
|
|
#include "settings.h"
|
|
|
|
|
#include "arguments.h"
|
2022-07-07 16:35:48 +00:00
|
|
|
|
#include "node_settings.h"
|
2022-07-06 17:51:51 +00:00
|
|
|
|
|
2022-07-07 16:35:48 +00:00
|
|
|
|
static int settingsClose(Ihandle *self)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-07 16:35:48 +00:00
|
|
|
|
settingsResetChange();
|
|
|
|
|
IupSetAttribute(IupGetDialog(self), "SIMULATEMODAL", "OFF");
|
|
|
|
|
IupHide(IupGetDialog(self));
|
2022-07-06 17:51:51 +00:00
|
|
|
|
return IUP_DEFAULT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int settingsSave(Ihandle *self)
|
|
|
|
|
{
|
2022-07-07 16:35:48 +00:00
|
|
|
|
settingsSaveSettings();
|
|
|
|
|
IupSetAttribute(IupGetDialog(self), "SIMULATEMODAL", "OFF");
|
|
|
|
|
IupHide(IupGetDialog(self));
|
2022-07-06 17:51:51 +00:00
|
|
|
|
return IUP_DEFAULT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int settingsTglMultimonitor(Ihandle *self)
|
|
|
|
|
{
|
2022-07-07 16:35:48 +00:00
|
|
|
|
settingsToggleChange(PARAMETER_MULTIMONITOR);
|
2022-07-06 17:51:51 +00:00
|
|
|
|
return IUP_DEFAULT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int settingsTglFullscreen(Ihandle *self)
|
|
|
|
|
{
|
2022-07-07 16:35:48 +00:00
|
|
|
|
settingsToggleChange(PARAMETER_FULLSCREEN);
|
2022-07-06 17:51:51 +00:00
|
|
|
|
return IUP_DEFAULT;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-07 16:35:48 +00:00
|
|
|
|
static int settingsTglAuthentication(Ihandle *self)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-07 16:35:48 +00:00
|
|
|
|
settingsToggleChange(PARAMETER_AUTHENTICATION);
|
|
|
|
|
return IUP_DEFAULT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Блок настроек
|
|
|
|
|
*/
|
|
|
|
|
static Ihandle* getFrmCheckbox()
|
|
|
|
|
{
|
|
|
|
|
Ihandle *tglMultimonitor, *tglFullscreen, *tglAuthentication;
|
2022-07-06 17:51:51 +00:00
|
|
|
|
|
|
|
|
|
tglMultimonitor = IupToggle("Мультиэкран", NULL);
|
|
|
|
|
tglFullscreen = IupToggle("На весь экран", NULL);
|
2022-07-07 16:35:48 +00:00
|
|
|
|
tglAuthentication = IupToggle("Аутентификация", NULL);
|
|
|
|
|
|
|
|
|
|
IupSetInt(tglMultimonitor, "VALUE", settingsGetEnable(PARAMETER_MULTIMONITOR));
|
|
|
|
|
IupSetInt(tglFullscreen, "VALUE", settingsGetEnable(PARAMETER_FULLSCREEN));
|
|
|
|
|
IupSetInt(tglAuthentication, "VALUE", settingsGetEnable(PARAMETER_AUTHENTICATION));
|
|
|
|
|
|
|
|
|
|
return IupVbox(
|
|
|
|
|
IupSetCallbacks(IupSetAttributes(tglMultimonitor, "NAME=SETTINGS_TGL_MULTIMONITOR"), "ACTION",
|
|
|
|
|
(Icallback) settingsTglMultimonitor, NULL),
|
|
|
|
|
IupSetCallbacks(IupSetAttributes(tglFullscreen, "NAME=SETTINGS_TGL_FULLSCREEN"), "ACTION",
|
|
|
|
|
(Icallback) settingsTglFullscreen, NULL),
|
|
|
|
|
IupSetCallbacks(IupSetAttributes(tglAuthentication, "NAME=SETTINGS_TGL_AUTHENTICATION"), "ACTION",
|
|
|
|
|
(Icallback) settingsTglAuthentication, NULL),
|
|
|
|
|
NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//void tool_action_cb(Ihandle *self, int state)
|
|
|
|
|
//{
|
|
|
|
|
// if (state == 1)
|
|
|
|
|
// {
|
|
|
|
|
// int tool_index = IupGetInt(self, "TOOLINDEX");
|
|
|
|
|
// switch (tool_index)
|
|
|
|
|
// {
|
|
|
|
|
// case 0:
|
|
|
|
|
// {
|
|
|
|
|
// settingsSetValue(PARAMETER_SECURITY, "tls");
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
// case 1:
|
|
|
|
|
// {
|
|
|
|
|
// settingsSetValue(PARAMETER_SECURITY, "rdp");
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
// case 2:
|
|
|
|
|
// {
|
|
|
|
|
// settingsSetValue(PARAMETER_SECURITY, "nla");
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
// case 3:
|
|
|
|
|
// {
|
|
|
|
|
// settingsSetValue(PARAMETER_SECURITY, "ext");
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
//
|
|
|
|
|
//static Ihandle* getFrmSecurity()
|
|
|
|
|
//{
|
|
|
|
|
// Ihandle *frmSettings;
|
|
|
|
|
// Ihandle *grdSecurity;
|
|
|
|
|
//
|
|
|
|
|
// grdSecurity = IupGridBox(
|
|
|
|
|
// IupSetCallbacks(IupSetAttributes(IupToggle(NULL, NULL), "TITLE=TLS, TOOLINDEX=0, VALUE=ON"), "ACTION", (Icallback)tool_action_cb, NULL),
|
|
|
|
|
// IupSetCallbacks(IupSetAttributes(IupToggle(NULL, NULL), "TITLE=RDP, TOOLINDEX=1"), "ACTION", (Icallback)tool_action_cb, NULL),
|
|
|
|
|
// IupSetCallbacks(IupSetAttributes(IupToggle(NULL, NULL), "TITLE=NLA, TOOLINDEX=2"), "ACTION", (Icallback)tool_action_cb, NULL),
|
|
|
|
|
// IupSetCallbacks(IupSetAttributes(IupToggle(NULL, NULL), "TITLE=EXT, TOOLINDEX=3"), "ACTION", (Icallback)tool_action_cb, NULL),
|
|
|
|
|
// NULL);
|
|
|
|
|
//
|
|
|
|
|
//// tglTLS = IupToggle("TLS", NULL);
|
|
|
|
|
//// tglRDP = IupToggle("RDP", NULL);
|
|
|
|
|
//// tglNLA = IupToggle("NLA", NULL);
|
|
|
|
|
//// tglEXT = IupToggle("EXT", NULL);
|
|
|
|
|
//
|
|
|
|
|
// frmSettings = IupSetAttributes(IupFrame(IupSetAttributes(getFrmCheckbox(), "MARGIN=3x2, GAP=2, ALIGNMENT=ALEFT")), "TITLE=\"Настройки\"");
|
|
|
|
|
//
|
|
|
|
|
// return frmSettings;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
static Ihandle* getHorBoxSettings()
|
|
|
|
|
{
|
|
|
|
|
Ihandle *frmSettings;
|
|
|
|
|
|
|
|
|
|
frmSettings = IupSetAttributes(IupFrame(IupSetAttributes(getFrmCheckbox(), "MARGIN=3x2, GAP=2, ALIGNMENT=ALEFT")), "TITLE=\"Настройки\"");
|
|
|
|
|
return IupHbox(frmSettings, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Блок кнопок
|
|
|
|
|
*/
|
|
|
|
|
static Ihandle* getHorBoxButtons()
|
|
|
|
|
{
|
|
|
|
|
Ihandle *btnSave, *btnClose;
|
|
|
|
|
|
|
|
|
|
btnSave = IupButton("Сохранить", NULL);
|
|
|
|
|
IupSetAttribute(btnSave, "NAME", "SETTIGS_BTN_SAVE");
|
|
|
|
|
IupSetAttribute(btnSave, "TIP", "Сохранить настройки");
|
|
|
|
|
|
|
|
|
|
btnClose = IupButton("Закрыть", NULL);
|
|
|
|
|
IupSetAttribute(btnClose, "NAME", "SETTIGS_BTN_CLOSE");
|
|
|
|
|
|
|
|
|
|
IupSetHandle("btnClosePointer", btnClose);
|
|
|
|
|
|
|
|
|
|
return IupSetAttributes(
|
|
|
|
|
IupHbox(IupFill(), IupSetCallbacks(btnSave, "ACTION", (Icallback) settingsSave, NULL),
|
|
|
|
|
IupSetCallbacks(btnClose, "ACTION", (Icallback) settingsClose, NULL), IupFill(),
|
|
|
|
|
NULL), "ALIGNMENT=ACENTER:ACENTER, GAP=10, MARGIN=10x10");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int settingsMainWindow(Ihandle *self)
|
|
|
|
|
{
|
|
|
|
|
Ihandle *dlg;
|
|
|
|
|
Ihandle *vBoxMain;
|
|
|
|
|
|
|
|
|
|
vBoxMain = IupSetAttributes(IupVbox(getHorBoxSettings(), getHorBoxButtons(), NULL), "NMARGIN=2x2, ALIGNMENT=ACENTER");
|
2022-07-06 17:51:51 +00:00
|
|
|
|
|
|
|
|
|
dlg = IupDialog(vBoxMain);
|
|
|
|
|
IupSetAttribute(dlg, "TITLE", "Настройки");
|
2022-07-07 16:35:48 +00:00
|
|
|
|
IupSetCallback(
|
|
|
|
|
IupSetAttributes(dlg,
|
|
|
|
|
"ICON=icon, DIALOGFRAME=ON, SIMULATEMODAL=ON, DEFAULTESC=btnClosePointer, TOPMOST=YES, BRINGFRONT=YES, NAME=SETTINGS_MAIN_WINDOW"),
|
|
|
|
|
"CLOSE_CB", (Icallback) settingsClose);
|
2022-07-06 17:51:51 +00:00
|
|
|
|
|
|
|
|
|
IupShowXY(dlg, IUP_CURRENT, IUP_CURRENT);
|
|
|
|
|
|
|
|
|
|
return IUP_DEFAULT;
|
|
|
|
|
}
|