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

/*
 * Copyright (C) 2011-2012 Lucas Baudin <xapantu@gmail.com>
 *               2013      Mario Guerriero <mario@elementaryos.org>
                 2014-2023 elementary, Inc. (https://elementary.io)
 *
 * This file is part of Code.
 *
 * Code 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 3 of the License, or
 * (at your option) any later version.
 *
 * Code 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, see <http://www.gnu.org/licenses/>.
 */

#include <glib-object.h>
#include <gtk/gtk.h>
#include <handy.h>
#include <granite.h>
#include <gtksourceview/gtksource.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <gdk/gdk.h>
#include <float.h>
#include <math.h>
#include <glib/gi18n-lib.h>
#include <gio/gio.h>

#define SCRATCH_MAIN_WINDOW_ACTION_GROUP "win"
#define SCRATCH_MAIN_WINDOW_ACTION_PREFIX SCRATCH_MAIN_WINDOW_ACTION_GROUP "."
#define SCRATCH_MAIN_WINDOW_ACTION_FIND_NEXT "action-find-next"
#define SCRATCH_MAIN_WINDOW_ACTION_FIND_PREVIOUS "action-find-previous"
#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

typedef enum  {
	SCRATCH_CASE_SENSITIVE_MODE_NEVER,
	SCRATCH_CASE_SENSITIVE_MODE_MIXED,
	SCRATCH_CASE_SENSITIVE_MODE_ALWAYS
} ScratchCaseSensitiveMode;

#define SCRATCH_TYPE_CASE_SENSITIVE_MODE (scratch_case_sensitive_mode_get_type ())

#define SCRATCH_WIDGETS_TYPE_SEARCH_BAR (scratch_widgets_search_bar_get_type ())
#define SCRATCH_WIDGETS_SEARCH_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SCRATCH_WIDGETS_TYPE_SEARCH_BAR, ScratchWidgetsSearchBar))
#define SCRATCH_WIDGETS_SEARCH_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SCRATCH_WIDGETS_TYPE_SEARCH_BAR, ScratchWidgetsSearchBarClass))
#define SCRATCH_WIDGETS_IS_SEARCH_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SCRATCH_WIDGETS_TYPE_SEARCH_BAR))
#define SCRATCH_WIDGETS_IS_SEARCH_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SCRATCH_WIDGETS_TYPE_SEARCH_BAR))
#define SCRATCH_WIDGETS_SEARCH_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SCRATCH_WIDGETS_TYPE_SEARCH_BAR, ScratchWidgetsSearchBarClass))

typedef struct _ScratchWidgetsSearchBar ScratchWidgetsSearchBar;
typedef struct _ScratchWidgetsSearchBarClass ScratchWidgetsSearchBarClass;
typedef struct _ScratchWidgetsSearchBarPrivate ScratchWidgetsSearchBarPrivate;

#define SCRATCH_TYPE_MAIN_WINDOW (scratch_main_window_get_type ())
#define SCRATCH_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SCRATCH_TYPE_MAIN_WINDOW, ScratchMainWindow))
#define SCRATCH_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SCRATCH_TYPE_MAIN_WINDOW, ScratchMainWindowClass))
#define SCRATCH_IS_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SCRATCH_TYPE_MAIN_WINDOW))
#define SCRATCH_IS_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SCRATCH_TYPE_MAIN_WINDOW))
#define SCRATCH_MAIN_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SCRATCH_TYPE_MAIN_WINDOW, ScratchMainWindowClass))

typedef struct _ScratchMainWindow ScratchMainWindow;
typedef struct _ScratchMainWindowClass ScratchMainWindowClass;

#define SCRATCH_WIDGETS_TYPE_SOURCE_VIEW (scratch_widgets_source_view_get_type ())
#define SCRATCH_WIDGETS_SOURCE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SCRATCH_WIDGETS_TYPE_SOURCE_VIEW, ScratchWidgetsSourceView))
#define SCRATCH_WIDGETS_SOURCE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SCRATCH_WIDGETS_TYPE_SOURCE_VIEW, ScratchWidgetsSourceViewClass))
#define SCRATCH_WIDGETS_IS_SOURCE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SCRATCH_WIDGETS_TYPE_SOURCE_VIEW))
#define SCRATCH_WIDGETS_IS_SOURCE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SCRATCH_WIDGETS_TYPE_SOURCE_VIEW))
#define SCRATCH_WIDGETS_SOURCE_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SCRATCH_WIDGETS_TYPE_SOURCE_VIEW, ScratchWidgetsSourceViewClass))

typedef struct _ScratchWidgetsSourceView ScratchWidgetsSourceView;
typedef struct _ScratchWidgetsSourceViewClass ScratchWidgetsSourceViewClass;
enum  {
	SCRATCH_WIDGETS_SEARCH_BAR_0_PROPERTY,
	SCRATCH_WIDGETS_SEARCH_BAR_WINDOW_PROPERTY,
	SCRATCH_WIDGETS_SEARCH_BAR_IS_FOCUSED_PROPERTY,
	SCRATCH_WIDGETS_SEARCH_BAR_IS_REVEALED_PROPERTY,
	SCRATCH_WIDGETS_SEARCH_BAR_ENTRY_TEXT_PROPERTY,
	SCRATCH_WIDGETS_SEARCH_BAR_SEARCH_OCCURRENCES_PROPERTY,
	SCRATCH_WIDGETS_SEARCH_BAR_TRANSITION_TIME_MSEC_PROPERTY,
	SCRATCH_WIDGETS_SEARCH_BAR_NUM_PROPERTIES
};
static GParamSpec* scratch_widgets_search_bar_properties[SCRATCH_WIDGETS_SEARCH_BAR_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define __vala_GtkTextIter_free0(var) ((var == NULL) ? NULL : (var = (_vala_GtkTextIter_free (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

#define SCRATCH_SERVICES_TYPE_DOCUMENT (scratch_services_document_get_type ())
#define SCRATCH_SERVICES_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SCRATCH_SERVICES_TYPE_DOCUMENT, ScratchServicesDocument))
#define SCRATCH_SERVICES_DOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SCRATCH_SERVICES_TYPE_DOCUMENT, ScratchServicesDocumentClass))
#define SCRATCH_SERVICES_IS_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SCRATCH_SERVICES_TYPE_DOCUMENT))
#define SCRATCH_SERVICES_IS_DOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SCRATCH_SERVICES_TYPE_DOCUMENT))
#define SCRATCH_SERVICES_DOCUMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SCRATCH_SERVICES_TYPE_DOCUMENT, ScratchServicesDocumentClass))

typedef struct _ScratchServicesDocument ScratchServicesDocument;
typedef struct _ScratchServicesDocumentClass ScratchServicesDocumentClass;

#define SCRATCH_TYPE_APPLICATION (scratch_application_get_type ())
#define SCRATCH_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SCRATCH_TYPE_APPLICATION, ScratchApplication))
#define SCRATCH_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SCRATCH_TYPE_APPLICATION, ScratchApplicationClass))
#define SCRATCH_IS_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SCRATCH_TYPE_APPLICATION))
#define SCRATCH_IS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SCRATCH_TYPE_APPLICATION))
#define SCRATCH_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SCRATCH_TYPE_APPLICATION, ScratchApplicationClass))

typedef struct _ScratchApplication ScratchApplication;
typedef struct _ScratchApplicationClass ScratchApplicationClass;
#define _gtk_widget_path_unref0(var) ((var == NULL) ? NULL : (var = (gtk_widget_path_unref (var), NULL)))

struct _ScratchWidgetsSearchBar {
	GtkBox parent_instance;
	ScratchWidgetsSearchBarPrivate * priv;
};

struct _ScratchWidgetsSearchBarClass {
	GtkBoxClass parent_class;
};

struct _ScratchWidgetsSearchBarPrivate {
	ScratchMainWindow* _window;
	GtkButton* tool_arrow_up;
	GtkButton* tool_arrow_down;
	GraniteSwitchModelButton* cycle_search_button;
	GtkComboBoxText* case_sensitive_search_button;
	GraniteSwitchModelButton* regex_search_button;
	GraniteSwitchModelButton* whole_word_search_button;
	GtkSearchEntry* search_entry;
	GtkSearchEntry* replace_entry;
	GtkLabel* search_occurence_count_label;
	GtkButton* replace_tool_button;
	GtkButton* replace_all_tool_button;
	ScratchWidgetsSourceView* text_view;
	GtkTextBuffer* text_buffer;
	GtkSourceSearchContext* search_context;
	guint update_search_label_timeout_id;
	GtkRevealer* revealer;
};

static gint ScratchWidgetsSearchBar_private_offset;
static gpointer scratch_widgets_search_bar_parent_class = NULL;
VALA_EXTERN GSettings* scratch_settings;

VALA_EXTERN GType scratch_case_sensitive_mode_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType scratch_widgets_search_bar_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ScratchWidgetsSearchBar, g_object_unref)
VALA_EXTERN GType scratch_main_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ScratchMainWindow, g_object_unref)
VALA_EXTERN GType scratch_widgets_source_view_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ScratchWidgetsSourceView, g_object_unref)
VALA_EXTERN ScratchWidgetsSearchBar* scratch_widgets_search_bar_new (ScratchMainWindow* window);
VALA_EXTERN ScratchWidgetsSearchBar* scratch_widgets_search_bar_construct (GType object_type,
                                                               ScratchMainWindow* window);
VALA_EXTERN void scratch_widgets_search_bar_set_text_view (ScratchWidgetsSearchBar* self,
                                               ScratchWidgetsSourceView* text_view);
static void scratch_widgets_search_bar_cancel_update_search_widgets (ScratchWidgetsSearchBar* self);
static void scratch_widgets_search_bar_on_text_buffer_changed (ScratchWidgetsSearchBar* self);
static void _scratch_widgets_search_bar_on_text_buffer_changed_gtk_text_buffer_changed (GtkTextBuffer* _sender,
                                                                                 gpointer self);
static void scratch_widgets_search_bar_update_search_widgets (ScratchWidgetsSearchBar* self);
static void scratch_widgets_search_bar_on_replace_entry_activate (ScratchWidgetsSearchBar* self);
static void _vala_GtkTextIter_free (GtkTextIter* self);
static GtkTextIter* _vala_GtkTextIter_copy (GtkTextIter* self);
static gboolean scratch_widgets_search_bar_search_for_iter (ScratchWidgetsSearchBar* self,
                                                     GtkTextIter* start_iter,
                                                     GtkTextIter** end_iter);
static void scratch_widgets_search_bar_on_replace_all_entry_activate (ScratchWidgetsSearchBar* self);
VALA_EXTERN ScratchMainWindow* scratch_widgets_search_bar_get_window (ScratchWidgetsSearchBar* self);
VALA_EXTERN GType scratch_services_document_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ScratchServicesDocument, g_object_unref)
VALA_EXTERN ScratchServicesDocument* scratch_main_window_get_current_document (ScratchMainWindow* self);
VALA_EXTERN void scratch_services_document_toggle_changed_handlers (ScratchServicesDocument* self,
                                                        gboolean enabled);
static void scratch_widgets_search_bar_on_search_parameters_changed (ScratchWidgetsSearchBar* self);
static gboolean scratch_widgets_search_bar_on_search_entry_focused_in (ScratchWidgetsSearchBar* self,
                                                                GdkEventFocus* event);
static gboolean __lambda145_ (ScratchWidgetsSearchBar* self);
static gboolean ___lambda145__gsource_func (gpointer self);
VALA_EXTERN gboolean scratch_widgets_search_bar_search (ScratchWidgetsSearchBar* self);
static gboolean scratch_widgets_search_bar_has_matches (ScratchWidgetsSearchBar* self);
VALA_EXTERN void scratch_widgets_search_bar_highlight_none (ScratchWidgetsSearchBar* self);
static gboolean scratch_widgets_search_bar_search_for_iter_backward (ScratchWidgetsSearchBar* self,
                                                              GtkTextIter* start_iter,
                                                              GtkTextIter** end_iter);
VALA_EXTERN void scratch_widgets_search_bar_search_previous (ScratchWidgetsSearchBar* self);
VALA_EXTERN void scratch_widgets_search_bar_search_next (ScratchWidgetsSearchBar* self);
VALA_EXTERN void scratch_widgets_search_bar_focus_search_entry (ScratchWidgetsSearchBar* self);
VALA_EXTERN void scratch_widgets_search_bar_focus_replace_entry (ScratchWidgetsSearchBar* self);
VALA_EXTERN void scratch_widgets_search_bar_reveal (ScratchWidgetsSearchBar* self,
                                        gboolean to_reveal);
VALA_EXTERN gboolean scratch_widgets_search_bar_get_is_revealed (ScratchWidgetsSearchBar* self);
VALA_EXTERN void scratch_widgets_search_bar_set_search_entry_text (ScratchWidgetsSearchBar* self,
                                                       const gchar* text);
static gboolean scratch_widgets_search_bar_on_search_entry_key_press (ScratchWidgetsSearchBar* self,
                                                               GdkEventKey* event);
static gboolean scratch_widgets_search_bar_on_replace_entry_key_press (ScratchWidgetsSearchBar* self,
                                                                GdkEventKey* event);
static gboolean __lambda144_ (ScratchWidgetsSearchBar* self);
static gboolean ___lambda144__gsource_func (gpointer self);
static void scratch_widgets_search_bar_set_window (ScratchWidgetsSearchBar* self,
                                            ScratchMainWindow* value);
VALA_EXTERN gboolean scratch_widgets_search_bar_get_is_focused (ScratchWidgetsSearchBar* self);
VALA_EXTERN const gchar* scratch_widgets_search_bar_get_entry_text (ScratchWidgetsSearchBar* self);
VALA_EXTERN guint scratch_widgets_search_bar_get_search_occurrences (ScratchWidgetsSearchBar* self);
VALA_EXTERN guint scratch_widgets_search_bar_get_transition_time_msec (ScratchWidgetsSearchBar* self);
static GObject * scratch_widgets_search_bar_constructor (GType type,
                                                  guint n_construct_properties,
                                                  GObjectConstructParam * construct_properties);
VALA_EXTERN GType scratch_application_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ScratchApplication, g_object_unref)
static void _scratch_widgets_search_bar_search_next_gtk_button_clicked (GtkButton* _sender,
                                                                 gpointer self);
static void _scratch_widgets_search_bar_search_previous_gtk_button_clicked (GtkButton* _sender,
                                                                     gpointer self);
static void _scratch_widgets_search_bar_on_search_parameters_changed_gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                                                                         gpointer self);
static void _scratch_widgets_search_bar_on_search_parameters_changed_gtk_combo_box_changed (GtkComboBox* _sender,
                                                                                     gpointer self);
static void _scratch_widgets_search_bar_on_replace_entry_activate_gtk_button_clicked (GtkButton* _sender,
                                                                               gpointer self);
static void _scratch_widgets_search_bar_on_replace_all_entry_activate_gtk_button_clicked (GtkButton* _sender,
                                                                                   gpointer self);
static void _scratch_widgets_search_bar_on_search_parameters_changed_gtk_editable_changed (GtkEditable* _sender,
                                                                                    gpointer self);
static gboolean _scratch_widgets_search_bar_on_search_entry_key_press_gtk_widget_key_press_event (GtkWidget* _sender,
                                                                                           GdkEventKey* event,
                                                                                           gpointer self);
static gboolean _scratch_widgets_search_bar_on_search_entry_focused_in_gtk_widget_focus_in_event (GtkWidget* _sender,
                                                                                           GdkEventFocus* event,
                                                                                           gpointer self);
static void _scratch_widgets_search_bar___lambda146_ (ScratchWidgetsSearchBar* self,
                                               GtkEntryIconPosition p0,
                                               GdkEvent* p1);
static void __scratch_widgets_search_bar___lambda146__gtk_entry_icon_release (GtkEntry* _sender,
                                                                       GtkEntryIconPosition icon_pos,
                                                                       GdkEvent* event,
                                                                       gpointer self);
static void _scratch_widgets_search_bar_on_replace_entry_activate_gtk_entry_activate (GtkEntry* _sender,
                                                                               gpointer self);
