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

#include <handy.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>

#define TOOTLE_DIALOGS_TYPE_ISAVED_WINDOW (tootle_dialogs_isaved_window_get_type ())
#define TOOTLE_DIALOGS_ISAVED_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_DIALOGS_TYPE_ISAVED_WINDOW, TootleDialogsISavedWindow))
#define TOOTLE_DIALOGS_IS_ISAVED_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_DIALOGS_TYPE_ISAVED_WINDOW))
#define TOOTLE_DIALOGS_ISAVED_WINDOW_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TOOTLE_DIALOGS_TYPE_ISAVED_WINDOW, TootleDialogsISavedWindowIface))

typedef struct _TootleDialogsISavedWindow TootleDialogsISavedWindow;
typedef struct _TootleDialogsISavedWindowIface TootleDialogsISavedWindowIface;

#define TOOTLE_DIALOGS_TYPE_MAIN_WINDOW (tootle_dialogs_main_window_get_type ())
#define TOOTLE_DIALOGS_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_DIALOGS_TYPE_MAIN_WINDOW, TootleDialogsMainWindow))
#define TOOTLE_DIALOGS_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_DIALOGS_TYPE_MAIN_WINDOW, TootleDialogsMainWindowClass))
#define TOOTLE_DIALOGS_IS_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_DIALOGS_TYPE_MAIN_WINDOW))
#define TOOTLE_DIALOGS_IS_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_DIALOGS_TYPE_MAIN_WINDOW))
#define TOOTLE_DIALOGS_MAIN_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_DIALOGS_TYPE_MAIN_WINDOW, TootleDialogsMainWindowClass))

typedef struct _TootleDialogsMainWindow TootleDialogsMainWindow;
typedef struct _TootleDialogsMainWindowClass TootleDialogsMainWindowClass;
typedef struct _TootleDialogsMainWindowPrivate TootleDialogsMainWindowPrivate;

#define TOOTLE_VIEWS_TYPE_BASE (tootle_views_base_get_type ())
#define TOOTLE_VIEWS_BASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_VIEWS_TYPE_BASE, TootleViewsBase))
#define TOOTLE_VIEWS_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_VIEWS_TYPE_BASE, TootleViewsBaseClass))
#define TOOTLE_VIEWS_IS_BASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_VIEWS_TYPE_BASE))
#define TOOTLE_VIEWS_IS_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_VIEWS_TYPE_BASE))
#define TOOTLE_VIEWS_BASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_VIEWS_TYPE_BASE, TootleViewsBaseClass))

