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

/*
 * ExcludeListSummaryWindow.vala
 *
 * Copyright 2012-2018 Tony George <teejeetech@gmail.com>
 *
 * 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.
 *
 * 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 General Public License for more details.
 *
 * You should have received a copy of the GNU 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.
 *
 *
 */

#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gee.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
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define TYPE_EXCLUDE_LIST_SUMMARY_WINDOW (exclude_list_summary_window_get_type ())
#define EXCLUDE_LIST_SUMMARY_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_EXCLUDE_LIST_SUMMARY_WINDOW, ExcludeListSummaryWindow))
#define EXCLUDE_LIST_SUMMARY_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_EXCLUDE_LIST_SUMMARY_WINDOW, ExcludeListSummaryWindowClass))
#define IS_EXCLUDE_LIST_SUMMARY_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_EXCLUDE_LIST_SUMMARY_WINDOW))
#define IS_EXCLUDE_LIST_SUMMARY_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_EXCLUDE_LIST_SUMMARY_WINDOW))
#define EXCLUDE_LIST_SUMMARY_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_EXCLUDE_LIST_SUMMARY_WINDOW, ExcludeListSummaryWindowClass))

typedef struct _ExcludeListSummaryWindow ExcludeListSummaryWindow;
typedef struct _ExcludeListSummaryWindowClass ExcludeListSummaryWindowClass;
typedef struct _ExcludeListSummaryWindowPrivate ExcludeListSummaryWindowPrivate;
enum  {
	EXCLUDE_LIST_SUMMARY_WINDOW_0_PROPERTY,
	EXCLUDE_LIST_SUMMARY_WINDOW_NUM_PROPERTIES
};
static GParamSpec* exclude_list_summary_window_properties[EXCLUDE_LIST_SUMMARY_WINDOW_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define TYPE_MAIN (main_get_type ())
#define MAIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MAIN, Main))
#define MAIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MAIN, MainClass))
#define IS_MAIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MAIN))
#define IS_MAIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MAIN))
#define MAIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MAIN, MainClass))

typedef struct _Main Main;
typedef struct _MainClass MainClass;
#define _g_free0(var) (var = (g_free (var), NULL))

struct _ExcludeListSummaryWindow {
	GtkWindow parent_instance;
	ExcludeListSummaryWindowPrivate * priv;
};

struct _ExcludeListSummaryWindowClass {
	GtkWindowClass parent_class;
};

struct _ExcludeListSummaryWindowPrivate {
	GtkBox* vbox_main;
	GtkLabel* lbl_list;
	GtkButton* btn_close;
	gboolean for_restore;
	gint def_width;
	gint def_height;
};

static gint ExcludeListSummaryWindow_private_offset;
static gpointer exclude_list_summary_window_parent_class = NULL;
VALA_EXTERN Main* App;

VALA_EXTERN GType exclude_list_summary_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ExcludeListSummaryWindow, g_object_unref)
VALA_EXTERN ExcludeListSummaryWindow* exclude_list_summary_window_new (gboolean _for_restore);
VALA_EXTERN ExcludeListSummaryWindow* exclude_list_summary_window_construct (GType object_type,
                                                                 gboolean _for_restore);
VALA_EXTERN void tee_jee_logging_log_debug (const gchar* message);
VALA_EXTERN GdkPixbuf* icon_manager_lookup (const gchar* icon_name,
                                gint icon_size,
                                gboolean symbolic,
                                gboolean use_hardcoded,
                                gint scale);
VALA_EXTERN GtkLabel* tee_jee_gtk_helper_add_label (GtkBox* box,
                                        const gchar* text,
                                        gboolean bold,
                                        gboolean italic,
                                        gboolean large);
VALA_EXTERN GtkLabel* tee_jee_gtk_helper_add_label_scrolled (GtkBox* box,
                                                 const gchar* text,
                                                 gboolean show_border,
                                                 gboolean wrap,
                                                 gint ellipsize_chars);
