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

/* MainWindow.vala
 *
 * Copyright 2020-2021 Dylan McCall <dylan@dylanmccall.ca>
 *
 * 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, see <http://www.gnu.org/licenses/>.
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

#include "settings.h"
#include <gio/gio.h>
#include <adwaita.h>
#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <stdlib.h>
#include <string.h>
#include "common.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

#define BREAK_TIMER_SETTINGS_PANELS_TYPE_WELCOME_PANEL (break_timer_settings_panels_welcome_panel_get_type ())
#define BREAK_TIMER_SETTINGS_PANELS_WELCOME_PANEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BREAK_TIMER_SETTINGS_PANELS_TYPE_WELCOME_PANEL, BreakTimerSettingsPanelsWelcomePanel))
#define BREAK_TIMER_SETTINGS_PANELS_WELCOME_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BREAK_TIMER_SETTINGS_PANELS_TYPE_WELCOME_PANEL, BreakTimerSettingsPanelsWelcomePanelClass))
#define BREAK_TIMER_SETTINGS_PANELS_IS_WELCOME_PANEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BREAK_TIMER_SETTINGS_PANELS_TYPE_WELCOME_PANEL))
#define BREAK_TIMER_SETTINGS_PANELS_IS_WELCOME_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BREAK_TIMER_SETTINGS_PANELS_TYPE_WELCOME_PANEL))
#define BREAK_TIMER_SETTINGS_PANELS_WELCOME_PANEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BREAK_TIMER_SETTINGS_PANELS_TYPE_WELCOME_PANEL, BreakTimerSettingsPanelsWelcomePanelClass))

typedef struct _BreakTimerSettingsPanelsWelcomePanel BreakTimerSettingsPanelsWelcomePanel;
typedef struct _BreakTimerSettingsPanelsWelcomePanelClass BreakTimerSettingsPanelsWelcomePanelClass;

#define BREAK_TIMER_SETTINGS_PANELS_TYPE_STATUS_PANEL (break_timer_settings_panels_status_panel_get_type ())
#define BREAK_TIMER_SETTINGS_PANELS_STATUS_PANEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BREAK_TIMER_SETTINGS_PANELS_TYPE_STATUS_PANEL, BreakTimerSettingsPanelsStatusPanel))
#define BREAK_TIMER_SETTINGS_PANELS_STATUS_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BREAK_TIMER_SETTINGS_PANELS_TYPE_STATUS_PANEL, BreakTimerSettingsPanelsStatusPanelClass))
#define BREAK_TIMER_SETTINGS_PANELS_IS_STATUS_PANEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BREAK_TIMER_SETTINGS_PANELS_TYPE_STATUS_PANEL))
#define BREAK_TIMER_SETTINGS_PANELS_IS_STATUS_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BREAK_TIMER_SETTINGS_PANELS_TYPE_STATUS_PANEL))
#define BREAK_TIMER_SETTINGS_PANELS_STATUS_PANEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BREAK_TIMER_SETTINGS_PANELS_TYPE_STATUS_PANEL, BreakTimerSettingsPanelsStatusPanelClass))

typedef struct _BreakTimerSettingsPanelsStatusPanel BreakTimerSettingsPanelsStatusPanel;
typedef struct _BreakTimerSettingsPanelsStatusPanelClass BreakTimerSettingsPanelsStatusPanelClass;
enum  {
	BREAK_TIMER_SETTINGS_MAIN_WINDOW_0_PROPERTY,
	BREAK_TIMER_SETTINGS_MAIN_WINDOW_NUM_PROPERTIES
};
static GParamSpec* break_timer_settings_main_window_properties[BREAK_TIMER_SETTINGS_MAIN_WINDOW_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
#define _g_thread_unref0(var) ((var == NULL) ? NULL : (var = (g_thread_unref (var), NULL)))

struct _BreakTimerSettingsMainWindowPrivate {
	BreakTimerSettingsBreakManager* break_manager;
	GDBusConnection* dbus_connection;
	GMenu* app_menu;
	AdwHeaderBar* header;
	GtkStack* main_stack;
	AdwBanner* permission_error_banner;
	GtkButton* settings_button;
	GtkSwitch* master_switch;
	GtkMenuButton* menu_button;
	BreakTimerSettingsBreakSettingsDialog* break_settings_dialog;
	BreakTimerSettingsPanelsWelcomePanel* welcome_panel;
	BreakTimerSettingsPanelsStatusPanel* status_panel;
	gboolean skip_tour;
};

static gint BreakTimerSettingsMainWindow_private_offset;
static gpointer break_timer_settings_main_window_parent_class = NULL;
static GInitableIface * break_timer_settings_main_window_g_initable_parent_iface = NULL;

VALA_EXTERN GType break_timer_settings_panels_welcome_panel_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType break_timer_settings_panels_status_panel_get_type (void) G_GNUC_CONST ;
static void break_timer_settings_main_window_on_settings_clicked (BreakTimerSettingsMainWindow* self);
static void _break_timer_settings_main_window_on_settings_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                               gpointer self);
static void break_timer_settings_main_window_on_permission_error_banner_button_clicked (BreakTimerSettingsMainWindow* self,
                                                                                 AdwBanner* banner);
static void _break_timer_settings_main_window_on_permission_error_banner_button_clicked_adw_banner_button_clicked (AdwBanner* _sender,
                                                                                                            gpointer self);
VALA_EXTERN BreakTimerSettingsPanelsStatusPanel* break_timer_settings_panels_status_panel_new (BreakTimerSettingsBreakManager* break_manager,
                                                                                   GtkBuilder* builder);
VALA_EXTERN BreakTimerSettingsPanelsStatusPanel* break_timer_settings_panels_status_panel_construct (GType object_type,
                                                                                         BreakTimerSettingsBreakManager* break_manager,
                                                                                         GtkBuilder* builder);
VALA_EXTERN BreakTimerSettingsPanelsWelcomePanel* break_timer_settings_panels_welcome_panel_new (BreakTimerSettingsBreakManager* break_manager,
                                                                                     GtkBuilder* builder,
                                                                                     BreakTimerSettingsMainWindow* main_window);
VALA_EXTERN BreakTimerSettingsPanelsWelcomePanel* break_timer_settings_panels_welcome_panel_construct (GType object_type,
                                                                                           BreakTimerSettingsBreakManager* break_manager,
                                                                                           GtkBuilder* builder,
                                                                                           BreakTimerSettingsMainWindow* main_window);
static void break_timer_settings_main_window_on_tour_finished (BreakTimerSettingsMainWindow* self);
static void _break_timer_settings_main_window_on_tour_finished_break_timer_settings_panels_welcome_panel_tour_finished (BreakTimerSettingsPanelsWelcomePanel* _sender,
                                                                                                                 gpointer self);
static void break_timer_settings_main_window_on_break_manager_permissions_error_change (BreakTimerSettingsMainWindow* self);
static void _break_timer_settings_main_window_on_break_manager_permissions_error_change_g_object_notify (GObject* _sender,
                                                                                                  GParamSpec* pspec,
                                                                                                  gpointer self);
static void break_timer_settings_main_window_update_visible_panel (BreakTimerSettingsMainWindow* self);
static void _break_timer_settings_main_window_update_visible_panel_g_object_notify (GObject* _sender,
                                                                             GParamSpec* pspec,
                                                                             gpointer self);
static gboolean break_timer_settings_main_window_real_init (GInitable* base,
                                                     GCancellable* cancellable,
                                                     GError** error);
VALA_EXTERN gboolean break_timer_settings_panels_welcome_panel_is_active (BreakTimerSettingsPanelsWelcomePanel* self);
VALA_EXTERN void break_timer_settings_panels_welcome_panel_settings_button_clicked (BreakTimerSettingsPanelsWelcomePanel* self);
static gboolean __lambda6_ (BreakTimerSettingsMainWindow* self);
static gboolean break_timer_settings_main_window_launch_application_settings (BreakTimerSettingsMainWindow* self);
static gboolean ___lambda6__gsource_func (gpointer self);
static gboolean __lambda7_ (BreakTimerSettingsMainWindow* self);
static void _g_free0_ (gpointer var);
static void _g_variant_unref0_ (gpointer var);
static gpointer ___lambda7__gthread_func (gpointer self);
static void break_timer_settings_main_window_finalize (GObject * obj);
static GType break_timer_settings_main_window_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

static inline gpointer
break_timer_settings_main_window_get_instance_private (BreakTimerSettingsMainWindow* self)
{
	return G_STRUCT_MEMBER_P (self, BreakTimerSettingsMainWindow_private_offset);
}

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

static void
_break_timer_settings_main_window_on_settings_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                          gpointer self)
{
	break_timer_settings_main_window_on_settings_clicked ((BreakTimerSettingsMainWindow*) self);
}

static void
_break_timer_settings_main_window_on_permission_error_banner_button_clicked_adw_banner_button_clicked (AdwBanner* _sender,
                                                                                                       gpointer self)
{
	break_timer_settings_main_window_on_permission_error_banner_button_clicked ((BreakTimerSettingsMainWindow*) self, _sender);
}

static void
_break_timer_settings_main_window_on_tour_finished_break_timer_settings_panels_welcome_panel_tour_finished (BreakTimerSettingsPanelsWelcomePanel* _sender,
                                                                                                            gpointer self)
{
	break_timer_settings_main_window_on_tour_finished ((BreakTimerSettingsMainWindow*) self);
}

static void
_break_timer_settings_main_window_on_break_manager_permissions_error_change_g_object_notify (GObject* _sender,
                                                                                             GParamSpec* pspec,
                                                                                             gpointer self)
{
	break_timer_settings_main_window_on_break_manager_permissions_error_change ((BreakTimerSettingsMainWindow*) self);
}

static void
_break_timer_settings_main_window_update_visible_panel_g_object_notify (GObject* _sender,
                                                                        GParamSpec* pspec,
                                                                        gpointer self)
{
	break_timer_settings_main_window_update_visible_panel ((BreakTimerSettingsMainWindow*) self);
}

BreakTimerSettingsMainWindow*
break_timer_settings_main_window_construct (GType object_type,
                                            BreakTimerSettingsApplication* application,
                                            BreakTimerSettingsBreakManager* break_manager)
{
	BreakTimerSettingsMainWindow * self = NULL;
	BreakTimerSettingsBreakManager* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	GtkBuilder* builder = NULL;
	GtkBuilder* _tmp3_;
	GMenu* _tmp5_;
	GMenu* _tmp6_;
	GMenu* _tmp7_;
	BreakTimerSettingsBreakSettingsDialog* _tmp8_;
	BreakTimerSettingsBreakSettingsDialog* _tmp9_;
	BreakTimerSettingsBreakSettingsDialog* _tmp10_;
	BreakTimerSettingsBreakSettingsDialog* _tmp11_;
	GtkBox* content = NULL;
	GtkBox* _tmp12_;
	AdwHeaderBar* _tmp13_;
	AdwHeaderBar* _tmp14_;
	GtkSwitch* _tmp15_;
	GtkSwitch* _tmp16_;
	GtkSwitch* _tmp17_;
	AdwHeaderBar* _tmp18_;
	GtkSwitch* _tmp19_;
	GtkMenuButton* _tmp20_;
	GtkMenuButton* _tmp21_;
	GtkMenuButton* _tmp22_;
	GMenu* _tmp23_;
	AdwHeaderBar* _tmp24_;
	GtkMenuButton* _tmp25_;
	GtkButton* _tmp26_;
	GtkButton* _tmp27_;
	GtkButton* _tmp28_;
	GtkImage* _tmp29_;
	GtkImage* _tmp30_;
	GtkButton* _tmp31_;
	AdwHeaderBar* _tmp32_;
	GtkButton* _tmp33_;
	GtkStack* _tmp34_;
	GtkStack* _tmp35_;
	GtkStack* _tmp36_;
	GtkStack* _tmp37_;
	GtkStack* _tmp38_;
	AdwBanner* _tmp39_;
	AdwBanner* _tmp40_;
	AdwBanner* _tmp41_;
	AdwBanner* _tmp42_;
	BreakTimerSettingsPanelsStatusPanel* _tmp43_;
	GtkStack* _tmp44_;
	BreakTimerSettingsPanelsStatusPanel* _tmp45_;
	BreakTimerSettingsPanelsWelcomePanel* _tmp46_;
	GtkStack* _tmp47_;
	BreakTimerSettingsPanelsWelcomePanel* _tmp48_;
	BreakTimerSettingsPanelsWelcomePanel* _tmp49_;
	AdwHeaderBar* _tmp50_;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (application != NULL, NULL);
	g_return_val_if_fail (break_manager != NULL, NULL);
	self = (BreakTimerSettingsMainWindow*) g_object_new (object_type, "application", application, NULL);
	_tmp0_ = _g_object_ref0 (break_manager);
	_g_object_unref0 (self->priv->break_manager);
	self->priv->break_manager = _tmp0_;
	_tmp1_ = break_timer_settings_break_manager_get_master_enabled (break_manager);
	_tmp2_ = _tmp1_;
	self->priv->skip_tour = _tmp2_;
	gtk_window_set_title ((GtkWindow*) self, _ ("Break Timer"));
	gtk_window_set_default_size ((GtkWindow*) self, 850, 400);
	_tmp3_ = gtk_builder_new ();
	builder = _tmp3_;
	{
		gtk_builder_add_from_resource (builder, "/org/gnome/BreakTimer/settings/ui/settings-panels.ui", &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		const gchar* _tmp4_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp4_ = e->message;
		g_error ("MainWindow.vala:62: Error loading UI: %s", _tmp4_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (builder);
		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;
	}
	_tmp5_ = g_menu_new ();
	_g_object_unref0 (self->priv->app_menu);
	self->priv->app_menu = _tmp5_;
	_tmp6_ = self->priv->app_menu;
	g_menu_append (_tmp6_, _ ("About"), "app.about");
	_tmp7_ = self->priv->app_menu;
	g_menu_append (_tmp7_, _ ("Quit"), "app.quit");
	_tmp8_ = break_timer_settings_break_settings_dialog_new (break_manager);
	g_object_ref_sink (_tmp8_);
	_g_object_unref0 (self->priv->break_settings_dialog);
	self->priv->break_settings_dialog = _tmp8_;
	_tmp9_ = self->priv->break_settings_dialog;
	gtk_window_set_modal ((GtkWindow*) _tmp9_, TRUE);
	_tmp10_ = self->priv->break_settings_dialog;
	gtk_window_set_transient_for ((GtkWindow*) _tmp10_, (GtkWindow*) self);
	_tmp11_ = self->priv->break_settings_dialog;
	gtk_window_set_hide_on_close ((GtkWindow*) _tmp11_, TRUE);
	_tmp12_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp12_);
	content = _tmp12_;
	adw_application_window_set_content ((AdwApplicationWindow*) self, (GtkWidget*) content);
	gtk_orientable_set_orientation ((GtkOrientable*) content, GTK_ORIENTATION_VERTICAL);
	gtk_widget_set_vexpand ((GtkWidget*) content, TRUE);
	_tmp13_ = (AdwHeaderBar*) adw_header_bar_new ();
	g_object_ref_sink (_tmp13_);
	_g_object_unref0 (self->priv->header);
	self->priv->header = _tmp13_;
	_tmp14_ = self->priv->header;
	gtk_box_append (content, (GtkWidget*) _tmp14_);
	_tmp15_ = (GtkSwitch*) gtk_switch_new ();
	g_object_ref_sink (_tmp15_);
	_g_object_unref0 (self->priv->master_switch);
	self->priv->master_switch = _tmp15_;
	_tmp16_ = self->priv->master_switch;
	gtk_widget_set_valign ((GtkWidget*) _tmp16_, GTK_ALIGN_CENTER);
	_tmp17_ = self->priv->master_switch;
	g_object_bind_property_with_closures ((GObject*) break_manager, "master-enabled", (GObject*) _tmp17_, "active", G_BINDING_BIDIRECTIONAL | 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)));
	_tmp18_ = self->priv->header;
	_tmp19_ = self->priv->master_switch;
	adw_header_bar_pack_start (_tmp18_, (GtkWidget*) _tmp19_);
	_tmp20_ = (GtkMenuButton*) gtk_menu_button_new ();
	g_object_ref_sink (_tmp20_);
	_g_object_unref0 (self->priv->menu_button);
	self->priv->menu_button = _tmp20_;
	_tmp21_ = self->priv->menu_button;
	gtk_menu_button_set_direction (_tmp21_, GTK_ARROW_NONE);
	_tmp22_ = self->priv->menu_button;
	_tmp23_ = self->priv->app_menu;
	gtk_menu_button_set_menu_model (_tmp22_, (GMenuModel*) _tmp23_);
	_tmp24_ = self->priv->header;
	_tmp25_ = self->priv->menu_button;
	adw_header_bar_pack_end (_tmp24_, (GtkWidget*) _tmp25_);
	_tmp26_ = (GtkButton*) gtk_button_new ();
	g_object_ref_sink (_tmp26_);
	_g_object_unref0 (self->priv->settings_button);
	self->priv->settings_button = _tmp26_;
	_tmp27_ = self->priv->settings_button;
	g_signal_connect_object (_tmp27_, "clicked", (GCallback) _break_timer_settings_main_window_on_settings_clicked_gtk_button_clicked, self, 0);
	_tmp28_ = self->priv->settings_button;
	_tmp29_ = (GtkImage*) gtk_image_new_from_icon_name ("alarm-symbolic");
	g_object_ref_sink (_tmp29_);
	_tmp30_ = _tmp29_;
	gtk_button_set_child (_tmp28_, (GtkWidget*) _tmp30_);
	_g_object_unref0 (_tmp30_);
	_tmp31_ = self->priv->settings_button;
	gtk_widget_set_valign ((GtkWidget*) _tmp31_, GTK_ALIGN_CENTER);
	_tmp32_ = self->priv->header;
	_tmp33_ = self->priv->settings_button;
	adw_header_bar_pack_end (_tmp32_, (GtkWidget*) _tmp33_);
	_tmp34_ = (GtkStack*) gtk_stack_new ();
	g_object_ref_sink (_tmp34_);
	_g_object_unref0 (self->priv->main_stack);
	self->priv->main_stack = _tmp34_;
	_tmp35_ = self->priv->main_stack;
	gtk_box_append (content, (GtkWidget*) _tmp35_);
	_tmp36_ = self->priv->main_stack;
	gtk_widget_set_margin_top ((GtkWidget*) _tmp36_, 6);
	_tmp37_ = self->priv->main_stack;
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp37_, 6);
	_tmp38_ = self->priv->main_stack;
	gtk_stack_set_transition_duration (_tmp38_, (guint) 250);
	_tmp39_ = (AdwBanner*) adw_banner_new (_ ("Break Timer needs permission to start automatically and run in the bac" \
"kground"));
	g_object_ref_sink (_tmp39_);
	_g_object_unref0 (self->priv->permission_error_banner);
	self->priv->permission_error_banner = _tmp39_;
	_tmp40_ = self->priv->permission_error_banner;
	adw_banner_set_button_label (_tmp40_, _ ("Open Settings"));
	_tmp41_ = self->priv->permission_error_banner;
	g_signal_connect_object (_tmp41_, "button-clicked", (GCallback) _break_timer_settings_main_window_on_permission_error_banner_button_clicked_adw_banner_button_clicked, self, 0);
	_tmp42_ = self->priv->permission_error_banner;
	gtk_box_append (content, (GtkWidget*) _tmp42_);
	_tmp43_ = break_timer_settings_panels_status_panel_new (break_manager, builder);
	g_object_ref_sink (_tmp43_);
	_g_object_unref0 (self->priv->status_panel);
	self->priv->status_panel = _tmp43_;
	_tmp44_ = self->priv->main_stack;
	_tmp45_ = self->priv->status_panel;
	gtk_stack_add_named (_tmp44_, (GtkWidget*) _tmp45_, "status_panel");
	_tmp46_ = break_timer_settings_panels_welcome_panel_new (break_manager, builder, self);
	g_object_ref_sink (_tmp46_);
	_g_object_unref0 (self->priv->welcome_panel);
	self->priv->welcome_panel = _tmp46_;
	_tmp47_ = self->priv->main_stack;
	_tmp48_ = self->priv->welcome_panel;
	gtk_stack_add_named (_tmp47_, (GtkWidget*) _tmp48_, "welcome_panel");
	_tmp49_ = self->priv->welcome_panel;
	g_signal_connect_object (_tmp49_, "tour-finished", (GCallback) _break_timer_settings_main_window_on_tour_finished_break_timer_settings_panels_welcome_panel_tour_finished, self, 0);
	_tmp50_ = self->priv->header;
	gtk_widget_show ((GtkWidget*) _tmp50_);
	gtk_widget_show ((GtkWidget*) content);
	g_signal_connect_object ((GObject*) break_manager, "notify::permissions-error", (GCallback) _break_timer_settings_main_window_on_break_manager_permissions_error_change_g_object_notify, self, 0);
	g_signal_connect_object ((GObject*) break_manager, "notify::foreground-break", (GCallback) _break_timer_settings_main_window_update_visible_panel_g_object_notify, self, 0);
	break_timer_settings_main_window_update_visible_panel (self);
	_g_object_unref0 (content);
	_g_object_unref0 (builder);
	return self;
}

BreakTimerSettingsMainWindow*
break_timer_settings_main_window_new (BreakTimerSettingsApplication* application,
                                      BreakTimerSettingsBreakManager* break_manager)
{
	return break_timer_settings_main_window_construct (BREAK_TIMER_SETTINGS_TYPE_MAIN_WINDOW, application, break_manager);
}

static gboolean
break_timer_settings_main_window_real_init (GInitable* base,
                                            GCancellable* cancellable,
                                            GError** error)
{
	BreakTimerSettingsMainWindow * self;
	GDBusConnection* _tmp0_ = NULL;
	GDBusConnection* _tmp1_;
	GDBusConnection* _tmp3_;
	BreakTimerSettingsBreakManager* _tmp4_;
	GList* _tmp5_;
	BreakTimerSettingsBreakSettingsDialog* _tmp20_;
	BreakTimerSettingsPanelsStatusPanel* _tmp22_;
	GError* _inner_error0_ = NULL;
	gboolean result;
	self = (BreakTimerSettingsMainWindow*) base;
	_tmp1_ = g_bus_get_sync (G_BUS_TYPE_SESSION, cancellable, &_inner_error0_);
	_tmp0_ = _tmp1_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp2_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		return _tmp2_;
	}
	_tmp3_ = _tmp0_;
	_tmp0_ = NULL;
	_g_object_unref0 (self->priv->dbus_connection);
	self->priv->dbus_connection = _tmp3_;
	_tmp4_ = self->priv->break_manager;
	_tmp5_ = break_timer_settings_break_manager_all_breaks (_tmp4_);
	{
		GList* break_type_collection = NULL;
		GList* break_type_it = NULL;
		break_type_collection = _tmp5_;
		for (break_type_it = break_type_collection; break_type_it != NULL; break_type_it = break_type_it->next) {
			BreakTimerSettingsBreakBreakType* _tmp6_;
			BreakTimerSettingsBreakBreakType* break_type = NULL;
			_tmp6_ = _g_object_ref0 ((BreakTimerSettingsBreakBreakType*) break_type_it->data);
			break_type = _tmp6_;
			{
				BreakTimerSettingsBreakBreakInfoWidget* info_widget = NULL;
				BreakTimerSettingsBreakBreakType* _tmp7_;
				BreakTimerSettingsBreakBreakInfoWidget* _tmp8_;
				BreakTimerSettingsBreakBreakInfoWidget* _tmp9_;
				BreakTimerSettingsBreakBreakInfoWidget* _tmp10_;
				GtkStack* _tmp11_;
				BreakTimerSettingsBreakBreakInfoWidget* _tmp12_;
				BreakTimerSettingsBreakBreakType* _tmp13_;
				const gchar* _tmp14_;
				const gchar* _tmp15_;
				BreakTimerSettingsBreakBreakInfoWidget* _tmp16_;
				BreakTimerSettingsBreakBreakInfoWidget* _tmp17_;
				BreakTimerSettingsBreakBreakInfoWidget* _tmp18_;
				BreakTimerSettingsBreakBreakInfoWidget* _tmp19_;
				_tmp7_ = break_type;
				_tmp8_ = break_timer_settings_break_break_type_get_info_widget (_tmp7_);
				_tmp9_ = _tmp8_;
				_tmp10_ = _g_object_ref0 (_tmp9_);
				info_widget = _tmp10_;
				_tmp11_ = self->priv->main_stack;
				_tmp12_ = info_widget;
				_tmp13_ = break_type;
				_tmp14_ = break_timer_settings_break_break_type_get_id (_tmp13_);
				_tmp15_ = _tmp14_;
				gtk_stack_add_named (_tmp11_, (GtkWidget*) _tmp12_, _tmp15_);
				_tmp16_ = info_widget;
				gtk_widget_set_margin_start ((GtkWidget*) _tmp16_, 20);
				_tmp17_ = info_widget;
				gtk_widget_set_margin_end ((GtkWidget*) _tmp17_, 20);
				_tmp18_ = info_widget;
				gtk_widget_set_halign ((GtkWidget*) _tmp18_, GTK_ALIGN_FILL);
				_tmp19_ = info_widget;
				gtk_widget_set_valign ((GtkWidget*) _tmp19_, GTK_ALIGN_FILL);
				_g_object_unref0 (info_widget);
				_g_object_unref0 (break_type);
			}
		}
	}
	_tmp20_ = self->priv->break_settings_dialog;
	break_timer_settings_break_settings_dialog_init (_tmp20_, cancellable, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp21_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (_tmp0_);
		return _tmp21_;
	}
	_tmp22_ = self->priv->status_panel;
	g_initable_init ((GInitable*) _tmp22_, cancellable, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp23_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (_tmp0_);
		return _tmp23_;
	}
	result = TRUE;
	_g_object_unref0 (_tmp0_);
	return result;
}

static void
break_timer_settings_main_window_on_break_manager_permissions_error_change (BreakTimerSettingsMainWindow* self)
{
	BreakTimerSettingsBreakManager* _tmp0_;
	BreakTimerSettingsBreakManagerPermissionsError _tmp1_;
	BreakTimerSettingsBreakManagerPermissionsError _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->break_manager;
	_tmp1_ = break_timer_settings_break_manager_get_permissions_error (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_ != BREAK_TIMER_SETTINGS_BREAK_MANAGER_PERMISSIONS_ERROR_NONE) {
		AdwBanner* _tmp3_;
		_tmp3_ = self->priv->permission_error_banner;
		adw_banner_set_revealed (_tmp3_, TRUE);
	} else {
		AdwBanner* _tmp4_;
		_tmp4_ = self->priv->permission_error_banner;
		adw_banner_set_revealed (_tmp4_, FALSE);
	}
}

GtkWidget*
break_timer_settings_main_window_get_master_switch (BreakTimerSettingsMainWindow* self)
{
	GtkSwitch* _tmp0_;
	GtkWidget* _tmp1_;
	GtkWidget* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->master_switch;
	_tmp1_ = _g_object_ref0 ((GtkWidget*) _tmp0_);
	result = _tmp1_;
	return result;
}

GtkWidget*
break_timer_settings_main_window_get_settings_button (BreakTimerSettingsMainWindow* self)
{
	GtkButton* _tmp0_;
	GtkWidget* _tmp1_;
	GtkWidget* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->settings_button;
	_tmp1_ = _g_object_ref0 ((GtkWidget*) _tmp0_);
	result = _tmp1_;
	return result;
}

static void
break_timer_settings_main_window_update_visible_panel (BreakTimerSettingsMainWindow* self)
{
	GtkStackTransitionType transition = 0;
	GtkStack* _tmp0_;
	GtkWidget* _tmp1_;
	BreakTimerSettingsPanelsWelcomePanel* _tmp2_;
	BreakTimerSettingsBreakBreakType* foreground_break = NULL;
	BreakTimerSettingsBreakManager* _tmp3_;
	BreakTimerSettingsBreakBreakType* _tmp4_;
	BreakTimerSettingsBreakBreakType* _tmp5_;
	BreakTimerSettingsBreakBreakType* _tmp6_;
	gboolean _tmp7_ = FALSE;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->main_stack;
	_tmp1_ = gtk_stack_get_visible_child (_tmp0_);
	_tmp2_ = self->priv->welcome_panel;
	if (_tmp1_ == G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, gtk_widget_get_type (), GtkWidget)) {
		transition = GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT;
	} else {
		transition = GTK_STACK_TRANSITION_TYPE_NONE;
	}
	_tmp3_ = self->priv->break_manager;
	_tmp4_ = break_timer_settings_break_manager_get_foreground_break (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = _g_object_ref0 (_tmp5_);
	foreground_break = _tmp6_;
	if (!self->priv->skip_tour) {
		BreakTimerSettingsPanelsWelcomePanel* _tmp8_;
		_tmp8_ = self->priv->welcome_panel;
		_tmp7_ = break_timer_settings_panels_welcome_panel_is_active (_tmp8_);
	} else {
		_tmp7_ = FALSE;
	}
	if (_tmp7_) {
		GtkStack* _tmp9_;
		_tmp9_ = self->priv->main_stack;
		gtk_stack_set_visible_child_full (_tmp9_, "welcome_panel", transition);
		gtk_window_set_title ((GtkWindow*) self, _ ("Welcome Tour"));
	} else {
		BreakTimerSettingsBreakBreakType* _tmp10_;
		_tmp10_ = foreground_break;
		if (_tmp10_ != NULL) {
			GtkStack* _tmp11_;
			BreakTimerSettingsBreakBreakType* _tmp12_;
			const gchar* _tmp13_;
			const gchar* _tmp14_;
			BreakTimerSettingsBreakBreakType* _tmp15_;
			BreakTimerSettingsBreakBreakInfoWidget* _tmp16_;
			BreakTimerSettingsBreakBreakInfoWidget* _tmp17_;
			const gchar* _tmp18_;
			const gchar* _tmp19_;
			_tmp11_ = self->priv->main_stack;
			_tmp12_ = foreground_break;
			_tmp13_ = break_timer_settings_break_break_type_get_id (_tmp12_);
			_tmp14_ = _tmp13_;
			gtk_stack_set_visible_child_full (_tmp11_, _tmp14_, transition);
			_tmp15_ = foreground_break;
			_tmp16_ = break_timer_settings_break_break_type_get_info_widget (_tmp15_);
			_tmp17_ = _tmp16_;
			_tmp18_ = break_timer_settings_break_break_info_widget_get_title (_tmp17_);
			_tmp19_ = _tmp18_;
			gtk_window_set_title ((GtkWindow*) self, _tmp19_);
		} else {
			GtkStack* _tmp20_;
			_tmp20_ = self->priv->main_stack;
			gtk_stack_set_visible_child_full (_tmp20_, "status_panel", transition);
			gtk_window_set_title ((GtkWindow*) self, _ ("Break Timer"));
		}
	}
	_g_object_unref0 (foreground_break);
}

static void
break_timer_settings_main_window_on_tour_finished (BreakTimerSettingsMainWindow* self)
{
	g_return_if_fail (self != NULL);
	break_timer_settings_main_window_update_visible_panel (self);
}

static void
break_timer_settings_main_window_on_settings_clicked (BreakTimerSettingsMainWindow* self)
{
	BreakTimerSettingsBreakSettingsDialog* _tmp0_;
	BreakTimerSettingsPanelsWelcomePanel* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->break_settings_dialog;
	gtk_widget_show ((GtkWidget*) _tmp0_);
	_tmp1_ = self->priv->welcome_panel;
	break_timer_settings_panels_welcome_panel_settings_button_clicked (_tmp1_);
}

static gboolean
__lambda6_ (BreakTimerSettingsMainWindow* self)
{
	gboolean result;
	break_timer_settings_main_window_launch_application_settings (self);
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
___lambda6__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda6_ ((BreakTimerSettingsMainWindow*) self);
	return result;
}

static void
break_timer_settings_main_window_on_permission_error_banner_button_clicked (BreakTimerSettingsMainWindow* self,
                                                                            AdwBanner* banner)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (banner != NULL);
	g_idle_add_full (G_PRIORITY_HIGH_IDLE, ___lambda6__gsource_func, g_object_ref (self), g_object_unref);
}

static void
_g_free0_ (gpointer var)
{
	var = (g_free (var), NULL);
}

static void
_g_variant_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (g_variant_unref (var), NULL));
}

static gboolean
__lambda7_ (BreakTimerSettingsMainWindow* self)
{
	GVariant** parameters = NULL;
	GVariant* _tmp0_;
	GVariant** _tmp1_;
	gint parameters_length1;
	gint _parameters_size_;
	GHashTable* platform_data = NULL;
	GHashFunc _tmp2_;
	GEqualFunc _tmp3_;
	GHashTable* _tmp4_;
	GError* _inner_error0_ = NULL;
	gboolean result;
	_tmp0_ = g_variant_new ("(sav)", "applications", NULL);
	g_variant_ref_sink (_tmp0_);
	_tmp1_ = g_new0 (GVariant*, 1 + 1);
	_tmp1_[0] = _tmp0_;
	parameters = _tmp1_;
	parameters_length1 = 1;
	_parameters_size_ = parameters_length1;
	_tmp2_ = g_str_hash;
	_tmp3_ = g_str_equal;
	_tmp4_ = g_hash_table_new_full (_tmp2_, _tmp3_, _g_free0_, _g_variant_unref0_);
	platform_data = _tmp4_;
	{
		BreakTimerCommonIFreedesktopApplication* gnome_settings_application = NULL;
		GDBusConnection* _tmp5_;
		BreakTimerCommonIFreedesktopApplication* _tmp6_;
		BreakTimerCommonIFreedesktopApplication* _tmp8_;
		GVariant** _tmp9_;
		gint _tmp9__length1;
		GHashTable* _tmp10_;
		_tmp5_ = self->priv->dbus_connection;
		_tmp6_ = (BreakTimerCommonIFreedesktopApplication*) g_initable_new (BREAK_TIMER_COMMON_TYPE_IFREEDESKTOP_APPLICATION_PROXY, NULL, &_inner_error0_, "g-flags", G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, "g-name", "org.gnome.Settings", "g-connection", _tmp5_, "g-object-path", "/org/gnome/Settings", "g-interface-name", "org.freedesktop.Application", NULL);
		gnome_settings_application = (BreakTimerCommonIFreedesktopApplication*) _tmp6_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			gboolean _tmp7_ = FALSE;
			if (_inner_error0_->domain == G_IO_ERROR) {
				goto __catch0_g_io_error;
			}
			if (_inner_error0_->domain == G_DBUS_ERROR) {
				goto __catch0_g_dbus_error;
			}
			_g_hash_table_unref0 (platform_data);
			parameters = (_vala_array_free (parameters, parameters_length1, (GDestroyNotify) g_variant_unref), NULL);
			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 _tmp7_;
		}
		_tmp8_ = gnome_settings_application;
		_tmp9_ = parameters;
		_tmp9__length1 = parameters_length1;
		_tmp10_ = platform_data;
		break_timer_common_ifreedesktop_application_activate_action (_tmp8_, "launch-panel", _tmp9_, (gint) _tmp9__length1, _tmp10_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			gboolean _tmp11_ = FALSE;
			_g_object_unref0 (gnome_settings_application);
			if (_inner_error0_->domain == G_IO_ERROR) {
				goto __catch0_g_io_error;
			}
			if (_inner_error0_->domain == G_DBUS_ERROR) {
				goto __catch0_g_dbus_error;
			}
			_g_hash_table_unref0 (platform_data);
			parameters = (_vala_array_free (parameters, parameters_length1, (GDestroyNotify) g_variant_unref), NULL);
			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 _tmp11_;
		}
		_g_object_unref0 (gnome_settings_application);
	}
	goto __finally0;
	__catch0_g_io_error:
	{
		GError* _error_ = NULL;
		GError* _tmp12_;
		const gchar* _tmp13_;
		_error_ = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp12_ = _error_;
		_tmp13_ = _tmp12_->message;
		g_warning ("MainWindow.vala:230: Error connecting to org.gnome.Settings: %s", _tmp13_);
		result = FALSE;
		_g_error_free0 (_error_);
		_g_hash_table_unref0 (platform_data);
		parameters = (_vala_array_free (parameters, parameters_length1, (GDestroyNotify) g_variant_unref), NULL);
		return result;
	}
	goto __finally0;
	__catch0_g_dbus_error:
	{
		GError* _error_ = NULL;
		GError* _tmp14_;
		const gchar* _tmp15_;
		_error_ = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp14_ = _error_;
		_tmp15_ = _tmp14_->message;
		g_warning ("MainWindow.vala:233: Error launching org.gnome.Settings: %s", _tmp15_);
		result = FALSE;
		_g_error_free0 (_error_);
		_g_hash_table_unref0 (platform_data);
		parameters = (_vala_array_free (parameters, parameters_length1, (GDestroyNotify) g_variant_unref), NULL);
		return result;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp16_ = FALSE;
		_g_hash_table_unref0 (platform_data);
		parameters = (_vala_array_free (parameters, parameters_length1, (GDestroyNotify) g_variant_unref), 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 _tmp16_;
	}
	result = TRUE;
	_g_hash_table_unref0 (platform_data);
	parameters = (_vala_array_free (parameters, parameters_length1, (GDestroyNotify) g_variant_unref), NULL);
	return result;
}

static gpointer
___lambda7__gthread_func (gpointer self)
{
	gpointer result;
	result = (gpointer) ((gintptr) __lambda7_ ((BreakTimerSettingsMainWindow*) self));
	g_object_unref (self);
	return result;
}

static gboolean
break_timer_settings_main_window_launch_application_settings (BreakTimerSettingsMainWindow* self)
{
	GThread* _tmp0_;
	GThread* _tmp1_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = g_thread_new (NULL, ___lambda7__gthread_func, g_object_ref (self));
	_tmp1_ = _tmp0_;
	_g_thread_unref0 (_tmp1_);
	result = TRUE;
	return result;
}

static void
break_timer_settings_main_window_class_init (BreakTimerSettingsMainWindowClass * klass,
                                             gpointer klass_data)
{
	break_timer_settings_main_window_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &BreakTimerSettingsMainWindow_private_offset);
	G_OBJECT_CLASS (klass)->finalize = break_timer_settings_main_window_finalize;
}

static void
break_timer_settings_main_window_g_initable_interface_init (GInitableIface * iface,
                                                            gpointer iface_data)
{
	break_timer_settings_main_window_g_initable_parent_iface = g_type_interface_peek_parent (iface);
	iface->init = (gboolean (*) (GInitable*, GCancellable*, GError**)) break_timer_settings_main_window_real_init;
}

static void
break_timer_settings_main_window_instance_init (BreakTimerSettingsMainWindow * self,
                                                gpointer klass)
{
	self->priv = break_timer_settings_main_window_get_instance_private (self);
}

static void
break_timer_settings_main_window_finalize (GObject * obj)
{
	BreakTimerSettingsMainWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BREAK_TIMER_SETTINGS_TYPE_MAIN_WINDOW, BreakTimerSettingsMainWindow);
	_g_object_unref0 (self->priv->break_manager);
	_g_object_unref0 (self->priv->dbus_connection);
	_g_object_unref0 (self->priv->app_menu);
	_g_object_unref0 (self->priv->header);
	_g_object_unref0 (self->priv->main_stack);
	_g_object_unref0 (self->priv->permission_error_banner);
	_g_object_unref0 (self->priv->settings_button);
	_g_object_unref0 (self->priv->master_switch);
	_g_object_unref0 (self->priv->menu_button);
	_g_object_unref0 (self->priv->break_settings_dialog);
	_g_object_unref0 (self->priv->welcome_panel);
	_g_object_unref0 (self->priv->status_panel);
	G_OBJECT_CLASS (break_timer_settings_main_window_parent_class)->finalize (obj);
}

static GType
break_timer_settings_main_window_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BreakTimerSettingsMainWindowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) break_timer_settings_main_window_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BreakTimerSettingsMainWindow), 0, (GInstanceInitFunc) break_timer_settings_main_window_instance_init, NULL };
	static const GInterfaceInfo g_initable_info = { (GInterfaceInitFunc) break_timer_settings_main_window_g_initable_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType break_timer_settings_main_window_type_id;
	break_timer_settings_main_window_type_id = g_type_register_static (adw_application_window_get_type (), "BreakTimerSettingsMainWindow", &g_define_type_info, 0);
	g_type_add_interface_static (break_timer_settings_main_window_type_id, g_initable_get_type (), &g_initable_info);
	BreakTimerSettingsMainWindow_private_offset = g_type_add_instance_private (break_timer_settings_main_window_type_id, sizeof (BreakTimerSettingsMainWindowPrivate));
	return break_timer_settings_main_window_type_id;
}

GType
break_timer_settings_main_window_get_type (void)
{
	static volatile gsize break_timer_settings_main_window_type_id__once = 0;
	if (g_once_init_enter (&break_timer_settings_main_window_type_id__once)) {
		GType break_timer_settings_main_window_type_id;
		break_timer_settings_main_window_type_id = break_timer_settings_main_window_get_type_once ();
		g_once_init_leave (&break_timer_settings_main_window_type_id__once, break_timer_settings_main_window_type_id);
	}
	return break_timer_settings_main_window_type_id__once;
}

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

