[evolution/gnome-3-8] Add e_alert_bar_close_alert().
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/gnome-3-8] Add e_alert_bar_close_alert().
- Date: Sat, 10 Aug 2013 21:37:27 +0000 (UTC)
commit 7056c2e6214f50a2c9550de98be1d982c02cf2bb
Author: Matthew Barnes <mbarnes redhat com>
Date: Sat Aug 10 16:41:38 2013 -0400
Add e_alert_bar_close_alert().
Closes the active EAlert and returns TRUE, or else returns FALSE if
there is no active EAlert.
(cherry picked from commit 2ecce97b88d418a77eb399ff4ca70a329e6aed3b)
doc/reference/libeutil/libeutil-sections.txt | 1 +
e-util/e-alert-bar.c | 40 ++++++++++++++++++++++++++
e-util/e-alert-bar.h | 1 +
3 files changed, 42 insertions(+), 0 deletions(-)
---
diff --git a/doc/reference/libeutil/libeutil-sections.txt b/doc/reference/libeutil/libeutil-sections.txt
index ab5d33a..d06b962 100644
--- a/doc/reference/libeutil/libeutil-sections.txt
+++ b/doc/reference/libeutil/libeutil-sections.txt
@@ -161,6 +161,7 @@ EAlertBar
e_alert_bar_new
e_alert_bar_clear
e_alert_bar_add_alert
+e_alert_bar_close_alert
<SUBSECTION Standard>
E_ALERT_BAR
E_IS_ALERT_BAR
diff --git a/e-util/e-alert-bar.c b/e-util/e-alert-bar.c
index c19fa74..4e621d7 100644
--- a/e-util/e-alert-bar.c
+++ b/e-util/e-alert-bar.c
@@ -298,10 +298,20 @@ alert_bar_get_request_mode (GtkWidget *widget)
}
static void
+alert_bar_close (GtkInfoBar *info_bar)
+{
+ /* GtkInfoBar's close() method looks for a button with a response
+ * code of GTK_RESPONSE_CANCEL. But that does not apply here, so
+ * we have to override the method. */
+ e_alert_bar_close_alert (E_ALERT_BAR (info_bar));
+}
+
+static void
e_alert_bar_class_init (EAlertBarClass *class)
{
GObjectClass *object_class;
GtkWidgetClass *widget_class;
+ GtkInfoBarClass *info_bar_class;
g_type_class_add_private (class, sizeof (EAlertBarPrivate));
@@ -311,6 +321,9 @@ e_alert_bar_class_init (EAlertBarClass *class)
widget_class = GTK_WIDGET_CLASS (class);
widget_class->get_request_mode = alert_bar_get_request_mode;
+
+ info_bar_class = GTK_INFO_BAR_CLASS (class);
+ info_bar_class->close = alert_bar_close;
}
static void
@@ -388,3 +401,30 @@ e_alert_bar_add_alert (EAlertBar *alert_bar,
alert_bar_show_alert (alert_bar);
}
+
+/**
+ * e_alert_bar_close_alert:
+ * @alert_bar: an #EAlertBar
+ *
+ * Closes the active #EAlert and returns %TRUE, or else returns %FALSE if
+ * there is no active #EAlert.
+ *
+ * Returns: whether an #EAlert was closed
+ **/
+gboolean
+e_alert_bar_close_alert (EAlertBar *alert_bar)
+{
+ EAlert *alert;
+ gboolean alert_closed = FALSE;
+
+ g_return_val_if_fail (E_IS_ALERT_BAR (alert_bar), FALSE);
+
+ alert = g_queue_peek_head (&alert_bar->priv->alerts);
+
+ if (alert != NULL) {
+ alert_bar_response_close (alert);
+ alert_closed = TRUE;
+ }
+
+ return alert_closed;
+}
diff --git a/e-util/e-alert-bar.h b/e-util/e-alert-bar.h
index d565f1b..5604657 100644
--- a/e-util/e-alert-bar.h
+++ b/e-util/e-alert-bar.h
@@ -66,6 +66,7 @@ GtkWidget * e_alert_bar_new (void);
void e_alert_bar_clear (EAlertBar *alert_bar);
void e_alert_bar_add_alert (EAlertBar *alert_bar,
EAlert *alert);
+gboolean e_alert_bar_close_alert (EAlertBar *alert_bar);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]