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

/*
 * Copyright 2026 elementary, Inc. (https://elementary.io)
 * SPDX-License-Identifier: GPL-3.0-or-later
 *
 * Authored by: Leonhard Kargl <leo.kargl@proton.me>
 */

#include <granite-7.h>
#include <glib-object.h>
#include <ibus.h>
#include <gio/gio.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>
#include <glib.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
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define GALA_DAEMON_TYPE_CANDIDATE_AREA (gala_daemon_candidate_area_get_type ())
#define GALA_DAEMON_CANDIDATE_AREA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_DAEMON_TYPE_CANDIDATE_AREA, GalaDaemonCandidateArea))
#define GALA_DAEMON_CANDIDATE_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GALA_DAEMON_TYPE_CANDIDATE_AREA, GalaDaemonCandidateAreaClass))
#define GALA_DAEMON_IS_CANDIDATE_AREA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_DAEMON_TYPE_CANDIDATE_AREA))
#define GALA_DAEMON_IS_CANDIDATE_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GALA_DAEMON_TYPE_CANDIDATE_AREA))
#define GALA_DAEMON_CANDIDATE_AREA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GALA_DAEMON_TYPE_CANDIDATE_AREA, GalaDaemonCandidateAreaClass))

typedef struct _GalaDaemonCandidateArea GalaDaemonCandidateArea;
typedef struct _GalaDaemonCandidateAreaClass GalaDaemonCandidateAreaClass;
typedef struct _GalaDaemonCandidateAreaPrivate GalaDaemonCandidateAreaPrivate;
enum  {
	GALA_DAEMON_CANDIDATE_AREA_0_PROPERTY,
	GALA_DAEMON_CANDIDATE_AREA_SERVICE_PROPERTY,
	GALA_DAEMON_CANDIDATE_AREA_NUM_PROPERTIES
};
static GParamSpec* gala_daemon_candidate_area_properties[GALA_DAEMON_CANDIDATE_AREA_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define GALA_DAEMON_TYPE_CANDIDATE_BOX (gala_daemon_candidate_box_get_type ())
#define GALA_DAEMON_CANDIDATE_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_DAEMON_TYPE_CANDIDATE_BOX, GalaDaemonCandidateBox))
#define GALA_DAEMON_CANDIDATE_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GALA_DAEMON_TYPE_CANDIDATE_BOX, GalaDaemonCandidateBoxClass))
#define GALA_DAEMON_IS_CANDIDATE_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_DAEMON_TYPE_CANDIDATE_BOX))
#define GALA_DAEMON_IS_CANDIDATE_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GALA_DAEMON_TYPE_CANDIDATE_BOX))
#define GALA_DAEMON_CANDIDATE_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GALA_DAEMON_TYPE_CANDIDATE_BOX, GalaDaemonCandidateBoxClass))

typedef struct _GalaDaemonCandidateBox GalaDaemonCandidateBox;
typedef struct _GalaDaemonCandidateBoxClass GalaDaemonCandidateBoxClass;

#define GALA_DAEMON_TYPE_CANDIDATE (gala_daemon_candidate_get_type ())
#define GALA_DAEMON_CANDIDATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_DAEMON_TYPE_CANDIDATE, GalaDaemonCandidate))
#define GALA_DAEMON_CANDIDATE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GALA_DAEMON_TYPE_CANDIDATE, GalaDaemonCandidateClass))
#define GALA_DAEMON_IS_CANDIDATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_DAEMON_TYPE_CANDIDATE))
#define GALA_DAEMON_IS_CANDIDATE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GALA_DAEMON_TYPE_CANDIDATE))
#define GALA_DAEMON_CANDIDATE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GALA_DAEMON_TYPE_CANDIDATE, GalaDaemonCandidateClass))

typedef struct _GalaDaemonCandidate GalaDaemonCandidate;
typedef struct _GalaDaemonCandidateClass GalaDaemonCandidateClass;
#define _g_free0(var) (var = (g_free (var), NULL))

struct _GalaDaemonCandidateArea {
	GraniteBin parent_instance;
	GalaDaemonCandidateAreaPrivate * priv;
};

struct _GalaDaemonCandidateAreaClass {
	GraniteBinClass parent_class;
};

struct _GalaDaemonCandidateAreaPrivate {
	IBusPanelService* _service;
	GListStore* model;
	GtkSingleSelection* selection_model;
	GtkListView* list_view;
	GtkButton* prev_page_button;
	GtkButton* next_page_button;
	GraniteBox* button_box;
	GraniteBox* content_box;
};

static gint GalaDaemonCandidateArea_private_offset;
static gpointer gala_daemon_candidate_area_parent_class = NULL;

VALA_EXTERN GType gala_daemon_candidate_area_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GalaDaemonCandidateArea, g_object_unref)
VALA_EXTERN GalaDaemonCandidateArea* gala_daemon_candidate_area_new (IBusPanelService* service);
VALA_EXTERN GalaDaemonCandidateArea* gala_daemon_candidate_area_construct (GType object_type,
                                                               IBusPanelService* service);
