GUI-FreeRDP/settings.c

177 lines
5.5 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* settings.c
*
* Created on: 6 июл. 2022 г.
* Author: alexander
*/
#include <iup.h>
#include <stdlib.h>
#include <stdbool.h>
#include "settings.h"
#include "arguments.h"
#include "node_settings.h"
static int settingsClose(Ihandle *self)
{
settingsResetChange();
IupSetAttribute(IupGetDialog(self), "SIMULATEMODAL", "OFF");
IupHide(IupGetDialog(self));
return IUP_DEFAULT;
}
static int settingsSave(Ihandle *self)
{
settingsSaveSettings();
IupSetAttribute(IupGetDialog(self), "SIMULATEMODAL", "OFF");
IupHide(IupGetDialog(self));
return IUP_DEFAULT;
}
static int settingsTglMultimonitor(Ihandle *self)
{
settingsToggleChange(PARAMETER_MULTIMONITOR);
return IUP_DEFAULT;
}
static int settingsTglFullscreen(Ihandle *self)
{
settingsToggleChange(PARAMETER_FULLSCREEN);
return IUP_DEFAULT;
}
static int settingsTglAuthentication(Ihandle *self)
{
settingsToggleChange(PARAMETER_AUTHENTICATION);
return IUP_DEFAULT;
}
/*
* Блок настроек
*/
static Ihandle* getFrmCheckbox()
{
Ihandle *tglMultimonitor, *tglFullscreen, *tglAuthentication;
tglMultimonitor = IupToggle("Мультиэкран", NULL);
tglFullscreen = IupToggle("На весь экран", NULL);
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");
dlg = IupDialog(vBoxMain);
IupSetAttribute(dlg, "TITLE", "Настройки");
IupSetCallback(
IupSetAttributes(dlg,
"ICON=icon, DIALOGFRAME=ON, SIMULATEMODAL=ON, DEFAULTESC=btnClosePointer, TOPMOST=YES, BRINGFRONT=YES, NAME=SETTINGS_MAIN_WINDOW"),
"CLOSE_CB", (Icallback) settingsClose);
IupShowXY(dlg, IUP_CURRENT, IUP_CURRENT);
return IUP_DEFAULT;
}