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

/* SPDX-License-Identifier: GPL-3.0-or-later*/

#include "graphs.h"
#include <adwaita.h>
#include <gtk/gtk.h>
#include <glib.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>
#include <glib-object.h>
#include <gdk/gdk.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  {
	GRAPHS_STYLE_EDITOR_0_PROPERTY,
	GRAPHS_STYLE_EDITOR_CONTENT_VIEW_PROPERTY,
	GRAPHS_STYLE_EDITOR_EDITOR_BOX_PROPERTY,
	GRAPHS_STYLE_EDITOR_CANVAS_PROPERTY,
	GRAPHS_STYLE_EDITOR_STYLENAME_PROPERTY,
	GRAPHS_STYLE_EDITOR_CSS_PROVIDER_PROPERTY,
	GRAPHS_STYLE_EDITOR_UNSAVED_PROPERTY,
	GRAPHS_STYLE_EDITOR_NUM_PROPERTIES
};
static GParamSpec* graphs_style_editor_properties[GRAPHS_STYLE_EDITOR_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

#define GRAPHS_TYPE_STYLE_PREVIEW (graphs_style_preview_get_type ())
#define GRAPHS_STYLE_PREVIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GRAPHS_TYPE_STYLE_PREVIEW, GraphsStylePreview))
#define GRAPHS_STYLE_PREVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GRAPHS_TYPE_STYLE_PREVIEW, GraphsStylePreviewClass))
#define GRAPHS_IS_STYLE_PREVIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GRAPHS_TYPE_STYLE_PREVIEW))
#define GRAPHS_IS_STYLE_PREVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GRAPHS_TYPE_STYLE_PREVIEW))
#define GRAPHS_STYLE_PREVIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GRAPHS_TYPE_STYLE_PREVIEW, GraphsStylePreviewClass))

typedef struct _GraphsStylePreview GraphsStylePreview;
typedef struct _GraphsStylePreviewClass GraphsStylePreviewClass;
typedef struct _Block12Data Block12Data;
typedef struct _Block13Data Block13Data;
typedef struct _Block14Data Block14Data;
typedef struct _Block15Data Block15Data;
enum  {
	GRAPHS_STYLE_EDITOR_LOAD_REQUEST_SIGNAL,
	GRAPHS_STYLE_EDITOR_SAVE_REQUEST_SIGNAL,
	GRAPHS_STYLE_EDITOR_NUM_SIGNALS
};
static guint graphs_style_editor_signals[GRAPHS_STYLE_EDITOR_NUM_SIGNALS] = {0};

struct _GraphsStyleEditorPrivate {
	AdwBin* _editor_bin;
	AdwBin* _canvas_bin;
	GtkStack* _stack;
	GtkGridView* _style_grid;
	AdwToolbarView* _content_view;
	GtkCssProvider* _css_provider;
	gboolean _unsaved;
	GFile* _file;
	gboolean _force_close;
	guint _inhibit_cookie;
	gchar* _stylename;
};

struct _Block12Data {
	int _ref_count_;
	GraphsStyleEditor* self;
	GraphsStyle* style;
};

struct _Block13Data {
	int _ref_count_;
	GraphsStyleEditor* self;
	GSimpleAction* save_action;
};

struct _Block14Data {
	int _ref_count_;
	GraphsStyleEditor* self;
	GtkFileDialog* dialog;
};

struct _Block15Data {
	int _ref_count_;
	GraphsStyleEditor* self;
	GtkFileDialog* dialog;
};

static gint GraphsStyleEditor_private_offset;
static gpointer graphs_style_editor_parent_class = NULL;

static GtkStack* graphs_style_editor_get_stack (GraphsStyleEditor* self);
static void graphs_style_editor_on_factory_setup (GraphsStyleEditor* self,
                                           GObject* object);
VALA_EXTERN GraphsStylePreview* graphs_style_preview_new (void);
VALA_EXTERN GraphsStylePreview* graphs_style_preview_construct (GType object_type);
VALA_EXTERN GType graphs_style_preview_get_type (void) G_GNUC_CONST ;
static void graphs_style_editor_on_factory_bind (GraphsStyleEditor* self,
                                          GObject* object);
static Block12Data* block12_data_ref (Block12Data* _data12_);
static void block12_data_unref (void * _userdata_);
VALA_EXTERN void graphs_style_preview_set_style (GraphsStylePreview* self,
                                     GraphsStyle* value);
VALA_EXTERN GtkMenuButton* graphs_style_preview_get_menu_button (GraphsStylePreview* self);
static void ___lambda5_ (Block12Data* _data12_);
static void ____lambda5__g_simple_action_activate (GSimpleAction* _sender,
                                            GVariant* parameter,
                                            gpointer self);
static void ___lambda6_ (Block12Data* _data12_);
static void ____lambda6__g_simple_action_activate (GSimpleAction* _sender,
                                            GVariant* parameter,
                                            gpointer self);
static void ___lambda7_ (Block12Data* _data12_);
static void __lambda8_ (Block12Data* _data12_,
                 AdwAlertDialog* d,
                 const gchar* response);
static void ___lambda8__adw_alert_dialog_response (AdwAlertDialog* _sender,
                                            const gchar* response,
                                            gpointer self);
static void ____lambda7__g_simple_action_activate (GSimpleAction* _sender,
                                            GVariant* parameter,
                                            gpointer self);
static gboolean graphs_style_editor_real_close_request (GtkWindow* base);
static void ___lambda75_ (GraphsStyleEditor* self,
                   AdwAlertDialog* d,
                   const gchar* response);
static void ____lambda75__adw_alert_dialog_response (AdwAlertDialog* _sender,
                                              const gchar* response,
                                              gpointer self);
static AdwBin* graphs_style_editor_get_editor_bin (GraphsStyleEditor* self);
static AdwBin* graphs_style_editor_get_canvas_bin (GraphsStyleEditor* self);
static GtkGridView* graphs_style_editor_get_style_grid (GraphsStyleEditor* self);
static void graphs_style_editor_set_css_provider (GraphsStyleEditor* self,
                                           GtkCssProvider* value);
static GObject * graphs_style_editor_constructor (GType type,
                                           guint n_construct_properties,
                                           GObjectConstructParam * construct_properties);
static Block13Data* block13_data_ref (Block13Data* _data13_);
static void block13_data_unref (void * _userdata_);
static void _graphs_style_editor___lambda76_ (GraphsStyleEditor* self);
static void __graphs_style_editor___lambda76__g_simple_action_activate (GSimpleAction* _sender,
                                                                 GVariant* parameter,
                                                                 gpointer self);
static void _graphs_style_editor___lambda77_ (GraphsStyleEditor* self);
static Block14Data* block14_data_ref (Block14Data* _data14_);
static void block14_data_unref (void * _userdata_);
static void __lambda78_ (Block14Data* _data14_,
                  GObject* d,
                  GAsyncResult* response);
static void ___lambda78__gasync_ready_callback (GObject* source_object,
                                         GAsyncResult* res,
                                         gpointer self);
static void __graphs_style_editor___lambda77__g_simple_action_activate (GSimpleAction* _sender,
                                                                 GVariant* parameter,
                                                                 gpointer self);
static void _graphs_style_editor___lambda79_ (GraphsStyleEditor* self);
static Block15Data* block15_data_ref (Block15Data* _data15_);
static void block15_data_unref (void * _userdata_);
static void __lambda80_ (Block15Data* _data15_,
                  GObject* d,
                  GAsyncResult* response);
static void ___lambda80__gasync_ready_callback (GObject* source_object,
                                         GAsyncResult* res,
                                         gpointer self);
static void __graphs_style_editor___lambda79__g_simple_action_activate (GSimpleAction* _sender,
                                                                 GVariant* parameter,
                                                                 gpointer self);
static void _graphs_style_editor___lambda81_ (GraphsStyleEditor* self);
static void __lambda82_ (GraphsStyleEditor* self,
                  AdwAlertDialog* d,
                  const gchar* response);
static void ___lambda82__adw_alert_dialog_response (AdwAlertDialog* _sender,
                                             const gchar* response,
                                             gpointer self);
static void __graphs_style_editor___lambda81__g_simple_action_activate (GSimpleAction* _sender,
                                                                 GVariant* parameter,
                                                                 gpointer self);
static void _graphs_style_editor___lambda83_ (GraphsStyleEditor* self);
static void __graphs_style_editor___lambda83__g_simple_action_activate (GSimpleAction* _sender,
                                                                 GVariant* parameter,
                                                                 gpointer self);
static void _graphs_style_editor___lambda84_ (GraphsStyleEditor* self);
static void __graphs_style_editor___lambda84__g_simple_action_activate (GSimpleAction* _sender,
                                                                 GVariant* parameter,
                                                                 gpointer self);
static void _graphs_style_editor___lambda85_ (GraphsStyleEditor* self);
static void __lambda86_ (GraphsStyleEditor* self,
                  GFile* file);
static void ___lambda86__graphs_add_style_dialog_accept (GraphsAddStyleDialog* _sender,
                                                  GFile* file,
                                                  gpointer self);
static void __graphs_style_editor___lambda85__g_simple_action_activate (GSimpleAction* _sender,
                                                                 GVariant* parameter,
                                                                 gpointer self);
static void _graphs_style_editor___lambda87_ (Block13Data* _data13_);
static void __graphs_style_editor___lambda87__g_object_notify (GObject* _sender,
                                                        GParamSpec* pspec,
                                                        gpointer self);
static void _graphs_style_editor_on_factory_setup_gtk_signal_list_item_factory_setup (GtkSignalListItemFactory* _sender,
                                                                               GObject* object,
                                                                               gpointer self);
static void _graphs_style_editor_on_factory_bind_gtk_signal_list_item_factory_bind (GtkSignalListItemFactory* _sender,
                                                                             GObject* object,
                                                                             gpointer self);
static void graphs_style_editor_finalize (GObject * obj);
static GType graphs_style_editor_get_type_once (void);
static void _vala_graphs_style_editor_get_property (GObject * object,
                                             guint property_id,
                                             GValue * value,
                                             GParamSpec * pspec);
static void _vala_graphs_style_editor_set_property (GObject * object,
                                             guint property_id,
                                             const GValue * value,
                                             GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
graphs_style_editor_get_instance_private (GraphsStyleEditor* self)
{
	return G_STRUCT_MEMBER_P (self, GraphsStyleEditor_private_offset);
}

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

void
graphs_style_editor_load (GraphsStyleEditor* self,
                          GFile* file)
{
	GFile* _tmp0_;
	GtkStack* _tmp1_;
	GtkSelectionModel* _tmp2_;
	GtkSelectionModel* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (file != NULL);
	_tmp0_ = _g_object_ref0 (file);
	_g_object_unref0 (self->priv->_file);
	self->priv->_file = _tmp0_;
	g_signal_emit (self, graphs_style_editor_signals[GRAPHS_STYLE_EDITOR_LOAD_REQUEST_SIGNAL], 0, file);
	_tmp1_ = self->priv->_stack;
	_tmp2_ = gtk_stack_get_pages (_tmp1_);
	_tmp3_ = _tmp2_;
	gtk_selection_model_select_item (_tmp3_, (guint) 1, TRUE);
	_g_object_unref0 (_tmp3_);
}

void
graphs_style_editor_save (GraphsStyleEditor* self)
{
	GFile* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_file;
	g_signal_emit (self, graphs_style_editor_signals[GRAPHS_STYLE_EDITOR_SAVE_REQUEST_SIGNAL], 0, _tmp0_);
	graphs_style_editor_set_unsaved (self, FALSE);
}

void
graphs_style_editor_close_style (GraphsStyleEditor* self)
{
	GtkStack* _tmp0_;
	GtkSelectionModel* _tmp1_;
	GtkSelectionModel* _tmp2_;
	g_return_if_fail (self != NULL);
	graphs_style_editor_set_unsaved (self, FALSE);
	gtk_window_set_title ((GtkWindow*) self, _ ("Graphs Style Editor"));
	_tmp0_ = self->priv->_stack;
	_tmp1_ = gtk_stack_get_pages (_tmp0_);
	_tmp2_ = _tmp1_;
	gtk_selection_model_select_item (_tmp2_, (guint) 0, TRUE);
	_g_object_unref0 (_tmp2_);
}

static void
graphs_style_editor_on_factory_setup (GraphsStyleEditor* self,
                                      GObject* object)
{
	GtkListItem* item = NULL;
	GtkListItem* _tmp0_;
	GraphsStylePreview* _tmp1_;
	GraphsStylePreview* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (object != NULL);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (object, gtk_list_item_get_type (), GtkListItem));
	item = _tmp0_;
	_tmp1_ = graphs_style_preview_new ();
	g_object_ref_sink (_tmp1_);
	_tmp2_ = _tmp1_;
	gtk_list_item_set_child (item, (GtkWidget*) _tmp2_);
	_g_object_unref0 (_tmp2_);
	_g_object_unref0 (item);
}

static Block12Data*
block12_data_ref (Block12Data* _data12_)
{
	g_atomic_int_inc (&_data12_->_ref_count_);
	return _data12_;
}

static void
block12_data_unref (void * _userdata_)
{
	Block12Data* _data12_;
	_data12_ = (Block12Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data12_->_ref_count_)) {
		GraphsStyleEditor* self;
		self = _data12_->self;
		_g_object_unref0 (_data12_->style);
		_g_object_unref0 (self);
		g_slice_free (Block12Data, _data12_);
	}
}

