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

/*
 * Copyright (c) 2011-2015 Ikey Doherty <ikey@solus-project.com>
 *
 * 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.
 */

#include <glib-object.h>
#include <gtk/gtk.h>
#include <gee.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gdk/gdk.h>
#include <float.h>
#include <math.h>
#include "wingpanel.h"

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define WINGPANEL_SERVICES_TYPE_POPOVER_MANAGER (wingpanel_services_popover_manager_get_type ())
#define WINGPANEL_SERVICES_POPOVER_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WINGPANEL_SERVICES_TYPE_POPOVER_MANAGER, WingpanelServicesPopoverManager))
#define WINGPANEL_SERVICES_POPOVER_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WINGPANEL_SERVICES_TYPE_POPOVER_MANAGER, WingpanelServicesPopoverManagerClass))
#define WINGPANEL_SERVICES_IS_POPOVER_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WINGPANEL_SERVICES_TYPE_POPOVER_MANAGER))
#define WINGPANEL_SERVICES_IS_POPOVER_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WINGPANEL_SERVICES_TYPE_POPOVER_MANAGER))
#define WINGPANEL_SERVICES_POPOVER_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WINGPANEL_SERVICES_TYPE_POPOVER_MANAGER, WingpanelServicesPopoverManagerClass))

typedef struct _WingpanelServicesPopoverManager WingpanelServicesPopoverManager;
typedef struct _WingpanelServicesPopoverManagerClass WingpanelServicesPopoverManagerClass;
typedef struct _WingpanelServicesPopoverManagerPrivate WingpanelServicesPopoverManagerPrivate;

#define WINGPANEL_TYPE_PANEL_WINDOW (wingpanel_panel_window_get_type ())
#define WINGPANEL_PANEL_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WINGPANEL_TYPE_PANEL_WINDOW, WingpanelPanelWindow))
#define WINGPANEL_PANEL_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WINGPANEL_TYPE_PANEL_WINDOW, WingpanelPanelWindowClass))
#define WINGPANEL_IS_PANEL_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WINGPANEL_TYPE_PANEL_WINDOW))
#define WINGPANEL_IS_PANEL_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WINGPANEL_TYPE_PANEL_WINDOW))
#define WINGPANEL_PANEL_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WINGPANEL_TYPE_PANEL_WINDOW, WingpanelPanelWindowClass))

typedef struct _WingpanelPanelWindow WingpanelPanelWindow;
typedef struct _WingpanelPanelWindowClass WingpanelPanelWindowClass;

#define WINGPANEL_WIDGETS_TYPE_INDICATOR_ENTRY (wingpanel_widgets_indicator_entry_get_type ())
#define WINGPANEL_WIDGETS_INDICATOR_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WINGPANEL_WIDGETS_TYPE_INDICATOR_ENTRY, WingpanelWidgetsIndicatorEntry))
#define WINGPANEL_WIDGETS_INDICATOR_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WINGPANEL_WIDGETS_TYPE_INDICATOR_ENTRY, WingpanelWidgetsIndicatorEntryClass))
#define WINGPANEL_WIDGETS_IS_INDICATOR_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WINGPANEL_WIDGETS_TYPE_INDICATOR_ENTRY))
#define WINGPANEL_WIDGETS_IS_INDICATOR_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WINGPANEL_WIDGETS_TYPE_INDICATOR_ENTRY))
#define WINGPANEL_WIDGETS_INDICATOR_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WINGPANEL_WIDGETS_TYPE_INDICATOR_ENTRY, WingpanelWidgetsIndicatorEntryClass))

typedef struct _WingpanelWidgetsIndicatorEntry WingpanelWidgetsIndicatorEntry;
typedef struct _WingpanelWidgetsIndicatorEntryClass WingpanelWidgetsIndicatorEntryClass;

#define WINGPANEL_WIDGETS_TYPE_INDICATOR_POPOVER (wingpanel_widgets_indicator_popover_get_type ())
#define WINGPANEL_WIDGETS_INDICATOR_POPOVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WINGPANEL_WIDGETS_TYPE_INDICATOR_POPOVER, WingpanelWidgetsIndicatorPopover))
#define WINGPANEL_WIDGETS_INDICATOR_POPOVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WINGPANEL_WIDGETS_TYPE_INDICATOR_POPOVER, WingpanelWidgetsIndicatorPopoverClass))
#define WINGPANEL_WIDGETS_IS_INDICATOR_POPOVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WINGPANEL_WIDGETS_TYPE_INDICATOR_POPOVER))
#define WINGPANEL_WIDGETS_IS_INDICATOR_POPOVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WINGPANEL_WIDGETS_TYPE_INDICATOR_POPOVER))
#define WINGPANEL_WIDGETS_INDICATOR_POPOVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WINGPANEL_WIDGETS_TYPE_INDICATOR_POPOVER, WingpanelWidgetsIndicatorPopoverClass))

