[gnome-games/wip/abhinavsingh/gamepad-config: 20/22] gamepad: Add 'unplugged' signal to GamepadMonitor
- From: Abhinav Singh <abhinavsingh src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/abhinavsingh/gamepad-config: 20/22] gamepad: Add 'unplugged' signal to GamepadMonitor
- Date: Thu, 27 Jul 2017 10:18:27 +0000 (UTC)
commit 7453a50992d3b99983146bd85f92750ba3165bec
Author: theawless <theawless gmail com>
Date: Wed May 24 09:26:29 2017 +0530
gamepad: Add 'unplugged' signal to GamepadMonitor
The motivation is that without this signal, the users of GamepadMonitor
were forced to maintain an array for the plugged-in gamepads.
src/gamepad/gamepad-monitor.c | 19 +++++++++++++++++--
src/gamepad/gamepad-monitor.vapi | 1 +
2 files changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/src/gamepad/gamepad-monitor.c b/src/gamepad/gamepad-monitor.c
index e5fd497..d34c7b6 100644
--- a/src/gamepad/gamepad-monitor.c
+++ b/src/gamepad/gamepad-monitor.c
@@ -20,6 +20,7 @@ G_DEFINE_TYPE (GamesGamepadMonitor, games_gamepad_monitor, G_TYPE_OBJECT)
enum {
SIGNAL_GAMEPAD_PLUGGED,
+ SIGNAL_GAMEPAD_UNPLUGGED,
LAST_SIGNAL,
};
@@ -46,6 +47,7 @@ on_gamepad_unplugged (GamesGamepad *sender,
g_return_if_fail (sender != NULL);
g_hash_table_remove (self->gamepads, sender);
+ g_signal_emit (self, signals[SIGNAL_GAMEPAD_UNPLUGGED], 0);
}
static GamesGamepad *
@@ -206,9 +208,9 @@ static void games_gamepad_monitor_class_init (GamesGamepadMonitorClass *klass) {
G_OBJECT_CLASS (klass)->finalize = finalize;
/**
- * GamesGamepad::unplugged:
+ * GamesGamepad::plugged:
*
- * Emitted when the gamepad is unplugged.
+ * Emitted when the gamepad is plugged.
*/
signals[SIGNAL_GAMEPAD_PLUGGED] =
g_signal_new ("gamepad_plugged",
@@ -218,6 +220,19 @@ static void games_gamepad_monitor_class_init (GamesGamepadMonitorClass *klass) {
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
GAMES_TYPE_GAMEPAD);
+
+ /**
+ * GamesGamepad::unplugged:
+ *
+ * Emitted when the gamepad is unplugged.
+ */
+ signals[SIGNAL_GAMEPAD_UNPLUGGED] =
+ g_signal_new ("gamepad_unplugged",
+ GAMES_TYPE_GAMEPAD_MONITOR,
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
}
static void
diff --git a/src/gamepad/gamepad-monitor.vapi b/src/gamepad/gamepad-monitor.vapi
index ec61c08..8a67ec1 100644
--- a/src/gamepad/gamepad-monitor.vapi
+++ b/src/gamepad/gamepad-monitor.vapi
@@ -3,6 +3,7 @@
[CCode (cheader_filename = "gamepad-monitor.h")]
private class Games.GamepadMonitor : GLib.Object {
public signal void gamepad_plugged (Gamepad gamepad);
+ public signal void gamepad_unplugged ();
public static GamepadMonitor get_instance ();
public void foreach_gamepad (GamepadCallback callback);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]