Set a default action name on the dbus notification

This commit is contained in:
Kovid Goyal 2019-02-03 13:53:26 +05:30
parent 1bf2864638
commit 4c9a6ed56c
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
8 changed files with 17 additions and 12 deletions

View File

@ -179,7 +179,7 @@ def generate_wrappers(glfw_header):
int glfwGetXKBScancode(const char* key_name, int case_sensitive)
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, \
int32_t timeout, GLFWDBusnotificationcreatedfun callback, void *data)
const char *action_text, int32_t timeout, GLFWDBusnotificationcreatedfun callback, void *data)
void glfwDBusSetUserNotificationHandler(GLFWDBusnotificationactivatedfun handler)
'''.splitlines():
if line:

7
glfw/linux_notify.c vendored
View File

@ -64,7 +64,7 @@ message_handler(DBusConnection *conn, DBusMessage *msg, void *user_data) {
}
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();
static DBusConnection *added_signal_match = NULL;
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, &body)
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_open_container(&args, DBUS_TYPE_ARRAY, "{sv}", &array)) OOMMSG;
if (!dbus_message_iter_close_container(&args, &array)) OOMMSG;

2
glfw/linux_notify.h vendored
View File

@ -14,6 +14,6 @@ typedef unsigned long long notification_id_type;
typedef void (*GLFWDBusnotificationcreatedfun)(notification_id_type, uint32_t, void*);
typedef void (*GLFWDBusnotificationactivatedfun)(uint32_t, const char*);
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
glfw_dbus_set_user_notification_activated_handler(GLFWDBusnotificationactivatedfun handler);

4
glfw/wl_window.c vendored
View File

@ -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) {
return glfw_dbus_send_user_notification(app_name, icon, summary, body, timeout, callback, 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, action_name, timeout, callback, data);
}
GLFWAPI void glfwDBusSetUserNotificationHandler(GLFWDBusnotificationactivatedfun handler) {

4
glfw/x11_window.c vendored
View File

@ -2895,8 +2895,8 @@ GLFWAPI int glfwGetXKBScancode(const char* keyName, GLFWbool 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) {
return glfw_dbus_send_user_notification(app_name, icon, summary, body, timeout, callback, 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, action_name, timeout, callback, data);
}
GLFWAPI void glfwDBusSetUserNotificationHandler(GLFWDBusnotificationactivatedfun handler) {

2
kitty/glfw-wrapper.h generated
View File

@ -1909,7 +1909,7 @@ typedef void (*glfwRequestWaylandFrameEvent_func)(GLFWwindow*, unsigned long lon
glfwRequestWaylandFrameEvent_func 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;
#define glfwDBusUserNotify glfwDBusUserNotify_impl

View File

@ -1037,14 +1037,14 @@ dbus_notification_created_callback(unsigned long long notification_id, uint32_t
static PyObject*
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;
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) {
PyErr_SetString(PyExc_RuntimeError, "Failed to load glfwDBusUserNotify, did you call glfw_init?");
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);
}
#endif

View File

@ -42,6 +42,6 @@ else:
):
if icon is True:
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:
alloc_map[alloc_id] = identifier