static void gala_daemon_candidate_area_on_setup (GalaDaemonCandidateArea* self,
                                          GObject* obj);
VALA_EXTERN IBusPanelService* gala_daemon_candidate_area_get_service (GalaDaemonCandidateArea* self);
VALA_EXTERN GalaDaemonCandidateBox* gala_daemon_candidate_box_new (IBusPanelService* service,
                                                       GtkListItem* list_item);
VALA_EXTERN GalaDaemonCandidateBox* gala_daemon_candidate_box_construct (GType object_type,
                                                             IBusPanelService* service,
                                                             GtkListItem* list_item);
VALA_EXTERN GType gala_daemon_candidate_box_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GalaDaemonCandidateBox, g_object_unref)
static void gala_daemon_candidate_area_on_bind (GalaDaemonCandidateArea* self,
                                         GObject* obj);
VALA_EXTERN GType gala_daemon_candidate_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GalaDaemonCandidate, g_object_unref)
VALA_EXTERN void gala_daemon_candidate_box_set_candidate (GalaDaemonCandidateBox* self,
                                              GalaDaemonCandidate* candidate);
VALA_EXTERN void gala_daemon_candidate_area_update (GalaDaemonCandidateArea* self,
                                        IBusLookupTable* table);
static void gala_daemon_candidate_area_update_orientation (GalaDaemonCandidateArea* self,
                                                    GtkOrientation orientation);
VALA_EXTERN GalaDaemonCandidate* gala_daemon_candidate_new (const gchar* label,
                                                const gchar* candidate);
VALA_EXTERN GalaDaemonCandidate* gala_daemon_candidate_construct (GType object_type,
                                                      const gchar* label,
                                                      const gchar* candidate);
static void gala_daemon_candidate_area_update_buttons (GalaDaemonCandidateArea* self,
                                                gboolean wraps_around,
                                                guint page,
                                                guint n_pages);
static void gala_daemon_candidate_area_set_service (GalaDaemonCandidateArea* self,
                                             IBusPanelService* value);
static GObject * gala_daemon_candidate_area_constructor (GType type,
                                                  guint n_construct_properties,
                                                  GObjectConstructParam * construct_properties);
static void _gala_daemon_candidate_area_on_setup_gtk_signal_list_item_factory_setup (GtkSignalListItemFactory* _sender,
                                                                              GObject* object,
                                                                              gpointer self);
static void _gala_daemon_candidate_area_on_bind_gtk_signal_list_item_factory_bind (GtkSignalListItemFactory* _sender,
                                                                            GObject* object,
                                                                            gpointer self);
static void _ibus_panel_service_page_up_gtk_button_clicked (GtkButton* _sender,
                                                     gpointer self);
static void _ibus_panel_service_page_down_gtk_button_clicked (GtkButton* _sender,
                                                       gpointer self);
static void gala_daemon_candidate_area_finalize (GObject * obj);
static GType gala_daemon_candidate_area_get_type_once (void);
static void _vala_gala_daemon_candidate_area_get_property (GObject * object,
                                                    guint property_id,
                                                    GValue * value,
                                                    GParamSpec * pspec);
static void _vala_gala_daemon_candidate_area_set_property (GObject * object,
                                                    guint property_id,
                                                    const GValue * value,
                                                    GParamSpec * pspec);

static const gchar* GALA_DAEMON_CANDIDATE_AREA_DEFAULT_LABELS[16] = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "a", "b", "c", "d", "e", "f"};

static inline gpointer
gala_daemon_candidate_area_get_instance_private (GalaDaemonCandidateArea* self)
{
	return G_STRUCT_MEMBER_P (self, GalaDaemonCandidateArea_private_offset);
}

