[balsa/wip/gtk4: 118/351] Make libbalsa_clear_source_id() gboolean
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/wip/gtk4: 118/351] Make libbalsa_clear_source_id() gboolean
- Date: Wed, 23 May 2018 21:26:51 +0000 (UTC)
commit e840ab858146ca634f05cf744fea60afacff6b6a
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Tue Jan 9 09:38:58 2018 -0500
Make libbalsa_clear_source_id() gboolean
For convenience, it now returns whether a GSource was removed.
libbalsa/misc.c | 12 +++++++++---
libbalsa/misc.h | 2 +-
src/information-dialog.c | 7 +++----
3 files changed, 13 insertions(+), 8 deletions(-)
---
diff --git a/libbalsa/misc.c b/libbalsa/misc.c
index e490266..e0bfcb9 100644
--- a/libbalsa/misc.c
+++ b/libbalsa/misc.c
@@ -1213,14 +1213,20 @@ libbalsa_font_string_to_css(const gchar * font_string,
/*
* Convenience function for removing and clearing a GSource id
+ *
+ * Returns TRUE if the GSource was removed
*/
-void
+gboolean
libbalsa_clear_source_id(guint * tag)
{
- g_return_if_fail(tag != NULL);
+ gboolean retval;
- if (*tag != 0U) {
+ g_return_val_if_fail(tag != NULL, FALSE);
+
+ if ((retval = (*tag != 0U))) {
g_source_remove(*tag);
*tag = 0U;
}
+
+ return retval;
}
diff --git a/libbalsa/misc.h b/libbalsa/misc.h
index ac02514..9756236 100644
--- a/libbalsa/misc.h
+++ b/libbalsa/misc.h
@@ -158,6 +158,6 @@ gchar * libbalsa_text_to_html(const gchar * title, const gchar * body, const gch
GString * libbalsa_html_encode_hyperlinks(GString * paragraph);
gchar *libbalsa_font_string_to_css(const gchar * font_string, const gchar * name);
-void libbalsa_clear_source_id(guint * tag);
+gboolean libbalsa_clear_source_id(guint * tag);
#endif /* __LIBBALSA_MISC_H__ */
diff --git a/src/information-dialog.c b/src/information-dialog.c
index a2327cb..2616e5c 100644
--- a/src/information-dialog.c
+++ b/src/information-dialog.c
@@ -302,7 +302,7 @@ balsa_information_list(GtkWindow *parent, LibBalsaInformationType type,
}
}
-static guint bar_timeout_id = 0;
+static guint bar_timeout_id = 0U;
static gboolean
status_bar_refresh(gpointer data)
{
@@ -315,7 +315,7 @@ status_bar_refresh(gpointer data)
gtk_statusbar_pop(statusbar, context_id);
}
- bar_timeout_id = 0;
+ bar_timeout_id = 0U;
return FALSE;
}
@@ -335,9 +335,8 @@ balsa_information_bar(GtkWindow *parent, LibBalsaInformationType type,
context_id = gtk_statusbar_get_context_id(statusbar, "Information bar");
/* First clear any current message. */
- if (bar_timeout_id) {
+ if (libbalsa_clear_source_id(&bar_timeout_id)) {
gtk_statusbar_pop(statusbar, context_id);
- g_source_remove(bar_timeout_id);
}
line = g_strdup(msg);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]