static gboolean _scratch_widgets_search_bar_on_replace_entry_key_press_gtk_widget_key_press_event (GtkWidget* _sender,
                                                                                            GdkEventKey* event,
                                                                                            gpointer self);
static void scratch_widgets_search_bar_finalize (GObject * obj);
static GType scratch_widgets_search_bar_get_type_once (void);
static void _vala_scratch_widgets_search_bar_get_property (GObject * object,
                                                    guint property_id,
                                                    GValue * value,
                                                    GParamSpec * pspec);
static void _vala_scratch_widgets_search_bar_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 gssize _vala_array_length (gpointer array);

 G_GNUC_NO_INLINE static GType
scratch_case_sensitive_mode_get_type_once (void)
{
	static const GEnumValue values[] = {{SCRATCH_CASE_SENSITIVE_MODE_NEVER, "SCRATCH_CASE_SENSITIVE_MODE_NEVER", "never"}, {SCRATCH_CASE_SENSITIVE_MODE_MIXED, "SCRATCH_CASE_SENSITIVE_MODE_MIXED", "mixed"}, {SCRATCH_CASE_SENSITIVE_MODE_ALWAYS, "SCRATCH_CASE_SENSITIVE_MODE_ALWAYS", "always"}, {0, NULL, NULL}};
	GType scratch_case_sensitive_mode_type_id;
	scratch_case_sensitive_mode_type_id = g_enum_register_static ("ScratchCaseSensitiveMode", values);
	return scratch_case_sensitive_mode_type_id;
}

GType
scratch_case_sensitive_mode_get_type (void)
{
	static gsize scratch_case_sensitive_mode_type_id__once = 0;
	if (g_once_init_enter (&scratch_case_sensitive_mode_type_id__once)) {
		GType scratch_case_sensitive_mode_type_id;
		scratch_case_sensitive_mode_type_id = scratch_case_sensitive_mode_get_type_once ();
		g_once_init_leave (&scratch_case_sensitive_mode_type_id__once, scratch_case_sensitive_mode_type_id);
	}
	return scratch_case_sensitive_mode_type_id__once;
}

static inline gpointer
scratch_widgets_search_bar_get_instance_private (ScratchWidgetsSearchBar* self)
{
	return G_STRUCT_MEMBER_P (self, ScratchWidgetsSearchBar_private_offset);
}

ScratchWidgetsSearchBar*
scratch_widgets_search_bar_construct (GType object_type,
                                      ScratchMainWindow* window)
{
	ScratchWidgetsSearchBar * self = NULL;
	g_return_val_if_fail (window != NULL, NULL);
	self = (ScratchWidgetsSearchBar*) g_object_new (object_type, "window", window, NULL);
	return self;
}

ScratchWidgetsSearchBar*
scratch_widgets_search_bar_new (ScratchMainWindow* window)
{
	return scratch_widgets_search_bar_construct (SCRATCH_WIDGETS_TYPE_SEARCH_BAR, window);
}

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

static void
_scratch_widgets_search_bar_on_text_buffer_changed_gtk_text_buffer_changed (GtkTextBuffer* _sender,
                                                                            gpointer self)
{
	scratch_widgets_search_bar_on_text_buffer_changed ((ScratchWidgetsSearchBar*) self);
}

void
scratch_widgets_search_bar_set_text_view (ScratchWidgetsSearchBar* self,
                                          ScratchWidgetsSourceView* text_view)
{
	ScratchWidgetsSourceView* _tmp0_;
	ScratchWidgetsSourceView* _tmp1_;
	ScratchWidgetsSourceView* _tmp5_;
	GtkTextBuffer* _tmp6_;
	GtkTextBuffer* _tmp7_;
	GtkTextBuffer* _tmp8_;
	GtkTextBuffer* _tmp9_;
	GtkSourceSearchContext* _tmp10_;
	GtkSourceSearchContext* _tmp11_;
	GtkSourceSearchSettings* _tmp12_;
	GtkSourceSearchSettings* _tmp13_;
	GraniteSwitchModelButton* _tmp14_;
	gboolean _tmp15_;
	gboolean _tmp16_;
	GtkSourceSearchContext* _tmp17_;
	GtkSourceSearchSettings* _tmp18_;
	GtkSourceSearchSettings* _tmp19_;
	GraniteSwitchModelButton* _tmp20_;
	gboolean _tmp21_;
	gboolean _tmp22_;
	GtkSourceSearchContext* _tmp23_;
	GtkSourceSearchSettings* _tmp24_;
	GtkSourceSearchSettings* _tmp25_;
	GtkSearchEntry* _tmp26_;
	const gchar* _tmp27_;
	const gchar* _tmp28_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->text_view;
	if (_tmp0_ == text_view) {
		return;
	}
	scratch_widgets_search_bar_cancel_update_search_widgets (self);
	_tmp1_ = _g_object_ref0 (text_view);
	_g_object_unref0 (self->priv->text_view);
	self->priv->text_view = _tmp1_;
	if (text_view == NULL) {
		g_warning ("SearchBar.vala:273: No SourceView is associated with SearchManager!");
		_g_object_unref0 (self->priv->search_context);
		self->priv->search_context = NULL;
		return;
	} else {
		GtkTextBuffer* _tmp2_;
		_tmp2_ = self->priv->text_buffer;
		if (_tmp2_ != NULL) {
			GtkTextBuffer* _tmp3_;
			guint _tmp4_;
			_tmp3_ = self->priv->text_buffer;
			g_signal_parse_name ("changed", gtk_text_buffer_get_type (), &_tmp4_, NULL, FALSE);
			g_signal_handlers_disconnect_matched (_tmp3_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp4_, 0, NULL, (GCallback) _scratch_widgets_search_bar_on_text_buffer_changed_gtk_text_buffer_changed, self);
		}
	}
	_tmp5_ = _g_object_ref0 (text_view);
	_g_object_unref0 (self->priv->text_view);
	self->priv->text_view = _tmp5_;
	_tmp6_ = gtk_text_view_get_buffer ((GtkTextView*) text_view);
	_tmp7_ = _g_object_ref0 (_tmp6_);
	_g_object_unref0 (self->priv->text_buffer);
	self->priv->text_buffer = _tmp7_;
	_tmp8_ = self->priv->text_buffer;
	g_signal_connect_object (_tmp8_, "changed", (GCallback) _scratch_widgets_search_bar_on_text_buffer_changed_gtk_text_buffer_changed, self, 0);
	_tmp9_ = self->priv->text_buffer;
	_tmp10_ = gtk_source_search_context_new (G_TYPE_CHECK_INSTANCE_TYPE (_tmp9_, gtk_source_buffer_get_type ()) ? ((GtkSourceBuffer*) _tmp9_) : NULL, NULL);
	_g_object_unref0 (self->priv->search_context);
	self->priv->search_context = _tmp10_;
	_tmp11_ = self->priv->search_context;
	_tmp12_ = gtk_source_search_context_get_settings (_tmp11_);
	_tmp13_ = _tmp12_;
	_tmp14_ = self->priv->cycle_search_button;
	_tmp15_ = gtk_toggle_button_get_active ((GtkToggleButton*) _tmp14_);
	_tmp16_ = _tmp15_;
	gtk_source_search_settings_set_wrap_around (_tmp13_, _tmp16_);
	_tmp17_ = self->priv->search_context;
	_tmp18_ = gtk_source_search_context_get_settings (_tmp17_);
	_tmp19_ = _tmp18_;
	_tmp20_ = self->priv->regex_search_button;
	_tmp21_ = gtk_toggle_button_get_active ((GtkToggleButton*) _tmp20_);
	_tmp22_ = _tmp21_;
	gtk_source_search_settings_set_regex_enabled (_tmp19_, _tmp22_);
	_tmp23_ = self->priv->search_context;
	_tmp24_ = gtk_source_search_context_get_settings (_tmp23_);
	_tmp25_ = _tmp24_;
	_tmp26_ = self->priv->search_entry;
	_tmp27_ = gtk_entry_get_text ((GtkEntry*) _tmp26_);
	_tmp28_ = _tmp27_;
	gtk_source_search_settings_set_search_text (_tmp25_, _tmp28_);
	scratch_widgets_search_bar_on_text_buffer_changed (self);
}

static void
scratch_widgets_search_bar_on_text_buffer_changed (ScratchWidgetsSearchBar* self)
{
	g_return_if_fail (self != NULL);
	scratch_widgets_search_bar_update_search_widgets (self);
}

static void
_vala_GtkTextIter_free (GtkTextIter* self)
{
	g_boxed_free (gtk_text_iter_get_type (), self);
}

static GtkTextIter*
_vala_GtkTextIter_copy (GtkTextIter* self)
{
	return g_boxed_copy (gtk_text_iter_get_type (), self);
}

static gpointer
__vala_GtkTextIter_copy0 (gpointer self)
{
	return self ? _vala_GtkTextIter_copy (self) : NULL;
}

static void
scratch_widgets_search_bar_on_replace_entry_activate (ScratchWidgetsSearchBar* self)
{
	GtkTextBuffer* _tmp0_;
	GtkTextIter* start_iter = NULL;
	GtkTextIter* end_iter = NULL;
	GtkTextBuffer* _tmp1_;
	GtkTextBuffer* _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	GtkTextIter _tmp5_ = {0};
	GtkTextIter _tmp6_;
	GtkTextIter* _tmp7_;
	GtkTextIter* _tmp8_;
	GtkTextIter* _tmp9_ = NULL;
	gboolean _tmp10_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->text_buffer;
	if (_tmp0_ == NULL) {
		g_warning ("SearchBar.vala:296: No valid buffer to replace");
		return;
	}
	_tmp1_ = self->priv->text_buffer;
	_tmp2_ = self->priv->text_buffer;
	g_object_get (_tmp2_, "cursor-position", &_tmp3_, NULL);
	_tmp4_ = _tmp3_;
	gtk_text_buffer_get_iter_at_offset (_tmp1_, &_tmp5_, _tmp4_);
	__vala_GtkTextIter_free0 (start_iter);
	_tmp6_ = _tmp5_;
	_tmp7_ = __vala_GtkTextIter_copy0 (&_tmp6_);
	start_iter = _tmp7_;
	_tmp8_ = start_iter;
	_tmp10_ = scratch_widgets_search_bar_search_for_iter (self, _tmp8_, &_tmp9_);
	__vala_GtkTextIter_free0 (end_iter);
	end_iter = _tmp9_;
	if (_tmp10_) {
		gchar* replace_string = NULL;
		GtkSearchEntry* _tmp11_;
		const gchar* _tmp12_;
		const gchar* _tmp13_;
		gchar* _tmp14_;
		_tmp11_ = self->priv->replace_entry;
		_tmp12_ = gtk_entry_get_text ((GtkEntry*) _tmp11_);
		_tmp13_ = _tmp12_;
		_tmp14_ = g_strdup (_tmp13_);
		replace_string = _tmp14_;
		{
			GtkSourceSearchContext* _tmp15_;
			GtkTextIter* _tmp16_;
			GtkTextIter* _tmp17_;
			const gchar* _tmp18_;
			const gchar* _tmp19_;
			gint _tmp20_;
			gint _tmp21_;
			GtkTextIter _tmp22_;
			GtkTextIter _tmp23_;
			GtkSearchEntry* _tmp24_;
			const gchar* _tmp25_;
			const gchar* _tmp26_;
			GtkSearchEntry* _tmp27_;
			const gchar* _tmp28_;
			const gchar* _tmp29_;
			scratch_widgets_search_bar_cancel_update_search_widgets (self);
			_tmp15_ = self->priv->search_context;
			_tmp16_ = start_iter;
			_tmp17_ = end_iter;
			_tmp18_ = replace_string;
			_tmp19_ = replace_string;
			_tmp20_ = strlen (_tmp19_);
			_tmp21_ = _tmp20_;
			_tmp22_ = *_tmp16_;
			_tmp23_ = *_tmp17_;
			gtk_source_search_context_replace (_tmp15_, &_tmp22_, &_tmp23_, _tmp18_, _tmp21_, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
			scratch_widgets_search_bar_update_search_widgets (self);
			_tmp24_ = self->priv->search_entry;
			_tmp25_ = gtk_entry_get_text ((GtkEntry*) _tmp24_);
			_tmp26_ = _tmp25_;
			_tmp27_ = self->priv->replace_entry;
			_tmp28_ = gtk_entry_get_text ((GtkEntry*) _tmp27_);
			_tmp29_ = _tmp28_;
			g_debug ("SearchBar.vala:309: Replaced \"%s\" with \"%s\"", _tmp26_, _tmp29_);
		}
		goto __finally0;
		__catch0_g_error:
		{
			GError* e = NULL;
			GError* _tmp30_;
			const gchar* _tmp31_;
			e = _inner_error0_;
			_inner_error0_ = NULL;
			_tmp30_ = e;
			_tmp31_ = _tmp30_->message;
			g_critical ("SearchBar.vala:311: %s", _tmp31_);
			_g_error_free0 (e);
		}
		__finally0:
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_free0 (replace_string);
			__vala_GtkTextIter_free0 (end_iter);
			__vala_GtkTextIter_free0 (start_iter);
			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 (replace_string);
	}
	__vala_GtkTextIter_free0 (end_iter);
	__vala_GtkTextIter_free0 (start_iter);
}

static void
scratch_widgets_search_bar_on_replace_all_entry_activate (ScratchWidgetsSearchBar* self)
{
	gboolean _tmp0_ = FALSE;
	GtkTextBuffer* _tmp1_;
	gchar* replace_string = NULL;
	GtkSearchEntry* _tmp5_;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	gchar* _tmp8_;
	ScratchMainWindow* _tmp9_;
	ScratchServicesDocument* _tmp10_;
	ScratchServicesDocument* _tmp11_;
	ScratchMainWindow* _tmp19_;
	ScratchServicesDocument* _tmp20_;
	ScratchServicesDocument* _tmp21_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp1_ = self->priv->text_buffer;
	if (_tmp1_ == NULL) {
		_tmp0_ = TRUE;
	} else {
		ScratchMainWindow* _tmp2_;
		ScratchServicesDocument* _tmp3_;
		ScratchServicesDocument* _tmp4_;
		_tmp2_ = self->priv->_window;
		_tmp3_ = scratch_main_window_get_current_document (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp0_ = _tmp4_ == NULL;
		_g_object_unref0 (_tmp4_);
	}
	if (_tmp0_) {
		g_debug ("SearchBar.vala:318: No valid buffer to replace");
		return;
	}
	_tmp5_ = self->priv->replace_entry;
	_tmp6_ = gtk_entry_get_text ((GtkEntry*) _tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = g_strdup (_tmp7_);
	replace_string = _tmp8_;
	_tmp9_ = self->priv->_window;
	_tmp10_ = scratch_main_window_get_current_document (_tmp9_);
	_tmp11_ = _tmp10_;
	scratch_services_document_toggle_changed_handlers (_tmp11_, FALSE);
	_g_object_unref0 (_tmp11_);
	{
		GtkSourceSearchContext* _tmp12_;
		const gchar* _tmp13_;
		const gchar* _tmp14_;
		gint _tmp15_;
		gint _tmp16_;
		scratch_widgets_search_bar_cancel_update_search_widgets (self);
		_tmp12_ = self->priv->search_context;
		_tmp13_ = replace_string;
		_tmp14_ = replace_string;
		_tmp15_ = strlen (_tmp14_);
		_tmp16_ = _tmp15_;
		gtk_source_search_context_replace_all (_tmp12_, _tmp13_, _tmp16_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		scratch_widgets_search_bar_update_search_widgets (self);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp17_;
		const gchar* _tmp18_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp17_ = e;
		_tmp18_ = _tmp17_->message;
		g_critical ("SearchBar.vala:329: %s", _tmp18_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (replace_string);
		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;
	}
	_tmp19_ = self->priv->_window;
	_tmp20_ = scratch_main_window_get_current_document (_tmp19_);
	_tmp21_ = _tmp20_;
	scratch_services_document_toggle_changed_handlers (_tmp21_, TRUE);
	_g_object_unref0 (_tmp21_);
	_g_free0 (replace_string);
}

static void
scratch_widgets_search_bar_on_search_parameters_changed (ScratchWidgetsSearchBar* self)
{
	GtkSourceSearchContext* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->search_context;
	if (_tmp0_ != NULL) {
		gchar* search_string = NULL;
		GtkSearchEntry* _tmp1_;
		const gchar* _tmp2_;
		const gchar* _tmp3_;
		gchar* _tmp4_;
		GtkSourceSearchContext* _tmp5_;
		GtkSourceSearchSettings* _tmp6_;
		GtkSourceSearchSettings* _tmp7_;
		const gchar* _tmp8_;
		ScratchCaseSensitiveMode case_mode = 0;
		GtkComboBoxText* _tmp9_;
		gint _tmp10_;
		gint _tmp11_;
		GtkSourceSearchContext* _tmp31_;
		GtkSourceSearchSettings* _tmp32_;
		GtkSourceSearchSettings* _tmp33_;
		GraniteSwitchModelButton* _tmp34_;
		gboolean _tmp35_;
		gboolean _tmp36_;
		GtkSourceSearchContext* _tmp37_;
		GtkSourceSearchSettings* _tmp38_;
		GtkSourceSearchSettings* _tmp39_;
		GraniteSwitchModelButton* _tmp40_;
		gboolean _tmp41_;
		gboolean _tmp42_;
		_tmp1_ = self->priv->search_entry;
		_tmp2_ = gtk_entry_get_text ((GtkEntry*) _tmp1_);
		_tmp3_ = _tmp2_;
		_tmp4_ = g_strdup (_tmp3_);
		search_string = _tmp4_;
		_tmp5_ = self->priv->search_context;
		_tmp6_ = gtk_source_search_context_get_settings (_tmp5_);
		_tmp7_ = _tmp6_;
		_tmp8_ = search_string;
		gtk_source_search_settings_set_search_text (_tmp7_, _tmp8_);
		_tmp9_ = self->priv->case_sensitive_search_button;
		_tmp10_ = gtk_combo_box_get_active ((GtkComboBox*) _tmp9_);
		_tmp11_ = _tmp10_;
		case_mode = (ScratchCaseSensitiveMode) _tmp11_;
		switch (case_mode) {
			case SCRATCH_CASE_SENSITIVE_MODE_NEVER:
			{
				GtkSourceSearchContext* _tmp12_;
				GtkSourceSearchSettings* _tmp13_;
				GtkSourceSearchSettings* _tmp14_;
				_tmp12_ = self->priv->search_context;
				_tmp13_ = gtk_source_search_context_get_settings (_tmp12_);
				_tmp14_ = _tmp13_;
				gtk_source_search_settings_set_case_sensitive (_tmp14_, FALSE);
				break;
			}
			case SCRATCH_CASE_SENSITIVE_MODE_MIXED:
			{
				gboolean _tmp15_ = FALSE;
				const gchar* _tmp16_;
				gchar* _tmp17_;
				gchar* _tmp18_;
				const gchar* _tmp19_;
				gboolean _tmp20_;
				GtkSourceSearchContext* _tmp25_;
				GtkSourceSearchSettings* _tmp26_;
				GtkSourceSearchSettings* _tmp27_;
				_tmp16_ = search_string;
				_tmp17_ = g_utf8_strup (_tmp16_, (gssize) -1);
				_tmp18_ = _tmp17_;
				_tmp19_ = search_string;
				_tmp20_ = g_strcmp0 (_tmp18_, _tmp19_) == 0;
				_g_free0 (_tmp18_);
				if (_tmp20_) {
					_tmp15_ = TRUE;
				} else {
					const gchar* _tmp21_;
					gchar* _tmp22_;
					gchar* _tmp23_;
					const gchar* _tmp24_;
					_tmp21_ = search_string;
					_tmp22_ = g_utf8_strdown (_tmp21_, (gssize) -1);
					_tmp23_ = _tmp22_;
					_tmp24_ = search_string;
					_tmp15_ = g_strcmp0 (_tmp23_, _tmp24_) == 0;
					_g_free0 (_tmp23_);
				}
				_tmp25_ = self->priv->search_context;
				_tmp26_ = gtk_source_search_context_get_settings (_tmp25_);
				_tmp27_ = _tmp26_;
				gtk_source_search_settings_set_case_sensitive (_tmp27_, !_tmp15_);
				break;
			}
			case SCRATCH_CASE_SENSITIVE_MODE_ALWAYS:
			{
				GtkSourceSearchContext* _tmp28_;
				GtkSourceSearchSettings* _tmp29_;
				GtkSourceSearchSettings* _tmp30_;
				_tmp28_ = self->priv->search_context;
				_tmp29_ = gtk_source_search_context_get_settings (_tmp28_);
				_tmp30_ = _tmp29_;
				gtk_source_search_settings_set_case_sensitive (_tmp30_, TRUE);
				break;
			}
			default:
			{
				g_assert_not_reached ();
			}
		}
		_tmp31_ = self->priv->search_context;
		_tmp32_ = gtk_source_search_context_get_settings (_tmp31_);
		_tmp33_ = _tmp32_;
		_tmp34_ = self->priv->whole_word_search_button;
		_tmp35_ = gtk_toggle_button_get_active ((GtkToggleButton*) _tmp34_);
		_tmp36_ = _tmp35_;
		gtk_source_search_settings_set_at_word_boundaries (_tmp33_, _tmp36_);
		_tmp37_ = self->priv->search_context;
		_tmp38_ = gtk_source_search_context_get_settings (_tmp37_);
		_tmp39_ = _tmp38_;
		_tmp40_ = self->priv->regex_search_button;
		_tmp41_ = gtk_toggle_button_get_active ((GtkToggleButton*) _tmp40_);
		_tmp42_ = _tmp41_;
		gtk_source_search_settings_set_regex_enabled (_tmp39_, _tmp42_);
		_g_free0 (search_string);
	}
	scratch_widgets_search_bar_update_search_widgets (self);
}

static gboolean
__lambda145_ (ScratchWidgetsSearchBar* self)
{
	GtkSearchEntry* _tmp0_;
	gboolean result;
	scratch_widgets_search_bar_update_search_widgets (self);
	_tmp0_ = self->priv->search_entry;
	gtk_editable_select_region ((GtkEditable*) _tmp0_, 0, -1);
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
___lambda145__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda145_ ((ScratchWidgetsSearchBar*) self);
	return result;
}

static gboolean
scratch_widgets_search_bar_on_search_entry_focused_in (ScratchWidgetsSearchBar* self,
                                                       GdkEventFocus* event)
{
	GtkTextBuffer* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp0_ = self->priv->text_buffer;
	if (_tmp0_ == NULL) {
		result = FALSE;
		return result;
	}
	g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, ___lambda145__gsource_func, g_object_ref (self), g_object_unref);
	result = GDK_EVENT_PROPAGATE;
	return result;
}

gboolean
scratch_widgets_search_bar_search (ScratchWidgetsSearchBar* self)
{
	GtkSearchEntry* _tmp0_;
	GtkSourceSearchContext* _tmp1_;
	GtkSourceSearchContext* _tmp2_;
	GtkSourceSearchContext* _tmp3_;
	GtkTextIter* start_iter = NULL;
	GtkTextIter* end_iter = NULL;
	GtkTextBuffer* _tmp4_;
	GtkTextBuffer* _tmp5_;
	gint _tmp6_;
	gint _tmp7_;
	GtkTextIter _tmp8_ = {0};
	GtkTextIter _tmp9_;
	GtkTextIter* _tmp10_;
	GtkTextIter* _tmp11_;
	GtkTextIter* _tmp12_ = NULL;
	gboolean _tmp13_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->search_entry;
	gtk_widget_grab_focus ((GtkWidget*) _tmp0_);
	_tmp1_ = self->priv->search_context;
	if (_tmp1_ == NULL) {
		result = FALSE;
		return result;
	}
	_tmp2_ = self->priv->search_context;
	gtk_source_search_context_set_highlight (_tmp2_, FALSE);
	if (!scratch_widgets_search_bar_has_matches (self)) {
		g_debug ("SearchBar.vala:385: Can't search anything in a non-existent buffer and" \
"/or without anything to search.");
		result = FALSE;
		return result;
	}
	_tmp3_ = self->priv->search_context;
	gtk_source_search_context_set_highlight (_tmp3_, TRUE);
	_tmp4_ = self->priv->text_buffer;
	_tmp5_ = self->priv->text_buffer;
	g_object_get (_tmp5_, "cursor-position", &_tmp6_, NULL);
	_tmp7_ = _tmp6_;
	gtk_text_buffer_get_iter_at_offset (_tmp4_, &_tmp8_, _tmp7_);
	__vala_GtkTextIter_free0 (start_iter);
	_tmp9_ = _tmp8_;
	_tmp10_ = __vala_GtkTextIter_copy0 (&_tmp9_);
	start_iter = _tmp10_;
	_tmp11_ = start_iter;
	_tmp13_ = scratch_widgets_search_bar_search_for_iter (self, _tmp11_, &_tmp12_);
	__vala_GtkTextIter_free0 (end_iter);
	end_iter = _tmp12_;
	if (_tmp13_) {
		GtkSearchEntry* _tmp14_;
		GtkStyleContext* _tmp15_;
		GtkSearchEntry* _tmp16_;
		_tmp14_ = self->priv->search_entry;
		_tmp15_ = gtk_widget_get_style_context ((GtkWidget*) _tmp14_);
		gtk_style_context_remove_class (_tmp15_, GTK_STYLE_CLASS_ERROR);
		_tmp16_ = self->priv->search_entry;
		g_object_set ((GtkEntry*) _tmp16_, "primary-icon-name", "edit-find-symbolic", NULL);
	} else {
		GtkTextBuffer* _tmp17_;
		GtkTextIter _tmp18_ = {0};
		GtkTextIter _tmp19_;
		GtkTextIter* _tmp20_;
		GtkTextIter* _tmp21_;
		GtkTextIter* _tmp22_ = NULL;
		gboolean _tmp23_;
		_tmp17_ = self->priv->text_buffer;
		gtk_text_buffer_get_start_iter (_tmp17_, &_tmp18_);
		__vala_GtkTextIter_free0 (start_iter);
		_tmp19_ = _tmp18_;
		_tmp20_ = __vala_GtkTextIter_copy0 (&_tmp19_);
		start_iter = _tmp20_;
		_tmp21_ = start_iter;
		_tmp23_ = scratch_widgets_search_bar_search_for_iter (self, _tmp21_, &_tmp22_);
		__vala_GtkTextIter_free0 (end_iter);
		end_iter = _tmp22_;
		if (_tmp23_) {
			GtkSearchEntry* _tmp24_;
			GtkStyleContext* _tmp25_;
			GtkSearchEntry* _tmp26_;
			_tmp24_ = self->priv->search_entry;
			_tmp25_ = gtk_widget_get_style_context ((GtkWidget*) _tmp24_);
			gtk_style_context_remove_class (_tmp25_, GTK_STYLE_CLASS_ERROR);
			_tmp26_ = self->priv->search_entry;
			g_object_set ((GtkEntry*) _tmp26_, "primary-icon-name", "edit-find-symbolic", NULL);
		} else {
			GtkSearchEntry* _tmp27_;
			const gchar* _tmp28_;
			const gchar* _tmp29_;
			GtkTextIter* _tmp30_;
			GtkTextBuffer* _tmp31_;
			GtkTextIter* _tmp32_;
			GtkTextIter* _tmp33_;
			GtkTextIter _tmp34_;
			GtkTextIter _tmp35_;
			GtkSearchEntry* _tmp36_;
			GtkStyleContext* _tmp37_;
			GtkSearchEntry* _tmp38_;
			_tmp27_ = self->priv->search_entry;
			_tmp28_ = gtk_entry_get_text ((GtkEntry*) _tmp27_);
			_tmp29_ = _tmp28_;
			g_debug ("SearchBar.vala:403: Not found: \"%s\"", _tmp29_);
			_tmp30_ = start_iter;
			gtk_text_iter_set_offset (_tmp30_, -1);
			_tmp31_ = self->priv->text_buffer;
			_tmp32_ = start_iter;
			_tmp33_ = start_iter;
			_tmp34_ = *_tmp32_;
			_tmp35_ = *_tmp33_;
			gtk_text_buffer_select_range (_tmp31_, &_tmp34_, &_tmp35_);
			_tmp36_ = self->priv->search_entry;
			_tmp37_ = gtk_widget_get_style_context ((GtkWidget*) _tmp36_);
			gtk_style_context_add_class (_tmp37_, GTK_STYLE_CLASS_ERROR);
			_tmp38_ = self->priv->search_entry;
			g_object_set ((GtkEntry*) _tmp38_, "primary-icon-name", "dialog-error-symbolic", NULL);
			result = FALSE;
			__vala_GtkTextIter_free0 (end_iter);
			__vala_GtkTextIter_free0 (start_iter);
			return result;
		}
	}
	result = TRUE;
	__vala_GtkTextIter_free0 (end_iter);
	__vala_GtkTextIter_free0 (start_iter);
	return result;
}

void
scratch_widgets_search_bar_highlight_none (ScratchWidgetsSearchBar* self)
{
	GtkSourceSearchContext* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->search_context;
	if (_tmp0_ != NULL) {
		GtkSourceSearchContext* _tmp1_;
		_tmp1_ = self->priv->search_context;
		gtk_source_search_context_set_highlight (_tmp1_, FALSE);
	}
}

static gboolean
scratch_widgets_search_bar_has_matches (ScratchWidgetsSearchBar* self)
{
	gboolean _tmp0_ = FALSE;
	GtkTextBuffer* _tmp1_;
	gboolean has_wrapped_around = FALSE;
	GtkTextIter* start_iter = NULL;
	GtkTextIter* end_iter = NULL;
	GtkTextBuffer* _tmp5_;
	GtkTextIter _tmp6_ = {0};
	GtkTextIter _tmp7_;
	GtkTextIter* _tmp8_;
	GtkSourceSearchContext* _tmp9_;
	GtkTextIter* _tmp10_;
	GtkTextIter _tmp11_;
	GtkTextIter _tmp12_ = {0};
	GtkTextIter _tmp13_ = {0};
	gboolean _tmp14_ = FALSE;
	gboolean _tmp15_;
	GtkTextIter _tmp16_;
	GtkTextIter* _tmp17_;
	GtkTextIter _tmp18_;
	GtkTextIter* _tmp19_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp1_ = self->priv->text_buffer;
	if (_tmp1_ == NULL) {
		_tmp0_ = TRUE;
	} else {
		GtkSearchEntry* _tmp2_;
		const gchar* _tmp3_;
		const gchar* _tmp4_;
		_tmp2_ = self->priv->search_entry;
		_tmp3_ = gtk_entry_get_text ((GtkEntry*) _tmp2_);
		_tmp4_ = _tmp3_;
		_tmp0_ = g_strcmp0 (_tmp4_, "") == 0;
	}
	if (_tmp0_) {
		result = FALSE;
		return result;
	}
	_tmp5_ = self->priv->text_buffer;
	gtk_text_buffer_get_start_iter (_tmp5_, &_tmp6_);
	__vala_GtkTextIter_free0 (start_iter);
	_tmp7_ = _tmp6_;
	_tmp8_ = __vala_GtkTextIter_copy0 (&_tmp7_);
	start_iter = _tmp8_;
	_tmp9_ = self->priv->search_context;
	_tmp10_ = start_iter;
	_tmp11_ = *_tmp10_;
	_tmp15_ = gtk_source_search_context_forward (_tmp9_, &_tmp11_, &_tmp12_, &_tmp13_, &_tmp14_);
	__vala_GtkTextIter_free0 (start_iter);
	_tmp16_ = _tmp12_;
	_tmp17_ = __vala_GtkTextIter_copy0 (&_tmp16_);
	start_iter = _tmp17_;
	__vala_GtkTextIter_free0 (end_iter);
	_tmp18_ = _tmp13_;
	_tmp19_ = __vala_GtkTextIter_copy0 (&_tmp18_);
	end_iter = _tmp19_;
	has_wrapped_around = _tmp14_;
	result = _tmp15_;
	__vala_GtkTextIter_free0 (end_iter);
	__vala_GtkTextIter_free0 (start_iter);
	return result;
}

static gboolean
scratch_widgets_search_bar_search_for_iter (ScratchWidgetsSearchBar* self,
                                            GtkTextIter* start_iter,
                                            GtkTextIter** end_iter)
{
	GtkTextIter* _vala_end_iter = NULL;
	GtkTextIter* _tmp0_;
	GtkSourceSearchContext* _tmp1_;
	gboolean has_wrapped_around = FALSE;
	gboolean found = FALSE;
	GtkSourceSearchContext* _tmp2_;
	GtkTextIter _tmp3_;
	GtkTextIter _tmp4_ = {0};
	GtkTextIter _tmp5_ = {0};
	gboolean _tmp6_ = FALSE;
	gboolean _tmp7_;
	GtkTextIter _tmp8_;
	GtkTextIter _tmp9_;
	GtkTextIter* _tmp10_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = __vala_GtkTextIter_copy0 (start_iter);
	__vala_GtkTextIter_free0 (_vala_end_iter);
	_vala_end_iter = _tmp0_;
	_tmp1_ = self->priv->search_context;
	if (_tmp1_ == NULL) {
		g_critical ("SearchBar.vala:436: Trying to search forwards with no search context");
		result = FALSE;
		if (end_iter) {
			*end_iter = _vala_end_iter;
		} else {
			__vala_GtkTextIter_free0 (_vala_end_iter);
		}
		return result;
	}
	_tmp2_ = self->priv->search_context;
	_tmp3_ = *start_iter;
	_tmp7_ = gtk_source_search_context_forward (_tmp2_, &_tmp3_, &_tmp4_, &_tmp5_, &_tmp6_);
	_tmp8_ = _tmp4_;
	start_iter = &_tmp8_;
	__vala_GtkTextIter_free0 (_vala_end_iter);
	_tmp9_ = _tmp5_;
	_tmp10_ = __vala_GtkTextIter_copy0 (&_tmp9_);
	_vala_end_iter = _tmp10_;
	has_wrapped_around = _tmp6_;
	found = _tmp7_;
	if (found) {
		GtkTextBuffer* _tmp11_;
		GtkTextIter* _tmp12_;
		GtkTextIter _tmp13_;
		GtkTextIter _tmp14_;
		ScratchWidgetsSourceView* _tmp15_;
		GtkTextIter _tmp16_;
		_tmp11_ = self->priv->text_buffer;
		_tmp12_ = _vala_end_iter;
		_tmp13_ = *start_iter;
		_tmp14_ = *_tmp12_;
		gtk_text_buffer_select_range (_tmp11_, &_tmp13_, &_tmp14_);
		if (has_wrapped_around) {
			gtk_text_iter_backward_lines (start_iter, 3);
		} else {
			gtk_text_iter_forward_lines (start_iter, 3);
		}
		_tmp15_ = self->priv->text_view;
		_tmp16_ = *start_iter;
		gtk_text_view_scroll_to_iter ((GtkTextView*) _tmp15_, &_tmp16_, (gdouble) 0, FALSE, (gdouble) 0, (gdouble) 0);
	}
	result = found;
	if (end_iter) {
		*end_iter = _vala_end_iter;
	} else {
		__vala_GtkTextIter_free0 (_vala_end_iter);
	}
	return result;
}

static gboolean
scratch_widgets_search_bar_search_for_iter_backward (ScratchWidgetsSearchBar* self,
                                                     GtkTextIter* start_iter,
                                                     GtkTextIter** end_iter)
{
	GtkTextIter* _vala_end_iter = NULL;
	GtkTextIter* _tmp0_;
	GtkSourceSearchContext* _tmp1_;
	gboolean has_wrapped_around = FALSE;
	gboolean found = FALSE;
	GtkSourceSearchContext* _tmp2_;
	GtkTextIter _tmp3_;
	GtkTextIter _tmp4_ = {0};
	GtkTextIter _tmp5_ = {0};
	gboolean _tmp6_ = FALSE;
	gboolean _tmp7_;
	GtkTextIter _tmp8_;
	GtkTextIter _tmp9_;
	GtkTextIter* _tmp10_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = __vala_GtkTextIter_copy0 (start_iter);
	__vala_GtkTextIter_free0 (_vala_end_iter);
	_vala_end_iter = _tmp0_;
	_tmp1_ = self->priv->search_context;
	if (_tmp1_ == NULL) {
		g_critical ("SearchBar.vala:459: Trying to search backwards with no search context");
		result = FALSE;
		if (end_iter) {
			*end_iter = _vala_end_iter;
		} else {
			__vala_GtkTextIter_free0 (_vala_end_iter);
		}
		return result;
	}
	_tmp2_ = self->priv->search_context;
	_tmp3_ = *start_iter;
	_tmp7_ = gtk_source_search_context_backward (_tmp2_, &_tmp3_, &_tmp4_, &_tmp5_, &_tmp6_);
	_tmp8_ = _tmp4_;
	start_iter = &_tmp8_;
	__vala_GtkTextIter_free0 (_vala_end_iter);
	_tmp9_ = _tmp5_;
	_tmp10_ = __vala_GtkTextIter_copy0 (&_tmp9_);
	_vala_end_iter = _tmp10_;
	has_wrapped_around = _tmp6_;
	found = _tmp7_;
	if (found) {
		GtkTextBuffer* _tmp11_;
		GtkTextIter* _tmp12_;
		GtkTextIter _tmp13_;
		GtkTextIter _tmp14_;
		ScratchWidgetsSourceView* _tmp15_;
		GtkTextIter _tmp16_;
		_tmp11_ = self->priv->text_buffer;
		_tmp12_ = _vala_end_iter;
		_tmp13_ = *start_iter;
		_tmp14_ = *_tmp12_;
		gtk_text_buffer_select_range (_tmp11_, &_tmp13_, &_tmp14_);
		if (has_wrapped_around) {
			gtk_text_iter_forward_lines (start_iter, 3);
		} else {
			gtk_text_iter_backward_lines (start_iter, 3);
		}
		_tmp15_ = self->priv->text_view;
		_tmp16_ = *start_iter;
		gtk_text_view_scroll_to_iter ((GtkTextView*) _tmp15_, &_tmp16_, (gdouble) 0, FALSE, (gdouble) 0, (gdouble) 0);
	}
	result = found;
	if (end_iter) {
		*end_iter = _vala_end_iter;
	} else {
		__vala_GtkTextIter_free0 (_vala_end_iter);
	}
	return result;
}

void
scratch_widgets_search_bar_search_previous (ScratchWidgetsSearchBar* self)
{
	GtkTextIter* start_iter = NULL;
	GtkTextIter* end_iter = NULL;
	GtkTextBuffer* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->text_buffer;
	if (_tmp0_ != NULL) {
		GtkTextBuffer* _tmp1_;
		GtkTextIter _tmp2_ = {0};
		GtkTextIter _tmp3_ = {0};
		GtkTextIter _tmp4_;
		GtkTextIter* _tmp5_;
		GtkTextIter _tmp6_;
		GtkTextIter* _tmp7_;
		gboolean _tmp8_ = FALSE;
		GtkTextIter* _tmp9_;
		GtkTextIter* _tmp10_ = NULL;
		gboolean _tmp11_;
		_tmp1_ = self->priv->text_buffer;
		gtk_text_buffer_get_selection_bounds (_tmp1_, &_tmp2_, &_tmp3_);
		__vala_GtkTextIter_free0 (start_iter);
		_tmp4_ = _tmp2_;
		_tmp5_ = __vala_GtkTextIter_copy0 (&_tmp4_);
		start_iter = _tmp5_;
		__vala_GtkTextIter_free0 (end_iter);
		_tmp6_ = _tmp3_;
		_tmp7_ = __vala_GtkTextIter_copy0 (&_tmp6_);
		end_iter = _tmp7_;
		_tmp9_ = start_iter;
		_tmp11_ = scratch_widgets_search_bar_search_for_iter_backward (self, _tmp9_, &_tmp10_);
		__vala_GtkTextIter_free0 (end_iter);
		end_iter = _tmp10_;
		if (!_tmp11_) {
			GraniteSwitchModelButton* _tmp12_;
			gboolean _tmp13_;
			gboolean _tmp14_;
			_tmp12_ = self->priv->cycle_search_button;
			_tmp13_ = gtk_toggle_button_get_active ((GtkToggleButton*) _tmp12_);
			_tmp14_ = _tmp13_;
			_tmp8_ = _tmp14_;
		} else {
			_tmp8_ = FALSE;
		}
		if (_tmp8_) {
			GtkTextBuffer* _tmp15_;
			GtkTextIter _tmp16_ = {0};
			GtkTextIter _tmp17_;
			GtkTextIter* _tmp18_;
			GtkTextIter* _tmp19_;
			GtkTextIter* _tmp20_ = NULL;
			_tmp15_ = self->priv->text_buffer;
			gtk_text_buffer_get_end_iter (_tmp15_, &_tmp16_);
			__vala_GtkTextIter_free0 (start_iter);
			_tmp17_ = _tmp16_;
			_tmp18_ = __vala_GtkTextIter_copy0 (&_tmp17_);
			start_iter = _tmp18_;
			_tmp19_ = start_iter;
			scratch_widgets_search_bar_search_for_iter_backward (self, _tmp19_, &_tmp20_);
			__vala_GtkTextIter_free0 (end_iter);
			end_iter = _tmp20_;
		}
		scratch_widgets_search_bar_update_search_widgets (self);
	}
	__vala_GtkTextIter_free0 (end_iter);
	__vala_GtkTextIter_free0 (start_iter);
}

void
scratch_widgets_search_bar_search_next (ScratchWidgetsSearchBar* self)
{
	GtkTextIter* start_iter = NULL;
	GtkTextIter* end_iter = NULL;
	GtkTextIter* end_iter_tmp = NULL;
	GtkTextBuffer* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->text_buffer;
	if (_tmp0_ != NULL) {
		GtkTextBuffer* _tmp1_;
		GtkTextIter _tmp2_ = {0};
		GtkTextIter _tmp3_ = {0};
		GtkTextIter _tmp4_;
		GtkTextIter* _tmp5_;
		GtkTextIter _tmp6_;
		GtkTextIter* _tmp7_;
		gboolean _tmp8_ = FALSE;
		GtkTextIter* _tmp9_;
		GtkTextIter* _tmp10_ = NULL;
		gboolean _tmp11_;
		_tmp1_ = self->priv->text_buffer;
		gtk_text_buffer_get_selection_bounds (_tmp1_, &_tmp2_, &_tmp3_);
		__vala_GtkTextIter_free0 (start_iter);
		_tmp4_ = _tmp2_;
		_tmp5_ = __vala_GtkTextIter_copy0 (&_tmp4_);
		start_iter = _tmp5_;
		__vala_GtkTextIter_free0 (end_iter);
		_tmp6_ = _tmp3_;
		_tmp7_ = __vala_GtkTextIter_copy0 (&_tmp6_);
		end_iter = _tmp7_;
		_tmp9_ = end_iter;
		_tmp11_ = scratch_widgets_search_bar_search_for_iter (self, _tmp9_, &_tmp10_);
		__vala_GtkTextIter_free0 (end_iter_tmp);
		end_iter_tmp = _tmp10_;
		if (!_tmp11_) {
			GraniteSwitchModelButton* _tmp12_;
			gboolean _tmp13_;
			gboolean _tmp14_;
			_tmp12_ = self->priv->cycle_search_button;
			_tmp13_ = gtk_toggle_button_get_active ((GtkToggleButton*) _tmp12_);
			_tmp14_ = _tmp13_;
			_tmp8_ = _tmp14_;
		} else {
			_tmp8_ = FALSE;
		}
		if (_tmp8_) {
			GtkTextBuffer* _tmp15_;
			GtkTextIter _tmp16_ = {0};
			GtkTextIter _tmp17_;
			GtkTextIter* _tmp18_;
			GtkTextIter* _tmp19_;
			GtkTextIter* _tmp20_ = NULL;
			_tmp15_ = self->priv->text_buffer;
			gtk_text_buffer_get_start_iter (_tmp15_, &_tmp16_);
			__vala_GtkTextIter_free0 (start_iter);
			_tmp17_ = _tmp16_;
			_tmp18_ = __vala_GtkTextIter_copy0 (&_tmp17_);
			start_iter = _tmp18_;
			_tmp19_ = start_iter;
			scratch_widgets_search_bar_search_for_iter (self, _tmp19_, &_tmp20_);
			__vala_GtkTextIter_free0 (end_iter);
			end_iter = _tmp20_;
		}
		scratch_widgets_search_bar_update_search_widgets (self);
	}
	__vala_GtkTextIter_free0 (end_iter_tmp);
	__vala_GtkTextIter_free0 (end_iter);
	__vala_GtkTextIter_free0 (start_iter);
}

void
scratch_widgets_search_bar_focus_search_entry (ScratchWidgetsSearchBar* self)
{
	GtkSearchEntry* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->search_entry;
	gtk_widget_grab_focus ((GtkWidget*) _tmp0_);
}

void
scratch_widgets_search_bar_focus_replace_entry (ScratchWidgetsSearchBar* self)
{
	GtkSearchEntry* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->replace_entry;
	gtk_widget_grab_focus ((GtkWidget*) _tmp0_);
}

void
scratch_widgets_search_bar_reveal (ScratchWidgetsSearchBar* self,
                                   gboolean to_reveal)
{
	GtkRevealer* _tmp0_;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_;
	gboolean _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->revealer;
	gtk_revealer_set_reveal_child (_tmp0_, to_reveal);
	_tmp2_ = scratch_widgets_search_bar_get_is_revealed (self);
	_tmp3_ = _tmp2_;
	if (_tmp3_) {
		_tmp1_ = !to_reveal;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		scratch_widgets_search_bar_set_search_entry_text (self, "");
	}
}

void
scratch_widgets_search_bar_set_search_entry_text (ScratchWidgetsSearchBar* self,
                                                  const gchar* text)
{
	GtkSearchEntry* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (text != NULL);
	_tmp0_ = self->priv->search_entry;
	gtk_entry_set_text ((GtkEntry*) _tmp0_, text);
}

static gboolean
scratch_widgets_search_bar_on_search_entry_key_press (ScratchWidgetsSearchBar* self,
                                                      GdkEventKey* event)
{
	GtkSearchEntry* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* key = NULL;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	const gchar* _tmp7_;
	const gchar* _tmp8_;
	GQuark _tmp10_ = 0U;
	static GQuark _tmp9_label0 = 0;
	static GQuark _tmp9_label1 = 0;
	static GQuark _tmp9_label2 = 0;
	static GQuark _tmp9_label3 = 0;
	static GQuark _tmp9_label4 = 0;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp0_ = self->priv->search_entry;
	_tmp1_ = gtk_entry_get_text ((GtkEntry*) _tmp0_);
	_tmp2_ = _tmp1_;
	if (g_strcmp0 (_tmp2_, "") == 0) {
		result = FALSE;
		return result;
	}
	_tmp3_ = gdk_keyval_name (event->keyval);
	_tmp4_ = g_strdup (_tmp3_);
	key = _tmp4_;
	if ((event->state & GDK_SHIFT_MASK) == GDK_SHIFT_MASK) {
		const gchar* _tmp5_;
		gchar* _tmp6_;
		_tmp5_ = key;
		_tmp6_ = g_strconcat ("<Shift>", _tmp5_, NULL);
		_g_free0 (key);
		key = _tmp6_;
	}
	_tmp7_ = key;
	_tmp8_ = _tmp7_;
	_tmp10_ = (NULL == _tmp8_) ? 0 : g_quark_from_string (_tmp8_);
	if ((_tmp10_ == ((0 != _tmp9_label0) ? _tmp9_label0 : (_tmp9_label0 = g_quark_from_static_string ("<Shift>Return")))) || (_tmp10_ == ((0 != _tmp9_label1) ? _tmp9_label1 : (_tmp9_label1 = g_quark_from_static_string ("Up"))))) {
		switch (0) {
			default:
			{
				scratch_widgets_search_bar_search_previous (self);
				result = TRUE;
				_g_free0 (key);
				return result;
			}
		}
	} else if ((_tmp10_ == ((0 != _tmp9_label2) ? _tmp9_label2 : (_tmp9_label2 = g_quark_from_static_string ("Return")))) || (_tmp10_ == ((0 != _tmp9_label3) ? _tmp9_label3 : (_tmp9_label3 = g_quark_from_static_string ("Down"))))) {
		switch (0) {
			default:
			{
				scratch_widgets_search_bar_search_next (self);
				result = TRUE;
				_g_free0 (key);
				return result;
			}
		}
	} else if (_tmp10_ == ((0 != _tmp9_label4) ? _tmp9_label4 : (_tmp9_label4 = g_quark_from_static_string ("Tab")))) {
		switch (0) {
			default:
			{
				GtkSearchEntry* _tmp11_;
				gboolean _tmp12_;
				gboolean _tmp13_;
				_tmp11_ = self->priv->search_entry;
				g_object_get ((GtkWidget*) _tmp11_, "is-focus", &_tmp12_, NULL);
				_tmp13_ = _tmp12_;
				if (_tmp13_) {
					GtkSearchEntry* _tmp14_;
					_tmp14_ = self->priv->replace_entry;
					gtk_widget_grab_focus ((GtkWidget*) _tmp14_);
				}
				result = TRUE;
				_g_free0 (key);
				return result;
			}
		}
	}
	result = FALSE;
	_g_free0 (key);
	return result;
}

static gboolean
scratch_widgets_search_bar_on_replace_entry_key_press (ScratchWidgetsSearchBar* self,
                                                       GdkEventKey* event)
{
	GtkSearchEntry* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	GQuark _tmp6_ = 0U;
	static GQuark _tmp5_label0 = 0;
	static GQuark _tmp5_label1 = 0;
	static GQuark _tmp5_label2 = 0;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp0_ = self->priv->search_entry;
	_tmp1_ = gtk_entry_get_text ((GtkEntry*) _tmp0_);
	_tmp2_ = _tmp1_;
	if (g_strcmp0 (_tmp2_, "") == 0) {
		result = FALSE;
		return result;
	}
	_tmp3_ = gdk_keyval_name (event->keyval);
	_tmp4_ = _tmp3_;
	_tmp6_ = (NULL == _tmp4_) ? 0 : g_quark_from_string (_tmp4_);
	if (_tmp6_ == ((0 != _tmp5_label0) ? _tmp5_label0 : (_tmp5_label0 = g_quark_from_static_string ("Up")))) {
		switch (0) {
			default:
			{
				scratch_widgets_search_bar_search_previous (self);
				result = TRUE;
				return result;
			}
		}
	} else if (_tmp6_ == ((0 != _tmp5_label1) ? _tmp5_label1 : (_tmp5_label1 = g_quark_from_static_string ("Down")))) {
		switch (0) {
			default:
			{
				scratch_widgets_search_bar_search_next (self);
				result = TRUE;
				return result;
			}
		}
	} else if (_tmp6_ == ((0 != _tmp5_label2) ? _tmp5_label2 : (_tmp5_label2 = g_quark_from_static_string ("Tab")))) {
		switch (0) {
			default:
			{
				GtkSearchEntry* _tmp7_;
				gboolean _tmp8_;
				gboolean _tmp9_;
				_tmp7_ = self->priv->replace_entry;
				g_object_get ((GtkWidget*) _tmp7_, "is-focus", &_tmp8_, NULL);
				_tmp9_ = _tmp8_;
				if (_tmp9_) {
					GtkSearchEntry* _tmp10_;
					_tmp10_ = self->priv->search_entry;
					gtk_widget_grab_focus ((GtkWidget*) _tmp10_);
				}
				result = TRUE;
				return result;
			}
		}
	}
	result = FALSE;
	return result;
}

static void
scratch_widgets_search_bar_cancel_update_search_widgets (ScratchWidgetsSearchBar* self)
{
	g_return_if_fail (self != NULL);
	if (self->priv->update_search_label_timeout_id > ((guint) 0)) {
		g_source_remove (self->priv->update_search_label_timeout_id);
		self->priv->update_search_label_timeout_id = (guint) 0;
	}
}

static gboolean
__lambda144_ (ScratchWidgetsSearchBar* self)
{
	GtkSourceSearchContext* _tmp0_;
	GtkTextIter* iter = NULL;
	GtkTextIter* start_iter = NULL;
	GtkTextIter* end_iter = NULL;
	GtkTextBuffer* _tmp5_;
	GtkTextBuffer* _tmp6_;
	gint _tmp7_;
	gint _tmp8_;
	GtkTextIter _tmp9_ = {0};
	GtkTextIter _tmp10_;
	GtkTextIter* _tmp11_;
	gint count_of_search = 0;
	GtkSourceSearchContext* _tmp12_;
	gint location_of_search = 0;
	gboolean found = FALSE;
	GtkSourceSearchContext* _tmp13_;
	GtkTextIter* _tmp14_;
	GtkTextIter _tmp15_;
	GtkTextIter _tmp16_ = {0};
	GtkTextIter _tmp17_ = {0};
	gboolean _tmp18_;
	GtkTextIter _tmp19_;
	GtkTextIter* _tmp20_;
	GtkTextIter _tmp21_;
	GtkTextIter* _tmp22_;
	gboolean _tmp23_ = FALSE;
	GtkButton* _tmp33_;
	GtkButton* _tmp34_;
	gboolean _tmp35_ = FALSE;
	gboolean _tmp36_ = FALSE;
	GtkTextBuffer* _tmp37_;
	GtkStyleContext* ctx = NULL;
	GtkSearchEntry* _tmp93_;
	GtkStyleContext* _tmp94_;
	GtkStyleContext* _tmp95_;
	gboolean _tmp96_ = FALSE;
	GtkSearchEntry* _tmp97_;
	const gchar* _tmp98_;
	const gchar* _tmp99_;
	gboolean result;
	self->priv->update_search_label_timeout_id = (guint) 0;
	_tmp0_ = self->priv->search_context;
	if (_tmp0_ == NULL) {
		GtkButton* _tmp1_;
		GtkButton* _tmp2_;
		GtkButton* _tmp3_;
		GtkButton* _tmp4_;
		g_debug ("SearchBar.vala:593: update occurrence with null context");
		_tmp1_ = self->priv->replace_tool_button;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp1_, FALSE);
		_tmp2_ = self->priv->replace_all_tool_button;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp2_, FALSE);
		_tmp3_ = self->priv->tool_arrow_up;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp3_, FALSE);
		_tmp4_ = self->priv->tool_arrow_down;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp4_, FALSE);
		result = G_SOURCE_REMOVE;
		return result;
	}
	_tmp5_ = self->priv->text_buffer;
	_tmp6_ = self->priv->text_buffer;
	g_object_get (_tmp6_, "cursor-position", &_tmp7_, NULL);
	_tmp8_ = _tmp7_;
	gtk_text_buffer_get_iter_at_offset (_tmp5_, &_tmp9_, _tmp8_);
	__vala_GtkTextIter_free0 (iter);
	_tmp10_ = _tmp9_;
	_tmp11_ = __vala_GtkTextIter_copy0 (&_tmp10_);
	iter = _tmp11_;
	_tmp12_ = self->priv->search_context;
	count_of_search = gtk_source_search_context_get_occurrences_count (_tmp12_);
	location_of_search = 0;
	_tmp13_ = self->priv->search_context;
	_tmp14_ = iter;
	_tmp15_ = *_tmp14_;
	_tmp18_ = gtk_source_search_context_forward (_tmp13_, &_tmp15_, &_tmp16_, &_tmp17_, NULL);
	__vala_GtkTextIter_free0 (start_iter);
	_tmp19_ = _tmp16_;
	_tmp20_ = __vala_GtkTextIter_copy0 (&_tmp19_);
	start_iter = _tmp20_;
	__vala_GtkTextIter_free0 (end_iter);
	_tmp21_ = _tmp17_;
	_tmp22_ = __vala_GtkTextIter_copy0 (&_tmp21_);
	end_iter = _tmp22_;
	found = _tmp18_;
	if (count_of_search > 0) {
		_tmp23_ = found;
	} else {
		_tmp23_ = FALSE;
	}
	if (_tmp23_) {
		GtkSourceSearchContext* _tmp24_;
		GtkTextIter* _tmp25_;
		GtkTextIter* _tmp26_;
		GtkTextIter _tmp27_;
		GtkTextIter _tmp28_;
		_tmp24_ = self->priv->search_context;
		_tmp25_ = start_iter;
		_tmp26_ = end_iter;
		_tmp27_ = *_tmp25_;
		_tmp28_ = *_tmp26_;
		location_of_search = gtk_source_search_context_get_occurrence_position (_tmp24_, &_tmp27_, &_tmp28_);
	}
	if (count_of_search > -1) {
		if (count_of_search > 0) {
			GtkLabel* _tmp29_;
			gchar* _tmp30_;
			gchar* _tmp31_;
			_tmp29_ = self->priv->search_occurence_count_label;
			_tmp30_ = g_strdup_printf (_ ("%d of %d"), location_of_search, count_of_search);
			_tmp31_ = _tmp30_;
			gtk_label_set_label (_tmp29_, _tmp31_);
			_g_free0 (_tmp31_);
		} else {
			GtkLabel* _tmp32_;
			_tmp32_ = self->priv->search_occurence_count_label;
			gtk_label_set_label (_tmp32_, _ ("no results"));
		}
	}
	_tmp33_ = self->priv->replace_tool_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp33_, location_of_search > 0);
	_tmp34_ = self->priv->replace_all_tool_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp34_, count_of_search > 0);
	_tmp37_ = self->priv->text_buffer;
	if (_tmp37_ == NULL) {
		_tmp36_ = TRUE;
	} else {
		GtkSearchEntry* _tmp38_;
		const gchar* _tmp39_;
		const gchar* _tmp40_;
		_tmp38_ = self->priv->search_entry;
		_tmp39_ = gtk_entry_get_text ((GtkEntry*) _tmp38_);
		_tmp40_ = _tmp39_;
		_tmp36_ = g_strcmp0 (_tmp40_, "") == 0;
	}
	if (_tmp36_) {
		_tmp35_ = TRUE;
	} else {
		_tmp35_ = count_of_search == 0;
	}
	if (_tmp35_) {
		GtkButton* _tmp41_;
		GtkButton* _tmp42_;
		_tmp41_ = self->priv->tool_arrow_up;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp41_, FALSE);
		_tmp42_ = self->priv->tool_arrow_down;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp42_, FALSE);
	} else {
		GraniteSwitchModelButton* _tmp43_;
		gboolean _tmp44_;
		gboolean _tmp45_;
		_tmp43_ = self->priv->cycle_search_button;
		_tmp44_ = gtk_toggle_button_get_active ((GtkToggleButton*) _tmp43_);
		_tmp45_ = _tmp44_;
		if (_tmp45_) {
			GtkButton* _tmp46_;
			GtkButton* _tmp47_;
			_tmp46_ = self->priv->tool_arrow_down;
			gtk_widget_set_sensitive ((GtkWidget*) _tmp46_, TRUE);
			_tmp47_ = self->priv->tool_arrow_up;
			gtk_widget_set_sensitive ((GtkWidget*) _tmp47_, TRUE);
		} else {
			GtkTextIter* tmp_start_iter = NULL;
			GtkTextIter* tmp_end_iter = NULL;
			gboolean is_in_start = FALSE;
			gboolean is_in_end = FALSE;
			GtkTextBuffer* _tmp48_;
			GtkTextIter _tmp49_ = {0};
			GtkTextIter _tmp50_;
			GtkTextIter* _tmp51_;
			GtkTextBuffer* _tmp52_;
			GtkTextIter _tmp53_ = {0};
			GtkTextIter _tmp54_;
			GtkTextIter* _tmp55_;
			GtkTextBuffer* _tmp56_;
			GtkTextIter _tmp57_ = {0};
			GtkTextIter _tmp58_ = {0};
			GtkTextIter _tmp59_;
			GtkTextIter* _tmp60_;
			GtkTextIter _tmp61_;
			GtkTextIter* _tmp62_;
			GtkTextIter* _tmp63_;
			GtkTextIter* _tmp64_;
			GtkTextIter _tmp65_;
			GtkTextIter* _tmp66_;
			GtkTextIter* _tmp67_;
			GtkTextIter _tmp68_;
			_tmp48_ = self->priv->text_buffer;
			gtk_text_buffer_get_start_iter (_tmp48_, &_tmp49_);
			__vala_GtkTextIter_free0 (tmp_start_iter);
			_tmp50_ = _tmp49_;
			_tmp51_ = __vala_GtkTextIter_copy0 (&_tmp50_);
			tmp_start_iter = _tmp51_;
			_tmp52_ = self->priv->text_buffer;
			gtk_text_buffer_get_end_iter (_tmp52_, &_tmp53_);
			__vala_GtkTextIter_free0 (tmp_end_iter);
			_tmp54_ = _tmp53_;
			_tmp55_ = __vala_GtkTextIter_copy0 (&_tmp54_);
			tmp_end_iter = _tmp55_;
			_tmp56_ = self->priv->text_buffer;
			gtk_text_buffer_get_selection_bounds (_tmp56_, &_tmp57_, &_tmp58_);
			__vala_GtkTextIter_free0 (start_iter);
			_tmp59_ = _tmp57_;
			_tmp60_ = __vala_GtkTextIter_copy0 (&_tmp59_);
			start_iter = _tmp60_;
			__vala_GtkTextIter_free0 (end_iter);
			_tmp61_ = _tmp58_;
			_tmp62_ = __vala_GtkTextIter_copy0 (&_tmp61_);
			end_iter = _tmp62_;
			_tmp63_ = start_iter;
			_tmp64_ = tmp_start_iter;
			_tmp65_ = *_tmp64_;
			is_in_start = gtk_text_iter_compare (_tmp63_, &_tmp65_) == 0;
			_tmp66_ = end_iter;
			_tmp67_ = tmp_end_iter;
			_tmp68_ = *_tmp67_;
			is_in_end = gtk_text_iter_compare (_tmp66_, &_tmp68_) == 0;
			if (!is_in_end) {
				GtkButton* _tmp69_;
				GtkSourceSearchContext* _tmp70_;
				GtkTextIter* _tmp71_;
				GtkTextIter _tmp72_;
				GtkTextIter _tmp73_ = {0};
				GtkTextIter _tmp74_ = {0};
				gboolean _tmp75_;
				GtkTextIter _tmp76_;
				GtkTextIter* _tmp77_;
				GtkTextIter _tmp78_;
				GtkTextIter* _tmp79_;
				_tmp69_ = self->priv->tool_arrow_down;
				_tmp70_ = self->priv->search_context;
				_tmp71_ = end_iter;
				_tmp72_ = *_tmp71_;
				_tmp75_ = gtk_source_search_context_forward (_tmp70_, &_tmp72_, &_tmp73_, &_tmp74_, NULL);
				__vala_GtkTextIter_free0 (tmp_start_iter);
				_tmp76_ = _tmp73_;
				_tmp77_ = __vala_GtkTextIter_copy0 (&_tmp76_);
				tmp_start_iter = _tmp77_;
				__vala_GtkTextIter_free0 (tmp_end_iter);
				_tmp78_ = _tmp74_;
				_tmp79_ = __vala_GtkTextIter_copy0 (&_tmp78_);
				tmp_end_iter = _tmp79_;
				gtk_widget_set_sensitive ((GtkWidget*) _tmp69_, _tmp75_);
			} else {
				GtkButton* _tmp80_;
				_tmp80_ = self->priv->tool_arrow_down;
				gtk_widget_set_sensitive ((GtkWidget*) _tmp80_, FALSE);
			}
			if (!is_in_start) {
				GtkButton* _tmp81_;
				GtkSourceSearchContext* _tmp82_;
				GtkTextIter* _tmp83_;
				GtkTextIter _tmp84_;
				GtkTextIter _tmp85_ = {0};
				GtkTextIter _tmp86_ = {0};
				gboolean _tmp87_;
				GtkTextIter _tmp88_;
				GtkTextIter* _tmp89_;
				GtkTextIter _tmp90_;
				GtkTextIter* _tmp91_;
				_tmp81_ = self->priv->tool_arrow_up;
				_tmp82_ = self->priv->search_context;
				_tmp83_ = start_iter;
				_tmp84_ = *_tmp83_;
				_tmp87_ = gtk_source_search_context_backward (_tmp82_, &_tmp84_, &_tmp85_, &_tmp86_, NULL);
				__vala_GtkTextIter_free0 (tmp_start_iter);
				_tmp88_ = _tmp85_;
				_tmp89_ = __vala_GtkTextIter_copy0 (&_tmp88_);
				tmp_start_iter = _tmp89_;
				__vala_GtkTextIter_free0 (end_iter);
				_tmp90_ = _tmp86_;
				_tmp91_ = __vala_GtkTextIter_copy0 (&_tmp90_);
				end_iter = _tmp91_;
				gtk_widget_set_sensitive ((GtkWidget*) _tmp81_, _tmp87_);
			} else {
				GtkButton* _tmp92_;
				_tmp92_ = self->priv->tool_arrow_up;
				gtk_widget_set_sensitive ((GtkWidget*) _tmp92_, FALSE);
			}
			__vala_GtkTextIter_free0 (tmp_end_iter);
			__vala_GtkTextIter_free0 (tmp_start_iter);
		}
	}
	_tmp93_ = self->priv->search_entry;
	_tmp94_ = gtk_widget_get_style_context ((GtkWidget*) _tmp93_);
	_tmp95_ = _g_object_ref0 (_tmp94_);
	ctx = _tmp95_;
	_tmp97_ = self->priv->search_entry;
	_tmp98_ = gtk_entry_get_text ((GtkEntry*) _tmp97_);
	_tmp99_ = _tmp98_;
	if (g_strcmp0 (_tmp99_, "") != 0) {
		_tmp96_ = count_of_search == 0;
	} else {
		_tmp96_ = FALSE;
	}
	if (_tmp96_) {
		GtkStyleContext* _tmp100_;
		GtkSearchEntry* _tmp101_;
		_tmp100_ = ctx;
		gtk_style_context_add_class (_tmp100_, GTK_STYLE_CLASS_ERROR);
		_tmp101_ = self->priv->search_entry;
		g_object_set ((GtkEntry*) _tmp101_, "primary-icon-name", "dialog-error-symbolic", NULL);
	} else {
		GtkStyleContext* _tmp102_;
		_tmp102_ = ctx;
		if (gtk_style_context_has_class (_tmp102_, GTK_STYLE_CLASS_ERROR)) {
			GtkStyleContext* _tmp103_;
			GtkSearchEntry* _tmp104_;
			_tmp103_ = ctx;
			gtk_style_context_remove_class (_tmp103_, GTK_STYLE_CLASS_ERROR);
			_tmp104_ = self->priv->search_entry;
			g_object_set ((GtkEntry*) _tmp104_, "primary-icon-name", "edit-find-symbolic", NULL);
		}
	}
	result = G_SOURCE_REMOVE;
	_g_object_unref0 (ctx);
	__vala_GtkTextIter_free0 (end_iter);
	__vala_GtkTextIter_free0 (start_iter);
	__vala_GtkTextIter_free0 (iter);
	return result;
}