GalaDaemonCandidateArea*
gala_daemon_candidate_area_construct (GType object_type,
                                      IBusPanelService* service)
{
	GalaDaemonCandidateArea * self = NULL;
	g_return_val_if_fail (service != NULL, NULL);
	self = (GalaDaemonCandidateArea*) g_object_new (object_type, "service", service, NULL);
	return self;
}

GalaDaemonCandidateArea*
gala_daemon_candidate_area_new (IBusPanelService* service)
{
	return gala_daemon_candidate_area_construct (GALA_DAEMON_TYPE_CANDIDATE_AREA, service);
}

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

static void
gala_daemon_candidate_area_on_setup (GalaDaemonCandidateArea* self,
                                     GObject* obj)
{
	GtkListItem* item = NULL;
	GtkListItem* _tmp0_;
	IBusPanelService* _tmp1_;
	GalaDaemonCandidateBox* _tmp2_;
	GalaDaemonCandidateBox* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (obj != NULL);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (obj, gtk_list_item_get_type (), GtkListItem));
	item = _tmp0_;
	_tmp1_ = self->priv->_service;
	_tmp2_ = gala_daemon_candidate_box_new (_tmp1_, item);
	g_object_ref_sink (_tmp2_);
	_tmp3_ = _tmp2_;
	gtk_list_item_set_child (item, (GtkWidget*) _tmp3_);
	_g_object_unref0 (_tmp3_);
	_g_object_unref0 (item);
}

static void
gala_daemon_candidate_area_on_bind (GalaDaemonCandidateArea* self,
                                    GObject* obj)
{
	GtkListItem* item = NULL;
	GtkListItem* _tmp0_;
	GalaDaemonCandidate* candidate = NULL;
	GObject* _tmp1_;
	GObject* _tmp2_;
	GalaDaemonCandidate* _tmp3_;
	GalaDaemonCandidateBox* box = NULL;
	GtkWidget* _tmp4_;
	GtkWidget* _tmp5_;
	GalaDaemonCandidateBox* _tmp6_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (obj != NULL);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (obj, gtk_list_item_get_type (), GtkListItem));
	item = _tmp0_;
	_tmp1_ = gtk_list_item_get_item (item);
	_tmp2_ = _tmp1_;
	_tmp3_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GALA_DAEMON_TYPE_CANDIDATE, GalaDaemonCandidate));
	candidate = _tmp3_;
	_tmp4_ = gtk_list_item_get_child (item);
	_tmp5_ = _tmp4_;
	_tmp6_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, GALA_DAEMON_TYPE_CANDIDATE_BOX, GalaDaemonCandidateBox));
	box = _tmp6_;
	gala_daemon_candidate_box_set_candidate (box, candidate);
	_g_object_unref0 (box);
	_g_object_unref0 (candidate);
	_g_object_unref0 (item);
}

static gchar*
string_strip (const gchar* self)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup (self);
	_result_ = _tmp0_;
	g_strstrip (_result_);
	result = _result_;
	return result;
}

