@ -6,57 +6,172 @@ config_settings_gui main_config;
config_all * all_config ;
void fill_tree_view_u_g_p ( custom_window * _config_gui , char * str_fill , GtkListStore * list , config_all * all_config , int flag_gui_add ) {
int fill_tree_view_project ( config_all * all_config , char * disk , GtkWidget * tree_view , char * str_fill , GtkListStore * list , int flag_gui_add ) {
GtkTreeModel * model = GTK_TREE_MODEL ( list ) ;
if ( flag_gui_add = = 0 ) {
g_object_ref ( list ) ;
gtk_list_store_clear ( list ) ;
}
int flag_searhc = 0 ;
for ( int i = 0 ; i < all_config - > v_u_g_p . pfVectorTotal ( & all_config - > v_u_g_p ) ; i + + ) {
GtkTreeIter iter ;
config_u_g_p * _config = ( config_u_g_p * ) all_config - > v_u_g_p . pfVectorGet ( & all_config - > v_u_g_p , i ) ;
if ( strcmp ( _config - > type_arr , str_fill ) = = 0 ) {
if ( strcmp ( _config - > type_arr , " prjquota " ) ! = 0 ) {
gtk_list_store_append ( list , & iter ) ;
char * deferring_size = wrapper_str_time ( _config - > deferring_size ) ;
char * deferring_file = wrapper_str_time ( _config - > deferring_file ) ;
gtk_list_store_set ( list , & iter ,
0 , _config - > actors ,
1 , _config - > quota ,
2 , _config - > size_memory ,
3 , philos_format_cfg_str_size_memory ( " " , _config - > soft_restriction_size , _config - > soft_restriction_size_pow ) ,
4 , philos_format_cfg_str_size_memory ( " " , _config - > soft_restriction_file , _config - > soft_restriction_file_pow ) ,
5 , philos_format_cfg_str_size_memory ( " " , _config - > severe_limitation_size , _config - > severe_limitation_size_pow ) ,
6 , _config - > files ,
7 , philos_format_cfg_str_size_memory ( " " , _config - > severe_limitation_file , _config - > severe_limitation_file_pow ) ,
8 , deferring_size ,
9 , deferring_file ,
- 1 ) ;
}
else {
gtk_list_store_append ( list , & iter ) ;
char * deferring_size = wrapper_str_time ( _config - > deferring_size ) ;
char * deferring_file = wrapper_str_time ( _config - > deferring_file ) ;
gtk_list_store_set ( list , & iter ,
0 , yon_char_from_int ( _config - > id ) ,
1 , _config - > actors ,
2 , _config - > quota ,
3 , _config - > size_memory ,
4 , philos_format_cfg_str_size_memory ( " " , _config - > soft_restriction_size , _config - > soft_restriction_size_pow ) ,
5 , philos_format_cfg_str_size_memory ( " " , _config - > soft_restriction_file , _config - > soft_restriction_file_pow ) ,
6 , philos_format_cfg_str_size_memory ( " " , _config - > severe_limitation_size , _config - > severe_limitation_size_pow ) ,
7 , _config - > files ,
8 , philos_format_cfg_str_size_memory ( " " , _config - > severe_limitation_file , _config - > severe_limitation_file_pow ) ,
9 , deferring_size ,
10 , deferring_file ,
- 1 ) ;
}
}
}
if ( strcmp ( _config - > type_arr , str_fill ) = = 0 & & strstr ( _config - > UNIX_file , disk ) ) {
GtkTreeIter iter ;
flag_searhc + + ;
gtk_list_store_append ( list , & iter ) ;
char * deferring_size = wrapper_str_time ( _config - > deferring_size ) ;
char * deferring_file = wrapper_str_time ( _config - > deferring_file ) ;
gtk_list_store_set ( list , & iter ,
0 , fill_tree_view_id ( _config - > id ) ,
1 , _config - > actors ,
2 , _config - > quota ,
3 , _config - > size_memory ,
4 , philos_format_cfg_str_size_memory ( " " , _config - > soft_restriction_size , _config - > soft_restriction_size_pow ) ,
5 , philos_format_cfg_str_size_memory ( " " , _config - > soft_restriction_file , _config - > soft_restriction_file_pow ) ,
6 , philos_format_cfg_str_size_memory ( " " , _config - > severe_limitation_size , _config - > severe_limitation_size_pow ) ,
7 , _config - > files ,
8 , philos_format_cfg_str_size_memory ( " " , _config - > severe_limitation_file , _config - > severe_limitation_file_pow ) ,
9 , deferring_size ,
10 , deferring_file ,
- 1 ) ;
}
}
if ( flag_gui_add ! = 0 ) {
gtk_tree_view_set_model ( GTK_TREE_VIEW ( _config_gui - > treeViewMain ) , model ) ;
gtk_tree_view_set_model ( GTK_TREE_VIEW ( tree_view ) , model ) ;
}
return flag_searhc ;
}
int fill_tree_view_user_group ( config_all * all_config , char * disk , GtkWidget * tree_view , char * str_fill , GtkListStore * list , int flag_gui_add ) {
GtkTreeModel * model = GTK_TREE_MODEL ( list ) ;
if ( flag_gui_add = = 0 ) {
g_object_ref ( list ) ;
gtk_list_store_clear ( list ) ;
}
int flag_searhc = 0 ;
for ( int i = 0 ; i < all_config - > v_u_g_p . pfVectorTotal ( & all_config - > v_u_g_p ) ; i + + ) {
config_u_g_p * _config = ( config_u_g_p * ) all_config - > v_u_g_p . pfVectorGet ( & all_config - > v_u_g_p , i ) ;
if ( strcmp ( _config - > type_arr , str_fill ) = = 0 & & strstr ( _config - > UNIX_file , disk ) ) {
GtkTreeIter iter ;
flag_searhc + + ;
gtk_list_store_append ( list , & iter ) ;
char * deferring_size = wrapper_str_time ( _config - > deferring_size ) ;
char * deferring_file = wrapper_str_time ( _config - > deferring_file ) ;
gtk_list_store_set ( list , & iter ,
0 , _config - > actors ,
1 , _config - > quota ,
2 , _config - > size_memory ,
3 , philos_format_cfg_str_size_memory ( " " , _config - > soft_restriction_size , _config - > soft_restriction_size_pow ) ,
4 , philos_format_cfg_str_size_memory ( " " , _config - > soft_restriction_file , _config - > soft_restriction_file_pow ) ,
5 , philos_format_cfg_str_size_memory ( " " , _config - > severe_limitation_size , _config - > severe_limitation_size_pow ) ,
6 , _config - > files ,
7 , philos_format_cfg_str_size_memory ( " " , _config - > severe_limitation_file , _config - > severe_limitation_file_pow ) ,
8 , deferring_size ,
9 , deferring_file ,
- 1 ) ;
}
}
if ( flag_gui_add ! = 0 ) {
gtk_tree_view_set_model ( GTK_TREE_VIEW ( tree_view ) , model ) ;
}
return flag_searhc ;
}
void entry_user_disk ( ) {
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 . tree_view , " usrquota " , cfg_custom_gui . user . liststore , 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 ( ) {
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 . tree_view , " grpquota " , cfg_custom_gui . group . liststore , 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 ( ) {
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_project ( all_config , activ_text , cfg_custom_gui . project . tree_view , " prjquota " , cfg_custom_gui . project . liststore , 0 ) ;
if ( find = = 0 ) {
g_object_ref ( cfg_custom_gui . project . liststore ) ;
gtk_list_store_clear ( cfg_custom_gui . project . liststore ) ;
}
}
void set_time_spin ( hotebook * widgets , size_t seconds_file , size_t seconds_size ) {
me_time t_file = time_convert ( seconds_file ) ;
me_time t_size = time_convert ( seconds_size ) ;
if ( seconds_file ! = - 1 ) {
gtk_spin_button_set_value ( GTK_SPIN_BUTTON ( widgets - > spinWeeksFile ) , t_file . weeks ) ;
gtk_spin_button_set_value ( GTK_SPIN_BUTTON ( widgets - > spinDaysFile ) , t_file . days ) ;
gtk_spin_button_set_value ( GTK_SPIN_BUTTON ( widgets - > spinHoursFile ) , t_file . hours ) ;
gtk_spin_button_set_value ( GTK_SPIN_BUTTON ( widgets - > spinMinutesFile ) , t_file . minutes ) ;
}
else {
gtk_spin_button_set_value ( GTK_SPIN_BUTTON ( widgets - > spinWeeksFile ) , 0 ) ;
gtk_spin_button_set_value ( GTK_SPIN_BUTTON ( widgets - > spinDaysFile ) , 0 ) ;
gtk_spin_button_set_value ( GTK_SPIN_BUTTON ( widgets - > spinHoursFile ) , 0 ) ;
gtk_spin_button_set_value ( GTK_SPIN_BUTTON ( widgets - > spinMinutesFile ) , 0 ) ;
}
if ( seconds_size ! = - 1 ) {
gtk_spin_button_set_value ( GTK_SPIN_BUTTON ( widgets - > spinWeeksSize ) , t_size . weeks ) ;
gtk_spin_button_set_value ( GTK_SPIN_BUTTON ( widgets - > spinDaysSize ) , t_size . days ) ;
gtk_spin_button_set_value ( GTK_SPIN_BUTTON ( widgets - > spinHoursSize ) , t_size . hours ) ;
gtk_spin_button_set_value ( GTK_SPIN_BUTTON ( widgets - > spinMinutesSize ) , t_size . minutes ) ;
}
else {
gtk_spin_button_set_value ( GTK_SPIN_BUTTON ( widgets - > spinWeeksSize ) , 0 ) ;
gtk_spin_button_set_value ( GTK_SPIN_BUTTON ( widgets - > spinDaysSize ) , 0 ) ;
gtk_spin_button_set_value ( GTK_SPIN_BUTTON ( widgets - > spinHoursSize ) , 0 ) ;
gtk_spin_button_set_value ( GTK_SPIN_BUTTON ( widgets - > spinMinutesSize ) , 0 ) ;
}
}
void tree_view_select ( hotebook * widgets ) {
tree_view_edit ( all_config , 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 ) ;
}
}
int tree_view_edit ( config_all * _all_config , hotebook * widgets ) {
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 ) ) {
all_config - > flag_set_data = 1 ;
all_config - > flag_save = 2 ;
char * str_iter = gtk_tree_model_get_string_from_iter ( model , & iter ) ;
index = atoi ( str_iter ) ;
_all_config - > v_u_g_p ;
config_u_g_p * _config = ( config_u_g_p * ) _all_config - > v_u_g_p . pfVectorGet ( & _all_config - > v_u_g_p , index ) ;
set_time_spin ( widgets , _config - > deferring_file , _config - > deferring_size ) ;
return 1 ;
}
else {
return 0 ;
}
}
@ -103,17 +218,11 @@ void wrapper_system_save() {
void load_system_cfg ( ) {
all_config - > flag_load = 0 ;
load_template_load_cfg ( all_config , CMD_LOAD_SYSTEM ) ;
fill_tree_view_u_g_p ( & cfg_custom_gui , " usrquota " , cfg_custom_gui . liststoreUser , all_config , 0 ) ;
fill_tree_view_u_g_p ( & cfg_custom_gui , " grpquota " , cfg_custom_gui . liststoreGroups , all_config , 0 ) ;
fill_tree_view_u_g_p ( & cfg_custom_gui , " prjquota " , cfg_custom_gui . liststoreProject , all_config , 0 ) ;
yon_ubl_status_box_render ( LOCAL_LOAD_SUCCESS_LABEL , BACKGROUND_IMAGE_SUCCESS_TYPE ) ;
}
void load_global_cfg ( ) {
all_config - > flag_load = 1 ;
fill_tree_view_u_g_p ( & cfg_custom_gui , " usrquota " , cfg_custom_gui . liststoreUser , all_config , 0 ) ;
fill_tree_view_u_g_p ( & cfg_custom_gui , " grpquota " , cfg_custom_gui . liststoreGroups , all_config , 0 ) ;
fill_tree_view_u_g_p ( & cfg_custom_gui , " prjquota " , cfg_custom_gui . liststoreProject , all_config , 0 ) ;
load_template_load_cfg ( all_config , CMD_LOAD_GLOBAL ) ;
yon_ubl_status_box_render ( LOCAL_LOAD_SUCCESS_LABEL , BACKGROUND_IMAGE_SUCCESS_TYPE ) ;
}
@ -124,17 +233,23 @@ void control_event(main_window* _config_main_gui, custom_window* _config_custom_
g_signal_connect ( G_OBJECT ( _config_main_gui - > SaveGlobalMenuItem ) , " activate " , G_CALLBACK ( wrapper_global_save ) , NULL ) ;
g_signal_connect ( G_OBJECT ( _config_main_gui - > SaveLocalMenuItem ) , " activate " , G_CALLBACK ( wrapper_system_save ) , NULL ) ;
g_signal_connect ( G_OBJECT ( _config_main_gui - > SaveMenuItem ) , " activate " , G_CALLBACK ( wrapper_all_save ) , NULL ) ;
g_signal_connect ( G_OBJECT ( _config_custom_gui - > btnAddUsers ) , " clicked " , G_CALLBACK ( wrapper_add_user_show ) , glade_path ) ;
g_signal_connect ( G_OBJECT ( _config_custom_gui - > btnEditUsers ) , " clicked " , G_CALLBACK ( wrapper_edit_user_show ) , glade_path ) ;
g_signal_connect ( G_OBJECT ( _config_custom_gui - > btnAddGroups ) , " clicked " , G_CALLBACK ( wrapper_add_group_show ) , glade_path ) ;
g_signal_connect ( G_OBJECT ( _config_custom_gui - > btnEditGroups ) , " clicked " , G_CALLBACK ( wrapper_edit_group_show ) , glade_path ) ;
g_signal_connect ( G_OBJECT ( _config_custom_gui - > btnAddProject ) , " clicked " , G_CALLBACK ( wrapper_add_project_show ) , glade_path ) ;
g_signal_connect ( G_OBJECT ( _config_custom_gui - > btnEditProjec t) , " clicked " , G_CALLBACK ( wrapper_edit_project_show ) , glade_path ) ;
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 - > 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 - > project. btnAdd) , " clicked " , G_CALLBACK ( wrapper_add_project_show ) , glade_path ) ;
g_signal_connect ( G_OBJECT ( _config_custom_gui - > user. btnEdit) , " clicked " , G_CALLBACK ( wrapper_edit_project_show ) , glade_path ) ;
g_signal_connect ( G_OBJECT ( _config_custom_gui - > btnFilterUsers ) , " clicked " , G_CALLBACK ( wrapper_filters_user_show ) , glade_path ) ;
g_signal_connect ( G_OBJECT ( _config_custom_gui - > btnFilterGroups ) , " clicked " , G_CALLBACK ( wrapper_filters_group_show ) , glade_path ) ;
g_signal_connect ( G_OBJECT ( _config_custom_gui - > btnFilterProject ) , " clicked " , G_CALLBACK ( wrapper_filters_project_show ) , 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 ) ;
g_signal_connect ( G_OBJECT ( _config_custom_gui - > user . comboBox ) , " changed " , G_CALLBACK ( entry_user_disk ) , NULL ) ;
g_signal_connect ( G_OBJECT ( _config_custom_gui - > group . comboBox ) , " changed " , G_CALLBACK ( entry_groups_disk ) , NULL ) ;
g_signal_connect ( G_OBJECT ( _config_custom_gui - > project . comboBox ) , " changed " , G_CALLBACK ( entry_project_disk ) , NULL ) ;
g_signal_connect ( G_OBJECT ( _config_custom_gui - > user . tree_view ) , " cursor-changed " , G_CALLBACK ( tree_view_select ) , & _config_custom_gui - > user ) ;
g_signal_connect ( G_OBJECT ( _config_custom_gui - > group . tree_view ) , " cursor-changed " , G_CALLBACK ( tree_view_select ) , & _config_custom_gui - > group ) ;
g_signal_connect ( G_OBJECT ( _config_custom_gui - > project . tree_view ) , " cursor-changed " , G_CALLBACK ( tree_view_select ) , & _config_custom_gui - > project ) ;
}
/*