typedef struct _WingpanelWidgetsIndicatorPopover WingpanelWidgetsIndicatorPopover;
typedef struct _WingpanelWidgetsIndicatorPopoverClass WingpanelWidgetsIndicatorPopoverClass;
enum  {
	WINGPANEL_SERVICES_POPOVER_MANAGER_0_PROPERTY,
	WINGPANEL_SERVICES_POPOVER_MANAGER_CURRENT_INDICATOR_PROPERTY,
	WINGPANEL_SERVICES_POPOVER_MANAGER_NUM_PROPERTIES
};
static GParamSpec* wingpanel_services_popover_manager_properties[WINGPANEL_SERVICES_POPOVER_MANAGER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block5Data Block5Data;
typedef struct _Block6Data Block6Data;

struct _WingpanelServicesPopoverManager {
	GObject parent_instance;
	WingpanelServicesPopoverManagerPrivate * priv;
};

struct _WingpanelServicesPopoverManagerClass {
	GObjectClass parent_class;
};

struct _WingpanelServicesPopoverManagerPrivate {
	WingpanelPanelWindow* owner;
	GtkGestureMultiPress* owner_gesture_controller;
	GeeHashMap* registered_indicators;
	WingpanelWidgetsIndicatorPopover* popover;
	WingpanelWidgetsIndicatorEntry* _current_indicator;
};

struct _Block5Data {
	int _ref_count_;
	WingpanelServicesPopoverManager* self;
	WingpanelPanelWindow* owner;
};

struct _Block6Data {
	int _ref_count_;
	Block5Data * _data5_;
	gulong handler_id;
};

static gint WingpanelServicesPopoverManager_private_offset;
static gpointer wingpanel_services_popover_manager_parent_class = NULL;

VALA_EXTERN GType wingpanel_services_popover_manager_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WingpanelServicesPopoverManager, g_object_unref)
VALA_EXTERN GType wingpanel_panel_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WingpanelPanelWindow, g_object_unref)
VALA_EXTERN GType wingpanel_widgets_indicator_entry_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WingpanelWidgetsIndicatorEntry, g_object_unref)
VALA_EXTERN GType wingpanel_widgets_indicator_popover_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WingpanelWidgetsIndicatorPopover, g_object_unref)
VALA_EXTERN WingpanelServicesPopoverManager* wingpanel_services_popover_manager_new (WingpanelPanelWindow* owner);
VALA_EXTERN WingpanelServicesPopoverManager* wingpanel_services_popover_manager_construct (GType object_type,
                                                                               WingpanelPanelWindow* owner);
static Block5Data* block5_data_ref (Block5Data* _data5_);
static void block5_data_unref (void * _userdata_);
VALA_EXTERN WingpanelWidgetsIndicatorPopover* wingpanel_widgets_indicator_popover_new (void);
VALA_EXTERN WingpanelWidgetsIndicatorPopover* wingpanel_widgets_indicator_popover_construct (GType object_type);
static void __lambda14_ (Block5Data* _data5_);
static Block6Data* block6_data_ref (Block6Data* _data6_);
static void block6_data_unref (void * _userdata_);
VALA_EXTERN void wingpanel_services_popover_manager_set_current_indicator (WingpanelServicesPopoverManager* self,
                                                               WingpanelWidgetsIndicatorEntry* value);
static void __lambda15_ (Block6Data* _data6_);
VALA_EXTERN void wingpanel_panel_window_set_expanded (WingpanelPanelWindow* self,
                                          gboolean expand);
static void ___lambda15__gtk_widget_unmap (GtkWidget* _sender,
                                    gpointer self);
static void ___lambda14__gtk_popover_closed (GtkPopover* _sender,
                                      gpointer self);
static void __lambda16_ (WingpanelServicesPopoverManager* self);
static void ___lambda16__gtk_gesture_multi_press_pressed (GtkGestureMultiPress* _sender,
                                                   gint n_press,
                                                   gdouble x,
                                                   gdouble y,
                                                   gpointer self);
static void __lambda17_ (Block5Data* _data5_);
static void ___lambda17__gtk_widget_realize (GtkWidget* _sender,
                                      gpointer self);
VALA_EXTERN void wingpanel_services_popover_manager_set_popover_visible (WingpanelServicesPopoverManager* self,
                                                             const gchar* code_name,
                                                             gboolean visible);
VALA_EXTERN WingpanelWidgetsIndicatorEntry* wingpanel_services_popover_manager_get_current_indicator (WingpanelServicesPopoverManager* self);
VALA_EXTERN WingpanelIndicator* wingpanel_widgets_indicator_entry_get_base_indicator (WingpanelWidgetsIndicatorEntry* self);
VALA_EXTERN void wingpanel_services_popover_manager_toggle_popover_visible (WingpanelServicesPopoverManager* self,
                                                                const gchar* code_name);
VALA_EXTERN gboolean wingpanel_services_popover_manager_get_visible (WingpanelServicesPopoverManager* self,
                                                         WingpanelWidgetsIndicatorEntry* entry);
static void wingpanel_services_popover_manager_update_has_tooltip (WingpanelServicesPopoverManager* self,
                                                            GtkWidget* display_widget,
                                                            gboolean enable);
VALA_EXTERN void wingpanel_services_popover_manager_close (WingpanelServicesPopoverManager* self);
VALA_EXTERN void wingpanel_services_popover_manager_unregister_indicator (WingpanelServicesPopoverManager* self,
                                                              WingpanelWidgetsIndicatorEntry* widg);
