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

/*
 * Copyright © 2025 Alain M. (https://github.com/alainm23/planify)
 *
 * 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 3 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
 *
 * Authored by: Alain M. <alainmh23@gmail.com>
 */

#include <adwaita.h>
#include <glib-object.h>
#include <gee.h>
#include <glib.h>
#include <gtk/gtk.h>
#include "planify.h"
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>
#include <float.h>
#include <math.h>
#include <gio/gio.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 DIALOGS_PREFERENCES_PAGES_TYPE_BASE_PAGE (dialogs_preferences_pages_base_page_get_type ())
#define DIALOGS_PREFERENCES_PAGES_BASE_PAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DIALOGS_PREFERENCES_PAGES_TYPE_BASE_PAGE, DialogsPreferencesPagesBasePage))
#define DIALOGS_PREFERENCES_PAGES_BASE_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DIALOGS_PREFERENCES_PAGES_TYPE_BASE_PAGE, DialogsPreferencesPagesBasePageClass))
#define DIALOGS_PREFERENCES_PAGES_IS_BASE_PAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DIALOGS_PREFERENCES_PAGES_TYPE_BASE_PAGE))
#define DIALOGS_PREFERENCES_PAGES_IS_BASE_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DIALOGS_PREFERENCES_PAGES_TYPE_BASE_PAGE))
#define DIALOGS_PREFERENCES_PAGES_BASE_PAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DIALOGS_PREFERENCES_PAGES_TYPE_BASE_PAGE, DialogsPreferencesPagesBasePageClass))

typedef struct _DialogsPreferencesPagesBasePage DialogsPreferencesPagesBasePage;
typedef struct _DialogsPreferencesPagesBasePageClass DialogsPreferencesPagesBasePageClass;
typedef struct _DialogsPreferencesPagesBasePagePrivate DialogsPreferencesPagesBasePagePrivate;

#define DIALOGS_PREFERENCES_PAGES_TYPE_TODOIST_SETUP (dialogs_preferences_pages_todoist_setup_get_type ())
#define DIALOGS_PREFERENCES_PAGES_TODOIST_SETUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DIALOGS_PREFERENCES_PAGES_TYPE_TODOIST_SETUP, DialogsPreferencesPagesTodoistSetup))
#define DIALOGS_PREFERENCES_PAGES_TODOIST_SETUP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DIALOGS_PREFERENCES_PAGES_TYPE_TODOIST_SETUP, DialogsPreferencesPagesTodoistSetupClass))
#define DIALOGS_PREFERENCES_PAGES_IS_TODOIST_SETUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DIALOGS_PREFERENCES_PAGES_TYPE_TODOIST_SETUP))
#define DIALOGS_PREFERENCES_PAGES_IS_TODOIST_SETUP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DIALOGS_PREFERENCES_PAGES_TYPE_TODOIST_SETUP))
#define DIALOGS_PREFERENCES_PAGES_TODOIST_SETUP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DIALOGS_PREFERENCES_PAGES_TYPE_TODOIST_SETUP, DialogsPreferencesPagesTodoistSetupClass))

typedef struct _DialogsPreferencesPagesTodoistSetup DialogsPreferencesPagesTodoistSetup;
typedef struct _DialogsPreferencesPagesTodoistSetupClass DialogsPreferencesPagesTodoistSetupClass;
typedef struct _DialogsPreferencesPagesTodoistSetupPrivate DialogsPreferencesPagesTodoistSetupPrivate;

#define DIALOGS_PREFERENCES_PAGES_TYPE_ACCOUNTS (dialogs_preferences_pages_accounts_get_type ())
#define DIALOGS_PREFERENCES_PAGES_ACCOUNTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DIALOGS_PREFERENCES_PAGES_TYPE_ACCOUNTS, DialogsPreferencesPagesAccounts))
#define DIALOGS_PREFERENCES_PAGES_ACCOUNTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DIALOGS_PREFERENCES_PAGES_TYPE_ACCOUNTS, DialogsPreferencesPagesAccountsClass))
#define DIALOGS_PREFERENCES_PAGES_IS_ACCOUNTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DIALOGS_PREFERENCES_PAGES_TYPE_ACCOUNTS))
#define DIALOGS_PREFERENCES_PAGES_IS_ACCOUNTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DIALOGS_PREFERENCES_PAGES_TYPE_ACCOUNTS))
#define DIALOGS_PREFERENCES_PAGES_ACCOUNTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DIALOGS_PREFERENCES_PAGES_TYPE_ACCOUNTS, DialogsPreferencesPagesAccountsClass))

typedef struct _DialogsPreferencesPagesAccounts DialogsPreferencesPagesAccounts;
typedef struct _DialogsPreferencesPagesAccountsClass DialogsPreferencesPagesAccountsClass;
enum  {
	DIALOGS_PREFERENCES_PAGES_TODOIST_SETUP_0_PROPERTY,
	DIALOGS_PREFERENCES_PAGES_TODOIST_SETUP_ACCOUNTS_PAGE_PROPERTY,
	DIALOGS_PREFERENCES_PAGES_TODOIST_SETUP_NUM_PROPERTIES
};
static GParamSpec* dialogs_preferences_pages_todoist_setup_properties[DIALOGS_PREFERENCES_PAGES_TODOIST_SETUP_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
#define _http_response_unref0(var) ((var == NULL) ? NULL : (var = (http_response_unref (var), NULL)))

struct _DialogsPreferencesPagesBasePage {
	AdwNavigationPage parent_instance;
	DialogsPreferencesPagesBasePagePrivate * priv;
	GeeHashMap* signal_map;
};

struct _DialogsPreferencesPagesBasePageClass {
	AdwNavigationPageClass parent_class;
	void (*clean_up) (DialogsPreferencesPagesBasePage* self);
};

struct _DialogsPreferencesPagesTodoistSetup {
	DialogsPreferencesPagesBasePage parent_instance;
	DialogsPreferencesPagesTodoistSetupPrivate * priv;
};

struct _DialogsPreferencesPagesTodoistSetupClass {
	DialogsPreferencesPagesBasePageClass parent_class;
};

struct _DialogsPreferencesPagesTodoistSetupPrivate {
	DialogsPreferencesPagesAccounts* _accounts_page;
	GtkStack* stack;
	AdwEntryRow* token_entry;
	WidgetsLoadingButton* login_button;
	WidgetsLoadingButton* oauth_button;
	GtkButton* cancel_button;
	gchar* oauth_state;
	ObjectsSource* migrate_source;
};

static gint DialogsPreferencesPagesTodoistSetup_private_offset;
static gpointer dialogs_preferences_pages_todoist_setup_parent_class = NULL;

VALA_EXTERN GType dialogs_preferences_pages_base_page_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DialogsPreferencesPagesBasePage, g_object_unref)
VALA_EXTERN GType dialogs_preferences_pages_todoist_setup_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DialogsPreferencesPagesTodoistSetup, g_object_unref)
VALA_EXTERN GType dialogs_preferences_pages_accounts_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DialogsPreferencesPagesAccounts, g_object_unref)
VALA_EXTERN DialogsPreferencesPagesTodoistSetup* dialogs_preferences_pages_todoist_setup_new (AdwPreferencesDialog* preferences_dialog,
                                                                                  DialogsPreferencesPagesAccounts* accounts_page);
VALA_EXTERN DialogsPreferencesPagesTodoistSetup* dialogs_preferences_pages_todoist_setup_construct (GType object_type,
                                                                                        AdwPreferencesDialog* preferences_dialog,
                                                                                        DialogsPreferencesPagesAccounts* accounts_page);
static GtkWidget* dialogs_preferences_pages_todoist_setup_build_main_page (DialogsPreferencesPagesTodoistSetup* self);
static void __lambda294_ (DialogsPreferencesPagesTodoistSetup* self);
static void dialogs_preferences_pages_todoist_setup_start_oauth_flow (DialogsPreferencesPagesTodoistSetup* self);
static void ___lambda294__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static void __lambda295_ (DialogsPreferencesPagesTodoistSetup* self);
static void dialogs_preferences_pages_todoist_setup_cancel_oauth_flow (DialogsPreferencesPagesTodoistSetup* self);
static void ___lambda295__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static void __lambda296_ (DialogsPreferencesPagesTodoistSetup* self);
static void ___lambda296__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static GtkWidget* dialogs_preferences_pages_todoist_setup_build_token_page (DialogsPreferencesPagesTodoistSetup* self);
static void __lambda297_ (DialogsPreferencesPagesTodoistSetup* self);
static void ___lambda297__gtk_editable_changed (GtkEditable* _sender,
                                         gpointer self);
