Sophie

Sophie

distrib > Mandriva > 2009.0 > x86_64 > media > main-testing-src > by-pkgid > 31aa94742bb6cc6735ea4eaf2978fce1 > files > 2

system-config-printer-1.0.16-0.1mdv2009.0.src.rpm

--- system-config-printer-1.0.12/applet.py	2008-11-30 14:47:27.000000000 -0800
+++ system-config-printer-1.0.12/applet.py.new	2008-12-26 14:11:57.000000000 -0800
@@ -17,6 +17,7 @@
 ## along with this program; if not, write to the Free Software
 ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
+import mdv_printer_custom
 import cups
 import sys
 import statereason
@@ -101,6 +102,131 @@
 
         return False
 
+    @dbus.service.method(PDS_IFACE, in_signature='', out_signature='b')
+    def InstallSpooler (self):
+        import os
+        packages2install = ['task-printing-server', 'hplip-model-data']
+        """,
+        'cups',
+        'foomatic-db',
+        'foomatic-db-engine',
+        'foomatic-db-hpijs',
+        'foomatic-filters',
+        'gutenprint-cups',
+        'gutenprint-foomatic',
+        'hplip-model-data']
+        """
+        packages = []
+        for package in packages2install:
+            if not mdv_printer_custom.is_installed_packages([package]):
+                packages.append(package)
+
+        # spooler installed if packages is empty
+        if packages.__len__() == 0:
+            return True
+
+        title = _("Installing Printing System..")
+        text = _("Installing Printing System. Please wait...")
+        n = pynotify.Notification (title, text, 'printer')
+        n.set_urgency (pynotify.URGENCY_NORMAL)
+        n.show()
+
+        if mdv_printer_custom.install_packages(packages):
+            return True
+        else:
+            return False
+
+    @dbus.service.method(PDS_IFACE, in_signature='ss', out_signature='')
+    def InstallingPrinter (self, make, model):
+        printer = make+" "+model
+        title = _("Installing printer")
+        text = _("Installing `%s'. Please wait...") % (printer)
+        n = pynotify.Notification (title, text, 'printer')
+        n.set_urgency (pynotify.URGENCY_NORMAL)
+        n.show()
+
+    @dbus.service.method(PDS_IFACE, in_signature='ss', out_signature='')
+    def PrinterDisabled (self, make, model):
+        printer = make+" "+model
+        title = _("Printer disabled")
+        text = _("The printer `%s' is disabled") % (printer)
+        n = pynotify.Notification (title, text, 'printer')
+        n.set_urgency (pynotify.URGENCY_CRITICAL)
+        n.show()
+
+    @dbus.service.method(PDS_IFACE, in_signature='', out_signature='')
+    def InstallSpoolerFailed (self):
+        title = _("Installation failed")
+        text = _("The printing system installation has failed")
+        n = pynotify.Notification (title, text, 'printer')
+        n.set_urgency (pynotify.URGENCY_CRITICAL)
+        n.set_timeout (pynotify.EXPIRES_NEVER)
+        n.show()
+
+    @dbus.service.method(PDS_IFACE, in_signature='', out_signature='')
+    def SpoolerStartFailed (self):
+        title = _("Printing system failed")
+        text = _("It was not possible to start the printing system")
+        n = pynotify.Notification (title, text, 'printer')
+        n.set_urgency (pynotify.URGENCY_CRITICAL)
+        n.set_timeout (pynotify.EXPIRES_NEVER)
+        n.show()
+
+    @dbus.service.method(PDS_IFACE, in_signature='ss', out_signature='b')
+    def PrinterFirmwareDownload (self, make, model):
+        import gtk
+        printer = make+" "+model
+        title = _("Firmware Required")
+        text = _("The printer `%s' requires firmware") % (printer)
+        n = pynotify.Notification (title, text, 'printer')
+        n.set_urgency (pynotify.URGENCY_NORMAL)
+        n.show()
+        string = _("Do you want to download the firmware for `%s' from the internet?") % (model)
+        dialog = gtk.MessageDialog(flags=0, type=gtk.MESSAGE_WARNING,buttons=gtk.BUTTONS_YES_NO, message_format=string)
+        result = dialog.run()
+        dialog.destroy()
+        if result==gtk.RESPONSE_YES:
+            return True
+        return False
+
+    @dbus.service.method(PDS_IFACE, in_signature='ss', out_signature='')
+    def PrinterEnabled (self, make, model):
+        self.wake_up ()
+        """Hack to make kde4 system tray show the icon"""
+        viewer.set_special_statusicon (SEARCHING_ICON)
+        viewer.unset_special_statusicon ()
+
+        printer = make+" "+model
+        title = _("Printer enabled")
+        text = _("The printer `%s' is enabled") % (printer)
+        n = pynotify.Notification (title, text, 'printer')
+        n.set_urgency (pynotify.URGENCY_NORMAL)
+        n.show()
+
+    @dbus.service.method(PDS_IFACE, in_signature='ss', out_signature='')
+    def MissingDriver (self, make, model):
+        printer = make+" "+model
+        title = _("Missing printer driver")
+        text = _("It is not possible to install `%s' without the right driver") % (printer)
+        n = pynotify.Notification (title, text, 'printer')
+        n.set_urgency (pynotify.URGENCY_CRITICAL)
+        n.set_timeout (pynotify.EXPIRES_NEVER)
+        n.show()
+
+    @dbus.service.method(PDS_IFACE, in_signature='ssas', out_signature='b')
+    def InstallDriver (self, make, model, packages):
+        import os
+        printer = make+" "+model
+        title = _("Install printer driver")
+        text = _("`%s' requires driver installation") % (printer)
+        n = pynotify.Notification (title, text, 'printer')
+        n.set_urgency (pynotify.URGENCY_NORMAL)
+        n.show()
+        if mdv_printer_custom.install_packages(packages):
+             return True
+        else:
+             return False
+
     @dbus.service.method(PDS_IFACE, in_signature='isssss', out_signature='')
     def NewPrinter (self, status, name, mfg, mdl, des, cmd):
         #status = 1
@@ -141,18 +267,20 @@
             pkgs = reduce (lambda x,y: x + ", " + y, missing_pkgs)
             title = _("Install printer driver")
             text = _("`%s' requires driver installation: %s.") % (name, pkgs)
-            n = pynotify.Notification (title, text)
+            n = pynotify.Notification (title, text, 'printer')
             n.set_urgency (pynotify.URGENCY_CRITICAL)
             if os.access (self.INSTALL_PACKAGES_COMMAND, os.X_OK):
                 n.add_action ("install-driver", _("Install"),
                               lambda x, y: self.install_driver (x, y,
                                                                 missing_pkgs))
+            n.show()
         elif status == self.STATUS_SUCCESS:
             text = _("`%s' is ready for printing.") % name
-            n = pynotify.Notification (title, text)
+            n = pynotify.Notification (title, text, 'printer')
             n.set_urgency (pynotify.URGENCY_NORMAL)
             n.add_action ("configure", _("Configure"),
                           lambda x, y: self.configure (x, y, name))
+            n.show()
         else: # Model mismatch
             devid = "MFG:%s;MDL:%s;DES:%s;CMD:%s;" % \
                 (mfg, mdl, des, cmd)
@@ -164,6 +292,7 @@
                           lambda x, y: self.find_driver (x, y, name, devid))
 
         n.set_timeout (pynotify.EXPIRES_NEVER)
+        n.show()
         viewer.notify_new_printer (name, n)
         # Set the icon back how it was.
         self.timeout_ready ()
@@ -241,6 +370,7 @@
 
 if __name__ == '__main__':
     import sys, getopt
+
     try:
         opts, args = getopt.gnu_getopt (sys.argv[1:], '',
                                         ['no-tray-icon',