VALA_EXTERN void wingpanel_services_popover_manager_register_indicator (WingpanelServicesPopoverManager* self,
                                                            WingpanelWidgetsIndicatorEntry* widg);
VALA_EXTERN GtkWidget* wingpanel_widgets_indicator_entry_get_display_widget (WingpanelWidgetsIndicatorEntry* self);
VALA_EXTERN void wingpanel_widgets_indicator_popover_set_content (WingpanelWidgetsIndicatorPopover* self,
                                                      GtkWidget* content);
VALA_EXTERN GtkWidget* wingpanel_widgets_indicator_entry_get_indicator_widget (WingpanelWidgetsIndicatorEntry* self);
static void wingpanel_services_popover_manager_finalize (GObject * obj);
static GType wingpanel_services_popover_manager_get_type_once (void);
static void _vala_wingpanel_services_popover_manager_get_property (GObject * object,
                                                            guint property_id,
                                                            GValue * value,
                                                            GParamSpec * pspec);
static void _vala_wingpanel_services_popover_manager_set_property (GObject * object,
                                                            guint property_id,
                                                            const GValue * value,
                                                            GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
wingpanel_services_popover_manager_get_instance_private (WingpanelServicesPopoverManager* self)
{
	return G_STRUCT_MEMBER_P (self, WingpanelServicesPopoverManager_private_offset);
}

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

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_)) {
		WingpanelServicesPopoverManager* self;
		self = _data5_->self;
		_g_object_unref0 (_data5_->owner);
		_g_object_unref0 (self);
		g_slice_free (Block5Data, _data5_);
	}
}

static Block6Data*
block6_data_ref (Block6Data* _data6_)
{
	g_atomic_int_inc (&_data6_->_ref_count_);
	return _data6_;
}

static void
block6_data_unref (void * _userdata_)
{
	Block6Data* _data6_;
	_data6_ = (Block6Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data6_->_ref_count_)) {
		WingpanelServicesPopoverManager* self;
		self = _data6_->_data5_->self;
		block5_data_unref (_data6_->_data5_);
		_data6_->_data5_ = NULL;
		g_slice_free (Block6Data, _data6_);
	}
}

static void
__lambda15_ (Block6Data* _data6_)
{
	Block5Data* _data5_;
	WingpanelServicesPopoverManager* self;
	WingpanelWidgetsIndicatorPopover* _tmp0_;
	_data5_ = _data6_->_data5_;
	self = _data5_->self;
	wingpanel_panel_window_set_expanded (_data5_->owner, FALSE);
	_tmp0_ = self->priv->popover;
	g_signal_handler_disconnect ((GObject*) _tmp0_, _data6_->handler_id);
}

static void
___lambda15__gtk_widget_unmap (GtkWidget* _sender,
                               gpointer self)
{
	__lambda15_ (self);
}

static void
__lambda14_ (Block5Data* _data5_)
{
	WingpanelServicesPopoverManager* self;
	Block6Data* _data6_;
	WingpanelWidgetsIndicatorPopover* _tmp0_;
	gulong _tmp1_;
	self = _data5_->self;
	_data6_ = g_slice_new0 (Block6Data);
	_data6_->_ref_count_ = 1;
	_data6_->_data5_ = block5_data_ref (_data5_);
	wingpanel_services_popover_manager_set_current_indicator (self, NULL);
	_data6_->handler_id = (gulong) 0;
	_tmp0_ = self->priv->popover;
	_tmp1_ = g_signal_connect_data ((GtkWidget*) _tmp0_, "unmap", (GCallback) ___lambda15__gtk_widget_unmap, block6_data_ref (_data6_), (GClosureNotify) block6_data_unref, 0);
	_data6_->handler_id = _tmp1_;
	block6_data_unref (_data6_);
	_data6_ = NULL;
}

static void
___lambda14__gtk_popover_closed (GtkPopover* _sender,
                                 gpointer self)
{
	__lambda14_ (self);
}

static void
__lambda16_ (WingpanelServicesPopoverManager* self)
{
	wingpanel_services_popover_manager_set_current_indicator (self, NULL);
}

static void
___lambda16__gtk_gesture_multi_press_pressed (GtkGestureMultiPress* _sender,
                                              gint n_press,
                                              gdouble x,
                                              gdouble y,
                                              gpointer self)
{
	__lambda16_ ((WingpanelServicesPopoverManager*) self);
}

static void
__lambda17_ (Block5Data* _data5_)
{
	WingpanelServicesPopoverManager* self;
	GtkGestureMultiPress* _tmp0_;
	GdkWindow* _tmp1_;
	self = _data5_->self;
	_tmp0_ = self->priv->owner_gesture_controller;
	_tmp1_ = gtk_widget_get_window ((GtkWidget*) _data5_->owner);
	gtk_gesture_set_window ((GtkGesture*) _tmp0_, _tmp1_);
}

static void
___lambda17__gtk_widget_realize (GtkWidget* _sender,
                                 gpointer self)
{
	__lambda17_ (self);
}

