diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index c2258c3..e4dcc64 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -78,6 +78,7 @@ endif() set(SOURCE_FILES ubl-settings-update.c + ubl-settings-update-save.c ubl-settings-update-web.c ubl-settings-update-mirror.c ubl-settings-update-repo.c diff --git a/source/ubl-settings-update-repo.c b/source/ubl-settings-update-repo.c index fc297d5..67a1fd2 100644 --- a/source/ubl-settings-update-repo.c +++ b/source/ubl-settings-update-repo.c @@ -20,9 +20,13 @@ void on_repo_move_up(GtkWidget *,main_window *widgets){ int size; config_str params = yon_config_get_all_by_key(REPOSITORY_search,&size); for (int i=0;iAutoUpdateCheck){ @@ -187,47 +202,6 @@ void on_toggle_button_toggled(GtkWidget *self, main_window *widgets){ } } -void yon_load_proceed(YON_CONFIG_TYPE type){ - if (type!=YON_CONFIG_CUSTOM){ - yon_config_clean(); - if (!yon_char_is_empty(config_get_default_command)) - yon_config_load_config(YON_CONFIG_DEFAULT,config_get_default_command,NULL); - } - if (type==YON_CONFIG_GLOBAL){ - yon_config_load_config(type,config_get_command("global"),NULL); - } else if (type==YON_CONFIG_LOCAL){ - yon_config_load_config(type,config_get_command("system"),NULL); - } else if (type==YON_CONFIG_CUSTOM){ - 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); - textdomain(LocaleName); - gtk_window_set_icon_name(GTK_WINDOW(dialog),"com.ublinux.ubl-settings-services"); - gtk_window_set_title(GTK_WINDOW(dialog),TITLE_LABEL); - GtkFileFilter *filter = gtk_file_filter_new(); - gtk_file_filter_add_pattern(filter,"*.ini"); - gtk_file_filter_set_name(filter, "*.ini"); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog),filter); - gtk_widget_show(dialog); - int response = gtk_dialog_run(GTK_DIALOG(dialog)); - if (response == GTK_RESPONSE_ACCEPT){ - char *file = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); - if (!yon_char_is_empty(file)){ - path=file; - } - yon_config_clean(); - if (!yon_char_is_empty(config_get_default_command)) - yon_config_load_config(YON_CONFIG_DEFAULT,config_get_default_command,NULL); - char *command = config_get_command(path); - yon_config_load_config(type,command,NULL); - gtk_widget_destroy(dialog); - } else { - gtk_widget_destroy(dialog); - } - } - yon_config_set_ignore(AUTOUPDATE_timestamp); -} - void yon_interface_update(main_window *widgets){ gtk_list_store_clear(widgets->ReposList); gtk_list_store_clear(widgets->MirrorList); @@ -561,50 +535,6 @@ char *on_save_repos(main_window *widgets){ } -void on_config_save(GtkWidget *, main_window *){ - main_config.save_config=YON_CONFIG_BOTH; - yon_save_proceed(NULL,YON_CONFIG_BOTH,config_get_command("global"),NULL); -} - -void on_config_local_save(GtkWidget *, main_window *){ - main_config.save_config=YON_CONFIG_LOCAL; - yon_save_proceed("system",YON_CONFIG_LOCAL,config_get_command("system"),NULL); - -} - -void on_config_global_save(GtkWidget *, main_window *){ - main_config.save_config=YON_CONFIG_GLOBAL; - yon_save_proceed("global",YON_CONFIG_GLOBAL,config_get_command("global"),NULL); - -} - -void on_config_custom_save(GtkWidget *, main_window *){ - main_config.save_config=YON_CONFIG_LOCAL; - template_saving_window *window = yon_save_proceed(NULL,YON_CONFIG_CUSTOM,config_get_command("system"),NULL); - if (window){}; -} - - -void on_config_local_load(GtkWidget *,main_window *widgets){ - yon_load_proceed(YON_CONFIG_LOCAL); - yon_ubl_status_box_render(yon_char_get_localised_from_lib(LOCAL_LOAD_SUCCESS_LABEL),BACKGROUND_IMAGE_SUCCESS_TYPE); - main_config.load_mode=YON_CONFIG_LOCAL; - yon_interface_update(widgets); -} - -void on_config_global_load(GtkWidget *,main_window *widgets){ - yon_load_proceed(YON_CONFIG_GLOBAL); - yon_ubl_status_box_render(yon_char_get_localised_from_lib(GLOBAL_LOAD_SUCCESS_LABEL),BACKGROUND_IMAGE_SUCCESS_TYPE); - main_config.load_mode=YON_CONFIG_GLOBAL; - yon_interface_update(widgets); -} - -void on_config_custom_load(GtkWidget *,main_window *widgets){ - yon_load_proceed(YON_CONFIG_CUSTOM); - yon_ubl_status_box_render(yon_char_get_localised_from_lib(LOCAL_LOAD_SUCCESS_LABEL),BACKGROUND_IMAGE_SUCCESS_TYPE); - main_config.load_mode=YON_CONFIG_CUSTOM; - yon_interface_update(widgets); -} void on_toggle_cell_toggled(GtkCellRenderer *self,char *path, main_window *widgets){ GtkListStore *target = NULL; @@ -1484,6 +1414,7 @@ void yon_main_window_complete(main_window *widgets){ } yon_root_button_setup((template_main_window*)widgets,main_config.launch_arguments,main_config.launch_size); yon_save_window_set_postsave_function(on_save_done,widgets); + yon_save_window_set_presave_function(on_save_start,widgets); } int main(int argc, char *argv[]){ diff --git a/source/ubl-settings-update.h b/source/ubl-settings-update.h index 8f9e0a6..e9ee3a3 100644 --- a/source/ubl-settings-update.h +++ b/source/ubl-settings-update.h @@ -93,7 +93,7 @@ #define AUTOUPDATE_timestamp "AUTOUPDATE[timestamp]" #define AUTOUPDATE_timestamp_command "ubconfig --source global get [update] AUTOUPDATE[timestamp]" - +#define config_presave_clean_command(target_config) yon_char_unite("ubconfig ",!yon_char_is_empty(target_config)?"--target ":"",!yon_char_is_empty(target_config)?target_config:""," remove [update] REPOSITORY[*]",NULL) typedef char* string; @@ -108,6 +108,8 @@ typedef struct { int launch_size; } config; +extern config main_config; + typedef struct { template_window_fields GtkWidget *AutoUpdateCheck; @@ -388,5 +390,6 @@ void on_password_hash_sensitiveness(GtkWidget *,password_window *window); void on_update_clicked(GtkWidget *, main_window *widgets); void on_repo_move_up(GtkWidget *,main_window *widgets); void on_repo_move_down(GtkWidget *,main_window *widgets); +void on_save_start(main_window *widgets, char* path); #endif \ No newline at end of file