diff --git a/callbacks.c b/callbacks.c index 54f83e9..3487134 100644 --- a/callbacks.c +++ b/callbacks.c @@ -221,6 +221,17 @@ cb_file_monitor(GFileMonitor* monitor, GFile* file, GFile* UNUSED(other_file), G sc_reload(session, NULL, NULL, 0); } +static gboolean +password_dialog(gpointer data) +{ + zathura_password_dialog_info_t* dialog = data; + if (dialog != NULL) { + girara_dialog(dialog->zathura->ui.session, "Incorrect password. Enter password:", true, NULL, + (girara_callback_inputbar_activate_t) cb_password_dialog, dialog); + } + return FALSE; +} + bool cb_password_dialog(GtkEntry* entry, zathura_password_dialog_info_t* dialog) { @@ -245,18 +256,19 @@ cb_password_dialog(GtkEntry* entry, zathura_password_dialog_info_t* dialog) g_free(input); } - girara_dialog(dialog->zathura->ui.session, "Enter password:", true, NULL, - (girara_callback_inputbar_activate_t) cb_password_dialog, dialog); - + g_idle_add(password_dialog, dialog); return false; } /* try to open document again */ - document_open(dialog->zathura, dialog->path, input); + if (document_open(dialog->zathura, dialog->path, input) == false) { + g_idle_add(password_dialog, dialog); + } else { + g_free(dialog->path); + free(dialog); + } g_free(input); - g_free(dialog->path); - free(dialog); return true; diff --git a/shortcuts.c b/shortcuts.c index 9534c47..217886a 100644 --- a/shortcuts.c +++ b/shortcuts.c @@ -23,13 +23,15 @@ sc_abort(girara_session_t* session, girara_argument_t* UNUSED(argument), g_return_val_if_fail(session->global.data != NULL, false); zathura_t* zathura = session->global.data; - for (unsigned int page_id = 0; page_id < zathura->document->number_of_pages; ++page_id) { - zathura_page_t* page = zathura->document->pages[page_id]; - if (page == NULL) { - continue; - } + if (zathura->document != NULL) { + for (unsigned int page_id = 0; page_id < zathura->document->number_of_pages; ++page_id) { + zathura_page_t* page = zathura->document->pages[page_id]; + if (page == NULL) { + continue; + } - g_object_set(page->drawing_area, "draw-links", FALSE, NULL); + g_object_set(page->drawing_area, "draw-links", FALSE, NULL); + } } girara_mode_set(session, session->modes.normal);