pull/43/head
parent fbe5957225
commit 12711de434

@ -12,16 +12,24 @@ char *config_set_global_command = NULL;
char *config_set_local_command = NULL; char *config_set_local_command = NULL;
char *config_set_custom_command = NULL; char *config_set_custom_command = NULL;
void yon_load_proceed(YON_CONFIG_TYPE type){ int __yon_load_proceed(YON_CONFIG_TYPE type){
if (type!=YON_CONFIG_CUSTOM){
yon_config_clean(); yon_config_clean();
}
if (!yon_char_is_empty(config_get_default_command)) if (!yon_char_is_empty(config_get_default_command))
yon_config_load_config(YON_CONFIG_DEFAULT,config_get_default_command,NULL); yon_config_load_config(YON_CONFIG_DEFAULT,config_get_default_command,NULL);
if (type==YON_CONFIG_GLOBAL){ if (type==YON_CONFIG_GLOBAL){
yon_config_load_config(type,config_get_global_command,NULL); if (yon_config_load_config(type,config_get_global_command,NULL)){
} else if (type==YON_CONFIG_LOCAL){ yon_ubl_status_box_render(GLOBAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
yon_config_load_config(type,config_get_local_command,NULL); }
}
else if (type==YON_CONFIG_LOCAL){
if (yon_config_load_config(type,config_get_local_command,NULL)){
yon_ubl_status_box_render(LOCAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
}
} else if (type==YON_CONFIG_CUSTOM){ } else if (type==YON_CONFIG_CUSTOM){
char *path=""; char *path;
textdomain(template_ui_LocaleName);
GtkWidget *dialog = gtk_file_chooser_dialog_new(template_app_information.app_title,NULL,GTK_FILE_CHOOSER_ACTION_SAVE,CANCEL_LABEL,GTK_RESPONSE_CANCEL,OPEN_LABEL,GTK_RESPONSE_ACCEPT,NULL); GtkWidget *dialog = gtk_file_chooser_dialog_new(template_app_information.app_title,NULL,GTK_FILE_CHOOSER_ACTION_SAVE,CANCEL_LABEL,GTK_RESPONSE_CANCEL,OPEN_LABEL,GTK_RESPONSE_ACCEPT,NULL);
gtk_window_set_icon_name(GTK_WINDOW(dialog),yon_char_append("com.ublinux.",template_app_information.app_tech_name)); gtk_window_set_icon_name(GTK_WINDOW(dialog),yon_char_append("com.ublinux.",template_app_information.app_tech_name));
gtk_window_set_title(GTK_WINDOW(dialog),template_app_information.app_title); gtk_window_set_title(GTK_WINDOW(dialog),template_app_information.app_title);
@ -34,66 +42,70 @@ void yon_load_proceed(YON_CONFIG_TYPE type){
if (response == GTK_RESPONSE_ACCEPT){ if (response == GTK_RESPONSE_ACCEPT){
char *file = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); char *file = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
if (!yon_char_is_empty(file)){ if (!yon_char_is_empty(file)){
path=file; path=yon_char_unite("'",file,"'",NULL);
}
yon_config_clean();
char *final_command = yon_config_parameter_prepare_command(config_get_custom_command,file,NULL,NULL);
if (yon_config_load_config(type,final_command,NULL)){
yon_ubl_status_box_render(LOCAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
} }
gtk_widget_destroy(dialog); gtk_widget_destroy(dialog);
} else { } else {
gtk_widget_destroy(dialog); gtk_widget_destroy(dialog);
return 0;
} }
char *command = yon_config_parameter_prepare_command(config_get_custom_command,path,NULL,NULL);
yon_config_load_config(type,command,NULL);
} }
return 1;
} }
void on_config_local_load(GtkWidget *){ void __on_config_local_load(GtkWidget *){
yon_load_proceed(YON_CONFIG_LOCAL); __yon_load_proceed(YON_CONFIG_LOCAL);
template_config->load_mode=1; template_config->load_mode=1;
} }
void on_config_global_load(GtkWidget *){ void __on_config_global_load(GtkWidget *){
yon_load_proceed(YON_CONFIG_GLOBAL); __yon_load_proceed(YON_CONFIG_GLOBAL);
template_config->load_mode=0; template_config->load_mode=0;
} }
void on_config_custom_load(GtkWidget *){ void __on_config_custom_load(GtkWidget *){
yon_load_proceed(YON_CONFIG_CUSTOM); __yon_load_proceed(YON_CONFIG_CUSTOM);
yon_ubl_status_box_render(GLOBAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
template_config->load_mode=3; template_config->load_mode=3;
} }
void on_config_global_local_save(){ void __on_config_global_local_save(){
yon_save_proceed(NULL,YON_CONFIG_BOTH,config_get_global_command,NULL); yon_save_proceed(NULL,YON_CONFIG_BOTH,config_get_global_command,NULL);
} }
void on_config_global_save(){ void __on_config_global_save(){
yon_save_proceed("global",YON_CONFIG_GLOBAL,config_get_global_command,NULL); yon_save_proceed("global",YON_CONFIG_GLOBAL,config_get_global_command,NULL);
} }
void on_config_local_save(){ void __on_config_local_save(){
yon_save_proceed("system",YON_CONFIG_LOCAL,config_get_global_command,NULL); yon_save_proceed("system",YON_CONFIG_LOCAL,config_get_global_command,NULL);
} }
void on_config_custom_save(){ void __on_config_custom_save(){
yon_save_proceed(NULL,YON_CONFIG_CUSTOM,config_get_custom_command,NULL); yon_save_proceed(NULL,YON_CONFIG_CUSTOM,config_get_custom_command,NULL);
} }
void yon_ubl_settings_window_set_standard_callbacks(template_main_window *widgets, char *get_global_command, char *get_local_command,char *get_custom_command, char *get_default_command, char *get_global_only_command, char *get_local_only_command){ void yon_ubl_settings_window_set_standard_callbacks(template_main_window *widgets, char *get_global_command, char *get_local_command,char *get_custom_command, char *get_default_command, char *get_global_only_command, char *get_local_only_command){
if (!yon_char_is_empty(get_global_command)){ if (!yon_char_is_empty(get_global_command)){
g_signal_connect(G_OBJECT(widgets->LoadGlobalMenuItem),"activate",G_CALLBACK(on_config_global_load),NULL); g_signal_connect(G_OBJECT(widgets->LoadGlobalMenuItem),"activate",G_CALLBACK(__on_config_global_load),NULL);
g_signal_connect(G_OBJECT(widgets->SaveGlobalMenuItem),"activate",G_CALLBACK(on_config_global_load),NULL); g_signal_connect(G_OBJECT(widgets->SaveGlobalMenuItem),"activate",G_CALLBACK(__on_config_global_load),NULL);
config_get_global_command = yon_char_new(get_global_command); config_get_global_command = yon_char_new(get_global_command);
config_set_global_command = yon_char_replace_single(get_global_command,"get","set"); config_set_global_command = yon_char_replace_single(get_global_command,"get","set");
} }
if (!yon_char_is_empty(get_global_command)){ if (!yon_char_is_empty(get_global_command)){
g_signal_connect(G_OBJECT(widgets->LoadLocalMenuItem),"activate",G_CALLBACK(on_config_local_load),NULL); g_signal_connect(G_OBJECT(widgets->LoadLocalMenuItem),"activate",G_CALLBACK(__on_config_local_load),NULL);
g_signal_connect(G_OBJECT(widgets->SaveLocalMenuItem),"activate",G_CALLBACK(on_config_local_save),NULL); g_signal_connect(G_OBJECT(widgets->SaveLocalMenuItem),"activate",G_CALLBACK(__on_config_local_save),NULL);
config_get_local_command = yon_char_new(get_local_command); config_get_local_command = yon_char_new(get_local_command);
config_set_local_command = yon_char_replace_single(get_local_command,"get","set"); config_set_local_command = yon_char_replace_single(get_local_command,"get","set");
} }
if (!yon_char_is_empty(get_global_command)){ if (!yon_char_is_empty(get_global_command)){
g_signal_connect(G_OBJECT(widgets->LoadCustomMenuItem),"activate",G_CALLBACK(on_config_custom_load),NULL); g_signal_connect(G_OBJECT(widgets->LoadCustomMenuItem),"activate",G_CALLBACK(__on_config_custom_load),NULL);
g_signal_connect(G_OBJECT(widgets->SaveCustomMenuItem),"activate",G_CALLBACK(on_config_custom_load),NULL); g_signal_connect(G_OBJECT(widgets->SaveCustomMenuItem),"activate",G_CALLBACK(__on_config_custom_load),NULL);
config_get_custom_command = yon_char_new(get_custom_command); config_get_custom_command = yon_char_new(get_custom_command);
config_set_custom_command = yon_char_replace_single(get_custom_command,"get","set"); config_set_custom_command = yon_char_replace_single(get_custom_command,"get","set");
} }

@ -6,7 +6,7 @@ template_app_info template_app_information;
static char *__yon_config_mode=NULL; static char *__yon_config_mode=NULL;
void config_init(); void __yon_config_init();
char *yon_char_get_localised_from_lib(char *string){ char *yon_char_get_localised_from_lib(char *string){
textdomain(template_ui_LocaleName); textdomain(template_ui_LocaleName);
@ -131,7 +131,6 @@ void on_about(GtkWidget *self, char *version_application){
//functions //functions
int yon_confirmation_dialog_call(GtkWidget *self,dialog_confirmation_data *data){ int yon_confirmation_dialog_call(GtkWidget *self,dialog_confirmation_data *data){
textdomain(template_ui_LocaleName); textdomain(template_ui_LocaleName);
GtkWidget *dialog = gtk_dialog_new_with_buttons(template_app_information.app_title,GTK_WINDOW(gtk_widget_get_toplevel(self)),GTK_DIALOG_USE_HEADER_BAR,CANCEL_LABEL,GTK_RESPONSE_CANCEL,ACCEPT_LABEL,GTK_RESPONSE_ACCEPT,NULL); GtkWidget *dialog = gtk_dialog_new_with_buttons(template_app_information.app_title,GTK_WINDOW(gtk_widget_get_toplevel(self)),GTK_DIALOG_USE_HEADER_BAR,CANCEL_LABEL,GTK_RESPONSE_CANCEL,ACCEPT_LABEL,GTK_RESPONSE_ACCEPT,NULL);
@ -149,7 +148,7 @@ int yon_confirmation_dialog_call(GtkWidget *self,dialog_confirmation_data *data)
gtk_style_context_add_class(gtk_widget_get_style_context((GtkWidget*)g_list_nth_data(list,1)),"marginright"); gtk_style_context_add_class(gtk_widget_get_style_context((GtkWidget*)g_list_nth_data(list,1)),"marginright");
g_list_free(list); g_list_free(list);
GtkWidget *header_label = gtk_label_new(template_app_information.app_title); GtkWidget *header_label = gtk_label_new(yon_char_is_empty(data->title)?template_app_information.app_title:data->title);
gtk_widget_show(header_label); gtk_widget_show(header_label);
PangoAttrList *attributes = pango_attr_list_new(); PangoAttrList *attributes = pango_attr_list_new();
PangoAttribute *boldAttr = pango_attr_weight_new(PANGO_WEIGHT_BOLD); PangoAttribute *boldAttr = pango_attr_weight_new(PANGO_WEIGHT_BOLD);
@ -192,6 +191,15 @@ int yon_confirmation_dialog_call(GtkWidget *self,dialog_confirmation_data *data)
return resp; return resp;
} }
dialog_confirmation_data *yon_confirmation_dialog_data_new(){
dialog_confirmation_data *data = new(dialog_confirmation_data);
data->action_text=NULL;
data->data=NULL;
data->function=NULL;
data->title=NULL;
return data;
}
char* yon_debug_output(char *pattern,char*text){ char* yon_debug_output(char *pattern,char*text){
if (template_config->debug_mode){ if (template_config->debug_mode){
printf(pattern,text); printf(pattern,text);
@ -221,7 +229,7 @@ int yon_ubl_connect_config(_template_config *config){
else else
replaces=1; replaces=1;
template_config = config; template_config = config;
config_init(); __yon_config_init();
return replaces; return replaces;
} }
@ -509,7 +517,7 @@ void yon_root_button_setup(template_main_window *widgets, config_str args, int a
textdomain(template_app_information.app_locale); textdomain(template_app_information.app_locale);
} }
void config_init(){ void __yon_config_init(){
template_config->always_open_documentation=0; template_config->always_open_documentation=0;
template_config->socket_id=-1; template_config->socket_id=-1;
template_config->save_socket_id=-1; template_config->save_socket_id=-1;

@ -160,6 +160,7 @@ typedef struct {
void (*function)(void*,void*); void (*function)(void*,void*);
void *data; void *data;
char *action_text; char *action_text;
char *title;
} dialog_confirmation_data; } dialog_confirmation_data;
typedef struct { typedef struct {
@ -178,6 +179,9 @@ filechooser_window *yon_file_chooser_window_new(GtkFileChooserAction action);
GtkResponseType yon_file_chooser_start(filechooser_window *window); GtkResponseType yon_file_chooser_start(filechooser_window *window);
void yon_file_chooser_set_button_label(char *label); void yon_file_chooser_set_button_label(char *label);
dialog_confirmation_data *yon_confirmation_dialog_data_new();
int yon_confirmation_dialog_call(GtkWidget *self,dialog_confirmation_data *data); int yon_confirmation_dialog_call(GtkWidget *self,dialog_confirmation_data *data);
/**yon_open_browser(GtkWidget *self, char *link) /**yon_open_browser(GtkWidget *self, char *link)

Loading…
Cancel
Save