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

/*-
* Copyright (c) 2014-2017 elementary LLC. (http://launchpad.net/switchboard-plug-security-privacy)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* Authored by: Corentin Noël <corentin@elementaryos.org>
*/

#include "security-privacy.h"
#include <glib-object.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gee.h>
#include <glib/gi18n-lib.h>
#include <float.h>
#include <math.h>
#include <zeitgeist-datamodel.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  {
	INCLUDE_TREE_VIEW_0_PROPERTY,
	INCLUDE_TREE_VIEW_NUM_PROPERTIES
};
static GParamSpec* include_tree_view_properties[INCLUDE_TREE_VIEW_NUM_PROPERTIES];
typedef enum  {
	INCLUDE_TREE_VIEW_COLUMNS_ACTIVE,
	INCLUDE_TREE_VIEW_COLUMNS_NAME,
	INCLUDE_TREE_VIEW_COLUMNS_ICON,
	INCLUDE_TREE_VIEW_COLUMNS_FILE_TYPE,
	INCLUDE_TREE_VIEW_COLUMNS_N_COLUMNS
} IncludeTreeViewColumns;

#define INCLUDE_TREE_VIEW_TYPE_COLUMNS (include_tree_view_columns_get_type ())
#define _security_privacy_file_type_blacklist_unref0(var) ((var == NULL) ? NULL : (var = (security_privacy_file_type_blacklist_unref (var), NULL)))
typedef struct _Block9Data Block9Data;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _IncludeTreeViewPrivate {
	SecurityPrivacyFileTypeBlacklist* filetype_blacklist;
};

struct _Block9Data {
	int _ref_count_;
	IncludeTreeView* self;
	GtkListStore* list_store;
};

static gint IncludeTreeView_private_offset;
static gpointer include_tree_view_parent_class = NULL;

static GType include_tree_view_columns_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
static void include_tree_view_set_inclue_iter_to_liststore (IncludeTreeView* self,
                                                     GtkListStore* list_store,
                                                     const gchar* name,
                                                     const gchar* icon,
                                                     const gchar* file_type);
static GObject * include_tree_view_constructor (GType type,
                                         guint n_construct_properties,
                                         GObjectConstructParam * construct_properties);
static Block9Data* block9_data_ref (Block9Data* _data9_);
static void block9_data_unref (void * _userdata_);
static void _include_tree_view___lambda4_ (Block9Data* _data9_,
                                    GtkTreePath* path,
                                    GtkTreeViewColumn* column);
static void __include_tree_view___lambda4__gtk_tree_view_row_activated (GtkTreeView* _sender,
                                                                 GtkTreePath* path,
                                                                 GtkTreeViewColumn* column,
                                                                 gpointer self);
static void include_tree_view_finalize (GObject * obj);
static GType include_tree_view_get_type_once (void);

static inline gpointer
include_tree_view_get_instance_private (IncludeTreeView* self)
{
	return G_STRUCT_MEMBER_P (self, IncludeTreeView_private_offset);
}

static GType
include_tree_view_columns_get_type_once (void)
{
	static const GEnumValue values[] = {{INCLUDE_TREE_VIEW_COLUMNS_ACTIVE, "INCLUDE_TREE_VIEW_COLUMNS_ACTIVE", "active"}, {INCLUDE_TREE_VIEW_COLUMNS_NAME, "INCLUDE_TREE_VIEW_COLUMNS_NAME", "name"}, {INCLUDE_TREE_VIEW_COLUMNS_ICON, "INCLUDE_TREE_VIEW_COLUMNS_ICON", "icon"}, {INCLUDE_TREE_VIEW_COLUMNS_FILE_TYPE, "INCLUDE_TREE_VIEW_COLUMNS_FILE_TYPE", "file-type"}, {INCLUDE_TREE_VIEW_COLUMNS_N_COLUMNS, "INCLUDE_TREE_VIEW_COLUMNS_N_COLUMNS", "n-columns"}, {0, NULL, NULL}};
	GType include_tree_view_columns_type_id;
	include_tree_view_columns_type_id = g_enum_register_static ("IncludeTreeViewColumns", values);
	return include_tree_view_columns_type_id;
}