WingpanelServicesPopoverManager*
wingpanel_services_popover_manager_construct (GType object_type,
                                              WingpanelPanelWindow* owner)
{
	WingpanelServicesPopoverManager * self = NULL;
	Block5Data* _data5_;
	WingpanelPanelWindow* _tmp0_;
	GeeHashMap* _tmp1_;
	WingpanelWidgetsIndicatorPopover* _tmp2_;
	WingpanelWidgetsIndicatorPopover* _tmp3_;
	GdkWindow* _tmp4_;
	GdkWindow* _tmp5_;
	GtkGestureMultiPress* _tmp6_ = NULL;
	GtkGestureMultiPress* _tmp7_;
	_data5_ = g_slice_new0 (Block5Data);
	_data5_->_ref_count_ = 1;
	_tmp0_ = _g_object_ref0 (owner);
	_g_object_unref0 (_data5_->owner);
	_data5_->owner = _tmp0_;
	self = (WingpanelServicesPopoverManager*) g_object_new (object_type, NULL);
	_data5_->self = g_object_ref (self);
	_tmp1_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, WINGPANEL_WIDGETS_TYPE_INDICATOR_ENTRY, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->registered_indicators);
	self->priv->registered_indicators = _tmp1_;
	self->priv->owner = _data5_->owner;
	_tmp2_ = wingpanel_widgets_indicator_popover_new ();
	g_object_ref_sink (_tmp2_);
	_g_object_unref0 (self->priv->popover);
	self->priv->popover = _tmp2_;
	_tmp3_ = self->priv->popover;
	g_signal_connect_data ((GtkPopover*) _tmp3_, "closed", (GCallback) ___lambda14__gtk_popover_closed, block5_data_ref (_data5_), (GClosureNotify) block5_data_unref, 0);
	_tmp4_ = gtk_widget_get_window ((GtkWidget*) _data5_->owner);
	_tmp5_ = _g_object_ref0 (_tmp4_);
	_tmp6_ = (GtkGestureMultiPress*) gtk_gesture_multi_press_new ((GtkWidget*) _data5_->owner);
	gtk_gesture_set_window ((GtkGesture*) _tmp6_, _tmp5_);
	_g_object_unref0 (_tmp5_);
	_g_object_unref0 (self->priv->owner_gesture_controller);
	self->priv->owner_gesture_controller = _tmp6_;
	_tmp7_ = self->priv->owner_gesture_controller;
	g_signal_connect_object (_tmp7_, "pressed", (GCallback) ___lambda16__gtk_gesture_multi_press_pressed, self, 0);
	g_signal_connect_data ((GtkWidget*) _data5_->owner, "realize", (GCallback) ___lambda17__gtk_widget_realize, block5_data_ref (_data5_), (GClosureNotify) block5_data_unref, 0);
	block5_data_unref (_data5_);
	_data5_ = NULL;
	return self;
}

WingpanelServicesPopoverManager*
wingpanel_services_popover_manager_new (WingpanelPanelWindow* owner)
{
	return wingpanel_services_popover_manager_construct (WINGPANEL_SERVICES_TYPE_POPOVER_MANAGER, owner);
}

void
wingpanel_services_popover_manager_set_popover_visible (WingpanelServicesPopoverManager* self,
                                                        const gchar* code_name,
                                                        gboolean visible)
{
	GeeHashMap* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (code_name != NULL);
	_tmp0_ = self->priv->registered_indicators;
	if (gee_abstract_map_has_key ((GeeAbstractMap*) _tmp0_, code_name)) {
		WingpanelWidgetsIndicatorEntry* new_indicator = NULL;
		GeeHashMap* _tmp1_;
		gpointer _tmp2_;
		gboolean _tmp3_ = FALSE;
		_tmp1_ = self->priv->registered_indicators;
		_tmp2_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp1_, code_name);
		new_indicator = (WingpanelWidgetsIndicatorEntry*) _tmp2_;
		if (visible) {
			gboolean _tmp4_ = FALSE;
			WingpanelWidgetsIndicatorEntry* _tmp5_;
			WingpanelWidgetsIndicatorEntry* _tmp6_;
			_tmp5_ = wingpanel_services_popover_manager_get_current_indicator (self);
			_tmp6_ = _tmp5_;
			if (_tmp6_ == NULL) {
				_tmp4_ = TRUE;
			} else {
				WingpanelWidgetsIndicatorEntry* _tmp7_;
				WingpanelWidgetsIndicatorEntry* _tmp8_;
				WingpanelIndicator* _tmp9_;
				WingpanelIndicator* _tmp10_;
				const gchar* _tmp11_;
				const gchar* _tmp12_;
				WingpanelWidgetsIndicatorEntry* _tmp13_;
				WingpanelIndicator* _tmp14_;
				WingpanelIndicator* _tmp15_;
				const gchar* _tmp16_;
				const gchar* _tmp17_;
				_tmp7_ = wingpanel_services_popover_manager_get_current_indicator (self);
				_tmp8_ = _tmp7_;
				_tmp9_ = wingpanel_widgets_indicator_entry_get_base_indicator (_tmp8_);
				_tmp10_ = _tmp9_;
				_tmp11_ = wingpanel_indicator_get_code_name (_tmp10_);
				_tmp12_ = _tmp11_;
				_tmp13_ = new_indicator;
				_tmp14_ = wingpanel_widgets_indicator_entry_get_base_indicator (_tmp13_);
				_tmp15_ = _tmp14_;
				_tmp16_ = wingpanel_indicator_get_code_name (_tmp15_);
				_tmp17_ = _tmp16_;
				_tmp4_ = g_strcmp0 (_tmp12_, _tmp17_) != 0;
			}
			_tmp3_ = _tmp4_;
		} else {
			_tmp3_ = FALSE;
		}
		if (_tmp3_) {
			WingpanelWidgetsIndicatorEntry* _tmp18_;
			_tmp18_ = new_indicator;
			wingpanel_services_popover_manager_set_current_indicator (self, _tmp18_);
		} else {
			gboolean _tmp19_ = FALSE;
			WingpanelWidgetsIndicatorEntry* _tmp20_;
			WingpanelWidgetsIndicatorEntry* _tmp21_;
			WingpanelIndicator* _tmp22_;
			WingpanelIndicator* _tmp23_;
			const gchar* _tmp24_;
			const gchar* _tmp25_;
			WingpanelWidgetsIndicatorEntry* _tmp26_;
			WingpanelIndicator* _tmp27_;
			WingpanelIndicator* _tmp28_;
			const gchar* _tmp29_;
			const gchar* _tmp30_;
			_tmp20_ = wingpanel_services_popover_manager_get_current_indicator (self);
			_tmp21_ = _tmp20_;
			_tmp22_ = wingpanel_widgets_indicator_entry_get_base_indicator (_tmp21_);
			_tmp23_ = _tmp22_;
			_tmp24_ = wingpanel_indicator_get_code_name (_tmp23_);
			_tmp25_ = _tmp24_;
			_tmp26_ = new_indicator;
			_tmp27_ = wingpanel_widgets_indicator_entry_get_base_indicator (_tmp26_);
			_tmp28_ = _tmp27_;
			_tmp29_ = wingpanel_indicator_get_code_name (_tmp28_);
			_tmp30_ = _tmp29_;
			if (g_strcmp0 (_tmp25_, _tmp30_) == 0) {
				_tmp19_ = !visible;
			} else {
				_tmp19_ = FALSE;
			}
			if (_tmp19_) {
				wingpanel_services_popover_manager_set_current_indicator (self, NULL);
			}
		}
		_g_object_unref0 (new_indicator);
	}
}

