Filechooser update

pull/48/head
parent 54ce72a128
commit b99f674d78
No known key found for this signature in database
GPG Key ID: FF1D842BF4DDE92B

@ -70,6 +70,23 @@ void on_file_chooser_exit(GtkWidget *, filechooser_window *){
__yon_filechooser_window = NULL;
}
void on_file_chooser_check_root(GtkWidget *, filechooser_window *window){
char *cur_path = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(window->MainFileChooser));
if (!yon_char_is_empty(window->root)&&!strstr(cur_path,window->root)) gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(window->MainFileChooser),window->root);
}
void yon_file_chooser_set_root(filechooser_window *window, char *root_path){
window->root = yon_char_new(root_path);
g_signal_connect(G_OBJECT(window->MainFileChooser),"current-folder-changed",G_CALLBACK(on_file_chooser_check_root),window);
}
void yon_file_chooser_remove_root(filechooser_window *window, char *root_path){
if (!yon_char_is_empty(window->root)) free(window->root);
window->root=NULL;
g_signal_handlers_disconnect_by_func(G_OBJECT(window->MainFileChooser),G_CALLBACK(on_file_chooser_check_root),window);
}
filechooser_window *yon_file_chooser_window_new(GtkFileChooserAction action){
if (!__yon_filechooser_window){
filechooser_window *window = malloc(sizeof(filechooser_window));
@ -84,6 +101,8 @@ filechooser_window *yon_file_chooser_window_new(GtkFileChooserAction action){
window->ChooseFolderCheck = yon_gtk_builder_get_widget(builder,"ChooseFolderCheck");
window->last_any_selection=NULL;
window->last_success_selection=NULL;
window->root=NULL;
g_signal_connect(G_OBJECT(window->ChooseFolderCheck),"toggled",G_CALLBACK(on_file_chooser_selected),window);
g_signal_connect(G_OBJECT(window->MainFileChooser),"selection-changed",G_CALLBACK(on_file_chooser_selected),window);
g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_file_chooser_cancel),window);
g_signal_connect(G_OBJECT(window->SaveButton),"clicked",G_CALLBACK(on_file_chooser_accept),window);

@ -173,11 +173,14 @@ typedef struct {
char *last_success_selection;
char *last_any_selection;
GtkResponseType responce;
char *root;
} filechooser_window;
filechooser_window *yon_file_chooser_window_new(GtkFileChooserAction action);
GtkResponseType yon_file_chooser_start(filechooser_window *window);
void yon_file_chooser_set_button_label(char *label);
void yon_file_chooser_set_root(filechooser_window *window, char *root_path);
void yon_file_chooser_remove_root(filechooser_window *window, char *root_path);
dialog_confirmation_data *yon_confirmation_dialog_data_new();

Loading…
Cancel
Save