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

/*
 * Copyright 2019 elementary, Inc. (https://elementary.io)
 *           2011-2012 Giulio Collura
 *
 * 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 3 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, see <http://www.gnu.org/licenses/>.
 */

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

#define SLINGSHOT_WIDGETS_APP_BUTTON_ICON_SIZE 64
#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_APP_BUTTON_0_PROPERTY,
	SLINGSHOT_WIDGETS_APP_BUTTON_APP_PROPERTY,
	SLINGSHOT_WIDGETS_APP_BUTTON_NUM_PROPERTIES
};
static GParamSpec* slingshot_widgets_app_button_properties[SLINGSHOT_WIDGETS_APP_BUTTON_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 _Block5Data Block5Data;
enum  {
	SLINGSHOT_WIDGETS_APP_BUTTON_APP_LAUNCHED_SIGNAL,
	SLINGSHOT_WIDGETS_APP_BUTTON_NUM_SIGNALS
};
static guint slingshot_widgets_app_button_signals[SLINGSHOT_WIDGETS_APP_BUTTON_NUM_SIGNALS] = {0};

struct _SlingshotWidgetsAppButtonPrivate {
	SlingshotBackendApp* _app;
	GtkLabel* badge;
	gboolean dragging;
	GtkPopover* tooltip_popover;
	gchar* tooltip_text_str;
	guint delay_ms;
	guint timeout_id;
	SlingshotAppContextMenu* ctx_menu;
};

struct _Block5Data {
	int _ref_count_;
	SlingshotWidgetsAppButton* self;
	GraniteAsyncImage* image;
};

static gint SlingshotWidgetsAppButton_private_offset;
static gpointer slingshot_widgets_app_button_parent_class = NULL;
static GType slingshot_widgets_app_button_type_id = 0;

static gboolean __lambda40_ (SlingshotWidgetsAppButton* self,
                      GdkEventCrossing* ev);
static gboolean ___lambda41_ (SlingshotWidgetsAppButton* self);
static gboolean ____lambda41__gsource_func (gpointer self);
static gboolean ___lambda40__gtk_widget_enter_notify_event (GtkWidget* _sender,
                                                     GdkEventCrossing* event,
                                                     gpointer self);
static gboolean __lambda42_ (SlingshotWidgetsAppButton* self,
                      GdkEventCrossing* ev);
static gboolean ___lambda42__gtk_widget_leave_notify_event (GtkWidget* _sender,
                                                     GdkEventCrossing* event,
                                                     gpointer self);
static void slingshot_widgets_app_button_show_context_menu_at (SlingshotWidgetsAppButton* self,
                                                        gdouble x,
                                                        gdouble y);
static void __lambda43_ (SlingshotWidgetsAppButton* self);
static void ___lambda43__slingshot_app_context_menu_app_launched (SlingshotAppContextMenu* _sender,
                                                           gpointer self);
static GObject * slingshot_widgets_app_button_constructor (GType type,
                                                    guint n_construct_properties,
                                                    GObjectConstructParam * construct_properties);
static Block5Data* block5_data_ref (Block5Data* _data5_);
static void block5_data_unref (void * _userdata_);
static gboolean _slingshot_widgets_app_button___lambda44_ (SlingshotWidgetsAppButton* self,
                                                    GdkEventButton* e);
static gboolean __slingshot_widgets_app_button___lambda44__gtk_widget_button_press_event (GtkWidget* _sender,
                                                                                   GdkEventButton* event,
                                                                                   gpointer self);
static gboolean _slingshot_widgets_app_button___lambda45_ (SlingshotWidgetsAppButton* self,
                                                    GdkEventKey* e);
static gboolean __slingshot_widgets_app_button___lambda45__gtk_widget_key_press_event (GtkWidget* _sender,
                                                                                GdkEventKey* event,
                                                                                gpointer self);
static void _slingshot_widgets_app_button___lambda46_ (Block5Data* _data5_);
static void __slingshot_widgets_app_button___lambda46__g_object_notify (GObject* _sender,
                                                                 GParamSpec* pspec,
                                                                 gpointer self);
static void slingshot_widgets_app_button_finalize (GObject * obj);
static void _vala_slingshot_widgets_app_button_get_property (GObject * object,
                                                      guint property_id,
                                                      GValue * value,
                                                      GParamSpec * pspec);
static void _vala_slingshot_widgets_app_button_set_property (GObject * object,
                                                      guint property_id,
                                                      const GValue * value,
                                                      GParamSpec * pspec);

static inline gpointer
slingshot_widgets_app_button_get_instance_private (SlingshotWidgetsAppButton* self)
{
	return G_STRUCT_MEMBER_P (self, SlingshotWidgetsAppButton_private_offset);
}

static gboolean
___lambda41_ (SlingshotWidgetsAppButton* self)
{
	GtkPopover* _tmp0_;
	gboolean result;
	self->priv->timeout_id = (guint) 0;
	_tmp0_ = self->priv->tooltip_popover;
	if (_tmp0_ == NULL) {
		GtkPopover* _tmp1_;
		GtkPopover* _tmp2_;
		GtkLabel* msg = NULL;
		const gchar* _tmp3_;
		GtkLabel* _tmp4_;
		GtkPopover* _tmp5_;
		GtkLabel* _tmp6_;
		GtkLabel* _tmp7_;
		GtkPopover* _tmp8_;
		GtkPopover* _tmp9_;
		_tmp1_ = (GtkPopover*) gtk_popover_new ((GtkWidget*) self);
		g_object_ref_sink (_tmp1_);
		_g_object_unref0 (self->priv->tooltip_popover);
		self->priv->tooltip_popover = _tmp1_;
		_tmp2_ = self->priv->tooltip_popover;
		gtk_popover_set_position (_tmp2_, GTK_POS_BOTTOM);
		_tmp3_ = self->priv->tooltip_text_str;
		_tmp4_ = (GtkLabel*) gtk_label_new (_tmp3_);
		g_object_ref_sink (_tmp4_);
		msg = _tmp4_;
		_tmp5_ = self->priv->tooltip_popover;
		_tmp6_ = msg;
		gtk_container_add ((GtkContainer*) _tmp5_, (GtkWidget*) _tmp6_);
		_tmp7_ = msg;
		gtk_widget_show ((GtkWidget*) _tmp7_);
		_tmp8_ = self->priv->tooltip_popover;
		gtk_popover_set_modal (_tmp8_, FALSE);
		_tmp9_ = self->priv->tooltip_popover;
		gtk_widget_show_all ((GtkWidget*) _tmp9_);
		_g_object_unref0 (msg);
	}
	result = FALSE;
	return result;
}

static gboolean
____lambda41__gsource_func (gpointer self)
{
	gboolean result;
	result = ___lambda41_ ((SlingshotWidgetsAppButton*) self);
	return result;
}

static gboolean
__lambda40_ (SlingshotWidgetsAppButton* self,
             GdkEventCrossing* ev)
{
	gboolean result;
	g_return_val_if_fail (ev != NULL, FALSE);
	if (self->priv->timeout_id == ((guint) 0)) {
		self->priv->timeout_id = g_timeout_add_full (G_PRIORITY_DEFAULT, self->priv->delay_ms, ____lambda41__gsource_func, g_object_ref (self), g_object_unref);
	}
	result = FALSE;
	return result;
}

static gboolean
___lambda40__gtk_widget_enter_notify_event (GtkWidget* _sender,
                                            GdkEventCrossing* event,
                                            gpointer self)
{
	gboolean result;
	result = __lambda40_ ((SlingshotWidgetsAppButton*) self, event);
	return result;
}

static gboolean
__lambda42_ (SlingshotWidgetsAppButton* self,
             GdkEventCrossing* ev)
{
	GtkPopover* _tmp0_;
	gboolean result;
	g_return_val_if_fail (ev != NULL, FALSE);
	if (self->priv->timeout_id != ((guint) 0)) {
		g_source_remove (self->priv->timeout_id);
		self->priv->timeout_id = (guint) 0;
	}
	_tmp0_ = self->priv->tooltip_popover;
	if (_tmp0_ != NULL) {
		GtkPopover* _tmp1_;
		GtkPopover* _tmp2_;
		_tmp1_ = self->priv->tooltip_popover;
		gtk_widget_hide ((GtkWidget*) _tmp1_);
		_tmp2_ = self->priv->tooltip_popover;
		gtk_widget_destroy ((GtkWidget*) _tmp2_);
		_g_object_unref0 (self->priv->tooltip_popover);
		self->priv->tooltip_popover = NULL;
	}
	result = FALSE;
	return result;
}

static gboolean
___lambda42__gtk_widget_leave_notify_event (GtkWidget* _sender,
                                            GdkEventCrossing* event,
                                            gpointer self)
{
	gboolean result;
	result = __lambda42_ ((SlingshotWidgetsAppButton*) self, event);
	return result;
}

SlingshotWidgetsAppButton*
slingshot_widgets_app_button_construct (GType object_type,
                                        SlingshotBackendApp* app)
{
	SlingshotWidgetsAppButton * self = NULL;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	g_return_val_if_fail (app != NULL, NULL);
	self = (SlingshotWidgetsAppButton*) g_object_new (object_type, "app", app, NULL);
	_tmp0_ = slingshot_backend_app_get_description (app);
	_tmp1_ = _tmp0_;
	_tmp2_ = g_strdup (_tmp1_);
	_g_free0 (self->priv->tooltip_text_str);
	self->priv->tooltip_text_str = _tmp2_;
	gtk_widget_add_events ((GtkWidget*) self, (gint) (GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK));
	g_signal_connect_object ((GtkWidget*) self, "enter-notify-event", (GCallback) ___lambda40__gtk_widget_enter_notify_event, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "leave-notify-event", (GCallback) ___lambda42__gtk_widget_leave_notify_event, self, 0);
	return self;
}

SlingshotWidgetsAppButton*
slingshot_widgets_app_button_new (SlingshotBackendApp* app)
{
	return slingshot_widgets_app_button_construct (SLINGSHOT_WIDGETS_TYPE_APP_BUTTON, app);
}

void
slingshot_widgets_app_button_launch_app (SlingshotWidgetsAppButton* self)
{
	SlingshotBackendApp* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_app;
	slingshot_backend_app_launch (_tmp0_);
	g_signal_emit (self, slingshot_widgets_app_button_signals[SLINGSHOT_WIDGETS_APP_BUTTON_APP_LAUNCHED_SIGNAL], 0);
}

static void
__lambda43_ (SlingshotWidgetsAppButton* self)
{
	g_signal_emit (self, slingshot_widgets_app_button_signals[SLINGSHOT_WIDGETS_APP_BUTTON_APP_LAUNCHED_SIGNAL], 0);
}

static void
___lambda43__slingshot_app_context_menu_app_launched (SlingshotAppContextMenu* _sender,
                                                      gpointer self)
{
	__lambda43_ ((SlingshotWidgetsAppButton*) self);
}

static void
slingshot_widgets_app_button_show_context_menu_at (SlingshotWidgetsAppButton* self,
                                                   gdouble x,
                                                   gdouble y)
{
	GtkPopover* _tmp0_;
	SlingshotBackendApp* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	SlingshotBackendApp* _tmp6_;
	const gchar* _tmp7_;
	const gchar* _tmp8_;
	SlingshotAppContextMenu* _tmp9_;
	SlingshotAppContextMenu* _tmp10_;
	SlingshotAppContextMenu* _tmp11_;
	gboolean _tmp12_;
	gboolean _tmp13_;
	SlingshotAppContextMenu* _tmp14_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->tooltip_popover;
	if (_tmp0_ != NULL) {
		GtkPopover* _tmp1_;
		GtkPopover* _tmp2_;
		_tmp1_ = self->priv->tooltip_popover;
		gtk_widget_hide ((GtkWidget*) _tmp1_);
		_tmp2_ = self->priv->tooltip_popover;
		gtk_widget_destroy ((GtkWidget*) _tmp2_);
		_g_object_unref0 (self->priv->tooltip_popover);
		self->priv->tooltip_popover = NULL;
	}
	if (self->priv->timeout_id != ((guint) 0)) {
		g_source_remove (self->priv->timeout_id);
		self->priv->timeout_id = (guint) 0;
	}
	_tmp3_ = self->priv->_app;
	_tmp4_ = slingshot_backend_app_get_desktop_id (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = self->priv->_app;
	_tmp7_ = slingshot_backend_app_get_desktop_path (_tmp6_);
	_tmp8_ = _tmp7_;
	_tmp9_ = slingshot_app_context_menu_new (_tmp5_, _tmp8_, (GtkWidget*) self);
	g_object_ref_sink (_tmp9_);
	_g_object_unref0 (self->priv->ctx_menu);
	self->priv->ctx_menu = _tmp9_;
	_tmp10_ = self->priv->ctx_menu;
	g_signal_connect_object (_tmp10_, "app-launched", (GCallback) ___lambda43__slingshot_app_context_menu_app_launched, self, 0);
	_tmp11_ = self->priv->ctx_menu;
	_tmp12_ = slingshot_app_context_menu_get_has_items (_tmp11_);
	_tmp13_ = _tmp12_;
	if (!_tmp13_) {
		return;
	}
	_tmp14_ = self->priv->ctx_menu;
	slingshot_app_context_menu_popup_at_pointer_coords (_tmp14_, x, y);
}

SlingshotBackendApp*
slingshot_widgets_app_button_get_app (SlingshotWidgetsAppButton* self)
{
	SlingshotBackendApp* result;
	SlingshotBackendApp* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_app;
	result = _tmp0_;
	return result;
}

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

static void
slingshot_widgets_app_button_set_app (SlingshotWidgetsAppButton* self,
                                      SlingshotBackendApp* value)
{
	SlingshotBackendApp* old_value;
	g_return_if_fail (self != NULL);
	old_value = slingshot_widgets_app_button_get_app (self);
	if (old_value != value) {
		SlingshotBackendApp* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_app);
		self->priv->_app = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, slingshot_widgets_app_button_properties[SLINGSHOT_WIDGETS_APP_BUTTON_APP_PROPERTY]);
	}
}