static void __lambda298_ (DialogsPreferencesPagesTodoistSetup* self);
static void dialogs_preferences_pages_todoist_setup_on_token_login_clicked (DialogsPreferencesPagesTodoistSetup* self);
static void ___lambda298__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static void dialogs_preferences_pages_todoist_setup_handle_oauth_callback (DialogsPreferencesPagesTodoistSetup* self,
                                                                    const gchar* uri);
static void __lambda303_ (DialogsPreferencesPagesTodoistSetup* self,
                   GObject* obj,
                   GAsyncResult* res);
VALA_EXTERN AdwPreferencesDialog* dialogs_preferences_pages_base_page_get_preferences_dialog (DialogsPreferencesPagesBasePage* self);
static void dialogs_preferences_pages_todoist_setup_verify_response (DialogsPreferencesPagesTodoistSetup* self,
                                                              HttpResponse* response);
static void ___lambda303__gasync_ready_callback (GObject* source_object,
                                          GAsyncResult* res,
                                          gpointer self);
static void __lambda299_ (DialogsPreferencesPagesTodoistSetup* self,
                   GObject* obj,
                   GAsyncResult* res);
static void ___lambda299__gasync_ready_callback (GObject* source_object,
                                          GAsyncResult* res,
                                          gpointer self);
VALA_EXTERN DialogsPreferencesPagesAccounts* dialogs_preferences_pages_todoist_setup_get_accounts_page (DialogsPreferencesPagesTodoistSetup* self);
VALA_EXTERN void dialogs_preferences_pages_accounts_show_message_error (DialogsPreferencesPagesAccounts* self,
                                                            gint error_code,
                                                            const gchar* error_message,
                                                            gboolean visible_issue_button);
VALA_EXTERN void dialogs_preferences_pages_todoist_setup_set_migrate_mode (DialogsPreferencesPagesTodoistSetup* self,
                                                               ObjectsSource* source);
static void dialogs_preferences_pages_todoist_setup_set_accounts_page (DialogsPreferencesPagesTodoistSetup* self,
                                                                DialogsPreferencesPagesAccounts* value);
static GObject * dialogs_preferences_pages_todoist_setup_constructor (GType type,
                                                               guint n_construct_properties,
                                                               GObjectConstructParam * construct_properties);
VALA_EXTERN GtkWidget* dialogs_preferences_pages_accounts_build_sync_page (DialogsPreferencesPagesAccounts* self);
static void _dialogs_preferences_pages_todoist_setup___lambda304_ (DialogsPreferencesPagesTodoistSetup* self,
                                                            const gchar* uri);
static void __dialogs_preferences_pages_todoist_setup___lambda304__services_event_bus_oauth_callback (ServicesEventBus* _sender,
                                                                                               const gchar* uri,
                                                                                               gpointer self);
static void _dialogs_preferences_pages_todoist_setup___lambda305_ (DialogsPreferencesPagesTodoistSetup* self);
VALA_EXTERN void dialogs_preferences_pages_base_page_clean_up (DialogsPreferencesPagesBasePage* self);
static void __dialogs_preferences_pages_todoist_setup___lambda305__gtk_widget_destroy (GtkWidget* _sender,
                                                                                gpointer self);
static void dialogs_preferences_pages_todoist_setup_finalize (GObject * obj);
static GType dialogs_preferences_pages_todoist_setup_get_type_once (void);
static void _vala_dialogs_preferences_pages_todoist_setup_get_property (GObject * object,
                                                                 guint property_id,
                                                                 GValue * value,
                                                                 GParamSpec * pspec);
static void _vala_dialogs_preferences_pages_todoist_setup_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 gssize _vala_array_length (gpointer array);

static inline gpointer
dialogs_preferences_pages_todoist_setup_get_instance_private (DialogsPreferencesPagesTodoistSetup* self)
{
	return G_STRUCT_MEMBER_P (self, DialogsPreferencesPagesTodoistSetup_private_offset);
}

DialogsPreferencesPagesTodoistSetup*
dialogs_preferences_pages_todoist_setup_construct (GType object_type,
                                                   AdwPreferencesDialog* preferences_dialog,
                                                   DialogsPreferencesPagesAccounts* accounts_page)
{
	DialogsPreferencesPagesTodoistSetup * self = NULL;
	g_return_val_if_fail (preferences_dialog != NULL, NULL);
	g_return_val_if_fail (accounts_page != NULL, NULL);
	self = (DialogsPreferencesPagesTodoistSetup*) g_object_new (object_type, "preferences-dialog", preferences_dialog, "accounts-page", accounts_page, "title", _ ("Todoist"), NULL);
	return self;
}

DialogsPreferencesPagesTodoistSetup*
dialogs_preferences_pages_todoist_setup_new (AdwPreferencesDialog* preferences_dialog,
                                             DialogsPreferencesPagesAccounts* accounts_page)
{
	return dialogs_preferences_pages_todoist_setup_construct (DIALOGS_PREFERENCES_PAGES_TYPE_TODOIST_SETUP, preferences_dialog, accounts_page);
}

static void
__lambda294_ (DialogsPreferencesPagesTodoistSetup* self)
{
	dialogs_preferences_pages_todoist_setup_start_oauth_flow (self);
}

static void
___lambda294__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda294_ ((DialogsPreferencesPagesTodoistSetup*) self);
}

static void
__lambda295_ (DialogsPreferencesPagesTodoistSetup* self)
{
	dialogs_preferences_pages_todoist_setup_cancel_oauth_flow (self);
}

static void
___lambda295__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda295_ ((DialogsPreferencesPagesTodoistSetup*) self);
}

static void
__lambda296_ (DialogsPreferencesPagesTodoistSetup* self)
{
	GtkStack* _tmp0_;
	_tmp0_ = self->priv->stack;
	gtk_stack_set_visible_child_name (_tmp0_, "token");
}

static void
___lambda296__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda296_ ((DialogsPreferencesPagesTodoistSetup*) self);
}

