/* Copyright (C) 2014 The giomm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
*/
_CONFIGINCLUDE(giommconfig.h)
#include
#include
#include
_DEFS(giomm,gio)
_PINCLUDE(glibmm/private/object_p.h)
namespace Gio
{
class GIOMM_API Icon;
/** User Notifications (pop up messages).
*
* Gio::Notification is a mechanism for creating a notification to be shown
* to the user -- typically as a pop-up notification presented by the
* desktop environment shell.
*
* The key difference between Notification and other similar APIs is
* that, if supported by the desktop environment, notifications sent
* with Notification will persist after the application has exited,
* and even across system reboots.
*
* Since the user may click on a notification while the application is
* not running, applications using Notification should be able to be
* started as a D-Bus service, using Gio::Application.
*
* User interaction with a notification (either the default action, or
* buttons) must be associated with actions on the application (ie:
* "app." actions). It is not possible to route user interaction
* through the notification itself, because the object will not exist if
* the application is autostarted as a result of a notification being
* clicked.
*
* A notification can be sent with Gio::Application::send_notification().
*
* @newin{2,40}
*/
class GIOMM_API Notification : public Glib::Object
{
_CLASS_GOBJECT(Notification, GNotification, G_NOTIFICATION, Glib::Object, GObject, , , GIOMM_API)
protected:
// Can't use _WRAP_CTOR. GNotification has no properties, but it must have a title.
explicit Notification(const Glib::ustring& title);
_IGNORE(g_notification_new)
public:
_WRAP_ENUM(Priority, GNotificationPriority, newin "2,44", decl_prefix GIOMM_API)
_WRAP_METHOD_DOCS_ONLY(g_notification_new)
_WRAP_CREATE(const Glib::ustring& title)
_WRAP_METHOD(void set_title(const Glib::ustring& title), g_notification_set_title)
_WRAP_METHOD(void set_body(const Glib::ustring& body), g_notification_set_body)
_WRAP_METHOD(void set_icon(const Glib::RefPtr& icon), g_notification_set_icon)
_IGNORE(g_notification_set_urgent)
_WRAP_METHOD(void set_priority(Priority priority = Priority::NORMAL), g_notification_set_priority, newin "2,44")
_WRAP_METHOD(void set_category(const Glib::ustring& category), g_notification_set_category)
_WRAP_METHOD(void add_button(const Glib::ustring& label, const Glib::ustring& detailed_action), g_notification_add_button)
/** Adds a button that activates @a action when clicked.
* @a action must be an application-wide action (it must start with "app.").
* @a action will be activated with @a target as its parameter.
*
* @newin{2,40}
*
* @param label Label of the button.
* @param action An action name.
* @param target @a action's parameter.
*/
template
void add_button(const Glib::ustring& label, const Glib::ustring& action, const T_Value& target);
_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)
_WRAP_METHOD(void set_default_action(const Glib::ustring& detailed_action), g_notification_set_default_action)
/** Sets the default action to @a action.
* This action is activated when the notification is clicked on. It must be an
* application-wide action (start with "app.").
* @a action will be activated with @a target as its parameter.
*
* When no default action is set, the application that the notification
* was sent on is activated.
*
* @newin{2,40}
*
* @param action An action name.
* @param target @a action's parameter.
*/
template
void set_default_action(const Glib::ustring& action, const T_Value& target);
_WRAP_METHOD(void set_default_action_variant(const Glib::ustring& action, const Glib::VariantBase& target), g_notification_set_default_action_and_target_value)
// Ignore functions with variable-length parameter lists.
_IGNORE(g_notification_add_button_with_target, g_notification_set_default_action_and_target)
// There are no properties, signals, vfuncs.
};
template
void Notification::add_button(const Glib::ustring& label, const Glib::ustring& action, const T_Value& target)
{
using type_glib_variant = Glib::Variant;
add_button_variant(label, action, type_glib_variant::create(target));
}
template
void Notification::set_default_action(const Glib::ustring& action, const T_Value& target)
{
using type_glib_variant = Glib::Variant;
set_default_action_variant(action, type_glib_variant::create(target));
}
} // namespace Gio