WIP Configuration mode

pull/96/head
parent 1c65cfca78
commit cb5027f73b
No known key found for this signature in database
GPG Key ID: FF1D842BF4DDE92B

@ -17,6 +17,7 @@
<file>ubinstall-gtk-bootloader-user.glade</file>
<file>ubinstall-gtk-network-box.glade</file>
<file>ubinstall-gtk-advanced-box.glade</file>
<file>ubinstall-gtk-configuration-mode.glade</file>
</gresource>
<gresource prefix="/com/ublinux/css">
<file>ubinstall-gtk.css</file>

@ -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

@ -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;i<main_config.arg_size;i++){
if (!strcmp(main_config.arg_target[i],"socket-id")||!strcmp(main_config.arg_target[i],"socket-ext-id")||!strcmp(main_config.arg_target[i],"socket-trd-id")){ i++;
continue;
}
char *temp = yon_char_unite(argline," ", main_config.arg_target[i],NULL);
if(strcmp(argline,"")&&strcmp(argline,LocaleName))
free(argline);
argline=temp;
}
if (getuid()!=0){
argline = yon_char_unite("setsid /usr/bin/bash -c 'pkexec ",argline,"'; exit",NULL);
pthread_t thread_id;
pthread_create(&thread_id, NULL, (void *)on_root_get_root,argline);
gtk_widget_destroy(widgets->MainWindow);
}
}
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));
}

@ -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;

@ -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);
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);

@ -206,4 +206,6 @@
#define WRONG_IP_LABEL _("Ip adress is incorrect")
#define ENABLED_KERNEL_MISSING_LABEL _("No kernel was enabled")
#define ENABLED_KERNEL_MISSING_LABEL _("No kernel was enabled")
#define CONFIGURATION_MODE_TITLE_LABEL _("Choose installation configuration file")

@ -0,0 +1,184 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<interface domain="ubinstall-gtk">
<requires lib="gtk+" version="3.24"/>
<!-- interface-css-provider-path ubinstall-gtk.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.zoom-symbolic</property>
</object>
<object class="GtkWindow" id="MainWindow">
<property name="width-request">400</property>
<property name="height-request">250</property>
<property name="can-focus">False</property>
<property name="modal">True</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox" id="StatusBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox">
<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">15</property>
<property name="margin-bottom">15</property>
<property name="spacing">15</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="valign">start</property>
<property name="icon-name">com.ublinux.ubinstall-gtk</property>
<property name="icon_size">6</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Choose a path for configuration file</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="spacing">5</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">File position:</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="PathEntry">
<property name="visible">True</property>
<property name="can-focus">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="PathButton">
<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="thin"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
<child type="titlebar">
<object class="GtkHeaderBar">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child type="title">
<object class="GtkLabel" id="headerTopic">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-bottom">2</property>
<property name="label" translatable="yes">UBLinux installation</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</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>
</object>
</child>
<child>
<object class="GtkButton" id="ChooseButton">
<property name="label" translatable="yes">Choose</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
</object>
<packing>
<property name="pack-type">end</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</interface>
Loading…
Cancel
Save