void
gala_daemon_candidate_area_update (GalaDaemonCandidateArea* self,
                                   IBusLookupTable* table)
{
	GListStore* _tmp0_;
	guint n_candidates = 0U;
	guint page_size = 0U;
	guint cursor_pos = 0U;
	guint page = 0U;
	guint start_index = 0U;
	guint end_index = 0U;
	GtkSingleSelection* _tmp28_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (table != NULL);
	_tmp0_ = self->priv->model;
	g_list_store_remove_all (_tmp0_);
	if (ibus_lookup_table_get_orientation (table) == ((gint) IBUS_ORIENTATION_HORIZONTAL)) {
		gala_daemon_candidate_area_update_orientation (self, GTK_ORIENTATION_HORIZONTAL);
	} else {
		gala_daemon_candidate_area_update_orientation (self, GTK_ORIENTATION_VERTICAL);
	}
	n_candidates = ibus_lookup_table_get_number_of_candidates (table);
	page_size = ibus_lookup_table_get_page_size (table);
	if (page_size == ((guint) 0)) {
		g_warning ("CandidateArea.vala:86: LookupTable page size is 0, using 5");
		page_size = (guint) 5;
	}
	cursor_pos = ibus_lookup_table_get_cursor_pos (table);
	page = (guint) (cursor_pos / page_size);
	start_index = page * page_size;
	end_index = MIN (start_index + page_size, n_candidates);
	{
		guint i = 0U;
		i = start_index;
		{
			gboolean _tmp1_ = FALSE;
			_tmp1_ = TRUE;
			while (TRUE) {
				IBusText* _tmp3_ = NULL;
				IBusText* _tmp4_;
				const gchar* _tmp5_ = NULL;
				gchar* ibus_label = NULL;
				gchar* _tmp7_;
				const gchar* _tmp8_ = NULL;
				gboolean _tmp9_ = FALSE;
				const gchar* _tmp10_;
				gchar* label = NULL;
				gchar* _tmp17_;
				IBusText* _tmp18_ = NULL;
				IBusText* _tmp19_;
				const gchar* _tmp20_ = NULL;
				gchar* candidate = NULL;
				gchar* _tmp22_;
				GListStore* _tmp23_;
				const gchar* _tmp24_;
				const gchar* _tmp25_;
				GalaDaemonCandidate* _tmp26_;
				GalaDaemonCandidate* _tmp27_;
				if (!_tmp1_) {
					guint _tmp2_;
					_tmp2_ = i;
					i = _tmp2_ + 1;
				}
				_tmp1_ = FALSE;
				if (!(i < end_index)) {
					break;
				}
				_tmp4_ = ibus_lookup_table_get_label (table, i);
				_tmp3_ = _tmp4_;
				_tmp5_ = NULL;
				if (_tmp3_ != NULL) {
					const gchar* _tmp6_;
					_tmp6_ = _tmp3_->text;
					_tmp5_ = _tmp6_;
				}
				_tmp7_ = g_strdup (_tmp5_);
				ibus_label = _tmp7_;
				_tmp10_ = ibus_label;
				if (_tmp10_ != NULL) {
					const gchar* _tmp11_;
					gchar* _tmp12_;
					gchar* _tmp13_;
					_tmp11_ = ibus_label;
					_tmp12_ = string_strip (_tmp11_);
					_tmp13_ = _tmp12_;
					_tmp9_ = g_strcmp0 (_tmp13_, "") != 0;
					_g_free0 (_tmp13_);
				} else {
					_tmp9_ = FALSE;
				}
				if (_tmp9_) {
					const gchar* _tmp14_;
					_tmp14_ = ibus_label;
					_tmp8_ = _tmp14_;
				} else {
					const gchar* _tmp15_ = NULL;
					if ((i - start_index) < ((guint) G_N_ELEMENTS (GALA_DAEMON_CANDIDATE_AREA_DEFAULT_LABELS))) {
						const gchar* _tmp16_;
						_tmp16_ = GALA_DAEMON_CANDIDATE_AREA_DEFAULT_LABELS[i - start_index];
						_tmp15_ = _tmp16_;
					} else {
						_tmp15_ = NULL;
					}
					_tmp8_ = _tmp15_;
				}
				_tmp17_ = g_strdup (_tmp8_);
				label = _tmp17_;
				_tmp19_ = ibus_lookup_table_get_candidate (table, i);
				_tmp18_ = _tmp19_;
				_tmp20_ = NULL;
				if (_tmp18_ != NULL) {
					const gchar* _tmp21_;
					_tmp21_ = _tmp18_->text;
					_tmp20_ = _tmp21_;
				}
				_tmp22_ = g_strdup (_tmp20_);
				candidate = _tmp22_;
				_tmp23_ = self->priv->model;
				_tmp24_ = label;
				_tmp25_ = candidate;
				_tmp26_ = gala_daemon_candidate_new (_tmp24_, _tmp25_);
				_tmp27_ = _tmp26_;
				g_list_store_append (_tmp23_, (GObject*) _tmp27_);
				_g_object_unref0 (_tmp27_);
				_g_free0 (candidate);
				_g_free0 (label);
				_g_free0 (ibus_label);
			}
		}
	}
	_tmp28_ = self->priv->selection_model;
	gtk_single_selection_set_selected (_tmp28_, ibus_lookup_table_get_cursor_in_page (table));
	gala_daemon_candidate_area_update_buttons (self, ibus_lookup_table_is_round (table), page, (guint) (((n_candidates + page_size) - 1) / page_size));
}

