Allow properties to be set in any order
The code as written needlessly required summary to be set first. https://bugzilla.gnome.org/show_bug.cgi?id=645222
This commit is contained in:
parent
cdc6f37dd8
commit
10ea1f0e65
|
@ -228,6 +228,12 @@ notify_notification_class_init (NotifyNotificationClass *klass)
|
||||||
| G_PARAM_STATIC_BLURB));
|
| G_PARAM_STATIC_BLURB));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
notify_notification_update_internal (NotifyNotification *notification,
|
||||||
|
const char *summary,
|
||||||
|
const char *body,
|
||||||
|
const char *icon);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
notify_notification_set_property (GObject *object,
|
notify_notification_set_property (GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
|
@ -243,21 +249,21 @@ notify_notification_set_property (GObject *object,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_SUMMARY:
|
case PROP_SUMMARY:
|
||||||
notify_notification_update (notification,
|
notify_notification_update_internal (notification,
|
||||||
g_value_get_string (value),
|
g_value_get_string (value),
|
||||||
priv->body,
|
priv->body,
|
||||||
priv->icon_name);
|
priv->icon_name);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_BODY:
|
case PROP_BODY:
|
||||||
notify_notification_update (notification,
|
notify_notification_update_internal (notification,
|
||||||
priv->summary,
|
priv->summary,
|
||||||
g_value_get_string (value),
|
g_value_get_string (value),
|
||||||
priv->icon_name);
|
priv->icon_name);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_ICON_NAME:
|
case PROP_ICON_NAME:
|
||||||
notify_notification_update (notification,
|
notify_notification_update_internal (notification,
|
||||||
priv->summary,
|
priv->summary,
|
||||||
priv->body,
|
priv->body,
|
||||||
g_value_get_string (value));
|
g_value_get_string (value));
|
||||||
|
@ -389,6 +395,35 @@ notify_notification_new (const char *summary,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
notify_notification_update_internal (NotifyNotification *notification,
|
||||||
|
const char *summary,
|
||||||
|
const char *body,
|
||||||
|
const char *icon)
|
||||||
|
{
|
||||||
|
if (notification->priv->summary != summary) {
|
||||||
|
g_free (notification->priv->summary);
|
||||||
|
notification->priv->summary = g_strdup (summary);
|
||||||
|
g_object_notify (G_OBJECT (notification), "summary");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (notification->priv->body != body) {
|
||||||
|
g_free (notification->priv->body);
|
||||||
|
notification->priv->body = (body != NULL
|
||||||
|
&& *body != '\0' ? g_strdup (body) : NULL);
|
||||||
|
g_object_notify (G_OBJECT (notification), "body");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (notification->priv->icon_name != icon) {
|
||||||
|
g_free (notification->priv->icon_name);
|
||||||
|
notification->priv->icon_name = (icon != NULL
|
||||||
|
&& *icon != '\0' ? g_strdup (icon) : NULL);
|
||||||
|
g_object_notify (G_OBJECT (notification), "icon-name");
|
||||||
|
}
|
||||||
|
|
||||||
|
notification->priv->updates_pending = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* notify_notification_update:
|
* notify_notification_update:
|
||||||
* @notification: The notification to update.
|
* @notification: The notification to update.
|
||||||
|
@ -412,27 +447,7 @@ notify_notification_update (NotifyNotification *notification,
|
||||||
g_return_val_if_fail (NOTIFY_IS_NOTIFICATION (notification), FALSE);
|
g_return_val_if_fail (NOTIFY_IS_NOTIFICATION (notification), FALSE);
|
||||||
g_return_val_if_fail (summary != NULL && *summary != '\0', FALSE);
|
g_return_val_if_fail (summary != NULL && *summary != '\0', FALSE);
|
||||||
|
|
||||||
if (notification->priv->summary != summary) {
|
notify_notification_update_internal (notification, summary, body, icon);
|
||||||
g_free (notification->priv->summary);
|
|
||||||
notification->priv->summary = g_strdup (summary);
|
|
||||||
g_object_notify (G_OBJECT (notification), "summary");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (notification->priv->body != body) {
|
|
||||||
g_free (notification->priv->body);
|
|
||||||
notification->priv->body = (body != NULL
|
|
||||||
&& *body != '\0' ? g_strdup (body) : NULL);
|
|
||||||
g_object_notify (G_OBJECT (notification), "body");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (notification->priv->icon_name != icon) {
|
|
||||||
g_free (notification->priv->icon_name);
|
|
||||||
notification->priv->icon_name = (icon != NULL
|
|
||||||
&& *icon != '\0' ? g_strdup (icon) : NULL);
|
|
||||||
g_object_notify (G_OBJECT (notification), "icon-name");
|
|
||||||
}
|
|
||||||
|
|
||||||
notification->priv->updates_pending = TRUE;
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue