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

Using KNotification from a plasmoid

Tags: None
(comma "," separated)
B4700011
Registered Member
Posts
16
Karma
0

Using KNotification from a plasmoid

Fri Feb 25, 2011 12:12 am
Hi.

I am trying to use KNotification::event() from a plasmoid (C++) with custom notification events defined in a .notifyrc file, and I'm failing rather miserably.

If I use the default notification event it all works, so I don't think it's a problem with my code as such.

If I go to the notification configuration section in systemsettings I can see my plasmoid's custom events, so the .notifyrc file is being found and read properly.

I have of course done the whole
Code: Select all
killall /usr/bin/knotify4; kbuildsycoca4; kquitapp plasma-desktop; sleep 5; plasma-desktop; knotify
thing, so I don't think it's a problem with that either.

What I'm guessing is that it's to do with KDE not being able to associate my .notifyrc file with the plasmoid in question. According to the KNotification docs:
Your application should install a file called: $KDEDIR/share/apps/appname/appname.notifyrc


Well, so what would be appname as far as my applet is concerned? If mine were a full-blown app, I would define that in KApplication, but being a plasmoid, I don't have any calls to it in my code.

Any help would be much appreciated--I've been banging my head against the keyboard for hours with this.
B4700011
Registered Member
Posts
16
Karma
0
Just replying to myself.

Sure enough, having spent hours on this, 90 seconds after posting, I have come across the solution by looking at the source code of plasma_pastebin.

Turns out I could use KComponentData, like this:

Code: Select all
notification->setComponentData(KComponentData("my-plasma-applet"));


Then I would have /usr/share/kde4/apps/my-plasma-applet/my-plasma-applet.notifyrc

Sorry for the noise. I'll leave my post up though, in case someone else ever runs into the same problem.


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], ourcraft