static void
gala_daemon_candidate_area_update_orientation (GalaDaemonCandidateArea* self,
                                               GtkOrientation orientation)
{
	GraniteBox* _tmp0_;
	GtkListView* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->content_box;
	gtk_orientable_set_orientation ((GtkOrientable*) _tmp0_, orientation);
	_tmp1_ = self->priv->list_view;
	gtk_orientable_set_orientation ((GtkOrientable*) _tmp1_, orientation);
	if (orientation == GTK_ORIENTATION_HORIZONTAL) {
		GtkButton* _tmp2_;
		GtkButton* _tmp3_;
		_tmp2_ = self->priv->prev_page_button;
		gtk_button_set_icon_name (_tmp2_, "go-previous");
		_tmp3_ = self->priv->next_page_button;
		gtk_button_set_icon_name (_tmp3_, "go-next");
	} else {
		GtkButton* _tmp4_;
		GtkButton* _tmp5_;
		_tmp4_ = self->priv->prev_page_button;
		gtk_button_set_icon_name (_tmp4_, "go-up");
		_tmp5_ = self->priv->next_page_button;
		gtk_button_set_icon_name (_tmp5_, "go-down");
	}
}

static void
gala_daemon_candidate_area_update_buttons (GalaDaemonCandidateArea* self,
                                           gboolean wraps_around,
                                           guint page,
                                           guint n_pages)
{
	GraniteBox* _tmp0_;
	gboolean _tmp1_ = FALSE;
	GtkButton* _tmp2_;
	gboolean _tmp3_ = FALSE;
	GtkButton* _tmp4_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->button_box;
	gtk_widget_set_visible ((GtkWidget*) _tmp0_, n_pages > ((guint) 1));
	if (wraps_around) {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = page > ((guint) 0);
	}
	_tmp2_ = self->priv->prev_page_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp2_, _tmp1_);
	if (wraps_around) {
		_tmp3_ = TRUE;
	} else {
		_tmp3_ = page < (n_pages - 1);
	}
	_tmp4_ = self->priv->next_page_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp4_, _tmp3_);
}

IBusPanelService*
gala_daemon_candidate_area_get_service (GalaDaemonCandidateArea* self)
{
	IBusPanelService* result;
	IBusPanelService* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_service;
	result = _tmp0_;
	return result;
}

static void
gala_daemon_candidate_area_set_service (GalaDaemonCandidateArea* self,
                                        IBusPanelService* value)
{
	IBusPanelService* old_value;
	g_return_if_fail (self != NULL);
	old_value = gala_daemon_candidate_area_get_service (self);
	if (old_value != value) {
		IBusPanelService* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_service);
		self->priv->_service = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, gala_daemon_candidate_area_properties[GALA_DAEMON_CANDIDATE_AREA_SERVICE_PROPERTY]);
	}
}

static void
_gala_daemon_candidate_area_on_setup_gtk_signal_list_item_factory_setup (GtkSignalListItemFactory* _sender,
                                                                         GObject* object,
                                                                         gpointer self)
{
	gala_daemon_candidate_area_on_setup ((GalaDaemonCandidateArea*) self, object);
}

static void
_gala_daemon_candidate_area_on_bind_gtk_signal_list_item_factory_bind (GtkSignalListItemFactory* _sender,
                                                                       GObject* object,
                                                                       gpointer self)
{
	gala_daemon_candidate_area_on_bind ((GalaDaemonCandidateArea*) self, object);
}

static void
_ibus_panel_service_page_up_gtk_button_clicked (GtkButton* _sender,
                                                gpointer self)
{
	ibus_panel_service_page_up ((IBusPanelService*) self);
}

static void
_ibus_panel_service_page_down_gtk_button_clicked (GtkButton* _sender,
                                                  gpointer self)
{
	ibus_panel_service_page_down ((IBusPanelService*) self);
}

