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

#include "protonplus_core.h"
#include <adwaita.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <glib.h>
#include <glib-object.h>
#include <glib/gi18n-lib.h>
#include <gee.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

enum  {
	PROTON_PLUS_WIDGETS_HEADER_BOX_0_PROPERTY,
	PROTON_PLUS_WIDGETS_HEADER_BOX_HEADER_BAR_PROPERTY,
	PROTON_PLUS_WIDGETS_HEADER_BOX_NARROW_NAVIGATION_PROPERTY,
	PROTON_PLUS_WIDGETS_HEADER_BOX_NUM_PROPERTIES
};
static GParamSpec* proton_plus_widgets_header_box_properties[PROTON_PLUS_WIDGETS_HEADER_BOX_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
enum  {
	PROTON_PLUS_WIDGETS_HEADER_BOX_LAUNCHER_SELECTED_SIGNAL,
	PROTON_PLUS_WIDGETS_HEADER_BOX_DOWNLOAD_SELECTED_SIGNAL,
	PROTON_PLUS_WIDGETS_HEADER_BOX_NUM_SIGNALS
};
static guint proton_plus_widgets_header_box_signals[PROTON_PLUS_WIDGETS_HEADER_BOX_NUM_SIGNALS] = {0};

struct _ProtonPlusWidgetsHeaderBoxPrivate {
	AdwHeaderBar* _header_bar;
	ProtonPlusWidgetsHeaderLaunchersButton* _launchers_button;
	ProtonPlusWidgetsHeaderDownloadsIndicator* _downloads_indicator;
	GtkMenuButton* _menu_button;
	GtkButton* _back_button;
	GMenu* _menu;
	gboolean controller_mode_active;
	AdwViewSwitcher* global_view_switcher;
	ProtonPlusWidgetsHeaderPresentation* current_presentation;
	gboolean _narrow_navigation;
};

static gint ProtonPlusWidgetsHeaderBox_private_offset;
static gpointer proton_plus_widgets_header_box_parent_class = NULL;

static void proton_plus_widgets_header_box_set_launchers_button (ProtonPlusWidgetsHeaderBox* self,
                                                          ProtonPlusWidgetsHeaderLaunchersButton* value);
static ProtonPlusWidgetsHeaderLaunchersButton* proton_plus_widgets_header_box_get_launchers_button (ProtonPlusWidgetsHeaderBox* self);
static void __lambda197_ (ProtonPlusWidgetsHeaderBox* self,
                   ProtonPlusModelsLauncher* launcher);
static void ___lambda197__proton_plus_widgets_header_launchers_button_launcher_selected (ProtonPlusWidgetsHeaderLaunchersButton* _sender,
                                                                                  ProtonPlusModelsLauncher* launcher,
                                                                                  gpointer self);
static void proton_plus_widgets_header_box_set_downloads_indicator (ProtonPlusWidgetsHeaderBox* self,
                                                             ProtonPlusWidgetsHeaderDownloadsIndicator* value);
static ProtonPlusWidgetsHeaderDownloadsIndicator* proton_plus_widgets_header_box_get_downloads_indicator (ProtonPlusWidgetsHeaderBox* self);
static void __lambda198_ (ProtonPlusWidgetsHeaderBox* self,
                   ProtonPlusServicesInstallJob* job);
static void ___lambda198__proton_plus_widgets_header_downloads_indicator_download_selected (ProtonPlusWidgetsHeaderDownloadsIndicator* _sender,
                                                                                     ProtonPlusServicesInstallJob* job,
                                                                                     gpointer self);
static void proton_plus_widgets_header_box_set_menu (ProtonPlusWidgetsHeaderBox* self,
                                              GMenu* value);
static void proton_plus_widgets_header_box_rebuild_menu (ProtonPlusWidgetsHeaderBox* self);
static void proton_plus_widgets_header_box_set_menu_button (ProtonPlusWidgetsHeaderBox* self,
                                                     GtkMenuButton* value);
static GtkMenuButton* proton_plus_widgets_header_box_get_menu_button (ProtonPlusWidgetsHeaderBox* self);
static GMenu* proton_plus_widgets_header_box_get_menu (ProtonPlusWidgetsHeaderBox* self);
static void proton_plus_widgets_header_box_set_back_button (ProtonPlusWidgetsHeaderBox* self,
                                                     GtkButton* value);
static GtkButton* proton_plus_widgets_header_box_get_back_button (ProtonPlusWidgetsHeaderBox* self);
static void __lambda199_ (ProtonPlusWidgetsHeaderBox* self);
static void ___lambda199__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static void proton_plus_widgets_header_box_set_header_bar (ProtonPlusWidgetsHeaderBox* self,
                                                    AdwHeaderBar* value);
static void proton_plus_widgets_header_box_update_title_widget (ProtonPlusWidgetsHeaderBox* self);
static void proton_plus_widgets_header_box_real_dispose (GObject* base);
static void proton_plus_widgets_header_box_finalize (GObject * obj);
static GType proton_plus_widgets_header_box_get_type_once (void);
static void _vala_proton_plus_widgets_header_box_get_property (GObject * object,
                                                        guint property_id,
                                                        GValue * value,
                                                        GParamSpec * pspec);
static void _vala_proton_plus_widgets_header_box_set_property (GObject * object,
                                                        guint property_id,
                                                        const GValue * value,
                                                        GParamSpec * pspec);

static inline gpointer
proton_plus_widgets_header_box_get_instance_private (ProtonPlusWidgetsHeaderBox* self)
{
	return G_STRUCT_MEMBER_P (self, ProtonPlusWidgetsHeaderBox_private_offset);
}

static void
__lambda197_ (ProtonPlusWidgetsHeaderBox* self,
              ProtonPlusModelsLauncher* launcher)
{
	g_return_if_fail (launcher != NULL);
	g_signal_emit (self, proton_plus_widgets_header_box_signals[PROTON_PLUS_WIDGETS_HEADER_BOX_LAUNCHER_SELECTED_SIGNAL], 0, launcher);
}

static void
___lambda197__proton_plus_widgets_header_launchers_button_launcher_selected (ProtonPlusWidgetsHeaderLaunchersButton* _sender,
                                                                             ProtonPlusModelsLauncher* launcher,
                                                                             gpointer self)
{
	__lambda197_ ((ProtonPlusWidgetsHeaderBox*) self, launcher);
}

static void
__lambda198_ (ProtonPlusWidgetsHeaderBox* self,
              ProtonPlusServicesInstallJob* job)
{
	g_return_if_fail (job != NULL);
	g_signal_emit (self, proton_plus_widgets_header_box_signals[PROTON_PLUS_WIDGETS_HEADER_BOX_DOWNLOAD_SELECTED_SIGNAL], 0, job);
}

static void
___lambda198__proton_plus_widgets_header_downloads_indicator_download_selected (ProtonPlusWidgetsHeaderDownloadsIndicator* _sender,
                                                                                ProtonPlusServicesInstallJob* job,
                                                                                gpointer self)
{
	__lambda198_ ((ProtonPlusWidgetsHeaderBox*) self, job);
}

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

static void
__lambda199_ (ProtonPlusWidgetsHeaderBox* self)
{
	ProtonPlusWidgetsHeaderPresentation* _tmp0_ = NULL;
	ProtonPlusWidgetsHeaderPresentation* _tmp1_;
	_tmp1_ = self->priv->current_presentation;
	_tmp0_ = _tmp1_;
	if (_tmp0_ != NULL) {
		proton_plus_widgets_header_presentation_request_back (_tmp0_);
	}
}

static void
___lambda199__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda199_ ((ProtonPlusWidgetsHeaderBox*) self);
}

