parent
1c65cfca78
commit
cb5027f73b
@ -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));
|
||||
}
|
||||
|
||||
@ -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…
Reference in new issue