/* Indicator.c generated by valac 0.56.17, the Vala compiler
 * generated from Indicator.vala, do not modify */

/*
 * Copyright (c) 2011-2019 elementary, Inc. (https://elementary.io)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This program 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
 * General Public License for more details.
 *
 * You should have received a copy of the GNU 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.
 */

#include "a11y.h"
#include <gtk/gtk.h>
#include <wingpanel.h>
#include <glib-object.h>
#include <glib/gi18n-lib.h>
#include <glib.h>
#include <gio/gio.h>
#include <gmodule.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  {
	A11_Y_INDICATOR_0_PROPERTY,
	A11_Y_INDICATOR_SERVER_TYPE_PROPERTY,
	A11_Y_INDICATOR_NUM_PROPERTIES
};
static GParamSpec* a11_y_indicator_properties[A11_Y_INDICATOR_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _A11YIndicatorPrivate {
	GtkImage* panel_icon;
	GtkGrid* main_grid;
	WingpanelIndicatorManagerServerType _server_type;
};

static gint A11YIndicator_private_offset;
static gpointer a11_y_indicator_parent_class = NULL;

static GtkWidget* a11_y_indicator_real_get_display_widget (WingpanelIndicator* base);
static GtkWidget* a11_y_indicator_real_get_widget (WingpanelIndicator* base);
static void a11_y_indicator_real_opened (WingpanelIndicator* base);
static void a11_y_indicator_real_closed (WingpanelIndicator* base);
static void a11_y_indicator_finalize (GObject * obj);
static GType a11_y_indicator_get_type_once (void);
static void _vala_a11_y_indicator_get_property (GObject * object,
                                         guint property_id,
                                         GValue * value,
                                         GParamSpec * pspec);
static void _vala_a11_y_indicator_set_property (GObject * object,
                                         guint property_id,
                                         const GValue * value,
                                         GParamSpec * pspec);

static inline gpointer
a11_y_indicator_get_instance_private (A11YIndicator* self)
{
	return G_STRUCT_MEMBER_P (self, A11YIndicator_private_offset);
}

A11YIndicator*
a11_y_indicator_construct (GType object_type,
                           WingpanelIndicatorManagerServerType indicator_server_type)
{
	A11YIndicator * self = NULL;
	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	self = (A11YIndicator*) g_object_new (object_type, "code-name", WINGPANEL_INDICATOR_ACCESSIBILITY, "server-type", indicator_server_type, NULL);
	return self;
}

A11YIndicator*
a11_y_indicator_new (WingpanelIndicatorManagerServerType indicator_server_type)
{
	return a11_y_indicator_construct (A11_Y_TYPE_INDICATOR, indicator_server_type);
}

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

static GtkWidget*
a11_y_indicator_real_get_display_widget (WingpanelIndicator* base)
{
	A11YIndicator * self;
	GtkImage* _tmp0_;
	GtkImage* _tmp5_;
	GtkWidget* _tmp6_;
	GtkWidget* result;
	self = (A11YIndicator*) base;
	_tmp0_ = self->priv->panel_icon;
	if (_tmp0_ == NULL) {
		GtkImage* _tmp1_;
		WingpanelIndicatorManagerServerType _tmp2_;
		_tmp1_ = (GtkImage*) gtk_image_new_from_icon_name ("preferences-desktop-accessibility-symbolic", (GtkIconSize) GTK_ICON_SIZE_LARGE_TOOLBAR);
		g_object_ref_sink (_tmp1_);
		_g_object_unref0 (self->priv->panel_icon);
		self->priv->panel_icon = _tmp1_;
		_tmp2_ = self->priv->_server_type;
		if (_tmp2_ == WINGPANEL_INDICATOR_MANAGER_SERVER_TYPE_GREETER) {
			wingpanel_indicator_set_visible ((WingpanelIndicator*) self, TRUE);
		} else {
			GSettings* visible_settings = NULL;
			GSettings* _tmp3_;
			GSettings* _tmp4_;
			_tmp3_ = g_settings_new ("io.elementary.desktop.wingpanel.a11y");
			visible_settings = _tmp3_;
			_tmp4_ = visible_settings;
			g_settings_bind (_tmp4_, "show-indicator", (GObject*) self, "visible", G_SETTINGS_BIND_DEFAULT);
			_g_object_unref0 (visible_settings);
		}
	}
	_tmp5_ = self->priv->panel_icon;
	_tmp6_ = _g_object_ref0 ((GtkWidget*) _tmp5_);
	result = _tmp6_;
	return result;
}

static GtkWidget*
a11_y_indicator_real_get_widget (WingpanelIndicator* base)
{
	A11YIndicator * self;
	GtkGrid* _tmp0_;
	GtkGrid* _tmp4_;
	GtkWidget* _tmp5_;
	GtkWidget* result;
	self = (A11YIndicator*) base;
	_tmp0_ = self->priv->main_grid;
	if (_tmp0_ == NULL) {
		WingpanelIndicatorManagerServerType _tmp1_;
		_tmp1_ = self->priv->_server_type;
		if (_tmp1_ == WINGPANEL_INDICATOR_MANAGER_SERVER_TYPE_GREETER) {
			A11YGreeterWidget* _tmp2_;
			_tmp2_ = a11_y_greeter_widget_new ();
			g_object_ref_sink (_tmp2_);
			_g_object_unref0 (self->priv->main_grid);
			self->priv->main_grid = (GtkGrid*) _tmp2_;
		} else {
			A11YSessionWidget* _tmp3_;
			_tmp3_ = a11_y_session_widget_new ();
			g_object_ref_sink (_tmp3_);
			_g_object_unref0 (self->priv->main_grid);
			self->priv->main_grid = (GtkGrid*) _tmp3_;
		}
	}
	_tmp4_ = self->priv->main_grid;
	_tmp5_ = _g_object_ref0 ((GtkWidget*) _tmp4_);
	result = _tmp5_;
	return result;
}

static void
a11_y_indicator_real_opened (WingpanelIndicator* base)
{
	A11YIndicator * self;
	self = (A11YIndicator*) base;
}

static void
a11_y_indicator_real_closed (WingpanelIndicator* base)
{
	A11YIndicator * self;
	self = (A11YIndicator*) base;
}

WingpanelIndicatorManagerServerType
a11_y_indicator_get_server_type (A11YIndicator* self)
{
	WingpanelIndicatorManagerServerType result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_server_type;
	return result;
}

void
a11_y_indicator_set_server_type (A11YIndicator* self,
                                 WingpanelIndicatorManagerServerType value)
{
	WingpanelIndicatorManagerServerType old_value;
	g_return_if_fail (self != NULL);
	old_value = a11_y_indicator_get_server_type (self);
	if (old_value != value) {
		self->priv->_server_type = value;
		g_object_notify_by_pspec ((GObject *) self, a11_y_indicator_properties[A11_Y_INDICATOR_SERVER_TYPE_PROPERTY]);
	}
}

static void
a11_y_indicator_class_init (A11YIndicatorClass * klass,
                            gpointer klass_data)
{
	a11_y_indicator_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &A11YIndicator_private_offset);
	((WingpanelIndicatorClass *) klass)->get_display_widget = (GtkWidget* (*) (WingpanelIndicator*)) a11_y_indicator_real_get_display_widget;
	((WingpanelIndicatorClass *) klass)->get_widget = (GtkWidget* (*) (WingpanelIndicator*)) a11_y_indicator_real_get_widget;
	((WingpanelIndicatorClass *) klass)->opened = (void (*) (WingpanelIndicator*)) a11_y_indicator_real_opened;
	((WingpanelIndicatorClass *) klass)->closed = (void (*) (WingpanelIndicator*)) a11_y_indicator_real_closed;
	G_OBJECT_CLASS (klass)->get_property = _vala_a11_y_indicator_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_a11_y_indicator_set_property;
	G_OBJECT_CLASS (klass)->finalize = a11_y_indicator_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), A11_Y_INDICATOR_SERVER_TYPE_PROPERTY, a11_y_indicator_properties[A11_Y_INDICATOR_SERVER_TYPE_PROPERTY] = g_param_spec_enum ("server-type", "server-type", "server-type", WINGPANEL_INDICATOR_MANAGER_TYPE_SERVER_TYPE, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
}

