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

/*
* SPDX-License-Identifier: LGPL-2.1-or-later
* SPDX-FileCopyrightText: 2015-2025 elementary, Inc. (https://elementary.io)
*/

#include "keyboard.h"
#include <wingpanel-9.h>
#include <gdk/gdk.h>
#include <gio/gio.h>
#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib/gi18n-lib.h>
#include <glib.h>
#include <granite-7.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.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  {
	KEYBOARD_INDICATOR_0_PROPERTY,
	KEYBOARD_INDICATOR_SERVER_TYPE_PROPERTY,
	KEYBOARD_INDICATOR_NUM_PROPERTIES
};
static GParamSpec* keyboard_indicator_properties[KEYBOARD_INDICATOR_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block1Data Block1Data;
#define _g_free0(var) (var = (g_free (var), NULL))

struct _KeyboardIndicatorPrivate {
	WingpanelIndicatorManagerServerType _server_type;
	GdkDevice* device;
	GSettings* settings;
	GtkBox* indicator_box;
	GtkRevealer* numlock_revealer;
	GtkRevealer* capslock_revealer;
	KeyboardWidgetsPopoverWidget* popover_widget;
	GtkLabel* layouts_icon;
	GtkRevealer* layouts_revealer;
};

struct _Block1Data {
	int _ref_count_;
	KeyboardIndicator* self;
	GtkGestureClick* gesture_click;
};

static gint KeyboardIndicator_private_offset;
static gpointer keyboard_indicator_parent_class = NULL;

static GtkWidget* keyboard_indicator_real_get_display_widget (WingpanelIndicator* base);
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (void * _userdata_);
static void ___lambda9_ (KeyboardIndicator* self);
static void keyboard_indicator_update_visibility (KeyboardIndicator* self);
static void ____lambda9__g_settings_changed (GSettings* _sender,
                                      const gchar* key,
                                      gpointer self);
static void ___lambda10_ (KeyboardIndicator* self);
static void ____lambda10__gdk_device_changed (GdkDevice* _sender,
                                       gpointer self);
static void ___lambda11_ (Block1Data* _data1_);
static void ____lambda11__gtk_gesture_click_pressed (GtkGestureClick* _sender,
                                              gint n_press,
                                              gdouble x,
                                              gdouble y,
                                              gpointer self);
static void ___lambda12_ (KeyboardIndicator* self);
static void ____lambda12__keyboard_widgets_popover_widget_updated (KeyboardWidgetsPopoverWidget* _sender,
                                                            gpointer self);
static void keyboard_indicator_update_tooltip (KeyboardIndicator* self);
static GtkWidget* keyboard_indicator_real_get_widget (WingpanelIndicator* base);
static void keyboard_indicator_real_opened (WingpanelIndicator* base);
static void keyboard_indicator_real_closed (WingpanelIndicator* base);
static void keyboard_indicator_finalize (GObject * obj);
static GType keyboard_indicator_get_type_once (void);
static void _vala_keyboard_indicator_get_property (GObject * object,
                                            guint property_id,
                                            GValue * value,
                                            GParamSpec * pspec);
static void _vala_keyboard_indicator_set_property (GObject * object,
                                            guint property_id,
                                            const GValue * value,
                                            GParamSpec * pspec);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

static inline gpointer
keyboard_indicator_get_instance_private (KeyboardIndicator* self)
{
	return G_STRUCT_MEMBER_P (self, KeyboardIndicator_private_offset);
}

KeyboardIndicator*
keyboard_indicator_construct (GType object_type,
                              WingpanelIndicatorManagerServerType server_type)
{
	KeyboardIndicator * self = NULL;
	bindtextdomain (CONSTANTS_GETTEXT_PACKAGE, CONSTANTS_LOCALEDIR);
	bind_textdomain_codeset (CONSTANTS_GETTEXT_PACKAGE, "UTF-8");
	self = (KeyboardIndicator*) g_object_new (object_type, "code-name", WINGPANEL_INDICATOR_KEYBOARD, "server-type", server_type, NULL);
	return self;
}

KeyboardIndicator*
keyboard_indicator_new (WingpanelIndicatorManagerServerType server_type)
{
	return keyboard_indicator_construct (KEYBOARD_TYPE_INDICATOR, server_type);
}

static Block1Data*
block1_data_ref (Block1Data* _data1_)
{
	g_atomic_int_inc (&_data1_->_ref_count_);
	return _data1_;
}

static void
block1_data_unref (void * _userdata_)
{
	Block1Data* _data1_;
	_data1_ = (Block1Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
		KeyboardIndicator* self;
		self = _data1_->self;
		_g_object_unref0 (_data1_->gesture_click);
		_g_object_unref0 (self);
		g_slice_free (Block1Data, _data1_);
	}
}

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

static void
___lambda9_ (KeyboardIndicator* self)
{
	keyboard_indicator_update_visibility (self);
}

static void
____lambda9__g_settings_changed (GSettings* _sender,
                                 const gchar* key,
                                 gpointer self)
{
	___lambda9_ ((KeyboardIndicator*) self);
}

static void
___lambda10_ (KeyboardIndicator* self)
{
	keyboard_indicator_update_visibility (self);
}

static void
____lambda10__gdk_device_changed (GdkDevice* _sender,
                                  gpointer self)
{
	___lambda10_ ((KeyboardIndicator*) self);
}

static void
___lambda11_ (Block1Data* _data1_)
{
	KeyboardIndicator* self;
	KeyboardWidgetsPopoverWidget* _tmp0_;
	GtkGestureClick* _tmp1_;
	GtkGestureClick* _tmp2_;
	self = _data1_->self;
	_tmp0_ = self->priv->popover_widget;
	keyboard_widgets_popover_widget_next (_tmp0_);
	_tmp1_ = _data1_->gesture_click;
	gtk_gesture_set_state ((GtkGesture*) _tmp1_, GTK_EVENT_SEQUENCE_CLAIMED);
	_tmp2_ = _data1_->gesture_click;
	gtk_event_controller_reset ((GtkEventController*) _tmp2_);
}

static void
____lambda11__gtk_gesture_click_pressed (GtkGestureClick* _sender,
                                         gint n_press,
                                         gdouble x,
                                         gdouble y,
                                         gpointer self)
{
	___lambda11_ (self);
}

static void
___lambda12_ (KeyboardIndicator* self)
{
	keyboard_indicator_update_visibility (self);
}

static void
____lambda12__keyboard_widgets_popover_widget_updated (KeyboardWidgetsPopoverWidget* _sender,
                                                       gpointer self)
{
	___lambda12_ ((KeyboardIndicator*) self);
}

static GtkWidget*
keyboard_indicator_real_get_display_widget (WingpanelIndicator* base)
{
	KeyboardIndicator * self;
	GtkBox* _tmp0_;
	GtkBox* _tmp47_;
	GtkWidget* _tmp48_;
	GtkWidget* result;
	self = (KeyboardIndicator*) base;
	_tmp0_ = self->priv->indicator_box;
	if (_tmp0_ == NULL) {
		Block1Data* _data1_;
		GtkImage* numlock_icon = NULL;
		GtkImage* _tmp1_;
		GtkImage* _tmp2_;
		GtkWidget* _tmp3_;
		gchar** _tmp4_;
		gchar** _tmp5_;
		gint _tmp5__length1;
		gchar* _tmp6_;
		GtkRevealer* _tmp7_ = NULL;
		GtkImage* capslock_icon = NULL;
		GtkImage* _tmp8_;
		GtkImage* _tmp9_;
		GtkWidget* _tmp10_;
		gchar** _tmp11_;
		gchar** _tmp12_;
		gint _tmp12__length1;
		gchar* _tmp13_;
		GtkRevealer* _tmp14_ = NULL;
		GtkLabel* _tmp15_ = NULL;
		GtkLabel* _tmp16_;
		GtkLabel* _tmp17_;
		GtkWidget* _tmp18_;
		GtkRevealer* _tmp19_ = NULL;
		GtkBox* _tmp20_ = NULL;
		GtkBox* _tmp21_;
		GtkRevealer* _tmp22_;
		GtkBox* _tmp23_;
		GtkRevealer* _tmp24_;
		GtkBox* _tmp25_;
		GtkRevealer* _tmp26_;
		GtkCssProvider* provider = NULL;
		GtkCssProvider* _tmp27_;
		GtkCssProvider* _tmp28_;
		GdkDisplay* _tmp29_;
		GtkCssProvider* _tmp30_;
		GSettings* _tmp31_;
		GdkDisplay* _tmp32_;
		GdkSeat* _tmp33_;
		GdkDevice* _tmp34_;
		GdkDevice* _tmp35_;
		GSettings* _tmp36_;
		GdkDevice* _tmp37_;
		GtkGestureClick* _tmp38_ = NULL;
		GtkGestureClick* _tmp39_;
		GtkBox* _tmp40_;
		GtkGestureClick* _tmp41_;
		GtkEventController* _tmp42_;
		WingpanelIndicatorManagerServerType _tmp43_;
		KeyboardWidgetsPopoverWidget* _tmp44_;
		KeyboardWidgetsPopoverWidget* _tmp45_;
		KeyboardWidgetsPopoverWidget* _tmp46_;
		_data1_ = g_slice_new0 (Block1Data);
		_data1_->_ref_count_ = 1;
		_data1_->self = g_object_ref (self);
		_tmp1_ = (GtkImage*) gtk_image_new_from_icon_name ("input-keyboard-numlock-symbolic");
		g_object_ref_sink (_tmp1_);
		numlock_icon = _tmp1_;
		_tmp2_ = numlock_icon;
		_tmp3_ = _g_object_ref0 ((GtkWidget*) _tmp2_);
		_tmp4_ = g_new0 (gchar*, 0 + 1);
		_tmp5_ = _tmp4_;
		_tmp5__length1 = 0;
		_tmp6_ = granite_markup_accel_tooltip (_tmp5_, (gint) 0, _ ("Num Lock is on"));
		_tmp7_ = (GtkRevealer*) gtk_revealer_new ();
		gtk_revealer_set_child (_tmp7_, _tmp3_);
		_g_object_unref0 (_tmp3_);
		gtk_revealer_set_transition_type (_tmp7_, GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT);
		gtk_widget_set_tooltip_markup ((GtkWidget*) _tmp7_, _tmp6_);
		_g_free0 (_tmp6_);
		g_object_ref_sink (_tmp7_);
		_g_object_unref0 (self->priv->numlock_revealer);
		self->priv->numlock_revealer = _tmp7_;
		_tmp5_ = (_vala_array_free (_tmp5_, _tmp5__length1, (GDestroyNotify) g_free), NULL);
		_tmp8_ = (GtkImage*) gtk_image_new_from_icon_name ("input-keyboard-capslock-symbolic");
		g_object_ref_sink (_tmp8_);
		capslock_icon = _tmp8_;
		_tmp9_ = capslock_icon;
		_tmp10_ = _g_object_ref0 ((GtkWidget*) _tmp9_);
		_tmp11_ = g_new0 (gchar*, 0 + 1);
		_tmp12_ = _tmp11_;
		_tmp12__length1 = 0;
		_tmp13_ = granite_markup_accel_tooltip (_tmp12_, (gint) 0, _ ("Caps Lock is on"));
		_tmp14_ = (GtkRevealer*) gtk_revealer_new ();
		gtk_revealer_set_child (_tmp14_, _tmp10_);
		_g_object_unref0 (_tmp10_);
		gtk_revealer_set_transition_type (_tmp14_, GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT);
		gtk_widget_set_tooltip_markup ((GtkWidget*) _tmp14_, _tmp13_);
		_g_free0 (_tmp13_);
		g_object_ref_sink (_tmp14_);
		_g_object_unref0 (self->priv->capslock_revealer);
		self->priv->capslock_revealer = _tmp14_;
		_tmp12_ = (_vala_array_free (_tmp12_, _tmp12__length1, (GDestroyNotify) g_free), NULL);
		_tmp15_ = (GtkLabel*) gtk_label_new (NULL);
		g_object_set ((GtkWidget*) _tmp15_, "height-request", 20, NULL);
		g_object_set ((GtkWidget*) _tmp15_, "width-request", 20, NULL);
		gtk_widget_set_margin_top ((GtkWidget*) _tmp15_, 2);
		gtk_widget_set_margin_bottom ((GtkWidget*) _tmp15_, 2);
		gtk_widget_set_margin_start ((GtkWidget*) _tmp15_, 2);
		gtk_widget_set_margin_end ((GtkWidget*) _tmp15_, 2);
		g_object_ref_sink (_tmp15_);
		_g_object_unref0 (self->priv->layouts_icon);
		self->priv->layouts_icon = _tmp15_;
		_tmp16_ = self->priv->layouts_icon;
		gtk_widget_add_css_class ((GtkWidget*) _tmp16_, "keyboard-icon");
		_tmp17_ = self->priv->layouts_icon;
		_tmp18_ = _g_object_ref0 ((GtkWidget*) _tmp17_);
		_tmp19_ = (GtkRevealer*) gtk_revealer_new ();
		gtk_revealer_set_child (_tmp19_, _tmp18_);
		_g_object_unref0 (_tmp18_);
		gtk_revealer_set_transition_type (_tmp19_, GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT);
		g_object_ref_sink (_tmp19_);
		_g_object_unref0 (self->priv->layouts_revealer);
		self->priv->layouts_revealer = _tmp19_;
		_tmp20_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
		gtk_widget_set_valign ((GtkWidget*) _tmp20_, GTK_ALIGN_CENTER);
		g_object_ref_sink (_tmp20_);
		_g_object_unref0 (self->priv->indicator_box);
		self->priv->indicator_box = _tmp20_;
		_tmp21_ = self->priv->indicator_box;
		_tmp22_ = self->priv->numlock_revealer;
		gtk_box_append (_tmp21_, (GtkWidget*) _tmp22_);
		_tmp23_ = self->priv->indicator_box;
		_tmp24_ = self->priv->capslock_revealer;
		gtk_box_append (_tmp23_, (GtkWidget*) _tmp24_);
		_tmp25_ = self->priv->indicator_box;
		_tmp26_ = self->priv->layouts_revealer;
		gtk_box_append (_tmp25_, (GtkWidget*) _tmp26_);
		_tmp27_ = gtk_css_provider_new ();
		provider = _tmp27_;
		_tmp28_ = provider;
		gtk_css_provider_load_from_resource (_tmp28_, "/io/elementary/desktop/wingpanel/keyboard/KeyboardIcon.css");
		_tmp29_ = gdk_display_get_default ();
		_tmp30_ = provider;
		gtk_style_context_add_provider_for_display (_tmp29_, (GtkStyleProvider*) _tmp30_, (guint) GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
		_tmp31_ = g_settings_new ("io.elementary.wingpanel.keyboard");
		_g_object_unref0 (self->priv->settings);
		self->priv->settings = _tmp31_;
		_tmp32_ = gdk_display_get_default ();
		_tmp33_ = gdk_display_get_default_seat (_tmp32_);
		_tmp34_ = gdk_seat_get_keyboard (_tmp33_);
		_tmp35_ = _g_object_ref0 (_tmp34_);
		_g_object_unref0 (self->priv->device);
		self->priv->device = _tmp35_;
		_tmp36_ = self->priv->settings;
		g_signal_connect_object (_tmp36_, "changed", (GCallback) ____lambda9__g_settings_changed, self, 0);
		_tmp37_ = self->priv->device;
		g_signal_connect_object (_tmp37_, "changed", (GCallback) ____lambda10__gdk_device_changed, self, 0);
		_tmp38_ = (GtkGestureClick*) gtk_gesture_click_new ();
		gtk_gesture_single_set_button ((GtkGestureSingle*) _tmp38_, (guint) GDK_BUTTON_MIDDLE);
		_data1_->gesture_click = _tmp38_;
		_tmp39_ = _data1_->gesture_click;
		g_signal_connect_data (_tmp39_, "pressed", (GCallback) ____lambda11__gtk_gesture_click_pressed, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0);
		_tmp40_ = self->priv->indicator_box;
		_tmp41_ = _data1_->gesture_click;
		_tmp42_ = _g_object_ref0 ((GtkEventController*) _tmp41_);
		gtk_widget_add_controller ((GtkWidget*) _tmp40_, _tmp42_);
		_tmp43_ = self->priv->_server_type;
		_tmp44_ = keyboard_widgets_popover_widget_new (_tmp43_);
		g_object_ref_sink (_tmp44_);
		_g_object_unref0 (self->priv->popover_widget);
		self->priv->popover_widget = _tmp44_;
		_tmp45_ = self->priv->popover_widget;
		g_signal_connect_object (_tmp45_, "updated", (GCallback) ____lambda12__keyboard_widgets_popover_widget_updated, self, 0);
		_tmp46_ = self->priv->popover_widget;
		g_signal_emit_by_name (_tmp46_, "updated");
		_g_object_unref0 (provider);
		_g_object_unref0 (capslock_icon);
		_g_object_unref0 (numlock_icon);
		block1_data_unref (_data1_);
		_data1_ = NULL;
	}
	_tmp47_ = self->priv->indicator_box;
	_tmp48_ = _g_object_ref0 ((GtkWidget*) _tmp47_);
	result = _tmp48_;
	return result;
}

static gchar*
string_slice (const gchar* self,
              glong start,
              glong end)
{
	glong string_length = 0L;
	gint _tmp0_;
	gint _tmp1_;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gchar* _tmp4_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	string_length = (glong) _tmp1_;
	if (start < ((glong) 0)) {
		start = string_length + start;
	}
	if (end < ((glong) 0)) {
		end = string_length + end;
	}
	if (start >= ((glong) 0)) {
		_tmp2_ = start <= string_length;
	} else {
		_tmp2_ = FALSE;
	}
	g_return_val_if_fail (_tmp2_, NULL);
	if (end >= ((glong) 0)) {
		_tmp3_ = end <= string_length;
	} else {
		_tmp3_ = FALSE;
	}
	g_return_val_if_fail (_tmp3_, NULL);
	g_return_val_if_fail (start <= end, NULL);
	_tmp4_ = g_strndup (((gchar*) self) + start, (gsize) (end - start));
	result = _tmp4_;
	return result;
}

static void
keyboard_indicator_update_visibility (KeyboardIndicator* self)
{
	GtkLabel* _tmp0_;
	KeyboardWidgetsPopoverWidget* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gboolean _tmp6_ = FALSE;
	KeyboardWidgetsPopoverWidget* _tmp7_;
	GtkRevealer* _tmp9_;
	gboolean _tmp10_ = FALSE;
	GdkDevice* _tmp11_;
	GtkRevealer* _tmp13_;
	gboolean _tmp14_ = FALSE;
	GdkDevice* _tmp15_;
	GtkRevealer* _tmp17_;
	gboolean _tmp18_ = FALSE;
	GtkRevealer* _tmp19_;
	gboolean _tmp20_;
	gboolean _tmp21_;
	gboolean _tmp31_ = FALSE;
	GtkRevealer* _tmp32_;
	gboolean _tmp33_;
	gboolean _tmp34_;
	gboolean _tmp40_ = FALSE;
	gboolean _tmp41_ = FALSE;
	GtkRevealer* _tmp42_;
	gboolean _tmp43_;
	gboolean _tmp44_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->layouts_icon;
	_tmp1_ = self->priv->popover_widget;
	_tmp2_ = keyboard_widgets_popover_widget_get_current_language_code (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = string_slice (_tmp3_, (glong) 0, (glong) 2);
	_tmp5_ = _tmp4_;
	gtk_label_set_label (_tmp0_, _tmp5_);
	_g_free0 (_tmp5_);
	_tmp7_ = self->priv->popover_widget;
	if (keyboard_widgets_popover_widget_has_multiple_layouts (_tmp7_)) {
		_tmp6_ = TRUE;
	} else {
		GSettings* _tmp8_;
		_tmp8_ = self->priv->settings;
		_tmp6_ = g_settings_get_boolean (_tmp8_, "always-show-layout");
	}
	_tmp9_ = self->priv->layouts_revealer;
	gtk_revealer_set_reveal_child (_tmp9_, _tmp6_);
	_tmp11_ = self->priv->device;
	if (gdk_device_get_num_lock_state (_tmp11_)) {
		GSettings* _tmp12_;
		_tmp12_ = self->priv->settings;
		_tmp10_ = g_settings_get_boolean (_tmp12_, "numlock");
	} else {
		_tmp10_ = FALSE;
	}
	_tmp13_ = self->priv->numlock_revealer;
	gtk_revealer_set_reveal_child (_tmp13_, _tmp10_);
	_tmp15_ = self->priv->device;
	if (gdk_device_get_caps_lock_state (_tmp15_)) {
		GSettings* _tmp16_;
		_tmp16_ = self->priv->settings;
		_tmp14_ = g_settings_get_boolean (_tmp16_, "capslock");
	} else {
		_tmp14_ = FALSE;
	}
	_tmp17_ = self->priv->capslock_revealer;
	gtk_revealer_set_reveal_child (_tmp17_, _tmp14_);
	_tmp19_ = self->priv->numlock_revealer;
	_tmp20_ = gtk_revealer_get_reveal_child (_tmp19_);
	_tmp21_ = _tmp20_;
	if (_tmp21_) {
		gboolean _tmp22_ = FALSE;
		GtkRevealer* _tmp23_;
		gboolean _tmp24_;
		gboolean _tmp25_;
		_tmp23_ = self->priv->layouts_revealer;
		_tmp24_ = gtk_revealer_get_reveal_child (_tmp23_);
		_tmp25_ = _tmp24_;
		if (_tmp25_) {
			_tmp22_ = TRUE;
		} else {
			GtkRevealer* _tmp26_;
			gboolean _tmp27_;
			gboolean _tmp28_;
			_tmp26_ = self->priv->capslock_revealer;
			_tmp27_ = gtk_revealer_get_reveal_child (_tmp26_);
			_tmp28_ = _tmp27_;
			_tmp22_ = _tmp28_;
		}
		_tmp18_ = _tmp22_;
	} else {
		_tmp18_ = FALSE;
	}
	if (_tmp18_) {
		GtkRevealer* _tmp29_;
		_tmp29_ = self->priv->numlock_revealer;
		gtk_widget_set_margin_end ((GtkWidget*) _tmp29_, 6);
	} else {
		GtkRevealer* _tmp30_;
		_tmp30_ = self->priv->numlock_revealer;
		gtk_widget_set_margin_end ((GtkWidget*) _tmp30_, 0);
	}
	_tmp32_ = self->priv->capslock_revealer;
	_tmp33_ = gtk_revealer_get_reveal_child (_tmp32_);
	_tmp34_ = _tmp33_;
	if (_tmp34_) {
		GtkRevealer* _tmp35_;
		gboolean _tmp36_;
		gboolean _tmp37_;
		_tmp35_ = self->priv->layouts_revealer;
		_tmp36_ = gtk_revealer_get_reveal_child (_tmp35_);
		_tmp37_ = _tmp36_;
		_tmp31_ = _tmp37_;
	} else {
		_tmp31_ = FALSE;
	}
	if (_tmp31_) {
		GtkRevealer* _tmp38_;
		_tmp38_ = self->priv->capslock_revealer;
		gtk_widget_set_margin_end ((GtkWidget*) _tmp38_, 6);
	} else {
		GtkRevealer* _tmp39_;
		_tmp39_ = self->priv->capslock_revealer;
		gtk_widget_set_margin_end ((GtkWidget*) _tmp39_, 0);
	}
	_tmp42_ = self->priv->layouts_revealer;
	_tmp43_ = gtk_revealer_get_reveal_child (_tmp42_);
	_tmp44_ = _tmp43_;
	if (_tmp44_) {
		_tmp41_ = TRUE;
	} else {
		GtkRevealer* _tmp45_;
		gboolean _tmp46_;
		gboolean _tmp47_;
		_tmp45_ = self->priv->numlock_revealer;
		_tmp46_ = gtk_revealer_get_reveal_child (_tmp45_);
		_tmp47_ = _tmp46_;
		_tmp41_ = _tmp47_;
	}
	if (_tmp41_) {
		_tmp40_ = TRUE;
	} else {
		GtkRevealer* _tmp48_;
		gboolean _tmp49_;
		gboolean _tmp50_;
		_tmp48_ = self->priv->capslock_revealer;
		_tmp49_ = gtk_revealer_get_reveal_child (_tmp48_);
		_tmp50_ = _tmp49_;
		_tmp40_ = _tmp50_;
	}
	wingpanel_indicator_set_visible ((WingpanelIndicator*) self, _tmp40_);
	keyboard_indicator_update_tooltip (self);
}

static GtkWidget*
keyboard_indicator_real_get_widget (WingpanelIndicator* base)
{
	KeyboardIndicator * self;
	KeyboardWidgetsPopoverWidget* _tmp0_;
	GtkWidget* _tmp1_;
	GtkWidget* result;
	self = (KeyboardIndicator*) base;
	_tmp0_ = self->priv->popover_widget;
	_tmp1_ = _g_object_ref0 ((GtkWidget*) _tmp0_);
	result = _tmp1_;
	return result;
}

static void
keyboard_indicator_real_opened (WingpanelIndicator* base)
{
	KeyboardIndicator * self;
	self = (KeyboardIndicator*) base;
}

static void
keyboard_indicator_real_closed (WingpanelIndicator* base)
{
	KeyboardIndicator * self;
	self = (KeyboardIndicator*) base;
}

static void
keyboard_indicator_update_tooltip (KeyboardIndicator* self)
{
	gchar* description = NULL;
	KeyboardWidgetsPopoverWidget* _tmp0_;
	gchar* _tmp1_;
	gchar* accel_label = NULL;
	gchar* _tmp2_;
	GtkRevealer* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->popover_widget;
	_tmp1_ = keyboard_widgets_popover_widget_get_current_description (_tmp0_);
	description = _tmp1_;
	_tmp2_ = g_strdup_printf (GRANITE_TOOLTIP_SECONDARY_TEXT_MARKUP, _ ("Middle-click to switch to the next layout"));
	accel_label = _tmp2_;
	_tmp3_ = self->priv->layouts_revealer;
	_tmp4_ = g_strdup_printf ("%s\n%s", description, accel_label);
	_tmp5_ = _tmp4_;
	gtk_widget_set_tooltip_markup ((GtkWidget*) _tmp3_, _tmp5_);
	_g_free0 (_tmp5_);
	_g_free0 (accel_label);
	_g_free0 (description);
}

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

static void
keyboard_indicator_set_server_type (KeyboardIndicator* self,
                                    WingpanelIndicatorManagerServerType value)
{
	WingpanelIndicatorManagerServerType old_value;
	g_return_if_fail (self != NULL);
	old_value = keyboard_indicator_get_server_type (self);
	if (old_value != value) {
		self->priv->_server_type = value;
		g_object_notify_by_pspec ((GObject *) self, keyboard_indicator_properties[KEYBOARD_INDICATOR_SERVER_TYPE_PROPERTY]);
	}
}

static void
keyboard_indicator_class_init (KeyboardIndicatorClass * klass,
                               gpointer klass_data)
{
	keyboard_indicator_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &KeyboardIndicator_private_offset);
	((WingpanelIndicatorClass *) klass)->get_display_widget = (GtkWidget* (*) (WingpanelIndicator*)) keyboard_indicator_real_get_display_widget;
	((WingpanelIndicatorClass *) klass)->get_widget = (GtkWidget* (*) (WingpanelIndicator*)) keyboard_indicator_real_get_widget;
	((WingpanelIndicatorClass *) klass)->opened = (void (*) (WingpanelIndicator*)) keyboard_indicator_real_opened;
	((WingpanelIndicatorClass *) klass)->closed = (void (*) (WingpanelIndicator*)) keyboard_indicator_real_closed;
	G_OBJECT_CLASS (klass)->get_property = _vala_keyboard_indicator_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_keyboard_indicator_set_property;
	G_OBJECT_CLASS (klass)->finalize = keyboard_indicator_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), KEYBOARD_INDICATOR_SERVER_TYPE_PROPERTY, keyboard_indicator_properties[KEYBOARD_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_ONLY));
}