static gboolean
___lambda144__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda144_ ((ScratchWidgetsSearchBar*) self);
	return result;
}

static void
scratch_widgets_search_bar_update_search_widgets (ScratchWidgetsSearchBar* self)
{
	g_return_if_fail (self != NULL);
	scratch_widgets_search_bar_cancel_update_search_widgets (self);
	self->priv->update_search_label_timeout_id = g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 100, ___lambda144__gsource_func, g_object_ref (self), g_object_unref);
}

ScratchMainWindow*
scratch_widgets_search_bar_get_window (ScratchWidgetsSearchBar* self)
{
	ScratchMainWindow* result;
	ScratchMainWindow* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_window;
	result = _tmp0_;
	return result;
}

static void
scratch_widgets_search_bar_set_window (ScratchWidgetsSearchBar* self,
                                       ScratchMainWindow* value)
{
	ScratchMainWindow* old_value;
	g_return_if_fail (self != NULL);
	old_value = scratch_widgets_search_bar_get_window (self);
	if (old_value != value) {
		self->priv->_window = value;
		g_object_notify_by_pspec ((GObject *) self, scratch_widgets_search_bar_properties[SCRATCH_WIDGETS_SEARCH_BAR_WINDOW_PROPERTY]);
	}
}

gboolean
scratch_widgets_search_bar_get_is_focused (ScratchWidgetsSearchBar* self)
{
	gboolean result;
	gboolean _tmp0_ = FALSE;
	GtkSearchEntry* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp1_ = self->priv->search_entry;
	g_object_get ((GtkWidget*) _tmp1_, "has-focus", &_tmp2_, NULL);
	_tmp3_ = _tmp2_;
	if (_tmp3_) {
		_tmp0_ = TRUE;
	} else {
		GtkSearchEntry* _tmp4_;
		gboolean _tmp5_;
		gboolean _tmp6_;
		_tmp4_ = self->priv->replace_entry;
		g_object_get ((GtkWidget*) _tmp4_, "has-focus", &_tmp5_, NULL);
		_tmp6_ = _tmp5_;
		_tmp0_ = _tmp6_;
	}
	result = _tmp0_;
	return result;
}