static GObject *
gala_daemon_candidate_area_constructor (GType type,
                                        guint n_construct_properties,
                                        GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GalaDaemonCandidateArea * self;
	GListStore* _tmp0_;
	GListStore* _tmp1_;
	GListModel* _tmp2_;
	GtkSingleSelection* _tmp3_;
	GtkSignalListItemFactory* factory = NULL;
	GtkSignalListItemFactory* _tmp4_;
	GtkSignalListItemFactory* _tmp5_;
	GtkSignalListItemFactory* _tmp6_;
	GtkSingleSelection* _tmp7_;
	GtkSelectionModel* _tmp8_;
	GtkSignalListItemFactory* _tmp9_;
	GtkListItemFactory* _tmp10_;
	GtkListView* _tmp11_;
	GtkButton* _tmp12_;
	GtkButton* _tmp13_;
	IBusPanelService* _tmp14_;
	GtkButton* _tmp15_;
	GtkButton* _tmp16_;
	IBusPanelService* _tmp17_;
	GraniteBox* _tmp18_ = NULL;
	GraniteBox* _tmp19_;
	GtkButton* _tmp20_;
	GraniteBox* _tmp21_;
	GtkButton* _tmp22_;
	GraniteBox* _tmp23_;
	GraniteBox* _tmp24_;
	GtkListView* _tmp25_;
	GraniteBox* _tmp26_;
	GraniteBox* _tmp27_;
	GraniteBox* _tmp28_;
	parent_class = G_OBJECT_CLASS (gala_daemon_candidate_area_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GALA_DAEMON_TYPE_CANDIDATE_AREA, GalaDaemonCandidateArea);
	_tmp0_ = g_list_store_new (GALA_DAEMON_TYPE_CANDIDATE);
	_g_object_unref0 (self->priv->model);
	self->priv->model = _tmp0_;
	_tmp1_ = self->priv->model;
	_tmp2_ = _g_object_ref0 ((GListModel*) _tmp1_);
	_tmp3_ = gtk_single_selection_new (_tmp2_);
	_g_object_unref0 (self->priv->selection_model);
	self->priv->selection_model = _tmp3_;
	_tmp4_ = (GtkSignalListItemFactory*) gtk_signal_list_item_factory_new ();
	factory = _tmp4_;
	_tmp5_ = factory;
	g_signal_connect_object (_tmp5_, "setup", (GCallback) _gala_daemon_candidate_area_on_setup_gtk_signal_list_item_factory_setup, self, 0);
	_tmp6_ = factory;
	g_signal_connect_object (_tmp6_, "bind", (GCallback) _gala_daemon_candidate_area_on_bind_gtk_signal_list_item_factory_bind, self, 0);
	_tmp7_ = self->priv->selection_model;
	_tmp8_ = _g_object_ref0 ((GtkSelectionModel*) _tmp7_);
	_tmp9_ = factory;
	_tmp10_ = _g_object_ref0 ((GtkListItemFactory*) _tmp9_);
	_tmp11_ = (GtkListView*) gtk_list_view_new (_tmp8_, _tmp10_);
	g_object_ref_sink (_tmp11_);
	_g_object_unref0 (self->priv->list_view);
	self->priv->list_view = _tmp11_;
	_tmp12_ = (GtkButton*) gtk_button_new ();
	g_object_ref_sink (_tmp12_);
	_g_object_unref0 (self->priv->prev_page_button);
	self->priv->prev_page_button = _tmp12_;
	_tmp13_ = self->priv->prev_page_button;
	_tmp14_ = self->priv->_service;
	g_signal_connect_object (_tmp13_, "clicked", (GCallback) _ibus_panel_service_page_up_gtk_button_clicked, _tmp14_, 0);
	_tmp15_ = (GtkButton*) gtk_button_new ();
	g_object_ref_sink (_tmp15_);
	_g_object_unref0 (self->priv->next_page_button);
	self->priv->next_page_button = _tmp15_;
	_tmp16_ = self->priv->next_page_button;
	_tmp17_ = self->priv->_service;
	g_signal_connect_object (_tmp16_, "clicked", (GCallback) _ibus_panel_service_page_down_gtk_button_clicked, _tmp17_, 0);
	_tmp18_ = granite_box_new (GTK_ORIENTATION_HORIZONTAL, GRANITE_BOX_SPACING_LINKED);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp18_, TRUE);
	g_object_ref_sink (_tmp18_);
	_g_object_unref0 (self->priv->button_box);
	self->priv->button_box = _tmp18_;
	_tmp19_ = self->priv->button_box;
	_tmp20_ = self->priv->prev_page_button;
	gtk_box_append ((GtkBox*) _tmp19_, (GtkWidget*) _tmp20_);
	_tmp21_ = self->priv->button_box;
	_tmp22_ = self->priv->next_page_button;
	gtk_box_append ((GtkBox*) _tmp21_, (GtkWidget*) _tmp22_);
	_tmp23_ = granite_box_new (GTK_ORIENTATION_VERTICAL, GRANITE_BOX_SPACING_SINGLE);
	g_object_ref_sink (_tmp23_);
	_g_object_unref0 (self->priv->content_box);
	self->priv->content_box = _tmp23_;
	_tmp24_ = self->priv->content_box;
	_tmp25_ = self->priv->list_view;
	gtk_box_append ((GtkBox*) _tmp24_, (GtkWidget*) _tmp25_);
	_tmp26_ = self->priv->content_box;
	_tmp27_ = self->priv->button_box;
	gtk_box_append ((GtkBox*) _tmp26_, (GtkWidget*) _tmp27_);
	_tmp28_ = self->priv->content_box;
	granite_bin_set_child ((GraniteBin*) self, (GtkWidget*) _tmp28_);
	_g_object_unref0 (factory);
	return obj;
}

