rpms/system-config-printer/F-12 system-config-printer-custom-state-reasons.patch, NONE, 1.1 system-config-printer.spec, 1.305, 1.306

Tim Waugh twaugh at fedoraproject.org
Thu Oct 29 17:32:41 UTC 2009


Author: twaugh

Update of /cvs/pkgs/rpms/system-config-printer/F-12
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv28137

Modified Files:
	system-config-printer.spec 
Added Files:
	system-config-printer-custom-state-reasons.patch 
Log Message:
* Thu Oct 29 2009 Tim Waugh <twaugh at redhat.com> 1.1.13-5
- Added upstream patch for custom state reasons (bug #531872).


system-config-printer-custom-state-reasons.patch:
 monitor.py                          |    4 ++--
 statereason.py                      |   27 ++++++++++++++++++++++++---
 system-config-printer.py            |    5 +++--
 troubleshoot/PrinterStateReasons.py |    2 +-
 4 files changed, 30 insertions(+), 8 deletions(-)

--- NEW FILE system-config-printer-custom-state-reasons.patch ---
diff -up system-config-printer-1.1.13/monitor.py.custom-state-reasons system-config-printer-1.1.13/monitor.py
--- system-config-printer-1.1.13/monitor.py.custom-state-reasons	2009-09-04 10:35:48.000000000 +0100
+++ system-config-printer-1.1.13/monitor.py	2009-10-29 17:18:46.813021287 +0000
@@ -62,7 +62,7 @@ def collect_printer_state_reasons (conne
                 continue
             if not result.has_key (name):
                 result[name] = []
-            result[name].append (StateReason (name, reason))
+            result[name].append (StateReason (connection, name, reason))
     return result
 
 class Watcher:
@@ -408,7 +408,7 @@ class Monitor:
                             break
                         if state_reason_is_harmless (reason):
                             continue
-                        reasons.append (StateReason (name, reason))
+                        reasons.append (StateReason (c, name, reason))
                     self.printer_state_reasons[name] = reasons
 
                     deferred_calls.append ((self.watcher.printer_event,
diff -up system-config-printer-1.1.13/statereason.py.custom-state-reasons system-config-printer-1.1.13/statereason.py
--- system-config-printer-1.1.13/statereason.py.custom-state-reasons	2009-09-04 10:35:48.000000000 +0100
+++ system-config-printer-1.1.13/statereason.py	2009-10-29 17:18:46.814020769 +0000
@@ -17,6 +17,8 @@
 ## along with this program; if not, write to the Free Software
 ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
+import cups
+
 _ = lambda x: x
 def set_gettext_function (fn):
     global _
@@ -33,11 +35,12 @@ class StateReason:
         ERROR: "dialog-error"
         }
 
-    def __init__(self, printer, reason):
+    def __init__(self, connection, printer, reason):
         self.printer = printer
         self.reason = reason
         self.level = None
         self.canonical_reason = None
+        self.connection = connection
 
     def get_printer (self):
         return self.printer
@@ -53,6 +56,7 @@ class StateReason:
             self.level = self.WARNING
         else:
             self.level = self.ERROR
+
         return self.level
 
     def get_reason (self):
@@ -69,6 +73,7 @@ class StateReason:
         return self.canonical_reason
 
     def __repr__ (self):
+        self.get_level()
         if self.level == self.REPORT:
             level = "REPORT"
         elif self.level == self.WARNING:
@@ -119,8 +124,24 @@ class StateReason:
                 title = _("Printer warning")
             elif self.get_level () == self.ERROR:
                 title = _("Printer error")
-            text = _("Printer '%s': '%s'.") % (self.get_printer (),
-                                               self.get_reason ())
+
+            try:
+                f = self.connection.getPPD(self.printer)
+                ppd = cups.PPD (f)
+                schemes = ["text", "http", "help", "file"]
+                localized_reason = ""
+                for scheme in schemes:
+                    reason = ppd.localizeIPPReason(self.reason, scheme)
+                    if reason != None:
+                        localized_reason = localized_reason + reason + ", "
+                if localized_reason != "":
+                    reason = localized_reason[:-2]
+                else:
+                    reason = self.get_reason()
+            except cups.IPPError:
+                reason = self.get_reason()
+
+            text = _("Printer '%s': '%s'.") % (self.get_printer (), reason)
         return (title, text)
 
     def get_tuple (self):
diff -up system-config-printer-1.1.13/system-config-printer.py.custom-state-reasons system-config-printer-1.1.13/system-config-printer.py
--- system-config-printer-1.1.13/system-config-printer.py.custom-state-reasons	2009-10-29 16:51:28.567896668 +0000
+++ system-config-printer-1.1.13/system-config-printer.py	2009-10-29 17:18:46.816896209 +0000
@@ -1445,7 +1445,8 @@ class GUI(GtkGUI, monitor.Watcher):
                             emblem = gtk.STOCK_MEDIA_PAUSE
                             continue
 
-                        r = statereason.StateReason (object.name, reason)
+                        r = statereason.StateReason (object.connection,
+                                                     object.name, reason)
                         if worst_reason == None:
                             worst_reason = r
                         elif r > worst_reason:
@@ -2579,7 +2580,7 @@ class GUI(GtkGUI, monitor.Watcher):
 
             any = True
             iter = store.append (None)
-            r = statereason.StateReason (printer.name, reason)
+            r = statereason.StateReason (printer.connection, printer.name, reason)
             if r.get_reason () == "paused":
                 icon = gtk.STOCK_MEDIA_PAUSE
             else:
diff -up system-config-printer-1.1.13/troubleshoot/PrinterStateReasons.py.custom-state-reasons system-config-printer-1.1.13/troubleshoot/PrinterStateReasons.py
--- system-config-printer-1.1.13/troubleshoot/PrinterStateReasons.py.custom-state-reasons	2009-09-04 10:35:48.000000000 +0100
+++ system-config-printer-1.1.13/troubleshoot/PrinterStateReasons.py	2009-10-29 17:18:46.817896728 +0000
@@ -71,7 +71,7 @@ class PrinterStateReasons(Question):
             if reason == "none":
                 continue
 
-            r = statereason.StateReason (queue, reason)
+            r = statereason.StateReason (c, queue, reason)
             (title, description) = r.get_description ()
             level = r.get_level ()
             if level == statereason.StateReason.ERROR:


Index: system-config-printer.spec
===================================================================
RCS file: /cvs/pkgs/rpms/system-config-printer/F-12/system-config-printer.spec,v
retrieving revision 1.305
retrieving revision 1.306
diff -u -p -r1.305 -r1.306
--- system-config-printer.spec	29 Oct 2009 17:26:45 -0000	1.305
+++ system-config-printer.spec	29 Oct 2009 17:32:41 -0000	1.306
@@ -30,6 +30,7 @@ Patch12: system-config-printer-jobs-wind
 Patch13: system-config-printer-strip-zxs-pcl3.patch
 Patch14: system-config-printer-troubleshoot-network-printers.patch
 Patch15: system-config-printer-strip-zjs.patch
+Patch16: system-config-printer-custom-state-reasons.patch
 
 BuildRequires: cups-devel >= 1.2
 BuildRequires: python-devel >= 2.4
@@ -105,6 +106,7 @@ printers.
 %patch13 -p1 -b .strip-zxs-pcl3
 %patch14 -p1 -b .troubleshoot-network-printers
 %patch15 -p1 -b .strip-zjs
+%patch16 -p1 -b .custom-state-reasons
 
 %build
 %configure --with-udev-rules --with-polkit-1
@@ -217,6 +219,7 @@ exit 0
 
 %changelog
 * Thu Oct 29 2009 Tim Waugh <twaugh at redhat.com> 1.1.13-5
+- Added upstream patch for custom state reasons (bug #531872).
 - Strip 'zjs' from make-and-model as well (bug #531869).
 
 * Wed Oct 28 2009 Tim Waugh <twaugh at redhat.com> 1.1.13-4




More information about the fedora-extras-commits mailing list