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

/*
 * SPDX-License-Identifier: GPL-2.0-or-later
 * SPDX-FileCopyrightText: 2016-2023 elementary, Inc. (https://elementary.io)
 */

#include "io.elementary.settings.sharing.h"
#include <gio/gio.h>
#include <glib-object.h>
#include <glib.h>
#include <switchboard.h>
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.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  {
	SHARING_WIDGETS_BLUETOOTH_PAGE_0_PROPERTY,
	SHARING_WIDGETS_BLUETOOTH_PAGE_NUM_PROPERTIES
};
static GParamSpec* sharing_widgets_bluetooth_page_properties[SHARING_WIDGETS_BLUETOOTH_PAGE_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _SharingWidgetsBluetoothPagePrivate {
	GSettings* daemon_settings;
};

static gint SharingWidgetsBluetoothPage_private_offset;
static gpointer sharing_widgets_bluetooth_page_parent_class = NULL;

static void sharing_widgets_bluetooth_page_set_service_state (SharingWidgetsBluetoothPage* self);
static GObject * sharing_widgets_bluetooth_page_constructor (GType type,
                                                      guint n_construct_properties,
                                                      GObjectConstructParam * construct_properties);
static void _sharing_widgets_bluetooth_page___lambda8_ (SharingWidgetsBluetoothPage* self);
static void __sharing_widgets_bluetooth_page___lambda8__g_settings_changed (GSettings* _sender,
                                                                     const gchar* key,
                                                                     gpointer self);
static void _sharing_widgets_bluetooth_page___lambda9_ (SharingWidgetsBluetoothPage* self);
static void __sharing_widgets_bluetooth_page___lambda9__g_object_notify (GObject* _sender,
                                                                  GParamSpec* pspec,
                                                                  gpointer self);
static void _sharing_widgets_bluetooth_page___lambda10_ (SharingWidgetsBluetoothPage* self);
static void __sharing_widgets_bluetooth_page___lambda10__gtk_button_clicked (GtkButton* _sender,
                                                                      gpointer self);
static void sharing_widgets_bluetooth_page_finalize (GObject * obj);
static GType sharing_widgets_bluetooth_page_get_type_once (void);

static inline gpointer
sharing_widgets_bluetooth_page_get_instance_private (SharingWidgetsBluetoothPage* self)
{
	return G_STRUCT_MEMBER_P (self, SharingWidgetsBluetoothPage_private_offset);
}

SharingWidgetsBluetoothPage*
sharing_widgets_bluetooth_page_construct (GType object_type)
{
	SharingWidgetsBluetoothPage * self = NULL;
	self = (SharingWidgetsBluetoothPage*) g_object_new (object_type, "activatable", TRUE, NULL);
	return self;
}

SharingWidgetsBluetoothPage*
sharing_widgets_bluetooth_page_new (void)
{
	return sharing_widgets_bluetooth_page_construct (SHARING_WIDGETS_TYPE_BLUETOOTH_PAGE);
}

static void
sharing_widgets_bluetooth_page_set_service_state (SharingWidgetsBluetoothPage* self)
{
	GSettings* _tmp0_;
	GSettings* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->daemon_settings;
	if (!g_settings_get_boolean (_tmp0_, "enabled")) {
		switchboard_settings_page_set_description ((SwitchboardSettingsPage*) self, _ ("The Bluetooth device is either disconnected or disabled. Check Bluetoo" \
"th settings and try again."));
		switchboard_settings_page_set_status_type ((SwitchboardSettingsPage*) self, SWITCHBOARD_SETTINGS_PAGE_STATUS_TYPE_ERROR);
		switchboard_settings_page_set_status ((SwitchboardSettingsPage*) self, _ ("Not Available"));
		return;
	}
	_tmp1_ = self->priv->daemon_settings;
	if (g_settings_get_boolean (_tmp1_, "sharing")) {
		switchboard_settings_page_set_description ((SwitchboardSettingsPage*) self, _ ("While enabled, Bluetooth devices can send files to Downloads."));
		switchboard_settings_page_set_status ((SwitchboardSettingsPage*) self, _ ("Enabled"));
		switchboard_settings_page_set_status_type ((SwitchboardSettingsPage*) self, SWITCHBOARD_SETTINGS_PAGE_STATUS_TYPE_SUCCESS);
	} else {
		switchboard_settings_page_set_description ((SwitchboardSettingsPage*) self, _ ("While disabled, Bluetooth devices can not send files to Downloads."));
		switchboard_settings_page_set_status ((SwitchboardSettingsPage*) self, _ ("Disabled"));
		switchboard_settings_page_set_status_type ((SwitchboardSettingsPage*) self, SWITCHBOARD_SETTINGS_PAGE_STATUS_TYPE_OFFLINE);
	}
}

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

static void
_sharing_widgets_bluetooth_page___lambda8_ (SharingWidgetsBluetoothPage* self)
{
	sharing_widgets_bluetooth_page_set_service_state (self);
}

static void
__sharing_widgets_bluetooth_page___lambda8__g_settings_changed (GSettings* _sender,
                                                                const gchar* key,
                                                                gpointer self)
{
	_sharing_widgets_bluetooth_page___lambda8_ ((SharingWidgetsBluetoothPage*) self);
}

static void
_sharing_widgets_bluetooth_page___lambda9_ (SharingWidgetsBluetoothPage* self)
{
	sharing_widgets_bluetooth_page_set_service_state (self);
}

static void
__sharing_widgets_bluetooth_page___lambda9__g_object_notify (GObject* _sender,
                                                             GParamSpec* pspec,
                                                             gpointer self)
{
	_sharing_widgets_bluetooth_page___lambda9_ ((SharingWidgetsBluetoothPage*) self);
}

static void
_sharing_widgets_bluetooth_page___lambda10_ (SharingWidgetsBluetoothPage* self)
{
	GtkUriLauncher* uri_launcher = NULL;
	GtkUriLauncher* _tmp0_;
	GtkUriLauncher* _tmp1_;
	GApplication* _tmp2_;
	GtkWindow* _tmp3_;
	GtkWindow* _tmp4_;
	_tmp0_ = gtk_uri_launcher_new ("settings://network/bluetooth");
	uri_launcher = _tmp0_;
	_tmp1_ = uri_launcher;
	_tmp2_ = g_application_get_default ();
	_tmp3_ = gtk_application_get_active_window (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, gtk_application_get_type (), GtkApplication));
	_tmp4_ = _tmp3_;
	gtk_uri_launcher_launch (_tmp1_, _tmp4_, NULL, NULL, NULL);
	_g_object_unref0 (uri_launcher);
}

