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

/*
 * Copyright 2011-2019 elementary, Inc. (https://elementary.io)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301 USA.
 *
 * Authored by: Corentin Noël <corentin@elementary.io>
 *              Giulio Collura
 */
/* The first entries of ResultType enum must match those of Synapse.MatchType so that a cast from*/
/* Synapse.MatchType to ResultType is valid.*/

#include "slingshot.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <granite.h>
#include <gtk/gtk.h>
#include <gee.h>
#include <glib-object.h>
#include <gdk/gdk.h>
#include <gio/gio.h>
#include <float.h>
#include <math.h>

#define SLINGSHOT_WIDGETS_SEARCH_VIEW_MAX_RESULTS 10
#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

enum  {
	SLINGSHOT_WIDGETS_SEARCH_VIEW_0_PROPERTY,
	SLINGSHOT_WIDGETS_SEARCH_VIEW_NUM_PROPERTIES
};
static GParamSpec* slingshot_widgets_search_view_properties[SLINGSHOT_WIDGETS_SEARCH_VIEW_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block14Data Block14Data;
#define __vala_GdkEvent_free0(var) ((var == NULL) ? NULL : (var = (_vala_GdkEvent_free (var), NULL)))
#define __vala_GdkEventSequence_free0(var) ((var == NULL) ? NULL : (var = (_vala_GdkEventSequence_free (var), NULL)))
enum  {
	SLINGSHOT_WIDGETS_SEARCH_VIEW_START_SEARCH_SIGNAL,
	SLINGSHOT_WIDGETS_SEARCH_VIEW_APP_LAUNCHED_SIGNAL,
	SLINGSHOT_WIDGETS_SEARCH_VIEW_NUM_SIGNALS
};
static guint slingshot_widgets_search_view_signals[SLINGSHOT_WIDGETS_SEARCH_VIEW_NUM_SIGNALS] = {0};

struct _SlingshotWidgetsSearchViewPrivate {
	GraniteWidgetsAlertView* alert_view;
	GtkListBox* list_box;
	GeeHashMap* limitator;
	gchar* drag_uri;
	GtkGestureMultiPress* click_controller;
	GtkEventControllerKey* menu_key_controller;
};

struct _Block14Data {
	int _ref_count_;
	SlingshotWidgetsSearchView* self;
	GtkListBoxRow* row;
};

static gint SlingshotWidgetsSearchView_private_offset;
static gpointer slingshot_widgets_search_view_parent_class = NULL;

static void slingshot_widgets_search_view_move_cursor (SlingshotWidgetsSearchView* self,
                                                GtkMovementStep step,
                                                gint count);
static void slingshot_widgets_search_view_create_item (SlingshotWidgetsSearchView* self,
                                                SlingshotBackendApp* app,
                                                const gchar* search_term,
                                                SlingshotWidgetsResultType result_type);
static void __lambda50_ (SlingshotWidgetsSearchView* self,
                  SynapseSearchMatch* search,
                  SynapseMatch* target);
static void ___lambda50__slingshot_backend_app_start_search (SlingshotBackendApp* _sender,
                                                      SynapseSearchMatch* search_match,
                                                      SynapseMatch* target,
                                                      gpointer self);
static void __lambda51_ (SlingshotWidgetsSearchView* self);
static void ___lambda51__slingshot_backend_app_launched (SlingshotBackendApp* _sender,
                                                  SlingshotBackendApp* app,
                                                  gpointer self);
static void __lambda49_ (SlingshotWidgetsSearchView* self,
                  GtkWidget* child);
static void ___lambda49__gfunc (gconstpointer data,
                         gpointer self);
static gint slingshot_widgets_search_view_update_sort (SlingshotWidgetsSearchView* self,
                                                GtkListBoxRow* row1,
                                                GtkListBoxRow* row2);
static void slingshot_widgets_search_view_update_header (SlingshotWidgetsSearchItem* row,
                                                  SlingshotWidgetsSearchItem* before,
                                                  SlingshotWidgetsSearchView* self);
static void g_cclosure_user_marshal_VOID__OBJECT_OBJECT (GClosure * closure,
                                                  GValue * return_value,
                                                  guint n_param_values,
                                                  const GValue * param_values,
                                                  gpointer invocation_hint,
                                                  gpointer marshal_data);
static GObject * slingshot_widgets_search_view_constructor (GType type,
                                                     guint n_construct_properties,
                                                     GObjectConstructParam * construct_properties);
static gint _slingshot_widgets_search_view___lambda52_ (SlingshotWidgetsSearchView* self,
                                                 GtkListBoxRow* row1,
                                                 GtkListBoxRow* row2);
static gint __slingshot_widgets_search_view___lambda52__gtk_list_box_sort_func (GtkListBoxRow* row1,
                                                                         GtkListBoxRow* row2,
                                                                         gpointer self);
static void _slingshot_widgets_search_view___lambda53_ (SlingshotWidgetsSearchView* self,
                                                 GdkDragContext* ctx);
static void __slingshot_widgets_search_view___lambda53__gtk_widget_drag_begin (GtkWidget* _sender,
                                                                        GdkDragContext* context,
                                                                        gpointer self);
static void _slingshot_widgets_search_view___lambda54_ (SlingshotWidgetsSearchView* self);
static void __slingshot_widgets_search_view___lambda54__gtk_widget_drag_end (GtkWidget* _sender,
                                                                      GdkDragContext* context,
                                                                      gpointer self);
static void _slingshot_widgets_search_view___lambda55_ (SlingshotWidgetsSearchView* self,
                                                 GdkDragContext* ctx,
                                                 GtkSelectionData* sel,
                                                 guint info,
                                                 guint time);
static void __slingshot_widgets_search_view___lambda55__gtk_widget_drag_data_get (GtkWidget* _sender,
                                                                           GdkDragContext* context,
                                                                           GtkSelectionData* selection_data,
                                                                           guint info,
                                                                           guint time_,
                                                                           gpointer self);
static void _slingshot_widgets_search_view_move_cursor_gtk_list_box_move_cursor (GtkListBox* _sender,
                                                                          GtkMovementStep step,
                                                                          gint count,
                                                                          gpointer self);
static void _slingshot_widgets_search_view___lambda56_ (SlingshotWidgetsSearchView* self,
                                                 GtkListBoxRow* row);
static Block14Data* block14_data_ref (Block14Data* _data14_);
static void block14_data_unref (void * _userdata_);
static gboolean __lambda57_ (Block14Data* _data14_);
static gboolean ___lambda57__gsource_func (gpointer self);
static void __slingshot_widgets_search_view___lambda56__gtk_list_box_row_activated (GtkListBox* _sender,
                                                                             GtkListBoxRow* row,
                                                                             gpointer self);
static void _slingshot_widgets_search_view___lambda58_ (SlingshotWidgetsSearchView* self,
                                                 gint n_press,
                                                 gdouble x,
                                                 gdouble y);
static GdkEvent* _vala_GdkEvent_copy (GdkEvent* self);
static void _vala_GdkEvent_free (GdkEvent* self);
static void _vala_GdkEventSequence_free (GdkEventSequence* self);
static void __slingshot_widgets_search_view___lambda58__gtk_gesture_multi_press_pressed (GtkGestureMultiPress* _sender,
                                                                                  gint n_press,
                                                                                  gdouble x,
                                                                                  gdouble y,
                                                                                  gpointer self);
static void _slingshot_widgets_search_view___lambda59_ (SlingshotWidgetsSearchView* self,
                                                 guint keyval,
                                                 guint keycode,
                                                 GdkModifierType state);
static void __slingshot_widgets_search_view___lambda59__gtk_event_controller_key_key_released (GtkEventControllerKey* _sender,
                                                                                        guint keyval,
                                                                                        guint keycode,
                                                                                        GdkModifierType state,
                                                                                        gpointer self);
static void slingshot_widgets_search_view_finalize (GObject * obj);
static GType slingshot_widgets_search_view_get_type_once (void);
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);

