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

/*
 * RsyncLogWindow.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 <gdk/gdk.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_RSYNC_LOG_WINDOW (rsync_log_window_get_type ())
#define RSYNC_LOG_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_RSYNC_LOG_WINDOW, RsyncLogWindow))
#define RSYNC_LOG_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_RSYNC_LOG_WINDOW, RsyncLogWindowClass))
#define IS_RSYNC_LOG_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_RSYNC_LOG_WINDOW))
#define IS_RSYNC_LOG_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_RSYNC_LOG_WINDOW))
#define RSYNC_LOG_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_RSYNC_LOG_WINDOW, RsyncLogWindowClass))

typedef struct _RsyncLogWindow RsyncLogWindow;
typedef struct _RsyncLogWindowClass RsyncLogWindowClass;
typedef struct _RsyncLogWindowPrivate RsyncLogWindowPrivate;

#define TYPE_RSYNC_LOG_BOX (rsync_log_box_get_type ())
#define RSYNC_LOG_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_RSYNC_LOG_BOX, RsyncLogBox))
#define RSYNC_LOG_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_RSYNC_LOG_BOX, RsyncLogBoxClass))
#define IS_RSYNC_LOG_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_RSYNC_LOG_BOX))
#define IS_RSYNC_LOG_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_RSYNC_LOG_BOX))
#define RSYNC_LOG_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_RSYNC_LOG_BOX, RsyncLogBoxClass))

typedef struct _RsyncLogBox RsyncLogBox;
typedef struct _RsyncLogBoxClass RsyncLogBoxClass;
enum  {
	RSYNC_LOG_WINDOW_0_PROPERTY,
	RSYNC_LOG_WINDOW_NUM_PROPERTIES
};
static GParamSpec* rsync_log_window_properties[RSYNC_LOG_WINDOW_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _RsyncLogWindow {
	GtkWindow parent_instance;
	RsyncLogWindowPrivate * priv;
};

struct _RsyncLogWindowClass {
	GtkWindowClass parent_class;
};

struct _RsyncLogWindowPrivate {
	gint def_width;
	gint def_height;
	RsyncLogBox* logbox;
	gchar* rsync_log_file;
};

static gint RsyncLogWindow_private_offset;
static gpointer rsync_log_window_parent_class = NULL;

VALA_EXTERN GType rsync_log_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (RsyncLogWindow, g_object_unref)
VALA_EXTERN GType rsync_log_box_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (RsyncLogBox, g_object_unref)
VALA_EXTERN RsyncLogWindow* rsync_log_window_new (const gchar* _rsync_log_file);
VALA_EXTERN RsyncLogWindow* rsync_log_window_construct (GType object_type,
                                            const gchar* _rsync_log_file);
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);
static gboolean rsync_log_window_on_delete_event (RsyncLogWindow* self,
                                           GdkEventAny* event);
static gboolean _rsync_log_window_on_delete_event_gtk_widget_delete_event (GtkWidget* _sender,
                                                                    GdkEventAny* event,
                                                                    gpointer self);
VALA_EXTERN RsyncLogBox* rsync_log_box_new (GtkWindow* _window);
VALA_EXTERN RsyncLogBox* rsync_log_box_construct (GType object_type,
                                      GtkWindow* _window);
VALA_EXTERN void rsync_log_box_open_log (RsyncLogBox* self,
                             const gchar* _rsync_log_file);
VALA_EXTERN gboolean rsync_log_box_get_is_running (RsyncLogBox* self);
static void rsync_log_window_finalize (GObject * obj);
static GType rsync_log_window_get_type_once (void);

static inline gpointer
rsync_log_window_get_instance_private (RsyncLogWindow* self)
{
	return G_STRUCT_MEMBER_P (self, RsyncLogWindow_private_offset);
}

static gboolean
_rsync_log_window_on_delete_event_gtk_widget_delete_event (GtkWidget* _sender,
                                                           GdkEventAny* event,
                                                           gpointer self)
{
	gboolean result;
	result = rsync_log_window_on_delete_event ((RsyncLogWindow*) self, event);
	return result;
}

RsyncLogWindow*
rsync_log_window_construct (GType object_type,
                            const gchar* _rsync_log_file)
{
	RsyncLogWindow * self = NULL;
	GdkPixbuf* _tmp0_;
	GdkPixbuf* _tmp1_;
	gchar* _tmp2_;
	RsyncLogBox* _tmp3_;
	RsyncLogBox* _tmp4_;
	RsyncLogBox* _tmp5_;
	const gchar* _tmp6_;
	g_return_val_if_fail (_rsync_log_file != NULL, NULL);
	self = (RsyncLogWindow*) g_object_new (object_type, NULL);
	tee_jee_logging_log_debug ("RsyncLogWindow: RsyncLogWindow()");
	gtk_window_set_title ((GtkWindow*) self, _ ("Rsync Log Viewer"));
	g_object_set ((GtkWindow*) self, "window-position", GTK_WIN_POS_CENTER_ON_PARENT, NULL);
	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_);
	gtk_window_set_resizable ((GtkWindow*) self, TRUE);
	gtk_window_set_modal ((GtkWindow*) self, TRUE);
	g_signal_connect_object ((GtkWidget*) self, "delete-event", (GCallback) _rsync_log_window_on_delete_event_gtk_widget_delete_event, self, 0);
	_tmp2_ = g_strdup (_rsync_log_file);
	_g_free0 (self->priv->rsync_log_file);
	self->priv->rsync_log_file = _tmp2_;
	_tmp3_ = rsync_log_box_new ((GtkWindow*) self);
	g_object_ref_sink (_tmp3_);
	_g_object_unref0 (self->priv->logbox);
	self->priv->logbox = _tmp3_;
	_tmp4_ = self->priv->logbox;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp4_);
	gtk_widget_show_all ((GtkWidget*) self);
	_tmp5_ = self->priv->logbox;
	_tmp6_ = self->priv->rsync_log_file;
	rsync_log_box_open_log (_tmp5_, _tmp6_);
	tee_jee_logging_log_debug ("RsyncLogWindow: RsyncLogWindow(): exit");
	return self;
}

RsyncLogWindow*
rsync_log_window_new (const gchar* _rsync_log_file)
{
	return rsync_log_window_construct (TYPE_RSYNC_LOG_WINDOW, _rsync_log_file);
}

static gboolean
rsync_log_window_on_delete_event (RsyncLogWindow* self,
                                  GdkEventAny* event)
{
	RsyncLogBox* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp0_ = self->priv->logbox;
	_tmp1_ = rsync_log_box_get_is_running (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_) {
		result = TRUE;
		return result;
	} else {
		guint _tmp3_;
		g_signal_parse_name ("delete-event", gtk_widget_get_type (), &_tmp3_, NULL, FALSE);
		g_signal_handlers_disconnect_matched ((GtkWidget*) self, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp3_, 0, NULL, (GCallback) _rsync_log_window_on_delete_event_gtk_widget_delete_event, self);
		result = FALSE;
		return result;
	}
}

static void
rsync_log_window_class_init (RsyncLogWindowClass * klass,
                             gpointer klass_data)
{
	rsync_log_window_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &RsyncLogWindow_private_offset);
	G_OBJECT_CLASS (klass)->finalize = rsync_log_window_finalize;
}

static void
rsync_log_window_instance_init (RsyncLogWindow * self,
                                gpointer klass)
{
	self->priv = rsync_log_window_get_instance_private (self);
	self->priv->def_width = 800;
	self->priv->def_height = 600;
}

static void
rsync_log_window_finalize (GObject * obj)
{
	RsyncLogWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_RSYNC_LOG_WINDOW, RsyncLogWindow);
	_g_object_unref0 (self->priv->logbox);
	_g_free0 (self->priv->rsync_log_file);
	G_OBJECT_CLASS (rsync_log_window_parent_class)->finalize (obj);
}

static GType
rsync_log_window_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (RsyncLogWindowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rsync_log_window_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RsyncLogWindow), 0, (GInstanceInitFunc) rsync_log_window_instance_init, NULL };
	GType rsync_log_window_type_id;
	rsync_log_window_type_id = g_type_register_static (gtk_window_get_type (), "RsyncLogWindow", &g_define_type_info, 0);
	RsyncLogWindow_private_offset = g_type_add_instance_private (rsync_log_window_type_id, sizeof (RsyncLogWindowPrivate));
	return rsync_log_window_type_id;
}

GType
rsync_log_window_get_type (void)
{
	static volatile gsize rsync_log_window_type_id__once = 0;
	if (g_once_init_enter (&rsync_log_window_type_id__once)) {
		GType rsync_log_window_type_id;
		rsync_log_window_type_id = rsync_log_window_get_type_once ();
		g_once_init_leave (&rsync_log_window_type_id__once, rsync_log_window_type_id);
	}
	return rsync_log_window_type_id__once;
}