ProtonPlusWidgetsHeaderBox*
proton_plus_widgets_header_box_construct (GType object_type)
{
	ProtonPlusWidgetsHeaderBox * self = NULL;
	ProtonPlusWidgetsHeaderLaunchersButton* _tmp0_;
	ProtonPlusWidgetsHeaderLaunchersButton* _tmp1_;
	ProtonPlusWidgetsHeaderLaunchersButton* _tmp2_;
	ProtonPlusWidgetsHeaderDownloadsIndicator* _tmp3_;
	ProtonPlusWidgetsHeaderDownloadsIndicator* _tmp4_;
	ProtonPlusWidgetsHeaderDownloadsIndicator* _tmp5_;
	GMenu* _tmp6_;
	GMenu* _tmp7_;
	GtkMenuButton* _tmp8_;
	GtkMenuButton* _tmp9_;
	GtkMenuButton* _tmp10_;
	GtkMenuButton* _tmp11_;
	GtkMenuButton* _tmp12_;
	GtkMenuButton* _tmp13_;
	GMenu* _tmp14_;
	GtkPopover* menu_popover = NULL;
	GtkMenuButton* _tmp15_;
	GtkPopover* _tmp16_;
	GtkPopover* _tmp17_;
	GtkPopover* _tmp18_;
	GtkButton* _tmp21_ = NULL;
	GtkButton* _tmp22_;
	GtkButton* _tmp23_;
	GtkButton* _tmp24_;
	GtkButton* _tmp25_;
	GtkButton* _tmp26_;
	AdwHeaderBar* _tmp27_;
	AdwHeaderBar* _tmp28_;
	AdwHeaderBar* _tmp29_;
	ProtonPlusWidgetsHeaderLaunchersButton* _tmp30_;
	AdwHeaderBar* _tmp31_;
	GtkButton* _tmp32_;
	AdwHeaderBar* _tmp33_;
	GtkMenuButton* _tmp34_;
	AdwHeaderBar* _tmp35_;
	ProtonPlusWidgetsHeaderDownloadsIndicator* _tmp36_;
	AdwHeaderBar* _tmp37_;
	AdwHeaderBar* _tmp38_;
	self = (ProtonPlusWidgetsHeaderBox*) g_object_new (object_type, NULL);
	_tmp0_ = proton_plus_widgets_header_launchers_button_new ();
	g_object_ref_sink (_tmp0_);
	_tmp1_ = _tmp0_;
	proton_plus_widgets_header_box_set_launchers_button (self, _tmp1_);
	_g_object_unref0 (_tmp1_);
	_tmp2_ = self->priv->_launchers_button;
	g_signal_connect_object (_tmp2_, "launcher-selected", (GCallback) ___lambda197__proton_plus_widgets_header_launchers_button_launcher_selected, self, 0);
	_tmp3_ = proton_plus_widgets_header_downloads_indicator_new ();
	g_object_ref_sink (_tmp3_);
	_tmp4_ = _tmp3_;
	proton_plus_widgets_header_box_set_downloads_indicator (self, _tmp4_);
	_g_object_unref0 (_tmp4_);
	_tmp5_ = self->priv->_downloads_indicator;
	g_signal_connect_object (_tmp5_, "download-selected", (GCallback) ___lambda198__proton_plus_widgets_header_downloads_indicator_download_selected, self, 0);
	_tmp6_ = g_menu_new ();
	_tmp7_ = _tmp6_;
	proton_plus_widgets_header_box_set_menu (self, _tmp7_);
	_g_object_unref0 (_tmp7_);
	proton_plus_widgets_header_box_rebuild_menu (self);
	_tmp8_ = (GtkMenuButton*) gtk_menu_button_new ();
	g_object_ref_sink (_tmp8_);
	_tmp9_ = _tmp8_;
	proton_plus_widgets_header_box_set_menu_button (self, _tmp9_);
	_g_object_unref0 (_tmp9_);
	_tmp10_ = self->priv->_menu_button;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp10_, _ ("Main Menu"));
	_tmp11_ = self->priv->_menu_button;
	gtk_menu_button_set_icon_name (_tmp11_, "open-menu-symbolic");
	_tmp12_ = self->priv->_menu_button;
	gtk_accessible_update_property ((GtkAccessible*) _tmp12_, GTK_ACCESSIBLE_PROPERTY_LABEL, _ ("Main Menu"), -1, -1);
	_tmp13_ = self->priv->_menu_button;
	_tmp14_ = self->priv->_menu;
	gtk_menu_button_set_menu_model (_tmp13_, (GMenuModel*) _tmp14_);
	_tmp15_ = self->priv->_menu_button;
	_tmp16_ = gtk_menu_button_get_popover (_tmp15_);
	_tmp17_ = _g_object_ref0 (_tmp16_);
	menu_popover = _tmp17_;
	_tmp18_ = menu_popover;
	if (_tmp18_ != NULL) {
		GtkPopover* _tmp19_;
		GtkMenuButton* _tmp20_;
		_tmp19_ = menu_popover;
		_tmp20_ = self->priv->_menu_button;
		proton_plus_widgets_window_register_popover_for_controller (G_TYPE_CHECK_INSTANCE_CAST (_tmp19_, gtk_popover_get_type (), GtkPopover), (GtkWidget*) _tmp20_, NULL);
	}
	_tmp21_ = (GtkButton*) gtk_button_new_from_icon_name ("go-previous-symbolic");
	gtk_widget_set_valign ((GtkWidget*) _tmp21_, GTK_ALIGN_CENTER);
	gtk_widget_set_visible ((GtkWidget*) _tmp21_, FALSE);
	g_object_ref_sink (_tmp21_);
	_tmp22_ = _tmp21_;
	proton_plus_widgets_header_box_set_back_button (self, _tmp22_);
	_g_object_unref0 (_tmp22_);
	_tmp23_ = self->priv->_back_button;
	gtk_widget_add_css_class ((GtkWidget*) _tmp23_, "flat");
	_tmp24_ = self->priv->_back_button;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp24_, _ ("Back"));
	_tmp25_ = self->priv->_back_button;
	gtk_accessible_update_property ((GtkAccessible*) _tmp25_, GTK_ACCESSIBLE_PROPERTY_LABEL, _ ("Back"), -1, -1);
	_tmp26_ = self->priv->_back_button;
	g_signal_connect_object (_tmp26_, "clicked", (GCallback) ___lambda199__gtk_button_clicked, self, 0);
	_tmp27_ = (AdwHeaderBar*) adw_header_bar_new ();
	g_object_ref_sink (_tmp27_);
	_tmp28_ = _tmp27_;
	proton_plus_widgets_header_box_set_header_bar (self, _tmp28_);
	_g_object_unref0 (_tmp28_);
	_tmp29_ = self->priv->_header_bar;
	_tmp30_ = self->priv->_launchers_button;
	adw_header_bar_pack_start (_tmp29_, (GtkWidget*) _tmp30_);
	_tmp31_ = self->priv->_header_bar;
	_tmp32_ = self->priv->_back_button;
	adw_header_bar_pack_start (_tmp31_, (GtkWidget*) _tmp32_);
	_tmp33_ = self->priv->_header_bar;
	_tmp34_ = self->priv->_menu_button;
	adw_header_bar_pack_end (_tmp33_, (GtkWidget*) _tmp34_);
	_tmp35_ = self->priv->_header_bar;
	_tmp36_ = self->priv->_downloads_indicator;
	adw_header_bar_pack_end (_tmp35_, (GtkWidget*) _tmp36_);
	_tmp37_ = self->priv->_header_bar;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp37_, TRUE);
	_tmp38_ = self->priv->_header_bar;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp38_);
	_g_object_unref0 (menu_popover);
	return self;
}