static Block5Data*
block5_data_ref (Block5Data* _data5_)
{
	g_atomic_int_inc (&_data5_->_ref_count_);
	return _data5_;
}

static void
block5_data_unref (void * _userdata_)
{
	Block5Data* _data5_;
	_data5_ = (Block5Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data5_->_ref_count_)) {
		SlingshotWidgetsAppButton* self;
		self = _data5_->self;
		_g_object_unref0 (_data5_->image);
		_g_object_unref0 (self);
		g_slice_free (Block5Data, _data5_);
	}
}

static gboolean
_slingshot_widgets_app_button___lambda44_ (SlingshotWidgetsAppButton* self,
                                           GdkEventButton* e)
{
	gboolean result;
	g_return_val_if_fail (e != NULL, FALSE);
	switch (e->button) {
		case 1:
		{
			slingshot_widgets_app_button_launch_app (self);
			result = GDK_EVENT_STOP;
			return result;
		}
		case 3:
		{
			slingshot_widgets_app_button_show_context_menu_at (self, e->x, e->y);
			result = GDK_EVENT_STOP;
			return result;
		}
		default:
		{
			result = GDK_EVENT_STOP;
			return result;
		}
	}
}

static gboolean
__slingshot_widgets_app_button___lambda44__gtk_widget_button_press_event (GtkWidget* _sender,
                                                                          GdkEventButton* event,
                                                                          gpointer self)
{
	gboolean result;
	result = _slingshot_widgets_app_button___lambda44_ ((SlingshotWidgetsAppButton*) self, event);
	return result;
}

