X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gio%2Fgnotification.c;h=53c5c6ba9ae3b2313c8d21050fe69935451d7593;hb=356a3987cee7ceddcb3fe623edf0bd2881895add;hp=4add2325dab0b5275fdbd90fc186729c30c8dbbc;hpb=6957004007fb2a5faf0013e6ec44926d841404b5;p=platform%2Fupstream%2Fglib.git diff --git a/gio/gnotification.c b/gio/gnotification.c index 4add232..53c5c6b 100644 --- a/gio/gnotification.c +++ b/gio/gnotification.c @@ -12,9 +12,7 @@ * 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, write to the - * Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. + * Public License along with this library; if not, see . * * Authors: Lars Uebernickel */ @@ -25,10 +23,12 @@ #include "gdbusutils.h" #include "gicon.h" #include "gaction.h" +#include "gioenumtypes.h" /** * SECTION:gnotification * @short_description: User Notifications (pop up messages) + * @include: gio/gio.h * * #GNotification is a mechanism for creating a notification to be shown * to the user -- typically as a pop-up notification presented by the @@ -73,7 +73,7 @@ struct _GNotification gchar *title; gchar *body; GIcon *icon; - gboolean urgent; + GNotificationPriority priority; GPtrArray *buttons; gchar *default_action; GVariant *default_action_target; @@ -287,19 +287,19 @@ g_notification_set_icon (GNotification *notification, } /*< private > - * g_notification_get_urgent: + * g_notification_get_priority: * @notification: a #GNotification * - * Returns %TRUE if @notification is marked as urgent. + * Returns the priority of @notification * - * Since: 2.40 + * Since: 2.42 */ -gboolean -g_notification_get_urgent (GNotification *notification) +GNotificationPriority +g_notification_get_priority (GNotification *notification) { - g_return_val_if_fail (G_IS_NOTIFICATION (notification), FALSE); + g_return_val_if_fail (G_IS_NOTIFICATION (notification), G_NOTIFICATION_PRIORITY_NORMAL); - return notification->urgent; + return notification->priority; } /** @@ -307,7 +307,7 @@ g_notification_get_urgent (GNotification *notification) * @notification: a #GNotification * @urgent: %TRUE if @notification is urgent * - * Sets or unsets whether @notification is marked as urgent. + * Deprecated in favor of g_notification_set_priority(). * * Since: 2.40 */ @@ -317,7 +317,24 @@ g_notification_set_urgent (GNotification *notification, { g_return_if_fail (G_IS_NOTIFICATION (notification)); - notification->urgent = urgent; + g_notification_set_priority (notification, G_NOTIFICATION_PRIORITY_URGENT); +} + +/** + * g_notification_set_priority: + * @notification: a #GNotification + * @priority: a #GNotificationPriority + * + * Sets the priority of @notification to @priority. See + * #GNotificationPriority for possible values. + */ +void +g_notification_set_priority (GNotification *notification, + GNotificationPriority priority) +{ + g_return_if_fail (G_IS_NOTIFICATION (notification)); + + notification->priority = priority; } /** @@ -367,15 +384,15 @@ g_notification_add_button (GNotification *notification, * @notification: a #GNotification * @label: label of the button * @action: an action name - * @target_format: (allow-none): a GVariant format string, or %NULL - * @...: positional parameters, as determined by @format_string + * @target_format: (allow-none): a #GVariant format string, or %NULL + * @...: positional parameters, as determined by @target_format * * Adds a button to @notification that activates @action when clicked. * @action must be an application-wide action (it must start with "app."). * * If @target_format is given, it is used to collect remaining - * positional parameters into a GVariant instance, similar to - * g_variant_new(). @action will be activated with that GVariant as its + * positional parameters into a #GVariant instance, similar to + * g_variant_new(). @action will be activated with that #GVariant as its * parameter. * * Since: 2.40 @@ -405,7 +422,7 @@ g_notification_add_button_with_target (GNotification *notification, * @notification: a #GNotification * @label: label of the button * @action: an action name - * @target: (allow-none): a GVariant to use as @action's parameter, or %NULL + * @target: (allow-none): a #GVariant to use as @action's parameter, or %NULL * * Adds a button to @notification that activates @action when clicked. * @action must be an application-wide action (it must start with "app."). @@ -595,16 +612,16 @@ g_notification_set_default_action (GNotification *notification, * g_notification_set_default_action_and_target: (skip) * @notification: a #GNotification * @action: an action name - * @target_format: (allow-none): a GVariant format string, or %NULL - * @...: positional parameters, as determined by @format_string + * @target_format: (allow-none): a #GVariant format string, or %NULL + * @...: positional parameters, as determined by @target_format * * Sets the default action of @notification to @action. This action is * activated when the notification is clicked on. It must be an * application-wide action (it must start with "app."). * * If @target_format is given, it is used to collect remaining - * positional parameters into a GVariant instance, similar to - * g_variant_new(). @action will be activated with that GVariant as its + * positional parameters into a #GVariant instance, similar to + * g_variant_new(). @action will be activated with that #GVariant as its * parameter. * * When no default action is set, the application that the notification @@ -635,16 +652,12 @@ g_notification_set_default_action_and_target (GNotification *notification, * g_notification_set_default_action_and_target_value: (rename-to g_notification_set_default_action_and_target) * @notification: a #GNotification * @action: an action name - * @target: (allow-none): a GVariant to use as @action's parameter, or %NULL + * @target: (allow-none): a #GVariant to use as @action's parameter, or %NULL * * Sets the default action of @notification to @action. This action is * activated when the notification is clicked on. It must be an * application-wide action (start with "app."). * - * If @target_format is given, it is used to collect remaining - * positional parameters into a GVariant instance, similar to - * g_variant_new(). - * * If @target is non-%NULL, @action will be activated with @target as * its parameter. * @@ -692,6 +705,21 @@ g_notification_serialize_button (Button *button) return g_variant_builder_end (&builder); } +static GVariant * +g_notification_get_priority_nick (GNotification *notification) +{ + GEnumClass *enum_class; + GEnumValue *value; + GVariant *nick; + + enum_class = g_type_class_ref (G_TYPE_NOTIFICATION_PRIORITY); + value = g_enum_get_value (enum_class, g_notification_get_priority (notification)); + nick = g_variant_new_string (value->value_nick); + g_type_class_unref (enum_class); + + return nick; +} + /*< private > * g_notification_serialize: * @@ -723,7 +751,7 @@ g_notification_serialize (GNotification *notification) } } - g_variant_builder_add (&builder, "{sv}", "urgent", g_variant_new_boolean (notification->urgent)); + g_variant_builder_add (&builder, "{sv}", "priority", g_notification_get_priority_nick (notification)); if (notification->default_action) {