diff options
author | Matthias Clasen <mclasen@redhat.com> | 2008-09-17 22:07:10 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2008-09-17 22:07:10 +0000 |
commit | 8ec27f776004b14839742829a85be9e580ff2799 (patch) | |
tree | 021114df61a35a9a48121b0e49ecb2aea5300ca3 /gtk/gtkprinter.c | |
parent | df619a1370273305726416fc5eb04b46c267915c (diff) | |
download | gtk+-8ec27f776004b14839742829a85be9e580ff2799.tar.gz |
Bug 346903 – gtk_enumerate_printers needs events to complete
2008-09-17 Matthias Clasen <mclasen@redhat.com>
Bug 346903 – gtk_enumerate_printers needs events to complete
* gtk/gtkprintbackend.h:
* gtk/gtkprintbackend.c: Add a GtkPrintBackend::status property.
* modules/printbackends/cups/gtkcupsutils.h:
* modules/printbackends/cups/gtkcupsutils.c: Turn the connection
test into a tristate available/unavailable/in progress.
* modules/printbackends/cups/gtkprintbackendcups.c: Use a single
connection test instance for getting the default printer and for
getting the printer list. Set the GtkPrintBackend::status property
according to the result of the connection test. Use the printer-type
attribute to find the default printer, if cups supports it.
* gtk/gtkprinter.c: When enumerating printers, give up when
the backend status is 'unavailable'.
* gtk/gtkprintunixdialog.c (printer_status_cb): Select the printer
when it is the default and nothing else has been selected yet.
svn path=/trunk/; revision=21417
Diffstat (limited to 'gtk/gtkprinter.c')
-rw-r--r-- | gtk/gtkprinter.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/gtk/gtkprinter.c b/gtk/gtkprinter.c index 8dc08f3137..0e9fd77fc8 100644 --- a/gtk/gtkprinter.c +++ b/gtk/gtkprinter.c @@ -1098,6 +1098,21 @@ list_added_cb (GtkPrintBackend *backend, } static void +backend_status_changed (GObject *object, + GParamSpec *pspec, + gpointer data) +{ + GtkPrintBackend *backend = GTK_PRINT_BACKEND (object); + PrinterList *printer_list = data; + GtkPrintBackendStatus status; + + g_object_get (backend, "status", &status, NULL); + + if (status == GTK_PRINT_BACKEND_STATUS_UNAVAILABLE) + list_done_cb (backend, printer_list); +} + +static void list_done_cb (GtkPrintBackend *backend, PrinterList *printer_list) { @@ -1105,6 +1120,7 @@ list_done_cb (GtkPrintBackend *backend, g_signal_handlers_disconnect_by_func (backend, list_added_cb, printer_list); g_signal_handlers_disconnect_by_func (backend, list_done_cb, printer_list); + g_signal_handlers_disconnect_by_func (backend, backend_status_changed, printer_list); gtk_print_backend_destroy (backend); g_object_unref (backend); @@ -1118,6 +1134,7 @@ list_printers_init (PrinterList *printer_list, GtkPrintBackend *backend) { GList *list, *node; + GtkPrintBackendStatus status; list = gtk_print_backend_get_printer_list (backend); @@ -1132,7 +1149,10 @@ list_printers_init (PrinterList *printer_list, g_list_free (list); - if (gtk_print_backend_printer_list_is_done (backend)) + g_object_get (backend, "status", &status, NULL); + + if (status == GTK_PRINT_BACKEND_STATUS_UNAVAILABLE || + gtk_print_backend_printer_list_is_done (backend)) { printer_list->backends = g_list_remove (printer_list->backends, backend); gtk_print_backend_destroy (backend); @@ -1146,6 +1166,9 @@ list_printers_init (PrinterList *printer_list, g_signal_connect (backend, "printer-list-done", (GCallback) list_done_cb, printer_list); + g_signal_connect (backend, "notify::status", + (GCallback) backend_status_changed, + printer_list); } return FALSE; |