const gchar*
slingshot_widgets_result_type_to_string (SlingshotWidgetsResultType self)
{
	const gchar* result;
	switch (self) {
		case SLINGSHOT_WIDGETS_RESULT_TYPE_TEXT:
		{
			result = _ ("Text");
			return result;
		}
		case SLINGSHOT_WIDGETS_RESULT_TYPE_CALCULATION:
		{
			result = _ ("Calculation");
			return result;
		}
		case SLINGSHOT_WIDGETS_RESULT_TYPE_APPLICATION:
		{
			result = _ ("Applications");
			return result;
		}
		case SLINGSHOT_WIDGETS_RESULT_TYPE_GENERIC_URI:
		{
			result = _ ("Files");
			return result;
		}
		case SLINGSHOT_WIDGETS_RESULT_TYPE_LINK:
		case SLINGSHOT_WIDGETS_RESULT_TYPE_ACTION:
		{
			result = _ ("Actions");
			return result;
		}
		case SLINGSHOT_WIDGETS_RESULT_TYPE_SEARCH:
		{
			result = _ ("Search");
			return result;
		}
		case SLINGSHOT_WIDGETS_RESULT_TYPE_CONTACT:
		{
			result = _ ("Contacts");
			return result;
		}
		case SLINGSHOT_WIDGETS_RESULT_TYPE_INTERNET:
		{
			result = _ ("Internet");
			return result;
		}
		case SLINGSHOT_WIDGETS_RESULT_TYPE_SETTINGS:
		{
			result = _ ("Settings");
			return result;
		}
		case SLINGSHOT_WIDGETS_RESULT_TYPE_APP_ACTIONS:
		{
			result = _ ("Application Actions");
			return result;
		}
		case SLINGSHOT_WIDGETS_RESULT_TYPE_BOOKMARK:
		{
			result = _ ("Bookmarks");
			return result;
		}
		default:
		{
			result = _ ("Other");
			return result;
		}
	}
}

static GType
slingshot_widgets_result_type_get_type_once (void)
{
	static const GEnumValue values[] = {{SLINGSHOT_WIDGETS_RESULT_TYPE_UNKNOWN, "SLINGSHOT_WIDGETS_RESULT_TYPE_UNKNOWN", "unknown"}, {SLINGSHOT_WIDGETS_RESULT_TYPE_TEXT, "SLINGSHOT_WIDGETS_RESULT_TYPE_TEXT", "text"}, {SLINGSHOT_WIDGETS_RESULT_TYPE_CALCULATION, "SLINGSHOT_WIDGETS_RESULT_TYPE_CALCULATION", "calculation"}, {SLINGSHOT_WIDGETS_RESULT_TYPE_APPLICATION, "SLINGSHOT_WIDGETS_RESULT_TYPE_APPLICATION", "application"}, {SLINGSHOT_WIDGETS_RESULT_TYPE_BOOKMARK, "SLINGSHOT_WIDGETS_RESULT_TYPE_BOOKMARK", "bookmark"}, {SLINGSHOT_WIDGETS_RESULT_TYPE_GENERIC_URI, "SLINGSHOT_WIDGETS_RESULT_TYPE_GENERIC_URI", "generic-uri"}, {SLINGSHOT_WIDGETS_RESULT_TYPE_ACTION, "SLINGSHOT_WIDGETS_RESULT_TYPE_ACTION", "action"}, {SLINGSHOT_WIDGETS_RESULT_TYPE_SEARCH, "SLINGSHOT_WIDGETS_RESULT_TYPE_SEARCH", "search"}, {SLINGSHOT_WIDGETS_RESULT_TYPE_APP_ACTIONS, "SLINGSHOT_WIDGETS_RESULT_TYPE_APP_ACTIONS", "app-actions"}, {SLINGSHOT_WIDGETS_RESULT_TYPE_CONTACT, "SLINGSHOT_WIDGETS_RESULT_TYPE_CONTACT", "contact"}, {SLINGSHOT_WIDGETS_RESULT_TYPE_INTERNET, "SLINGSHOT_WIDGETS_RESULT_TYPE_INTERNET", "internet"}, {SLINGSHOT_WIDGETS_RESULT_TYPE_SETTINGS, "SLINGSHOT_WIDGETS_RESULT_TYPE_SETTINGS", "settings"}, {SLINGSHOT_WIDGETS_RESULT_TYPE_LINK, "SLINGSHOT_WIDGETS_RESULT_TYPE_LINK", "link"}, {0, NULL, NULL}};
	GType slingshot_widgets_result_type_type_id;
	slingshot_widgets_result_type_type_id = g_enum_register_static ("SlingshotWidgetsResultType", values);
	return slingshot_widgets_result_type_type_id;
}

GType
slingshot_widgets_result_type_get_type (void)
{
	static volatile gsize slingshot_widgets_result_type_type_id__once = 0;
	if (g_once_init_enter (&slingshot_widgets_result_type_type_id__once)) {
		GType slingshot_widgets_result_type_type_id;
		slingshot_widgets_result_type_type_id = slingshot_widgets_result_type_get_type_once ();
		g_once_init_leave (&slingshot_widgets_result_type_type_id__once, slingshot_widgets_result_type_type_id);
	}
	return slingshot_widgets_result_type_type_id__once;
}

static inline gpointer
slingshot_widgets_search_view_get_instance_private (SlingshotWidgetsSearchView* self)
{
	return G_STRUCT_MEMBER_P (self, SlingshotWidgetsSearchView_private_offset);
}

static void
slingshot_widgets_search_view_move_cursor (SlingshotWidgetsSearchView* self,
                                           GtkMovementStep step,
                                           gint count)
{
	GtkListBoxRow* selected = NULL;
	GtkListBox* _tmp0_;
	GtkListBoxRow* _tmp1_;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp4_ = FALSE;
	GtkListBoxRow* _tmp5_;
	GtkListBox* _tmp6_;
	GtkListBoxRow* _tmp7_;
	GtkListBox* _tmp8_;
	GtkListBoxRow* _tmp9_;
	GtkListBoxRow* _tmp10_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->list_box;
	_tmp1_ = gtk_list_box_get_selected_row (_tmp0_);
	selected = _tmp1_;
	if (step != GTK_MOVEMENT_DISPLAY_LINES) {
		_tmp2_ = TRUE;
	} else {
		GtkListBoxRow* _tmp3_;
		_tmp3_ = selected;
		_tmp2_ = _tmp3_ == NULL;
	}
	if (_tmp2_) {
		return;
	}
	_tmp5_ = selected;
	_tmp6_ = self->priv->list_box;
	_tmp7_ = gtk_list_box_get_row_at_index (_tmp6_, 0);
	if (_tmp5_ == _tmp7_) {
		_tmp4_ = count == -1;
	} else {
		_tmp4_ = FALSE;
	}
	if (_tmp4_) {
		g_signal_emit_by_name ((GtkWidget*) self, "move-focus", GTK_DIR_TAB_BACKWARD);
		return;
	}
	_tmp8_ = self->priv->list_box;
	_tmp9_ = selected;
	_tmp10_ = gtk_list_box_get_row_at_index (_tmp8_, gtk_list_box_row_get_index (_tmp9_) + count);
	if (_tmp10_ == NULL) {
		GtkListBox* _tmp11_;
		GtkListBox* _tmp12_;
		GtkListBoxRow* _tmp13_;
		_tmp11_ = self->priv->list_box;
		_tmp12_ = self->priv->list_box;
		_tmp13_ = gtk_list_box_get_row_at_index (_tmp12_, 0);
		gtk_list_box_select_row (_tmp11_, _tmp13_);
		g_signal_emit_by_name ((GtkWidget*) self, "move-focus", GTK_DIR_TAB_FORWARD);
	}
}