static gboolean
_slingshot_widgets_app_button___lambda45_ (SlingshotWidgetsAppButton* self,
                                           GdkEventKey* e)
{
	gboolean result;
	g_return_val_if_fail (e != NULL, FALSE);
	if (e->keyval == GDK_KEY_Menu) {
		slingshot_widgets_app_button_show_context_menu_at (self, (gdouble) 0, (gdouble) 0);
		result = GDK_EVENT_STOP;
		return result;
	}
	result = GDK_EVENT_PROPAGATE;
	return result;
}

static gboolean
__slingshot_widgets_app_button___lambda45__gtk_widget_key_press_event (GtkWidget* _sender,
                                                                       GdkEventKey* event,
                                                                       gpointer self)
{
	gboolean result;
	result = _slingshot_widgets_app_button___lambda45_ ((SlingshotWidgetsAppButton*) self, event);
	return result;
}

static void
_slingshot_widgets_app_button___lambda46_ (Block5Data* _data5_)
{
	SlingshotWidgetsAppButton* self;
	GraniteAsyncImage* _tmp0_;
	SlingshotBackendApp* _tmp1_;
	GIcon* _tmp2_;
	GIcon* _tmp3_;
	self = _data5_->self;
	_tmp0_ = _data5_->image;
	_tmp1_ = self->priv->_app;
	_tmp2_ = slingshot_backend_app_get_icon (_tmp1_);
	_tmp3_ = _tmp2_;
	granite_async_image_set_from_gicon_async (_tmp0_, _tmp3_, SLINGSHOT_WIDGETS_APP_BUTTON_ICON_SIZE, NULL, NULL, NULL);
}

