【问题标题】:How to create a notification class in vala如何在 vala 中创建通知类
【发布时间】:2020-11-19 03:36:47
【问题描述】:

我正在学习 vala 语言,我想创建一个服务来触发通知。 这是我的代码

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);
  }
}

但我面临这个错误

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

我在 meson.build 文件中添加了文件 Services/Notification.vala 无效

【问题讨论】:

    标签: gtk glib vala


    【解决方案1】:

    您的基类名称中有错字 - Glib.Object 应该是 GLib.Object(注意大写的 L

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-06-27
      • 2022-01-03
      • 1970-01-01
      • 2021-06-17
      • 2018-06-09
      • 1970-01-01
      • 2023-04-02
      相关资源
      最近更新 更多