diff options
author | Marek Kasik <mkasik@redhat.com> | 2009-08-29 21:32:01 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2009-08-29 21:32:01 -0400 |
commit | 3b336186ee4d55799f4290c672d6bccd787c70fa (patch) | |
tree | 57e64e3d5882b5193407d88050f1318746fac613 /modules | |
parent | 2d8b8e054a76901aa625725bac8b7610ff927a77 (diff) | |
download | gtk+-3b336186ee4d55799f4290c672d6bccd787c70fa.tar.gz |
Add CUPS events as soon as possible when printing
CUPS events are added in prepare part of the main loop. These
events are initialized before their addition (#434318, #586466).
Diffstat (limited to 'modules')
-rw-r--r-- | modules/printbackends/cups/gtkprintbackendcups.c | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/modules/printbackends/cups/gtkprintbackendcups.c b/modules/printbackends/cups/gtkprintbackendcups.c index f84c920c17..e930980cff 100644 --- a/modules/printbackends/cups/gtkprintbackendcups.c +++ b/modules/printbackends/cups/gtkprintbackendcups.c @@ -803,15 +803,11 @@ request_password (gpointer data) return FALSE; } -static gboolean -cups_dispatch_watch_check (GSource *source) +static void +cups_dispatch_add_poll (GSource *source) { GtkPrintCupsDispatchWatch *dispatch; GtkCupsPollState poll_state; - gboolean result; - - GTK_NOTE (PRINTING, - g_print ("CUPS Backend: %s <source %p>\n", G_STRFUNC, source)); dispatch = (GtkPrintCupsDispatchWatch *) source; @@ -820,26 +816,41 @@ cups_dispatch_watch_check (GSource *source) if (dispatch->request->http != NULL) { if (dispatch->data_poll == NULL) - { + { dispatch->data_poll = g_new0 (GPollFD, 1); - g_source_add_poll (source, dispatch->data_poll); - } - else - { + if (poll_state == GTK_CUPS_HTTP_READ) dispatch->data_poll->events = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_PRI; else if (poll_state == GTK_CUPS_HTTP_WRITE) dispatch->data_poll->events = G_IO_OUT | G_IO_ERR; else dispatch->data_poll->events = 0; - } #ifdef HAVE_CUPS_API_1_2 - dispatch->data_poll->fd = httpGetFd (dispatch->request->http); + dispatch->data_poll->fd = httpGetFd (dispatch->request->http); #else - dispatch->data_poll->fd = dispatch->request->http->fd; + dispatch->data_poll->fd = dispatch->request->http->fd; #endif + g_source_add_poll (source, dispatch->data_poll); + } } +} + +static gboolean +cups_dispatch_watch_check (GSource *source) +{ + GtkPrintCupsDispatchWatch *dispatch; + GtkCupsPollState poll_state; + gboolean result; + + GTK_NOTE (PRINTING, + g_print ("CUPS Backend: %s <source %p>\n", G_STRFUNC, source)); + + dispatch = (GtkPrintCupsDispatchWatch *) source; + + poll_state = gtk_cups_request_get_poll_state (dispatch->request); + + cups_dispatch_add_poll (source); if (poll_state != GTK_CUPS_HTTP_IDLE && !dispatch->request->need_password) if (!(dispatch->data_poll->revents & dispatch->data_poll->events)) @@ -868,6 +879,7 @@ cups_dispatch_watch_prepare (GSource *source, gint *timeout_) { GtkPrintCupsDispatchWatch *dispatch; + gboolean result; dispatch = (GtkPrintCupsDispatchWatch *) source; @@ -876,7 +888,11 @@ cups_dispatch_watch_prepare (GSource *source, *timeout_ = -1; - return gtk_cups_request_read_write (dispatch->request); + result = gtk_cups_request_read_write (dispatch->request); + + cups_dispatch_add_poll (source); + + return result; } static gboolean |