void
wingpanel_services_popover_manager_toggle_popover_visible (WingpanelServicesPopoverManager* self,
                                                           const gchar* code_name)
{
	GeeHashMap* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (code_name != NULL);
	_tmp0_ = self->priv->registered_indicators;
	if (gee_abstract_map_has_key ((GeeAbstractMap*) _tmp0_, code_name)) {
		GeeHashMap* _tmp1_;
		gpointer _tmp2_;
		WingpanelWidgetsIndicatorEntry* _tmp3_;
		_tmp1_ = self->priv->registered_indicators;
		_tmp2_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp1_, code_name);
		_tmp3_ = (WingpanelWidgetsIndicatorEntry*) _tmp2_;
		wingpanel_services_popover_manager_set_current_indicator (self, _tmp3_);
		_g_object_unref0 (_tmp3_);
	}
}

gboolean
wingpanel_services_popover_manager_get_visible (WingpanelServicesPopoverManager* self,
                                                WingpanelWidgetsIndicatorEntry* entry)
{
	gboolean _tmp0_ = FALSE;
	WingpanelWidgetsIndicatorEntry* _tmp1_;
	WingpanelWidgetsIndicatorEntry* _tmp2_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (entry != NULL, FALSE);
	_tmp1_ = wingpanel_services_popover_manager_get_current_indicator (self);
	_tmp2_ = _tmp1_;
	if (_tmp2_ != NULL) {
		WingpanelWidgetsIndicatorEntry* _tmp3_;
		WingpanelWidgetsIndicatorEntry* _tmp4_;
		WingpanelIndicator* _tmp5_;
		WingpanelIndicator* _tmp6_;
		const gchar* _tmp7_;
		const gchar* _tmp8_;
		WingpanelIndicator* _tmp9_;
		WingpanelIndicator* _tmp10_;
		const gchar* _tmp11_;
		const gchar* _tmp12_;
		_tmp3_ = wingpanel_services_popover_manager_get_current_indicator (self);
		_tmp4_ = _tmp3_;
		_tmp5_ = wingpanel_widgets_indicator_entry_get_base_indicator (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp7_ = wingpanel_indicator_get_code_name (_tmp6_);
		_tmp8_ = _tmp7_;
		_tmp9_ = wingpanel_widgets_indicator_entry_get_base_indicator (entry);
		_tmp10_ = _tmp9_;
		_tmp11_ = wingpanel_indicator_get_code_name (_tmp10_);
		_tmp12_ = _tmp11_;
		_tmp0_ = g_strcmp0 (_tmp8_, _tmp12_) == 0;
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

static void
wingpanel_services_popover_manager_update_has_tooltip (WingpanelServicesPopoverManager* self,
                                                       GtkWidget* display_widget,
                                                       gboolean enable)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (display_widget != NULL);
	if (display_widget != NULL) {
		gtk_widget_set_has_tooltip (display_widget, enable);
	}
}

void
wingpanel_services_popover_manager_close (WingpanelServicesPopoverManager* self)
{
	WingpanelWidgetsIndicatorEntry* _tmp0_;
	WingpanelWidgetsIndicatorEntry* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = wingpanel_services_popover_manager_get_current_indicator (self);
	_tmp1_ = _tmp0_;
	if (_tmp1_ != NULL) {
		wingpanel_services_popover_manager_set_current_indicator (self, NULL);
	}
}

void
wingpanel_services_popover_manager_unregister_indicator (WingpanelServicesPopoverManager* self,
                                                         WingpanelWidgetsIndicatorEntry* widg)
{
	GeeHashMap* _tmp0_;
	WingpanelIndicator* _tmp1_;
	WingpanelIndicator* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->registered_indicators;
	_tmp1_ = wingpanel_widgets_indicator_entry_get_base_indicator (widg);
	_tmp2_ = _tmp1_;
	_tmp3_ = wingpanel_indicator_get_code_name (_tmp2_);
	_tmp4_ = _tmp3_;
	if (gee_abstract_map_has_key ((GeeAbstractMap*) _tmp0_, _tmp4_)) {
		GeeHashMap* _tmp5_;
		WingpanelIndicator* _tmp6_;
		WingpanelIndicator* _tmp7_;
		const gchar* _tmp8_;
		const gchar* _tmp9_;
		_tmp5_ = self->priv->registered_indicators;
		_tmp6_ = wingpanel_widgets_indicator_entry_get_base_indicator (widg);
		_tmp7_ = _tmp6_;
		_tmp8_ = wingpanel_indicator_get_code_name (_tmp7_);
		_tmp9_ = _tmp8_;
		gee_abstract_map_unset ((GeeAbstractMap*) _tmp5_, _tmp9_, NULL);
	}
}

void
wingpanel_services_popover_manager_register_indicator (WingpanelServicesPopoverManager* self,
                                                       WingpanelWidgetsIndicatorEntry* widg)
{
	GeeHashMap* _tmp0_;
	WingpanelIndicator* _tmp1_;
	WingpanelIndicator* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	GeeHashMap* _tmp5_;
	WingpanelIndicator* _tmp6_;
	WingpanelIndicator* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->registered_indicators;
	_tmp1_ = wingpanel_widgets_indicator_entry_get_base_indicator (widg);
	_tmp2_ = _tmp1_;
	_tmp3_ = wingpanel_indicator_get_code_name (_tmp2_);
	_tmp4_ = _tmp3_;
	if (gee_abstract_map_has_key ((GeeAbstractMap*) _tmp0_, _tmp4_)) {
		return;
	}
	_tmp5_ = self->priv->registered_indicators;
	_tmp6_ = wingpanel_widgets_indicator_entry_get_base_indicator (widg);
	_tmp7_ = _tmp6_;
	_tmp8_ = wingpanel_indicator_get_code_name (_tmp7_);
	_tmp9_ = _tmp8_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp5_, _tmp9_, widg);
}

WingpanelWidgetsIndicatorEntry*
wingpanel_services_popover_manager_get_current_indicator (WingpanelServicesPopoverManager* self)
{
	WingpanelWidgetsIndicatorEntry* result;
	WingpanelWidgetsIndicatorEntry* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_current_indicator;
	result = _tmp0_;
	return result;
}

void
wingpanel_services_popover_manager_set_current_indicator (WingpanelServicesPopoverManager* self,
                                                          WingpanelWidgetsIndicatorEntry* value)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp2_ = FALSE;
	WingpanelWidgetsIndicatorEntry* _tmp3_;
	WingpanelWidgetsIndicatorEntry* _tmp29_;
	g_return_if_fail (self != NULL);
	if (value == NULL) {
		WingpanelWidgetsIndicatorEntry* _tmp1_;
		_tmp1_ = self->priv->_current_indicator;
		_tmp0_ = _tmp1_ == NULL;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		return;
	}
	_tmp3_ = self->priv->_current_indicator;
	if (_tmp3_ == NULL) {
		_tmp2_ = value != NULL;
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		WingpanelWidgetsIndicatorEntry* _tmp4_;
		_tmp4_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_current_indicator);
		self->priv->_current_indicator = _tmp4_;
	} else {
		gboolean _tmp5_ = FALSE;
		if (value == NULL) {
			WingpanelWidgetsIndicatorEntry* _tmp6_;
			_tmp6_ = self->priv->_current_indicator;
			_tmp5_ = _tmp6_ != NULL;
		} else {
			_tmp5_ = FALSE;
		}
		if (_tmp5_) {
			WingpanelWidgetsIndicatorEntry* _tmp7_;
			WingpanelIndicator* _tmp8_;
			WingpanelIndicator* _tmp9_;
			_tmp7_ = self->priv->_current_indicator;
			_tmp8_ = wingpanel_widgets_indicator_entry_get_base_indicator (_tmp7_);
			_tmp9_ = _tmp8_;
			wingpanel_indicator_closed (_tmp9_);
			_g_object_unref0 (self->priv->_current_indicator);
			self->priv->_current_indicator = NULL;
		} else {
			WingpanelWidgetsIndicatorEntry* _tmp10_;
			WingpanelIndicator* _tmp11_;
			WingpanelIndicator* _tmp12_;
			const gchar* _tmp13_;
			const gchar* _tmp14_;
			WingpanelIndicator* _tmp15_;
			WingpanelIndicator* _tmp16_;
			const gchar* _tmp17_;
			const gchar* _tmp18_;
			_tmp10_ = self->priv->_current_indicator;
			_tmp11_ = wingpanel_widgets_indicator_entry_get_base_indicator (_tmp10_);
			_tmp12_ = _tmp11_;
			_tmp13_ = wingpanel_indicator_get_code_name (_tmp12_);
			_tmp14_ = _tmp13_;
			_tmp15_ = wingpanel_widgets_indicator_entry_get_base_indicator (value);
			_tmp16_ = _tmp15_;
			_tmp17_ = wingpanel_indicator_get_code_name (_tmp16_);
			_tmp18_ = _tmp17_;
			if (g_strcmp0 (_tmp14_, _tmp18_) == 0) {
				WingpanelWidgetsIndicatorEntry* _tmp19_;
				WingpanelIndicator* _tmp20_;
				WingpanelIndicator* _tmp21_;
				_tmp19_ = self->priv->_current_indicator;
				_tmp20_ = wingpanel_widgets_indicator_entry_get_base_indicator (_tmp19_);
				_tmp21_ = _tmp20_;
				wingpanel_indicator_closed (_tmp21_);
				_g_object_unref0 (self->priv->_current_indicator);
				self->priv->_current_indicator = NULL;
			} else {
				WingpanelWidgetsIndicatorEntry* _tmp22_;
				GtkWidget* _tmp23_;
				GtkWidget* _tmp24_;
				WingpanelWidgetsIndicatorEntry* _tmp25_;
				WingpanelIndicator* _tmp26_;
				WingpanelIndicator* _tmp27_;
				WingpanelWidgetsIndicatorEntry* _tmp28_;
				_tmp22_ = self->priv->_current_indicator;
				_tmp23_ = wingpanel_widgets_indicator_entry_get_display_widget (_tmp22_);
				_tmp24_ = _tmp23_;
				wingpanel_services_popover_manager_update_has_tooltip (self, _tmp24_, TRUE);
				_tmp25_ = self->priv->_current_indicator;
				_tmp26_ = wingpanel_widgets_indicator_entry_get_base_indicator (_tmp25_);
				_tmp27_ = _tmp26_;
				wingpanel_indicator_closed (_tmp27_);
				_tmp28_ = _g_object_ref0 (value);
				_g_object_unref0 (self->priv->_current_indicator);
				self->priv->_current_indicator = _tmp28_;
			}
		}
	}
	_tmp29_ = self->priv->_current_indicator;
	if (_tmp29_ != NULL) {
		WingpanelWidgetsIndicatorPopover* _tmp30_;
		WingpanelWidgetsIndicatorEntry* _tmp31_;
		GtkWidget* _tmp32_;
		GtkWidget* _tmp33_;
		WingpanelWidgetsIndicatorPopover* _tmp34_;
		WingpanelWidgetsIndicatorEntry* _tmp35_;
		WingpanelWidgetsIndicatorEntry* _tmp36_;
		GtkWidget* _tmp37_;
		GtkWidget* _tmp38_;
		WingpanelPanelWindow* _tmp39_;
		WingpanelPanelWindow* _tmp40_;
		WingpanelWidgetsIndicatorPopover* _tmp41_;
		WingpanelWidgetsIndicatorPopover* _tmp42_;
		WingpanelWidgetsIndicatorEntry* _tmp43_;
		WingpanelIndicator* _tmp44_;
		WingpanelIndicator* _tmp45_;
		_tmp30_ = self->priv->popover;
		_tmp31_ = self->priv->_current_indicator;
		_tmp32_ = wingpanel_widgets_indicator_entry_get_indicator_widget (_tmp31_);
		_tmp33_ = _tmp32_;
		wingpanel_widgets_indicator_popover_set_content (_tmp30_, _tmp33_);
		_tmp34_ = self->priv->popover;
		_tmp35_ = self->priv->_current_indicator;
		gtk_popover_set_relative_to ((GtkPopover*) _tmp34_, (GtkWidget*) _tmp35_);
		_tmp36_ = self->priv->_current_indicator;
		_tmp37_ = wingpanel_widgets_indicator_entry_get_display_widget (_tmp36_);
		_tmp38_ = _tmp37_;
		wingpanel_services_popover_manager_update_has_tooltip (self, _tmp38_, FALSE);
		_tmp39_ = self->priv->owner;
		wingpanel_panel_window_set_expanded (_tmp39_, TRUE);
		_tmp40_ = self->priv->owner;
		gtk_window_present ((GtkWindow*) _tmp40_);
		_tmp41_ = self->priv->popover;
		gtk_popover_popup ((GtkPopover*) _tmp41_);
		_tmp42_ = self->priv->popover;
		gtk_widget_show_all ((GtkWidget*) _tmp42_);
		_tmp43_ = self->priv->_current_indicator;
		_tmp44_ = wingpanel_widgets_indicator_entry_get_base_indicator (_tmp43_);
		_tmp45_ = _tmp44_;
		wingpanel_indicator_opened (_tmp45_);
	} else {
		WingpanelWidgetsIndicatorPopover* _tmp46_;
		GtkWidget* _tmp47_;
		GtkWidget* _tmp48_;
		GtkWidget* _tmp49_;
		WingpanelWidgetsIndicatorPopover* _tmp50_;
		_tmp46_ = self->priv->popover;
		_tmp47_ = gtk_popover_get_relative_to ((GtkPopover*) _tmp46_);
		_tmp48_ = wingpanel_widgets_indicator_entry_get_display_widget (G_TYPE_CHECK_INSTANCE_CAST (_tmp47_, WINGPANEL_WIDGETS_TYPE_INDICATOR_ENTRY, WingpanelWidgetsIndicatorEntry));
		_tmp49_ = _tmp48_;
		wingpanel_services_popover_manager_update_has_tooltip (self, _tmp49_, TRUE);
		_tmp50_ = self->priv->popover;
		gtk_popover_popdown ((GtkPopover*) _tmp50_);
	}
	g_object_notify_by_pspec ((GObject *) self, wingpanel_services_popover_manager_properties[WINGPANEL_SERVICES_POPOVER_MANAGER_CURRENT_INDICATOR_PROPERTY]);
}

