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

/*
 * SPDX-License-Identifier: LGPL-3.0-or-later
 * SPDX-FileCopyrightText: 2011-2025 elementary, Inc. (https://elementary.io)
 */

#include <granite-7.h>
#include <glib-object.h>
#include <adwaita.h>
#include <gtk/gtk.h>
#include <glib.h>
#include <vte/vte.h>
#include <glib/gi18n-lib.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>
#include <pcre2.h>

#define TERMINAL_MAIN_WINDOW_ACTION_PREFIX "win."
#define TERMINAL_MAIN_WINDOW_ACTION_SEARCH_PREVIOUS "action-search-previous"
#define TERMINAL_MAIN_WINDOW_ACTION_SEARCH_NEXT "action-search-next"
#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 TERMINAL_WIDGETS_TYPE_SEARCH_TOOLBAR (terminal_widgets_search_toolbar_get_type ())
#define TERMINAL_WIDGETS_SEARCH_TOOLBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TERMINAL_WIDGETS_TYPE_SEARCH_TOOLBAR, TerminalWidgetsSearchToolbar))
#define TERMINAL_WIDGETS_SEARCH_TOOLBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TERMINAL_WIDGETS_TYPE_SEARCH_TOOLBAR, TerminalWidgetsSearchToolbarClass))
#define TERMINAL_WIDGETS_IS_SEARCH_TOOLBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TERMINAL_WIDGETS_TYPE_SEARCH_TOOLBAR))
#define TERMINAL_WIDGETS_IS_SEARCH_TOOLBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TERMINAL_WIDGETS_TYPE_SEARCH_TOOLBAR))
#define TERMINAL_WIDGETS_SEARCH_TOOLBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TERMINAL_WIDGETS_TYPE_SEARCH_TOOLBAR, TerminalWidgetsSearchToolbarClass))

typedef struct _TerminalWidgetsSearchToolbar TerminalWidgetsSearchToolbar;
typedef struct _TerminalWidgetsSearchToolbarClass TerminalWidgetsSearchToolbarClass;
typedef struct _TerminalWidgetsSearchToolbarPrivate TerminalWidgetsSearchToolbarPrivate;

#define TERMINAL_TYPE_MAIN_WINDOW (terminal_main_window_get_type ())
#define TERMINAL_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TERMINAL_TYPE_MAIN_WINDOW, TerminalMainWindow))
#define TERMINAL_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TERMINAL_TYPE_MAIN_WINDOW, TerminalMainWindowClass))
#define TERMINAL_IS_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TERMINAL_TYPE_MAIN_WINDOW))
#define TERMINAL_IS_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TERMINAL_TYPE_MAIN_WINDOW))
#define TERMINAL_MAIN_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TERMINAL_TYPE_MAIN_WINDOW, TerminalMainWindowClass))