static void exclude_list_summary_window_create_actions (ExcludeListSummaryWindow* self);
VALA_EXTERN void exclude_list_summary_window_refresh (ExcludeListSummaryWindow* self);
VALA_EXTERN GtkButton* tee_jee_gtk_helper_add_button (GtkBox* box,
                                          const gchar* text,
                                          const gchar* tooltip,
                                          GtkSizeGroup* size_group,
                                          GtkImage* icon);
static void __lambda74_ (ExcludeListSummaryWindow* self);
static void ___lambda74__gtk_button_clicked (GtkButton* _sender,
                                      gpointer self);
VALA_EXTERN GType main_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Main, g_object_unref)
VALA_EXTERN GeeArrayList* main_create_exclude_list_for_restore (Main* self);
VALA_EXTERN GeeArrayList* main_create_exclude_list_for_backup (Main* self);
static void exclude_list_summary_window_finalize (GObject * obj);
static GType exclude_list_summary_window_get_type_once (void);

static inline gpointer
exclude_list_summary_window_get_instance_private (ExcludeListSummaryWindow* self)
{
	return G_STRUCT_MEMBER_P (self, ExcludeListSummaryWindow_private_offset);
}

ExcludeListSummaryWindow*
exclude_list_summary_window_construct (GType object_type,
                                       gboolean _for_restore)
{
	ExcludeListSummaryWindow * self = NULL;
	GdkPixbuf* _tmp0_;
	GdkPixbuf* _tmp1_;
	GtkBox* _tmp2_;
	GtkBox* _tmp3_;
	GtkBox* _tmp4_;
	GtkBox* _tmp5_;
	GtkLabel* _tmp6_;
	GtkLabel* _tmp7_;
	GtkBox* _tmp8_;
	GtkLabel* _tmp9_;
	self = (ExcludeListSummaryWindow*) g_object_new (object_type, NULL);
	tee_jee_logging_log_debug ("ExcludeListSummaryWindow: ExcludeListSummaryWindow()");
	gtk_window_set_title ((GtkWindow*) self, _ ("Exclude List Summary"));
	g_object_set ((GtkWindow*) self, "window-position", GTK_WIN_POS_CENTER, NULL);
	gtk_window_set_modal ((GtkWindow*) self, TRUE);
	gtk_window_set_default_size ((GtkWindow*) self, self->priv->def_width, self->priv->def_height);
	_tmp0_ = icon_manager_lookup ("timeshift", 16, FALSE, FALSE, 1);
	_tmp1_ = _tmp0_;
	gtk_window_set_icon ((GtkWindow*) self, _tmp1_);
	_g_object_unref0 (_tmp1_);
	self->priv->for_restore = _for_restore;
	_tmp2_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
	g_object_ref_sink (_tmp2_);
	_g_object_unref0 (self->priv->vbox_main);
	self->priv->vbox_main = _tmp2_;
	_tmp3_ = self->priv->vbox_main;
	g_object_set ((GtkWidget*) _tmp3_, "margin", 12, NULL);
	_tmp4_ = self->priv->vbox_main;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp4_);
	_tmp5_ = self->priv->vbox_main;
	_tmp6_ = tee_jee_gtk_helper_add_label (_tmp5_, _ ("Files &amp; directories matching the patterns below will be excluded. " \
"Patterns starting with a + will include the item instead of excluding."), FALSE, FALSE, FALSE);
	_tmp7_ = _tmp6_;
	_g_object_unref0 (_tmp7_);
	_tmp8_ = self->priv->vbox_main;
	_tmp9_ = tee_jee_gtk_helper_add_label_scrolled (_tmp8_, "", TRUE, TRUE, 40);
	_g_object_unref0 (self->priv->lbl_list);
	self->priv->lbl_list = _tmp9_;
	exclude_list_summary_window_create_actions (self);
	exclude_list_summary_window_refresh (self);
	gtk_widget_show_all ((GtkWidget*) self);
	tee_jee_logging_log_debug ("ExcludeListSummaryWindow: ExcludeListSummaryWindow(): exit");
	return self;
}