typedef struct _TootleViewsBase TootleViewsBase;
typedef struct _TootleViewsBaseClass TootleViewsBaseClass;
enum  {
	TOOTLE_DIALOGS_MAIN_WINDOW_0_PROPERTY,
	TOOTLE_DIALOGS_MAIN_WINDOW_NUM_PROPERTIES
};
static GParamSpec* tootle_dialogs_main_window_properties[TOOTLE_DIALOGS_MAIN_WINDOW_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define TOOTLE_VIEWS_TYPE_TABBED_BASE (tootle_views_tabbed_base_get_type ())
#define TOOTLE_VIEWS_TABBED_BASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_VIEWS_TYPE_TABBED_BASE, TootleViewsTabbedBase))
#define TOOTLE_VIEWS_TABBED_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_VIEWS_TYPE_TABBED_BASE, TootleViewsTabbedBaseClass))
#define TOOTLE_VIEWS_IS_TABBED_BASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_VIEWS_TYPE_TABBED_BASE))
#define TOOTLE_VIEWS_IS_TABBED_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_VIEWS_TYPE_TABBED_BASE))
#define TOOTLE_VIEWS_TABBED_BASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_VIEWS_TYPE_TABBED_BASE, TootleViewsTabbedBaseClass))

typedef struct _TootleViewsTabbedBase TootleViewsTabbedBase;
typedef struct _TootleViewsTabbedBaseClass TootleViewsTabbedBaseClass;

#define TOOTLE_VIEWS_TYPE_MAIN (tootle_views_main_get_type ())
#define TOOTLE_VIEWS_MAIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_VIEWS_TYPE_MAIN, TootleViewsMain))
#define TOOTLE_VIEWS_MAIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_VIEWS_TYPE_MAIN, TootleViewsMainClass))
#define TOOTLE_VIEWS_IS_MAIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_VIEWS_TYPE_MAIN))
#define TOOTLE_VIEWS_IS_MAIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_VIEWS_TYPE_MAIN))
#define TOOTLE_VIEWS_MAIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_VIEWS_TYPE_MAIN, TootleViewsMainClass))

typedef struct _TootleViewsMain TootleViewsMain;
typedef struct _TootleViewsMainClass TootleViewsMainClass;

#define TOOTLE_TYPE_APPLICATION (tootle_application_get_type ())
#define TOOTLE_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_TYPE_APPLICATION, TootleApplication))
#define TOOTLE_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_TYPE_APPLICATION, TootleApplicationClass))
#define TOOTLE_IS_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_TYPE_APPLICATION))
#define TOOTLE_IS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_TYPE_APPLICATION))
#define TOOTLE_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_TYPE_APPLICATION, TootleApplicationClass))

typedef struct _TootleApplication TootleApplication;
typedef struct _TootleApplicationClass TootleApplicationClass;

#define TOOTLE_TYPE_SETTINGS (tootle_settings_get_type ())
#define TOOTLE_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_TYPE_SETTINGS, TootleSettings))
#define TOOTLE_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_TYPE_SETTINGS, TootleSettingsClass))
#define TOOTLE_IS_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_TYPE_SETTINGS))
#define TOOTLE_IS_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_TYPE_SETTINGS))
#define TOOTLE_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_TYPE_SETTINGS, TootleSettingsClass))

typedef struct _TootleSettings TootleSettings;
typedef struct _TootleSettingsClass TootleSettingsClass;
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _TootleApplicationPrivate TootleApplicationPrivate;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _TootleDialogsISavedWindowIface {
	GTypeInterface parent_iface;
};

struct _TootleDialogsMainWindow {
	HdyWindow parent_instance;
	TootleDialogsMainWindowPrivate * priv;
};

struct _TootleDialogsMainWindowClass {
	HdyWindowClass parent_class;
};

struct _TootleDialogsMainWindowPrivate {
	HdyDeck* deck;
	TootleViewsBase* last_view;
};

struct _TootleApplication {
	GtkApplication parent_instance;
	TootleApplicationPrivate * priv;
	GtkCssProvider* css_provider;
	GtkCssProvider* zoom_css_provider;
	gchar** ACCEL_ABOUT;
	gint ACCEL_ABOUT_length1;
	gchar** ACCEL_NEW_POST;
	gint ACCEL_NEW_POST_length1;
	gchar** ACCEL_BACK;
	gint ACCEL_BACK_length1;
	gchar** ACCEL_REFRESH;
	gint ACCEL_REFRESH_length1;
	gchar** ACCEL_SEARCH;
	gint ACCEL_SEARCH_length1;
	gchar** ACCEL_TIMELINE_0;
	gint ACCEL_TIMELINE_0_length1;
	gchar** ACCEL_TIMELINE_1;
	gint ACCEL_TIMELINE_1_length1;
	gchar** ACCEL_TIMELINE_2;
	gint ACCEL_TIMELINE_2_length1;
	gchar** ACCEL_TIMELINE_3;
	gint ACCEL_TIMELINE_3_length1;
};

struct _TootleApplicationClass {
	GtkApplicationClass parent_class;
};

static gint TootleDialogsMainWindow_private_offset;
static gpointer tootle_dialogs_main_window_parent_class = NULL;
extern TootleDialogsMainWindow* tootle_window;
extern TootleApplication* tootle_app;
extern TootleSettings* tootle_settings;
static TootleDialogsISavedWindowIface * tootle_dialogs_main_window_tootle_dialogs_isaved_window_parent_iface = NULL;

GType tootle_dialogs_isaved_window_get_type (void) G_GNUC_CONST ;
GType tootle_dialogs_main_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleDialogsMainWindow, g_object_unref)
GType tootle_views_base_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleViewsBase, g_object_unref)
#define TOOTLE_DIALOGS_MAIN_WINDOW_ZOOM_CLASS "ttl-scalable"
TootleDialogsMainWindow* tootle_dialogs_main_window_new (GtkApplication* app);
TootleDialogsMainWindow* tootle_dialogs_main_window_construct (GType object_type,
                                                               GtkApplication* app);
#define BUILD_DOMAIN "com.github.bleakgrey.tootle"
#define BUILD_NAME "Tootle"
TootleViewsBase* tootle_dialogs_main_window_open_view (TootleDialogsMainWindow* self,
                                                       TootleViewsBase* view);
