Исправил генерацию id

pull/24/head
Igor Belitskiy 2 years ago
parent 9f247724b2
commit 17c7f12923

@ -278,9 +278,10 @@ void temp_event(temp_set_window* temp_widgets) {
g_signal_connect(G_OBJECT(temp_widgets->quotegroupSizeHardLimitSpin), "changed", G_CALLBACK(update_max_size_spin), NULL);
if (strstr(flag_temp_u_g_p,"prjquota")) {
g_signal_connect(G_OBJECT(temp_widgets->btnReviewProject),"clicked",G_CALLBACK(wrapper_show_file_manager),NULL);
g_signal_connect(G_OBJECT(temp_widgets->btnGenerateProject),"clicked",G_CALLBACK(generate_id),NULL);
g_signal_connect(G_OBJECT(temp_widgets->btnGenerateProject),"clicked",G_CALLBACK(wrapper_generate_id),NULL);
g_signal_connect(G_OBJECT(temp_widgets->chbAuto),"toggled",G_CALLBACK(set_activ_project_id),NULL);
g_signal_connect(G_OBJECT(temp_widgets->entryCatalogProject), "changed", G_CALLBACK(temp_check_path), NULL);
g_signal_connect(G_OBJECT(temp_widgets->entryProjectId), "changed", G_CALLBACK(check_generate_id), NULL);
}
else {
g_signal_connect(G_OBJECT(temp_widgets->btnOpenUserGroup),"clicked",G_CALLBACK(wrapper_table_u_g_show),NULL);
@ -682,7 +683,8 @@ void table_u_g_event() {
}
config_u_g_p* get_temp_gui_data_base(config_u_g_p* _config) {
update_max_size_spin(NULL, NULL);
update_max_size_spin(NULL, NULL);
check_generate_id();
set_widget_config(temp_widgets->quotegroupSizeSoftLimitCheck,
temp_widgets->quotegroupSizeSoftLimitSpin,
temp_widgets->quotegroupSizeSoftLimitCombo,
@ -792,23 +794,51 @@ void set_widget_config(GtkWidget* check, GtkWidget* spin, GtkWidget* combo, size
}
}
}
void check_generate_id() {
g_signal_handlers_block_by_func(G_OBJECT(temp_widgets->entryProjectId), G_CALLBACK(check_generate_id), NULL);
int active = gtk_widget_get_sensitive(temp_widgets->entryProjectId);
if (active) {
char* text = (char*)gtk_entry_get_text(GTK_ENTRY(temp_widgets->entryProjectId));
if (strlen(text)) {
int id = atoi(text);
if (check_generate(vec_temp, id)) {
id = generate_id(vec_temp, id);
gtk_entry_set_text(GTK_ENTRY(temp_widgets->entryProjectId), yon_char_from_int(id));
}
}
}
g_signal_handlers_unblock_by_func(G_OBJECT(temp_widgets->entryProjectId), G_CALLBACK(check_generate_id), NULL);
}
void wrapper_generate_id() {
int id = generate_id(vec_temp, -1);
gtk_entry_set_text(GTK_ENTRY(temp_widgets->entryProjectId), yon_char_from_int(id));
}
void generate_id() {
int max_id = -1;
if (vec_temp->vectorList.total> 0) {
for (int index = 0; index < vec_temp->vectorList.total; index++) {
config_u_g_p* _config = (config_u_g_p*)vec_temp->pfVectorGet(vec_temp, index);
int generate_id(vector* _vec_temp, int max_id) {
if (_vec_temp->vectorList.total> 0) {
for (int index = 0; index < _vec_temp->vectorList.total; index++) {
config_u_g_p* _config = (config_u_g_p*)_vec_temp->pfVectorGet(_vec_temp, index);
if (_config->id > max_id) {
max_id = _config->id;
}
}
}
max_id++;
gtk_entry_set_text(GTK_ENTRY(temp_widgets->entryProjectId), yon_char_from_int(max_id));
return max_id;
}
int check_generate(vector* _vec_temp, int max_id) {
if (_vec_temp->vectorList.total> 0) {
for (int index = 0; index < _vec_temp->vectorList.total; index++) {
config_u_g_p* _config = (config_u_g_p*)_vec_temp->pfVectorGet(_vec_temp, index);
if (_config->id == max_id) {
return 1;
}
}
}
return 0;
}
void set_activ_project_id() {
gboolean active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(temp_widgets->chbAuto));
if (active) {

@ -37,7 +37,10 @@ config_u_g_p* get_temp_gui_data_base(config_u_g_p* _config);
void get_add_gui_data_base(config_all* all_config);
void get_edit_gui_data_base(config_all* all_config, int index);
void set_widget(GtkWidget* check, GtkWidget* spin, GtkWidget* combo, int value_spin, int pow_mem_size);
void generate_id();
int generate_id(vector* _vec_temp, int max_id);
void wrapper_generate_id();
int check_generate(vector* _vec_temp, int max_id);
void check_generate_id();
void set_activ_project_id();
int wrapper_check_save();
void block_btn_save();

Loading…
Cancel
Save