static void
a11_y_indicator_instance_init (A11YIndicator * self,
                               gpointer klass)
{
	self->priv = a11_y_indicator_get_instance_private (self);
}

static void
a11_y_indicator_finalize (GObject * obj)
{
	A11YIndicator * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, A11_Y_TYPE_INDICATOR, A11YIndicator);
	_g_object_unref0 (self->priv->panel_icon);
	_g_object_unref0 (self->priv->main_grid);
	G_OBJECT_CLASS (a11_y_indicator_parent_class)->finalize (obj);
}

static GType
a11_y_indicator_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (A11YIndicatorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) a11_y_indicator_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (A11YIndicator), 0, (GInstanceInitFunc) a11_y_indicator_instance_init, NULL };
	GType a11_y_indicator_type_id;
	a11_y_indicator_type_id = g_type_register_static (WINGPANEL_TYPE_INDICATOR, "A11YIndicator", &g_define_type_info, 0);
	A11YIndicator_private_offset = g_type_add_instance_private (a11_y_indicator_type_id, sizeof (A11YIndicatorPrivate));
	return a11_y_indicator_type_id;
}

GType
a11_y_indicator_get_type (void)
{
	static volatile gsize a11_y_indicator_type_id__once = 0;
	if (g_once_init_enter (&a11_y_indicator_type_id__once)) {
		GType a11_y_indicator_type_id;
		a11_y_indicator_type_id = a11_y_indicator_get_type_once ();
		g_once_init_leave (&a11_y_indicator_type_id__once, a11_y_indicator_type_id);
	}
	return a11_y_indicator_type_id__once;
}

static void
_vala_a11_y_indicator_get_property (GObject * object,
                                    guint property_id,
                                    GValue * value,
                                    GParamSpec * pspec)
{
	A11YIndicator * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, A11_Y_TYPE_INDICATOR, A11YIndicator);
	switch (property_id) {
		case A11_Y_INDICATOR_SERVER_TYPE_PROPERTY:
		g_value_set_enum (value, a11_y_indicator_get_server_type (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_a11_y_indicator_set_property (GObject * object,
                                    guint property_id,
                                    const GValue * value,
                                    GParamSpec * pspec)
{
	A11YIndicator * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, A11_Y_TYPE_INDICATOR, A11YIndicator);
	switch (property_id) {
		case A11_Y_INDICATOR_SERVER_TYPE_PROPERTY:
		a11_y_indicator_set_server_type (self, g_value_get_enum (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

WingpanelIndicator*
get_indicator (GModule* module,
               WingpanelIndicatorManagerServerType server_type)
{
	A11YIndicator* _tmp0_;
	WingpanelIndicator* result;
	g_return_val_if_fail (module != NULL, NULL);
	g_debug ("Indicator.vala:69: Activating Accessibility Indicator");
	_tmp0_ = a11_y_indicator_new (server_type);
	result = (WingpanelIndicator*) _tmp0_;
	return result;
}

