Исправил файл связи всех функций

pull/24/head
Igor Belitskiy 2 years ago
parent 4467343fc6
commit 323315d78e

@ -7,21 +7,24 @@ config_all* all_config;
int index_selected = 0;
void wrapper_filters_user_show() {
filters_set_name("user");
filters_set_name("usrquota");
filters_show(NULL, glade_path);
}
void wrapper_filters_group_show() {
filters_set_name("group");
filters_set_name("grpquota");
filters_show(NULL, glade_path);
}
void wrapper_filters_project_show() {
filters_set_name("project");
filters_set_name("prjquota");
filters_show(NULL, glade_path);
}
void wrapper_add_user_show() {
set_temp_menu("user", "add");
char* activ_text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(cfg_custom_gui.user.comboBox));
activ_text= yon_char_divide_search(activ_text, " ", -1);
set_disk(activ_text);
set_temp_menu("usrquota", "add");
set_all_config(all_config);
set_vector(&all_config->v_user);
temp_show(NULL, glade_path);
@ -31,8 +34,9 @@ void wrapper_add_user_show() {
}
void wrapper_edit_user_show() {
int index = wrapper_select_tree_view(&cfg_custom_gui.user);
set_temp_menu("user", "edit");
temp_set_index(index_selected);
printf("%d\n", index);
set_temp_menu("usrquota", "edit");
temp_set_index(index);
set_all_config(all_config);
temp_show(NULL, glade_path);
set_vector(&all_config->v_user);
@ -42,7 +46,10 @@ void wrapper_edit_user_show() {
}
void wrapper_add_group_show() {
set_temp_menu("group", "add");
char* activ_text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(cfg_custom_gui.group.comboBox));
activ_text= yon_char_divide_search(activ_text, " ", -1);
set_disk(activ_text);
set_temp_menu("grpquota", "add");
set_all_config(all_config);
set_vector(&all_config->v_group);
temp_show(NULL, glade_path);
@ -51,8 +58,8 @@ void wrapper_add_group_show() {
}
void wrapper_edit_group_show() {
int index = wrapper_select_tree_view(&cfg_custom_gui.group);
set_temp_menu("group", "edit");
temp_set_index(index_selected);
set_temp_menu("grpquota", "edit");
temp_set_index(index);
set_all_config(all_config);
set_vector(&all_config->v_group);
temp_show(NULL, glade_path);
@ -61,7 +68,7 @@ void wrapper_edit_group_show() {
g_signal_connect(G_OBJECT(get_widget_temp()->btnSaveTempSave),"clicked",G_CALLBACK(entry_groups_disk),&i);
}
void wrapper_add_project_show() {
set_temp_menu("project", "add");
set_temp_menu("prjquota", "add");
set_all_config(all_config);
set_vector(&all_config->v_project);
temp_show(NULL, glade_path);
@ -70,8 +77,8 @@ void wrapper_add_project_show() {
}
void wrapper_edit_project_show() {
int index = wrapper_select_tree_view(&cfg_custom_gui.project);
set_temp_menu("project", "edit");
temp_set_index(index_selected);
set_temp_menu("prjquota", "edit");
temp_set_index(index);
set_all_config(all_config);
temp_show(NULL, glade_path);
set_vector(&all_config->v_project);
@ -80,42 +87,62 @@ void wrapper_edit_project_show() {
g_signal_connect(G_OBJECT(get_widget_temp()->btnSaveTempSave),"clicked",G_CALLBACK(entry_project_disk),&i);
}
void block_spin_time(hotebook* widgets,void (*f)()) {
g_signal_handlers_block_by_func(G_OBJECT(widgets->spinWeeksSize), G_CALLBACK(f), NULL);
g_signal_handlers_block_by_func(G_OBJECT(widgets->spinDaysSize), G_CALLBACK(f), NULL);
g_signal_handlers_block_by_func(G_OBJECT(widgets->spinHoursSize), G_CALLBACK(f), NULL);
g_signal_handlers_block_by_func(G_OBJECT(widgets->spinMinutesSize), G_CALLBACK(f), NULL);
g_signal_handlers_block_by_func(G_OBJECT(widgets->spinWeeksFile), G_CALLBACK(f), NULL);
g_signal_handlers_block_by_func(G_OBJECT(widgets->spinDaysFile), G_CALLBACK(f), NULL);
g_signal_handlers_block_by_func(G_OBJECT(widgets->spinHoursFile), G_CALLBACK(f), NULL);
g_signal_handlers_block_by_func(G_OBJECT(widgets->spinMinutesFile), G_CALLBACK(f), NULL);
}
void unlock_spin_time(hotebook* widgets,void (*f)()) {
g_signal_handlers_unblock_by_func(G_OBJECT(widgets->spinWeeksSize), G_CALLBACK(f), NULL);
g_signal_handlers_unblock_by_func(G_OBJECT(widgets->spinDaysSize), G_CALLBACK(f), NULL);
g_signal_handlers_unblock_by_func(G_OBJECT(widgets->spinHoursSize), G_CALLBACK(f), NULL);
g_signal_handlers_unblock_by_func(G_OBJECT(widgets->spinMinutesSize), G_CALLBACK(f), NULL);
g_signal_handlers_unblock_by_func(G_OBJECT(widgets->spinWeeksFile), G_CALLBACK(f), NULL);
g_signal_handlers_unblock_by_func(G_OBJECT(widgets->spinDaysFile), G_CALLBACK(f), NULL);
g_signal_handlers_unblock_by_func(G_OBJECT(widgets->spinHoursFile), G_CALLBACK(f), NULL);
g_signal_handlers_unblock_by_func(G_OBJECT(widgets->spinMinutesFile), G_CALLBACK(f), NULL);
}
void entry_user_disk(GtkWidget *self,int* flag_update) {
if (flag_update) {
temp_on_destroy_subwindow(self);
}
char* activ_text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(cfg_custom_gui.user.comboBox));
activ_text= yon_char_divide_search(activ_text, " ", -1);
int find = fill_tree_view_user_group(all_config, activ_text, &cfg_custom_gui.user,"usrquota", 0);
if (find >= 0) {
if (find == 0) {
g_object_ref(cfg_custom_gui.user.liststore);
gtk_list_store_clear(cfg_custom_gui.user.liststore);
}
}
void entry_groups_disk(GtkWidget *self,int* flag_update) {
if (flag_update) {
temp_on_destroy_subwindow(self);
}
}
void entry_groups_disk(GtkWidget *self,int* flag_update) {
char* activ_text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(cfg_custom_gui.group.comboBox));
activ_text= yon_char_divide_search(activ_text, " ", -1);
int find = fill_tree_view_user_group(all_config, activ_text, &cfg_custom_gui.group,"grpquota", 0);
if (find >= 0) {
if (find == 0) {
g_object_ref(cfg_custom_gui.group.liststore);
gtk_list_store_clear(cfg_custom_gui.group.liststore);
}
}
void entry_project_disk(GtkWidget *self,int* flag_update) {
if (flag_update) {
temp_on_destroy_subwindow(self);
}
}
void entry_project_disk(GtkWidget *self,int* flag_update) {
int find = fill_tree_view_project(all_config, &cfg_custom_gui.project,"prjquota", 0);
if (find >= 0) {
if (find == 0) {
g_object_ref(cfg_custom_gui.project.liststore);
gtk_list_store_clear(cfg_custom_gui.project.liststore);
}
if (flag_update) {
temp_on_destroy_subwindow(self);
}
}
void tree_view_select_user(GtkWidget* self) {
@ -131,40 +158,122 @@ void tree_view_select_project(GtkWidget* self) {
void tree_view_select(GtkWidget* self, vector* vec_temp, hotebook* widgets) {
if (self) {}
tree_view_edit(all_config, vec_temp, widgets);
GtkTreeIter iter;
GtkTreeModel *model = GTK_TREE_MODEL(widgets->liststore);
GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->tree_view));
if(gtk_tree_selection_get_selected(selection, &model, &iter)) {
gtk_widget_set_sensitive(widgets->btnAdd,1);
gtk_widget_set_sensitive(widgets->btnDel,1);
gtk_widget_set_sensitive(widgets->btnEdit,1);
}
else {
if (main_config.lock_save_global == 0 || main_config.lock_save_local == 0) {
if (vec_temp->vectorList.total > 0) {
tree_view_edit(all_config, vec_temp, widgets);
GtkTreeIter iter;
GtkTreeModel *model = GTK_TREE_MODEL(widgets->liststore);
GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->tree_view));
if(gtk_tree_selection_get_selected(selection, &model, &iter)) {
gtk_widget_set_sensitive(widgets->btnAdd,1);
gtk_widget_set_sensitive(widgets->btnDel,1);
gtk_widget_set_sensitive(widgets->btnEdit,1);
}
else {
if (main_config.lock_save_global == 0 || main_config.lock_save_local == 0) {
gtk_widget_set_sensitive(widgets->btnAdd,1);
}
gtk_widget_set_sensitive(widgets->btnDel,0);
gtk_widget_set_sensitive(widgets->btnEdit,0);
}
gtk_widget_set_sensitive(widgets->btnDel,0);
gtk_widget_set_sensitive(widgets->btnEdit,0);
}
}
}
void wrapper_get_spin_time_gui_user() {
get_spin_time_gui(&all_config->v_user , &cfg_custom_gui.user);
entry_user_disk(0, 0);
}
void wrapper_get_spin_time_gui_group() {
get_spin_time_gui(&all_config->v_group ,&cfg_custom_gui.group);
entry_groups_disk(0, 0);
}
void wrapper_get_spin_time_gui_project() {
get_spin_time_gui(&all_config->v_project , &cfg_custom_gui.project);
entry_project_disk(0, 0);
}
void get_spin_time_gui(vector* vec_u_g_p, hotebook* widgets) {
if (index_selected != -1) {
config_u_g_p* _config = (config_u_g_p*)vec_u_g_p->pfVectorGet(vec_u_g_p, index_selected);
int spin_week_size = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widgets->spinWeeksSize));
int spin_days_size = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widgets->spinDaysSize));
int spin_hours_size = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widgets->spinHoursSize));
int spin_minutes_size = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widgets->spinMinutesSize));
int second_size = spin_week_size*7*24*3600+spin_days_size*24*3600+spin_hours_size*3600+spin_minutes_size*60;
int spin_week_file = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widgets->spinWeeksFile));
int spin_days_file = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widgets->spinDaysFile));
int spin_hours_file = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widgets->spinHoursFile));
int spin_minutes_file = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widgets->spinMinutesFile));
int second_file = spin_week_file*7*24*3600+spin_days_file*24*3600+spin_hours_file*3600+spin_minutes_file*60;
_config->deferring_size = second_size;
_config->deferring_file = second_file;
vec_u_g_p->pfVectorSet(vec_u_g_p, index_selected, _config);
set_time_spin(widgets,_config->deferring_file, _config->deferring_size);
}
}
void template_remove(vector* vec_temp, hotebook* widgets) {
int index = wrapper_select_tree_view(widgets);
if (index!=-1) {
config_u_g_p* _config = (config_u_g_p*)vec_temp->pfVectorGet(vec_temp, index);
model_clear_cfg(_config);
vec_temp->pfVectorDelete(vec_temp, index);
}
}
void user_remove() {
GtkTreeIter iter;
GtkTreeModel *model = GTK_TREE_MODEL(cfg_custom_gui.user.liststore);
GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(cfg_custom_gui.user.tree_view));
if(gtk_tree_selection_get_selected(selection, &model, &iter)) {
gtk_list_store_remove(cfg_custom_gui.user.liststore, &iter);
}
template_remove(&all_config->v_user , &cfg_custom_gui.user);
}
void group_remove() {
GtkTreeIter iter;
GtkTreeModel *model = GTK_TREE_MODEL(cfg_custom_gui.group.liststore);
GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(cfg_custom_gui.group.tree_view));
if(gtk_tree_selection_get_selected(selection, &model, &iter)) {
gtk_list_store_remove(cfg_custom_gui.group.liststore, &iter);
}
template_remove(&all_config->v_group ,&cfg_custom_gui.group);
}
void project_remove() {
GtkTreeIter iter;
GtkTreeModel *model = GTK_TREE_MODEL(cfg_custom_gui.project.liststore);
GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(cfg_custom_gui.project.tree_view));
if(gtk_tree_selection_get_selected(selection, &model, &iter)) {
gtk_list_store_remove(cfg_custom_gui.project.liststore, &iter);
}
template_remove(&all_config->v_project , &cfg_custom_gui.project);
}
int wrapper_select_tree_view(hotebook* widgets) {
block_spin_time(widgets, wrapper_get_spin_time_gui_user);
block_spin_time(widgets, wrapper_get_spin_time_gui_group);
block_spin_time(widgets, wrapper_get_spin_time_gui_project);
int index = 0;
GtkTreeIter iter;
GtkTreeModel *model = GTK_TREE_MODEL(widgets->liststore);
GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->tree_view));
if(gtk_tree_selection_get_selected(selection, &model, &iter)) {
char* str_iter = gtk_tree_model_get_string_from_iter(model, &iter);
index = atoi(str_iter);
index_selected = index;
return index;
}
else {
return -1;
//index_selected = -1;
}
unlock_spin_time(widgets, wrapper_get_spin_time_gui_user);
unlock_spin_time(widgets, wrapper_get_spin_time_gui_group);
unlock_spin_time(widgets, wrapper_get_spin_time_gui_project);
return index;
}
void wrapper_all_save() {
@ -229,11 +338,13 @@ void control_event(main_window* _config_main_gui, custom_window* _config_custom_
g_signal_connect(G_OBJECT(_config_main_gui->SaveMenuItem), "activate", G_CALLBACK(wrapper_all_save), NULL);
g_signal_connect(G_OBJECT(_config_custom_gui->user.btnAdd),"clicked",G_CALLBACK(wrapper_add_user_show), glade_path);
g_signal_connect(G_OBJECT(_config_custom_gui->user.btnEdit),"clicked",G_CALLBACK(wrapper_edit_user_show), glade_path);
g_signal_connect(G_OBJECT(_config_custom_gui->user.btnDel),"clicked",G_CALLBACK(user_remove), glade_path);
g_signal_connect(G_OBJECT(_config_custom_gui->group.btnAdd),"clicked",G_CALLBACK(wrapper_add_group_show), glade_path);
g_signal_connect(G_OBJECT(_config_custom_gui->group.btnEdit),"clicked",G_CALLBACK(wrapper_edit_group_show), glade_path);
g_signal_connect(G_OBJECT(_config_custom_gui->group.btnDel),"clicked",G_CALLBACK(group_remove), glade_path);
g_signal_connect(G_OBJECT(_config_custom_gui->project.btnAdd),"clicked",G_CALLBACK(wrapper_add_project_show), glade_path);
g_signal_connect(G_OBJECT(_config_custom_gui->project.btnEdit),"clicked",G_CALLBACK(wrapper_edit_project_show), glade_path);
g_signal_connect(G_OBJECT(_config_custom_gui->project.btnDel),"clicked",G_CALLBACK(project_remove), glade_path);
g_signal_connect(G_OBJECT(_config_custom_gui->user.btnFilter),"clicked",G_CALLBACK(wrapper_filters_user_show), glade_path);
g_signal_connect(G_OBJECT(_config_custom_gui->group.btnFilter),"clicked",G_CALLBACK(wrapper_filters_group_show), glade_path);
g_signal_connect(G_OBJECT(_config_custom_gui->project.btnFilter),"clicked",G_CALLBACK(wrapper_filters_project_show), glade_path);
@ -243,6 +354,33 @@ void control_event(main_window* _config_main_gui, custom_window* _config_custom_
g_signal_connect(G_OBJECT(_config_custom_gui->user.tree_view), "cursor-changed", G_CALLBACK(tree_view_select_user), NULL);
g_signal_connect(G_OBJECT(_config_custom_gui->group.tree_view), "cursor-changed", G_CALLBACK(tree_view_select_group), NULL);
g_signal_connect(G_OBJECT(_config_custom_gui->project.tree_view), "cursor-changed", G_CALLBACK(tree_view_select_project), NULL);
g_signal_connect(G_OBJECT(_config_custom_gui->user.spinWeeksSize), "value-changed", G_CALLBACK(wrapper_get_spin_time_gui_user), NULL);
g_signal_connect(G_OBJECT(_config_custom_gui->user.spinDaysSize), "value-changed", G_CALLBACK(wrapper_get_spin_time_gui_user), NULL);
g_signal_connect(G_OBJECT(_config_custom_gui->user.spinHoursSize), "value-changed", G_CALLBACK(wrapper_get_spin_time_gui_user), NULL);
g_signal_connect(G_OBJECT(_config_custom_gui->user.spinMinutesSize), "value-changed", G_CALLBACK(wrapper_get_spin_time_gui_user), NULL);
g_signal_connect(G_OBJECT(_config_custom_gui->user.spinWeeksFile), "value-changed", G_CALLBACK(wrapper_get_spin_time_gui_user), NULL);
g_signal_connect(G_OBJECT(_config_custom_gui->user.spinDaysFile), "value-changed", G_CALLBACK(wrapper_get_spin_time_gui_user), NULL);
g_signal_connect(G_OBJECT(_config_custom_gui->user.spinHoursFile), "value-changed", G_CALLBACK(wrapper_get_spin_time_gui_user), NULL);
g_signal_connect(G_OBJECT(_config_custom_gui->user.spinMinutesFile), "value-changed", G_CALLBACK(wrapper_get_spin_time_gui_user), NULL);
g_signal_connect(G_OBJECT(_config_custom_gui->group.spinWeeksSize), "value-changed", G_CALLBACK(wrapper_get_spin_time_gui_group), NULL);
g_signal_connect(G_OBJECT(_config_custom_gui->group.spinDaysSize), "value-changed", G_CALLBACK(wrapper_get_spin_time_gui_group), NULL);
g_signal_connect(G_OBJECT(_config_custom_gui->group.spinHoursSize), "value-changed", G_CALLBACK(wrapper_get_spin_time_gui_group), NULL);
g_signal_connect(G_OBJECT(_config_custom_gui->group.spinMinutesSize), "value-changed", G_CALLBACK(wrapper_get_spin_time_gui_group), NULL);
g_signal_connect(G_OBJECT(_config_custom_gui->group.spinWeeksFile), "value-changed", G_CALLBACK(wrapper_get_spin_time_gui_group), NULL);
g_signal_connect(G_OBJECT(_config_custom_gui->group.spinDaysFile), "value-changed", G_CALLBACK(wrapper_get_spin_time_gui_group), NULL);
g_signal_connect(G_OBJECT(_config_custom_gui->group.spinHoursFile), "value-changed", G_CALLBACK(wrapper_get_spin_time_gui_group), NULL);
g_signal_connect(G_OBJECT(_config_custom_gui->group.spinMinutesFile), "value-changed", G_CALLBACK(wrapper_get_spin_time_gui_group), NULL);
g_signal_connect(G_OBJECT(_config_custom_gui->project.spinWeeksSize), "value-changed", G_CALLBACK(wrapper_get_spin_time_gui_project), NULL);
g_signal_connect(G_OBJECT(_config_custom_gui->project.spinDaysSize), "value-changed", G_CALLBACK(wrapper_get_spin_time_gui_project), NULL);
g_signal_connect(G_OBJECT(_config_custom_gui->project.spinHoursSize), "value-changed", G_CALLBACK(wrapper_get_spin_time_gui_project), NULL);
g_signal_connect(G_OBJECT(_config_custom_gui->project.spinMinutesSize), "value-changed", G_CALLBACK(wrapper_get_spin_time_gui_project), NULL);
g_signal_connect(G_OBJECT(_config_custom_gui->project.spinWeeksFile), "value-changed", G_CALLBACK(wrapper_get_spin_time_gui_project), NULL);
g_signal_connect(G_OBJECT(_config_custom_gui->project.spinDaysFile), "value-changed", G_CALLBACK(wrapper_get_spin_time_gui_project), NULL);
g_signal_connect(G_OBJECT(_config_custom_gui->project.spinHoursFile), "value-changed", G_CALLBACK(wrapper_get_spin_time_gui_project), NULL);
g_signal_connect(G_OBJECT(_config_custom_gui->project.spinMinutesFile), "value-changed", G_CALLBACK(wrapper_get_spin_time_gui_project), NULL);
}
/*
@ -349,7 +487,7 @@ int main(int argc, char *argv[]){
gtk_init(&argc,&argv);
main_window *widgets = setup_window(&cfg_main_gui,&cfg_custom_gui);
filters_set_name("project");
filters_set_name("prjquota");
filters_init_flag();
control_event(widgets, &cfg_custom_gui);
yon_ubl_header_setup_resource(widgets->HeadOverlay,widgets->HeadBox,widgets->HeadImage,banner_path);

@ -24,5 +24,11 @@ void wrapper_edit_project_show();
void wrapper_filters_user_show();
void wrapper_filters_group_show();
void wrapper_filters_project_show();
void wrapper_get_spin_time_gui_user();
void wrapper_get_spin_time_gui_group();
void wrapper_get_spin_time_gui_project();
void get_spin_time_gui(vector* vec_u_g_p, hotebook* widgets);
void tree_view_select(GtkWidget* self, vector* vec_temp, hotebook* widgets);
void block_spin_time(hotebook* widgets,void (*f)());
void unlock_spin_time(hotebook* widgets,void (*f)());

Loading…
Cancel
Save