[glib] unix signal watch: make API match other sources
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] unix signal watch: make API match other sources
- Date: Tue, 30 Aug 2011 23:23:04 +0000 (UTC)
commit c0eb77bfc8be7c30c271f2415c08f8f3186113c3
Author: Ryan Lortie <desrt desrt ca>
Date: Tue Aug 30 09:45:52 2011 -0400
unix signal watch: make API match other sources
Change the unix signal watch API to match other sources in both
available functions, names of those functions and order of the
parameters to the _full function.
https://bugzilla.gnome.org/show_bug.cgi?id=657705
docs/reference/glib/glib-sections.txt | 3 +-
glib/glib-unix.c | 36 ++++++++++++++++++++++++++------
glib/glib-unix.h | 16 +++++++++-----
glib/glib.symbols | 3 +-
glib/tests/unix.c | 12 +---------
5 files changed, 45 insertions(+), 25 deletions(-)
---
diff --git a/docs/reference/glib/glib-sections.txt b/docs/reference/glib/glib-sections.txt
index 10f7ab9..e7036a6 100644
--- a/docs/reference/glib/glib-sections.txt
+++ b/docs/reference/glib/glib-sections.txt
@@ -1958,8 +1958,9 @@ g_win32_ftruncate
<FILE>gunix</FILE>
G_UNIX_ERROR
g_unix_open_pipe
+g_unix_signal_add
+g_unix_signal_add_full
g_unix_signal_source_new
-g_unix_signal_add_watch_full
g_unix_set_fd_nonblocking
<SUBSECTION Private>
diff --git a/glib/glib-unix.c b/glib/glib-unix.c
index 77bcea1..6b5495b 100644
--- a/glib/glib-unix.c
+++ b/glib/glib-unix.c
@@ -223,10 +223,10 @@ g_unix_signal_source_new (int signum)
}
/**
- * g_unix_signal_add_watch_full:
- * @signum: Signal number
+ * g_unix_signal_add_full:
* @priority: the priority of the signal source. Typically this will be in
* the range between #G_PRIORITY_DEFAULT and #G_PRIORITY_HIGH.
+ * @signum: Signal number
* @handler: Callback
* @user_data: Data for @handler
* @notify: #GDestroyNotify for @handler
@@ -240,11 +240,11 @@ g_unix_signal_source_new (int signum)
* Since: 2.30
*/
guint
-g_unix_signal_add_watch_full (int signum,
- int priority,
- GSourceFunc handler,
- gpointer user_data,
- GDestroyNotify notify)
+g_unix_signal_add_full (int priority,
+ int signum,
+ GSourceFunc handler,
+ gpointer user_data,
+ GDestroyNotify notify)
{
guint id;
GSource *source;
@@ -260,3 +260,25 @@ g_unix_signal_add_watch_full (int signum,
return id;
}
+
+/**
+ * g_unix_signal_add_full:
+ * @signum: Signal number
+ * @handler: Callback
+ * @user_data: Data for @handler
+ *
+ * A convenience function for g_unix_signal_source_new(), which
+ * attaches to the default #GMainContext. You can remove the watch
+ * using g_source_remove().
+ *
+ * Returns: An ID (greater than 0) for the event source
+ *
+ * Since: 2.30
+ */
+guint
+g_unix_signal_add (int signum,
+ GSourceFunc handler,
+ gpointer user_data)
+{
+ return g_unix_signal_add_full (G_PRIORITY_DEFAULT, signum, handler, user_data, NULL);
+}
diff --git a/glib/glib-unix.h b/glib/glib-unix.h
index b136fe3..32c6c80 100644
--- a/glib/glib-unix.h
+++ b/glib/glib-unix.h
@@ -65,12 +65,16 @@ gboolean g_unix_set_fd_nonblocking (gint fd,
gboolean nonblock,
GError **error);
-GSource *g_unix_signal_source_new (gint signum);
+GSource *g_unix_signal_source_new (gint signum);
-guint g_unix_signal_add_watch_full (gint signum,
- gint priority,
- GSourceFunc handler,
- gpointer user_data,
- GDestroyNotify notify);
+guint g_unix_signal_add_full (gint priority,
+ gint signum,
+ GSourceFunc handler,
+ gpointer user_data,
+ GDestroyNotify notify);
+
+guint g_unix_signal_add (gint signum,
+ GSourceFunc handler,
+ gpointer user_data);
#endif
diff --git a/glib/glib.symbols b/glib/glib.symbols
index 3af1cfa..f611d91 100644
--- a/glib/glib.symbols
+++ b/glib/glib.symbols
@@ -1576,8 +1576,9 @@ g_hostname_to_unicode
g_unix_error_quark
g_unix_open_pipe
g_unix_set_fd_nonblocking
+g_unix_signal_add
+g_unix_signal_add_full
g_unix_signal_source_new
-g_unix_signal_add_watch_full
#endif
g_ascii_table
g_utf8_skip
diff --git a/glib/tests/unix.c b/glib/tests/unix.c
index 453ad64..061b5a6 100644
--- a/glib/tests/unix.c
+++ b/glib/tests/unix.c
@@ -98,11 +98,7 @@ test_signal (int signum)
mainloop = g_main_loop_new (NULL, FALSE);
sig_received = FALSE;
- g_unix_signal_add_watch_full (signum,
- G_PRIORITY_DEFAULT,
- on_sig_received,
- mainloop,
- NULL);
+ g_unix_signal_add (signum, on_sig_received, mainloop);
kill (getpid (), signum);
g_assert (!sig_received);
g_timeout_add (5000, sig_not_received, mainloop);
@@ -138,11 +134,7 @@ test_sighup_add_remove (void)
mainloop = g_main_loop_new (NULL, FALSE);
sig_received = FALSE;
- id = g_unix_signal_add_watch_full (SIGHUP,
- G_PRIORITY_DEFAULT,
- on_sig_received,
- mainloop,
- NULL);
+ id = g_unix_signal_add (SIGHUP, on_sig_received, mainloop);
g_source_remove (id);
kill (getpid (), SIGHUP);
g_assert (!sig_received);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]