Fixed Repository window file chooser

pull/118/head
parent a185cabd43
commit 19bc9bd2e0

@ -1042,15 +1042,38 @@ void on_repo_source_add(GtkWidget *, repo_add_window *window){
} }
void on_file_chooser_open(GtkWidget *, GtkEntry *target){ void on_file_chooser_open(GtkWidget *, GtkEntry *target){
GtkWidget *dialog = gtk_file_chooser_dialog_new(TITLE_LABEL,GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(target))),GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,CANCEL_LABEL,GTK_RESPONSE_CANCEL,ACCEPT_LABEL,GTK_RESPONSE_ACCEPT,NULL); filechooser_window *window = yon_file_chooser_window_new(GTK_FILE_CHOOSER_ACTION_OPEN);
int resp = gtk_dialog_run(GTK_DIALOG(dialog)); if (yon_file_chooser_start(window)){
if (resp == GTK_RESPONSE_ACCEPT){ char *file = window->last_success_selection;
char *file = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
if (!yon_char_is_empty(file)){ if (!yon_char_is_empty(file)){
gtk_entry_set_text(target,file); gtk_entry_set_text(target,file);
} }
} }
gtk_widget_destroy(dialog); free(window);
}
void on_repo_file_chooser_open(GtkWidget *, repo_add_window *window){
filechooser_window *fchwindow = NULL;
const char *source_type = gtk_combo_box_get_active_id(GTK_COMBO_BOX(window->RepoSourceCombo));
if (yon_char_is_empty(source_type)){
GtkFileFilter *filter = gtk_file_filter_new();
fchwindow = yon_file_chooser_window_new(GTK_FILE_CHOOSER_ACTION_OPEN);
gtk_file_filter_set_name(filter,"*ini");
gtk_file_filter_add_pattern(filter,"*ini");
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fchwindow->MainFileChooser),filter);
} else if (!strcmp(source_type,"file://")){
fchwindow = yon_file_chooser_window_new(GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fchwindow->ChooseFolderCheck),1);
} else return;
yon_gtk_window_setup(GTK_WINDOW(fchwindow->Window),GTK_WINDOW(window->Window),yon_char_get_localised_from_lib(CHOOSE_FILE_LABEL),icon_path,"file_chooser");
if (yon_file_chooser_start(fchwindow)){
char *file = fchwindow->last_success_selection;
if (!yon_char_is_empty(file)){
gtk_entry_set_text(GTK_ENTRY(window->RepoSourceEntry),file);
}
}
free(fchwindow);
} }
void on_password_hash_sensitiveness(GtkWidget *,password_window *window){ void on_password_hash_sensitiveness(GtkWidget *,password_window *window){
@ -1138,6 +1161,7 @@ void on_sign_check_toggled(GtkToggleButton *self, repo_add_window *window){
void on_repo_source_changed(GtkComboBox *self, repo_add_window *window){ void on_repo_source_changed(GtkComboBox *self, repo_add_window *window){
int active = gtk_combo_box_get_active(self); int active = gtk_combo_box_get_active(self);
gtk_entry_set_text(GTK_ENTRY(window->RepoSourceEntry),"");
if (active ==0 || active == 4){ if (active ==0 || active == 4){
gtk_widget_set_sensitive(window->RepoSourceButton,1); gtk_widget_set_sensitive(window->RepoSourceButton,1);
} else { } else {
@ -1177,7 +1201,7 @@ repo_add_window *yon_repo_add_window_new(){
window->sections = NULL; window->sections = NULL;
window->name=NULL; window->name=NULL;
g_signal_connect(G_OBJECT(window->RepoSourceButton),"clicked",G_CALLBACK(on_file_chooser_open),window->RepoSourceEntry); g_signal_connect(G_OBJECT(window->RepoSourceButton),"clicked",G_CALLBACK(on_repo_file_chooser_open),window);
g_signal_connect(G_OBJECT(window->RepoSourceAddButton),"clicked",G_CALLBACK(on_repo_source_add),window); g_signal_connect(G_OBJECT(window->RepoSourceAddButton),"clicked",G_CALLBACK(on_repo_source_add),window);
g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL);
g_signal_connect(G_OBJECT(window->UsageDefaultCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button_inversed),window->UsageEnableInsallCheck); g_signal_connect(G_OBJECT(window->UsageDefaultCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button_inversed),window->UsageEnableInsallCheck);

@ -391,5 +391,6 @@ void on_update_clicked(GtkWidget *, main_window *widgets);
void on_repo_move_up(GtkWidget *,main_window *widgets); void on_repo_move_up(GtkWidget *,main_window *widgets);
void on_repo_move_down(GtkWidget *,main_window *widgets); void on_repo_move_down(GtkWidget *,main_window *widgets);
void on_save_start(main_window *widgets, char* path); void on_save_start(main_window *widgets, char* path);
void on_repo_file_chooser_open(GtkWidget *, repo_add_window *window);
#endif #endif
Loading…
Cancel
Save