Commit a4c4e5bb authored by Guido Gunther's avatar Guido Gunther Committed by Guido Gunther
Browse files

lockscreen-manager: Drop PhoshLockscreenManagerPrivate



It's a finaly type so no need for priv (and it's very unlikely
we'll ever derive here)
Signed-off-by: Guido Gunther's avatarGuido Günther <guido.gunther@puri.sm>
parent 9ba7f117
......@@ -46,7 +46,9 @@ enum {
static GParamSpec *props[PHOSH_LOCKSCREEN_MANAGER_PROP_LAST_PROP];
typedef struct {
struct _PhoshLockscreenManager {
GObject parent;
PhoshLockscreen *lockscreen; /* phone display lock screen */
PhoshSessionPresence *presence; /* gnome-session's presence interface */
GPtrArray *shields; /* other outputs */
......@@ -56,39 +58,32 @@ typedef struct {
gboolean locked;
gint64 active_time; /* when lock was activated (in us) */
int transform; /* the shell transform before locking */
} PhoshLockscreenManagerPrivate;
typedef struct _PhoshLockscreenManager {
GObject parent;
} PhoshLockscreenManager;
};
G_DEFINE_TYPE_WITH_PRIVATE (PhoshLockscreenManager, phosh_lockscreen_manager, G_TYPE_OBJECT)
G_DEFINE_TYPE (PhoshLockscreenManager, phosh_lockscreen_manager, G_TYPE_OBJECT)
static void
lockscreen_unlock_cb (PhoshLockscreenManager *self, PhoshLockscreen *lockscreen)
{
PhoshLockscreenManagerPrivate *priv = phosh_lockscreen_manager_get_instance_private (self);
PhoshShell *shell = phosh_shell_get_default ();
PhoshMonitorManager *monitor_manager = phosh_shell_get_monitor_manager (shell);
phosh_shell_set_transform (shell, priv->transform);
priv->transform = PHOSH_MONITOR_TRANSFORM_NORMAL;
phosh_shell_set_transform (shell, self->transform);
self->transform = PHOSH_MONITOR_TRANSFORM_NORMAL;
g_return_if_fail (PHOSH_IS_LOCKSCREEN (lockscreen));
g_return_if_fail (lockscreen == PHOSH_LOCKSCREEN (priv->lockscreen));
g_return_if_fail (lockscreen == PHOSH_LOCKSCREEN (self->lockscreen));
g_signal_handlers_disconnect_by_data (lockscreen, self);
g_signal_handlers_disconnect_by_data (monitor_manager, self);
g_clear_pointer (&priv->lockscreen, phosh_cp_widget_destroy);
g_clear_pointer (&self->lockscreen, phosh_cp_widget_destroy);
/* Unlock all other outputs */
g_clear_pointer (&priv->shields, g_ptr_array_unref);
g_clear_pointer (&self->shields, g_ptr_array_unref);
priv->locked = FALSE;
priv->active_time = 0;
self->locked = FALSE;
self->active_time = 0;
g_object_notify_by_pspec (G_OBJECT (self), props[PHOSH_LOCKSCREEN_MANAGER_PROP_LOCKED]);
}
......@@ -109,7 +104,6 @@ static void
lock_monitor (PhoshLockscreenManager *self,
PhoshMonitor *monitor)
{
PhoshLockscreenManagerPrivate *priv = phosh_lockscreen_manager_get_instance_private (self);
PhoshWayland *wl = phosh_wayland_get_default ();
GtkWidget *shield;
......@@ -117,7 +111,7 @@ lock_monitor (PhoshLockscreenManager *self,
phosh_wayland_get_zwlr_layer_shell_v1 (wl),
monitor->wl_output);
g_ptr_array_add (priv->shields, shield);
g_ptr_array_add (self->shields, shield);
gtk_widget_show (shield);
}
......@@ -152,19 +146,18 @@ on_monitor_added (PhoshLockscreenManager *self,
static void
lockscreen_lock (PhoshLockscreenManager *self)
{
PhoshLockscreenManagerPrivate *priv = phosh_lockscreen_manager_get_instance_private (self);
PhoshMonitor *primary_monitor;
PhoshWayland *wl = phosh_wayland_get_default ();
PhoshShell *shell = phosh_shell_get_default ();
PhoshMonitorManager *monitor_manager = phosh_shell_get_monitor_manager (shell);
g_return_if_fail (!priv->locked);
g_return_if_fail (!self->locked);
primary_monitor = phosh_shell_get_primary_monitor (shell);
g_return_if_fail (primary_monitor);
/* Undo any transform on the primary display so the keypad becomes usable */
priv->transform = phosh_shell_get_transform (shell);
self->transform = phosh_shell_get_transform (shell);
phosh_shell_set_transform (shell, PHOSH_MONITOR_TRANSFORM_NORMAL);
/* Listen for monitor changes */
......@@ -179,13 +172,13 @@ lockscreen_lock (PhoshLockscreenManager *self)
G_CONNECT_SWAPPED);
/* The primary output gets the clock, keypad, ... */
priv->lockscreen = PHOSH_LOCKSCREEN (phosh_lockscreen_new (
self->lockscreen = PHOSH_LOCKSCREEN (phosh_lockscreen_new (
phosh_wayland_get_zwlr_layer_shell_v1(wl),
primary_monitor->wl_output));
gtk_widget_show (GTK_WIDGET (priv->lockscreen));
gtk_widget_show (GTK_WIDGET (self->lockscreen));
/* Lock all other outputs */
priv->shields = g_ptr_array_new_with_free_func ((GDestroyNotify) (gtk_widget_destroy));
self->shields = g_ptr_array_new_with_free_func ((GDestroyNotify) (gtk_widget_destroy));
for (int i = 0; i < phosh_monitor_manager_get_num_monitors (monitor_manager); i++) {
PhoshMonitor *monitor = phosh_monitor_manager_get_monitor (monitor_manager, i);
......@@ -196,13 +189,13 @@ lockscreen_lock (PhoshLockscreenManager *self)
}
g_object_connect (
priv->lockscreen,
self->lockscreen,
"swapped-object-signal::lockscreen-unlock", G_CALLBACK(lockscreen_unlock_cb), self,
"swapped-object-signal::wakeup-output", G_CALLBACK(lockscreen_wakeup_output_cb), self,
NULL);
priv->locked = TRUE;
priv->active_time = g_get_monotonic_time ();
self->locked = TRUE;
self->active_time = g_get_monotonic_time ();
g_object_notify_by_pspec (G_OBJECT (self), props[PHOSH_LOCKSCREEN_MANAGER_PROP_LOCKED]);
}
......@@ -247,14 +240,13 @@ phosh_lockscreen_manager_get_property (GObject *object,
GParamSpec *pspec)
{
PhoshLockscreenManager *self = PHOSH_LOCKSCREEN_MANAGER (object);
PhoshLockscreenManagerPrivate *priv = phosh_lockscreen_manager_get_instance_private(self);
switch (property_id) {
case PHOSH_LOCKSCREEN_MANAGER_PROP_LOCKED:
g_value_set_boolean (value, priv->locked);
g_value_set_boolean (value, self->locked);
break;
case PHOSH_LOCKSCREEN_MANAGER_PROP_TIMEOUT:
g_value_set_uint (value, priv->timeout);
g_value_set_uint (value, self->timeout);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
......@@ -267,14 +259,13 @@ static void
phosh_lockscreen_manager_dispose (GObject *object)
{
PhoshLockscreenManager *self = PHOSH_LOCKSCREEN_MANAGER (object);
PhoshLockscreenManagerPrivate *priv = phosh_lockscreen_manager_get_instance_private (self);
g_clear_pointer (&priv->shields, g_ptr_array_unref);
if (priv->lockscreen) {
g_signal_handlers_disconnect_by_data (priv->lockscreen, self);
g_clear_pointer (&priv->lockscreen, phosh_cp_widget_destroy);
g_clear_pointer (&self->shields, g_ptr_array_unref);
if (self->lockscreen) {
g_signal_handlers_disconnect_by_data (self->lockscreen, self);
g_clear_pointer (&self->lockscreen, phosh_cp_widget_destroy);
}
g_clear_object (&priv->settings);
g_clear_object (&self->settings);
G_OBJECT_CLASS (phosh_lockscreen_manager_parent_class)->dispose (object);
}
......@@ -284,16 +275,15 @@ static void
phosh_lockscreen_manager_constructed (GObject *object)
{
PhoshLockscreenManager *self = PHOSH_LOCKSCREEN_MANAGER (object);
PhoshLockscreenManagerPrivate *priv = phosh_lockscreen_manager_get_instance_private (self);
G_OBJECT_CLASS (phosh_lockscreen_manager_parent_class)->constructed (object);
priv->settings = g_settings_new ("org.gnome.desktop.session");
g_settings_bind (priv->settings, "idle-delay", self, "timeout", G_SETTINGS_BIND_GET);
self->settings = g_settings_new ("org.gnome.desktop.session");
g_settings_bind (self->settings, "idle-delay", self, "timeout", G_SETTINGS_BIND_GET);
priv->presence = phosh_session_presence_get_default_failable ();
if (priv->presence) {
g_signal_connect_swapped (priv->presence,
self->presence = phosh_session_presence_get_default_failable ();
if (self->presence) {
g_signal_connect_swapped (self->presence,
"status-changed",
(GCallback) presence_status_changed_cb,
self);
......@@ -357,40 +347,36 @@ phosh_lockscreen_manager_new (void)
void
phosh_lockscreen_manager_set_locked (PhoshLockscreenManager *self, gboolean state)
{
PhoshLockscreenManagerPrivate *priv = phosh_lockscreen_manager_get_instance_private (self);
g_return_if_fail (PHOSH_IS_LOCKSCREEN_MANAGER (self));
if (state == priv->locked)
if (state == self->locked)
return;
if (state)
lockscreen_lock (self);
else
lockscreen_unlock_cb (self, PHOSH_LOCKSCREEN (priv->lockscreen));
lockscreen_unlock_cb (self, PHOSH_LOCKSCREEN (self->lockscreen));
}
gboolean
phosh_lockscreen_manager_get_locked (PhoshLockscreenManager *self)
{
PhoshLockscreenManagerPrivate *priv = phosh_lockscreen_manager_get_instance_private (self);
g_return_val_if_fail (PHOSH_IS_LOCKSCREEN_MANAGER (self), FALSE);
return priv->locked;
return self->locked;
}
void
phosh_lockscreen_manager_set_timeout (PhoshLockscreenManager *self, int timeout)
{
PhoshLockscreenManagerPrivate *priv = phosh_lockscreen_manager_get_instance_private (self);
g_return_if_fail (PHOSH_IS_LOCKSCREEN_MANAGER (self));
if (timeout == priv->timeout)
if (timeout == self->timeout)
return;
g_debug("Setting lock screen idle timeout to %d seconds", timeout);
priv->timeout = timeout;
self->timeout = timeout;
g_object_notify_by_pspec (G_OBJECT (self), props[PHOSH_LOCKSCREEN_MANAGER_PROP_TIMEOUT]);
}
......@@ -399,18 +385,16 @@ phosh_lockscreen_manager_set_timeout (PhoshLockscreenManager *self, int timeout)
int
phosh_lockscreen_manager_get_timeout (PhoshLockscreenManager *self)
{
PhoshLockscreenManagerPrivate *priv = phosh_lockscreen_manager_get_instance_private (self);
g_return_val_if_fail (PHOSH_IS_LOCKSCREEN_MANAGER (self), 0);
return priv->timeout;
return self->timeout;
}
gint64
phosh_lockscreen_manager_get_active_time (PhoshLockscreenManager *self)
{
PhoshLockscreenManagerPrivate *priv = phosh_lockscreen_manager_get_instance_private (self);
g_return_val_if_fail (PHOSH_IS_LOCKSCREEN_MANAGER (self), 0);
return priv->active_time;
return self->active_time;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment