summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorJohn Palmieri <johnp@src.gnome.org>2006-07-06 17:55:32 +0000
committerJohn Palmieri <johnp@src.gnome.org>2006-07-06 17:55:32 +0000
commit828014328c583c0470f9f29efd27e81021129c10 (patch)
tree2fe936e2133e30dcd77d19b13a38b756dbd1167a /modules
parent0407469ce1fb7af3d73daac06e70807ae428da59 (diff)
downloadgtk+-828014328c583c0470f9f29efd27e81021129c10.tar.gz
Get the name of the first printer in a class to use when requesting a PPD
* modules/printbackends/cups/gtkprintbackendcups.c: (cups_request_printer_list_cb): Get the name of the first printer in a class to use when requesting a PPD (cups_request_ppd_cb, cups_request_ppd): Fix the parameters of the "details-acquired" signal emittion (cups_request_ppd): get the ppd name from the cups printer * modules/printbackends/cups/gtkprintercups.c (gtk_printer_cups_get_ppd_name): New method for getting the name of the ppd we should request
Diffstat (limited to 'modules')
-rw-r--r--modules/printbackends/cups/gtkprintbackendcups.c38
-rw-r--r--modules/printbackends/cups/gtkprintercups.c16
-rw-r--r--modules/printbackends/cups/gtkprintercups.h4
3 files changed, 51 insertions, 7 deletions
diff --git a/modules/printbackends/cups/gtkprintbackendcups.c b/modules/printbackends/cups/gtkprintbackendcups.c
index d484991c75..add72fb7f7 100644
--- a/modules/printbackends/cups/gtkprintbackendcups.c
+++ b/modules/printbackends/cups/gtkprintbackendcups.c
@@ -956,6 +956,9 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
list_has_changed = FALSE;
+ GTK_NOTE (PRINTING,
+ g_print ("CUPS Backend: %s\n", G_STRFUNC));
+
cups_backend->list_printers_pending = FALSE;
if (gtk_cups_result_is_error (result))
@@ -1001,6 +1004,11 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
else if (!strcmp (attr->name, "member-uris") &&
attr->value_tag == IPP_TAG_URI)
member_uris = attr->values[0].string.text;
+ else
+ {
+ GTK_NOTE (PRINTING,
+ g_print ("CUPS Backend: Attribute %s ignored", attr->name));
+ }
attr = attr->next;
}
@@ -1034,10 +1042,20 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
cups_printer->device_uri = g_strdup_printf ("/printers/%s", printer_name);
+ /* Check to see if we are looking at a class */
if (member_uris)
- cups_printer->printer_uri = g_strdup (member_uris);
+ {
+ cups_printer->printer_uri = g_strdup (member_uris);
+ /* TODO if member_uris is a class we need to recursivly find a printer */
+ GTK_NOTE (PRINTING,
+ g_print ("CUPS Backend: Found class with printer %s\n", member_uris));
+ }
else
- cups_printer->printer_uri = g_strdup (printer_uri);
+ {
+ cups_printer->printer_uri = g_strdup (printer_uri);
+ GTK_NOTE (PRINTING,
+ g_print ("CUPS Backend: Found printer %s\n", printer_uri));
+ }
#if (CUPS_VERSION_MAJOR == 1 && CUPS_VERSION_MINOR >= 2) || CUPS_VERSION_MAJOR > 1
httpSeparateURI (HTTP_URI_CODING_ALL, cups_printer->printer_uri,
@@ -1056,6 +1074,13 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
resource);
#endif
+ if (member_uris && !strncmp (resource, "/printers/", 10))
+ {
+ cups_printer->ppd_name = g_strdup (resource + 10);
+ GTK_NOTE (PRINTING,
+ g_print ("CUPS Backend: Setting ppd name '%s' for printer class '%s'\n", cups_printer->ppd_name, printer_name));
+ }
+
gethostname (uri, sizeof(uri));
if (strcasecmp (uri, hostname) == 0)
strcpy (hostname, "localhost");
@@ -1198,7 +1223,7 @@ cups_request_ppd_cb (GtkPrintBackendCups *print_backend,
if (gtk_cups_result_is_error (result))
{
- g_signal_emit_by_name (printer, "details-acquired", printer, FALSE);
+ g_signal_emit_by_name (printer, "details-acquired", FALSE);
return;
}
@@ -1209,7 +1234,7 @@ cups_request_ppd_cb (GtkPrintBackendCups *print_backend,
data->printer->ppd_file = ppdOpenFd (dup (g_io_channel_unix_get_fd (data->ppd_io)));
gtk_printer_set_has_details (printer, TRUE);
- g_signal_emit_by_name (printer, "details-acquired", printer, TRUE);
+ g_signal_emit_by_name (printer, "details-acquired", TRUE);
}
static void
@@ -1259,7 +1284,7 @@ cups_request_ppd (GtkPrinter *printer)
g_free (ppd_filename);
g_free (data);
- g_signal_emit_by_name (printer, "details-acquired", printer, FALSE);
+ g_signal_emit_by_name (printer, "details-acquired", FALSE);
return;
}
@@ -1270,7 +1295,8 @@ cups_request_ppd (GtkPrinter *printer)
data->printer = g_object_ref (printer);
- resource = g_strdup_printf ("/printers/%s.ppd", gtk_printer_get_name (printer));
+ resource = g_strdup_printf ("/printers/%s.ppd",
+ gtk_printer_cups_get_ppd_name (GTK_PRINTER_CUPS(printer)));
request = gtk_cups_request_new (http,
GTK_CUPS_GET,
0,
diff --git a/modules/printbackends/cups/gtkprintercups.c b/modules/printbackends/cups/gtkprintercups.c
index 2a8a5355f4..21ae2c6837 100644
--- a/modules/printbackends/cups/gtkprintercups.c
+++ b/modules/printbackends/cups/gtkprintercups.c
@@ -73,6 +73,7 @@ gtk_printer_cups_init (GtkPrinterCups *printer)
printer->state = 0;
printer->hostname = NULL;
printer->port = 0;
+ printer->ppd_name = NULL;
printer->ppd_file = NULL;
}
@@ -88,6 +89,7 @@ gtk_printer_cups_finalize (GObject *object)
g_free (printer->device_uri);
g_free (printer->printer_uri);
g_free (printer->hostname);
+ g_free (printer->ppd_name);
if (printer->ppd_file)
ppdClose (printer->ppd_file);
@@ -124,3 +126,17 @@ gtk_printer_cups_get_ppd (GtkPrinterCups *printer)
{
return printer->ppd_file;
}
+
+char *
+gtk_printer_cups_get_ppd_name (GtkPrinterCups *printer)
+{
+ gchar *result;
+
+ result = printer->ppd_name;
+
+ if (result == NULL)
+ result = gtk_printer_get_name (GTK_PRINTER (printer));
+
+ return result;
+}
+
diff --git a/modules/printbackends/cups/gtkprintercups.h b/modules/printbackends/cups/gtkprintercups.h
index 510050918f..d33a5ab5eb 100644
--- a/modules/printbackends/cups/gtkprintercups.h
+++ b/modules/printbackends/cups/gtkprintercups.h
@@ -50,6 +50,7 @@ struct _GtkPrinterCups
ipp_pstate_t state;
gboolean reading_ppd;
+ gchar *ppd_name;
ppd_file_t *ppd_file;
};
@@ -63,7 +64,8 @@ GType gtk_printer_cups_get_type (void) G_GNUC_CONST;
void gtk_printer_cups_register_type (GTypeModule *module);
GtkPrinterCups *gtk_printer_cups_new (const char *name,
GtkPrintBackend *backend);
-ppd_file_t * gtk_printer_cups_get_ppd (GtkPrinterCups *printer);
+ppd_file_t *gtk_printer_cups_get_ppd (GtkPrinterCups *printer);
+char *gtk_printer_cups_get_ppd_name (GtkPrinterCups *printer);
G_END_DECLS