/* gca-app-activatable.c generated by valac 0.28.0.11-bbdd, the Vala compiler
 * generated from gca-app-activatable.vala, do not modify */


#include <glib.h>
#include <glib-object.h>
#include <libpeas/peas.h>
#include <gedit/gedit-app-activatable.h>
#include <gedit/gedit-app.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <stdio.h>
#include <gdk/gdk.h>


#define GCA_TYPE_APP_ACTIVATABLE (gca_app_activatable_get_type ())
#define GCA_APP_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCA_TYPE_APP_ACTIVATABLE, GcaAppActivatable))
#define GCA_APP_ACTIVATABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GCA_TYPE_APP_ACTIVATABLE, GcaAppActivatableClass))
#define GCA_IS_APP_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCA_TYPE_APP_ACTIVATABLE))
#define GCA_IS_APP_ACTIVATABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GCA_TYPE_APP_ACTIVATABLE))
#define GCA_APP_ACTIVATABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GCA_TYPE_APP_ACTIVATABLE, GcaAppActivatableClass))

typedef struct _GcaAppActivatable GcaAppActivatable;
typedef struct _GcaAppActivatableClass GcaAppActivatableClass;
typedef struct _GcaAppActivatablePrivate GcaAppActivatablePrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _GcaAppActivatable {
	PeasExtensionBase parent_instance;
	GcaAppActivatablePrivate * priv;
};

struct _GcaAppActivatableClass {
	PeasExtensionBaseClass parent_class;
};

struct _GcaAppActivatablePrivate {
	GeditApp* _app;
	GtkCssProvider* d_provider;
};


static gpointer gca_app_activatable_parent_class = NULL;
static GeditAppActivatableInterface* gca_app_activatable_gedit_app_activatable_parent_iface = NULL;

GType gca_app_activatable_get_type (void) G_GNUC_CONST;
#define GCA_APP_ACTIVATABLE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GCA_TYPE_APP_ACTIVATABLE, GcaAppActivatablePrivate))
enum  {
	GCA_APP_ACTIVATABLE_DUMMY_PROPERTY,
	GCA_APP_ACTIVATABLE_APP
};
static void gca_app_activatable_real_activate (GeditAppActivatable* base);
static void gca_app_activatable_real_deactivate (GeditAppActivatable* base);
GcaAppActivatable* gca_app_activatable_new (void);
GcaAppActivatable* gca_app_activatable_construct (GType object_type);
static void gca_app_activatable_finalize (GObject* obj);
static void _vala_gca_app_activatable_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_gca_app_activatable_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);