typedef struct _TerminalMainWindow TerminalMainWindow;
typedef struct _TerminalMainWindowClass TerminalMainWindowClass;
enum  {
	TERMINAL_WIDGETS_SEARCH_TOOLBAR_0_PROPERTY,
	TERMINAL_WIDGETS_SEARCH_TOOLBAR_WINDOW_PROPERTY,
	TERMINAL_WIDGETS_SEARCH_TOOLBAR_NUM_PROPERTIES
};
static GParamSpec* terminal_widgets_search_toolbar_properties[TERMINAL_WIDGETS_SEARCH_TOOLBAR_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define TERMINAL_TYPE_TERMINAL_WIDGET (terminal_terminal_widget_get_type ())
#define TERMINAL_TERMINAL_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TERMINAL_TYPE_TERMINAL_WIDGET, TerminalTerminalWidget))
#define TERMINAL_TERMINAL_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TERMINAL_TYPE_TERMINAL_WIDGET, TerminalTerminalWidgetClass))
#define TERMINAL_IS_TERMINAL_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TERMINAL_TYPE_TERMINAL_WIDGET))
#define TERMINAL_IS_TERMINAL_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TERMINAL_TYPE_TERMINAL_WIDGET))
#define TERMINAL_TERMINAL_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TERMINAL_TYPE_TERMINAL_WIDGET, TerminalTerminalWidgetClass))

typedef struct _TerminalTerminalWidget TerminalTerminalWidget;
typedef struct _TerminalTerminalWidgetClass TerminalTerminalWidgetClass;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _vte_regex_unref0(var) ((var == NULL) ? NULL : (var = (vte_regex_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _TerminalWidgetsSearchToolbar {
	GraniteBox parent_instance;
	TerminalWidgetsSearchToolbarPrivate * priv;
};

struct _TerminalWidgetsSearchToolbarClass {
	GraniteBoxClass parent_class;
};

struct _TerminalWidgetsSearchToolbarPrivate {
	TerminalMainWindow* _window;
	GtkToggleButton* cycle_button;
	guint last_search_term_length;
	GtkSearchEntry* search_entry;
};

static gint TerminalWidgetsSearchToolbar_private_offset;
static gpointer terminal_widgets_search_toolbar_parent_class = NULL;

VALA_EXTERN GType terminal_widgets_search_toolbar_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TerminalWidgetsSearchToolbar, g_object_unref)
VALA_EXTERN GType terminal_main_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TerminalMainWindow, g_object_unref)
VALA_EXTERN TerminalWidgetsSearchToolbar* terminal_widgets_search_toolbar_new (TerminalMainWindow* window);
VALA_EXTERN TerminalWidgetsSearchToolbar* terminal_widgets_search_toolbar_construct (GType object_type,
                                                                         TerminalMainWindow* window);
static gboolean terminal_widgets_search_toolbar_real_grab_focus (GtkWidget* base);
VALA_EXTERN void terminal_widgets_search_toolbar_clear (TerminalWidgetsSearchToolbar* self);
VALA_EXTERN void terminal_widgets_search_toolbar_previous_search (TerminalWidgetsSearchToolbar* self);
static TerminalMainWindow* terminal_widgets_search_toolbar_get_window (TerminalWidgetsSearchToolbar* self);
VALA_EXTERN GType terminal_terminal_widget_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TerminalTerminalWidget, g_object_unref)
VALA_EXTERN TerminalTerminalWidget* terminal_main_window_get_current_terminal (TerminalMainWindow* self);
VALA_EXTERN void terminal_widgets_search_toolbar_next_search (TerminalWidgetsSearchToolbar* self);
static void terminal_widgets_search_toolbar_set_window (TerminalWidgetsSearchToolbar* self,
                                                 TerminalMainWindow* value);
static GObject * terminal_widgets_search_toolbar_constructor (GType type,
                                                       guint n_construct_properties,
                                                       GObjectConstructParam * construct_properties);
static void _terminal_widgets_search_toolbar___lambda7_ (TerminalWidgetsSearchToolbar* self);
static void __terminal_widgets_search_toolbar___lambda7__gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                                                             gpointer self);
static void _terminal_widgets_search_toolbar___lambda8_ (TerminalWidgetsSearchToolbar* self);
static void __terminal_widgets_search_toolbar___lambda8__gtk_button_clicked (GtkButton* _sender,
                                                                      gpointer self);
static void _terminal_widgets_search_toolbar___lambda9_ (TerminalWidgetsSearchToolbar* self);
static void __terminal_widgets_search_toolbar___lambda9__gtk_button_clicked (GtkButton* _sender,
                                                                      gpointer self);
static void _terminal_widgets_search_toolbar___lambda10_ (TerminalWidgetsSearchToolbar* self);
static void __terminal_widgets_search_toolbar___lambda10__gtk_button_clicked (GtkButton* _sender,
                                                                       gpointer self);
static void _terminal_widgets_search_toolbar___lambda11_ (TerminalWidgetsSearchToolbar* self);
VALA_EXTERN GSimpleAction* terminal_main_window_get_simple_action (TerminalMainWindow* self,
                                                       const gchar* action);
static void __terminal_widgets_search_toolbar___lambda11__gtk_search_entry_search_changed (GtkSearchEntry* _sender,
                                                                                    gpointer self);
static void terminal_widgets_search_toolbar_finalize (GObject * obj);
static GType terminal_widgets_search_toolbar_get_type_once (void);
static void _vala_terminal_widgets_search_toolbar_get_property (GObject * object,
                                                         guint property_id,
                                                         GValue * value,
                                                         GParamSpec * pspec);
