|
|
|
@ -64,47 +64,72 @@ void on_quota_configuration_update(GtkWidget *, quota_window *window){
|
|
|
|
long hrd = (long)gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->HardRestrictionSpin));
|
|
|
|
long hrd = (long)gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->HardRestrictionSpin));
|
|
|
|
long pgl = (long)gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->PagingLimitSpin));
|
|
|
|
long pgl = (long)gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->PagingLimitSpin));
|
|
|
|
long cpu = (long)gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->CpuLimitSpin));
|
|
|
|
long cpu = (long)gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->CpuLimitSpin));
|
|
|
|
char *soft_limit = "";
|
|
|
|
char *soft_limit = NULL;
|
|
|
|
char *hard_limit = "";
|
|
|
|
char *hard_limit = NULL;
|
|
|
|
char *paging_limit = "";
|
|
|
|
char *paging_limit = NULL;
|
|
|
|
char *cpu_limit = "";
|
|
|
|
char *cpu_limit = NULL;
|
|
|
|
if (sft) soft_limit = yon_char_unite("MemoryHigh=",yon_char_from_long(sft),get_size_mod(GTK_COMBO_BOX(window->SoftRestrictionCombo)),NULL);
|
|
|
|
if (sft) soft_limit = yon_char_unite("MemoryHigh=",yon_char_from_long(sft),get_size_mod(GTK_COMBO_BOX(window->SoftRestrictionCombo)),NULL);
|
|
|
|
if (hrd) hard_limit = yon_char_unite("MemoryMax=",yon_char_from_long(hrd),get_size_mod(GTK_COMBO_BOX(window->HardRestrictionCombo)),NULL);
|
|
|
|
if (hrd) hard_limit = yon_char_unite("MemoryMax=",yon_char_from_long(hrd),get_size_mod(GTK_COMBO_BOX(window->HardRestrictionCombo)),NULL);
|
|
|
|
if (pgl) paging_limit = yon_char_unite("MemorySwapMax=",yon_char_from_long(pgl),get_size_mod(GTK_COMBO_BOX(window->PagingLimitCombo)),NULL);
|
|
|
|
if (pgl) paging_limit = yon_char_unite("MemorySwapMax=",yon_char_from_long(pgl),get_size_mod(GTK_COMBO_BOX(window->PagingLimitCombo)),NULL);
|
|
|
|
if (cpu) cpu_limit = yon_char_unite("CPUQuota=",yon_char_from_long(cpu),"%",NULL);
|
|
|
|
if (cpu) cpu_limit = yon_char_unite("CPUQuota=",yon_char_from_long(cpu),"%",NULL);
|
|
|
|
|
|
|
|
|
|
|
|
char *read_limit = "";
|
|
|
|
char *read_devices = NULL;
|
|
|
|
char *read_devices = "";
|
|
|
|
|
|
|
|
dictionary *dict;
|
|
|
|
dictionary *dict;
|
|
|
|
for_dictionaries(dict,window->devices){
|
|
|
|
for_dictionaries(dict,window->devices){
|
|
|
|
device_limits *limits = yon_dictionary_get_data(dict,device_limits*);
|
|
|
|
device_limits *limits = yon_dictionary_get_data(dict,device_limits*);
|
|
|
|
if (dict->data&&limits->read)
|
|
|
|
if (dict->data&&limits->read)
|
|
|
|
if (!strstr(limits->read," 0 "))
|
|
|
|
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);
|
|
|
|
char *tmp = yon_char_unite(read_devices ? read_devices : "","IOReadBandwidthMax=",yon_char_divide_search(yon_char_new(dict->key)," ",-1)," ",limits->read,",",NULL);
|
|
|
|
|
|
|
|
free(read_devices);
|
|
|
|
|
|
|
|
read_devices = tmp;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (read_devices[strlen(read_devices)-1]==',') read_devices[strlen(read_devices)-1]='\0';
|
|
|
|
if (read_devices && strlen(read_devices) > 0 && read_devices[strlen(read_devices)-1]==',')
|
|
|
|
read_limit = yon_char_unite(read_limit,read_devices,NULL);
|
|
|
|
read_devices[strlen(read_devices)-1]='\0';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char *write_devices = NULL;
|
|
|
|
char *write_limit = "";
|
|
|
|
|
|
|
|
char *write_devices = "";
|
|
|
|
|
|
|
|
for_dictionaries(dict,window->devices){
|
|
|
|
for_dictionaries(dict,window->devices){
|
|
|
|
device_limits *limits = yon_dictionary_get_data(dict,device_limits*);
|
|
|
|
device_limits *limits = yon_dictionary_get_data(dict,device_limits*);
|
|
|
|
if (dict->data&&limits->write)
|
|
|
|
if (dict->data&&limits->write)
|
|
|
|
if (!strstr(limits->write," 0 "))
|
|
|
|
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);
|
|
|
|
char *tmp = yon_char_unite(write_devices ? write_devices : "","IOWriteBandwidthMax=",yon_char_divide_search(yon_char_new(dict->key)," ",-1)," ",limits->write,",",NULL);
|
|
|
|
|
|
|
|
free(write_devices);
|
|
|
|
|
|
|
|
write_devices = tmp;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (write_devices[strlen(write_devices)-1]==',') write_devices[strlen(write_devices)-1]='\0';
|
|
|
|
if (write_devices && strlen(write_devices) > 0 && write_devices[strlen(write_devices)-1]==',')
|
|
|
|
write_limit = yon_char_unite(write_limit,write_devices,NULL);
|
|
|
|
write_devices[strlen(write_devices)-1]='\0';
|
|
|
|
|
|
|
|
|
|
|
|
output_line = yon_char_unite(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->SoftRestrictionCheck))? yon_char_append(soft_limit,","): "",
|
|
|
|
char *soft_part = NULL;
|
|
|
|
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->HardRestrictionCheck))? yon_char_append(hard_limit,","):"",
|
|
|
|
char *hard_part = NULL;
|
|
|
|
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->PagingLimitCheck))? yon_char_append(paging_limit,","):"",
|
|
|
|
char *paging_part = NULL;
|
|
|
|
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->CpuLimitCheck))? yon_char_append(cpu_limit,","):"",
|
|
|
|
char *cpu_part = NULL;
|
|
|
|
(read_devices && strcmp(read_devices,"")!=0 ) ? yon_char_append(read_limit,","):"",
|
|
|
|
char *read_part = NULL;
|
|
|
|
(write_devices && strcmp(write_devices,"")!=0 ) ? yon_char_append(write_limit,","):"",NULL);
|
|
|
|
char *write_part = NULL;
|
|
|
|
|
|
|
|
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->SoftRestrictionCheck)) && soft_limit) soft_part = yon_char_unite(soft_limit,",",NULL);
|
|
|
|
|
|
|
|
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->HardRestrictionCheck)) && hard_limit) hard_part = yon_char_unite(hard_limit,",",NULL);
|
|
|
|
|
|
|
|
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->PagingLimitCheck)) && paging_limit) paging_part = yon_char_unite(paging_limit,",",NULL);
|
|
|
|
|
|
|
|
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->CpuLimitCheck)) && cpu_limit) cpu_part = yon_char_unite(cpu_limit,",",NULL);
|
|
|
|
|
|
|
|
if (read_devices && strcmp(read_devices,"")!=0) read_part = yon_char_unite(read_devices,",",NULL);
|
|
|
|
|
|
|
|
if (write_devices && strcmp(write_devices,"")!=0) write_part = yon_char_unite(write_devices,",",NULL);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
output_line = yon_char_unite(soft_part ? soft_part : "",hard_part ? hard_part : "",paging_part ? paging_part : "",cpu_part ? cpu_part : "",read_part ? read_part : "",write_part ? write_part : "",NULL);
|
|
|
|
if (output_line&&strcmp(output_line,"")!=0&&output_line[strlen(output_line)-1] == ',') output_line[strlen(output_line)-1] = '\0';
|
|
|
|
if (output_line&&strcmp(output_line,"")!=0&&output_line[strlen(output_line)-1] == ',') output_line[strlen(output_line)-1] = '\0';
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(window->ManualInputEntry),output_line);
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(window->ManualInputEntry),output_line ? output_line : "");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
free(output_line);
|
|
|
|
|
|
|
|
free(soft_limit);
|
|
|
|
|
|
|
|
free(hard_limit);
|
|
|
|
|
|
|
|
free(paging_limit);
|
|
|
|
|
|
|
|
free(cpu_limit);
|
|
|
|
|
|
|
|
free(read_devices);
|
|
|
|
|
|
|
|
free(write_devices);
|
|
|
|
|
|
|
|
free(soft_part);
|
|
|
|
|
|
|
|
free(hard_part);
|
|
|
|
|
|
|
|
free(paging_part);
|
|
|
|
|
|
|
|
free(cpu_part);
|
|
|
|
|
|
|
|
free(read_part);
|
|
|
|
|
|
|
|
free(write_part);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void on_limit_manual_input(GtkWidget *self, double *, quota_window *window){
|
|
|
|
void on_limit_manual_input(GtkWidget *self, double *, quota_window *window){
|
|
|
|
@ -118,12 +143,12 @@ void on_check_maximum(GtkWidget *self, GtkWidget *pair){
|
|
|
|
if (main_config.avaliable_ram==0){
|
|
|
|
if (main_config.avaliable_ram==0){
|
|
|
|
struct sysinfo inf;
|
|
|
|
struct sysinfo inf;
|
|
|
|
sysinfo(&inf);
|
|
|
|
sysinfo(&inf);
|
|
|
|
main_config.avaliable_ram=inf.totalram;
|
|
|
|
main_config.avaliable_ram = (long)inf.totalram * inf.mem_unit;
|
|
|
|
main_config.avaliable_swap=inf.totalswap;
|
|
|
|
main_config.avaliable_swap = (long)inf.totalswap * inf.mem_unit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
double cur_ram = main_config.avaliable_ram;
|
|
|
|
double cur_ram = main_config.avaliable_ram;
|
|
|
|
double cur_value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(self));
|
|
|
|
double cur_value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(self));
|
|
|
|
for (int i=0;i<required_size;i++)
|
|
|
|
for (int i=0;i<required_size+1;i++)
|
|
|
|
cur_ram=cur_ram/1024;
|
|
|
|
cur_ram=cur_ram/1024;
|
|
|
|
GtkAdjustment *adj = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(self));
|
|
|
|
GtkAdjustment *adj = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(self));
|
|
|
|
gtk_adjustment_set_upper(adj,cur_ram);
|
|
|
|
gtk_adjustment_set_upper(adj,cur_ram);
|
|
|
|
@ -136,8 +161,8 @@ void on_check_maximum(GtkWidget *self, GtkWidget *pair){
|
|
|
|
if (main_config.avaliable_ram==0){
|
|
|
|
if (main_config.avaliable_ram==0){
|
|
|
|
struct sysinfo inf;
|
|
|
|
struct sysinfo inf;
|
|
|
|
sysinfo(&inf);
|
|
|
|
sysinfo(&inf);
|
|
|
|
main_config.avaliable_ram=inf.totalram;
|
|
|
|
main_config.avaliable_ram = (long)inf.totalram * inf.mem_unit;
|
|
|
|
main_config.avaliable_swap=inf.totalswap;
|
|
|
|
main_config.avaliable_swap = (long)inf.totalswap * inf.mem_unit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
double cur_ram = main_config.avaliable_ram;
|
|
|
|
double cur_ram = main_config.avaliable_ram;
|
|
|
|
double cur_value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(pair));
|
|
|
|
double cur_value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(pair));
|
|
|
|
@ -155,14 +180,14 @@ void on_check_maximum_cpu(GtkWidget *self, GtkWidget *pair){
|
|
|
|
if (GTK_IS_SPIN_BUTTON(self)){
|
|
|
|
if (GTK_IS_SPIN_BUTTON(self)){
|
|
|
|
if (GTK_IS_COMBO_BOX(pair)){
|
|
|
|
if (GTK_IS_COMBO_BOX(pair)){
|
|
|
|
int required_size = gtk_combo_box_get_active(GTK_COMBO_BOX(pair));
|
|
|
|
int required_size = gtk_combo_box_get_active(GTK_COMBO_BOX(pair));
|
|
|
|
if (main_config.avaliable_ram==0){
|
|
|
|
if (main_config.avaliable_swap==0){
|
|
|
|
struct sysinfo inf;
|
|
|
|
struct sysinfo inf;
|
|
|
|
sysinfo(&inf);
|
|
|
|
sysinfo(&inf);
|
|
|
|
main_config.avaliable_swap=inf.totalswap;
|
|
|
|
main_config.avaliable_swap=inf.totalswap;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
double cur_ram = main_config.avaliable_swap;
|
|
|
|
double cur_ram = main_config.avaliable_swap;
|
|
|
|
double cur_value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(self));
|
|
|
|
double cur_value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(self));
|
|
|
|
for (int i=0;i<required_size;i++)
|
|
|
|
for (int i=0;i<required_size+1;i++)
|
|
|
|
cur_ram=cur_ram/1024;
|
|
|
|
cur_ram=cur_ram/1024;
|
|
|
|
GtkAdjustment *adj = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(self));
|
|
|
|
GtkAdjustment *adj = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(self));
|
|
|
|
gtk_adjustment_set_upper(adj,cur_ram);
|
|
|
|
gtk_adjustment_set_upper(adj,cur_ram);
|
|
|
|
@ -194,19 +219,19 @@ void on_quota_target_type_changed(GtkWidget *self, quota_window *window){
|
|
|
|
if (active == 0) {
|
|
|
|
if (active == 0) {
|
|
|
|
gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(window->TargetCombo));
|
|
|
|
gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(window->TargetCombo));
|
|
|
|
for (int i=0; i<main_config.users_size;i++){
|
|
|
|
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_combo_box_text_append(GTK_COMBO_BOX_TEXT(window->TargetCombo),main_config.users[i],main_config.users[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (active == 1) {
|
|
|
|
if (active == 1) {
|
|
|
|
gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(window->TargetCombo));
|
|
|
|
gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(window->TargetCombo));
|
|
|
|
for (int i=0; i<main_config.processes_size;i++){
|
|
|
|
for (int i=0; i<main_config.processes_size;i++){
|
|
|
|
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(window->TargetCombo),main_config.processes[i]);
|
|
|
|
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(window->TargetCombo),main_config.processes[i],main_config.processes[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (active == 2) {
|
|
|
|
if (active == 2) {
|
|
|
|
gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(window->TargetCombo));
|
|
|
|
gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(window->TargetCombo));
|
|
|
|
for (int i=0; i<main_config.slices_size;i++){
|
|
|
|
for (int i=0; i<main_config.slices_size;i++){
|
|
|
|
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(window->TargetCombo),main_config.slices[i]);
|
|
|
|
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(window->TargetCombo),main_config.slices[i],main_config.slices[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -224,9 +249,10 @@ void yon_get_devices(quota_window *window){
|
|
|
|
for (int i=0; i<size;i++){
|
|
|
|
for (int i=0; i<size;i++){
|
|
|
|
yon_char_remove_last_symbol(devices_parsed[i],'\n');
|
|
|
|
yon_char_remove_last_symbol(devices_parsed[i],'\n');
|
|
|
|
char *pa = strstr(devices_parsed[i],"/");
|
|
|
|
char *pa = strstr(devices_parsed[i],"/");
|
|
|
|
|
|
|
|
if (!pa) continue;
|
|
|
|
char *device_name = yon_char_new(pa);
|
|
|
|
char *device_name = yon_char_new(pa);
|
|
|
|
char *id = yon_char_divide_search(device_name," ",-1);
|
|
|
|
char *id = yon_char_divide_search(device_name," ",-1);
|
|
|
|
free(device_name);
|
|
|
|
if (!yon_char_is_empty(device_name)||id != device_name) free(device_name);
|
|
|
|
device_limits *limits = malloc(sizeof(device_limits));
|
|
|
|
device_limits *limits = malloc(sizeof(device_limits));
|
|
|
|
limits->device_name = yon_char_new(pa);
|
|
|
|
limits->device_name = yon_char_new(pa);
|
|
|
|
limits->read=NULL;
|
|
|
|
limits->read=NULL;
|
|
|
|
@ -400,7 +426,7 @@ int yon_get_size_request_from_letter(char size){
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 'G': return 2;
|
|
|
|
case 'G': return 2;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 'T': return 0;
|
|
|
|
case 'T': return 3;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default: return -1;
|
|
|
|
default: return -1;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
@ -569,10 +595,10 @@ void on_quota_manual_input(GtkWidget *self, quota_window *window){
|
|
|
|
if (rtn){
|
|
|
|
if (rtn){
|
|
|
|
for (int i=0; i<size; i++){
|
|
|
|
for (int i=0; i<size; i++){
|
|
|
|
char *value = yon_char_new(rtn[i]);
|
|
|
|
char *value = yon_char_new(rtn[i]);
|
|
|
|
|
|
|
|
if (!value || !*value) { free(value); continue; }
|
|
|
|
yon_char_divide_search(value,"=",-1);
|
|
|
|
yon_char_divide_search(value,"=",-1);
|
|
|
|
int size = yon_get_size_request_from_letter(value[strlen(value)-1]);
|
|
|
|
int size = yon_get_size_request_from_letter(value[strlen(value)-1]);
|
|
|
|
if (size!=-1||strstr(rtn[i],"CPUQuota=")){
|
|
|
|
if (size!=-1||strstr(rtn[i],"CPUQuota=")){
|
|
|
|
// value[strlen(value)-1]='\0';
|
|
|
|
|
|
|
|
if (strstr(rtn[i],"MemoryHigh=")){
|
|
|
|
if (strstr(rtn[i],"MemoryHigh=")){
|
|
|
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->SoftRestrictionCheck),1);
|
|
|
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->SoftRestrictionCheck),1);
|
|
|
|
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->SoftRestrictionSpin),strtol(value,NULL,10));
|
|
|
|
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->SoftRestrictionSpin),strtol(value,NULL,10));
|
|
|
|
@ -601,7 +627,10 @@ void on_quota_manual_input(GtkWidget *self, quota_window *window){
|
|
|
|
((device_limits*)dict->data)->write=NULL;
|
|
|
|
((device_limits*)dict->data)->write=NULL;
|
|
|
|
((device_limits*)dict->data)->read=NULL;
|
|
|
|
((device_limits*)dict->data)->read=NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (((device_limits*)dict->data)->read) free(((device_limits*)dict->data)->read);
|
|
|
|
((device_limits*)dict->data)->read = value;
|
|
|
|
((device_limits*)dict->data)->read = value;
|
|
|
|
|
|
|
|
value = NULL;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -615,20 +644,23 @@ void on_quota_manual_input(GtkWidget *self, quota_window *window){
|
|
|
|
((device_limits*)dict->data)->write=NULL;
|
|
|
|
((device_limits*)dict->data)->write=NULL;
|
|
|
|
((device_limits*)dict->data)->read=NULL;
|
|
|
|
((device_limits*)dict->data)->read=NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (((device_limits*)dict->data)->write) free(((device_limits*)dict->data)->write);
|
|
|
|
((device_limits*)dict->data)->write = value;
|
|
|
|
((device_limits*)dict->data)->write = value;
|
|
|
|
|
|
|
|
value = NULL;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else return;
|
|
|
|
} else { free(value); free(string); return; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
free(value);
|
|
|
|
free(value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
char *value = yon_char_new(string);
|
|
|
|
char *value = yon_char_new(string);
|
|
|
|
|
|
|
|
if (!value || !*value) { free(value); return; }
|
|
|
|
yon_char_divide_search(value,"=",-1);
|
|
|
|
yon_char_divide_search(value,"=",-1);
|
|
|
|
int size = yon_get_size_request_from_letter(value[strlen(value)-1]);
|
|
|
|
int size = yon_get_size_request_from_letter(value[strlen(value)-1]);
|
|
|
|
if (size!=-1||strstr(string,"CPUQuota=")){
|
|
|
|
if (size!=-1||strstr(string,"CPUQuota=")){
|
|
|
|
// value[strlen(value)-1]='\0';
|
|
|
|
|
|
|
|
if (strstr(string,"MemoryHigh=")){
|
|
|
|
if (strstr(string,"MemoryHigh=")){
|
|
|
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->SoftRestrictionCheck),1);
|
|
|
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->SoftRestrictionCheck),1);
|
|
|
|
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->SoftRestrictionSpin),strtol(value,NULL,10));
|
|
|
|
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->SoftRestrictionSpin),strtol(value,NULL,10));
|
|
|
|
@ -651,13 +683,15 @@ void on_quota_manual_input(GtkWidget *self, quota_window *window){
|
|
|
|
char *name = yon_char_divide_search(value, " ",-1);
|
|
|
|
char *name = yon_char_divide_search(value, " ",-1);
|
|
|
|
dictionary *dict;
|
|
|
|
dictionary *dict;
|
|
|
|
for_dictionaries(dict,window->devices){
|
|
|
|
for_dictionaries(dict,window->devices){
|
|
|
|
if (strstr(dict->key,name)){
|
|
|
|
if (!strcmp(dict->key,name)){
|
|
|
|
if (!((device_limits*)dict->data)){
|
|
|
|
if (!((device_limits*)dict->data)){
|
|
|
|
dict->data = g_malloc0(sizeof(device_limits));
|
|
|
|
dict->data = g_malloc0(sizeof(device_limits));
|
|
|
|
((device_limits*)dict->data)->write=NULL;
|
|
|
|
((device_limits*)dict->data)->write=NULL;
|
|
|
|
((device_limits*)dict->data)->read=NULL;
|
|
|
|
((device_limits*)dict->data)->read=NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (((device_limits*)dict->data)->read) free(((device_limits*)dict->data)->read);
|
|
|
|
((device_limits*)dict->data)->read = value;
|
|
|
|
((device_limits*)dict->data)->read = value;
|
|
|
|
|
|
|
|
value = NULL;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -666,19 +700,24 @@ void on_quota_manual_input(GtkWidget *self, quota_window *window){
|
|
|
|
char *name = yon_char_divide_search(value, " ",-1);
|
|
|
|
char *name = yon_char_divide_search(value, " ",-1);
|
|
|
|
dictionary *dict;
|
|
|
|
dictionary *dict;
|
|
|
|
for_dictionaries(dict,window->devices){
|
|
|
|
for_dictionaries(dict,window->devices){
|
|
|
|
if (strstr(dict->key,name)){
|
|
|
|
if (!strcmp(dict->key,name)){
|
|
|
|
if (!((device_limits*)dict->data)){
|
|
|
|
if (!((device_limits*)dict->data)){
|
|
|
|
dict->data = g_malloc0(sizeof(device_limits));
|
|
|
|
dict->data = g_malloc0(sizeof(device_limits));
|
|
|
|
((device_limits*)dict->data)->write=NULL;
|
|
|
|
((device_limits*)dict->data)->write=NULL;
|
|
|
|
((device_limits*)dict->data)->read=NULL;
|
|
|
|
((device_limits*)dict->data)->read=NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (((device_limits*)dict->data)->write) free(((device_limits*)dict->data)->write);
|
|
|
|
((device_limits*)dict->data)->write = value;
|
|
|
|
((device_limits*)dict->data)->write = value;
|
|
|
|
|
|
|
|
value = NULL;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else return;
|
|
|
|
} else { free(value); free(string); return; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!yon_char_is_empty(value)) free(value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!yon_char_is_empty(string)) free(string);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void on_quota_manual_input_focus (GtkWidget *self, GdkEventFocus *, quota_window *window){
|
|
|
|
void on_quota_manual_input_focus (GtkWidget *self, GdkEventFocus *, quota_window *window){
|
|
|
|
@ -726,6 +765,7 @@ void on_filters_opened(GtkWidget *, main_window *widgets) {
|
|
|
|
|
|
|
|
|
|
|
|
void on_add_open(GtkWidget *, main_window *widgets){
|
|
|
|
void on_add_open(GtkWidget *, main_window *widgets){
|
|
|
|
quota_window *window = yon_quota_window_new();
|
|
|
|
quota_window *window = yon_quota_window_new();
|
|
|
|
|
|
|
|
yon_gtk_window_setup(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window),NULL,icon_path,"quota_window");
|
|
|
|
|
|
|
|
|
|
|
|
gtk_window_set_title(GTK_WINDOW(window->Window),TITLE_LABEL);
|
|
|
|
gtk_window_set_title(GTK_WINDOW(window->Window),TITLE_LABEL);
|
|
|
|
|
|
|
|
|
|
|
|
@ -769,7 +809,7 @@ void on_information(GtkWidget *, main_window *widgets){
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->TargetTypeCombo),0);
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->TargetTypeCombo),0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->TargetCombo),yon_gtk_combo_box_text_find(widgets->TargetCombo,name));
|
|
|
|
gtk_combo_box_set_active_id(GTK_COMBO_BOX(widgets->TargetCombo),name);
|
|
|
|
g_signal_handlers_unblock_by_func(G_OBJECT(widgets->TargetCombo),on_information_chosen_changed,widgets);
|
|
|
|
g_signal_handlers_unblock_by_func(G_OBJECT(widgets->TargetCombo),on_information_chosen_changed,widgets);
|
|
|
|
char *command = get_information_command((char*)name);
|
|
|
|
char *command = get_information_command((char*)name);
|
|
|
|
main_config.last_info = yon_char_new((char*)name);
|
|
|
|
main_config.last_info = yon_char_new((char*)name);
|
|
|
|
@ -967,6 +1007,12 @@ quota_window *yon_quota_window_new(){
|
|
|
|
g_signal_connect(G_OBJECT(window->ManualInputEntry),"changed",G_CALLBACK(on_manual_edit),window);
|
|
|
|
g_signal_connect(G_OBJECT(window->ManualInputEntry),"changed",G_CALLBACK(on_manual_edit),window);
|
|
|
|
g_signal_connect(G_OBJECT(window->ManualInputEntry),"focus-out-event",G_CALLBACK(yon_manual_string_finish),window);
|
|
|
|
g_signal_connect(G_OBJECT(window->ManualInputEntry),"focus-out-event",G_CALLBACK(yon_manual_string_finish),window);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct sysinfo inf;
|
|
|
|
|
|
|
|
sysinfo(&inf);
|
|
|
|
|
|
|
|
main_config.avaliable_ram=inf.totalram;
|
|
|
|
|
|
|
|
main_config.avaliable_swap=inf.totalswap;
|
|
|
|
|
|
|
|
main_config.cores = sysconf(_SC_NPROCESSORS_ONLN);
|
|
|
|
|
|
|
|
|
|
|
|
yon_get_devices(window);
|
|
|
|
yon_get_devices(window);
|
|
|
|
window->devices=window->devices->first;
|
|
|
|
window->devices=window->devices->first;
|
|
|
|
|
|
|
|
|
|
|
|
@ -988,14 +1034,9 @@ quota_window *yon_quota_window_new(){
|
|
|
|
yon_char_remove_last_symbol(main_config.slices[i],'\n');
|
|
|
|
yon_char_remove_last_symbol(main_config.slices[i],'\n');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (int i=0; i<main_config.users_size;i++){
|
|
|
|
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_combo_box_text_append(GTK_COMBO_BOX_TEXT(window->TargetCombo),main_config.users[i],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);
|
|
|
|
gtk_widget_show(window->Window);
|
|
|
|
return window;
|
|
|
|
return window;
|
|
|
|
@ -1042,9 +1083,9 @@ void yon_quota_update(quota_window *window){
|
|
|
|
if (!strcmp(parsed_parameter[0],"MemoryHigh")&&parsed_size>1){
|
|
|
|
if (!strcmp(parsed_parameter[0],"MemoryHigh")&&parsed_size>1){
|
|
|
|
soft_restr = atol(parsed_parameter[1]);
|
|
|
|
soft_restr = atol(parsed_parameter[1]);
|
|
|
|
int size_mult = yon_get_size_get_from_letter(parsed_parameter[1][strlen(parsed_parameter[1])-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;
|
|
|
|
if (size_mult < 0) size_mult = -1;
|
|
|
|
long hard_current_max = main_config.avaliable_ram;
|
|
|
|
long hard_current_max = main_config.avaliable_ram;
|
|
|
|
for (int i=0;i<size_mult+1;i++)
|
|
|
|
for (int i=0;i<size_mult+1;i++) hard_current_max /= 1024;
|
|
|
|
hard_current_max=hard_current_max/1024;
|
|
|
|
hard_current_max=hard_current_max/1024;
|
|
|
|
gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(window->SoftRestrictionSpin)),hard_current_max);
|
|
|
|
gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(window->SoftRestrictionSpin)),hard_current_max);
|
|
|
|
if (soft_restr) {
|
|
|
|
if (soft_restr) {
|
|
|
|
@ -1164,6 +1205,7 @@ void on_edit_open(GtkWidget *, main_window *widgets){
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
if (!gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree)),&model,&iter)) return;
|
|
|
|
if (!gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree)),&model,&iter)) return;
|
|
|
|
quota_window *window = yon_quota_window_new();
|
|
|
|
quota_window *window = yon_quota_window_new();
|
|
|
|
|
|
|
|
yon_gtk_window_setup(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window),NULL,icon_path,"quota_window");
|
|
|
|
gtk_widget_set_sensitive(window->BlockUiBox,1);
|
|
|
|
gtk_widget_set_sensitive(window->BlockUiBox,1);
|
|
|
|
char *target, *type;
|
|
|
|
char *target, *type;
|
|
|
|
gtk_tree_model_get(model,&iter,0,&type,1,&target,-1);
|
|
|
|
gtk_tree_model_get(model,&iter,0,&type,1,&target,-1);
|
|
|
|
@ -1206,9 +1248,9 @@ gboolean on_dispatcher_update(GtkWidget *,main_window *widgets){
|
|
|
|
void on_processes_update(GtkWidget *,main_window *widgets){
|
|
|
|
void on_processes_update(GtkWidget *,main_window *widgets){
|
|
|
|
int show_all = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->ShowAllCheck));
|
|
|
|
int show_all = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->ShowAllCheck));
|
|
|
|
int show_core = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->ShowCoreCheck));
|
|
|
|
int show_core = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->ShowCoreCheck));
|
|
|
|
char *command = get_processes_tree_command;
|
|
|
|
char *command = yon_char_new(get_processes_tree_command);
|
|
|
|
if (show_all) yon_char_append(command, " -k");
|
|
|
|
if (show_all) command = yon_char_append(command, " -k");
|
|
|
|
if (show_core) yon_char_append(command, " -l");
|
|
|
|
if (show_core) command = yon_char_append(command, " -l");
|
|
|
|
yon_terminal_integrated_start_shell(widgets->ProcessesTerminal, command,NULL,NULL);
|
|
|
|
yon_terminal_integrated_start_shell(widgets->ProcessesTerminal, command,NULL,NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -1236,7 +1278,7 @@ void on_info_target_type_switched(GtkWidget *self, main_window *widgets){
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (int i=0; i<size;i++){
|
|
|
|
for (int i=0; i<size;i++){
|
|
|
|
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widgets->TargetCombo),str[i]);
|
|
|
|
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(widgets->TargetCombo),str[i],str[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -1363,8 +1405,8 @@ int main(int argc, char *argv[]){
|
|
|
|
main_config.launch_size=argc;
|
|
|
|
main_config.launch_size=argc;
|
|
|
|
yon_window_check_root_message(widgets);
|
|
|
|
yon_window_check_root_message(widgets);
|
|
|
|
yon_main_window_complete((main_window*)widgets);
|
|
|
|
yon_main_window_complete((main_window*)widgets);
|
|
|
|
char *path = yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",LocaleName,"/",LocaleName,".conf",NULL);
|
|
|
|
yon_window_config_load(config_path);
|
|
|
|
yon_window_config_load(path);
|
|
|
|
|
|
|
|
gtk_main();
|
|
|
|
gtk_main();
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|