static GtkWidget*
dialogs_preferences_pages_todoist_setup_build_main_page (DialogsPreferencesPagesTodoistSetup* self)
{
	GtkImage* icon = NULL;
	GtkImage* _tmp0_ = NULL;
	GtkLabel* title_label = NULL;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar** _tmp3_;
	GtkLabel* _tmp4_ = NULL;
	GtkLabel* description_label = NULL;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar** _tmp7_;
	GtkLabel* _tmp8_ = NULL;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar** _tmp11_;
	WidgetsLoadingButton* _tmp12_ = NULL;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gchar** _tmp15_;
	GtkButton* _tmp16_ = NULL;
	GtkButton* token_button = NULL;
	gchar* _tmp17_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	gchar** _tmp20_;
	GtkButton* _tmp21_ = NULL;
	GtkBox* content_box = NULL;
	GtkBox* _tmp22_ = NULL;
	WidgetsLoadingButton* _tmp23_;
	GtkButton* _tmp24_;
	GeeHashMap* _tmp25_;
	WidgetsLoadingButton* _tmp26_;
	gulong _tmp27_;
	WidgetsLoadingButton* _tmp28_;
	GeeHashMap* _tmp29_;
	GtkButton* _tmp30_;
	gulong _tmp31_;
	GtkButton* _tmp32_;
	GeeHashMap* _tmp33_;
	gulong _tmp34_;
	GtkWidget* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = (GtkImage*) gtk_image_new_from_icon_name ("todoist");
	gtk_image_set_pixel_size (_tmp0_, 64);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp0_, 6);
	g_object_ref_sink (_tmp0_);
	icon = _tmp0_;
	_tmp1_ = g_strdup ("font-bold");
	_tmp2_ = g_strdup ("title-2");
	_tmp3_ = g_new0 (gchar*, 2 + 1);
	_tmp3_[0] = _tmp1_;
	_tmp3_[1] = _tmp2_;
	_tmp4_ = (GtkLabel*) gtk_label_new (_ ("Connect to Todoist"));
	gtk_widget_set_css_classes ((GtkWidget*) _tmp4_, _tmp3_);
	_tmp3_ = (_vala_array_free (_tmp3_, 2, (GDestroyNotify) g_free), NULL);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp4_, 24);
	g_object_ref_sink (_tmp4_);
	title_label = _tmp4_;
	_tmp5_ = g_strdup ("dimmed");
	_tmp6_ = g_strdup ("caption");
	_tmp7_ = g_new0 (gchar*, 2 + 1);
	_tmp7_[0] = _tmp5_;
	_tmp7_[1] = _tmp6_;
	_tmp8_ = (GtkLabel*) gtk_label_new (_ ("Sign in with your Todoist account to sync your tasks"));
	gtk_widget_set_css_classes ((GtkWidget*) _tmp8_, _tmp7_);
	_tmp7_ = (_vala_array_free (_tmp7_, 2, (GDestroyNotify) g_free), NULL);
	gtk_label_set_wrap (_tmp8_, TRUE);
	gtk_label_set_justify (_tmp8_, GTK_JUSTIFY_CENTER);
	gtk_label_set_max_width_chars (_tmp8_, 40);
	g_object_ref_sink (_tmp8_);
	description_label = _tmp8_;
	_tmp9_ = g_strdup ("suggested-action");
	_tmp10_ = g_strdup ("pill");
	_tmp11_ = g_new0 (gchar*, 2 + 1);
	_tmp11_[0] = _tmp9_;
	_tmp11_[1] = _tmp10_;
	_tmp12_ = widgets_loading_button_new_with_label (_ ("Sign in with Browser"));
	gtk_widget_set_css_classes ((GtkWidget*) _tmp12_, _tmp11_);
	_tmp11_ = (_vala_array_free (_tmp11_, 2, (GDestroyNotify) g_free), NULL);
	gtk_widget_set_halign ((GtkWidget*) _tmp12_, GTK_ALIGN_CENTER);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp12_, 12);
	g_object_ref_sink (_tmp12_);
	_g_object_unref0 (self->priv->oauth_button);
	self->priv->oauth_button = _tmp12_;
	_tmp13_ = g_strdup ("flat");
	_tmp14_ = g_strdup ("pill");
	_tmp15_ = g_new0 (gchar*, 2 + 1);
	_tmp15_[0] = _tmp13_;
	_tmp15_[1] = _tmp14_;
	_tmp16_ = (GtkButton*) gtk_button_new_with_label (_ ("Cancel"));
	gtk_widget_set_css_classes ((GtkWidget*) _tmp16_, _tmp15_);
	_tmp15_ = (_vala_array_free (_tmp15_, 2, (GDestroyNotify) g_free), NULL);
	gtk_widget_set_halign ((GtkWidget*) _tmp16_, GTK_ALIGN_CENTER);
	gtk_widget_set_visible ((GtkWidget*) _tmp16_, FALSE);
	g_object_ref_sink (_tmp16_);
	_g_object_unref0 (self->priv->cancel_button);
	self->priv->cancel_button = _tmp16_;
	_tmp17_ = g_strdup ("flat");
	_tmp18_ = g_strdup ("caption");
	_tmp19_ = g_strdup ("accent");
	_tmp20_ = g_new0 (gchar*, 3 + 1);
	_tmp20_[0] = _tmp17_;
	_tmp20_[1] = _tmp18_;
	_tmp20_[2] = _tmp19_;
	_tmp21_ = (GtkButton*) gtk_button_new_with_label (_ ("Use API Token instead"));
	gtk_widget_set_css_classes ((GtkWidget*) _tmp21_, _tmp20_);
	_tmp20_ = (_vala_array_free (_tmp20_, 3, (GDestroyNotify) g_free), NULL);
	gtk_widget_set_halign ((GtkWidget*) _tmp21_, GTK_ALIGN_CENTER);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp21_, 6);
	g_object_ref_sink (_tmp21_);
	token_button = _tmp21_;
	_tmp22_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
	gtk_widget_set_vexpand ((GtkWidget*) _tmp22_, TRUE);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp22_, TRUE);
	gtk_widget_set_valign ((GtkWidget*) _tmp22_, GTK_ALIGN_CENTER);
	gtk_widget_set_halign ((GtkWidget*) _tmp22_, GTK_ALIGN_CENTER);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp22_, 32);
	g_object_ref_sink (_tmp22_);
	content_box = _tmp22_;
	gtk_box_append (content_box, (GtkWidget*) icon);
	gtk_box_append (content_box, (GtkWidget*) title_label);
	gtk_box_append (content_box, (GtkWidget*) description_label);
	_tmp23_ = self->priv->oauth_button;
	gtk_box_append (content_box, (GtkWidget*) _tmp23_);
	_tmp24_ = self->priv->cancel_button;
	gtk_box_append (content_box, (GtkWidget*) _tmp24_);
	gtk_box_append (content_box, (GtkWidget*) token_button);
	_tmp25_ = ((DialogsPreferencesPagesBasePage*) self)->signal_map;
	_tmp26_ = self->priv->oauth_button;
	_tmp27_ = g_signal_connect_object ((GtkButton*) _tmp26_, "clicked", (GCallback) ___lambda294__gtk_button_clicked, self, 0);
	_tmp28_ = self->priv->oauth_button;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp25_, (gpointer) ((guintptr) _tmp27_), (GObject*) _tmp28_);
	_tmp29_ = ((DialogsPreferencesPagesBasePage*) self)->signal_map;
	_tmp30_ = self->priv->cancel_button;
	_tmp31_ = g_signal_connect_object (_tmp30_, "clicked", (GCallback) ___lambda295__gtk_button_clicked, self, 0);
	_tmp32_ = self->priv->cancel_button;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp29_, (gpointer) ((guintptr) _tmp31_), (GObject*) _tmp32_);
	_tmp33_ = ((DialogsPreferencesPagesBasePage*) self)->signal_map;
	_tmp34_ = g_signal_connect_object (token_button, "clicked", (GCallback) ___lambda296__gtk_button_clicked, self, 0);
	gee_abstract_map_set ((GeeAbstractMap*) _tmp33_, (gpointer) ((guintptr) _tmp34_), (GObject*) token_button);
	result = (GtkWidget*) content_box;
	_g_object_unref0 (token_button);
	_g_object_unref0 (description_label);
	_g_object_unref0 (title_label);
	_g_object_unref0 (icon);
	return result;
}

static void
__lambda297_ (DialogsPreferencesPagesTodoistSetup* self)
{
	gboolean _tmp0_ = FALSE;
	AdwEntryRow* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	WidgetsLoadingButton* _tmp7_;
	_tmp1_ = self->priv->token_entry;
	_tmp2_ = gtk_editable_get_text ((GtkEditable*) _tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_ != NULL) {
		AdwEntryRow* _tmp4_;
		const gchar* _tmp5_;
		const gchar* _tmp6_;
		_tmp4_ = self->priv->token_entry;
		_tmp5_ = gtk_editable_get_text ((GtkEditable*) _tmp4_);
		_tmp6_ = _tmp5_;
		_tmp0_ = g_strcmp0 (_tmp6_, "") != 0;
	} else {
		_tmp0_ = FALSE;
	}
	_tmp7_ = self->priv->login_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp7_, _tmp0_);
}

static void
___lambda297__gtk_editable_changed (GtkEditable* _sender,
                                    gpointer self)
{
	__lambda297_ ((DialogsPreferencesPagesTodoistSetup*) self);
}

static void
__lambda298_ (DialogsPreferencesPagesTodoistSetup* self)
{
	dialogs_preferences_pages_todoist_setup_on_token_login_clicked (self);
}

static void
___lambda298__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda298_ ((DialogsPreferencesPagesTodoistSetup*) self);
}