static void _vala_terminal_widgets_search_toolbar_set_property (GObject * object,
                                                         guint property_id,
                                                         const GValue * value,
                                                         GParamSpec * pspec);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

static inline gpointer
terminal_widgets_search_toolbar_get_instance_private (TerminalWidgetsSearchToolbar* self)
{
	return G_STRUCT_MEMBER_P (self, TerminalWidgetsSearchToolbar_private_offset);
}

TerminalWidgetsSearchToolbar*
terminal_widgets_search_toolbar_construct (GType object_type,
                                           TerminalMainWindow* window)
{
	TerminalWidgetsSearchToolbar * self = NULL;
	g_return_val_if_fail (window != NULL, NULL);
	self = (TerminalWidgetsSearchToolbar*) g_object_new (object_type, "window", window, NULL);
	return self;
}

TerminalWidgetsSearchToolbar*
terminal_widgets_search_toolbar_new (TerminalMainWindow* window)
{
	return terminal_widgets_search_toolbar_construct (TERMINAL_WIDGETS_TYPE_SEARCH_TOOLBAR, window);
}

static gboolean
terminal_widgets_search_toolbar_real_grab_focus (GtkWidget* base)
{
	TerminalWidgetsSearchToolbar * self;
	GtkSearchEntry* _tmp0_;
	gboolean result;
	self = (TerminalWidgetsSearchToolbar*) base;
	_tmp0_ = self->priv->search_entry;
	result = gtk_widget_grab_focus ((GtkWidget*) _tmp0_);
	return result;
}

void
terminal_widgets_search_toolbar_clear (TerminalWidgetsSearchToolbar* self)
{
	GtkSearchEntry* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->search_entry;
	gtk_editable_set_text ((GtkEditable*) _tmp0_, "");
	self->priv->last_search_term_length = (guint) 0;
}