gboolean
scratch_widgets_search_bar_get_is_revealed (ScratchWidgetsSearchBar* self)
{
	gboolean result;
	GtkRevealer* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->revealer;
	_tmp1_ = gtk_revealer_get_child_revealed (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

const gchar*
scratch_widgets_search_bar_get_entry_text (ScratchWidgetsSearchBar* self)
{
	const gchar* result;
	GtkSearchEntry* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->search_entry;
	_tmp1_ = gtk_entry_get_text ((GtkEntry*) _tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

guint
scratch_widgets_search_bar_get_search_occurrences (ScratchWidgetsSearchBar* self)
{
	guint result;
	gboolean _tmp0_ = FALSE;
	GtkSourceSearchContext* _tmp1_;
	g_return_val_if_fail (self != NULL, 0U);
	_tmp1_ = self->priv->search_context;
	if (_tmp1_ == NULL) {
		_tmp0_ = TRUE;
	} else {
		GtkSourceSearchContext* _tmp2_;
		GtkSourceSearchSettings* _tmp3_;
		GtkSourceSearchSettings* _tmp4_;
		const gchar* _tmp5_;
		const gchar* _tmp6_;
		_tmp2_ = self->priv->search_context;
		_tmp3_ = gtk_source_search_context_get_settings (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp5_ = gtk_source_search_settings_get_search_text (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp0_ = g_strcmp0 (_tmp6_, "") == 0;
	}
	if (_tmp0_) {
		result = (guint) 0;
		return result;
	} else {
		GtkSourceSearchContext* _tmp7_;
		_tmp7_ = self->priv->search_context;
		result = (guint) gtk_source_search_context_get_occurrences_count (_tmp7_);
		return result;
	}
}

guint
scratch_widgets_search_bar_get_transition_time_msec (ScratchWidgetsSearchBar* self)
{
	guint result;
	GtkRevealer* _tmp0_;
	guint _tmp1_;
	guint _tmp2_;
	g_return_val_if_fail (self != NULL, 0U);
	_tmp0_ = self->priv->revealer;
	_tmp1_ = gtk_revealer_get_transition_duration (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_ + 10;
	return result;
}

static void
_scratch_widgets_search_bar_search_next_gtk_button_clicked (GtkButton* _sender,
                                                            gpointer self)
{
	scratch_widgets_search_bar_search_next ((ScratchWidgetsSearchBar*) self);
}

static void
_scratch_widgets_search_bar_search_previous_gtk_button_clicked (GtkButton* _sender,
                                                                gpointer self)
{
	scratch_widgets_search_bar_search_previous ((ScratchWidgetsSearchBar*) self);
}

static void
_scratch_widgets_search_bar_on_search_parameters_changed_gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                                                                    gpointer self)
{
	scratch_widgets_search_bar_on_search_parameters_changed ((ScratchWidgetsSearchBar*) self);
}

static void
_scratch_widgets_search_bar_on_search_parameters_changed_gtk_combo_box_changed (GtkComboBox* _sender,
                                                                                gpointer self)
{
	scratch_widgets_search_bar_on_search_parameters_changed ((ScratchWidgetsSearchBar*) self);
}

static void
_scratch_widgets_search_bar_on_replace_entry_activate_gtk_button_clicked (GtkButton* _sender,
                                                                          gpointer self)
{
	scratch_widgets_search_bar_on_replace_entry_activate ((ScratchWidgetsSearchBar*) self);
}

static void
_scratch_widgets_search_bar_on_replace_all_entry_activate_gtk_button_clicked (GtkButton* _sender,
                                                                              gpointer self)
{
	scratch_widgets_search_bar_on_replace_all_entry_activate ((ScratchWidgetsSearchBar*) self);
}

static void
_scratch_widgets_search_bar_on_search_parameters_changed_gtk_editable_changed (GtkEditable* _sender,
                                                                               gpointer self)
{
	scratch_widgets_search_bar_on_search_parameters_changed ((ScratchWidgetsSearchBar*) self);
}

static gboolean
_scratch_widgets_search_bar_on_search_entry_key_press_gtk_widget_key_press_event (GtkWidget* _sender,
                                                                                  GdkEventKey* event,
                                                                                  gpointer self)
{
	gboolean result;
	result = scratch_widgets_search_bar_on_search_entry_key_press ((ScratchWidgetsSearchBar*) self, event);
	return result;
}

static gboolean
_scratch_widgets_search_bar_on_search_entry_focused_in_gtk_widget_focus_in_event (GtkWidget* _sender,
                                                                                  GdkEventFocus* event,
                                                                                  gpointer self)
{
	gboolean result;
	result = scratch_widgets_search_bar_on_search_entry_focused_in ((ScratchWidgetsSearchBar*) self, event);
	return result;
}

static void
_scratch_widgets_search_bar___lambda146_ (ScratchWidgetsSearchBar* self,
                                          GtkEntryIconPosition p0,
                                          GdkEvent* p1)
{
	g_return_if_fail (p1 != NULL);
	if (p0 == GTK_ENTRY_ICON_PRIMARY) {
		scratch_widgets_search_bar_search_next (self);
	}
}

static void
__scratch_widgets_search_bar___lambda146__gtk_entry_icon_release (GtkEntry* _sender,
                                                                  GtkEntryIconPosition icon_pos,
                                                                  GdkEvent* event,
                                                                  gpointer self)
{
	_scratch_widgets_search_bar___lambda146_ ((ScratchWidgetsSearchBar*) self, icon_pos, event);
}

static void
_scratch_widgets_search_bar_on_replace_entry_activate_gtk_entry_activate (GtkEntry* _sender,
                                                                          gpointer self)
{
	scratch_widgets_search_bar_on_replace_entry_activate ((ScratchWidgetsSearchBar*) self);
}

static gboolean
_scratch_widgets_search_bar_on_replace_entry_key_press_gtk_widget_key_press_event (GtkWidget* _sender,
                                                                                   GdkEventKey* event,
                                                                                   gpointer self)
{
	gboolean result;
	result = scratch_widgets_search_bar_on_replace_entry_key_press ((ScratchWidgetsSearchBar*) self, event);
	return result;
}

static GObject *
scratch_widgets_search_bar_constructor (GType type,
                                        guint n_construct_properties,
                                        GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	ScratchWidgetsSearchBar * self;
	gchar* _tmp0_;
	GtkSearchEntry* _tmp1_ = NULL;
	GtkLabel* _tmp2_;
	GtkLabel* _tmp3_;
	GtkStyleContext* _tmp4_;
	ScratchApplication* app_instance = NULL;
	GApplication* _tmp5_;
	ScratchApplication* _tmp6_;
	GtkButton* _tmp7_;
	GtkButton* _tmp8_;
	GtkButton* _tmp9_;
	GtkButton* _tmp10_;
	ScratchApplication* _tmp11_;
	gchar** _tmp12_;
	gchar** _tmp13_;
	gchar** _tmp14_;
	gint _tmp14__length1;
	gchar* _tmp15_;
	gchar* _tmp16_;
	GtkButton* _tmp17_;
	GtkButton* _tmp18_;
	GtkButton* _tmp19_;
	GtkButton* _tmp20_;
	ScratchApplication* _tmp21_;
	gchar** _tmp22_;
	gchar** _tmp23_;
	gchar** _tmp24_;
	gint _tmp24__length1;
	gchar* _tmp25_;
	gchar* _tmp26_;
	GraniteSwitchModelButton* _tmp27_;
	GtkComboBoxText* _tmp28_;
	GtkComboBoxText* _tmp29_;
	GtkComboBoxText* _tmp30_;
	GtkComboBoxText* _tmp31_;
	GtkComboBoxText* _tmp32_;
	GtkLabel* case_sensitive_search_label = NULL;
	GtkLabel* _tmp33_;
	GtkBox* case_sensitive_box = NULL;
	GtkBox* _tmp34_;
	GtkBox* _tmp35_;
	GtkLabel* _tmp36_;
	GtkBox* _tmp37_;
	GtkComboBoxText* _tmp38_;
	GtkBox* _tmp39_;
	GtkStyleContext* _tmp40_;
	GraniteSwitchModelButton* _tmp41_;
	GraniteSwitchModelButton* _tmp42_;
	GtkBox* search_option_box = NULL;
	GtkBox* _tmp43_ = NULL;
	GtkBox* _tmp44_;
	GraniteSwitchModelButton* _tmp45_;
	GtkBox* _tmp46_;
	GtkBox* _tmp47_;
	GtkBox* _tmp48_;
	GraniteSwitchModelButton* _tmp49_;
	GtkBox* _tmp50_;
	GraniteSwitchModelButton* _tmp51_;
	GtkPopover* search_popover = NULL;
	GtkPopover* _tmp52_;
	GtkPopover* _tmp53_;
	GtkBox* _tmp54_;
	GtkPopover* _tmp55_;
	GtkBox* search_buttonbox = NULL;
	GtkBox* _tmp56_;
	GtkBox* _tmp57_;
	GtkLabel* _tmp58_;
	GtkBox* _tmp59_;
	GtkImage* _tmp60_;
	GtkImage* _tmp61_;
	GtkMenuButton* search_menubutton = NULL;
	GtkPopover* _tmp62_;
	GtkPopover* _tmp63_;
	gchar* _tmp64_;
	GtkMenuButton* _tmp65_ = NULL;
	GtkMenuButton* _tmp66_;
	GtkBox* _tmp67_;
	GraniteSwitchModelButton* _tmp68_;
	GtkComboBoxText* _tmp69_;
	GraniteSwitchModelButton* _tmp70_;
	GraniteSwitchModelButton* _tmp71_;
	GSettings* _tmp72_;
	GraniteSwitchModelButton* _tmp73_;
	GSettings* _tmp74_;
	GraniteSwitchModelButton* _tmp75_;
	GSettings* _tmp76_;
	GtkComboBoxText* _tmp77_;
	GSettings* _tmp78_;
	GraniteSwitchModelButton* _tmp79_;
	GraniteSwitchModelButton* _tmp80_;
	GraniteSwitchModelButton* _tmp81_;
	GraniteSwitchModelButton* _tmp82_;
	GraniteSwitchModelButton* _tmp83_;
	GraniteSwitchModelButton* _tmp84_;
	GtkLabel* _tmp85_;
	GraniteSwitchModelButton* _tmp86_;
	GtkComboBoxText* _tmp87_;
	GtkBox* search_box = NULL;
	GtkBox* _tmp88_ = NULL;
	GtkBox* _tmp89_;
	GtkStyleContext* _tmp90_;
	GtkBox* _tmp91_;
	GtkSearchEntry* _tmp92_;
	GtkBox* _tmp93_;
	GtkButton* _tmp94_;
	GtkBox* _tmp95_;
	GtkButton* _tmp96_;
	GtkBox* _tmp97_;
	GtkMenuButton* _tmp98_;
	GtkFlowBoxChild* search_flow_box_child = NULL;
	GtkFlowBoxChild* _tmp99_;
	GtkFlowBoxChild* _tmp100_;
	GtkFlowBoxChild* _tmp101_;
	GtkBox* _tmp102_;
	GtkSearchEntry* _tmp103_;
	GtkSearchEntry* _tmp104_;
	GtkSearchEntry* _tmp105_;
	GtkSearchEntry* _tmp106_;
	GtkButton* _tmp107_;
	GtkButton* _tmp108_;
	GtkButton* _tmp109_;
	GtkButton* _tmp110_;
	GtkGrid* replace_grid = NULL;
	GtkGrid* _tmp111_ = NULL;
	GtkGrid* _tmp112_;
	GtkStyleContext* _tmp113_;
	GtkGrid* _tmp114_;
	GtkSearchEntry* _tmp115_;
	GtkGrid* _tmp116_;
	GtkButton* _tmp117_;
	GtkGrid* _tmp118_;
	GtkButton* _tmp119_;
	GtkFlowBoxChild* replace_flow_box_child = NULL;
	GtkFlowBoxChild* _tmp120_;
	GtkFlowBoxChild* _tmp121_;
	GtkFlowBoxChild* _tmp122_;
	GtkGrid* _tmp123_;
	GtkSearchEntry* _tmp124_;
	GtkSearchEntry* _tmp125_;
	GtkSearchEntry* _tmp126_;
	GtkSearchEntry* _tmp127_;
	GtkSearchEntry* _tmp128_;
	GtkSearchEntry* _tmp129_;
	GtkWidgetPath* entry_path = NULL;
	GtkWidgetPath* _tmp130_;
	GtkWidgetPath* _tmp131_;
	GtkStyleContext* entry_context = NULL;
	GtkStyleContext* _tmp132_;
	GtkStyleContext* _tmp133_;
	GtkWidgetPath* _tmp134_;
	GtkStyleContext* _tmp135_;
	GtkFlowBox* flowbox = NULL;
	GtkFlowBox* _tmp136_ = NULL;
	GtkFlowBox* _tmp137_;
	GtkStyleContext* _tmp138_;
	GtkFlowBox* _tmp139_;
	GtkFlowBoxChild* _tmp140_;
	GtkFlowBox* _tmp141_;
	GtkFlowBoxChild* _tmp142_;
	GtkFlowBox* _tmp143_;
	GtkWidget* _tmp144_;
	GtkRevealer* _tmp145_ = NULL;
	GtkRevealer* _tmp146_;
	parent_class = G_OBJECT_CLASS (scratch_widgets_search_bar_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SCRATCH_WIDGETS_TYPE_SEARCH_BAR, ScratchWidgetsSearchBar);
	gtk_orientable_set_orientation ((GtkOrientable*) self, GTK_ORIENTATION_HORIZONTAL);
	_tmp0_ = g_strdup (_ ("Find"));
	_tmp1_ = (GtkSearchEntry*) gtk_search_entry_new ();
	gtk_widget_set_hexpand ((GtkWidget*) _tmp1_, TRUE);
	gtk_entry_set_placeholder_text ((GtkEntry*) _tmp1_, _tmp0_);
	_g_free0 (_tmp0_);
	g_object_ref_sink (_tmp1_);
	_g_object_unref0 (self->priv->search_entry);
	self->priv->search_entry = _tmp1_;
	_tmp2_ = (GtkLabel*) gtk_label_new (_ ("No Results"));
	g_object_ref_sink (_tmp2_);
	_g_object_unref0 (self->priv->search_occurence_count_label);
	self->priv->search_occurence_count_label = _tmp2_;
	_tmp3_ = self->priv->search_occurence_count_label;
	_tmp4_ = gtk_widget_get_style_context ((GtkWidget*) _tmp3_);
	gtk_style_context_add_class (_tmp4_, GRANITE_STYLE_CLASS_SMALL_LABEL);
	_tmp5_ = g_application_get_default ();
	_tmp6_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, SCRATCH_TYPE_APPLICATION, ScratchApplication));
	app_instance = _tmp6_;
	_tmp7_ = (GtkButton*) gtk_button_new_from_icon_name ("go-down-symbolic", (GtkIconSize) GTK_ICON_SIZE_SMALL_TOOLBAR);
	g_object_ref_sink (_tmp7_);
	_g_object_unref0 (self->priv->tool_arrow_down);
	self->priv->tool_arrow_down = _tmp7_;
	_tmp8_ = self->priv->tool_arrow_down;
	g_signal_connect_object (_tmp8_, "clicked", (GCallback) _scratch_widgets_search_bar_search_next_gtk_button_clicked, self, 0);
	_tmp9_ = self->priv->tool_arrow_down;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp9_, FALSE);
	_tmp10_ = self->priv->tool_arrow_down;
	_tmp11_ = app_instance;
	_tmp13_ = _tmp12_ = gtk_application_get_accels_for_action ((GtkApplication*) _tmp11_, SCRATCH_MAIN_WINDOW_ACTION_PREFIX SCRATCH_MAIN_WINDOW_ACTION_FIND_NEXT);
	_tmp14_ = _tmp13_;
	_tmp14__length1 = _vala_array_length (_tmp12_);
	_tmp15_ = granite_markup_accel_tooltip (_tmp14_, (gint) _vala_array_length (_tmp12_), _ ("Search next"));
	_tmp16_ = _tmp15_;
	gtk_widget_set_tooltip_markup ((GtkWidget*) _tmp10_, _tmp16_);
	_g_free0 (_tmp16_);
	_tmp14_ = (_vala_array_free (_tmp14_, _tmp14__length1, (GDestroyNotify) g_free), NULL);
	_tmp17_ = (GtkButton*) gtk_button_new_from_icon_name ("go-up-symbolic", (GtkIconSize) GTK_ICON_SIZE_SMALL_TOOLBAR);
	g_object_ref_sink (_tmp17_);
	_g_object_unref0 (self->priv->tool_arrow_up);
	self->priv->tool_arrow_up = _tmp17_;
	_tmp18_ = self->priv->tool_arrow_up;
	g_signal_connect_object (_tmp18_, "clicked", (GCallback) _scratch_widgets_search_bar_search_previous_gtk_button_clicked, self, 0);
	_tmp19_ = self->priv->tool_arrow_up;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp19_, FALSE);
	_tmp20_ = self->priv->tool_arrow_up;
	_tmp21_ = app_instance;
	_tmp23_ = _tmp22_ = gtk_application_get_accels_for_action ((GtkApplication*) _tmp21_, SCRATCH_MAIN_WINDOW_ACTION_PREFIX SCRATCH_MAIN_WINDOW_ACTION_FIND_PREVIOUS);
	_tmp24_ = _tmp23_;
	_tmp24__length1 = _vala_array_length (_tmp22_);
	_tmp25_ = granite_markup_accel_tooltip (_tmp24_, (gint) _vala_array_length (_tmp22_), _ ("Search previous"));
	_tmp26_ = _tmp25_;
	gtk_widget_set_tooltip_markup ((GtkWidget*) _tmp20_, _tmp26_);
	_g_free0 (_tmp26_);
	_tmp24_ = (_vala_array_free (_tmp24_, _tmp24__length1, (GDestroyNotify) g_free), NULL);
	_tmp27_ = granite_switch_model_button_new (_ ("Cyclic Search"));
	g_object_ref_sink (_tmp27_);
	_g_object_unref0 (self->priv->cycle_search_button);
	self->priv->cycle_search_button = _tmp27_;
	_tmp28_ = (GtkComboBoxText*) gtk_combo_box_text_new ();
	g_object_ref_sink (_tmp28_);
	_g_object_unref0 (self->priv->case_sensitive_search_button);
	self->priv->case_sensitive_search_button = _tmp28_;
	_tmp29_ = self->priv->case_sensitive_search_button;
	gtk_combo_box_text_append (_tmp29_, "never", _ ("Never"));
	_tmp30_ = self->priv->case_sensitive_search_button;
	gtk_combo_box_text_append (_tmp30_, "mixed", _ ("Mixed Case"));
	_tmp31_ = self->priv->case_sensitive_search_button;
	gtk_combo_box_text_append (_tmp31_, "always", _ ("Always"));
	_tmp32_ = self->priv->case_sensitive_search_button;
	gtk_combo_box_set_active ((GtkComboBox*) _tmp32_, 1);
	_tmp33_ = (GtkLabel*) gtk_label_new (_ ("Case Sensitive"));
	g_object_ref_sink (_tmp33_);
	case_sensitive_search_label = _tmp33_;
	_tmp34_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
	g_object_ref_sink (_tmp34_);
	case_sensitive_box = _tmp34_;
	_tmp35_ = case_sensitive_box;
	_tmp36_ = case_sensitive_search_label;
	gtk_container_add ((GtkContainer*) _tmp35_, (GtkWidget*) _tmp36_);
	_tmp37_ = case_sensitive_box;
	_tmp38_ = self->priv->case_sensitive_search_button;
	gtk_container_add ((GtkContainer*) _tmp37_, (GtkWidget*) _tmp38_);
	_tmp39_ = case_sensitive_box;
	_tmp40_ = gtk_widget_get_style_context ((GtkWidget*) _tmp39_);
	gtk_style_context_add_class (_tmp40_, GTK_STYLE_CLASS_MENUITEM);
	_tmp41_ = granite_switch_model_button_new (_ ("Use Regular Expressions"));
	g_object_ref_sink (_tmp41_);
	_g_object_unref0 (self->priv->regex_search_button);
	self->priv->regex_search_button = _tmp41_;
	_tmp42_ = granite_switch_model_button_new (_ ("Match Whole Words"));
	g_object_ref_sink (_tmp42_);
	_g_object_unref0 (self->priv->whole_word_search_button);
	self->priv->whole_word_search_button = _tmp42_;
	_tmp43_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp43_, 3);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp43_, 3);
	g_object_ref_sink (_tmp43_);
	search_option_box = _tmp43_;
	_tmp44_ = search_option_box;
	_tmp45_ = self->priv->cycle_search_button;
	gtk_container_add ((GtkContainer*) _tmp44_, (GtkWidget*) _tmp45_);
	_tmp46_ = search_option_box;
	_tmp47_ = case_sensitive_box;
	gtk_container_add ((GtkContainer*) _tmp46_, (GtkWidget*) _tmp47_);
	_tmp48_ = search_option_box;
	_tmp49_ = self->priv->whole_word_search_button;
	gtk_container_add ((GtkContainer*) _tmp48_, (GtkWidget*) _tmp49_);
	_tmp50_ = search_option_box;
	_tmp51_ = self->priv->regex_search_button;
	gtk_container_add ((GtkContainer*) _tmp50_, (GtkWidget*) _tmp51_);
	_tmp52_ = (GtkPopover*) gtk_popover_new (NULL);
	g_object_ref_sink (_tmp52_);
	search_popover = _tmp52_;
	_tmp53_ = search_popover;
	_tmp54_ = search_option_box;
	gtk_container_add ((GtkContainer*) _tmp53_, (GtkWidget*) _tmp54_);
	_tmp55_ = search_popover;
	gtk_widget_show_all ((GtkWidget*) _tmp55_);
	_tmp56_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	g_object_ref_sink (_tmp56_);
	search_buttonbox = _tmp56_;
	_tmp57_ = search_buttonbox;
	_tmp58_ = self->priv->search_occurence_count_label;
	gtk_container_add ((GtkContainer*) _tmp57_, (GtkWidget*) _tmp58_);
	_tmp59_ = search_buttonbox;
	_tmp60_ = (GtkImage*) gtk_image_new_from_icon_name ("pan-down-symbolic", (GtkIconSize) GTK_ICON_SIZE_SMALL_TOOLBAR);
	g_object_ref_sink (_tmp60_);
	_tmp61_ = _tmp60_;
	gtk_container_add ((GtkContainer*) _tmp59_, (GtkWidget*) _tmp61_);
	_g_object_unref0 (_tmp61_);
	_tmp62_ = search_popover;
	_tmp63_ = _g_object_ref0 (_tmp62_);
	_tmp64_ = g_strdup (_ ("Search Options"));
	_tmp65_ = (GtkMenuButton*) gtk_menu_button_new ();
	gtk_menu_button_set_popover (_tmp65_, _tmp63_);
	_g_object_unref0 (_tmp63_);
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp65_, _tmp64_);
	_g_free0 (_tmp64_);
	g_object_ref_sink (_tmp65_);
	search_menubutton = _tmp65_;
	_tmp66_ = search_menubutton;
	_tmp67_ = search_buttonbox;
	gtk_container_add ((GtkContainer*) _tmp66_, (GtkWidget*) _tmp67_);
	_tmp68_ = self->priv->cycle_search_button;
	g_signal_connect_object ((GtkToggleButton*) _tmp68_, "toggled", (GCallback) _scratch_widgets_search_bar_on_search_parameters_changed_gtk_toggle_button_toggled, self, 0);
	_tmp69_ = self->priv->case_sensitive_search_button;
	g_signal_connect_object ((GtkComboBox*) _tmp69_, "changed", (GCallback) _scratch_widgets_search_bar_on_search_parameters_changed_gtk_combo_box_changed, self, 0);
	_tmp70_ = self->priv->whole_word_search_button;
	g_signal_connect_object ((GtkToggleButton*) _tmp70_, "toggled", (GCallback) _scratch_widgets_search_bar_on_search_parameters_changed_gtk_toggle_button_toggled, self, 0);
	_tmp71_ = self->priv->regex_search_button;
	g_signal_connect_object ((GtkToggleButton*) _tmp71_, "toggled", (GCallback) _scratch_widgets_search_bar_on_search_parameters_changed_gtk_toggle_button_toggled, self, 0);
	_tmp72_ = scratch_settings;
	_tmp73_ = self->priv->cycle_search_button;
	g_settings_bind (_tmp72_, "cyclic-search", (GObject*) _tmp73_, "active", G_SETTINGS_BIND_DEFAULT);
	_tmp74_ = scratch_settings;
	_tmp75_ = self->priv->whole_word_search_button;
	g_settings_bind (_tmp74_, "wholeword-search", (GObject*) _tmp75_, "active", G_SETTINGS_BIND_DEFAULT);
	_tmp76_ = scratch_settings;
	_tmp77_ = self->priv->case_sensitive_search_button;
	g_settings_bind (_tmp76_, "case-sensitive-search", (GObject*) _tmp77_, "active-id", G_SETTINGS_BIND_DEFAULT);
	_tmp78_ = scratch_settings;
	_tmp79_ = self->priv->regex_search_button;
	g_settings_bind (_tmp78_, "regex-search", (GObject*) _tmp79_, "active", G_SETTINGS_BIND_DEFAULT);
	_tmp80_ = self->priv->regex_search_button;
	_tmp81_ = self->priv->cycle_search_button;
	g_object_bind_property_with_closures ((GObject*) _tmp80_, "active", (GObject*) _tmp81_, "sensitive", G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp82_ = self->priv->regex_search_button;
	_tmp83_ = self->priv->whole_word_search_button;
	g_object_bind_property_with_closures ((GObject*) _tmp82_, "active", (GObject*) _tmp83_, "sensitive", G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp84_ = self->priv->regex_search_button;
	_tmp85_ = case_sensitive_search_label;
	g_object_bind_property_with_closures ((GObject*) _tmp84_, "active", (GObject*) _tmp85_, "sensitive", G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp86_ = self->priv->regex_search_button;
	_tmp87_ = self->priv->case_sensitive_search_button;
	g_object_bind_property_with_closures ((GObject*) _tmp86_, "active", (GObject*) _tmp87_, "sensitive", G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp88_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp88_, 3);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp88_, 3);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp88_, 3);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp88_, 6);
	g_object_ref_sink (_tmp88_);
	search_box = _tmp88_;
	_tmp89_ = search_box;
	_tmp90_ = gtk_widget_get_style_context ((GtkWidget*) _tmp89_);
	gtk_style_context_add_class (_tmp90_, GTK_STYLE_CLASS_LINKED);
	_tmp91_ = search_box;
	_tmp92_ = self->priv->search_entry;
	gtk_container_add ((GtkContainer*) _tmp91_, (GtkWidget*) _tmp92_);
	_tmp93_ = search_box;
	_tmp94_ = self->priv->tool_arrow_down;
	gtk_container_add ((GtkContainer*) _tmp93_, (GtkWidget*) _tmp94_);
	_tmp95_ = search_box;
	_tmp96_ = self->priv->tool_arrow_up;
	gtk_container_add ((GtkContainer*) _tmp95_, (GtkWidget*) _tmp96_);
	_tmp97_ = search_box;
	_tmp98_ = search_menubutton;
	gtk_container_add ((GtkContainer*) _tmp97_, (GtkWidget*) _tmp98_);
	_tmp99_ = (GtkFlowBoxChild*) gtk_flow_box_child_new ();
	g_object_ref_sink (_tmp99_);
	search_flow_box_child = _tmp99_;
	_tmp100_ = search_flow_box_child;
	gtk_widget_set_can_focus ((GtkWidget*) _tmp100_, FALSE);
	_tmp101_ = search_flow_box_child;
	_tmp102_ = search_box;
	gtk_container_add ((GtkContainer*) _tmp101_, (GtkWidget*) _tmp102_);
	_tmp103_ = (GtkSearchEntry*) gtk_search_entry_new ();
	g_object_ref_sink (_tmp103_);
	_g_object_unref0 (self->priv->replace_entry);
	self->priv->replace_entry = _tmp103_;
	_tmp104_ = self->priv->replace_entry;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp104_, TRUE);
	_tmp105_ = self->priv->replace_entry;
	gtk_entry_set_placeholder_text ((GtkEntry*) _tmp105_, _ ("Replace With"));
	_tmp106_ = self->priv->replace_entry;
	gtk_entry_set_icon_from_icon_name ((GtkEntry*) _tmp106_, GTK_ENTRY_ICON_PRIMARY, "edit-symbolic");
	_tmp107_ = (GtkButton*) gtk_button_new_with_label (_ ("Replace"));
	g_object_ref_sink (_tmp107_);
	_g_object_unref0 (self->priv->replace_tool_button);
	self->priv->replace_tool_button = _tmp107_;
	_tmp108_ = self->priv->replace_tool_button;
	g_signal_connect_object (_tmp108_, "clicked", (GCallback) _scratch_widgets_search_bar_on_replace_entry_activate_gtk_button_clicked, self, 0);
	_tmp109_ = (GtkButton*) gtk_button_new_with_label (_ ("Replace all"));
	g_object_ref_sink (_tmp109_);
	_g_object_unref0 (self->priv->replace_all_tool_button);
	self->priv->replace_all_tool_button = _tmp109_;
	_tmp110_ = self->priv->replace_all_tool_button;
	g_signal_connect_object (_tmp110_, "clicked", (GCallback) _scratch_widgets_search_bar_on_replace_all_entry_activate_gtk_button_clicked, self, 0);
	_tmp111_ = (GtkGrid*) gtk_grid_new ();
	gtk_widget_set_margin_top ((GtkWidget*) _tmp111_, 3);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp111_, 6);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp111_, 3);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp111_, 3);
	g_object_ref_sink (_tmp111_);
	replace_grid = _tmp111_;
	_tmp112_ = replace_grid;
	_tmp113_ = gtk_widget_get_style_context ((GtkWidget*) _tmp112_);
	gtk_style_context_add_class (_tmp113_, GTK_STYLE_CLASS_LINKED);
	_tmp114_ = replace_grid;
	_tmp115_ = self->priv->replace_entry;
	gtk_container_add ((GtkContainer*) _tmp114_, (GtkWidget*) _tmp115_);
	_tmp116_ = replace_grid;
	_tmp117_ = self->priv->replace_tool_button;
	gtk_container_add ((GtkContainer*) _tmp116_, (GtkWidget*) _tmp117_);
	_tmp118_ = replace_grid;
	_tmp119_ = self->priv->replace_all_tool_button;
	gtk_container_add ((GtkContainer*) _tmp118_, (GtkWidget*) _tmp119_);
	_tmp120_ = (GtkFlowBoxChild*) gtk_flow_box_child_new ();
	g_object_ref_sink (_tmp120_);
	replace_flow_box_child = _tmp120_;
	_tmp121_ = replace_flow_box_child;
	gtk_widget_set_can_focus ((GtkWidget*) _tmp121_, FALSE);
	_tmp122_ = replace_flow_box_child;
	_tmp123_ = replace_grid;
	gtk_container_add ((GtkContainer*) _tmp122_, (GtkWidget*) _tmp123_);
	_tmp124_ = self->priv->search_entry;
	g_signal_connect_object ((GtkEditable*) _tmp124_, "changed", (GCallback) _scratch_widgets_search_bar_on_search_parameters_changed_gtk_editable_changed, self, 0);
	_tmp125_ = self->priv->search_entry;
	g_signal_connect_object ((GtkWidget*) _tmp125_, "key-press-event", (GCallback) _scratch_widgets_search_bar_on_search_entry_key_press_gtk_widget_key_press_event, self, 0);
	_tmp126_ = self->priv->search_entry;
	g_signal_connect_object ((GtkWidget*) _tmp126_, "focus-in-event", (GCallback) _scratch_widgets_search_bar_on_search_entry_focused_in_gtk_widget_focus_in_event, self, 0);
	_tmp127_ = self->priv->search_entry;
	g_signal_connect_object ((GtkEntry*) _tmp127_, "icon-release", (GCallback) __scratch_widgets_search_bar___lambda146__gtk_entry_icon_release, self, 0);
	_tmp128_ = self->priv->replace_entry;
	g_signal_connect_object ((GtkEntry*) _tmp128_, "activate", (GCallback) _scratch_widgets_search_bar_on_replace_entry_activate_gtk_entry_activate, self, 0);
	_tmp129_ = self->priv->replace_entry;
	g_signal_connect_object ((GtkWidget*) _tmp129_, "key-press-event", (GCallback) _scratch_widgets_search_bar_on_replace_entry_key_press_gtk_widget_key_press_event, self, 0);
	_tmp130_ = gtk_widget_path_new ();
	entry_path = _tmp130_;
	_tmp131_ = entry_path;
	gtk_widget_path_append_type (_tmp131_, gtk_widget_get_type ());
	_tmp132_ = gtk_style_context_new ();
	entry_context = _tmp132_;
	_tmp133_ = entry_context;
	_tmp134_ = entry_path;
	gtk_style_context_set_path (_tmp133_, _tmp134_);
	_tmp135_ = entry_context;
	gtk_style_context_add_class (_tmp135_, "entry");
	_tmp136_ = (GtkFlowBox*) gtk_flow_box_new ();
	gtk_flow_box_set_selection_mode (_tmp136_, GTK_SELECTION_NONE);
	gtk_flow_box_set_column_spacing (_tmp136_, (guint) 6);
	gtk_flow_box_set_max_children_per_line (_tmp136_, (guint) 2);
	g_object_ref_sink (_tmp136_);
	flowbox = _tmp136_;
	_tmp137_ = flowbox;
	_tmp138_ = gtk_widget_get_style_context ((GtkWidget*) _tmp137_);
	gtk_style_context_add_class (_tmp138_, "search-bar");
	_tmp139_ = flowbox;
	_tmp140_ = search_flow_box_child;
	gtk_container_add ((GtkContainer*) _tmp139_, (GtkWidget*) _tmp140_);
	_tmp141_ = flowbox;
	_tmp142_ = replace_flow_box_child;
	gtk_container_add ((GtkContainer*) _tmp141_, (GtkWidget*) _tmp142_);
	_tmp143_ = flowbox;
	_tmp144_ = _g_object_ref0 ((GtkWidget*) _tmp143_);
	_tmp145_ = (GtkRevealer*) gtk_revealer_new ();
	g_object_set ((GtkContainer*) _tmp145_, "child", _tmp144_, NULL);
	_g_object_unref0 (_tmp144_);
	gtk_revealer_set_reveal_child (_tmp145_, FALSE);
	g_object_ref_sink (_tmp145_);
	_g_object_unref0 (self->priv->revealer);
	self->priv->revealer = _tmp145_;
	_tmp146_ = self->priv->revealer;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp146_);
	scratch_widgets_search_bar_update_search_widgets (self);
	_g_object_unref0 (flowbox);
	_g_object_unref0 (entry_context);
	_gtk_widget_path_unref0 (entry_path);
	_g_object_unref0 (replace_flow_box_child);
	_g_object_unref0 (replace_grid);
	_g_object_unref0 (search_flow_box_child);
	_g_object_unref0 (search_box);
	_g_object_unref0 (search_menubutton);
	_g_object_unref0 (search_buttonbox);
	_g_object_unref0 (search_popover);
	_g_object_unref0 (search_option_box);
	_g_object_unref0 (case_sensitive_box);
	_g_object_unref0 (case_sensitive_search_label);
	_g_object_unref0 (app_instance);
	return obj;
}

