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

/*
 * This file is part of budgie-desktop
 *
 * Copyright (C) 2015-2016 Solus Project
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 */

#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>
#include <glib/gi18n-lib.h>


#define TYPE_LIST_ITEM (list_item_get_type ())
#define LIST_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_LIST_ITEM, ListItem))
#define LIST_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_LIST_ITEM, ListItemClass))
#define IS_LIST_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_LIST_ITEM))
#define IS_LIST_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_LIST_ITEM))
#define LIST_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_LIST_ITEM, ListItemClass))

typedef struct _ListItem ListItem;
typedef struct _ListItemClass ListItemClass;
typedef struct _ListItemPrivate ListItemPrivate;

#define TYPE_PLACE_ITEM (place_item_get_type ())
#define PLACE_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PLACE_ITEM, PlaceItem))
#define PLACE_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PLACE_ITEM, PlaceItemClass))
#define IS_PLACE_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PLACE_ITEM))
#define IS_PLACE_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PLACE_ITEM))
#define PLACE_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PLACE_ITEM, PlaceItemClass))

typedef struct _PlaceItem PlaceItem;
typedef struct _PlaceItemClass PlaceItemClass;
typedef struct _PlaceItemPrivate PlaceItemPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block5Data Block5Data;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _ListItem {
	GtkBox parent_instance;
	ListItemPrivate * priv;
	gchar* item_class;
	gchar* category_name;
	GtkToolButton* name_button;
	GtkOverlay* overlay;
	GtkSpinner* spin;
};

struct _ListItemClass {
	GtkBoxClass parent_class;
};

struct _PlaceItem {
	ListItem parent_instance;
	PlaceItemPrivate * priv;
};

struct _PlaceItemClass {
	ListItemClass parent_class;
};

struct _Block5Data {
	int _ref_count_;
	PlaceItem* self;
	GFile* file;
};


static gpointer place_item_parent_class = NULL;
static GType place_item_type_id = 0;

GType list_item_get_type (void) G_GNUC_CONST;
GType list_item_register_type (GTypeModule * module);
GType place_item_get_type (void) G_GNUC_CONST;
GType place_item_register_type (GTypeModule * module);
enum  {
	PLACE_ITEM_DUMMY_PROPERTY
};
PlaceItem* place_item_new (GFile* file, const gchar* class);
PlaceItem* place_item_construct (GType object_type, GFile* file, const gchar* class);
static Block5Data* block5_data_ref (Block5Data* _data5_);
static void block5_data_unref (void * _userdata_);
ListItem* list_item_construct (GType object_type);
void list_item_set_button (ListItem* self, const gchar* label, GtkImage* image, gboolean spinner);
GtkImage* list_item_get_icon (ListItem* self, GIcon* icon);
static void __lambda6_ (Block5Data* _data5_);
void list_item_open_directory (ListItem* self, const gchar* location);
static void ___lambda6__gtk_tool_button_clicked (GtkToolButton* _sender, gpointer self);


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


static Block5Data* block5_data_ref (Block5Data* _data5_) {
	g_atomic_int_inc (&_data5_->_ref_count_);
	return _data5_;
}


static void block5_data_unref (void * _userdata_) {
	Block5Data* _data5_;
	_data5_ = (Block5Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data5_->_ref_count_)) {
		PlaceItem* self;
		self = _data5_->self;
		_g_object_unref0 (_data5_->file);
		_g_object_unref0 (self);
		g_slice_free (Block5Data, _data5_);
	}
}


static void __lambda6_ (Block5Data* _data5_) {
	PlaceItem* self;
	GFile* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	self = _data5_->self;
	_tmp0_ = _data5_->file;
	_tmp1_ = g_file_get_uri (_tmp0_);
	_tmp2_ = _tmp1_;
	list_item_open_directory ((ListItem*) self, _tmp2_);
	_g_free0 (_tmp2_);
}


static void ___lambda6__gtk_tool_button_clicked (GtkToolButton* _sender, gpointer self) {
	__lambda6_ (self);
}