static GType
include_tree_view_columns_get_type (void)
{
	static volatile gsize include_tree_view_columns_type_id__once = 0;
	if (g_once_init_enter (&include_tree_view_columns_type_id__once)) {
		GType include_tree_view_columns_type_id;
		include_tree_view_columns_type_id = include_tree_view_columns_get_type_once ();
		g_once_init_leave (&include_tree_view_columns_type_id__once, include_tree_view_columns_type_id);
	}
	return include_tree_view_columns_type_id__once;
}

IncludeTreeView*
include_tree_view_construct (GType object_type)
{
	IncludeTreeView * self = NULL;
	self = (IncludeTreeView*) g_object_new (object_type, "row-spacing", 6, NULL);
	return self;
}

IncludeTreeView*
include_tree_view_new (void)
{
	return include_tree_view_construct (TYPE_INCLUDE_TREE_VIEW);
}

static void
include_tree_view_set_inclue_iter_to_liststore (IncludeTreeView* self,
                                                GtkListStore* list_store,
                                                const gchar* name,
                                                const gchar* icon,
                                                const gchar* file_type)
{
	GtkTreeIter iter = {0};
	GtkTreeIter _tmp0_ = {0};
	gboolean active = FALSE;
	SecurityPrivacyFileTypeBlacklist* _tmp1_;
	GeeHashSet* _tmp2_;
	GeeHashSet* _tmp3_;
	GtkTreeIter _tmp4_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (list_store != NULL);
	g_return_if_fail (name != NULL);
	g_return_if_fail (icon != NULL);
	g_return_if_fail (file_type != NULL);
	gtk_list_store_append (list_store, &_tmp0_);
	iter = _tmp0_;
	_tmp1_ = self->priv->filetype_blacklist;
	_tmp2_ = security_privacy_file_type_blacklist_get_all_filetypes (_tmp1_);
	_tmp3_ = _tmp2_;
	active = gee_abstract_collection_contains ((GeeAbstractCollection*) _tmp3_, file_type) == FALSE;
	_tmp4_ = iter;
	gtk_list_store_set (list_store, &_tmp4_, INCLUDE_TREE_VIEW_COLUMNS_ACTIVE, active, INCLUDE_TREE_VIEW_COLUMNS_NAME, name, INCLUDE_TREE_VIEW_COLUMNS_ICON, icon, INCLUDE_TREE_VIEW_COLUMNS_FILE_TYPE, file_type, -1);
}

static Block9Data*
block9_data_ref (Block9Data* _data9_)
{
	g_atomic_int_inc (&_data9_->_ref_count_);
	return _data9_;
}

static void
block9_data_unref (void * _userdata_)
{
	Block9Data* _data9_;
	_data9_ = (Block9Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data9_->_ref_count_)) {
		IncludeTreeView* self;
		self = _data9_->self;
		_g_object_unref0 (_data9_->list_store);
		_g_object_unref0 (self);
		g_slice_free (Block9Data, _data9_);
	}
}

static void
_include_tree_view___lambda4_ (Block9Data* _data9_,
                               GtkTreePath* path,
                               GtkTreeViewColumn* column)
{
	IncludeTreeView* self;
	GValue active = {0};
	GtkTreeIter iter = {0};
	GtkListStore* _tmp0_;
	GtkTreeIter _tmp1_ = {0};
	GtkListStore* _tmp2_;
	GtkTreeIter _tmp3_;
	GValue _tmp4_ = {0};
	gboolean is_active = FALSE;
	GtkListStore* _tmp5_;
	GtkTreeIter _tmp6_;
	GValue name = {0};
	GtkListStore* _tmp7_;
	GtkTreeIter _tmp8_;
	GValue _tmp9_ = {0};
	self = _data9_->self;
	g_return_if_fail (path != NULL);
	_tmp0_ = _data9_->list_store;
	gtk_tree_model_get_iter ((GtkTreeModel*) _tmp0_, &_tmp1_, path);
	iter = _tmp1_;
	_tmp2_ = _data9_->list_store;
	_tmp3_ = iter;
	gtk_tree_model_get_value ((GtkTreeModel*) _tmp2_, &_tmp3_, (gint) INCLUDE_TREE_VIEW_COLUMNS_ACTIVE, &_tmp4_);
	G_IS_VALUE (&active) ? (g_value_unset (&active), NULL) : NULL;
	active = _tmp4_;
	is_active = !g_value_get_boolean (&active);
	_tmp5_ = _data9_->list_store;
	_tmp6_ = iter;
	gtk_list_store_set (_tmp5_, &_tmp6_, INCLUDE_TREE_VIEW_COLUMNS_ACTIVE, is_active, -1);
	_tmp7_ = _data9_->list_store;
	_tmp8_ = iter;
	gtk_tree_model_get_value ((GtkTreeModel*) _tmp7_, &_tmp8_, (gint) INCLUDE_TREE_VIEW_COLUMNS_FILE_TYPE, &_tmp9_);
	G_IS_VALUE (&name) ? (g_value_unset (&name), NULL) : NULL;
	name = _tmp9_;
	if (is_active == TRUE) {
		SecurityPrivacyFileTypeBlacklist* _tmp10_;
		const gchar* _tmp11_;
		_tmp10_ = self->priv->filetype_blacklist;
		_tmp11_ = g_value_get_string (&name);
		security_privacy_file_type_blacklist_unblock (_tmp10_, _tmp11_);
	} else {
		SecurityPrivacyFileTypeBlacklist* _tmp12_;
		const gchar* _tmp13_;
		_tmp12_ = self->priv->filetype_blacklist;
		_tmp13_ = g_value_get_string (&name);
		security_privacy_file_type_blacklist_block (_tmp12_, _tmp13_);
	}
	G_IS_VALUE (&name) ? (g_value_unset (&name), NULL) : NULL;
	G_IS_VALUE (&active) ? (g_value_unset (&active), NULL) : NULL;
}

static void
__include_tree_view___lambda4__gtk_tree_view_row_activated (GtkTreeView* _sender,
                                                            GtkTreePath* path,
                                                            GtkTreeViewColumn* column,
                                                            gpointer self)
{
	_include_tree_view___lambda4_ (self, path, column);
}

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

