Information button shows right type and name of shown element

pull/61/head
Ivan Yartsev 2 years ago
parent a6ebd67a9a
commit 7d9fed8cc0

@ -294,6 +294,8 @@ void on_device_current_changed(GtkWidget *self, quota_window *window){
yon_dictionary_get(&window->devices,chosen); yon_dictionary_get(&window->devices,chosen);
if (!window->devices->data) if (!window->devices->data)
window->devices->data = g_malloc0(sizeof(device_limits)); window->devices->data = g_malloc0(sizeof(device_limits));
((device_limits*)window->devices->data)->write=NULL;
((device_limits*)window->devices->data)->read=NULL;
} else { } else {
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->DeviceLimitReadCheck))) if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->DeviceLimitReadCheck)))
yon_dictionary_get_data(window->devices,device_limits*)->read=yon_char_append(yon_char_from_long(gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->DeviceLimitReadSpin))),get_size_mod(GTK_COMBO_BOX(window->DeviceLimitReadCombo))); yon_dictionary_get_data(window->devices,device_limits*)->read=yon_char_append(yon_char_from_long(gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->DeviceLimitReadSpin))),get_size_mod(GTK_COMBO_BOX(window->DeviceLimitReadCombo)));
@ -304,6 +306,8 @@ void on_device_current_changed(GtkWidget *self, quota_window *window){
yon_dictionary_get(&window->devices,chosen); yon_dictionary_get(&window->devices,chosen);
if (!window->devices->data) if (!window->devices->data)
window->devices->data = g_malloc0(sizeof(device_limits)); 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 *read = yon_dictionary_get_data(window->devices,device_limits*)->read;
char *write = yon_dictionary_get_data(window->devices,device_limits*)->write; char *write = yon_dictionary_get_data(window->devices,device_limits*)->write;
if (read) { if (read) {
@ -511,6 +515,149 @@ void on_apply_filters(GtkWidget *self, dictionary *dict){
on_close_subwindow(self); on_close_subwindow(self);
} }
// void on_quota_manual_input(GtkWidget *self, quota_window *window){
// // g_signal_handlers_block_by_func(G_OBJECT(window));
// int size=0;
// char *string = yon_char_new((char*)gtk_entry_get_text(GTK_ENTRY(self)));
// config_str rtn = yon_char_parse(string,&size,",");
// if (rtn){
// for (int i=0; i<size; i++){
// char *value = yon_char_new(rtn[i]);
// yon_char_divide_search(value,"=",-1);
// int size = yon_get_size_request_from_letter(value[strlen(value)-1]);
// if (size!=-1||strstr(rtn[i],"CPUQuota=")){
// // value[strlen(value)-1]='\0';
// if (strstr(rtn[i],"MemoryHigh=")){
// 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_combo_box_set_active(GTK_COMBO_BOX(window->SoftRestrictionCombo),size);
// } else if (strstr(rtn[i],"MemoryMax=")){
// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->HardRestrictionCheck),1);
// gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->HardRestrictionSpin),strtol(value,NULL,10));
// gtk_combo_box_set_active(GTK_COMBO_BOX(window->HardRestrictionCombo),size);
// } else if (strstr(rtn[i],"MemorySwapMax=")){
// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->PagingLimitCheck),1);
// gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->PagingLimitSpin),strtol(value,NULL,10));
// gtk_combo_box_set_active(GTK_COMBO_BOX(window->PagingLimitCombo),size);
// } else if (strstr(rtn[i],"CPUQuota=")){
// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->CpuLimitCheck),1);
// gtk_spin_button_set_value(GTK_SPIN_BUTTON(window-> CpuLimitSpin),strtol(value,NULL,10));
// } else if (strstr(rtn[i],"IOReadBandwidthMax=")){
// char *name = yon_char_divide_search(value, " ",-1);
// dictionary *dict;
// for_dictionaries(dict,window->devices){
// if (strstr(dict->key,name)){
// if (!((device_limits*)dict->data)){
// dict->data = g_malloc0(sizeof(device_limits));
// ((device_limits*)dict->data)->write=NULL;
// ((device_limits*)dict->data)->read=NULL;
// }
// ((device_limits*)dict->data)->read = value;
// }
// }
// } else if (strstr(rtn[i],"IOWriteBandwidthMax=")){
// char *name = yon_char_divide_search(value, " ",-1);
// dictionary *dict;
// for_dictionaries(dict,window->devices){
// if (strstr(dict->key,name)){
// if (!((device_limits*)dict->data)){
// dict->data = g_malloc0(sizeof(device_limits));
// ((device_limits*)dict->data)->write=NULL;
// ((device_limits*)dict->data)->read=NULL;
// }
// ((device_limits*)dict->data)->write = value;
// }
// }
// } else return;
// }
// free(value);
// }
// } else {
// char *value = yon_char_new(string);
// yon_char_divide_search(value,"=",-1);
// int size = yon_get_size_request_from_letter(value[strlen(value)-1]);
// if (size!=-1||strstr(string,"CPUQuota=")){
// // value[strlen(value)-1]='\0';
// if (strstr(string,"MemoryHigh=")){
// 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_combo_box_set_active(GTK_COMBO_BOX(window->SoftRestrictionCombo),size);
// } else if (strstr(string,"MemoryMax=")){
// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->HardRestrictionCheck),1);
// gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->HardRestrictionSpin),strtol(value,NULL,10));
// gtk_combo_box_set_active(GTK_COMBO_BOX(window->HardRestrictionCombo),size);
// } else if (strstr(string,"MemorySwapMax=")){
// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->PagingLimitCheck),1);
// gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->PagingLimitSpin),strtol(value,NULL,10));
// gtk_combo_box_set_active(GTK_COMBO_BOX(window->PagingLimitCombo),size);
// } else if (strstr(string,"CPUQuota=")){
// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->CpuLimitCheck),1);
// gtk_spin_button_set_value(GTK_SPIN_BUTTON(window-> CpuLimitSpin),strtol(value,NULL,10));
// } else if (strstr(string,"IOReadBandwidthMax=")){
// char *name = yon_char_divide_search(value, " ",-1);
// dictionary *dict;
// for_dictionaries(dict,window->devices){
// if (strstr(dict->key,name)){
// if (!((device_limits*)dict->data)){
// dict->data = g_malloc0(sizeof(device_limits));
// ((device_limits*)dict->data)->write=NULL;
// ((device_limits*)dict->data)->read=NULL;
// }
// ((device_limits*)dict->data)->read = value;
// }
// }
// } else if (strstr(string,"IOWriteBandwidthMax=")){
// char *name = yon_char_divide_search(value, " ",-1);
// dictionary *dict;
// for_dictionaries(dict,window->devices){
// if (strstr(dict->key,name)){
// if (!((device_limits*)dict->data)){
// dict->data = g_malloc0(sizeof(device_limits));
// ((device_limits*)dict->data)->write=NULL;
// ((device_limits*)dict->data)->read=NULL;
// }
// ((device_limits*)dict->data)->write = value;
// }
// }
// } else return;
// }
// }
// g_signal_handlers_block_by_func(G_OBJECT(window->DeviceLimitCombo),G_CALLBACK(on_device_current_changed),window);
// gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitCombo),0);
// g_signal_handlers_unblock_by_func(G_OBJECT(window->DeviceLimitCombo),G_CALLBACK(on_device_current_changed),window);
// if (window->devices->data){
// if (((device_limits*)window->devices->data)->read&&strcmp(((device_limits*)window->devices->data)->read,"")!=0){
// char *rd = ((device_limits*)window->devices->data)->read;
// g_signal_handlers_block_by_func(G_OBJECT(window->DeviceLimitReadCheck),G_CALLBACK(on_quota_configuration_update),window);
// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitReadCheck),1);
// g_signal_handlers_unblock_by_func(G_OBJECT(window->DeviceLimitReadCheck),G_CALLBACK(on_quota_configuration_update),window);
// 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;
// }
// }
// void on_quota_manual_input_focus (GtkWidget *self, GdkEventFocus *event, quota_window *window){
// on_quota_manual_input(self,window);
// }
void on_filters_opened(GtkWidget *self, main_window *widgets) { void on_filters_opened(GtkWidget *self, main_window *widgets) {
GtkBuilder *builder = gtk_builder_new_from_resource(glade_filters_path); GtkBuilder *builder = gtk_builder_new_from_resource(glade_filters_path);
@ -665,6 +812,9 @@ void on_add_open(GtkWidget *self, main_window *widgets){
g_signal_connect(G_OBJECT(window->CpuLimitCheck),"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->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->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); yon_get_devices(window);
dictionary *dict; dictionary *dict;
for_dictionaries(dict,window->devices){ for_dictionaries(dict,window->devices){
@ -692,10 +842,17 @@ void on_information(GtkWidget *self, main_window *widgets){
GtkTreeModel *model = GTK_TREE_MODEL(main_config.list); GtkTreeModel *model = GTK_TREE_MODEL(main_config.list);
GtkTreeIter iter; GtkTreeIter iter;
if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree)),&model,&iter)){ if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree)),&model,&iter)){
char *name; char *name, *group;
gtk_tree_model_get(model,&iter,1,&name,-1); gtk_tree_model_get(model,&iter,1,&name,0,&group,-1);
g_signal_handlers_block_by_func(G_OBJECT(widgets->TargetCombo),on_information_chosen_changed,widgets); g_signal_handlers_block_by_func(G_OBJECT(widgets->TargetCombo),on_information_chosen_changed,widgets);
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->TargetCombo),-1); if (strcmp(group,STR_PROCESS)==0){
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->TargetTypeCombo),1);
} else if (strcmp(group,STR_SLICE)==0){
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->TargetTypeCombo),2);
} else {
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));
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 = yon_char_unite(get_information_command, (char*)name," --no-pager",NULL); char *command = yon_char_unite(get_information_command, (char*)name," --no-pager",NULL);
main_config.last_info = yon_char_new((char*)name); main_config.last_info = yon_char_new((char*)name);
@ -892,8 +1049,11 @@ void on_edit_open(GtkWidget *self, main_window *widgets){
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(dict->key,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)->read=NULL;
}
((device_limits*)dict->data)->read=read_limit; ((device_limits*)dict->data)->read=read_limit;
} }
} }
@ -901,8 +1061,11 @@ void on_edit_open(GtkWidget *self, main_window *widgets){
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(dict->key,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)->read=NULL;
}
((device_limits*)dict->data)->read=read_limit; ((device_limits*)dict->data)->read=read_limit;
} }
} }
@ -911,8 +1074,11 @@ void on_edit_open(GtkWidget *self, main_window *widgets){
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(dict->key,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)->read=NULL;
}
((device_limits*)dict->data)->write=write_limit; ((device_limits*)dict->data)->write=write_limit;
} }
} }
@ -920,8 +1086,11 @@ void on_edit_open(GtkWidget *self, main_window *widgets){
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(dict->key,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)->read=NULL;
}
((device_limits*)dict->data)->write=write_limit; ((device_limits*)dict->data)->write=write_limit;
} }
} }

@ -40,7 +40,7 @@
#define remove_local_command "ubconfig --target system remove security " #define remove_local_command "ubconfig --target system remove security "
#define get_devices_command "findmnt -lo source,target,fstype,label,size -t ext4 |grep -vE \"zram|\\]|\\[|SOURCE\"" #define get_devices_command "findmnt -lo source,target,fstype,label,size -t ext4 |grep -vE \"zram|\\]|\\[|SOURCE\""
#define get_processes_tree_command "clear; systemd-cgls --no-page" #define get_processes_tree_command "clear; systemd-cgls --no-page"
#define get_dispatcher_command "systemd-cgtop" #define get_dispatcher_command "clear; systemd-cgtop"
#define get_information_command "systemctl status " #define get_information_command "systemctl status "
#define CGROUP_QUOTA(name) yon_char_unite("CGROUP_QUOTA[",name,"]",NULL) #define CGROUP_QUOTA(name) yon_char_unite("CGROUP_QUOTA[",name,"]",NULL)

@ -1793,6 +1793,10 @@ int yon_gtk_combo_box_text_fill(GtkWidget *combo, config_str parameters,int size
* [RU] * [RU]
* Проивзодит поиск по GtkComboBoxText [combo_box] * Проивзодит поиск по GtkComboBoxText [combo_box]
* возвращает 1 если элемент [text_to_find] найден, иначе возвращает 0 * возвращает 1 если элемент [text_to_find] найден, иначе возвращает 0
* ИСПОЛЬЗОВАТЬ В СВЯЗКЕ С
* g_signal_handlers_block_by_func()
* и
* g_signal_handlers_unblock_by_func()
*/ */
int yon_gtk_combo_box_text_find(GtkWidget *combo_box, char *text_to_find){ int yon_gtk_combo_box_text_find(GtkWidget *combo_box, char *text_to_find){
if (combo_box&&text_to_find){ if (combo_box&&text_to_find){

Loading…
Cancel
Save