diff --git a/gresource.xml b/gresource.xml index 0ed7fcf..319ad25 100644 --- a/gresource.xml +++ b/gresource.xml @@ -17,6 +17,7 @@ ubinstall-gtk-bootloader-user.glade ubinstall-gtk-network-box.glade ubinstall-gtk-advanced-box.glade + ubinstall-gtk-configuration-mode.glade ubinstall-gtk.css diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 990ee99..4256ed5 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -74,6 +74,7 @@ set(DEPENDFILES ../ubinstall-gtk-bootloader-user.glade ../ubinstall-gtk-network-box.glade ../ubinstall-gtk-advanced-box.glade + ../ubinstall-gtk-configuration-mode.glade ../gresource.xml ../ubinstall-gtk.css ../modules.csv diff --git a/source/ubinstall-gtk-configuration-mode.c b/source/ubinstall-gtk-configuration-mode.c index d0b0e8f..79fce71 100644 --- a/source/ubinstall-gtk-configuration-mode.c +++ b/source/ubinstall-gtk-configuration-mode.c @@ -1,25 +1,64 @@ #include "ubinstall-gtk.h" +void configuration_mode_accept(GtkWidget *,configuration_window *window){ + const char *path = gtk_entry_get_text(GTK_ENTRY(window->PathEntry)); + if (yon_char_is_empty(path)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),_EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->PathEntry); + return; + } + if (!yon_char_is_empty(main_config.config_save_path)) free(main_config.config_save_path); + main_config.config_save_path = yon_char_new(path); + gtk_widget_destroy(window->Window); +} + +void on_path_choose(GtkWidget *,configuration_window *window){ + filechooser_window *dialog = yon_file_chooser_window_new(GTK_FILE_CHOOSER_ACTION_SAVE); + yon_gtk_window_setup(GTK_WINDOW(dialog->Window),GTK_WINDOW(window->Window),CONFIGURATION_MODE_TITLE_LABEL,icon_path,"filechooser_window"); + 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->MainFileChooser),filter); + if (yon_file_chooser_start(dialog)==GTK_RESPONSE_APPLY){ + gtk_entry_set_text(GTK_ENTRY(window->PathEntry),dialog->last_success_selection); + free(dialog); + } +} + +void on_configuration_exit(GtkWidget *,configuration_window *window){ + main_window *widgets = g_object_get_data(G_OBJECT(window->Window),"widgets"); + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widgets->ConfigurationModeMenuItem),0); + gtk_widget_destroy(window->Window); +} + void on_configuration_mode_switch(GtkWidget *self,main_window *widgets){ - if (getuid()) { - if (main_config.configure_mode==1){ - char *argline = LocaleName; - for (int i=1;iMainWindow); - } - } + if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(self))){ + GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_configuration_mode); + configuration_window *window = malloc(sizeof(configuration_window)); + window->Window = yon_gtk_builder_get_widget(builder,"MainWindow"); + window->StatusBox = yon_gtk_builder_get_widget(builder,"StatusBox"); + window->PathEntry = yon_gtk_builder_get_widget(builder,"PathEntry"); + window->PathButton = yon_gtk_builder_get_widget(builder,"PathButton"); + window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); + window->ChooseButton = yon_gtk_builder_get_widget(builder,"ChooseButton"); + + g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_configuration_exit),window); + g_signal_connect(G_OBJECT(window->Window),"destroy",G_CALLBACK(gtk_main_quit),NULL); + g_signal_connect(G_OBJECT(window->ChooseButton),"clicked",G_CALLBACK(configuration_mode_accept),window); + g_signal_connect(G_OBJECT(window->PathButton),"clicked",G_CALLBACK(on_path_choose),window); + g_object_set_data(G_OBJECT(window->Window),"widgets",widgets); + yon_gtk_window_setup(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->MainWindow),CONFIGURATION_MODE_TITLE_LABEL,icon_path,"configuration_window"); + + if (!yon_char_is_empty(main_config.config_save_path)) gtk_entry_set_text(GTK_ENTRY(window->PathEntry),main_config.config_save_path); + gtk_widget_show(window->Window); + gtk_main(); + + main_config.configure_mode = 1; + gtk_widget_destroy(window->Window); + return; + + } else { + main_config.configure_mode = 0; + } - main_config.configure_mode = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(self)); } diff --git a/source/ubinstall-gtk-page-switch.c b/source/ubinstall-gtk-page-switch.c index 81cf723..e8a4a38 100644 --- a/source/ubinstall-gtk-page-switch.c +++ b/source/ubinstall-gtk-page-switch.c @@ -20,10 +20,10 @@ enum YON_PAGES yon_page_get_next(main_window *widgets, enum YON_PAGES page){ case YON_PAGE_STARTUP: return YON_PAGE_BOOTLOADER; break; case YON_PAGE_BOOTLOADER: return YON_PAGE_NETWORK; break; case YON_PAGE_NETWORK: return main_config.configure_mode? YON_PAGE_CONFIGURE_END : YON_PAGE_INSTALLATION; break; - case YON_PAGE_INSTALL_COMMON: return main_config.configure_mode?YON_PAGE_KERNEL:YON_PAGE_OS_COMPONENTS; break; - case YON_PAGE_INSTALL_SEPARATE: return main_config.configure_mode?YON_PAGE_KERNEL:YON_PAGE_OS_COMPONENTS; break; - case YON_PAGE_INSTALL_SAME_PARTITION: return main_config.configure_mode?YON_PAGE_KERNEL:YON_PAGE_OS_COMPONENTS; break; - case YON_PAGE_INSTALL_ADVANCED: return main_config.configure_mode?YON_PAGE_KERNEL:YON_PAGE_OS_COMPONENTS; break; + case YON_PAGE_INSTALL_COMMON: return YON_PAGE_OS_COMPONENTS; break; + case YON_PAGE_INSTALL_SEPARATE: return YON_PAGE_OS_COMPONENTS; break; + case YON_PAGE_INSTALL_SAME_PARTITION: return YON_PAGE_OS_COMPONENTS; break; + case YON_PAGE_INSTALL_ADVANCED: return YON_PAGE_OS_COMPONENTS; break; case YON_PAGE_INSTALL_RECOVERY: return yon_recovery_get_next(widgets); break; case YON_PAGE_RECOVERY_GRUB_INSTALL: return main_config.configure_mode?YON_PAGE_INSTALLATION:YON_PAGE_INSTALLATION_BEGIN; break; case YON_PAGE_RECOVERY_GRUB_UPDATE: return main_config.configure_mode?YON_PAGE_INSTALLATION:YON_PAGE_INSTALLATION_BEGIN; break; diff --git a/source/ubinstall-gtk.h b/source/ubinstall-gtk.h index b192da8..d3c25e0 100755 --- a/source/ubinstall-gtk.h +++ b/source/ubinstall-gtk.h @@ -34,6 +34,7 @@ #define glade_path_service "/com/ublinux/ui/ubinstall-gtk-service-window.glade" #define glade_path_bootloader_user "/com/ublinux/ui/ubinstall-gtk-bootloader-user.glade" #define glade_path_advanced_part "/com/ublinux/ui/ubinstall-gtk-advanced-box.glade" +#define glade_path_configuration_mode "/com/ublinux/ui/ubinstall-gtk-configuration-mode.glade" #define CssPath "/com/ublinux/css/ubinstall-gtk.css" #define config_path yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",LocaleName,"/",LocaleName,".conf",NULL) @@ -869,6 +870,15 @@ typedef struct { char *prev_name; } bootloader_user_window; +typedef struct { + GtkWidget *Window; + GtkWidget *StatusBox; + GtkWidget *PathEntry; + GtkWidget *PathButton; + GtkWidget *CancelButton; + GtkWidget *ChooseButton; +} configuration_window; + void config_init(); main_window *yon_main_window_complete(); ubinstall_language_window *yon_ubinstall_language_new(); @@ -937,7 +947,7 @@ void on_config_global_local_save(GtkWidget *,main_window *widgets); void on_config_custom_load(GtkWidget *,main_window *); void on_config_global_load(GtkWidget *,main_window *); void on_config_local_load(GtkWidget *,main_window *widgets); -// void yon_save_proceed(char *path, YON_CONFIG_TYPE type); +void yon_config_save_proceed(char *path, YON_CONFIG_TYPE type); void on_page_next_clicked(GtkWidget *, main_window *widgets); void on_page_prev_clicked(GtkWidget *, main_window *widgets); void yon_load_proceed(YON_CONFIG_TYPE type); @@ -1052,4 +1062,7 @@ void yon_layout_build(char *key, GHashTable *value, main_window *widgets); void yon_os_row_setup(os_row *row, char *name, char *version,char *tags, char *description); os_row *yon_os_row_new(); void yon_quick_install(GtkWidget *, main_window *widgets); -void on_keyboard_layout_chosen(GtkCellRenderer *self, gchar *path, main_window *widgets); \ No newline at end of file +void on_keyboard_layout_chosen(GtkCellRenderer *self, gchar *path, main_window *widgets); +void configuration_mode_accept(GtkWidget *,configuration_window *window); +void on_path_choose(GtkWidget *,configuration_window *window); +void on_configuration_exit(GtkWidget *,configuration_window *window); \ No newline at end of file diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 65e5c25..413261d 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -206,4 +206,6 @@ #define WRONG_IP_LABEL _("Ip adress is incorrect") -#define ENABLED_KERNEL_MISSING_LABEL _("No kernel was enabled") \ No newline at end of file +#define ENABLED_KERNEL_MISSING_LABEL _("No kernel was enabled") + +#define CONFIGURATION_MODE_TITLE_LABEL _("Choose installation configuration file") \ No newline at end of file diff --git a/ubinstall-gtk-configuration-mode.glade b/ubinstall-gtk-configuration-mode.glade new file mode 100644 index 0000000..f4e73df --- /dev/null +++ b/ubinstall-gtk-configuration-mode.glade @@ -0,0 +1,184 @@ + + + + + + + True + False + com.ublinux.libublsettingsui-gtk3.zoom-symbolic + + + 400 + 250 + False + True + + + True + False + vertical + + + True + False + vertical + + + + + + False + True + 1 + + + + + True + False + 5 + 5 + 15 + 15 + 15 + + + True + False + start + com.ublinux.ubinstall-gtk + 6 + + + False + True + 0 + + + + + True + False + vertical + 5 + + + True + False + Choose a path for configuration file + 0 + + + False + True + 0 + + + + + True + False + 5 + + + True + False + File position: + 0 + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + True + True + True + image1 + + + + False + True + 2 + + + + + False + True + 1 + + + + + True + True + 1 + + + + + False + True + 2 + + + + + + + True + False + + + True + False + 2 + UBLinux installation + + + + + + + + Cancel + True + True + True + + + + + Choose + True + True + True + + + end + 1 + + + + + +