summaryrefslogtreecommitdiff
path: root/modules/printbackends
diff options
context:
space:
mode:
authorMarek Kasik <mkasik@redhat.com>2012-04-17 17:12:56 +0200
committerMarek Kasik <mkasik@redhat.com>2012-04-20 17:04:58 +0200
commitf6e2d0947d9f0d17e0a52b0e0d0046c4fd787912 (patch)
tree0549e88e2186e0cdcfa9aecb20534833aa05905f /modules/printbackends
parent516fb8906594521a80ccbf8d6d2b2f347a1e7d90 (diff)
downloadgtk+-f6e2d0947d9f0d17e0a52b0e0d0046c4fd787912.tar.gz
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)
Diffstat (limited to 'modules/printbackends')
-rw-r--r--modules/printbackends/cups/gtkprintbackendcups.c83
-rw-r--r--modules/printbackends/cups/gtkprintercups.c1
-rw-r--r--modules/printbackends/cups/gtkprintercups.h2
3 files changed, 50 insertions, 36 deletions
diff --git a/modules/printbackends/cups/gtkprintbackendcups.c b/modules/printbackends/cups/gtkprintbackendcups.c
index f7081daef3..3a250bb424 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 e8c652f426..3a45e2f6da 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 e8dae061e8..ecc5e38d3e 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;