void
slingshot_widgets_search_view_set_results (SlingshotWidgetsSearchView* self,
                                           GeeList* matches,
                                           const gchar* search_term)
{
	gint _tmp0_;
	gint _tmp1_;
	GtkListBoxRow* first = NULL;
	GtkListBox* _tmp41_;
	GtkListBoxRow* _tmp42_;
	GtkListBoxRow* _tmp43_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (matches != NULL);
	g_return_if_fail (search_term != NULL);
	slingshot_widgets_search_view_clear (self);
	_tmp0_ = gee_collection_get_size ((GeeCollection*) matches);
	_tmp1_ = _tmp0_;
	if (_tmp1_ > 0) {
		{
			GeeList* _match_list = NULL;
			gint _match_size = 0;
			GeeList* _tmp2_;
			gint _tmp3_;
			gint _tmp4_;
			gint _match_index = 0;
			_match_list = matches;
			_tmp2_ = _match_list;
			_tmp3_ = gee_collection_get_size ((GeeCollection*) _tmp2_);
			_tmp4_ = _tmp3_;
			_match_size = _tmp4_;
			_match_index = -1;
			while (TRUE) {
				gint _tmp5_;
				gint _tmp6_;
				SynapseMatch* match = NULL;
				GeeList* _tmp7_;
				gpointer _tmp8_;
				SlingshotBackendApp* app = NULL;
				SynapseMatch* _tmp9_;
				SlingshotBackendApp* _tmp10_;
				SlingshotWidgetsResultType result_type = 0;
				SynapseMatch* _tmp11_;
				SynapseMatchType _tmp12_;
				SynapseMatchType _tmp13_;
				SynapseMatch* _tmp14_;
				SlingshotBackendApp* _tmp37_;
				_match_index = _match_index + 1;
				_tmp5_ = _match_index;
				_tmp6_ = _match_size;
				if (!(_tmp5_ < _tmp6_)) {
					break;
				}
				_tmp7_ = _match_list;
				_tmp8_ = gee_list_get (_tmp7_, _match_index);
				match = (SynapseMatch*) _tmp8_;
				_tmp9_ = match;
				_tmp10_ = slingshot_backend_app_new_from_synapse_match (_tmp9_, NULL);
				app = _tmp10_;
				_tmp11_ = match;
				_tmp12_ = synapse_match_get_match_type (_tmp11_);
				_tmp13_ = _tmp12_;
				result_type = (SlingshotWidgetsResultType) _tmp13_;
				_tmp14_ = match;
				if (SYNAPSE_DESKTOP_FILE_PLUGIN_IS_ACTION_MATCH (_tmp14_)) {
					result_type = SLINGSHOT_WIDGETS_RESULT_TYPE_APP_ACTIONS;
				} else {
					SynapseMatch* _tmp15_;
					_tmp15_ = match;
					if (SYNAPSE_IS_SWITCHBOARD_OBJECT (_tmp15_)) {
						result_type = SLINGSHOT_WIDGETS_RESULT_TYPE_SETTINGS;
					} else {
						SynapseMatch* _tmp16_;
						_tmp16_ = match;
						if (SYNAPSE_LINK_PLUGIN_IS_RESULT (_tmp16_)) {
							result_type = SLINGSHOT_WIDGETS_RESULT_TYPE_INTERNET;
						} else {
							SynapseMatch* _tmp17_;
							_tmp17_ = match;
							if (SYNAPSE_FILE_BOOKMARK_PLUGIN_IS_RESULT (_tmp17_)) {
								result_type = SLINGSHOT_WIDGETS_RESULT_TYPE_BOOKMARK;
							}
						}
					}
				}
				if (result_type == SLINGSHOT_WIDGETS_RESULT_TYPE_UNKNOWN) {
					GeeList* actions = NULL;
					SynapseMatch* _tmp18_;
					GeeList* _tmp19_;
					_tmp18_ = match;
					_tmp19_ = slingshot_backend_synapse_search_find_actions_for_match (_tmp18_);
					actions = _tmp19_;
					{
						GeeList* _action_list = NULL;
						GeeList* _tmp20_;
						gint _action_size = 0;
						GeeList* _tmp21_;
						gint _tmp22_;
						gint _tmp23_;
						gint _action_index = 0;
						_tmp20_ = actions;
						_action_list = _tmp20_;
						_tmp21_ = _action_list;
						_tmp22_ = gee_collection_get_size ((GeeCollection*) _tmp21_);
						_tmp23_ = _tmp22_;
						_action_size = _tmp23_;
						_action_index = -1;
						while (TRUE) {
							gint _tmp24_;
							gint _tmp25_;
							SynapseMatch* action = NULL;
							GeeList* _tmp26_;
							gpointer _tmp27_;
							SynapseMatch* _tmp28_;
							SynapseMatch* _tmp29_;
							SlingshotBackendApp* _tmp30_;
							SlingshotBackendApp* _tmp31_;
							SlingshotBackendApp* _tmp32_;
							SynapseMatch* _tmp33_;
							SynapseMatch* _tmp34_;
							SynapseMatchType _tmp35_;
							SynapseMatchType _tmp36_;
							_action_index = _action_index + 1;
							_tmp24_ = _action_index;
							_tmp25_ = _action_size;
							if (!(_tmp24_ < _tmp25_)) {
								break;
							}
							_tmp26_ = _action_list;
							_tmp27_ = gee_list_get (_tmp26_, _action_index);
							action = (SynapseMatch*) _tmp27_;
							_tmp28_ = action;
							_tmp29_ = match;
							_tmp30_ = slingshot_backend_app_new_from_synapse_match (_tmp28_, _tmp29_);
							_g_object_unref0 (app);
							app = _tmp30_;
							_tmp31_ = app;
							_tmp32_ = app;
							_tmp33_ = slingshot_backend_app_get_match (_tmp32_);
							_tmp34_ = _tmp33_;
							_tmp35_ = synapse_match_get_match_type (_tmp34_);
							_tmp36_ = _tmp35_;
							slingshot_widgets_search_view_create_item (self, _tmp31_, search_term, (SlingshotWidgetsResultType) _tmp36_);
							_g_object_unref0 (action);
						}
					}
					_g_object_unref0 (actions);
					_g_object_unref0 (app);
					_g_object_unref0 (match);
					continue;
				}
				_tmp37_ = app;
				slingshot_widgets_search_view_create_item (self, _tmp37_, search_term, result_type);
				_g_object_unref0 (app);
				_g_object_unref0 (match);
			}
		}
	} else {
		GraniteWidgetsAlertView* _tmp38_;
		gchar* _tmp39_;
		gchar* _tmp40_;
		_tmp38_ = self->priv->alert_view;
		_tmp39_ = g_strdup_printf (_ ("No Results for “%s”"), search_term);
		_tmp40_ = _tmp39_;
		granite_widgets_alert_view_set_title (_tmp38_, _tmp40_);
		_g_free0 (_tmp40_);
	}
	_tmp41_ = self->priv->list_box;
	_tmp42_ = gtk_list_box_get_row_at_index (_tmp41_, 0);
	first = _tmp42_;
	_tmp43_ = first;
	if (_tmp43_ != NULL) {
		GtkListBox* _tmp44_;
		GtkListBoxRow* _tmp45_;
		_tmp44_ = self->priv->list_box;
		_tmp45_ = first;
		gtk_list_box_select_row (_tmp44_, _tmp45_);
	}
}

