summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKjell Ahlstedt <kjell.ahlstedt@bredband.net>2014-01-28 09:53:43 +0100
committerKjell Ahlstedt <kjell.ahlstedt@bredband.net>2014-01-28 09:53:43 +0100
commitf4528c2e3827400279b7429279a6ad0133184062 (patch)
treebdcc27a38e4c88e507674b4b454d4032985ee475
parentdd95a40c58192da4472e65d812085ee5dd9a8091 (diff)
downloadglibmm-f4528c2e3827400279b7429279a6ad0133184062.tar.gz
Add Gio::Notification
* gio/src/application.hg: Add send_notification(), withdraw_notification(). * gio/src/notification.[hg|ccg]: New files. * gio/src/filelist.am: Add notification.hg. * gio/giomm.h: Add giomm/notification.h. * tools/m4/convert_gio.m4: Add conversions between GNotification and Gio::Notification. Bug #722896.
-rw-r--r--gio/giomm.h1
-rw-r--r--gio/src/application.hg4
-rw-r--r--gio/src/filelist.am1
-rw-r--r--gio/src/notification.ccg31
-rw-r--r--gio/src/notification.hg133
-rw-r--r--tools/m4/convert_gio.m44
6 files changed, 174 insertions, 0 deletions
diff --git a/gio/giomm.h b/gio/giomm.h
index 2ce4935f..5f31f092 100644
--- a/gio/giomm.h
+++ b/gio/giomm.h
@@ -101,6 +101,7 @@
#include <giomm/mountoperation.h>
#include <giomm/networkaddress.h>
#include <giomm/networkservice.h>
+#include <giomm/notification.h>
#include <giomm/outputstream.h>
#include <giomm/pollableinputstream.h>
#include <giomm/pollableoutputstream.h>
diff --git a/gio/src/application.hg b/gio/src/application.hg
index d619902f..d8d02eff 100644
--- a/gio/src/application.hg
+++ b/gio/src/application.hg
@@ -29,6 +29,7 @@
#include <glibmm/object.h>
#include <glibmm/variant.h>
#include <giomm/dbusconnection.h>
+#include <giomm/notification.h>
_DEFS(giomm,gio)
_PINCLUDE(glibmm/private/object_p.h)
@@ -194,6 +195,9 @@ public:
_WRAP_METHOD(void mark_busy(), g_application_mark_busy)
_WRAP_METHOD(void unmark_busy(), g_application_unmark_busy)
+ _WRAP_METHOD(void send_notification(const Glib::ustring& id{?}, const Glib::RefPtr<Notification>& notification), g_application_send_notification)
+ _WRAP_METHOD(void withdraw_notification(const Glib::ustring& id), g_application_withdraw_notification)
+
_WRAP_PROPERTY("action-group", Glib::RefPtr<ActionGroup>)
_WRAP_PROPERTY("application-id", Glib::ustring)
_WRAP_PROPERTY("flags", ApplicationFlags)
diff --git a/gio/src/filelist.am b/gio/src/filelist.am
index fbc0e335..e2a545f1 100644
--- a/gio/src/filelist.am
+++ b/gio/src/filelist.am
@@ -88,6 +88,7 @@ giomm_files_any_hg = \
mountoperation.hg \
networkaddress.hg \
networkservice.hg \
+ notification.hg \
outputstream.hg \
pollableinputstream.hg \
pollableoutputstream.hg \
diff --git a/gio/src/notification.ccg b/gio/src/notification.ccg
new file mode 100644
index 00000000..05783950
--- /dev/null
+++ b/gio/src/notification.ccg
@@ -0,0 +1,31 @@
+/* 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 <http://www.gnu.org/licenses/>.
+ */
+
+#include <gio/gio.h>
+#include <giomm/icon.h>
+#include <glibmm/variant.h>
+
+namespace Gio
+{
+
+Notification::Notification(const Glib::ustring& title)
+: _CONSTRUCT()
+{
+ // The title is compulsory. Don't skip it, if it's empty.
+ set_title(title);
+}
+
+} // namespace Gio
diff --git a/gio/src/notification.hg b/gio/src/notification.hg
new file mode 100644
index 00000000..674bd4ed
--- /dev/null
+++ b/gio/src/notification.hg
@@ -0,0 +1,133 @@
+/* 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 <http://www.gnu.org/licenses/>.
+ */
+
+#include <glibmm/object.h>
+#include <glibmm/ustring.h>
+#include <glibmm/variant.h>
+
+_DEFS(giomm,gio)
+_PINCLUDE(glibmm/private/object_p.h)
+
+namespace Gio
+{
+class 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 Notification : public Glib::Object
+{
+ _CLASS_GOBJECT(Notification, GNotification, G_NOTIFICATION, Glib::Object, GObject)
+
+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_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>& icon), g_notification_set_icon)
+ _WRAP_METHOD(void set_urgent(bool urgent = true), g_notification_set_urgent)
+
+ _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 <typename T_Value>
+ 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 <typename T_Value>
+ 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)
+ // Ignore private methods
+ _IGNORE(g_notification_get_urgent, g_notification_get_button, g_notification_get_default_action)
+ _IGNORE(g_notification_get_n_buttons, g_notification_get_button_with_action, g_notification_serialize)
+ _IGNORE(g_notification_get_icon, g_notification_get_id, g_notification_get_body, g_notification_get_title)
+
+ // There are no properties, signals, vfuncs.
+};
+
+template <typename T_Value>
+void Notification::add_button(const Glib::ustring& label, const Glib::ustring& action, const T_Value& target)
+{
+ typedef Glib::Variant<T_Value> type_glib_variant;
+
+ add_button_variant(label, action, type_glib_variant::create(target));
+}
+
+template <typename T_Value>
+void Notification::set_default_action(const Glib::ustring& action, const T_Value& target)
+{
+ typedef Glib::Variant<T_Value> type_glib_variant;
+
+ set_default_action_variant(action, type_glib_variant::create(target));
+}
+
+} // namespace Gio
diff --git a/tools/m4/convert_gio.m4 b/tools/m4/convert_gio.m4
index 0cc55b9d..a6f04a3e 100644
--- a/tools/m4/convert_gio.m4
+++ b/tools/m4/convert_gio.m4
@@ -237,6 +237,10 @@ _CONVERSION(`PasswordSave',`GPasswordSave',`($2)$3')
#MountOperation
#_CONVERSION(`GAskPasswordFlags',`AskPasswordFlags',`($2)$3')
+# Notification
+_CONVERSION(`GNotification*',`Glib::RefPtr<Notification>',`Glib::wrap($3)')
+_CONVERSION(`const Glib::RefPtr<Notification>&',`GNotification*',__CONVERT_CONST_REFPTR_TO_P)
+
# OutputStream
_CONVERSION(`GOutputStream*',`Glib::RefPtr<OutputStream>',`Glib::wrap($3)')
_CONVERSION(`const Glib::RefPtr<OutputStream>&',`GOutputStream*',__CONVERT_CONST_REFPTR_TO_P)