diff --git a/source/ubl-settings-usergroups-settings.c b/source/ubl-settings-usergroups-settings.c index d2ac761..600a6fc 100644 --- a/source/ubl-settings-usergroups-settings.c +++ b/source/ubl-settings-usergroups-settings.c @@ -87,8 +87,26 @@ 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,¶meter,-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){ @@ -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;iUserMinCell){ + 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,¶meter,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){ diff --git a/source/ubl-settings-usergroups.h b/source/ubl-settings-usergroups.h index 14da670..a5c0ceb 100644 --- a/source/ubl-settings-usergroups.h +++ b/source/ubl-settings-usergroups.h @@ -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 \ No newline at end of file diff --git a/ubl-settings-usergroups-additional-settings.glade b/ubl-settings-usergroups-additional-settings.glade index 954f8ef..749b5d4 100644 --- a/ubl-settings-usergroups-additional-settings.glade +++ b/ubl-settings-usergroups-additional-settings.glade @@ -10,54 +10,96 @@ - + - + + + + + + + + + + + + + True All groups in system - 1 - 65535 + 1 + 65535 True True + True + False + False + + False + False False Groups - 1000 - 6000 + 1000 + 6000 True False + False + False + False + + False + False False System groups - 500 - 999 + 500 + 999 True False + False + False + False + + False + False False Group GID range - 0 - 0 + + True False + False + True + True + + True + False False Group GID in system - 0 - 0 + + True False + False + True + False + + True + False @@ -68,54 +110,96 @@ - + - + + + + + + + + + + + + + True All system users - 1 - 65535 + 1 + 65535 True True + True + False + False + + False + False False Users - 1000 - 6000 + 1000 + 6000 True False + False + False + False + + False + False False System users - 500 - 999 + 500 + 999 True False + False + False + False + + False + False False Users UID range - 0 - 0 + + True False + False + True + True + + True + False False User UID in system - 0 - 0 + + True False + False + True + False + + True + False @@ -614,6 +698,7 @@ + 5 0 @@ -625,6 +710,7 @@ + 5 1 @@ -638,6 +724,8 @@ 5 + 6 + 7 2 @@ -651,6 +739,8 @@ 5 + 6 + 8 3 @@ -831,10 +921,11 @@ - + - + + 6 0 @@ -846,6 +937,7 @@ + 5 1 @@ -856,10 +948,11 @@ Minimum GID - True 5 + 6 + 7 2 @@ -870,10 +963,11 @@ Maximum GID - True 5 + 6 + 8 3