static void
__lambda50_ (SlingshotWidgetsSearchView* self,
             SynapseSearchMatch* search,
             SynapseMatch* target)
{
	g_return_if_fail (search != NULL);
	g_signal_emit (self, slingshot_widgets_search_view_signals[SLINGSHOT_WIDGETS_SEARCH_VIEW_START_SEARCH_SIGNAL], 0, search, target);
}

static void
___lambda50__slingshot_backend_app_start_search (SlingshotBackendApp* _sender,
                                                 SynapseSearchMatch* search_match,
                                                 SynapseMatch* target,
                                                 gpointer self)
{
	__lambda50_ ((SlingshotWidgetsSearchView*) self, search_match, target);
}

static void
__lambda51_ (SlingshotWidgetsSearchView* self)
{
	g_signal_emit (self, slingshot_widgets_search_view_signals[SLINGSHOT_WIDGETS_SEARCH_VIEW_APP_LAUNCHED_SIGNAL], 0);
}

static void
___lambda51__slingshot_backend_app_launched (SlingshotBackendApp* _sender,
                                             SlingshotBackendApp* app,
                                             gpointer self)
{
	__lambda51_ ((SlingshotWidgetsSearchView*) self);
}

static void
slingshot_widgets_search_view_create_item (SlingshotWidgetsSearchView* self,
                                           SlingshotBackendApp* app,
                                           const gchar* search_term,
                                           SlingshotWidgetsResultType result_type)
{
	GeeHashMap* _tmp0_;
	SlingshotWidgetsSearchItem* search_item = NULL;
	SlingshotWidgetsSearchItem* _tmp5_;
	GtkListBox* _tmp6_;
	SlingshotWidgetsSearchItem* _tmp7_;
	SlingshotWidgetsSearchItem* _tmp8_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (app != NULL);
	g_return_if_fail (search_term != NULL);
	_tmp0_ = self->priv->limitator;
	if (gee_abstract_map_has_key ((GeeAbstractMap*) _tmp0_, (gpointer) ((gintptr) result_type))) {
		guint amount = 0U;
		GeeHashMap* _tmp1_;
		gpointer _tmp2_;
		_tmp1_ = self->priv->limitator;
		_tmp2_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp1_, (gpointer) ((gintptr) result_type));
		amount = (guint) ((guintptr) _tmp2_);
		if (amount >= ((guint) SLINGSHOT_WIDGETS_SEARCH_VIEW_MAX_RESULTS)) {
			return;
		} else {
			GeeHashMap* _tmp3_;
			_tmp3_ = self->priv->limitator;
			gee_abstract_map_set ((GeeAbstractMap*) _tmp3_, (gpointer) ((gintptr) result_type), (gpointer) ((guintptr) (amount + 1)));
		}
	} else {
		GeeHashMap* _tmp4_;
		_tmp4_ = self->priv->limitator;
		gee_abstract_map_set ((GeeAbstractMap*) _tmp4_, (gpointer) ((gintptr) result_type), (gpointer) ((guintptr) 1));
	}
	_tmp5_ = slingshot_widgets_search_item_new (app, search_term, result_type);
	g_object_ref_sink (_tmp5_);
	search_item = _tmp5_;
	g_signal_connect_object (app, "start-search", (GCallback) ___lambda50__slingshot_backend_app_start_search, self, 0);
	g_signal_connect_object (app, "launched", (GCallback) ___lambda51__slingshot_backend_app_launched, self, 0);
	_tmp6_ = self->priv->list_box;
	_tmp7_ = search_item;
	gtk_container_add ((GtkContainer*) _tmp6_, (GtkWidget*) _tmp7_);
	_tmp8_ = search_item;
	gtk_widget_show_all ((GtkWidget*) _tmp8_);
	_g_object_unref0 (search_item);
}

static void
__lambda49_ (SlingshotWidgetsSearchView* self,
             GtkWidget* child)
{
	g_return_if_fail (child != NULL);
	gtk_widget_destroy (child);
}

static void
___lambda49__gfunc (gconstpointer data,
                    gpointer self)
{
	__lambda49_ ((SlingshotWidgetsSearchView*) self, (GtkWidget*) data);
}

void
slingshot_widgets_search_view_clear (SlingshotWidgetsSearchView* self)
{
	GeeHashMap* _tmp0_;
	GtkListBox* _tmp1_;
	GList* _tmp2_;
	GList* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->limitator;
	gee_abstract_map_clear ((GeeAbstractMap*) _tmp0_);
	_tmp1_ = self->priv->list_box;
	_tmp2_ = gtk_container_get_children ((GtkContainer*) _tmp1_);
	_tmp3_ = _tmp2_;
	g_list_foreach (_tmp3_, ___lambda49__gfunc, self);
	(_tmp3_ == NULL) ? NULL : (_tmp3_ = (g_list_free (_tmp3_), NULL));
}

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

void
slingshot_widgets_search_view_activate_selection (SlingshotWidgetsSearchView* self)
{
	GtkListBoxRow* selection = NULL;
	GtkListBox* _tmp0_;
	GtkListBoxRow* _tmp1_;
	GtkListBoxRow* _tmp2_;
	GtkListBoxRow* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->list_box;
	_tmp1_ = gtk_list_box_get_selected_row (_tmp0_);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	selection = _tmp2_;
	_tmp3_ = selection;
	if (_tmp3_ != NULL) {
		GtkListBox* _tmp4_;
		GtkListBoxRow* _tmp5_;
		_tmp4_ = self->priv->list_box;
		_tmp5_ = selection;
		g_signal_emit_by_name (_tmp4_, "row-activated", _tmp5_);
	}
	_g_object_unref0 (selection);
}