PlaceItem* place_item_construct (GType object_type, GFile* file, const gchar* class) {
	PlaceItem * self = NULL;
	Block5Data* _data5_;
	GFile* _tmp0_ = NULL;
	GFile* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	GtkToolButton* _tmp19_ = NULL;
	GFile* _tmp20_ = NULL;
	gchar* _tmp21_ = NULL;
	gchar* _tmp22_ = NULL;
	gchar* _tmp23_ = NULL;
	gchar* _tmp24_ = NULL;
	const gchar* _tmp25_ = NULL;
	GtkToolButton* _tmp26_ = NULL;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (file != NULL, NULL);
	g_return_val_if_fail (class != NULL, NULL);
	_data5_ = g_slice_new0 (Block5Data);
	_data5_->_ref_count_ = 1;
	_tmp0_ = file;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (_data5_->file);
	_data5_->file = _tmp1_;
	self = (PlaceItem*) list_item_construct (object_type);
	_data5_->self = g_object_ref (self);
	_tmp2_ = class;
	_tmp3_ = g_strdup (_tmp2_);
	_g_free0 (((ListItem*) self)->item_class);
	((ListItem*) self)->item_class = _tmp3_;
	{
		GFileInfo* info = NULL;
		GFile* _tmp4_ = NULL;
		GFileInfo* _tmp5_ = NULL;
		GFile* _tmp6_ = NULL;
		gchar* _tmp7_ = NULL;
		gchar* _tmp8_ = NULL;
		GIcon* _tmp9_ = NULL;
		GtkImage* _tmp10_ = NULL;
		GtkImage* _tmp11_ = NULL;
		_tmp4_ = _data5_->file;
		_tmp5_ = g_file_query_info (_tmp4_, "standard::symbolic-icon", G_FILE_QUERY_INFO_NONE, NULL, &_inner_error_);
		info = _tmp5_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch7_g_error;
		}
		_tmp6_ = _data5_->file;
		_tmp7_ = g_file_get_basename (_tmp6_);
		_tmp8_ = _tmp7_;
		_tmp9_ = g_file_info_get_symbolic_icon (info);
		_tmp10_ = list_item_get_icon ((ListItem*) self, _tmp9_);
		_tmp11_ = _tmp10_;
		list_item_set_button ((ListItem*) self, _tmp8_, _tmp11_, FALSE);
		_g_object_unref0 (_tmp11_);
		_g_free0 (_tmp8_);
		_g_object_unref0 (info);
	}
	goto __finally7;
	__catch7_g_error:
	{
		GError* e = NULL;
		GFile* _tmp12_ = NULL;
		gchar* _tmp13_ = NULL;
		gchar* _tmp14_ = NULL;
		GtkImage* _tmp15_ = NULL;
		GtkImage* _tmp16_ = NULL;
		GError* _tmp17_ = NULL;
		const gchar* _tmp18_ = NULL;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp12_ = _data5_->file;
		_tmp13_ = g_file_get_basename (_tmp12_);
		_tmp14_ = _tmp13_;
		_tmp15_ = list_item_get_icon ((ListItem*) self, NULL);
		_tmp16_ = _tmp15_;
		list_item_set_button ((ListItem*) self, _tmp14_, _tmp16_, FALSE);
		_g_object_unref0 (_tmp16_);
		_g_free0 (_tmp14_);
		_tmp17_ = e;
		_tmp18_ = _tmp17_->message;
		g_warning ("PlaceItem.vala:24: %s", _tmp18_);
		_g_error_free0 (e);
	}
	__finally7:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		block5_data_unref (_data5_);
		_data5_ = NULL;
		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 NULL;
	}
	_tmp19_ = ((ListItem*) self)->name_button;
	_tmp20_ = _data5_->file;
	_tmp21_ = g_file_get_basename (_tmp20_);
	_tmp22_ = _tmp21_;
	_tmp23_ = g_strdup_printf ("Open \"%s\"", _tmp22_);
	_tmp24_ = _tmp23_;
	_tmp25_ = _ (_tmp24_);
	gtk_tool_item_set_tooltip_text ((GtkToolItem*) _tmp19_, _tmp25_);
	_g_free0 (_tmp24_);
	_g_free0 (_tmp22_);
	_tmp26_ = ((ListItem*) self)->name_button;
	g_signal_connect_data (_tmp26_, "clicked", (GCallback) ___lambda6__gtk_tool_button_clicked, block5_data_ref (_data5_), (GClosureNotify) block5_data_unref, 0);
	block5_data_unref (_data5_);
	_data5_ = NULL;
	return self;
}


PlaceItem* place_item_new (GFile* file, const gchar* class) {
	return place_item_construct (TYPE_PLACE_ITEM, file, class);
}


static void place_item_class_init (PlaceItemClass * klass) {
	place_item_parent_class = g_type_class_peek_parent (klass);
}


static void place_item_instance_init (PlaceItem * self) {
}


GType place_item_get_type (void) {
	return place_item_type_id;
}


GType place_item_register_type (GTypeModule * module) {
	static const GTypeInfo g_define_type_info = { sizeof (PlaceItemClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) place_item_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (PlaceItem), 0, (GInstanceInitFunc) place_item_instance_init, NULL };
	place_item_type_id = g_type_module_register_type (module, TYPE_LIST_ITEM, "PlaceItem", &g_define_type_info, 0);
	return place_item_type_id;
}