static void
___lambda5_ (Block12Data* _data12_)
{
	GraphsStyleEditor* self;
	GraphsStyle* _tmp0_;
	GFile* _tmp1_;
	GFile* _tmp2_;
	self = _data12_->self;
	_tmp0_ = _data12_->style;
	_tmp1_ = graphs_style_get_file (_tmp0_);
	_tmp2_ = _tmp1_;
	graphs_style_editor_load (self, _tmp2_);
}

static void
____lambda5__g_simple_action_activate (GSimpleAction* _sender,
                                       GVariant* parameter,
                                       gpointer self)
{
	___lambda5_ (self);
}

static void
___lambda6_ (Block12Data* _data12_)
{
	GraphsStyleEditor* self;
	GtkFileLauncher* launcher = NULL;
	GraphsStyle* _tmp0_;
	GFile* _tmp1_;
	GFile* _tmp2_;
	GtkFileLauncher* _tmp3_;
	self = _data12_->self;
	_tmp0_ = _data12_->style;
	_tmp1_ = graphs_style_get_file (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = gtk_file_launcher_new (_tmp2_);
	launcher = _tmp3_;
	gtk_file_launcher_set_always_ask (launcher, TRUE);
	gtk_file_launcher_launch (launcher, (GtkWindow*) self, NULL, NULL, NULL);
	_g_object_unref0 (launcher);
}

static void
____lambda6__g_simple_action_activate (GSimpleAction* _sender,
                                       GVariant* parameter,
                                       gpointer self)
{
	___lambda6_ (self);
}

static void
__lambda8_ (Block12Data* _data12_,
            AdwAlertDialog* d,
            const gchar* response)
{
	GraphsStyleEditor* self;
	GError* _inner_error0_ = NULL;
	self = _data12_->self;
	g_return_if_fail (d != NULL);
	g_return_if_fail (response != NULL);
	if (g_strcmp0 (response, "delete") != 0) {
		return;
	}
	{
		GraphsStyle* _tmp0_;
		GFile* _tmp1_;
		GFile* _tmp2_;
		_tmp0_ = _data12_->style;
		_tmp1_ = graphs_style_get_file (_tmp0_);
		_tmp2_ = _tmp1_;
		g_file_trash (_tmp2_, NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
		g_assert_not_reached ();
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
}

static void
___lambda8__adw_alert_dialog_response (AdwAlertDialog* _sender,
                                       const gchar* response,
                                       gpointer self)
{
	__lambda8_ (self, _sender, response);
}

static void
___lambda7_ (Block12Data* _data12_)
{
	GraphsStyleEditor* self;
	AdwAlertDialog* dialog = NULL;
	GObject* _tmp0_;
	gchar* msg = NULL;
	gchar* _tmp1_;
	GraphsStyle* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	self = _data12_->self;
	_tmp0_ = graphs_tools_build_dialog ("delete_style");
	dialog = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, adw_alert_dialog_get_type (), AdwAlertDialog);
	_tmp1_ = g_strdup (_ ("Are you sure you want to delete %s?"));
	msg = _tmp1_;
	_tmp2_ = _data12_->style;
	_tmp3_ = graphs_style_get_name (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = g_strdup_printf (msg, _tmp4_);
	_tmp6_ = _tmp5_;
	adw_alert_dialog_set_body (dialog, _tmp6_);
	_g_free0 (_tmp6_);
	g_signal_connect_data (dialog, "response", (GCallback) ___lambda8__adw_alert_dialog_response, block12_data_ref (_data12_), (GClosureNotify) block12_data_unref, 0);
	adw_dialog_present ((AdwDialog*) dialog, (GtkWidget*) self);
	_g_free0 (msg);
	_g_object_unref0 (dialog);
}

static void
____lambda7__g_simple_action_activate (GSimpleAction* _sender,
                                       GVariant* parameter,
                                       gpointer self)
{
	___lambda7_ (self);
}

static void
graphs_style_editor_on_factory_bind (GraphsStyleEditor* self,
                                     GObject* object)
{
	Block12Data* _data12_;
	GtkListItem* item = NULL;
	GtkListItem* _tmp0_;
	GraphsStylePreview* preview = NULL;
	GtkListItem* _tmp1_;
	GtkWidget* _tmp2_;
	GraphsStylePreview* _tmp3_;
	GtkListItem* _tmp4_;
	GObject* _tmp5_;
	GraphsStyle* _tmp6_;
	GraphsStylePreview* _tmp7_;
	GraphsStyle* _tmp8_;
	gboolean _tmp9_ = FALSE;
	GraphsStyle* _tmp10_;
	gboolean _tmp11_;
	gboolean _tmp12_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (object != NULL);
	_data12_ = g_slice_new0 (Block12Data);
	_data12_->_ref_count_ = 1;
	_data12_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (object, gtk_list_item_get_type (), GtkListItem));
	item = _tmp0_;
	_tmp1_ = item;
	_tmp2_ = gtk_list_item_get_child (_tmp1_);
	_tmp3_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GRAPHS_TYPE_STYLE_PREVIEW, GraphsStylePreview));
	preview = _tmp3_;
	_tmp4_ = item;
	_tmp5_ = gtk_list_item_get_item (_tmp4_);
	_tmp6_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, GRAPHS_TYPE_STYLE, GraphsStyle));
	_data12_->style = _tmp6_;
	_tmp7_ = preview;
	_tmp8_ = _data12_->style;
	graphs_style_preview_set_style (_tmp7_, _tmp8_);
	_tmp10_ = _data12_->style;
	_tmp11_ = graphs_style_get_mutable (_tmp10_);
	_tmp12_ = _tmp11_;
	if (_tmp12_) {
		GraphsStylePreview* _tmp13_;
		GtkMenuButton* _tmp14_;
		GtkMenuButton* _tmp15_;
		_tmp13_ = preview;
		_tmp14_ = graphs_style_preview_get_menu_button (_tmp13_);
		_tmp15_ = _tmp14_;
		_tmp9_ = !gtk_widget_get_visible ((GtkWidget*) _tmp15_);
	} else {
		_tmp9_ = FALSE;
	}
	if (_tmp9_) {
		GraphsStylePreview* _tmp16_;
		GtkMenuButton* _tmp17_;
		GtkMenuButton* _tmp18_;
		GSimpleActionGroup* action_group = NULL;
		GSimpleActionGroup* _tmp19_;
		GSimpleAction* open_action = NULL;
		GSimpleAction* _tmp20_;
		GSimpleAction* _tmp21_;
		GSimpleActionGroup* _tmp22_;
		GSimpleAction* _tmp23_;
		GSimpleAction* open_with_action = NULL;
		GSimpleAction* _tmp24_;
		GSimpleAction* _tmp25_;
		GSimpleActionGroup* _tmp26_;
		GSimpleAction* _tmp27_;
		GSimpleAction* delete_action = NULL;
		GSimpleAction* _tmp28_;
		GSimpleAction* _tmp29_;
		GSimpleActionGroup* _tmp30_;
		GSimpleAction* _tmp31_;
		GraphsStylePreview* _tmp32_;
		GtkMenuButton* _tmp33_;
		GtkMenuButton* _tmp34_;
		GSimpleActionGroup* _tmp35_;
		_tmp16_ = preview;
		_tmp17_ = graphs_style_preview_get_menu_button (_tmp16_);
		_tmp18_ = _tmp17_;
		gtk_widget_set_visible ((GtkWidget*) _tmp18_, TRUE);
		_tmp19_ = g_simple_action_group_new ();
		action_group = _tmp19_;
		_tmp20_ = g_simple_action_new ("open", NULL);
		open_action = _tmp20_;
		_tmp21_ = open_action;
		g_signal_connect_data (_tmp21_, "activate", (GCallback) ____lambda5__g_simple_action_activate, block12_data_ref (_data12_), (GClosureNotify) block12_data_unref, 0);
		_tmp22_ = action_group;
		_tmp23_ = open_action;
		g_action_map_add_action ((GActionMap*) _tmp22_, (GAction*) _tmp23_);
		_tmp24_ = g_simple_action_new ("open_with", NULL);
		open_with_action = _tmp24_;
		_tmp25_ = open_with_action;
		g_signal_connect_data (_tmp25_, "activate", (GCallback) ____lambda6__g_simple_action_activate, block12_data_ref (_data12_), (GClosureNotify) block12_data_unref, 0);
		_tmp26_ = action_group;
		_tmp27_ = open_with_action;
		g_action_map_add_action ((GActionMap*) _tmp26_, (GAction*) _tmp27_);
		_tmp28_ = g_simple_action_new ("delete", NULL);
		delete_action = _tmp28_;
		_tmp29_ = delete_action;
		g_signal_connect_data (_tmp29_, "activate", (GCallback) ____lambda7__g_simple_action_activate, block12_data_ref (_data12_), (GClosureNotify) block12_data_unref, 0);
		_tmp30_ = action_group;
		_tmp31_ = delete_action;
		g_action_map_add_action ((GActionMap*) _tmp30_, (GAction*) _tmp31_);
		_tmp32_ = preview;
		_tmp33_ = graphs_style_preview_get_menu_button (_tmp32_);
		_tmp34_ = _tmp33_;
		_tmp35_ = action_group;
		gtk_widget_insert_action_group ((GtkWidget*) _tmp34_, "style", (GActionGroup*) _tmp35_);
		_g_object_unref0 (delete_action);
		_g_object_unref0 (open_with_action);
		_g_object_unref0 (open_action);
		_g_object_unref0 (action_group);
	}
	_g_object_unref0 (preview);
	_g_object_unref0 (item);
	block12_data_unref (_data12_);
	_data12_ = NULL;
}

