/* gcp-app-activatable.c generated by valac 0.19.0, the Vala compiler
 * generated from gcp-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 GCP_TYPE_APP_ACTIVATABLE (gcp_app_activatable_get_type ())
#define GCP_APP_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCP_TYPE_APP_ACTIVATABLE, GcpAppActivatable))
#define GCP_APP_ACTIVATABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GCP_TYPE_APP_ACTIVATABLE, GcpAppActivatableClass))
#define GCP_IS_APP_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCP_TYPE_APP_ACTIVATABLE))
#define GCP_IS_APP_ACTIVATABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GCP_TYPE_APP_ACTIVATABLE))
#define GCP_APP_ACTIVATABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GCP_TYPE_APP_ACTIVATABLE, GcpAppActivatableClass))

typedef struct _GcpAppActivatable GcpAppActivatable;
typedef struct _GcpAppActivatableClass GcpAppActivatableClass;
typedef struct _GcpAppActivatablePrivate GcpAppActivatablePrivate;
#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 _GcpAppActivatable {
	PeasExtensionBase parent_instance;
	GcpAppActivatablePrivate * priv;
};

struct _GcpAppActivatableClass {
	PeasExtensionBaseClass parent_class;
};

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


static gpointer gcp_app_activatable_parent_class = NULL;
static GeditAppActivatableInterface* gcp_app_activatable_gedit_app_activatable_parent_iface = NULL;

GType gcp_app_activatable_get_type (void) G_GNUC_CONST;
#define GCP_APP_ACTIVATABLE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GCP_TYPE_APP_ACTIVATABLE, GcpAppActivatablePrivate))
enum  {
	GCP_APP_ACTIVATABLE_DUMMY_PROPERTY,
	GCP_APP_ACTIVATABLE_APP
};
static void gcp_app_activatable_real_activate (GeditAppActivatable* base);
static void gcp_app_activatable_real_deactivate (GeditAppActivatable* base);
GcpAppActivatable* gcp_app_activatable_new (void);
GcpAppActivatable* gcp_app_activatable_construct (GType object_type);
GeditApp* gcp_app_activatable_get_app (GcpAppActivatable* self);
void gcp_app_activatable_set_app (GcpAppActivatable* self, GeditApp* value);
static void gcp_app_activatable_finalize (GObject* obj);
static void _vala_gcp_app_activatable_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_gcp_app_activatable_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);


static void gcp_app_activatable_real_activate (GeditAppActivatable* base) {
	GcpAppActivatable * self;
	GtkCssProvider* _tmp0_;
	gchar* _tmp1_ = NULL;
	gchar* _tmp2_;
	GFile* _tmp3_ = NULL;
	GFile* _tmp4_;
	GFile* file;
	GFile* _tmp5_ = NULL;
	GFile* child;
	GdkScreen* _tmp10_ = NULL;
	GtkCssProvider* _tmp11_;
	GError * _inner_error_ = NULL;
	self = (GcpAppActivatable*) 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, "gcp.css");
	child = _tmp5_;
	{
		GtkCssProvider* _tmp6_;
		_tmp6_ = self->priv->d_provider;
		gtk_css_provider_load_from_file (_tmp6_, child, &_inner_error_);
		if (_inner_error_ != NULL) {
			goto __catch1_g_error;
		}
	}
	goto __finally1;
	__catch1_g_error:
	{
		GError* _error_ = NULL;
		FILE* _tmp7_;
		GError* _tmp8_;
		const gchar* _tmp9_;
		_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_);
	}
	__finally1:
	if (_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 gcp_app_activatable_real_deactivate (GeditAppActivatable* base) {
	GcpAppActivatable * self;
	GdkScreen* _tmp0_ = NULL;
	GtkCssProvider* _tmp1_;
	self = (GcpAppActivatable*) base;
	_tmp0_ = gdk_screen_get_default ();
	_tmp1_ = self->priv->d_provider;
	gtk_style_context_remove_provider_for_screen (_tmp0_, (GtkStyleProvider*) _tmp1_);
}


GcpAppActivatable* gcp_app_activatable_construct (GType object_type) {
	GcpAppActivatable * self = NULL;
	self = (GcpAppActivatable*) g_object_new (object_type, NULL);
	return self;
}


GcpAppActivatable* gcp_app_activatable_new (void) {
	return gcp_app_activatable_construct (GCP_TYPE_APP_ACTIVATABLE);
}


GeditApp* gcp_app_activatable_get_app (GcpAppActivatable* self) {
	GeditApp* result;
	GeditApp* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_app;
	result = _tmp0_;
	return result;
}


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


void gcp_app_activatable_set_app (GcpAppActivatable* self, GeditApp* value) {
	GeditApp* _tmp0_;
	GeditApp* _tmp1_;
	g_return_if_fail (self != NULL);
	_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 gcp_app_activatable_class_init (GcpAppActivatableClass * klass) {
	gcp_app_activatable_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (GcpAppActivatablePrivate));
	G_OBJECT_CLASS (klass)->get_property = _vala_gcp_app_activatable_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_gcp_app_activatable_set_property;
	G_OBJECT_CLASS (klass)->finalize = gcp_app_activatable_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GCP_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));
}


static void gcp_app_activatable_gedit_app_activatable_interface_init (GeditAppActivatableInterface * iface) {
	gcp_app_activatable_gedit_app_activatable_parent_iface = g_type_interface_peek_parent (iface);
	iface->activate = (void (*)(GeditAppActivatable*)) gcp_app_activatable_real_activate;
	iface->deactivate = (void (*)(GeditAppActivatable*)) gcp_app_activatable_real_deactivate;
}


static void gcp_app_activatable_instance_init (GcpAppActivatable * self) {
	self->priv = GCP_APP_ACTIVATABLE_GET_PRIVATE (self);
}


static void gcp_app_activatable_finalize (GObject* obj) {
	GcpAppActivatable * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GCP_TYPE_APP_ACTIVATABLE, GcpAppActivatable);
	_g_object_unref0 (self->priv->_app);
	_g_object_unref0 (self->priv->d_provider);
	G_OBJECT_CLASS (gcp_app_activatable_parent_class)->finalize (obj);
}


GType gcp_app_activatable_get_type (void) {
	static volatile gsize gcp_app_activatable_type_id__volatile = 0;
	if (g_once_init_enter (&gcp_app_activatable_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (GcpAppActivatableClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gcp_app_activatable_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GcpAppActivatable), 0, (GInstanceInitFunc) gcp_app_activatable_instance_init, NULL };
		static const GInterfaceInfo gedit_app_activatable_info = { (GInterfaceInitFunc) gcp_app_activatable_gedit_app_activatable_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
		GType gcp_app_activatable_type_id;
		gcp_app_activatable_type_id = g_type_register_static (peas_extension_base_get_type (), "GcpAppActivatable", &g_define_type_info, 0);
		g_type_add_interface_static (gcp_app_activatable_type_id, gedit_app_activatable_get_type (), &gedit_app_activatable_info);
		g_once_init_leave (&gcp_app_activatable_type_id__volatile, gcp_app_activatable_type_id);
	}
	return gcp_app_activatable_type_id__volatile;
}


static void _vala_gcp_app_activatable_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	GcpAppActivatable * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GCP_TYPE_APP_ACTIVATABLE, GcpAppActivatable);
	switch (property_id) {
		case GCP_APP_ACTIVATABLE_APP:
		g_value_set_object (value, gcp_app_activatable_get_app (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_gcp_app_activatable_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	GcpAppActivatable * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GCP_TYPE_APP_ACTIVATABLE, GcpAppActivatable);
	switch (property_id) {
		case GCP_APP_ACTIVATABLE_APP:
		gcp_app_activatable_set_app (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