static GObject *
include_tree_view_constructor (GType type,
                               guint n_construct_properties,
                               GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	IncludeTreeView * self;
	Block9Data* _data9_;
	SecurityPrivacyBlacklist* _tmp0_;
	SecurityPrivacyBlacklist* _tmp1_;
	SecurityPrivacyFileTypeBlacklist* _tmp2_;
	GtkListStore* _tmp3_;
	GtkTreeView* view = NULL;
	GtkListStore* _tmp4_;
	GtkTreeView* _tmp5_;
	GtkTreeView* _tmp6_;
	GtkTreeView* _tmp7_;
	GtkTreeView* _tmp8_;
	GtkCellRendererToggle* celltoggle = NULL;
	GtkCellRendererToggle* _tmp9_;
	GtkTreeView* _tmp10_;
	GtkCellRendererText* cell = NULL;
	GtkCellRendererText* _tmp11_;
	GtkCellRendererPixbuf* cellpixbuf = NULL;
	GtkCellRendererPixbuf* _tmp12_ = NULL;
	GtkTreeView* _tmp13_;
	GtkCellRendererToggle* _tmp14_;
	GtkTreeView* _tmp15_;
	GtkCellRendererPixbuf* _tmp16_;
	GtkTreeView* _tmp17_;
	GtkCellRendererText* _tmp18_;
	GtkScrolledWindow* scrolled = NULL;
	GtkTreeView* _tmp19_;
	GtkWidget* _tmp20_;
	GtkScrolledWindow* _tmp21_ = NULL;
	GtkLabel* record_label = NULL;
	GtkLabel* _tmp22_;
	GtkLabel* _tmp23_;
	GtkLabel* _tmp24_;
	GtkScrolledWindow* _tmp25_;
	GtkListStore* _tmp26_;
	GtkListStore* _tmp27_;
	GtkListStore* _tmp28_;
	GtkListStore* _tmp29_;
	GtkListStore* _tmp30_;
	GtkListStore* _tmp31_;
	GtkListStore* _tmp32_;
	parent_class = G_OBJECT_CLASS (include_tree_view_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_INCLUDE_TREE_VIEW, IncludeTreeView);
	_data9_ = g_slice_new0 (Block9Data);
	_data9_->_ref_count_ = 1;
	_data9_->self = g_object_ref (self);
	_tmp0_ = security_privacy_track_panel_get_blacklist ();
	_tmp1_ = _tmp0_;
	_tmp2_ = security_privacy_file_type_blacklist_new (_tmp1_);
	_security_privacy_file_type_blacklist_unref0 (self->priv->filetype_blacklist);
	self->priv->filetype_blacklist = _tmp2_;
	_tmp3_ = gtk_list_store_new ((gint) INCLUDE_TREE_VIEW_COLUMNS_N_COLUMNS, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, -1);
	_data9_->list_store = _tmp3_;
	_tmp4_ = _data9_->list_store;
	_tmp5_ = (GtkTreeView*) gtk_tree_view_new_with_model ((GtkTreeModel*) _tmp4_);
	g_object_ref_sink (_tmp5_);
	view = _tmp5_;
	_tmp6_ = view;
	gtk_widget_set_vexpand ((GtkWidget*) _tmp6_, TRUE);
	_tmp7_ = view;
	gtk_tree_view_set_headers_visible (_tmp7_, FALSE);
	_tmp8_ = view;
	gtk_tree_view_set_activate_on_single_click (_tmp8_, TRUE);
	_tmp9_ = (GtkCellRendererToggle*) gtk_cell_renderer_toggle_new ();
	g_object_ref_sink (_tmp9_);
	celltoggle = _tmp9_;
	_tmp10_ = view;
	g_signal_connect_data (_tmp10_, "row-activated", (GCallback) __include_tree_view___lambda4__gtk_tree_view_row_activated, block9_data_ref (_data9_), (GClosureNotify) block9_data_unref, 0);
	_tmp11_ = (GtkCellRendererText*) gtk_cell_renderer_text_new ();
	g_object_ref_sink (_tmp11_);
	cell = _tmp11_;
	_tmp12_ = (GtkCellRendererPixbuf*) gtk_cell_renderer_pixbuf_new ();
	g_object_set (_tmp12_, "icon-size", GTK_ICON_SIZE_LARGE, NULL);
	g_object_ref_sink (_tmp12_);
	cellpixbuf = _tmp12_;
	_tmp13_ = view;
	_tmp14_ = celltoggle;
	gtk_tree_view_insert_column_with_attributes (_tmp13_, -1, "", (GtkCellRenderer*) _tmp14_, "active", INCLUDE_TREE_VIEW_COLUMNS_ACTIVE, NULL);
	_tmp15_ = view;
	_tmp16_ = cellpixbuf;
	gtk_tree_view_insert_column_with_attributes (_tmp15_, -1, "", (GtkCellRenderer*) _tmp16_, "icon-name", INCLUDE_TREE_VIEW_COLUMNS_ICON, NULL);
	_tmp17_ = view;
	_tmp18_ = cell;
	gtk_tree_view_insert_column_with_attributes (_tmp17_, -1, "", (GtkCellRenderer*) _tmp18_, "markup", INCLUDE_TREE_VIEW_COLUMNS_NAME, NULL);
	_tmp19_ = view;
	_tmp20_ = _g_object_ref0 ((GtkWidget*) _tmp19_);
	_tmp21_ = (GtkScrolledWindow*) gtk_scrolled_window_new ();
	gtk_scrolled_window_set_child (_tmp21_, _tmp20_);
	_g_object_unref0 (_tmp20_);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp21_, TRUE);
	gtk_widget_set_vexpand ((GtkWidget*) _tmp21_, TRUE);
	gtk_scrolled_window_set_has_frame (_tmp21_, TRUE);
	g_object_ref_sink (_tmp21_);
	scrolled = _tmp21_;
	_tmp22_ = (GtkLabel*) gtk_label_new (_ ("Data Sources:"));
	g_object_ref_sink (_tmp22_);
	record_label = _tmp22_;
	_tmp23_ = record_label;
	gtk_label_set_xalign (_tmp23_, (gfloat) 0);
	_tmp24_ = record_label;
	gtk_grid_attach ((GtkGrid*) self, (GtkWidget*) _tmp24_, 0, 0, 1, 1);
	_tmp25_ = scrolled;
	gtk_grid_attach ((GtkGrid*) self, (GtkWidget*) _tmp25_, 0, 1, 1, 1);
	_tmp26_ = _data9_->list_store;
	include_tree_view_set_inclue_iter_to_liststore (self, _tmp26_, _ ("Chat Logs"), "internet-chat", ZEITGEIST_NMO_IMMESSAGE);
	_tmp27_ = _data9_->list_store;
	include_tree_view_set_inclue_iter_to_liststore (self, _tmp27_, _ ("Documents"), "x-office-document", ZEITGEIST_NFO_DOCUMENT);
	_tmp28_ = _data9_->list_store;
	include_tree_view_set_inclue_iter_to_liststore (self, _tmp28_, _ ("Music"), "audio-x-generic", ZEITGEIST_NFO_AUDIO);
	_tmp29_ = _data9_->list_store;
	include_tree_view_set_inclue_iter_to_liststore (self, _tmp29_, _ ("Pictures"), "image-x-generic", ZEITGEIST_NFO_IMAGE);
	_tmp30_ = _data9_->list_store;
	include_tree_view_set_inclue_iter_to_liststore (self, _tmp30_, _ ("Presentations"), "x-office-presentation", ZEITGEIST_NFO_PRESENTATION);
	_tmp31_ = _data9_->list_store;
	include_tree_view_set_inclue_iter_to_liststore (self, _tmp31_, _ ("Spreadsheets"), "x-office-spreadsheet", ZEITGEIST_NFO_SPREADSHEET);
	_tmp32_ = _data9_->list_store;
	include_tree_view_set_inclue_iter_to_liststore (self, _tmp32_, _ ("Videos"), "video-x-generic", ZEITGEIST_NFO_VIDEO);
	_g_object_unref0 (record_label);
	_g_object_unref0 (scrolled);
	_g_object_unref0 (cellpixbuf);
	_g_object_unref0 (cell);
	_g_object_unref0 (celltoggle);
	_g_object_unref0 (view);
	block9_data_unref (_data9_);
	_data9_ = NULL;
	return obj;
}

