GNOME Bugzilla – Bug 722896
Wrap GNotification
Last modified: 2014-01-28 09:48:41 UTC
A first version of the new class Gio::Notification will be attached soon.
Created attachment 267119 [details] [review] patch: Add Gio::Notification Here's a first version of the new class Gio::Notification. I have not wrapped g_notification_add_button_with_target() and g_notification_set_default_action_and_target(). They have variable-length parameter lists. We don't like such functions, do we? They are not necessary. There are groups of 3 functions, g_notification_add_button*() and g_notification_set_default_action*(). The 3 functions within each group have equal functionality, but different parameters. Would it be a good idea to call the wrapped functions in these groups just add_button() and set_default_action()? I.e. overloaded function names. I will also add Gio::Application::send_notification() and withdraw_notification(). An example program would be nice, e.g. at gtkmm-documentation/examples/book/application/. Either make a new example or add a call to Gio::Application:: send_notification() to one of the existing examples. gtk+/examples/bloatpad.c can probably provide some hints.
After having looked at what was recently done in Gio::Action, I think that the functions that take a GVariant parameter should probably be wrapped differently to what I've done in comment 1. _WRAP_METHOD(void add_button_variant(const Glib::ustring& label, const Glib::ustring& action, const Glib::VariantBase& target), g_notification_add_button_with_target_value) template <typename T_Value> void add_button(const Glib::ustring& label, const Glib::ustring& action, const T_Value& target); and equivalent for set_default_action[_variant]().
An off-topic comment: When I studied action.hg, I noted this definition: template <typename T_Value> void Action::activate(const Glib::Variant<T_Value>& value) { activate(value); } Shouldn't it be activate_variant(value)? activate() calls itself recursively, doesn't it? Compare template <typename T_Value> void Action::change_state(const Glib::Variant<T_Value>& value) { change_state_variant(value); }
(In reply to comment #3) > Shouldn't it be activate_variant(value)? activate() calls itself recursively, > doesn't it? Yes, I guess you are right. Note that both these methods are just there to maintain API compatibility. There's a change_state/activate typo in the comment about that on activate().
Created attachment 267297 [details] [review] patch: Add Gio::Notification Updated patch. I'll add some menu items and actions to gtkmm-documentation/examples/book/ application/app_and_win_menus that send a notification and react when it's clicked. If that works as expected, and no one suggests improvements of my Gio::Notification, I'll push it. I have created a glibmm-2-38 branch, and fixed Gio::Action::activate() in both the glibmm-2-38 branch and the master branch.
I have pushed a patch in glibmm that adds Gio::Notification and Gio::Application::[send,withdraw]_notification(), https://git.gnome.org/browse/glibmm/commit/?id=f4528c2e3827400279b7429279a6ad0133184062 and a patch in gtkmm-documentation that adds some actions and menu items to the book/application/app_and_win_menus example, https://git.gnome.org/browse/gtkmm-documentation/commit/?id=682f3bfcb9e1b63805f1daf8ccc1a353d1be5297
That looks great. Thanks.