static void
___lambda75_ (GraphsStyleEditor* self,
              AdwAlertDialog* d,
              const gchar* response)
{
	const gchar* _tmp0_;
	GQuark _tmp2_ = 0U;
	static GQuark _tmp1_label0 = 0;
	static GQuark _tmp1_label1 = 0;
	g_return_if_fail (d != NULL);
	g_return_if_fail (response != NULL);
	_tmp0_ = response;
	_tmp2_ = (NULL == _tmp0_) ? 0 : g_quark_from_string (_tmp0_);
	if (_tmp2_ == ((0 != _tmp1_label0) ? _tmp1_label0 : (_tmp1_label0 = g_quark_from_static_string ("discard")))) {
		switch (0) {
			default:
			{
				{
					self->priv->_force_close = TRUE;
					gtk_window_close ((GtkWindow*) self);
					break;
				}
			}
		}
	} else if (_tmp2_ == ((0 != _tmp1_label1) ? _tmp1_label1 : (_tmp1_label1 = g_quark_from_static_string ("save")))) {
		switch (0) {
			default:
			{
				{
					graphs_style_editor_save (self);
					self->priv->_force_close = TRUE;
					gtk_window_close ((GtkWindow*) self);
					break;
				}
			}
		}
	}
}

static void
____lambda75__adw_alert_dialog_response (AdwAlertDialog* _sender,
                                         const gchar* response,
                                         gpointer self)
{
	___lambda75_ ((GraphsStyleEditor*) self, _sender, response);
}

