Beispiel #1
0
 def setupKDE(app, wnd):
     try:
         icons = KIconLoader()
         systray = KSystemTray(wnd)
         systray.setPixmap(icons.loadIcon("kedit", 1))
         QToolTip.add(systray, "PyQLogger - Blogger GUI")
         systray.show()
     except Exception, inst:
         sys.stderr.write("setupKDE: cannot set tray, exception: %s\n" %
                          inst)
Beispiel #2
0
 def _setupTray(app, wnd):
     try:
         icons = KIconLoader()
         systray = KSystemTray(wnd["Class"])
         p = QPixmap()
         p.loadFromData(icon)
         systray.setPixmap(p)
         QToolTip.add(systray, "PyQLogger - Blogger GUI")
         systray.show()
         wnd["Impl"].systray = systray
     except Exception, inst:
         sys.stderr.write(
             "setupKDE: cannot set tray, exception: %s\n" %
             inst)
Beispiel #3
0
 def startSmart(self):
     if self.state != KSmartTray.State.Waiting:
         KNotifyClient.event(self.sysTray.winId(), "fatalerror",
                             "There is a running process.")
     else:
         self.sysTray.checkAction.setEnabled(False)
         self.sysTray.startSmartAction.setEnabled(False)
         self.sysTray.stopAction.setEnabled(False)
         self.process.resetAll()
         self.process.setArguments(["kdesu", "-d", "-c", "smart --gui"])
         if not self.process.start():
             KNotifyClient.event(self.sysTray.winId(), "fatalerror",
                                 "Couldn't run 'smart'.")
         else:
             self.state = KSmartTray.State.RunningSmart
             QToolTip.remove(self.sysTray)
             QToolTip.add(self.sysTray, "Running Smart Package Manager...")
 def startSmart(self):
     if self.state != KSmartTray.State.Waiting:
         KNotifyClient.event(self.sysTray.winId(), "fatalerror",
                              "There is a running process.")
     else:
         self.sysTray.checkAction.setEnabled(False)
         self.sysTray.startSmartAction.setEnabled(False)
         self.sysTray.stopAction.setEnabled(False)
         self.process.resetAll()
         self.process.setArguments(["kdesu", "-d", "-c", "smart --gui"])
         if not self.process.start():
             KNotifyClient.event(self.sysTray.winId(), "fatalerror",
                                  "Couldn't run 'smart'.")
         else:
             self.state = KSmartTray.State.RunningSmart
             QToolTip.remove(self.sysTray)
             QToolTip.add(self.sysTray, "Running Smart Package Manager...")
Beispiel #5
0
 def internalCheckUpgrades(self, manual):
     if not manual and self.blinkTimer.isActive():
         return
     if self.state == KSmartTray.State.Waiting:
         self.sysTray.checkAction.setEnabled(False)
         self.sysTray.startSmartAction.setEnabled(False)
         self.sysTray.stopAction.setEnabled(True)
         self.process.resetAll()
         if manual:
             self.process.setArguments(["smart-update"])
         else:
             self.process.setArguments(["smart-update", "--after", "60"])
         if not self.process.start():
             KNotifyClient.event(self.sysTray.winId(), "fatalerror",
                                 "Couldn't run 'smart-update'.")
         else:
             QToolTip.add(self.sysTray, "Updating channels...")
             self.state = KSmartTray.State.Updating
 def internalCheckUpgrades(self, manual):
     if not manual and self.blinkTimer.isActive():
         return
     if self.state == KSmartTray.State.Waiting:
         self.sysTray.checkAction.setEnabled(False)
         self.sysTray.startSmartAction.setEnabled(False)
         self.sysTray.stopAction.setEnabled(True)
         self.process.resetAll()
         if manual:
             self.process.setArguments(["smart-update"])
         else:
             self.process.setArguments(["smart-update", "--after", "60"])
         if not self.process.start():
             KNotifyClient.event(self.sysTray.winId(), "fatalerror",
                                  "Couldn't run 'smart-update'.")
         else:
             QToolTip.add(self.sysTray, "Updating channels...")
             self.state = KSmartTray.State.Updating
 def SimpleButton(parent, title, handler, page=None, image=None):
     tabpage = parent.getPage(page)
     button = QPushButton(tabpage)
     if image:
         bi = QPixmap()
         bi.loadFromData(image, "PNG")
         button.setIconSet(QIconSet(bi))
         w = bi.width() + 3
         h = bi.height() + 3
         if w < 32:
             w = 32
         if h < 32:
             h = 32
         button.setMaximumSize(QSize(w, h))
     else:
         button.setText(title)
     QToolTip.add(button, title)
     parent.connect(button, SIGNAL("clicked()"), handler)
     button.show()
     p = ToolbarPlugin(parent)
     p.getWidget = lambda: button
 def SimpleButton(parent, title, handler, page=None, image=None):
     tabpage = parent.getPage(page)
     button = QPushButton(tabpage)
     if image : 
         bi = QPixmap()
         bi.loadFromData(image, "PNG")
         button.setIconSet(QIconSet(bi))
         w = bi.width()+3
         h = bi.height()+3
         if w < 32:
             w = 32
         if h < 32:
             h = 32
         button.setMaximumSize(QSize(w, h))
     else:
         button.setText(title)
     QToolTip.add(button, title)
     parent.connect(button, SIGNAL("clicked()"), handler)
     button.show()
     p = ToolbarPlugin(parent)
     p.getWidget = lambda: button