void
terminal_widgets_search_toolbar_previous_search (TerminalWidgetsSearchToolbar* self)
{
	TerminalMainWindow* _tmp0_;
	TerminalTerminalWidget* _tmp1_;
	TerminalTerminalWidget* _tmp2_;
	GtkToggleButton* _tmp3_;
	gboolean _tmp4_;
	gboolean _tmp5_;
	TerminalMainWindow* _tmp6_;
	TerminalTerminalWidget* _tmp7_;
	TerminalTerminalWidget* _tmp8_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_window;
	_tmp1_ = terminal_main_window_get_current_terminal (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = self->priv->cycle_button;
	_tmp4_ = gtk_toggle_button_get_active (_tmp3_);
	_tmp5_ = _tmp4_;
	vte_terminal_search_set_wrap_around ((VteTerminal*) _tmp2_, _tmp5_);
	_tmp6_ = self->priv->_window;
	_tmp7_ = terminal_main_window_get_current_terminal (_tmp6_);
	_tmp8_ = _tmp7_;
	vte_terminal_search_find_previous ((VteTerminal*) _tmp8_);
}

void
terminal_widgets_search_toolbar_next_search (TerminalWidgetsSearchToolbar* self)
{
	TerminalMainWindow* _tmp0_;
	TerminalTerminalWidget* _tmp1_;
	TerminalTerminalWidget* _tmp2_;
	GtkToggleButton* _tmp3_;
	gboolean _tmp4_;
	gboolean _tmp5_;
	TerminalMainWindow* _tmp6_;
	TerminalTerminalWidget* _tmp7_;
	TerminalTerminalWidget* _tmp8_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_window;
	_tmp1_ = terminal_main_window_get_current_terminal (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = self->priv->cycle_button;
	_tmp4_ = gtk_toggle_button_get_active (_tmp3_);
	_tmp5_ = _tmp4_;
	vte_terminal_search_set_wrap_around ((VteTerminal*) _tmp2_, _tmp5_);
	_tmp6_ = self->priv->_window;
	_tmp7_ = terminal_main_window_get_current_terminal (_tmp6_);
	_tmp8_ = _tmp7_;
	vte_terminal_search_find_next ((VteTerminal*) _tmp8_);
}

static TerminalMainWindow*
terminal_widgets_search_toolbar_get_window (TerminalWidgetsSearchToolbar* self)
{
	TerminalMainWindow* result;
	TerminalMainWindow* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_window;
	result = _tmp0_;
	return result;
}

static void
terminal_widgets_search_toolbar_set_window (TerminalWidgetsSearchToolbar* self,
                                            TerminalMainWindow* value)
{
	TerminalMainWindow* old_value;
	g_return_if_fail (self != NULL);
	old_value = terminal_widgets_search_toolbar_get_window (self);
	if (old_value != value) {
		self->priv->_window = value;
		g_object_notify_by_pspec ((GObject *) self, terminal_widgets_search_toolbar_properties[TERMINAL_WIDGETS_SEARCH_TOOLBAR_WINDOW_PROPERTY]);
	}
}

static void
_terminal_widgets_search_toolbar___lambda7_ (TerminalWidgetsSearchToolbar* self)
{
	GtkToggleButton* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	_tmp0_ = self->priv->cycle_button;
	_tmp1_ = gtk_toggle_button_get_active (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_) {
		GtkToggleButton* _tmp3_;
		GtkToggleButton* _tmp4_;
		_tmp3_ = self->priv->cycle_button;
		gtk_widget_set_tooltip_text ((GtkWidget*) _tmp3_, _ ("Disable cyclic search"));
		_tmp4_ = self->priv->cycle_button;
		gtk_button_set_icon_name ((GtkButton*) _tmp4_, "media-playlist-repeat-symbolic");
	} else {
		GtkToggleButton* _tmp5_;
		GtkToggleButton* _tmp6_;
		_tmp5_ = self->priv->cycle_button;
		gtk_widget_set_tooltip_text ((GtkWidget*) _tmp5_, _ ("Enable cyclic search"));
		_tmp6_ = self->priv->cycle_button;
		gtk_button_set_icon_name ((GtkButton*) _tmp6_, "media-playlist-repeat-disabled-symbolic");
	}
}

static void
__terminal_widgets_search_toolbar___lambda7__gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                                                        gpointer self)
{
	_terminal_widgets_search_toolbar___lambda7_ ((TerminalWidgetsSearchToolbar*) self);
}

static void
_terminal_widgets_search_toolbar___lambda8_ (TerminalWidgetsSearchToolbar* self)
{
	gtk_widget_grab_focus ((GtkWidget*) self);
}

static void
__terminal_widgets_search_toolbar___lambda8__gtk_button_clicked (GtkButton* _sender,
                                                                 gpointer self)
{
	_terminal_widgets_search_toolbar___lambda8_ ((TerminalWidgetsSearchToolbar*) self);
}

static void
_terminal_widgets_search_toolbar___lambda9_ (TerminalWidgetsSearchToolbar* self)
{
	gtk_widget_grab_focus ((GtkWidget*) self);
}

static void
__terminal_widgets_search_toolbar___lambda9__gtk_button_clicked (GtkButton* _sender,
                                                                 gpointer self)
{
	_terminal_widgets_search_toolbar___lambda9_ ((TerminalWidgetsSearchToolbar*) self);
}

static void
_terminal_widgets_search_toolbar___lambda10_ (TerminalWidgetsSearchToolbar* self)
{
	gtk_widget_grab_focus ((GtkWidget*) self);
}

static void
__terminal_widgets_search_toolbar___lambda10__gtk_button_clicked (GtkButton* _sender,
                                                                  gpointer self)
{
	_terminal_widgets_search_toolbar___lambda10_ ((TerminalWidgetsSearchToolbar*) self);
}

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

static void
_terminal_widgets_search_toolbar___lambda11_ (TerminalWidgetsSearchToolbar* self)
{
	GtkSearchEntry* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	VteTerminal* term = NULL;
	TerminalMainWindow* _tmp17_;
	TerminalTerminalWidget* _tmp18_;
	TerminalTerminalWidget* _tmp19_;
	VteTerminal* _tmp20_;
	gchar* search_term = NULL;
	GtkSearchEntry* _tmp21_;
	const gchar* _tmp22_;
	const gchar* _tmp23_;
	gchar* _tmp24_;
	const gchar* _tmp25_;
	gint _tmp26_;
	gint _tmp27_;
	const gchar* _tmp30_;
	gint _tmp31_;
	gint _tmp32_;
	GError* _inner_error0_ = NULL;
	_tmp0_ = self->priv->search_entry;
	_tmp1_ = gtk_editable_get_text ((GtkEditable*) _tmp0_);
	_tmp2_ = _tmp1_;
	if (g_strcmp0 (_tmp2_, "") != 0) {
		TerminalMainWindow* _tmp3_;
		GSimpleAction* _tmp4_;
		GSimpleAction* _tmp5_;
		TerminalMainWindow* _tmp6_;
		GSimpleAction* _tmp7_;
		GSimpleAction* _tmp8_;
		GtkToggleButton* _tmp9_;
		_tmp3_ = self->priv->_window;
		_tmp4_ = terminal_main_window_get_simple_action (_tmp3_, TERMINAL_MAIN_WINDOW_ACTION_SEARCH_NEXT);
		_tmp5_ = _tmp4_;
		g_simple_action_set_enabled (_tmp5_, TRUE);
		_g_object_unref0 (_tmp5_);
		_tmp6_ = self->priv->_window;
		_tmp7_ = terminal_main_window_get_simple_action (_tmp6_, TERMINAL_MAIN_WINDOW_ACTION_SEARCH_PREVIOUS);
		_tmp8_ = _tmp7_;
		g_simple_action_set_enabled (_tmp8_, TRUE);
		_g_object_unref0 (_tmp8_);
		_tmp9_ = self->priv->cycle_button;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp9_, TRUE);
	} else {
		TerminalMainWindow* _tmp10_;
		GSimpleAction* _tmp11_;
		GSimpleAction* _tmp12_;
		TerminalMainWindow* _tmp13_;
		GSimpleAction* _tmp14_;
		GSimpleAction* _tmp15_;
		GtkToggleButton* _tmp16_;
		_tmp10_ = self->priv->_window;
		_tmp11_ = terminal_main_window_get_simple_action (_tmp10_, TERMINAL_MAIN_WINDOW_ACTION_SEARCH_NEXT);
		_tmp12_ = _tmp11_;
		g_simple_action_set_enabled (_tmp12_, FALSE);
		_g_object_unref0 (_tmp12_);
		_tmp13_ = self->priv->_window;
		_tmp14_ = terminal_main_window_get_simple_action (_tmp13_, TERMINAL_MAIN_WINDOW_ACTION_SEARCH_PREVIOUS);
		_tmp15_ = _tmp14_;
		g_simple_action_set_enabled (_tmp15_, FALSE);
		_g_object_unref0 (_tmp15_);
		_tmp16_ = self->priv->cycle_button;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp16_, FALSE);
	}
	_tmp17_ = self->priv->_window;
	_tmp18_ = terminal_main_window_get_current_terminal (_tmp17_);
	_tmp19_ = _tmp18_;
	_tmp20_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp19_, vte_terminal_get_type (), VteTerminal));
	term = _tmp20_;
	_tmp21_ = self->priv->search_entry;
	_tmp22_ = gtk_editable_get_text ((GtkEditable*) _tmp21_);
	_tmp23_ = _tmp22_;
	_tmp24_ = g_strdup (_tmp23_);
	search_term = _tmp24_;
	terminal_widgets_search_toolbar_previous_search (self);
	_tmp25_ = search_term;
	_tmp26_ = strlen (_tmp25_);
	_tmp27_ = _tmp26_;
	if (self->priv->last_search_term_length > ((guint) _tmp27_)) {
		VteTerminal* _tmp28_;
		VteTerminal* _tmp29_;
		_tmp28_ = term;
		vte_terminal_match_remove_all (_tmp28_);
		_tmp29_ = term;
		vte_terminal_unselect_all (_tmp29_);
	}
	_tmp30_ = search_term;
	_tmp31_ = strlen (_tmp30_);
	_tmp32_ = _tmp31_;
	self->priv->last_search_term_length = (guint) _tmp32_;
	{
		VteRegex* regex = NULL;
		const gchar* _tmp33_;
		gchar* _tmp34_;
		gchar* _tmp35_;
		VteRegex* _tmp36_;
		VteRegex* _tmp37_;
		VteTerminal* _tmp38_;
		VteRegex* _tmp39_;
		_tmp33_ = search_term;
		_tmp34_ = g_regex_escape_string (_tmp33_, -1);
		_tmp35_ = _tmp34_;
		_tmp36_ = vte_regex_new_for_search (_tmp35_, (gssize) -1, (guint32) (PCRE2_CASELESS | PCRE2_MULTILINE), &_inner_error0_);
		_tmp37_ = _tmp36_;
		_g_free0 (_tmp35_);
		regex = _tmp37_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp38_ = term;
		_tmp39_ = regex;
		vte_terminal_search_set_regex (_tmp38_, _tmp39_, (guint32) 0);
		terminal_widgets_search_toolbar_next_search (self);
		_vte_regex_unref0 (regex);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* er = NULL;
		GError* _tmp40_;
		const gchar* _tmp41_;
		er = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp40_ = er;
		_tmp41_ = _tmp40_->message;
		g_warning ("SearchToolbar.vala:105: There was an error to compile the regex: %s", _tmp41_);
		_g_error_free0 (er);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (search_term);
		_g_object_unref0 (term);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
	_g_free0 (search_term);
	_g_object_unref0 (term);
}

