Search code examples
gtkglibvala

How to create a notification class in vala


Im learning vala language and I want to create a service to trigger a notification. Thats my code

public class Services.Notifications : Glib.Object {
  

  public void sendNotification (string title, string body,string icon_name, GLib.NotificationPriority priority) {
      var notification = new Notification (title);
      notification.set_body (body);
      notification.set_icon (new ThemedIcon (icon_name));
      notification.set_priority (priority);

      send_notification ("com.github.andirsun.myapp", notification);
  }
}

But Im facing this error

class Notifications: null
base type `null' of class `Services.Notifications' is not an object type

I added the file Services/Notification.vala in the meson.build file bit no works


Solution

  • You have a typo in your base class's name - Glib.Object should be GLib.Object (note the upper-case L)