Beispiel #9
0
    def timeoutSlot(self):
        interfaceName = self.wirelessInterface.returnInterfaceName()
        interfaceESSID = self.wirelessInterface.returnESSID()
        interfaceMode = self.wirelessInterface.returnMode()
        linkStatus = self.wirelessInterface.returnLinkStatus()
        noiseStatus = self.wirelessInterface.returnNoiseStatus()
        signalStatus = self.wirelessInterface.returnSignalStatus()
        bitRate = self.wirelessInterface.returnBitrate()
        received = self.wirelessInterface.returnReceived()
        transferred = self.wirelessInterface.returnTransferred()
        status = self.wirelessInterface.returnInterfaceStatus()
        ''' Tray icon name '''
        if int(status):
            index = int(linkStatus) / 20
            iconName = 'pywireless_' + str(index)
            ''' Tooltip '''
            toolTip = _('''<center><img align="center" src="/usr/share/PyWireless/%s.png"></center>
            <center>
            <table border="0" bgcolor="#000000" cellspacing="1" cellpadding="1">
            <tr>
                <td colspan="2" bgcolor="#04CC1A"><center><b>Monitoring:</b> [ %s ]</b></center></td>
            <tr>
                <td bgcolor="#CCCCCC"><b>ESSID:</b></td>
                <td bgcolor="#CCCCCC"><center>%s</center></td>
            </tr>
            <tr>
                <td bgcolor="#EEEEEE"><b>Link Quality:</b></td>
                    <td bgcolor="#EEEEEE"><center>%d</center></td>
            </tr>
            <tr>
                <td bgcolor="#CCCCCC"><b>Bitrate:</b></td>
                <td bgcolor="#CCCCCC"><center>%s</center></td>
            </tr>
            <tr>
               <td bgcolor="#EEEEEE"><b>Mode:</b></td>
                <td bgcolor="#EEEEEE"><center>%s</center></td>
            </tr>
            <tr>
                <td bgcolor="#CCCCCC"><b>Noise Level:</b></td>
                <td bgcolor="#CCCCCC"><center>%d dBm</center></td>
            </tr>
            <tr>
                <td bgcolor="#EEEEEE"><b>Signal Level:</b></td>
                <td bgcolor="#EEEEEE"><center>%d dBm</center></td>
            </tr>
            <tr>
                <td bgcolor="#CCCCCC"><b>Received:</b></td>
                <td bgcolor="#CCCCCC"><center>%s</center></td>
            </tr>
            <tr>
                <td bgcolor="#EEEEEE"><b>Transferred:</b></td>
                <td bgcolor="#EEEEEE"><center>%s</center></td>
            </tr>
            </table>
            </center>
            ''') % (iconName, interfaceName, interfaceESSID, \
                    linkStatus, bitRate, interfaceMode, \
                    noiseStatus, signalStatus, received, transferred)
        else:
            iconName = 'pywireless'
            toolTip = _(
                '''<center><img align="center" src="/usr/share/PyWireless/%s.png"></center>
            <center>
            <table border="0" bgcolor="#000000" cellspacing="1" cellpadding="1">
            <tr>
                <td colspan="2" bgcolor="#DD0500"><center>[ %s ] <b>is powered off</b></center></td>
            tr>
            </table>
            </center>''') % (iconName, interfaceName)

        QToolTip.add(self, toolTip)
        self.setPixmap(self.icons.loadIcon(iconName, KIcon.Desktop, 22))
