aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2010-11-01 05:11:35 +0800
committerRodrigo Moya <rodrigo@gnome-db.org>2010-11-10 06:33:20 +0800
commit616f0b140bb937d7afeb46f834e32e8c51a67e1e (patch)
treee9a794d8f2722bb9034f01bf1192b0b16b2e3d57 /e-util
parent4a929caada81820d7499b09875870b84e9900912 (diff)
downloadgsoc2013-evolution-616f0b140bb937d7afeb46f834e32e8c51a67e1e.tar.gz
gsoc2013-evolution-616f0b140bb937d7afeb46f834e32e8c51a67e1e.tar.zst
gsoc2013-evolution-616f0b140bb937d7afeb46f834e32e8c51a67e1e.zip
EActivity: Add an "alert-sink" property.
This is just for convenience, EActivity does not use this property. Especially useful in async function callbacks when the operation failed and now you have to do something useful with the GError.
Diffstat (limited to 'e-util')
-rw-r--r--e-util/e-activity.c75
-rw-r--r--e-util/e-activity.h6
2 files changed, 61 insertions, 20 deletions
diff --git a/e-util/e-activity.c b/e-util/e-activity.c
index 7e0cb1c8be..74d0eeda26 100644
--- a/e-util/e-activity.c
+++ b/e-util/e-activity.c
@@ -34,6 +34,7 @@
struct _EActivityPrivate {
GCancellable *cancellable;
+ EAlertSink *alert_sink;
EActivityState state;
gchar *icon_name;
@@ -43,6 +44,7 @@ struct _EActivityPrivate {
enum {
PROP_0,
+ PROP_ALERT_SINK,
PROP_CANCELLABLE,
PROP_ICON_NAME,
PROP_PERCENT,
@@ -75,6 +77,12 @@ activity_set_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
+ case PROP_ALERT_SINK:
+ e_activity_set_alert_sink (
+ E_ACTIVITY (object),
+ g_value_get_object (value));
+ return;
+
case PROP_CANCELLABLE:
e_activity_set_cancellable (
E_ACTIVITY (object),
@@ -116,6 +124,12 @@ activity_get_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
+ case PROP_ALERT_SINK:
+ g_value_set_object (
+ value, e_activity_get_alert_sink (
+ E_ACTIVITY (object)));
+ return;
+
case PROP_CANCELLABLE:
g_value_set_object (
value, e_activity_get_cancellable (
@@ -157,6 +171,11 @@ activity_dispose (GObject *object)
priv = E_ACTIVITY_GET_PRIVATE (object);
+ if (priv->alert_sink != NULL) {
+ g_object_unref (priv->alert_sink);
+ priv->alert_sink = NULL;
+ }
+
if (priv->cancellable != NULL) {
g_signal_handlers_disconnect_matched (
priv->cancellable,
@@ -245,6 +264,17 @@ e_activity_class_init (EActivityClass *class)
g_object_class_install_property (
object_class,
+ PROP_ALERT_SINK,
+ g_param_spec_object (
+ "alert-sink",
+ NULL,
+ NULL,
+ E_TYPE_ALERT_SINK,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (
+ object_class,
PROP_CANCELLABLE,
g_param_spec_object (
"cancellable",
@@ -314,24 +344,6 @@ e_activity_new (void)
return g_object_new (E_TYPE_ACTIVITY, NULL);
}
-EActivity *
-e_activity_newv (const gchar *format, ...)
-{
- EActivity *activity;
- gchar *text;
- va_list args;
-
- activity = e_activity_new ();
-
- va_start (args, format);
- text = g_strdup_vprintf (format, args);
- e_activity_set_text (activity, text);
- g_free (text);
- va_end (args);
-
- return activity;
-}
-
gchar *
e_activity_describe (EActivity *activity)
{
@@ -345,6 +357,33 @@ e_activity_describe (EActivity *activity)
return class->describe (activity);
}
+EAlertSink *
+e_activity_get_alert_sink (EActivity *activity)
+{
+ g_return_val_if_fail (E_IS_ACTIVITY (activity), NULL);
+
+ return activity->priv->alert_sink;
+}
+
+void
+e_activity_set_alert_sink (EActivity *activity,
+ EAlertSink *alert_sink)
+{
+ g_return_if_fail (E_IS_ACTIVITY (activity));
+
+ if (alert_sink != NULL) {
+ g_return_if_fail (E_IS_ALERT_SINK (alert_sink));
+ g_object_ref (alert_sink);
+ }
+
+ if (activity->priv->alert_sink != NULL)
+ g_object_unref (activity->priv->alert_sink);
+
+ activity->priv->alert_sink = alert_sink;
+
+ g_object_notify (G_OBJECT (activity), "alert-sink");
+}
+
GCancellable *
e_activity_get_cancellable (EActivity *activity)
{
diff --git a/e-util/e-activity.h b/e-util/e-activity.h
index 63195b770a..4602a5696e 100644
--- a/e-util/e-activity.h
+++ b/e-util/e-activity.h
@@ -23,6 +23,7 @@
#define E_ACTIVITY_H
#include <gtk/gtk.h>
+#include <e-util/e-alert-sink.h>
#include <e-util/e-util-enums.h>
/* Standard GObject macros */
@@ -64,9 +65,10 @@ struct _EActivityClass {
GType e_activity_get_type (void);
EActivity * e_activity_new (void);
-EActivity * e_activity_newv (const gchar *format,
- ...) G_GNUC_PRINTF (1, 2);
gchar * e_activity_describe (EActivity *activity);
+EAlertSink * e_activity_get_alert_sink (EActivity *activity);
+void e_activity_set_alert_sink (EActivity *activity,
+ EAlertSink *alert_sink);
GCancellable * e_activity_get_cancellable (EActivity *activity);
void e_activity_set_cancellable (EActivity *activity,
GCancellable *cancellable);