static void
gala_daemon_candidate_area_class_init (GalaDaemonCandidateAreaClass * klass,
                                       gpointer klass_data)
{
	gala_daemon_candidate_area_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GalaDaemonCandidateArea_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_gala_daemon_candidate_area_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_gala_daemon_candidate_area_set_property;
	G_OBJECT_CLASS (klass)->constructor = gala_daemon_candidate_area_constructor;
	G_OBJECT_CLASS (klass)->finalize = gala_daemon_candidate_area_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_DAEMON_CANDIDATE_AREA_SERVICE_PROPERTY, gala_daemon_candidate_area_properties[GALA_DAEMON_CANDIDATE_AREA_SERVICE_PROPERTY] = g_param_spec_object ("service", "service", "service", ibus_panel_service_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
gala_daemon_candidate_area_instance_init (GalaDaemonCandidateArea * self,
                                          gpointer klass)
{
	self->priv = gala_daemon_candidate_area_get_instance_private (self);
}

static void
gala_daemon_candidate_area_finalize (GObject * obj)
{
	GalaDaemonCandidateArea * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GALA_DAEMON_TYPE_CANDIDATE_AREA, GalaDaemonCandidateArea);
	_g_object_unref0 (self->priv->_service);
	_g_object_unref0 (self->priv->model);
	_g_object_unref0 (self->priv->selection_model);
	_g_object_unref0 (self->priv->list_view);
	_g_object_unref0 (self->priv->prev_page_button);
	_g_object_unref0 (self->priv->next_page_button);
	_g_object_unref0 (self->priv->button_box);
	_g_object_unref0 (self->priv->content_box);
	G_OBJECT_CLASS (gala_daemon_candidate_area_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
gala_daemon_candidate_area_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GalaDaemonCandidateAreaClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gala_daemon_candidate_area_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GalaDaemonCandidateArea), 0, (GInstanceInitFunc) gala_daemon_candidate_area_instance_init, NULL };
	GType gala_daemon_candidate_area_type_id;
	gala_daemon_candidate_area_type_id = g_type_register_static (GRANITE_TYPE_BIN, "GalaDaemonCandidateArea", &g_define_type_info, G_TYPE_FLAG_NONE);
	GalaDaemonCandidateArea_private_offset = g_type_add_instance_private (gala_daemon_candidate_area_type_id, sizeof (GalaDaemonCandidateAreaPrivate));
	return gala_daemon_candidate_area_type_id;
}

GType
gala_daemon_candidate_area_get_type (void)
{
	static gsize gala_daemon_candidate_area_type_id__once = 0;
	if (g_once_init_enter (&gala_daemon_candidate_area_type_id__once)) {
		GType gala_daemon_candidate_area_type_id;
		gala_daemon_candidate_area_type_id = gala_daemon_candidate_area_get_type_once ();
		g_once_init_leave (&gala_daemon_candidate_area_type_id__once, gala_daemon_candidate_area_type_id);
	}
	return gala_daemon_candidate_area_type_id__once;
}

static void
_vala_gala_daemon_candidate_area_get_property (GObject * object,
                                               guint property_id,
                                               GValue * value,
                                               GParamSpec * pspec)
{
	GalaDaemonCandidateArea * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_DAEMON_TYPE_CANDIDATE_AREA, GalaDaemonCandidateArea);
	switch (property_id) {
		case GALA_DAEMON_CANDIDATE_AREA_SERVICE_PROPERTY:
		g_value_set_object (value, gala_daemon_candidate_area_get_service (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_gala_daemon_candidate_area_set_property (GObject * object,
                                               guint property_id,
                                               const GValue * value,
                                               GParamSpec * pspec)
{
	GalaDaemonCandidateArea * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_DAEMON_TYPE_CANDIDATE_AREA, GalaDaemonCandidateArea);
	switch (property_id) {
		case GALA_DAEMON_CANDIDATE_AREA_SERVICE_PROPERTY:
		gala_daemon_candidate_area_set_service (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