Beispiel #10
0
    def processDone(self, process):
        if self.state == KSmartTray.State.Updating:
            if not process.normalExit() or process.exitStatus() != 0:
                self.updateFailed = True
            if self.updateFailed and not self.lastKnownStatus == "":
                self.state = KSmartTray.State.Waiting
            else:
                process.resetAll()
                process.setArguments(["smart", "upgrade", "--check-update"])
                if not process.start():
                    KNotifyClient.event(self.sysTray.winId(), "fatalerror",
                                        "Couldn't run 'smart upgrade'.")
                    self.state = KSmartTray.State.Waiting
                    self.lastKnownStatus = ""
                else:
                    QToolTip.remove(self.sysTray)
                    QToolTip.add(self.sysTray,
                                 "Verifying upgradable packages...")
                    self.state = KSmartTray.State.Checking
        elif self.state == KSmartTray.State.Checking:
            self.state = KSmartTray.State.Waiting
            if process.normalExit():
                if process.exitStatus() == 0:
                    self.lastKnownStatus = "There are new upgrades available!"
                    KNotifyClient.event(self.sysTray.winId(),
                                        "found-new-upgrades",
                                        self.lastKnownStatus)
                    self.emit(PYSIGNAL("foundNewUpgrades()"), ())
                elif process.exitStatus() == 1:
                    self.lastKnownStatus = "There are pending upgrades!"
                    if not self.updateFailed:
                        KNotifyClient.event(self.sysTray.winId(),
                                            "found-old-upgrades",
                                            self.lastKnownStatus)
                    self.emit(PYSIGNAL("foundOldUpgrades()"), ())
                elif process.exitStatus() == 2:
                    self.lastKnownStatus = "No interesting upgrades available."
                    if not self.updateFailed:
                        KNotifyClient.event(self.sysTray.winId(),
                                            "found-no-upgrades",
                                            self.lastKnownStatus)
                    self.emit(PYSIGNAL("foundNoUpgrades()"), ())
                else:
                    self.lastKnownStatus = ""
        elif self.state == KSmartTray.State.Upgrading:
            self.state = KSmartTray.State.Waiting
            self.lastKnownStatus = ""
        elif self.state == KSmartTray.State.RunningSmart:
            self.state = KSmartTray.State.Waiting
            self.lastKnownStatus = ""
        else:
            # Error!
            pass

        if self.state == KSmartTray.State.Waiting:
            self.updateFailed = False
            self.sysTray.checkAction.setEnabled(True)
            self.sysTray.startSmartAction.setEnabled(True)
            self.sysTray.stopAction.setEnabled(False)
            if not self.lastKnownStatus == "":
                QToolTip.remove(self.sysTray)
                QToolTip.add(self.sysTray, self.lastKnownStatus)
            else:
                QToolTip.remove(self.sysTray)
    def processDone(self, process):
        if self.state == KSmartTray.State.Updating:
            if not process.normalExit() or process.exitStatus() != 0:
                self.updateFailed = True
            if self.updateFailed and not self.lastKnownStatus == "":
                self.state = KSmartTray.State.Waiting
            else:
                process.resetAll()
                process.setArguments(["smart", "upgrade", "--check-update"])
                if not process.start():
                    KNotifyClient.event(self.sysTray.winId(), "fatalerror",
                                         "Couldn't run 'smart upgrade'.")
                    self.state = KSmartTray.State.Waiting
                    self.lastKnownStatus = ""
                else:
                    QToolTip.remove(self.sysTray)
                    QToolTip.add(self.sysTray,
                                  "Verifying upgradable packages...")
                    self.state = KSmartTray.State.Checking
        elif self.state == KSmartTray.State.Checking:
            self.state = KSmartTray.State.Waiting
            if process.normalExit():
                if process.exitStatus() == 0:
                    self.lastKnownStatus = "There are new upgrades available!"
                    KNotifyClient.event(self.sysTray.winId(), "found-new-upgrades",
                                         self.lastKnownStatus)
                    self.emit(PYSIGNAL("foundNewUpgrades()"), ())
                elif process.exitStatus() == 1:
                    self.lastKnownStatus = "There are pending upgrades!"
                    if not self.updateFailed:
                        KNotifyClient.event(self.sysTray.winId(),
                                             "found-old-upgrades",
                                             self.lastKnownStatus)
                    self.emit(PYSIGNAL("foundOldUpgrades()"), ())
                elif process.exitStatus() == 2:
                    self.lastKnownStatus = "No interesting upgrades available."
                    if not self.updateFailed:
                        KNotifyClient.event(self.sysTray.winId(),
                                             "found-no-upgrades",
                                             self.lastKnownStatus)
                    self.emit(PYSIGNAL("foundNoUpgrades()"), ())
                else:
                    self.lastKnownStatus = ""
        elif self.state == KSmartTray.State.Upgrading:
            self.state = KSmartTray.State.Waiting
            self.lastKnownStatus = ""
        elif self.state ==  KSmartTray.State.RunningSmart:
            self.state = KSmartTray.State.Waiting
            self.lastKnownStatus = ""
        else:
            # Error!
            pass

        if self.state == KSmartTray.State.Waiting:
            self.updateFailed = False
            self.sysTray.checkAction.setEnabled(True)
            self.sysTray.startSmartAction.setEnabled(True)
            self.sysTray.stopAction.setEnabled(False)
            if not self.lastKnownStatus == "":
                QToolTip.remove(self.sysTray)
                QToolTip.add(self.sysTray, self.lastKnownStatus)
            else:
                QToolTip.remove(self.sysTray)