Close open document in cb_destroy

This commit is contained in:
Moritz Lipp 2012-03-07 01:11:18 +01:00
parent e73ca51d05
commit 593d8063fe
3 changed files with 10 additions and 4 deletions

View file

@ -18,8 +18,13 @@
#include "page_widget.h"
gboolean
cb_destroy(GtkWidget* UNUSED(widget), gpointer UNUSED(data))
cb_destroy(GtkWidget* UNUSED(widget), zathura_t* zathura)
{
if (zathura != NULL && zathura->document != NULL) {
zathura_document_free(zathura->document);
zathura->document = NULL;
}
gtk_main_quit();
return TRUE;
}

View file

@ -8,15 +8,16 @@
#include <girara/macros.h>
#include "document.h"
#include "zathura.h"
/**
* Quits the current zathura session
*
* @param widget The gtk window of zathura
* @param data NULL
* @param zathura Correspondending zathura session
* @return true if no error occured and the event has been handled
*/
gboolean cb_destroy(GtkWidget* widget, gpointer data);
gboolean cb_destroy(GtkWidget* widget, zathura_t* zathura);
/**
* This function gets called when the buffer of girara changes

View file

@ -225,7 +225,7 @@ zathura_init(int argc, char* argv[])
girara_statusbar_item_set_text(zathura->ui.session, zathura->ui.statusbar.file, "[No Name]");
/* signals */
g_signal_connect(G_OBJECT(zathura->ui.session->gtk.window), "destroy", G_CALLBACK(cb_destroy), NULL);
g_signal_connect(G_OBJECT(zathura->ui.session->gtk.window), "destroy", G_CALLBACK(cb_destroy), zathura);
/* save page padding */
zathura->global.page_padding = 1;