Cleanups
This commit is contained in:
parent
9a1bc58a8d
commit
6ffc87bb80
@ -1,3 +1,9 @@
|
|||||||
|
2006-06-21 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* modules/printbackends/cups/gtkprintbackendcups.c: Remove the
|
||||||
|
GError parameter from cups_request_execute(), and various other
|
||||||
|
cleanups.
|
||||||
|
|
||||||
2006-06-20 Matthias Clasen <mclasen@redhat.com>
|
2006-06-20 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* gtk/gtkprintjob.c (gtk_print_job_class_init): Make
|
* gtk/gtkprintjob.c (gtk_print_job_class_init): Make
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
2006-06-21 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* modules/printbackends/cups/gtkprintbackendcups.c: Remove the
|
||||||
|
GError parameter from cups_request_execute(), and various other
|
||||||
|
cleanups.
|
||||||
|
|
||||||
2006-06-20 Matthias Clasen <mclasen@redhat.com>
|
2006-06-20 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* gtk/gtkprintjob.c (gtk_print_job_class_init): Make
|
* gtk/gtkprintjob.c (gtk_print_job_class_init): Make
|
||||||
|
@ -64,8 +64,8 @@ typedef struct _GtkPrintBackendCupsClass GtkPrintBackendCupsClass;
|
|||||||
static GType print_backend_cups_type = 0;
|
static GType print_backend_cups_type = 0;
|
||||||
|
|
||||||
typedef void (* GtkPrintCupsResponseCallbackFunc) (GtkPrintBackend *print_backend,
|
typedef void (* GtkPrintCupsResponseCallbackFunc) (GtkPrintBackend *print_backend,
|
||||||
GtkCupsResult *result,
|
GtkCupsResult *result,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
@ -101,7 +101,7 @@ struct _GtkPrintBackendCups
|
|||||||
|
|
||||||
guint list_printers_poll;
|
guint list_printers_poll;
|
||||||
guint list_printers_pending : 1;
|
guint list_printers_pending : 1;
|
||||||
guint got_default_printer : 1;
|
guint got_default_printer : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
static GObjectClass *backend_parent_class;
|
static GObjectClass *backend_parent_class;
|
||||||
@ -115,8 +115,7 @@ static void cups_request_execute (GtkPrintBack
|
|||||||
GtkCupsRequest *request,
|
GtkCupsRequest *request,
|
||||||
GtkPrintCupsResponseCallbackFunc callback,
|
GtkPrintCupsResponseCallbackFunc callback,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
GDestroyNotify notify,
|
GDestroyNotify notify);
|
||||||
GError **err);
|
|
||||||
static void cups_printer_get_settings_from_options (GtkPrinter *printer,
|
static void cups_printer_get_settings_from_options (GtkPrinter *printer,
|
||||||
GtkPrinterOptionSet *options,
|
GtkPrinterOptionSet *options,
|
||||||
GtkPrintSettings *settings);
|
GtkPrintSettings *settings);
|
||||||
@ -170,7 +169,7 @@ gtk_print_backend_cups_register_type (GTypeModule *module)
|
|||||||
NULL, /* class_finalize */
|
NULL, /* class_finalize */
|
||||||
NULL, /* class_data */
|
NULL, /* class_data */
|
||||||
sizeof (GtkPrintBackendCups),
|
sizeof (GtkPrintBackendCups),
|
||||||
0, /* n_preallocs */
|
0, /* n_preallocs */
|
||||||
(GInstanceInitFunc) gtk_print_backend_cups_init
|
(GInstanceInitFunc) gtk_print_backend_cups_init
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -216,7 +215,7 @@ gtk_print_backend_cups_get_type (void)
|
|||||||
* the filesystem using Unix/Linux API calls
|
* the filesystem using Unix/Linux API calls
|
||||||
*
|
*
|
||||||
* Return value: the new #GtkPrintBackendCups object
|
* Return value: the new #GtkPrintBackendCups object
|
||||||
**/
|
*/
|
||||||
GtkPrintBackend *
|
GtkPrintBackend *
|
||||||
gtk_print_backend_cups_new (void)
|
gtk_print_backend_cups_new (void)
|
||||||
{
|
{
|
||||||
@ -331,7 +330,7 @@ cups_print_cb (GtkPrintBackendCups *print_backend,
|
|||||||
ipp_attribute_t *attr; /* IPP job-id attribute */
|
ipp_attribute_t *attr; /* IPP job-id attribute */
|
||||||
ipp_t *response = gtk_cups_result_get_response (result);
|
ipp_t *response = gtk_cups_result_get_response (result);
|
||||||
|
|
||||||
if ((attr = ippFindAttribute(response, "job-id", IPP_TAG_INTEGER)) != NULL)
|
if ((attr = ippFindAttribute (response, "job-id", IPP_TAG_INTEGER)) != NULL)
|
||||||
job_id = attr->values[0].integer;
|
job_id = attr->values[0].integer;
|
||||||
|
|
||||||
if (!gtk_print_job_get_track_print_status (ps->job) || job_id == 0)
|
if (!gtk_print_job_get_track_print_status (ps->job) || job_id == 0)
|
||||||
@ -352,9 +351,9 @@ cups_print_cb (GtkPrintBackendCups *print_backend,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
add_cups_options (const char *key,
|
add_cups_options (const gchar *key,
|
||||||
const char *value,
|
const gchar *value,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
GtkCupsRequest *request = user_data;
|
GtkCupsRequest *request = user_data;
|
||||||
|
|
||||||
@ -364,7 +363,7 @@ add_cups_options (const char *key,
|
|||||||
if (strcmp (value, "gtk-ignore-value") == 0)
|
if (strcmp (value, "gtk-ignore-value") == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
key = key + strlen("cups-");
|
key = key + strlen ("cups-");
|
||||||
|
|
||||||
gtk_cups_request_encode_option (request, key, value);
|
gtk_cups_request_encode_option (request, key, value);
|
||||||
}
|
}
|
||||||
@ -377,7 +376,6 @@ gtk_print_backend_cups_print_stream (GtkPrintBackend *print_backend,
|
|||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
GDestroyNotify dnotify)
|
GDestroyNotify dnotify)
|
||||||
{
|
{
|
||||||
GError *error;
|
|
||||||
GtkPrinterCups *cups_printer;
|
GtkPrinterCups *cups_printer;
|
||||||
CupsPrintStreamData *ps;
|
CupsPrintStreamData *ps;
|
||||||
GtkCupsRequest *request;
|
GtkCupsRequest *request;
|
||||||
@ -387,8 +385,6 @@ gtk_print_backend_cups_print_stream (GtkPrintBackend *print_backend,
|
|||||||
cups_printer = GTK_PRINTER_CUPS (gtk_print_job_get_printer (job));
|
cups_printer = GTK_PRINTER_CUPS (gtk_print_job_get_printer (job));
|
||||||
settings = gtk_print_job_get_settings (job);
|
settings = gtk_print_job_get_settings (job);
|
||||||
|
|
||||||
error = NULL;
|
|
||||||
|
|
||||||
request = gtk_cups_request_new (NULL,
|
request = gtk_cups_request_new (NULL,
|
||||||
GTK_CUPS_POST,
|
GTK_CUPS_POST,
|
||||||
IPP_PRINT_JOB,
|
IPP_PRINT_JOB,
|
||||||
@ -419,8 +415,7 @@ gtk_print_backend_cups_print_stream (GtkPrintBackend *print_backend,
|
|||||||
request,
|
request,
|
||||||
(GtkPrintCupsResponseCallbackFunc) cups_print_cb,
|
(GtkPrintCupsResponseCallbackFunc) cups_print_cb,
|
||||||
ps,
|
ps,
|
||||||
(GDestroyNotify)cups_free_print_stream_data,
|
(GDestroyNotify)cups_free_print_stream_data);
|
||||||
&error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -588,8 +583,7 @@ cups_request_execute (GtkPrintBackendCups *print_backend,
|
|||||||
GtkCupsRequest *request,
|
GtkCupsRequest *request,
|
||||||
GtkPrintCupsResponseCallbackFunc callback,
|
GtkPrintCupsResponseCallbackFunc callback,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
GDestroyNotify notify,
|
GDestroyNotify notify)
|
||||||
GError **err)
|
|
||||||
{
|
{
|
||||||
GtkPrintCupsDispatchWatch *dispatch;
|
GtkPrintCupsDispatchWatch *dispatch;
|
||||||
|
|
||||||
@ -681,7 +675,6 @@ static void
|
|||||||
cups_request_printer_info (GtkPrintBackendCups *print_backend,
|
cups_request_printer_info (GtkPrintBackendCups *print_backend,
|
||||||
const gchar *printer_name)
|
const gchar *printer_name)
|
||||||
{
|
{
|
||||||
GError *error;
|
|
||||||
GtkCupsRequest *request;
|
GtkCupsRequest *request;
|
||||||
gchar *printer_uri;
|
gchar *printer_uri;
|
||||||
static const char * const pattrs[] = /* Attributes we're interested in */
|
static const char * const pattrs[] = /* Attributes we're interested in */
|
||||||
@ -693,8 +686,6 @@ cups_request_printer_info (GtkPrintBackendCups *print_backend,
|
|||||||
"queued-job-count"
|
"queued-job-count"
|
||||||
};
|
};
|
||||||
|
|
||||||
error = NULL;
|
|
||||||
|
|
||||||
request = gtk_cups_request_new (NULL,
|
request = gtk_cups_request_new (NULL,
|
||||||
GTK_CUPS_POST,
|
GTK_CUPS_POST,
|
||||||
IPP_GET_PRINTER_ATTRIBUTES,
|
IPP_GET_PRINTER_ATTRIBUTES,
|
||||||
@ -717,9 +708,7 @@ cups_request_printer_info (GtkPrintBackendCups *print_backend,
|
|||||||
request,
|
request,
|
||||||
(GtkPrintCupsResponseCallbackFunc) cups_request_printer_info_cb,
|
(GtkPrintCupsResponseCallbackFunc) cups_request_printer_info_cb,
|
||||||
g_strdup (printer_name),
|
g_strdup (printer_name),
|
||||||
(GDestroyNotify) g_free,
|
(GDestroyNotify) g_free);
|
||||||
&error);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -825,12 +814,9 @@ cups_request_job_info_cb (GtkPrintBackendCups *print_backend,
|
|||||||
static void
|
static void
|
||||||
cups_request_job_info (CupsJobPollData *data)
|
cups_request_job_info (CupsJobPollData *data)
|
||||||
{
|
{
|
||||||
GError *error;
|
|
||||||
GtkCupsRequest *request;
|
GtkCupsRequest *request;
|
||||||
gchar *printer_uri;
|
gchar *printer_uri;
|
||||||
|
|
||||||
|
|
||||||
error = NULL;
|
|
||||||
request = gtk_cups_request_new (NULL,
|
request = gtk_cups_request_new (NULL,
|
||||||
GTK_CUPS_POST,
|
GTK_CUPS_POST,
|
||||||
IPP_GET_JOB_ATTRIBUTES,
|
IPP_GET_JOB_ATTRIBUTES,
|
||||||
@ -847,8 +833,7 @@ cups_request_job_info (CupsJobPollData *data)
|
|||||||
request,
|
request,
|
||||||
(GtkPrintCupsResponseCallbackFunc) cups_request_job_info_cb,
|
(GtkPrintCupsResponseCallbackFunc) cups_request_job_info_cb,
|
||||||
data,
|
data,
|
||||||
NULL,
|
NULL);
|
||||||
&error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -867,7 +852,7 @@ cups_job_info_poll_timeout (gpointer user_data)
|
|||||||
static void
|
static void
|
||||||
cups_begin_polling_info (GtkPrintBackendCups *print_backend,
|
cups_begin_polling_info (GtkPrintBackendCups *print_backend,
|
||||||
GtkPrintJob *job,
|
GtkPrintJob *job,
|
||||||
int job_id)
|
gint job_id)
|
||||||
{
|
{
|
||||||
CupsJobPollData *data;
|
CupsJobPollData *data;
|
||||||
|
|
||||||
@ -888,8 +873,7 @@ mark_printer_inactive (GtkPrinter *printer,
|
|||||||
GtkPrintBackend *backend)
|
GtkPrintBackend *backend)
|
||||||
{
|
{
|
||||||
gtk_printer_set_is_active (printer, FALSE);
|
gtk_printer_set_is_active (printer, FALSE);
|
||||||
g_signal_emit_by_name (backend,
|
g_signal_emit_by_name (backend, "printer-removed", printer);
|
||||||
"printer-removed", printer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
@ -907,6 +891,7 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
|
|||||||
GtkCupsResult *result,
|
GtkCupsResult *result,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
|
GtkPrintBackend *backend = GTK_PRINT_BACKEND (cups_backend);
|
||||||
ipp_attribute_t *attr;
|
ipp_attribute_t *attr;
|
||||||
ipp_t *response;
|
ipp_t *response;
|
||||||
gboolean list_has_changed;
|
gboolean list_has_changed;
|
||||||
@ -914,8 +899,6 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
|
|||||||
|
|
||||||
list_has_changed = FALSE;
|
list_has_changed = FALSE;
|
||||||
|
|
||||||
g_assert (GTK_IS_PRINT_BACKEND_CUPS (cups_backend));
|
|
||||||
|
|
||||||
cups_backend->list_printers_pending = FALSE;
|
cups_backend->list_printers_pending = FALSE;
|
||||||
|
|
||||||
if (gtk_cups_result_is_error (result))
|
if (gtk_cups_result_is_error (result))
|
||||||
@ -924,24 +907,23 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* gether the names of the printers in the current queue
|
/* Gather the names of the printers in the current queue
|
||||||
so we may check to see if they were removed */
|
* so we may check to see if they were removed
|
||||||
removed_printer_checklist = gtk_print_backend_get_printer_list (GTK_PRINT_BACKEND (cups_backend));
|
*/
|
||||||
|
removed_printer_checklist = gtk_print_backend_get_printer_list (backend);
|
||||||
|
|
||||||
response = gtk_cups_result_get_response (result);
|
response = gtk_cups_result_get_response (result);
|
||||||
|
|
||||||
|
|
||||||
for (attr = response->attrs; attr != NULL; attr = attr->next)
|
for (attr = response->attrs; attr != NULL; attr = attr->next)
|
||||||
{
|
{
|
||||||
GtkPrinter *printer;
|
GtkPrinter *printer;
|
||||||
const gchar *printer_name;
|
const gchar *printer_name;
|
||||||
const char *printer_uri;
|
const gchar *printer_uri;
|
||||||
const char *member_uris;
|
const gchar *member_uris;
|
||||||
GList *node;
|
GList *node;
|
||||||
|
|
||||||
/*
|
/* Skip leading attributes until we hit a printer...
|
||||||
* Skip leading attributes until we hit a printer...
|
*/
|
||||||
*/
|
|
||||||
while (attr != NULL && attr->group_tag != IPP_TAG_PRINTER)
|
while (attr != NULL && attr->group_tag != IPP_TAG_PRINTER)
|
||||||
attr = attr->next;
|
attr = attr->next;
|
||||||
|
|
||||||
@ -953,13 +935,13 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
|
|||||||
member_uris = NULL;
|
member_uris = NULL;
|
||||||
while (attr != NULL && attr->group_tag == IPP_TAG_PRINTER)
|
while (attr != NULL && attr->group_tag == IPP_TAG_PRINTER)
|
||||||
{
|
{
|
||||||
if (!strcmp(attr->name, "printer-name") &&
|
if (!strcmp (attr->name, "printer-name") &&
|
||||||
attr->value_tag == IPP_TAG_NAME)
|
attr->value_tag == IPP_TAG_NAME)
|
||||||
printer_name = attr->values[0].string.text;
|
printer_name = attr->values[0].string.text;
|
||||||
else if (!strcmp(attr->name, "printer-uri-supported") &&
|
else if (!strcmp (attr->name, "printer-uri-supported") &&
|
||||||
attr->value_tag == IPP_TAG_URI)
|
attr->value_tag == IPP_TAG_URI)
|
||||||
printer_uri = attr->values[0].string.text;
|
printer_uri = attr->values[0].string.text;
|
||||||
else if (!strcmp(attr->name, "member-uris") &&
|
else if (!strcmp (attr->name, "member-uris") &&
|
||||||
attr->value_tag == IPP_TAG_URI)
|
attr->value_tag == IPP_TAG_URI)
|
||||||
member_uris = attr->values[0].string.text;
|
member_uris = attr->values[0].string.text;
|
||||||
|
|
||||||
@ -979,27 +961,24 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
|
|||||||
node = g_list_find_custom (removed_printer_checklist, printer_name, (GCompareFunc) find_printer);
|
node = g_list_find_custom (removed_printer_checklist, printer_name, (GCompareFunc) find_printer);
|
||||||
removed_printer_checklist = g_list_delete_link (removed_printer_checklist, node);
|
removed_printer_checklist = g_list_delete_link (removed_printer_checklist, node);
|
||||||
|
|
||||||
printer = gtk_print_backend_find_printer (GTK_PRINT_BACKEND (cups_backend), printer_name);
|
printer = gtk_print_backend_find_printer (backend, printer_name);
|
||||||
if (!printer)
|
if (!printer)
|
||||||
{
|
{
|
||||||
GtkPrinterCups *cups_printer;
|
GtkPrinterCups *cups_printer;
|
||||||
char uri[HTTP_MAX_URI], /* Printer URI */
|
char uri[HTTP_MAX_URI]; /* Printer URI */
|
||||||
method[HTTP_MAX_URI], /* Method/scheme name */
|
char method[HTTP_MAX_URI]; /* Method/scheme name */
|
||||||
username[HTTP_MAX_URI], /* Username:password */
|
char username[HTTP_MAX_URI]; /* Username:password */
|
||||||
hostname[HTTP_MAX_URI], /* Hostname */
|
char hostname[HTTP_MAX_URI]; /* Hostname */
|
||||||
resource[HTTP_MAX_URI]; /* Resource name */
|
char resource[HTTP_MAX_URI]; /* Resource name */
|
||||||
int port; /* Port number */
|
int port; /* Port number */
|
||||||
|
|
||||||
list_has_changed = TRUE;
|
list_has_changed = TRUE;
|
||||||
cups_printer = gtk_printer_cups_new (printer_name,
|
cups_printer = gtk_printer_cups_new (printer_name, backend);
|
||||||
GTK_PRINT_BACKEND (cups_backend));
|
|
||||||
|
|
||||||
cups_printer->device_uri = g_strdup_printf ("/printers/%s", printer_name);
|
cups_printer->device_uri = g_strdup_printf ("/printers/%s", printer_name);
|
||||||
|
|
||||||
if (member_uris)
|
if (member_uris)
|
||||||
{
|
cups_printer->printer_uri = g_strdup (member_uris);
|
||||||
cups_printer->printer_uri = g_strdup (member_uris);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
cups_printer->printer_uri = g_strdup (printer_uri);
|
cups_printer->printer_uri = g_strdup (printer_uri);
|
||||||
|
|
||||||
@ -1020,9 +999,9 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
|
|||||||
resource);
|
resource);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gethostname(uri, sizeof(uri));
|
gethostname (uri, sizeof(uri));
|
||||||
if (strcasecmp(uri, hostname) == 0)
|
if (strcasecmp (uri, hostname) == 0)
|
||||||
strcpy(hostname, "localhost");
|
strcpy (hostname, "localhost");
|
||||||
|
|
||||||
cups_printer->hostname = g_strdup (hostname);
|
cups_printer->hostname = g_strdup (hostname);
|
||||||
cups_printer->port = port;
|
cups_printer->port = port;
|
||||||
@ -1034,7 +1013,7 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
|
|||||||
gtk_printer_set_is_default (printer, TRUE);
|
gtk_printer_set_is_default (printer, TRUE);
|
||||||
|
|
||||||
|
|
||||||
gtk_print_backend_add_printer (GTK_PRINT_BACKEND (cups_backend), printer);
|
gtk_print_backend_add_printer (backend, printer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
g_object_ref (printer);
|
g_object_ref (printer);
|
||||||
@ -1048,9 +1027,7 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
|
|||||||
|
|
||||||
if (gtk_printer_is_new (printer))
|
if (gtk_printer_is_new (printer))
|
||||||
{
|
{
|
||||||
g_signal_emit_by_name (GTK_PRINT_BACKEND (cups_backend),
|
g_signal_emit_by_name (backend, "printer-added", printer);
|
||||||
"printer-added",
|
|
||||||
printer);
|
|
||||||
|
|
||||||
gtk_printer_set_is_new (printer, FALSE);
|
gtk_printer_set_is_new (printer, FALSE);
|
||||||
}
|
}
|
||||||
@ -1069,22 +1046,20 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
|
|||||||
as inactive if it is in the list, emitting a printer_removed signal */
|
as inactive if it is in the list, emitting a printer_removed signal */
|
||||||
if (removed_printer_checklist != NULL)
|
if (removed_printer_checklist != NULL)
|
||||||
{
|
{
|
||||||
g_list_foreach (removed_printer_checklist, (GFunc) mark_printer_inactive,
|
g_list_foreach (removed_printer_checklist, (GFunc) mark_printer_inactive, backend);
|
||||||
GTK_PRINT_BACKEND (cups_backend));
|
|
||||||
g_list_free (removed_printer_checklist);
|
g_list_free (removed_printer_checklist);
|
||||||
list_has_changed = TRUE;
|
list_has_changed = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (list_has_changed)
|
if (list_has_changed)
|
||||||
g_signal_emit_by_name (GTK_PRINT_BACKEND (cups_backend), "printer-list-changed");
|
g_signal_emit_by_name (backend, "printer-list-changed");
|
||||||
|
|
||||||
gtk_print_backend_set_list_done (GTK_PRINT_BACKEND (cups_backend));
|
gtk_print_backend_set_list_done (backend);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
cups_request_printer_list (GtkPrintBackendCups *cups_backend)
|
cups_request_printer_list (GtkPrintBackendCups *cups_backend)
|
||||||
{
|
{
|
||||||
GError *error;
|
|
||||||
GtkCupsRequest *request;
|
GtkCupsRequest *request;
|
||||||
static const char * const pattrs[] = /* Attributes we're interested in */
|
static const char * const pattrs[] = /* Attributes we're interested in */
|
||||||
{
|
{
|
||||||
@ -1099,8 +1074,6 @@ cups_request_printer_list (GtkPrintBackendCups *cups_backend)
|
|||||||
|
|
||||||
cups_backend->list_printers_pending = TRUE;
|
cups_backend->list_printers_pending = TRUE;
|
||||||
|
|
||||||
error = NULL;
|
|
||||||
|
|
||||||
request = gtk_cups_request_new (NULL,
|
request = gtk_cups_request_new (NULL,
|
||||||
GTK_CUPS_POST,
|
GTK_CUPS_POST,
|
||||||
CUPS_GET_PRINTERS,
|
CUPS_GET_PRINTERS,
|
||||||
@ -1116,9 +1089,7 @@ cups_request_printer_list (GtkPrintBackendCups *cups_backend)
|
|||||||
request,
|
request,
|
||||||
(GtkPrintCupsResponseCallbackFunc) cups_request_printer_list_cb,
|
(GtkPrintCupsResponseCallbackFunc) cups_request_printer_list_cb,
|
||||||
request,
|
request,
|
||||||
NULL,
|
NULL);
|
||||||
&error);
|
|
||||||
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -1193,9 +1164,9 @@ cups_request_ppd (GtkPrinter *printer)
|
|||||||
|
|
||||||
error = NULL;
|
error = NULL;
|
||||||
/* FIXME this can return NULL! */
|
/* FIXME this can return NULL! */
|
||||||
http = httpConnectEncrypt(cups_printer->hostname,
|
http = httpConnectEncrypt (cups_printer->hostname,
|
||||||
cups_printer->port,
|
cups_printer->port,
|
||||||
cupsEncryption());
|
cupsEncryption ());
|
||||||
|
|
||||||
data = g_new0 (GetPPDData, 1);
|
data = g_new0 (GetPPDData, 1);
|
||||||
|
|
||||||
@ -1236,8 +1207,7 @@ cups_request_ppd (GtkPrinter *printer)
|
|||||||
request,
|
request,
|
||||||
(GtkPrintCupsResponseCallbackFunc) cups_request_ppd_cb,
|
(GtkPrintCupsResponseCallbackFunc) cups_request_ppd_cb,
|
||||||
data,
|
data,
|
||||||
(GDestroyNotify)get_ppd_data_free,
|
(GDestroyNotify)get_ppd_data_free);
|
||||||
&error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1251,13 +1221,14 @@ cups_request_default_printer_cb (GtkPrintBackendCups *print_backend,
|
|||||||
|
|
||||||
response = gtk_cups_result_get_response (result);
|
response = gtk_cups_result_get_response (result);
|
||||||
|
|
||||||
if ((attr = ippFindAttribute(response, "printer-name", IPP_TAG_NAME)) != NULL)
|
if ((attr = ippFindAttribute (response, "printer-name", IPP_TAG_NAME)) != NULL)
|
||||||
print_backend->default_printer = g_strdup (attr->values[0].string.text);
|
print_backend->default_printer = g_strdup (attr->values[0].string.text);
|
||||||
|
|
||||||
print_backend->got_default_printer = TRUE;
|
print_backend->got_default_printer = TRUE;
|
||||||
|
|
||||||
/* Make sure to kick off get_printers if we are polling it, as we could
|
/* Make sure to kick off get_printers if we are polling it,
|
||||||
have blocked this reading the default printer */
|
* as we could have blocked this reading the default printer
|
||||||
|
*/
|
||||||
if (print_backend->list_printers_poll != 0)
|
if (print_backend->list_printers_poll != 0)
|
||||||
cups_request_printer_list (print_backend);
|
cups_request_printer_list (print_backend);
|
||||||
}
|
}
|
||||||
@ -1265,20 +1236,17 @@ cups_request_default_printer_cb (GtkPrintBackendCups *print_backend,
|
|||||||
static void
|
static void
|
||||||
cups_request_default_printer (GtkPrintBackendCups *print_backend)
|
cups_request_default_printer (GtkPrintBackendCups *print_backend)
|
||||||
{
|
{
|
||||||
GError *error;
|
|
||||||
GtkCupsRequest *request;
|
GtkCupsRequest *request;
|
||||||
const char *str;
|
const char *str;
|
||||||
|
|
||||||
error = NULL;
|
if ((str = g_getenv ("LPDEST")) != NULL)
|
||||||
|
|
||||||
if ((str = getenv("LPDEST")) != NULL)
|
|
||||||
{
|
{
|
||||||
print_backend->default_printer = g_strdup (str);
|
print_backend->default_printer = g_strdup (str);
|
||||||
print_backend->got_default_printer = TRUE;
|
print_backend->got_default_printer = TRUE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if ((str = getenv("PRINTER")) != NULL &&
|
else if ((str = g_getenv ("PRINTER")) != NULL &&
|
||||||
strcmp(str, "lp") != 0)
|
strcmp (str, "lp") != 0)
|
||||||
{
|
{
|
||||||
print_backend->default_printer = g_strdup (str);
|
print_backend->default_printer = g_strdup (str);
|
||||||
print_backend->got_default_printer = TRUE;
|
print_backend->got_default_printer = TRUE;
|
||||||
@ -1296,11 +1264,9 @@ cups_request_default_printer (GtkPrintBackendCups *print_backend)
|
|||||||
request,
|
request,
|
||||||
(GtkPrintCupsResponseCallbackFunc) cups_request_default_printer_cb,
|
(GtkPrintCupsResponseCallbackFunc) cups_request_default_printer_cb,
|
||||||
g_object_ref (print_backend),
|
g_object_ref (print_backend),
|
||||||
g_object_unref,
|
g_object_unref);
|
||||||
&error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cups_printer_request_details (GtkPrinter *printer)
|
cups_printer_request_details (GtkPrinter *printer)
|
||||||
{
|
{
|
||||||
@ -1313,7 +1279,8 @@ cups_printer_request_details (GtkPrinter *printer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
ppd_text_to_utf8 (ppd_file_t *ppd_file, const char *text)
|
ppd_text_to_utf8 (ppd_file_t *ppd_file,
|
||||||
|
const char *text)
|
||||||
{
|
{
|
||||||
const char *encoding = NULL;
|
const char *encoding = NULL;
|
||||||
char *res;
|
char *res;
|
||||||
@ -1591,7 +1558,7 @@ available_choices (ppd_file_t *ppd,
|
|||||||
{
|
{
|
||||||
ppd_option_t *other_option;
|
ppd_option_t *other_option;
|
||||||
int i, j;
|
int i, j;
|
||||||
char *conflicts;
|
gchar *conflicts;
|
||||||
ppd_const_t *constraint;
|
ppd_const_t *constraint;
|
||||||
const char *choice, *other_choice;
|
const char *choice, *other_choice;
|
||||||
ppd_option_t *option1, *option2;
|
ppd_option_t *option1, *option2;
|
||||||
@ -1693,13 +1660,13 @@ available_choices (ppd_file_t *ppd,
|
|||||||
|
|
||||||
|
|
||||||
/* Some ppds don't have a "use printer default" option for
|
/* Some ppds don't have a "use printer default" option for
|
||||||
InputSlot. This means you always have to select a particular slot,
|
* InputSlot. This means you always have to select a particular slot,
|
||||||
and you can't auto-pick source based on the paper size. To support
|
* and you can't auto-pick source based on the paper size. To support
|
||||||
this we always add an auto option if there isn't one already. If
|
* this we always add an auto option if there isn't one already. If
|
||||||
the user chooses the generated option we don't send any InputSlot
|
* the user chooses the generated option we don't send any InputSlot
|
||||||
value when printing. The way we detect existing auto-cases is based
|
* value when printing. The way we detect existing auto-cases is based
|
||||||
on feedback from Michael Sweet of cups fame.
|
* on feedback from Michael Sweet of cups fame.
|
||||||
*/
|
*/
|
||||||
add_auto = 0;
|
add_auto = 0;
|
||||||
if (strcmp (option->keyword, "InputSlot") == 0)
|
if (strcmp (option->keyword, "InputSlot") == 0)
|
||||||
{
|
{
|
||||||
@ -1814,14 +1781,14 @@ create_boolean_option (ppd_file_t *ppd_file,
|
|||||||
{
|
{
|
||||||
label = get_option_text (ppd_file, ppd_option);
|
label = get_option_text (ppd_file, ppd_option);
|
||||||
option = gtk_printer_option_new (gtk_name, label,
|
option = gtk_printer_option_new (gtk_name, label,
|
||||||
GTK_PRINTER_OPTION_TYPE_BOOLEAN);
|
GTK_PRINTER_OPTION_TYPE_BOOLEAN);
|
||||||
g_free (label);
|
g_free (label);
|
||||||
|
|
||||||
gtk_printer_option_allocate_choices (option, 2);
|
gtk_printer_option_allocate_choices (option, 2);
|
||||||
option->choices[0] = g_strdup ("True");
|
option->choices[0] = g_strdup ("True");
|
||||||
option->choices_display[0] = g_strdup ("True");
|
option->choices_display[0] = g_strdup ("True");
|
||||||
option->choices[1] = g_strdup ("True");
|
option->choices[1] = g_strdup ("False");
|
||||||
option->choices_display[1] = g_strdup ("True");
|
option->choices_display[1] = g_strdup ("False");
|
||||||
|
|
||||||
gtk_printer_option_set (option, ppd_option->defchoice);
|
gtk_printer_option_set (option, ppd_option->defchoice);
|
||||||
}
|
}
|
||||||
@ -2041,7 +2008,7 @@ cups_printer_get_options (GtkPrinter *printer,
|
|||||||
|
|
||||||
paper_size = gtk_page_setup_get_paper_size (page_setup);
|
paper_size = gtk_page_setup_get_paper_size (page_setup);
|
||||||
|
|
||||||
option = ppdFindOption(ppd_file, "PageSize");
|
option = ppdFindOption (ppd_file, "PageSize");
|
||||||
strncpy (option->defchoice, gtk_paper_size_get_ppd_name (paper_size),
|
strncpy (option->defchoice, gtk_paper_size_get_ppd_name (paper_size),
|
||||||
PPD_MAX_NAME);
|
PPD_MAX_NAME);
|
||||||
|
|
||||||
@ -2091,6 +2058,7 @@ set_conflicts_from_option (GtkPrinterOptionSet *set,
|
|||||||
{
|
{
|
||||||
GtkPrinterOption *option;
|
GtkPrinterOption *option;
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
if (ppd_option->conflicted)
|
if (ppd_option->conflicted)
|
||||||
{
|
{
|
||||||
name = get_option_name (ppd_option->keyword);
|
name = get_option_name (ppd_option->keyword);
|
||||||
@ -2174,15 +2142,15 @@ map_settings_to_option (GtkPrinterOption *option,
|
|||||||
const char *standard_value;
|
const char *standard_value;
|
||||||
|
|
||||||
/* If the cups-specific setting is set, always use that */
|
/* If the cups-specific setting is set, always use that */
|
||||||
|
|
||||||
name = g_strdup_printf ("cups-%s", cups_name);
|
name = g_strdup_printf ("cups-%s", cups_name);
|
||||||
cups_value = gtk_print_settings_get (settings, name);
|
cups_value = gtk_print_settings_get (settings, name);
|
||||||
g_free (name);
|
g_free (name);
|
||||||
|
|
||||||
if (cups_value != NULL) {
|
if (cups_value != NULL)
|
||||||
gtk_printer_option_set (option, cups_value);
|
{
|
||||||
return;
|
gtk_printer_option_set (option, cups_value);
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Otherwise we try to convert from the general setting */
|
/* Otherwise we try to convert from the general setting */
|
||||||
standard_value = gtk_print_settings_get (settings, standard_name);
|
standard_value = gtk_print_settings_get (settings, standard_name);
|
||||||
@ -2564,10 +2532,10 @@ cups_printer_list_papers (GtkPrinter *printer)
|
|||||||
size = &ppd_file->sizes[i];
|
size = &ppd_file->sizes[i];
|
||||||
|
|
||||||
display_name = NULL;
|
display_name = NULL;
|
||||||
option = ppdFindOption(ppd_file, "PageSize");
|
option = ppdFindOption (ppd_file, "PageSize");
|
||||||
if (option)
|
if (option)
|
||||||
{
|
{
|
||||||
choice = ppdFindChoice(option, size->name);
|
choice = ppdFindChoice (option, size->name);
|
||||||
if (choice)
|
if (choice)
|
||||||
display_name = ppd_text_to_utf8 (ppd_file, choice->text);
|
display_name = ppd_text_to_utf8 (ppd_file, choice->text);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user