ProtonPlusWidgetsHeaderBox*
proton_plus_widgets_header_box_new (void)
{
	return proton_plus_widgets_header_box_construct (PROTON_PLUS_WIDGETS_HEADER_TYPE_BOX);
}

void
proton_plus_widgets_header_box_set_controller_mode_active (ProtonPlusWidgetsHeaderBox* self,
                                                           gboolean active)
{
	g_return_if_fail (self != NULL);
	if (self->priv->controller_mode_active == active) {
		return;
	}
	self->priv->controller_mode_active = active;
	proton_plus_widgets_header_box_rebuild_menu (self);
}

static void
proton_plus_widgets_header_box_rebuild_menu (ProtonPlusWidgetsHeaderBox* self)
{
	GMenu* _tmp0_;
	GMenu* settings_section = NULL;
	GMenu* _tmp1_;
	GMenu* _tmp2_;
	GMenu* _tmp3_;
	GMenu* _tmp4_;
	GMenu* help_section = NULL;
	GMenu* _tmp5_;
	GMenu* _tmp7_;
	GMenu* _tmp8_;
	GMenu* _tmp9_;
	GMenu* application_section = NULL;
	GMenu* _tmp10_;
	GMenu* _tmp11_;
	GMenu* _tmp12_;
	GMenu* _tmp14_;
	GMenu* _tmp15_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_menu;
	g_menu_remove_all (_tmp0_);
	_tmp1_ = g_menu_new ();
	settings_section = _tmp1_;
	_tmp2_ = settings_section;
	g_menu_append (_tmp2_, _ ("_Preferences"), "app.preferences");
	_tmp3_ = self->priv->_menu;
	_tmp4_ = settings_section;
	g_menu_append_section (_tmp3_, NULL, (GMenuModel*) _tmp4_);
	_tmp5_ = g_menu_new ();
	help_section = _tmp5_;
	if (!self->priv->controller_mode_active) {
		GMenu* _tmp6_;
		_tmp6_ = help_section;
		g_menu_append (_tmp6_, _ ("_Keyboard Shortcuts"), "win.show-help-overlay");
	}
	_tmp7_ = help_section;
	g_menu_append (_tmp7_, _ ("_Help"), "app.help");
	_tmp8_ = self->priv->_menu;
	_tmp9_ = help_section;
	g_menu_append_section (_tmp8_, NULL, (GMenuModel*) _tmp9_);
	_tmp10_ = g_menu_new ();
	application_section = _tmp10_;
	_tmp11_ = application_section;
	g_menu_append (_tmp11_, _ ("_Donate"), "app.donate");
	_tmp12_ = application_section;
	g_menu_append (_tmp12_, _ ("_About ProtonPlus"), "app.about");
	if (self->priv->controller_mode_active) {
		GMenu* _tmp13_;
		_tmp13_ = application_section;
		g_menu_append (_tmp13_, _ ("_Exit"), "app.quit");
	}
	_tmp14_ = self->priv->_menu;
	_tmp15_ = application_section;
	g_menu_append_section (_tmp14_, NULL, (GMenuModel*) _tmp15_);
	_g_object_unref0 (application_section);
	_g_object_unref0 (help_section);
	_g_object_unref0 (settings_section);
}