static void
__sharing_widgets_bluetooth_page___lambda10__gtk_button_clicked (GtkButton* _sender,
                                                                 gpointer self)
{
	_sharing_widgets_bluetooth_page___lambda10_ ((SharingWidgetsBluetoothPage*) self);
}

static GObject *
sharing_widgets_bluetooth_page_constructor (GType type,
                                            guint n_construct_properties,
                                            GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	SharingWidgetsBluetoothPage * self;
	GThemedIcon* _tmp0_;
	GThemedIcon* _tmp1_;
	GtkSwitch* accept_switch = NULL;
	GtkSwitch* _tmp2_ = NULL;
	GtkLabel* accept_label = NULL;
	GtkSwitch* _tmp3_;
	GtkWidget* _tmp4_;
	GtkLabel* _tmp5_ = NULL;
	GtkBox* box = NULL;
	GtkBox* _tmp6_;
	GtkBox* _tmp7_;
	GtkLabel* _tmp8_;
	GtkBox* _tmp9_;
	GtkSwitch* _tmp10_;
	GtkBox* _tmp11_;
	GtkButton* settings_button = NULL;
	GtkButton* _tmp12_;
	GSettings* _tmp13_;
	GSettings* _tmp14_;
	GtkSwitch* _tmp15_;
	GtkSwitch* _tmp16_;
	GSettings* _tmp17_;
	GtkSwitch* _tmp18_;
	GSettings* _tmp19_;
	GtkSwitch* _tmp20_;
	GtkSwitch* _tmp21_;
	GtkButton* _tmp22_;
	parent_class = G_OBJECT_CLASS (sharing_widgets_bluetooth_page_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SHARING_WIDGETS_TYPE_BLUETOOTH_PAGE, SharingWidgetsBluetoothPage);
	switchboard_settings_page_set_title ((SwitchboardSettingsPage*) self, _ ("Bluetooth"));
	_tmp0_ = (GThemedIcon*) g_themed_icon_new ("preferences-bluetooth");
	_tmp1_ = _tmp0_;
	switchboard_settings_page_set_icon ((SwitchboardSettingsPage*) self, (GIcon*) _tmp1_);
	_g_object_unref0 (_tmp1_);
	switchboard_settings_page_set_show_end_title_buttons ((SwitchboardSettingsPage*) self, TRUE);
	_tmp2_ = (GtkSwitch*) gtk_switch_new ();
	gtk_widget_set_valign ((GtkWidget*) _tmp2_, GTK_ALIGN_CENTER);
	g_object_ref_sink (_tmp2_);
	accept_switch = _tmp2_;
	_tmp3_ = accept_switch;
	_tmp4_ = _g_object_ref0 ((GtkWidget*) _tmp3_);
	_tmp5_ = (GtkLabel*) gtk_label_new (_ ("Ask before accepting files:"));
	gtk_widget_set_halign ((GtkWidget*) _tmp5_, GTK_ALIGN_END);
	gtk_label_set_mnemonic_widget (_tmp5_, _tmp4_);
	_g_object_unref0 (_tmp4_);
	g_object_ref_sink (_tmp5_);
	accept_label = _tmp5_;
	_tmp6_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
	g_object_ref_sink (_tmp6_);
	box = _tmp6_;
	_tmp7_ = box;
	_tmp8_ = accept_label;
	gtk_box_append (_tmp7_, (GtkWidget*) _tmp8_);
	_tmp9_ = box;
	_tmp10_ = accept_switch;
	gtk_box_append (_tmp9_, (GtkWidget*) _tmp10_);
	_tmp11_ = box;
	switchboard_settings_page_set_child ((SwitchboardSettingsPage*) self, (GtkWidget*) _tmp11_);
	_tmp12_ = switchboard_settings_page_add_button ((SwitchboardSettingsPage*) self, _ ("Bluetooth Settings…"));
	settings_button = _tmp12_;
	_tmp13_ = g_settings_new ("io.elementary.desktop.bluetooth");
	_g_object_unref0 (self->priv->daemon_settings);
	self->priv->daemon_settings = _tmp13_;
	_tmp14_ = self->priv->daemon_settings;
	_tmp15_ = switchboard_settings_page_get_status_switch ((SwitchboardSettingsPage*) self);
	_tmp16_ = _tmp15_;
	g_settings_bind (_tmp14_, "sharing", (GObject*) _tmp16_, "active", G_SETTINGS_BIND_NO_SENSITIVITY);
	_tmp17_ = self->priv->daemon_settings;
	_tmp18_ = accept_switch;
	g_settings_bind (_tmp17_, "confirm-accept-files", (GObject*) _tmp18_, "active", G_SETTINGS_BIND_DEFAULT);
	sharing_widgets_bluetooth_page_set_service_state (self);
	_tmp19_ = self->priv->daemon_settings;
	g_signal_connect_object (_tmp19_, "changed::enabled", (GCallback) __sharing_widgets_bluetooth_page___lambda8__g_settings_changed, self, 0);
	_tmp20_ = switchboard_settings_page_get_status_switch ((SwitchboardSettingsPage*) self);
	_tmp21_ = _tmp20_;
	g_signal_connect_object ((GObject*) _tmp21_, "notify::active", (GCallback) __sharing_widgets_bluetooth_page___lambda9__g_object_notify, self, 0);
	_tmp22_ = settings_button;
	g_signal_connect_object (_tmp22_, "clicked", (GCallback) __sharing_widgets_bluetooth_page___lambda10__gtk_button_clicked, self, 0);
	_g_object_unref0 (settings_button);
	_g_object_unref0 (box);
	_g_object_unref0 (accept_label);
	_g_object_unref0 (accept_switch);
	return obj;
}

