parent
7ea298513c
commit
80827ec0ad
@ -0,0 +1,95 @@
|
|||||||
|
#include "ubl-settings-manager.h"
|
||||||
|
|
||||||
|
struct config_chooser {
|
||||||
|
GtkWidget *RootBox;
|
||||||
|
GtkWidget *PathEntry;
|
||||||
|
GtkWidget *PathButton;
|
||||||
|
GtkWidget *ClearButton;
|
||||||
|
};
|
||||||
|
|
||||||
|
void on_config_destroy(GtkWidget *, struct config_chooser *parameter);
|
||||||
|
void on_config_destroy(GtkWidget *, struct config_chooser *parameter){
|
||||||
|
free(parameter);
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_config_chooser_opened(GtkWidget *, struct config_chooser *parameter);
|
||||||
|
void on_config_chooser_opened(GtkWidget *, struct config_chooser *parameter){
|
||||||
|
filechooser_window *window = yon_file_chooser_window_new(GTK_FILE_CHOOSER_ACTION_SAVE);
|
||||||
|
yon_gtk_window_setup(GTK_WINDOW(window->Window),NULL,CHOOSE_FILE_LABEL,icon_path,"file_chooser");
|
||||||
|
GtkFileFilter *ini_filter = gtk_file_filter_new();
|
||||||
|
GtkFileFilter *yaml_filter = gtk_file_filter_new();
|
||||||
|
GtkFileFilter *json_filter = gtk_file_filter_new();
|
||||||
|
gtk_file_filter_add_pattern(ini_filter,"*.ini");
|
||||||
|
gtk_file_filter_set_name(ini_filter,"*.ini");
|
||||||
|
gtk_file_filter_add_pattern(yaml_filter,"*.yaml");
|
||||||
|
gtk_file_filter_set_name(yaml_filter,"*.yaml");
|
||||||
|
gtk_file_filter_add_pattern(json_filter,"*.json");
|
||||||
|
gtk_file_filter_set_name(json_filter,"*.json");
|
||||||
|
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(window->MainFileChooser),ini_filter);
|
||||||
|
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(window->MainFileChooser),yaml_filter);
|
||||||
|
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(window->MainFileChooser),json_filter);
|
||||||
|
if (yon_file_chooser_start(window) != GTK_RESPONSE_CANCEL){
|
||||||
|
char *full_name = NULL;
|
||||||
|
gtk_entry_set_text(GTK_ENTRY(parameter->PathEntry),window->last_success_selection);
|
||||||
|
GtkFileFilter *cur_filter = gtk_file_chooser_get_filter(GTK_FILE_CHOOSER(window->MainFileChooser));
|
||||||
|
|
||||||
|
if ((cur_filter == ini_filter&&!strstr(window->last_success_selection,".ini"))){
|
||||||
|
full_name = yon_char_append(window->last_success_selection,".ini");
|
||||||
|
} else if ((cur_filter == yaml_filter&&!strstr(window->last_success_selection,".yaml"))){
|
||||||
|
full_name = yon_char_append(window->last_success_selection,".yaml");
|
||||||
|
} else if ((cur_filter == json_filter&&!strstr(window->last_success_selection,".json"))){
|
||||||
|
full_name = yon_char_append(window->last_success_selection,".json");
|
||||||
|
} else {
|
||||||
|
full_name = yon_char_new(window->last_success_selection);
|
||||||
|
}
|
||||||
|
if (access(full_name,F_OK)){
|
||||||
|
yon_launch(ubconfig_file_create(full_name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_config_chooser_clear(GtkWidget *,struct config_chooser *parameter);
|
||||||
|
void on_config_chooser_clear(GtkWidget *,struct config_chooser *parameter){
|
||||||
|
yon_window_config_erase_instant_parameter("file",yon_configuration_window_section);
|
||||||
|
gtk_entry_set_text(GTK_ENTRY(parameter->PathEntry),"");
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkWidget *yon_config_chooser_new( char *){
|
||||||
|
struct config_chooser *parameter = malloc(sizeof(struct config_chooser));
|
||||||
|
GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_config);
|
||||||
|
|
||||||
|
parameter->RootBox = yon_gtk_builder_get_widget(builder,"RootBox");
|
||||||
|
parameter->PathEntry = yon_gtk_builder_get_widget(builder,"PathEntry");
|
||||||
|
parameter->PathButton = yon_gtk_builder_get_widget(builder,"PathButton");
|
||||||
|
parameter->ClearButton = yon_gtk_builder_get_widget(builder,"ClearButton");
|
||||||
|
|
||||||
|
g_object_set_data(G_OBJECT(parameter->RootBox),"data_struct",parameter);
|
||||||
|
g_signal_connect(G_OBJECT(parameter->PathButton),"clicked",G_CALLBACK(on_config_chooser_opened),parameter);
|
||||||
|
g_signal_connect(G_OBJECT(parameter->ClearButton),"clicked",G_CALLBACK(on_config_chooser_clear),parameter);
|
||||||
|
g_signal_connect(G_OBJECT(parameter->RootBox),"destroy",G_CALLBACK(on_config_destroy),parameter);
|
||||||
|
return parameter->RootBox;
|
||||||
|
}
|
||||||
|
|
||||||
|
void yon_config_chooser_update(GtkWidget *root){
|
||||||
|
struct config_chooser *parameter = g_object_get_data(G_OBJECT(root),"data_struct");
|
||||||
|
char *target;
|
||||||
|
if (!yon_window_config_get_parameter(yon_configuration_window_section,"file",&target,YON_TYPE_STRING)){
|
||||||
|
target = NULL;
|
||||||
|
}
|
||||||
|
if (target){
|
||||||
|
gtk_entry_set_text(GTK_ENTRY(parameter->PathEntry),target);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void yon_config_chooser_save(GtkWidget *root){
|
||||||
|
struct config_chooser *parameter = g_object_get_data(G_OBJECT(root),"data_struct");
|
||||||
|
char *path = (char*)gtk_entry_get_text(GTK_ENTRY(parameter->PathEntry));
|
||||||
|
if (!yon_char_is_empty(path)){
|
||||||
|
yon_window_config_add_instant_parameter("file",yon_configuration_window_section,path,YON_TYPE_STRING);
|
||||||
|
yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(main_config.widgets->StatusBox),"config_mode",CONFIG_MODE_LABEL(path),BACKGROUND_IMAGE_INFO_TYPE);
|
||||||
|
} else {
|
||||||
|
yon_window_config_erase_instant_parameter("file",yon_configuration_window_section);
|
||||||
|
yon_ubl_status_box_despawn_infinite(GTK_CONTAINER(main_config.widgets->StatusBox));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,124 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- Generated with glade 3.40.0 -->
|
||||||
|
<interface domain="ubl-settings-manager">
|
||||||
|
<requires lib="gtk+" version="3.24"/>
|
||||||
|
<!-- interface-css-provider-path ubl-settings-manager.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="GtkFrame" id="RootBox">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="label-xalign">0</property>
|
||||||
|
<property name="shadow-type">in</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkAlignment">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="top-padding">5</property>
|
||||||
|
<property name="bottom-padding">5</property>
|
||||||
|
<property name="left-padding">5</property>
|
||||||
|
<property name="right-padding">5</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<property name="spacing">15</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="label" translatable="yes">Select the configuration file that the applications will use to save the settings. The selected file will be sent to the applications as an argument.</property>
|
||||||
|
<property name="wrap">True</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">Configuration file:</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="ClearButton">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">True</property>
|
||||||
|
<property name="receives-default">True</property>
|
||||||
|
<property name="image">image2</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>
|
||||||
|
<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">3</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child type="label_item">
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<object class="GtkImage" id="image2">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="icon-name">com.ublinux.libublsettingsui-gtk3.trash-symbolic</property>
|
||||||
|
</object>
|
||||||
|
</interface>
|
||||||
Loading…
Reference in new issue