static void
__terminal_widgets_search_toolbar___lambda11__gtk_search_entry_search_changed (GtkSearchEntry* _sender,
                                                                               gpointer self)
{
	_terminal_widgets_search_toolbar___lambda11_ ((TerminalWidgetsSearchToolbar*) self);
}

static GObject *
terminal_widgets_search_toolbar_constructor (GType type,
                                             guint n_construct_properties,
                                             GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	TerminalWidgetsSearchToolbar * self;
	gchar* _tmp0_;
	GtkSearchEntry* _tmp1_ = NULL;
	GtkButton* previous_button = NULL;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar** _tmp5_;
	gchar** _tmp6_;
	gint _tmp6__length1;
	gchar* _tmp7_;
	GtkButton* _tmp8_ = NULL;
	GtkButton* _tmp9_;
	GtkButton* next_button = NULL;
	gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar** _tmp13_;
	gchar** _tmp14_;
	gint _tmp14__length1;
	gchar* _tmp15_;
	GtkButton* _tmp16_ = NULL;
	GtkButton* _tmp17_;
	GtkToggleButton* _tmp18_ = NULL;
	GtkToggleButton* _tmp19_;
	GtkToggleButton* _tmp20_;
	GtkSearchEntry* _tmp21_;
	GtkButton* _tmp22_;
	GtkButton* _tmp23_;
	GtkToggleButton* _tmp24_;
	GtkButton* _tmp25_;
	GtkButton* _tmp26_;
	GtkToggleButton* _tmp27_;
	GtkSearchEntry* _tmp28_;
	parent_class = G_OBJECT_CLASS (terminal_widgets_search_toolbar_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TERMINAL_WIDGETS_TYPE_SEARCH_TOOLBAR, TerminalWidgetsSearchToolbar);
	_tmp0_ = g_strdup (_ ("Find"));
	_tmp1_ = (GtkSearchEntry*) gtk_search_entry_new ();
	gtk_widget_set_hexpand ((GtkWidget*) _tmp1_, TRUE);
	g_object_set (_tmp1_, "placeholder-text", _tmp0_, NULL);
	_g_free0 (_tmp0_);
	g_object_ref_sink (_tmp1_);
	_g_object_unref0 (self->priv->search_entry);
	self->priv->search_entry = _tmp1_;
	_tmp2_ = g_strdup (TERMINAL_MAIN_WINDOW_ACTION_PREFIX TERMINAL_MAIN_WINDOW_ACTION_SEARCH_PREVIOUS);
	_tmp3_ = g_strdup ("<Control>Up");
	_tmp4_ = g_strdup ("<Control><Shift>g");
	_tmp5_ = g_new0 (gchar*, 2 + 1);
	_tmp5_[0] = _tmp3_;
	_tmp5_[1] = _tmp4_;
	_tmp6_ = _tmp5_;
	_tmp6__length1 = 2;
	_tmp7_ = granite_markup_accel_tooltip (_tmp6_, (gint) 2, _ ("Previous result"));
	_tmp8_ = (GtkButton*) gtk_button_new_from_icon_name ("go-up-symbolic");
	gtk_actionable_set_action_name ((GtkActionable*) _tmp8_, _tmp2_);
	_g_free0 (_tmp2_);
	gtk_widget_set_tooltip_markup ((GtkWidget*) _tmp8_, _tmp7_);
	_g_free0 (_tmp7_);
	g_object_ref_sink (_tmp8_);
	_tmp9_ = _tmp8_;
	_tmp6_ = (_vala_array_free (_tmp6_, _tmp6__length1, (GDestroyNotify) g_free), NULL);
	previous_button = _tmp9_;
	_tmp10_ = g_strdup (TERMINAL_MAIN_WINDOW_ACTION_PREFIX TERMINAL_MAIN_WINDOW_ACTION_SEARCH_NEXT);
	_tmp11_ = g_strdup ("<Control>Down");
	_tmp12_ = g_strdup ("<Control>g");
	_tmp13_ = g_new0 (gchar*, 2 + 1);
	_tmp13_[0] = _tmp11_;
	_tmp13_[1] = _tmp12_;
	_tmp14_ = _tmp13_;
	_tmp14__length1 = 2;
	_tmp15_ = granite_markup_accel_tooltip (_tmp14_, (gint) 2, _ ("Next result"));
	_tmp16_ = (GtkButton*) gtk_button_new_from_icon_name ("go-down-symbolic");
	gtk_actionable_set_action_name ((GtkActionable*) _tmp16_, _tmp10_);
	_g_free0 (_tmp10_);
	gtk_widget_set_tooltip_markup ((GtkWidget*) _tmp16_, _tmp15_);
	_g_free0 (_tmp15_);
	g_object_ref_sink (_tmp16_);
	_tmp17_ = _tmp16_;
	_tmp14_ = (_vala_array_free (_tmp14_, _tmp14__length1, (GDestroyNotify) g_free), NULL);
	next_button = _tmp17_;
	_tmp18_ = (GtkToggleButton*) gtk_toggle_button_new ();
	gtk_toggle_button_set_active (_tmp18_, FALSE);
	gtk_widget_set_sensitive ((GtkWidget*) _tmp18_, FALSE);
	g_object_ref_sink (_tmp18_);
	_g_object_unref0 (self->priv->cycle_button);
	self->priv->cycle_button = _tmp18_;
	_tmp19_ = self->priv->cycle_button;
	g_signal_connect_object (_tmp19_, "toggled", (GCallback) __terminal_widgets_search_toolbar___lambda7__gtk_toggle_button_toggled, self, 0);
	_tmp20_ = self->priv->cycle_button;
	gtk_toggle_button_toggled (_tmp20_);
	granite_box_set_child_spacing ((GraniteBox*) self, GRANITE_BOX_SPACING_LINKED);
	_tmp21_ = self->priv->search_entry;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp21_);
	_tmp22_ = next_button;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp22_);
	_tmp23_ = previous_button;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp23_);
	_tmp24_ = self->priv->cycle_button;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp24_);
	_tmp25_ = next_button;
	g_signal_connect_object (_tmp25_, "clicked", (GCallback) __terminal_widgets_search_toolbar___lambda8__gtk_button_clicked, self, G_CONNECT_AFTER);
	_tmp26_ = previous_button;
	g_signal_connect_object (_tmp26_, "clicked", (GCallback) __terminal_widgets_search_toolbar___lambda9__gtk_button_clicked, self, G_CONNECT_AFTER);
	_tmp27_ = self->priv->cycle_button;
	g_signal_connect_object ((GtkButton*) _tmp27_, "clicked", (GCallback) __terminal_widgets_search_toolbar___lambda10__gtk_button_clicked, self, G_CONNECT_AFTER);
	_tmp28_ = self->priv->search_entry;
	g_signal_connect_object (_tmp28_, "search-changed", (GCallback) __terminal_widgets_search_toolbar___lambda11__gtk_search_entry_search_changed, self, 0);
	_g_object_unref0 (next_button);
	_g_object_unref0 (previous_button);
	return obj;
}