static gboolean
graphs_style_editor_real_close_request (GtkWindow* base)
{
	GraphsStyleEditor * self;
	GraphsApplication* application = NULL;
	GtkApplication* _tmp0_;
	GtkApplication* _tmp1_;
	GraphsApplication* _tmp2_;
	gboolean _tmp4_;
	GraphsApplication* _tmp8_;
	gboolean result;
	self = (GraphsStyleEditor*) base;
	_tmp0_ = gtk_window_get_application ((GtkWindow*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GRAPHS_TYPE_APPLICATION, GraphsApplication));
	application = _tmp2_;
	if (self->priv->_force_close) {
		GraphsApplication* _tmp3_;
		_tmp3_ = application;
		graphs_application_on_style_editor_closed (_tmp3_, self);
		result = FALSE;
		_g_object_unref0 (application);
		return result;
	}
	_tmp4_ = self->priv->_unsaved;
	if (_tmp4_) {
		AdwAlertDialog* dialog = NULL;
		GObject* _tmp5_;
		AdwAlertDialog* _tmp6_;
		AdwAlertDialog* _tmp7_;
		_tmp5_ = graphs_tools_build_dialog ("save_style_changes");
		dialog = G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, adw_alert_dialog_get_type (), AdwAlertDialog);
		_tmp6_ = dialog;
		g_signal_connect_object (_tmp6_, "response", (GCallback) ____lambda75__adw_alert_dialog_response, self, 0);
		_tmp7_ = dialog;
		adw_dialog_present ((AdwDialog*) _tmp7_, (GtkWidget*) self);
		result = TRUE;
		_g_object_unref0 (dialog);
		_g_object_unref0 (application);
		return result;
	}
	_tmp8_ = application;
	graphs_application_on_style_editor_closed (_tmp8_, self);
	result = FALSE;
	_g_object_unref0 (application);
	return result;
}

GraphsStyleEditor*
graphs_style_editor_construct (GType object_type)
{
	GraphsStyleEditor * self = NULL;
	self = (GraphsStyleEditor*) g_object_new (object_type, NULL);
	return self;
}

GraphsStyleEditor*
graphs_style_editor_new (void)
{
	return graphs_style_editor_construct (GRAPHS_TYPE_STYLE_EDITOR);
}

static AdwBin*
graphs_style_editor_get_editor_bin (GraphsStyleEditor* self)
{
	AdwBin* result;
	AdwBin* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_editor_bin;
	result = _tmp0_;
	return result;
}

static AdwBin*
graphs_style_editor_get_canvas_bin (GraphsStyleEditor* self)
{
	AdwBin* result;
	AdwBin* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_canvas_bin;
	result = _tmp0_;
	return result;
}

static GtkStack*
graphs_style_editor_get_stack (GraphsStyleEditor* self)
{
	GtkStack* result;
	GtkStack* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_stack;
	result = _tmp0_;
	return result;
}

static GtkGridView*
graphs_style_editor_get_style_grid (GraphsStyleEditor* self)
{
	GtkGridView* result;
	GtkGridView* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_style_grid;
	result = _tmp0_;
	return result;
}

AdwToolbarView*
graphs_style_editor_get_content_view (GraphsStyleEditor* self)
{
	AdwToolbarView* result;
	AdwToolbarView* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_content_view;
	result = _tmp0_;
	return result;
}

GtkBox*
graphs_style_editor_get_editor_box (GraphsStyleEditor* self)
{
	GtkBox* result;
	AdwBin* _tmp0_;
	GtkWidget* _tmp1_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_editor_bin;
	_tmp1_ = adw_bin_get_child (_tmp0_);
	result = G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_box_get_type (), GtkBox);
	return result;
}

void
graphs_style_editor_set_editor_box (GraphsStyleEditor* self,
                                    GtkBox* value)
{
	AdwBin* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_editor_bin;
	adw_bin_set_child (_tmp0_, (GtkWidget*) value);
	g_object_notify_by_pspec ((GObject *) self, graphs_style_editor_properties[GRAPHS_STYLE_EDITOR_EDITOR_BOX_PROPERTY]);
}

GraphsCanvas*
graphs_style_editor_get_canvas (GraphsStyleEditor* self)
{
	GraphsCanvas* result;
	AdwBin* _tmp0_;
	GtkWidget* _tmp1_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_canvas_bin;
	_tmp1_ = adw_bin_get_child (_tmp0_);
	result = G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GRAPHS_TYPE_CANVAS, GraphsCanvas);
	return result;
}

void
graphs_style_editor_set_canvas (GraphsStyleEditor* self,
                                GraphsCanvas* value)
{
	AdwBin* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_canvas_bin;
	adw_bin_set_child (_tmp0_, (GtkWidget*) value);
	g_object_notify_by_pspec ((GObject *) self, graphs_style_editor_properties[GRAPHS_STYLE_EDITOR_CANVAS_PROPERTY]);
}

void
graphs_style_editor_set_stylename (GraphsStyleEditor* self,
                                   const gchar* value)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup (value);
	_g_free0 (self->priv->_stylename);
	self->priv->_stylename = _tmp0_;
	_tmp1_ = g_strdup_printf (_ ("Graphs Style Editor — %s"), value);
	_tmp2_ = _tmp1_;
	gtk_window_set_title ((GtkWindow*) self, _tmp2_);
	_g_free0 (_tmp2_);
	if (self->priv->_inhibit_cookie > ((guint) 0)) {
		GtkApplication* _tmp3_;
		GtkApplication* _tmp4_;
		GtkApplication* _tmp5_;
		GtkApplication* _tmp6_;
		_tmp3_ = gtk_window_get_application ((GtkWindow*) self);
		_tmp4_ = _tmp3_;
		gtk_application_uninhibit (_tmp4_, self->priv->_inhibit_cookie);
		_tmp5_ = gtk_window_get_application ((GtkWindow*) self);
		_tmp6_ = _tmp5_;
		self->priv->_inhibit_cookie = gtk_application_inhibit (_tmp6_, (GtkWindow*) self, GTK_APPLICATION_INHIBIT_LOGOUT, value);
	}
	g_object_notify_by_pspec ((GObject *) self, graphs_style_editor_properties[GRAPHS_STYLE_EDITOR_STYLENAME_PROPERTY]);
}

GtkCssProvider*
graphs_style_editor_get_css_provider (GraphsStyleEditor* self)
{
	GtkCssProvider* result;
	GtkCssProvider* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_css_provider;
	result = _tmp0_;
	return result;
}

static void
graphs_style_editor_set_css_provider (GraphsStyleEditor* self,
                                      GtkCssProvider* value)
{
	GtkCssProvider* old_value;
	g_return_if_fail (self != NULL);
	old_value = graphs_style_editor_get_css_provider (self);
	if (old_value != value) {
		GtkCssProvider* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_css_provider);
		self->priv->_css_provider = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, graphs_style_editor_properties[GRAPHS_STYLE_EDITOR_CSS_PROVIDER_PROPERTY]);
	}
}

gboolean
graphs_style_editor_get_unsaved (GraphsStyleEditor* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_unsaved;
	return result;
}

void
graphs_style_editor_set_unsaved (GraphsStyleEditor* self,
                                 gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = graphs_style_editor_get_unsaved (self);
	if (old_value != value) {
		self->priv->_unsaved = value;
		g_object_notify_by_pspec ((GObject *) self, graphs_style_editor_properties[GRAPHS_STYLE_EDITOR_UNSAVED_PROPERTY]);
	}
}

static Block13Data*
block13_data_ref (Block13Data* _data13_)
{
	g_atomic_int_inc (&_data13_->_ref_count_);
	return _data13_;
}

