diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-08-11 04:41:38 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-08-11 05:20:35 +0800 |
commit | 2ecce97b88d418a77eb399ff4ca70a329e6aed3b (patch) | |
tree | ec5822d80f6ccb9f2c30a91b571a16b525a9692a | |
parent | 82cf89330597aa4feeb6d4fb1174dbc0bd13d1e4 (diff) | |
download | gsoc2013-evolution-2ecce97b88d418a77eb399ff4ca70a329e6aed3b.tar gsoc2013-evolution-2ecce97b88d418a77eb399ff4ca70a329e6aed3b.tar.gz gsoc2013-evolution-2ecce97b88d418a77eb399ff4ca70a329e6aed3b.tar.bz2 gsoc2013-evolution-2ecce97b88d418a77eb399ff4ca70a329e6aed3b.tar.lz gsoc2013-evolution-2ecce97b88d418a77eb399ff4ca70a329e6aed3b.tar.xz gsoc2013-evolution-2ecce97b88d418a77eb399ff4ca70a329e6aed3b.tar.zst gsoc2013-evolution-2ecce97b88d418a77eb399ff4ca70a329e6aed3b.zip |
Add e_alert_bar_close_alert().
Closes the active EAlert and returns TRUE, or else returns FALSE if
there is no active EAlert.
-rw-r--r-- | doc/reference/evolution-util/evolution-util-sections.txt | 1 | ||||
-rw-r--r-- | e-util/e-alert-bar.c | 40 | ||||
-rw-r--r-- | e-util/e-alert-bar.h | 1 |
3 files changed, 42 insertions, 0 deletions
diff --git a/doc/reference/evolution-util/evolution-util-sections.txt b/doc/reference/evolution-util/evolution-util-sections.txt index f4878fd4fd..aa1ac5f920 100644 --- a/doc/reference/evolution-util/evolution-util-sections.txt +++ b/doc/reference/evolution-util/evolution-util-sections.txt @@ -162,6 +162,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 c19fa74a47..4e621d7f56 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 d565f1ba84..560465756c 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 |