static void
wingpanel_services_popover_manager_class_init (WingpanelServicesPopoverManagerClass * klass,
                                               gpointer klass_data)
{
	wingpanel_services_popover_manager_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &WingpanelServicesPopoverManager_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_wingpanel_services_popover_manager_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_wingpanel_services_popover_manager_set_property;
	G_OBJECT_CLASS (klass)->finalize = wingpanel_services_popover_manager_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), WINGPANEL_SERVICES_POPOVER_MANAGER_CURRENT_INDICATOR_PROPERTY, wingpanel_services_popover_manager_properties[WINGPANEL_SERVICES_POPOVER_MANAGER_CURRENT_INDICATOR_PROPERTY] = g_param_spec_object ("current-indicator", "current-indicator", "current-indicator", WINGPANEL_WIDGETS_TYPE_INDICATOR_ENTRY, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
wingpanel_services_popover_manager_instance_init (WingpanelServicesPopoverManager * self,
                                                  gpointer klass)
{
	self->priv = wingpanel_services_popover_manager_get_instance_private (self);
	self->priv->_current_indicator = NULL;
}

static void
wingpanel_services_popover_manager_finalize (GObject * obj)
{
	WingpanelServicesPopoverManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, WINGPANEL_SERVICES_TYPE_POPOVER_MANAGER, WingpanelServicesPopoverManager);
	_g_object_unref0 (self->priv->owner_gesture_controller);
	_g_object_unref0 (self->priv->registered_indicators);
	_g_object_unref0 (self->priv->popover);
	_g_object_unref0 (self->priv->_current_indicator);
	G_OBJECT_CLASS (wingpanel_services_popover_manager_parent_class)->finalize (obj);
}

