Check for details request before print
Checks for details request before sending a job to a printer. Shows busy state indication (cursor + status field). This avoids printing to wrong printer (bug #576601).
This commit is contained in:
@ -379,6 +379,32 @@ get_toplevel (GtkWidget *widget)
|
|||||||
return GTK_WINDOW (toplevel);
|
return GTK_WINDOW (toplevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_busy_cursor (GtkPrintUnixDialog *dialog,
|
||||||
|
gboolean busy)
|
||||||
|
{
|
||||||
|
GtkWindow *toplevel;
|
||||||
|
GdkDisplay *display;
|
||||||
|
GdkCursor *cursor;
|
||||||
|
|
||||||
|
toplevel = get_toplevel (GTK_WIDGET (dialog));
|
||||||
|
if (!toplevel || !GTK_WIDGET_REALIZED (toplevel))
|
||||||
|
return;
|
||||||
|
|
||||||
|
display = gtk_widget_get_display (GTK_WIDGET (toplevel));
|
||||||
|
|
||||||
|
if (busy)
|
||||||
|
cursor = gdk_cursor_new_for_display (display, GDK_WATCH);
|
||||||
|
else
|
||||||
|
cursor = NULL;
|
||||||
|
|
||||||
|
gdk_window_set_cursor (GTK_WIDGET (toplevel)->window, cursor);
|
||||||
|
gdk_display_flush (display);
|
||||||
|
|
||||||
|
if (cursor)
|
||||||
|
gdk_cursor_unref (cursor);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
add_custom_button_to_dialog (GtkDialog *dialog,
|
add_custom_button_to_dialog (GtkDialog *dialog,
|
||||||
const gchar *mnemonic_label,
|
const gchar *mnemonic_label,
|
||||||
@ -418,9 +444,17 @@ error_dialogs (GtkPrintUnixDialog *print_dialog,
|
|||||||
{
|
{
|
||||||
printer = gtk_print_unix_dialog_get_selected_printer (print_dialog);
|
printer = gtk_print_unix_dialog_get_selected_printer (print_dialog);
|
||||||
|
|
||||||
|
if (printer != NULL)
|
||||||
|
{
|
||||||
|
if (priv->request_details_tag || !gtk_printer_is_accepting_jobs (printer))
|
||||||
|
{
|
||||||
|
g_signal_stop_emission_by_name (print_dialog, "response");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Shows overwrite confirmation dialog in the case of printing to file which
|
/* Shows overwrite confirmation dialog in the case of printing to file which
|
||||||
* already exists. */
|
* already exists. */
|
||||||
if (printer != NULL && gtk_printer_is_virtual (printer))
|
if (gtk_printer_is_virtual (printer))
|
||||||
{
|
{
|
||||||
option = gtk_printer_option_set_lookup (priv->options,
|
option = gtk_printer_option_set_lookup (priv->options,
|
||||||
"gtk-main-page-custom-input");
|
"gtk-main-page-custom-input");
|
||||||
@ -487,6 +521,7 @@ error_dialogs (GtkPrintUnixDialog *print_dialog,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -570,6 +605,13 @@ disconnect_printer_details_request (GtkPrintUnixDialog *dialog)
|
|||||||
g_signal_handler_disconnect (priv->request_details_printer,
|
g_signal_handler_disconnect (priv->request_details_printer,
|
||||||
priv->request_details_tag);
|
priv->request_details_tag);
|
||||||
priv->request_details_tag = 0;
|
priv->request_details_tag = 0;
|
||||||
|
set_busy_cursor (dialog, FALSE);
|
||||||
|
gtk_list_store_set (GTK_LIST_STORE (priv->printer_list),
|
||||||
|
g_object_get_data (G_OBJECT (priv->request_details_printer),
|
||||||
|
"gtk-print-tree-iter"),
|
||||||
|
PRINTER_LIST_COL_STATE,
|
||||||
|
gtk_printer_get_state_message (priv->request_details_printer),
|
||||||
|
-1);
|
||||||
g_object_unref (priv->request_details_printer);
|
g_object_unref (priv->request_details_printer);
|
||||||
priv->request_details_printer = NULL;
|
priv->request_details_printer = NULL;
|
||||||
}
|
}
|
||||||
@ -1806,6 +1848,11 @@ selected_printer_changed (GtkTreeSelection *selection,
|
|||||||
/* take the reference */
|
/* take the reference */
|
||||||
priv->request_details_printer = printer;
|
priv->request_details_printer = printer;
|
||||||
gtk_printer_request_details (printer);
|
gtk_printer_request_details (printer);
|
||||||
|
set_busy_cursor (dialog, TRUE);
|
||||||
|
gtk_list_store_set (GTK_LIST_STORE (priv->printer_list),
|
||||||
|
g_object_get_data (G_OBJECT (printer), "gtk-print-tree-iter"),
|
||||||
|
PRINTER_LIST_COL_STATE, _("Getting printer information..."),
|
||||||
|
-1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user