static void
block13_data_unref (void * _userdata_)
{
	Block13Data* _data13_;
	_data13_ = (Block13Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data13_->_ref_count_)) {
		GraphsStyleEditor* self;
		self = _data13_->self;
		_g_object_unref0 (_data13_->save_action);
		_g_object_unref0 (self);
		g_slice_free (Block13Data, _data13_);
	}
}

static void
_graphs_style_editor___lambda76_ (GraphsStyleEditor* self)
{
	GFile* _tmp0_;
	_tmp0_ = self->priv->_file;
	if (_tmp0_ == NULL) {
		return;
	}
	graphs_style_editor_save (self);
}

static void
__graphs_style_editor___lambda76__g_simple_action_activate (GSimpleAction* _sender,
                                                            GVariant* parameter,
                                                            gpointer self)
{
	_graphs_style_editor___lambda76_ ((GraphsStyleEditor*) self);
}

static Block14Data*
block14_data_ref (Block14Data* _data14_)
{
	g_atomic_int_inc (&_data14_->_ref_count_);
	return _data14_;
}

static void
block14_data_unref (void * _userdata_)
{
	Block14Data* _data14_;
	_data14_ = (Block14Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data14_->_ref_count_)) {
		GraphsStyleEditor* self;
		self = _data14_->self;
		_g_object_unref0 (_data14_->dialog);
		_g_object_unref0 (self);
		g_slice_free (Block14Data, _data14_);
	}
}

static void
__lambda78_ (Block14Data* _data14_,
             GObject* d,
             GAsyncResult* response)
{
	GraphsStyleEditor* self;
	GError* _inner_error0_ = NULL;
	self = _data14_->self;
	g_return_if_fail (response != NULL);
	{
		GFile* _tmp0_ = NULL;
		GtkFileDialog* _tmp1_;
		GFile* _tmp2_;
		GFile* _tmp3_;
		_tmp1_ = _data14_->dialog;
		_tmp2_ = gtk_file_dialog_save_finish (_tmp1_, response, &_inner_error0_);
		_tmp0_ = _tmp2_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp3_ = _tmp0_;
		_tmp0_ = NULL;
		_g_object_unref0 (self->priv->_file);
		self->priv->_file = _tmp3_;
		graphs_style_editor_save (self);
		_g_object_unref0 (_tmp0_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
}

static void
___lambda78__gasync_ready_callback (GObject* source_object,
                                    GAsyncResult* res,
                                    gpointer self)
{
	__lambda78_ (self, source_object, res);
	block14_data_unref (self);
}

static void
_graphs_style_editor___lambda77_ (GraphsStyleEditor* self)
{
	Block14Data* _data14_;
	GFile* _tmp0_;
	GtkFileDialog* _tmp1_;
	GtkFileDialog* _tmp2_;
	GListModel* _tmp3_;
	GListModel* _tmp4_;
	GtkFileDialog* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	GtkFileDialog* _tmp8_;
	_data14_ = g_slice_new0 (Block14Data);
	_data14_->_ref_count_ = 1;
	_data14_->self = g_object_ref (self);
	_tmp0_ = self->priv->_file;
	if (_tmp0_ == NULL) {
		block14_data_unref (_data14_);
		_data14_ = NULL;
		return;
	}
	_tmp1_ = gtk_file_dialog_new ();
	_data14_->dialog = _tmp1_;
	_tmp2_ = _data14_->dialog;
	_tmp3_ = graphs_get_mplstyle_file_filters ();
	_tmp4_ = _tmp3_;
	gtk_file_dialog_set_filters (_tmp2_, _tmp4_);
	_g_object_unref0 (_tmp4_);
	_tmp5_ = _data14_->dialog;
	_tmp6_ = g_strconcat (_ ("Style"), ".mplstyle", NULL);
	_tmp7_ = _tmp6_;
	gtk_file_dialog_set_initial_name (_tmp5_, _tmp7_);
	_g_free0 (_tmp7_);
	_tmp8_ = _data14_->dialog;
	gtk_file_dialog_save (_tmp8_, (GtkWindow*) self, NULL, ___lambda78__gasync_ready_callback, block14_data_ref (_data14_));
	block14_data_unref (_data14_);
	_data14_ = NULL;
}

static void
__graphs_style_editor___lambda77__g_simple_action_activate (GSimpleAction* _sender,
                                                            GVariant* parameter,
                                                            gpointer self)
{
	_graphs_style_editor___lambda77_ ((GraphsStyleEditor*) self);
}

static Block15Data*
block15_data_ref (Block15Data* _data15_)
{
	g_atomic_int_inc (&_data15_->_ref_count_);
	return _data15_;
}

static void
block15_data_unref (void * _userdata_)
{
	Block15Data* _data15_;
	_data15_ = (Block15Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data15_->_ref_count_)) {
		GraphsStyleEditor* self;
		self = _data15_->self;
		_g_object_unref0 (_data15_->dialog);
		_g_object_unref0 (self);
		g_slice_free (Block15Data, _data15_);
	}
}

static void
__lambda80_ (Block15Data* _data15_,
             GObject* d,
             GAsyncResult* response)
{
	GraphsStyleEditor* self;
	GError* _inner_error0_ = NULL;
	self = _data15_->self;
	g_return_if_fail (response != NULL);
	{
		GFile* file = NULL;
		GtkFileDialog* _tmp0_;
		GFile* _tmp1_;
		gboolean _tmp2_ = FALSE;
		GFile* _tmp3_;
		_tmp0_ = _data15_->dialog;
		_tmp1_ = gtk_file_dialog_open_finish (_tmp0_, response, &_inner_error0_);
		file = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp3_ = self->priv->_file;
		if (_tmp3_ == NULL) {
			_tmp2_ = TRUE;
		} else {
			gboolean _tmp4_;
			_tmp4_ = self->priv->_unsaved;
			_tmp2_ = !_tmp4_;
		}
		if (_tmp2_) {
			GFile* _tmp5_;
			_tmp5_ = file;
			graphs_style_editor_load (self, _tmp5_);
		} else {
			GraphsStyleEditor* new_window = NULL;
			GtkApplication* _tmp6_;
			GtkApplication* _tmp7_;
			GraphsStyleEditor* _tmp8_;
			GraphsStyleEditor* _tmp9_;
			GFile* _tmp10_;
			GraphsStyleEditor* _tmp11_;
			_tmp6_ = gtk_window_get_application ((GtkWindow*) self);
			_tmp7_ = _tmp6_;
			_tmp8_ = graphs_application_create_style_editor (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, GRAPHS_TYPE_APPLICATION, GraphsApplication));
			new_window = _tmp8_;
			_tmp9_ = new_window;
			_tmp10_ = file;
			graphs_style_editor_load (_tmp9_, _tmp10_);
			_tmp11_ = new_window;
			gtk_window_present ((GtkWindow*) _tmp11_);
			_g_object_unref0 (new_window);
		}
		_g_object_unref0 (file);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
}

static void
___lambda80__gasync_ready_callback (GObject* source_object,
                                    GAsyncResult* res,
                                    gpointer self)
{
	__lambda80_ (self, source_object, res);
	block15_data_unref (self);
}

static void
_graphs_style_editor___lambda79_ (GraphsStyleEditor* self)
{
	Block15Data* _data15_;
	GtkFileDialog* _tmp0_;
	GtkFileDialog* _tmp1_;
	GListModel* _tmp2_;
	GListModel* _tmp3_;
	GtkFileDialog* _tmp4_;
	_data15_ = g_slice_new0 (Block15Data);
	_data15_->_ref_count_ = 1;
	_data15_->self = g_object_ref (self);
	_tmp0_ = gtk_file_dialog_new ();
	_data15_->dialog = _tmp0_;
	_tmp1_ = _data15_->dialog;
	_tmp2_ = graphs_get_mplstyle_file_filters ();
	_tmp3_ = _tmp2_;
	gtk_file_dialog_set_filters (_tmp1_, _tmp3_);
	_g_object_unref0 (_tmp3_);
	_tmp4_ = _data15_->dialog;
	gtk_file_dialog_open (_tmp4_, (GtkWindow*) self, NULL, ___lambda80__gasync_ready_callback, block15_data_ref (_data15_));
	block15_data_unref (_data15_);
	_data15_ = NULL;
}

static void
__graphs_style_editor___lambda79__g_simple_action_activate (GSimpleAction* _sender,
                                                            GVariant* parameter,
                                                            gpointer self)
{
	_graphs_style_editor___lambda79_ ((GraphsStyleEditor*) self);
}

static void
__lambda82_ (GraphsStyleEditor* self,
             AdwAlertDialog* d,
             const gchar* response)
{
	const gchar* _tmp0_;
	GQuark _tmp2_ = 0U;
	static GQuark _tmp1_label0 = 0;
	static GQuark _tmp1_label1 = 0;
	g_return_if_fail (d != NULL);
	g_return_if_fail (response != NULL);
	_tmp0_ = response;
	_tmp2_ = (NULL == _tmp0_) ? 0 : g_quark_from_string (_tmp0_);
	if (_tmp2_ == ((0 != _tmp1_label0) ? _tmp1_label0 : (_tmp1_label0 = g_quark_from_static_string ("discard")))) {
		switch (0) {
			default:
			{
				{
					graphs_style_editor_close_style (self);
					break;
				}
			}
		}
	} else if (_tmp2_ == ((0 != _tmp1_label1) ? _tmp1_label1 : (_tmp1_label1 = g_quark_from_static_string ("save")))) {
		switch (0) {
			default:
			{
				{
					graphs_style_editor_save (self);
					graphs_style_editor_close_style (self);
					break;
				}
			}
		}
	}
}

static void
___lambda82__adw_alert_dialog_response (AdwAlertDialog* _sender,
                                        const gchar* response,
                                        gpointer self)
{
	__lambda82_ ((GraphsStyleEditor*) self, _sender, response);
}

static void
_graphs_style_editor___lambda81_ (GraphsStyleEditor* self)
{
	gboolean _tmp0_;
	AdwAlertDialog* dialog = NULL;
	GObject* _tmp1_;
	AdwAlertDialog* _tmp2_;
	AdwAlertDialog* _tmp3_;
	_tmp0_ = self->priv->_unsaved;
	if (!_tmp0_) {
		graphs_style_editor_close_style (self);
		return;
	}
	_tmp1_ = graphs_tools_build_dialog ("save_style_changes");
	dialog = G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, adw_alert_dialog_get_type (), AdwAlertDialog);
	_tmp2_ = dialog;
	g_signal_connect_object (_tmp2_, "response", (GCallback) ___lambda82__adw_alert_dialog_response, self, 0);
	_tmp3_ = dialog;
	adw_dialog_present ((AdwDialog*) _tmp3_, (GtkWidget*) self);
	_g_object_unref0 (dialog);
}

