[gtk+] printing: Get default number-up value from CUPS
- From: Marek KaÅÃk <mkasik src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] printing: Get default number-up value from CUPS
- Date: Fri, 20 Apr 2012 15:05:13 +0000 (UTC)
commit f6e2d0947d9f0d17e0a52b0e0d0046c4fd787912
Author: Marek Kasik <mkasik redhat com>
Date: Tue Apr 17 17:12:56 2012 +0200
printing: Get default number-up value from CUPS
Requests "number-up-default" attribute from CUPS and
uses its value for setting value of "gtk-n-up" option.
(#672993)
modules/printbackends/cups/gtkprintbackendcups.c | 83 ++++++++++++---------
modules/printbackends/cups/gtkprintercups.c | 1 +
modules/printbackends/cups/gtkprintercups.h | 2 +
3 files changed, 50 insertions(+), 36 deletions(-)
---
diff --git a/modules/printbackends/cups/gtkprintbackendcups.c b/modules/printbackends/cups/gtkprintbackendcups.c
index f7081da..3a250bb 100644
--- a/modules/printbackends/cups/gtkprintbackendcups.c
+++ b/modules/printbackends/cups/gtkprintbackendcups.c
@@ -1737,7 +1737,8 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
gchar *default_cover_after = NULL;
gboolean remote_printer = FALSE;
gchar **auth_info_required = NULL;
-
+ gint default_number_up = 1;
+
/* Skip leading attributes until we hit a printer...
*/
while (attr != NULL && attr->group_tag != IPP_TAG_PRINTER)
@@ -1864,6 +1865,10 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
auth_info_required[i] = g_strdup (attr->values[i].string.text);
}
}
+ else if (strcmp (attr->name, "number-up-default") == 0)
+ {
+ default_number_up = attr->values[0].integer;
+ }
else
{
GTK_NOTE (PRINTING,
@@ -1988,6 +1993,8 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
cups_printer->default_cover_before = g_strdup (default_cover_before);
cups_printer->default_cover_after = g_strdup (default_cover_after);
+ cups_printer->default_number_up = default_number_up;
+
cups_printer->hostname = g_strdup (hostname);
cups_printer->port = port;
@@ -2188,7 +2195,8 @@ cups_request_printer_list (GtkPrintBackendCups *cups_backend)
"job-sheets-supported",
"job-sheets-default",
"printer-type",
- "auth-info-required"
+ "auth-info-required",
+ "number-up-default"
};
if (cups_backend->reading_ppds > 0 || cups_backend->list_printers_pending)
@@ -3613,45 +3621,12 @@ cups_printer_get_options (GtkPrinter *printer,
#ifdef HAVE_COLORD
GtkPrintBackendCupsColordHelper *helper;
#endif
+ char *default_number_up;
set = gtk_printer_option_set_new ();
/* Cups specific, non-ppd related settings */
- /* Translators, this string is used to label the pages-per-sheet option
- * in the print dialog
- */
- option = gtk_printer_option_new ("gtk-n-up", _("Pages per Sheet"), GTK_PRINTER_OPTION_TYPE_PICKONE);
- gtk_printer_option_choices_from_array (option, G_N_ELEMENTS (n_up),
- n_up, n_up);
- gtk_printer_option_set (option, "1");
- set_option_from_settings (option, settings);
- gtk_printer_option_set_add (set, option);
- g_object_unref (option);
-
- if (cups_printer_get_capabilities (printer) & GTK_PRINT_CAPABILITY_NUMBER_UP_LAYOUT)
- {
- for (i = 0; i < G_N_ELEMENTS (n_up_layout_display); i++)
- n_up_layout_display[i] = _(n_up_layout_display[i]);
-
- /* Translators, this string is used to label the option in the print
- * dialog that controls in what order multiple pages are arranged
- */
- option = gtk_printer_option_new ("gtk-n-up-layout", _("Page Ordering"), GTK_PRINTER_OPTION_TYPE_PICKONE);
- gtk_printer_option_choices_from_array (option, G_N_ELEMENTS (n_up_layout),
- n_up_layout, n_up_layout_display);
-
- text_direction = gtk_widget_get_default_direction ();
- if (text_direction == GTK_TEXT_DIR_LTR)
- gtk_printer_option_set (option, "lrtb");
- else
- gtk_printer_option_set (option, "rltb");
-
- set_option_from_settings (option, settings);
- gtk_printer_option_set_add (set, option);
- g_object_unref (option);
- }
-
for (i = 0; i < G_N_ELEMENTS(prio_display); i++)
prio_display[i] = _(prio_display[i]);
@@ -3692,6 +3667,42 @@ cups_printer_get_options (GtkPrinter *printer,
gpointer value;
gint j;
+ /* Translators, this string is used to label the pages-per-sheet option
+ * in the print dialog
+ */
+ option = gtk_printer_option_new ("gtk-n-up", _("Pages per Sheet"), GTK_PRINTER_OPTION_TYPE_PICKONE);
+ gtk_printer_option_choices_from_array (option, G_N_ELEMENTS (n_up),
+ n_up, n_up);
+ default_number_up = g_strdup_printf ("%d", cups_printer->default_number_up);
+ gtk_printer_option_set (option, default_number_up);
+ g_free (default_number_up);
+ set_option_from_settings (option, settings);
+ gtk_printer_option_set_add (set, option);
+ g_object_unref (option);
+
+ if (cups_printer_get_capabilities (printer) & GTK_PRINT_CAPABILITY_NUMBER_UP_LAYOUT)
+ {
+ for (i = 0; i < G_N_ELEMENTS (n_up_layout_display); i++)
+ n_up_layout_display[i] = _(n_up_layout_display[i]);
+
+ /* Translators, this string is used to label the option in the print
+ * dialog that controls in what order multiple pages are arranged
+ */
+ option = gtk_printer_option_new ("gtk-n-up-layout", _("Page Ordering"), GTK_PRINTER_OPTION_TYPE_PICKONE);
+ gtk_printer_option_choices_from_array (option, G_N_ELEMENTS (n_up_layout),
+ n_up_layout, n_up_layout_display);
+
+ text_direction = gtk_widget_get_default_direction ();
+ if (text_direction == GTK_TEXT_DIR_LTR)
+ gtk_printer_option_set (option, "lrtb");
+ else
+ gtk_printer_option_set (option, "rltb");
+
+ set_option_from_settings (option, settings);
+ gtk_printer_option_set_add (set, option);
+ g_object_unref (option);
+ }
+
num_of_covers = backend->number_of_covers;
cover = g_new (char *, num_of_covers + 1);
cover[num_of_covers] = NULL;
diff --git a/modules/printbackends/cups/gtkprintercups.c b/modules/printbackends/cups/gtkprintercups.c
index e8c652f..3a45e2f 100644
--- a/modules/printbackends/cups/gtkprintercups.c
+++ b/modules/printbackends/cups/gtkprintercups.c
@@ -113,6 +113,7 @@ gtk_printer_cups_init (GtkPrinterCups *printer)
printer->get_remote_ppd_attempts = 0;
printer->remote_cups_connection_test = NULL;
printer->auth_info_required = NULL;
+ printer->default_number_up = 1;
}
static void
diff --git a/modules/printbackends/cups/gtkprintercups.h b/modules/printbackends/cups/gtkprintercups.h
index e8dae06..ecc5e38 100644
--- a/modules/printbackends/cups/gtkprintercups.h
+++ b/modules/printbackends/cups/gtkprintercups.h
@@ -61,6 +61,8 @@ struct _GtkPrinterCups
gchar *default_cover_before;
gchar *default_cover_after;
+ gint default_number_up;
+
gboolean remote;
guint get_remote_ppd_poll;
gint get_remote_ppd_attempts;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]