Commit 02f2ad25 authored by Carlos Garcia Campos's avatar Carlos Garcia Campos

[shell] Call close_window when window is destroyed by delete-event

parent 91bc6390
...@@ -3397,31 +3397,18 @@ print_jobs_confirmation_dialog_response (GtkDialog *dialog, ...@@ -3397,31 +3397,18 @@ print_jobs_confirmation_dialog_response (GtkDialog *dialog,
} }
} }
static void static gboolean
ev_window_cmd_file_close_window (GtkAction *action, EvWindow *ev_window) ev_window_check_print_queue (EvWindow *ev_window)
{ {
GtkWidget *dialog; GtkWidget *dialog;
gchar *text, *markup; gchar *text, *markup;
gint n_print_jobs; gint n_print_jobs;
if (EV_WINDOW_IS_PRESENTATION (ev_window)) {
gint current_page;
/* Save current page */
current_page = ev_view_presentation_get_current_page (
EV_VIEW_PRESENTATION (ev_window->priv->presentation_view));
ev_document_model_set_page (ev_window->priv->model, current_page);
}
/* TODO: warn about form fields, and annots not saved */
n_print_jobs = ev_window->priv->print_queue ? n_print_jobs = ev_window->priv->print_queue ?
g_queue_get_length (ev_window->priv->print_queue) : 0; g_queue_get_length (ev_window->priv->print_queue) : 0;
if (n_print_jobs == 0) { if (n_print_jobs == 0)
gtk_widget_destroy (GTK_WIDGET (ev_window)); return FALSE;
return;
}
dialog = gtk_message_dialog_new (GTK_WINDOW (ev_window), dialog = gtk_message_dialog_new (GTK_WINDOW (ev_window),
GTK_DIALOG_MODAL, GTK_DIALOG_MODAL,
...@@ -3452,7 +3439,7 @@ ev_window_cmd_file_close_window (GtkAction *action, EvWindow *ev_window) ...@@ -3452,7 +3439,7 @@ ev_window_cmd_file_close_window (GtkAction *action, EvWindow *ev_window)
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s",
_("If you close the window, pending print " _("If you close the window, pending print "
"jobs will not be printed.")); "jobs will not be printed."));
gtk_dialog_add_buttons (GTK_DIALOG (dialog), gtk_dialog_add_buttons (GTK_DIALOG (dialog),
_("Cancel _print and Close"), _("Cancel _print and Close"),
GTK_RESPONSE_NO, GTK_RESPONSE_NO,
...@@ -3472,6 +3459,33 @@ ev_window_cmd_file_close_window (GtkAction *action, EvWindow *ev_window) ...@@ -3472,6 +3459,33 @@ ev_window_cmd_file_close_window (GtkAction *action, EvWindow *ev_window)
G_CALLBACK (print_jobs_confirmation_dialog_response), G_CALLBACK (print_jobs_confirmation_dialog_response),
ev_window); ev_window);
gtk_widget_show (dialog); gtk_widget_show (dialog);
return TRUE;
}
static gboolean
ev_window_close (EvWindow *ev_window)
{
if (EV_WINDOW_IS_PRESENTATION (ev_window)) {
gint current_page;
/* Save current page */
current_page = ev_view_presentation_get_current_page (
EV_VIEW_PRESENTATION (ev_window->priv->presentation_view));
ev_document_model_set_page (ev_window->priv->model, current_page);
}
if (ev_window_check_print_queue (ev_window))
return FALSE;
return TRUE;
}
static void
ev_window_cmd_file_close_window (GtkAction *action, EvWindow *ev_window)
{
if (ev_window_close (ev_window))
gtk_widget_destroy (GTK_WIDGET (ev_window));
} }
static void static void
...@@ -5257,6 +5271,13 @@ ev_window_key_press_event (GtkWidget *widget, ...@@ -5257,6 +5271,13 @@ ev_window_key_press_event (GtkWidget *widget,
return handled; return handled;
} }
static gboolean
ev_window_delete_event (GtkWidget *widget,
GdkEventAny *event)
{
return !ev_window_close (EV_WINDOW (widget));
}
static void static void
ev_window_class_init (EvWindowClass *ev_window_class) ev_window_class_init (EvWindowClass *ev_window_class)
{ {
...@@ -5266,6 +5287,7 @@ ev_window_class_init (EvWindowClass *ev_window_class) ...@@ -5266,6 +5287,7 @@ ev_window_class_init (EvWindowClass *ev_window_class)
g_object_class->dispose = ev_window_dispose; g_object_class->dispose = ev_window_dispose;
g_object_class->finalize = ev_window_finalize; g_object_class->finalize = ev_window_finalize;
widget_class->delete_event = ev_window_delete_event;
widget_class->key_press_event = ev_window_key_press_event; widget_class->key_press_event = ev_window_key_press_event;
widget_class->screen_changed = ev_window_screen_changed; widget_class->screen_changed = ev_window_screen_changed;
widget_class->window_state_event = ev_window_state_event; widget_class->window_state_event = ev_window_state_event;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment