Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

codenav: Keep "Go to file" dialog open after denying creation of file that wasn't found #1329

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions codenav/src/goto_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ create_dialog(GtkWidget **dialog, GtkTreeModel *completion_model)
GtkEntryCompletion *completion;

*dialog = gtk_dialog_new_with_buttons(_("Go to File..."), GTK_WINDOW(geany->main_widgets->window),
GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);
GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);

gtk_dialog_set_default_response(GTK_DIALOG(*dialog), GTK_RESPONSE_ACCEPT);

Expand Down Expand Up @@ -286,6 +286,8 @@ menu_item_activate(guint key_id)

/* Create the user dialog and get response */
dialog_entry = create_dialog(&dialog, completion_list);

_show_dialog:
response = gtk_dialog_run(GTK_DIALOG(dialog));

/* Filename */
Expand All @@ -306,12 +308,20 @@ menu_item_activate(guint key_id)
GTK_BUTTONS_OK_CANCEL,
_("%s not found, create it?"), chosen_file);
gtk_window_set_title(GTK_WINDOW(dialog_new), "Geany");
if(gtk_dialog_run(GTK_DIALOG(dialog_new)) == GTK_RESPONSE_OK)
response = gtk_dialog_run(GTK_DIALOG(dialog_new));

if (response == GTK_RESPONSE_OK)
{
document_new_file(chosen_path, current_doc->file_type, NULL);
document_set_text_changed(document_get_current(), TRUE);
}

gtk_widget_destroy(dialog_new);

/* File wasn't found and user denied creating it,
* go back to the initial "Go to file" dialog. */
if (response != GTK_RESPONSE_OK)
goto _show_dialog;
}
else
document_open_file(chosen_path, FALSE, NULL, NULL);
Expand Down