/* PopoverManager.c generated by valac 0.56.19, 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 <glib.h>
#include <gee.h>
#include <stdlib.h>
#include <string.h>
#include <granite-7.h>
#include <gtk/gtk.h>
#include "wingpanel-9.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_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;
enum  {
	WINGPANEL_SERVICES_POPOVER_MANAGER_0_PROPERTY,
	WINGPANEL_SERVICES_POPOVER_MANAGER_INDICATOR_OPEN_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)))

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

struct _WingpanelServicesPopoverManagerClass {
	GObjectClass parent_class;
};

struct _WingpanelServicesPopoverManagerPrivate {
	gboolean _indicator_open;
	GeeHashMap* registered_indicators;
	GtkPopover* popover;
	WingpanelWidgetsIndicatorEntry* _current_indicator;
};

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_widgets_indicator_entry_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WingpanelWidgetsIndicatorEntry, g_object_unref)
VALA_EXTERN WingpanelServicesPopoverManager* wingpanel_services_popover_manager_new (void);
VALA_EXTERN WingpanelServicesPopoverManager* wingpanel_services_popover_manager_construct (GType object_type);
static void __lambda8_ (WingpanelServicesPopoverManager* self);
VALA_EXTERN void wingpanel_services_popover_manager_set_current_indicator (WingpanelServicesPopoverManager* self,
                                                               WingpanelWidgetsIndicatorEntry* value);
static void ___lambda8__gtk_popover_closed (GtkPopover* _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 gboolean wingpanel_services_popover_manager_get_indicator_open (WingpanelServicesPopoverManager* self);
static void wingpanel_services_popover_manager_set_indicator_open (WingpanelServicesPopoverManager* self,
                                                            gboolean value);
VALA_EXTERN GtkWidget* wingpanel_widgets_indicator_entry_get_display_widget (WingpanelWidgetsIndicatorEntry* self);
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 void
__lambda8_ (WingpanelServicesPopoverManager* self)
{
	GtkPopover* _tmp0_;
	wingpanel_services_popover_manager_set_current_indicator (self, NULL);
	_tmp0_ = self->priv->popover;
	gtk_widget_unparent ((GtkWidget*) _tmp0_);
}

static void
___lambda8__gtk_popover_closed (GtkPopover* _sender,
                                gpointer self)
{
	__lambda8_ ((WingpanelServicesPopoverManager*) self);
}

WingpanelServicesPopoverManager*
wingpanel_services_popover_manager_construct (GType object_type)
{
	WingpanelServicesPopoverManager * self = NULL;
	GeeHashMap* _tmp0_;
	GtkPopover* _tmp1_ = NULL;
	GtkPopover* _tmp2_;
	GtkPopover* _tmp3_;
	self = (WingpanelServicesPopoverManager*) g_object_new (object_type, NULL);
	_tmp0_ = 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 = _tmp0_;
	_tmp1_ = (GtkPopover*) gtk_popover_new ();
	gtk_popover_set_position (_tmp1_, GTK_POS_BOTTOM);
	g_object_ref_sink (_tmp1_);
	_g_object_unref0 (self->priv->popover);
	self->priv->popover = _tmp1_;
	_tmp2_ = self->priv->popover;
	gtk_widget_add_css_class ((GtkWidget*) _tmp2_, "indicator");
	_tmp3_ = self->priv->popover;
	g_signal_connect_object (_tmp3_, "closed", (GCallback) ___lambda8__gtk_popover_closed, self, 0);
	return self;
}

WingpanelServicesPopoverManager*
wingpanel_services_popover_manager_new (void)
{
	return wingpanel_services_popover_manager_construct (WINGPANEL_SERVICES_TYPE_POPOVER_MANAGER);
}

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

gboolean
wingpanel_services_popover_manager_get_indicator_open (WingpanelServicesPopoverManager* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_indicator_open;
	return result;
}

static void
wingpanel_services_popover_manager_set_indicator_open (WingpanelServicesPopoverManager* self,
                                                       gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = wingpanel_services_popover_manager_get_indicator_open (self);
	if (old_value != value) {
		self->priv->_indicator_open = value;
		g_object_notify_by_pspec ((GObject *) self, wingpanel_services_popover_manager_properties[WINGPANEL_SERVICES_POPOVER_MANAGER_INDICATOR_OPEN_PROPERTY]);
	}
}

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

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

void
wingpanel_services_popover_manager_set_current_indicator (WingpanelServicesPopoverManager* self,
                                                          WingpanelWidgetsIndicatorEntry* value)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp2_ = FALSE;
	WingpanelWidgetsIndicatorEntry* _tmp3_;
	WingpanelWidgetsIndicatorEntry* _tmp30_;
	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_;
		wingpanel_services_popover_manager_set_indicator_open (self, TRUE);
		_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_;
			wingpanel_services_popover_manager_set_indicator_open (self, FALSE);
			_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_;
				GtkPopover* _tmp29_;
				_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->popover;
				gtk_widget_unparent ((GtkWidget*) _tmp29_);
			}
		}
	}
	_tmp30_ = self->priv->_current_indicator;
	if (_tmp30_ != NULL) {
		GtkPopover* _tmp31_;
		WingpanelWidgetsIndicatorEntry* _tmp32_;
		GtkWidget* _tmp33_;
		GtkWidget* _tmp34_;
		WingpanelWidgetsIndicatorEntry* _tmp35_;
		GtkWidget* _tmp36_;
		GtkWidget* _tmp37_;
		GtkPopover* _tmp38_;
		WingpanelWidgetsIndicatorEntry* _tmp39_;
		GtkPopover* _tmp40_;
		WingpanelWidgetsIndicatorEntry* _tmp41_;
		WingpanelIndicator* _tmp42_;
		WingpanelIndicator* _tmp43_;
		_tmp31_ = self->priv->popover;
		_tmp32_ = self->priv->_current_indicator;
		_tmp33_ = wingpanel_widgets_indicator_entry_get_indicator_widget (_tmp32_);
		_tmp34_ = _tmp33_;
		gtk_popover_set_child (_tmp31_, _tmp34_);
		_tmp35_ = self->priv->_current_indicator;
		_tmp36_ = wingpanel_widgets_indicator_entry_get_display_widget (_tmp35_);
		_tmp37_ = _tmp36_;
		wingpanel_services_popover_manager_update_has_tooltip (self, _tmp37_, FALSE);
		_tmp38_ = self->priv->popover;
		_tmp39_ = self->priv->_current_indicator;
		gtk_widget_set_parent ((GtkWidget*) _tmp38_, (GtkWidget*) _tmp39_);
		_tmp40_ = self->priv->popover;
		gtk_popover_popup (_tmp40_);
		_tmp41_ = self->priv->_current_indicator;
		_tmp42_ = wingpanel_widgets_indicator_entry_get_base_indicator (_tmp41_);
		_tmp43_ = _tmp42_;
		wingpanel_indicator_opened (_tmp43_);
	} else {
		GtkPopover* _tmp44_;
		GtkWidget* _tmp45_;
		GtkWidget* _tmp46_;
		GtkWidget* _tmp47_;
		GtkWidget* _tmp48_;
		GtkPopover* _tmp49_;
		_tmp44_ = self->priv->popover;
		_tmp45_ = gtk_widget_get_parent ((GtkWidget*) _tmp44_);
		_tmp46_ = _tmp45_;
		_tmp47_ = wingpanel_widgets_indicator_entry_get_display_widget (G_TYPE_CHECK_INSTANCE_CAST (_tmp46_, WINGPANEL_WIDGETS_TYPE_INDICATOR_ENTRY, WingpanelWidgetsIndicatorEntry));
		_tmp48_ = _tmp47_;
		wingpanel_services_popover_manager_update_has_tooltip (self, _tmp48_, TRUE);
		_tmp49_ = self->priv->popover;
		gtk_popover_popdown (_tmp49_);
	}
	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_INDICATOR_OPEN_PROPERTY, wingpanel_services_popover_manager_properties[WINGPANEL_SERVICES_POPOVER_MANAGER_INDICATOR_OPEN_PROPERTY] = g_param_spec_boolean ("indicator-open", "indicator-open", "indicator-open", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	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->_indicator_open = FALSE;
	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->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_INDICATOR_OPEN_PROPERTY:
		g_value_set_boolean (value, wingpanel_services_popover_manager_get_indicator_open (self));
		break;
		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_INDICATOR_OPEN_PROPERTY:
		wingpanel_services_popover_manager_set_indicator_open (self, g_value_get_boolean (value));
		break;
		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;
}