static gint
slingshot_widgets_search_view_update_sort (SlingshotWidgetsSearchView* self,
                                           GtkListBoxRow* row1,
                                           GtkListBoxRow* row2)
{
	SlingshotWidgetsSearchItem* item1 = NULL;
	SlingshotWidgetsSearchItem* _tmp0_;
	SlingshotWidgetsSearchItem* item2 = NULL;
	SlingshotWidgetsSearchItem* _tmp1_;
	SlingshotWidgetsSearchItem* _tmp2_;
	SlingshotWidgetsResultType _tmp3_;
	SlingshotWidgetsResultType _tmp4_;
	SlingshotWidgetsSearchItem* _tmp5_;
	SlingshotWidgetsResultType _tmp6_;
	SlingshotWidgetsResultType _tmp7_;
	gint result;
	g_return_val_if_fail (self != NULL, 0);
	g_return_val_if_fail (row1 != NULL, 0);
	g_return_val_if_fail (row2 != NULL, 0);
	_tmp0_ = _g_object_ref0 (SLINGSHOT_WIDGETS_IS_SEARCH_ITEM (row1) ? ((SlingshotWidgetsSearchItem*) row1) : NULL);
	item1 = _tmp0_;
	_tmp1_ = _g_object_ref0 (SLINGSHOT_WIDGETS_IS_SEARCH_ITEM (row2) ? ((SlingshotWidgetsSearchItem*) row2) : NULL);
	item2 = _tmp1_;
	_tmp2_ = item1;
	_tmp3_ = slingshot_widgets_search_item_get_result_type (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = item2;
	_tmp6_ = slingshot_widgets_search_item_get_result_type (_tmp5_);
	_tmp7_ = _tmp6_;
	if (_tmp4_ != _tmp7_) {
		SlingshotWidgetsSearchItem* _tmp8_;
		SlingshotWidgetsResultType _tmp9_;
		SlingshotWidgetsResultType _tmp10_;
		SlingshotWidgetsSearchItem* _tmp11_;
		SlingshotWidgetsResultType _tmp12_;
		SlingshotWidgetsResultType _tmp13_;
		_tmp8_ = item1;
		_tmp9_ = slingshot_widgets_search_item_get_result_type (_tmp8_);
		_tmp10_ = _tmp9_;
		_tmp11_ = item2;
		_tmp12_ = slingshot_widgets_search_item_get_result_type (_tmp11_);
		_tmp13_ = _tmp12_;
		result = (gint) (_tmp10_ - _tmp13_);
		_g_object_unref0 (item2);
		_g_object_unref0 (item1);
		return result;
	}
	result = 0;
	_g_object_unref0 (item2);
	_g_object_unref0 (item1);
	return result;
}

static void
slingshot_widgets_search_view_update_header (SlingshotWidgetsSearchItem* row,
                                             SlingshotWidgetsSearchItem* before,
                                             SlingshotWidgetsSearchView* self)
{
	gboolean _tmp0_ = FALSE;
	GraniteHeaderLabel* header = NULL;
	SlingshotWidgetsResultType _tmp5_;
	SlingshotWidgetsResultType _tmp6_;
	const gchar* _tmp7_;
	GraniteHeaderLabel* _tmp8_;
	GraniteHeaderLabel* _tmp9_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (row != NULL);
	if (before != NULL) {
		SlingshotWidgetsResultType _tmp1_;
		SlingshotWidgetsResultType _tmp2_;
		SlingshotWidgetsResultType _tmp3_;
		SlingshotWidgetsResultType _tmp4_;
		_tmp1_ = slingshot_widgets_search_item_get_result_type (before);
		_tmp2_ = _tmp1_;
		_tmp3_ = slingshot_widgets_search_item_get_result_type (row);
		_tmp4_ = _tmp3_;
		_tmp0_ = _tmp2_ == _tmp4_;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		gtk_list_box_row_set_header ((GtkListBoxRow*) row, NULL);
		return;
	}
	_tmp5_ = slingshot_widgets_search_item_get_result_type (row);
	_tmp6_ = _tmp5_;
	_tmp7_ = slingshot_widgets_result_type_to_string (_tmp6_);
	_tmp8_ = granite_header_label_new (_tmp7_);
	g_object_ref_sink (_tmp8_);
	header = _tmp8_;
	_tmp9_ = header;
	gtk_list_box_row_set_header ((GtkListBoxRow*) row, (GtkWidget*) _tmp9_);
	_g_object_unref0 (header);
}

SlingshotWidgetsSearchView*
slingshot_widgets_search_view_construct (GType object_type)
{
	SlingshotWidgetsSearchView * self = NULL;
	self = (SlingshotWidgetsSearchView*) g_object_new (object_type, NULL);
	return self;
}

SlingshotWidgetsSearchView*
slingshot_widgets_search_view_new (void)
{
	return slingshot_widgets_search_view_construct (SLINGSHOT_WIDGETS_TYPE_SEARCH_VIEW);
}

static void
g_cclosure_user_marshal_VOID__OBJECT_OBJECT (GClosure * closure,
                                             GValue * return_value,
                                             guint n_param_values,
                                             const GValue * param_values,
                                             gpointer invocation_hint,
                                             gpointer marshal_data)
{
	typedef void (*GMarshalFunc_VOID__OBJECT_OBJECT) (gpointer data1, gpointer arg_1, gpointer arg_2, gpointer data2);
	register GMarshalFunc_VOID__OBJECT_OBJECT callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 3);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__OBJECT_OBJECT) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_object (param_values + 1), g_value_get_object (param_values + 2), data2);
}

static gint
_slingshot_widgets_search_view___lambda52_ (SlingshotWidgetsSearchView* self,
                                            GtkListBoxRow* row1,
                                            GtkListBoxRow* row2)
{
	gint result;
	g_return_val_if_fail (row1 != NULL, 0);
	g_return_val_if_fail (row2 != NULL, 0);
	result = slingshot_widgets_search_view_update_sort (self, row1, row2);
	return result;
}

static gint
__slingshot_widgets_search_view___lambda52__gtk_list_box_sort_func (GtkListBoxRow* row1,
                                                                    GtkListBoxRow* row2,
                                                                    gpointer self)
{
	gint result;
	result = _slingshot_widgets_search_view___lambda52_ ((SlingshotWidgetsSearchView*) self, row1, row2);
	return result;
}

static void
_slingshot_widgets_search_view___lambda53_ (SlingshotWidgetsSearchView* self,
                                            GdkDragContext* ctx)
{
	GtkListBoxRow* selected_row = NULL;
	GtkListBox* _tmp0_;
	GtkListBoxRow* _tmp1_;
	GtkListBoxRow* _tmp2_;
	GtkListBoxRow* _tmp3_;
	g_return_if_fail (ctx != NULL);
	_tmp0_ = self->priv->list_box;
	_tmp1_ = gtk_list_box_get_selected_row (_tmp0_);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	selected_row = _tmp2_;
	_tmp3_ = selected_row;
	if (_tmp3_ != NULL) {
		SlingshotWidgetsSearchItem* drag_item = NULL;
		GtkListBoxRow* _tmp4_;
		SlingshotWidgetsSearchItem* _tmp5_;
		SlingshotWidgetsSearchItem* _tmp6_;
		const gchar* _tmp7_;
		const gchar* _tmp8_;
		gchar* _tmp9_;
		const gchar* _tmp10_;
		_tmp4_ = selected_row;
		_tmp5_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, SLINGSHOT_WIDGETS_TYPE_SEARCH_ITEM, SlingshotWidgetsSearchItem));
		drag_item = _tmp5_;
		_tmp6_ = drag_item;
		_tmp7_ = slingshot_widgets_search_item_get_app_uri (_tmp6_);
		_tmp8_ = _tmp7_;
		_tmp9_ = g_strdup (_tmp8_);
		_g_free0 (self->priv->drag_uri);
		self->priv->drag_uri = _tmp9_;
		_tmp10_ = self->priv->drag_uri;
		if (_tmp10_ != NULL) {
			SlingshotWidgetsSearchItem* _tmp11_;
			GtkImage* _tmp12_;
			GtkImage* _tmp13_;
			GIcon* _tmp14_;
			GIcon* _tmp15_;
			GIcon* _tmp16_;
			_tmp11_ = drag_item;
			_tmp12_ = slingshot_widgets_search_item_get_image (_tmp11_);
			_tmp13_ = _tmp12_;
			g_object_get (_tmp13_, "gicon", &_tmp14_, NULL);
			_tmp15_ = _tmp14_;
			_tmp16_ = _tmp15_;
			gtk_drag_set_icon_gicon (ctx, _tmp16_, 32, 32);
			_g_object_unref0 (_tmp16_);
		}
		g_signal_emit (self, slingshot_widgets_search_view_signals[SLINGSHOT_WIDGETS_SEARCH_VIEW_APP_LAUNCHED_SIGNAL], 0);
		_g_object_unref0 (drag_item);
	}
	_g_object_unref0 (selected_row);
}

static void
__slingshot_widgets_search_view___lambda53__gtk_widget_drag_begin (GtkWidget* _sender,
                                                                   GdkDragContext* context,
                                                                   gpointer self)
{
	_slingshot_widgets_search_view___lambda53_ ((SlingshotWidgetsSearchView*) self, context);
}

static void
_slingshot_widgets_search_view___lambda54_ (SlingshotWidgetsSearchView* self)
{
	const gchar* _tmp0_;
	_tmp0_ = self->priv->drag_uri;
	if (_tmp0_ != NULL) {
		g_signal_emit (self, slingshot_widgets_search_view_signals[SLINGSHOT_WIDGETS_SEARCH_VIEW_APP_LAUNCHED_SIGNAL], 0);
	}
	_g_free0 (self->priv->drag_uri);
	self->priv->drag_uri = NULL;
}

