Exemplo n.º 1
0
    def init(self):
        debug("GoogleTranslatorApplet: init().")
        BasePlasmoid.init(self)

        self._widget = None
        self.setHasConfigurationInterface(False)
        self.setAspectRatioMode(Plasma.IgnoreAspectRatio)

        self.notifier = Notifier(self)
        self.nwmon = NetworkMonitor()
        if self.nwmon.connected():
          self.setBusy(False)
        else:
            self.notifier.notify("waiting-for-network", i18n("Waiting for network connection."))

        self.nwmon.status_changed.connect(self.netstate_changed)

        # Main widget
        debug("GoogleTranslatorApplet: Creating main widget.")
        self._widget = GoogleTranslator(self)
        self._widget.init()
        self.setGraphicsWidget(self._widget)
        self.setPopupIcon(self.metadata.pluginName())

        self.setGraphicsWidget(self._widget)

        # Tool tip for panel
        self.metadata = self.package().metadata()
        self.tooltipdata = Plasma.ToolTipContent()
        self.tooltipdata.setMainText(self.metadata.name())
        self.tooltipdata.setSubText(self.metadata.description())
        self.tooltipdata.setImage(KIcon(self.metadata.pluginName()))
        Plasma.ToolTipManager.self().setContent(self.applet, self.tooltipdata)

        # Only register the tooltip in panels
        #if (self.formFactor() != Plasma.Planar):
        if ((self.formFactor() == Plasma.Horizontal) or (self.formFactor() == Plasma.Vertical)):
            print("GoogleTranslatorApplet: In Panel")
            Plasma.ToolTipManager.self().registerWidget(self.applet)
        else:
            Plasma.ToolTipManager.self().unregisterWidget(self.applet)
            print("GoogleTranslatorApplet: Not in Panel")

        self.configChanged()
Exemplo n.º 2
0
 def __init__(self,parent,args=None):
     self.parent = parent
     BasePlasmoid.__init__(self, parent)