151 lines
5.1 KiB
C
151 lines
5.1 KiB
C
/*
|
||
* gui.c
|
||
*
|
||
* Created on: 6 июл. 2022 г.
|
||
* Author: alexander
|
||
*/
|
||
|
||
#include <string.h>
|
||
#include <stdlib.h>
|
||
#include <stdio.h>
|
||
|
||
#include "gui.h"
|
||
#include "settings.h"
|
||
#include "node_settings.h"
|
||
#include "images.h"
|
||
#include "arguments.h"
|
||
|
||
static int guiExit(Ihandle *self)
|
||
{
|
||
return IUP_CLOSE;
|
||
}
|
||
|
||
static int guiConnect(Ihandle *self)
|
||
{
|
||
settingsSetValue(PARAMETER_SERVER, IupGetAttribute(IupGetDialogChild(self, "SERVER"), "LINEVALUE"));
|
||
settingsSetValue(PARAMETER_USERNAME, IupGetAttribute(IupGetDialogChild(self, "USER"), "LINEVALUE"));
|
||
settingsSetValue(PARAMETER_PASSWORD, IupGetAttribute(IupGetDialogChild(self, "PASSWORD"), "LINEVALUE"));
|
||
|
||
Arguments *args = buildArguments();
|
||
for (int i = 0; i < args->argc; ++i)
|
||
{
|
||
printf("%s\n", args->argv[i]);
|
||
}
|
||
printf("\n");
|
||
|
||
|
||
// char *program = "xfreerdp";
|
||
// char *domain = "/d:agrohold";
|
||
// char *certignore = "/cert-ignore";
|
||
//
|
||
// char **argv = (char**) malloc(sizeof(char*) * 8);
|
||
//
|
||
// argv[0] = program;
|
||
// argv[1] = server;
|
||
// argv[2] = domain;
|
||
// argv[3] = user;
|
||
// argv[4] = password;
|
||
// argv[5] = certignore;
|
||
//
|
||
// Ihandle *child = IupGetDialogChild(self, "SETTINGS_WINDOW");
|
||
//
|
||
// if (!strcmp(IupGetAttribute(IupGetDialogChild(child, "SETTINGS_FULLSCREEN"), "VALUE"), "ON"))
|
||
// {
|
||
// argv[6] = "/f\0";
|
||
// }
|
||
//
|
||
// if (!strcmp(IupGetAttribute(IupGetDialogChild(child, "SETTINGS_MULTIMONITOR"), "VALUE"), "ON"))
|
||
// {
|
||
// argv[7] = "/multimon\0";
|
||
// }
|
||
//
|
||
|
||
return IUP_DEFAULT;
|
||
}
|
||
|
||
Ihandle* guiStart()
|
||
{
|
||
Ihandle *dlg;
|
||
Ihandle *icon, *bgHead;
|
||
Ihandle *vBoxMain, *hBoxServer, *hBoxUser, *hBoxPassword, *hBoxButtons; // Boxes
|
||
Ihandle *labelImage;
|
||
Ihandle *labelServer, *inputServer;
|
||
Ihandle *labelUser, *inputUser;
|
||
Ihandle *labelPassword, *inputPassword;
|
||
Ihandle *btnConnect, *btnClose, *btnSettings;
|
||
|
||
icon = IupImageRGBA(64, 64, idata_icon);
|
||
IupSetHandle("icon", icon);
|
||
|
||
labelImage = IupLabel(NULL);
|
||
|
||
bgHead = IupImageRGBA(405, 72, idata_head);
|
||
IupSetAttributeHandle(labelImage, "IMAGE", bgHead);
|
||
|
||
labelServer = IupLabel("Компьютер:");
|
||
IupSetAttribute(labelServer, "SIZE", "80x16");
|
||
// IupSetAttribute(labelServer, "FONT", "Helvetica, 14");
|
||
IupSetAttribute(labelServer, "ALIGNMENT", "ARIGHT:ACENTER");
|
||
IupSetAttribute(labelServer, "PADDING", "5");
|
||
inputServer = IupText(NULL);
|
||
IupSetAttribute(inputServer, "NAME", "SERVER");
|
||
// IupSetAttribute(inputServer, "BORDER", "NO");
|
||
IupSetAttribute(inputServer, "SIZE", "100");
|
||
// IupSetAttribute(inputServer, "PADDING", "10x");
|
||
hBoxServer = IupHbox(labelServer, inputServer, NULL);
|
||
IupSetAttribute(hBoxServer, "MARGIN", "10x10");
|
||
|
||
labelUser = IupLabel("Пользователь:");
|
||
IupSetAttribute(labelUser, "SIZE", "80x16");
|
||
IupSetAttribute(labelUser, "ALIGNMENT", "ARIGHT:ACENTER");
|
||
IupSetAttribute(labelUser, "PADDING", "5");
|
||
inputUser = IupText(NULL);
|
||
IupSetAttribute(inputUser, "NAME", "USER");
|
||
IupSetAttribute(inputUser, "SIZE", "100");
|
||
// IupSetAttribute(inputUser, "PADDING", "10x10");
|
||
hBoxUser = IupHbox(labelUser, inputUser, NULL);
|
||
IupSetAttribute(hBoxUser, "MARGIN", "10x0");
|
||
|
||
labelPassword = IupLabel("Пароль:");
|
||
IupSetAttribute(labelPassword, "SIZE", "80x16");
|
||
IupSetAttribute(labelPassword, "ALIGNMENT", "ARIGHT:ACENTER");
|
||
IupSetAttribute(labelPassword, "PADDING", "5");
|
||
inputPassword = IupText(NULL);
|
||
IupSetAttribute(inputPassword, "SIZE", "100");
|
||
// IupSetAttribute(inputPassword, "PADDING", "10x10");
|
||
IupSetAttribute(inputPassword, "NAME", "PASSWORD");
|
||
IupSetAttribute(inputPassword, "PASSWORD", "YES");
|
||
hBoxPassword = IupHbox(labelPassword, inputPassword, NULL);
|
||
IupSetAttribute(hBoxPassword, "MARGIN", "10x10");
|
||
|
||
btnConnect = IupButton("Подключение", NULL);
|
||
IupSetHandle("CONNECT", btnConnect);
|
||
IupSetAttribute(btnConnect, "NAME", "CONNECT");
|
||
btnClose = IupButton("Закрыть", NULL);
|
||
IupSetHandle("CLOSE", btnClose);
|
||
IupSetAttribute(btnClose, "NAME", "CLOSE");
|
||
btnSettings = IupButton("Настройки", NULL);
|
||
IupSetAttribute(btnSettings, "NAME", "SETTINGS");
|
||
hBoxButtons = IupHbox(IupFill(), btnConnect, btnClose, btnSettings, IupFill(), NULL);
|
||
IupSetAttribute(hBoxButtons, "ALIGNMENT", "ACENTER:ACENTER");
|
||
IupSetAttribute(hBoxButtons, "GAP", "10");
|
||
IupSetAttribute(hBoxButtons, "MARGIN", "10x10");
|
||
|
||
vBoxMain = IupVbox(labelImage, hBoxServer, hBoxUser, hBoxPassword, hBoxButtons, NULL);
|
||
|
||
IupSetCallback(btnConnect, "ACTION", (Icallback) guiConnect);
|
||
IupSetCallback(btnClose, "ACTION", (Icallback) guiExit);
|
||
IupSetCallback(btnSettings, "ACTION", (Icallback) settingsWindow);
|
||
|
||
dlg = IupDialog(vBoxMain);
|
||
IupSetAttribute(dlg, "IMAGE", "BG_HEAD");
|
||
IupSetAttribute(dlg, "ICON", "icon");
|
||
IupSetAttribute(dlg, "TITLE", "GUI FreeRDP");
|
||
IupSetAttribute(dlg, "RESIZE", "NO");
|
||
IupSetAttribute(dlg, "PARENTDIALOG", "MAIN_WINDOW");
|
||
IupSetAttribute(dlg, "DEFAULTENTER", "CONNECT");
|
||
IupSetAttribute(dlg, "DEFAULTESC", "CLOSE");
|
||
|
||
return dlg;
|
||
}
|