static void
__slingshot_widgets_app_button___lambda46__g_object_notify (GObject* _sender,
                                                            GParamSpec* pspec,
                                                            gpointer self)
{
	_slingshot_widgets_app_button___lambda46_ (self);
}

static GObject *
slingshot_widgets_app_button_constructor (GType type,
                                          guint n_construct_properties,
                                          GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	SlingshotWidgetsAppButton * self;
	Block5Data* _data5_;
	GtkTargetEntry dnd = {0};
	GtkTargetEntry _tmp0_ = {0};
	GtkTargetEntry _tmp1_;
	GtkTargetEntry* _tmp2_;
	GtkTargetEntry* _tmp3_;
	gint _tmp3__length1;
	GtkStyleContext* _tmp4_;
	GtkLabel* app_label = NULL;
	SlingshotBackendApp* _tmp5_;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	GtkLabel* _tmp8_;
	GtkLabel* _tmp9_;
	GtkLabel* _tmp10_;
	GtkLabel* _tmp11_;
	GtkLabel* _tmp12_;
	GtkLabel* _tmp13_;
	GtkLabel* _tmp14_;
	GtkLabel* _tmp15_;
	SlingshotBackendApp* _tmp16_;
	GIcon* _tmp17_;
	GIcon* _tmp18_;
	GraniteAsyncImage* _tmp19_;
	GraniteAsyncImage* _tmp20_;
	GraniteAsyncImage* _tmp21_;
	GraniteAsyncImage* _tmp22_;
	GraniteAsyncImage* _tmp23_;
	GtkLabel* _tmp24_;
	GtkLabel* _tmp25_;
	GtkLabel* _tmp26_;
	GtkLabel* _tmp27_;
	GtkStyleContext* badge_style_context = NULL;
	GtkLabel* _tmp28_;
	GtkStyleContext* _tmp29_;
	GtkStyleContext* _tmp30_;
	GtkOverlay* overlay = NULL;
	GtkOverlay* _tmp31_;
	GtkOverlay* _tmp32_;
	GtkOverlay* _tmp33_;
	GraniteAsyncImage* _tmp34_;
	GtkGrid* grid = NULL;
	GtkGrid* _tmp35_;
	GtkGrid* _tmp36_;
	GtkGrid* _tmp37_;
	GtkGrid* _tmp38_;
	GtkGrid* _tmp39_;
	GtkGrid* _tmp40_;
	GtkOverlay* _tmp41_;
	GtkGrid* _tmp42_;
	GtkLabel* _tmp43_;
	GtkGrid* _tmp44_;
	SlingshotBackendApp* _tmp45_;
	parent_class = G_OBJECT_CLASS (slingshot_widgets_app_button_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SLINGSHOT_WIDGETS_TYPE_APP_BUTTON, SlingshotWidgetsAppButton);
	_data5_ = g_slice_new0 (Block5Data);
	_data5_->_ref_count_ = 1;
	_data5_->self = g_object_ref (self);
	_tmp0_.target = "text/uri-list";
	_tmp0_.flags = (guint) 0;
	_tmp0_.info = (guint) 0;
	dnd = _tmp0_;
	_tmp1_ = dnd;
	_tmp2_ = g_new0 (GtkTargetEntry, 1);
	_tmp2_[0] = _tmp1_;
	_tmp3_ = _tmp2_;
	_tmp3__length1 = 1;
	gtk_drag_source_set ((GtkWidget*) self, GDK_BUTTON1_MASK, _tmp3_, (gint) 1, GDK_ACTION_COPY);
	_tmp3_ = (g_free (_tmp3_), NULL);
	_tmp4_ = gtk_widget_get_style_context ((GtkWidget*) self);
	gtk_style_context_add_class (_tmp4_, GTK_STYLE_CLASS_FLAT);
	_tmp5_ = self->priv->_app;
	_tmp6_ = slingshot_backend_app_get_name (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = (GtkLabel*) gtk_label_new (_tmp7_);
	g_object_ref_sink (_tmp8_);
	app_label = _tmp8_;
	_tmp9_ = app_label;
	gtk_widget_set_halign ((GtkWidget*) _tmp9_, GTK_ALIGN_CENTER);
	_tmp10_ = app_label;
	gtk_label_set_justify (_tmp10_, GTK_JUSTIFY_CENTER);
	_tmp11_ = app_label;
	gtk_label_set_lines (_tmp11_, 2);
	_tmp12_ = app_label;
	gtk_label_set_max_width_chars (_tmp12_, 16);
	_tmp13_ = app_label;
	gtk_label_set_width_chars (_tmp13_, 16);
	_tmp14_ = app_label;
	g_object_set (_tmp14_, "wrap-mode", PANGO_WRAP_WORD_CHAR, NULL);
	_tmp15_ = app_label;
	gtk_label_set_ellipsize (_tmp15_, PANGO_ELLIPSIZE_END);
	_tmp16_ = self->priv->_app;
	_tmp17_ = slingshot_backend_app_get_icon (_tmp16_);
	_tmp18_ = _tmp17_;
	_tmp19_ = granite_async_image_new_from_gicon_async (_tmp18_, SLINGSHOT_WIDGETS_APP_BUTTON_ICON_SIZE, TRUE, TRUE);
	g_object_ref_sink (_tmp19_);
	_data5_->image = _tmp19_;
	_tmp20_ = _data5_->image;
	gtk_image_set_pixel_size ((GtkImage*) _tmp20_, SLINGSHOT_WIDGETS_APP_BUTTON_ICON_SIZE);
	_tmp21_ = _data5_->image;
	gtk_widget_set_margin_top ((GtkWidget*) _tmp21_, 9);
	_tmp22_ = _data5_->image;
	gtk_widget_set_margin_end ((GtkWidget*) _tmp22_, 6);
	_tmp23_ = _data5_->image;
	gtk_widget_set_margin_start ((GtkWidget*) _tmp23_, 6);
	_tmp24_ = (GtkLabel*) gtk_label_new ("!");
	g_object_ref_sink (_tmp24_);
	_g_object_unref0 (self->priv->badge);
	self->priv->badge = _tmp24_;
	_tmp25_ = self->priv->badge;
	gtk_widget_set_visible ((GtkWidget*) _tmp25_, FALSE);
	_tmp26_ = self->priv->badge;
	gtk_widget_set_halign ((GtkWidget*) _tmp26_, GTK_ALIGN_END);
	_tmp27_ = self->priv->badge;
	gtk_widget_set_valign ((GtkWidget*) _tmp27_, GTK_ALIGN_START);
	_tmp28_ = self->priv->badge;
	_tmp29_ = gtk_widget_get_style_context ((GtkWidget*) _tmp28_);
	badge_style_context = _tmp29_;
	_tmp30_ = badge_style_context;
	gtk_style_context_add_class (_tmp30_, GRANITE_STYLE_CLASS_BADGE);
	_tmp31_ = (GtkOverlay*) gtk_overlay_new ();
	g_object_ref_sink (_tmp31_);
	overlay = _tmp31_;
	_tmp32_ = overlay;
	gtk_widget_set_halign ((GtkWidget*) _tmp32_, GTK_ALIGN_CENTER);
	_tmp33_ = overlay;
	_tmp34_ = _data5_->image;
	gtk_container_add ((GtkContainer*) _tmp33_, (GtkWidget*) _tmp34_);
	_tmp35_ = (GtkGrid*) gtk_grid_new ();
	g_object_ref_sink (_tmp35_);
	grid = _tmp35_;
	_tmp36_ = grid;
	gtk_orientable_set_orientation ((GtkOrientable*) _tmp36_, GTK_ORIENTATION_VERTICAL);
	_tmp37_ = grid;
	gtk_grid_set_row_spacing (_tmp37_, 6);
	_tmp38_ = grid;
	g_object_set ((GtkWidget*) _tmp38_, "expand", TRUE, NULL);
	_tmp39_ = grid;
	gtk_widget_set_halign ((GtkWidget*) _tmp39_, GTK_ALIGN_CENTER);
	_tmp40_ = grid;
	_tmp41_ = overlay;
	gtk_container_add ((GtkContainer*) _tmp40_, (GtkWidget*) _tmp41_);
	_tmp42_ = grid;
	_tmp43_ = app_label;
	gtk_container_add ((GtkContainer*) _tmp42_, (GtkWidget*) _tmp43_);
	_tmp44_ = grid;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp44_);
	g_signal_connect_object ((GtkWidget*) self, "button-press-event", (GCallback) __slingshot_widgets_app_button___lambda44__gtk_widget_button_press_event, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "key-press-event", (GCallback) __slingshot_widgets_app_button___lambda45__gtk_widget_key_press_event, self, 0);
	_tmp45_ = self->priv->_app;
	g_signal_connect_data ((GObject*) _tmp45_, "notify::icon", (GCallback) __slingshot_widgets_app_button___lambda46__g_object_notify, block5_data_ref (_data5_), (GClosureNotify) block5_data_unref, 0);
	_g_object_unref0 (grid);
	_g_object_unref0 (overlay);
	_g_object_unref0 (app_label);
	block5_data_unref (_data5_);
	_data5_ = NULL;
	return obj;
}

