gtk - 如何在 vala 中创建通知类
问题描述
我正在学习 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 无效
解决方案
您的基类名称中有错字 -Glib.Object
应该是GLib.Object
(注意大写L
)
推荐阅读
- asp.net-mvc - 在 MVC 中将数据导入 ViewModel
- php - Laravel 中的 MVC 模式应该是怎样的?
- javascript - 如何创建仅导出 JSON 的节点配置模块
- javascript - 将日期字符串正确解析为时间戳?
- ios - 如何在 React Native 0.60+ 中添加原生模块?
- youtube-api - YouTube Data API v3 搜索缺失的视频
- amazon-web-services - 如何在公共网络中制作 docker swarm 网络?
- django - 从帖子链接重定向到文件的问题
- jquery - 尝试从使用“追加”切换到具有 [0] 和变量的“追加”
- c# - 添加新的 XEelement 并更新 XML.Descendent