static void
scratch_widgets_search_bar_class_init (ScratchWidgetsSearchBarClass * klass,
                                       gpointer klass_data)
{
	scratch_widgets_search_bar_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ScratchWidgetsSearchBar_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_scratch_widgets_search_bar_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_scratch_widgets_search_bar_set_property;
	G_OBJECT_CLASS (klass)->constructor = scratch_widgets_search_bar_constructor;
	G_OBJECT_CLASS (klass)->finalize = scratch_widgets_search_bar_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), SCRATCH_WIDGETS_SEARCH_BAR_WINDOW_PROPERTY, scratch_widgets_search_bar_properties[SCRATCH_WIDGETS_SEARCH_BAR_WINDOW_PROPERTY] = g_param_spec_object ("window", "window", "window", SCRATCH_TYPE_MAIN_WINDOW, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), SCRATCH_WIDGETS_SEARCH_BAR_IS_FOCUSED_PROPERTY, scratch_widgets_search_bar_properties[SCRATCH_WIDGETS_SEARCH_BAR_IS_FOCUSED_PROPERTY] = g_param_spec_boolean ("is-focused", "is-focused", "is-focused", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), SCRATCH_WIDGETS_SEARCH_BAR_IS_REVEALED_PROPERTY, scratch_widgets_search_bar_properties[SCRATCH_WIDGETS_SEARCH_BAR_IS_REVEALED_PROPERTY] = g_param_spec_boolean ("is-revealed", "is-revealed", "is-revealed", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), SCRATCH_WIDGETS_SEARCH_BAR_ENTRY_TEXT_PROPERTY, scratch_widgets_search_bar_properties[SCRATCH_WIDGETS_SEARCH_BAR_ENTRY_TEXT_PROPERTY] = g_param_spec_string ("entry-text", "entry-text", "entry-text", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), SCRATCH_WIDGETS_SEARCH_BAR_SEARCH_OCCURRENCES_PROPERTY, scratch_widgets_search_bar_properties[SCRATCH_WIDGETS_SEARCH_BAR_SEARCH_OCCURRENCES_PROPERTY] = g_param_spec_uint ("search-occurrences", "search-occurrences", "search-occurrences", 0, G_MAXUINT, 0U, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), SCRATCH_WIDGETS_SEARCH_BAR_TRANSITION_TIME_MSEC_PROPERTY, scratch_widgets_search_bar_properties[SCRATCH_WIDGETS_SEARCH_BAR_TRANSITION_TIME_MSEC_PROPERTY] = g_param_spec_uint ("transition-time-msec", "transition-time-msec", "transition-time-msec", 0, G_MAXUINT, 0U, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
scratch_widgets_search_bar_instance_init (ScratchWidgetsSearchBar * self,
                                          gpointer klass)
{
	self->priv = scratch_widgets_search_bar_get_instance_private (self);
	self->priv->text_view = NULL;
	self->priv->text_buffer = NULL;
	self->priv->update_search_label_timeout_id = (guint) 0;
}

static void
scratch_widgets_search_bar_finalize (GObject * obj)
{
	ScratchWidgetsSearchBar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SCRATCH_WIDGETS_TYPE_SEARCH_BAR, ScratchWidgetsSearchBar);
	_g_object_unref0 (self->priv->tool_arrow_up);
	_g_object_unref0 (self->priv->tool_arrow_down);
	_g_object_unref0 (self->priv->cycle_search_button);
	_g_object_unref0 (self->priv->case_sensitive_search_button);
	_g_object_unref0 (self->priv->regex_search_button);
	_g_object_unref0 (self->priv->whole_word_search_button);
	_g_object_unref0 (self->priv->search_entry);
	_g_object_unref0 (self->priv->replace_entry);
	_g_object_unref0 (self->priv->search_occurence_count_label);
	_g_object_unref0 (self->priv->replace_tool_button);
	_g_object_unref0 (self->priv->replace_all_tool_button);
	_g_object_unref0 (self->priv->text_view);
	_g_object_unref0 (self->priv->text_buffer);
	_g_object_unref0 (self->priv->search_context);
	_g_object_unref0 (self->priv->revealer);
	G_OBJECT_CLASS (scratch_widgets_search_bar_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
scratch_widgets_search_bar_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ScratchWidgetsSearchBarClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) scratch_widgets_search_bar_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ScratchWidgetsSearchBar), 0, (GInstanceInitFunc) scratch_widgets_search_bar_instance_init, NULL };
	GType scratch_widgets_search_bar_type_id;
	scratch_widgets_search_bar_type_id = g_type_register_static (gtk_box_get_type (), "ScratchWidgetsSearchBar", &g_define_type_info, G_TYPE_FLAG_NONE);
	ScratchWidgetsSearchBar_private_offset = g_type_add_instance_private (scratch_widgets_search_bar_type_id, sizeof (ScratchWidgetsSearchBarPrivate));
	return scratch_widgets_search_bar_type_id;
}

