Added combo box parameter for settings window

pull/38/head
parent cbd3f42bc8
commit bd91820abc

@ -3,22 +3,6 @@
<interface domain="libublsettingsui-gtk3">
<requires lib="gtk+" version="3.24"/>
<!-- interface-css-provider-path libublsettingsui-gtk3.css -->
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">com.ublinux.libublsettingsui-gtk3.cancel-symbolic</property>
<style>
<class name="marginright"/>
</style>
</object>
<object class="GtkImage" id="image2">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">com.ublinux.libublsettingsui-gtk3.accept-symbolic</property>
<style>
<class name="marginright"/>
</style>
</object>
<object class="GtkWindow" id="Window">
<property name="width-request">450</property>
<property name="height-request">200</property>
@ -68,6 +52,10 @@
<object class="GtkBox" id="WorkZoneBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
@ -103,6 +91,7 @@
<object class="GtkHeaderBar">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="show-close-button">True</property>
<child type="title">
<object class="GtkLabel" id="HeaderTopic">
<property name="visible">True</property>
@ -121,37 +110,6 @@
<property name="icon-name">com.ublinux.libublsettingsui-gtk3</property>
</object>
</child>
<child>
<object class="GtkButton" id="CancelButton">
<property name="label" translatable="yes">Cancel</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image1</property>
<style>
<class name="marginright"/>
</style>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="AcceptButton">
<property name="label" translatable="yes">Apply</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">image2</property>
<style>
<class name="marginright"/>
</style>
</object>
<packing>
<property name="pack-type">end</property>
<property name="position">2</property>
</packing>
</child>
<style>
<class name="toolbar"/>
</style>

@ -1,5 +1,7 @@
#include "libublsettingsui-gtk3.h"
void on_confuguration_combo_box_changed(GtkComboBox *self, char *id);
typedef struct {
char *id;
GtkWidget *Box;
@ -50,7 +52,14 @@ yon_configuration_combo_parameter *yon_configuration_combo_box_parameter_new(cha
for (int i=0;parameters[i]&&parameters[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);
gtk_widget_show_all(parameter->Box);
return parameter;
}
@ -58,6 +67,7 @@ yon_configuration_combo_parameter *yon_configuration_combo_box_parameter_new(cha
typedef struct yon_configuration_parameters {
dictionary_fields(yon_configuration_parameters);
char *label;
char *value;
enum CONFIGURATION_PARAMETER_TYPE type;
} yon_configuration_parameters;
@ -68,7 +78,6 @@ ubl_settings_window *yon_ubl_settings_window_new(){
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");
g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL);
return window;
}
@ -134,15 +143,6 @@ void yon_ubl_settings_window_init(GtkMenu *menu){
g_signal_connect(G_OBJECT(menu_item),"activate",G_CALLBACK(__yon_on_ubl_settings_window_open),NULL);
}
void *yon_ubl_settings_window_get(char *id){
yon_configuration_parameters *current = (yon_configuration_parameters*)yon_dictionary_get((dictionary**)&__yon_settings_parameters,id);
if (current){
return current->data;
} else {
return NULL;
}
}
yon_configuration_parameters *yon_configuration_parameter_new()
{
yon_configuration_parameters *dict = malloc(sizeof(yon_configuration_parameters));
@ -150,6 +150,8 @@ yon_configuration_parameters *yon_configuration_parameter_new()
dict->key = NULL;
dict->next = NULL;
dict->prev = NULL;
dict->data = NULL;
dict->value = NULL;
dict->first = (struct yon_configuration_parameters*)dict;
dict->data_type = DICTIONARY_OTHER_TYPE;
return dict;
@ -162,6 +164,8 @@ yon_configuration_parameters *yon_configuration_parameter_append(yon_configurati
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;
return targetdict->next;
}
@ -213,3 +217,21 @@ void yon_configuration_window_add_combo_box_parameter(enum CONFIGURATION_PARAMET
}
}
char *yon_settings_configuration_get(char *id){
yon_configuration_parameters *cur = (yon_configuration_parameters*)yon_dictionary_get((dictionary**)&__yon_settings_parameters,id);
if (cur){
return cur->value;
}
return NULL;
}
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);
}
}
}

@ -269,6 +269,8 @@ typedef struct {
GtkWidget *CancelButton;
} ubl_settings_window;
char *yon_settings_configuration_get(char *id);
#define VERSION_LABEL yon_char_unite(_("Version:")," ",!yon_char_is_empty(template_app_information.app_version)?template_app_information.app_version:"","\n",NULL)
#define HELP_LABEL(rest) yon_char_unite(template_app_information.app_tech_name,_(" version:")," ", !yon_char_is_empty(template_app_information.app_version)?template_app_information.app_version:"","\n",template_app_information.app_title,"\n",_("Usage:"), " ",template_app_information.app_tech_name," ",_("[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\t--clear-config\t\t\t",_("Reset application settings"),"\n",!yon_char_is_empty(rest)?rest:NULL,NULL)

Loading…
Cancel
Save