void
proton_plus_widgets_header_box_initialize (ProtonPlusWidgetsHeaderBox* self,
                                           GeeLinkedList* launchers,
                                           AdwViewSwitcher* view_switcher)
{
	ProtonPlusWidgetsHeaderLaunchersButton* _tmp0_;
	AdwViewSwitcher* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (launchers != NULL);
	g_return_if_fail (view_switcher != NULL);
	_tmp0_ = self->priv->_launchers_button;
	proton_plus_widgets_header_launchers_button_initialize (_tmp0_, launchers);
	_tmp1_ = _g_object_ref0 (view_switcher);
	_g_object_unref0 (self->priv->global_view_switcher);
	self->priv->global_view_switcher = _tmp1_;
	proton_plus_widgets_header_box_update_title_widget (self);
}

void
proton_plus_widgets_header_box_set_presentation (ProtonPlusWidgetsHeaderBox* self,
                                                 ProtonPlusWidgetsHeaderPresentation* presentation)
{
	ProtonPlusWidgetsHeaderPresentation* _tmp0_;
	ProtonPlusWidgetsHeaderPresentation* _tmp1_;
	ProtonPlusWidgetsHeaderPresentation* _tmp15_;
	gboolean _tmp16_ = FALSE;
	GtkButton* _tmp19_;
	ProtonPlusWidgetsHeaderLaunchersButton* _tmp20_;
	ProtonPlusWidgetsHeaderDownloadsIndicator* _tmp21_;
	GtkMenuButton* _tmp22_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->current_presentation;
	if (_tmp0_ == presentation) {
		proton_plus_widgets_header_box_update_title_widget (self);
		return;
	}
	_tmp1_ = self->priv->current_presentation;
	if (_tmp1_ != NULL) {
		ProtonPlusWidgetsHeaderPresentation* _tmp2_;
		_tmp2_ = self->priv->current_presentation;
		proton_plus_widgets_header_presentation_attach_back_widget (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, PROTON_PLUS_WIDGETS_HEADER_TYPE_PRESENTATION, ProtonPlusWidgetsHeaderPresentation), NULL);
		{
			GeeArrayList* _action_list = NULL;
			ProtonPlusWidgetsHeaderPresentation* _tmp3_;
			GeeArrayList* _tmp4_;
			GeeArrayList* _tmp5_;
			gint _action_size = 0;
			GeeArrayList* _tmp6_;
			gint _tmp7_;
			gint _tmp8_;
			gint _action_index = 0;
			_tmp3_ = self->priv->current_presentation;
			_tmp4_ = proton_plus_widgets_header_presentation_get_end_actions (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, PROTON_PLUS_WIDGETS_HEADER_TYPE_PRESENTATION, ProtonPlusWidgetsHeaderPresentation));
			_tmp5_ = _tmp4_;
			_action_list = _tmp5_;
			_tmp6_ = _action_list;
			_tmp7_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp6_);
			_tmp8_ = _tmp7_;
			_action_size = _tmp8_;
			_action_index = -1;
			while (TRUE) {
				gint _tmp9_;
				gint _tmp10_;
				GtkWidget* action = NULL;
				GeeArrayList* _tmp11_;
				gpointer _tmp12_;
				AdwHeaderBar* _tmp13_;
				GtkWidget* _tmp14_;
				_action_index = _action_index + 1;
				_tmp9_ = _action_index;
				_tmp10_ = _action_size;
				if (!(_tmp9_ < _tmp10_)) {
					break;
				}
				_tmp11_ = _action_list;
				_tmp12_ = gee_abstract_list_get ((GeeAbstractList*) _tmp11_, _action_index);
				action = (GtkWidget*) _tmp12_;
				_tmp13_ = self->priv->_header_bar;
				_tmp14_ = action;
				adw_header_bar_remove (_tmp13_, _tmp14_);
				_g_object_unref0 (action);
			}
		}
	}
	_tmp15_ = _g_object_ref0 (presentation);
	_g_object_unref0 (self->priv->current_presentation);
	self->priv->current_presentation = _tmp15_;
	if (presentation != NULL) {
		gboolean _tmp17_;
		gboolean _tmp18_;
		_tmp17_ = proton_plus_widgets_header_presentation_get_can_navigate_back (G_TYPE_CHECK_INSTANCE_CAST (presentation, PROTON_PLUS_WIDGETS_HEADER_TYPE_PRESENTATION, ProtonPlusWidgetsHeaderPresentation));
		_tmp18_ = _tmp17_;
		_tmp16_ = _tmp18_;
	} else {
		_tmp16_ = FALSE;
	}
	_tmp19_ = self->priv->_back_button;
	gtk_widget_set_visible ((GtkWidget*) _tmp19_, _tmp16_);
	_tmp20_ = self->priv->_launchers_button;
	gtk_widget_set_visible ((GtkWidget*) _tmp20_, presentation == NULL);
	_tmp21_ = self->priv->_downloads_indicator;
	proton_plus_widgets_header_downloads_indicator_set_global_header_visible (_tmp21_, presentation == NULL);
	_tmp22_ = self->priv->_menu_button;
	gtk_widget_set_visible ((GtkWidget*) _tmp22_, presentation == NULL);
	if (presentation != NULL) {
		GtkButton* _tmp23_;
		_tmp23_ = self->priv->_back_button;
		proton_plus_widgets_header_presentation_attach_back_widget (G_TYPE_CHECK_INSTANCE_CAST (presentation, PROTON_PLUS_WIDGETS_HEADER_TYPE_PRESENTATION, ProtonPlusWidgetsHeaderPresentation), (GtkWidget*) _tmp23_);
		{
			GeeArrayList* _action_list = NULL;
			GeeArrayList* _tmp24_;
			GeeArrayList* _tmp25_;
			gint _action_size = 0;
			GeeArrayList* _tmp26_;
			gint _tmp27_;
			gint _tmp28_;
			gint _action_index = 0;
			_tmp24_ = proton_plus_widgets_header_presentation_get_end_actions (G_TYPE_CHECK_INSTANCE_CAST (presentation, PROTON_PLUS_WIDGETS_HEADER_TYPE_PRESENTATION, ProtonPlusWidgetsHeaderPresentation));
			_tmp25_ = _tmp24_;
			_action_list = _tmp25_;
			_tmp26_ = _action_list;
			_tmp27_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp26_);
			_tmp28_ = _tmp27_;
			_action_size = _tmp28_;
			_action_index = -1;
			while (TRUE) {
				gint _tmp29_;
				gint _tmp30_;
				GtkWidget* action = NULL;
				GeeArrayList* _tmp31_;
				gpointer _tmp32_;
				AdwHeaderBar* _tmp33_;
				GtkWidget* _tmp34_;
				_action_index = _action_index + 1;
				_tmp29_ = _action_index;
				_tmp30_ = _action_size;
				if (!(_tmp29_ < _tmp30_)) {
					break;
				}
				_tmp31_ = _action_list;
				_tmp32_ = gee_abstract_list_get ((GeeAbstractList*) _tmp31_, _action_index);
				action = (GtkWidget*) _tmp32_;
				_tmp33_ = self->priv->_header_bar;
				_tmp34_ = action;
				adw_header_bar_pack_end (_tmp33_, _tmp34_);
				_g_object_unref0 (action);
			}
		}
	}
	proton_plus_widgets_header_box_update_title_widget (self);
}

