|
|
|
@ -3,84 +3,134 @@
|
|
|
|
void on_confuguration_combo_box_changed(GtkComboBox *self, char *id);
|
|
|
|
void on_confuguration_combo_box_changed(GtkComboBox *self, char *id);
|
|
|
|
void __yon_on_boolean_parameter_toggled(GtkToggleButton *self ,char *id);
|
|
|
|
void __yon_on_boolean_parameter_toggled(GtkToggleButton *self ,char *id);
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
struct yon_configuration_combo_parameter{
|
|
|
|
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;
|
|
|
|
|
|
|
|
GtkWidget *Box;
|
|
|
|
GtkWidget *Box;
|
|
|
|
GtkWidget *Label;
|
|
|
|
GtkWidget *Label;
|
|
|
|
GtkWidget *ComboBox;
|
|
|
|
GtkWidget *ComboBox;
|
|
|
|
} yon_configuration_combo_parameter;
|
|
|
|
char *id;
|
|
|
|
|
|
|
|
};
|
|
|
|
// typedef struct {
|
|
|
|
// yon_configuration_entry_parameter *yon_configuration_entry_parameter_new(char *id, char *label_text){
|
|
|
|
// char *id;
|
|
|
|
// yon_configuration_entry_parameter *parameter = malloc(sizeof(yon_configuration_entry_parameter));
|
|
|
|
// GtkWidget *Label;
|
|
|
|
// parameter->Box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5);
|
|
|
|
// GtkWidget *GtkTreeView;
|
|
|
|
// parameter->Label = gtk_label_new(label_text);
|
|
|
|
// GtkListStore *list;
|
|
|
|
// parameter->Entry = gtk_entry_new();
|
|
|
|
// } yon_configuration_list_parameter;
|
|
|
|
// 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);
|
|
|
|
typedef struct yon_configuration_parameters {
|
|
|
|
// return parameter;
|
|
|
|
dictionary_fields(yon_configuration_parameters);
|
|
|
|
// }
|
|
|
|
char *label;
|
|
|
|
|
|
|
|
char *value;
|
|
|
|
// yon_configuration_parameters *__yon_settings_parameters = NULL;
|
|
|
|
GCallback func;
|
|
|
|
|
|
|
|
enum CONFIGURATION_PARAMETER_TYPE type;
|
|
|
|
// GtkWidget *yon_configuration_combo_box_parameter_new(char *id){
|
|
|
|
} yon_configuration_parameters;
|
|
|
|
// struct yon_configuration_combo_parameter *parameter = malloc(sizeof(struct yon_configuration_combo_parameter));
|
|
|
|
|
|
|
|
// parameter->Box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5);
|
|
|
|
yon_configuration_entry_parameter *yon_configuration_entry_parameter_new(char *id, char *label_text){
|
|
|
|
// parameter->Label = gtk_label_new(NULL);
|
|
|
|
yon_configuration_entry_parameter *parameter = malloc(sizeof(yon_configuration_entry_parameter));
|
|
|
|
// parameter->ComboBox = gtk_combo_box_text_new();
|
|
|
|
parameter->Box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5);
|
|
|
|
// parameter->id = yon_char_new(id);
|
|
|
|
parameter->Label = gtk_label_new(label_text);
|
|
|
|
// g_object_set_data(G_OBJECT(parameter->Box),"data_struct",parameter);
|
|
|
|
parameter->Entry = gtk_entry_new();
|
|
|
|
// gtk_box_pack_start(GTK_BOX(parameter->Box),parameter->Label,0,0,0);
|
|
|
|
parameter->id = yon_char_new(id);
|
|
|
|
// gtk_box_pack_start(GTK_BOX(parameter->Box),parameter->ComboBox,0,0,0);
|
|
|
|
gtk_box_pack_start(GTK_BOX(parameter->Box),parameter->Label,1,1,0);
|
|
|
|
// // for (int i=0;parameters[i]&¶meters[i+1];i+=2){
|
|
|
|
gtk_box_pack_start(GTK_BOX(parameter->Box),parameter->Entry,1,1,0);
|
|
|
|
// // gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(parameter->ComboBox),parameters[i],parameters[i+1]);
|
|
|
|
gtk_widget_show_all(parameter->Box);
|
|
|
|
// // }
|
|
|
|
return parameter;
|
|
|
|
// // 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;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
yon_configuration_parameters *__yon_settings_parameters = NULL;
|
|
|
|
char *yon_settings_configuration_get(char *id){
|
|
|
|
|
|
|
|
char *return_val = NULL;
|
|
|
|
yon_configuration_combo_parameter *yon_configuration_combo_box_parameter_new(char *id, char *label_text, config_str parameters){
|
|
|
|
yon_window_config_get_parameter(yon_configuration_window_section,id,&return_val,YON_TYPE_STRING);
|
|
|
|
yon_configuration_combo_parameter *parameter = malloc(sizeof(yon_configuration_combo_parameter));
|
|
|
|
return return_val;
|
|
|
|
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(){
|
|
|
|
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");
|
|
|
|
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->window = yon_gtk_builder_get_widget(builder,"Window");
|
|
|
|
window->WorkZoneBox = yon_gtk_builder_get_widget(builder,"WorkZoneBox");
|
|
|
|
window->WorkZoneBox = yon_gtk_builder_get_widget(builder,"WorkZoneBox");
|
|
|
|
window->AcceptButton = yon_gtk_builder_get_widget(builder,"AcceptButton");
|
|
|
|
// window->AcceptButton = yon_gtk_builder_get_widget(builder,"AcceptButton");
|
|
|
|
window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton");
|
|
|
|
// window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton");
|
|
|
|
gtk_window_set_title(GTK_WINDOW(window->window),template_app_information.app_title);
|
|
|
|
char *icon_name = yon_char_unite("com.ublinux.",template_app_information.app_tech_name,NULL);
|
|
|
|
gtk_window_set_icon_name(GTK_WINDOW(window->window),yon_char_append("com.ublinux.",template_app_information.app_tech_name));
|
|
|
|
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;
|
|
|
|
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){
|
|
|
|
dictionary *__yon_configuration_custom_parameters = NULL;
|
|
|
|
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);
|
|
|
|
void __yon_on_ubl_settings_window_open(){
|
|
|
|
gtk_box_pack_start(GTK_BOX(parameter->Box),parameter->CheckButton,0,0,0);
|
|
|
|
if (!__yon_configuration_custom_parameters) return;
|
|
|
|
return parameter;
|
|
|
|
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);
|
|
|
|
//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;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
yon_configuration_parameters *yon_configuration_parameter_append(yon_configuration_parameters *targetdict)
|
|
|
|
void yon_on_settings_window_accept(GtkWidget*,GdkEvent *,ubl_settings_window *window){
|
|
|
|
{
|
|
|
|
dictionary *current;
|
|
|
|
targetdict = (yon_configuration_parameters*)yon_dictionary_get_last((dictionary*)targetdict);
|
|
|
|
for_dictionaries(current,__yon_configuration_custom_parameters){
|
|
|
|
targetdict->next = (struct yon_configuration_parameters*)yon_configuration_parameter_new();
|
|
|
|
struct yon_configuration_custom_parameter *parameter = ((struct yon_configuration_custom_parameter*)current->data);
|
|
|
|
targetdict->next->prev = (struct yon_configuration_parameters*)targetdict;
|
|
|
|
parameter->custom_callbacks->custom_parameter_save_value_func(parameter->custom_parameter_root);
|
|
|
|
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;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
yon_configuration_parameters *yon_configuration_parameter_append_with_label(yon_configuration_parameters *dict, char *key, void *data)
|
|
|
|
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));
|
|
|
|
yon_configuration_parameters *dct = yon_configuration_parameter_append(dict);
|
|
|
|
parameter->custom_callbacks = custom_parameter_data;
|
|
|
|
dct->key = yon_char_new(key);
|
|
|
|
parameter->custom_parameter_id = yon_char_new(id);
|
|
|
|
dct->label = data;
|
|
|
|
yon_dictionary_add_or_create_if_exists_with_data(__yon_configuration_custom_parameters,(char*)id,parameter);
|
|
|
|
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);}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void yon_configuration_window_add_boolean_parameter(enum CONFIGURATION_PARAMETER_TYPE type, char *id, char *label){
|
|
|
|
#define date_format_parameter "DateFormat"
|
|
|
|
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){
|
|
|
|
void on_parameter_destroy(GtkWidget *, struct yon_date_chooser_option *parameter);
|
|
|
|
char *return_val = NULL;
|
|
|
|
void on_parameter_destroy(GtkWidget *, struct yon_date_chooser_option *parameter){
|
|
|
|
yon_window_config_get_parameter("settings",id,&return_val,YON_TYPE_STRING);
|
|
|
|
free(parameter);
|
|
|
|
return return_val;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//signnals section
|
|
|
|
GtkWidget *yon_date_chooser_new( char *){
|
|
|
|
|
|
|
|
struct yon_date_chooser_option *parameter = malloc(sizeof(struct yon_date_chooser_option));
|
|
|
|
|
|
|
|
|
|
|
|
void __yon_on_boolean_parameter_toggled(GtkToggleButton *self ,char *id){
|
|
|
|
parameter->RootBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5);
|
|
|
|
yon_configuration_parameters *current = (yon_configuration_parameters*)yon_dictionary_get((dictionary**)&__yon_settings_parameters,id);
|
|
|
|
parameter->DateLabel = gtk_label_new(DATE_FORMAT_SETTINGS_LABEL);
|
|
|
|
if (current){
|
|
|
|
parameter->DateCombo = gtk_combo_box_text_new();
|
|
|
|
current->data= gtk_toggle_button_get_active(self)?(void*)1:(void*)0;
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
|
void on_confuguration_combo_box_changed(GtkComboBox *self, char *id){
|
|
|
|
g_signal_connect(G_OBJECT(parameter->RootBox),"destroy",G_CALLBACK(on_parameter_destroy),parameter);
|
|
|
|
yon_configuration_parameters *cur = (yon_configuration_parameters*)yon_dictionary_get((dictionary**)&__yon_settings_parameters,id);
|
|
|
|
gtk_widget_show_all(parameter->RootBox);
|
|
|
|
if (cur){
|
|
|
|
return parameter->RootBox;
|
|
|
|
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_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;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_show(window->window);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//init section
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
|
void yon_configuration_window_add_combo_box_parameter(enum CONFIGURATION_PARAMETER_TYPE type, char *id, char *label, GCallback func, gpointer data,...){
|
|
|
|
char *target;
|
|
|
|
yon_configuration_parameter_add_or_create_if_exists_with_data(__yon_settings_parameters,id,label);
|
|
|
|
if (!yon_window_config_get_parameter(yon_configuration_window_section,date_format_parameter,&target,YON_TYPE_STRING)){
|
|
|
|
va_list args;
|
|
|
|
target = NULL;
|
|
|
|
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);
|
|
|
|
if (target){
|
|
|
|
yon_configuration_parameters *parameter = (yon_configuration_parameters*)yon_dictionary_get_last((dictionary*)__yon_settings_parameters);
|
|
|
|
gtk_combo_box_set_active_id(GTK_COMBO_BOX(parameter->DateCombo),target);
|
|
|
|
if (parameter){
|
|
|
|
} else {
|
|
|
|
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(parameter->DateCombo),0);
|
|
|
|
parameter->data = (void*)variants;
|
|
|
|
|
|
|
|
parameter->type = CONFIGURATION_PARAMETER_COMBO_BOX;
|
|
|
|
|
|
|
|
parameter->func = func;
|
|
|
|
|
|
|
|
parameter->value = data;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void yon_ubl_settings_window_init(GtkMenu *menu){
|
|
|
|
void yon_date_chooser_save(GtkWidget *root){
|
|
|
|
GtkWidget *menu_item = gtk_menu_item_new();
|
|
|
|
struct yon_date_chooser_option *parameter = g_object_get_data(G_OBJECT(root),"data_struct");
|
|
|
|
GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
|
|
|
|
char *path = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(parameter->DateCombo));
|
|
|
|
textdomain(template_ui_LocaleName);
|
|
|
|
if (!yon_char_is_empty(path)){
|
|
|
|
GtkWidget *label = gtk_label_new(CONFIG_WINDOW_MENU_LABEL);
|
|
|
|
yon_window_config_add_instant_parameter(date_format_parameter,yon_configuration_window_section,path,YON_TYPE_STRING);
|
|
|
|
textdomain(template_app_information.app_locale);
|
|
|
|
} else {
|
|
|
|
gtk_style_context_add_class(gtk_widget_get_style_context(menu_item),"menuitemtop");
|
|
|
|
yon_window_config_erase_instant_parameter(date_format_parameter,yon_configuration_window_section);
|
|
|
|
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);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|