Compare commits
3 Commits
5a6aef9424
...
b9f02e4211
Author | SHA1 | Date |
---|---|---|
Alexander Zhirov | b9f02e4211 | |
Alexander Zhirov | 719f159b9a | |
Alexander Zhirov | cb57c8d92a |
41
arguments.c
41
arguments.c
|
@ -10,20 +10,45 @@
|
|||
#include "node_settings.h"
|
||||
#include "concat.h"
|
||||
|
||||
#include "xrandr.h"
|
||||
|
||||
void settingsLoad()
|
||||
{
|
||||
addParameterKey(PARAMETER_XFREERDP, "xfreerdp", true, true);
|
||||
addParameterKey(PARAMETER_SERVER, "/v:", true, true);
|
||||
addParameterKey(PARAMETER_USERNAME, "/u:", true, true);
|
||||
addParameterKey(PARAMETER_PASSWORD, "/p:", true, true);
|
||||
addParameterKey(PARAMETER_MULTIMONITOR, "/multimon", true, true);
|
||||
addParameterKey(PARAMETER_FULLSCREEN, "/f", true, true);
|
||||
addParameterKey(PARAMETER_AUTHENTICATION, "-authentication", true, true);
|
||||
addParameterKey(PARAMETER_SECURITY, "/sec:", true, true);
|
||||
addParameterKey(PARAMETER_XFREERDP, "xfreerdp", true, true, NULL, NULL);
|
||||
addParameterKey(PARAMETER_SERVER, "/v:", true, true, NULL, NULL);
|
||||
addParameterKey(PARAMETER_USERNAME, "/u:", true, true, NULL, NULL);
|
||||
addParameterKey(PARAMETER_PASSWORD, "/p:", true, true, NULL, NULL);
|
||||
addParameterKey(PARAMETER_CERTIGNORE, "/cert-ignore", true, true, NULL, NULL);
|
||||
addParameterKey(PARAMETER_THEMES, "-themes", false, true, NULL, NULL);
|
||||
addParameterKey(PARAMETER_WALLPAPER, "-wallpaper", false, true, NULL, NULL);
|
||||
addParameterKey(PARAMETER_ENCRYPTION, "-encryption", false, true, NULL, NULL);
|
||||
addParameterKey(PARAMETER_FONTS, "-fonts", false, true, NULL, NULL);
|
||||
addParameterKey(PARAMETER_SOUND, "/sound", false, true, NULL, NULL);
|
||||
addParameterKey(PARAMETER_COMPRESSION, "+compression", false, true, NULL, NULL);
|
||||
addParameterKey(PARAMETER_FULLSCREEN, "/f", false, true, NULL, NULL);
|
||||
addParameterKey(PARAMETER_MULTIMONITOR, "/multimon", false, true, getParameter(PARAMETER_FULLSCREEN), NULL);
|
||||
addParameterKey(PARAMETER_AUTHENTICATION, "-authentication", true, true, NULL, NULL);
|
||||
addParameterKey(PARAMETER_SECURITY, "/sec:", true, true, NULL, NULL);
|
||||
addParameterValue(PARAMETER_SECURITY, VALUE_SECURITY_TLS, "tls", true);
|
||||
addParameterValue(PARAMETER_SECURITY, VALUE_SECURITY_RDP, "rdp", false);
|
||||
addParameterValue(PARAMETER_SECURITY, VALUE_SECURITY_NLA, "nla", false);
|
||||
addParameterValue(PARAMETER_SECURITY, VALUE_SECURITY_EXT, "ext", false);
|
||||
addParameterKey(PARAMETER_BITSPERPIXEL, "/bpp:", true, true, NULL, NULL);
|
||||
addParameterValue(PARAMETER_BITSPERPIXEL, VALUES_BITSPERPIXEL_8, "8", true);
|
||||
addParameterValue(PARAMETER_BITSPERPIXEL, VALUES_BITSPERPIXEL_16, "16", false);
|
||||
addParameterValue(PARAMETER_BITSPERPIXEL, VALUES_BITSPERPIXEL_24, "24", false);
|
||||
addParameterValue(PARAMETER_BITSPERPIXEL, VALUES_BITSPERPIXEL_32, "32", false);
|
||||
|
||||
addParameterKey(PARAMETER_USB, "/a:drive,USB,", true, true, NULL, NULL);
|
||||
addParameterValue(PARAMETER_USB, VALUES_USB_DRIVE, "/mnt/usbdevice", true);
|
||||
|
||||
addParameterKey(PARAMETER_MONITORS, "/monitors:", false, true, getParameter(PARAMETER_FULLSCREEN), getParameter(PARAMETER_MULTIMONITOR));
|
||||
x_info *monitors = getXInfo();
|
||||
for (size_t i = 0; i < monitors->count; ++i)
|
||||
{
|
||||
addParameterValue(PARAMETER_MONITORS, i, monitors->monitor[i].ptrIndexMonitor, !i);
|
||||
}
|
||||
freeXInfo(monitors);
|
||||
}
|
||||
|
||||
void settingsFree()
|
||||
|
|
|
@ -48,7 +48,7 @@ static void freeAllNodeValue(NodeValue *node)
|
|||
}
|
||||
}
|
||||
|
||||
static NodeParameter* newNodeParameter(Parameter name, char *key, bool set, bool singleValue)
|
||||
static NodeParameter* newNodeParameter(Parameter name, char *key, bool set, bool singleValue, NodeParameter *dependence, NodeParameter *conflict)
|
||||
{
|
||||
NodeParameter *node = (NodeParameter*) malloc(sizeof(NodeParameter));
|
||||
node->name = name;
|
||||
|
@ -56,7 +56,10 @@ static NodeParameter* newNodeParameter(Parameter name, char *key, bool set, bool
|
|||
node->change = false;
|
||||
node->value = NULL;
|
||||
node->countValue = 0;
|
||||
node->countValueSet = 0;
|
||||
node->singleValue = singleValue;
|
||||
node->dependence = dependence;
|
||||
node->conflict = conflict;
|
||||
node->next = NULL;
|
||||
|
||||
node->key = (char*) malloc(sizeof(char) * strlen(key));
|
||||
|
@ -116,11 +119,25 @@ static NodeParameter* getNodeParameter(Parameter name)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void addParameterKey(Parameter name, char *key, bool set, bool singleValue)
|
||||
NodeParameter* getParameter(Parameter name)
|
||||
{
|
||||
for (NodeParameter *head = settings.parameter; head; head = head->next)
|
||||
{
|
||||
if (head->name == name)
|
||||
{
|
||||
return head;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void addParameterKey(Parameter name, char *key, bool set, bool singleValue, NodeParameter *dependence, NodeParameter *conflict)
|
||||
{
|
||||
if (!settings.parameter)
|
||||
{
|
||||
settings.parameter = newNodeParameter(name, key, set, singleValue);
|
||||
settings.parameter = newNodeParameter(name, key, set, singleValue, dependence, conflict);
|
||||
++settings.countParameter;
|
||||
if (set)
|
||||
{
|
||||
|
@ -138,7 +155,7 @@ void addParameterKey(Parameter name, char *key, bool set, bool singleValue)
|
|||
else
|
||||
{
|
||||
node = getLastNodeParameter();
|
||||
node->next = newNodeParameter(name, key, set, singleValue);
|
||||
node->next = newNodeParameter(name, key, set, singleValue, dependence, conflict);
|
||||
++settings.countParameter;
|
||||
if (set)
|
||||
{
|
||||
|
@ -306,6 +323,12 @@ void changeParameter(Parameter name)
|
|||
|
||||
}
|
||||
|
||||
void setParameter(Parameter name, bool set)
|
||||
{
|
||||
NodeParameter *node = getNodeParameter(name);
|
||||
node->set = set;
|
||||
}
|
||||
|
||||
void changeValue(Parameter pName, Value vName)
|
||||
{
|
||||
NodeParameter *pNode = getNodeParameter(pName);
|
||||
|
@ -344,7 +367,10 @@ static void saveChangeSingleValueSettings(NodeParameter *node)
|
|||
{
|
||||
nChange->change = false;
|
||||
nChange->set = true;
|
||||
nSet->set = false;
|
||||
if (nSet)
|
||||
{
|
||||
nSet->set = false;
|
||||
}
|
||||
++node->countValueSet;
|
||||
}
|
||||
}
|
||||
|
@ -376,6 +402,14 @@ void saveChangeSettings()
|
|||
pHead->change = false;
|
||||
pHead->set = !pHead->set;
|
||||
}
|
||||
if (pHead->dependence && !pHead->dependence->set)
|
||||
{
|
||||
pHead->set = false;
|
||||
}
|
||||
if (pHead->conflict && pHead->conflict->set)
|
||||
{
|
||||
pHead->set = false;
|
||||
}
|
||||
if (pHead->set)
|
||||
{
|
||||
++settings.countParameterSet;
|
||||
|
@ -431,3 +465,13 @@ bool getSetValue(Parameter pName, Value vName)
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
int getCountValue(Parameter name)
|
||||
{
|
||||
NodeParameter *node = getNodeParameter(name);
|
||||
if (!node)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return node->countValue;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,8 @@ typedef struct NodeParameter
|
|||
bool singleValue;
|
||||
size_t countValue;
|
||||
size_t countValueSet;
|
||||
struct NodeParameter *dependence;
|
||||
struct NodeParameter *conflict;
|
||||
struct NodeParameter *next;
|
||||
} NodeParameter;
|
||||
|
||||
|
@ -44,18 +46,20 @@ typedef struct NodeHead
|
|||
|
||||
extern NodeHead settings;
|
||||
|
||||
void addParameterKey(Parameter name, char *key, bool set, bool singleValue);
|
||||
NodeParameter* getParameter(Parameter name);
|
||||
void addParameterKey(Parameter name, char *key, bool set, bool singleValue, NodeParameter *dependence, NodeParameter *conflict);
|
||||
void addParameterValue(Parameter pName, Value vName, char *current, bool set);
|
||||
void freeSettings();
|
||||
|
||||
NodeValue *getSetNodeValue(NodeParameter *node);
|
||||
bool getSetParameter(Parameter name);
|
||||
bool getSetValue(Parameter pName, Value vName);
|
||||
int getCountValue(Parameter name);
|
||||
void changeParameter(Parameter name);
|
||||
void changeValue(Parameter pName, Value vName);
|
||||
void saveChangeSettings();
|
||||
void resetChangeSettings();
|
||||
|
||||
void setParameter(Parameter name, bool set);
|
||||
void setParameterValue(Parameter pName, Value vName, char *current);
|
||||
|
||||
#endif /* SETTINGS_H_ */
|
||||
|
|
12
parameter.h
12
parameter.h
|
@ -14,10 +14,20 @@ typedef enum
|
|||
PARAMETER_SERVER,
|
||||
PARAMETER_USERNAME,
|
||||
PARAMETER_PASSWORD,
|
||||
PARAMETER_CERTIGNORE,
|
||||
PARAMETER_THEMES,
|
||||
PARAMETER_WALLPAPER,
|
||||
PARAMETER_ENCRYPTION,
|
||||
PARAMETER_FONTS,
|
||||
PARAMETER_SOUND,
|
||||
PARAMETER_COMPRESSION,
|
||||
PARAMETER_MONITORS,
|
||||
PARAMETER_MULTIMONITOR,
|
||||
PARAMETER_FULLSCREEN,
|
||||
PARAMETER_AUTHENTICATION,
|
||||
PARAMETER_SECURITY
|
||||
PARAMETER_SECURITY,
|
||||
PARAMETER_BITSPERPIXEL,
|
||||
PARAMETER_USB
|
||||
} Parameter;
|
||||
|
||||
#endif /* PARAMETERS_H_ */
|
||||
|
|
270
settings.c
270
settings.c
|
@ -10,6 +10,9 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "xrandr.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#include "settings.h"
|
||||
#include "arguments.h"
|
||||
#include "node_settings.h"
|
||||
|
@ -19,7 +22,6 @@ void toggleActive(Ihandle *self, char *name)
|
|||
IupSetInt(IupGetDialogChild(self, name), "ACTIVE", !IupGetInt(IupGetDialogChild(self, name), "ACTIVE"));
|
||||
}
|
||||
|
||||
|
||||
static int settingsClose(Ihandle *self)
|
||||
{
|
||||
resetChangeSettings();
|
||||
|
@ -36,24 +38,54 @@ static int settingsSave(Ihandle *self)
|
|||
return IUP_DEFAULT;
|
||||
}
|
||||
|
||||
static int settingsTglMultimonitor(Ihandle *self)
|
||||
{
|
||||
changeParameter(PARAMETER_MULTIMONITOR);
|
||||
return IUP_DEFAULT;
|
||||
}
|
||||
|
||||
static int settingsTglFullscreen(Ihandle *self)
|
||||
{
|
||||
changeParameter(PARAMETER_FULLSCREEN);
|
||||
return IUP_DEFAULT;
|
||||
}
|
||||
|
||||
static int settingsTglAuthentication(Ihandle *self)
|
||||
{
|
||||
changeParameter(PARAMETER_AUTHENTICATION);
|
||||
return IUP_DEFAULT;
|
||||
}
|
||||
|
||||
static int settingsTglCertIgnore(Ihandle *self)
|
||||
{
|
||||
changeParameter(PARAMETER_CERTIGNORE);
|
||||
return IUP_DEFAULT;
|
||||
}
|
||||
|
||||
static int settingsTglThemes(Ihandle *self)
|
||||
{
|
||||
changeParameter(PARAMETER_THEMES);
|
||||
return IUP_DEFAULT;
|
||||
}
|
||||
|
||||
static int settingsTglWallpaper(Ihandle *self)
|
||||
{
|
||||
changeParameter(PARAMETER_WALLPAPER);
|
||||
return IUP_DEFAULT;
|
||||
}
|
||||
|
||||
static int settingsTglSound(Ihandle *self)
|
||||
{
|
||||
changeParameter(PARAMETER_SOUND);
|
||||
return IUP_DEFAULT;
|
||||
}
|
||||
|
||||
static int settingsTglFonts(Ihandle *self)
|
||||
{
|
||||
changeParameter(PARAMETER_FONTS);
|
||||
return IUP_DEFAULT;
|
||||
}
|
||||
|
||||
static int settingsTglEncryption(Ihandle *self)
|
||||
{
|
||||
changeParameter(PARAMETER_ENCRYPTION);
|
||||
return IUP_DEFAULT;
|
||||
}
|
||||
|
||||
static int settingsTglCompression(Ihandle *self)
|
||||
{
|
||||
changeParameter(PARAMETER_COMPRESSION);
|
||||
return IUP_DEFAULT;
|
||||
}
|
||||
|
||||
static int settingsUseSecurity(Ihandle *self)
|
||||
{
|
||||
changeParameter(PARAMETER_SECURITY);
|
||||
|
@ -96,29 +128,122 @@ static void settingsChooseSecurity(Ihandle *self, int state)
|
|||
}
|
||||
}
|
||||
|
||||
static int settingsUseBitsPerPixel(Ihandle *self)
|
||||
{
|
||||
changeParameter(PARAMETER_BITSPERPIXEL);
|
||||
toggleActive(self, "BITSPERPIXEL_8");
|
||||
toggleActive(self, "BITSPERPIXEL_16");
|
||||
toggleActive(self, "BITSPERPIXEL_24");
|
||||
toggleActive(self, "BITSPERPIXEL_32");
|
||||
|
||||
return IUP_DEFAULT;
|
||||
}
|
||||
|
||||
static void settingsChooseBitsPerPixel(Ihandle *self, int state)
|
||||
{
|
||||
if (state == 1)
|
||||
{
|
||||
int tool_index = IupGetInt(self, "TOOLINDEX");
|
||||
switch (tool_index)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
changeValue(PARAMETER_BITSPERPIXEL, VALUES_BITSPERPIXEL_8);
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
changeValue(PARAMETER_BITSPERPIXEL, VALUES_BITSPERPIXEL_16);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
changeValue(PARAMETER_BITSPERPIXEL, VALUES_BITSPERPIXEL_24);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
changeValue(PARAMETER_BITSPERPIXEL, VALUES_BITSPERPIXEL_32);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int settingsChooseMonitor(Ihandle *ih, char *text, int item, int state)
|
||||
{
|
||||
if (state == 1)
|
||||
{
|
||||
changeValue(PARAMETER_MONITORS, item - 1);
|
||||
}
|
||||
|
||||
return IUP_DEFAULT;
|
||||
}
|
||||
|
||||
static int settingsTglMultimonitor(Ihandle *self)
|
||||
{
|
||||
changeParameter(PARAMETER_MULTIMONITOR);
|
||||
|
||||
IupSetInt(IupGetDialogChild(self, "MONITORS"), "ACTIVE", !IupGetInt(IupGetDialogChild(self, "SETTINGS_TGL_MULTIMONITOR"), "VALUE"));
|
||||
setParameter(PARAMETER_MONITORS, !IupGetInt(IupGetDialogChild(self, "SETTINGS_TGL_MULTIMONITOR"), "VALUE"));
|
||||
return IUP_DEFAULT;
|
||||
}
|
||||
|
||||
static int settingsTglFullscreen(Ihandle *self)
|
||||
{
|
||||
changeParameter(PARAMETER_FULLSCREEN);
|
||||
toggleActive(self, "SETTINGS_TGL_MULTIMONITOR");
|
||||
IupSetInt(IupGetDialogChild(self, "MONITORS"), "ACTIVE", !IupGetInt(IupGetDialogChild(self, "SETTINGS_TGL_MULTIMONITOR"), "VALUE") && IupGetInt(IupGetDialogChild(self, "SETTINGS_TGL_FULLSCREEN"), "VALUE"));
|
||||
setParameter(PARAMETER_MONITORS, !IupGetInt(IupGetDialogChild(self, "SETTINGS_TGL_MULTIMONITOR"), "VALUE"));
|
||||
return IUP_DEFAULT;
|
||||
}
|
||||
|
||||
/*
|
||||
* Блок настроек
|
||||
*/
|
||||
static Ihandle* settingsBoxCheckbox()
|
||||
{
|
||||
Ihandle *tglMultimonitor, *tglFullscreen, *tglAuthentication;
|
||||
Ihandle *tglAuthentication, *tglCertIgnore, *tglThemes, *tglWallpaper, *tglSound, *tglFonts, *tglEncryption, *tglCompression;
|
||||
|
||||
tglMultimonitor = IupToggle("Несколько мониторов", NULL);
|
||||
tglFullscreen = IupToggle("На весь экран", NULL);
|
||||
tglAuthentication = IupToggle("Аутентификация", NULL);
|
||||
tglCertIgnore = IupToggle("Игнорировать сертификат", NULL);
|
||||
tglThemes = IupToggle("Отключить темы", NULL);
|
||||
tglWallpaper = IupToggle("Отключить обои", NULL);
|
||||
|
||||
tglSound = IupToggle("Поддержка звука", NULL);
|
||||
tglFonts = IupToggle("Отключить прорисовку шрифтов", NULL);
|
||||
tglEncryption = IupToggle("Отключить шифрование", NULL);
|
||||
tglCompression = IupToggle("Сжатие данных", NULL);
|
||||
|
||||
IupSetInt(tglMultimonitor, "VALUE", getSetParameter(PARAMETER_MULTIMONITOR));
|
||||
IupSetInt(tglFullscreen, "VALUE", getSetParameter(PARAMETER_FULLSCREEN));
|
||||
IupSetInt(tglAuthentication, "VALUE", getSetParameter(PARAMETER_AUTHENTICATION));
|
||||
IupSetInt(tglCertIgnore, "VALUE", getSetParameter(PARAMETER_CERTIGNORE));
|
||||
IupSetInt(tglThemes, "VALUE", getSetParameter(PARAMETER_THEMES));
|
||||
IupSetInt(tglWallpaper, "VALUE", getSetParameter(PARAMETER_WALLPAPER));
|
||||
IupSetInt(tglSound, "VALUE", getSetParameter(PARAMETER_SOUND));
|
||||
IupSetInt(tglFonts, "VALUE", getSetParameter(PARAMETER_FONTS));
|
||||
IupSetInt(tglEncryption, "VALUE", getSetParameter(PARAMETER_ENCRYPTION));
|
||||
IupSetInt(tglCompression, "VALUE", getSetParameter(PARAMETER_COMPRESSION));
|
||||
|
||||
return IupHbox(IupSetAttributes(IupFrame(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)), "TITLE=\"Общие\""), NULL);
|
||||
return IupSetAttributes(
|
||||
IupFrame(
|
||||
IupVbox(
|
||||
IupSetCallbacks(IupSetAttributes(tglAuthentication, "NAME=SETTINGS_TGL_AUTHENTICATION"), "ACTION",
|
||||
(Icallback) settingsTglAuthentication, NULL),
|
||||
IupSetCallbacks(IupSetAttributes(tglCertIgnore, "NAME=SETTINGS_TGL_AUTHENTICATION"), "ACTION",
|
||||
(Icallback) settingsTglCertIgnore, NULL),
|
||||
IupSetCallbacks(IupSetAttributes(tglThemes, "NAME=SETTINGS_TGL_THEMES"), "ACTION", (Icallback) settingsTglThemes,
|
||||
NULL),
|
||||
IupSetCallbacks(IupSetAttributes(tglWallpaper, "NAME=SETTINGS_TGL_WALLPAPER"), "ACTION", (Icallback) settingsTglWallpaper,
|
||||
NULL), IupSetCallbacks(IupSetAttributes(tglSound, "NAME=SETTINGS_TGL_SOUND"), "ACTION", (Icallback) settingsTglSound,
|
||||
NULL), IupSetCallbacks(IupSetAttributes(tglFonts, "NAME=SETTINGS_TGL_FONTS"), "ACTION", (Icallback) settingsTglFonts,
|
||||
NULL),
|
||||
IupSetCallbacks(IupSetAttributes(tglEncryption, "NAME=SETTINGS_TGL_ENCRYPTION"), "ACTION",
|
||||
(Icallback) settingsTglEncryption,
|
||||
NULL),
|
||||
IupSetCallbacks(IupSetAttributes(tglCompression, "NAME=SETTINGS_TGL_COMPRESSION"), "ACTION",
|
||||
(Icallback) settingsTglCompression,
|
||||
NULL),
|
||||
NULL)), "TITLE=\"Общие\", MARGIN=10x10");
|
||||
}
|
||||
|
||||
static Ihandle* settingsBoxSecurity()
|
||||
|
@ -129,7 +254,7 @@ static Ihandle* settingsBoxSecurity()
|
|||
|
||||
tglSecurity = IupToggle("Использовать", NULL);
|
||||
IupSetInt(tglSecurity, "VALUE", getSetParameter(PARAMETER_SECURITY));
|
||||
IupSetCallback(tglSecurity, "ACTION", (Icallback)settingsUseSecurity);
|
||||
IupSetCallback(tglSecurity, "ACTION", (Icallback) settingsUseSecurity);
|
||||
|
||||
tglTLS = IupToggle("TLS", NULL);
|
||||
IupSetInt(tglTLS, "VALUE", getSetValue(PARAMETER_SECURITY, VALUE_SECURITY_TLS));
|
||||
|
@ -144,19 +269,96 @@ static Ihandle* settingsBoxSecurity()
|
|||
IupSetInt(tglEXT, "VALUE", getSetValue(PARAMETER_SECURITY, VALUE_SECURITY_EXT));
|
||||
IupSetInt(tglEXT, "ACTIVE", getSetParameter(PARAMETER_SECURITY));
|
||||
|
||||
grdSecurity = IupRadio(IupGridBox(
|
||||
IupSetCallbacks(IupSetAttributes(tglTLS, "NAME=SECURITY_TLS, TOOLINDEX=0"), "ACTION", (Icallback)settingsChooseSecurity, NULL),
|
||||
IupSetCallbacks(IupSetAttributes(tglRDP, "NAME=SECURITY_RDP, TOOLINDEX=1"), "ACTION", (Icallback)settingsChooseSecurity, NULL),
|
||||
IupSetCallbacks(IupSetAttributes(tglNLA, "NAME=SECURITY_NLA, TOOLINDEX=2"), "ACTION", (Icallback)settingsChooseSecurity, NULL),
|
||||
IupSetCallbacks(IupSetAttributes(tglEXT, "NAME=SECURITY_EXT, TOOLINDEX=3"), "ACTION", (Icallback)settingsChooseSecurity, NULL),
|
||||
NULL));
|
||||
grdSecurity = IupRadio(
|
||||
IupGridBox(
|
||||
IupSetCallbacks(IupSetAttributes(tglTLS, "NAME=SECURITY_TLS, TOOLINDEX=0"), "ACTION", (Icallback) settingsChooseSecurity, NULL),
|
||||
IupSetCallbacks(IupSetAttributes(tglRDP, "NAME=SECURITY_RDP, TOOLINDEX=1"), "ACTION", (Icallback) settingsChooseSecurity, NULL),
|
||||
IupSetCallbacks(IupSetAttributes(tglNLA, "NAME=SECURITY_NLA, TOOLINDEX=2"), "ACTION", (Icallback) settingsChooseSecurity, NULL),
|
||||
IupSetCallbacks(IupSetAttributes(tglEXT, "NAME=SECURITY_EXT, TOOLINDEX=3"), "ACTION", (Icallback) settingsChooseSecurity, NULL),
|
||||
NULL));
|
||||
|
||||
return IupHbox(IupSetAttributes(IupFrame(IupVbox(tglSecurity, grdSecurity, NULL)), "TITLE=\"Протокол безопасности\", MARGIN=15x10"), NULL);
|
||||
}
|
||||
|
||||
static Ihandle* settingsBoxBitsPerPixel()
|
||||
{
|
||||
Ihandle *tglBitsPerPixel;
|
||||
Ihandle *tgl8, *tgl16, *tgl24, *tgl32;
|
||||
Ihandle *grdBitsPerPixel;
|
||||
|
||||
tglBitsPerPixel = IupToggle("Использовать", NULL);
|
||||
IupSetInt(tglBitsPerPixel, "VALUE", getSetParameter(PARAMETER_BITSPERPIXEL));
|
||||
IupSetCallback(tglBitsPerPixel, "ACTION", (Icallback) settingsUseBitsPerPixel);
|
||||
|
||||
tgl8 = IupToggle("8 бит", NULL);
|
||||
IupSetInt(tgl8, "VALUE", getSetValue(PARAMETER_BITSPERPIXEL, VALUES_BITSPERPIXEL_8));
|
||||
IupSetInt(tgl8, "ACTIVE", getSetParameter(PARAMETER_BITSPERPIXEL));
|
||||
tgl16 = IupToggle("16 бит", NULL);
|
||||
IupSetInt(tgl16, "VALUE", getSetValue(PARAMETER_BITSPERPIXEL, VALUES_BITSPERPIXEL_16));
|
||||
IupSetInt(tgl16, "ACTIVE", getSetParameter(PARAMETER_BITSPERPIXEL));
|
||||
tgl24 = IupToggle("24 бит", NULL);
|
||||
IupSetInt(tgl24, "VALUE", getSetValue(PARAMETER_BITSPERPIXEL, VALUES_BITSPERPIXEL_24));
|
||||
IupSetInt(tgl24, "ACTIVE", getSetParameter(PARAMETER_BITSPERPIXEL));
|
||||
tgl32 = IupToggle("32 бит", NULL);
|
||||
IupSetInt(tgl32, "VALUE", getSetValue(PARAMETER_BITSPERPIXEL, VALUES_BITSPERPIXEL_32));
|
||||
IupSetInt(tgl32, "ACTIVE", getSetParameter(PARAMETER_BITSPERPIXEL));
|
||||
|
||||
grdBitsPerPixel = IupRadio(
|
||||
IupGridBox(IupSetCallbacks(IupSetAttributes(tgl8, "NAME=BITSPERPIXEL_8, TOOLINDEX=0"), "ACTION", (Icallback) settingsChooseBitsPerPixel,
|
||||
NULL), IupSetCallbacks(IupSetAttributes(tgl16, "NAME=BITSPERPIXEL_16, TOOLINDEX=1"), "ACTION", (Icallback) settingsChooseBitsPerPixel,
|
||||
NULL), IupSetCallbacks(IupSetAttributes(tgl24, "NAME=BITSPERPIXEL_24, TOOLINDEX=2"), "ACTION", (Icallback) settingsChooseBitsPerPixel,
|
||||
NULL), IupSetCallbacks(IupSetAttributes(tgl32, "NAME=BITSPERPIXEL_32, TOOLINDEX=3"), "ACTION", (Icallback) settingsChooseBitsPerPixel,
|
||||
NULL),
|
||||
NULL));
|
||||
|
||||
return IupHbox(IupSetAttributes(IupFrame(IupVbox(tglBitsPerPixel, grdBitsPerPixel, NULL)), "TITLE=\"Глубина цвета\", MARGIN=15x10"), NULL);
|
||||
}
|
||||
|
||||
static Ihandle* settingsBoxMonitor()
|
||||
{
|
||||
Ihandle *tglFullscreen, *tglMultimonitor, *ddMonitor;
|
||||
|
||||
tglMultimonitor = IupToggle("Все мониторы", NULL);
|
||||
tglFullscreen = IupToggle("На весь экран", NULL);
|
||||
ddMonitor = IupList(NULL);
|
||||
|
||||
x_info *monitors = getXInfo();
|
||||
char *allMonitorIndex = (char*) malloc(sizeof(char) * 3);
|
||||
sprintf(allMonitorIndex, "%hu", monitors->count + 1);
|
||||
size_t setValueIndex = 0;
|
||||
|
||||
for (short i = 0; i < monitors->count; ++i)
|
||||
{
|
||||
IupSetAttribute(ddMonitor, monitors->monitor[i].ptrIndexItem, monitors->monitor[i].ptrName);
|
||||
if (getSetValue(PARAMETER_MONITORS, i))
|
||||
setValueIndex = i + 1;
|
||||
}
|
||||
|
||||
IupSetInt(ddMonitor, "VALUE", setValueIndex ? setValueIndex : 1);
|
||||
IupSetInt(tglMultimonitor, "VALUE", getSetParameter(PARAMETER_MULTIMONITOR));
|
||||
IupSetInt(tglFullscreen, "VALUE", getSetParameter(PARAMETER_FULLSCREEN));
|
||||
|
||||
IupSetInt(tglMultimonitor, "ACTIVE", getSetParameter(PARAMETER_FULLSCREEN));
|
||||
IupSetInt(ddMonitor, "ACTIVE", getSetParameter(PARAMETER_FULLSCREEN) && !getSetParameter(PARAMETER_MULTIMONITOR));
|
||||
|
||||
free(monitors);
|
||||
|
||||
return IupSetAttributes(
|
||||
IupFrame(
|
||||
IupVbox(
|
||||
IupSetCallbacks(IupSetAttributes(tglFullscreen, "NAME=SETTINGS_TGL_FULLSCREEN, EXPAND=YES"), "ACTION",
|
||||
(Icallback) settingsTglFullscreen, NULL),
|
||||
IupSetCallbacks(IupSetAttributes(tglMultimonitor, "NAME=SETTINGS_TGL_MULTIMONITOR"), "ACTION",
|
||||
(Icallback) settingsTglMultimonitor, NULL),
|
||||
IupSetCallbacks(IupSetAttributes(ddMonitor, "NAME=MONITORS, DROPDOWN=YES, EXPAND=YES"), "ACTION",
|
||||
(Icallback) settingsChooseMonitor, NULL),
|
||||
NULL)), "TITLE=\"Монитор\", MARGIN=10x10, CGAP=5");
|
||||
}
|
||||
|
||||
static Ihandle* settingsHorizontalBox()
|
||||
{
|
||||
return IupSetAttributes(IupHbox(settingsBoxCheckbox(), settingsBoxSecurity(), NULL), "MARGIN=5x5");
|
||||
return IupSetAttributes(
|
||||
IupHbox(IupVbox(settingsBoxCheckbox(), settingsBoxMonitor(), NULL), settingsBoxSecurity(), settingsBoxBitsPerPixel(), NULL), "MARGIN=5x5");
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
13
value.h
13
value.h
|
@ -10,7 +10,18 @@
|
|||
|
||||
typedef enum
|
||||
{
|
||||
VALUE_SERVER, VALUE_USERNAME, VALUE_PASSWORD, VALUE_SECURITY_TLS, VALUE_SECURITY_RDP, VALUE_SECURITY_NLA, VALUE_SECURITY_EXT,
|
||||
VALUE_SERVER,
|
||||
VALUE_USERNAME,
|
||||
VALUE_PASSWORD,
|
||||
VALUE_SECURITY_TLS,
|
||||
VALUE_SECURITY_RDP,
|
||||
VALUE_SECURITY_NLA,
|
||||
VALUE_SECURITY_EXT,
|
||||
VALUES_BITSPERPIXEL_8,
|
||||
VALUES_BITSPERPIXEL_16,
|
||||
VALUES_BITSPERPIXEL_24,
|
||||
VALUES_BITSPERPIXEL_32,
|
||||
VALUES_USB_DRIVE
|
||||
} Value;
|
||||
|
||||
#endif /* VALUE_H_ */
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* xrandr.h
|
||||
*
|
||||
* Created on: 11 июл. 2022 г.
|
||||
* Author: alexander
|
||||
*/
|
||||
|
||||
#ifndef XRANDR_H_
|
||||
#define XRANDR_H_
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char name[10];
|
||||
char *ptrName;
|
||||
char *ptrIndexItem;
|
||||
char *ptrIndexMonitor;
|
||||
int width;
|
||||
int height;
|
||||
int primary;
|
||||
} x_monitor;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int count;
|
||||
x_monitor monitor[5];
|
||||
} x_info;
|
||||
|
||||
int XInfo(x_info *info);
|
||||
x_info *getXInfo();
|
||||
void freeXInfo(x_info *info);
|
||||
|
||||
#endif /* XRANDR_H_ */
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* xrandr_broker.c
|
||||
*
|
||||
* Created on: 11 июл. 2022 г.
|
||||
* Author: alexander
|
||||
*/
|
||||
|
||||
#include "xrandr.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
x_info *getXInfo()
|
||||
{
|
||||
x_info *monitors = (x_info *) malloc(sizeof(x_info));
|
||||
XInfo(monitors);
|
||||
|
||||
for (int i = 0; i < monitors->count; ++i)
|
||||
{
|
||||
monitors->monitor[i].ptrName = (char *)malloc(sizeof(char) * strlen(monitors->monitor[i].name));
|
||||
monitors->monitor[i].ptrIndexItem = (char *)malloc(sizeof(char) * 3);
|
||||
monitors->monitor[i].ptrIndexMonitor = (char *)malloc(sizeof(char) * 3);
|
||||
|
||||
strcpy(monitors->monitor[i].ptrName, monitors->monitor[i].name);
|
||||
sprintf(monitors->monitor[i].ptrIndexItem, "%d", i + 1);
|
||||
sprintf(monitors->monitor[i].ptrIndexMonitor, "%d", i);
|
||||
}
|
||||
|
||||
return monitors;
|
||||
}
|
||||
|
||||
void freeXInfo(x_info *info)
|
||||
{
|
||||
for (int i = 0; i < info->count; ++i)
|
||||
{
|
||||
if (info->monitor[i].ptrName)
|
||||
free(info->monitor[i].ptrName);
|
||||
if (info->monitor[i].ptrIndexItem)
|
||||
free(info->monitor[i].ptrIndexItem);
|
||||
if (info->monitor[i].ptrIndexMonitor)
|
||||
free(info->monitor[i].ptrIndexMonitor);
|
||||
}
|
||||
free(info);
|
||||
}
|
Loading…
Reference in New Issue