static void
proton_plus_widgets_header_box_update_title_widget (ProtonPlusWidgetsHeaderBox* self)
{
	ProtonPlusWidgetsHeaderPresentation* _tmp0_;
	gboolean _tmp5_ = FALSE;
	gboolean _tmp6_ = FALSE;
	gboolean _tmp7_;
	gboolean _tmp8_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->current_presentation;
	if (_tmp0_ != NULL) {
		AdwHeaderBar* _tmp1_;
		ProtonPlusWidgetsHeaderPresentation* _tmp2_;
		GtkWidget* _tmp3_;
		GtkWidget* _tmp4_;
		_tmp1_ = self->priv->_header_bar;
		_tmp2_ = self->priv->current_presentation;
		_tmp3_ = proton_plus_widgets_header_presentation_get_title_widget (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, PROTON_PLUS_WIDGETS_HEADER_TYPE_PRESENTATION, ProtonPlusWidgetsHeaderPresentation));
		_tmp4_ = _tmp3_;
		adw_header_bar_set_title_widget (_tmp1_, _tmp4_);
		return;
	}
	_tmp7_ = proton_plus_widgets_header_box_get_narrow_navigation (self);
	_tmp8_ = _tmp7_;
	if (!_tmp8_) {
		AdwViewSwitcher* _tmp9_;
		_tmp9_ = self->priv->global_view_switcher;
		_tmp6_ = _tmp9_ != NULL;
	} else {
		_tmp6_ = FALSE;
	}
	if (_tmp6_) {
		gboolean _tmp10_ = FALSE;
		AdwViewSwitcher* _tmp11_;
		GtkWidget* _tmp12_;
		_tmp11_ = self->priv->global_view_switcher;
		_tmp12_ = gtk_widget_get_parent ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (_tmp11_, adw_view_switcher_get_type (), AdwViewSwitcher));
		if (_tmp12_ == NULL) {
			_tmp10_ = TRUE;
		} else {
			AdwHeaderBar* _tmp13_;
			GtkWidget* _tmp14_;
			AdwViewSwitcher* _tmp15_;
			_tmp13_ = self->priv->_header_bar;
			_tmp14_ = adw_header_bar_get_title_widget (_tmp13_);
			_tmp15_ = self->priv->global_view_switcher;
			_tmp10_ = _tmp14_ == G_TYPE_CHECK_INSTANCE_CAST (_tmp15_, gtk_widget_get_type (), GtkWidget);
		}
		_tmp5_ = _tmp10_;
	} else {
		_tmp5_ = FALSE;
	}
	if (_tmp5_) {
		AdwHeaderBar* _tmp16_;
		AdwViewSwitcher* _tmp17_;
		_tmp16_ = self->priv->_header_bar;
		_tmp17_ = self->priv->global_view_switcher;
		adw_header_bar_set_title_widget (_tmp16_, (GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (_tmp17_, adw_view_switcher_get_type (), AdwViewSwitcher));
	} else {
		AdwHeaderBar* _tmp18_;
		_tmp18_ = self->priv->_header_bar;
		adw_header_bar_set_title_widget (_tmp18_, NULL);
	}
}