TootleViewsMain* tootle_views_main_new (void);
TootleViewsMain* tootle_views_main_construct (GType object_type);
GType tootle_views_tabbed_base_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleViewsTabbedBase, g_object_unref)
GType tootle_views_main_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleViewsMain, g_object_unref)
gboolean tootle_dialogs_main_window_back (TootleDialogsMainWindow* self);
static void tootle_dialogs_main_window_on_child_transition (TootleDialogsMainWindow* self);
static void _tootle_dialogs_main_window_on_child_transition_g_object_notify (GObject* _sender,
                                                                      GParamSpec* pspec,
                                                                      gpointer self);
static gboolean tootle_dialogs_main_window_real_delete_event (GtkWidget* base,
                                                       GdkEventAny* event);
GType tootle_application_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleApplication, g_object_unref)
gboolean tootle_application_on_window_closed (TootleApplication* self);
void tootle_dialogs_main_window_switch_timeline (TootleDialogsMainWindow* self,
                                                 gint32 num) G_GNUC_DEPRECATED ;
static gboolean tootle_dialogs_main_window_on_button_press (TootleDialogsMainWindow* self,
                                                     GdkEventButton* ev);
static void tootle_dialogs_main_window_on_zoom_level_changed (TootleDialogsMainWindow* self);
GType tootle_settings_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleSettings, g_object_unref)
gint tootle_settings_get_post_text_size (TootleSettings* self);
static void tootle_dialogs_main_window_on_view_changed (TootleDialogsMainWindow* self);
void tootle_views_base_set_current (TootleViewsBase* self,
                                    gboolean value);
void tootle_views_base_on_hidden (TootleViewsBase* self);
void tootle_views_base_on_shown (TootleViewsBase* self);
static GObject * tootle_dialogs_main_window_constructor (GType type,
                                                  guint n_construct_properties,
                                                  GObjectConstructParam * construct_properties);
static void _tootle_dialogs_main_window___lambda129_ (TootleDialogsMainWindow* self);
static void __tootle_dialogs_main_window___lambda129__g_object_notify (GObject* _sender,
                                                                GParamSpec* pspec,
                                                                gpointer self);
static void _tootle_dialogs_main_window_on_view_changed_g_object_notify (GObject* _sender,
                                                                  GParamSpec* pspec,
                                                                  gpointer self);
static gboolean _tootle_dialogs_main_window_on_button_press_gtk_widget_button_press_event (GtkWidget* _sender,
                                                                                    GdkEventButton* event,
                                                                                    gpointer self);
void tootle_dialogs_isaved_window_restore_state (TootleDialogsISavedWindow* self);
static void tootle_dialogs_main_window_finalize (GObject * obj);
static GType tootle_dialogs_main_window_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
tootle_dialogs_main_window_get_instance_private (TootleDialogsMainWindow* self)
{
	return G_STRUCT_MEMBER_P (self, TootleDialogsMainWindow_private_offset);
}

TootleDialogsMainWindow*
tootle_dialogs_main_window_construct (GType object_type,
                                      GtkApplication* app)
{
	TootleDialogsMainWindow * self = NULL;
	TootleViewsMain* _tmp0_;
	TootleViewsMain* _tmp1_;
	TootleViewsBase* _tmp2_;
	TootleViewsBase* _tmp3_;
	g_return_val_if_fail (app != NULL, NULL);
	self = (TootleDialogsMainWindow*) g_object_new (object_type, "application", app, "icon-name", BUILD_DOMAIN, "title", BUILD_NAME, "resizable", TRUE, "window-position", GTK_WIN_POS_CENTER, NULL);
	_tmp0_ = tootle_views_main_new ();
	g_object_ref_sink (_tmp0_);
	_tmp1_ = _tmp0_;
	_tmp2_ = tootle_dialogs_main_window_open_view (self, (TootleViewsBase*) _tmp1_);
	_tmp3_ = _tmp2_;
	_g_object_unref0 (_tmp3_);
	_g_object_unref0 (_tmp1_);
	return self;
}

TootleDialogsMainWindow*
tootle_dialogs_main_window_new (GtkApplication* app)
{
	return tootle_dialogs_main_window_construct (TOOTLE_DIALOGS_TYPE_MAIN_WINDOW, app);
}

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

