diff --git a/source/ubl-settings-resourcequota.c b/source/ubl-settings-resourcequota.c index 1a92013..ef69879 100644 --- a/source/ubl-settings-resourcequota.c +++ b/source/ubl-settings-resourcequota.c @@ -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; - on_device_limits_update(self,window); 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 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); for (int i=0; idevices,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){ - char *chosen = (char*)gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->DeviceLimitCombo)); - if (!window->devices->data){ - printf("%s\n",gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->DeviceLimitCombo))); - yon_dictionary_get(&window->devices,chosen); - if (!window->devices->data){ - window->devices->data = g_malloc0(sizeof(device_limits)); - } - ((device_limits*)window->devices->data)->write=NULL; - ((device_limits*)window->devices->data)->read=NULL; - } else { - long read_lim = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->DeviceLimitReadSpin)); - long write_lim = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->DeviceLimitWriteSpin)); - 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))); - } else yon_dictionary_get_data(window->devices,device_limits*)->read = NULL; - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->DeviceLimitWriteCheck))){ - 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))); - } else yon_dictionary_get_data(window->devices,device_limits*)->write = NULL; - yon_dictionary_get(&window->devices,chosen); - if (!window->devices->data){ - window->devices->data = g_malloc0(sizeof(device_limits)); - } - ((device_limits*)window->devices->data)->write=NULL; - ((device_limits*)window->devices->data)->read=NULL; - char *read = yon_dictionary_get_data(window->devices,device_limits*)->read; - char *write = yon_dictionary_get_data(window->devices,device_limits*)->write; - if (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; +void on_device_set(GtkWidget *self, quota_window *window){ + char *id = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(window->DeviceLimitCombo)); + if (!yon_char_is_empty(id)){ + dictionary *current = yon_dictionary_get(&window->devices,id); + if (current){ + device_limits *limits = yon_dictionary_get_data(current,device_limits*); + if (self == window->DeviceLimitReadCheck||self == window->DeviceLimitReadSpin||self == window->DeviceLimitReadCombo){ + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->DeviceLimitReadCheck))){ + long value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->DeviceLimitReadSpin)); + if (!value) { + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->DeviceLimitReadSpin); + return; + } + 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->DeviceLimitReadCombo))),NULL); + if (!yon_char_is_empty(limits->read)) free(limits->read); + limits->read=full_str; + } else { + limits->read=NULL; + } + } else if (self == window->DeviceLimitWriteCheck||self == window->DeviceLimitWriteSpin||self == window->DeviceLimitWriteCombo){ + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->DeviceLimitWriteCheck))){ + long value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->DeviceLimitWriteSpin)); + if (!value) { + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->DeviceLimitWriteSpin); + return; + } + 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); + if (!yon_char_is_empty(limits->read)) free(limits->read); + limits->read=full_str; + } else { + limits->read=NULL; + } } - } 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]){ - 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; + } +} + +void on_device_current_changed(GtkWidget *, quota_window *window){ + char *chosen = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(window->DeviceLimitCombo)); + if (!yon_char_is_empty(chosen)){ + dictionary *current = yon_dictionary_get(&window->devices,chosen); + if (current){ + device_limits *limits = yon_dictionary_get_data(current,device_limits*); + char *read = limits->read; + char *write = limits->write; + 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'; 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){ @@ -537,7 +574,7 @@ void on_quota_manual_input(GtkWidget *self, quota_window *window){ char *name = yon_char_divide_search(value, " ",-1); dictionary *dict; for_dictionaries(dict,window->devices){ - if (strstr(dict->key,name)){ + if (!strcmp(dict->key,name)){ if (!((device_limits*)dict->data)){ dict->data = g_malloc0(sizeof(device_limits)); ((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); dictionary *dict; for_dictionaries(dict,window->devices){ - if (strstr(dict->key,name)){ + if (!strcmp(dict->key,name)){ if (!((device_limits*)dict->data)){ dict->data = g_malloc0(sizeof(device_limits)); ((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); 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); @@ -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->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_gtk_widget_set_sensitive_from_combo_box),window->DeviceLimitWriteCheck); + 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); @@ -787,11 +830,21 @@ void on_add_open(GtkWidget *, main_window *widgets){ yon_get_devices(window); dictionary *dict; 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.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;iTargetCombo),main_config.users[i]); } @@ -880,7 +933,7 @@ void on_quotas_edit(GtkWidget *self, dictionary *windows){ dictionary *dict; for_dictionaries(dict,window->devices){ 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'; 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; 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); + 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'; 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); } +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){ GtkTreeModel *model = GTK_TREE_MODEL(main_config.list); GtkTreeIter iter; @@ -944,6 +1005,7 @@ void on_edit_open(GtkWidget *, main_window *widgets){ 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->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"); @@ -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->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_gtk_widget_set_sensitive_from_combo_box),window->DeviceLimitWriteCheck); + 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); yon_get_devices(window); dictionary *dict; 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); int read_size=0; config_str read_parsed = yon_char_parse(read,&read_size,"\n"); int write_size=0; config_str write_parsed = yon_char_parse(write,&write_size,"\n"); 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) for (int i=0; ikey,read_cur)){ + if (strstr(temp,read_cur)){ if(!dict->data){ dict->data = g_malloc0(sizeof(device_limits)); ((device_limits*)dict->data)->write=NULL; @@ -1053,7 +1117,7 @@ void on_edit_open(GtkWidget *, main_window *widgets){ else{ char *read_limit = yon_char_new(read); char *read_cur = yon_char_divide_search(read_limit," ",-1); - if (strstr(dict->key,read_cur)){ + if (strstr(temp,read_cur)){ if(!dict->data){ dict->data = g_malloc0(sizeof(device_limits)); ((device_limits*)dict->data)->write=NULL; @@ -1066,7 +1130,7 @@ void on_edit_open(GtkWidget *, main_window *widgets){ for (int i=0; ikey,write_cur)){ + if (strstr(temp,write_cur)){ if(!dict->data){ dict->data = g_malloc0(sizeof(device_limits)); ((device_limits*)dict->data)->write=NULL; @@ -1078,7 +1142,7 @@ void on_edit_open(GtkWidget *, main_window *widgets){ else{ char *write_limit = yon_char_new(write); char *write_cur = yon_char_divide_search(write_limit," ",-1); - if (strstr(dict->key,write_cur)){ + if (strstr(temp,write_cur)){ if(!dict->data){ dict->data = g_malloc0(sizeof(device_limits)); ((device_limits*)dict->data)->write=NULL; @@ -1093,6 +1157,12 @@ void on_edit_open(GtkWidget *, main_window *widgets){ 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; diff --git a/source/ubl-settings-resourcequota.h b/source/ubl-settings-resourcequota.h index dc299b4..ce9d9e0 100644 --- a/source/ubl-settings-resourcequota.h +++ b/source/ubl-settings-resourcequota.h @@ -136,6 +136,7 @@ typedef struct { GtkWidget *TargetTypeCombo; GtkWidget *TargetCombo; GtkWidget *TargetLabel; + GtkWidget *TypeLabel; GtkWidget *SoftRestrictionCheck; GtkWidget *SoftRestrictionSpin; GtkWidget *SoftRestrictionCombo; @@ -177,6 +178,7 @@ typedef struct { } filters_window; typedef struct { + char *device_name; char *read; char *write; } device_limits; @@ -220,4 +222,6 @@ void on_check_maximum_cpu(GtkWidget *self, GtkWidget *pair); void on_check_maximum(GtkWidget *self, GtkWidget *pair); void on_limit_manual_input(GtkWidget *self, double *new_value, quota_window *window); void on_quota_configuration_update(GtkWidget *self, quota_window *window); -void on_device_limits_update(GtkWidget *, quota_window *window); \ No newline at end of file +void on_device_limits_update(GtkWidget *, quota_window *window); +void yon_widget_set_sensitive(GtkComboBox *toggle, GtkWidget *target); +void on_device_set(GtkWidget *self, quota_window *window); \ No newline at end of file diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 0915a56..8f641a7 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -87,6 +87,8 @@ #define VIEW_PROPERTIES_LABEL _("View properties for") +#define EMPTY_IMPORTANT_LABEL _("Important field is empty") + #define REMOVE_TITLE_LABEL _("Remove quota") #define REMOVE_VALIDATION_LABEL(target) yon_char_unite(_("Are you sure you want to remove quota")," ",target,"?",NULL) #define ADDING_LABEL _("Add quota") diff --git a/ubl-settings-resourcequota-quota.glade b/ubl-settings-resourcequota-quota.glade index 302ac46..3f808c8 100644 --- a/ubl-settings-resourcequota-quota.glade +++ b/ubl-settings-resourcequota-quota.glade @@ -3,6 +3,57 @@ + + 1 + 1 + 1 + 1 + 10 + + + 1 + 1 + 1 + 1 + 10 + + + 1 + 1 + 1 + 1 + 10 + + + 1 + 1 + 1 + 1 + 10 + + + 1 + 1 + 1 + 1 + 10 + + + 1 + 1 + 1 + 10 + + + True + False + process-stop-symbolic + + + True + False + emblem-ok-symbolic + False start @@ -105,6 +156,8 @@ False + 5 + 5 5 @@ -119,9 +172,10 @@ - + True False + label False @@ -129,6 +183,20 @@ 1 + + + True + False + + + + + + False + True + 2 + + False @@ -941,55 +1009,4 @@ - - 1 - 1 - 1 - 1 - 10 - - - 1 - 1 - 1 - 1 - 10 - - - 1 - 1 - 1 - 1 - 10 - - - 1 - 1 - 1 - 1 - 10 - - - 1 - 1 - 1 - 1 - 10 - - - 1 - 1 - 1 - 10 - - - True - False - process-stop-symbolic - - - True - False - emblem-ok-symbolic -