/* LockPanel.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from LockPanel.vala, do not modify */

/*-
 * Copyright 2014-2020 elementary, Inc. (https://elementary.io)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this program; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301 USA
 *
 * Authored by: Corentin Noël <corentin@elementary.io>
 */

#include "security-privacy.h"
#include <glib-object.h>
#include <gio/gio.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
#include <switchboard.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

enum  {
	SECURITY_PRIVACY_LOCK_PANEL_0_PROPERTY,
	SECURITY_PRIVACY_LOCK_PANEL_NUM_PROPERTIES
};
static GParamSpec* security_privacy_lock_panel_properties[SECURITY_PRIVACY_LOCK_PANEL_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_settings_schema_unref0(var) ((var == NULL) ? NULL : (var = (g_settings_schema_unref (var), NULL)))

static gpointer security_privacy_lock_panel_parent_class = NULL;

static GObject * security_privacy_lock_panel_constructor (GType type,
                                                   guint n_construct_properties,
                                                   GObjectConstructParam * construct_properties);
static GType security_privacy_lock_panel_get_type_once (void);

SecurityPrivacyLockPanel*
security_privacy_lock_panel_construct (GType object_type)
{
	SecurityPrivacyLockPanel * self = NULL;
	GThemedIcon* _tmp0_;
	GThemedIcon* _tmp1_;
	_tmp0_ = (GThemedIcon*) g_themed_icon_new ("system-lock-screen");
	_tmp1_ = _tmp0_;
	self = (SecurityPrivacyLockPanel*) g_object_new (object_type, "icon", _tmp1_, "title", _ ("Locking"), NULL);
	_g_object_unref0 (_tmp1_);
	return self;
}

SecurityPrivacyLockPanel*
security_privacy_lock_panel_new (void)
{
	return security_privacy_lock_panel_construct (SECURITY_PRIVACY_TYPE_LOCK_PANEL);
}

static GObject *
security_privacy_lock_panel_constructor (GType type,
                                         guint n_construct_properties,
                                         GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	SecurityPrivacyLockPanel * self;
	GtkLabel* lock_suspend_label = NULL;
	GtkLabel* _tmp0_;
	GtkLabel* _tmp1_;
	GtkSwitch* lock_suspend_switch = NULL;
	GtkSwitch* _tmp2_;
	GtkSwitch* _tmp3_;
	GtkLabel* lock_sleep_label = NULL;
	GtkLabel* _tmp4_;
	GtkLabel* _tmp5_;
	GtkSwitch* lock_sleep_switch = NULL;
	GtkSwitch* _tmp6_;
	GtkSwitch* _tmp7_;
	GtkGrid* grid = NULL;
	GtkGrid* _tmp8_ = NULL;
	GtkGrid* _tmp9_;
	GtkLabel* _tmp10_;
	GtkGrid* _tmp11_;
	GtkSwitch* _tmp12_;
	GtkGrid* _tmp13_;
	GtkLabel* _tmp14_;
	GtkGrid* _tmp15_;
	GtkSwitch* _tmp16_;
	GtkGrid* _tmp17_;
	GSettings* gnome_screensaver_settings = NULL;
	GSettings* _tmp18_;
	GSettings* screensaver_settings = NULL;
	GSettings* _tmp19_;
	GSettingsSchema* schema = NULL;
	GSettingsSchemaSource* _tmp20_;
	GSettingsSchema* _tmp21_;
	GSettingsSchema* _tmp22_;
	GSettings* _tmp34_;
	GtkSwitch* _tmp35_;
	GSettings* _tmp36_;
	GtkSwitch* _tmp37_;
	parent_class = G_OBJECT_CLASS (security_privacy_lock_panel_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SECURITY_PRIVACY_TYPE_LOCK_PANEL, SecurityPrivacyLockPanel);
	_tmp0_ = (GtkLabel*) gtk_label_new (_ ("Lock on suspend:"));
	g_object_ref_sink (_tmp0_);
	lock_suspend_label = _tmp0_;
	_tmp1_ = lock_suspend_label;
	gtk_widget_set_halign ((GtkWidget*) _tmp1_, GTK_ALIGN_END);
	_tmp2_ = (GtkSwitch*) gtk_switch_new ();
	g_object_ref_sink (_tmp2_);
	lock_suspend_switch = _tmp2_;
	_tmp3_ = lock_suspend_switch;
	gtk_widget_set_halign ((GtkWidget*) _tmp3_, GTK_ALIGN_START);
	_tmp4_ = (GtkLabel*) gtk_label_new (_ ("Lock after screen turns off:"));
	g_object_ref_sink (_tmp4_);
	lock_sleep_label = _tmp4_;
	_tmp5_ = lock_sleep_label;
	gtk_widget_set_halign ((GtkWidget*) _tmp5_, GTK_ALIGN_END);
	_tmp6_ = (GtkSwitch*) gtk_switch_new ();
	g_object_ref_sink (_tmp6_);
	lock_sleep_switch = _tmp6_;
	_tmp7_ = lock_sleep_switch;
	gtk_widget_set_halign ((GtkWidget*) _tmp7_, GTK_ALIGN_START);
	_tmp8_ = (GtkGrid*) gtk_grid_new ();
	gtk_grid_set_column_spacing (_tmp8_, 6);
	gtk_grid_set_row_spacing (_tmp8_, 6);
	g_object_ref_sink (_tmp8_);
	grid = _tmp8_;
	_tmp9_ = grid;
	_tmp10_ = lock_suspend_label;
	gtk_grid_attach (_tmp9_, (GtkWidget*) _tmp10_, 0, 0, 1, 1);
	_tmp11_ = grid;
	_tmp12_ = lock_suspend_switch;
	gtk_grid_attach (_tmp11_, (GtkWidget*) _tmp12_, 1, 0, 1, 1);
	_tmp13_ = grid;
	_tmp14_ = lock_sleep_label;
	gtk_grid_attach (_tmp13_, (GtkWidget*) _tmp14_, 0, 1, 1, 1);
	_tmp15_ = grid;
	_tmp16_ = lock_sleep_switch;
	gtk_grid_attach (_tmp15_, (GtkWidget*) _tmp16_, 1, 1, 1, 1);
	_tmp17_ = grid;
	switchboard_settings_page_set_child ((SwitchboardSettingsPage*) self, (GtkWidget*) _tmp17_);
	switchboard_settings_page_set_show_end_title_buttons ((SwitchboardSettingsPage*) self, TRUE);
	_tmp18_ = g_settings_new ("org.gnome.desktop.screensaver");
	gnome_screensaver_settings = _tmp18_;
	_tmp19_ = g_settings_new ("io.elementary.desktop.screensaver");
	screensaver_settings = _tmp19_;
	_tmp20_ = g_settings_schema_source_get_default ();
	_tmp21_ = g_settings_schema_source_lookup (_tmp20_, "org.gnome.desktop.privacy", TRUE);
	schema = _tmp21_;
	_tmp22_ = schema;
	if (g_settings_schema_has_key (_tmp22_, "usb-protection")) {
		GtkLabel* usb_lock_label = NULL;
		GtkLabel* _tmp23_;
		GtkLabel* _tmp24_;
		GtkSwitch* usb_lock_switch = NULL;
		GtkSwitch* _tmp25_;
		GtkSwitch* _tmp26_;
		GtkGrid* _tmp27_;
		GtkLabel* _tmp28_;
		GtkGrid* _tmp29_;
		GtkSwitch* _tmp30_;
		GSettings* gnome_privacy_settings = NULL;
		GSettings* _tmp31_;
		GSettings* _tmp32_;
		GtkSwitch* _tmp33_;
		_tmp23_ = (GtkLabel*) gtk_label_new (_ ("Forbid new USB devices when locked:"));
		g_object_ref_sink (_tmp23_);
		usb_lock_label = _tmp23_;
		_tmp24_ = usb_lock_label;
		gtk_widget_set_halign ((GtkWidget*) _tmp24_, GTK_ALIGN_END);
		_tmp25_ = (GtkSwitch*) gtk_switch_new ();
		g_object_ref_sink (_tmp25_);
		usb_lock_switch = _tmp25_;
		_tmp26_ = usb_lock_switch;
		gtk_widget_set_halign ((GtkWidget*) _tmp26_, GTK_ALIGN_START);
		_tmp27_ = grid;
		_tmp28_ = usb_lock_label;
		gtk_grid_attach (_tmp27_, (GtkWidget*) _tmp28_, 0, 2, 1, 1);
		_tmp29_ = grid;
		_tmp30_ = usb_lock_switch;
		gtk_grid_attach (_tmp29_, (GtkWidget*) _tmp30_, 1, 2, 1, 1);
		_tmp31_ = g_settings_new ("org.gnome.desktop.privacy");
		gnome_privacy_settings = _tmp31_;
		_tmp32_ = gnome_privacy_settings;
		_tmp33_ = usb_lock_switch;
		g_settings_bind (_tmp32_, "usb-protection", (GObject*) _tmp33_, "active", G_SETTINGS_BIND_DEFAULT);
		_g_object_unref0 (gnome_privacy_settings);
		_g_object_unref0 (usb_lock_switch);
		_g_object_unref0 (usb_lock_label);
	}
	_tmp34_ = gnome_screensaver_settings;
	_tmp35_ = lock_sleep_switch;
	g_settings_bind (_tmp34_, "lock-enabled", (GObject*) _tmp35_, "active", G_SETTINGS_BIND_DEFAULT);
	_tmp36_ = screensaver_settings;
	_tmp37_ = lock_suspend_switch;
	g_settings_bind (_tmp36_, "lock-on-suspend", (GObject*) _tmp37_, "active", G_SETTINGS_BIND_DEFAULT);
	_g_settings_schema_unref0 (schema);
	_g_object_unref0 (screensaver_settings);
	_g_object_unref0 (gnome_screensaver_settings);
	_g_object_unref0 (grid);
	_g_object_unref0 (lock_sleep_switch);
	_g_object_unref0 (lock_sleep_label);
	_g_object_unref0 (lock_suspend_switch);
	_g_object_unref0 (lock_suspend_label);
	return obj;
}

static void
security_privacy_lock_panel_class_init (SecurityPrivacyLockPanelClass * klass,
                                        gpointer klass_data)
{
	security_privacy_lock_panel_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->constructor = security_privacy_lock_panel_constructor;
}

static void
security_privacy_lock_panel_instance_init (SecurityPrivacyLockPanel * self,
                                           gpointer klass)
{
}

static GType
security_privacy_lock_panel_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (SecurityPrivacyLockPanelClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) security_privacy_lock_panel_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SecurityPrivacyLockPanel), 0, (GInstanceInitFunc) security_privacy_lock_panel_instance_init, NULL };
	GType security_privacy_lock_panel_type_id;
	security_privacy_lock_panel_type_id = g_type_register_static (SWITCHBOARD_TYPE_SETTINGS_PAGE, "SecurityPrivacyLockPanel", &g_define_type_info, 0);
	return security_privacy_lock_panel_type_id;
}

GType
security_privacy_lock_panel_get_type (void)
{
	static volatile gsize security_privacy_lock_panel_type_id__once = 0;
	if (g_once_init_enter (&security_privacy_lock_panel_type_id__once)) {
		GType security_privacy_lock_panel_type_id;
		security_privacy_lock_panel_type_id = security_privacy_lock_panel_get_type_once ();
		g_once_init_leave (&security_privacy_lock_panel_type_id__once, security_privacy_lock_panel_type_id);
	}
	return security_privacy_lock_panel_type_id__once;
}

