/* MapsView.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from MapsView.vala, do not modify */

/*
 * Copyright 2025 elementary, Inc. (https://elementary.io)
 * SPDX-License-Identifier: LGPL-3.0-or-later
 */

#include "granite-7.h"
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <shumate/shumate.h>
#include <float.h>
#include <math.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define TYPE_DEMO_PAGE (demo_page_get_type ())
#define DEMO_PAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DEMO_PAGE, DemoPage))
#define DEMO_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DEMO_PAGE, DemoPageClass))
#define IS_DEMO_PAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DEMO_PAGE))
#define IS_DEMO_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DEMO_PAGE))
#define DEMO_PAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DEMO_PAGE, DemoPageClass))

typedef struct _DemoPage DemoPage;
typedef struct _DemoPageClass DemoPageClass;
typedef struct _DemoPagePrivate DemoPagePrivate;

#define TYPE_MAPS_VIEW (maps_view_get_type ())
#define MAPS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MAPS_VIEW, MapsView))
#define MAPS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MAPS_VIEW, MapsViewClass))
#define IS_MAPS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MAPS_VIEW))
#define IS_MAPS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MAPS_VIEW))
#define MAPS_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MAPS_VIEW, MapsViewClass))

typedef struct _MapsView MapsView;
typedef struct _MapsViewClass MapsViewClass;
typedef struct _MapsViewPrivate MapsViewPrivate;
enum  {
	MAPS_VIEW_0_PROPERTY,
	MAPS_VIEW_NUM_PROPERTIES
};
static GParamSpec* maps_view_properties[MAPS_VIEW_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _DemoPage {
	GraniteToolBox parent_instance;
	DemoPagePrivate * priv;
};

struct _DemoPageClass {
	GraniteToolBoxClass parent_class;
};

struct _MapsView {
	DemoPage parent_instance;
	MapsViewPrivate * priv;
};

struct _MapsViewClass {
	DemoPageClass parent_class;
};

struct _MapsViewPrivate {
	gchar* styles;
};

static gint MapsView_private_offset;
static gpointer maps_view_parent_class = NULL;

VALA_EXTERN GType demo_page_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DemoPage, g_object_unref)
VALA_EXTERN GType maps_view_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MapsView, g_object_unref)
VALA_EXTERN MapsView* maps_view_new (void);
VALA_EXTERN MapsView* maps_view_construct (GType object_type);
VALA_EXTERN DemoPage* demo_page_new (void);
VALA_EXTERN DemoPage* demo_page_construct (GType object_type);
static GObject * maps_view_constructor (GType type,
                                 guint n_construct_properties,
                                 GObjectConstructParam * construct_properties);
VALA_EXTERN void demo_page_set_title (DemoPage* self,
                          const gchar* value);
VALA_EXTERN void demo_page_set_child (DemoPage* self,
                          GtkWidget* value);
static void maps_view_finalize (GObject * obj);
static GType maps_view_get_type_once (void);

static inline gpointer
maps_view_get_instance_private (MapsView* self)
{
	return G_STRUCT_MEMBER_P (self, MapsView_private_offset);
}

MapsView*
maps_view_construct (GType object_type)
{
	MapsView * self = NULL;
	self = (MapsView*) demo_page_construct (object_type);
	return self;
}

MapsView*
maps_view_new (void)
{
	return maps_view_construct (TYPE_MAPS_VIEW);
}

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