static void
sharing_widgets_bluetooth_page_class_init (SharingWidgetsBluetoothPageClass * klass,
                                           gpointer klass_data)
{
	sharing_widgets_bluetooth_page_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &SharingWidgetsBluetoothPage_private_offset);
	G_OBJECT_CLASS (klass)->constructor = sharing_widgets_bluetooth_page_constructor;
	G_OBJECT_CLASS (klass)->finalize = sharing_widgets_bluetooth_page_finalize;
}

static void
sharing_widgets_bluetooth_page_instance_init (SharingWidgetsBluetoothPage * self,
                                              gpointer klass)
{
	self->priv = sharing_widgets_bluetooth_page_get_instance_private (self);
}

static void
sharing_widgets_bluetooth_page_finalize (GObject * obj)
{
	SharingWidgetsBluetoothPage * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SHARING_WIDGETS_TYPE_BLUETOOTH_PAGE, SharingWidgetsBluetoothPage);
	_g_object_unref0 (self->priv->daemon_settings);
	G_OBJECT_CLASS (sharing_widgets_bluetooth_page_parent_class)->finalize (obj);
}

static GType
sharing_widgets_bluetooth_page_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (SharingWidgetsBluetoothPageClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) sharing_widgets_bluetooth_page_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SharingWidgetsBluetoothPage), 0, (GInstanceInitFunc) sharing_widgets_bluetooth_page_instance_init, NULL };
	GType sharing_widgets_bluetooth_page_type_id;
	sharing_widgets_bluetooth_page_type_id = g_type_register_static (SWITCHBOARD_TYPE_SETTINGS_PAGE, "SharingWidgetsBluetoothPage", &g_define_type_info, 0);
	SharingWidgetsBluetoothPage_private_offset = g_type_add_instance_private (sharing_widgets_bluetooth_page_type_id, sizeof (SharingWidgetsBluetoothPagePrivate));
	return sharing_widgets_bluetooth_page_type_id;
}

GType
sharing_widgets_bluetooth_page_get_type (void)
{
	static volatile gsize sharing_widgets_bluetooth_page_type_id__once = 0;
	if (g_once_init_enter (&sharing_widgets_bluetooth_page_type_id__once)) {
		GType sharing_widgets_bluetooth_page_type_id;
		sharing_widgets_bluetooth_page_type_id = sharing_widgets_bluetooth_page_get_type_once ();
		g_once_init_leave (&sharing_widgets_bluetooth_page_type_id__once, sharing_widgets_bluetooth_page_type_id);
	}
	return sharing_widgets_bluetooth_page_type_id__once;
}