static void
keyboard_indicator_instance_init (KeyboardIndicator * self,
                                  gpointer klass)
{
	self->priv = keyboard_indicator_get_instance_private (self);
}

static void
keyboard_indicator_finalize (GObject * obj)
{
	KeyboardIndicator * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, KEYBOARD_TYPE_INDICATOR, KeyboardIndicator);
	_g_object_unref0 (self->priv->device);
	_g_object_unref0 (self->priv->settings);
	_g_object_unref0 (self->priv->indicator_box);
	_g_object_unref0 (self->priv->numlock_revealer);
	_g_object_unref0 (self->priv->capslock_revealer);
	_g_object_unref0 (self->priv->popover_widget);
	_g_object_unref0 (self->priv->layouts_icon);
	_g_object_unref0 (self->priv->layouts_revealer);
	G_OBJECT_CLASS (keyboard_indicator_parent_class)->finalize (obj);
}

static GType
keyboard_indicator_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (KeyboardIndicatorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) keyboard_indicator_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (KeyboardIndicator), 0, (GInstanceInitFunc) keyboard_indicator_instance_init, NULL };
	GType keyboard_indicator_type_id;
	keyboard_indicator_type_id = g_type_register_static (WINGPANEL_TYPE_INDICATOR, "KeyboardIndicator", &g_define_type_info, 0);
	KeyboardIndicator_private_offset = g_type_add_instance_private (keyboard_indicator_type_id, sizeof (KeyboardIndicatorPrivate));
	return keyboard_indicator_type_id;
}