void
proton_plus_widgets_header_box_open_menu (ProtonPlusWidgetsHeaderBox* self)
{
	GtkMenuButton* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_menu_button;
	g_signal_emit_by_name (_tmp0_, "activate");
}

void
proton_plus_widgets_header_box_open_launchers (ProtonPlusWidgetsHeaderBox* self)
{
	ProtonPlusWidgetsHeaderLaunchersButton* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_launchers_button;
	proton_plus_widgets_header_launchers_button_button_clicked (_tmp0_);
}

gboolean
proton_plus_widgets_header_box_focus_launchers (ProtonPlusWidgetsHeaderBox* self)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	ProtonPlusWidgetsHeaderLaunchersButton* _tmp3_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp3_ = self->priv->_launchers_button;
	if (gtk_widget_get_mapped ((GtkWidget*) _tmp3_)) {
		ProtonPlusWidgetsHeaderLaunchersButton* _tmp4_;
		_tmp4_ = self->priv->_launchers_button;
		_tmp2_ = gtk_widget_is_visible ((GtkWidget*) _tmp4_);
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		ProtonPlusWidgetsHeaderLaunchersButton* _tmp5_;
		_tmp5_ = self->priv->_launchers_button;
		_tmp1_ = gtk_widget_is_sensitive ((GtkWidget*) _tmp5_);
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		ProtonPlusWidgetsHeaderLaunchersButton* _tmp6_;
		_tmp6_ = self->priv->_launchers_button;
		_tmp0_ = gtk_widget_grab_focus ((GtkWidget*) _tmp6_);
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

gboolean
proton_plus_widgets_header_box_select_launcher (ProtonPlusWidgetsHeaderBox* self,
                                                ProtonPlusModelsLauncher* launcher)
{
	ProtonPlusWidgetsHeaderLaunchersButton* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (launcher != NULL, FALSE);
	_tmp0_ = self->priv->_launchers_button;
	result = proton_plus_widgets_header_launchers_button_select_launcher (_tmp0_, launcher);
	return result;
}

static void
proton_plus_widgets_header_box_real_dispose (GObject* base)
{
	ProtonPlusWidgetsHeaderBox * self;
	ProtonPlusWidgetsHeaderPresentation* _tmp0_;
	self = (ProtonPlusWidgetsHeaderBox*) base;
	_tmp0_ = self->priv->current_presentation;
	if (_tmp0_ != NULL) {
		ProtonPlusWidgetsHeaderPresentation* _tmp1_;
		_tmp1_ = self->priv->current_presentation;
		proton_plus_widgets_header_presentation_attach_back_widget (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, PROTON_PLUS_WIDGETS_HEADER_TYPE_PRESENTATION, ProtonPlusWidgetsHeaderPresentation), NULL);
	}
	_g_object_unref0 (self->priv->current_presentation);
	self->priv->current_presentation = NULL;
	_g_object_unref0 (self->priv->global_view_switcher);
	self->priv->global_view_switcher = NULL;
	G_OBJECT_CLASS (proton_plus_widgets_header_box_parent_class)->dispose ((GObject*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_box_get_type (), GtkBox));
}