ExcludeListSummaryWindow*
exclude_list_summary_window_new (gboolean _for_restore)
{
	return exclude_list_summary_window_construct (TYPE_EXCLUDE_LIST_SUMMARY_WINDOW, _for_restore);
}

static void
__lambda74_ (ExcludeListSummaryWindow* self)
{
	gtk_widget_destroy ((GtkWidget*) self);
}

static void
___lambda74__gtk_button_clicked (GtkButton* _sender,
                                 gpointer self)
{
	__lambda74_ ((ExcludeListSummaryWindow*) self);
}

static void
exclude_list_summary_window_create_actions (ExcludeListSummaryWindow* self)
{
	GtkBox* hbox = NULL;
	GtkBox* _tmp0_;
	GtkBox* _tmp1_;
	GtkSizeGroup* size_group = NULL;
	GtkSizeGroup* _tmp2_;
	GtkImage* img = NULL;
	GtkImage* _tmp3_;
	GtkButton* _tmp4_;
	GtkButton* _tmp5_;
	g_return_if_fail (self != NULL);
	_tmp0_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	g_object_ref_sink (_tmp0_);
	hbox = _tmp0_;
	_tmp1_ = self->priv->vbox_main;
	gtk_container_add ((GtkContainer*) _tmp1_, (GtkWidget*) hbox);
	_tmp2_ = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
	size_group = _tmp2_;
	_tmp3_ = (GtkImage*) gtk_image_new_from_stock ("gtk-ok", (GtkIconSize) GTK_ICON_SIZE_BUTTON);
	g_object_ref_sink (_tmp3_);
	img = _tmp3_;
	_tmp4_ = tee_jee_gtk_helper_add_button (hbox, _ ("OK"), "", size_group, img);
	_g_object_unref0 (self->priv->btn_close);
	self->priv->btn_close = _tmp4_;
	_tmp5_ = self->priv->btn_close;
	g_signal_connect_object (_tmp5_, "clicked", (GCallback) ___lambda74__gtk_button_clicked, self, 0);
	_g_object_unref0 (img);
	_g_object_unref0 (size_group);
	_g_object_unref0 (hbox);
}

static gchar*
string_strip (const gchar* self)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup (self);
	_result_ = _tmp0_;
	g_strstrip (_result_);
	result = _result_;
	return result;
}

void
exclude_list_summary_window_refresh (ExcludeListSummaryWindow* self)
{
	GeeArrayList* list = NULL;
	gchar* txt = NULL;
	gchar* _tmp4_;
	GtkLabel* _tmp24_;
	const gchar* _tmp25_;
	g_return_if_fail (self != NULL);
	if (self->priv->for_restore) {
		Main* _tmp0_;
		GeeArrayList* _tmp1_;
		_tmp0_ = App;
		_tmp1_ = main_create_exclude_list_for_restore (_tmp0_);
		_g_object_unref0 (list);
		list = _tmp1_;
	} else {
		Main* _tmp2_;
		GeeArrayList* _tmp3_;
		_tmp2_ = App;
		_tmp3_ = main_create_exclude_list_for_backup (_tmp2_);
		_g_object_unref0 (list);
		list = _tmp3_;
	}
	_tmp4_ = g_strdup ("");
	txt = _tmp4_;
	{
		GeeArrayList* _pattern_list = NULL;
		GeeArrayList* _tmp5_;
		gint _pattern_size = 0;
		GeeArrayList* _tmp6_;
		gint _tmp7_;
		gint _tmp8_;
		gint _pattern_index = 0;
		_tmp5_ = list;
		_pattern_list = _tmp5_;
		_tmp6_ = _pattern_list;
		_tmp7_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp6_);
		_tmp8_ = _tmp7_;
		_pattern_size = _tmp8_;
		_pattern_index = -1;
		while (TRUE) {
			gint _tmp9_;
			gint _tmp10_;
			gchar* pattern = NULL;
			GeeArrayList* _tmp11_;
			gpointer _tmp12_;
			const gchar* _tmp13_;
			gchar* _tmp14_;
			gchar* _tmp15_;
			gint _tmp16_;
			gint _tmp17_;
			gboolean _tmp18_;
			_pattern_index = _pattern_index + 1;
			_tmp9_ = _pattern_index;
			_tmp10_ = _pattern_size;
			if (!(_tmp9_ < _tmp10_)) {
				break;
			}
			_tmp11_ = _pattern_list;
			_tmp12_ = gee_abstract_list_get ((GeeAbstractList*) _tmp11_, _pattern_index);
			pattern = (gchar*) _tmp12_;
			_tmp13_ = pattern;
			_tmp14_ = string_strip (_tmp13_);
			_tmp15_ = _tmp14_;
			_tmp16_ = strlen (_tmp15_);
			_tmp17_ = _tmp16_;
			_tmp18_ = _tmp17_ > 0;
			_g_free0 (_tmp15_);
			if (_tmp18_) {
				const gchar* _tmp19_;
				const gchar* _tmp20_;
				gchar* _tmp21_;
				gchar* _tmp22_;
				gchar* _tmp23_;
				_tmp19_ = txt;
				_tmp20_ = pattern;
				_tmp21_ = g_strdup_printf ("%s\n", _tmp20_);
				_tmp22_ = _tmp21_;
				_tmp23_ = g_strconcat (_tmp19_, _tmp22_, NULL);
				_g_free0 (txt);
				txt = _tmp23_;
				_g_free0 (_tmp22_);
			}
			_g_free0 (pattern);
		}
	}
	_tmp24_ = self->priv->lbl_list;
	_tmp25_ = txt;
	gtk_label_set_label (_tmp24_, _tmp25_);
	_g_free0 (txt);
	_g_object_unref0 (list);
}

