Set a default action name on the dbus notification
This commit is contained in:
parent
1bf2864638
commit
4c9a6ed56c
@ -179,7 +179,7 @@ def generate_wrappers(glfw_header):
|
|||||||
int glfwGetXKBScancode(const char* key_name, int case_sensitive)
|
int glfwGetXKBScancode(const char* key_name, int case_sensitive)
|
||||||
void glfwRequestWaylandFrameEvent(GLFWwindow *handle, unsigned long long id, GLFWwaylandframecallbackfunc callback)
|
void glfwRequestWaylandFrameEvent(GLFWwindow *handle, unsigned long long id, GLFWwaylandframecallbackfunc callback)
|
||||||
unsigned long long glfwDBusUserNotify(const char *app_name, const char* icon, const char *summary, const char *body, \
|
unsigned long long glfwDBusUserNotify(const char *app_name, const char* icon, const char *summary, const char *body, \
|
||||||
int32_t timeout, GLFWDBusnotificationcreatedfun callback, void *data)
|
const char *action_text, int32_t timeout, GLFWDBusnotificationcreatedfun callback, void *data)
|
||||||
void glfwDBusSetUserNotificationHandler(GLFWDBusnotificationactivatedfun handler)
|
void glfwDBusSetUserNotificationHandler(GLFWDBusnotificationactivatedfun handler)
|
||||||
'''.splitlines():
|
'''.splitlines():
|
||||||
if line:
|
if line:
|
||||||
|
|||||||
7
glfw/linux_notify.c
vendored
7
glfw/linux_notify.c
vendored
@ -64,7 +64,7 @@ message_handler(DBusConnection *conn, DBusMessage *msg, void *user_data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
notification_id_type
|
notification_id_type
|
||||||
glfw_dbus_send_user_notification(const char *app_name, const char* icon, const char *summary, const char *body, int32_t timeout, GLFWDBusnotificationcreatedfun callback, void *user_data) {
|
glfw_dbus_send_user_notification(const char *app_name, const char* icon, const char *summary, const char *body, const char* action_name, int32_t timeout, GLFWDBusnotificationcreatedfun callback, void *user_data) {
|
||||||
DBusConnection *session_bus = glfw_dbus_session_bus();
|
DBusConnection *session_bus = glfw_dbus_session_bus();
|
||||||
static DBusConnection *added_signal_match = NULL;
|
static DBusConnection *added_signal_match = NULL;
|
||||||
if (!session_bus) return 0;
|
if (!session_bus) return 0;
|
||||||
@ -91,6 +91,11 @@ glfw_dbus_send_user_notification(const char *app_name, const char* icon, const c
|
|||||||
APPEND(DBUS_TYPE_STRING, &summary)
|
APPEND(DBUS_TYPE_STRING, &summary)
|
||||||
APPEND(DBUS_TYPE_STRING, &body)
|
APPEND(DBUS_TYPE_STRING, &body)
|
||||||
if (!dbus_message_iter_open_container(&args, DBUS_TYPE_ARRAY, "s", &array)) OOMMSG;
|
if (!dbus_message_iter_open_container(&args, DBUS_TYPE_ARRAY, "s", &array)) OOMMSG;
|
||||||
|
if (action_name) {
|
||||||
|
static const char* default_action = "default";
|
||||||
|
dbus_message_iter_append_basic(&array, DBUS_TYPE_STRING, &default_action);
|
||||||
|
dbus_message_iter_append_basic(&array, DBUS_TYPE_STRING, &action_name);
|
||||||
|
}
|
||||||
if (!dbus_message_iter_close_container(&args, &array)) OOMMSG;
|
if (!dbus_message_iter_close_container(&args, &array)) OOMMSG;
|
||||||
if (!dbus_message_iter_open_container(&args, DBUS_TYPE_ARRAY, "{sv}", &array)) OOMMSG;
|
if (!dbus_message_iter_open_container(&args, DBUS_TYPE_ARRAY, "{sv}", &array)) OOMMSG;
|
||||||
if (!dbus_message_iter_close_container(&args, &array)) OOMMSG;
|
if (!dbus_message_iter_close_container(&args, &array)) OOMMSG;
|
||||||
|
|||||||
2
glfw/linux_notify.h
vendored
2
glfw/linux_notify.h
vendored
@ -14,6 +14,6 @@ typedef unsigned long long notification_id_type;
|
|||||||
typedef void (*GLFWDBusnotificationcreatedfun)(notification_id_type, uint32_t, void*);
|
typedef void (*GLFWDBusnotificationcreatedfun)(notification_id_type, uint32_t, void*);
|
||||||
typedef void (*GLFWDBusnotificationactivatedfun)(uint32_t, const char*);
|
typedef void (*GLFWDBusnotificationactivatedfun)(uint32_t, const char*);
|
||||||
notification_id_type
|
notification_id_type
|
||||||
glfw_dbus_send_user_notification(const char *app_name, const char* icon, const char *summary, const char *body, int32_t timeout, GLFWDBusnotificationcreatedfun, void*);
|
glfw_dbus_send_user_notification(const char *app_name, const char* icon, const char *summary, const char *body, const char *action_name, int32_t timeout, GLFWDBusnotificationcreatedfun, void*);
|
||||||
void
|
void
|
||||||
glfw_dbus_set_user_notification_activated_handler(GLFWDBusnotificationactivatedfun handler);
|
glfw_dbus_set_user_notification_activated_handler(GLFWDBusnotificationactivatedfun handler);
|
||||||
|
|||||||
4
glfw/wl_window.c
vendored
4
glfw/wl_window.c
vendored
@ -2132,8 +2132,8 @@ GLFWAPI void glfwRequestWaylandFrameEvent(GLFWwindow *handle, unsigned long long
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI unsigned long long glfwDBusUserNotify(const char *app_name, const char* icon, const char *summary, const char *body, int32_t timeout, GLFWDBusnotificationcreatedfun callback, void *data) {
|
GLFWAPI unsigned long long glfwDBusUserNotify(const char *app_name, const char* icon, const char *summary, const char *body, const char *action_name, int32_t timeout, GLFWDBusnotificationcreatedfun callback, void *data) {
|
||||||
return glfw_dbus_send_user_notification(app_name, icon, summary, body, timeout, callback, data);
|
return glfw_dbus_send_user_notification(app_name, icon, summary, body, action_name, timeout, callback, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwDBusSetUserNotificationHandler(GLFWDBusnotificationactivatedfun handler) {
|
GLFWAPI void glfwDBusSetUserNotificationHandler(GLFWDBusnotificationactivatedfun handler) {
|
||||||
|
|||||||
4
glfw/x11_window.c
vendored
4
glfw/x11_window.c
vendored
@ -2895,8 +2895,8 @@ GLFWAPI int glfwGetXKBScancode(const char* keyName, GLFWbool caseSensitive) {
|
|||||||
return glfw_xkb_keysym_from_name(keyName, caseSensitive);
|
return glfw_xkb_keysym_from_name(keyName, caseSensitive);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI unsigned long long glfwDBusUserNotify(const char *app_name, const char* icon, const char *summary, const char *body, int32_t timeout, GLFWDBusnotificationcreatedfun callback, void *data) {
|
GLFWAPI unsigned long long glfwDBusUserNotify(const char *app_name, const char* icon, const char *summary, const char *body, const char *action_name, int32_t timeout, GLFWDBusnotificationcreatedfun callback, void *data) {
|
||||||
return glfw_dbus_send_user_notification(app_name, icon, summary, body, timeout, callback, data);
|
return glfw_dbus_send_user_notification(app_name, icon, summary, body, action_name, timeout, callback, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwDBusSetUserNotificationHandler(GLFWDBusnotificationactivatedfun handler) {
|
GLFWAPI void glfwDBusSetUserNotificationHandler(GLFWDBusnotificationactivatedfun handler) {
|
||||||
|
|||||||
2
kitty/glfw-wrapper.h
generated
2
kitty/glfw-wrapper.h
generated
@ -1909,7 +1909,7 @@ typedef void (*glfwRequestWaylandFrameEvent_func)(GLFWwindow*, unsigned long lon
|
|||||||
glfwRequestWaylandFrameEvent_func glfwRequestWaylandFrameEvent_impl;
|
glfwRequestWaylandFrameEvent_func glfwRequestWaylandFrameEvent_impl;
|
||||||
#define glfwRequestWaylandFrameEvent glfwRequestWaylandFrameEvent_impl
|
#define glfwRequestWaylandFrameEvent glfwRequestWaylandFrameEvent_impl
|
||||||
|
|
||||||
typedef unsigned long long (*glfwDBusUserNotify_func)(const char*, const char*, const char*, const char*, int32_t, GLFWDBusnotificationcreatedfun, void*);
|
typedef unsigned long long (*glfwDBusUserNotify_func)(const char*, const char*, const char*, const char*, const char*, int32_t, GLFWDBusnotificationcreatedfun, void*);
|
||||||
glfwDBusUserNotify_func glfwDBusUserNotify_impl;
|
glfwDBusUserNotify_func glfwDBusUserNotify_impl;
|
||||||
#define glfwDBusUserNotify glfwDBusUserNotify_impl
|
#define glfwDBusUserNotify glfwDBusUserNotify_impl
|
||||||
|
|
||||||
|
|||||||
@ -1037,14 +1037,14 @@ dbus_notification_created_callback(unsigned long long notification_id, uint32_t
|
|||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
dbus_send_notification(PyObject *self UNUSED, PyObject *args) {
|
dbus_send_notification(PyObject *self UNUSED, PyObject *args) {
|
||||||
char *app_name, *icon, *summary, *body;
|
char *app_name, *icon, *summary, *body, *action_name;
|
||||||
int timeout = -1;
|
int timeout = -1;
|
||||||
if (!PyArg_ParseTuple(args, "ssss|i", &app_name, &icon, &summary, &body, &timeout)) return NULL;
|
if (!PyArg_ParseTuple(args, "sssss|i", &app_name, &icon, &summary, &body, &action_name, &timeout)) return NULL;
|
||||||
if (!glfwDBusUserNotify) {
|
if (!glfwDBusUserNotify) {
|
||||||
PyErr_SetString(PyExc_RuntimeError, "Failed to load glfwDBusUserNotify, did you call glfw_init?");
|
PyErr_SetString(PyExc_RuntimeError, "Failed to load glfwDBusUserNotify, did you call glfw_init?");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
unsigned long long notification_id = glfwDBusUserNotify(app_name, icon, summary, body, timeout, dbus_notification_created_callback, NULL);
|
unsigned long long notification_id = glfwDBusUserNotify(app_name, icon, summary, body, action_name, timeout, dbus_notification_created_callback, NULL);
|
||||||
return PyLong_FromUnsignedLongLong(notification_id);
|
return PyLong_FromUnsignedLongLong(notification_id);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -42,6 +42,6 @@ else:
|
|||||||
):
|
):
|
||||||
if icon is True:
|
if icon is True:
|
||||||
icon = logo_png_file
|
icon = logo_png_file
|
||||||
alloc_id = dbus_send_notification(application, icon, title, body, timeout)
|
alloc_id = dbus_send_notification(application, icon, title, body, 'Click to see changes', timeout)
|
||||||
if alloc_id and identifier is not None:
|
if alloc_id and identifier is not None:
|
||||||
alloc_map[alloc_id] = identifier
|
alloc_map[alloc_id] = identifier
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user