Skip to content

Commit

Permalink
Added bindings for ppdLocalizeIPPReason and ppdLocalizeMarkerName.
Browse files Browse the repository at this point in the history
	* cupsppd.c (PPD_localizeIPPReason): New method.
	(PPD_localizeMarkerName): Likewise.
  • Loading branch information
twaugh committed Dec 23, 2008
1 parent bd3d70a commit 3ff3789
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2008-12-23 Tim Waugh <twaugh@redhat.com>

* cupsppd.c (PPD_localizeIPPReason): New method.
(PPD_localizeMarkerName): Likewise.

2008-12-17 Tim Waugh <twaugh@redhat.com>

* cupsconnection.c (Connection_printTestPage): Look for
Expand Down
5 changes: 5 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
NEWS
----

New in 1.9.45:

* cups.PPD.localizeIPPReason()
* cups.PPD.localizeMarkerName()

New in 1.9.42:

* cups.Connection.getJobAttributes() now takes optional requested_attributes
Expand Down
66 changes: 66 additions & 0 deletions cupsppd.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,62 @@ PPD_localize (PPD *self)
return PyErr_SetFromErrno (PyExc_RuntimeError);
}

static PyObject *
PPD_localizeIPPReason (PPD *self, PyObject *args, PyObject *kwds)
{
PyObject *ret;
const char *reason;
const char *scheme = NULL;
char *buffer;
const size_t bufsize = 1024;
static char *kwlist[] = { "reason", "scheme", NULL };

if (!PyArg_ParseTupleAndKeywords (args, kwds, "s|s", kwlist,
&reason, &scheme))
return NULL;

buffer = malloc (bufsize);
if (ppdLocalizeIPPReason (self->ppd, reason, scheme, buffer, bufsize))
{
ret = make_PyUnicode_from_ppd_string (self, buffer);
} else {
ret = Py_None;
Py_INCREF (Py_None);
}

free (buffer);
return ret;
}

static PyObject *
PPD_localizeMarkerName (PPD *self, PyObject *args)
{
#if CUPS_VERSION_MAJOR > 1 || (CUPS_VERSION_MAJOR == 1 && CUPS_VERSION_MINOR >= 4)
PyObject *ret;
const char *name;
const char *lname;

if (!PyArg_ParseTuple (args, "s", &name))
return NULL;

lname = ppdLocalizeMarkerName (self->ppd, name);

if (lname != NULL)
{
ret = make_PyUnicode_from_ppd_string (self, lname);
} else {
ret = Py_None;
Py_INCREF (Py_None);
}

return ret;
#else /* earlier than CUPS 1.4 */
PyErr_SetString (PyExc_RuntimeError,
"Operation not supported - recompile against CUPS 1.4 or later");
return NULL;
#endif /* CUPS 1.4 */
}

static PyObject *
PPD_markDefaults (PPD *self)
{
Expand Down Expand Up @@ -641,6 +697,16 @@ PyMethodDef PPD_methods[] =
"localize() -> None\n\n"
"Localize PPD to the current locale." },

{ "localizeIPPReason",
(PyCFunction) PPD_localizeIPPReason, METH_VARARGS | METH_KEYWORDS,
"localizeIPPReason(reason, scheme) -> string or None\n\n"
"Localize IPP reason to the current locale." },

{ "localizeMarkerName",
(PyCFunction) PPD_localizeMarkerName, METH_VARARGS,
"localizeMarkerName(name) -> string or None\n\n"
"Localize marker name to the current locale." },

{ "markDefaults",
(PyCFunction) PPD_markDefaults, METH_NOARGS,
"markDefaults() -> None\n\n"
Expand Down

0 comments on commit 3ff3789

Please sign in to comment.