static void
terminal_widgets_search_toolbar_class_init (TerminalWidgetsSearchToolbarClass * klass,
                                            gpointer klass_data)
{
	terminal_widgets_search_toolbar_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &TerminalWidgetsSearchToolbar_private_offset);
	((GtkWidgetClass *) klass)->grab_focus = (gboolean (*) (GtkWidget*)) terminal_widgets_search_toolbar_real_grab_focus;
	G_OBJECT_CLASS (klass)->get_property = _vala_terminal_widgets_search_toolbar_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_terminal_widgets_search_toolbar_set_property;
	G_OBJECT_CLASS (klass)->constructor = terminal_widgets_search_toolbar_constructor;
	G_OBJECT_CLASS (klass)->finalize = terminal_widgets_search_toolbar_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), TERMINAL_WIDGETS_SEARCH_TOOLBAR_WINDOW_PROPERTY, terminal_widgets_search_toolbar_properties[TERMINAL_WIDGETS_SEARCH_TOOLBAR_WINDOW_PROPERTY] = g_param_spec_object ("window", "window", "window", TERMINAL_TYPE_MAIN_WINDOW, G_PARAM_STATIC_STRINGS | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
terminal_widgets_search_toolbar_instance_init (TerminalWidgetsSearchToolbar * self,
                                               gpointer klass)
{
	self->priv = terminal_widgets_search_toolbar_get_instance_private (self);
	self->priv->last_search_term_length = (guint) 0;
}

static void
terminal_widgets_search_toolbar_finalize (GObject * obj)
{
	TerminalWidgetsSearchToolbar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TERMINAL_WIDGETS_TYPE_SEARCH_TOOLBAR, TerminalWidgetsSearchToolbar);
	_g_object_unref0 (self->priv->cycle_button);
	_g_object_unref0 (self->priv->search_entry);
	G_OBJECT_CLASS (terminal_widgets_search_toolbar_parent_class)->finalize (obj);
}

