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

/*
* Copyright (c) 2011-2013 Yorba Foundation
*               2018 elementary LLC. (https://elementary.io)
*
* 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 2.1 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 "io.elementary.photos.h"
#include <gtk/gtk.h>
#include <glib.h>
#include <glib-object.h>
#include <glib/gi18n-lib.h>
#include <string.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  {
	SEARCH_ROW_MODIFIED_0_PROPERTY,
	SEARCH_ROW_MODIFIED_NUM_PROPERTIES
};
static GParamSpec* search_row_modified_properties[SEARCH_ROW_MODIFIED_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _search_condition_unref0(var) ((var == NULL) ? NULL : (var = (search_condition_unref (var), NULL)))
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _SearchRowModifiedPrivate {
	GtkComboBoxText* modified_context;
	GtkComboBoxText* modified_state;
};

static gint SearchRowModified_private_offset;
static gpointer search_row_modified_parent_class = NULL;

static void search_row_modified_on_changed (SearchRowModified* self);
static void _search_row_modified_on_changed_gtk_combo_box_changed (GtkComboBox* _sender,
                                                            gpointer self);
static SearchCondition* search_row_modified_real_get_search_condition (SearchRow* base);
static void search_row_modified_real_populate (SearchRow* base,
                                        SearchCondition* sc);
static gboolean search_row_modified_real_is_complete (SearchRow* base);
static void search_row_modified_finalize (GObject * obj);
static GType search_row_modified_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
search_row_modified_get_instance_private (SearchRowModified* self)
{
	return G_STRUCT_MEMBER_P (self, SearchRowModified_private_offset);
}

static void
_search_row_modified_on_changed_gtk_combo_box_changed (GtkComboBox* _sender,
                                                       gpointer self)
{
	search_row_modified_on_changed ((SearchRowModified*) self);
}

SearchRowModified*
search_row_modified_construct (GType object_type,
                               SearchRowContainer* parent)
{
	SearchRowModified * self = NULL;
	GtkComboBoxText* _tmp0_;
	GtkComboBoxText* _tmp1_;
	GtkComboBoxText* _tmp2_;
	GtkComboBoxText* _tmp3_;
	GtkComboBoxText* _tmp4_;
	GtkComboBoxText* _tmp5_;
	GtkComboBoxText* _tmp6_;
	GtkComboBoxText* _tmp7_;
	GtkComboBoxText* _tmp8_;
	GtkComboBoxText* _tmp9_;
	GtkComboBoxText* _tmp10_;
	GtkComboBoxText* _tmp11_;
	GtkComboBoxText* _tmp12_;
	g_return_val_if_fail (parent != NULL, NULL);
	self = (SearchRowModified*) g_object_new (object_type, "parent", parent, NULL);
	_tmp0_ = (GtkComboBoxText*) gtk_combo_box_text_new ();
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->modified_context);
	self->priv->modified_context = _tmp0_;
	_tmp1_ = self->priv->modified_context;
	gtk_combo_box_text_append_text (_tmp1_, _ ("has"));
	_tmp2_ = self->priv->modified_context;
	gtk_combo_box_text_append_text (_tmp2_, _ ("has no"));
	_tmp3_ = self->priv->modified_context;
	gtk_combo_box_set_active ((GtkComboBox*) _tmp3_, 0);
	_tmp4_ = self->priv->modified_context;
	g_signal_connect_object ((GtkComboBox*) _tmp4_, "changed", (GCallback) _search_row_modified_on_changed_gtk_combo_box_changed, self, 0);
	_tmp5_ = (GtkComboBoxText*) gtk_combo_box_text_new ();
	g_object_ref_sink (_tmp5_);
	_g_object_unref0 (self->priv->modified_state);
	self->priv->modified_state = _tmp5_;
	_tmp6_ = self->priv->modified_state;
	gtk_combo_box_text_append_text (_tmp6_, _ ("modifications"));
	_tmp7_ = self->priv->modified_state;
	gtk_combo_box_text_append_text (_tmp7_, _ ("internal modifications"));
	_tmp8_ = self->priv->modified_state;
	gtk_combo_box_text_append_text (_tmp8_, _ ("external modifications"));
	_tmp9_ = self->priv->modified_state;
	gtk_combo_box_set_active ((GtkComboBox*) _tmp9_, 0);
	_tmp10_ = self->priv->modified_state;
	g_signal_connect_object ((GtkComboBox*) _tmp10_, "changed", (GCallback) _search_row_modified_on_changed_gtk_combo_box_changed, self, 0);
	_tmp11_ = self->priv->modified_context;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp11_);
	_tmp12_ = self->priv->modified_state;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp12_);
	gtk_widget_show_all ((GtkWidget*) self);
	return self;
}

SearchRowModified*
search_row_modified_new (SearchRowContainer* parent)
{
	return search_row_modified_construct (TYPE_SEARCH_ROW_MODIFIED, parent);
}

static SearchCondition*
search_row_modified_real_get_search_condition (SearchRow* base)
{
	SearchRowModified * self;
	SearchConditionSearchType search_type = 0;
	SearchRowContainer* _tmp0_;
	SearchRowContainer* _tmp1_;
	SearchConditionModifiedContext context = 0;
	GtkComboBoxText* _tmp2_;
	SearchConditionModifiedState state = 0;
	GtkComboBoxText* _tmp3_;
	SearchConditionModified* c = NULL;
	SearchConditionModified* _tmp4_;
	SearchCondition* result;
	self = (SearchRowModified*) base;
	_tmp0_ = search_row_get_parent ((SearchRow*) self);
	_tmp1_ = _tmp0_;
	search_type = search_row_container_get_search_type (_tmp1_);
	_tmp2_ = self->priv->modified_context;
	context = (SearchConditionModifiedContext) gtk_combo_box_get_active ((GtkComboBox*) _tmp2_);
	_tmp3_ = self->priv->modified_state;
	state = (SearchConditionModifiedState) gtk_combo_box_get_active ((GtkComboBox*) _tmp3_);
	_tmp4_ = search_condition_modified_new (search_type, context, state);
	c = _tmp4_;
	result = (SearchCondition*) c;
	return result;
}

static gpointer
_search_condition_ref0 (gpointer self)
{
	return self ? search_condition_ref (self) : NULL;
}

static void
search_row_modified_real_populate (SearchRow* base,
                                   SearchCondition* sc)
{
	SearchRowModified * self;
	SearchConditionModified* scm = NULL;
	SearchConditionModified* _tmp0_;
	GtkComboBoxText* _tmp1_;
	SearchConditionModifiedState _tmp2_;
	SearchConditionModifiedState _tmp3_;
	GtkComboBoxText* _tmp4_;
	SearchConditionModifiedContext _tmp5_;
	SearchConditionModifiedContext _tmp6_;
	self = (SearchRowModified*) base;
	g_return_if_fail (sc != NULL);
	_tmp0_ = _search_condition_ref0 (IS_SEARCH_CONDITION_MODIFIED (sc) ? ((SearchConditionModified*) sc) : NULL);
	scm = _tmp0_;
	_vala_assert (scm != NULL, "scm != null");
	_tmp1_ = self->priv->modified_state;
	_tmp2_ = search_condition_modified_get_state (scm);
	_tmp3_ = _tmp2_;
	gtk_combo_box_set_active ((GtkComboBox*) _tmp1_, (gint) _tmp3_);
	_tmp4_ = self->priv->modified_context;
	_tmp5_ = search_condition_modified_get_context (scm);
	_tmp6_ = _tmp5_;
	gtk_combo_box_set_active ((GtkComboBox*) _tmp4_, (gint) _tmp6_);
	_search_condition_unref0 (scm);
}

static gboolean
search_row_modified_real_is_complete (SearchRow* base)
{
	SearchRowModified * self;
	gboolean result;
	self = (SearchRowModified*) base;
	result = TRUE;
	return result;
}

static void
search_row_modified_on_changed (SearchRowModified* self)
{
	SearchRowContainer* _tmp0_;
	SearchRowContainer* _tmp1_;
	SearchRowContainer* _tmp2_;
	SearchRowContainer* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = search_row_get_parent ((SearchRow*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = search_row_get_parent ((SearchRow*) self);
	_tmp3_ = _tmp2_;
	g_signal_emit_by_name (_tmp1_, "changed", _tmp3_);
}

static void
search_row_modified_class_init (SearchRowModifiedClass * klass,
                                gpointer klass_data)
{
	search_row_modified_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &SearchRowModified_private_offset);
	((SearchRowClass *) klass)->get_search_condition = (SearchCondition* (*) (SearchRow*)) search_row_modified_real_get_search_condition;
	((SearchRowClass *) klass)->populate = (void (*) (SearchRow*, SearchCondition*)) search_row_modified_real_populate;
	((SearchRowClass *) klass)->is_complete = (gboolean (*) (SearchRow*)) search_row_modified_real_is_complete;
	G_OBJECT_CLASS (klass)->finalize = search_row_modified_finalize;
}

static void
search_row_modified_instance_init (SearchRowModified * self,
                                   gpointer klass)
{
	self->priv = search_row_modified_get_instance_private (self);
}

static void
search_row_modified_finalize (GObject * obj)
{
	SearchRowModified * self;
	GtkComboBoxText* _tmp0_;
	guint _tmp1_;
	GtkComboBoxText* _tmp2_;
	guint _tmp3_;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_SEARCH_ROW_MODIFIED, SearchRowModified);
	_tmp0_ = self->priv->modified_state;
	g_signal_parse_name ("changed", gtk_combo_box_get_type (), &_tmp1_, NULL, FALSE);
	g_signal_handlers_disconnect_matched ((GtkComboBox*) _tmp0_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp1_, 0, NULL, (GCallback) _search_row_modified_on_changed_gtk_combo_box_changed, self);
	_tmp2_ = self->priv->modified_context;
	g_signal_parse_name ("changed", gtk_combo_box_get_type (), &_tmp3_, NULL, FALSE);
	g_signal_handlers_disconnect_matched ((GtkComboBox*) _tmp2_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp3_, 0, NULL, (GCallback) _search_row_modified_on_changed_gtk_combo_box_changed, self);
	_g_object_unref0 (self->priv->modified_context);
	_g_object_unref0 (self->priv->modified_state);
	G_OBJECT_CLASS (search_row_modified_parent_class)->finalize (obj);
}

static GType
search_row_modified_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (SearchRowModifiedClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) search_row_modified_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SearchRowModified), 0, (GInstanceInitFunc) search_row_modified_instance_init, NULL };
	GType search_row_modified_type_id;
	search_row_modified_type_id = g_type_register_static (TYPE_SEARCH_ROW, "SearchRowModified", &g_define_type_info, 0);
	SearchRowModified_private_offset = g_type_add_instance_private (search_row_modified_type_id, sizeof (SearchRowModifiedPrivate));
	return search_row_modified_type_id;
}

GType
search_row_modified_get_type (void)
{
	static volatile gsize search_row_modified_type_id__once = 0;
	if (g_once_init_enter (&search_row_modified_type_id__once)) {
		GType search_row_modified_type_id;
		search_row_modified_type_id = search_row_modified_get_type_once ();
		g_once_init_leave (&search_row_modified_type_id__once, search_row_modified_type_id);
	}
	return search_row_modified_type_id__once;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

