sleep-monitor: merge RESUMING signal into NMSleepMonitor's SLEEPING signal

Having two signals is more complicated and everybody who cares about
one signal also cares about the other.
This commit is contained in:
Thomas Haller 2016-04-27 18:21:28 +02:00
parent 2208ca3726
commit 07db1217a9
3 changed files with 14 additions and 37 deletions

View file

@ -4017,21 +4017,12 @@ impl_manager_sleep (NMManager *self,
}
static void
sleeping_cb (NMSleepMonitor *monitor, gpointer user_data)
sleeping_cb (NMSleepMonitor *monitor, gboolean is_about_to_suspend, gpointer user_data)
{
NMManager *self = user_data;
_LOGD (LOGD_SUSPEND, "Received sleeping signal");
_internal_sleep (self, TRUE);
}
static void
resuming_cb (NMSleepMonitor *monitor, gpointer user_data)
{
NMManager *self = user_data;
_LOGD (LOGD_SUSPEND, "Received resuming signal");
_internal_sleep (self, FALSE);
_LOGD (LOGD_SUSPEND, "Received %s signal", is_about_to_suspend ? "sleeping" : "resuming");
_internal_sleep (self, is_about_to_suspend);
}
static void
@ -5200,8 +5191,6 @@ nm_manager_init (NMManager *self)
priv->sleep_monitor = g_object_ref (nm_sleep_monitor_get ());
g_signal_connect (priv->sleep_monitor, NM_SLEEP_MONITOR_SLEEPING,
G_CALLBACK (sleeping_cb), self);
g_signal_connect (priv->sleep_monitor, NM_SLEEP_MONITOR_RESUMING,
G_CALLBACK (resuming_cb), self);
/* Listen for authorization changes */
g_signal_connect (nm_auth_manager_get (),
@ -5438,7 +5427,6 @@ dispose (GObject *object)
if (priv->sleep_monitor) {
g_signal_handlers_disconnect_by_func (priv->sleep_monitor, sleeping_cb, manager);
g_signal_handlers_disconnect_by_func (priv->sleep_monitor, resuming_cb, manager);
g_clear_object (&priv->sleep_monitor);
}

View file

@ -84,7 +84,6 @@ struct _NMSleepMonitorClass {
enum {
SLEEPING,
RESUMING,
LAST_SIGNAL,
};
static guint signals[LAST_SIGNAL] = {0};
@ -238,17 +237,17 @@ sleep_signal (NMSleepMonitor *self,
_LOGD ("received %s signal", is_about_to_suspend ? "SLEEP" : "RESUME");
if (is_about_to_suspend) {
g_signal_emit (self, signals[SLEEPING], 0);
#if !USE_UPOWER
drop_inhibitor (self);
#endif
} else {
#if !USE_UPOWER
if (!is_about_to_suspend)
take_inhibitor (self);
#endif
g_signal_emit (self, signals[RESUMING], 0);
}
g_signal_emit (self, signals[SLEEPING], 0, is_about_to_suspend);
#if !USE_UPOWER
if (is_about_to_suspend)
drop_inhibitor (self);
#endif
}
static void
@ -337,13 +336,7 @@ nm_sleep_monitor_class_init (NMSleepMonitorClass *klass)
NM_TYPE_SLEEP_MONITOR,
G_SIGNAL_RUN_LAST,
0, NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
signals[RESUMING] = g_signal_new (NM_SLEEP_MONITOR_RESUMING,
NM_TYPE_SLEEP_MONITOR,
G_SIGNAL_RUN_LAST,
0, NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_cclosure_marshal_VOID__BOOLEAN,
G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
}

View file

@ -13,16 +13,13 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* (C) Copyright 2012 Red Hat, Inc.
* (C) Copyright 2012-2016 Red Hat, Inc.
* Author: Matthias Clasen <mclasen@redhat.com>
*/
#ifndef __NETWORKMANAGER_SLEEP_MONITOR_H__
#define __NETWORKMANAGER_SLEEP_MONITOR_H__
#include "nm-default.h"
G_BEGIN_DECLS
#define NM_TYPE_SLEEP_MONITOR (nm_sleep_monitor_get_type ())
@ -33,7 +30,6 @@ G_BEGIN_DECLS
#define NM_IS_SLEEP_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), NM_TYPE_SLEEP_MONITOR))
#define NM_SLEEP_MONITOR_SLEEPING "sleeping"
#define NM_SLEEP_MONITOR_RESUMING "resuming"
typedef struct _NMSleepMonitorClass NMSleepMonitorClass;