static void gca_app_activatable_real_activate (GeditAppActivatable* base) {
	GcaAppActivatable * self;
	GtkCssProvider* _tmp0_ = NULL;
	GFile* file = NULL;
	gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	GFile* _tmp3_ = NULL;
	GFile* _tmp4_ = NULL;
	GFile* child = NULL;
	GFile* _tmp5_ = NULL;
	GdkScreen* _tmp10_ = NULL;
	GtkCssProvider* _tmp11_ = NULL;
	GError * _inner_error_ = NULL;
	self = (GcaAppActivatable*) base;
	_tmp0_ = gtk_css_provider_new ();
	_g_object_unref0 (self->priv->d_provider);
	self->priv->d_provider = _tmp0_;
	_tmp1_ = peas_extension_base_get_data_dir ((PeasExtensionBase*) self);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_file_new_for_path (_tmp2_);
	_tmp4_ = _tmp3_;
	_g_free0 (_tmp2_);
	file = _tmp4_;
	_tmp5_ = g_file_get_child (file, "codeassistance.css");
	child = _tmp5_;
	{
		GtkCssProvider* _tmp6_ = NULL;
		_tmp6_ = self->priv->d_provider;
		gtk_css_provider_load_from_file (_tmp6_, child, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* _error_ = NULL;
		FILE* _tmp7_ = NULL;
		GError* _tmp8_ = NULL;
		const gchar* _tmp9_ = NULL;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		_tmp7_ = stderr;
		_tmp8_ = _error_;
		_tmp9_ = _tmp8_->message;
		fprintf (_tmp7_, "Could not load css for gcp: %s\n", _tmp9_);
		_g_error_free0 (_error_);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		_g_object_unref0 (child);
		_g_object_unref0 (file);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
	_tmp10_ = gdk_screen_get_default ();
	_tmp11_ = self->priv->d_provider;
	gtk_style_context_add_provider_for_screen (_tmp10_, (GtkStyleProvider*) _tmp11_, (guint) 600);
	_g_object_unref0 (child);
	_g_object_unref0 (file);
}


static void gca_app_activatable_real_deactivate (GeditAppActivatable* base) {
	GcaAppActivatable * self;
	GdkScreen* _tmp0_ = NULL;
	GtkCssProvider* _tmp1_ = NULL;
	self = (GcaAppActivatable*) base;
	_tmp0_ = gdk_screen_get_default ();
	_tmp1_ = self->priv->d_provider;
	gtk_style_context_remove_provider_for_screen (_tmp0_, (GtkStyleProvider*) _tmp1_);
}


GcaAppActivatable* gca_app_activatable_construct (GType object_type) {
	GcaAppActivatable * self = NULL;
	self = (GcaAppActivatable*) g_object_new (object_type, NULL);
	return self;
}


GcaAppActivatable* gca_app_activatable_new (void) {
	return gca_app_activatable_construct (GCA_TYPE_APP_ACTIVATABLE);
}


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


static GeditApp* gca_app_activatable_real_get_app (GeditAppActivatable* base) {
	GeditApp* result;
	GcaAppActivatable* self;
	GeditApp* _tmp0_ = NULL;
	GeditApp* _tmp1_ = NULL;
	self = (GcaAppActivatable*) base;
	_tmp0_ = self->priv->_app;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	result = _tmp1_;
	return result;
}


static void gca_app_activatable_real_set_app (GeditAppActivatable* base, GeditApp* value) {
	GcaAppActivatable* self;
	GeditApp* _tmp0_ = NULL;
	GeditApp* _tmp1_ = NULL;
	self = (GcaAppActivatable*) base;
	_tmp0_ = value;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->_app);
	self->priv->_app = _tmp1_;
	g_object_notify ((GObject *) self, "app");
}


static void gca_app_activatable_class_init (GcaAppActivatableClass * klass) {
	gca_app_activatable_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (GcaAppActivatablePrivate));
	G_OBJECT_CLASS (klass)->get_property = _vala_gca_app_activatable_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_gca_app_activatable_set_property;
	G_OBJECT_CLASS (klass)->finalize = gca_app_activatable_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GCA_APP_ACTIVATABLE_APP, g_param_spec_object ("app", "app", "app", gedit_app_get_type (), G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}


static void gca_app_activatable_gedit_app_activatable_interface_init (GeditAppActivatableInterface * iface) {
	gca_app_activatable_gedit_app_activatable_parent_iface = g_type_interface_peek_parent (iface);
	iface->activate = (void (*)(GeditAppActivatable*)) gca_app_activatable_real_activate;
	iface->deactivate = (void (*)(GeditAppActivatable*)) gca_app_activatable_real_deactivate;
}


static void gca_app_activatable_instance_init (GcaAppActivatable * self) {
	self->priv = GCA_APP_ACTIVATABLE_GET_PRIVATE (self);
}


static void gca_app_activatable_finalize (GObject* obj) {
	GcaAppActivatable * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GCA_TYPE_APP_ACTIVATABLE, GcaAppActivatable);
	_g_object_unref0 (self->priv->_app);
	_g_object_unref0 (self->priv->d_provider);
	G_OBJECT_CLASS (gca_app_activatable_parent_class)->finalize (obj);
}


GType gca_app_activatable_get_type (void) {
	static volatile gsize gca_app_activatable_type_id__volatile = 0;
	if (g_once_init_enter (&gca_app_activatable_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (GcaAppActivatableClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gca_app_activatable_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GcaAppActivatable), 0, (GInstanceInitFunc) gca_app_activatable_instance_init, NULL };
		static const GInterfaceInfo gedit_app_activatable_info = { (GInterfaceInitFunc) gca_app_activatable_gedit_app_activatable_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
		GType gca_app_activatable_type_id;
		gca_app_activatable_type_id = g_type_register_static (peas_extension_base_get_type (), "GcaAppActivatable", &g_define_type_info, 0);
		g_type_add_interface_static (gca_app_activatable_type_id, gedit_app_activatable_get_type (), &gedit_app_activatable_info);
		g_once_init_leave (&gca_app_activatable_type_id__volatile, gca_app_activatable_type_id);
	}
	return gca_app_activatable_type_id__volatile;
}


static void _vala_gca_app_activatable_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	GcaAppActivatable * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GCA_TYPE_APP_ACTIVATABLE, GcaAppActivatable);
	switch (property_id) {
		case GCA_APP_ACTIVATABLE_APP:
		g_value_take_object (value, gca_app_activatable_real_get_app ((GeditAppActivatable*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_gca_app_activatable_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	GcaAppActivatable * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GCA_TYPE_APP_ACTIVATABLE, GcaAppActivatable);
	switch (property_id) {
		case GCA_APP_ACTIVATABLE_APP:
		gca_app_activatable_real_set_app ((GeditAppActivatable*) self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