static GtkWidget*
dialogs_preferences_pages_todoist_setup_build_token_page (DialogsPreferencesPagesTodoistSetup* self)
{
	GtkImage* icon = NULL;
	gchar* _tmp0_;
	gchar** _tmp1_;
	GtkImage* _tmp2_ = NULL;
	GtkLabel* title_label = NULL;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar** _tmp5_;
	GtkLabel* _tmp6_ = NULL;
	GtkLabel* description_label = NULL;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar** _tmp9_;
	GtkLabel* _tmp10_ = NULL;
	GtkBox* header_box = NULL;
	GtkBox* _tmp11_ = NULL;
	AdwEntryRow* _tmp12_;
	AdwEntryRow* _tmp13_;
	AdwPreferencesGroup* entries_group = NULL;
	AdwPreferencesGroup* _tmp14_;
	AdwEntryRow* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	gchar** _tmp18_;
	WidgetsLoadingButton* _tmp19_ = NULL;
	GtkLabel* step1_label = NULL;
	GtkLabel* _tmp20_ = NULL;
	GtkLabel* step2_label = NULL;
	GtkLabel* _tmp21_ = NULL;
	GtkLabel* step3_label = NULL;
	GtkLabel* _tmp22_ = NULL;
	GtkBox* steps_box = NULL;
	GtkBox* _tmp23_ = NULL;
	AdwPreferencesGroup* instructions_group = NULL;
	AdwPreferencesGroup* _tmp24_ = NULL;
	GtkBox* content_box = NULL;
	GtkBox* _tmp25_ = NULL;
	WidgetsLoadingButton* _tmp26_;
	GeeHashMap* _tmp27_;
	AdwEntryRow* _tmp28_;
	gulong _tmp29_;
	AdwEntryRow* _tmp30_;
	GeeHashMap* _tmp31_;
	WidgetsLoadingButton* _tmp32_;
	gulong _tmp33_;
	WidgetsLoadingButton* _tmp34_;
	GtkWidget* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup ("dimmed");
	_tmp1_ = g_new0 (gchar*, 1 + 1);
	_tmp1_[0] = _tmp0_;
	_tmp2_ = (GtkImage*) gtk_image_new_from_icon_name ("key4-symbolic");
	gtk_image_set_pixel_size (_tmp2_, 48);
	gtk_widget_set_css_classes ((GtkWidget*) _tmp2_, _tmp1_);
	_tmp1_ = (_vala_array_free (_tmp1_, 1, (GDestroyNotify) g_free), NULL);
	g_object_ref_sink (_tmp2_);
	icon = _tmp2_;
	_tmp3_ = g_strdup ("font-bold");
	_tmp4_ = g_strdup ("title-3");
	_tmp5_ = g_new0 (gchar*, 2 + 1);
	_tmp5_[0] = _tmp3_;
	_tmp5_[1] = _tmp4_;
	_tmp6_ = (GtkLabel*) gtk_label_new (_ ("API Token"));
	gtk_widget_set_css_classes ((GtkWidget*) _tmp6_, _tmp5_);
	_tmp5_ = (_vala_array_free (_tmp5_, 2, (GDestroyNotify) g_free), NULL);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp6_, 12);
	g_object_ref_sink (_tmp6_);
	title_label = _tmp6_;
	_tmp7_ = g_strdup ("dimmed");
	_tmp8_ = g_strdup ("caption");
	_tmp9_ = g_new0 (gchar*, 2 + 1);
	_tmp9_[0] = _tmp7_;
	_tmp9_[1] = _tmp8_;
	_tmp10_ = (GtkLabel*) gtk_label_new (_ ("Connect using your personal Todoist API token"));
	gtk_widget_set_css_classes ((GtkWidget*) _tmp10_, _tmp9_);
	_tmp9_ = (_vala_array_free (_tmp9_, 2, (GDestroyNotify) g_free), NULL);
	gtk_label_set_wrap (_tmp10_, TRUE);
	gtk_label_set_justify (_tmp10_, GTK_JUSTIFY_CENTER);
	gtk_label_set_max_width_chars (_tmp10_, 40);
	g_object_ref_sink (_tmp10_);
	description_label = _tmp10_;
	_tmp11_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
	gtk_widget_set_halign ((GtkWidget*) _tmp11_, GTK_ALIGN_CENTER);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp11_, 18);
	g_object_ref_sink (_tmp11_);
	header_box = _tmp11_;
	gtk_box_append (header_box, (GtkWidget*) icon);
	gtk_box_append (header_box, (GtkWidget*) title_label);
	gtk_box_append (header_box, (GtkWidget*) description_label);
	_tmp12_ = (AdwEntryRow*) adw_entry_row_new ();
	g_object_ref_sink (_tmp12_);
	_g_object_unref0 (self->priv->token_entry);
	self->priv->token_entry = _tmp12_;
	_tmp13_ = self->priv->token_entry;
	adw_preferences_row_set_title ((AdwPreferencesRow*) _tmp13_, _ ("Paste your API token"));
	_tmp14_ = (AdwPreferencesGroup*) adw_preferences_group_new ();
	g_object_ref_sink (_tmp14_);
	entries_group = _tmp14_;
	_tmp15_ = self->priv->token_entry;
	adw_preferences_group_add (entries_group, (GtkWidget*) _tmp15_);
	_tmp16_ = g_strdup ("suggested-action");
	_tmp17_ = g_strdup ("pill");
	_tmp18_ = g_new0 (gchar*, 2 + 1);
	_tmp18_[0] = _tmp16_;
	_tmp18_[1] = _tmp17_;
	_tmp19_ = widgets_loading_button_new_with_label (_ ("Connect"));
	gtk_widget_set_margin_top ((GtkWidget*) _tmp19_, 16);
	gtk_widget_set_sensitive ((GtkWidget*) _tmp19_, FALSE);
	gtk_widget_set_css_classes ((GtkWidget*) _tmp19_, _tmp18_);
	_tmp18_ = (_vala_array_free (_tmp18_, 2, (GDestroyNotify) g_free), NULL);
	gtk_widget_set_halign ((GtkWidget*) _tmp19_, GTK_ALIGN_CENTER);
	g_object_ref_sink (_tmp19_);
	_g_object_unref0 (self->priv->login_button);
	self->priv->login_button = _tmp19_;
	_tmp20_ = (GtkLabel*) gtk_label_new (_ ("1. Go to Todoist → Settings → Integrations → Developer"));
	gtk_label_set_wrap (_tmp20_, TRUE);
	gtk_label_set_xalign (_tmp20_, (gfloat) 0);
	g_object_ref_sink (_tmp20_);
	step1_label = _tmp20_;
	_tmp21_ = (GtkLabel*) gtk_label_new (_ ("2. Copy your API token"));
	gtk_label_set_wrap (_tmp21_, TRUE);
	gtk_label_set_xalign (_tmp21_, (gfloat) 0);
	g_object_ref_sink (_tmp21_);
	step2_label = _tmp21_;
	_tmp22_ = (GtkLabel*) gtk_label_new (_ ("3. Paste it in the field above"));
	gtk_label_set_wrap (_tmp22_, TRUE);
	gtk_label_set_xalign (_tmp22_, (gfloat) 0);
	g_object_ref_sink (_tmp22_);
	step3_label = _tmp22_;
	_tmp23_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp23_, 8);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp23_, 8);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp23_, 12);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp23_, 12);
	g_object_ref_sink (_tmp23_);
	steps_box = _tmp23_;
	gtk_box_append (steps_box, (GtkWidget*) step1_label);
	gtk_box_append (steps_box, (GtkWidget*) step2_label);
	gtk_box_append (steps_box, (GtkWidget*) step3_label);
	_tmp24_ = (AdwPreferencesGroup*) adw_preferences_group_new ();
	gtk_widget_set_margin_top ((GtkWidget*) _tmp24_, 18);
	g_object_ref_sink (_tmp24_);
	instructions_group = _tmp24_;
	adw_preferences_group_set_title (instructions_group, _ ("How to get your token"));
	adw_preferences_group_add (instructions_group, (GtkWidget*) steps_box);
	_tmp25_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	gtk_widget_set_vexpand ((GtkWidget*) _tmp25_, TRUE);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp25_, TRUE);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp25_, 12);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp25_, 12);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp25_, 24);
	g_object_ref_sink (_tmp25_);
	content_box = _tmp25_;
	gtk_box_append (content_box, (GtkWidget*) header_box);
	gtk_box_append (content_box, (GtkWidget*) entries_group);
	_tmp26_ = self->priv->login_button;
	gtk_box_append (content_box, (GtkWidget*) _tmp26_);
	gtk_box_append (content_box, (GtkWidget*) instructions_group);
	_tmp27_ = ((DialogsPreferencesPagesBasePage*) self)->signal_map;
	_tmp28_ = self->priv->token_entry;
	_tmp29_ = g_signal_connect_object ((GtkEditable*) _tmp28_, "changed", (GCallback) ___lambda297__gtk_editable_changed, self, 0);
	_tmp30_ = self->priv->token_entry;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp27_, (gpointer) ((guintptr) _tmp29_), (GObject*) _tmp30_);
	_tmp31_ = ((DialogsPreferencesPagesBasePage*) self)->signal_map;
	_tmp32_ = self->priv->login_button;
	_tmp33_ = g_signal_connect_object ((GtkButton*) _tmp32_, "clicked", (GCallback) ___lambda298__gtk_button_clicked, self, 0);
	_tmp34_ = self->priv->login_button;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp31_, (gpointer) ((guintptr) _tmp33_), (GObject*) _tmp34_);
	result = (GtkWidget*) content_box;
	_g_object_unref0 (instructions_group);
	_g_object_unref0 (steps_box);
	_g_object_unref0 (step3_label);
	_g_object_unref0 (step2_label);
	_g_object_unref0 (step1_label);
	_g_object_unref0 (entries_group);
	_g_object_unref0 (header_box);
	_g_object_unref0 (description_label);
	_g_object_unref0 (title_label);
	_g_object_unref0 (icon);
	return result;
}

