Merge pull request 'Fixed quota saving and editng' (#72) from YanTheKaller/ubl-settings-resourcequota:master into master

Reviewed-on: #72
master v2.35
Dmitry Razumov 1 month ago
commit eb0ede883c

@ -72,8 +72,9 @@ void on_quota_configuration_update(GtkWidget *, quota_window *window){
char *read_devices = ""; char *read_devices = "";
dictionary *dict; dictionary *dict;
for_dictionaries(dict,window->devices){ for_dictionaries(dict,window->devices){
if (dict->data&&yon_dictionary_get_data(dict,device_limits*)->read) device_limits *limits = yon_dictionary_get_data(dict,device_limits*);
if (!strstr(yon_dictionary_get_data(dict,device_limits*)->read," 0 ")) if (dict->data&&limits->read)
if (!strstr(limits->read," 0 "))
read_devices = yon_char_unite(read_devices,"IOReadBandwidthMax=",yon_char_divide_search(yon_char_new(dict->key)," ",-1)," ",yon_dictionary_get_data(dict,device_limits*)->read,",",NULL); read_devices = yon_char_unite(read_devices,"IOReadBandwidthMax=",yon_char_divide_search(yon_char_new(dict->key)," ",-1)," ",yon_dictionary_get_data(dict,device_limits*)->read,",",NULL);
} }
if (read_devices[strlen(read_devices)-1]==',') read_devices[strlen(read_devices)-1]='\0'; if (read_devices[strlen(read_devices)-1]==',') read_devices[strlen(read_devices)-1]='\0';
@ -83,8 +84,9 @@ void on_quota_configuration_update(GtkWidget *, quota_window *window){
char *write_limit = ""; char *write_limit = "";
char *write_devices = ""; char *write_devices = "";
for_dictionaries(dict,window->devices){ for_dictionaries(dict,window->devices){
if (dict->data&&yon_dictionary_get_data(dict,device_limits*)->write) device_limits *limits = yon_dictionary_get_data(dict,device_limits*);
if (!strstr(yon_dictionary_get_data(dict,device_limits*)->write," 0 ")) if (dict->data&&limits->write)
if (!strstr(limits->write," 0 "))
write_devices = yon_char_unite(write_devices,"IOWriteBandwidthMax=",yon_char_divide_search(yon_char_new(dict->key)," ",-1)," ",yon_dictionary_get_data(dict,device_limits*)->write,",",NULL); write_devices = yon_char_unite(write_devices,"IOWriteBandwidthMax=",yon_char_divide_search(yon_char_new(dict->key)," ",-1)," ",yon_dictionary_get_data(dict,device_limits*)->write,",",NULL);
} }
if (write_devices[strlen(write_devices)-1]==',') write_devices[strlen(write_devices)-1]='\0'; if (write_devices[strlen(write_devices)-1]==',') write_devices[strlen(write_devices)-1]='\0';
@ -260,10 +262,10 @@ void on_device_set(GtkWidget *self, quota_window *window){
} }
char *value_str = yon_char_from_long(value); char *value_str = yon_char_from_long(value);
char *full_str = yon_char_unite(value_str,yon_size_get_mod(gtk_combo_box_get_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo))),NULL); char *full_str = yon_char_unite(value_str,yon_size_get_mod(gtk_combo_box_get_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo))),NULL);
if (!yon_char_is_empty(limits->read)) free(limits->read); if (!yon_char_is_empty(limits->write)) free(limits->write);
limits->read=full_str; limits->write=full_str;
} else { } else {
limits->read=NULL; limits->write=NULL;
} }
} }
} }
@ -279,9 +281,17 @@ void on_device_current_changed(GtkWidget *, quota_window *window){
char *read = limits->read; char *read = limits->read;
char *write = limits->write; char *write = limits->write;
if (!yon_char_is_empty(read)) { if (!yon_char_is_empty(read)) {
int size_mult = yon_get_size_get_from_letter(read[strlen(read)-1]);
long hard_current_max = main_config.avaliable_ram;
for (int i=0;i<size_mult+1;i++)
hard_current_max=hard_current_max/1024;
gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(window->DeviceLimitReadSpin)),hard_current_max);
g_signal_handlers_block_by_func(G_OBJECT(window->DeviceLimitReadSpin),G_CALLBACK(on_device_set),window);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitReadSpin),atoi(read)); gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitReadSpin),atoi(read));
g_signal_handlers_unblock_by_func(G_OBJECT(window->DeviceLimitReadSpin),G_CALLBACK(on_device_set),window);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitReadCheck),1); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitReadCheck),1);
switch (read[strlen(read)-1]){ switch (read[strlen(read)-1]){
default:
case 'K': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),0); case 'K': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),0);
break; break;
case 'M': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),1); case 'M': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),1);
@ -297,9 +307,17 @@ void on_device_current_changed(GtkWidget *, quota_window *window){
gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),0); gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),0);
} }
if (!yon_char_is_empty(write)) { if (!yon_char_is_empty(write)) {
int size_mult = yon_get_size_get_from_letter(write[strlen(write)-1]);
long hard_current_max = main_config.avaliable_ram;
for (int i=0;i<size_mult+1;i++)
hard_current_max=hard_current_max/1024;
gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(window->DeviceLimitWriteSpin)),hard_current_max);
g_signal_handlers_block_by_func(G_OBJECT(window->DeviceLimitWriteSpin),G_CALLBACK(on_device_set),window);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitWriteSpin),atoi(write)); gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitWriteSpin),atoi(write));
g_signal_handlers_unblock_by_func(G_OBJECT(window->DeviceLimitWriteSpin),G_CALLBACK(on_device_set),window);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitWriteCheck),1); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitWriteCheck),1);
switch (write[strlen(write)-1]){ switch (write[strlen(write)-1]){
default:
case 'K': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),0); case 'K': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),0);
break; break;
case 'M': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),1); case 'M': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),1);
@ -340,26 +358,30 @@ void on_quotas_save(GtkWidget *self, dictionary *windows){
char *hard = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->HardRestrictionCheck)) ? yon_char_append(yon_char_from_long(gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->HardRestrictionSpin))),get_size_mod(GTK_COMBO_BOX(window->HardRestrictionCombo))) : NULL; char *hard = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->HardRestrictionCheck)) ? yon_char_append(yon_char_from_long(gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->HardRestrictionSpin))),get_size_mod(GTK_COMBO_BOX(window->HardRestrictionCombo))) : NULL;
char *paging = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->PagingLimitCheck)) ? yon_char_append(yon_char_from_long(gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->PagingLimitSpin))),get_size_mod(GTK_COMBO_BOX(window->PagingLimitCombo))) : NULL; char *paging = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->PagingLimitCheck)) ? yon_char_append(yon_char_from_long(gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->PagingLimitSpin))),get_size_mod(GTK_COMBO_BOX(window->PagingLimitCombo))) : NULL;
char *cpu = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->CpuLimitCheck)) ? yon_char_append(yon_char_from_long(gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->CpuLimitSpin))),"%") : NULL; char *cpu = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->CpuLimitCheck)) ? yon_char_append(yon_char_from_long(gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->CpuLimitSpin))),"%") : NULL;
char *read_limit = NULL;
char *read_devices = NULL; int size_read=0;
int size_write=0;
config_str limits_read = NULL;
config_str limits_write = NULL;
dictionary *dict; dictionary *dict;
for_dictionaries(dict,window->devices){ for_dictionaries(dict,window->devices){
if (dict->data&&yon_dictionary_get_data(dict,device_limits*)->read) device_limits *limit = yon_dictionary_get_data(dict,device_limits*);
read_devices = yon_char_unite(read_devices?read_devices:"","",yon_char_divide_search(yon_char_new(dict->key)," ",-1)," ",yon_dictionary_get_data(dict,device_limits*)->read,"\n",NULL); if (limit&&limit->read){
char *temp = yon_char_unite(dict->key," ",limit->read,NULL);
yon_char_parsed_add_or_create_if_exists(limits_read,&size_read,temp);
free(temp);
}
if (limit&&limit->write){
char *temp = yon_char_unite(dict->key," ",limit->write,NULL);
yon_char_parsed_add_or_create_if_exists(limits_write,&size_write,temp);
free(temp);
}
} }
if (!yon_char_is_empty(read_devices)&&read_devices[strlen(read_devices)-1]=='\n') read_devices[strlen(read_devices)-1]='\0';
read_limit = yon_char_unite(read_limit?read_limit:"",read_devices,NULL);
char *write_limit = NULL;
char *write_devices = NULL;
for_dictionaries(dict,window->devices){
if (dict->data&&yon_dictionary_get_data(dict,device_limits*)->write)
write_devices = yon_char_unite(write_devices?write_devices:"","",yon_char_divide_search(yon_char_new(dict->key)," ",-1)," ",yon_dictionary_get_data(dict,device_limits*)->write,"\n",NULL);
}
if (!yon_char_is_empty(write_devices)&&write_devices[strlen(write_devices)-1]=='\n') write_devices[strlen(write_devices)-1]='\0';
write_limit = yon_char_unite(write_limit?write_limit:"",write_devices,NULL);
gtk_list_store_append(main_config.list,&iter); gtk_list_store_append(main_config.list,&iter);
gtk_list_store_set(main_config.list,&iter,0,type,1,target,2,soft,3,hard,4,paging,5,cpu,6,read_limit,7,write_limit,8,string,-1); gtk_list_store_set(main_config.list,&iter,0,type,1,target,2,soft,3,hard,4,paging,5,cpu,6,yon_char_parsed_to_string(limits_read,size_read,"\n"),7,yon_char_parsed_to_string(limits_write,size_write,"\n"),8,string,-1);
yon_char_parsed_free(limits_read,size_read);
yon_char_parsed_free(limits_write,size_write);
yon_config_register(CGROUP_QUOTA((char*)target),CGROUP_QUOTA_comd((char*)target),yon_char_new((char*)string)); yon_config_register(CGROUP_QUOTA((char*)target),CGROUP_QUOTA_comd((char*)target),yon_char_new((char*)string));
on_subwindow_close(self); on_subwindow_close(self);
yon_ubl_status_box_render(SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); yon_ubl_status_box_render(SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
@ -704,66 +726,15 @@ void on_filters_opened(GtkWidget *, main_window *widgets) {
} }
void on_add_open(GtkWidget *, main_window *widgets){ void on_add_open(GtkWidget *, main_window *widgets){
GtkBuilder *builder = gtk_builder_new_from_resource(glade_quota_path); quota_window *window = yon_quota_window_new();
quota_window *window = g_malloc0(sizeof(quota_window));
window->Window = yon_gtk_builder_get_widget(builder,"QuotasWindow");
window->TitleLabel = yon_gtk_builder_get_widget(builder,"TitleLabel");
window->StatusBox = yon_gtk_builder_get_widget(builder,"StatusBox");
window->BlockUiBox = yon_gtk_builder_get_widget(builder,"BlockUiBox");
window->TargetTypeCombo = yon_gtk_builder_get_widget(builder,"TargetTypeCombo");
window->AddQuotaTargetBox = yon_gtk_builder_get_widget(builder,"AddQuotaTargetBox");
window->EditQuotaTargetBox = yon_gtk_builder_get_widget(builder,"EditQuotaTargetBox");
window->TargetCombo = yon_gtk_builder_get_widget(builder,"TargetCombo");
window->TargetLabel = yon_gtk_builder_get_widget(builder,"TargetLabel");
window->SoftRestrictionCheck = yon_gtk_builder_get_widget(builder,"SoftRestrictionCheck");
window->SoftRestrictionSpin = yon_gtk_builder_get_widget(builder,"SoftRestrictionSpin");
window->SoftRestrictionCombo = yon_gtk_builder_get_widget(builder,"SoftRestrictionCombo");
window->HardRestrictionCheck = yon_gtk_builder_get_widget(builder,"HardRestrictionCheck");
window->HardRestrictionSpin = yon_gtk_builder_get_widget(builder,"HardRestrictionSpin");
window->HardRestrictionCombo = yon_gtk_builder_get_widget(builder,"HardRestrictionCombo");
window->PagingLimitCheck = yon_gtk_builder_get_widget(builder,"PagingLimitCheck");
window->PagingLimitSpin = yon_gtk_builder_get_widget(builder,"PagingLimitSpin");
window->PagingLimitCombo = yon_gtk_builder_get_widget(builder,"PagingLimitCombo");
window->CpuLimitCheck = yon_gtk_builder_get_widget(builder,"CpuLimitCheck");
window->CpuLimitSpin = yon_gtk_builder_get_widget(builder,"CpuLimitSpin");
window->DeviceLimitCombo = yon_gtk_builder_get_widget(builder,"DeviceLimitCombo");
window->DeviceLimitReadCheck = yon_gtk_builder_get_widget(builder,"DeviceLimitReadCheck");
window->DeviceLimitReadSpin = yon_gtk_builder_get_widget(builder,"DeviceLimitReadSpin");
window->DeviceLimitReadCombo = yon_gtk_builder_get_widget(builder,"DeviceLimitReadCombo");
window->DeviceLimitWriteCheck = yon_gtk_builder_get_widget(builder,"DeviceLimitWriteCheck");
window->DeviceLimitWriteSpin = yon_gtk_builder_get_widget(builder,"DeviceLimitWriteSpin");
window->DeviceLimitWriteCombo = yon_gtk_builder_get_widget(builder,"DeviceLimitWriteCombo");
window->ApplyChangesButton = yon_gtk_builder_get_widget(builder,"ApplyChangesButton");
window->ManualInputEntry = yon_gtk_builder_get_widget(builder,"ManualInputEntry");
window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton");
window->SaveButton = yon_gtk_builder_get_widget(builder,"SaveButton");
window->devices = NULL;
gtk_window_set_title(GTK_WINDOW(window->Window),TITLE_LABEL); gtk_window_set_title(GTK_WINDOW(window->Window),TITLE_LABEL);
struct sysinfo inf;
sysinfo(&inf);
main_config.avaliable_ram=inf.totalram;
main_config.avaliable_swap=inf.totalswap;
main_config.cores = sysconf(_SC_NPROCESSORS_ONLN);
dictionary *windows = NULL; dictionary *windows = NULL;
yon_dictionary_add_or_create_if_exists_with_data(windows,"window",window); yon_dictionary_add_or_create_if_exists_with_data(windows,"window",window);
yon_dictionary_add_or_create_if_exists_with_data(windows,"widgets",widgets); yon_dictionary_add_or_create_if_exists_with_data(windows,"widgets",widgets);
g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL);
g_signal_connect(G_OBJECT(window->SaveButton),"clicked",G_CALLBACK(on_quotas_save),windows); g_signal_connect(G_OBJECT(window->SaveButton),"clicked",G_CALLBACK(on_quotas_save),windows);
g_signal_connect(G_OBJECT(window->TargetTypeCombo),"changed",G_CALLBACK(on_quota_target_type_changed),window);
gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(window->SoftRestrictionSpin)),main_config.avaliable_ram); gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(window->SoftRestrictionSpin)),main_config.avaliable_ram);
gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(window->HardRestrictionSpin)),main_config.avaliable_ram); gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(window->HardRestrictionSpin)),main_config.avaliable_ram);
@ -772,82 +743,6 @@ void on_add_open(GtkWidget *, main_window *widgets){
gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(window->DeviceLimitReadSpin)),main_config.avaliable_ram); gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(window->DeviceLimitReadSpin)),main_config.avaliable_ram);
gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(window->DeviceLimitWriteSpin)),main_config.avaliable_ram); gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(window->DeviceLimitWriteSpin)),main_config.avaliable_ram);
g_signal_connect(G_OBJECT(window->DeviceLimitCombo),"changed",G_CALLBACK(on_device_current_changed),window);
g_signal_connect(G_OBJECT(window->DeviceLimitReadCheck),"toggled",G_CALLBACK(on_device_set),window);
g_signal_connect(G_OBJECT(window->DeviceLimitReadSpin),"value-changed",G_CALLBACK(on_device_set),window);
g_signal_connect(G_OBJECT(window->DeviceLimitReadCombo),"changed",G_CALLBACK(on_device_set),window);
g_signal_connect(G_OBJECT(window->DeviceLimitWriteCheck),"toggled",G_CALLBACK(on_device_set),window);
g_signal_connect(G_OBJECT(window->DeviceLimitWriteSpin),"value-changed",G_CALLBACK(on_device_set),window);
g_signal_connect(G_OBJECT(window->DeviceLimitWriteCombo),"changed",G_CALLBACK(on_device_set),window);
g_signal_connect(G_OBJECT(window->TargetCombo),"changed",G_CALLBACK(on_target_check_chosen),window);
g_signal_connect(G_OBJECT(window->SoftRestrictionSpin),"change-value",G_CALLBACK(on_check_maximum),window->SoftRestrictionCombo);
g_signal_connect(G_OBJECT(window->SoftRestrictionCombo),"changed",G_CALLBACK(on_check_maximum),window->SoftRestrictionSpin);
g_signal_connect(G_OBJECT(window->HardRestrictionSpin),"change-value",G_CALLBACK(on_check_maximum),window->HardRestrictionCombo);
g_signal_connect(G_OBJECT(window->HardRestrictionCombo),"changed",G_CALLBACK(on_check_maximum),window->HardRestrictionSpin);
g_signal_connect(G_OBJECT(window->PagingLimitSpin),"change-value",G_CALLBACK(on_check_maximum_cpu),window->PagingLimitCombo);
g_signal_connect(G_OBJECT(window->PagingLimitCombo),"changed",G_CALLBACK(on_check_maximum_cpu),window->PagingLimitSpin);
g_signal_connect(G_OBJECT(window->DeviceLimitReadSpin),"change-value",G_CALLBACK(on_check_maximum),window->DeviceLimitReadCombo);
g_signal_connect(G_OBJECT(window->DeviceLimitReadCombo),"changed",G_CALLBACK(on_check_maximum),window->DeviceLimitReadSpin);
g_signal_connect(G_OBJECT(window->DeviceLimitWriteSpin),"change-value",G_CALLBACK(on_check_maximum),window->DeviceLimitWriteCombo);
g_signal_connect(G_OBJECT(window->DeviceLimitWriteCombo),"changed",G_CALLBACK(on_check_maximum),window->DeviceLimitWriteSpin);
g_signal_connect(G_OBJECT(window->SoftRestrictionCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->SoftRestrictionCombo);
g_signal_connect(G_OBJECT(window->SoftRestrictionCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->SoftRestrictionSpin);
g_signal_connect(G_OBJECT(window->HardRestrictionCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->HardRestrictionCombo);
g_signal_connect(G_OBJECT(window->HardRestrictionCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->HardRestrictionSpin);
g_signal_connect(G_OBJECT(window->PagingLimitCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->PagingLimitCombo);
g_signal_connect(G_OBJECT(window->PagingLimitCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->PagingLimitSpin);
g_signal_connect(G_OBJECT(window->CpuLimitCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->CpuLimitSpin);
g_signal_connect(G_OBJECT(window->DeviceLimitReadCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->DeviceLimitReadCombo);
g_signal_connect(G_OBJECT(window->DeviceLimitReadCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->DeviceLimitReadSpin);
g_signal_connect(G_OBJECT(window->DeviceLimitWriteCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->DeviceLimitWriteCombo);
g_signal_connect(G_OBJECT(window->DeviceLimitWriteCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->DeviceLimitWriteSpin);
g_signal_connect(G_OBJECT(window->DeviceLimitCombo),"changed",G_CALLBACK(yon_widget_set_sensitive),window->DeviceLimitReadCheck);
g_signal_connect(G_OBJECT(window->DeviceLimitCombo),"changed",G_CALLBACK(yon_widget_set_sensitive),window->DeviceLimitWriteCheck);
g_signal_connect(G_OBJECT(window->SoftRestrictionSpin),"output",G_CALLBACK(on_quota_configuration_update),window);
g_signal_connect(G_OBJECT(window->SoftRestrictionCombo),"changed",G_CALLBACK(on_quota_configuration_update),window);
g_signal_connect(G_OBJECT(window->HardRestrictionSpin),"output",G_CALLBACK(on_quota_configuration_update),window);
g_signal_connect(G_OBJECT(window->HardRestrictionCombo),"changed",G_CALLBACK(on_quota_configuration_update),window);
g_signal_connect(G_OBJECT(window->PagingLimitSpin),"output",G_CALLBACK(on_quota_configuration_update),window);
g_signal_connect(G_OBJECT(window->PagingLimitCombo),"changed",G_CALLBACK(on_quota_configuration_update),window);
g_signal_connect(G_OBJECT(window->CpuLimitSpin),"output",G_CALLBACK(on_quota_configuration_update),window);
g_signal_connect(G_OBJECT(window->DeviceLimitReadSpin),"output",G_CALLBACK(on_quota_configuration_update),window);
g_signal_connect(G_OBJECT(window->DeviceLimitReadCombo),"changed",G_CALLBACK(on_quota_configuration_update),window);
g_signal_connect(G_OBJECT(window->DeviceLimitWriteSpin),"output",G_CALLBACK(on_quota_configuration_update),window);
g_signal_connect(G_OBJECT(window->DeviceLimitWriteCombo),"changed",G_CALLBACK(on_quota_configuration_update),window);
g_signal_connect(G_OBJECT(window->SoftRestrictionCheck),"toggled",G_CALLBACK(on_quota_configuration_update),window);
g_signal_connect(G_OBJECT(window->HardRestrictionCheck),"toggled",G_CALLBACK(on_quota_configuration_update),window);
g_signal_connect(G_OBJECT(window->PagingLimitCheck),"toggled",G_CALLBACK(on_quota_configuration_update),window);
g_signal_connect(G_OBJECT(window->CpuLimitCheck),"toggled",G_CALLBACK(on_quota_configuration_update),window);
g_signal_connect(G_OBJECT(window->DeviceLimitReadCheck),"toggled",G_CALLBACK(on_quota_configuration_update),window);
g_signal_connect(G_OBJECT(window->DeviceLimitWriteCheck),"toggled",G_CALLBACK(on_quota_configuration_update),window);
g_signal_connect(G_OBJECT(window->ManualInputEntry),"activate",G_CALLBACK(on_quota_manual_input),window);
g_signal_connect(G_OBJECT(window->ManualInputEntry),"focus-out-event",G_CALLBACK(on_quota_manual_input_focus),window);
yon_get_devices(window);
dictionary *dict;
for_dictionaries(dict,window->devices){
char *temp = yon_char_new(yon_dictionary_get_data(dict,device_limits*)->device_name);
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(window->DeviceLimitCombo),dict->key,temp);
}
main_config.users = yon_ubl_get_all_users(&main_config.users_size);
main_config.processes = yon_config_load(get_processes_command,&main_config.processes_size);
main_config.slices = yon_config_load(get_slices_command,&main_config.slices_size);
for(int i=0;i<main_config.users_size;i++){
yon_char_remove_last_symbol(main_config.users[i],'\n');
}
for(int i=0;i<main_config.processes_size;i++){
yon_char_remove_last_symbol(main_config.processes[i],'\n');
}
for(int i=0;i<main_config.slices_size;i++){
yon_char_remove_last_symbol(main_config.slices[i],'\n');
}
for (int i=0; i<main_config.users_size;i++){
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(window->TargetCombo),main_config.users[i]);
}
gtk_widget_show(window->Window); gtk_widget_show(window->Window);
} }
@ -963,274 +858,327 @@ void yon_widget_set_sensitive(GtkComboBox *toggle, GtkWidget *target){
} }
} }
void on_edit_open(GtkWidget *, main_window *widgets){ void on_manual_edit(GtkWidget *, quota_window *window){
GtkTreeModel *model = GTK_TREE_MODEL(main_config.list); yon_quota_update(window);
GtkTreeIter iter; }
if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree)),&model,&iter)){
char *type;
char *target;
char *soft;
char *hard;
char *swap;
char *cpu;
char *read;
char *write;
int soft_size=-1;
int hard_size=-1;
int swap_size=-1;
gtk_tree_model_get(model,&iter,0,&type,1,&target,2,&soft,3,&hard,4,&swap,5,&cpu,6,&read,7,&write,-1);
if (soft&&strcmp(soft,"")!=0){
soft_size = yon_get_size_request_from_letter(soft[strlen(soft)-1]);
soft[strlen(soft)-1]='\0';
}
if (hard&&strcmp(hard,"")!=0){
hard_size=yon_get_size_request_from_letter(hard[strlen(hard)-1]);
hard[strlen(hard)-1]='\0';
}
if (swap&&strcmp(swap,"")!=0){
swap_size=yon_get_size_request_from_letter(swap[strlen(swap)-1]);
swap[strlen(swap)-1]='\0';
}
GtkBuilder *builder = gtk_builder_new_from_resource(glade_quota_path); quota_window *yon_quota_window_new(){
quota_window *window = g_malloc0(sizeof(quota_window)); GtkBuilder *builder = gtk_builder_new_from_resource(glade_quota_path);
quota_window *window = g_malloc0(sizeof(quota_window));
window->Window = yon_gtk_builder_get_widget(builder,"QuotasWindow");
window->Window = yon_gtk_builder_get_widget(builder,"QuotasWindow");
window->TitleLabel = yon_gtk_builder_get_widget(builder,"TitleLabel");
window->StatusBox = yon_gtk_builder_get_widget(builder,"StatusBox"); window->TitleLabel = yon_gtk_builder_get_widget(builder,"TitleLabel");
window->BlockUiBox = yon_gtk_builder_get_widget(builder,"BlockUiBox"); window->StatusBox = yon_gtk_builder_get_widget(builder,"StatusBox");
window->TargetTypeCombo = yon_gtk_builder_get_widget(builder,"TargetTypeCombo"); window->BlockUiBox = yon_gtk_builder_get_widget(builder,"BlockUiBox");
window->AddQuotaTargetBox = yon_gtk_builder_get_widget(builder,"AddQuotaTargetBox"); window->TargetTypeCombo = yon_gtk_builder_get_widget(builder,"TargetTypeCombo");
window->EditQuotaTargetBox = yon_gtk_builder_get_widget(builder,"EditQuotaTargetBox"); window->AddQuotaTargetBox = yon_gtk_builder_get_widget(builder,"AddQuotaTargetBox");
window->TargetCombo = yon_gtk_builder_get_widget(builder,"TargetCombo"); window->EditQuotaTargetBox = yon_gtk_builder_get_widget(builder,"EditQuotaTargetBox");
window->TargetLabel = yon_gtk_builder_get_widget(builder,"TargetLabel"); window->TargetCombo = yon_gtk_builder_get_widget(builder,"TargetCombo");
window->TypeLabel = yon_gtk_builder_get_widget(builder,"TypeLabel"); window->TargetLabel = yon_gtk_builder_get_widget(builder,"TargetLabel");
window->TypeLabel = yon_gtk_builder_get_widget(builder,"TypeLabel");
window->SoftRestrictionCheck = yon_gtk_builder_get_widget(builder,"SoftRestrictionCheck");
window->SoftRestrictionSpin = yon_gtk_builder_get_widget(builder,"SoftRestrictionSpin"); window->SoftRestrictionCheck = yon_gtk_builder_get_widget(builder,"SoftRestrictionCheck");
window->SoftRestrictionCombo = yon_gtk_builder_get_widget(builder,"SoftRestrictionCombo"); window->SoftRestrictionSpin = yon_gtk_builder_get_widget(builder,"SoftRestrictionSpin");
window->SoftRestrictionCombo = yon_gtk_builder_get_widget(builder,"SoftRestrictionCombo");
window->HardRestrictionCheck = yon_gtk_builder_get_widget(builder,"HardRestrictionCheck");
window->HardRestrictionSpin = yon_gtk_builder_get_widget(builder,"HardRestrictionSpin"); window->HardRestrictionCheck = yon_gtk_builder_get_widget(builder,"HardRestrictionCheck");
window->HardRestrictionCombo = yon_gtk_builder_get_widget(builder,"HardRestrictionCombo"); window->HardRestrictionSpin = yon_gtk_builder_get_widget(builder,"HardRestrictionSpin");
window->HardRestrictionCombo = yon_gtk_builder_get_widget(builder,"HardRestrictionCombo");
window->PagingLimitCheck = yon_gtk_builder_get_widget(builder,"PagingLimitCheck");
window->PagingLimitSpin = yon_gtk_builder_get_widget(builder,"PagingLimitSpin"); window->PagingLimitCheck = yon_gtk_builder_get_widget(builder,"PagingLimitCheck");
window->PagingLimitCombo = yon_gtk_builder_get_widget(builder,"PagingLimitCombo"); window->PagingLimitSpin = yon_gtk_builder_get_widget(builder,"PagingLimitSpin");
window->PagingLimitCombo = yon_gtk_builder_get_widget(builder,"PagingLimitCombo");
window->CpuLimitCheck = yon_gtk_builder_get_widget(builder,"CpuLimitCheck");
window->CpuLimitSpin = yon_gtk_builder_get_widget(builder,"CpuLimitSpin"); window->CpuLimitCheck = yon_gtk_builder_get_widget(builder,"CpuLimitCheck");
window->CpuLimitSpin = yon_gtk_builder_get_widget(builder,"CpuLimitSpin");
window->DeviceLimitCombo = yon_gtk_builder_get_widget(builder,"DeviceLimitCombo");
window->DeviceLimitCombo = yon_gtk_builder_get_widget(builder,"DeviceLimitCombo");
window->DeviceLimitReadCheck = yon_gtk_builder_get_widget(builder,"DeviceLimitReadCheck");
window->DeviceLimitReadSpin = yon_gtk_builder_get_widget(builder,"DeviceLimitReadSpin"); window->DeviceLimitReadCheck = yon_gtk_builder_get_widget(builder,"DeviceLimitReadCheck");
window->DeviceLimitReadCombo = yon_gtk_builder_get_widget(builder,"DeviceLimitReadCombo"); window->DeviceLimitReadSpin = yon_gtk_builder_get_widget(builder,"DeviceLimitReadSpin");
window->DeviceLimitReadCombo = yon_gtk_builder_get_widget(builder,"DeviceLimitReadCombo");
window->DeviceLimitWriteCheck = yon_gtk_builder_get_widget(builder,"DeviceLimitWriteCheck");
window->DeviceLimitWriteSpin = yon_gtk_builder_get_widget(builder,"DeviceLimitWriteSpin"); window->DeviceLimitWriteCheck = yon_gtk_builder_get_widget(builder,"DeviceLimitWriteCheck");
window->DeviceLimitWriteCombo = yon_gtk_builder_get_widget(builder,"DeviceLimitWriteCombo"); window->DeviceLimitWriteSpin = yon_gtk_builder_get_widget(builder,"DeviceLimitWriteSpin");
window->ApplyChangesButton = yon_gtk_builder_get_widget(builder,"ApplyChangesButton"); window->DeviceLimitWriteCombo = yon_gtk_builder_get_widget(builder,"DeviceLimitWriteCombo");
window->ManualInputEntry = yon_gtk_builder_get_widget(builder,"ManualInputEntry"); window->ApplyChangesButton = yon_gtk_builder_get_widget(builder,"ApplyChangesButton");
window->ManualInputEntry = yon_gtk_builder_get_widget(builder,"ManualInputEntry");
window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton");
window->SaveButton = yon_gtk_builder_get_widget(builder,"SaveButton"); window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton");
window->SaveButton = yon_gtk_builder_get_widget(builder,"SaveButton");
window->devices = NULL;
window->devices = NULL;
gtk_window_set_title(GTK_WINDOW(window->Window),EDITING_LABEL); g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL);
gtk_label_set_text(GTK_LABEL(window->TitleLabel),EDITING_LABEL); g_signal_connect(G_OBJECT(window->SoftRestrictionCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->SoftRestrictionCombo);
g_signal_connect(G_OBJECT(window->SoftRestrictionCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->SoftRestrictionSpin);
gtk_widget_show(window->EditQuotaTargetBox); g_signal_connect(G_OBJECT(window->HardRestrictionCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->HardRestrictionCombo);
gtk_widget_hide(window->AddQuotaTargetBox); g_signal_connect(G_OBJECT(window->HardRestrictionCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->HardRestrictionSpin);
struct sysinfo inf; g_signal_connect(G_OBJECT(window->PagingLimitCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->PagingLimitCombo);
sysinfo(&inf); g_signal_connect(G_OBJECT(window->PagingLimitCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->PagingLimitSpin);
main_config.avaliable_ram=inf.totalram; g_signal_connect(G_OBJECT(window->CpuLimitCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->CpuLimitSpin);
main_config.avaliable_swap=inf.totalswap; g_signal_connect(G_OBJECT(window->DeviceLimitReadCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->DeviceLimitReadCombo);
main_config.cores = sysconf(_SC_NPROCESSORS_ONLN); g_signal_connect(G_OBJECT(window->DeviceLimitReadCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->DeviceLimitReadSpin);
dictionary *windows = NULL; g_signal_connect(G_OBJECT(window->DeviceLimitWriteCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->DeviceLimitWriteCombo);
yon_dictionary_add_or_create_if_exists_with_data(windows,"window",window); g_signal_connect(G_OBJECT(window->DeviceLimitWriteCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->DeviceLimitWriteSpin);
yon_dictionary_add_or_create_if_exists_with_data(windows,"widgets",widgets); g_signal_connect(G_OBJECT(window->DeviceLimitCombo),"changed",G_CALLBACK(yon_widget_set_sensitive),window->DeviceLimitReadCheck);
g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); g_signal_connect(G_OBJECT(window->DeviceLimitCombo),"changed",G_CALLBACK(yon_widget_set_sensitive),window->DeviceLimitWriteCheck);
g_signal_connect(G_OBJECT(window->SaveButton),"clicked",G_CALLBACK(on_quotas_edit),windows); g_signal_connect(G_OBJECT(window->DeviceLimitWriteCombo),"changed",G_CALLBACK(on_check_maximum),window->DeviceLimitWriteSpin);
g_signal_connect(G_OBJECT(window->DeviceLimitReadCombo),"changed",G_CALLBACK(on_check_maximum),window->DeviceLimitReadSpin);
g_signal_connect(G_OBJECT(window->TargetTypeCombo),"changed",G_CALLBACK(on_quota_target_type_changed),window); gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitCombo),0);
g_signal_connect(G_OBJECT(window->DeviceLimitCombo),"changed",G_CALLBACK(on_device_current_changed),window);
long swap_current_max = main_config.avaliable_swap; g_signal_connect(G_OBJECT(window->DeviceLimitReadCheck),"toggled",G_CALLBACK(on_device_set),window);
for (int i=0;i<swap_size+1;i++) g_signal_connect(G_OBJECT(window->DeviceLimitReadSpin),"value-changed",G_CALLBACK(on_device_set),window);
swap_current_max=swap_current_max/1024; g_signal_connect(G_OBJECT(window->DeviceLimitReadCombo),"changed",G_CALLBACK(on_device_set),window);
g_signal_connect(G_OBJECT(window->DeviceLimitWriteCheck),"toggled",G_CALLBACK(on_device_set),window);
long soft_current_max = main_config.avaliable_ram; g_signal_connect(G_OBJECT(window->DeviceLimitWriteSpin),"value-changed",G_CALLBACK(on_device_set),window);
for (int i=0;i<soft_size+1;i++) g_signal_connect(G_OBJECT(window->DeviceLimitWriteCombo),"changed",G_CALLBACK(on_device_set),window);
soft_current_max=soft_current_max/1024; g_signal_connect(G_OBJECT(window->TargetCombo),"changed",G_CALLBACK(on_target_check_chosen),window);
g_signal_connect(G_OBJECT(window->SoftRestrictionSpin),"change-value",G_CALLBACK(on_check_maximum),window->SoftRestrictionCombo);
long hard_current_max = main_config.avaliable_ram; g_signal_connect(G_OBJECT(window->SoftRestrictionCombo),"changed",G_CALLBACK(on_check_maximum),window->SoftRestrictionSpin);
for (int i=0;i<hard_size+1;i++) g_signal_connect(G_OBJECT(window->HardRestrictionSpin),"change-value",G_CALLBACK(on_check_maximum),window->HardRestrictionCombo);
hard_current_max=hard_current_max/1024; g_signal_connect(G_OBJECT(window->HardRestrictionCombo),"changed",G_CALLBACK(on_check_maximum),window->HardRestrictionSpin);
g_signal_connect(G_OBJECT(window->PagingLimitSpin),"change-value",G_CALLBACK(on_check_maximum_cpu),window->PagingLimitCombo);
gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(window->SoftRestrictionSpin)),soft_current_max); g_signal_connect(G_OBJECT(window->PagingLimitCombo),"changed",G_CALLBACK(on_check_maximum_cpu),window->PagingLimitSpin);
gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(window->HardRestrictionSpin)),hard_current_max); g_signal_connect(G_OBJECT(window->DeviceLimitReadSpin),"change-value",G_CALLBACK(on_check_maximum),window->DeviceLimitReadCombo);
gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(window->PagingLimitSpin)),swap_current_max); g_signal_connect(G_OBJECT(window->DeviceLimitWriteSpin),"change-value",G_CALLBACK(on_check_maximum),window->DeviceLimitWriteCombo);
gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(window->CpuLimitSpin)),main_config.cores*100);
g_signal_connect(G_OBJECT(window->SoftRestrictionSpin),"output",G_CALLBACK(on_quota_configuration_update),window);
g_signal_connect(G_OBJECT(window->SoftRestrictionCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->SoftRestrictionCombo); g_signal_connect(G_OBJECT(window->SoftRestrictionCombo),"changed",G_CALLBACK(on_quota_configuration_update),window);
g_signal_connect(G_OBJECT(window->SoftRestrictionCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->SoftRestrictionSpin); g_signal_connect(G_OBJECT(window->HardRestrictionSpin),"output",G_CALLBACK(on_quota_configuration_update),window);
g_signal_connect(G_OBJECT(window->HardRestrictionCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->HardRestrictionCombo); g_signal_connect(G_OBJECT(window->HardRestrictionCombo),"changed",G_CALLBACK(on_quota_configuration_update),window);
g_signal_connect(G_OBJECT(window->HardRestrictionCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->HardRestrictionSpin); g_signal_connect(G_OBJECT(window->PagingLimitSpin),"output",G_CALLBACK(on_quota_configuration_update),window);
g_signal_connect(G_OBJECT(window->PagingLimitCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->PagingLimitCombo); g_signal_connect(G_OBJECT(window->PagingLimitCombo),"changed",G_CALLBACK(on_quota_configuration_update),window);
g_signal_connect(G_OBJECT(window->PagingLimitCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->PagingLimitSpin); g_signal_connect(G_OBJECT(window->CpuLimitSpin),"output",G_CALLBACK(on_quota_configuration_update),window);
g_signal_connect(G_OBJECT(window->CpuLimitCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->CpuLimitSpin); g_signal_connect(G_OBJECT(window->DeviceLimitReadSpin),"output",G_CALLBACK(on_quota_configuration_update),window);
g_signal_connect(G_OBJECT(window->DeviceLimitReadCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->DeviceLimitReadCombo); g_signal_connect(G_OBJECT(window->DeviceLimitReadCombo),"changed",G_CALLBACK(on_quota_configuration_update),window);
g_signal_connect(G_OBJECT(window->DeviceLimitReadCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->DeviceLimitReadSpin); g_signal_connect(G_OBJECT(window->DeviceLimitWriteSpin),"output",G_CALLBACK(on_quota_configuration_update),window);
g_signal_connect(G_OBJECT(window->DeviceLimitWriteCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->DeviceLimitWriteCombo); g_signal_connect(G_OBJECT(window->DeviceLimitWriteCombo),"changed",G_CALLBACK(on_quota_configuration_update),window);
g_signal_connect(G_OBJECT(window->DeviceLimitWriteCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->DeviceLimitWriteSpin); g_signal_connect(G_OBJECT(window->SoftRestrictionCheck),"toggled",G_CALLBACK(on_quota_configuration_update),window);
g_signal_connect(G_OBJECT(window->HardRestrictionCheck),"toggled",G_CALLBACK(on_quota_configuration_update),window);
g_signal_connect(G_OBJECT(window->DeviceLimitCombo),"changed",G_CALLBACK(yon_widget_set_sensitive),window->DeviceLimitReadCheck); g_signal_connect(G_OBJECT(window->PagingLimitCheck),"toggled",G_CALLBACK(on_quota_configuration_update),window);
g_signal_connect(G_OBJECT(window->DeviceLimitCombo),"changed",G_CALLBACK(yon_widget_set_sensitive),window->DeviceLimitWriteCheck); g_signal_connect(G_OBJECT(window->CpuLimitCheck),"toggled",G_CALLBACK(on_quota_configuration_update),window);
g_signal_connect(G_OBJECT(window->DeviceLimitReadCheck),"toggled",G_CALLBACK(on_quota_configuration_update),window);
yon_get_devices(window); g_signal_connect(G_OBJECT(window->DeviceLimitWriteCheck),"toggled",G_CALLBACK(on_quota_configuration_update),window);
dictionary *dict; g_signal_connect(G_OBJECT(window->TargetTypeCombo),"changed",G_CALLBACK(on_quota_target_type_changed),window);
gtk_widget_set_sensitive(window->BlockUiBox,1); g_signal_connect(G_OBJECT(window->ManualInputEntry),"changed",G_CALLBACK(on_manual_edit),window);
gtk_label_set_text(GTK_LABEL(window->TypeLabel),type);
gtk_label_set_text(GTK_LABEL(window->TargetLabel),target); yon_get_devices(window);
int read_size=0; window->devices=window->devices->first;
config_str read_parsed = yon_char_parse(read,&read_size,"\n");
int write_size=0; dictionary *dict;
config_str write_parsed = yon_char_parse(write,&write_size,"\n"); for_dictionaries(dict,window->devices){
for_dictionaries(dict,window->devices){ char *temp = yon_char_new(yon_dictionary_get_data(dict,device_limits*)->device_name);
char *temp = yon_char_new(yon_dictionary_get_data(dict,device_limits*)->device_name); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(window->DeviceLimitCombo),dict->key,temp);
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(window->DeviceLimitCombo),dict->key,temp); }
if (read_parsed) main_config.users = yon_ubl_get_all_users(&main_config.users_size);
for (int i=0; i<read_size;i++){ main_config.processes = yon_config_load(get_processes_command,&main_config.processes_size);
char *read_limit = yon_char_new(read_parsed[i]); main_config.slices = yon_config_load(get_slices_command,&main_config.slices_size);
char *read_cur = yon_char_divide_search(read_limit," ",-1); for(int i=0;i<main_config.users_size;i++){
if (strstr(temp,read_cur)){ yon_char_remove_last_symbol(main_config.users[i],'\n');
if(!dict->data){ }
dict->data = g_malloc0(sizeof(device_limits)); for(int i=0;i<main_config.processes_size;i++){
((device_limits*)dict->data)->write=NULL; yon_char_remove_last_symbol(main_config.processes[i],'\n');
((device_limits*)dict->data)->read=NULL; }
} for(int i=0;i<main_config.slices_size;i++){
((device_limits*)dict->data)->read=read_limit; yon_char_remove_last_symbol(main_config.slices[i],'\n');
} }
for (int i=0; i<main_config.users_size;i++){
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(window->TargetCombo),main_config.users[i]);
}
struct sysinfo inf;
sysinfo(&inf);
main_config.avaliable_ram=inf.totalram;
main_config.avaliable_swap=inf.totalswap;
main_config.cores = sysconf(_SC_NPROCESSORS_ONLN);
gtk_widget_show(window->Window);
return window;
}
void yon_quota_update(quota_window *window){
g_signal_handlers_block_by_func(G_OBJECT(window->SoftRestrictionSpin),G_CALLBACK(on_quota_configuration_update),window);
g_signal_handlers_block_by_func(G_OBJECT(window->SoftRestrictionCombo),G_CALLBACK(on_quota_configuration_update),window);
g_signal_handlers_block_by_func(G_OBJECT(window->HardRestrictionSpin),G_CALLBACK(on_quota_configuration_update),window);
g_signal_handlers_block_by_func(G_OBJECT(window->HardRestrictionCombo),G_CALLBACK(on_quota_configuration_update),window);
g_signal_handlers_block_by_func(G_OBJECT(window->PagingLimitSpin),G_CALLBACK(on_quota_configuration_update),window);
g_signal_handlers_block_by_func(G_OBJECT(window->PagingLimitCombo),G_CALLBACK(on_quota_configuration_update),window);
g_signal_handlers_block_by_func(G_OBJECT(window->CpuLimitSpin),G_CALLBACK(on_quota_configuration_update),window);
g_signal_handlers_block_by_func(G_OBJECT(window->DeviceLimitReadSpin),G_CALLBACK(on_quota_configuration_update),window);
g_signal_handlers_block_by_func(G_OBJECT(window->DeviceLimitReadCombo),G_CALLBACK(on_quota_configuration_update),window);
g_signal_handlers_block_by_func(G_OBJECT(window->DeviceLimitWriteSpin),G_CALLBACK(on_quota_configuration_update),window);
g_signal_handlers_block_by_func(G_OBJECT(window->DeviceLimitWriteCombo),G_CALLBACK(on_quota_configuration_update),window);
g_signal_handlers_block_by_func(G_OBJECT(window->SoftRestrictionCheck),G_CALLBACK(on_quota_configuration_update),window);
g_signal_handlers_block_by_func(G_OBJECT(window->HardRestrictionCheck),G_CALLBACK(on_quota_configuration_update),window);
g_signal_handlers_block_by_func(G_OBJECT(window->PagingLimitCheck),G_CALLBACK(on_quota_configuration_update),window);
g_signal_handlers_block_by_func(G_OBJECT(window->CpuLimitCheck),G_CALLBACK(on_quota_configuration_update),window);
g_signal_handlers_block_by_func(G_OBJECT(window->DeviceLimitReadCheck),G_CALLBACK(on_quota_configuration_update),window);
g_signal_handlers_block_by_func(G_OBJECT(window->DeviceLimitWriteCheck),G_CALLBACK(on_quota_configuration_update),window);
g_signal_handlers_block_by_func(G_OBJECT(window->TargetTypeCombo),G_CALLBACK(on_quota_target_type_changed),window);
g_signal_handlers_block_by_func(G_OBJECT(window->DeviceLimitReadCheck),G_CALLBACK(on_device_set),window);
g_signal_handlers_block_by_func(G_OBJECT(window->DeviceLimitReadSpin),G_CALLBACK(on_device_set),window);
g_signal_handlers_block_by_func(G_OBJECT(window->DeviceLimitReadCombo),G_CALLBACK(on_device_set),window);
g_signal_handlers_block_by_func(G_OBJECT(window->DeviceLimitWriteCheck),G_CALLBACK(on_device_set),window);
g_signal_handlers_block_by_func(G_OBJECT(window->DeviceLimitWriteSpin),G_CALLBACK(on_device_set),window);
g_signal_handlers_block_by_func(G_OBJECT(window->DeviceLimitWriteCombo),G_CALLBACK(on_device_set),window);
char *parameter = yon_char_new(gtk_entry_get_text(GTK_ENTRY(window->ManualInputEntry)));
int size;
config_str parsed = yon_char_parse(parameter,&size,",");
long soft_restr=0;
long hard_restr=0;
long swap_restr=0;
int cpu=0;
for (int i=0;i<size;i++){
int parsed_size=0;
config_str parsed_parameter = yon_char_parse(parsed[i],&parsed_size,"=");
if (parsed_size){
if (!strcmp(parsed_parameter[0],"MemoryHigh")&&parsed_size>1){
soft_restr = atol(parsed_parameter[1]);
int size_mult = yon_get_size_get_from_letter(parsed_parameter[1][strlen(parsed_parameter[1])-1]);
if (size_mult==-1) size_mult=0;
long hard_current_max = main_config.avaliable_ram;
for (int i=0;i<size_mult+1;i++)
hard_current_max=hard_current_max/1024;
gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(window->SoftRestrictionSpin)),hard_current_max);
if (soft_restr) {
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->SoftRestrictionSpin),soft_restr);
gtk_combo_box_set_active(GTK_COMBO_BOX(window->SoftRestrictionCombo),size_mult);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->SoftRestrictionCheck),1);
} else {
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->SoftRestrictionSpin),0);
gtk_combo_box_set_active(GTK_COMBO_BOX(window->SoftRestrictionCombo),0);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->SoftRestrictionCheck),0);
} }
else{ } else if (!strcmp(parsed_parameter[0],"MemoryMax")&&parsed_size>1){
char *read_limit = yon_char_new(read);
char *read_cur = yon_char_divide_search(read_limit," ",-1); hard_restr = atol(parsed_parameter[1]);
if (strstr(temp,read_cur)){ int size_mult = yon_get_size_get_from_letter(parsed_parameter[1][strlen(parsed_parameter[1])-1]);
if(!dict->data){ if (size_mult==-1) size_mult=0;
dict->data = g_malloc0(sizeof(device_limits)); long hard_current_max = main_config.avaliable_ram;
((device_limits*)dict->data)->write=NULL; for (int i=0;i<size_mult+1;i++)
((device_limits*)dict->data)->read=NULL; hard_current_max=hard_current_max/1024;
} gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(window->HardRestrictionSpin)),hard_current_max);
((device_limits*)dict->data)->read=read_limit; if (hard_restr){
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->HardRestrictionSpin),hard_restr);
gtk_combo_box_set_active(GTK_COMBO_BOX(window->HardRestrictionCombo),size_mult);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->HardRestrictionCheck),1);
} else {
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->HardRestrictionSpin),0);
gtk_combo_box_set_active(GTK_COMBO_BOX(window->HardRestrictionCombo),0);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->HardRestrictionCheck),0);
} }
} } else if (!strcmp(parsed_parameter[0],"MemorySwapMax")&&parsed_size>1){
if (write_parsed) swap_restr = atol(parsed_parameter[1]);
for (int i=0; i<write_size;i++){ int size_mult = yon_get_size_get_from_letter(parsed_parameter[1][strlen(parsed_parameter[1])-1]);
char *write_limit = yon_char_new(write_parsed[i]); if (size_mult==-1) size_mult=0;
char *write_cur = yon_char_divide_search(write_limit," ",-1); long hard_current_max = main_config.avaliable_swap;
if (strstr(temp,write_cur)){ for (int i=0;i<size_mult+1;i++)
if(!dict->data){ hard_current_max=hard_current_max/1024;
dict->data = g_malloc0(sizeof(device_limits)); gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(window->PagingLimitSpin)),hard_current_max);
((device_limits*)dict->data)->write=NULL; if (swap_restr){
((device_limits*)dict->data)->read=NULL; gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->PagingLimitSpin),swap_restr);
} gtk_combo_box_set_active(GTK_COMBO_BOX(window->PagingLimitCombo),size_mult);
((device_limits*)dict->data)->write=write_limit; gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->PagingLimitCheck),1);
} } else {
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->PagingLimitSpin),0);
gtk_combo_box_set_active(GTK_COMBO_BOX(window->PagingLimitCombo),0);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->PagingLimitCheck),0);
} }
else{
char *write_limit = yon_char_new(write); } else if (!strcmp(parsed_parameter[0],"CPUQuota")&&parsed_size>1){
char *write_cur = yon_char_divide_search(write_limit," ",-1); cpu = atoi(parsed_parameter[1]);
if (strstr(temp,write_cur)){ gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(window->CpuLimitSpin)),main_config.cores*100);
if(!dict->data){ if (cpu){
dict->data = g_malloc0(sizeof(device_limits)); gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->CpuLimitSpin),cpu);
((device_limits*)dict->data)->write=NULL; gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->CpuLimitCheck),1);
((device_limits*)dict->data)->read=NULL; } else {
} gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->CpuLimitSpin),0);
((device_limits*)dict->data)->write=write_limit; gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->CpuLimitCheck),0);
}
} else if (!strcmp(parsed_parameter[0],"IOReadBandwidthMax")&&parsed_size>1){
char *device = yon_char_divide_search(parsed_parameter[1]," ",-1);
dictionary *dict = yon_dictionary_get(&window->devices,device);
if (dict){
device_limits *limit = yon_dictionary_get_data(dict,device_limits*);
limit->read = yon_char_new(parsed_parameter[1]);
}
} else if (!strcmp(parsed_parameter[0],"IOWriteBandwidthMax")&&parsed_size>1){
char *device = yon_char_divide_search(parsed_parameter[1]," ",-1);
dictionary *dict = yon_dictionary_get(&window->devices,device);
if (dict){
device_limits *limit = yon_dictionary_get_data(dict,device_limits*);
limit->write = yon_char_new(parsed_parameter[1]);
} }
} }
} }
g_signal_connect(G_OBJECT(window->DeviceLimitWriteCombo),"changed",G_CALLBACK(on_check_maximum),window->DeviceLimitWriteSpin);
g_signal_connect(G_OBJECT(window->DeviceLimitReadCombo),"changed",G_CALLBACK(on_check_maximum),window->DeviceLimitReadSpin);
window->devices=window->devices->first;
gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitCombo),0);
g_signal_connect(G_OBJECT(window->DeviceLimitCombo),"changed",G_CALLBACK(on_device_current_changed),window);
g_signal_connect(G_OBJECT(window->DeviceLimitReadCheck),"toggled",G_CALLBACK(on_device_set),window);
g_signal_connect(G_OBJECT(window->DeviceLimitReadSpin),"value-changed",G_CALLBACK(on_device_set),window);
g_signal_connect(G_OBJECT(window->DeviceLimitReadCombo),"changed",G_CALLBACK(on_device_set),window);
g_signal_connect(G_OBJECT(window->DeviceLimitWriteCheck),"toggled",G_CALLBACK(on_device_set),window);
g_signal_connect(G_OBJECT(window->DeviceLimitWriteSpin),"value-changed",G_CALLBACK(on_device_set),window);
g_signal_connect(G_OBJECT(window->DeviceLimitWriteCombo),"changed",G_CALLBACK(on_device_set),window);
if (((device_limits*)window->devices->data)->read&&strcmp(((device_limits*)window->devices->data)->read,"")!=0){
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitReadCheck),1);
char *rd = ((device_limits*)window->devices->data)->read;
gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),yon_get_size_request_from_letter(rd[strlen(rd)-1]));
rd[strlen(rd)-1]='\0';
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitReadSpin),strtol(((device_limits*)window->devices->data)->read,NULL,10));
}
else ((device_limits*)window->devices->data)->read=NULL;
if (((device_limits*)window->devices->data)->write&&strcmp(((device_limits*)window->devices->data)->write,"")!=0){
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitWriteCheck),1);
gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),yon_get_size_request_from_letter(((device_limits*)window->devices->data)->write[strlen(((device_limits*)window->devices->data)->write)-1]));
((device_limits*)window->devices->data)->write[strlen(((device_limits*)window->devices->data)->write)-1]='\0';
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitWriteSpin),strtol(((device_limits*)window->devices->data)->write,NULL,10));
} else ((device_limits*)window->devices->data)->write=NULL;
if (soft&&strcmp(soft,"")!=0) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->SoftRestrictionCheck),1);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->SoftRestrictionSpin),strtol(soft,NULL,10));
gtk_combo_box_set_active(GTK_COMBO_BOX(window->SoftRestrictionCombo),soft_size);
}
if (hard&&strcmp(hard,"")!=0) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->HardRestrictionCheck),1);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->HardRestrictionSpin),strtol(hard,NULL,10));
gtk_combo_box_set_active(GTK_COMBO_BOX(window->HardRestrictionCombo),hard_size);
}
if (cpu&&strcmp(cpu,"")!=0) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->CpuLimitCheck),1);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->CpuLimitSpin),strtol(cpu,NULL,10));
}
if (swap&&strcmp(swap,"")!=0) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->PagingLimitCheck),1);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->PagingLimitSpin),strtol(swap,NULL,10));
gtk_combo_box_set_active(GTK_COMBO_BOX(window->PagingLimitCombo),swap_size);
}
for (int i=0; i<main_config.users_size;i++){
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(window->TargetCombo),main_config.users[i]);
}
}
if (!soft_restr) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->SoftRestrictionCheck),0);
if (!hard_restr) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->HardRestrictionCheck),0);
if (!swap_restr) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->PagingLimitCheck),0);
if (!cpu) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->CpuLimitCheck),0);
struct sysinfo inf;
sysinfo(&inf);
main_config.avaliable_ram=inf.totalram;
main_config.avaliable_swap=inf.totalswap;
main_config.cores = sysconf(_SC_NPROCESSORS_ONLN);
g_signal_handlers_unblock_by_func(G_OBJECT(window->SoftRestrictionSpin),G_CALLBACK(on_quota_configuration_update),window);
g_signal_handlers_unblock_by_func(G_OBJECT(window->SoftRestrictionCombo),G_CALLBACK(on_quota_configuration_update),window);
g_signal_handlers_unblock_by_func(G_OBJECT(window->HardRestrictionSpin),G_CALLBACK(on_quota_configuration_update),window);
g_signal_handlers_unblock_by_func(G_OBJECT(window->HardRestrictionCombo),G_CALLBACK(on_quota_configuration_update),window);
g_signal_handlers_unblock_by_func(G_OBJECT(window->PagingLimitSpin),G_CALLBACK(on_quota_configuration_update),window);
g_signal_handlers_unblock_by_func(G_OBJECT(window->PagingLimitCombo),G_CALLBACK(on_quota_configuration_update),window);
g_signal_handlers_unblock_by_func(G_OBJECT(window->CpuLimitSpin),G_CALLBACK(on_quota_configuration_update),window);
g_signal_handlers_unblock_by_func(G_OBJECT(window->DeviceLimitReadSpin),G_CALLBACK(on_quota_configuration_update),window);
g_signal_handlers_unblock_by_func(G_OBJECT(window->DeviceLimitReadCombo),G_CALLBACK(on_quota_configuration_update),window);
g_signal_handlers_unblock_by_func(G_OBJECT(window->DeviceLimitWriteSpin),G_CALLBACK(on_quota_configuration_update),window);
g_signal_handlers_unblock_by_func(G_OBJECT(window->DeviceLimitWriteCombo),G_CALLBACK(on_quota_configuration_update),window);
g_signal_handlers_unblock_by_func(G_OBJECT(window->SoftRestrictionCheck),G_CALLBACK(on_quota_configuration_update),window);
g_signal_handlers_unblock_by_func(G_OBJECT(window->HardRestrictionCheck),G_CALLBACK(on_quota_configuration_update),window);
g_signal_handlers_unblock_by_func(G_OBJECT(window->PagingLimitCheck),G_CALLBACK(on_quota_configuration_update),window);
g_signal_handlers_unblock_by_func(G_OBJECT(window->CpuLimitCheck),G_CALLBACK(on_quota_configuration_update),window);
g_signal_handlers_unblock_by_func(G_OBJECT(window->DeviceLimitReadCheck),G_CALLBACK(on_quota_configuration_update),window);
g_signal_handlers_unblock_by_func(G_OBJECT(window->DeviceLimitWriteCheck),G_CALLBACK(on_quota_configuration_update),window);
g_signal_handlers_unblock_by_func(G_OBJECT(window->TargetTypeCombo),G_CALLBACK(on_quota_target_type_changed),window);
g_signal_handlers_unblock_by_func(G_OBJECT(window->DeviceLimitReadCheck),G_CALLBACK(on_device_set),window);
g_signal_handlers_unblock_by_func(G_OBJECT(window->DeviceLimitReadSpin),G_CALLBACK(on_device_set),window);
g_signal_handlers_unblock_by_func(G_OBJECT(window->DeviceLimitReadCombo),G_CALLBACK(on_device_set),window);
g_signal_handlers_unblock_by_func(G_OBJECT(window->DeviceLimitWriteCheck),G_CALLBACK(on_device_set),window);
g_signal_handlers_unblock_by_func(G_OBJECT(window->DeviceLimitWriteSpin),G_CALLBACK(on_device_set),window);
g_signal_handlers_unblock_by_func(G_OBJECT(window->DeviceLimitWriteCombo),G_CALLBACK(on_device_set),window);
}
g_signal_connect(G_OBJECT(window->TargetCombo),"changed",G_CALLBACK(on_target_check_chosen),window); void on_edit_open(GtkWidget *, main_window *widgets){
g_signal_connect(G_OBJECT(window->SoftRestrictionSpin),"change-value",G_CALLBACK(on_check_maximum),window->SoftRestrictionCombo); GtkTreeModel *model = GTK_TREE_MODEL(main_config.list);
g_signal_connect(G_OBJECT(window->SoftRestrictionCombo),"changed",G_CALLBACK(on_check_maximum),window->SoftRestrictionSpin); GtkTreeIter iter;
g_signal_connect(G_OBJECT(window->HardRestrictionSpin),"change-value",G_CALLBACK(on_check_maximum),window->HardRestrictionCombo); if (!gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree)),&model,&iter)) return;
g_signal_connect(G_OBJECT(window->HardRestrictionCombo),"changed",G_CALLBACK(on_check_maximum),window->HardRestrictionSpin); quota_window *window = yon_quota_window_new();
g_signal_connect(G_OBJECT(window->PagingLimitSpin),"change-value",G_CALLBACK(on_check_maximum_cpu),window->PagingLimitCombo); gtk_widget_set_sensitive(window->BlockUiBox,1);
g_signal_connect(G_OBJECT(window->PagingLimitCombo),"changed",G_CALLBACK(on_check_maximum_cpu),window->PagingLimitSpin); char *target, *type;
g_signal_connect(G_OBJECT(window->DeviceLimitReadSpin),"change-value",G_CALLBACK(on_check_maximum),window->DeviceLimitReadCombo); gtk_tree_model_get(model,&iter,0,&type,1,&target,-1);
g_signal_connect(G_OBJECT(window->DeviceLimitWriteSpin),"change-value",G_CALLBACK(on_check_maximum),window->DeviceLimitWriteCombo);
gtk_label_set_text(GTK_LABEL(window->TypeLabel),type);
g_signal_connect(G_OBJECT(window->SoftRestrictionSpin),"output",G_CALLBACK(on_quota_configuration_update),window); gtk_label_set_text(GTK_LABEL(window->TargetLabel),target);
g_signal_connect(G_OBJECT(window->SoftRestrictionCombo),"changed",G_CALLBACK(on_quota_configuration_update),window); gtk_window_set_title(GTK_WINDOW(window->Window),EDITING_LABEL);
g_signal_connect(G_OBJECT(window->HardRestrictionSpin),"output",G_CALLBACK(on_quota_configuration_update),window); gtk_label_set_text(GTK_LABEL(window->TitleLabel),EDITING_LABEL);
g_signal_connect(G_OBJECT(window->HardRestrictionCombo),"changed",G_CALLBACK(on_quota_configuration_update),window);
g_signal_connect(G_OBJECT(window->PagingLimitSpin),"output",G_CALLBACK(on_quota_configuration_update),window); gtk_widget_show(window->EditQuotaTargetBox);
g_signal_connect(G_OBJECT(window->PagingLimitCombo),"changed",G_CALLBACK(on_quota_configuration_update),window); gtk_widget_hide(window->AddQuotaTargetBox);
g_signal_connect(G_OBJECT(window->CpuLimitSpin),"output",G_CALLBACK(on_quota_configuration_update),window);
g_signal_connect(G_OBJECT(window->DeviceLimitReadSpin),"output",G_CALLBACK(on_quota_configuration_update),window); char *parameter = config(CGROUP_QUOTA(target));
g_signal_connect(G_OBJECT(window->DeviceLimitReadCombo),"changed",G_CALLBACK(on_quota_configuration_update),window); gtk_entry_set_text(GTK_ENTRY(window->ManualInputEntry),parameter);
g_signal_connect(G_OBJECT(window->DeviceLimitWriteSpin),"output",G_CALLBACK(on_quota_configuration_update),window); yon_quota_update(window);
g_signal_connect(G_OBJECT(window->DeviceLimitWriteCombo),"changed",G_CALLBACK(on_quota_configuration_update),window); dictionary *windows = NULL;
g_signal_connect(G_OBJECT(window->SoftRestrictionCheck),"toggled",G_CALLBACK(on_quota_configuration_update),window); yon_dictionary_add_or_create_if_exists_with_data(windows,"window",window);
g_signal_connect(G_OBJECT(window->HardRestrictionCheck),"toggled",G_CALLBACK(on_quota_configuration_update),window); yon_dictionary_add_or_create_if_exists_with_data(windows,"widgets",widgets);
g_signal_connect(G_OBJECT(window->PagingLimitCheck),"toggled",G_CALLBACK(on_quota_configuration_update),window); g_signal_connect(G_OBJECT(window->SaveButton),"clicked",G_CALLBACK(on_quotas_edit),windows);
g_signal_connect(G_OBJECT(window->CpuLimitCheck),"toggled",G_CALLBACK(on_quota_configuration_update),window);
g_signal_connect(G_OBJECT(window->DeviceLimitReadCheck),"toggled",G_CALLBACK(on_quota_configuration_update),window);
g_signal_connect(G_OBJECT(window->DeviceLimitWriteCheck),"toggled",G_CALLBACK(on_quota_configuration_update),window);
gtk_widget_show(window->Window);
}
} }
gboolean on_dispatcher_update(GtkWidget *,main_window *widgets){ gboolean on_dispatcher_update(GtkWidget *,main_window *widgets){

@ -224,4 +224,7 @@ void on_limit_manual_input(GtkWidget *self, double *new_value, quota_window *win
void on_quota_configuration_update(GtkWidget *self, quota_window *window); void on_quota_configuration_update(GtkWidget *self, quota_window *window);
void on_device_limits_update(GtkWidget *, quota_window *window); void on_device_limits_update(GtkWidget *, quota_window *window);
void yon_widget_set_sensitive(GtkComboBox *toggle, GtkWidget *target); void yon_widget_set_sensitive(GtkComboBox *toggle, GtkWidget *target);
void on_device_set(GtkWidget *self, quota_window *window); void on_device_set(GtkWidget *self, quota_window *window);
quota_window *yon_quota_window_new();
void yon_quota_update(quota_window *window);
void on_manual_edit(GtkWidget *, quota_window *window);
Loading…
Cancel
Save