TootleViewsBase*
tootle_dialogs_main_window_open_view (TootleDialogsMainWindow* self,
                                      TootleViewsBase* view)
{
	HdyDeck* _tmp0_;
	HdyDeck* _tmp1_;
	TootleViewsBase* _tmp2_;
	TootleViewsBase* result = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (view != NULL, NULL);
	_tmp0_ = self->priv->deck;
	gtk_container_add ((GtkContainer*) _tmp0_, (GtkWidget*) view);
	_tmp1_ = self->priv->deck;
	hdy_deck_set_visible_child (_tmp1_, (GtkWidget*) view);
	_tmp2_ = _g_object_ref0 (view);
	result = _tmp2_;
	return result;
}

gboolean
tootle_dialogs_main_window_back (TootleDialogsMainWindow* self)
{
	HdyDeck* _tmp0_;
	gboolean result = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->deck;
	hdy_deck_navigate (_tmp0_, HDY_NAVIGATION_DIRECTION_BACK);
	result = TRUE;
	return result;
}

static void
tootle_dialogs_main_window_on_child_transition (TootleDialogsMainWindow* self)
{
	HdyDeck* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	GtkWidget* unused_child = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->deck;
	_tmp1_ = hdy_deck_get_transition_running (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_) {
		return;
	}
	while (TRUE) {
		HdyDeck* _tmp3_;
		GtkWidget* _tmp4_;
		GtkWidget* _tmp5_;
		GtkWidget* _tmp6_;
		GtkWidget* _tmp7_;
		_tmp3_ = self->priv->deck;
		_tmp4_ = hdy_deck_get_adjacent_child (_tmp3_, HDY_NAVIGATION_DIRECTION_FORWARD);
		_tmp5_ = _g_object_ref0 (_tmp4_);
		_g_object_unref0 (unused_child);
		unused_child = _tmp5_;
		_tmp6_ = unused_child;
		if (!(_tmp6_ != NULL)) {
			break;
		}
		_tmp7_ = unused_child;
		gtk_widget_destroy (_tmp7_);
	}
	_g_object_unref0 (unused_child);
}

static void
_tootle_dialogs_main_window_on_child_transition_g_object_notify (GObject* _sender,
                                                                 GParamSpec* pspec,
                                                                 gpointer self)
{
	tootle_dialogs_main_window_on_child_transition ((TootleDialogsMainWindow*) self);
}

static gboolean
tootle_dialogs_main_window_real_delete_event (GtkWidget* base,
                                              GdkEventAny* event)
{
	TootleDialogsMainWindow * self;
	TootleApplication* _tmp0_;
	gboolean result = FALSE;
	self = (TootleDialogsMainWindow*) base;
	g_return_val_if_fail (event != NULL, FALSE);
	_g_object_unref0 (tootle_window);
	tootle_window = NULL;
	_tmp0_ = tootle_app;
	result = tootle_application_on_window_closed (_tmp0_);
	return result;
}

void
tootle_dialogs_main_window_switch_timeline (TootleDialogsMainWindow* self,
                                            gint32 num)
{
	g_return_if_fail (self != NULL);
}

static gboolean
tootle_dialogs_main_window_on_button_press (TootleDialogsMainWindow* self,
                                            GdkEventButton* ev)
{
	gboolean result = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (ev != NULL, FALSE);
	if (ev->button == ((guint) 8)) {
		result = tootle_dialogs_main_window_back (self);
		return result;
	}
	result = FALSE;
	return result;
}

static const gchar*
string_to_string (const gchar* self)
{
	const gchar* result = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}

static void
tootle_dialogs_main_window_on_zoom_level_changed (TootleDialogsMainWindow* self)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	{
		gint scale = 0;
		TootleSettings* _tmp0_;
		gint _tmp1_;
		gint _tmp2_;
		gchar* css = NULL;
		gchar* _tmp3_;
		TootleApplication* _tmp5_;
		GtkCssProvider* _tmp6_;
		const gchar* _tmp7_;
		_tmp0_ = tootle_settings;
		_tmp1_ = tootle_settings_get_post_text_size (_tmp0_);
		_tmp2_ = _tmp1_;
		scale = _tmp2_;
		_tmp3_ = g_strdup ("");
		css = _tmp3_;
		if (scale > 100) {
			gchar* _tmp4_;
			_tmp4_ = g_strdup_printf ("\n" \
"\t\t\t\t\t.%s label {\n" \
"\t\t\t\t\t\tfont-size: %i%;\n" \
"\t\t\t\t\t}\n" \
"\t\t\t\t", TOOTLE_DIALOGS_MAIN_WINDOW_ZOOM_CLASS, scale);
			_g_free0 (css);
			css = _tmp4_;
		}
		_tmp5_ = tootle_app;
		_tmp6_ = _tmp5_->zoom_css_provider;
		_tmp7_ = css;
		gtk_css_provider_load_from_data (_tmp6_, _tmp7_, (gssize) -1, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_free0 (css);
			goto __catch0_g_error;
		}
		_g_free0 (css);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp8_;
		const gchar* _tmp9_;
		const gchar* _tmp10_;
		gchar* _tmp11_;
		gchar* _tmp12_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp8_ = e;
		_tmp9_ = _tmp8_->message;
		_tmp10_ = string_to_string (_tmp9_);
		_tmp11_ = g_strconcat ("Can't set zoom level: ", _tmp10_, NULL);
		_tmp12_ = _tmp11_;
		g_warning ("MainWindow.vala:88: %s", _tmp12_);
		_g_free0 (_tmp12_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		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;
	}
}

