Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 159409 Details for
Bug 157878
lpoptions ignored
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
patch for CUPS GtkPrint backend to honor ~/.cups/lpoptions
gtk+-2.10.8-cups-user-options.patch (text/plain), 5.28 KB, created by
Stijn Hoop
on 2007-07-17 08:23:01 UTC
(
hide
)
Description:
patch for CUPS GtkPrint backend to honor ~/.cups/lpoptions
Filename:
MIME Type:
Creator:
Stijn Hoop
Created:
2007-07-17 08:23:01 UTC
Size:
5.28 KB
patch
obsolete
>--- gtk+-2.10.8/modules/printbackends/cups/gtkprintbackendcups.c.cups-user-options 2007-07-17 09:14:40.000000000 +0200 >+++ gtk+-2.10.8/modules/printbackends/cups/gtkprintbackendcups.c 2007-07-17 10:05:54.000000000 +0200 >@@ -19,6 +19,7 @@ > * Boston, MA 02111-1307, USA. > */ > >+#include <ctype.h> > #include <unistd.h> > #include <sys/types.h> > #include <sys/stat.h> >@@ -1340,6 +1341,107 @@ > (GDestroyNotify)get_ppd_data_free); > } > >+static int >+cups_parse_lpoptions (const char *filename, >+ char **printer_name, >+ int num_options, >+ cups_option_t **options) >+{ >+ FILE *fp; >+ char line[1024], *lineptr, *name, *default_name = NULL; >+ >+ /* Code taken from CUPS 1.2.10 source, cups_get_dests function */ >+ if ((fp = fopen (filename, "r")) == NULL) >+ return num_options; >+ >+ while (fgets (line, sizeof(line), fp) != NULL) >+ { >+ if (strncasecmp (line, "dest", 4) == 0 && isspace (line[4] & 255)) >+ lineptr = line + 4; >+ else if (strncasecmp (line, "default", 7) == 0 && isspace (line[7] & 255)) >+ lineptr = line + 7; >+ else >+ continue; >+ >+ /* Skip leading whitespace */ >+ while (isspace(*lineptr & 255)) >+ lineptr++; >+ >+ if (!*lineptr) >+ continue; >+ >+ /* Strip any instance name off of the name */ >+ name = lineptr; >+ while (!isspace (*lineptr & 255) && *lineptr && *lineptr != '/') >+ lineptr++; >+ >+ if (!*lineptr) >+ continue; >+ >+ if (*lineptr == '/') >+ { >+ *lineptr++ = '\0'; >+ >+ while (!isspace (*lineptr & 255) && *lineptr) >+ lineptr++; >+ } >+ >+ *lineptr++ = '\0'; >+ >+ /* Check to see what we're looking for -- printer_name == NULL signifies >+ * searching for the default printer, otherwise we want the options >+ * for a specific one. */ >+ if (*printer_name == NULL) >+ { >+ if (strncasecmp (line, "default", 7) != 0) >+ continue; >+ >+ if (default_name != NULL) >+ g_free (default_name); >+ default_name = g_strdup (name); >+ } >+ else if (strncasecmp (name, *printer_name, strlen (*printer_name)) != 0) >+ continue; >+ >+ /* We found our printer, parse the options */ >+ num_options = cupsParseOptions (lineptr, num_options, options); >+ } >+ >+ if (*printer_name == NULL && default_name != NULL) >+ *printer_name = default_name; >+ >+ fclose(fp); >+ >+ return num_options; >+} >+ >+static int >+cups_get_user_options(char **printer_name, >+ int num_options, >+ cups_option_t **options) >+{ >+ const char *home; >+ char *filename; >+ >+ num_options = cups_parse_lpoptions ("/etc/cups/lpoptions", printer_name, >+ num_options, options); >+ >+ /* XXX: not on win32 I guess -- is this relevant in the cups backend? */ >+ if ((home = getenv("HOME")) != NULL) >+ { >+ filename = g_strdup_printf ("%s/.cups/lpoptions", home); >+ num_options = cups_parse_lpoptions (filename, printer_name, num_options, >+ options); >+ g_free (filename); >+ >+ filename = g_strdup_printf ("%s/.lpoptions", home); >+ num_options = cups_parse_lpoptions (filename, printer_name, num_options, >+ options); >+ g_free (filename); >+ } >+ >+ return num_options; >+} > > static void > cups_request_default_printer_cb (GtkPrintBackendCups *print_backend, >@@ -1368,6 +1470,9 @@ > { > GtkCupsRequest *request; > const char *str; >+ char *name = NULL; >+ int num_opts; >+ cups_option_t *opts = NULL; > > if ((str = g_getenv ("LPDEST")) != NULL) > { >@@ -1383,6 +1488,17 @@ > return; > } > >+ /* Figure out user setting for default printer */ >+ num_opts = cups_get_user_options(&name, 0, &opts); >+ cupsFreeOptions(num_opts, opts); >+ >+ if (name != NULL) >+ { >+ print_backend->default_printer = name; >+ print_backend->got_default_printer = TRUE; >+ return; >+ } >+ > request = gtk_cups_request_new (NULL, > GTK_CUPS_POST, > CUPS_GET_DEFAULT, >@@ -2143,6 +2259,9 @@ > char *prio_display[] = {N_("Urgent"), N_("High"), N_("Medium"), N_("Low") }; > char *cover[] = {"none", "classified", "confidential", "secret", "standard", "topsecret", "unclassified" }; > char *cover_display[] = {N_("None"), N_("Classified"), N_("Confidential"), N_("Secret"), N_("Standard"), N_("Top Secret"), N_("Unclassified"),}; >+ char *name; >+ int num_opts; >+ cups_option_t *opts = NULL; > > > set = gtk_printer_option_set_new (); >@@ -2239,6 +2358,25 @@ > handle_group (set, ppd_file, &ppd_file->groups[i], &ppd_file->groups[i], settings); > } > >+ /* Now honor the user set defaults for this printer */ >+ name = g_strdup (gtk_printer_get_name (printer)); >+ num_opts = cups_get_user_options(&name, 0, &opts); >+ g_free (name); >+ >+ for (i = 0; i < num_opts; i++) >+ { >+ if (STRING_IN_TABLE (opts->name, cups_option_blacklist)) >+ continue; >+ >+ name = get_option_name (opts[i].name); >+ option = gtk_printer_option_set_lookup (set, name); >+ if (option) >+ gtk_printer_option_set (option, opts[i].value); >+ g_free (name); >+ } >+ >+ cupsFreeOptions(num_opts, opts); >+ > return set; > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 157878
:
158429
| 159409