static void
__slingshot_widgets_search_view___lambda54__gtk_widget_drag_end (GtkWidget* _sender,
                                                                 GdkDragContext* context,
                                                                 gpointer self)
{
	_slingshot_widgets_search_view___lambda54_ ((SlingshotWidgetsSearchView*) self);
}

static void
_slingshot_widgets_search_view___lambda55_ (SlingshotWidgetsSearchView* self,
                                            GdkDragContext* ctx,
                                            GtkSelectionData* sel,
                                            guint info,
                                            guint time)
{
	const gchar* _tmp0_;
	g_return_if_fail (ctx != NULL);
	g_return_if_fail (sel != NULL);
	_tmp0_ = self->priv->drag_uri;
	if (_tmp0_ != NULL) {
		const gchar* _tmp1_;
		gchar* _tmp2_;
		gchar** _tmp3_;
		gchar** _tmp4_;
		gint _tmp4__length1;
		_tmp1_ = self->priv->drag_uri;
		_tmp2_ = g_strdup (_tmp1_);
		_tmp3_ = g_new0 (gchar*, 1 + 1);
		_tmp3_[0] = _tmp2_;
		_tmp4_ = _tmp3_;
		_tmp4__length1 = 1;
		gtk_selection_data_set_uris (sel, _tmp4_);
		_tmp4_ = (_vala_array_free (_tmp4_, _tmp4__length1, (GDestroyNotify) g_free), NULL);
	}
}

static void
__slingshot_widgets_search_view___lambda55__gtk_widget_drag_data_get (GtkWidget* _sender,
                                                                      GdkDragContext* context,
                                                                      GtkSelectionData* selection_data,
                                                                      guint info,
                                                                      guint time_,
                                                                      gpointer self)
{
	_slingshot_widgets_search_view___lambda55_ ((SlingshotWidgetsSearchView*) self, context, selection_data, info, time_);
}

static void
_slingshot_widgets_search_view_move_cursor_gtk_list_box_move_cursor (GtkListBox* _sender,
                                                                     GtkMovementStep step,
                                                                     gint count,
                                                                     gpointer self)
{
	slingshot_widgets_search_view_move_cursor ((SlingshotWidgetsSearchView*) self, step, count);
}

static Block14Data*
block14_data_ref (Block14Data* _data14_)
{
	g_atomic_int_inc (&_data14_->_ref_count_);
	return _data14_;
}

static void
block14_data_unref (void * _userdata_)
{
	Block14Data* _data14_;
	_data14_ = (Block14Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data14_->_ref_count_)) {
		SlingshotWidgetsSearchView* self;
		self = _data14_->self;
		_g_object_unref0 (_data14_->row);
		_g_object_unref0 (self);
		g_slice_free (Block14Data, _data14_);
	}
}

static gboolean
__lambda57_ (Block14Data* _data14_)
{
	SlingshotWidgetsSearchView* self;
	SlingshotWidgetsSearchItem* search_item = NULL;
	SlingshotWidgetsSearchItem* _tmp0_;
	SlingshotWidgetsSearchItem* _tmp1_;
	SlingshotWidgetsResultType _tmp2_;
	SlingshotWidgetsResultType _tmp3_;
	gboolean result;
	self = _data14_->self;
	_tmp0_ = _g_object_ref0 (SLINGSHOT_WIDGETS_IS_SEARCH_ITEM (_data14_->row) ? ((SlingshotWidgetsSearchItem*) _data14_->row) : NULL);
	search_item = _tmp0_;
	_tmp1_ = search_item;
	_tmp2_ = slingshot_widgets_search_item_get_result_type (_tmp1_);
	_tmp3_ = _tmp2_;
	switch (_tmp3_) {
		case SLINGSHOT_WIDGETS_RESULT_TYPE_APP_ACTIONS:
		case SLINGSHOT_WIDGETS_RESULT_TYPE_LINK:
		case SLINGSHOT_WIDGETS_RESULT_TYPE_SETTINGS:
		case SLINGSHOT_WIDGETS_RESULT_TYPE_BOOKMARK:
		case SLINGSHOT_WIDGETS_RESULT_TYPE_CALCULATION:
		case SLINGSHOT_WIDGETS_RESULT_TYPE_TEXT:
		{
			SlingshotWidgetsSearchItem* _tmp4_;
			SlingshotBackendApp* _tmp5_;
			SlingshotBackendApp* _tmp6_;
			SynapseMatch* _tmp7_;
			SynapseMatch* _tmp8_;
			_tmp4_ = search_item;
			_tmp5_ = slingshot_widgets_search_item_get_app (_tmp4_);
			_tmp6_ = _tmp5_;
			_tmp7_ = slingshot_backend_app_get_match (_tmp6_);
			_tmp8_ = _tmp7_;
			synapse_match_execute (_tmp8_, NULL);
			break;
		}
		default:
		{
			SlingshotWidgetsSearchItem* _tmp9_;
			SlingshotBackendApp* _tmp10_;
			SlingshotBackendApp* _tmp11_;
			_tmp9_ = search_item;
			_tmp10_ = slingshot_widgets_search_item_get_app (_tmp9_);
			_tmp11_ = _tmp10_;
			slingshot_backend_app_launch (_tmp11_);
			break;
		}
	}
	g_signal_emit (self, slingshot_widgets_search_view_signals[SLINGSHOT_WIDGETS_SEARCH_VIEW_APP_LAUNCHED_SIGNAL], 0);
	result = FALSE;
	_g_object_unref0 (search_item);
	return result;
}

static gboolean
___lambda57__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda57_ (self);
	return result;
}

static void
_slingshot_widgets_search_view___lambda56_ (SlingshotWidgetsSearchView* self,
                                            GtkListBoxRow* row)
{
	Block14Data* _data14_;
	GtkListBoxRow* _tmp0_;
	g_return_if_fail (row != NULL);
	_data14_ = g_slice_new0 (Block14Data);
	_data14_->_ref_count_ = 1;
	_data14_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (row);
	_g_object_unref0 (_data14_->row);
	_data14_->row = _tmp0_;
	g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, ___lambda57__gsource_func, block14_data_ref (_data14_), block14_data_unref);
	block14_data_unref (_data14_);
	_data14_ = NULL;
}

static void
__slingshot_widgets_search_view___lambda56__gtk_list_box_row_activated (GtkListBox* _sender,
                                                                        GtkListBoxRow* row,
                                                                        gpointer self)
{
	_slingshot_widgets_search_view___lambda56_ ((SlingshotWidgetsSearchView*) self, row);
}

static GdkEvent*
_vala_GdkEvent_copy (GdkEvent* self)
{
	return g_boxed_copy (gdk_event_get_type (), self);
}

static gpointer
__vala_GdkEvent_copy0 (gpointer self)
{
	return self ? _vala_GdkEvent_copy (self) : NULL;
}

static void
_vala_GdkEvent_free (GdkEvent* self)
{
	g_boxed_free (gdk_event_get_type (), self);
}

static void
_vala_GdkEventSequence_free (GdkEventSequence* self)
{
	g_boxed_free (gdk_event_sequence_get_type (), self);
}

