USERADD_SYNC shutdown WIP

pull/235/head
parent ff7573e76c
commit f51f31d976

@ -87,9 +87,27 @@ void on_additional_settings_changed(GtkWidget *self, ubl_settings_usergroups_add
// }
}
void on_additional_settings_user_sync_add(GtkWidget *, ubl_settings_usergroups_additional_settings_window *){
void on_additional_settings_user_sync_add(GtkWidget *self, ubl_settings_usergroups_additional_settings_window *window){
GtkTreeModel *model;
GtkTreeIter iter;
GtkWidget *tree;
if (self == window->UserAddButton){
tree = window->UsersTree;
} else {
tree = window->GroupsTree;
}
if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)),&model,&iter)){
char *name;
char *parameter;
int min_sensitive;
int max_sensitive;
gtk_tree_model_get(model,&iter,1,&name,7,&min_sensitive,8,&max_sensitive,9,&parameter,-1);
gtk_list_store_append(GTK_LIST_STORE(model),&iter);
gtk_list_store_set(GTK_LIST_STORE(model),&iter,0,1,1,name,5,1,6,1,7,min_sensitive,8,max_sensitive,9,parameter,10,1,11,1,-1);
}
}
void on_additional_settings_user_sync_remove(GtkWidget *, ubl_settings_usergroups_additional_settings_window *window){
GtkTreeModel *model;
@ -119,6 +137,96 @@ void on_additional_settings_changed(GtkWidget *self, ubl_settings_usergroups_add
}
}
void on_additional_settings_cell_toggled(GtkCellRenderer *self, char *path, ubl_settings_usergroups_additional_settings_window *window){
GtkTreeIter iter;
GtkTreeModel *model = NULL;
if (self == window->UserActiveCell){
model = GTK_TREE_MODEL(window->UsersShutdownList);
} else {
model = GTK_TREE_MODEL(window->GroupsShutdownList);
}
int status;
gtk_tree_model_get_iter_from_string(model,&iter,path);
gtk_tree_model_get(model,&iter,0,&status,-1);
gtk_list_store_set(GTK_LIST_STORE(model),&iter,0,!status,6,!status,-1);
if (path[0]=='0'&&!!status){
for_iter(model,&iter){
gtk_list_store_set(GTK_LIST_STORE(model),&iter,5,1,-1);
}
} else if (path[0] == '0'&&!status) {
int i=0;
for_iter(model,&iter){
if (i){
gtk_list_store_set(GTK_LIST_STORE(model),&iter,5,0,-1);
}
i++;
}
}
}
void on_additional_settings_cell_edited(GtkCellRenderer *self, char *path, char *new_text, ubl_settings_usergroups_additional_settings_window *window){
for (size_t i=0;i<strlen(new_text);i++){
if (!g_ascii_isdigit(new_text[i])) return;
}
GtkTreeIter iter;
GtkTreeModel *model = NULL;
int place_to_set = -1;
if (self == window->UserMinCell){
model = GTK_TREE_MODEL(window->UsersShutdownList);
place_to_set=2;
} else if (self == window->UserMaxCell) {
model = GTK_TREE_MODEL(window->UsersShutdownList);
place_to_set=3;
} else if (self == window->GroupMinCell) {
model = GTK_TREE_MODEL(window->GroupsShutdownList);
place_to_set=2;
} else if (self == window->GroupMaxCell) {
model = GTK_TREE_MODEL(window->GroupsShutdownList);
place_to_set=3;
}
gtk_tree_model_get_iter_from_string(model,&iter,path);
char *old_val;
gtk_tree_model_get(model,&iter,place_to_set==2?3:2,&old_val,-1);
if (yon_char_is_empty(old_val)) old_val = "";
if (!yon_char_is_empty(old_val)){
if (place_to_set==2){
if (atoi(new_text)>atoi(old_val)){
new_text=old_val;
}
} else {
if (atoi(old_val)>atoi(new_text)){
new_text = old_val;
}
}
}
gtk_list_store_set(GTK_LIST_STORE(model),&iter,place_to_set,new_text,place_to_set==2?3:2,old_val,-1);
}
void on_adiitional_settings_tree_selection_changed(GtkWidget *self, ubl_settings_usergroups_additional_settings_window *window){
GtkTreeModel *model;
GtkTreeIter iter;
GtkWidget *tree;
GtkWidget *add_button;
GtkWidget *remove_button;
if (self == window->UsersTree){
tree = window->UsersTree;
add_button = window->UserAddButton;
remove_button = window->UserRemoveButton;
} else {
tree = window->GroupsTree;
add_button = window->GroupAddButton;
remove_button = window->GroupRemoveButton;
}
if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)),&model,&iter)){
int deletable;
int creatable;
char *parameter;
gtk_tree_model_get(model,&iter,9,&parameter,10,&creatable,11,&deletable,-1);
if (creatable) gtk_widget_set_sensitive(add_button,1); else gtk_widget_set_sensitive(add_button,0);
if (deletable) gtk_widget_set_sensitive(remove_button,1); else gtk_widget_set_sensitive(remove_button,0);
}
}
ubl_settings_usergroups_additional_settings_window *yon_ubl_settings_usergroups_additional_settings_new(){
ubl_settings_usergroups_additional_settings_window *window = malloc(sizeof(ubl_settings_usergroups_additional_settings_window));
GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_ubl_settings_usergroups_additional_settings);
@ -150,6 +258,12 @@ ubl_settings_usergroups_additional_settings_window *yon_ubl_settings_usergroups_
window->GroupRemoveButton=yon_gtk_builder_get_widget(builder,"GroupRemoveButton");
window->UsersShutdownList=GTK_LIST_STORE(gtk_builder_get_object(builder,"UsersShutdownList"));
window->GroupsShutdownList=GTK_LIST_STORE(gtk_builder_get_object(builder,"GroupsShutdownList"));
window->UserActiveCell=GTK_CELL_RENDERER(gtk_builder_get_object(builder,"UserActiveCell"));
window->UserMinCell=GTK_CELL_RENDERER(gtk_builder_get_object(builder,"UserMinCell"));
window->UserMaxCell=GTK_CELL_RENDERER(gtk_builder_get_object(builder,"UserMaxCell"));
window->GroupActiveCell=GTK_CELL_RENDERER(gtk_builder_get_object(builder,"GroupActiveCell"));
window->GroupMinCell=GTK_CELL_RENDERER(gtk_builder_get_object(builder,"GroupMinCell"));
window->GroupMaxCell=GTK_CELL_RENDERER(gtk_builder_get_object(builder,"GroupMaxCell"));
window->default_password=NULL;
window->default_root_password=NULL;
@ -164,8 +278,18 @@ ubl_settings_usergroups_additional_settings_window *yon_ubl_settings_usergroups_
g_signal_connect(G_OBJECT(window->GroupAddButton),"clicked",G_CALLBACK(on_additional_settings_group_sync_add),window);
g_signal_connect(G_OBJECT(window->GroupRemoveButton),"clicked",G_CALLBACK(on_additional_settings_group_sync_remove),window);
g_signal_connect(G_OBJECT(window->UserActiveCell),"toggled",G_CALLBACK(on_additional_settings_cell_toggled),window);
g_signal_connect(G_OBJECT(window->GroupActiveCell),"toggled",G_CALLBACK(on_additional_settings_cell_toggled),window);
g_signal_connect(G_OBJECT(window->UserMinCell),"edited",G_CALLBACK(on_additional_settings_cell_edited),window);
g_signal_connect(G_OBJECT(window->UserMaxCell),"edited",G_CALLBACK(on_additional_settings_cell_edited),window);
g_signal_connect(G_OBJECT(window->GroupMinCell),"edited",G_CALLBACK(on_additional_settings_cell_edited),window);
g_signal_connect(G_OBJECT(window->GroupMaxCell),"edited",G_CALLBACK(on_additional_settings_cell_edited),window);
g_signal_connect(G_OBJECT(window->UsersShutdownSwitch),"activate",G_CALLBACK(on_additional_settings_changed),window);
g_signal_connect(G_OBJECT(window->GroupsShutdownSwitch),"activate",G_CALLBACK(on_additional_settings_changed),window);
g_signal_connect(G_OBJECT(window->UsersTree),"cursor-changed",G_CALLBACK(on_adiitional_settings_tree_selection_changed),window);
g_signal_connect(G_OBJECT(window->GroupsTree),"cursor-changed",G_CALLBACK(on_adiitional_settings_tree_selection_changed),window);
yon_gtk_revealer_set_from_switch(GTK_REVEALER(window->UserShutdownRevealer),GTK_SWITCH(window->UsersShutdownSwitch));
yon_gtk_revealer_set_from_switch(GTK_REVEALER(window->GroupShutdownRevealer),GTK_SWITCH(window->GroupsShutdownSwitch));
@ -180,7 +304,6 @@ ubl_settings_usergroups_additional_settings_window *yon_ubl_settings_usergroups_
gtk_switch_set_active(GTK_SWITCH(window->UsersShutdownSwitch),1);
}
}
int hash_size=0;
config_str hash_algos = yon_file_open(hash_list_path,&hash_size);
if (main_config.hash_default_id==-1){

@ -258,6 +258,12 @@ typedef struct{
GtkWidget *GroupRemoveButton;
GtkListStore *UsersShutdownList;
GtkListStore *GroupsShutdownList;
GtkCellRenderer *UserActiveCell;
GtkCellRenderer *UserMinCell;
GtkCellRenderer *UserMaxCell;
GtkCellRenderer *GroupActiveCell;
GtkCellRenderer *GroupMinCell;
GtkCellRenderer *GroupMaxCell;
const char *default_user_name;
const char *default_password;
@ -544,4 +550,7 @@ config_str yon_parameter_get_by_template(char *parameter, char *pattern, int *si
void on_additional_settings_group_sync_add(GtkWidget *, ubl_settings_usergroups_additional_settings_window *window);
void on_additional_settings_user_sync_remove(GtkWidget *, ubl_settings_usergroups_additional_settings_window *window);
void on_additional_settings_user_sync_add(GtkWidget *, ubl_settings_usergroups_additional_settings_window *window);
void on_additional_settings_cell_toggled(GtkCellRenderer *self, char *path, ubl_settings_usergroups_additional_settings_window *window);
void on_additional_settings_cell_edited(GtkCellRenderer *self, char *path, char *new_text, ubl_settings_usergroups_additional_settings_window *window);
void on_adiitional_settings_tree_selection_changed(GtkWidget *self, ubl_settings_usergroups_additional_settings_window *window);
#endif

@ -10,54 +10,96 @@
<!-- column-name RenderName -->
<column type="gchararray"/>
<!-- column-name ValueMin -->
<column type="gint"/>
<column type="gchararray"/>
<!-- column-name ValueMax -->
<column type="gint"/>
<column type="gchararray"/>
<!-- column-name Indeletable -->
<column type="gboolean"/>
<!-- column-name ActveSensitive -->
<column type="gboolean"/>
<!-- column-name Sensitive -->
<column type="gboolean"/>
<!-- column-name MinValueSensitive -->
<column type="gboolean"/>
<!-- column-name MaxValueSensitive -->
<column type="gboolean"/>
<!-- column-name Parameter -->
<column type="gchararray"/>
<!-- column-name Creatable -->
<column type="gboolean"/>
<!-- column-name Deletable -->
<column type="gboolean"/>
</columns>
<data>
<row>
<col id="0">True</col>
<col id="1" translatable="yes">All groups in system</col>
<col id="2">1</col>
<col id="3">65535</col>
<col id="2" translatable="yes">1</col>
<col id="3" translatable="yes">65535</col>
<col id="4">True</col>
<col id="5">True</col>
<col id="6">True</col>
<col id="7">False</col>
<col id="8">False</col>
<col id="9" translatable="yes"></col>
<col id="10">False</col>
<col id="11">False</col>
</row>
<row>
<col id="0">False</col>
<col id="1" translatable="yes">Groups</col>
<col id="2">1000</col>
<col id="3">6000</col>
<col id="2" translatable="yes">1000</col>
<col id="3" translatable="yes">6000</col>
<col id="4">True</col>
<col id="5">False</col>
<col id="6">False</col>
<col id="7">False</col>
<col id="8">False</col>
<col id="9" translatable="yes"></col>
<col id="10">False</col>
<col id="11">False</col>
</row>
<row>
<col id="0">False</col>
<col id="1" translatable="yes">System groups</col>
<col id="2">500</col>
<col id="3">999</col>
<col id="2" translatable="yes">500</col>
<col id="3" translatable="yes">999</col>
<col id="4">True</col>
<col id="5">False</col>
<col id="6">False</col>
<col id="7">False</col>
<col id="8">False</col>
<col id="9" translatable="yes"></col>
<col id="10">False</col>
<col id="11">False</col>
</row>
<row>
<col id="0">False</col>
<col id="1" translatable="yes">Group GID range</col>
<col id="2">0</col>
<col id="3">0</col>
<col id="2" translatable="yes"></col>
<col id="3" translatable="yes"></col>
<col id="4">True</col>
<col id="5">False</col>
<col id="6">False</col>
<col id="7">True</col>
<col id="8">True</col>
<col id="9" translatable="yes"></col>
<col id="10">True</col>
<col id="11">False</col>
</row>
<row>
<col id="0">False</col>
<col id="1" translatable="yes">Group GID in system</col>
<col id="2">0</col>
<col id="3">0</col>
<col id="2" translatable="yes"></col>
<col id="3" translatable="yes"></col>
<col id="4">True</col>
<col id="5">False</col>
<col id="6">False</col>
<col id="7">True</col>
<col id="8">False</col>
<col id="9" translatable="yes"></col>
<col id="10">True</col>
<col id="11">False</col>
</row>
</data>
</object>
@ -68,54 +110,96 @@
<!-- column-name Target -->
<column type="gchararray"/>
<!-- column-name MinValue -->
<column type="guint"/>
<column type="gchararray"/>
<!-- column-name MaxValue -->
<column type="guint"/>
<column type="gchararray"/>
<!-- column-name Indeletable -->
<column type="gboolean"/>
<!-- column-name ActiveSensitive -->
<column type="gboolean"/>
<!-- column-name Sensitive -->
<column type="gboolean"/>
<!-- column-name ValueMinSensitive -->
<column type="gboolean"/>
<!-- column-name ValueMaxSensitive -->
<column type="gboolean"/>
<!-- column-name Parameter -->
<column type="gchararray"/>
<!-- column-name Creatable -->
<column type="gboolean"/>
<!-- column-name Deletable -->
<column type="gboolean"/>
</columns>
<data>
<row>
<col id="0">True</col>
<col id="1" translatable="yes">All system users</col>
<col id="2">1</col>
<col id="3">65535</col>
<col id="2" translatable="yes">1</col>
<col id="3" translatable="yes">65535</col>
<col id="4">True</col>
<col id="5">True</col>
<col id="6">True</col>
<col id="7">False</col>
<col id="8">False</col>
<col id="9" translatable="yes"></col>
<col id="10">False</col>
<col id="11">False</col>
</row>
<row>
<col id="0">False</col>
<col id="1" translatable="yes">Users</col>
<col id="2">1000</col>
<col id="3">6000</col>
<col id="2" translatable="yes">1000</col>
<col id="3" translatable="yes">6000</col>
<col id="4">True</col>
<col id="5">False</col>
<col id="6">False</col>
<col id="7">False</col>
<col id="8">False</col>
<col id="9" translatable="yes"></col>
<col id="10">False</col>
<col id="11">False</col>
</row>
<row>
<col id="0">False</col>
<col id="1" translatable="yes">System users</col>
<col id="2">500</col>
<col id="3">999</col>
<col id="2" translatable="yes">500</col>
<col id="3" translatable="yes">999</col>
<col id="4">True</col>
<col id="5">False</col>
<col id="6">False</col>
<col id="7">False</col>
<col id="8">False</col>
<col id="9" translatable="yes"></col>
<col id="10">False</col>
<col id="11">False</col>
</row>
<row>
<col id="0">False</col>
<col id="1" translatable="yes">Users UID range</col>
<col id="2">0</col>
<col id="3">0</col>
<col id="2" translatable="yes"></col>
<col id="3" translatable="yes"></col>
<col id="4">True</col>
<col id="5">False</col>
<col id="6">False</col>
<col id="7">True</col>
<col id="8">True</col>
<col id="9" translatable="yes"></col>
<col id="10">True</col>
<col id="11">False</col>
</row>
<row>
<col id="0">False</col>
<col id="1" translatable="yes">User UID in system</col>
<col id="2">0</col>
<col id="3">0</col>
<col id="2" translatable="yes"></col>
<col id="3" translatable="yes"></col>
<col id="4">True</col>
<col id="5">False</col>
<col id="6">False</col>
<col id="7">True</col>
<col id="8">False</col>
<col id="9" translatable="yes"></col>
<col id="10">True</col>
<col id="11">False</col>
</row>
</data>
</object>
@ -614,6 +698,7 @@
<child>
<object class="GtkCellRendererToggle" id="UserActiveCell"/>
<attributes>
<attribute name="sensitive">5</attribute>
<attribute name="active">0</attribute>
</attributes>
</child>
@ -625,6 +710,7 @@
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="sensitive">5</attribute>
<attribute name="text">1</attribute>
</attributes>
</child>
@ -638,6 +724,8 @@
<property name="max-width-chars">5</property>
</object>
<attributes>
<attribute name="sensitive">6</attribute>
<attribute name="editable">7</attribute>
<attribute name="text">2</attribute>
</attributes>
</child>
@ -651,6 +739,8 @@
<property name="max-width-chars">5</property>
</object>
<attributes>
<attribute name="sensitive">6</attribute>
<attribute name="editable">8</attribute>
<attribute name="text">3</attribute>
</attributes>
</child>
@ -831,10 +921,11 @@
<object class="GtkTreeSelection"/>
</child>
<child>
<object class="GtkTreeViewColumn" id="GroupActiveCell">
<object class="GtkTreeViewColumn">
<child>
<object class="GtkCellRendererToggle"/>
<object class="GtkCellRendererToggle" id="GroupActiveCell"/>
<attributes>
<attribute name="sensitive">6</attribute>
<attribute name="active">0</attribute>
</attributes>
</child>
@ -846,6 +937,7 @@
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="sensitive">5</attribute>
<attribute name="text">1</attribute>
</attributes>
</child>
@ -856,10 +948,11 @@
<property name="title" translatable="yes">Minimum GID</property>
<child>
<object class="GtkCellRendererText" id="GroupMinCell">
<property name="editable">True</property>
<property name="max-width-chars">5</property>
</object>
<attributes>
<attribute name="sensitive">6</attribute>
<attribute name="editable">7</attribute>
<attribute name="text">2</attribute>
</attributes>
</child>
@ -870,10 +963,11 @@
<property name="title" translatable="yes">Maximum GID</property>
<child>
<object class="GtkCellRendererText" id="GroupMaxCell">
<property name="editable">True</property>
<property name="max-width-chars">5</property>
</object>
<attributes>
<attribute name="sensitive">6</attribute>
<attribute name="editable">8</attribute>
<attribute name="text">3</attribute>
</attributes>
</child>

Loading…
Cancel
Save