AdwHeaderBar*
proton_plus_widgets_header_box_get_header_bar (ProtonPlusWidgetsHeaderBox* self)
{
	AdwHeaderBar* result;
	AdwHeaderBar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_header_bar;
	result = _tmp0_;
	return result;
}

static void
proton_plus_widgets_header_box_set_header_bar (ProtonPlusWidgetsHeaderBox* self,
                                               AdwHeaderBar* value)
{
	AdwHeaderBar* old_value;
	g_return_if_fail (self != NULL);
	old_value = proton_plus_widgets_header_box_get_header_bar (self);
	if (old_value != value) {
		AdwHeaderBar* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_header_bar);
		self->priv->_header_bar = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, proton_plus_widgets_header_box_properties[PROTON_PLUS_WIDGETS_HEADER_BOX_HEADER_BAR_PROPERTY]);
	}
}

static ProtonPlusWidgetsHeaderLaunchersButton*
proton_plus_widgets_header_box_get_launchers_button (ProtonPlusWidgetsHeaderBox* self)
{
	ProtonPlusWidgetsHeaderLaunchersButton* result;
	ProtonPlusWidgetsHeaderLaunchersButton* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_launchers_button;
	result = _tmp0_;
	return result;
}

static void
proton_plus_widgets_header_box_set_launchers_button (ProtonPlusWidgetsHeaderBox* self,
                                                     ProtonPlusWidgetsHeaderLaunchersButton* value)
{
	ProtonPlusWidgetsHeaderLaunchersButton* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_launchers_button);
	self->priv->_launchers_button = _tmp0_;
}

static ProtonPlusWidgetsHeaderDownloadsIndicator*
proton_plus_widgets_header_box_get_downloads_indicator (ProtonPlusWidgetsHeaderBox* self)
{
	ProtonPlusWidgetsHeaderDownloadsIndicator* result;
	ProtonPlusWidgetsHeaderDownloadsIndicator* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_downloads_indicator;
	result = _tmp0_;
	return result;
}

static void
proton_plus_widgets_header_box_set_downloads_indicator (ProtonPlusWidgetsHeaderBox* self,
                                                        ProtonPlusWidgetsHeaderDownloadsIndicator* value)
{
	ProtonPlusWidgetsHeaderDownloadsIndicator* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_downloads_indicator);
	self->priv->_downloads_indicator = _tmp0_;
}

static GtkMenuButton*
proton_plus_widgets_header_box_get_menu_button (ProtonPlusWidgetsHeaderBox* self)
{
	GtkMenuButton* result;
	GtkMenuButton* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_menu_button;
	result = _tmp0_;
	return result;
}

static void
proton_plus_widgets_header_box_set_menu_button (ProtonPlusWidgetsHeaderBox* self,
                                                GtkMenuButton* value)
{
	GtkMenuButton* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_menu_button);
	self->priv->_menu_button = _tmp0_;
}

static GtkButton*
proton_plus_widgets_header_box_get_back_button (ProtonPlusWidgetsHeaderBox* self)
{
	GtkButton* result;
	GtkButton* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_back_button;
	result = _tmp0_;
	return result;
}

static void
proton_plus_widgets_header_box_set_back_button (ProtonPlusWidgetsHeaderBox* self,
                                                GtkButton* value)
{
	GtkButton* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_back_button);
	self->priv->_back_button = _tmp0_;
}

static GMenu*
proton_plus_widgets_header_box_get_menu (ProtonPlusWidgetsHeaderBox* self)
{
	GMenu* result;
	GMenu* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_menu;
	result = _tmp0_;
	return result;
}

static void
proton_plus_widgets_header_box_set_menu (ProtonPlusWidgetsHeaderBox* self,
                                         GMenu* value)
{
	GMenu* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_menu);
	self->priv->_menu = _tmp0_;
}

gboolean
proton_plus_widgets_header_box_get_narrow_navigation (ProtonPlusWidgetsHeaderBox* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_narrow_navigation;
	return result;
}

void
proton_plus_widgets_header_box_set_narrow_navigation (ProtonPlusWidgetsHeaderBox* self,
                                                      gboolean value)
{
	g_return_if_fail (self != NULL);
	if (self->priv->_narrow_navigation == value) {
		return;
	}
	self->priv->_narrow_navigation = value;
	proton_plus_widgets_header_box_update_title_widget (self);
	g_object_notify_by_pspec ((GObject *) self, proton_plus_widgets_header_box_properties[PROTON_PLUS_WIDGETS_HEADER_BOX_NARROW_NAVIGATION_PROPERTY]);
}