static void
tootle_dialogs_main_window_on_view_changed (TootleDialogsMainWindow* self)
{
	TootleViewsBase* view = NULL;
	HdyDeck* _tmp0_;
	GtkWidget* _tmp1_;
	GtkWidget* _tmp2_;
	TootleViewsBase* _tmp3_;
	TootleViewsBase* _tmp4_;
	TootleViewsBase* _tmp7_;
	TootleViewsBase* _tmp10_;
	TootleViewsBase* _tmp11_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->deck;
	_tmp1_ = hdy_deck_get_visible_child (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _g_object_ref0 (TOOTLE_VIEWS_IS_BASE (_tmp2_) ? ((TootleViewsBase*) _tmp2_) : NULL);
	view = _tmp3_;
	_tmp4_ = self->priv->last_view;
	if (_tmp4_ != NULL) {
		TootleViewsBase* _tmp5_;
		TootleViewsBase* _tmp6_;
		_tmp5_ = self->priv->last_view;
		tootle_views_base_set_current (_tmp5_, FALSE);
		_tmp6_ = self->priv->last_view;
		tootle_views_base_on_hidden (_tmp6_);
	}
	_tmp7_ = view;
	if (_tmp7_ != NULL) {
		TootleViewsBase* _tmp8_;
		TootleViewsBase* _tmp9_;
		_tmp8_ = view;
		tootle_views_base_set_current (_tmp8_, TRUE);
		_tmp9_ = view;
		tootle_views_base_on_shown (_tmp9_);
	}
	_tmp10_ = view;
	_tmp11_ = _g_object_ref0 (_tmp10_);
	_g_object_unref0 (self->priv->last_view);
	self->priv->last_view = _tmp11_;
	_g_object_unref0 (view);
}

static void
_tootle_dialogs_main_window___lambda129_ (TootleDialogsMainWindow* self)
{
	tootle_dialogs_main_window_on_zoom_level_changed (self);
}

static void
__tootle_dialogs_main_window___lambda129__g_object_notify (GObject* _sender,
                                                           GParamSpec* pspec,
                                                           gpointer self)
{
	_tootle_dialogs_main_window___lambda129_ ((TootleDialogsMainWindow*) self);
}

static void
_tootle_dialogs_main_window_on_view_changed_g_object_notify (GObject* _sender,
                                                             GParamSpec* pspec,
                                                             gpointer self)
{
	tootle_dialogs_main_window_on_view_changed ((TootleDialogsMainWindow*) self);
}

static gboolean
_tootle_dialogs_main_window_on_button_press_gtk_widget_button_press_event (GtkWidget* _sender,
                                                                           GdkEventButton* event,
                                                                           gpointer self)
{
	gboolean result;
	result = tootle_dialogs_main_window_on_button_press ((TootleDialogsMainWindow*) self, event);
	return result;
}

static GObject *
tootle_dialogs_main_window_constructor (GType type,
                                        guint n_construct_properties,
                                        GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	TootleDialogsMainWindow * self;
	GtkSettings* gtk_settings = NULL;
	GtkSettings* _tmp0_;
	GtkSettings* _tmp1_;
	TootleSettings* _tmp2_;
	GtkSettings* _tmp3_;
	TootleSettings* _tmp4_;
	HdyDeck* _tmp5_;
	parent_class = G_OBJECT_CLASS (tootle_dialogs_main_window_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TOOTLE_DIALOGS_TYPE_MAIN_WINDOW, TootleDialogsMainWindow);
	_tmp0_ = gtk_settings_get_default ();
	_tmp1_ = _g_object_ref0 (_tmp0_);
	gtk_settings = _tmp1_;
	_tmp2_ = tootle_settings;
	_tmp3_ = gtk_settings;
	g_object_bind_property_with_closures ((GObject*) _tmp2_, "dark-theme", (GObject*) _tmp3_, "gtk-application-prefer-dark-theme", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp4_ = tootle_settings;
	g_signal_connect_object ((GObject*) _tmp4_, "notify::post-text-size", (GCallback) __tootle_dialogs_main_window___lambda129__g_object_notify, self, 0);
	tootle_dialogs_main_window_on_zoom_level_changed (self);
	_tmp5_ = self->priv->deck;
	g_signal_connect_object ((GObject*) _tmp5_, "notify::visible-child", (GCallback) _tootle_dialogs_main_window_on_view_changed_g_object_notify, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "button-press-event", (GCallback) _tootle_dialogs_main_window_on_button_press_gtk_widget_button_press_event, self, 0);
	tootle_dialogs_isaved_window_restore_state ((TootleDialogsISavedWindow*) self);
	_g_object_unref0 (gtk_settings);
	return obj;
}

static void
tootle_dialogs_main_window_class_init (TootleDialogsMainWindowClass * klass,
                                       gpointer klass_data)
{
	tootle_dialogs_main_window_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &TootleDialogsMainWindow_private_offset);
	((GtkWidgetClass *) klass)->delete_event = (gboolean (*) (GtkWidget*, GdkEventAny*)) tootle_dialogs_main_window_real_delete_event;
	G_OBJECT_CLASS (klass)->constructor = tootle_dialogs_main_window_constructor;
	G_OBJECT_CLASS (klass)->finalize = tootle_dialogs_main_window_finalize;
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/com/github/bleakgrey/tootle/ui/dialogs/main.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "deck", FALSE, TootleDialogsMainWindow_private_offset + G_STRUCT_OFFSET (TootleDialogsMainWindowPrivate, deck));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_child_transition", G_CALLBACK(_tootle_dialogs_main_window_on_child_transition_g_object_notify));
}