static void
dialogs_preferences_pages_todoist_setup_start_oauth_flow (DialogsPreferencesPagesTodoistSetup* self)
{
	Util* _tmp0_;
	Util* _tmp1_;
	gchar* _tmp2_;
	gchar* oauth_url = NULL;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	WidgetsLoadingButton* _tmp5_;
	WidgetsLoadingButton* _tmp6_;
	GtkButton* _tmp7_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = util_get_default ();
	_tmp1_ = _tmp0_;
	_tmp2_ = util_generate_string (_tmp1_);
	_g_free0 (self->priv->oauth_state);
	self->priv->oauth_state = _tmp2_;
	_g_object_unref0 (_tmp1_);
	_tmp3_ = self->priv->oauth_state;
	_tmp4_ = g_strdup_printf ("https://todoist.com/oauth/authorize?client_id=%s&scope=%s&state=%s&red" \
"irect_uri=%s", CONSTANTS_TODOIST_CLIENT_ID, CONSTANTS_TODOIST_SCOPE, _tmp3_, CONSTANTS_TODOIST_REDIRECT_URI);
	oauth_url = _tmp4_;
	_tmp5_ = self->priv->oauth_button;
	widgets_loading_button_set_is_loading (_tmp5_, TRUE);
	_tmp6_ = self->priv->oauth_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp6_, FALSE);
	_tmp7_ = self->priv->cancel_button;
	gtk_widget_set_visible ((GtkWidget*) _tmp7_, TRUE);
	adw_navigation_page_set_title ((AdwNavigationPage*) self, _ ("Waiting for login…"));
	{
		g_app_info_launch_default_for_uri (oauth_url, NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp8_;
		const gchar* _tmp9_;
		WidgetsLoadingButton* _tmp10_;
		GtkButton* _tmp11_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp8_ = e;
		_tmp9_ = _tmp8_->message;
		g_warning ("TodoistSetup.vala:260: Error opening browser: %s", _tmp9_);
		_tmp10_ = self->priv->oauth_button;
		widgets_loading_button_set_is_loading (_tmp10_, FALSE);
		_tmp11_ = self->priv->cancel_button;
		gtk_widget_set_visible ((GtkWidget*) _tmp11_, FALSE);
		adw_navigation_page_set_title ((AdwNavigationPage*) self, _ ("Todoist"));
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (oauth_url);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
	_g_free0 (oauth_url);
}

static void
dialogs_preferences_pages_todoist_setup_cancel_oauth_flow (DialogsPreferencesPagesTodoistSetup* self)
{
	WidgetsLoadingButton* _tmp0_;
	WidgetsLoadingButton* _tmp1_;
	GtkButton* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->oauth_button;
	widgets_loading_button_set_is_loading (_tmp0_, FALSE);
	_tmp1_ = self->priv->oauth_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp1_, TRUE);
	_tmp2_ = self->priv->cancel_button;
	gtk_widget_set_visible ((GtkWidget*) _tmp2_, FALSE);
	adw_navigation_page_set_title ((AdwNavigationPage*) self, _ ("Todoist"));
}

static gchar*
string_replace (const gchar* self,
                const gchar* old,
                const gchar* replacement)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (old != NULL, NULL);
	g_return_val_if_fail (replacement != NULL, NULL);
	if ((*((gchar*) self)) == '\0') {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = (*((gchar*) old)) == '\0';
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = g_strcmp0 (old, replacement) == 0;
	}
	if (_tmp0_) {
		gchar* _tmp2_;
		_tmp2_ = g_strdup (self);
		result = _tmp2_;
		return result;
	}
	{
		GRegex* regex = NULL;
		gchar* _tmp3_;
		gchar* _tmp4_;
		GRegex* _tmp5_;
		GRegex* _tmp6_;
		gchar* _tmp7_ = NULL;
		GRegex* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		_tmp3_ = g_regex_escape_string (old, -1);
		_tmp4_ = _tmp3_;
		_tmp5_ = g_regex_new (_tmp4_, 0, 0, &_inner_error0_);
		_tmp6_ = _tmp5_;
		_g_free0 (_tmp4_);
		regex = _tmp6_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
		_tmp8_ = regex;
		_tmp9_ = g_regex_replace_literal (_tmp8_, self, (gssize) -1, 0, replacement, 0, &_inner_error0_);
		_tmp7_ = _tmp9_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_regex_unref0 (regex);
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
		_tmp10_ = _tmp7_;
		_tmp7_ = NULL;
		result = _tmp10_;
		_g_free0 (_tmp7_);
		_g_regex_unref0 (regex);
		return result;
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		g_clear_error (&_inner_error0_);
		g_assert_not_reached ();
	}
	__finally0:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
	g_clear_error (&_inner_error0_);
	return NULL;
}

static void
__lambda303_ (DialogsPreferencesPagesTodoistSetup* self,
              GObject* obj,
              GAsyncResult* res)
{
	HttpResponse* response = NULL;
	ServicesTodoist* _tmp0_;
	ServicesTodoist* _tmp1_;
	HttpResponse* _tmp2_;
	HttpResponse* _tmp3_;
	AdwPreferencesDialog* _tmp4_;
	AdwPreferencesDialog* _tmp5_;
	g_return_if_fail (res != NULL);
	_tmp0_ = services_todoist_get_default ();
	_tmp1_ = _tmp0_;
	_tmp2_ = services_todoist_login_finish (_tmp1_, res);
	_tmp3_ = _tmp2_;
	_g_object_unref0 (_tmp1_);
	response = _tmp3_;
	_tmp4_ = dialogs_preferences_pages_base_page_get_preferences_dialog ((DialogsPreferencesPagesBasePage*) self);
	_tmp5_ = _tmp4_;
	adw_preferences_dialog_pop_subpage (_tmp5_);
	dialogs_preferences_pages_todoist_setup_verify_response (self, response);
	_http_response_unref0 (response);
}

static void
___lambda303__gasync_ready_callback (GObject* source_object,
                                     GAsyncResult* res,
                                     gpointer self)
{
	__lambda303_ ((DialogsPreferencesPagesTodoistSetup*) self, source_object, res);
	g_object_unref (self);
}