static void
exclude_list_summary_window_class_init (ExcludeListSummaryWindowClass * klass,
                                        gpointer klass_data)
{
	exclude_list_summary_window_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ExcludeListSummaryWindow_private_offset);
	G_OBJECT_CLASS (klass)->finalize = exclude_list_summary_window_finalize;
}

static void
exclude_list_summary_window_instance_init (ExcludeListSummaryWindow * self,
                                           gpointer klass)
{
	self->priv = exclude_list_summary_window_get_instance_private (self);
	self->priv->for_restore = FALSE;
	self->priv->def_width = 500;
	self->priv->def_height = 450;
}

static void
exclude_list_summary_window_finalize (GObject * obj)
{
	ExcludeListSummaryWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_EXCLUDE_LIST_SUMMARY_WINDOW, ExcludeListSummaryWindow);
	_g_object_unref0 (self->priv->vbox_main);
	_g_object_unref0 (self->priv->lbl_list);
	_g_object_unref0 (self->priv->btn_close);
	G_OBJECT_CLASS (exclude_list_summary_window_parent_class)->finalize (obj);
}

static GType
exclude_list_summary_window_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ExcludeListSummaryWindowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) exclude_list_summary_window_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ExcludeListSummaryWindow), 0, (GInstanceInitFunc) exclude_list_summary_window_instance_init, NULL };
	GType exclude_list_summary_window_type_id;
	exclude_list_summary_window_type_id = g_type_register_static (gtk_window_get_type (), "ExcludeListSummaryWindow", &g_define_type_info, 0);
	ExcludeListSummaryWindow_private_offset = g_type_add_instance_private (exclude_list_summary_window_type_id, sizeof (ExcludeListSummaryWindowPrivate));
	return exclude_list_summary_window_type_id;
}

GType
exclude_list_summary_window_get_type (void)
{
	static volatile gsize exclude_list_summary_window_type_id__once = 0;
	if (g_once_init_enter (&exclude_list_summary_window_type_id__once)) {
		GType exclude_list_summary_window_type_id;
		exclude_list_summary_window_type_id = exclude_list_summary_window_get_type_once ();
		g_once_init_leave (&exclude_list_summary_window_type_id__once, exclude_list_summary_window_type_id);
	}
	return exclude_list_summary_window_type_id__once;
}

