/* components-headerbar-application.c generated by valac 0.56.3, the Vala compiler
 * generated from components-headerbar-application.vala, do not modify */

/*
 * Copyright © 2017 Software Freedom Conservancy Inc.
 * Copyright © 2021 Michael Gratton <mike@vee.net>
 * Copyright © 2022 Cédric Bellegarde <cedric.bellegarde@adishatz.org>
 *
 * This software is licensed under the GNU Lesser General Public License
 * (version 2.1 or later). See the COPYING file in this distribution.
 */

#include "geary-client-43.0.h"
#include <gtk/gtk.h>
#include <glib.h>
#include <glib-object.h>
#include <gio/gio.h>

enum  {
	COMPONENTS_APPLICATION_HEADER_BAR_0_PROPERTY,
	COMPONENTS_APPLICATION_HEADER_BAR_NUM_PROPERTIES
};
static GParamSpec* components_application_header_bar_properties[COMPONENTS_APPLICATION_HEADER_BAR_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _ComponentsApplicationHeaderBarPrivate {
	GtkMenuButton* app_menu_button;
};

static gint ComponentsApplicationHeaderBar_private_offset;
static gpointer components_application_header_bar_parent_class = NULL;

static GObject * components_application_header_bar_constructor (GType type,
                                                         guint n_construct_properties,
                                                         GObjectConstructParam * construct_properties);
static void components_application_header_bar_finalize (GObject * obj);
static GType components_application_header_bar_get_type_once (void);

static inline gpointer
components_application_header_bar_get_instance_private (ComponentsApplicationHeaderBar* self)
{
	return G_STRUCT_MEMBER_P (self, ComponentsApplicationHeaderBar_private_offset);
}

void
components_application_header_bar_show_app_menu (ComponentsApplicationHeaderBar* self)
{
	GtkMenuButton* _tmp0_;
	g_return_if_fail (COMPONENTS_IS_APPLICATION_HEADER_BAR (self));
	_tmp0_ = self->priv->app_menu_button;
	gtk_button_clicked (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, gtk_button_get_type (), GtkButton));
}

ComponentsApplicationHeaderBar*
components_application_header_bar_construct (GType object_type)
{
	ComponentsApplicationHeaderBar * self = NULL;
	self = (ComponentsApplicationHeaderBar*) g_object_new (object_type, NULL);
	return self;
}

ComponentsApplicationHeaderBar*
components_application_header_bar_new (void)
{
	return components_application_header_bar_construct (COMPONENTS_TYPE_APPLICATION_HEADER_BAR);
}

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

static GObject *
components_application_header_bar_constructor (GType type,
                                               guint n_construct_properties,
                                               GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	ComponentsApplicationHeaderBar * self;
	GtkBuilder* builder = NULL;
	GtkBuilder* _tmp0_;
	GMenuModel* app_menu = NULL;
	GtkBuilder* _tmp1_;
	GObject* _tmp2_;
	GMenuModel* _tmp3_;
	GtkMenuButton* _tmp4_;
	GMenuModel* _tmp5_;
	GtkPopover* _tmp6_;
	GtkPopover* _tmp7_;
	parent_class = G_OBJECT_CLASS (components_application_header_bar_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, COMPONENTS_TYPE_APPLICATION_HEADER_BAR, ComponentsApplicationHeaderBar);
	_tmp0_ = gtk_builder_new_from_resource ("/org/gnome/Geary/components-menu-application.ui");
	builder = _tmp0_;
	_tmp1_ = builder;
	_tmp2_ = gtk_builder_get_object (_tmp1_, "app_menu");
	_tmp3_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, g_menu_model_get_type (), GMenuModel));
	app_menu = _tmp3_;
	_tmp4_ = self->priv->app_menu_button;
	_tmp5_ = app_menu;
	_tmp6_ = (GtkPopover*) gtk_popover_new_from_model (NULL, _tmp5_);
	g_object_ref_sink (_tmp6_);
	_tmp7_ = _tmp6_;
	gtk_menu_button_set_popover (_tmp4_, _tmp7_);
	_g_object_unref0 (_tmp7_);
	_g_object_unref0 (app_menu);
	_g_object_unref0 (builder);
	return obj;
}

static void
components_application_header_bar_class_init (ComponentsApplicationHeaderBarClass * klass,
                                              gpointer klass_data)
{
	components_application_header_bar_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ComponentsApplicationHeaderBar_private_offset);
	G_OBJECT_CLASS (klass)->constructor = components_application_header_bar_constructor;
	G_OBJECT_CLASS (klass)->finalize = components_application_header_bar_finalize;
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/Geary/components-headerbar-application.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "app_menu_button", FALSE, ComponentsApplicationHeaderBar_private_offset + G_STRUCT_OFFSET (ComponentsApplicationHeaderBarPrivate, app_menu_button));
}

static void
components_application_header_bar_instance_init (ComponentsApplicationHeaderBar * self,
                                                 gpointer klass)
{
	self->priv = components_application_header_bar_get_instance_private (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
components_application_header_bar_finalize (GObject * obj)
{
	ComponentsApplicationHeaderBar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, COMPONENTS_TYPE_APPLICATION_HEADER_BAR, ComponentsApplicationHeaderBar);
	G_OBJECT_CLASS (components_application_header_bar_parent_class)->finalize (obj);
}

/**
 * The Application HeaderBar
 *
 * @see Application.MainWindow
 */
static GType
components_application_header_bar_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ComponentsApplicationHeaderBarClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) components_application_header_bar_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ComponentsApplicationHeaderBar), 0, (GInstanceInitFunc) components_application_header_bar_instance_init, NULL };
	GType components_application_header_bar_type_id;
	components_application_header_bar_type_id = g_type_register_static (hdy_header_bar_get_type (), "ComponentsApplicationHeaderBar", &g_define_type_info, 0);
	ComponentsApplicationHeaderBar_private_offset = g_type_add_instance_private (components_application_header_bar_type_id, sizeof (ComponentsApplicationHeaderBarPrivate));
	return components_application_header_bar_type_id;
}

GType
components_application_header_bar_get_type (void)
{
	static volatile gsize components_application_header_bar_type_id__once = 0;
	if (g_once_init_enter (&components_application_header_bar_type_id__once)) {
		GType components_application_header_bar_type_id;
		components_application_header_bar_type_id = components_application_header_bar_get_type_once ();
		g_once_init_leave (&components_application_header_bar_type_id__once, components_application_header_bar_type_id);
	}
	return components_application_header_bar_type_id__once;
}

