|
|
@ -53,9 +53,8 @@ void on_device_limits_update(GtkWidget *, quota_window *window){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void on_quota_configuration_update(GtkWidget *self, quota_window *window){
|
|
|
|
void on_quota_configuration_update(GtkWidget *, quota_window *window){
|
|
|
|
char *output_line = NULL;
|
|
|
|
char *output_line = NULL;
|
|
|
|
on_device_limits_update(self,window);
|
|
|
|
|
|
|
|
long sft = (long)gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->SoftRestrictionSpin));
|
|
|
|
long sft = (long)gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->SoftRestrictionSpin));
|
|
|
|
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));
|
|
|
@ -217,73 +216,112 @@ void yon_get_devices(quota_window *window){
|
|
|
|
config_str devices_parsed = yon_config_load(get_devices_command,&size);
|
|
|
|
config_str devices_parsed = yon_config_load(get_devices_command,&size);
|
|
|
|
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');
|
|
|
|
yon_dictionary_add_or_create_if_exists_with_data(window->devices,devices_parsed[i],NULL);
|
|
|
|
char *pa = strstr(devices_parsed[i],"/");
|
|
|
|
|
|
|
|
char *device_name = yon_char_new(pa);
|
|
|
|
|
|
|
|
char *id = yon_char_divide_search(device_name," ",-1);
|
|
|
|
|
|
|
|
free(device_name);
|
|
|
|
|
|
|
|
device_limits *limits = malloc(sizeof(device_limits));
|
|
|
|
|
|
|
|
limits->device_name = yon_char_new(pa);
|
|
|
|
|
|
|
|
limits->read=NULL;
|
|
|
|
|
|
|
|
limits->write=NULL;
|
|
|
|
|
|
|
|
yon_dictionary_add_or_create_if_exists_with_data(window->devices,id,limits);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
yon_char_parsed_free(devices_parsed,size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void on_device_current_changed(GtkWidget *, quota_window *window){
|
|
|
|
void on_device_set(GtkWidget *self, quota_window *window){
|
|
|
|
char *chosen = (char*)gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->DeviceLimitCombo));
|
|
|
|
char *id = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(window->DeviceLimitCombo));
|
|
|
|
if (!window->devices->data){
|
|
|
|
if (!yon_char_is_empty(id)){
|
|
|
|
printf("%s\n",gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->DeviceLimitCombo)));
|
|
|
|
dictionary *current = yon_dictionary_get(&window->devices,id);
|
|
|
|
yon_dictionary_get(&window->devices,chosen);
|
|
|
|
if (current){
|
|
|
|
if (!window->devices->data){
|
|
|
|
device_limits *limits = yon_dictionary_get_data(current,device_limits*);
|
|
|
|
window->devices->data = g_malloc0(sizeof(device_limits));
|
|
|
|
if (self == window->DeviceLimitReadCheck||self == window->DeviceLimitReadSpin||self == window->DeviceLimitReadCombo){
|
|
|
|
}
|
|
|
|
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->DeviceLimitReadCheck))){
|
|
|
|
((device_limits*)window->devices->data)->write=NULL;
|
|
|
|
long value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->DeviceLimitReadSpin));
|
|
|
|
((device_limits*)window->devices->data)->read=NULL;
|
|
|
|
if (!value) {
|
|
|
|
} else {
|
|
|
|
yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
|
|
|
|
long read_lim = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->DeviceLimitReadSpin));
|
|
|
|
yon_ubl_status_highlight_incorrect(window->DeviceLimitReadSpin);
|
|
|
|
long write_lim = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->DeviceLimitWriteSpin));
|
|
|
|
return;
|
|
|
|
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->DeviceLimitReadCheck))){
|
|
|
|
}
|
|
|
|
if (read_lim) yon_dictionary_get_data(window->devices,device_limits*)->read=yon_char_append(yon_char_from_long(read_lim),get_size_mod(GTK_COMBO_BOX(window->DeviceLimitReadCombo)));
|
|
|
|
char *value_str = yon_char_from_long(value);
|
|
|
|
} else yon_dictionary_get_data(window->devices,device_limits*)->read = NULL;
|
|
|
|
char *full_str = yon_char_unite(value_str,yon_size_get_mod(gtk_combo_box_get_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo))),NULL);
|
|
|
|
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->DeviceLimitWriteCheck))){
|
|
|
|
if (!yon_char_is_empty(limits->read)) free(limits->read);
|
|
|
|
if (write_lim) yon_dictionary_get_data(window->devices,device_limits*)->write=yon_char_append(yon_char_from_long(write_lim),get_size_mod(GTK_COMBO_BOX(window->DeviceLimitWriteCombo)));
|
|
|
|
limits->read=full_str;
|
|
|
|
} else yon_dictionary_get_data(window->devices,device_limits*)->write = NULL;
|
|
|
|
} else {
|
|
|
|
yon_dictionary_get(&window->devices,chosen);
|
|
|
|
limits->read=NULL;
|
|
|
|
if (!window->devices->data){
|
|
|
|
}
|
|
|
|
window->devices->data = g_malloc0(sizeof(device_limits));
|
|
|
|
} else if (self == window->DeviceLimitWriteCheck||self == window->DeviceLimitWriteSpin||self == window->DeviceLimitWriteCombo){
|
|
|
|
}
|
|
|
|
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->DeviceLimitWriteCheck))){
|
|
|
|
((device_limits*)window->devices->data)->write=NULL;
|
|
|
|
long value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->DeviceLimitWriteSpin));
|
|
|
|
((device_limits*)window->devices->data)->read=NULL;
|
|
|
|
if (!value) {
|
|
|
|
char *read = yon_dictionary_get_data(window->devices,device_limits*)->read;
|
|
|
|
yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
|
|
|
|
char *write = yon_dictionary_get_data(window->devices,device_limits*)->write;
|
|
|
|
yon_ubl_status_highlight_incorrect(window->DeviceLimitWriteSpin);
|
|
|
|
if (read) {
|
|
|
|
return;
|
|
|
|
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitReadSpin),atoi(read));
|
|
|
|
}
|
|
|
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitReadCheck),1);
|
|
|
|
char *value_str = yon_char_from_long(value);
|
|
|
|
switch (read[strlen(read)-1]){
|
|
|
|
char *full_str = yon_char_unite(value_str,yon_size_get_mod(gtk_combo_box_get_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo))),NULL);
|
|
|
|
case 'K': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),0);
|
|
|
|
if (!yon_char_is_empty(limits->read)) free(limits->read);
|
|
|
|
break;
|
|
|
|
limits->read=full_str;
|
|
|
|
case 'M': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),1);
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
limits->read=NULL;
|
|
|
|
case 'G': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),2);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'T': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),3);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitReadSpin),0);
|
|
|
|
|
|
|
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitReadCheck),0);
|
|
|
|
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),0);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (write) {
|
|
|
|
}
|
|
|
|
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitWriteSpin),atoi(write));
|
|
|
|
}
|
|
|
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitWriteCheck),1);
|
|
|
|
|
|
|
|
switch (write[strlen(write)-1]){
|
|
|
|
void on_device_current_changed(GtkWidget *, quota_window *window){
|
|
|
|
case 'K': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),0);
|
|
|
|
char *chosen = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(window->DeviceLimitCombo));
|
|
|
|
break;
|
|
|
|
if (!yon_char_is_empty(chosen)){
|
|
|
|
case 'M': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),1);
|
|
|
|
dictionary *current = yon_dictionary_get(&window->devices,chosen);
|
|
|
|
break;
|
|
|
|
if (current){
|
|
|
|
case 'G': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),2);
|
|
|
|
device_limits *limits = yon_dictionary_get_data(current,device_limits*);
|
|
|
|
break;
|
|
|
|
char *read = limits->read;
|
|
|
|
case 'T': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),3);
|
|
|
|
char *write = limits->write;
|
|
|
|
break;
|
|
|
|
if (!yon_char_is_empty(read)) {
|
|
|
|
|
|
|
|
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitReadSpin),atoi(read));
|
|
|
|
|
|
|
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitReadCheck),1);
|
|
|
|
|
|
|
|
switch (read[strlen(read)-1]){
|
|
|
|
|
|
|
|
case 'K': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),0);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'M': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),1);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'G': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),2);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'T': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),3);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitReadSpin),0);
|
|
|
|
|
|
|
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitReadCheck),0);
|
|
|
|
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!yon_char_is_empty(write)) {
|
|
|
|
|
|
|
|
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitWriteSpin),atoi(write));
|
|
|
|
|
|
|
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitWriteCheck),1);
|
|
|
|
|
|
|
|
switch (write[strlen(write)-1]){
|
|
|
|
|
|
|
|
case 'K': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),0);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'M': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),1);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'G': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),2);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'T': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),3);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitWriteSpin),0);
|
|
|
|
|
|
|
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitWriteCheck),0);
|
|
|
|
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitWriteSpin),0);
|
|
|
|
|
|
|
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitWriteCheck),0);
|
|
|
|
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),0);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitReadCheck),0);
|
|
|
|
|
|
|
|
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitReadSpin),0);
|
|
|
|
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),0);
|
|
|
|
|
|
|
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitWriteCheck),0);
|
|
|
|
|
|
|
|
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitWriteSpin),0);
|
|
|
|
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -312,7 +350,6 @@ void on_quotas_save(GtkWidget *self, dictionary *windows){
|
|
|
|
if (!yon_char_is_empty(read_devices)&&read_devices[strlen(read_devices)-1]=='\n') read_devices[strlen(read_devices)-1]='\0';
|
|
|
|
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);
|
|
|
|
read_limit = yon_char_unite(read_limit?read_limit:"",read_devices,NULL);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char *write_limit = NULL;
|
|
|
|
char *write_limit = NULL;
|
|
|
|
char *write_devices = NULL;
|
|
|
|
char *write_devices = NULL;
|
|
|
|
for_dictionaries(dict,window->devices){
|
|
|
|
for_dictionaries(dict,window->devices){
|
|
|
@ -537,7 +574,7 @@ 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;
|
|
|
@ -551,7 +588,7 @@ 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;
|
|
|
@ -736,6 +773,12 @@ void on_add_open(GtkWidget *, main_window *widgets){
|
|
|
|
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->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->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->SoftRestrictionSpin),"change-value",G_CALLBACK(on_check_maximum),window->SoftRestrictionCombo);
|
|
|
@ -761,8 +804,8 @@ void on_add_open(GtkWidget *, main_window *widgets){
|
|
|
|
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->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->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_gtk_widget_set_sensitive_from_combo_box),window->DeviceLimitReadCheck);
|
|
|
|
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_gtk_widget_set_sensitive_from_combo_box),window->DeviceLimitWriteCheck);
|
|
|
|
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->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->SoftRestrictionCombo),"changed",G_CALLBACK(on_quota_configuration_update),window);
|
|
|
@ -787,11 +830,21 @@ void on_add_open(GtkWidget *, main_window *widgets){
|
|
|
|
yon_get_devices(window);
|
|
|
|
yon_get_devices(window);
|
|
|
|
dictionary *dict;
|
|
|
|
dictionary *dict;
|
|
|
|
for_dictionaries(dict,window->devices){
|
|
|
|
for_dictionaries(dict,window->devices){
|
|
|
|
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(window->DeviceLimitCombo),dict->key);
|
|
|
|
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.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.processes = yon_config_load(get_processes_command,&main_config.processes_size);
|
|
|
|
main_config.slices = yon_config_load(get_slices_command,&main_config.slices_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++){
|
|
|
|
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_text(GTK_COMBO_BOX_TEXT(window->TargetCombo),main_config.users[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -880,7 +933,7 @@ void on_quotas_edit(GtkWidget *self, dictionary *windows){
|
|
|
|
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)
|
|
|
|
if (dict->data&&yon_dictionary_get_data(dict,device_limits*)->read)
|
|
|
|
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);
|
|
|
|
read_devices = yon_char_unite(read_devices?read_devices:"","",dict->key," ",yon_dictionary_get_data(dict,device_limits*)->read,"\n",NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (read_devices[strlen(read_devices)-1]=='\n') read_devices[strlen(read_devices)-1]='\0';
|
|
|
|
if (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);
|
|
|
|
read_limit = yon_char_unite(read_limit?read_limit:"",read_devices,NULL);
|
|
|
@ -890,7 +943,7 @@ void on_quotas_edit(GtkWidget *self, dictionary *windows){
|
|
|
|
char *write_devices = NULL;
|
|
|
|
char *write_devices = NULL;
|
|
|
|
for_dictionaries(dict,window->devices){
|
|
|
|
for_dictionaries(dict,window->devices){
|
|
|
|
if (dict->data&&yon_dictionary_get_data(dict,device_limits*)->write)
|
|
|
|
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);
|
|
|
|
write_devices = yon_char_unite(write_devices?write_devices:"","",dict->key," ",yon_dictionary_get_data(dict,device_limits*)->write,"\n",NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (write_devices[strlen(write_devices)-1]=='\n') write_devices[strlen(write_devices)-1]='\0';
|
|
|
|
if (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);
|
|
|
|
write_limit = yon_char_unite(write_limit?write_limit:"",write_devices,NULL);
|
|
|
@ -902,6 +955,14 @@ void on_quotas_edit(GtkWidget *self, dictionary *windows){
|
|
|
|
else yon_ubl_status_box_render(NOTHING_CHOSEN_LABEL,BACKGROUND_IMAGE_FAIL_TYPE);
|
|
|
|
else yon_ubl_status_box_render(NOTHING_CHOSEN_LABEL,BACKGROUND_IMAGE_FAIL_TYPE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void yon_widget_set_sensitive(GtkComboBox *toggle, GtkWidget *target){
|
|
|
|
|
|
|
|
if (gtk_combo_box_get_active(toggle)>-1){
|
|
|
|
|
|
|
|
gtk_widget_set_sensitive(target,1);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
gtk_widget_set_sensitive(target,0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void on_edit_open(GtkWidget *, main_window *widgets){
|
|
|
|
void on_edit_open(GtkWidget *, main_window *widgets){
|
|
|
|
GtkTreeModel *model = GTK_TREE_MODEL(main_config.list);
|
|
|
|
GtkTreeModel *model = GTK_TREE_MODEL(main_config.list);
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeIter iter;
|
|
|
@ -944,6 +1005,7 @@ void on_edit_open(GtkWidget *, main_window *widgets){
|
|
|
|
window->EditQuotaTargetBox = yon_gtk_builder_get_widget(builder,"EditQuotaTargetBox");
|
|
|
|
window->EditQuotaTargetBox = yon_gtk_builder_get_widget(builder,"EditQuotaTargetBox");
|
|
|
|
window->TargetCombo = yon_gtk_builder_get_widget(builder,"TargetCombo");
|
|
|
|
window->TargetCombo = yon_gtk_builder_get_widget(builder,"TargetCombo");
|
|
|
|
window->TargetLabel = yon_gtk_builder_get_widget(builder,"TargetLabel");
|
|
|
|
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->SoftRestrictionCheck = yon_gtk_builder_get_widget(builder,"SoftRestrictionCheck");
|
|
|
|
window->SoftRestrictionSpin = yon_gtk_builder_get_widget(builder,"SoftRestrictionSpin");
|
|
|
|
window->SoftRestrictionSpin = yon_gtk_builder_get_widget(builder,"SoftRestrictionSpin");
|
|
|
@ -1024,24 +1086,26 @@ void on_edit_open(GtkWidget *, main_window *widgets){
|
|
|
|
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->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->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_gtk_widget_set_sensitive_from_combo_box),window->DeviceLimitReadCheck);
|
|
|
|
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_gtk_widget_set_sensitive_from_combo_box),window->DeviceLimitWriteCheck);
|
|
|
|
g_signal_connect(G_OBJECT(window->DeviceLimitCombo),"changed",G_CALLBACK(yon_widget_set_sensitive),window->DeviceLimitWriteCheck);
|
|
|
|
|
|
|
|
|
|
|
|
yon_get_devices(window);
|
|
|
|
yon_get_devices(window);
|
|
|
|
dictionary *dict;
|
|
|
|
dictionary *dict;
|
|
|
|
gtk_widget_set_sensitive(window->BlockUiBox,1);
|
|
|
|
gtk_widget_set_sensitive(window->BlockUiBox,1);
|
|
|
|
|
|
|
|
gtk_label_set_text(GTK_LABEL(window->TypeLabel),type);
|
|
|
|
gtk_label_set_text(GTK_LABEL(window->TargetLabel),target);
|
|
|
|
gtk_label_set_text(GTK_LABEL(window->TargetLabel),target);
|
|
|
|
int read_size=0;
|
|
|
|
int read_size=0;
|
|
|
|
config_str read_parsed = yon_char_parse(read,&read_size,"\n");
|
|
|
|
config_str read_parsed = yon_char_parse(read,&read_size,"\n");
|
|
|
|
int write_size=0;
|
|
|
|
int write_size=0;
|
|
|
|
config_str write_parsed = yon_char_parse(write,&write_size,"\n");
|
|
|
|
config_str write_parsed = yon_char_parse(write,&write_size,"\n");
|
|
|
|
for_dictionaries(dict,window->devices){
|
|
|
|
for_dictionaries(dict,window->devices){
|
|
|
|
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(window->DeviceLimitCombo),dict->key);
|
|
|
|
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);
|
|
|
|
if (read_parsed)
|
|
|
|
if (read_parsed)
|
|
|
|
for (int i=0; i<read_size;i++){
|
|
|
|
for (int i=0; i<read_size;i++){
|
|
|
|
char *read_limit = yon_char_new(read_parsed[i]);
|
|
|
|
char *read_limit = yon_char_new(read_parsed[i]);
|
|
|
|
char *read_cur = yon_char_divide_search(read_limit," ",-1);
|
|
|
|
char *read_cur = yon_char_divide_search(read_limit," ",-1);
|
|
|
|
if (strstr(dict->key,read_cur)){
|
|
|
|
if (strstr(temp,read_cur)){
|
|
|
|
if(!dict->data){
|
|
|
|
if(!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;
|
|
|
@ -1053,7 +1117,7 @@ void on_edit_open(GtkWidget *, main_window *widgets){
|
|
|
|
else{
|
|
|
|
else{
|
|
|
|
char *read_limit = yon_char_new(read);
|
|
|
|
char *read_limit = yon_char_new(read);
|
|
|
|
char *read_cur = yon_char_divide_search(read_limit," ",-1);
|
|
|
|
char *read_cur = yon_char_divide_search(read_limit," ",-1);
|
|
|
|
if (strstr(dict->key,read_cur)){
|
|
|
|
if (strstr(temp,read_cur)){
|
|
|
|
if(!dict->data){
|
|
|
|
if(!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;
|
|
|
@ -1066,7 +1130,7 @@ void on_edit_open(GtkWidget *, main_window *widgets){
|
|
|
|
for (int i=0; i<write_size;i++){
|
|
|
|
for (int i=0; i<write_size;i++){
|
|
|
|
char *write_limit = yon_char_new(write_parsed[i]);
|
|
|
|
char *write_limit = yon_char_new(write_parsed[i]);
|
|
|
|
char *write_cur = yon_char_divide_search(write_limit," ",-1);
|
|
|
|
char *write_cur = yon_char_divide_search(write_limit," ",-1);
|
|
|
|
if (strstr(dict->key,write_cur)){
|
|
|
|
if (strstr(temp,write_cur)){
|
|
|
|
if(!dict->data){
|
|
|
|
if(!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;
|
|
|
@ -1078,7 +1142,7 @@ void on_edit_open(GtkWidget *, main_window *widgets){
|
|
|
|
else{
|
|
|
|
else{
|
|
|
|
char *write_limit = yon_char_new(write);
|
|
|
|
char *write_limit = yon_char_new(write);
|
|
|
|
char *write_cur = yon_char_divide_search(write_limit," ",-1);
|
|
|
|
char *write_cur = yon_char_divide_search(write_limit," ",-1);
|
|
|
|
if (strstr(dict->key,write_cur)){
|
|
|
|
if (strstr(temp,write_cur)){
|
|
|
|
if(!dict->data){
|
|
|
|
if(!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;
|
|
|
@ -1093,6 +1157,12 @@ void on_edit_open(GtkWidget *, main_window *widgets){
|
|
|
|
window->devices=window->devices->first;
|
|
|
|
window->devices=window->devices->first;
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitCombo),0);
|
|
|
|
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->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){
|
|
|
|
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);
|
|
|
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitReadCheck),1);
|
|
|
|
char *rd = ((device_limits*)window->devices->data)->read;
|
|
|
|
char *rd = ((device_limits*)window->devices->data)->read;
|
|
|
|