static void
include_tree_view_class_init (IncludeTreeViewClass * klass,
                              gpointer klass_data)
{
	include_tree_view_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &IncludeTreeView_private_offset);
	G_OBJECT_CLASS (klass)->constructor = include_tree_view_constructor;
	G_OBJECT_CLASS (klass)->finalize = include_tree_view_finalize;
}

static void
include_tree_view_instance_init (IncludeTreeView * self,
                                 gpointer klass)
{
	self->priv = include_tree_view_get_instance_private (self);
}

static void
include_tree_view_finalize (GObject * obj)
{
	IncludeTreeView * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_INCLUDE_TREE_VIEW, IncludeTreeView);
	_security_privacy_file_type_blacklist_unref0 (self->priv->filetype_blacklist);
	G_OBJECT_CLASS (include_tree_view_parent_class)->finalize (obj);
}

static GType
include_tree_view_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (IncludeTreeViewClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) include_tree_view_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (IncludeTreeView), 0, (GInstanceInitFunc) include_tree_view_instance_init, NULL };
	GType include_tree_view_type_id;
	include_tree_view_type_id = g_type_register_static (gtk_grid_get_type (), "IncludeTreeView", &g_define_type_info, 0);
	IncludeTreeView_private_offset = g_type_add_instance_private (include_tree_view_type_id, sizeof (IncludeTreeViewPrivate));
	return include_tree_view_type_id;
}

GType
include_tree_view_get_type (void)
{
	static volatile gsize include_tree_view_type_id__once = 0;
	if (g_once_init_enter (&include_tree_view_type_id__once)) {
		GType include_tree_view_type_id;
		include_tree_view_type_id = include_tree_view_get_type_once ();
		g_once_init_leave (&include_tree_view_type_id__once, include_tree_view_type_id);
	}
	return include_tree_view_type_id__once;
}