static void
slingshot_widgets_app_button_class_init (SlingshotWidgetsAppButtonClass * klass,
                                         gpointer klass_data)
{
	slingshot_widgets_app_button_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &SlingshotWidgetsAppButton_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_slingshot_widgets_app_button_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_slingshot_widgets_app_button_set_property;
	G_OBJECT_CLASS (klass)->constructor = slingshot_widgets_app_button_constructor;
	G_OBJECT_CLASS (klass)->finalize = slingshot_widgets_app_button_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), SLINGSHOT_WIDGETS_APP_BUTTON_APP_PROPERTY, slingshot_widgets_app_button_properties[SLINGSHOT_WIDGETS_APP_BUTTON_APP_PROPERTY] = g_param_spec_object ("app", "app", "app", SLINGSHOT_BACKEND_TYPE_APP, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	slingshot_widgets_app_button_signals[SLINGSHOT_WIDGETS_APP_BUTTON_APP_LAUNCHED_SIGNAL] = g_signal_new ("app-launched", SLINGSHOT_WIDGETS_TYPE_APP_BUTTON, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
slingshot_widgets_app_button_instance_init (SlingshotWidgetsAppButton * self,
                                            gpointer klass)
{
	gchar* _tmp0_;
	self->priv = slingshot_widgets_app_button_get_instance_private (self);
	self->priv->dragging = FALSE;
	self->priv->tooltip_popover = NULL;
	_tmp0_ = g_strdup ("");
	self->priv->tooltip_text_str = _tmp0_;
	self->priv->delay_ms = (guint) 500;
	self->priv->timeout_id = (guint) 0;
	self->priv->ctx_menu = NULL;
}

static void
slingshot_widgets_app_button_finalize (GObject * obj)
{
	SlingshotWidgetsAppButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SLINGSHOT_WIDGETS_TYPE_APP_BUTTON, SlingshotWidgetsAppButton);
	_g_object_unref0 (self->priv->_app);
	_g_object_unref0 (self->priv->badge);
	_g_object_unref0 (self->priv->tooltip_popover);
	_g_free0 (self->priv->tooltip_text_str);
	_g_object_unref0 (self->priv->ctx_menu);
	G_OBJECT_CLASS (slingshot_widgets_app_button_parent_class)->finalize (obj);
}

GType
slingshot_widgets_app_button_get_type (void)
{
	return slingshot_widgets_app_button_type_id;
}

GType
slingshot_widgets_app_button_register_type (GTypeModule * module)
{
	static const GTypeInfo g_define_type_info = { sizeof (SlingshotWidgetsAppButtonClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) slingshot_widgets_app_button_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SlingshotWidgetsAppButton), 0, (GInstanceInitFunc) slingshot_widgets_app_button_instance_init, NULL };
	slingshot_widgets_app_button_type_id = g_type_module_register_type (module, gtk_button_get_type (), "SlingshotWidgetsAppButton", &g_define_type_info, 0);
	SlingshotWidgetsAppButton_private_offset = sizeof (SlingshotWidgetsAppButtonPrivate);
	return slingshot_widgets_app_button_type_id;
}

static void
_vala_slingshot_widgets_app_button_get_property (GObject * object,
                                                 guint property_id,
                                                 GValue * value,
                                                 GParamSpec * pspec)
{
	SlingshotWidgetsAppButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SLINGSHOT_WIDGETS_TYPE_APP_BUTTON, SlingshotWidgetsAppButton);
	switch (property_id) {
		case SLINGSHOT_WIDGETS_APP_BUTTON_APP_PROPERTY:
		g_value_set_object (value, slingshot_widgets_app_button_get_app (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_slingshot_widgets_app_button_set_property (GObject * object,
                                                 guint property_id,
                                                 const GValue * value,
                                                 GParamSpec * pspec)
{
	SlingshotWidgetsAppButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SLINGSHOT_WIDGETS_TYPE_APP_BUTTON, SlingshotWidgetsAppButton);
	switch (property_id) {
		case SLINGSHOT_WIDGETS_APP_BUTTON_APP_PROPERTY:
		slingshot_widgets_app_button_set_app (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

