From db6311f7ea2252bd7ab894af3218e1227949b7a8 Mon Sep 17 00:00:00 2001 From: Ivan Dmitrievich Yartsev Date: Thu, 27 Nov 2025 14:21:09 +0600 Subject: [PATCH] Configuration window rework --- libublsettingsui-gtk3-config-window.glade | 4 +- source/libublsettingsui-gtk3-config-window.c | 426 +++++++++---------- source/libublsettingsui-gtk3.h | 39 +- 3 files changed, 235 insertions(+), 234 deletions(-) diff --git a/libublsettingsui-gtk3-config-window.glade b/libublsettingsui-gtk3-config-window.glade index 1adaf1f..14a981b 100644 --- a/libublsettingsui-gtk3-config-window.glade +++ b/libublsettingsui-gtk3-config-window.glade @@ -1,11 +1,11 @@ - + 450 - 200 + 176 False com.ublinux.libublsettingsui-gtk3 dialog diff --git a/source/libublsettingsui-gtk3-config-window.c b/source/libublsettingsui-gtk3-config-window.c index 9127dd4..5c9fc3b 100644 --- a/source/libublsettingsui-gtk3-config-window.c +++ b/source/libublsettingsui-gtk3-config-window.c @@ -3,84 +3,134 @@ void on_confuguration_combo_box_changed(GtkComboBox *self, char *id); void __yon_on_boolean_parameter_toggled(GtkToggleButton *self ,char *id); -typedef struct { - char *id; - GtkWidget *Box; - GtkWidget *CheckButton; -} yon_configuration_boolean_parameter; - -typedef struct { - char *id; - GtkWidget *Box; - GtkWidget *Label; - GtkWidget *Entry; -} yon_configuration_entry_parameter; - -typedef struct { - char *id; +struct yon_configuration_combo_parameter{ GtkWidget *Box; GtkWidget *Label; GtkWidget *ComboBox; -} yon_configuration_combo_parameter; - -// typedef struct { -// char *id; -// GtkWidget *Label; -// GtkWidget *GtkTreeView; -// GtkListStore *list; -// } yon_configuration_list_parameter; - - - -typedef struct yon_configuration_parameters { - dictionary_fields(yon_configuration_parameters); - char *label; - char *value; - GCallback func; - enum CONFIGURATION_PARAMETER_TYPE type; -} yon_configuration_parameters; - -yon_configuration_entry_parameter *yon_configuration_entry_parameter_new(char *id, char *label_text){ - yon_configuration_entry_parameter *parameter = malloc(sizeof(yon_configuration_entry_parameter)); - parameter->Box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); - parameter->Label = gtk_label_new(label_text); - parameter->Entry = gtk_entry_new(); - parameter->id = yon_char_new(id); - gtk_box_pack_start(GTK_BOX(parameter->Box),parameter->Label,1,1,0); - gtk_box_pack_start(GTK_BOX(parameter->Box),parameter->Entry,1,1,0); - gtk_widget_show_all(parameter->Box); - return parameter; + char *id; +}; +// yon_configuration_entry_parameter *yon_configuration_entry_parameter_new(char *id, char *label_text){ +// yon_configuration_entry_parameter *parameter = malloc(sizeof(yon_configuration_entry_parameter)); +// parameter->Box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); +// parameter->Label = gtk_label_new(label_text); +// parameter->Entry = gtk_entry_new(); +// parameter->id = yon_char_new(id); +// gtk_box_pack_start(GTK_BOX(parameter->Box),parameter->Label,1,1,0); +// gtk_box_pack_start(GTK_BOX(parameter->Box),parameter->Entry,1,1,0); +// gtk_widget_show_all(parameter->Box); +// return parameter; +// } + +// yon_configuration_parameters *__yon_settings_parameters = NULL; + +// GtkWidget *yon_configuration_combo_box_parameter_new(char *id){ +// struct yon_configuration_combo_parameter *parameter = malloc(sizeof(struct yon_configuration_combo_parameter)); +// parameter->Box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); +// parameter->Label = gtk_label_new(NULL); +// parameter->ComboBox = gtk_combo_box_text_new(); +// parameter->id = yon_char_new(id); +// g_object_set_data(G_OBJECT(parameter->Box),"data_struct",parameter); +// gtk_box_pack_start(GTK_BOX(parameter->Box),parameter->Label,0,0,0); +// gtk_box_pack_start(GTK_BOX(parameter->Box),parameter->ComboBox,0,0,0); +// // for (int i=0;parameters[i]&¶meters[i+1];i+=2){ +// // gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(parameter->ComboBox),parameters[i],parameters[i+1]); +// // } +// // char *value = NULL; +// // yon_window_config_get_parameter("settings",id,&value,YON_TYPE_STRING); +// // if (!yon_char_is_empty(value)){ +// // gtk_combo_box_set_active_id(GTK_COMBO_BOX(parameter->ComboBox),value); +// // } else { +// // gtk_combo_box_set_active(GTK_COMBO_BOX(parameter->ComboBox),0); +// // } +// // g_signal_connect(G_OBJECT(parameter->ComboBox),"changed",G_CALLBACK(on_confuguration_combo_box_changed),id); +// // yon_configuration_parameters *target = (yon_configuration_parameters*)yon_dictionary_get((dictionary**)&__yon_settings_parameters,id); +// // if (target){ +// // if (target->func){ +// // g_signal_connect(G_OBJECT(parameter->ComboBox),"changed",G_CALLBACK(target->func),target->value); +// // } +// // } +// // gtk_widget_show_all(parameter->Box); +// return parameter->Box; +// } + + +// GtkWidget *__yon_configuration_boolean_parameter_new(char *id, char *label_text){ +// yon_configuration_boolean_parameter *parameter = malloc(sizeof(yon_configuration_boolean_parameter)); +// parameter->Box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); +// parameter->CheckButton = gtk_check_button_new_with_label(label_text); +// parameter->id = yon_char_new(id); + +// g_signal_connect(G_OBJECT(parameter->CheckButton),"toggled",G_CALLBACK(__yon_on_boolean_parameter_toggled),parameter->id); +// gtk_box_pack_start(GTK_BOX(parameter->Box),parameter->CheckButton,0,0,0); +// return parameter; +// } + +// //parameter section + +// void yon_configuration_window_add_boolean_parameter(enum CONFIGURATION_PARAMETER_TYPE type, char *id, char *label){ +// yon_configuration_parameter_add_or_create_if_exists_with_data(__yon_settings_parameters,id,label); +// yon_configuration_parameters *parameter = (yon_configuration_parameters*)yon_dictionary_get_last((dictionary*)__yon_settings_parameters); +// if (parameter){ +// parameter->type = CONFIGURATION_PARAMETER_BOOL; +// } +// } + +char *yon_settings_configuration_get(char *id){ + char *return_val = NULL; + yon_window_config_get_parameter(yon_configuration_window_section,id,&return_val,YON_TYPE_STRING); + return return_val; } -yon_configuration_parameters *__yon_settings_parameters = NULL; - -yon_configuration_combo_parameter *yon_configuration_combo_box_parameter_new(char *id, char *label_text, config_str parameters){ - yon_configuration_combo_parameter *parameter = malloc(sizeof(yon_configuration_combo_parameter)); - parameter->Box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); - parameter->Label = gtk_label_new(label_text); - parameter->ComboBox = gtk_combo_box_text_new(); - parameter->id = yon_char_new(id); - gtk_box_pack_start(GTK_BOX(parameter->Box),parameter->Label,0,0,0); - gtk_box_pack_start(GTK_BOX(parameter->Box),parameter->ComboBox,0,0,0); - for (int i=0;parameters[i]&¶meters[i+1];i+=2){ - gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(parameter->ComboBox),parameters[i],parameters[i+1]); - } - char *value = NULL; - yon_window_config_get_parameter("settings",id,&value,YON_TYPE_STRING); - if (!yon_char_is_empty(value)){ - gtk_combo_box_set_active_id(GTK_COMBO_BOX(parameter->ComboBox),value); - } else { - gtk_combo_box_set_active(GTK_COMBO_BOX(parameter->ComboBox),0); - } - g_signal_connect(G_OBJECT(parameter->ComboBox),"changed",G_CALLBACK(on_confuguration_combo_box_changed),id); - yon_configuration_parameters *target = (yon_configuration_parameters*)yon_dictionary_get((dictionary**)&__yon_settings_parameters,id); - if (target){ - if (target->func){ - g_signal_connect(G_OBJECT(parameter->ComboBox),"changed",G_CALLBACK(target->func),target->value); - } - } - gtk_widget_show_all(parameter->Box); - return parameter; +//signnals section + +// void __yon_on_boolean_parameter_toggled(GtkToggleButton *self ,char *id){ +// yon_configuration_parameters *current = (yon_configuration_parameters*)yon_dictionary_get((dictionary**)&__yon_settings_parameters,id); +// if (current){ +// current->data= gtk_toggle_button_get_active(self)?(void*)1:(void*)0; +// } +// } + + +// void yon_configuration_window_add_boolean_parameter(char *id, void (*parameter_update_func)(GtkWidget*)){ +// struct yon_configuration_window_custom_parameter *custom_parameter_data = malloc(sizeof(struct yon_configuration_window_custom_parameter)); +// memset(custom_parameter_data,0,sizeof(struct yon_configuration_window_custom_parameter)); +// custom_parameter_data->custom_parameter_create_func = yon_configuration_boolean_parameter_new; +// yon_configuration_window_add_custom_parameter(id,custom_parameter_data); +// } + +// void yon_on_configuration_window_combo_changed(GtkWidget *root){ +// struct yon_configuration_combo_parameter *parameter = g_object_get_data(G_OBJECT(root),"data_struct"); +// const char *param_id = gtk_combo_box_get_active_id(GTK_COMBO_BOX(parameter->ComboBox)); +// yon_window_config_add_instant_parameter(parameter->id,"CONFIGURATION_WINDOW_PARAMETERS",(char*)param_id,YON_TYPE_STRING); +// } + +// void yon_configuration_window_add_combo_box_parameter(char *id, void (*parameter_update_func)(GtkWidget*)){ +// struct yon_configuration_window_custom_parameter *custom_parameter_data = malloc(sizeof(struct yon_configuration_window_custom_parameter)); +// memset(custom_parameter_data,0,sizeof(struct yon_configuration_window_custom_parameter)); +// custom_parameter_data->custom_parameter_create_func = yon_configuration_combo_box_parameter_new; +// yon_configuration_window_add_custom_parameter(id,custom_parameter_data); +// } + +// init section + +void __yon_on_ubl_settings_window_open(); +void yon_on_settings_window_accept(GtkWidget*,GdkEvent *,ubl_settings_window *window); + +void yon_ubl_settings_window_init(GtkMenu *menu){ + if (!yon_window_config_check_init()) return; + GtkWidget *menu_item = gtk_menu_item_new(); + GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0); + textdomain(template_ui_LocaleName); + GtkWidget *label = gtk_label_new(CONFIG_WINDOW_MENU_LABEL); + textdomain(template_app_information.app_locale); + gtk_style_context_add_class(gtk_widget_get_style_context(menu_item),"menuitemtop"); + GtkWidget *image = gtk_image_new_from_icon_name("com.ublinux.libublsettingsui-gtk3.settings-symbolic",GTK_ICON_SIZE_BUTTON); + gtk_menu_shell_prepend(GTK_MENU_SHELL(menu),menu_item); + gtk_container_add(GTK_CONTAINER(menu_item),box); + gtk_box_pack_start(GTK_BOX(box),image,0,0,5); + gtk_box_pack_start(GTK_BOX(box),label,0,0,5); + gtk_widget_show_all(menu_item); + g_signal_connect(G_OBJECT(menu_item),"activate",G_CALLBACK(__yon_on_ubl_settings_window_open),NULL); } ubl_settings_window *yon_ubl_settings_window_new(){ @@ -88,181 +138,99 @@ ubl_settings_window *yon_ubl_settings_window_new(){ GtkBuilder *builder = gtk_builder_new_from_resource("/com/ublinux/ui/libublsettingsui-gtk3-config-window.glade"); window->window = yon_gtk_builder_get_widget(builder,"Window"); window->WorkZoneBox = yon_gtk_builder_get_widget(builder,"WorkZoneBox"); - window->AcceptButton = yon_gtk_builder_get_widget(builder,"AcceptButton"); - window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); - gtk_window_set_title(GTK_WINDOW(window->window),template_app_information.app_title); - gtk_window_set_icon_name(GTK_WINDOW(window->window),yon_char_append("com.ublinux.",template_app_information.app_tech_name)); + // window->AcceptButton = yon_gtk_builder_get_widget(builder,"AcceptButton"); + // window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); + char *icon_name = yon_char_unite("com.ublinux.",template_app_information.app_tech_name,NULL); + yon_gtk_window_setup(GTK_WINDOW(window->window),NULL,template_app_information.app_title,icon_name,"SETTINGS_WINDOW"); + g_signal_connect(G_OBJECT(window->window),"delete-event",G_CALLBACK(yon_on_settings_window_accept),window); return window; } +struct yon_configuration_custom_parameter { + GtkWidget *custom_parameter_root; + char *custom_parameter_id; + struct yon_configuration_window_custom_parameter *custom_callbacks; +}; -yon_configuration_boolean_parameter *__yon_configuration_boolean_parameter_new(char *id, char *label_text){ - yon_configuration_boolean_parameter *parameter = malloc(sizeof(yon_configuration_boolean_parameter)); - parameter->Box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); - parameter->CheckButton = gtk_check_button_new_with_label(label_text); - parameter->id = yon_char_new(id); - - g_signal_connect(G_OBJECT(parameter->CheckButton),"toggled",G_CALLBACK(__yon_on_boolean_parameter_toggled),parameter->id); - gtk_box_pack_start(GTK_BOX(parameter->Box),parameter->CheckButton,0,0,0); - return parameter; -} +dictionary *__yon_configuration_custom_parameters = NULL; -//parameter section - -yon_configuration_parameters *yon_configuration_parameter_new() -{ - yon_configuration_parameters *dict = malloc(sizeof(yon_configuration_parameters)); - dict->data = NULL; - dict->key = NULL; - dict->next = NULL; - dict->prev = NULL; - dict->data = NULL; - dict->value = NULL; - dict->func = NULL; - dict->first = (struct yon_configuration_parameters*)dict; - dict->data_type = DICTIONARY_OTHER_TYPE; - return dict; +void __yon_on_ubl_settings_window_open(){ + if (!__yon_configuration_custom_parameters) return; + ubl_settings_window *window = yon_ubl_settings_window_new(); + dictionary *current = NULL; + for_dictionaries(current,__yon_configuration_custom_parameters){ + struct yon_configuration_custom_parameter *parameter = ((struct yon_configuration_custom_parameter*)current->data); + parameter->custom_parameter_root = parameter->custom_callbacks->custom_parameter_create_func(parameter->custom_parameter_id); + gtk_box_pack_start(GTK_BOX(window->WorkZoneBox),parameter->custom_parameter_root,0,0,0); + parameter->custom_callbacks->custom_parameter_update_func(parameter->custom_parameter_root); + } + gtk_widget_show(window->window); } -yon_configuration_parameters *yon_configuration_parameter_append(yon_configuration_parameters *targetdict) -{ - targetdict = (yon_configuration_parameters*)yon_dictionary_get_last((dictionary*)targetdict); - targetdict->next = (struct yon_configuration_parameters*)yon_configuration_parameter_new(); - targetdict->next->prev = (struct yon_configuration_parameters*)targetdict; - targetdict->next->first = targetdict->first; - targetdict->next->data_type = DICTIONARY_OTHER_TYPE; - targetdict->next->data = NULL; - targetdict->next->value = NULL; - targetdict->next->func = NULL; - return targetdict->next; +void yon_on_settings_window_accept(GtkWidget*,GdkEvent *,ubl_settings_window *window){ + dictionary *current; + for_dictionaries(current,__yon_configuration_custom_parameters){ + struct yon_configuration_custom_parameter *parameter = ((struct yon_configuration_custom_parameter*)current->data); + parameter->custom_callbacks->custom_parameter_save_value_func(parameter->custom_parameter_root); + } } -yon_configuration_parameters *yon_configuration_parameter_new_with_label(char *key, void *data) -{ - yon_configuration_parameters *dct = yon_configuration_parameter_new(); - dct->key = yon_char_new(key); - dct->label = data; - dct->data_type = DICTIONARY_OTHER_TYPE; - return dct; +void yon_configuration_window_add_custom_parameter(const char *id, struct yon_configuration_window_custom_parameter *custom_parameter_data){ + struct yon_configuration_custom_parameter *parameter = malloc(sizeof(struct yon_configuration_custom_parameter)); + parameter->custom_callbacks = custom_parameter_data; + parameter->custom_parameter_id = yon_char_new(id); + yon_dictionary_add_or_create_if_exists_with_data(__yon_configuration_custom_parameters,(char*)id,parameter); } -yon_configuration_parameters *yon_configuration_parameter_append_with_label(yon_configuration_parameters *dict, char *key, void *data) -{ - yon_configuration_parameters *dct = yon_configuration_parameter_append(dict); - dct->key = yon_char_new(key); - dct->label = data; - dct->data_type = DICTIONARY_OTHER_TYPE; - return dct; -} -#define yon_configuration_parameter_add_or_create_if_exists_with_data(dict,key,data) {if (!dict) dict=yon_configuration_parameter_new_with_label(key,data); \ - else dict=yon_configuration_parameter_append_with_label(dict,key,data);} +#define date_format_parameter "DateFormat" -void yon_configuration_window_add_boolean_parameter(enum CONFIGURATION_PARAMETER_TYPE type, char *id, char *label){ - yon_configuration_parameter_add_or_create_if_exists_with_data(__yon_settings_parameters,id,label); - yon_configuration_parameters *parameter = (yon_configuration_parameters*)yon_dictionary_get_last((dictionary*)__yon_settings_parameters); - if (parameter){ - parameter->type = CONFIGURATION_PARAMETER_BOOL; - } +void on_parameter_destroy(GtkWidget *, struct yon_date_chooser_option *parameter); +void on_parameter_destroy(GtkWidget *, struct yon_date_chooser_option *parameter){ + free(parameter); } -char *yon_settings_configuration_get(char *id){ - char *return_val = NULL; - yon_window_config_get_parameter("settings",id,&return_val,YON_TYPE_STRING); - return return_val; +GtkWidget *yon_date_chooser_new( char *){ + struct yon_date_chooser_option *parameter = malloc(sizeof(struct yon_date_chooser_option)); + + parameter->RootBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); + parameter->DateLabel = gtk_label_new(DATE_FORMAT_SETTINGS_LABEL); + parameter->DateCombo = gtk_combo_box_text_new(); + gtk_box_pack_start(GTK_BOX(parameter->RootBox),parameter->DateLabel,0,0,0); + gtk_box_pack_start(GTK_BOX(parameter->RootBox),parameter->DateCombo,1,1,0); + g_object_set_data(G_OBJECT(parameter->RootBox),"data_struct",parameter); + + g_signal_connect(G_OBJECT(parameter->RootBox),"destroy",G_CALLBACK(on_parameter_destroy),parameter); + gtk_widget_show_all(parameter->RootBox); + return parameter->RootBox; } -//signnals section - -void __yon_on_boolean_parameter_toggled(GtkToggleButton *self ,char *id){ - yon_configuration_parameters *current = (yon_configuration_parameters*)yon_dictionary_get((dictionary**)&__yon_settings_parameters,id); - if (current){ - current->data= gtk_toggle_button_get_active(self)?(void*)1:(void*)0; - } -} - -void on_confuguration_combo_box_changed(GtkComboBox *self, char *id){ - yon_configuration_parameters *cur = (yon_configuration_parameters*)yon_dictionary_get((dictionary**)&__yon_settings_parameters,id); - if (cur){ - char *cur_value = yon_char_new((char*)gtk_combo_box_get_active_id(self)); - if (yon_window_config_check_init()){ - yon_window_config_add_instant_parameter(id,"settings",cur_value,YON_TYPE_STRING); - } +void yon_date_chooser_update(GtkWidget *root){ + struct yon_date_chooser_option *parameter = g_object_get_data(G_OBJECT(root),"data_struct"); + gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(parameter->DateCombo)); + gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(parameter->DateCombo),"%d.%m.%Y",DMY_FORMAT_LABEL); + gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(parameter->DateCombo),"%d-%m-%Y",DMY_MINUS_FORMAT_LABEL); + gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(parameter->DateCombo),"%d/%m/%Y",DMY_SLASH_FORMAT_LABEL); + gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(parameter->DateCombo),"%m-%d-%Y",MDY_FORMAT_LABEL); + + char *target; + if (!yon_window_config_get_parameter(yon_configuration_window_section,date_format_parameter,&target,YON_TYPE_STRING)){ + target = NULL; } + if (target){ + gtk_combo_box_set_active_id(GTK_COMBO_BOX(parameter->DateCombo),target); + } else { + gtk_combo_box_set_active(GTK_COMBO_BOX(parameter->DateCombo),0); + } + } -void __yon_on_ubl_settings_window_open(){ - if (!__yon_settings_parameters) return; - ubl_settings_window *window = yon_ubl_settings_window_new(); - dictionary *current = NULL; - for_dictionaries(current,(dictionary*)__yon_settings_parameters){ - switch(((yon_configuration_parameters*)current)->type){ - case CONFIGURATION_PARAMETER_BOOL:{ - yon_configuration_boolean_parameter *cur = __yon_configuration_boolean_parameter_new(((yon_configuration_parameters*)current)->key,((yon_configuration_parameters*)current)->label); - gtk_box_pack_start(GTK_BOX(window->WorkZoneBox),cur->Box,0,0,0); - gtk_widget_show_all(window->WorkZoneBox); - - } break; - case CONFIGURATION_PARAMETER_ENTRY:{ - // yon_configuration_entry_parameter *cur = __yon_configuration_entry_parameter_new(current->key,current->label); - // gtk_box_pack_start(GTK_BOX(window->WorkZoneBox),cur->Box,0,0,0); - - } break; - case CONFIGURATION_PARAMETER_COMBO_BOX:{ - yon_configuration_combo_parameter *cur = yon_configuration_combo_box_parameter_new(((yon_configuration_parameters*)current)->key,((yon_configuration_parameters*)current)->label,(config_str)((yon_configuration_parameters*)current)->data); - gtk_box_pack_start(GTK_BOX(window->WorkZoneBox),cur->Box,0,0,0); - gtk_widget_show_all(window->WorkZoneBox); - } break; - case CONFIGURATION_PARAMETER_LIST_MULTIPLE:{ - } break; - } +void yon_date_chooser_save(GtkWidget *root){ + struct yon_date_chooser_option *parameter = g_object_get_data(G_OBJECT(root),"data_struct"); + char *path = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(parameter->DateCombo)); + if (!yon_char_is_empty(path)){ + yon_window_config_add_instant_parameter(date_format_parameter,yon_configuration_window_section,path,YON_TYPE_STRING); + } else { + yon_window_config_erase_instant_parameter(date_format_parameter,yon_configuration_window_section); } - gtk_widget_show(window->window); -} - -//init section - -void yon_configuration_window_add_combo_box_parameter(enum CONFIGURATION_PARAMETER_TYPE type, char *id, char *label, GCallback func, gpointer data,...){ - yon_configuration_parameter_add_or_create_if_exists_with_data(__yon_settings_parameters,id,label); - va_list args; - va_start(args,data); - char *cur=NULL; - int size=0; - config_str variants = NULL; - while ((cur=va_arg(args,char*))){ - yon_char_parsed_add_or_create_if_exists(variants,&size,cur); - } - { - char *target=NULL; - yon_window_config_get_parameter("settings",id,&target,YON_TYPE_STRING); - if (yon_char_is_empty(target)){ - yon_window_config_add_instant_parameter(id,"settings",variants[0],YON_TYPE_STRING); - } - } - yon_char_parsed_add_or_create_if_exists(variants,&size,NULL); - yon_configuration_parameters *parameter = (yon_configuration_parameters*)yon_dictionary_get_last((dictionary*)__yon_settings_parameters); - if (parameter){ - - parameter->data = (void*)variants; - parameter->type = CONFIGURATION_PARAMETER_COMBO_BOX; - parameter->func = func; - parameter->value = data; - } - -} - -void yon_ubl_settings_window_init(GtkMenu *menu){ - GtkWidget *menu_item = gtk_menu_item_new(); - GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0); - textdomain(template_ui_LocaleName); - GtkWidget *label = gtk_label_new(CONFIG_WINDOW_MENU_LABEL); - textdomain(template_app_information.app_locale); - gtk_style_context_add_class(gtk_widget_get_style_context(menu_item),"menuitemtop"); - GtkWidget *image = gtk_image_new_from_icon_name("com.ublinux.libublsettingsui-gtk3.settings-symbolic",GTK_ICON_SIZE_BUTTON); - gtk_menu_shell_prepend(GTK_MENU_SHELL(menu),menu_item); - gtk_container_add(GTK_CONTAINER(menu_item),box); - gtk_box_pack_start(GTK_BOX(box),image,0,0,5); - gtk_box_pack_start(GTK_BOX(box),label,0,0,5); - gtk_widget_show_all(menu_item); - g_signal_connect(G_OBJECT(menu_item),"activate",G_CALLBACK(__yon_on_ubl_settings_window_open),NULL); } \ No newline at end of file diff --git a/source/libublsettingsui-gtk3.h b/source/libublsettingsui-gtk3.h index 2ff607d..bc7d345 100644 --- a/source/libublsettingsui-gtk3.h +++ b/source/libublsettingsui-gtk3.h @@ -384,7 +384,8 @@ enum CONFIGURATION_PARAMETER_TYPE{ CONFIGURATION_PARAMETER_BOOL, CONFIGURATION_PARAMETER_ENTRY, CONFIGURATION_PARAMETER_COMBO_BOX, - CONFIGURATION_PARAMETER_LIST_MULTIPLE + CONFIGURATION_PARAMETER_LIST_MULTIPLE, + CONFIGURATION_PARAMETER_CUSTOM }; void yon_ubl_settings_window_init(GtkMenu *menu); @@ -398,10 +399,34 @@ char *yon_gtk_entry_check_restricted(GtkEntry *target); typedef struct { GtkWidget *window; GtkWidget *WorkZoneBox; - GtkWidget *AcceptButton; - GtkWidget *CancelButton; + // GtkWidget *AcceptButton; + // GtkWidget *CancelButton; } ubl_settings_window; +struct yon_date_chooser_option { + GtkWidget *RootBox; + GtkWidget *DateLabel; + GtkWidget *DateCombo; +}; + +struct yon_configuration_window_custom_parameter{ + GtkWidget *(*custom_parameter_create_func)(char*); + void (*custom_parameter_update_func)(GtkWidget*); + void (*custom_parameter_save_value_func)(GtkWidget*); +}; + +/// @brief Section name for configuration window's parameters saving and loading +#define yon_configuration_window_section "CONFIGURATION_WINDOW_SETTINGS" + +/// @brief Register custom parameter fow configuration window +/// @param id custom parameter id; +/// @param parameter Data struct with functions for creating, updating and geting data from custom parameter +void yon_configuration_window_add_custom_parameter(const char *id, struct yon_configuration_window_custom_parameter *custom_parameter_data); + +GtkWidget *yon_date_chooser_new( char *); +void yon_date_chooser_update(GtkWidget *root); +void yon_date_chooser_save(GtkWidget *root); + char *yon_settings_configuration_get(char *id); char *yon_custom_config_init(); @@ -640,4 +665,12 @@ yon_password_window *yon_password_open(GtkEntry *target); #define _ENCRYPTION_DEFAULT_LABEL yon_char_get_localised_from_lib("Default (None)") #define ACCESS_DENIED_LABEL(target) yon_char_unite(yon_char_get_localised_from_lib("Access to file denied"),": ", target,NULL) #define CONFIG_INVALID_LABEL yon_char_get_localised_from_lib("The configuration file contains incorrect parameters.") + #define DATE_FORMAT_SETTINGS_LABEL _("Date format:") + #define YEAR_FORMAT_LABEL _("YYYY") + #define MONTH_FORMAT_LABEL _("MM") + #define DAY_FORMAT_LABEL _("DD") + #define DMY_FORMAT_LABEL _("DD.MM.YYYY") + #define DMY_MINUS_FORMAT_LABEL _("DD-MM-YYYY") + #define DMY_SLASH_FORMAT_LABEL _("DD/MM/YYYY") + #define MDY_FORMAT_LABEL _("MM-DD-YYYY") #endif \ No newline at end of file -- 2.35.1