static GObject *
maps_view_constructor (GType type,
                       guint n_construct_properties,
                       GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	MapsView * self;
	GtkCssProvider* style_provider = NULL;
	GtkCssProvider* _tmp0_;
	GtkCssProvider* _tmp1_;
	const gchar* _tmp2_;
	GdkDisplay* _tmp3_;
	GtkCssProvider* _tmp4_;
	ShumateMapSourceRegistry* registry = NULL;
	ShumateMapSourceRegistry* _tmp5_;
	ShumateSimpleMap* simple_map = NULL;
	ShumateMapSourceRegistry* _tmp6_;
	ShumateMapSource* _tmp7_;
	ShumateMapSource* _tmp8_;
	ShumateSimpleMap* _tmp9_ = NULL;
	ShumateSimpleMap* _tmp10_;
	ShumateMarker* point = NULL;
	GtkImage* _tmp11_ = NULL;
	ShumateMarker* _tmp12_ = NULL;
	ShumateMarker* self_point = NULL;
	GtkGrid* _tmp13_;
	ShumateMarker* _tmp14_ = NULL;
	ShumateMarker* _tmp15_;
	ShumateMarkerLayer* marker_layer = NULL;
	ShumateSimpleMap* _tmp16_;
	ShumateViewport* _tmp17_;
	ShumateViewport* _tmp18_;
	ShumateMarkerLayer* _tmp19_;
	ShumateMarkerLayer* _tmp20_;
	ShumateMarker* _tmp21_;
	ShumateMarkerLayer* _tmp22_;
	ShumateMarker* _tmp23_;
	ShumateViewport* map_view = NULL;
	ShumateSimpleMap* _tmp24_;
	ShumateViewport* _tmp25_;
	ShumateViewport* _tmp26_;
	ShumateViewport* _tmp27_;
	ShumateViewport* _tmp28_;
	ShumateMap* map = NULL;
	ShumateSimpleMap* _tmp29_;
	ShumateMap* _tmp30_;
	ShumateMap* _tmp31_;
	ShumateMap* _tmp32_;
	ShumateMap* _tmp33_;
	ShumateMarkerLayer* _tmp34_;
	ShumateMap* _tmp35_;
	ShumateMarker* _tmp36_;
	gdouble _tmp37_;
	gdouble _tmp38_;
	ShumateMarker* _tmp39_;
	gdouble _tmp40_;
	gdouble _tmp41_;
	ShumateSimpleMap* _tmp42_;
	parent_class = G_OBJECT_CLASS (maps_view_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_MAPS_VIEW, MapsView);
	demo_page_set_title ((DemoPage*) self, "Shumate.SimpleMap");
	_tmp0_ = gtk_css_provider_new ();
	style_provider = _tmp0_;
	_tmp1_ = style_provider;
	_tmp2_ = self->priv->styles;
	gtk_css_provider_load_from_string (_tmp1_, _tmp2_);
	_tmp3_ = gdk_display_get_default ();
	_tmp4_ = style_provider;
	gtk_style_context_add_provider_for_display (_tmp3_, (GtkStyleProvider*) _tmp4_, (guint) GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
	_tmp5_ = shumate_map_source_registry_new_with_defaults ();
	registry = _tmp5_;
	_tmp6_ = registry;
	_tmp7_ = shumate_map_source_registry_get_by_id (_tmp6_, SHUMATE_MAP_SOURCE_OSM_MAPNIK);
	_tmp8_ = _g_object_ref0 (_tmp7_);
	_tmp9_ = shumate_simple_map_new ();
	shumate_simple_map_set_map_source (_tmp9_, _tmp8_);
	_g_object_unref0 (_tmp8_);
	gtk_widget_set_overflow ((GtkWidget*) _tmp9_, GTK_OVERFLOW_HIDDEN);
	gtk_widget_set_vexpand ((GtkWidget*) _tmp9_, TRUE);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp9_, 12);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp9_, 12);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp9_, 12);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp9_, 12);
	g_object_ref_sink (_tmp9_);
	simple_map = _tmp9_;
	_tmp10_ = simple_map;
	gtk_widget_add_css_class ((GtkWidget*) _tmp10_, GRANITE_CSS_CLASS_CARD);
	_tmp11_ = (GtkImage*) gtk_image_new_from_icon_name ("map-marker");
	gtk_image_set_pixel_size (_tmp11_, 48);
	g_object_ref_sink (_tmp11_);
	_tmp12_ = shumate_marker_new ();
	shumate_marker_set_child (_tmp12_, (GtkWidget*) _tmp11_);
	_g_object_unref0 (_tmp11_);
	g_object_set ((ShumateLocation*) _tmp12_, "latitude", 38.580753, NULL);
	g_object_set ((ShumateLocation*) _tmp12_, "longitude", -121.487300, NULL);
	g_object_ref_sink (_tmp12_);
	point = _tmp12_;
	_tmp13_ = (GtkGrid*) gtk_grid_new ();
	g_object_ref_sink (_tmp13_);
	_tmp14_ = shumate_marker_new ();
	shumate_marker_set_child (_tmp14_, (GtkWidget*) _tmp13_);
	_g_object_unref0 (_tmp13_);
	g_object_set ((ShumateLocation*) _tmp14_, "latitude", 38.575764, NULL);
	g_object_set ((ShumateLocation*) _tmp14_, "longitude", -121.478851, NULL);
	g_object_ref_sink (_tmp14_);
	self_point = _tmp14_;
	_tmp15_ = self_point;
	gtk_widget_add_css_class ((GtkWidget*) _tmp15_, "self");
	_tmp16_ = simple_map;
	_tmp17_ = shumate_simple_map_get_viewport (_tmp16_);
	_tmp18_ = _tmp17_;
	_tmp19_ = shumate_marker_layer_new_full (_tmp18_, GTK_SELECTION_SINGLE);
	g_object_ref_sink (_tmp19_);
	marker_layer = _tmp19_;
	_tmp20_ = marker_layer;
	_tmp21_ = point;
	shumate_marker_layer_add_marker (_tmp20_, _tmp21_);
	_tmp22_ = marker_layer;
	_tmp23_ = self_point;
	shumate_marker_layer_add_marker (_tmp22_, _tmp23_);
	_tmp24_ = simple_map;
	_tmp25_ = shumate_simple_map_get_viewport (_tmp24_);
	_tmp26_ = _tmp25_;
	_tmp27_ = _g_object_ref0 (_tmp26_);
	map_view = _tmp27_;
	_tmp28_ = map_view;
	shumate_viewport_set_zoom_level (_tmp28_, (gdouble) 15);
	_tmp29_ = simple_map;
	_tmp30_ = shumate_simple_map_get_map (_tmp29_);
	_tmp31_ = _tmp30_;
	_tmp32_ = _g_object_ref0 (_tmp31_);
	map = _tmp32_;
	_tmp33_ = map;
	_tmp34_ = marker_layer;
	shumate_map_add_layer (_tmp33_, (ShumateLayer*) _tmp34_);
	_tmp35_ = map;
	_tmp36_ = self_point;
	g_object_get ((ShumateLocation*) _tmp36_, "latitude", &_tmp37_, NULL);
	_tmp38_ = _tmp37_;
	_tmp39_ = self_point;
	g_object_get ((ShumateLocation*) _tmp39_, "longitude", &_tmp40_, NULL);
	_tmp41_ = _tmp40_;
	shumate_map_center_on (_tmp35_, _tmp38_, _tmp41_);
	_tmp42_ = simple_map;
	demo_page_set_child ((DemoPage*) self, (GtkWidget*) _tmp42_);
	_g_object_unref0 (map);
	_g_object_unref0 (map_view);
	_g_object_unref0 (marker_layer);
	_g_object_unref0 (self_point);
	_g_object_unref0 (point);
	_g_object_unref0 (simple_map);
	_g_object_unref0 (registry);
	_g_object_unref0 (style_provider);
	return obj;
}