static void
tootle_dialogs_main_window_tootle_dialogs_isaved_window_interface_init (TootleDialogsISavedWindowIface * iface,
                                                                        gpointer iface_data)
{
	tootle_dialogs_main_window_tootle_dialogs_isaved_window_parent_iface = g_type_interface_peek_parent (iface);
}

static void
tootle_dialogs_main_window_instance_init (TootleDialogsMainWindow * self,
                                          gpointer klass)
{
	self->priv = tootle_dialogs_main_window_get_instance_private (self);
	self->priv->last_view = NULL;
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
tootle_dialogs_main_window_finalize (GObject * obj)
{
	TootleDialogsMainWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TOOTLE_DIALOGS_TYPE_MAIN_WINDOW, TootleDialogsMainWindow);
	_g_object_unref0 (self->priv->last_view);
	G_OBJECT_CLASS (tootle_dialogs_main_window_parent_class)->finalize (obj);
}

static GType
tootle_dialogs_main_window_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (TootleDialogsMainWindowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) tootle_dialogs_main_window_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TootleDialogsMainWindow), 0, (GInstanceInitFunc) tootle_dialogs_main_window_instance_init, NULL };
	static const GInterfaceInfo tootle_dialogs_isaved_window_info = { (GInterfaceInitFunc) tootle_dialogs_main_window_tootle_dialogs_isaved_window_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType tootle_dialogs_main_window_type_id;
	tootle_dialogs_main_window_type_id = g_type_register_static (hdy_window_get_type (), "TootleDialogsMainWindow", &g_define_type_info, 0);
	g_type_add_interface_static (tootle_dialogs_main_window_type_id, TOOTLE_DIALOGS_TYPE_ISAVED_WINDOW, &tootle_dialogs_isaved_window_info);
	TootleDialogsMainWindow_private_offset = g_type_add_instance_private (tootle_dialogs_main_window_type_id, sizeof (TootleDialogsMainWindowPrivate));
	return tootle_dialogs_main_window_type_id;
}

GType
tootle_dialogs_main_window_get_type (void)
{
	static volatile gsize tootle_dialogs_main_window_type_id__volatile = 0;
	if (g_once_init_enter (&tootle_dialogs_main_window_type_id__volatile)) {
		GType tootle_dialogs_main_window_type_id;
		tootle_dialogs_main_window_type_id = tootle_dialogs_main_window_get_type_once ();
		g_once_init_leave (&tootle_dialogs_main_window_type_id__volatile, tootle_dialogs_main_window_type_id);
	}
	return tootle_dialogs_main_window_type_id__volatile;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

