This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Advice on my first ruby plasmoid

Tags: None
(comma "," separated)
acemutha
Registered Member
Posts
5
Karma
0
OS

Advice on my first ruby plasmoid

Fri Jun 11, 2010 8:01 am
Hi here's my first mail notifier for mutt plasmoid

Code: Select all
require 'plasma_applet'

module RubyMuttNotifier
  class Main < PlasmaScripting::Applet

    def initialize parent
      super parent
    end
   
    slots :openBox
    slots :changeText
   
    def init
      @layout = Qt::GraphicsLinearLayout.new Qt::Vertical, self
      self.layout = @layout

      @label = Plasma::Label.new self
      @label.setAlignment(Qt::AlignCenter)
      @label.setFont(Qt::Font.new('Arial', 12, Qt::Font::Normal))
      @label.text = 'No New Mail'
      @layout.add_item @label
     
      @box = Qt::FileInfo.new('/var/spool/mail/user');

      @mon = Qt::FileSystemWatcher.new()
      @mon.addPath(@box.absoluteFilePath())

      @button = Plasma::PushButton.new self
      @button.setFont(Qt::Font.new('Arial', 12, Qt::Font::Normal))
      @button.text = 'Open your inbox'
     
     
      @layout.add_item @button
     
Qt::Object.connect( @button, SIGNAL(:clicked), self, SLOT(:openBox) )
Qt::Object.connect(@mon,SIGNAL('fileChanged(QString)'),self,SLOT(:changeText))
    end


    def changeText()
     
      if @box.size > 0
   @label.setText('You got Mail!')
      else
   @label.setText('No New Mail')
      end
     
    end
   
    def openBox()
     
      trap("CLD") {
      pid = Process.wait
      @label.setText('No New Mail')
      exit
      }

      exec("/usr/bin/konsole -e /usr/bin/mutt") if fork.nil?
    end
   
  end
end



A part from the fact that sometimes it crashes...
what I don't know is how to set the geometry of my applet and in particular the size of the button.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
I would recommend looking at the KDE documentation ( which can be viewed at http://api.mts.ms if http://api.kde.org is down )

You may also wish to ask on the Plasma development mailing list, plasma-devel@kde.org


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
acemutha
Registered Member
Posts
5
Karma
0
OS
Thanks but...
problem is that both links are down
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
A third mirror is also available at http://purinchu.net/kdelibs-apidocs/


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
acemutha
Registered Member
Posts
5
Karma
0
OS

Re: Advice on my first ruby plasmoid

Fri Jun 11, 2010 12:49 pm
Ok thanks I'll check it out


Bookmarks



Who is online

Registered users: Bing [Bot], blue_bullet, Google [Bot], rockscient, Yahoo [Bot]