static void
__graphs_style_editor___lambda81__g_simple_action_activate (GSimpleAction* _sender,
                                                            GVariant* parameter,
                                                            gpointer self)
{
	_graphs_style_editor___lambda81_ ((GraphsStyleEditor*) self);
}

static void
_graphs_style_editor___lambda83_ (GraphsStyleEditor* self)
{
	gchar* path = NULL;
	gchar* _tmp0_;
	GtkBuilder* builder = NULL;
	const gchar* _tmp1_;
	GtkBuilder* _tmp2_;
	AdwShortcutsDialog* shortcuts_dialog = NULL;
	GtkBuilder* _tmp3_;
	GObject* _tmp4_;
	AdwShortcutsDialog* _tmp5_;
	AdwShortcutsDialog* _tmp6_;
	_tmp0_ = g_strdup ("/se/sjoerd/Graphs/ui/style-editor/shortcuts.ui");
	path = _tmp0_;
	_tmp1_ = path;
	_tmp2_ = gtk_builder_new_from_resource (_tmp1_);
	builder = _tmp2_;
	_tmp3_ = builder;
	_tmp4_ = gtk_builder_get_object (_tmp3_, "shortcuts");
	_tmp5_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, adw_shortcuts_dialog_get_type (), AdwShortcutsDialog));
	shortcuts_dialog = _tmp5_;
	_tmp6_ = shortcuts_dialog;
	adw_dialog_present ((AdwDialog*) _tmp6_, (GtkWidget*) self);
	_g_object_unref0 (shortcuts_dialog);
	_g_object_unref0 (builder);
	_g_free0 (path);
}

static void
__graphs_style_editor___lambda83__g_simple_action_activate (GSimpleAction* _sender,
                                                            GVariant* parameter,
                                                            gpointer self)
{
	_graphs_style_editor___lambda83_ ((GraphsStyleEditor*) self);
}

static void
_graphs_style_editor___lambda84_ (GraphsStyleEditor* self)
{
	graphs_import_style ((GtkWindow*) self, NULL, NULL);
}

static void
__graphs_style_editor___lambda84__g_simple_action_activate (GSimpleAction* _sender,
                                                            GVariant* parameter,
                                                            gpointer self)
{
	_graphs_style_editor___lambda84_ ((GraphsStyleEditor*) self);
}

static void
__lambda86_ (GraphsStyleEditor* self,
             GFile* file)
{
	g_return_if_fail (file != NULL);
	graphs_style_editor_load (self, file);
}

static void
___lambda86__graphs_add_style_dialog_accept (GraphsAddStyleDialog* _sender,
                                             GFile* file,
                                             gpointer self)
{
	__lambda86_ ((GraphsStyleEditor*) self, file);
}

static void
_graphs_style_editor___lambda85_ (GraphsStyleEditor* self)
{
	GraphsAddStyleDialog* dialog = NULL;
	GraphsAddStyleDialog* _tmp0_;
	GraphsAddStyleDialog* _tmp1_;
	_tmp0_ = graphs_add_style_dialog_new ((GtkWidget*) self);
	g_object_ref_sink (_tmp0_);
	dialog = _tmp0_;
	_tmp1_ = dialog;
	g_signal_connect_object (_tmp1_, "accept", (GCallback) ___lambda86__graphs_add_style_dialog_accept, self, 0);
	_g_object_unref0 (dialog);
}

static void
__graphs_style_editor___lambda85__g_simple_action_activate (GSimpleAction* _sender,
                                                            GVariant* parameter,
                                                            gpointer self)
{
	_graphs_style_editor___lambda85_ ((GraphsStyleEditor*) self);
}

static void
_graphs_style_editor___lambda87_ (Block13Data* _data13_)
{
	GraphsStyleEditor* self;
	gboolean _tmp0_;
	self = _data13_->self;
	_tmp0_ = self->priv->_unsaved;
	if (_tmp0_) {
		GSimpleAction* _tmp4_;
		if (self->priv->_inhibit_cookie == ((guint) 0)) {
			GtkApplication* _tmp1_;
			GtkApplication* _tmp2_;
			const gchar* _tmp3_;
			_tmp1_ = gtk_window_get_application ((GtkWindow*) self);
			_tmp2_ = _tmp1_;
			_tmp3_ = self->priv->_stylename;
			self->priv->_inhibit_cookie = gtk_application_inhibit (_tmp2_, (GtkWindow*) self, GTK_APPLICATION_INHIBIT_LOGOUT, _tmp3_);
		}
		_tmp4_ = _data13_->save_action;
		g_simple_action_set_enabled (_tmp4_, TRUE);
	} else {
		GSimpleAction* _tmp7_;
		if (self->priv->_inhibit_cookie > ((guint) 0)) {
			GtkApplication* _tmp5_;
			GtkApplication* _tmp6_;
			_tmp5_ = gtk_window_get_application ((GtkWindow*) self);
			_tmp6_ = _tmp5_;
			gtk_application_uninhibit (_tmp6_, self->priv->_inhibit_cookie);
			self->priv->_inhibit_cookie = (guint) 0;
		}
		_tmp7_ = _data13_->save_action;
		g_simple_action_set_enabled (_tmp7_, FALSE);
	}
}

static void
__graphs_style_editor___lambda87__g_object_notify (GObject* _sender,
                                                   GParamSpec* pspec,
                                                   gpointer self)
{
	_graphs_style_editor___lambda87_ (self);
}

static void
_graphs_style_editor_on_factory_setup_gtk_signal_list_item_factory_setup (GtkSignalListItemFactory* _sender,
                                                                          GObject* object,
                                                                          gpointer self)
{
	graphs_style_editor_on_factory_setup ((GraphsStyleEditor*) self, object);
}