static void
dialogs_preferences_pages_todoist_setup_handle_oauth_callback (DialogsPreferencesPagesTodoistSetup* self,
                                                               const gchar* uri)
{
	gchar** parts = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar** _tmp2_;
	gchar** _tmp3_;
	gchar** _tmp4_;
	gint _tmp4__length1;
	gint parts_length1;
	gint _parts_size_;
	const gchar* _tmp5_ = NULL;
	gchar** _tmp6_;
	gint _tmp6__length1;
	gchar* query = NULL;
	gchar* _tmp9_;
	gchar* code = NULL;
	gchar* _tmp10_;
	const gchar* _tmp11_;
	gchar** _tmp12_;
	gchar** _tmp13_;
	const gchar* _tmp25_;
	GtkStack* _tmp27_;
	ServicesTodoist* _tmp28_;
	ServicesTodoist* _tmp29_;
	const gchar* _tmp30_;
	gchar* _tmp31_;
	gchar* _tmp32_;
	ObjectsSource* _tmp33_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (uri != NULL);
	_tmp0_ = string_replace (uri, "planify://", "");
	_tmp1_ = _tmp0_;
	_tmp3_ = _tmp2_ = g_strsplit (_tmp1_, "?", 2);
	_tmp4_ = _tmp3_;
	_tmp4__length1 = _vala_array_length (_tmp2_);
	_g_free0 (_tmp1_);
	parts = _tmp4_;
	parts_length1 = _tmp4__length1;
	_parts_size_ = parts_length1;
	_tmp6_ = parts;
	_tmp6__length1 = parts_length1;
	if (_tmp6__length1 > 1) {
		gchar** _tmp7_;
		gint _tmp7__length1;
		const gchar* _tmp8_;
		_tmp7_ = parts;
		_tmp7__length1 = parts_length1;
		_tmp8_ = _tmp7_[1];
		_tmp5_ = _tmp8_;
	} else {
		_tmp5_ = "";
	}
	_tmp9_ = g_strdup (_tmp5_);
	query = _tmp9_;
	_tmp10_ = g_strdup ("");
	code = _tmp10_;
	_tmp11_ = query;
	_tmp13_ = _tmp12_ = g_strsplit (_tmp11_, "&", 0);
	{
		gchar** param_collection = NULL;
		gint param_collection_length1 = 0;
		gint _param_collection_size_ = 0;
		gint param_it = 0;
		param_collection = _tmp13_;
		param_collection_length1 = _vala_array_length (_tmp12_);
		for (param_it = 0; param_it < param_collection_length1; param_it = param_it + 1) {
			gchar* _tmp14_;
			gchar* param = NULL;
			_tmp14_ = g_strdup (param_collection[param_it]);
			param = _tmp14_;
			{
				gchar** kv = NULL;
				const gchar* _tmp15_;
				gchar** _tmp16_;
				gchar** _tmp17_;
				gint kv_length1;
				gint _kv_size_;
				gboolean _tmp18_ = FALSE;
				gchar** _tmp19_;
				gint _tmp19__length1;
				_tmp15_ = param;
				_tmp17_ = _tmp16_ = g_strsplit (_tmp15_, "=", 2);
				kv = _tmp17_;
				kv_length1 = _vala_array_length (_tmp16_);
				_kv_size_ = kv_length1;
				_tmp19_ = kv;
				_tmp19__length1 = kv_length1;
				if (_tmp19__length1 == 2) {
					gchar** _tmp20_;
					gint _tmp20__length1;
					const gchar* _tmp21_;
					_tmp20_ = kv;
					_tmp20__length1 = kv_length1;
					_tmp21_ = _tmp20_[0];
					_tmp18_ = g_strcmp0 (_tmp21_, "code") == 0;
				} else {
					_tmp18_ = FALSE;
				}
				if (_tmp18_) {
					gchar** _tmp22_;
					gint _tmp22__length1;
					const gchar* _tmp23_;
					gchar* _tmp24_;
					_tmp22_ = kv;
					_tmp22__length1 = kv_length1;
					_tmp23_ = _tmp22_[1];
					_tmp24_ = g_strdup (_tmp23_);
					_g_free0 (code);
					code = _tmp24_;
				}
				kv = (_vala_array_free (kv, kv_length1, (GDestroyNotify) g_free), NULL);
				_g_free0 (param);
			}
		}
		param_collection = (_vala_array_free (param_collection, param_collection_length1, (GDestroyNotify) g_free), NULL);
	}
	_tmp25_ = code;
	if (g_strcmp0 (_tmp25_, "") == 0) {
		WidgetsLoadingButton* _tmp26_;
		_tmp26_ = self->priv->oauth_button;
		widgets_loading_button_set_is_loading (_tmp26_, FALSE);
		adw_navigation_page_set_title ((AdwNavigationPage*) self, _ ("Todoist"));
		_g_free0 (code);
		_g_free0 (query);
		parts = (_vala_array_free (parts, parts_length1, (GDestroyNotify) g_free), NULL);
		return;
	}
	adw_navigation_page_set_title ((AdwNavigationPage*) self, _ ("Synchronizing…"));
	_tmp27_ = self->priv->stack;
	gtk_stack_set_visible_child_name (_tmp27_, "loading");
	_tmp28_ = services_todoist_get_default ();
	_tmp29_ = _tmp28_;
	_tmp30_ = code;
	_tmp31_ = g_strdup_printf ("%s?code=%s", CONSTANTS_TODOIST_REDIRECT_URI, _tmp30_);
	_tmp32_ = _tmp31_;
	_tmp33_ = self->priv->migrate_source;
	services_todoist_login (_tmp29_, _tmp32_, _tmp33_, ___lambda303__gasync_ready_callback, g_object_ref (self));
	_g_free0 (_tmp32_);
	_g_object_unref0 (_tmp29_);
	_g_free0 (code);
	_g_free0 (query);
	parts = (_vala_array_free (parts, parts_length1, (GDestroyNotify) g_free), NULL);
}

static void
__lambda299_ (DialogsPreferencesPagesTodoistSetup* self,
              GObject* obj,
              GAsyncResult* res)
{
	HttpResponse* response = NULL;
	ServicesTodoist* _tmp0_;
	ServicesTodoist* _tmp1_;
	HttpResponse* _tmp2_;
	HttpResponse* _tmp3_;
	AdwPreferencesDialog* _tmp4_;
	AdwPreferencesDialog* _tmp5_;
	g_return_if_fail (res != NULL);
	_tmp0_ = services_todoist_get_default ();
	_tmp1_ = _tmp0_;
	_tmp2_ = services_todoist_login_token_finish (_tmp1_, res);
	_tmp3_ = _tmp2_;
	_g_object_unref0 (_tmp1_);
	response = _tmp3_;
	_tmp4_ = dialogs_preferences_pages_base_page_get_preferences_dialog ((DialogsPreferencesPagesBasePage*) self);
	_tmp5_ = _tmp4_;
	adw_preferences_dialog_pop_subpage (_tmp5_);
	dialogs_preferences_pages_todoist_setup_verify_response (self, response);
	_http_response_unref0 (response);
}

static void
___lambda299__gasync_ready_callback (GObject* source_object,
                                     GAsyncResult* res,
                                     gpointer self)
{
	__lambda299_ ((DialogsPreferencesPagesTodoistSetup*) self, source_object, res);
	g_object_unref (self);
}

static void
dialogs_preferences_pages_todoist_setup_on_token_login_clicked (DialogsPreferencesPagesTodoistSetup* self)
{
	GtkStack* _tmp0_;
	ServicesTodoist* _tmp1_;
	ServicesTodoist* _tmp2_;
	AdwEntryRow* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	ObjectsSource* _tmp6_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->stack;
	gtk_stack_set_visible_child_name (_tmp0_, "loading");
	_tmp1_ = services_todoist_get_default ();
	_tmp2_ = _tmp1_;
	_tmp3_ = self->priv->token_entry;
	_tmp4_ = gtk_editable_get_text ((GtkEditable*) _tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = self->priv->migrate_source;
	services_todoist_login_token (_tmp2_, _tmp5_, _tmp6_, ___lambda299__gasync_ready_callback, g_object_ref (self));
	_g_object_unref0 (_tmp2_);
}

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;
}

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