static void
proton_plus_widgets_header_box_class_init (ProtonPlusWidgetsHeaderBoxClass * klass,
                                           gpointer klass_data)
{
	proton_plus_widgets_header_box_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ProtonPlusWidgetsHeaderBox_private_offset);
	((GObjectClass *) klass)->dispose = (void (*) (GObject*)) proton_plus_widgets_header_box_real_dispose;
	G_OBJECT_CLASS (klass)->get_property = _vala_proton_plus_widgets_header_box_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_proton_plus_widgets_header_box_set_property;
	G_OBJECT_CLASS (klass)->finalize = proton_plus_widgets_header_box_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), PROTON_PLUS_WIDGETS_HEADER_BOX_HEADER_BAR_PROPERTY, proton_plus_widgets_header_box_properties[PROTON_PLUS_WIDGETS_HEADER_BOX_HEADER_BAR_PROPERTY] = g_param_spec_object ("header-bar", "header-bar", "header-bar", adw_header_bar_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), PROTON_PLUS_WIDGETS_HEADER_BOX_NARROW_NAVIGATION_PROPERTY, proton_plus_widgets_header_box_properties[PROTON_PLUS_WIDGETS_HEADER_BOX_NARROW_NAVIGATION_PROPERTY] = g_param_spec_boolean ("narrow-navigation", "narrow-navigation", "narrow-navigation", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	proton_plus_widgets_header_box_signals[PROTON_PLUS_WIDGETS_HEADER_BOX_LAUNCHER_SELECTED_SIGNAL] = g_signal_new ("launcher-selected", PROTON_PLUS_WIDGETS_HEADER_TYPE_BOX, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, PROTON_PLUS_MODELS_TYPE_LAUNCHER);
	proton_plus_widgets_header_box_signals[PROTON_PLUS_WIDGETS_HEADER_BOX_DOWNLOAD_SELECTED_SIGNAL] = g_signal_new ("download-selected", PROTON_PLUS_WIDGETS_HEADER_TYPE_BOX, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, PROTON_PLUS_SERVICES_TYPE_INSTALL_JOB);
}

static void
proton_plus_widgets_header_box_instance_init (ProtonPlusWidgetsHeaderBox * self,
                                              gpointer klass)
{
	self->priv = proton_plus_widgets_header_box_get_instance_private (self);
	self->priv->controller_mode_active = FALSE;
	self->priv->_narrow_navigation = FALSE;
}

static void
proton_plus_widgets_header_box_finalize (GObject * obj)
{
	ProtonPlusWidgetsHeaderBox * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PROTON_PLUS_WIDGETS_HEADER_TYPE_BOX, ProtonPlusWidgetsHeaderBox);
	_g_object_unref0 (self->priv->_header_bar);
	_g_object_unref0 (self->priv->_launchers_button);
	_g_object_unref0 (self->priv->_downloads_indicator);
	_g_object_unref0 (self->priv->_menu_button);
	_g_object_unref0 (self->priv->_back_button);
	_g_object_unref0 (self->priv->_menu);
	_g_object_unref0 (self->priv->global_view_switcher);
	_g_object_unref0 (self->priv->current_presentation);
	G_OBJECT_CLASS (proton_plus_widgets_header_box_parent_class)->finalize (obj);
}

static GType
proton_plus_widgets_header_box_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ProtonPlusWidgetsHeaderBoxClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proton_plus_widgets_header_box_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtonPlusWidgetsHeaderBox), 0, (GInstanceInitFunc) proton_plus_widgets_header_box_instance_init, NULL };
	GType proton_plus_widgets_header_box_type_id;
	proton_plus_widgets_header_box_type_id = g_type_register_static (gtk_box_get_type (), "ProtonPlusWidgetsHeaderBox", &g_define_type_info, 0);
	ProtonPlusWidgetsHeaderBox_private_offset = g_type_add_instance_private (proton_plus_widgets_header_box_type_id, sizeof (ProtonPlusWidgetsHeaderBoxPrivate));
	return proton_plus_widgets_header_box_type_id;
}

GType
proton_plus_widgets_header_box_get_type (void)
{
	static volatile gsize proton_plus_widgets_header_box_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_widgets_header_box_type_id__once)) {
		GType proton_plus_widgets_header_box_type_id;
		proton_plus_widgets_header_box_type_id = proton_plus_widgets_header_box_get_type_once ();
		g_once_init_leave (&proton_plus_widgets_header_box_type_id__once, proton_plus_widgets_header_box_type_id);
	}
	return proton_plus_widgets_header_box_type_id__once;
}

static void
_vala_proton_plus_widgets_header_box_get_property (GObject * object,
                                                   guint property_id,
                                                   GValue * value,
                                                   GParamSpec * pspec)
{
	ProtonPlusWidgetsHeaderBox * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PROTON_PLUS_WIDGETS_HEADER_TYPE_BOX, ProtonPlusWidgetsHeaderBox);
	switch (property_id) {
		case PROTON_PLUS_WIDGETS_HEADER_BOX_HEADER_BAR_PROPERTY:
		g_value_set_object (value, proton_plus_widgets_header_box_get_header_bar (self));
		break;
		case PROTON_PLUS_WIDGETS_HEADER_BOX_NARROW_NAVIGATION_PROPERTY:
		g_value_set_boolean (value, proton_plus_widgets_header_box_get_narrow_navigation (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_proton_plus_widgets_header_box_set_property (GObject * object,
                                                   guint property_id,
                                                   const GValue * value,
                                                   GParamSpec * pspec)
{
	ProtonPlusWidgetsHeaderBox * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PROTON_PLUS_WIDGETS_HEADER_TYPE_BOX, ProtonPlusWidgetsHeaderBox);
	switch (property_id) {
		case PROTON_PLUS_WIDGETS_HEADER_BOX_HEADER_BAR_PROPERTY:
		proton_plus_widgets_header_box_set_header_bar (self, g_value_get_object (value));
		break;
		case PROTON_PLUS_WIDGETS_HEADER_BOX_NARROW_NAVIGATION_PROPERTY:
		proton_plus_widgets_header_box_set_narrow_navigation (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

