pull/38/head
parent a39c9469f2
commit 455dac66e3

@ -1,6 +1,7 @@
#include "libublsettingsui-gtk3.h"
void on_confuguration_combo_box_changed(GtkComboBox *self, char *id);
void __yon_on_boolean_parameter_toggled(GtkToggleButton *self ,char *id);
typedef struct {
char *id;
@ -29,6 +30,15 @@ typedef struct {
// GtkListStore *list;
// } yon_configuration_list_parameter;
typedef struct yon_configuration_parameters {
dictionary_fields(yon_configuration_parameters);
char *label;
char *value;
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);
@ -64,13 +74,6 @@ yon_configuration_combo_parameter *yon_configuration_combo_box_parameter_new(cha
return parameter;
}
typedef struct yon_configuration_parameters {
dictionary_fields(yon_configuration_parameters);
char *label;
char *value;
enum CONFIGURATION_PARAMETER_TYPE type;
} yon_configuration_parameters;
ubl_settings_window *yon_ubl_settings_window_new(){
ubl_settings_window *window = malloc(sizeof(ubl_settings_window));
GtkBuilder *builder = gtk_builder_new_from_resource("/com/ublinux/ui/libublsettingsui-gtk3-config-window.glade");
@ -83,12 +86,6 @@ ubl_settings_window *yon_ubl_settings_window_new(){
yon_configuration_parameters *__yon_settings_parameters = NULL;
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;
}
}
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));
@ -101,50 +98,7 @@ yon_configuration_boolean_parameter *__yon_configuration_boolean_parameter_new(c
return parameter;
}
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);
}
void yon_ubl_settings_window_init(GtkMenu *menu){
GtkWidget *menu_item = gtk_menu_item_new();
GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5);
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,0);
gtk_box_pack_start(GTK_BOX(box),label,0,0,0);
gtk_widget_show_all(menu_item);
g_signal_connect(G_OBJECT(menu_item),"activate",G_CALLBACK(__yon_on_ubl_settings_window_open),NULL);
}
//parameter section
yon_configuration_parameters *yon_configuration_parameter_new()
{
@ -201,6 +155,62 @@ void yon_configuration_window_add_boolean_parameter(enum CONFIGURATION_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;
}
//signnals section
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);
}
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){
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);
}
}
}
//init section
void yon_configuration_window_add_combo_box_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);
va_list args;
@ -228,18 +238,18 @@ void yon_configuration_window_add_combo_box_parameter(enum CONFIGURATION_PARAMET
}
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;
}
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){
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_ubl_settings_window_init(GtkMenu *menu){
GtkWidget *menu_item = gtk_menu_item_new();
GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5);
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,0);
gtk_box_pack_start(GTK_BOX(box),label,0,0,0);
gtk_widget_show_all(menu_item);
g_signal_connect(G_OBJECT(menu_item),"activate",G_CALLBACK(__yon_on_ubl_settings_window_open),NULL);
}

@ -1,5 +1,8 @@
#include "libublsettingsui-gtk3.h"
_template_config *template_config = NULL;
template_app_info template_app_information;
static char *__yon_config_mode=NULL;
char *yon_ubl_save_mode_get_icon_name(SAVE_MODE_TYPE type){

@ -66,7 +66,7 @@ typedef struct {
gboolean always_open_documentation;
} template_app_info;
static template_app_info template_app_information;
extern template_app_info template_app_information;
#define template_config_fields\
@ -89,8 +89,9 @@ static template_app_info template_app_information;
typedef struct {
template_config_fields
} _template_config;
[[maybe_unused]]
static _template_config *template_config;
extern _template_config *template_config;
#define template_window_fields\
GtkWidget *Window;\

Loading…
Cancel
Save