static void
dialogs_preferences_pages_todoist_setup_verify_response (DialogsPreferencesPagesTodoistSetup* self,
                                                         HttpResponse* response)
{
	gboolean _tmp0_;
	gboolean _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (response != NULL);
	_tmp0_ = http_response_get_status (response);
	_tmp1_ = _tmp0_;
	if (_tmp1_) {
		return;
	}
	_tmp2_ = http_response_get_error_code (response);
	_tmp3_ = _tmp2_;
	if (_tmp3_ != 409) {
		DialogsPreferencesPagesAccounts* _tmp4_;
		gint _tmp5_;
		gint _tmp6_;
		const gchar* _tmp7_;
		const gchar* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		_tmp4_ = self->priv->_accounts_page;
		_tmp5_ = http_response_get_error_code (response);
		_tmp6_ = _tmp5_;
		_tmp7_ = http_response_get_error (response);
		_tmp8_ = _tmp7_;
		_tmp9_ = string_strip (_tmp8_);
		_tmp10_ = _tmp9_;
		dialogs_preferences_pages_accounts_show_message_error (_tmp4_, _tmp6_, _tmp10_, TRUE);
		_g_free0 (_tmp10_);
	} else {
		AdwToast* toast = NULL;
		const gchar* _tmp11_;
		const gchar* _tmp12_;
		gchar* _tmp13_;
		gchar* _tmp14_;
		AdwToast* _tmp15_;
		AdwToast* _tmp16_;
		AdwToast* _tmp17_;
		AdwPreferencesDialog* _tmp18_;
		AdwPreferencesDialog* _tmp19_;
		AdwToast* _tmp20_;
		AdwToast* _tmp21_;
		_tmp11_ = http_response_get_error (response);
		_tmp12_ = _tmp11_;
		_tmp13_ = string_strip (_tmp12_);
		_tmp14_ = _tmp13_;
		_tmp15_ = adw_toast_new (_tmp14_);
		_tmp16_ = _tmp15_;
		_g_free0 (_tmp14_);
		toast = _tmp16_;
		_tmp17_ = toast;
		adw_toast_set_timeout (_tmp17_, (guint) 3);
		_tmp18_ = dialogs_preferences_pages_base_page_get_preferences_dialog ((DialogsPreferencesPagesBasePage*) self);
		_tmp19_ = _tmp18_;
		_tmp20_ = toast;
		_tmp21_ = _g_object_ref0 (_tmp20_);
		adw_preferences_dialog_add_toast (_tmp19_, _tmp21_);
		_g_object_unref0 (toast);
	}
}

void
dialogs_preferences_pages_todoist_setup_set_migrate_mode (DialogsPreferencesPagesTodoistSetup* self,
                                                          ObjectsSource* source)
{
	ObjectsSource* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (source != NULL);
	_tmp0_ = _g_object_ref0 (source);
	_g_object_unref0 (self->priv->migrate_source);
	self->priv->migrate_source = _tmp0_;
}

DialogsPreferencesPagesAccounts*
dialogs_preferences_pages_todoist_setup_get_accounts_page (DialogsPreferencesPagesTodoistSetup* self)
{
	DialogsPreferencesPagesAccounts* result;
	DialogsPreferencesPagesAccounts* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_accounts_page;
	result = _tmp0_;
	return result;
}

static void
dialogs_preferences_pages_todoist_setup_set_accounts_page (DialogsPreferencesPagesTodoistSetup* self,
                                                           DialogsPreferencesPagesAccounts* value)
{
	DialogsPreferencesPagesAccounts* old_value;
	g_return_if_fail (self != NULL);
	old_value = dialogs_preferences_pages_todoist_setup_get_accounts_page (self);
	if (old_value != value) {
		DialogsPreferencesPagesAccounts* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_accounts_page);
		self->priv->_accounts_page = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, dialogs_preferences_pages_todoist_setup_properties[DIALOGS_PREFERENCES_PAGES_TODOIST_SETUP_ACCOUNTS_PAGE_PROPERTY]);
	}
}

static void
_dialogs_preferences_pages_todoist_setup___lambda304_ (DialogsPreferencesPagesTodoistSetup* self,
                                                       const gchar* uri)
{
	g_return_if_fail (uri != NULL);
	dialogs_preferences_pages_todoist_setup_handle_oauth_callback (self, uri);
}

static void
__dialogs_preferences_pages_todoist_setup___lambda304__services_event_bus_oauth_callback (ServicesEventBus* _sender,
                                                                                          const gchar* uri,
                                                                                          gpointer self)
{
	_dialogs_preferences_pages_todoist_setup___lambda304_ ((DialogsPreferencesPagesTodoistSetup*) self, uri);
}

static void
_dialogs_preferences_pages_todoist_setup___lambda305_ (DialogsPreferencesPagesTodoistSetup* self)
{
	dialogs_preferences_pages_base_page_clean_up ((DialogsPreferencesPagesBasePage*) self);
}

static void
__dialogs_preferences_pages_todoist_setup___lambda305__gtk_widget_destroy (GtkWidget* _sender,
                                                                           gpointer self)
{
	_dialogs_preferences_pages_todoist_setup___lambda305_ ((DialogsPreferencesPagesTodoistSetup*) self);
}

static GObject *
dialogs_preferences_pages_todoist_setup_constructor (GType type,
                                                     guint n_construct_properties,
                                                     GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	DialogsPreferencesPagesTodoistSetup * self;
	GtkStack* _tmp0_ = NULL;
	GtkStack* _tmp1_;
	GtkWidget* _tmp2_;
	GtkWidget* _tmp3_;
	GtkStack* _tmp4_;
	GtkWidget* _tmp5_;
	GtkWidget* _tmp6_;
	GtkStack* _tmp7_;
	DialogsPreferencesPagesAccounts* _tmp8_;
	GtkWidget* _tmp9_;
	GtkWidget* _tmp10_;
	GtkStack* _tmp11_;
	GtkScrolledWindow* scrolled_window = NULL;
	GtkStack* _tmp12_;
	GtkWidget* _tmp13_;
	GtkScrolledWindow* _tmp14_ = NULL;
	AdwToolbarView* toolbar_view = NULL;
	AdwToolbarView* _tmp15_;
	AdwToolbarView* _tmp16_;
	AdwHeaderBar* _tmp17_;
	AdwHeaderBar* _tmp18_;
	AdwToolbarView* _tmp19_;
	GtkScrolledWindow* _tmp20_;
	AdwToolbarView* _tmp21_;
	GeeHashMap* _tmp22_;
	ServicesEventBus* _tmp23_;
	ServicesEventBus* _tmp24_;
	gulong _tmp25_;
	ServicesEventBus* _tmp26_;
	ServicesEventBus* _tmp27_;
	parent_class = G_OBJECT_CLASS (dialogs_preferences_pages_todoist_setup_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DIALOGS_PREFERENCES_PAGES_TYPE_TODOIST_SETUP, DialogsPreferencesPagesTodoistSetup);
	_tmp0_ = (GtkStack*) gtk_stack_new ();
	gtk_widget_set_vexpand ((GtkWidget*) _tmp0_, TRUE);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp0_, TRUE);
	gtk_stack_set_transition_type (_tmp0_, GTK_STACK_TRANSITION_TYPE_CROSSFADE);
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->stack);
	self->priv->stack = _tmp0_;
	_tmp1_ = self->priv->stack;
	_tmp2_ = dialogs_preferences_pages_todoist_setup_build_main_page (self);
	_tmp3_ = _tmp2_;
	gtk_stack_add_named (_tmp1_, _tmp3_, "main");
	_g_object_unref0 (_tmp3_);
	_tmp4_ = self->priv->stack;
	_tmp5_ = dialogs_preferences_pages_todoist_setup_build_token_page (self);
	_tmp6_ = _tmp5_;
	gtk_stack_add_named (_tmp4_, _tmp6_, "token");
	_g_object_unref0 (_tmp6_);
	_tmp7_ = self->priv->stack;
	_tmp8_ = self->priv->_accounts_page;
	_tmp9_ = dialogs_preferences_pages_accounts_build_sync_page (_tmp8_);
	_tmp10_ = _tmp9_;
	gtk_stack_add_named (_tmp7_, _tmp10_, "loading");
	_g_object_unref0 (_tmp10_);
	_tmp11_ = self->priv->stack;
	gtk_stack_set_visible_child_name (_tmp11_, "main");
	_tmp12_ = self->priv->stack;
	_tmp13_ = _g_object_ref0 ((GtkWidget*) _tmp12_);
	_tmp14_ = (GtkScrolledWindow*) gtk_scrolled_window_new ();
	gtk_widget_set_hexpand ((GtkWidget*) _tmp14_, TRUE);
	gtk_widget_set_vexpand ((GtkWidget*) _tmp14_, TRUE);
	g_object_set (_tmp14_, "hscrollbar-policy", GTK_POLICY_NEVER, NULL);
	g_object_set (_tmp14_, "vscrollbar-policy", GTK_POLICY_AUTOMATIC, NULL);
	gtk_scrolled_window_set_child (_tmp14_, _tmp13_);
	_g_object_unref0 (_tmp13_);
	g_object_ref_sink (_tmp14_);
	scrolled_window = _tmp14_;
	_tmp15_ = (AdwToolbarView*) adw_toolbar_view_new ();
	g_object_ref_sink (_tmp15_);
	toolbar_view = _tmp15_;
	_tmp16_ = toolbar_view;
	_tmp17_ = (AdwHeaderBar*) adw_header_bar_new ();
	g_object_ref_sink (_tmp17_);
	_tmp18_ = _tmp17_;
	adw_toolbar_view_add_top_bar (_tmp16_, (GtkWidget*) _tmp18_);
	_g_object_unref0 (_tmp18_);
	_tmp19_ = toolbar_view;
	_tmp20_ = scrolled_window;
	adw_toolbar_view_set_content (_tmp19_, (GtkWidget*) _tmp20_);
	_tmp21_ = toolbar_view;
	adw_navigation_page_set_child ((AdwNavigationPage*) self, (GtkWidget*) _tmp21_);
	_tmp22_ = ((DialogsPreferencesPagesBasePage*) self)->signal_map;
	_tmp23_ = services_event_bus_get_default ();
	_tmp24_ = _tmp23_;
	_tmp25_ = g_signal_connect_object (_tmp24_, "oauth-callback", (GCallback) __dialogs_preferences_pages_todoist_setup___lambda304__services_event_bus_oauth_callback, self, 0);
	_tmp26_ = services_event_bus_get_default ();
	_tmp27_ = _tmp26_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp22_, (gpointer) ((guintptr) _tmp25_), (GObject*) _tmp27_);
	_g_object_unref0 (_tmp27_);
	_g_object_unref0 (_tmp24_);
	g_signal_connect_object ((GtkWidget*) self, "destroy", (GCallback) __dialogs_preferences_pages_todoist_setup___lambda305__gtk_widget_destroy, self, 0);
	_g_object_unref0 (toolbar_view);
	_g_object_unref0 (scrolled_window);
	return obj;
}