static GType
wingpanel_services_popover_manager_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (WingpanelServicesPopoverManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) wingpanel_services_popover_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (WingpanelServicesPopoverManager), 0, (GInstanceInitFunc) wingpanel_services_popover_manager_instance_init, NULL };
	GType wingpanel_services_popover_manager_type_id;
	wingpanel_services_popover_manager_type_id = g_type_register_static (G_TYPE_OBJECT, "WingpanelServicesPopoverManager", &g_define_type_info, 0);
	WingpanelServicesPopoverManager_private_offset = g_type_add_instance_private (wingpanel_services_popover_manager_type_id, sizeof (WingpanelServicesPopoverManagerPrivate));
	return wingpanel_services_popover_manager_type_id;
}

GType
wingpanel_services_popover_manager_get_type (void)
{
	static volatile gsize wingpanel_services_popover_manager_type_id__once = 0;
	if (g_once_init_enter (&wingpanel_services_popover_manager_type_id__once)) {
		GType wingpanel_services_popover_manager_type_id;
		wingpanel_services_popover_manager_type_id = wingpanel_services_popover_manager_get_type_once ();
		g_once_init_leave (&wingpanel_services_popover_manager_type_id__once, wingpanel_services_popover_manager_type_id);
	}
	return wingpanel_services_popover_manager_type_id__once;
}

static void
_vala_wingpanel_services_popover_manager_get_property (GObject * object,
                                                       guint property_id,
                                                       GValue * value,
                                                       GParamSpec * pspec)
{
	WingpanelServicesPopoverManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, WINGPANEL_SERVICES_TYPE_POPOVER_MANAGER, WingpanelServicesPopoverManager);
	switch (property_id) {
		case WINGPANEL_SERVICES_POPOVER_MANAGER_CURRENT_INDICATOR_PROPERTY:
		g_value_set_object (value, wingpanel_services_popover_manager_get_current_indicator (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_wingpanel_services_popover_manager_set_property (GObject * object,
                                                       guint property_id,
                                                       const GValue * value,
                                                       GParamSpec * pspec)
{
	WingpanelServicesPopoverManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, WINGPANEL_SERVICES_TYPE_POPOVER_MANAGER, WingpanelServicesPopoverManager);
	switch (property_id) {
		case WINGPANEL_SERVICES_POPOVER_MANAGER_CURRENT_INDICATOR_PROPERTY:
		wingpanel_services_popover_manager_set_current_indicator (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

