parent
a95c0dbfbf
commit
8c3f67676b
@ -1,80 +1,104 @@
|
||||
#include "ubinstall-gtk.h"
|
||||
|
||||
int yon_users_save(main_window *widgets){
|
||||
if (yon_char_is_empty(gtk_entry_get_text(GTK_ENTRY(widgets->UserNameEntry)))||!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->UsernameSensitiveCheck))){
|
||||
yon_config_remove_by_key(user_gecos_parameter);
|
||||
if (gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->UserRootPasswordCombo))){
|
||||
const char *root_password = gtk_entry_get_text(GTK_ENTRY(widgets->UserRootPasswordEntry));
|
||||
if (yon_char_is_empty(root_password)){
|
||||
yon_ubl_status_box_spawn(GTK_CONTAINER(main_config.status_box),_EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
|
||||
yon_ubl_status_highlight_incorrect(widgets->UserRootPasswordEntry);
|
||||
return 0;
|
||||
}
|
||||
yon_config_register(root_password_parameter,root_password_parameter_command,(char*)root_password);
|
||||
} else {
|
||||
char *username = (char*)gtk_entry_get_text(GTK_ENTRY(widgets->UserNameEntry));
|
||||
if (username){};
|
||||
yon_config_register(user_gecos_parameter,user_gecos_parameter_command,username);
|
||||
yon_config_remove_by_key(root_password_parameter);
|
||||
}
|
||||
|
||||
if (yon_char_is_empty(gtk_entry_get_text(GTK_ENTRY(widgets->UserLoginEntry)))||!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->LoginSensitiveCheck))){
|
||||
yon_config_remove_by_key(user_name_parameter);
|
||||
int autologin = gtk_switch_get_active(GTK_SWITCH(widgets->UserAutologinSwitch));
|
||||
if (autologin){
|
||||
yon_config_register(autologin_parameter,autologin_parameter_command,"yes");
|
||||
} else {
|
||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->UserRootOnlyCheck))){
|
||||
yon_config_register(user_name_parameter,user_name_parameter_command,"root");
|
||||
} else {
|
||||
char *login = (char*)gtk_entry_get_text(GTK_ENTRY(widgets->UserLoginEntry));
|
||||
if (login){};
|
||||
yon_config_register(user_name_parameter,user_name_parameter_command,login);
|
||||
}
|
||||
yon_config_register(autologin_parameter,autologin_parameter_command,"no");
|
||||
}
|
||||
|
||||
if (gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->UserPasswordCombo))==1){
|
||||
if (yon_char_is_empty(gtk_entry_get_text(GTK_ENTRY(widgets->UserPasswordEntry)))){
|
||||
yon_ubl_status_box_spawn(GTK_CONTAINER(widgets->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
|
||||
yon_ubl_status_highlight_incorrect(widgets->UserPasswordEntry);
|
||||
return 0;
|
||||
} else {
|
||||
char *password = (char*)gtk_entry_get_text(GTK_ENTRY(widgets->UserPasswordEntry));
|
||||
if (password){};
|
||||
|
||||
yon_config_register(user_password_parameter,user_password_parameter_command,password);
|
||||
GList *users = gtk_container_get_children(GTK_CONTAINER(widgets->UserAddBox));
|
||||
GList *iter;
|
||||
for (iter=users;iter;iter=iter->next){
|
||||
yon_user_struct *user = g_object_get_data(G_OBJECT(iter->data),"yon_user_struct");
|
||||
if (user){
|
||||
if (!yon_user_save(user)){
|
||||
yon_ubl_status_box_spawn(GTK_CONTAINER(main_config.status_box),_EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
yon_config_remove_by_key(user_password_parameter);
|
||||
}
|
||||
}
|
||||
|
||||
if (gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->AdminPasswordCombo))==1){
|
||||
if (yon_char_is_empty(gtk_entry_get_text(GTK_ENTRY(widgets->AdminPasswordEntry)))){
|
||||
yon_ubl_status_box_spawn(GTK_CONTAINER(widgets->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
|
||||
yon_ubl_status_highlight_incorrect(widgets->AdminPasswordEntry);
|
||||
return 0;
|
||||
} else {
|
||||
char *root_password = (char*)gtk_entry_get_text(GTK_ENTRY(widgets->AdminPasswordEntry));
|
||||
if (root_password){};
|
||||
yon_config_register(root_password_parameter,root_password_parameter_command,root_password);
|
||||
yon_debug_output("%s\n",yon_config_get_all_info());
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
yon_config_remove_by_key(root_password_parameter);
|
||||
int yon_user_save(yon_user_struct *user){
|
||||
char *name = (char *)gtk_entry_get_text(GTK_ENTRY(user->UsernameEntry));
|
||||
char *login = (char *)gtk_entry_get_text(GTK_ENTRY(user->LoginEntry));
|
||||
char *password = NULL;
|
||||
if (yon_char_is_empty(login)){
|
||||
yon_ubl_status_box_spawn(GTK_CONTAINER(main_config.status_box),_EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
|
||||
yon_ubl_status_highlight_incorrect(user->LoginEntry);
|
||||
return 0;
|
||||
}
|
||||
if (gtk_combo_box_get_active(GTK_COMBO_BOX(user->PasswordCombo))){
|
||||
password = (char *)gtk_entry_get_text(GTK_ENTRY(user->PasswordEntry));
|
||||
if (yon_char_is_empty(password)){
|
||||
yon_ubl_status_highlight_incorrect(user->PasswordEntry);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
char *parameter = yon_char_unite(yon_char_return_if_exist(name,""),":::::",yon_char_return_if_exist(password,""),NULL);
|
||||
yon_config_register(USERADD_parameter(login),USERADD_parameter_command(login),parameter);
|
||||
free(parameter);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->HostnameSensitiveCheck))){
|
||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->AutoHostnameCheck))){
|
||||
yon_config_register(hostname_parameter,hostname_parameter_command,"auto");
|
||||
} else {
|
||||
if (!yon_char_is_empty(gtk_entry_get_text(GTK_ENTRY(widgets->HotnameEntry)))){
|
||||
char *hostname = (char*)gtk_entry_get_text(GTK_ENTRY(widgets->HotnameEntry));
|
||||
if (hostname){};
|
||||
yon_config_register(hostname_parameter,hostname_parameter_command,hostname);
|
||||
void on_user_add(GtkWidget *,main_window *widgets){
|
||||
yon_user_struct *user = yon_user_struct_new();
|
||||
gtk_box_pack_start(GTK_BOX(widgets->UserAddBox),user->MainBox,0,0,0);
|
||||
}
|
||||
|
||||
} else {
|
||||
yon_config_remove_by_key(hostname_parameter);
|
||||
void on_user_remove_clicked(GtkWidget *,yon_user_struct *user){
|
||||
gtk_widget_destroy(user->MainBox);
|
||||
free(user);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
yon_config_remove_by_key(hostname_parameter);
|
||||
}
|
||||
void yon_password_root_new(GtkWidget *, main_window *widgets){
|
||||
yon_password_window *window = yon_password_open(GTK_ENTRY(widgets->UserRootPasswordEntry));
|
||||
gtk_widget_hide(gtk_widget_get_parent(window->EncryptionCombo));
|
||||
gtk_widget_show(window->Window);
|
||||
}
|
||||
|
||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->AutologinSensitiveCheck))){
|
||||
char *autologin = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->UserAutologinSwitch))?"yes":"no";
|
||||
yon_config_register(autologin_parameter,autologin_parameter_command,autologin);
|
||||
} else {
|
||||
yon_config_remove_by_key(autologin_parameter);
|
||||
}
|
||||
return 1;
|
||||
void yon_password_new(GtkWidget *, yon_user_struct *user){
|
||||
yon_password_window *window = yon_password_open(GTK_ENTRY(user->PasswordEntry));
|
||||
gtk_widget_hide(gtk_widget_get_parent(window->EncryptionCombo));
|
||||
gtk_widget_show(window->Window);
|
||||
}
|
||||
|
||||
yon_user_struct *yon_user_struct_new(){
|
||||
yon_user_struct *user = new(yon_user_struct);
|
||||
GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_user);
|
||||
|
||||
user->MainBox = yon_gtk_builder_get_widget(builder,"MainBox");
|
||||
user->RemoveButton = yon_gtk_builder_get_widget(builder,"RemoveButton");
|
||||
user->UsernameEntry = yon_gtk_builder_get_widget(builder,"UsernameEntry");
|
||||
user->LoginEntry = yon_gtk_builder_get_widget(builder,"LoginEntry");
|
||||
user->PasswordCombo = yon_gtk_builder_get_widget(builder,"PasswordCombo");
|
||||
user->PasswordEntry = yon_gtk_builder_get_widget(builder,"PasswordEntry");
|
||||
user->PasswordButton = yon_gtk_builder_get_widget(builder,"PasswordButton");
|
||||
|
||||
g_object_set_data(G_OBJECT(user->MainBox),"yon_user_struct",user);
|
||||
|
||||
yon_gtk_entry_set_password_visibility_icon(GTK_ENTRY(user->PasswordEntry));
|
||||
|
||||
g_signal_connect(G_OBJECT(user->PasswordCombo),"changed",G_CALLBACK(yon_gtk_widget_set_sensitive_from_combo_box),user->PasswordEntry);
|
||||
g_signal_connect(G_OBJECT(user->PasswordCombo),"changed",G_CALLBACK(yon_gtk_widget_set_sensitive_from_combo_box),user->PasswordButton);
|
||||
g_signal_connect(G_OBJECT(user->PasswordButton),"clicked",G_CALLBACK(yon_password_new),user);
|
||||
g_signal_connect(G_OBJECT(user->RemoveButton),"clicked",G_CALLBACK(on_user_remove_clicked),user);
|
||||
return user;
|
||||
}
|
||||
@ -0,0 +1,219 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.40.0 -->
|
||||
<interface domain="ubinstall-gtk">
|
||||
<requires lib="gtk+" version="3.24"/>
|
||||
<!-- interface-css-provider-path ubinstall-gtk.css -->
|
||||
<object class="GtkImage" id="image1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="icon-name">com.ublinux.libublsettingsui-gtk3.trash-symbolic</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="image22">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="icon-name">com.ublinux.libublsettingsui-gtk3.edit-symbolic</property>
|
||||
</object>
|
||||
<object class="GtkBox" id="MainBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-left">5</property>
|
||||
<property name="margin-right">5</property>
|
||||
<property name="margin-start">5</property>
|
||||
<property name="margin-end">5</property>
|
||||
<property name="margin-top">5</property>
|
||||
<property name="margin-bottom">5</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">5</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">5</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="spacing">5</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Account name:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="UsernameEntry">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="placeholder-text" translatable="yes">Administrator</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="RemoveButton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="image">image1</property>
|
||||
<style>
|
||||
<class name="thin"/>
|
||||
</style>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="spacing">5</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Login:</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="LoginEntry">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="placeholder-text" translatable="yes">superadmin</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="spacing">5</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Password:</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="PasswordCombo">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="active">0</property>
|
||||
<items>
|
||||
<item translatable="yes">Default</item>
|
||||
<item translatable="yes">Set a password</item>
|
||||
</items>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="PasswordEntry">
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="visibility">False</property>
|
||||
<property name="invisible-char">●</property>
|
||||
<property name="placeholder-text" translatable="yes">ublinux</property>
|
||||
<property name="input-purpose">password</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="PasswordButton">
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="image">image22</property>
|
||||
<style>
|
||||
<class name="thin"/>
|
||||
</style>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<style>
|
||||
<class name="bggrey"/>
|
||||
</style>
|
||||
</object>
|
||||
</interface>
|
||||
Loading…
Reference in new issue