static void
_graphs_style_editor_on_factory_bind_gtk_signal_list_item_factory_bind (GtkSignalListItemFactory* _sender,
                                                                        GObject* object,
                                                                        gpointer self)
{
	graphs_style_editor_on_factory_bind ((GraphsStyleEditor*) self, object);
}

static GObject *
graphs_style_editor_constructor (GType type,
                                 guint n_construct_properties,
                                 GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GraphsStyleEditor * self;
	Block13Data* _data13_;
	GtkCssProvider* _tmp0_;
	GtkCssProvider* _tmp1_;
	GdkDisplay* _tmp2_;
	GtkCssProvider* _tmp3_;
	AdwToolbarView* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	GSimpleAction* _tmp7_;
	GSimpleAction* _tmp8_;
	GSimpleAction* _tmp9_;
	GSimpleAction* _tmp10_;
	GSimpleAction* save_as_action = NULL;
	GSimpleAction* _tmp11_;
	GSimpleAction* _tmp12_;
	GSimpleAction* _tmp13_;
	GSimpleAction* open_action = NULL;
	GSimpleAction* _tmp14_;
	GSimpleAction* _tmp15_;
	GSimpleAction* _tmp16_;
	GSimpleAction* close_action = NULL;
	GSimpleAction* _tmp17_;
	GSimpleAction* _tmp18_;
	GSimpleAction* _tmp19_;
	GSimpleAction* show_shortcuts_action = NULL;
	GSimpleAction* _tmp20_;
	GSimpleAction* _tmp21_;
	GSimpleAction* _tmp22_;
	GSimpleAction* import_action = NULL;
	GSimpleAction* _tmp23_;
	GSimpleAction* _tmp24_;
	GSimpleAction* _tmp25_;
	GSimpleAction* create_action = NULL;
	GSimpleAction* _tmp26_;
	GSimpleAction* _tmp27_;
	GSimpleAction* _tmp28_;
	GtkSignalListItemFactory* factory = NULL;
	GtkSignalListItemFactory* _tmp29_;
	GtkSignalListItemFactory* _tmp30_;
	GtkSignalListItemFactory* _tmp31_;
	GtkGridView* _tmp32_;
	GtkSignalListItemFactory* _tmp33_;
	GtkGridView* _tmp34_;
	GtkFilterListModel* _tmp35_;
	GtkFilterListModel* _tmp36_;
	GListModel* _tmp37_;
	GtkNoSelection* _tmp38_;
	GtkNoSelection* _tmp39_;
	parent_class = G_OBJECT_CLASS (graphs_style_editor_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GRAPHS_TYPE_STYLE_EDITOR, GraphsStyleEditor);
	_data13_ = g_slice_new0 (Block13Data);
	_data13_->_ref_count_ = 1;
	_data13_->self = g_object_ref (self);
	_tmp0_ = gtk_css_provider_new ();
	_tmp1_ = _tmp0_;
	graphs_style_editor_set_css_provider (self, _tmp1_);
	_g_object_unref0 (_tmp1_);
	_tmp2_ = gdk_display_get_default ();
	_tmp3_ = self->priv->_css_provider;
	gtk_style_context_add_provider_for_display (_tmp2_, (GtkStyleProvider*) _tmp3_, (guint) GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
	_tmp4_ = self->priv->_content_view;
	_tmp5_ = graphs_application_get_next_css_name ();
	_tmp6_ = _tmp5_;
	gtk_widget_set_name ((GtkWidget*) _tmp4_, _tmp6_);
	_g_free0 (_tmp6_);
	_tmp7_ = g_simple_action_new ("save-style", NULL);
	_data13_->save_action = _tmp7_;
	_tmp8_ = _data13_->save_action;
	g_signal_connect_object (_tmp8_, "activate", (GCallback) __graphs_style_editor___lambda76__g_simple_action_activate, self, 0);
	_tmp9_ = _data13_->save_action;
	g_simple_action_set_enabled (_tmp9_, FALSE);
	_tmp10_ = _data13_->save_action;
	g_action_map_add_action ((GActionMap*) self, (GAction*) _tmp10_);
	_tmp11_ = g_simple_action_new ("save-style-as", NULL);
	save_as_action = _tmp11_;
	_tmp12_ = save_as_action;
	g_signal_connect_object (_tmp12_, "activate", (GCallback) __graphs_style_editor___lambda77__g_simple_action_activate, self, 0);
	_tmp13_ = save_as_action;
	g_action_map_add_action ((GActionMap*) self, (GAction*) _tmp13_);
	_tmp14_ = g_simple_action_new ("open-style", NULL);
	open_action = _tmp14_;
	_tmp15_ = open_action;
	g_signal_connect_object (_tmp15_, "activate", (GCallback) __graphs_style_editor___lambda79__g_simple_action_activate, self, 0);
	_tmp16_ = open_action;
	g_action_map_add_action ((GActionMap*) self, (GAction*) _tmp16_);
	_tmp17_ = g_simple_action_new ("close-style", NULL);
	close_action = _tmp17_;
	_tmp18_ = close_action;
	g_signal_connect_object (_tmp18_, "activate", (GCallback) __graphs_style_editor___lambda81__g_simple_action_activate, self, 0);
	_tmp19_ = close_action;
	g_action_map_add_action ((GActionMap*) self, (GAction*) _tmp19_);
	_tmp20_ = g_simple_action_new ("show-shortcuts", NULL);
	show_shortcuts_action = _tmp20_;
	_tmp21_ = show_shortcuts_action;
	g_signal_connect_object (_tmp21_, "activate", (GCallback) __graphs_style_editor___lambda83__g_simple_action_activate, self, 0);
	_tmp22_ = show_shortcuts_action;
	g_action_map_add_action ((GActionMap*) self, (GAction*) _tmp22_);
	_tmp23_ = g_simple_action_new ("import-style", NULL);
	import_action = _tmp23_;
	_tmp24_ = import_action;
	g_signal_connect_object (_tmp24_, "activate", (GCallback) __graphs_style_editor___lambda84__g_simple_action_activate, self, 0);
	_tmp25_ = import_action;
	g_action_map_add_action ((GActionMap*) self, (GAction*) _tmp25_);
	_tmp26_ = g_simple_action_new ("create-style", NULL);
	create_action = _tmp26_;
	_tmp27_ = create_action;
	g_signal_connect_object (_tmp27_, "activate", (GCallback) __graphs_style_editor___lambda85__g_simple_action_activate, self, 0);
	_tmp28_ = create_action;
	g_action_map_add_action ((GActionMap*) self, (GAction*) _tmp28_);
	g_signal_connect_data ((GObject*) self, "notify::unsaved", (GCallback) __graphs_style_editor___lambda87__g_object_notify, block13_data_ref (_data13_), (GClosureNotify) block13_data_unref, 0);
	_tmp29_ = (GtkSignalListItemFactory*) gtk_signal_list_item_factory_new ();
	factory = _tmp29_;
	_tmp30_ = factory;
	g_signal_connect_object (_tmp30_, "setup", (GCallback) _graphs_style_editor_on_factory_setup_gtk_signal_list_item_factory_setup, self, 0);
	_tmp31_ = factory;
	g_signal_connect_object (_tmp31_, "bind", (GCallback) _graphs_style_editor_on_factory_bind_gtk_signal_list_item_factory_bind, self, 0);
	_tmp32_ = self->priv->_style_grid;
	_tmp33_ = factory;
	gtk_grid_view_set_factory (_tmp32_, (GtkListItemFactory*) _tmp33_);
	_tmp34_ = self->priv->_style_grid;
	_tmp35_ = graphs_style_manager_get_filtered_style_model ();
	_tmp36_ = _tmp35_;
	_tmp37_ = _g_object_ref0 ((GListModel*) _tmp36_);
	_tmp38_ = gtk_no_selection_new (_tmp37_);
	_tmp39_ = _tmp38_;
	gtk_grid_view_set_model (_tmp34_, (GtkSelectionModel*) _tmp39_);
	_g_object_unref0 (_tmp39_);
	_g_object_unref0 (factory);
	_g_object_unref0 (create_action);
	_g_object_unref0 (import_action);
	_g_object_unref0 (show_shortcuts_action);
	_g_object_unref0 (close_action);
	_g_object_unref0 (open_action);
	_g_object_unref0 (save_as_action);
	block13_data_unref (_data13_);
	_data13_ = NULL;
	return obj;
}

static void
graphs_style_editor_class_init (GraphsStyleEditorClass * klass,
                                gpointer klass_data)
{
	graphs_style_editor_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GraphsStyleEditor_private_offset);
	((GtkWindowClass *) klass)->close_request = (gboolean (*) (GtkWindow*)) graphs_style_editor_real_close_request;
	G_OBJECT_CLASS (klass)->get_property = _vala_graphs_style_editor_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_graphs_style_editor_set_property;
	G_OBJECT_CLASS (klass)->constructor = graphs_style_editor_constructor;
	G_OBJECT_CLASS (klass)->finalize = graphs_style_editor_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_STYLE_EDITOR_CONTENT_VIEW_PROPERTY, graphs_style_editor_properties[GRAPHS_STYLE_EDITOR_CONTENT_VIEW_PROPERTY] = g_param_spec_object ("content-view", "content-view", "content-view", adw_toolbar_view_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_STYLE_EDITOR_EDITOR_BOX_PROPERTY, graphs_style_editor_properties[GRAPHS_STYLE_EDITOR_EDITOR_BOX_PROPERTY] = g_param_spec_object ("editor-box", "editor-box", "editor-box", gtk_box_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_STYLE_EDITOR_CANVAS_PROPERTY, graphs_style_editor_properties[GRAPHS_STYLE_EDITOR_CANVAS_PROPERTY] = g_param_spec_object ("canvas", "canvas", "canvas", GRAPHS_TYPE_CANVAS, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_STYLE_EDITOR_STYLENAME_PROPERTY, graphs_style_editor_properties[GRAPHS_STYLE_EDITOR_STYLENAME_PROPERTY] = g_param_spec_string ("stylename", "stylename", "stylename", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_STYLE_EDITOR_CSS_PROVIDER_PROPERTY, graphs_style_editor_properties[GRAPHS_STYLE_EDITOR_CSS_PROVIDER_PROPERTY] = g_param_spec_object ("css-provider", "css-provider", "css-provider", gtk_css_provider_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GRAPHS_STYLE_EDITOR_UNSAVED_PROPERTY, graphs_style_editor_properties[GRAPHS_STYLE_EDITOR_UNSAVED_PROPERTY] = g_param_spec_boolean ("unsaved", "unsaved", "unsaved", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/se/sjoerd/Graphs/ui/style-editor/window.ui");
	graphs_style_editor_signals[GRAPHS_STYLE_EDITOR_LOAD_REQUEST_SIGNAL] = g_signal_new ("load-request", GRAPHS_TYPE_STYLE_EDITOR, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, g_file_get_type ());
	graphs_style_editor_signals[GRAPHS_STYLE_EDITOR_SAVE_REQUEST_SIGNAL] = g_signal_new ("save-request", GRAPHS_TYPE_STYLE_EDITOR, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, g_file_get_type ());
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "editor_bin", FALSE, GraphsStyleEditor_private_offset + G_STRUCT_OFFSET (GraphsStyleEditorPrivate, _editor_bin));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "canvas_bin", FALSE, GraphsStyleEditor_private_offset + G_STRUCT_OFFSET (GraphsStyleEditorPrivate, _canvas_bin));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "stack", FALSE, GraphsStyleEditor_private_offset + G_STRUCT_OFFSET (GraphsStyleEditorPrivate, _stack));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "style_grid", FALSE, GraphsStyleEditor_private_offset + G_STRUCT_OFFSET (GraphsStyleEditorPrivate, _style_grid));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "content_view", FALSE, GraphsStyleEditor_private_offset + G_STRUCT_OFFSET (GraphsStyleEditorPrivate, _content_view));
}

static void
graphs_style_editor_instance_init (GraphsStyleEditor * self,
                                   gpointer klass)
{
	self->priv = graphs_style_editor_get_instance_private (self);
	self->priv->_unsaved = FALSE;
	self->priv->_force_close = FALSE;
	self->priv->_inhibit_cookie = (guint) 0;
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
graphs_style_editor_finalize (GObject * obj)
{
	GraphsStyleEditor * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GRAPHS_TYPE_STYLE_EDITOR, GraphsStyleEditor);
	_g_object_unref0 (self->priv->_css_provider);
	_g_object_unref0 (self->priv->_file);
	_g_free0 (self->priv->_stylename);
	G_OBJECT_CLASS (graphs_style_editor_parent_class)->finalize (obj);
}

/**
     * Style Editor Window window
     */
static GType
graphs_style_editor_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GraphsStyleEditorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) graphs_style_editor_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GraphsStyleEditor), 0, (GInstanceInitFunc) graphs_style_editor_instance_init, NULL };
	GType graphs_style_editor_type_id;
	graphs_style_editor_type_id = g_type_register_static (adw_application_window_get_type (), "GraphsStyleEditor", &g_define_type_info, 0);
	GraphsStyleEditor_private_offset = g_type_add_instance_private (graphs_style_editor_type_id, sizeof (GraphsStyleEditorPrivate));
	return graphs_style_editor_type_id;
}

