Example #1
0
    def init(self):
        """ Const method for initializing the applet """

        self.readEntries()
        self.followSolid()

        self.connectedDevices = []
        self.maxQuality = 100.0

        self.iface = NetworkIface()
        self.notifyface = Notifier(dbus.get_default_main_loop())
        self.notifyface.registerNetwork()

        # Aspect ratio defined in Plasma
        self.setAspectRatioMode(Plasma.Square)

        self.loader = KIconLoader()
        self.defaultIcon = WIRED
        self.emblem = DISCONNECTED["emblem"]

        self.icon = NmIcon(self)
        self.icon.setToolTip(i18n("Click here to show connections.."))

        self.layout = QGraphicsLinearLayout(self.applet)
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.layout.setSpacing(0)
        self.layout.addItem(self.icon)

        self.connect(self.icon, SIGNAL("clicked()"), self.showDialog)

        self.receiverBlinker = Blinker(self)
        self.transmitterBlinker = Blinker(self, QColor(255,114,32))

        # Listen data transfers from lastUsed Device ..
        self.lastActiveDevice = None
        self.lastActivePackage = None

        self.initPopup()

        # It may cause crashes in PlasmoidViewer but luckly not in Plasma :)
        self.connect(Plasma.Theme.defaultTheme(), SIGNAL("themeChanged()"), self.updateTheme)

        # Listen network status from comar
        self.iface.listen(self.handler)

        QTimer.singleShot(self._config['pollinterval'], self.dataUpdated)

        # Context Menu
        icon = self.loader.loadIcon(WIRED, KIconLoader.NoGroup, 22)
        openNm = QAction(QIcon(icon), i18n("Open Network Manager"), self)
        self.actions.append(openNm)
        self.connect(openNm, SIGNAL("triggered(bool)"), self.openNM)
        self.connect(self.popup.ui.nmButton, SIGNAL("clicked()"), self.openNM)