static void
_slingshot_widgets_search_view___lambda58_ (SlingshotWidgetsSearchView* self,
                                            gint n_press,
                                            gdouble x,
                                            gdouble y)
{
	SlingshotWidgetsSearchItem* search_item = NULL;
	GtkListBox* _tmp0_;
	GtkListBoxRow* _tmp1_;
	SlingshotWidgetsSearchItem* _tmp2_;
	GdkEventSequence* sequence = NULL;
	GtkGestureMultiPress* _tmp3_;
	GdkEventSequence* _tmp4_;
	GdkEvent* event = NULL;
	GtkGestureMultiPress* _tmp5_;
	GdkEventSequence* _tmp6_;
	GdkEvent* _tmp7_;
	GdkEvent* _tmp8_;
	GdkEvent* _tmp9_;
	_tmp0_ = self->priv->list_box;
	_tmp1_ = gtk_list_box_get_selected_row (_tmp0_);
	_tmp2_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, SLINGSHOT_WIDGETS_TYPE_SEARCH_ITEM, SlingshotWidgetsSearchItem));
	search_item = _tmp2_;
	_tmp3_ = self->priv->click_controller;
	_tmp4_ = gtk_gesture_single_get_current_sequence ((GtkGestureSingle*) _tmp3_);
	sequence = _tmp4_;
	_tmp5_ = self->priv->click_controller;
	_tmp6_ = sequence;
	_tmp7_ = gtk_gesture_get_last_event ((GtkGesture*) _tmp5_, _tmp6_);
	_tmp8_ = __vala_GdkEvent_copy0 (_tmp7_);
	event = _tmp8_;
	_tmp9_ = event;
	if (gdk_event_triggers_context_menu (_tmp9_)) {
		GtkMenu* _tmp10_ = NULL;
		SlingshotWidgetsSearchItem* _tmp11_;
		GtkMenu* _tmp12_;
		GtkGestureMultiPress* _tmp13_;
		GtkGestureMultiPress* _tmp14_;
		_tmp11_ = search_item;
		_tmp12_ = slingshot_widgets_search_item_create_context_menu (_tmp11_);
		_tmp10_ = _tmp12_;
		if (_tmp10_ != NULL) {
			gtk_menu_popup_at_pointer (_tmp10_, NULL);
		}
		_tmp13_ = self->priv->click_controller;
		gtk_gesture_set_state ((GtkGesture*) _tmp13_, GTK_EVENT_SEQUENCE_CLAIMED);
		_tmp14_ = self->priv->click_controller;
		gtk_event_controller_reset ((GtkEventController*) _tmp14_);
		_g_object_unref0 (_tmp10_);
	}
	__vala_GdkEvent_free0 (event);
	__vala_GdkEventSequence_free0 (sequence);
	_g_object_unref0 (search_item);
}

static void
__slingshot_widgets_search_view___lambda58__gtk_gesture_multi_press_pressed (GtkGestureMultiPress* _sender,
                                                                             gint n_press,
                                                                             gdouble x,
                                                                             gdouble y,
                                                                             gpointer self)
{
	_slingshot_widgets_search_view___lambda58_ ((SlingshotWidgetsSearchView*) self, n_press, x, y);
}

static void
_slingshot_widgets_search_view___lambda59_ (SlingshotWidgetsSearchView* self,
                                            guint keyval,
                                            guint keycode,
                                            GdkModifierType state)
{
	SlingshotWidgetsSearchItem* search_item = NULL;
	GtkListBox* _tmp0_;
	GtkListBoxRow* _tmp1_;
	SlingshotWidgetsSearchItem* _tmp2_;
	GdkModifierType mods = 0U;
	_tmp0_ = self->priv->list_box;
	_tmp1_ = gtk_list_box_get_selected_row (_tmp0_);
	_tmp2_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, SLINGSHOT_WIDGETS_TYPE_SEARCH_ITEM, SlingshotWidgetsSearchItem));
	search_item = _tmp2_;
	mods = state & gtk_accelerator_get_default_mod_mask ();
	switch (keyval) {
		case GDK_KEY_F10:
		{
			if (mods == GDK_SHIFT_MASK) {
				GtkMenu* _tmp3_ = NULL;
				SlingshotWidgetsSearchItem* _tmp4_;
				GtkMenu* _tmp5_;
				_tmp4_ = search_item;
				_tmp5_ = slingshot_widgets_search_item_create_context_menu (_tmp4_);
				_tmp3_ = _tmp5_;
				if (_tmp3_ != NULL) {
					gtk_menu_popup_at_widget (_tmp3_, (GtkWidget*) self, GDK_GRAVITY_EAST, GDK_GRAVITY_CENTER, NULL);
				}
				_g_object_unref0 (_tmp3_);
			}
			break;
		}
		case GDK_KEY_Menu:
		case GDK_KEY_MenuKB:
		{
			GtkMenu* _tmp6_ = NULL;
			SlingshotWidgetsSearchItem* _tmp7_;
			GtkMenu* _tmp8_;
			_tmp7_ = search_item;
			_tmp8_ = slingshot_widgets_search_item_create_context_menu (_tmp7_);
			_tmp6_ = _tmp8_;
			if (_tmp6_ != NULL) {
				gtk_menu_popup_at_widget (_tmp6_, (GtkWidget*) self, GDK_GRAVITY_EAST, GDK_GRAVITY_CENTER, NULL);
			}
			_g_object_unref0 (_tmp6_);
			break;
		}
		default:
		{
			_g_object_unref0 (search_item);
			return;
		}
	}
	_g_object_unref0 (search_item);
}

static void
__slingshot_widgets_search_view___lambda59__gtk_event_controller_key_key_released (GtkEventControllerKey* _sender,
                                                                                   guint keyval,
                                                                                   guint keycode,
                                                                                   GdkModifierType state,
                                                                                   gpointer self)
{
	_slingshot_widgets_search_view___lambda59_ ((SlingshotWidgetsSearchView*) self, keyval, keycode, state);
}