static void
dialogs_preferences_pages_todoist_setup_class_init (DialogsPreferencesPagesTodoistSetupClass * klass,
                                                    gpointer klass_data)
{
	dialogs_preferences_pages_todoist_setup_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DialogsPreferencesPagesTodoistSetup_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_dialogs_preferences_pages_todoist_setup_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_dialogs_preferences_pages_todoist_setup_set_property;
	G_OBJECT_CLASS (klass)->constructor = dialogs_preferences_pages_todoist_setup_constructor;
	G_OBJECT_CLASS (klass)->finalize = dialogs_preferences_pages_todoist_setup_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DIALOGS_PREFERENCES_PAGES_TODOIST_SETUP_ACCOUNTS_PAGE_PROPERTY, dialogs_preferences_pages_todoist_setup_properties[DIALOGS_PREFERENCES_PAGES_TODOIST_SETUP_ACCOUNTS_PAGE_PROPERTY] = g_param_spec_object ("accounts-page", "accounts-page", "accounts-page", DIALOGS_PREFERENCES_PAGES_TYPE_ACCOUNTS, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
dialogs_preferences_pages_todoist_setup_instance_init (DialogsPreferencesPagesTodoistSetup * self,
                                                       gpointer klass)
{
	self->priv = dialogs_preferences_pages_todoist_setup_get_instance_private (self);
	self->priv->migrate_source = NULL;
}

static void
dialogs_preferences_pages_todoist_setup_finalize (GObject * obj)
{
	DialogsPreferencesPagesTodoistSetup * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DIALOGS_PREFERENCES_PAGES_TYPE_TODOIST_SETUP, DialogsPreferencesPagesTodoistSetup);
	g_debug ("TodoistSetup.vala:43: Destroying - Dialogs.Preferences.Pages.TodoistSe" \
"tup\n");
	_g_object_unref0 (self->priv->_accounts_page);
	_g_object_unref0 (self->priv->stack);
	_g_object_unref0 (self->priv->token_entry);
	_g_object_unref0 (self->priv->login_button);
	_g_object_unref0 (self->priv->oauth_button);
	_g_object_unref0 (self->priv->cancel_button);
	_g_free0 (self->priv->oauth_state);
	_g_object_unref0 (self->priv->migrate_source);
	G_OBJECT_CLASS (dialogs_preferences_pages_todoist_setup_parent_class)->finalize (obj);
}

static GType
dialogs_preferences_pages_todoist_setup_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DialogsPreferencesPagesTodoistSetupClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dialogs_preferences_pages_todoist_setup_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DialogsPreferencesPagesTodoistSetup), 0, (GInstanceInitFunc) dialogs_preferences_pages_todoist_setup_instance_init, NULL };
	GType dialogs_preferences_pages_todoist_setup_type_id;
	dialogs_preferences_pages_todoist_setup_type_id = g_type_register_static (DIALOGS_PREFERENCES_PAGES_TYPE_BASE_PAGE, "DialogsPreferencesPagesTodoistSetup", &g_define_type_info, 0);
	DialogsPreferencesPagesTodoistSetup_private_offset = g_type_add_instance_private (dialogs_preferences_pages_todoist_setup_type_id, sizeof (DialogsPreferencesPagesTodoistSetupPrivate));
	return dialogs_preferences_pages_todoist_setup_type_id;
}

GType
dialogs_preferences_pages_todoist_setup_get_type (void)
{
	static volatile gsize dialogs_preferences_pages_todoist_setup_type_id__once = 0;
	if (g_once_init_enter (&dialogs_preferences_pages_todoist_setup_type_id__once)) {
		GType dialogs_preferences_pages_todoist_setup_type_id;
		dialogs_preferences_pages_todoist_setup_type_id = dialogs_preferences_pages_todoist_setup_get_type_once ();
		g_once_init_leave (&dialogs_preferences_pages_todoist_setup_type_id__once, dialogs_preferences_pages_todoist_setup_type_id);
	}
	return dialogs_preferences_pages_todoist_setup_type_id__once;
}

static void
_vala_dialogs_preferences_pages_todoist_setup_get_property (GObject * object,
                                                            guint property_id,
                                                            GValue * value,
                                                            GParamSpec * pspec)
{
	DialogsPreferencesPagesTodoistSetup * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DIALOGS_PREFERENCES_PAGES_TYPE_TODOIST_SETUP, DialogsPreferencesPagesTodoistSetup);
	switch (property_id) {
		case DIALOGS_PREFERENCES_PAGES_TODOIST_SETUP_ACCOUNTS_PAGE_PROPERTY:
		g_value_set_object (value, dialogs_preferences_pages_todoist_setup_get_accounts_page (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_dialogs_preferences_pages_todoist_setup_set_property (GObject * object,
                                                            guint property_id,
                                                            const GValue * value,
                                                            GParamSpec * pspec)
{
	DialogsPreferencesPagesTodoistSetup * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DIALOGS_PREFERENCES_PAGES_TYPE_TODOIST_SETUP, DialogsPreferencesPagesTodoistSetup);
	switch (property_id) {
		case DIALOGS_PREFERENCES_PAGES_TODOIST_SETUP_ACCOUNTS_PAGE_PROPERTY:
		dialogs_preferences_pages_todoist_setup_set_accounts_page (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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);
}

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