static GType
terminal_widgets_search_toolbar_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (TerminalWidgetsSearchToolbarClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) terminal_widgets_search_toolbar_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TerminalWidgetsSearchToolbar), 0, (GInstanceInitFunc) terminal_widgets_search_toolbar_instance_init, NULL };
	GType terminal_widgets_search_toolbar_type_id;
	terminal_widgets_search_toolbar_type_id = g_type_register_static (GRANITE_TYPE_BOX, "TerminalWidgetsSearchToolbar", &g_define_type_info, 0);
	TerminalWidgetsSearchToolbar_private_offset = g_type_add_instance_private (terminal_widgets_search_toolbar_type_id, sizeof (TerminalWidgetsSearchToolbarPrivate));
	return terminal_widgets_search_toolbar_type_id;
}

GType
terminal_widgets_search_toolbar_get_type (void)
{
	static volatile gsize terminal_widgets_search_toolbar_type_id__once = 0;
	if (g_once_init_enter (&terminal_widgets_search_toolbar_type_id__once)) {
		GType terminal_widgets_search_toolbar_type_id;
		terminal_widgets_search_toolbar_type_id = terminal_widgets_search_toolbar_get_type_once ();
		g_once_init_leave (&terminal_widgets_search_toolbar_type_id__once, terminal_widgets_search_toolbar_type_id);
	}
	return terminal_widgets_search_toolbar_type_id__once;
}

static void
_vala_terminal_widgets_search_toolbar_get_property (GObject * object,
                                                    guint property_id,
                                                    GValue * value,
                                                    GParamSpec * pspec)
{
	TerminalWidgetsSearchToolbar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TERMINAL_WIDGETS_TYPE_SEARCH_TOOLBAR, TerminalWidgetsSearchToolbar);
	switch (property_id) {
		case TERMINAL_WIDGETS_SEARCH_TOOLBAR_WINDOW_PROPERTY:
		g_value_set_object (value, terminal_widgets_search_toolbar_get_window (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_terminal_widgets_search_toolbar_set_property (GObject * object,
                                                    guint property_id,
                                                    const GValue * value,
                                                    GParamSpec * pspec)
{
	TerminalWidgetsSearchToolbar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TERMINAL_WIDGETS_TYPE_SEARCH_TOOLBAR, TerminalWidgetsSearchToolbar);
	switch (property_id) {
		case TERMINAL_WIDGETS_SEARCH_TOOLBAR_WINDOW_PROPERTY:
		terminal_widgets_search_toolbar_set_window (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