static GObject *
slingshot_widgets_search_view_constructor (GType type,
                                           guint n_construct_properties,
                                           GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	SlingshotWidgetsSearchView * self;
	GraniteWidgetsAlertView* _tmp0_;
	GraniteWidgetsAlertView* _tmp1_;
	GeeHashMap* _tmp2_;
	static const GtkTargetEntry DND = {"text/uri-list", (guint) 0, (guint) 0};
	GtkTargetEntry* _tmp3_;
	GtkTargetEntry* _tmp4_;
	gint _tmp4__length1;
	GtkListBox* _tmp5_ = NULL;
	GtkListBox* _tmp6_;
	GtkListBox* _tmp7_;
	GtkListBox* _tmp8_;
	GraniteWidgetsAlertView* _tmp9_;
	GtkScrolledWindow* scrolled_window = NULL;
	GtkListBox* _tmp10_;
	GtkWidget* _tmp11_;
	GtkScrolledWindow* _tmp12_ = NULL;
	GtkScrolledWindow* _tmp13_;
	GtkListBox* _tmp14_;
	GtkListBox* _tmp15_;
	GtkListBox* _tmp16_;
	GtkListBox* _tmp17_;
	GtkListBox* _tmp18_;
	GtkListBox* _tmp19_;
	GtkGestureMultiPress* _tmp20_ = NULL;
	GtkGestureMultiPress* _tmp21_;
	GtkListBox* _tmp22_;
	GtkEventControllerKey* _tmp23_;
	GtkEventControllerKey* _tmp24_;
	parent_class = G_OBJECT_CLASS (slingshot_widgets_search_view_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SLINGSHOT_WIDGETS_TYPE_SEARCH_VIEW, SlingshotWidgetsSearchView);
	_tmp0_ = granite_widgets_alert_view_new ("", _ ("Try changing search terms."), "edit-find-symbolic");
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->alert_view);
	self->priv->alert_view = _tmp0_;
	_tmp1_ = self->priv->alert_view;
	gtk_widget_show_all ((GtkWidget*) _tmp1_);
	_tmp2_ = gee_hash_map_new (SLINGSHOT_WIDGETS_TYPE_RESULT_TYPE, NULL, NULL, G_TYPE_UINT, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->limitator);
	self->priv->limitator = _tmp2_;
	_tmp3_ = g_new0 (GtkTargetEntry, 1);
	_tmp3_[0] = DND;
	_tmp4_ = _tmp3_;
	_tmp4__length1 = 1;
	gtk_drag_source_set ((GtkWidget*) self, GDK_BUTTON1_MASK, _tmp4_, (gint) 1, GDK_ACTION_COPY);
	_tmp4_ = (g_free (_tmp4_), NULL);
	_tmp5_ = (GtkListBox*) gtk_list_box_new ();
	gtk_list_box_set_activate_on_single_click (_tmp5_, TRUE);
	gtk_list_box_set_selection_mode (_tmp5_, GTK_SELECTION_BROWSE);
	g_object_ref_sink (_tmp5_);
	_g_object_unref0 (self->priv->list_box);
	self->priv->list_box = _tmp5_;
	_tmp6_ = self->priv->list_box;
	gtk_list_box_set_sort_func (_tmp6_, __slingshot_widgets_search_view___lambda52__gtk_list_box_sort_func, g_object_ref (self), g_object_unref);
	_tmp7_ = self->priv->list_box;
	gtk_list_box_set_header_func (_tmp7_, (GtkListBoxUpdateHeaderFunc) slingshot_widgets_search_view_update_header, g_object_ref (self), g_object_unref);
	_tmp8_ = self->priv->list_box;
	_tmp9_ = self->priv->alert_view;
	gtk_list_box_set_placeholder (_tmp8_, (GtkWidget*) _tmp9_);
	_tmp10_ = self->priv->list_box;
	_tmp11_ = _g_object_ref0 ((GtkWidget*) _tmp10_);
	_tmp12_ = (GtkScrolledWindow*) gtk_scrolled_window_new (NULL, NULL);
	g_object_set ((GtkContainer*) _tmp12_, "child", _tmp11_, NULL);
	_g_object_unref0 (_tmp11_);
	g_object_set (_tmp12_, "hscrollbar-policy", GTK_POLICY_NEVER, NULL);
	g_object_ref_sink (_tmp12_);
	scrolled_window = _tmp12_;
	_tmp13_ = scrolled_window;
	g_object_set ((GtkContainer*) self, "child", (GtkWidget*) _tmp13_, NULL);
	_tmp14_ = self->priv->list_box;
	g_signal_connect_object ((GtkWidget*) _tmp14_, "drag-begin", (GCallback) __slingshot_widgets_search_view___lambda53__gtk_widget_drag_begin, self, 0);
	_tmp15_ = self->priv->list_box;
	g_signal_connect_object ((GtkWidget*) _tmp15_, "drag-end", (GCallback) __slingshot_widgets_search_view___lambda54__gtk_widget_drag_end, self, 0);
	_tmp16_ = self->priv->list_box;
	g_signal_connect_object ((GtkWidget*) _tmp16_, "drag-data-get", (GCallback) __slingshot_widgets_search_view___lambda55__gtk_widget_drag_data_get, self, 0);
	_tmp17_ = self->priv->list_box;
	g_signal_connect_object (_tmp17_, "move-cursor", (GCallback) _slingshot_widgets_search_view_move_cursor_gtk_list_box_move_cursor, self, 0);
	_tmp18_ = self->priv->list_box;
	g_signal_connect_object (_tmp18_, "row-activated", (GCallback) __slingshot_widgets_search_view___lambda56__gtk_list_box_row_activated, self, 0);
	_tmp19_ = self->priv->list_box;
	_tmp20_ = (GtkGestureMultiPress*) gtk_gesture_multi_press_new ((GtkWidget*) _tmp19_);
	gtk_gesture_single_set_button ((GtkGestureSingle*) _tmp20_, (guint) 0);
	gtk_gesture_single_set_exclusive ((GtkGestureSingle*) _tmp20_, TRUE);
	_g_object_unref0 (self->priv->click_controller);
	self->priv->click_controller = _tmp20_;
	_tmp21_ = self->priv->click_controller;
	g_signal_connect_object (_tmp21_, "pressed", (GCallback) __slingshot_widgets_search_view___lambda58__gtk_gesture_multi_press_pressed, self, 0);
	_tmp22_ = self->priv->list_box;
	_tmp23_ = (GtkEventControllerKey*) gtk_event_controller_key_new ((GtkWidget*) _tmp22_);
	_g_object_unref0 (self->priv->menu_key_controller);
	self->priv->menu_key_controller = _tmp23_;
	_tmp24_ = self->priv->menu_key_controller;
	g_signal_connect_object (_tmp24_, "key-released", (GCallback) __slingshot_widgets_search_view___lambda59__gtk_event_controller_key_key_released, self, 0);
	_g_object_unref0 (scrolled_window);
	return obj;
}

static void
slingshot_widgets_search_view_class_init (SlingshotWidgetsSearchViewClass * klass,
                                          gpointer klass_data)
{
	slingshot_widgets_search_view_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &SlingshotWidgetsSearchView_private_offset);
	G_OBJECT_CLASS (klass)->constructor = slingshot_widgets_search_view_constructor;
	G_OBJECT_CLASS (klass)->finalize = slingshot_widgets_search_view_finalize;
	slingshot_widgets_search_view_signals[SLINGSHOT_WIDGETS_SEARCH_VIEW_START_SEARCH_SIGNAL] = g_signal_new ("start-search", SLINGSHOT_WIDGETS_TYPE_SEARCH_VIEW, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OBJECT_OBJECT, G_TYPE_NONE, 2, SYNAPSE_TYPE_SEARCH_MATCH, SYNAPSE_TYPE_MATCH);
	slingshot_widgets_search_view_signals[SLINGSHOT_WIDGETS_SEARCH_VIEW_APP_LAUNCHED_SIGNAL] = g_signal_new ("app-launched", SLINGSHOT_WIDGETS_TYPE_SEARCH_VIEW, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
slingshot_widgets_search_view_instance_init (SlingshotWidgetsSearchView * self,
                                             gpointer klass)
{
	self->priv = slingshot_widgets_search_view_get_instance_private (self);
	self->priv->drag_uri = NULL;
}

static void
slingshot_widgets_search_view_finalize (GObject * obj)
{
	SlingshotWidgetsSearchView * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SLINGSHOT_WIDGETS_TYPE_SEARCH_VIEW, SlingshotWidgetsSearchView);
	_g_object_unref0 (self->priv->alert_view);
	_g_object_unref0 (self->priv->list_box);
	_g_object_unref0 (self->priv->limitator);
	_g_free0 (self->priv->drag_uri);
	_g_object_unref0 (self->priv->click_controller);
	_g_object_unref0 (self->priv->menu_key_controller);
	G_OBJECT_CLASS (slingshot_widgets_search_view_parent_class)->finalize (obj);
}

static GType
slingshot_widgets_search_view_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (SlingshotWidgetsSearchViewClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) slingshot_widgets_search_view_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SlingshotWidgetsSearchView), 0, (GInstanceInitFunc) slingshot_widgets_search_view_instance_init, NULL };
	GType slingshot_widgets_search_view_type_id;
	slingshot_widgets_search_view_type_id = g_type_register_static (gtk_bin_get_type (), "SlingshotWidgetsSearchView", &g_define_type_info, 0);
	SlingshotWidgetsSearchView_private_offset = g_type_add_instance_private (slingshot_widgets_search_view_type_id, sizeof (SlingshotWidgetsSearchViewPrivate));
	return slingshot_widgets_search_view_type_id;
}

GType
slingshot_widgets_search_view_get_type (void)
{
	static volatile gsize slingshot_widgets_search_view_type_id__once = 0;
	if (g_once_init_enter (&slingshot_widgets_search_view_type_id__once)) {
		GType slingshot_widgets_search_view_type_id;
		slingshot_widgets_search_view_type_id = slingshot_widgets_search_view_get_type_once ();
		g_once_init_leave (&slingshot_widgets_search_view_type_id__once, slingshot_widgets_search_view_type_id);
	}
	return slingshot_widgets_search_view_type_id__once;
}

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);
}