static void
maps_view_class_init (MapsViewClass * klass,
                      gpointer klass_data)
{
	maps_view_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &MapsView_private_offset);
	G_OBJECT_CLASS (klass)->constructor = maps_view_constructor;
	G_OBJECT_CLASS (klass)->finalize = maps_view_finalize;
}

static void
maps_view_instance_init (MapsView * self,
                         gpointer klass)
{
	gchar* _tmp0_;
	self->priv = maps_view_get_instance_private (self);
	_tmp0_ = g_strdup ("\n" \
"        map-marker.self {\n" \
"            background-color: @base_color;\n" \
"            border-radius: 50%;\n" \
"            box-shadow:\n" \
"                0 0 0 1px @borders,\n" \
"                0 3px 4px alpha(black, 0.15),\n" \
"                0 3px 3px -3px alpha(black, 0.35);\n" \
"            padding: 0.25rem;\n" \
"        }\n" \
"\n" \
"        map-marker.self grid {\n" \
"            background: @accent_color;\n" \
"            color: white;\n" \
"            border-radius: 50%;\n" \
"            min-height: 1rem;\n" \
"            min-width: 1rem;\n" \
"        }\n" \
"    ");
	self->priv->styles = _tmp0_;
}

static void
maps_view_finalize (GObject * obj)
{
	MapsView * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_MAPS_VIEW, MapsView);
	_g_free0 (self->priv->styles);
	G_OBJECT_CLASS (maps_view_parent_class)->finalize (obj);
}

static GType
maps_view_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (MapsViewClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) maps_view_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (MapsView), 0, (GInstanceInitFunc) maps_view_instance_init, NULL };
	GType maps_view_type_id;
	maps_view_type_id = g_type_register_static (TYPE_DEMO_PAGE, "MapsView", &g_define_type_info, 0);
	MapsView_private_offset = g_type_add_instance_private (maps_view_type_id, sizeof (MapsViewPrivate));
	return maps_view_type_id;
}

GType
maps_view_get_type (void)
{
	static volatile gsize maps_view_type_id__once = 0;
	if (g_once_init_enter (&maps_view_type_id__once)) {
		GType maps_view_type_id;
		maps_view_type_id = maps_view_get_type_once ();
		g_once_init_leave (&maps_view_type_id__once, maps_view_type_id);
	}
	return maps_view_type_id__once;
}