GType
scratch_widgets_search_bar_get_type (void)
{
	static gsize scratch_widgets_search_bar_type_id__once = 0;
	if (g_once_init_enter (&scratch_widgets_search_bar_type_id__once)) {
		GType scratch_widgets_search_bar_type_id;
		scratch_widgets_search_bar_type_id = scratch_widgets_search_bar_get_type_once ();
		g_once_init_leave (&scratch_widgets_search_bar_type_id__once, scratch_widgets_search_bar_type_id);
	}
	return scratch_widgets_search_bar_type_id__once;
}

static void
_vala_scratch_widgets_search_bar_get_property (GObject * object,
                                               guint property_id,
                                               GValue * value,
                                               GParamSpec * pspec)
{
	ScratchWidgetsSearchBar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SCRATCH_WIDGETS_TYPE_SEARCH_BAR, ScratchWidgetsSearchBar);
	switch (property_id) {
		case SCRATCH_WIDGETS_SEARCH_BAR_WINDOW_PROPERTY:
		g_value_set_object (value, scratch_widgets_search_bar_get_window (self));
		break;
		case SCRATCH_WIDGETS_SEARCH_BAR_IS_FOCUSED_PROPERTY:
		g_value_set_boolean (value, scratch_widgets_search_bar_get_is_focused (self));
		break;
		case SCRATCH_WIDGETS_SEARCH_BAR_IS_REVEALED_PROPERTY:
		g_value_set_boolean (value, scratch_widgets_search_bar_get_is_revealed (self));
		break;
		case SCRATCH_WIDGETS_SEARCH_BAR_ENTRY_TEXT_PROPERTY:
		g_value_set_string (value, scratch_widgets_search_bar_get_entry_text (self));
		break;
		case SCRATCH_WIDGETS_SEARCH_BAR_SEARCH_OCCURRENCES_PROPERTY:
		g_value_set_uint (value, scratch_widgets_search_bar_get_search_occurrences (self));
		break;
		case SCRATCH_WIDGETS_SEARCH_BAR_TRANSITION_TIME_MSEC_PROPERTY:
		g_value_set_uint (value, scratch_widgets_search_bar_get_transition_time_msec (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_scratch_widgets_search_bar_set_property (GObject * object,
                                               guint property_id,
                                               const GValue * value,
                                               GParamSpec * pspec)
{
	ScratchWidgetsSearchBar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SCRATCH_WIDGETS_TYPE_SEARCH_BAR, ScratchWidgetsSearchBar);
	switch (property_id) {
		case SCRATCH_WIDGETS_SEARCH_BAR_WINDOW_PROPERTY:
		scratch_widgets_search_bar_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);
}

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