GType
graphs_style_editor_get_type (void)
{
	static volatile gsize graphs_style_editor_type_id__once = 0;
	if (g_once_init_enter (&graphs_style_editor_type_id__once)) {
		GType graphs_style_editor_type_id;
		graphs_style_editor_type_id = graphs_style_editor_get_type_once ();
		g_once_init_leave (&graphs_style_editor_type_id__once, graphs_style_editor_type_id);
	}
	return graphs_style_editor_type_id__once;
}

static void
_vala_graphs_style_editor_get_property (GObject * object,
                                        guint property_id,
                                        GValue * value,
                                        GParamSpec * pspec)
{
	GraphsStyleEditor * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GRAPHS_TYPE_STYLE_EDITOR, GraphsStyleEditor);
	switch (property_id) {
		case GRAPHS_STYLE_EDITOR_CONTENT_VIEW_PROPERTY:
		g_value_set_object (value, graphs_style_editor_get_content_view (self));
		break;
		case GRAPHS_STYLE_EDITOR_EDITOR_BOX_PROPERTY:
		g_value_set_object (value, graphs_style_editor_get_editor_box (self));
		break;
		case GRAPHS_STYLE_EDITOR_CANVAS_PROPERTY:
		g_value_set_object (value, graphs_style_editor_get_canvas (self));
		break;
		case GRAPHS_STYLE_EDITOR_CSS_PROVIDER_PROPERTY:
		g_value_set_object (value, graphs_style_editor_get_css_provider (self));
		break;
		case GRAPHS_STYLE_EDITOR_UNSAVED_PROPERTY:
		g_value_set_boolean (value, graphs_style_editor_get_unsaved (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_graphs_style_editor_set_property (GObject * object,
                                        guint property_id,
                                        const GValue * value,
                                        GParamSpec * pspec)
{
	GraphsStyleEditor * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GRAPHS_TYPE_STYLE_EDITOR, GraphsStyleEditor);
	switch (property_id) {
		case GRAPHS_STYLE_EDITOR_EDITOR_BOX_PROPERTY:
		graphs_style_editor_set_editor_box (self, g_value_get_object (value));
		break;
		case GRAPHS_STYLE_EDITOR_CANVAS_PROPERTY:
		graphs_style_editor_set_canvas (self, g_value_get_object (value));
		break;
		case GRAPHS_STYLE_EDITOR_STYLENAME_PROPERTY:
		graphs_style_editor_set_stylename (self, g_value_get_string (value));
		break;
		case GRAPHS_STYLE_EDITOR_CSS_PROVIDER_PROPERTY:
		graphs_style_editor_set_css_provider (self, g_value_get_object (value));
		break;
		case GRAPHS_STYLE_EDITOR_UNSAVED_PROPERTY:
		graphs_style_editor_set_unsaved (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

