After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 722896 - Wrap GNotification
Wrap GNotification
Status: RESOLVED FIXED
Product: glibmm
Classification: Bindings
Component: giomm
2.39.x
Other All
: Normal enhancement
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2014-01-24 10:22 UTC by Kjell Ahlstedt
Modified: 2014-01-28 09:48 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch: Add Gio::Notification (6.38 KB, patch)
2014-01-24 10:30 UTC, Kjell Ahlstedt
none Details | Review
patch: Add Gio::Notification (7.73 KB, patch)
2014-01-27 12:32 UTC, Kjell Ahlstedt
none Details | Review

Description Kjell Ahlstedt 2014-01-24 10:22:45 UTC
A first version of the new class Gio::Notification will be attached soon.
Comment 1 Kjell Ahlstedt 2014-01-24 10:30:04 UTC
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.
Comment 2 Kjell Ahlstedt 2014-01-24 16:34:50 UTC
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]().
Comment 3 Kjell Ahlstedt 2014-01-24 16:35:31 UTC
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);
  }
Comment 4 Murray Cumming 2014-01-24 20:55:34 UTC
(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().
Comment 5 Kjell Ahlstedt 2014-01-27 12:32:37 UTC
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.
Comment 6 Kjell Ahlstedt 2014-01-28 09:21:59 UTC
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
Comment 7 Murray Cumming 2014-01-28 09:48:41 UTC
That looks great. Thanks.