[evolution] Use EAlert API in EAlertActivity rather than using g_object_get_data
- From: Jonathon Jongsma <jjongsma src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evolution] Use EAlert API in EAlertActivity rather than using g_object_get_data
- Date: Tue, 8 Dec 2009 20:38:38 +0000 (UTC)
commit e0ee2c648c2b101c3e8f1600fe9dcadf34963a63
Author: Jonathon Jongsma <jonathon quotidian org>
Date: Tue Dec 8 14:14:26 2009 -0600
Use EAlert API in EAlertActivity rather than using g_object_get_data
previously we were storing the EAlert's primary and secondary text in the dialog
object (using g_object_set_data_full). Since EAlertDialog encapsulates an
EAlert and we have access to the underlying EAlert object, we can just use the
EAlert API to get the primary and secondary text rather than storing duplicates
copies of it in the dialog.
e-util/e-alert-activity.c | 18 ++++++++++++++----
e-util/e-alert-dialog.c | 33 +++++++++++++++++++++++----------
e-util/e-alert-dialog.h | 1 +
3 files changed, 38 insertions(+), 14 deletions(-)
---
diff --git a/e-util/e-alert-activity.c b/e-util/e-alert-activity.c
index 1e8f915..23f747f 100644
--- a/e-util/e-alert-activity.c
+++ b/e-util/e-alert-activity.c
@@ -14,12 +14,16 @@
* You should have received a copy of the GNU Lesser General Public
* License along with the program; if not, see <http://www.gnu.org/licenses/>
*
+ * Authors:
+ * Jonathon Jongsma <jonathon jongsma collabora co uk>
*
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ * Copyright (C) 2009 Intel Corporation
*
*/
#include "e-alert-activity.h"
+#include "e-alert-dialog.h"
#define E_ALERT_ACTIVITY_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE \
@@ -100,21 +104,27 @@ alert_activity_constructed (GObject *object)
{
EActivity *activity;
EAlertActivity *alert_activity;
+ EAlert *alert;
GtkWidget *message_dialog;
- const gchar *primary_text;
- const gchar *secondary_text;
+ gchar *primary_text;
+ gchar *secondary_text;
alert_activity = E_ALERT_ACTIVITY (object);
message_dialog = e_alert_activity_get_message_dialog (alert_activity);
object = G_OBJECT (message_dialog);
- primary_text = g_object_get_data (object, "primary");
- secondary_text = g_object_get_data (object, "secondary");
+ alert = e_alert_dialog_get_alert (E_ALERT_DIALOG (message_dialog));
+ primary_text = e_alert_get_primary_text (alert);
+ secondary_text = e_alert_get_secondary_text (alert);
+ g_object_unref (alert);
activity = E_ACTIVITY (alert_activity);
e_activity_set_primary_text (activity, primary_text);
e_activity_set_secondary_text (activity, secondary_text);
+ g_free (primary_text);
+ g_free (secondary_text);
+
/* This is a constructor property, so can't do it in init().
* XXX What we really want to do is override the property's
* default value, but GObject does not support that. */
diff --git a/e-util/e-alert-dialog.c b/e-util/e-alert-dialog.c
index 5b8d2a8..dd4d399 100644
--- a/e-util/e-alert-dialog.c
+++ b/e-util/e-alert-dialog.c
@@ -125,7 +125,6 @@ e_alert_dialog_constructed (GObject *obj)
GtkWidget *action_area;
GtkWidget *content_area;
GString *out;
- gchar *perr=NULL, *serr=NULL;
gchar *title, *primary, *secondary;
g_return_if_fail (self != NULL);
@@ -203,15 +202,11 @@ e_alert_dialog_constructed (GObject *obj)
g_string_append_printf (out,
"<span weight=\"bold\" size=\"larger\">%s</span>\n\n",
primary);
- /* FIXME: What is this used for? */
- perr = g_strdup (primary);
- } else
- perr = g_strdup (title); /* XXX: why? */
+ }
secondary = e_alert_get_secondary_text (alert);
if (secondary) {
g_string_append (out, secondary);
- serr = g_strdup (secondary);
}
g_free (secondary);
@@ -238,9 +233,6 @@ e_alert_dialog_constructed (GObject *obj)
gtk_widget_show_all(hbox);
gtk_box_pack_start (GTK_BOX (content_area), hbox, TRUE, TRUE, 0);
- /* FIXME: What is this used for? */
- g_object_set_data_full ((GObject *) self, "primary", perr, g_free);
- g_object_set_data_full ((GObject *) self, "secondary", serr, g_free);
}
static void
@@ -333,7 +325,7 @@ e_alert_run_dialog_for_args (GtkWindow *parent, const gchar *tag, const gchar *a
/**
* e_alert_dialog_count_buttons:
- * @dialog: a #GtkDialog
+ * @dialog: a #EAlertDialog
*
* Counts the number of buttons in @dialog's action area.
*
@@ -360,3 +352,24 @@ e_alert_dialog_count_buttons (EAlertDialog *dialog)
return n_buttons;
}
+
+/**
+ * e_alert_dialog_get_alert:
+ * @dialog: a #EAlertDialog
+ *
+ * Convenience API for getting the #EAlert associated with @dialog
+ *
+ * Return value: the #EAlert associated with @dialog. The alert should be
+ * unreffed when no longer needed.
+ */
+EAlert *
+e_alert_dialog_get_alert (EAlertDialog *dialog)
+{
+ EAlert *alert = NULL;
+
+ g_return_val_if_fail (dialog != NULL, NULL);
+
+ g_object_get (dialog, "alert", &alert,
+ NULL);
+ return alert;
+}
diff --git a/e-util/e-alert-dialog.h b/e-util/e-alert-dialog.h
index d70a76a..df87c90 100644
--- a/e-util/e-alert-dialog.h
+++ b/e-util/e-alert-dialog.h
@@ -76,6 +76,7 @@ gint e_alert_run_dialog(GtkWindow *parent, EAlert *alert);
gint e_alert_run_dialog_for_args (GtkWindow *parent, const gchar *tag, const gchar *arg0, ...);
guint e_alert_dialog_count_buttons (EAlertDialog *dialog);
+EAlert *e_alert_dialog_get_alert (EAlertDialog *dialog);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]