From 7d9fed8cc07464fa9401264980a8164f3587c77c Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 28 Aug 2023 16:40:43 +0600 Subject: [PATCH 1/9] Information button shows right type and name of shown element --- source/ubl-settings-resourcequota.c | 183 ++++++++++++++++++++++++++-- source/ubl-settings-resourcequota.h | 2 +- source/ubl-utils.c | 4 + 3 files changed, 181 insertions(+), 8 deletions(-) diff --git a/source/ubl-settings-resourcequota.c b/source/ubl-settings-resourcequota.c index 5b26c45..818ac91 100644 --- a/source/ubl-settings-resourcequota.c +++ b/source/ubl-settings-resourcequota.c @@ -294,6 +294,8 @@ void on_device_current_changed(GtkWidget *self, quota_window *window){ 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 { 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))); @@ -304,6 +306,8 @@ void on_device_current_changed(GtkWidget *self, quota_window *window){ 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) { @@ -511,6 +515,149 @@ void on_apply_filters(GtkWidget *self, dictionary *dict){ 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; idevices){ +// 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) { 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->DeviceLimitReadCheck),"toggled",G_CALLBACK(on_quota_configuration_update),window); g_signal_connect(G_OBJECT(window->DeviceLimitWriteCheck),"toggled",G_CALLBACK(on_quota_configuration_update),window); + + // g_signal_connect(G_OBJECT(window->ManualInputEntry),"activate",G_CALLBACK(on_quota_manual_input),window); + // g_signal_connect(G_OBJECT(window->ManualInputEntry),"focus-out-event",G_CALLBACK(on_quota_manual_input_focus),window); yon_get_devices(window); dictionary *dict; for_dictionaries(dict,window->devices){ @@ -692,10 +842,17 @@ void on_information(GtkWidget *self, main_window *widgets){ GtkTreeModel *model = GTK_TREE_MODEL(main_config.list); GtkTreeIter iter; if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree)),&model,&iter)){ - char *name; - gtk_tree_model_get(model,&iter,1,&name,-1); + char *name, *group; + 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); - 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); char *command = yon_char_unite(get_information_command, (char*)name," --no-pager",NULL); 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_cur = yon_char_divide_search(read_limit," ",-1); if (strstr(dict->key,read_cur)){ - if(!dict->data) + if(!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=read_limit; } } @@ -901,8 +1061,11 @@ void on_edit_open(GtkWidget *self, main_window *widgets){ char *read_limit = yon_char_new(read); char *read_cur = yon_char_divide_search(read_limit," ",-1); if (strstr(dict->key,read_cur)){ - if(!dict->data) + if(!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=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_cur = yon_char_divide_search(write_limit," ",-1); if (strstr(dict->key,write_cur)){ - if(!dict->data) + if(!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=write_limit; } } @@ -920,8 +1086,11 @@ void on_edit_open(GtkWidget *self, main_window *widgets){ char *write_limit = yon_char_new(write); char *write_cur = yon_char_divide_search(write_limit," ",-1); if (strstr(dict->key,write_cur)){ - if(!dict->data) + if(!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=write_limit; } } diff --git a/source/ubl-settings-resourcequota.h b/source/ubl-settings-resourcequota.h index 446539c..caa22f5 100644 --- a/source/ubl-settings-resourcequota.h +++ b/source/ubl-settings-resourcequota.h @@ -40,7 +40,7 @@ #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_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 CGROUP_QUOTA(name) yon_char_unite("CGROUP_QUOTA[",name,"]",NULL) diff --git a/source/ubl-utils.c b/source/ubl-utils.c index 49fc4f8..54bd253 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -1793,6 +1793,10 @@ int yon_gtk_combo_box_text_fill(GtkWidget *combo, config_str parameters,int size * [RU] * Проивзодит поиск по GtkComboBoxText [combo_box] * возвращает 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){ if (combo_box&&text_to_find){ From fe88c3768cdc0b6f988db823c5ee09cade98089b Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 28 Aug 2023 16:56:39 +0600 Subject: [PATCH 2/9] Changed buttons position --- ubl-settings-resourcequota.glade | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ubl-settings-resourcequota.glade b/ubl-settings-resourcequota.glade index 42681ad..760b607 100644 --- a/ubl-settings-resourcequota.glade +++ b/ubl-settings-resourcequota.glade @@ -1623,8 +1623,6 @@ limit True False - 5 - 5 Save @@ -1703,8 +1701,6 @@ limit True False - 5 - 5 Load From 8ea02f9f922a45a098dbebb9dd2cc4f17161733d Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 29 Aug 2023 10:25:55 +0600 Subject: [PATCH 3/9] About has fixed --- source/ubl-settings-resourcequota.c | 287 ++++++++++++++-------------- 1 file changed, 144 insertions(+), 143 deletions(-) diff --git a/source/ubl-settings-resourcequota.c b/source/ubl-settings-resourcequota.c index 818ac91..f41a7b9 100644 --- a/source/ubl-settings-resourcequota.c +++ b/source/ubl-settings-resourcequota.c @@ -515,149 +515,150 @@ void on_apply_filters(GtkWidget *self, dictionary *dict){ 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; idevices){ -// 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(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); -// } + } 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; + break; + } + } + + } 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) { GtkBuilder *builder = gtk_builder_new_from_resource(glade_filters_path); @@ -813,8 +814,8 @@ void on_add_open(GtkWidget *self, main_window *widgets){ g_signal_connect(G_OBJECT(window->DeviceLimitReadCheck),"toggled",G_CALLBACK(on_quota_configuration_update),window); g_signal_connect(G_OBJECT(window->DeviceLimitWriteCheck),"toggled",G_CALLBACK(on_quota_configuration_update),window); - // g_signal_connect(G_OBJECT(window->ManualInputEntry),"activate",G_CALLBACK(on_quota_manual_input),window); - // g_signal_connect(G_OBJECT(window->ManualInputEntry),"focus-out-event",G_CALLBACK(on_quota_manual_input_focus),window); + g_signal_connect(G_OBJECT(window->ManualInputEntry),"activate",G_CALLBACK(on_quota_manual_input),window); + g_signal_connect(G_OBJECT(window->ManualInputEntry),"focus-out-event",G_CALLBACK(on_quota_manual_input_focus),window); yon_get_devices(window); dictionary *dict; for_dictionaries(dict,window->devices){ From d48db3797058173f36045030e2e674dd7a19a545 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 30 Aug 2023 17:26:00 +0600 Subject: [PATCH 4/9] Column minimum size depends on its localised name label --- source/ubl-settings-resourcequota.c | 11 ++++++++++- source/ubl-utils.c | 5 +++++ source/ubl-utils.h | 2 ++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/source/ubl-settings-resourcequota.c b/source/ubl-settings-resourcequota.c index f41a7b9..5560957 100644 --- a/source/ubl-settings-resourcequota.c +++ b/source/ubl-settings-resourcequota.c @@ -1387,10 +1387,11 @@ int main(int argc, char *argv[]){ {"socket-ext-id", 1,0, 'e'}, {"socket-trd-id", 1,0, 't'}, {"debug", 0,0, 'd'}, + {"clean-config", 0,0, 'c'}, { NULL, 0, NULL, 0 } }; for (int i=0;iWindow)); yon_window_config_load(config_path); on_config_load_local(); + GList *list = gtk_tree_view_get_columns(GTK_TREE_VIEW(widgets->MainTree)); + for (int i = 0; i < g_list_length(list); i++){ + yon_gtk_column_minimal_fixed_size_set((GtkTreeViewColumn*)g_list_nth_data(list,i)); + } + g_list_free(list); + GtkCssProvider *css=gtk_css_provider_new(); gtk_css_provider_load_from_resource(css,CssPath); gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), diff --git a/source/ubl-utils.c b/source/ubl-utils.c index 54bd253..bf36151 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -1811,6 +1811,11 @@ int yon_gtk_combo_box_text_find(GtkWidget *combo_box, char *text_to_find){ } return -1; } +void yon_gtk_column_minimal_fixed_size_set(GtkTreeViewColumn *column){ + int width= gtk_tree_view_column_get_width(column); + gtk_tree_view_column_set_min_width(column,width); +} + /**yon_dictionary_gtk_pack_start_multiple_widgets(GtkBox *destination, gboolean expand, gboolean fill, int padding, ...) * [EN] * diff --git a/source/ubl-utils.h b/source/ubl-utils.h index 5983344..dcdd903 100644 --- a/source/ubl-utils.h +++ b/source/ubl-utils.h @@ -277,6 +277,8 @@ int yon_gtk_combo_box_fill(GtkWidget *combo, char **parameters,int size); int yon_gtk_combo_box_text_find(GtkWidget *combo_box, char *text_to_find); +void yon_gtk_column_minimal_fixed_size_set(GtkTreeViewColumn *column); + int yon_gtk_icon_view_hide_empty(dictionary *icon_view_segment); int yon_dictionary_gtk_pack_start_multiple_widgets(GtkBox *destination, gboolean expand, gboolean fill, int padding, ...); From 7e2ee428392e04ab4dc01f5c877886b94a674608 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 31 Aug 2023 09:21:09 +0600 Subject: [PATCH 5/9] Cpu limit is properly shown at quota edit window --- source/ubl-settings-resourcequota.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/source/ubl-settings-resourcequota.c b/source/ubl-settings-resourcequota.c index 5560957..7f9b3d8 100644 --- a/source/ubl-settings-resourcequota.c +++ b/source/ubl-settings-resourcequota.c @@ -1123,10 +1123,9 @@ void on_edit_open(GtkWidget *self, main_window *widgets){ gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->HardRestrictionSpin),strtol(hard,NULL,10)); gtk_combo_box_set_active(GTK_COMBO_BOX(window->HardRestrictionCombo),hard_size); } - if (hard&&strcmp(hard,"")!=0) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->HardRestrictionCheck),1); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->HardRestrictionSpin),strtol(hard,NULL,10)); - gtk_combo_box_set_active(GTK_COMBO_BOX(window->HardRestrictionCombo),hard_size); + if (cpu&&strcmp(cpu,"")!=0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->CpuLimitCheck),1); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->CpuLimitSpin),strtol(cpu,NULL,10)); } if (swap&&strcmp(swap,"")!=0) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->PagingLimitCheck),1); From 0e04817fa5ca89afb8d7864ec577153c4c2c74ad Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 8 Sep 2023 14:24:00 +0600 Subject: [PATCH 6/9] Fixed limits at edit tab --- source/ubl-settings-resourcequota.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/source/ubl-settings-resourcequota.c b/source/ubl-settings-resourcequota.c index 7f9b3d8..d286f90 100644 --- a/source/ubl-settings-resourcequota.c +++ b/source/ubl-settings-resourcequota.c @@ -359,7 +359,7 @@ void on_quotas_save(GtkWidget *self, dictionary *windows){ char *soft = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->SoftRestrictionCheck)) ? yon_char_append(yon_char_from_long(gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->SoftRestrictionSpin))),get_size_mod(GTK_COMBO_BOX(window->SoftRestrictionCombo))) : NULL; char *hard = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->HardRestrictionCheck)) ? yon_char_append(yon_char_from_long(gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->HardRestrictionSpin))),get_size_mod(GTK_COMBO_BOX(window->HardRestrictionCombo))) : NULL; char *paging = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->PagingLimitCheck)) ? yon_char_append(yon_char_from_long(gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->PagingLimitSpin))),get_size_mod(GTK_COMBO_BOX(window->PagingLimitCombo))) : NULL; - char *cpu = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->CpuLimitCheck)) ? yon_char_from_long(gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->CpuLimitSpin))) : NULL; + char *cpu = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->CpuLimitCheck)) ? yon_char_append(yon_char_from_long(gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->CpuLimitSpin))),"%") : NULL; char *read_limit = ""; char *read_devices = ""; dictionary *dict; @@ -1013,12 +1013,22 @@ void on_edit_open(GtkWidget *self, main_window *widgets){ g_signal_connect(G_OBJECT(window->TargetTypeCombo),"changed",G_CALLBACK(on_quota_target_type_changed),window); - gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(window->SoftRestrictionSpin)),main_config.avaliable_ram); - gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(window->HardRestrictionSpin)),main_config.avaliable_ram); - gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(window->PagingLimitSpin)),main_config.avaliable_swap); + long swap_current_max = main_config.avaliable_swap; + for (int i=0;iSoftRestrictionSpin)),soft_current_max); + gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(window->HardRestrictionSpin)),hard_current_max); + gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(window->PagingLimitSpin)),swap_current_max); gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(window->CpuLimitSpin)),main_config.cores*100); - gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(window->DeviceLimitReadSpin)),main_config.avaliable_ram); - gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(window->DeviceLimitWriteSpin)),main_config.avaliable_ram); g_signal_connect(G_OBJECT(window->SoftRestrictionCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->SoftRestrictionCombo); g_signal_connect(G_OBJECT(window->SoftRestrictionCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->SoftRestrictionSpin); @@ -1096,6 +1106,8 @@ void on_edit_open(GtkWidget *self, main_window *widgets){ } } } + g_signal_connect(G_OBJECT(window->DeviceLimitWriteCombo),"changed",G_CALLBACK(on_check_maximum),window->DeviceLimitWriteSpin); + g_signal_connect(G_OBJECT(window->DeviceLimitReadCombo),"changed",G_CALLBACK(on_check_maximum),window->DeviceLimitReadSpin); window->devices=window->devices->first; gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitCombo),0); g_signal_connect(G_OBJECT(window->DeviceLimitCombo),"changed",G_CALLBACK(on_device_current_changed),window); @@ -1146,9 +1158,7 @@ void on_edit_open(GtkWidget *self, main_window *widgets){ g_signal_connect(G_OBJECT(window->PagingLimitSpin),"change-value",G_CALLBACK(on_check_maximum_cpu),window->PagingLimitCombo); g_signal_connect(G_OBJECT(window->PagingLimitCombo),"changed",G_CALLBACK(on_check_maximum_cpu),window->PagingLimitSpin); g_signal_connect(G_OBJECT(window->DeviceLimitReadSpin),"change-value",G_CALLBACK(on_check_maximum),window->DeviceLimitReadCombo); - g_signal_connect(G_OBJECT(window->DeviceLimitReadCombo),"changed",G_CALLBACK(on_check_maximum),window->DeviceLimitReadSpin); g_signal_connect(G_OBJECT(window->DeviceLimitWriteSpin),"change-value",G_CALLBACK(on_check_maximum),window->DeviceLimitWriteCombo); - g_signal_connect(G_OBJECT(window->DeviceLimitWriteCombo),"changed",G_CALLBACK(on_check_maximum),window->DeviceLimitWriteSpin); g_signal_connect(G_OBJECT(window->SoftRestrictionSpin),"output",G_CALLBACK(on_quota_configuration_update),window); g_signal_connect(G_OBJECT(window->SoftRestrictionCombo),"changed",G_CALLBACK(on_quota_configuration_update),window); From 3bd3074e4cc5ebf72f1de551c15c3e84938dae7c Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 8 Sep 2023 14:32:58 +0600 Subject: [PATCH 7/9] design fixes --- ubl-settings-resourcequota-quota.glade | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ubl-settings-resourcequota-quota.glade b/ubl-settings-resourcequota-quota.glade index 29401bd..4708587 100644 --- a/ubl-settings-resourcequota-quota.glade +++ b/ubl-settings-resourcequota-quota.glade @@ -178,11 +178,13 @@ True False + start 5 True False + start vertical 5 @@ -269,6 +271,7 @@ True False + start vertical 5 @@ -600,6 +603,7 @@ True False + start 5 @@ -624,6 +628,7 @@ True False + start 5 @@ -715,6 +720,7 @@ True False + start 5 From 5d913f07ec4838cbec9bc928fa9cbd6ed865fbf3 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 8 Sep 2023 17:40:09 +0600 Subject: [PATCH 8/9] Relocated root check for status message --- source/ubl-settings-resourcequota.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/ubl-settings-resourcequota.c b/source/ubl-settings-resourcequota.c index d286f90..63c47cc 100644 --- a/source/ubl-settings-resourcequota.c +++ b/source/ubl-settings-resourcequota.c @@ -472,7 +472,7 @@ void on_config_load_global(){ void on_config_load_local(){ yon_load_proceed(load_local_command); - yon_ubl_status_box_render(LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + yon_ubl_status_box_render(LOCAL_LOAD_SUCCESS,BACKGROUND_IMAGE_SUCCESS_TYPE); } @@ -1460,10 +1460,6 @@ int main(int argc, char *argv[]){ yon_ubl_header_setup_resource(widgets->HeadOverlay,widgets->HeadBox,widgets->HeadImage,banner_path); yon_ubl_status_box_setup(widgets->StatusIcon,widgets->StatusBox,widgets->StatusLabel); - if (getuid()!=0) - yon_ubl_status_box_render(ROOT_WARNING_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); - else - yon_ubl_status_box_render(LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); yon_ubl_setup_sockets(widgets->PlugBox,widgets->LeftBox,widgets->RightBox,main_config.socket_id,main_config.load_socket_id,main_config.save_socket_id); yon_window_config_setup(GTK_WINDOW(widgets->Window)); yon_window_config_load(config_path); @@ -1474,6 +1470,10 @@ int main(int argc, char *argv[]){ } g_list_free(list); + if (getuid()!=0) + yon_ubl_status_box_render(ROOT_WARNING_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); + else + yon_ubl_status_box_render(LOCAL_LOAD_SUCCESS,BACKGROUND_IMAGE_SUCCESS_TYPE); GtkCssProvider *css=gtk_css_provider_new(); gtk_css_provider_load_from_resource(css,CssPath); gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), From 3eabfebabf11a3aa1bef1ba55085229dbb362b82 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 28 May 2025 12:43:27 +0600 Subject: [PATCH 9/9] Application rework --- Makefile | 26 +- source/CMakeLists.txt | 30 +- source/ubl-cmake.in | 1 - source/ubl-settings-resourcequota.c | 653 ++++----- source/ubl-settings-resourcequota.h | 127 +- source/ubl-strings.h | 50 +- source/ubl-utils.c | 2051 -------------------------- source/ubl-utils.h | 368 ----- ubl-settings-resourcequota.glade | 2062 +++++++++------------------ ubl-settings-resourcequota.pot | 2 +- ubl-settings-resourcequota_ru.po | 4 +- 11 files changed, 1087 insertions(+), 4287 deletions(-) delete mode 100644 source/ubl-cmake.in delete mode 100644 source/ubl-utils.c delete mode 100644 source/ubl-utils.h diff --git a/Makefile b/Makefile index 4f59d1c..371bb65 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ DEPENDS = /bin/cmake PREFIX ?= /usr/local PKGNAME = $(MAKEFILE_DIR) FILE_VER = source/${PKGNAME}.h -PKGIDENT = $(subst /,-,$(subst /usr,,${PREFIX})) +PKGIDENT=$(subst /,-,${PREFIX}) default_target: all @@ -94,7 +94,6 @@ uninstall: done @$(RM) "${DESTDIR}${PREFIX}/bin/${PKGNAME}" @$(RM) "${DESTDIR}${PREFIX}/share/applications/${PKGNAME}.desktop" - @$(RM) "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/com.ublinux.${PKGNAME}.svg" @$(RM) "${DESTDIR}/usr/share/polkit-1/actions/com.ublinux.${PKGNAME}${PKGIDENT}.policy" @if [ -z ${DESTDIR} ]; then \ [ -d "${DESTDIR}${PREFIX}/share/icons/hicolor/" ] && gtk-update-icon-cache -fiq "${DESTDIR}${PREFIX}/share/icons/hicolor/" &>/dev/null || true; \ @@ -117,18 +116,19 @@ install: check uninstall install -dm755 "${DESTDIR}${PREFIX}/share/icons/hicolor/$${SIZE}x$${SIZE}/apps"; \ rsvg-convert -w $${SIZE} -h $${SIZE} -f svg --keep-image-data "com.ublinux.${PKGNAME}.svg" -o "${DESTDIR}${PREFIX}/share/icons/hicolor/$${SIZE}x$${SIZE}/apps/com.ublinux.${PKGNAME}.svg"; \ done - @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/" "com.ublinux.${PKGNAME}.svg" - @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.checked.svg" - @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.warning.svg" - @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.funnel-symbolic.svg" - @install -Dm644 -t "${DESTDIR}${PREFIX}/share/applications/" "${PKGNAME}.desktop" + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/apps/" "com.ublinux.${PKGNAME}.svg" + @cp ./com.ublinux.${PKGNAME}.policy ./compile/com.ublinux.${PKGNAME}${PKGIDENT}.policy + @sed -e 's+/usr/bin+${PREFIX}/bin+' -e 's+.run+${PKGIDENT}.run+g' ./compile/com.ublinux.${PKGNAME}${PKGIDENT}.policy -i @install -Dm755 -t "${DESTDIR}${PREFIX}/bin/" "${CMAKE_BUILD_DIR}/${PKGNAME}" - @install -Dm644 "com.ublinux.${PKGNAME}.policy" "${DESTDIR}/usr/share/polkit-1/actions/com.ublinux.${PKGNAME}${PKGIDENT}.policy" - @sed -e '\|annotate key=|s|/usr/bin|${PREFIX}/bin|' -e '/action id=/s/\.run/${PKGIDENT}\.run/' -i ${DESTDIR}/usr/share/polkit-1/actions/com.ublinux.${PKGNAME}${PKGIDENT}.policy + @install -Dm644 -t "${DESTDIR}${PREFIX}/share/applications/" "${PKGNAME}.desktop" + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.checked.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.warning.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/polkit-1/actions/" "${CMAKE_BUILD_DIR}/com.ublinux.${PKGNAME}${PKGIDENT}.policy" + @ldconfig -n /usr/local/lib @if [ -z ${DESTDIR} ]; then \ - [ -d "${DESTDIR}${PREFIX}/share/icons/hicolor/" ] && gtk-update-icon-cache -fiq "${DESTDIR}${PREFIX}/share/icons/hicolor/" &>/dev/null || true; \ + [ -d "${DESTDIR}/usr/share/icons/hicolor/" ] && gtk-update-icon-cache -fiq "${DESTDIR}/usr/share/icons/hicolor/" &>/dev/null || true; \ update-desktop-database --quiet &>/dev/null || true; \ - [ -d "${DESTDIR}${PREFIX}/share/applications" ] && touch "${DESTDIR}${PREFIX}/share/applications" &>/dev/null || true; \ + [ -d "${DESTDIR}/usr/share/applications" ] && touch "${DESTDIR}/usr/share/applications" &>/dev/null || true; \ fi @echo "Install: OK" @@ -147,7 +147,7 @@ help: echo "... init"; \ echo "... debug"; \ echo "... prepare"; \ - echo "... build"; \ + echo "... compile"; \ echo "... install"; \ echo "... uninstall"; \ - echo "... clean" + echo "... clean" \ No newline at end of file diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 5774811..5c92b1a 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -24,10 +24,6 @@ if(WEBKIT_LIBRARIES_FOUND) add_definitions(${WEBKIT_CFLAGS_OTHER}) endif() -configure_file(ubl-cmake.in ubl-cmake.h) - -file(COPY ${CMAKE_CURRENT_BINARY_DIR}/ubl-cmake.h DESTINATION ./) - set(GRESOURCE_C resources.c) set(GRESOURCE_XML gresource.xml) @@ -63,27 +59,33 @@ add_custom_target( DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C} ) -#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always -std=c++2a") -#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always -lm") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always \ +add_definitions(-DVTE_INCLUDE) + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always \ -O2 -pipe -fno-plt -fexceptions \ - -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security \ + -Wformat -Werror=format-security \ -fstack-clash-protection -fcf-protection") - + +string(FIND "${CMAKE_CXX_FLAGS}" "-D_FORTIFY_SOURCE" FORTIFY_FOUND) +if(FORTIFY_FOUND EQUAL -1) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wp,-D_FORTIFY_SOURCE=2") +endif() + set(SOURCE_FILES ubl-settings-resourcequota.c ubl-settings-resourcequota.h - ubl-utils.c - ubl-utils.h - ${CMAKE_CURRENT_BINARY_DIR}/ubl-cmake.h + ubl-strings.h ) set(LIBRARIES ${GTK_LIBRARIES} ${WEBKIT_LIBRARIES} - ${VTE291_LIBRARIES} - pthread) + ${UTILS_LIBRARIES} + ${VTE291_LIBRARIES} + ublsettings + ublsettings-gtk3 + ublsettingsui-gtk3) add_executable(${PROJECT_NAME} ${SOURCE_FILES} ${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C}) diff --git a/source/ubl-cmake.in b/source/ubl-cmake.in deleted file mode 100644 index d4623a7..0000000 --- a/source/ubl-cmake.in +++ /dev/null @@ -1 +0,0 @@ -#cmakedefine WEBKIT_FOUND diff --git a/source/ubl-settings-resourcequota.c b/source/ubl-settings-resourcequota.c index 63c47cc..ad44067 100644 --- a/source/ubl-settings-resourcequota.c +++ b/source/ubl-settings-resourcequota.c @@ -2,102 +2,27 @@ config main_config; -//signal emmit handlers - no header initialization - -/**on_close_subwindow(GtkWidget *self) - * [EN] - * Closes window in which [self] is contained. - * [RU] - * Закрывает окно, в котором расположен виджет [self]. -*/ -void on_close_subwindow(GtkWidget *self){ - gtk_widget_destroy(gtk_widget_get_toplevel(self)); -} - -/**yon_open_browser(GtkWidget *self, char *link) - * [EN] - * Opens browser with [link] link. - * [RU] - * Открывает браузер с [link] ссылкой. -*/ -void yon_open_browser(GtkWidget *self, char *link){ - yon_ubl_browser_window_open(link,TITLE_LABEL); -} - -/**on_open_documentation_confirmation(GtkWidget *self, char *link) - * [EN] - * Opens confirmation window for [link] link. - * [RU] - * Открывает окно подтверждение перехода по ссылке [link]. -*/ -void on_open_documentation_confirmation(GtkWidget *self, char *link){ - if (main_config.always_open_documentation==0){ - GtkBuilder *builder = gtk_builder_new_from_resource(glade_path); - documentation_confirmation_window *widgets = malloc(sizeof(documentation_confirmation_window)); - widgets->Window = yon_gtk_builder_get_widget(builder,"helpConfirmationWindow"); - widgets->AcceptButton = yon_gtk_builder_get_widget(builder,"ReadHelpButton"); - widgets->CloseButton = yon_gtk_builder_get_widget(builder,"CancelHelpButton"); - widgets->HatText = yon_gtk_builder_get_widget(builder,"webHeaderNameLabel"); - widgets->HeaderText = yon_gtk_builder_get_widget(builder,"helpHeader"); - widgets->InfoText = yon_gtk_builder_get_widget(builder,"helpText"); - widgets->AlwaysOpenCheck = yon_gtk_builder_get_widget(builder,"AlwaysOpenDocumentationCheckbox"); - gtk_label_set_text(GTK_LABEL(widgets->HatText),TITLE_LABEL); - gtk_label_set_text(GTK_LABEL(widgets->HeaderText),HELP_TITLE_LABEL); - gtk_label_set_text(GTK_LABEL(widgets->InfoText),HELP_INFO_LABEL); - gtk_button_set_label(GTK_BUTTON(widgets->AcceptButton),OPEN_HELP_LABEL); - gtk_button_set_label(GTK_BUTTON(widgets->AlwaysOpenCheck),HELP_ALWAYS_OPEN_LABEL); - gtk_button_set_label(GTK_BUTTON(widgets->CloseButton),CANCEL_LABEL); - gtk_widget_show_all(widgets->Window); - g_signal_connect(G_OBJECT(widgets->CloseButton),"clicked",G_CALLBACK(on_close_subwindow),NULL); - g_signal_connect(G_OBJECT(widgets->AcceptButton),"clicked",G_CALLBACK(yon_open_browser),yon_char_new(link)); - g_signal_connect(G_OBJECT(widgets->AcceptButton),"clicked",G_CALLBACK(on_close_subwindow),NULL); - - - } else { - yon_open_browser(self,link); - } -} - -/**on_link(GtkWidget *self, char* uri, gpointer user_data) - * [EN] - * Signal for hadnling AboutDialog links. - * Connect to "activate-link" signal. - * [self] is AboutDialog window; - * [uri] is activated link; - * [user_data] is pointer for user data, hasn't used in standard handler; - * [RU] - * Функция для обработки сигнала нажатия на ссылку окна AboutDialog. - * Присоединять к сигналу "activate-link". - * [self] - окно AboutDialog; - * [uri] - ссылка, по которой совершается переход; - * [user_data] - указатель на любые другие данные, не используется в стандартном обработчике; -*/ -void on_link(GtkWidget *self, char* uri, gpointer user_data){ - gtk_widget_destroy(self); - on_open_documentation_confirmation(self,uri); -} - -/**on_about() - * [EN] - * Function for setting up and showing AboutDialog. - * Connect it to "activate" signal of Documentation MenuItem. - * [RU] - * Функиця для настройки и показа окна AboutDialog. - * Присоединять к сигналу "activate" кнопки справки типа MenuItem. -*/ -void on_about(){ - GtkBuilder *builder=gtk_builder_new_from_resource(glade_path); - GtkWidget *window=yon_gtk_builder_get_widget(builder,"AboutWindow"); - GtkWidget *title=yon_gtk_builder_get_widget(builder,"headerAboutTopic"); - GtkWidget *hideButtonBox=yon_gtk_builder_get_widget(builder,"buttonBoxHide"); - gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(window),version_application); - gtk_about_dialog_set_website_label(GTK_ABOUT_DIALOG(window),PROJECT_HOME_LABEL); - gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(window),TITLE_LABEL); - gtk_label_set_text(GTK_LABEL(title),TITLE_LABEL); - g_signal_connect(G_OBJECT(window),"activate-link",G_CALLBACK(on_link),NULL); - gtk_widget_set_visible(hideButtonBox,0); - gtk_widget_destroy(hideButtonBox); - gtk_widget_show(window); +void on_save_done(main_window *, config_str output, int size){ + char *final_output = yon_char_parsed_to_string(output,size,""); + if (final_output){ + printf("%s\n",final_output); + free(final_output); + } + yon_char_parsed_free(output,size); + textdomain(template_ui_LocaleName); + switch (main_config.save_config){ + case 0: + yon_ubl_status_box_render(GLOBAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + break; + case 1: + yon_ubl_status_box_render(LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + break; + case 2: + yon_ubl_status_box_render(GLOBAL_LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + break; + } + textdomain(LocaleName); + } //functions @@ -117,7 +42,7 @@ char *get_size_mod(GtkComboBox *combo){ return size_modifier; } -void on_device_limits_update(GtkWidget *self, quota_window *window){ +void on_device_limits_update(GtkWidget *, quota_window *window){ if (window->devices->data){ 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))); @@ -130,19 +55,27 @@ void on_device_limits_update(GtkWidget *self, quota_window *window){ void on_quota_configuration_update(GtkWidget *self, quota_window *window){ char *output_line = NULL; - char *size_modifier=NULL; on_device_limits_update(self,window); - char *soft_limit = yon_char_unite("MemoryHigh=",yon_char_from_long((long)gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->SoftRestrictionSpin))),get_size_mod(GTK_COMBO_BOX(window->SoftRestrictionCombo)),NULL); - char *hard_limit = yon_char_unite("MemoryMax=",yon_char_from_long((long)gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->HardRestrictionSpin))),get_size_mod(GTK_COMBO_BOX(window->HardRestrictionCombo)),NULL); - char *paging_limit = yon_char_unite("MemorySwapMax=",yon_char_from_long((long)gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->PagingLimitSpin))),get_size_mod(GTK_COMBO_BOX(window->PagingLimitCombo)),NULL); - char *cpu_limit = yon_char_unite("CPUQuota=",yon_char_from_long((long)gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->CpuLimitSpin))),"%",NULL); + 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)); + long cpu = (long)gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->CpuLimitSpin)); + char *soft_limit = ""; + char *hard_limit = ""; + char *paging_limit = ""; + char *cpu_limit = ""; + 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 (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); char *read_limit = ""; char *read_devices = ""; 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,"IOReadBandwidthMax=",yon_char_divide_search(yon_char_new(dict->key)," ",-1)," ",yon_dictionary_get_data(dict,device_limits*)->read,",",NULL); + if (!strstr(yon_dictionary_get_data(dict,device_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); } if (read_devices[strlen(read_devices)-1]==',') read_devices[strlen(read_devices)-1]='\0'; read_limit = yon_char_unite(read_limit,read_devices,NULL); @@ -152,7 +85,8 @@ void on_quota_configuration_update(GtkWidget *self, quota_window *window){ char *write_devices = ""; for_dictionaries(dict,window->devices){ if (dict->data&&yon_dictionary_get_data(dict,device_limits*)->write) - write_devices = yon_char_unite(write_devices,"IOWriteBandwidthMax=",yon_char_divide_search(yon_char_new(dict->key)," ",-1)," ",yon_dictionary_get_data(dict,device_limits*)->write,",",NULL); + if (!strstr(yon_dictionary_get_data(dict,device_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); } if (write_devices[strlen(write_devices)-1]==',') write_devices[strlen(write_devices)-1]='\0'; write_limit = yon_char_unite(write_limit,write_devices,NULL); @@ -167,7 +101,7 @@ void on_quota_configuration_update(GtkWidget *self, quota_window *window){ gtk_entry_set_text(GTK_ENTRY(window->ManualInputEntry),output_line); } -void on_limit_manual_input(GtkWidget *self, double *new_value, quota_window *window){ +void on_limit_manual_input(GtkWidget *self, double *, quota_window *window){ on_quota_configuration_update(self, window); } @@ -281,78 +215,86 @@ void on_target_check_chosen(GtkWidget *self, quota_window *window){ void yon_get_devices(quota_window *window){ int size=0; config_str devices_parsed = yon_config_load(get_devices_command,&size); - yon_char_parsed_remove_newline_symbols(devices_parsed,&size); for (int i=0; idevices,devices_parsed[i],NULL); } } -void on_device_current_changed(GtkWidget *self, quota_window *window){ +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) + 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; + } + ((device_limits*)window->devices->data)->write=NULL; + ((device_limits*)window->devices->data)->read=NULL; } else { - 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))); - else yon_dictionary_get_data(window->devices,device_limits*)->read = NULL; - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->DeviceLimitWriteCheck))) - yon_dictionary_get_data(window->devices,device_limits*)->write=yon_char_append(yon_char_from_long(gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->DeviceLimitWriteSpin))),get_size_mod(GTK_COMBO_BOX(window->DeviceLimitWriteCombo))); - else yon_dictionary_get_data(window->devices,device_limits*)->write = NULL; + 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) + 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; - } - } 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); + } + ((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; } - 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; - } - } 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->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; } + } 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); + } } } void on_quotas_save(GtkWidget *self, dictionary *windows){ quota_window *window = yon_dictionary_get_data(windows->first,quota_window*); - main_window *widgets = yon_dictionary_get_data(windows->first->next,main_window*); + // main_window *widgets = yon_dictionary_get_data(windows->first->next,main_window*); GtkTreeIter iter; + if (!strcmp(gtk_entry_get_text(GTK_ENTRY(window->ManualInputEntry)),"")){ + yon_ubl_status_box_render(OPERATION_FAILED_EMPTY_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); + return; + } const char *string = gtk_entry_get_text(GTK_ENTRY(window->ManualInputEntry)); const char *type = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->TargetTypeCombo)); const char *target = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->TargetCombo)); @@ -381,8 +323,8 @@ void on_quotas_save(GtkWidget *self, dictionary *windows){ write_limit = yon_char_unite(write_limit,write_devices,NULL); gtk_list_store_append(main_config.list,&iter); gtk_list_store_set(main_config.list,&iter,0,type,1,target,2,soft,3,hard,4,paging,5,cpu,6,read_limit,7,write_limit,8,string,-1); - yon_config_register(CGROUP_QUOTA((char*)target),yon_char_new((char*)string)); - on_close_subwindow(self); + yon_config_register(CGROUP_QUOTA((char*)target),CGROUP_QUOTA_comd((char*)target),yon_char_new((char*)string)); + on_subwindow_close(self); yon_ubl_status_box_render(SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); } @@ -401,12 +343,12 @@ int yon_get_size_request_from_letter(char size){ } } -void yon_load_proceed(char *command){ +void yon_interface_update(main_window *){ gtk_list_store_clear(main_config.list); - if (yon_config_load_register(command)){ - config_str rtn = yon_config_get_all(); + int parameters_size; + config_str rtn = yon_config_get_all(¶meters_size); char *quota = NULL; - for (int i=0;rtn[i];i++){ + for (int i=0;ifirst,GList*); GList *checks = yon_dictionary_get_data(dict->first->next,GList*); if (g_list_length(columns)==g_list_length(checks)){ - for (int i=0;iDeviceLimitCombo),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){ +void on_quota_manual_input_focus (GtkWidget *self, GdkEventFocus *, quota_window *window){ on_quota_manual_input(self,window); } -void on_filters_opened(GtkWidget *self, main_window *widgets) { +void on_filters_opened(GtkWidget *, main_window *widgets) { GtkBuilder *builder = gtk_builder_new_from_resource(glade_filters_path); filters_window *window = g_malloc0(sizeof(filters_window)); @@ -680,7 +647,7 @@ void on_filters_opened(GtkWidget *self, main_window *widgets) { GList *columns = gtk_tree_view_get_columns(GTK_TREE_VIEW(widgets->MainTree)); GList *checks = gtk_container_get_children(GTK_CONTAINER(gtk_widget_get_parent(window->QuotaTypeCheck))); if (g_list_length(columns)==g_list_length(checks)){ - for (int i=0;iCancelButton),"clicked",G_CALLBACK(on_close_subwindow),NULL); + g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_apply_filters),dict); gtk_window_set_title(GTK_WINDOW(window->Window),TITLE_LABEL); gtk_widget_show(window->Window); } -void on_add_open(GtkWidget *self, main_window *widgets){ +void on_add_open(GtkWidget *, main_window *widgets){ GtkBuilder *builder = gtk_builder_new_from_resource(glade_quota_path); quota_window *window = g_malloc0(sizeof(quota_window)); @@ -755,7 +722,7 @@ void on_add_open(GtkWidget *self, main_window *widgets){ dictionary *windows = NULL; yon_dictionary_add_or_create_if_exists_with_data(windows,"window",window); yon_dictionary_add_or_create_if_exists_with_data(windows,"widgets",widgets); - g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_close_subwindow),NULL); + g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); g_signal_connect(G_OBJECT(window->SaveButton),"clicked",G_CALLBACK(on_quotas_save),windows); g_signal_connect(G_OBJECT(window->TargetTypeCombo),"changed",G_CALLBACK(on_quota_target_type_changed),window); @@ -822,8 +789,8 @@ void on_add_open(GtkWidget *self, main_window *widgets){ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(window->DeviceLimitCombo),dict->key); } main_config.users = yon_ubl_get_all_users(&main_config.users_size); - main_config.processes = yon_ubl_get_all_processes(&main_config.processes_size); - main_config.slices = yon_ubl_get_all_slices(&main_config.slices_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]); } @@ -835,11 +802,12 @@ void on_information_chosen_changed(GtkWidget *self, main_window *widgets){ if (chosen){ char *command = yon_char_unite(get_information_command, (char*)chosen," --no-pager",NULL); main_config.last_info = yon_char_new((char*)chosen); - yon_terminal_integrated_start(widgets->InformationTerminal, command, NULL, NULL); + vte_terminal_reset(VTE_TERMINAL(widgets->InformationTerminal),1,1); + yon_terminal_integrated_start(widgets->InformationTerminal, command); } } -void on_information(GtkWidget *self, main_window *widgets){ +void on_information(GtkWidget *, main_window *widgets){ GtkTreeModel *model = GTK_TREE_MODEL(main_config.list); GtkTreeIter iter; if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree)),&model,&iter)){ @@ -857,19 +825,21 @@ void on_information(GtkWidget *self, main_window *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); main_config.last_info = yon_char_new((char*)name); - yon_terminal_integrated_start(widgets->InformationTerminal, command, NULL, NULL); + vte_terminal_reset(VTE_TERMINAL(widgets->InformationTerminal),1,1); + yon_terminal_integrated_start(widgets->InformationTerminal, command); gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->MainNotebook),3); yon_ubl_status_box_render(SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); } else yon_ubl_status_box_render(NOTHING_CHOSEN_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); } -void on_information_update(GtkWidget *self, main_window *widgets){ +void on_information_update(GtkWidget *, main_window *widgets){ char *command = yon_char_unite(get_information_command, main_config.last_info," --no-pager",NULL); - yon_terminal_integrated_start(widgets->InformationTerminal, command, NULL, NULL); + vte_terminal_reset(VTE_TERMINAL(widgets->InformationTerminal),1,1); + yon_terminal_integrated_start(widgets->InformationTerminal, command); } -void on_remove(GtkWidget *self, main_window *widgets){ +void on_remove(GtkWidget *, main_window *widgets){ GtkTreeModel *model = GTK_TREE_MODEL(main_config.list); GtkTreeIter iter; if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree)),&model,&iter)){ @@ -888,6 +858,10 @@ void on_quotas_edit(GtkWidget *self, dictionary *windows){ quota_window *window = yon_dictionary_get_data(windows->first,quota_window*); main_window *widgets = yon_dictionary_get_data(windows->first->next,main_window*); GtkTreeIter iter; + if (!strcmp(gtk_entry_get_text(GTK_ENTRY(window->ManualInputEntry)),"")){ + yon_ubl_status_box_render(OPERATION_FAILED_EMPTY_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); + return; + } if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree)),&model,&iter)){ const char *string = gtk_entry_get_text(GTK_ENTRY(window->ManualInputEntry)); const char *target = gtk_label_get_text(GTK_LABEL(window->TargetLabel)); @@ -916,13 +890,13 @@ void on_quotas_edit(GtkWidget *self, dictionary *windows){ write_limit = yon_char_unite(write_limit,write_devices,NULL); gtk_list_store_set(main_config.list,&iter,1,target,2,soft,3,hard,4,paging,5,cpu,6,read_limit,7,write_limit,8,string,-1); yon_config_set(CGROUP_QUOTA(target),(void*)yon_char_new((char*)string)); - on_close_subwindow(self); + on_subwindow_close(self); yon_ubl_status_box_render(SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); } else yon_ubl_status_box_render(NOTHING_CHOSEN_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); } -void on_edit_open(GtkWidget *self, main_window *widgets){ +void on_edit_open(GtkWidget *, main_window *widgets){ GtkTreeModel *model = GTK_TREE_MODEL(main_config.list); GtkTreeIter iter; if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree)),&model,&iter)){ @@ -1008,7 +982,7 @@ void on_edit_open(GtkWidget *self, main_window *widgets){ dictionary *windows = NULL; yon_dictionary_add_or_create_if_exists_with_data(windows,"window",window); yon_dictionary_add_or_create_if_exists_with_data(windows,"widgets",widgets); - g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_close_subwindow),NULL); + g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); g_signal_connect(G_OBJECT(window->SaveButton),"clicked",G_CALLBACK(on_quotas_edit),windows); g_signal_connect(G_OBJECT(window->TargetTypeCombo),"changed",G_CALLBACK(on_quota_target_type_changed),window); @@ -1181,13 +1155,13 @@ void on_edit_open(GtkWidget *self, main_window *widgets){ } } -void on_dispatcher_update(GtkWidget *self,main_window *widgets){ +void on_dispatcher_update(GtkWidget *,main_window *widgets){ int interval = gtk_spin_button_get_value(GTK_SPIN_BUTTON(widgets->DispatcherUpdateSpin)); if (interval>0) { char* str_second = yon_char_from_int(interval); char *command = yon_char_unite(get_dispatcher_command," -d ",str_second,NULL); if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->DispatcherUpdateCheck))) command = yon_char_append(command," -n 1"); - yon_terminal_integrated_start(widgets->DispatcherTerminal, command, NULL, NULL); + yon_terminal_integrated_start_shell(widgets->DispatcherTerminal, command,NULL,NULL); free(str_second); GValue *val = g_malloc0(sizeof(GValue)); g_object_get_property(G_OBJECT(widgets->DispatcherUpdateSpin),"has-focus",val); @@ -1197,16 +1171,16 @@ void on_dispatcher_update(GtkWidget *self,main_window *widgets){ } } -void on_processes_update(GtkWidget *self,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_core = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->ShowCoreCheck)); char *command = get_processes_tree_command; if (show_all) yon_char_append(command, " -k"); if (show_core) yon_char_append(command, " -l"); - yon_terminal_integrated_start(widgets->ProcessesTerminal, command, NULL, NULL); + yon_terminal_integrated_start_shell(widgets->ProcessesTerminal, command,NULL,NULL); } -void on_tab_changed(GtkWidget *self, GtkWidget *page, int page_num, main_window *widgets){ +void on_tab_changed(GtkWidget *, GtkWidget *, int , main_window *){ } @@ -1236,51 +1210,22 @@ void on_info_target_type_switched(GtkWidget *self, main_window *widgets){ // standard functions -void config_init(){ - main_config.always_open_documentation=0; - main_config.win_height=0; - main_config.win_width=0; - main_config.win_pos_x=0; - main_config.win_pos_y=0; - main_config.socket_id=-1; - main_config.save_socket_id=-1; - main_config.load_socket_id=-1; - main_config.lock_help=0; - main_config.lock_help=0; - main_config.lock_load_global=0; - main_config.lock_save_global=0; - main_config.lock_save_local=0; - main_config.avaliable_ram=0; -} - -main_window *setup_window(){ - /* Widgets getting | Получение виджетов */ - main_window *widgets = malloc(sizeof(main_window)); - GtkBuilder *builder = gtk_builder_new_from_resource(glade_path); - widgets->Window = yon_gtk_builder_get_widget(builder,"MainWindow"); - widgets->HatLabel = yon_gtk_builder_get_widget(builder,"headerTopic"); - widgets->PlugBox = yon_gtk_builder_get_widget(builder,"plugBox"); - - widgets->HeadOverlay = yon_gtk_builder_get_widget(builder,"HeadOverlay"); - widgets->HeadImage = yon_gtk_builder_get_widget(builder,"HeadBackgroundImage"); - widgets->HeadBox = yon_gtk_builder_get_widget(builder,"HeaderBox"); - widgets->HeadTitleLabel = yon_gtk_builder_get_widget(builder,"HeaderTitleLabel"); - widgets->HeadInfoLabel = yon_gtk_builder_get_widget(builder,"HeaderInfoLabel"); - - widgets->StatusBox = yon_gtk_builder_get_widget(builder,"mainStatusBox"); - widgets->StatusIcon = yon_gtk_builder_get_widget(builder,"mainStatusIcon"); - widgets->StatusLabel = yon_gtk_builder_get_widget(builder,"mainStatusLabel"); - - widgets->SaveLabel = yon_gtk_builder_get_widget(builder,"headerSaveConfigLabel"); - widgets->SaveMenuItem = yon_gtk_builder_get_widget(builder,"SaveGlobalLocalConfigurationMenuItem"); - widgets->SaveGlobalMenuItem = yon_gtk_builder_get_widget(builder,"SaveGlobalConfigurationMenuItem"); - widgets->SaveLocalMenuItem = yon_gtk_builder_get_widget(builder,"SaveLocalConfigurationMenuItem"); - widgets->RightBox = yon_gtk_builder_get_widget(builder,"HeaderRightBox"); - - widgets->LoadLabel = yon_gtk_builder_get_widget(builder,"headerLoadConfigLabel"); - widgets->LoadGlobalMenuItem = yon_gtk_builder_get_widget(builder,"LoadGlobalConfigurationMenuItem"); - widgets->LoadLocalMenuItem = yon_gtk_builder_get_widget(builder,"LoadLocalConfigurationMenuItem"); - widgets->LeftBox = yon_gtk_builder_get_widget(builder,"HeaderLeftBox"); +// void config_init(){ +// main_config.avaliable_ram=0; +// } + +/**yon_main_window_complete(main_window *widgets) + * [EN] + * + * [RU] + * Функция настройки основного окна приложения. [widgets] - структура со стандартным интерфейсом. +*/ +void yon_main_window_complete(main_window *widgets){ + widgets = yon_remalloc(widgets,sizeof(main_window)); + GtkBuilder *builder = gtk_builder_new_from_resource(glade_path); + gtk_box_pack_start(GTK_BOX(widgets->InterfaceBox),yon_gtk_builder_get_widget(builder,"BoxMain"),1,1,0); + // Custom widgets configuration + { widgets->FiltersButton = yon_gtk_builder_get_widget(builder,"FiltersButton"); widgets->InformationButton = yon_gtk_builder_get_widget(builder,"InformationButton"); @@ -1307,28 +1252,7 @@ main_window *setup_window(){ widgets->InformationTerminal = yon_gtk_builder_get_widget(builder,"InformationTerminal"); main_config.list = GTK_LIST_STORE(gtk_builder_get_object(builder,"liststore")); - - widgets->DocumentationMenuItem = yon_ubl_menu_item_documentation_new(DOCUMENTATION_LABEL); - widgets->AboutMenuItem = yon_ubl_menu_item_about_new(ABOUT_LABEL); - - gtk_window_set_title(GTK_WINDOW(widgets->Window),TITLE_LABEL); - GtkWidget *menu = yon_gtk_builder_get_widget(builder,"menu2"); - gtk_menu_shell_append(GTK_MENU_SHELL(menu),widgets->DocumentationMenuItem); - gtk_menu_shell_append(GTK_MENU_SHELL(menu),widgets->AboutMenuItem); - - if (main_config.lock_load_global == 1){ - gtk_widget_set_sensitive(widgets->LoadGlobalMenuItem,0); - } - if (main_config.lock_save_global == 1){ - gtk_widget_set_sensitive(widgets->SaveGlobalMenuItem,0); - gtk_widget_set_sensitive(widgets->SaveMenuItem,0); - } - if (main_config.lock_save_local == 1){ - gtk_widget_set_sensitive(widgets->SaveLocalMenuItem,0); - gtk_widget_set_sensitive(widgets->SaveMenuItem,0); - } - /* Widget registration for config monitoring | Регистрация виджетов для мониторинга конфига */ // yon_window_config_add_custom_parameter(widgets->HeadInfoLabel,"head-text","label",YON_TYPE_STRING); @@ -1353,131 +1277,62 @@ main_window *setup_window(){ g_signal_connect(G_OBJECT(widgets->ProcessesUpdateButton),"clicked",G_CALLBACK(on_processes_update),widgets); g_signal_connect(G_OBJECT(widgets->InformationUpdateButton),"clicked",G_CALLBACK(on_information_update),widgets); - g_signal_connect(G_OBJECT(widgets->SaveMenuItem),"activate",G_CALLBACK(on_config_save),NULL); - g_signal_connect(G_OBJECT(widgets->SaveGlobalMenuItem),"activate",G_CALLBACK(on_config_save_global),NULL); - g_signal_connect(G_OBJECT(widgets->SaveLocalMenuItem),"activate",G_CALLBACK(on_config_save_local),NULL); - g_signal_connect(G_OBJECT(widgets->LoadGlobalMenuItem),"activate",G_CALLBACK(on_config_load_global),NULL); - g_signal_connect(G_OBJECT(widgets->LoadLocalMenuItem),"activate",G_CALLBACK(on_config_load_local),NULL); + g_signal_connect(G_OBJECT(widgets->SaveMenuItem),"activate",G_CALLBACK(on_config_global_local_save),widgets); + g_signal_connect(G_OBJECT(widgets->SaveGlobalMenuItem),"activate",G_CALLBACK(on_config_global_save),widgets); + g_signal_connect(G_OBJECT(widgets->SaveLocalMenuItem),"activate",G_CALLBACK(on_config_local_save),widgets); + g_signal_connect(G_OBJECT(widgets->SaveCustomMenuItem),"activate",G_CALLBACK(on_config_custom_save),widgets); + + g_signal_connect(G_OBJECT(widgets->LoadGlobalMenuItem),"activate",G_CALLBACK(on_config_global_load),widgets); + g_signal_connect(G_OBJECT(widgets->LoadLocalMenuItem),"activate",G_CALLBACK(on_config_local_load),widgets); + g_signal_connect(G_OBJECT(widgets->LoadCustomMenuItem),"activate",G_CALLBACK(on_config_custom_load),widgets); + + on_dispatcher_update(NULL,widgets); on_processes_update(NULL,widgets); yon_window_config_add_listener(widgets->DispatcherUpdateCheck,"DispatcherAutoupdate","active",YON_TYPE_BOOLEAN); yon_window_config_add_listener(widgets->ShowAllCheck,"ProcessShowAll","active",YON_TYPE_BOOLEAN); yon_window_config_add_listener(widgets->ShowCoreCheck,"ProcessShowCore","active",YON_TYPE_BOOLEAN); - yon_window_config_add_listener(widgets->DispatcherUpdateSpin,"DispatcherUpdateDelay","value",YON_TYPE_DOUBLE); + yon_gtk_tree_view_minimal_fixed_size_set_full(GTK_TREE_VIEW(widgets->MainTree)); GList *list = gtk_tree_view_get_columns(GTK_TREE_VIEW(widgets->MainTree)); - for (int i=0;iTargetTypeCombo,widgets); gtk_widget_show(widgets->Window); - return widgets; + } + + yon_root_button_setup((template_main_window*)widgets,main_config.launch_arguments,main_config.launch_size); + yon_save_window_set_postsave_function(on_save_done,widgets); } int main(int argc, char *argv[]){ - local=setlocale(LC_ALL, ""); + setlocale(LC_ALL, ""); textdomain (LocaleName); - config_init(); - int option_index=0; - int show_help=0; - int debug_mode=0; - { - struct option long_options[] = { - {"help", 0, 0, 'h'}, - {"version", 0, 0, 'V'}, - {"lock-help", 0,0, 1}, - {"lock-save", 0,0, 2}, - {"lock-save-local", 0,0, 3}, - {"lock-save-global", 0,0, 4}, - {"lock-load-global", 0,0, 5}, - {"socket-id", 1, 0, 's'}, - {"socket-ext-id", 1,0, 'e'}, - {"socket-trd-id", 1,0, 't'}, - {"debug", 0,0, 'd'}, - {"clean-config", 0,0, 'c'}, - { NULL, 0, NULL, 0 } - }; - for (int i=0;iHeadOverlay,widgets->HeadBox,widgets->HeadImage,banner_path); - - yon_ubl_status_box_setup(widgets->StatusIcon,widgets->StatusBox,widgets->StatusLabel); - yon_ubl_setup_sockets(widgets->PlugBox,widgets->LeftBox,widgets->RightBox,main_config.socket_id,main_config.load_socket_id,main_config.save_socket_id); - yon_window_config_setup(GTK_WINDOW(widgets->Window)); - yon_window_config_load(config_path); - on_config_load_local(); - GList *list = gtk_tree_view_get_columns(GTK_TREE_VIEW(widgets->MainTree)); - for (int i = 0; i < g_list_length(list); i++){ - yon_gtk_column_minimal_fixed_size_set((GtkTreeViewColumn*)g_list_nth_data(list,i)); - } - g_list_free(list); + //turn off if custom presented + // yon_ubl_settings_window_set_standard_callbacks(widgets,config_get_global_command,config_get_local_command,yon_config_get_custom_command("./"),config_get_default_command,config_get_global_only_parameters,config_get_local_only_parameters); - if (getuid()!=0) + 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(path); + main_config.launch_arguments=yon_char_parsed_copy(argv,argc); + main_config.launch_size=argc; + if (getuid()!=0){ + textdomain(template_ui_LocaleName); yon_ubl_status_box_render(ROOT_WARNING_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); - else - yon_ubl_status_box_render(LOCAL_LOAD_SUCCESS,BACKGROUND_IMAGE_SUCCESS_TYPE); - GtkCssProvider *css=gtk_css_provider_new(); - gtk_css_provider_load_from_resource(css,CssPath); - gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), - GTK_STYLE_PROVIDER(css), - -1); + textdomain(LocaleName); + } gtk_main(); + return 0; } \ No newline at end of file diff --git a/source/ubl-settings-resourcequota.h b/source/ubl-settings-resourcequota.h index caa22f5..b44c827 100644 --- a/source/ubl-settings-resourcequota.h +++ b/source/ubl-settings-resourcequota.h @@ -1,6 +1,8 @@ #include #include -#include "ubl-utils.h" +#include "libublsettings.h" +#include "libublsettings-gtk3.h" +#include "libublsettingsui-gtk3.h" #include #include #include @@ -9,7 +11,6 @@ #include #include #include -#include "ubl-cmake.h" #include "sys/sysinfo.h" #ifdef WEBKIT_FOUND @@ -30,41 +31,45 @@ #define LocalePath "/usr/share/locale" #define LocaleName "ubl-settings-resourcequota" -#define load_global_command "ubconfig --default --source global get security CGROUP_QUOTA[*]" -#define load_local_command "ubconfig --default --source system get security CGROUP_QUOTA[*]" -#define save_global_command "ubconfig --default --target global set security" -#define save_local_command "ubconfig --default --target system set security" -#define save_command "ubconfig set security " -#define remove_command "ubconfig remove security " -#define remove_global_command "ubconfig --target global --noexecute remove security " -#define remove_local_command "ubconfig --target system remove security " +// #define load_global_command "ubconfig --default --source global get security CGROUP_QUOTA[*]" +// #define load_local_command "ubconfig --default --source system get security CGROUP_QUOTA[*]" +// #define save_global_command "ubconfig --default --target global set security" +// #define save_local_command "ubconfig --default --target system set security" +// #define save_command "ubconfig set security " +// #define remove_command "ubconfig remove security " +// #define remove_global_command "ubconfig --target global --noexecute 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_processes_tree_command "clear; systemd-cgls --no-page" #define get_dispatcher_command "clear; systemd-cgtop" #define get_information_command "systemctl status " +#define get_processes_command "systemd-cgls --no-pager |grep -oE \"[-0-9A-Za-z.:]{1,}.service\"" +#define get_slices_command "systemd-cgls --no-pager |grep -oE \"[-0-9A-Za-z.:]{1,}.slice\"" + +#define yon_config_get_custom_command(target) yon_char_unite("ubconfig --source ",target," get security CGROUP_QUOTA[*]",NULL) +#define config_get_local_command "ubconfig --default --source system get security CGROUP_QUOTA[*]" +#define config_get_global_command "ubconfig --default --source global get security CGROUP_QUOTA[*]" +#define config_get_default_command "" + +#define config_get_global_only_parameters "" +#define config_get_local_only_parameters "" #define CGROUP_QUOTA(name) yon_char_unite("CGROUP_QUOTA[",name,"]",NULL) +#define CGROUP_QUOTA_comd(name) yon_char_unite("ubconfig -- source global get security CGROUP_QUOTA[",target,"]",NULL) + +#define CGROUP_QUOTA_parameter "CGROUP_QUOTA" +#define CGROUP_QUOTA_command "ubconfig -- source global get security CGROUP_QUOTA" typedef char *string; -string version_application; -char *local; +__attribute__((unused)) static \ +string version_application; typedef struct { - int always_open_documentation; - int win_pos_x; - int win_pos_y; - int win_width; - int win_height; - - int socket_id; - int load_socket_id; - int save_socket_id; - - int lock_help; - int lock_save_local; - int lock_save_global; - int lock_load_global; + template_config_fields + int save_config; + config_str launch_arguments; + int launch_size; GtkListStore *list; long avaliable_ram; long avaliable_swap; @@ -81,34 +86,7 @@ typedef struct { } config; typedef struct { - //Standard - GtkWidget *Window; - GtkWidget *HatLabel; - GtkWidget *PlugBox; - - GtkWidget *HeadOverlay; - GtkWidget *HeadImage; - GtkWidget *HeadBox; - GtkWidget *HeadTitleLabel; - GtkWidget *HeadInfoLabel; - - GtkWidget *StatusBox; - GtkWidget *StatusIcon; - GtkWidget *StatusLabel; - - GtkWidget *SaveLabel; - GtkWidget *SaveMenuItem; - GtkWidget *SaveGlobalMenuItem; - GtkWidget *SaveLocalMenuItem; - GtkWidget *RightBox; - - GtkWidget *LoadLabel; - GtkWidget *LoadGlobalMenuItem; - GtkWidget *LoadLocalMenuItem; - GtkWidget *LeftBox; - - GtkWidget *DocumentationMenuItem; - GtkWidget *AboutMenuItem; + template_window_fields // Custom GtkWidget *FiltersButton; GtkWidget *InformationButton; @@ -202,4 +180,43 @@ typedef struct { char *write; } device_limits; -main_window *setup_window(); \ No newline at end of file +main_window *setup_window(); +void on_save_done(main_window *, config_str output, int size); +char *get_size_mod(GtkComboBox *combo); +void yon_main_window_complete(main_window *widgets); +void config_init(); +void on_info_target_type_switched(GtkWidget *self, main_window *widgets); +void on_tab_changed(GtkWidget *self, GtkWidget *page, int page_num, main_window *widgets); +void on_processes_update(GtkWidget *self,main_window *widgets); +void on_dispatcher_update(GtkWidget *self,main_window *widgets); +void on_edit_open(GtkWidget *self, main_window *widgets); +void on_quotas_edit(GtkWidget *self, dictionary *windows); +void on_remove(GtkWidget *self, main_window *widgets); +void on_information_update(GtkWidget *self, main_window *widgets); +void on_information(GtkWidget *self, main_window *widgets); +void on_information_chosen_changed(GtkWidget *self, main_window *widgets); +void on_add_open(GtkWidget *self, main_window *widgets); +void on_filters_opened(GtkWidget *self, main_window *widgets); +void on_quota_manual_input_focus (GtkWidget *self, GdkEventFocus *event, quota_window *window); +void on_quota_manual_input(GtkWidget *self, quota_window *window); +void on_apply_filters(GtkWidget *self, dictionary *dict); +void yon_load_proceed(YON_CONFIG_TYPE type); +void on_config_custom_load(GtkWidget *,main_window *widgets); +void on_config_global_load(GtkWidget *,main_window *widgets); +void on_config_local_load(GtkWidget *,main_window *widgets); +void on_config_custom_save(GtkWidget *, main_window *); +void on_config_global_save(GtkWidget *, main_window *); +void on_config_local_save(GtkWidget *, main_window *); +void on_config_global_local_save(GtkWidget *, main_window *); +void yon_interface_update(main_window *); +int yon_get_size_request_from_letter(char size); +void on_quotas_save(GtkWidget *self, dictionary *windows); +void on_device_current_changed(GtkWidget *self, quota_window *window); +void yon_get_devices(quota_window *window); +void on_target_check_chosen(GtkWidget *self, quota_window *window); +void on_quota_target_type_changed(GtkWidget *self, quota_window *window); +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 diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 4d44887..c9fdef0 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -1,28 +1,28 @@ -#define VERSION_LABEL yon_char_unite(_("Version:")," ",version_application,"\n",NULL) -#define HELP_LABEL yon_char_unite(_("ubl-settings-resourcequota version:")," ", version_application,"\n",_("CPU and RAM quotas"),"\n",_("Usage:"), " ubl-settings-resourcequota ",_("[OPTIONS]"),"\n",_("Options:"),"\n\t--help, -h\t\t\t",_("Show this help"),"\n\t--version, -V\t\t\t",_("Show package version"),"\n\t--lock-help\t\t\t",_("Lock this help menu"),"\n\t--lock-save\t\t\t",_("Lock configuration saving"),"\n\t--lock-save-local\t\t",_("Lock local configration saving"),"\n\t--lock-save-global\t\t",_("Lock global configration saving"),"\n\t--lock-load-global\t\t",_("Lock global configration loading"),"\n",NULL) -#define ROOT_WARNING_LABEL _("Warning! Application was launched without root - root-dependent actions are locked") +// #define VERSION_LABEL yon_char_unite(_("Version:")," ",version_application,"\n",NULL) +// #define HELP_LABEL yon_char_unite(_("ubl-settings-resourcequota version:")," ", version_application,"\n",_("CPU and RAM quotas"),"\n",_("Usage:"), " ubl-settings-resourcequota ",_("[OPTIONS]"),"\n",_("Options:"),"\n\t--help, -h\t\t\t",_("Show this help"),"\n\t--version, -V\t\t\t",_("Show package version"),"\n\t--lock-help\t\t\t",_("Lock this help menu"),"\n\t--lock-save\t\t\t",_("Lock configuration saving"),"\n\t--lock-save-local\t\t",_("Lock local configration saving"),"\n\t--lock-save-global\t\t",_("Lock global configration saving"),"\n\t--lock-load-global\t\t",_("Lock global configration loading"),"\n",NULL) +// #define ROOT_WARNING_LABEL _("Warning! Application was launched without root - root-dependent actions are locked") #define TITLE_LABEL _("CPU and RAM quotas") #define TITLE_INFO_LABEL _("Configuring CPU and RAM quota settings for groups and users of the system") -#define SUCCESS_LABEL _("Operation succeeded") -#define ABOUT_LABEL _("About") -#define DOCUMENTATION_LABEL _("Documentation") -#define SAVE_LOCAL_LABEL _("Save to local configuration") -#define SAVE_GLOBAL_LABEL _("Save to global configuration") -#define SAVE_CONFIGURATION_LABEL _("Save configuration") -#define SAVE_LABEL _("Save") -#define LOAD_LOCAL_LABEL _("Load local configuration") -#define LOAD_GLOBAL_LABEL _("Load global configuration") -#define LOAD_LABEL _("Load") -#define LOAD_LABEL _("Load") - -#define CANCEL_LABEL _("Cancel") - -#define HELP_TITLE_LABEL _("Would you like to read documentation in the Web?") -#define HELP_INFO_LABEL _("You will be redirected to documentation website, where documentation is\ntranslated and supported by community.") -#define HELP_ALWAYS_OPEN_LABEL _("Always redirect to online documentation") -#define OPEN_HELP_LABEL _("Open documentation") -#define PROJECT_HOME_LABEL _("Project homepage") +// #define SUCCESS_LABEL _("Operation succeeded") +// #define ABOUT_LABEL _("About") +// #define DOCUMENTATION_LABEL _("Documentation") +// #define SAVE_LOCAL_LABEL _("Save to local configuration") +// #define SAVE_GLOBAL_LABEL _("Save to global configuration") +// #define SAVE_CONFIGURATION_LABEL _("Save configuration") +// #define SAVE_LABEL _("Save") +// #define LOAD_LOCAL_LABEL _("Load local configuration") +// #define LOAD_GLOBAL_LABEL _("Load global configuration") +// #define LOAD_LABEL _("Load") +// #define LOAD_LABEL _("Load") + +// #define CANCEL_LABEL _("Cancel") + +// #define HELP_TITLE_LABEL _("Would you like to read documentation in the Web?") +// #define HELP_INFO_LABEL _("You will be redirected to documentation website, where documentation is\ntranslated and supported by community.") +// #define HELP_ALWAYS_OPEN_LABEL _("Always redirect to online documentation") +// #define OPEN_HELP_LABEL _("Open documentation") +// #define PROJECT_HOME_LABEL _("Project homepage") #define NOTHING_CHOSEN_LABEL _("Nothing were chosen") #define STR_USER _("User") @@ -64,7 +64,7 @@ #define WRITE_LIMIT_TAB_LABEL _("I/O\nlimit\n(write)") #define QUOTA_OBJECT_LABEL _("Quota target") -#define SOFT_LIMIT_LABEL _("Soft RAM limit, n(volume)") +#define SOFT_LIMIT_LABEL _("Soft RAM limit, (volume)") #define HARD_LIMIT_LABEL _("Hard RAM limit, (volume)") #define SWAP_LIMIT_LABEL _("Swap file limit (volume)") #define CPU_LIMIT_LABEL _("CPU limit (%)") @@ -100,4 +100,6 @@ #define READ_LABEL _("Read") #define WRITE_LABEL _("Write") #define APPLY_CHANGES_LABEL _("Apply changes of operations limit") -#define MANUAL_INPUT_LABEL _("Manual input (for advanced users)") \ No newline at end of file +#define MANUAL_INPUT_LABEL _("Manual input (for advanced users)") + +#define OPERATION_FAILED_EMPTY_LABEL _("Current quota has no parameters") \ No newline at end of file diff --git a/source/ubl-utils.c b/source/ubl-utils.c deleted file mode 100644 index bf36151..0000000 --- a/source/ubl-utils.c +++ /dev/null @@ -1,2051 +0,0 @@ -#include "ubl-utils.h" - -// dictionary functions - -/**yon_dictionary_new(): - * [EN] - * Creates and returns empty dictionary - * [RU] - * Создаёт и возвращает пустой словарь. - */ -dictionary *yon_dictionary_new() -{ - dictionary *dict = malloc(sizeof(dictionary)); - dict->data = NULL; - dict->key = NULL; - dict->next = NULL; - dict->prev = NULL; - dict->first = dict; - dict->data_type = DICTIONARY_OTHER_TYPE; - return dict; -} - -/**yon_dictionary_copy(dictionary *dict) - * [EN] - * - * [RU] - * Создаёт и возвращает копию элемента словаря [dict] -*/ -dictionary *yon_dictinoary_copy(dictionary *dict){ - dictionary *dct = yon_dictionary_new_with_data(dict->key,dict->data); - dct->data_type= dict->data_type; - return dct; -} - -/**yon_dictionary_copy_deep(dictionary *dict) - * [EN] - * - * [RU] - * Создаёт полную копию словаря [dict] и возвращает первый элемент -*/ -dictionary *yon_dictionary_copy_deep(dictionary *dict){ - dictionary *dct = NULL; - dictionary *newone=NULL; - for_dictionaries(dct,dict){ - yon_dictionary_add_or_create_if_exists_with_data(newone,dct->key,dct->data); - newone->data_type=dct->data_type; - } - return newone->first; -} - -/**int yon_dictionary_set_data(dictionary *dict, void *data) - * [EN] - * - * [RU] - * Установить элементу словаря [dict] значение [data] -*/ -int yon_dictionary_set_data(dictionary *dict, void *data){ - dict->data=data; -} - -/**int yon_dictionary_set_key(dictionary *dict, char *key) - * [EN] - * - * [RU] - * Изменяет ключ элемента словаря [dict] на [key] -*/ -int yon_dictionary_set_key(dictionary *dict, char *key){ - dict->key=key; - return 1; -} - -/** int yon_dictionary_set(dictionary *dict, char *key, void *data) - * [EN] - * - * [RU] -* Устанавливает значение ключа элемента словаря [dict] на [key] и его данные на [data] -*/ -int yon_dictionary_set(dictionary *dict, char *key, void *data){ - dict->key=key; - dict->data=data; - return 1; -} - -/**int yon_dictionary_empty(dictionary *dict) - * [EN] - * - * [RU] - * Очищает элемент словаря [dict] от данных -*/ -int yon_dictionary_empty(dictionary *dict){ - dict->data=NULL; - dict->data_type=DICTIONARY_OTHER_TYPE; - return 1; -} - -/**yon_dictionary_switch_to_last(dictionary **dict) - * [EN] - * - * [RU] - * Переключает словарь [dict] на последний элемент. -*/ -void yon_dictionary_switch_to_last(dictionary **dict) -{ - dictionary *dct=NULL, *dact=*dict; - for_dictionaries(dct,dact); -} - -/**yon_dictionary_create_conneced(dictionary *targetdict) - * [EN] - * - * [RU] - * Создаёт новый элемент словаря [targetdict] -*/ -dictionary *yon_dictionary_append(dictionary *targetdict) -{ - targetdict = yon_dictionary_get_last(targetdict); - targetdict->next = yon_dictionary_new(); - targetdict->next->prev = targetdict; - targetdict->next->first = targetdict->first; - targetdict->next->data_type = DICTIONARY_OTHER_TYPE; - return targetdict->next; -} - -/**yon_dictionary_get_last(dictionary *dict) - * [EN] - * - * [RU] - * Возвращает последний элемент словаря [dict]. - * В отличае от yon_dictionary_switch_to_last() - * словарь [dict] остаётся на прежнем элементе. -*/ -dictionary *yon_dictionary_get_last(dictionary *dict) -{ - if (dict->next){ - dictionary *dct = NULL; - for_dictionaries(dct,dict); - return dct; - } else return dict; -} - -/**yon_dictionary_switch_places(dictionary *dict, int aim) - * [EN] - * - * [RU] - * Меняет элемент словаря [dict] местами с другим элементом. - * если [aim]<0 элемент меняется местами с левым элементом; - * если [aim]>0 элемент меняется местами с правым элементом; -*/ -dictionary *yon_dictionary_swap(dictionary *dict, int aim) -{ - if (aim < 0) - { - if (dict->prev) - { - if (dict->prev->prev) - { - dictionary *next = dict->next, *prev = dict->prev, *preprev = prev->prev; - if (next) - { - preprev->next = dict; - dict->prev = preprev; - dict->next = prev; - prev->prev = dict; - prev->next = next; - next->prev = prev; - } - else - { - preprev->next = dict; - dict->prev = preprev; - dict->next = prev; - prev->prev = dict; - prev->next = NULL; - } - return prev; - } - else - { - dictionary *next = dict->next, *prev = dict->prev; - if (next) - { - yon_dictionary_make_first(dict); - dict->prev = NULL; - dict->next = prev; - prev->prev = dict; - prev->next = next; - next->prev = prev; - } - else - { - dict->prev = NULL; - dict->next = prev; - prev->prev = dict; - prev->next = NULL; - } - return prev; - } - } - } - else if (aim > 0) - { - if (dict->next) - { - if (dict->next->next) - { - dictionary *next = dict->next, *prev = dict->prev, *afnext = next->next; - if (prev) - { - prev->next = next; - next->prev = prev; - next->next = dict; - dict->prev = next; - dict->next = afnext; - afnext->prev = dict; - } - else - { - yon_dictionary_make_first(next); - next->prev = NULL; - next->next = dict; - dict->prev = next; - dict->next = afnext; - afnext->prev = dict; - } - return next; - } - else - { - dictionary *next = dict->next, *prev = dict->prev; - if (prev) - { - prev->next = next; - next->prev = prev; - next->next = dict; - dict->prev = next; - dict->next = NULL; - } - else - { - next->prev = NULL; - next->next = dict; - dict->prev = next; - dict->next = NULL; - } - } - } - } -} - -/**yon_dictionary_make_first(dictionary *dict) - * [EN] - * - * [RU] - * Устанавливает указатель первого элемента словаря [dict] - * на текущий элемент. Не использовать. -*/ -void yon_dictionary_make_first(dictionary *dict) -{ - for (dictionary *dct = dict->first; dct != NULL; dct = dct->next) - { - dct->first = dict; - } -} - -/**yon_dictionary_make_nth(dictionary *dict, int nth) - * [EN] - * - * [RU] - * Перемещает элемент словаря [dict] на позицию [nth]. -*/ -void yon_dictionary_make_nth(dictionary *dict, int nth) -{ - dictionary *dct = dict->first; - for (int i = 0; i < nth; i++) - { - if (dct == NULL) - return; - else - dct = dct->next; - } - yon_dictionary_rip(dict); - dictionary *prev = dct->prev; - prev->next = dict; - dict->prev = prev; - dict->next = dct; - dct->prev = dict; -} - -/**yon_dictionary_create_with_data(char *key, void *data) - * [EN] - * - * [RU] - * Создаёт новый словарь с ключом [key] и указателем на данные [data] -*/ -dictionary *yon_dictionary_new_with_data(char *key, void *data) -{ - dictionary *dct = yon_dictionary_new(); - dct->key = yon_char_new(key); - dct->data = data; - dct->data_type = DICTIONARY_OTHER_TYPE; - return dct; -} - -/** void *yon_dictionary_free_all(dictionary *dictionary,void *data_manipulation) - * [EN] - * Frees whole [dictionary] and activates [data_manipulation] function if not NULL with [dictionary]->data argument for each dictionary. - * [RU] - * Освобождает память для всех элементов словаря [dictionary] и активирует функцию [data_manipulation], если она была передана, с аргументом [dictionary]->data на каждый элемент словаря. -*/ -void *yon_dictionary_free_all(dictionary *dictionary_to_free,void (*data_manipulation)(void*)){ - dictionary *dict=NULL; - for_dictionaries(dict,dictionary_to_free){ - if(data_manipulation) - data_manipulation(dict->data); - if(dict->prev) - free(dict->prev); - } - free(dict); - return NULL; -} - -/**yon_dictionary_create_with_data_connected(dictionary *dict, char *key, void *data) - * [EN] - * - * [RU] - * Создаёт новый элемент словаря, присоединяемый в конец словаря [dict] - * с ключом [key] и указателем на данные [data] -*/ -dictionary *yon_dictionary_append_with_data(dictionary *dict, char *key, void *data) -{ - dictionary *dct = yon_dictionary_append(dict); - dct->key = yon_char_new(key); - dct->data = data; - dct->data_type = DICTIONARY_OTHER_TYPE; - return dct; -} - -/**yon_dictionary_connect(dictionary *old, dictionary *toconnect) - * [EN] - * - * [RU] - * Присоединяет словарь [toconnect] в конец словаря [old]. -*/ -dictionary *yon_dictionary_connect(dictionary *old, dictionary *toconnect) -{ - dictionary *dict = yon_dictionary_get_last(old); - dict->next = toconnect; - toconnect->prev = dict; - toconnect->first = dict->first; - return toconnect; -} - -/**yon_dictionary_get(dictionary **dict, char *key) - * [EN] - * - * [RU] - * Возвращает элемент словаря [dict] с ключом [key]. - * Если такого элемента не было обнаружено, возвращается NULL -*/ -dictionary *yon_dictionary_get(dictionary **dict, char *key) -{ - dictionary *dct = *dict; - for (dictionary *pointer = dct->first; pointer != NULL; pointer = pointer->next) - { - if (strcmp(pointer->key, key) == 0) - { - *dict = pointer; - return pointer; - } - } - return NULL; -} - -/**yon_dictionary_rip(dictionary *dict) - * [EN] - * - * [RU] - * Вырезает элемент из словаря и возвращает вырезанный элемент. -*/ -dictionary *yon_dictionary_rip(dictionary *dict) -{ - if (!dict->next&&!dict->prev) return NULL; - else if (!dict->next) - { - dictionary *prev = dict->prev; - if (prev) - { - prev->next = NULL; - return prev; - } - else - return dict; - } - else if (!dict->prev) - { - dictionary *next = dict->next; - if (next) - { - yon_dictionary_make_first(next); - next->prev = NULL; - return next; - } - else - return dict; - } - else - { - dictionary *next = dict->next, *prev = dict->prev; - next->prev = prev; - prev->next = next; - return next; - } -} - -/**yon_dictionary_get_nth(dictionary *dict, int place) - * [EN] - * - * [RU] - * Возвращает [place]-й элемент словаря [dict] -*/ -dictionary *yon_dictionary_get_nth(dictionary *dict, int place) -{ - if (dict){ - dict = dict->first; - int i = 0; - for (i = 0; i < place; i++) - if (dict->next) - dict = dict->next; - else - break; - if (i == place) - return dict; - else - return NULL; - } else return NULL; -} - -// char functions - -int yon_char_find_last(char *source, char find){ - int size = strlen(source); - int i=size; - for (;source[i]!=find&&i>0;i--); - return i; -} - -/**[EN] - * - * creates new char string by combining two char strings. - */ -char *yon_char_append(char *source, char *append) -{ - if (source && append) - { - int size = strlen(source) + strlen(append) + 1; - char *final = malloc(size); - memset(final, 0, size); - if (strstr(source, "%%")) - sprintf(final, source, append); - else - sprintf(final, "%s%s", source, append); - return final; - } - else - return NULL; -} - -/**[EN] - * - * creates new char string by copying another char. - */ -char *yon_char_new(char *chr) -{ - if (chr){ - char *newchar = malloc(strlen(chr) + 1); - memset(newchar, 0, strlen(chr) + 1); - memcpy(newchar, chr, strlen(chr)); - return newchar; - } else - return NULL; -} - -/**yon_char_unite(char *source, ...) - * [En] - * - * [RU] - * Объединяет строку [source] со всеми строками, написанными в [...] -*/ -char *yon_char_unite(char *source, ...){ - va_list arglist; - char *new_char=NULL; - char *unite_char=NULL; - new_char=yon_char_new(source); - va_start(arglist,source); - unite_char = va_arg(arglist,char*); - while(unite_char){ - new_char = yon_char_append(new_char,unite_char); - unite_char = va_arg(arglist,char*); - } - va_end(arglist); - return new_char; -} - -/**yon_cut(char *source, int size, int startpos) - * [EN] - * cuts source string by size length from startpos position. - */ -char *yon_cut(char *source, int size, int startpos) -{ - char *cut = NULL; - cut = malloc(size + 1); - memset(cut, 0, size + 1); - memcpy(cut, source + startpos, size); - return cut; -} - -/**yon_char_divide(char *source, int dividepos) - * [EN] - * divides source string in dividepos position, - * returning left part of divided string and - * inserting right part to source string. - */ -char *yon_char_divide(char *source, int dividepos) -{ - char *cut = malloc(dividepos + 1); - memset(cut, 0, dividepos + 1); - memcpy(cut, source, dividepos); - char *left = malloc(strlen(source) - strlen(cut)); - memset(left, 0, strlen(source) - strlen(cut)); - memcpy(left, source + dividepos + 1, (strlen(source) - dividepos)); - memset(source, 0, strlen(source)); - memcpy(source, left, strlen(left)); - return cut; -} - -/**yon_char_find_count(char *source, char *find) - * [EN] - * - * [RU] - * Считает количество символов [find] в строке [source] -*/ -int yon_char_find_count(char *source, char *find){ - char *working_string=yon_char_new(source); - int i=0; - int size=0; - int pos=0; - config_str rtn = yon_char_parse(working_string,&size,"\n"); - for (int j=0;j= 10; i++) - { - convert_check = convert_check / 10; - } - char *ch = g_malloc0(i * sizeof(char) + 1); - sprintf(ch, "%d", int_to_convert); - return ch; -} - -/**yon_char_from_long(int int_to_convert) - * [EN] - * converts int to char*. - * - * [RU] - * Конвертирует int в char* - */ -char *yon_char_from_long(long int_to_convert) -{ - int i = 1; - double convert_check = (double)int_to_convert; - for (i = 1; convert_check >= 10; i++) - { - convert_check = convert_check / 10; - } - char *ch = g_malloc0(i * sizeof(char) + 1); - sprintf(ch, "%ld", int_to_convert); - return ch; -} - -/**yon_char_replace(char *source, char *find, char*replace) - * [EN] - * - * [RU] - * Заменяет в строке [source] все вхождения строки [find] на [replace] -*/ -char *yon_char_replace(char *source, char *find, char*replace){ - if (!strstr(replace,find)){ - - - char *final=NULL; - char *temp=NULL; - if(!strstr(replace,find)){ - while ((final=strstr(source,find))){ - temp=malloc(strlen(source)-strlen(final)); - memset(temp,0,strlen(source)-strlen(final)+strlen(replace)); - memcpy(temp,source,strlen(source)-strlen(final)); - temp=yon_char_append(temp,replace); - source=yon_char_append(temp,final+1); - } - - } - } - return source; -} - -/**yon_char_parse(char *parameters, int *size, char *divider) - * [EN] - * Parses string [parameters], divided by [divider], - * then returns parsed string array and sets [size] to - * size of returned array -*/ -char **yon_char_parse(char *parameters, int *size, char *divider){ - char **string=NULL; - int i=1; - string=malloc(sizeof(char*)); - char *paramline=yon_char_new(parameters); - char *param; - if (!strstr(parameters,divider)) return NULL; - while ((param=yon_char_divide_search(paramline,divider,1))){ - if (strcmp(param,paramline)==0||param[0]=='\0') break; - string=realloc(string,sizeof(char*)*i); - string[i-1]=yon_char_new(param); - i++; - } - string=realloc(string,sizeof(char*)*i); - string[i-1]=yon_char_new(paramline); - i++; - *size=i-1; - return string; -} - -/**yon_char_parsed_rip(char **char_string, int *size, int item_to_delete) - * [EN] - * - * [RU] - * Удаляет элемент [item_to_delete] из массива строк [char_string], размера [size] - * Возвращает получившийся массив, в [size] загружается размер нового массива. -*/ -char **yon_char_parsed_rip(char **char_string, int *size, int item_to_delete){ - char **new_char_parsed=NULL; - new_char_parsed=malloc(sizeof(char*)*((*size)-1)); - int flag = 0; - for (int i=0;i < (*size);i++){ - if (i==item_to_delete) { - flag = 1; - } - if (flag == 0) { - new_char_parsed[i]=yon_char_new(char_string[i]); - } - else if (flag == 1 && i!=item_to_delete) { - new_char_parsed[i-1]=yon_char_new(char_string[i]); - } - } - (*size)=(*size)-1; - return new_char_parsed; -} - -/**yon_char_parsed_check_exist(char **parameters, int size, char *param) - * [EN] - * Checks if [parameters] string array of length [size] - * has [param] element; - * [RU] - * Проверяет есть ли в массиве строк [parameters], размера [size] - * элемент [param] -*/ -int yon_char_parsed_check_exist(char **parameters, int size, char *param){ - - for (int i=0;ipw_name,NULL); - else { - user_list = yon_char_parsed_append(user_list,user_size,user->pw_name); - } - } - endpwent(); - return user_list; -} - -config_str yon_ubl_get_all_processes(int *processes_size){ - config_str processes = yon_config_load(get_processes_command,processes_size); - yon_char_parsed_remove_newline_symbols(processes,processes_size); - return processes; -} - -config_str yon_ubl_get_all_slices(int *slices_size){ - config_str slices = yon_config_load(get_slices_command,slices_size); - yon_char_parsed_remove_newline_symbols(slices,slices_size); - return slices; -} - -// parsing functions - - -apps *yon_apps_scan_and_parse_desktops(int *sizef) -{ - int size = 0; - struct apps *applist; - { - DIR *directory = opendir(DesktopPath); - struct dirent *de; - while ((de = readdir(directory))) - { - FILE *file; - char *path = yon_char_append(DesktopPath, de->d_name); - file = fopen(path, "r"); - if (strlen(de->d_name) > 9) - { - char *extension = strstr(path, "."); - if (extension != NULL) - { - if (strcmp(extension, ".desktop") == 0) - { - apps tempapp; - GKeyFile *gfile = g_key_file_new(); - GError *err = NULL; - g_key_file_load_from_file(gfile, path, G_KEY_FILE_KEEP_TRANSLATIONS, NULL); - char *Type = g_key_file_get_string(gfile, "Desktop Entry", "Type", &err); - if (err) - { - printf("%s\n", err->message); - } - if (strcmp(Type, "Application") == 0) - tempapp.Type = 1; - else if (strcmp(Type, "pyApplication") == 0) - tempapp.Type = 2; - else - continue; - tempapp.Name = g_key_file_get_locale_string(gfile, "Desktop Entry", "Name", setlocale(LC_ALL, NULL), NULL); - if (tempapp.Name == NULL) - continue; - tempapp.Categories = g_key_file_get_string(gfile, "Desktop Entry", "Categories", NULL); - if (tempapp.Categories == NULL) - continue; - tempapp.Exec = g_key_file_get_string(gfile, "Desktop Entry", "Exec", NULL); - if (tempapp.Exec == NULL) - continue; - tempapp.Icon = g_key_file_get_string(gfile, "Desktop Entry", "Icon", NULL); - if (tempapp.Icon == NULL) - continue; - tempapp.Pluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "Pluggable", NULL); - if (!tempapp.Pluggable) - tempapp.Pluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "X-XfcePluggable", NULL); - if (tempapp.Pluggable) - tempapp.DualPluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "X-UBLPluggable", NULL); - if (g_key_file_get_boolean(gfile, "Desktop Entry", "X-UBL-SettingsManager-Hidden", NULL) == 0) - if (size == 0) - { - applist = (apps *)malloc(size + 1 * sizeof(apps)); - applist[0].Name = yon_char_new(tempapp.Name); - applist[0].Categories = yon_char_new(tempapp.Categories); - applist[0].Exec = yon_char_new(tempapp.Exec); - applist[0].Icon = yon_char_new(tempapp.Icon); - applist[0].Type = tempapp.Type; - applist[0].Pluggable = tempapp.Pluggable; - applist[0].DualPluggable = tempapp.DualPluggable; - size++; - } - else - { - applist = (apps *)realloc(applist, (size + 1) * sizeof(apps)); - applist[size].Name = yon_char_new(tempapp.Name); - applist[size].Categories = yon_char_new(tempapp.Categories); - applist[size].Exec = yon_char_new(tempapp.Exec); - applist[size].Icon = yon_char_new(tempapp.Icon); - applist[size].Pluggable = tempapp.Pluggable; - applist[size].DualPluggable = tempapp.DualPluggable; - applist[size].Type = tempapp.Type; - size++; - } - } - } - } - } - } - *sizef = size; - return applist; -}; - -void yon_apps_sort(apps *applist, int size) -{ - apps tmp; - if (size > 2) - { - for (int i = 1; i < size; i++) - { - for (int j = 1; j < size; j++) - { - if (strcmp(applist[j].Name, applist[j - 1].Name) < 0) - { - tmp = applist[j]; - applist[j] = applist[j - 1]; - applist[j - 1] = tmp; - }; - } - }; - } -}; - -apps *yon_apps_get_by_name(apps *applist, char *name, int size) -{ - for (int i = 0; i < size; i++) - { - if (strcmp(applist[i].Name, name) == 0) - return &applist[i]; - } - return NULL; -}; - -//config functions - -/**yon_config_load_register(char *command) - * [EN] - * - * [RU] - * Выполняет команду [command]. - * Полученные данные парсятся и регистрируются в конфиг. -*/ -int yon_config_load_register(char *command){ - if (__yon__config__strings){ - __yon__config__strings = yon_dictionary_free_all(__yon__config__strings,NULL); - } - FILE *output = popen(command, "r"); - char **output_strings = NULL; - output_strings = malloc(sizeof(char*)); - int i = 0; - char str[4096]; - memset(str, 0, 4096); - while (fgets(str, 4096, output)) - { - if (strcmp(str, "") != 0&& strcmp(str,"(null)\n")!=0) - { - char *key = yon_char_divide_search(str,"=",-1); - char *final_str=yon_char_divide_search(str,"\n",-1); - yon_dictionary_add_or_create_if_exists_with_data(__yon__config__strings,key,yon_char_new(final_str)); - __yon__config__strings->data_type=DICTIONARY_CHAR_TYPE; - } - } - check_config - return 1; - else return 0; -} - -/**yon_config_remove_by_key(char *key) - * [EN] - * - * [RU] - * Удаляет параметр конфига по ключу [key] -*/ -int yon_config_remove_by_key(char *key){ - check_config{ - dictionary *dict = yon_dictionary_get(&__yon__config__strings,key); - if (dict){ - yon_dictionary_rip(dict); - return 1; - }else return 0; - } - return 0; -} - -/**yon_config_remove_by_data(void *data) - * [EN] - * - * [RU] - * Производит поиск по конфигу на наличие параметра со значением [data] и удаляет найденное значение из конфига. -*/ -int yon_config_remove_by_data(void *data){ - check_config{ - dictionary *dict = NULL; - for_dictionaries(dict,__yon__config__strings){ - if (dict->data==data){ - yon_dictionary_rip(dict); - return 1; - } - } - return 0; - } - return 0; -} - -/**yon_config_remove_element(char *key, char *deleted) - * [EN] - * - * [RU] - * Удаляет элемент [deleted] из массива параметров с ключом [key] -*/ -int yon_config_remove_element(char *key, char *deleted){ - check_config{ - dictionary *dict = yon_dictionary_get(&__yon__config__strings,key); - char *data = (char*)dict->data; - char *found = strstr(data,deleted); - int size=strlen(data)-strlen(found)+1; - char *new_data = malloc(size); - memset(new_data,0,size); - if (strlen(found)!=strlen(deleted)){ - memcpy(new_data,data,size-1); - new_data = yon_char_append(new_data,found+strlen(deleted)+1); - } else { - memcpy(new_data,data,size-2); - new_data = yon_char_append(new_data,found+strlen(deleted)); - } - dict->data=(void*)(new_data); - // free(data); - dict->flag1=1; - return 1; - } else return 0; -} - -/**yon_config_get_by_key(char *key) - * [EN] - * - * [RU] - * Возвращает значение параметра конфига с ключом [key] -*/ -void *yon_config_get_by_key(char *key){ - check_config{ - dictionary *dict = NULL; - for_dictionaries(dict, __yon__config__strings){ - if (strcmp(dict->key,key)==0){ - return dict->data; - } - } - } - return NULL; -} - -/**yon_config_get_key_by_data(char *data) - * [EN] - * - * [RU] - * Возвращает ключ параметра конфига со значением [data]. - * Если параметр с таким значением не найден, возвращается NULL -*/ -char *yon_config_get_key_by_data(char *data){ - check_config{ - dictionary *dict = NULL; - for_dictionaries(dict, __yon__config__strings){ - if (strcmp(((char*)dict->data),data)==0){ - return dict->key; - } - } - } - return NULL; -} - -/**yon_config_set(char *key, void *data) - * [EN] - * - * [RU] - * Производит поиск по конфигу и заменяет значение параметра с ключом [key] на новое значение [data]; -*/ -int yon_config_set(char *key, void *data){ - check_config{ - dictionary *dict = yon_dictionary_get(&__yon__config__strings,key); - dict->data=data; - dict->flag1=1; - return 1; - } else return 0; -} - - -/**yon_config_append(char *key, void *data) - * [EN] - * - * [RU] - * Производит поиск по конфигу и дополняет значение параметра с ключом [key] значением [data]; -*/ -int yon_config_append(char *key, char *data){ - check_config{ - dictionary *dict = yon_dictionary_get(&__yon__config__strings,key); - if (strcmp(((char*)dict->data),"")!=0) - dict->data=(void*)(yon_char_unite((char*)dict->data," ",data,NULL)); - else dict->data=(void*)data; - dict->flag1=1; - return 1; - } else return 0; -} - - -/**yon_config_clean() - * [EN] - * Erase all parameters from config; - * [RU] - * Удаляет все параметры из конфига; -*/ -int yon_config_clean(){ - check_config{ - __yon__config__strings = yon_dictionary_free_all(__yon__config__strings, NULL); - return 1; - } - else return 0; -} - -/**yon_config_register(char *key, void *data) - * [EN] - * - * [RU] - * Регистрирует новый параметр конфига. - * [key] - ключ параметра; - * [data] - значение параметра; -*/ -void yon_config_register(char *key, void *data){ - if (!__yon__config__strings||!yon_dictionary_get(&__yon__config__strings,key)){ - yon_dictionary_add_or_create_if_exists_with_data(__yon__config__strings,key,data); - } - else if (yon_dictionary_get(&__yon__config__strings,key)) __yon__config__strings->data=data; - __yon__config__strings->data_type=DICTIONARY_CHAR_TYPE; - __yon__config__strings->flag1=1; -} - -/**yon_config_load(char *command, int *str_len) - * [EN] - * - * [RU] - * Выполняет команду [command] и возвращает распаршеный результат выполнения команды. - * В [str_len] возвращается длина возвращаемого массива -*/ -config_str yon_config_load(char *command, int *str_len){ - FILE *output = popen(command, "r"); - char **output_strings = NULL; - output_strings = malloc(sizeof(char)); - int i = 0; - char str[4096]; - memset(str, 0, 4096); - while (fgets(str, 4096, output)) - { - if (strcmp(str, "") != 0) - { - output_strings = realloc(output_strings, sizeof(char *) * (i + 1)); - // printf("%s\n", str); - output_strings[i] = NULL; - output_strings[i] = yon_char_new(str); - memset(str, 0, 4096); - i++; - } - } - if (i>0){ - *str_len = i; - return output_strings; - } else{ - *str_len=-1; - return NULL; - } -} - -/**int yon_config_save_registered(char *path, char *section) - * [EN] - * Saves config with [command] - * [RU] - * Выполняет команду [command], добавляя в конец все записи конфига в таком виде: - * [ПАРАМЕТР1]="[значения1]" [ПАРАМЕТР2]="[значения2]" -*/ -int yon_config_save_registered(char *path, char *section){ - check_config{ - char *command = yon_char_unite("/usr/bin/ubconfig",path ? yon_char_append(" --target ",path):"", " set ", section,NULL); - char *remove_command = yon_char_unite("/usr/bin/ubconfig", path ? yon_char_append(" --target ",path):"", " remove ", section,NULL); - dictionary *dict = NULL; - int any_add = 0; - int any_remove = 0; - for_dictionaries(dict,__yon__config__strings){ - char *data = yon_dictionary_get_data(dict,char*); - if (dict->flag1==1&&strcmp(data,"")!=0){ - command = yon_char_unite(command, " ", dict->key,"=\"", yon_dictionary_get_data(dict,char*),"\"", NULL); - any_add=1; - } - if (strcmp(data,"")==0){ - remove_command = yon_char_unite(remove_command, " ", dict->key, NULL); - any_remove=1; - } - } - if (any_add) yon_launch(command); - if (any_remove) yon_launch(remove_command); - return 1; - } else return 1; -} - -/**yon_config_get_all(int *size) - * [EN] - * - * [RU] - * Возвращает массив со всеми параметрами конфига, оканчивающаяся NULL - * [size] - указатель, в который выгружается длина массива -*/ -config_str yon_config_get_all(int *size){ - check_config{ - *size = 1; - config_str conf = NULL; - dictionary *dict = NULL; - for_dictionaries(dict,__yon__config__strings){ - conf = yon_remalloc(conf,sizeof(char*)*(*size)); - conf[(*size)-1] = yon_char_unite(dict->key,"=",(char*)dict->data,NULL); - (*size)++; - } - conf = yon_remalloc(conf,sizeof(char*)*(*size)); - conf[*size-1] = NULL; - return conf; - } else return NULL; -} - -/**char *yon_config_get_parameter(config parameters, int size, char *param) - * [EN] - * Gets parameter [param] from parameter list [parameters] of size [size]; - * or NULL if nothing were found - * [RU] - * Возвращает параметр [param] из массива строк [parameters] размером [size] - * или NULL если такой не был найден -*/ -char *yon_config_get_parameter(config_str parameters, int size, char *param) -{ - if (param[0]==' ') - yon_char_divide_search(param," ",-1); - param=yon_char_divide_search(yon_char_new(param)," ",-1); - - char *str = NULL; - for (int j = 0; j < size; j++) - { - char *name = yon_char_divide_search(yon_char_new(parameters[j]), "=", 1); - if (name) - { - if (strcmp(name, param) == 0) - { - str = yon_char_divide_search(yon_char_new(parameters[j]), "\n", 1); - if (strcmp(str, "") != 0 && strcmp(str, "(null)") != 0) - return str; - else - return NULL; - } - } - } - return NULL; -} - - - -// terminal-using functions - -/**yon_launch_app_with_arguments(char *name, char *args) - * [EN] - * Execute [command] in separate thread; - * [RU] - * Выполнить команду [command] в отдельном потоке; -*/ -int yon_launch_app_with_arguments(char *name, char *args) -{ - char *path = yon_char_unite("/usr/bin/", name, " ", args,NULL); - pthread_t thread_id; - char *command = NULL; - command = path; - pthread_create(&thread_id, NULL, (void *)yon_launch, command); -}; - -/**yon_launch(char *command) - * [EN] - * Execute command [command] - * [RU] - * Выполнить команду [command] -*/ -void yon_launch(char *command) -{ - system(command); -} - -// Gtk functions - - -#ifdef __GTK_H__ - - -static render_data render; - -#ifdef VTE_TERMINAL - -static void child_ready(VteTerminal *terminal, GPid pid, GError *error, gpointer user_data) -{ - if (!terminal) return; - if (pid == -1) printf("Error\n\n\n"); - else vte_terminal_feed_child(VTE_TERMINAL(terminal),(char*)user_data,strlen((char*)user_data)); -} - -/** - * void yon_terminal_integrated_launch(GtkWidget *place_to_show, void *endwork_function, void* endwork_function_argument) - * [EN] - * launches terminal with specific [command], - * terminal is shown in [place_to_show] container, - * after terminal done its work [endwork_function] is called with [endwork_function_argument] argument. - * [RU] - * Запускает терминал с командой [command], - * терминал добавляется в контейнер [place_to_show] виджета, - * после завершения работы терминала вызывается функция [endwork_function] с аргументом [endwork_function_argument]. -*/ -void yon_terminal_integrated_launch(GtkWidget *place_to_show, char* command, void *endwork_function, void* endwork_function_argument){ - char **commands=new_arr(char*,2); - gchar **envp = g_get_environ(); - commands[0]=(gchar *)g_strdup(g_environ_getenv(envp, "SHELL")); - commands[1]=NULL; - char **env=new_arr(char*,2); - env[0]=""; - env[1]=NULL; - GtkWidget *terminal = vte_terminal_new(); - vte_terminal_set_size(VTE_TERMINAL(terminal),10,15); - VtePty *pty = vte_pty_new_sync(VTE_PTY_DEFAULT,NULL,NULL); - vte_terminal_set_pty(VTE_TERMINAL(terminal),pty); - gtk_container_add(GTK_CONTAINER(place_to_show),terminal); - char *install_command=yon_char_unite("tput cup 0 0 && tput ed; ",command," ; sleep 5;exit 0","\n",NULL); - if(endwork_function) - g_signal_connect(G_OBJECT(terminal), "child-exited", G_CALLBACK(endwork_function), endwork_function_argument); - vte_terminal_spawn_async(VTE_TERMINAL(terminal), - VTE_PTY_DEFAULT, - NULL, - commands, - NULL, - 0, - NULL, NULL, - NULL, - -1, - NULL, - child_ready, - install_command); - vte_pty_spawn_async(pty, - NULL, - commands, - NULL, - 0, - NULL, NULL, - NULL, - -1, - NULL, - NULL, - NULL); - vte_terminal_set_scrollback_lines(VTE_TERMINAL(terminal), -1); - vte_terminal_set_scroll_on_output(VTE_TERMINAL(terminal), TRUE); - vte_terminal_set_scroll_on_keystroke(VTE_TERMINAL(terminal), TRUE); - gtk_widget_show_all(terminal); - } - -/**yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *endwork_function, void* endwork_function_argument) - * [EN] - * launches terminal with specific [command], - * terminal is shown in [place_to_show] container, - * after terminal done its work [endwork_function] is called with [endwork_function_argument] argument. - * [RU] - * Запускает терминал с командой [command], - * терминал добавляется в контейнер [place_to_show] виджета, - * после завершения работы терминала вызывается функция [endwork_function] с аргументом [endwork_function_argument]. -*/ -void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *endwork_function, void* endwork_function_argument){ - char **commands=new_arr(char*,2); - gchar **envp = g_get_environ(); - commands[0]=(gchar *)g_strdup(g_environ_getenv(envp, "SHELL")); - commands[1]=NULL; - char **env=new_arr(char*,2); - env[0]=""; - env[1]=NULL; - vte_terminal_set_size(VTE_TERMINAL(terminal),10,15); - VtePty *pty = vte_pty_new_sync(VTE_PTY_DEFAULT,NULL,NULL); - vte_terminal_set_pty(VTE_TERMINAL(terminal),pty); - char *install_command=yon_char_unite("tput cup 0 0 && tput ed; ",command," ; sleep 5;exit 0","\n",NULL); - if(endwork_function) - g_signal_connect(G_OBJECT(terminal), "child-exited", G_CALLBACK(endwork_function), endwork_function_argument); - vte_terminal_spawn_async(VTE_TERMINAL(terminal), - VTE_PTY_DEFAULT, - NULL, - commands, - NULL, - 0, - NULL, NULL, - NULL, - -1, - NULL, - child_ready, - install_command); - vte_pty_spawn_async(pty, - NULL, - commands, - NULL, - 0, - NULL, NULL, - NULL, - -1, - NULL, - NULL, - NULL); - vte_terminal_set_scrollback_lines(VTE_TERMINAL(terminal), -1); - vte_terminal_set_scroll_on_output(VTE_TERMINAL(terminal), TRUE); - vte_terminal_set_scroll_on_keystroke(VTE_TERMINAL(terminal), TRUE); - gtk_widget_show_all(terminal); - } -#endif - - // Window config functions - - #define check_window_config_setup if(__yon_window_config_target_window) - - typedef struct { - char *parameter_name; - enum YON_TYPE containing_type; - GtkWidget *track_widget; - char *property_name; - } __yon_listener_parameter; - - typedef struct { - char *parameter_name; - char *section; - enum YON_TYPE containing_type; - void *property; - } __yon_custom_parameter; - - struct { - int x; - int y; - int width; - int height; - int fullscreen; - dictionary *custom_listeners; - dictionary *custom_parameters; - dictionary *deleted_parameters; - } __yon_main_window_config; - - static GtkWindow *__yon_window_config_target_window = NULL; - static GKeyFile *__yon_window_config_file = NULL; - static char *__yon_window_config_path = NULL; - - void yon_window_config_save(){ - g_key_file_set_integer(__yon_window_config_file,"window","WindowPosX",__yon_main_window_config.x); - g_key_file_set_integer(__yon_window_config_file,"window","WindowPosY",__yon_main_window_config.y); - g_key_file_set_integer(__yon_window_config_file,"window","WindowWidth",__yon_main_window_config.width); - g_key_file_set_integer(__yon_window_config_file,"window","WindowHeight",__yon_main_window_config.height); - g_key_file_set_integer(__yon_window_config_file,"window","fullscreen",__yon_main_window_config.fullscreen); - dictionary *dict=NULL; - if (__yon_main_window_config.custom_listeners) - for_dictionaries(dict,__yon_main_window_config.custom_listeners){ - __yon_listener_parameter *param = yon_dictionary_get_data(dict,__yon_listener_parameter*); - GValue *val = g_malloc0(sizeof(GValue)); - g_object_get_property(G_OBJECT(param->track_widget),param->property_name,val); - switch(param->containing_type){ - case YON_TYPE_STRING: - g_key_file_set_string(__yon_window_config_file,"window",param->parameter_name, g_value_get_string(val)); - break; - case YON_TYPE_INT: - g_key_file_set_integer(__yon_window_config_file,"window",param->parameter_name, g_value_get_int(val)); - break; - case YON_TYPE_DOUBLE: - g_key_file_set_double(__yon_window_config_file,"window",param->parameter_name, g_value_get_double(val)); - break; - case YON_TYPE_BOOLEAN: - g_key_file_set_boolean(__yon_window_config_file,"window",param->parameter_name, g_value_get_boolean(val)); - break; - case YON_TYPE_OTHER:printf("\033[0;31mCannot save %s property with %s key\033[0m\n",param->property_name,param->parameter_name);break; - } - } - if (__yon_main_window_config.custom_parameters) - for_dictionaries(dict,__yon_main_window_config.custom_parameters){ - __yon_custom_parameter *param = yon_dictionary_get_data(dict,__yon_custom_parameter*); - switch (param->containing_type){ - case YON_TYPE_STRING: - g_key_file_set_string(__yon_window_config_file,param->section,param->parameter_name, (char*)param->property); - break; - case YON_TYPE_INT: - g_key_file_set_integer(__yon_window_config_file,param->section,param->parameter_name, *(int*)param->property); - break; - case YON_TYPE_DOUBLE: - g_key_file_set_double(__yon_window_config_file,param->section,param->parameter_name, *(double*)param->property); - break; - case YON_TYPE_BOOLEAN: - g_key_file_set_boolean(__yon_window_config_file,param->section,param->parameter_name, *(gboolean*)param->property); - break; - default: - break; - } - } - if (__yon_main_window_config.deleted_parameters) - for_dictionaries(dict,__yon_main_window_config.deleted_parameters){ - __yon_custom_parameter *param = yon_dictionary_get_data(dict,__yon_custom_parameter*); - g_key_file_remove_key(__yon_window_config_file,param->section,param->parameter_name,NULL); - } - g_key_file_save_to_file(__yon_window_config_file,__yon_window_config_path,NULL); - } - - void yon_get_is_fullscreen(){ - gtk_window_is_maximized(__yon_window_config_target_window); - __yon_main_window_config.fullscreen = gtk_window_is_maximized(__yon_window_config_target_window); - if (!__yon_main_window_config.fullscreen) gtk_window_get_position(__yon_window_config_target_window,&__yon_main_window_config.x,&__yon_main_window_config.y); - } - - /**yon_on_configured_window_destroy(GtkWidget* self,GdkEvent* event) - * [EN] - * - * [RU] - * Сохраняет настройки основного окна. Вызывается когда основное окно уничтожается. - */ - void yon_on_configured_window_destroy(GtkWidget* self,GdkEvent* event){ - check_window_config_setup{ - yon_get_is_fullscreen(); - yon_window_config_save(); - } - gtk_main_quit(); - } - - void __yon_window_config_on_resize(){ - int max=0; - max=gtk_window_is_maximized(__yon_window_config_target_window); - if(max==0){ - gtk_window_get_size(__yon_window_config_target_window,&__yon_main_window_config.width,&__yon_main_window_config.height); - gtk_window_get_position(__yon_window_config_target_window,&__yon_main_window_config.x,&__yon_main_window_config.y); - } - } - - /**yon_window_config_setup(GtkWindow *window) - * [EN] - * - * [RU] - * Устанавливает указатель на окно для отслеживания его положения и размера - */ - void yon_window_config_setup(GtkWindow *window){ - __yon_window_config_target_window = window; - g_signal_connect(G_OBJECT(window),"delete-event",G_CALLBACK(yon_on_configured_window_destroy),NULL); - g_signal_connect(G_OBJECT(window),"check-resize"/*"configure-event"*/,G_CALLBACK(__yon_window_config_on_resize),NULL); - } - - void _yon_maximize(void *data){ - g_usleep(G_USEC_PER_SEC/10); - if(__yon_main_window_config.fullscreen ==1) gtk_window_maximize(__yon_window_config_target_window); - } - - /**yon_window_config_load(char *path) - * [EN] - * - * [RU] - * Загружает конфиг окна и инициализирует отслеживание его параметров - */ - int yon_window_config_load(char *path){ - __yon_window_config_file = g_key_file_new(); - __yon_window_config_path=yon_char_new(path); - if (!g_key_file_load_from_file(__yon_window_config_file,__yon_window_config_path,G_KEY_FILE_NONE,NULL)){ - struct stat st; - int size; - char *path = yon_char_divide(yon_char_new(__yon_window_config_path),yon_char_find_last(__yon_window_config_path,'/')); - if (stat(path, &st) == -1) { - mkdir(path, 0777); - } - FILE *fp; - fp=fopen(__yon_window_config_path,"w"); - fclose(fp); - g_key_file_load_from_file(__yon_window_config_file,__yon_window_config_path,G_KEY_FILE_NONE,NULL); - } - __yon_main_window_config.x = g_key_file_get_integer(__yon_window_config_file,"window","WindowPosX",NULL); - __yon_main_window_config.y = g_key_file_get_integer(__yon_window_config_file,"window","WindowPosY",NULL); - __yon_main_window_config.width = g_key_file_get_integer(__yon_window_config_file,"window","WindowWidth",NULL); - __yon_main_window_config.height = g_key_file_get_integer(__yon_window_config_file,"window","WindowHeight",NULL); - __yon_main_window_config.fullscreen = g_key_file_get_integer(__yon_window_config_file,"window","fullscreen",NULL); - dictionary *dict=NULL; - if (__yon_main_window_config.custom_listeners) - for_dictionaries(dict,__yon_main_window_config.custom_listeners){ - __yon_listener_parameter *param = yon_dictionary_get_data(dict,__yon_listener_parameter*); - GValue *val = g_malloc0(sizeof(GValue)); - g_object_get_property(G_OBJECT(param->track_widget),param->property_name,val); - switch(param->containing_type){ - case YON_TYPE_STRING: - g_value_set_string(val,g_key_file_get_string(__yon_window_config_file,"window",param->parameter_name, NULL)); - break; - case YON_TYPE_INT: - g_value_set_int(val,g_key_file_get_integer(__yon_window_config_file,"window",param->parameter_name, NULL)); - break; - case YON_TYPE_DOUBLE: - g_value_set_double(val,g_key_file_get_double(__yon_window_config_file,"window",param->parameter_name, NULL)); - break; - case YON_TYPE_BOOLEAN: - gboolean res = g_key_file_get_boolean(__yon_window_config_file,"window",param->parameter_name, NULL); - g_value_set_boolean(val,res); - break; - default:printf("\033[0;31mCannot load %s property with %s key\033[0m\n",param->property_name,param->parameter_name);break; - } - g_object_set_property(G_OBJECT(param->track_widget),param->property_name,val); - } - if (__yon_main_window_config.width!=0&&__yon_main_window_config.height!=0) gtk_window_resize(__yon_window_config_target_window,__yon_main_window_config.width,__yon_main_window_config.height); - if (__yon_main_window_config.x!=0&&__yon_main_window_config.y!=0) gtk_window_move(__yon_window_config_target_window,__yon_main_window_config.x,__yon_main_window_config.y); - - - pthread_t tid; - pthread_create(&tid,NULL,(void *)_yon_maximize,NULL); - return 1; - } - - void yon_window_config_apply(){ - dictionary *dict=NULL; - gtk_window_move(__yon_window_config_target_window,__yon_main_window_config.x,__yon_main_window_config.y); - gtk_window_resize(__yon_window_config_target_window,__yon_main_window_config.width,__yon_main_window_config.height); - } - - config_str yon_window_config_get_section(char *section, gsize *size){ - config_str key = g_key_file_get_keys(__yon_window_config_file,section,size,NULL); - return key; - } - - /**yon_window_config_add_listener(GtkWidget *widget, char *param_name, char *widget_property, enum YON_TYPE val_type) - * [EN] - * - * [RU] - * Добавляет параметр виджета [widget] по названию [widget_property] для отслеживания и сохраняет его в конфиг под ключом [param_name]. - */ - void yon_window_config_add_listener(GtkWidget *widget, char *param_name, char *widget_property, enum YON_TYPE val_type){ - __yon_listener_parameter *param = NULL; - param = yon_remalloc(param,sizeof(__yon_listener_parameter)); - param->parameter_name = yon_char_new(param_name); - param->track_widget = widget; - param->property_name = yon_char_new(widget_property); - param->containing_type = val_type; - yon_dictionary_add_or_create_if_exists_with_data(__yon_main_window_config.custom_listeners,param->parameter_name,param); - } - - void yon_window_config_add_custom_parameter(char *param_name, char *section, void *tracked_value, enum YON_TYPE val_type){ - __yon_custom_parameter *param = NULL; - param = yon_remalloc(param,sizeof(__yon_custom_parameter)); - param->parameter_name = yon_char_new(param_name); - param->section=section; - param->property = tracked_value; - param->containing_type = val_type; - yon_dictionary_add_or_create_if_exists_with_data(__yon_main_window_config.custom_parameters,param->parameter_name,param); - } - - void yon_window_config_erase_custom_parameter(char *param_name, char *section){ - __yon_custom_parameter *param = NULL; - param = yon_remalloc(param,sizeof(__yon_custom_parameter)); - param->parameter_name=param_name; - param->section=section; - yon_dictionary_add_or_create_if_exists_with_data(__yon_main_window_config.deleted_parameters,param->parameter_name,param); - } - - int yon_window_config_get_parameter(char *section, char *config_parameter, void *return_value, enum YON_TYPE type){ - GError *err=NULL; - switch (type){ - case YON_TYPE_BOOLEAN: - *((int*)return_value) = g_key_file_get_boolean(__yon_window_config_file,section,config_parameter,&err); - if (err) return 0; else return 1; - break; - case YON_TYPE_INT: - *((int*)return_value) = g_key_file_get_integer(__yon_window_config_file,section,config_parameter,&err); - if (err) return 0; else return 1; - break; - case YON_TYPE_DOUBLE: - *((int*)return_value) = g_key_file_get_double(__yon_window_config_file,section,config_parameter,&err); - if (err) return 0; else return 1; - break; - case YON_TYPE_STRING: - *((char**)return_value) = g_key_file_get_string(__yon_window_config_file,section,config_parameter,&err); - if (err) return 0; else return 1; - break; - case YON_TYPE_STRING_LIST: - gsize size=0; - *((char***)return_value) = g_key_file_get_string_list(__yon_window_config_file,section,config_parameter,&size,&err); - *((char***)return_value)=yon_remalloc(return_value,size+1); - *((char***)return_value)[size]=NULL; - if (err) return 0; else return 1; - break; - } - } - -GtkWidget *yon_ubl_menu_item_about_new(char *buttonname){ - GtkWidget *menu_item = gtk_menu_item_new(); - gtk_style_context_add_class(gtk_widget_get_style_context(menu_item),"menuitembottom"); - GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0); - GtkWidget *label = gtk_label_new(buttonname); - GtkWidget *image = gtk_image_new_from_icon_name("dialog-information-symbolic",GTK_ICON_SIZE_BUTTON); - gtk_label_set_xalign(GTK_LABEL(label),0.0); - gtk_box_pack_start(GTK_BOX(box),image,0,0,5); - gtk_box_pack_start(GTK_BOX(box),label,0,0,5); - gtk_container_add(GTK_CONTAINER(menu_item),box); - gtk_widget_show_all(menu_item); - return menu_item; -} - -GtkWidget *yon_ubl_menu_item_documentation_new(char *buttonname){ - GtkWidget *menu_item = gtk_menu_item_new(); - gtk_style_context_add_class(gtk_widget_get_style_context(menu_item),"menuitemtop"); - GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0); - GtkWidget *label = gtk_label_new(buttonname); - GtkWidget *image = gtk_image_new_from_icon_name("dialog-question-symbolic",GTK_ICON_SIZE_BUTTON); - gtk_label_set_xalign(GTK_LABEL(label),0.0); - gtk_box_pack_start(GTK_BOX(box),image,0,0,5); - gtk_box_pack_start(GTK_BOX(box),label,0,0,5); - gtk_container_add(GTK_CONTAINER(menu_item),box); - gtk_widget_show_all(menu_item); - return menu_item; -} - - -// other Gtk functions - -/**yon_gtk_combo_box_text_fill(GtkWidget *combo, config_str parameters,int size) - * [EN] - * - * [RU] - * Добавляет в Комбобокс [combo] все строки из массива строк [parameters] размера [size] -*/ -int yon_gtk_combo_box_text_fill(GtkWidget *combo, config_str parameters,int size){ - if (combo&¶meters){ - for (int i=0;i=0 ? 1 : 0); -} - -void yon_gtk_widget_set_sensitive_from_toggle_combo_box_inversed(GtkComboBox *toggle, GtkWidget *target){ - gtk_widget_set_sensitive(target,!gtk_combo_box_get_active(toggle)>=0 ? 0 : 1); -} - -void _yon_ubl_header_setup(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image, char *image_path) -{ - gtk_overlay_add_overlay(GTK_OVERLAY(Overlay), Head); - gtk_image_set_from_file(GTK_IMAGE(Image), image_path); -} - -void _yon_ubl_header_setup_resource(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image, char *image_path) -{ - gtk_overlay_add_overlay(GTK_OVERLAY(Overlay), Head); - gtk_image_set_from_resource(GTK_IMAGE(Image), image_path); -} - -int yon_ubl_status_box_setup(GtkWidget *icon, GtkWidget *box, GtkWidget *label) -{ - if(icon&&box&&label){ - render.icon=icon; - render.box=box; - render.label=label; - return 1; - } else return 0; -} - -void _yon_ubl_status_box_render(char *text, BACKGROUND_IMAGE_TYPE type) -{ - render_data data = render; - GtkIconTheme *ictheme = gtk_icon_theme_get_default(); - GError *err = NULL; - if (err) - { - printf("%s\n", err->message); - g_error_free(err); - } - if (type == BACKGROUND_IMAGE_SUCCESS_TYPE||! type) - { - gtk_style_context_remove_class(gtk_widget_get_style_context(data.box), "boxInfoMessError"); - gtk_style_context_add_class(gtk_widget_get_style_context(data.box), "boxInfoMessOK"); - gtk_image_set_from_pixbuf(GTK_IMAGE(data.icon), gtk_icon_theme_load_icon_for_scale(ictheme, "com.ublinux.ubl-settings-video.checked", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, &err)); - } - else if (type == BACKGROUND_IMAGE_FAIL_TYPE) - { - gtk_style_context_remove_class(gtk_widget_get_style_context(data.box), "boxInfoMessOK"); - gtk_style_context_add_class(gtk_widget_get_style_context(data.box), "boxInfoMessError"); - gtk_image_set_from_pixbuf(GTK_IMAGE(data.icon), gtk_icon_theme_load_icon_for_scale(ictheme, "com.ublinux.ubl-settings-video.warning", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, &err)); - } - if (text) - gtk_label_set_text(GTK_LABEL(data.label), text); -} - -void yon_ubl_status_box_render(char *text, BACKGROUND_IMAGE_TYPE type){ - _yon_ubl_status_box_render(text,type); -} - -/**yon_ubl_setup_sockets(GtkWidget *main_window, GtkWidget *left_window, GtkWidget *right_window, int socket_main_id, int socket_left_id, int socket_right_id) - * [EN] - * Set up plugs for using with GtkSockets insine ubl-settings-manager. - * [main_window] is container widget, which holds main application functionality. - * [left_window] is container widget, which holds widgets, have to be shown at left part of ubl-settings-manager header. - * [right_window] is container widget, which holds widgets, have to be shown at right part of ubl-settings-manager header. - * [socket_main_id] is id of socket for [main_window]. - * [socket_left_id] is id of socket for [left_window]. - * [socket_right_id] is id of socket for [right_window]. - * [RU] - * Настраивает плаги для работы с сокетами в утилите ubl-settings-manager. - * [main_window] - контейнер основного интерфейса приложения. - * [left_window] - контейнер для виджетов которые должны отображаться в левой части шапки ubl-settings-manager. - * [right_window] - контейнер для виджетов которые должны отображаться в правой части шапки ubl-settings-manager. - * [socket_main_id] - id сокета для [main_window]. - * [socket_left_id] - id сокета для [left_window]. - * [socket_right_id] - id сокета для [right_window]. -*/ -void yon_ubl_setup_sockets(GtkWidget *main_window, GtkWidget *left_window, GtkWidget *right_window, int socket_main_id, int socket_left_id, int socket_right_id){ - if (main_window&&socket_main_id>-1){ - gtk_widget_hide(gtk_widget_get_toplevel(main_window)); - GtkWidget *plug_main=gtk_plug_new(socket_main_id); - GtkWidget *plug_left=NULL; - GtkWidget *plug_right=NULL; - GtkWidget *box=NULL; - g_signal_connect(G_OBJECT(plug_main), "destroy", G_CALLBACK(gtk_main_quit),NULL); - if (socket_left_id>-1&&left_window){ - plug_left=gtk_plug_new(socket_left_id); - g_object_ref(left_window); - gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(left_window)),left_window); - gtk_container_add(GTK_CONTAINER(plug_left),left_window); - gtk_style_context_add_class(gtk_widget_get_style_context(plug_left),"primary-toolbar"); - gtk_style_context_add_class(gtk_widget_get_style_context(left_window),"button"); - gtk_style_context_add_class(gtk_widget_get_style_context(left_window),"opacited"); - gtk_style_context_add_class(gtk_widget_get_style_context(left_window),"color"); - gtk_style_context_add_class(gtk_widget_get_style_context(plug_left),"noborder"); - gtk_widget_show(plug_left); - } - else if (left_window){ - if (box==NULL){ - box=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); - gtk_box_pack_start(GTK_BOX(main_window),box,0,0,5); - gtk_box_reorder_child(GTK_BOX(main_window),box,0); - gtk_widget_show(box); - } - gtk_style_context_add_class(gtk_widget_get_style_context(left_window),"inherited"); - gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(left_window)),left_window); - gtk_box_pack_end(GTK_BOX(box),left_window,0,0,5); - } - if (socket_right_id>-1&&right_window){ - plug_right=gtk_plug_new(socket_right_id); - g_object_ref(right_window); - gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(right_window)),right_window); - gtk_container_add(GTK_CONTAINER(plug_right),right_window); - gtk_style_context_add_class(gtk_widget_get_style_context(plug_right),"primary-toolbar"); - gtk_style_context_add_class(gtk_widget_get_style_context(right_window),"button"); - gtk_style_context_add_class(gtk_widget_get_style_context(right_window),"opacited"); - gtk_style_context_add_class(gtk_widget_get_style_context(right_window),"color"); - gtk_style_context_add_class(gtk_widget_get_style_context(plug_right),"noborder"); - gtk_widget_show(plug_right); - } - else if (right_window){ - if (box==NULL){ - box=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); - gtk_box_pack_start(GTK_BOX(main_window),box,0,0,5); - gtk_box_reorder_child(GTK_BOX(main_window),box,0); - gtk_widget_show(box); - } - gtk_style_context_add_class(gtk_widget_get_style_context(right_window),"inherited"); - gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(right_window)),right_window); - gtk_box_pack_start(GTK_BOX(box),right_window,0,0,5); - } - g_object_ref(main_window); - gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(main_window)),main_window); - gtk_container_add(GTK_CONTAINER(plug_main),main_window); - gtk_widget_show(plug_main); - } -} - -#ifdef WEBKIT_FOUND - -/**yon_ubl_browser_window_open(char *link, char *browser_window_name) - * [EN] - * Launches integrated browser window, named [browser_window_name] at header with [link]. - * [RU] - * Открывает встроенный браузер с именем [browser_window_name] и показываемой страницей по ссылке [link] -*/ -void yon_ubl_browser_window_open(char *link, char *browser_window_name){ - GtkWidget *browser=gtk_window_new(GTK_WINDOW_TOPLEVEL); - GtkWidget *web_place=gtk_box_new(GTK_ORIENTATION_VERTICAL,0); - GtkWidget *header=gtk_header_bar_new(); - GtkWidget *header_label=gtk_label_new(browser_window_name); - GtkWidget *WebView=webkit_web_view_new(); - gtk_container_add(GTK_CONTAINER(browser),web_place); - gtk_window_set_titlebar(GTK_WINDOW(browser),header); - gtk_window_set_title(GTK_WINDOW(browser),browser_window_name); - gtk_widget_set_size_request(browser,800,600); - gtk_header_bar_set_custom_title(GTK_HEADER_BAR(header),header_label); - gtk_header_bar_set_show_close_button(GTK_HEADER_BAR(header),1); - webkit_web_view_load_uri(WEBKIT_WEB_VIEW(WebView),link); - gtk_box_pack_start(GTK_BOX(web_place),WebView,1,1,0); - gtk_widget_show_all(browser); -} -#else - -/**yon_ubl_browser_window_open(char *link, char *browser_window_name) - * [EN] - * Launches browser with [link]. - * [browser_window_name] is't used. It's needed for compatibility with webkit version of that function. - * [RU] - * Открывает браузер со страницей по ссылке [link] - * [browser_window_name] не используется. Нужна для совместимости с webkit версией этой функции. -*/ -void yon_ubl_browser_window_open(char *link, char *browser_window_name){ - char *user=getenv("SUDO_USER"); - if (!user) - user=getlogin(); - char *command=yon_char_unite("sudo -u ",user," xdg-open ", link,NULL); - yon_launch_app(command); -} -#endif - -#endif \ No newline at end of file diff --git a/source/ubl-utils.h b/source/ubl-utils.h deleted file mode 100644 index dcdd903..0000000 --- a/source/ubl-utils.h +++ /dev/null @@ -1,368 +0,0 @@ -#ifndef UBL_UTILS -#define UBL_UTILS -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "ubl-cmake.h" -#ifdef WEBKIT_FOUND - #include -#endif -#define DesktopPath "/usr/share/applications/" -#define try bool __HadError=false; -#define catch(x) ExitJmp:if(__HadError) -#define throw(x) {__HadError=true;goto ExitJmp;} -static char** array_size_pow; -#define for_dictionaries(obj, obj1) for (obj = obj1->first; obj != NULL; obj = obj->next) - -#define new(type) malloc(sizeof(type)) -#define new_arr(type,size) malloc(sizeof(type)*size) - -#define get_home_dir_command yon_char_unite("getent passwd \"",yon_ubl_root_user_get(),"\" | cut -d: -f6",NULL) - -#define get_processes_command "systemd-cgls --no-pager |grep -oE \"[-0-9A-Za-z.:]{1,}.service\"" -#define get_slices_command "systemd-cgls --no-pager |grep -oE \"[-0-9A-Za-z.:]{1,}.slice\"" - -typedef enum -{ - #ifdef __GTK_H__ - DICTIONARY_GTK_WIDGETS_TYPE, - #endif - DICTIONARY_OTHER_TYPE=0, - DICTIONARY_CHAR_TYPE, - DICTIONARY_INT_TYPE, - DICTIONARY_BOOL_TYPE, - -} DICT_TYPE; - -typedef struct dictionary -{ - char *key; - void *data; - struct dictionary *next; - struct dictionary *prev; - struct dictionary *first; - DICT_TYPE data_type; - int flag1; -} dictionary; - -typedef struct apps -{ - char *Name; - int Type; - char *Categories; - char *Exec; - char *Icon; - int Pluggable; - int DualPluggable; -} apps; - -typedef char** config_str; - -static dictionary *__yon__config__strings = NULL; -#define check_config if(__yon__config__strings&&__yon__config__strings->data_type==DICTIONARY_CHAR_TYPE) - -#define config(key) yon_config_get_by_key(key) - -#define for_config dictionary temp = NULL; for_dictionary(temp,__yon__config__strings) - -#define yon_remalloc(pointer, size) (!pointer) ? malloc(size) : realloc(pointer, size) -// dictionary functions - -/**yon_dictionary_get_data(dictionary, type) - * [EN] - * Gets data from dictionary. - * [dictionary] is dictionary, from which data should be extracted; - * [type] is type of data, [dictionary] contains. - * [RU] - * Возвращает данные из словаря. - * [dictionary] - словарь из которого достаются данные. - * [type] - тип данных, хранящихся в словаре [dictionary]. -*/ -#define yon_dictionary_get_data(dictionary, type) ((type)dictionary->data) - -/**yon_dictionary_add_or_create_if_exists_with_data(dict,key,data) - * [EN] - * - * [RU] - * Добавляет элемент словаря в конец словаря [dict] c ключом [key] и данными [data]. - * Если словарь не существует, создаёт его -*/ -#define yon_dictionary_add_or_create_if_exists_with_data(dict,key,data) {if (!dict) dict=yon_dictionary_new_with_data(key,data); \ - else dict=yon_dictionary_append_with_data(dict,key,data);} - -dictionary *yon_dictionary_new(); - -dictionary *yon_dictionary_append(dictionary *targetdict); - -dictionary *yon_dictionary_get_last(dictionary *dict); - -dictionary *yon_dictionary_swap(dictionary *dict, int aim); - -void yon_dictionary_make_first(dictionary *dict); - -void yon_dictionary_make_nth(dictionary *dict, int nth); - -dictionary *yon_dictionary_new_with_data(char *key, void *data); - -dictionary *yon_dictionary_append_with_data(dictionary *dict, char *key, void *data); - -dictionary *yon_dictionary_connect(dictionary *old, dictionary *toconnect); - -dictionary *yon_dictionary_get(dictionary **dict, char *key); - -dictionary *yon_dictionary_rip(dictionary *dict); - -dictionary *yon_dictionary_get_nth(dictionary *dict, int place); - -void *yon_dictionary_free_all(dictionary *dictionary,void (data_manipulation)(void*)); - -// char functions - -int yon_char_find_last(char *source, char find); - -char *yon_char_append(char *source, char *append); - -char *yon_char_new(char *chr); - -char *yon_char_unite(char *source, ...); - -char *yon_cut(char *source, int size, int startpos); - -char *yon_char_divide(char *source, int dividepos); - -char *yon_char_divide_search(char *source, char *dividepos, int delete_divider); - -char *yon_char_from_int(int int_to_convert); -char *yon_char_from_long(long int_to_convert); - -char *yon_char_replace(char *source, char *find, char*replace); - -char **yon_char_parse(char *parameters, int *size, char *divider); - -char **yon_char_parsed_rip(char **char_string, int *size, int item_to_delete); - -int yon_char_parsed_check_exist(char **parameters, int size, char *param); - -int yon_char_find_count(char *source, char *find); - -int yon_char_parsed_includes_char_parsed (config_str source, config_str to_check, int source_size, int check_size); - -config_str yon_char_parsed_new (int *size, ...); - -void yon_char_parsed_copy(config_str *source, config_str *to_copy); - -config_str yon_char_parsed_append(config_str parsed, int *size, char *string); - -int yon_char_parsed_remove_newline_symbols(config_str parsed, int *size); - -int yon_ubl_check_root(); - -char *yon_ubl_root_user_get(); - -char *yon_ubl_user_get_home_directory(); - -config_str yon_ubl_get_all_users(int *user_size); -config_str yon_ubl_get_all_processes(int *processes_size); -config_str yon_ubl_get_all_slices(int *slices_size); - -// parsing functions - -config_str philos_list_user(int* size); - -apps *yon_apps_scan_and_parse_desktops(int *sizef); - -void yon_apps_sort(apps *applist, int size); - -apps *yon_apps_get_by_name(apps *applist, char *name, int size); - -config_str yon_config_load(char *command, int *str_len); - -int yon_config_save_registered(char *path, char *section); - -char *yon_config_get_parameter(config_str parameters, int size, char *param); - -int yon_config_load_register(char *command); - -int yon_config_remove_by_key(char *key); - -int yon_config_remove_by_data(void *data); - -int yon_config_remove_element(char *key, char *deleted); - -void *yon_config_get_by_key(char *key); - -char *yon_config_get_key_by_data(char *data); - -int yon_config_set(char *key, void *data); - -int yon_config_clean(); - -void yon_config_register(char *key, void *data); - -config_str yon_config_get_all(); - -// terminal-using functions - -int yon_launch_app_with_arguments(char *name, char *args); - -void yon_launch(char *command); - -// Gtk functions - -#ifdef __GTK_H__ -#ifdef VTE_TERMINAL -void yon_terminal_integrated_launch(GtkWidget *place_to_show, char* command, void *endwork_function, void* endwork_function_argument); - -void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *endwork_function, void* endwork_function_argument); - -#endif - -enum YON_TYPE{ - YON_TYPE_STRING, - YON_TYPE_STRING_LIST, - YON_TYPE_INT, - YON_TYPE_DOUBLE, - YON_TYPE_BOOLEAN, - YON_TYPE_OTHER -}; - -GtkWidget *yon_ubl_menu_item_about_new(char *buttonname); -GtkWidget *yon_ubl_menu_item_documentation_new(char *buttonname); - -/**yon_gtk_builder_get_widget(builder, widget_name) - * [EN] - * Returns GtkWidget from GtkBuilder *[builder]. - * [builder] is GtkBuilder*; - * [widget_name] is id of widget; -*/ -#define yon_gtk_builder_get_widget(builder, widget_name) GTK_WIDGET(gtk_builder_get_object(builder, widget_name)) - -typedef struct -{ - GtkWidget *Icon; - GtkWidget *Label; - GtkWidget *IconView; - GtkListStore *List; -} expander_icon_view; - -void yon_window_config_setup(GtkWindow *window); - -int yon_window_config_load(char *path); - -config_str yon_window_config_get_section(char *section, gsize *size); - -void yon_window_config_add_listener(GtkWidget *widget, char *param_name, char *widget_property, enum YON_TYPE val_type); - -void yon_window_config_add_custom_parameter(char *param_name, char *section, void *tracked_value, enum YON_TYPE val_type); - -void yon_window_config_erase_custom_parameter(char *param_name, char *section); - -int yon_window_config_get_parameter(char *section, char *config_parameter, void *return_value, enum YON_TYPE type); - -int yon_gtk_combo_box_fill(GtkWidget *combo, char **parameters,int size); - -int yon_gtk_combo_box_text_find(GtkWidget *combo_box, char *text_to_find); - -void yon_gtk_column_minimal_fixed_size_set(GtkTreeViewColumn *column); - -int yon_gtk_icon_view_hide_empty(dictionary *icon_view_segment); - -int yon_dictionary_gtk_pack_start_multiple_widgets(GtkBox *destination, gboolean expand, gboolean fill, int padding, ...); - -int yon_dictionary_gtk_pack_end_multiple_widgets(GtkBox *destination, gboolean expand, gboolean fill, int padding, ...); - -void yon_gtk_widget_set_sensitive_from_toggle_button(GtkToggleButton *toggle, GtkWidget *target); -void yon_gtk_widget_set_sensitive_from_toggle_button_inversed(GtkToggleButton *toggle, GtkWidget *target); -void yon_gtk_widget_set_sensitive_from_combo_box(GtkComboBox *toggle, GtkWidget *target); -void yon_gtk_widget_set_sensitive_from_combo_box_inversed(GtkComboBox *toggle, GtkWidget *target); - -typedef enum -{ - BACKGROUND_IMAGE_SUCCESS_TYPE, - BACKGROUND_IMAGE_FAIL_TYPE -} BACKGROUND_IMAGE_TYPE; - -typedef struct { - BACKGROUND_IMAGE_TYPE type; - GtkWidget *icon; - GtkWidget *box; - GtkWidget *label; - char* text_to_render; -} render_data; - - -/**yon_ubl_status_box_setup(render,icon,box,label) - * [EN] - * Sets up [render] structure of type render_data. - * [icon] is GtkImage widget of status box for showing status icons; - * [box] is GtkBox widget of status box for showing status color; - * [label] is GtkLabel widget of status box for showing status text; - * [RU] - * Настраивает структуру [render] типа render_data. - * [icon] - виджет типа GtkIcon в котором будут отображаться статусные иконки; - * [box] - виджет типа GtkBox в котором будет отображаться цвет статуса; - * [label] - виджет типа GtkLabel в котором будет отображаться текст статусного сообщения; -*/ -int yon_ubl_status_box_setup(GtkWidget *icon, GtkWidget *box, GtkWidget *label); - -/**yon_ubl_status_box_render(render,text,type) - * [EN] - * Renders message in status box; - * [render] is render_data structure of status box; - * [text] is text to be shown in status box; - * [type] if type of message. Can be BACKGROUND_IMAGE_FAIL_TYPE or BACKGROUND_IMAGE_SUCCESS_TYPE - * [RU] - * Отображает сообщение в статусном окне. - * [render] - структура типа render_data для нужного статусного окна; - * [text] - текст, отображаемый в статусном окне; - * [type] - тип сообщения. Может быть: - * BACKGROUND_IMAGE_FAIL_TYPE (красный фон,иконка - восклицательный знак) - * или - * BACKGROUND_IMAGE_SUCCESS_TYPE (Жёлтный фон, иконка - галка) -*/ -void yon_ubl_status_box_render(char *text, BACKGROUND_IMAGE_TYPE type); - -/**yon_ubl_header_setup(overlay, head, image, imag_path) - * [EN] - * Sets up header of app. - * [overlay] is overlay for app header; - * [head] is box of header, which connects to [overlay] - * [image] is header background image; - * [imag_path] is path of image, shown in [image] - * [RU] - * Настраивает заголовок приложения. - * [overlay] - оверлей заголовка приложения; - * [head] - шапка заголовка, присоединяемая к [overlay] - * [image] - виджет картинки для заднего фона; - * [imag_path] - путь до картинки, загружаемой в [image] -*/ -#define yon_ubl_header_setup(overlay, head, image, imag_path) _yon_ubl_header_setup(GTK_WIDGET(overlay), GTK_WIDGET(head), GTK_WIDGET(image), (char *)imag_path) -#define yon_ubl_header_setup_resource(overlay, head, image, imag_path) _yon_ubl_header_setup_resource(GTK_WIDGET(overlay), GTK_WIDGET(head), GTK_WIDGET(image), (char *)imag_path) -#endif - -void _yon_ubl_header_setup(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image, char *image_path); - -void _yon_ubl_header_setup_resource(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image, char *image_path); - -void yon_ubl_setup_sockets(GtkWidget *main_window, GtkWidget *left_window, GtkWidget *right_window, int socket_main_id, int socket_left_id, int socket_right_id); -#ifdef WEBKIT_FOUND - -void yon_ubl_browser_window_open(char *link, char *browser_window_name); -#else -void yon_ubl_browser_window_open(char *link, char *browser_window_name); -#endif -#endif \ No newline at end of file diff --git a/ubl-settings-resourcequota.glade b/ubl-settings-resourcequota.glade index 760b607..f3c35fe 100644 --- a/ubl-settings-resourcequota.glade +++ b/ubl-settings-resourcequota.glade @@ -4,178 +4,6 @@ - - False - False - True - center - com.ublinux.ubl-settings-resourcequota - dialog - True - ubl-settings-resourcequota - 1.0 - Copyright © 2022 - 2023, UBSoft LLC - CPU and RAM quotas - https://wiki.ublinux.com/ - Project Home Page - Это приложение распространяется без каких-либо гарантий. -Подробнее в <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.html">GNU General Public License, версии 2 или позднее</a>. - UBGroup - UBGroup - com.ublinux.ubl-settings-resourcequota - True - gpl-2-0 - - - True - False - vertical - 2 - - - False - end - - - False - False - 1 - - - - - - - - - - True - False - True - - - True - False - 5 - 5 - 5 - 5 - 2 - CPU and RAM quotas - - - - - - - - - - True - False - center - - - 90 - True - False - 5 - 5 - 5 - 5 - 6 - 6 - 64 - com.ublinux.ubl-settings-resourcequota - - - False - True - 0 - - - - - True - False - - - True - False - - - True - False - vertical - - - 255 - True - False - end - CPU and RAM quotas - 0 - - - - - - - - True - True - 0 - - - - - 255 - True - False - start - 5 - 5 - Configuring CPU and RAM quota settings for groups and users of the system - True - 0 - - - - - - - - True - True - 1 - - - - - False - True - 0 - - - - - True - True - 0 - - - - - True - True - 1 - - - 100 1 @@ -253,210 +81,6 @@ False emblem-synchronizing-symbolic - - True - False - process-stop-symbolic - - - True - False - emblem-ok-symbolic - - - 450 - False - False - 450 - com.ublinux.ubl-settings-resourcequota - - - True - False - 5 - 5 - 5 - 5 - 5 - 5 - vertical - 10 - - - True - False - - - True - False - start - 20 - 20 - dialog-question-symbolic - 6 - - - False - True - 0 - - - - - True - False - vertical - - - True - False - start - 10 - 5 - Would you like to read documentation in the Web? - True - 0 - - - - - - - False - True - 0 - - - - - True - False - start - start - 10 - 10 - You will be redirected to documentation website where documentation is -translated and supported by community. - True - 0 - - - - False - True - 1 - - - - - Always redirect to online documentation - True - True - False - end - True - - - - False - True - end - 2 - - - - - - True - True - 1 - - - - - - True - True - 0 - - - - - True - False - 30 - True - - - Cancel - True - True - True - image8 - - - - True - True - 0 - - - - - Read Online - True - True - True - image9 - - - - True - True - 1 - - - - - False - True - 1 - - - - - - - True - False - True - - - True - False - CPU and RAM quotas - - - - - - - - @@ -479,690 +103,287 @@ translated and supported by community. - - True - False - False - - - True - False - Load global configuration - - - - - - True - False - Load local configuration - - - - - - True - False - False - False - - + True False - False - - - True - False - Save configuration - - - - - - True - False - Save to global configuration - - - - - - True - False - Save to local configuration - - - - - - 800 - 600 - False - com.ublinux.ubl-settings-resourcequota - CPU and RAM quotas + vertical - + True False + True + True vertical - + True False + True + True vertical - + True - False - - - True - False - 5 - 5 - 5 - 5 - 5 - 5 - 25 - - - False - True - 0 - - + True - + True False - start - 5 - 5 - 5 - 5 - 6 - 6 - True - 0 - - - - - - - False - True - 1 - - - - - False - True - 0 - - - - - True - False - vertical - - - 81 - True - False - - - True - False - start - - - -1 - - - - - False - True - 0 - - - - - False - True - 1 - - - - - True - False - 5 - 5 - 5 - 5 - 5 - True - True - vertical - - - True - False - True - True vertical - + True True - + True - False - vertical + True + adjustment5 + liststore + 0 + + + - - True - True + + True + fixed + 15 + Quota type + True - - True - True - adjustment5 - liststore - 0 - - - - - - True - fixed - 15 - Quota type - True - - - word - - - - - 0 - - - - - - - True - fixed - 15 - Quota + + word + - + + + 0 + + + + + + + True + fixed + 15 + Quota target - True - - - word - - - - - 1 - - - - - - - True - fixed - 15 - Soft RAM limit, + True + + + word + - + + + 1 + + + + + + + True + fixed + 15 + Soft RAM limit, (volume) - True - - - word - - - - - 2 - - - - - - - True - fixed - 15 - Hard RAM limit, + True + + + word + - + + + 2 + + + + + + + True + fixed + 15 + Hard RAM limit, (volume) - True - - - word - - - - - 3 - - - - - - - True - fixed - 15 - Swap file + True + + + word + - + + + 3 + + + + + + + True + fixed + 15 + Swap file limit (volume) - True - - - word - - - - - 4 - - - - - - - True - fixed - 15 - CPU limit -(%) - True - - - word - - - - - 5 - - - - - - - True - fixed - 15 - I/O -limit -(read) - True - - - word - 100 - - - - - 6 - - - - - - - autosize - 15 - I/O -limit -(write) - True - - - word - 100 - - - - - 7 - - - - + True + + + word + - + + 4 + - - True - True - 0 - - - True - False + + True + fixed + 15 + CPU limit +(%) + True - - True - True - True - 5 - 5 - 5 - 5 - 5 - 5 - - - True - False - - - True - False - com.ublinux.ubl-settings-resourcequota.funnel-symbolic - - - False - True - 0 - - - - - True - False - 5 - 5 - 5 - 5 - Filters - - - False - True - 1 - - - - + + word + - - - False - True - 0 - + + 5 + + + + + + True + fixed + 15 + I/O +limit +(read) + True - - True - True - True - 5 - 5 - 5 - 5 - 5 - 5 - - - True - False - - - True - False - value-increase-symbolic - - - False - True - 0 - - - - - True - False - 5 - 5 - 5 - 5 - Add - - - False - True - 1 - - - - + + word + 100 + - - - False - True - end - 2 - + + 6 + + + + + + autosize + 15 + I/O +limit +(write) + True - - True - True - True - 5 - 5 - 5 - 5 - 5 - 5 - - - True - False - - - True - False - document-edit-symbolic - - - False - True - 0 - - - - - True - False - 5 - 5 - 5 - 5 - Edit - - - False - True - 1 - - - - + + word + 100 + - - - False - True - end - 3 - + + 7 + + + + + + + + True + True + 0 + + + + + True + False + + + True + True + True + 5 + 5 + 5 + 5 + 5 + 5 + + + True + False - + True - True - True - 5 - 5 - 5 - 5 - 5 - 5 - - - True - False - - - True - False - user-trash-symbolic - - - False - True - 0 - - - - - True - False - 5 - 5 - 5 - 5 - Remove - - - False - True - 1 - - - - + False + com.ublinux.ubl-settings-resourcequota.funnel-symbolic False True - end - 4 + 0 - + True - True - True + False 5 5 5 5 - 5 - 5 - - - True - False - - - True - False - dialog-information-symbolic - - - False - True - 0 - - - - - True - False - 5 - 5 - 5 - 5 - Information - - - False - True - 1 - - - - + Filters False True - end - 5 + 1 - - False - True - 2 - - - - - True - False - Quotas list - - False + False + True + 0 - + True - False + True + True + 5 + 5 5 5 5 5 - vertical - 5 - + True False - 5 - - Update every + True - True - False - True + False + value-increase-symbolic False @@ -1170,83 +391,68 @@ limit 0 - - - True - False - True - 6 - 1 - adjustDisp - - - False - True - 2 - - True False - seconds - - - False - True - 3 - - - - - Update - True - True - True - image1 + 5 + 5 + 5 + 5 + Add False True - end - 4 + 1 - - False - True - 0 - + + + False + True + end + 2 + + + + + True + True + True + 5 + 5 + 5 + 5 + 5 + 5 True False - + True - False - True - natural - adjustment1 - natural - UTF-8 - True - False + False + document-edit-symbolic - True + False True 0 - + True False - vertical - adjustment1 + 5 + 5 + 5 + 5 + Edit False @@ -1255,50 +461,35 @@ limit - - True - True - 1 - - 1 - - - - - True - False - Dispatcher - - - 1 - False + False + True + end + 3 - + True - False + True + True + 5 + 5 5 5 5 5 - vertical - 5 - + True False - 5 - - All groups including empty + True - True - False - True + False + user-trash-symbolic False @@ -1307,12 +498,14 @@ limit - - Core streams + True - True - False - True + False + 5 + 5 + 5 + 5 + Remove False @@ -1320,57 +513,52 @@ limit 1 - - - Update - True - True - True - image2 - - - False - True - end - 2 - - - - False - True - 0 - + + + False + True + end + 4 + + + + + True + True + True + 5 + 5 + 5 + 5 + 5 + 5 True False - + True - False - True - natural - adjustment2 - natural - UTF-8 - 0 - True - False + False + dialog-information-symbolic - True + False True 0 - + True False - vertical - adjustment2 + 5 + 5 + 5 + 5 + Information False @@ -1379,251 +567,228 @@ limit - - True - True - 1 - - 2 + False + True + end + 5 - - - True - False - Processes + + + False + True + 2 + + + + + + + True + False + Quotas list + + + False + + + + + True + False + 5 + 5 + 5 + 5 + vertical + 5 + + + True + False + 5 + + + Update every + True + True + False + True - 2 - False + False + True + 0 - + True - False - 5 - 5 - 5 - 5 - vertical - 5 - - - True - False - 5 - - - True - False - View properties for - - - False - True - 0 - - - - - True - False - 0 - 0 - - User - Process - Slice - - - - True - True - 1 - - - - - True - False - - - True - True - 2 - - - - - Update - True - True - True - image3 - - - False - True - end - 3 - - - - - False - True - 0 - - - - - True - False - - - True - False - True - natural - adjustment3 - natural - UTF-8 - True - False - - - True - True - 0 - - - - - True - False - vertical - adjustment3 - - - False - True - 1 - - - - - True - True - 1 - - + False + True + 6 + 1 + adjustDisp - 3 + False + True + 2 - + True False - Information + seconds + False + True 3 - False - - + + + Update + True + True + True + image1 + + + False + True + end + 4 + - - + + + False + True + 0 + + + + + True + False + + + True + False + True + natural + adjustment1 + natural + UTF-8 + True + False + + + True + True + 0 + + + + + True + False + vertical + adjustment1 + + + False + True + 1 + True True - 0 + 1 - False - True - 0 + 1 + + + + + True + False + Dispatcher + + + 1 + False - - - False - True - 2 - - - - - True - True - 0 - - - - - - - True - False - True - - - True - False - 5 - 5 - 5 - 5 - 2 - CPU and RAM quotas - - - - - - - - True - False - 5 - 5 - 32 - com.ublinux.ubl-settings-resourcequota - - - - - True - False - - - True - True - False - True - menu3 - False True False + 5 + 5 + 5 + 5 + vertical + 5 - + True False - Save + 5 + + + All groups including empty + True + True + False + True + + + False + True + 0 + + + + + Core streams + True + True + False + True + + + False + True + 1 + + + + + Update + True + True + True + image2 + + + False + True + end + 2 + + False @@ -1632,76 +797,135 @@ limit - + True False - pan-down-symbolic + + + True + False + True + natural + adjustment2 + natural + UTF-8 + 0 + True + False + + + True + True + 0 + + + + + True + False + vertical + adjustment2 + + + False + True + 1 + + - False + True True 1 + + 2 + - - - False - True - 0 - - - - - True - True - True - False - True - True - menu2 - none - - + + + True + False + Processes + + + 2 + False + - - - - False - True - 1 - - - - - end - 1 - - - - - True - False - - - True - True - False - True - menu1 - False True False + 5 + 5 + 5 + 5 + vertical + 5 - + True False - Load + 5 + + + True + False + View properties for + + + False + True + 0 + + + + + True + False + 0 + 0 + + User + Process + Slice + + + + True + True + 1 + + + + + True + False + + + True + True + 2 + + + + + Update + True + True + True + image3 + + + False + True + end + 3 + + False @@ -1710,33 +934,153 @@ limit - + True False - pan-down-symbolic + + + True + False + True + natural + adjustment3 + natural + UTF-8 + True + False + + + True + True + 0 + + + + + True + False + vertical + adjustment3 + + + False + True + 1 + + - False + True True 1 + + 3 + + + + + True + False + Information + + + 3 + False + + + + + + + - False + True True 0 - 2 + False + True + 0 + + + False + True + 2 + + + + + True + False + False + + + True + False + Load global configuration + + + + + + True + False + Load local configuration + + + + + + True + False + False + False + + + True + False + False + + + True + False + Save configuration + + + + + + True + False + Save to global configuration + + + + + + True + False + Save to local configuration diff --git a/ubl-settings-resourcequota.pot b/ubl-settings-resourcequota.pot index 98a3ac3..e6c9622 100644 --- a/ubl-settings-resourcequota.pot +++ b/ubl-settings-resourcequota.pot @@ -284,7 +284,7 @@ msgid "Quota target" msgstr "" #: source/ubl-strings.h:67 -msgid "Soft RAM limit, n(volume)" +msgid "Soft RAM limit, (volume)" msgstr "" #: source/ubl-strings.h:68 diff --git a/ubl-settings-resourcequota_ru.po b/ubl-settings-resourcequota_ru.po index bfe1aa6..8c1aff1 100644 --- a/ubl-settings-resourcequota_ru.po +++ b/ubl-settings-resourcequota_ru.po @@ -115,7 +115,7 @@ msgstr "Сохранить" #: source/ubl-strings.h:14 msgid "Load local configuration" -msgstr "Загрузить локальную конфигуруцию" +msgstr "Загрузить локальную конфигурацию" #: source/ubl-strings.h:15 msgid "Load global configuration" @@ -309,7 +309,7 @@ msgstr "Объект квотирования" #: source/ubl-strings.h:67 #, fuzzy -msgid "Soft RAM limit, n(volume)" +msgid "Soft RAM limit, (volume)" msgstr "Мягкий лимит ОЗУ, (объём)" #: source/ubl-strings.h:68