GType
keyboard_indicator_get_type (void)
{
	static volatile gsize keyboard_indicator_type_id__once = 0;
	if (g_once_init_enter (&keyboard_indicator_type_id__once)) {
		GType keyboard_indicator_type_id;
		keyboard_indicator_type_id = keyboard_indicator_get_type_once ();
		g_once_init_leave (&keyboard_indicator_type_id__once, keyboard_indicator_type_id);
	}
	return keyboard_indicator_type_id__once;
}

static void
_vala_keyboard_indicator_get_property (GObject * object,
                                       guint property_id,
                                       GValue * value,
                                       GParamSpec * pspec)
{
	KeyboardIndicator * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, KEYBOARD_TYPE_INDICATOR, KeyboardIndicator);
	switch (property_id) {
		case KEYBOARD_INDICATOR_SERVER_TYPE_PROPERTY:
		g_value_set_enum (value, keyboard_indicator_get_server_type (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_keyboard_indicator_set_property (GObject * object,
                                       guint property_id,
                                       const GValue * value,
                                       GParamSpec * pspec)
{
	KeyboardIndicator * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, KEYBOARD_TYPE_INDICATOR, KeyboardIndicator);
	switch (property_id) {
		case KEYBOARD_INDICATOR_SERVER_TYPE_PROPERTY:
		keyboard_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)
{
	KeyboardIndicator* indicator = NULL;
	KeyboardIndicator* _tmp0_;
	WingpanelIndicator* result;
	g_return_val_if_fail (module != NULL, NULL);
	g_debug ("Indicator.vala:156: Activating Keyboard Indicator");
	_tmp0_ = keyboard_indicator_new (server_type);
	indicator = _tmp0_;
	result = (WingpanelIndicator*) indicator;
	return result;
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

