Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use properties instead of private fields in dunstify #1444

Merged
merged 2 commits into from
Feb 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 8 additions & 41 deletions dunstify.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,53 +173,20 @@ void parse_commandline(int argc, char *argv[])
}
}

typedef struct _NotifyNotificationPrivate
{
guint32 id;
char *app_name;
char *summary;
char *body;

/* NULL to use icon data. Anything else to have server lookup icon */
char *icon_name;

/*
* -1 = use server default
* 0 = never timeout
* > 0 = Number of milliseconds before we timeout
*/
gint timeout;

GSList *actions;
GHashTable *action_map;
GHashTable *hints;

gboolean has_nondefault_actions;
gboolean updates_pending;

gulong proxy_signal_handler;

gint closed_reason;
} knickers;

int get_id(NotifyNotification *n)
{
knickers *kn = n->priv;

/* I'm sorry for taking a peek */
return kn->id;
GValue value = G_VALUE_INIT;
g_value_init(&value, G_TYPE_UINT);
Copy link
Contributor

@liskin liskin Feb 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, this is really weird… on Debian, this results in:

(dunstify:5973): GLib-GObject-CRITICAL **: 14:52:22.702: g_value_get_int: assertion 'G_VALUE_HOLDS_INT (value)' failed

Seems like an INT vs UINT mismatch. But upstream declares it as an int, not uint:
https://github.com/GNOME/libnotify/blob/570982f616838abba6bdd8ca2bdb2f32f3b1d1de/libnotify/notification.c#L167

So I'm really confused how this could work anywhere else. Any ideas?

If, one the other hand, I do what notify-send does:

int get_id(NotifyNotification *n)
{
    gint id;
    g_object_get(G_OBJECT(n), "id", &id, NULL);
    return id;
}

then it works just fine.

Copy link
Member Author

@bynect bynect Feb 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very strange since ids are represented as uint (https://specifications.freedesktop.org/notification-spec/latest/protocol.html#id-1.10.3.3.4). Also that code is ignoring the fact that upstream thinks that the value should be an int. I'll have to check the code of libnotify

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also what version of debian/libnotify are you on?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very strange since ids are represented as uint (https://specifications.freedesktop.org/notification-spec/latest/protocol.html#id-1.10.3.3.4). Also that code is ignoring the fact that upstream thinks that the value should be an int. I'll have to check the code of libnotify

Yeah they probably are uint in the dbus protocol but the property is declared in libnotify as int here: https://github.com/GNOME/libnotify/blob/570982f616838abba6bdd8ca2bdb2f32f3b1d1de/libnotify/notification.c#L167

Also what version of debian/libnotify are you on?

0.8.4-1

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible that Debian enables assertions and whatever build of libnotify you have doesn't?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess so. I'm on gentoo, but maybe that's more of a glib configuration? Anyway I'll just change it like notifysend does

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

g_object_get_property(G_OBJECT(n), "id", &value);
return g_value_get_int(&value);
}

void put_id(NotifyNotification *n, guint32 id)
{
knickers *kn = n->priv;

/* And now I'm putting stuff into
* your knickers. I'm sorry.
* I'm so sorry.
* */

kn->id = id;
GValue value = G_VALUE_INIT;
g_value_init(&value, G_TYPE_UINT);
g_value_set_uint(&value, id);
g_object_set_property(G_OBJECT(n), "id", &value);
}

void actioned(NotifyNotification *n, char *a, gpointer foo)
Expand Down