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

/*
 * Copyright (c) 2011-2015 Wingpanel Developers (http://launchpad.net/wingpanel)
 *
 * 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 <gtk/gtk.h>
#include <glib-object.h>
#include <granite-7.h>
#include <glib.h>
#include "pantheon-desktop-shell-client-protocol.h"
#include <wayland-client.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <gdk/gdk.h>
#include <cairo-gobject.h>
#include <gdk/wayland/gdkwayland.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_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;
typedef struct _WingpanelPanelWindowPrivate WingpanelPanelWindowPrivate;

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

#define WINGPANEL_WIDGETS_TYPE_PANEL (wingpanel_widgets_panel_get_type ())
#define WINGPANEL_WIDGETS_PANEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WINGPANEL_WIDGETS_TYPE_PANEL, WingpanelWidgetsPanel))
#define WINGPANEL_WIDGETS_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WINGPANEL_WIDGETS_TYPE_PANEL, WingpanelWidgetsPanelClass))
#define WINGPANEL_WIDGETS_IS_PANEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WINGPANEL_WIDGETS_TYPE_PANEL))
#define WINGPANEL_WIDGETS_IS_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WINGPANEL_WIDGETS_TYPE_PANEL))
#define WINGPANEL_WIDGETS_PANEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WINGPANEL_WIDGETS_TYPE_PANEL, WingpanelWidgetsPanelClass))

typedef struct _WingpanelWidgetsPanel WingpanelWidgetsPanel;
typedef struct _WingpanelWidgetsPanelClass WingpanelWidgetsPanelClass;
enum  {
	WINGPANEL_PANEL_WINDOW_0_PROPERTY,
	WINGPANEL_PANEL_WINDOW_NUM_PROPERTIES
};
static GParamSpec* wingpanel_panel_window_properties[WINGPANEL_PANEL_WINDOW_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _wl_proxy_destroy0(var) ((var == NULL) ? NULL : (var = (wl_proxy_destroy (var), NULL)))

#define WINGPANEL_SERVICES_TYPE_BACKGROUND_MANAGER (wingpanel_services_background_manager_get_type ())
#define WINGPANEL_SERVICES_BACKGROUND_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WINGPANEL_SERVICES_TYPE_BACKGROUND_MANAGER, WingpanelServicesBackgroundManager))
#define WINGPANEL_SERVICES_BACKGROUND_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WINGPANEL_SERVICES_TYPE_BACKGROUND_MANAGER, WingpanelServicesBackgroundManagerClass))
#define WINGPANEL_SERVICES_IS_BACKGROUND_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WINGPANEL_SERVICES_TYPE_BACKGROUND_MANAGER))
#define WINGPANEL_SERVICES_IS_BACKGROUND_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WINGPANEL_SERVICES_TYPE_BACKGROUND_MANAGER))
#define WINGPANEL_SERVICES_BACKGROUND_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WINGPANEL_SERVICES_TYPE_BACKGROUND_MANAGER, WingpanelServicesBackgroundManagerClass))

typedef struct _WingpanelServicesBackgroundManager WingpanelServicesBackgroundManager;
typedef struct _WingpanelServicesBackgroundManagerClass WingpanelServicesBackgroundManagerClass;
typedef void (*wl_RegistryListenerGlobal) (void* data, struct wl_registry* wl_registry, guint32 name, const gchar* interface, guint32 version);
#define _wl_registry_destroy0(var) ((var == NULL) ? NULL : (var = (wl_registry_destroy (var), NULL)))
typedef enum  {
	WINGPANEL_SERVICES_BACKGROUND_STATE_LIGHT,
	WINGPANEL_SERVICES_BACKGROUND_STATE_DARK,
	WINGPANEL_SERVICES_BACKGROUND_STATE_MAXIMIZED,
	WINGPANEL_SERVICES_BACKGROUND_STATE_TRANSLUCENT_DARK,
	WINGPANEL_SERVICES_BACKGROUND_STATE_TRANSLUCENT_LIGHT
} WingpanelServicesBackgroundState;

#define WINGPANEL_SERVICES_TYPE_BACKGROUND_STATE (wingpanel_services_background_state_get_type ())
#define _g_free0(var) (var = (g_free (var), NULL))

struct _WingpanelPanelWindow {
	GtkWindow parent_instance;
	WingpanelPanelWindowPrivate * priv;
	WingpanelServicesPopoverManager* popover_manager;
};

struct _WingpanelPanelWindowClass {
	GtkWindowClass parent_class;
};

struct _WingpanelPanelWindowPrivate {
	WingpanelWidgetsPanel* panel;
	gint panel_height;
	struct io_elementary_pantheon_shell_v1* desktop_shell;
	struct io_elementary_pantheon_panel_v1* desktop_panel;
	GtkCssProvider* style_provider;
};

static gint WingpanelPanelWindow_private_offset;
static gpointer wingpanel_panel_window_parent_class = NULL;
static struct wl_registry_listener wingpanel_panel_window_registry_listener;
static struct wl_registry_listener wingpanel_panel_window_registry_listener = {0};

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_services_popover_manager_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WingpanelServicesPopoverManager, g_object_unref)
VALA_EXTERN GType wingpanel_widgets_panel_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WingpanelWidgetsPanel, g_object_unref)
VALA_EXTERN WingpanelPanelWindow* wingpanel_panel_window_new (GtkApplication* application);
VALA_EXTERN WingpanelPanelWindow* wingpanel_panel_window_construct (GType object_type,
                                                        GtkApplication* application);
VALA_EXTERN WingpanelServicesPopoverManager* wingpanel_services_popover_manager_new (void);
VALA_EXTERN WingpanelServicesPopoverManager* wingpanel_services_popover_manager_construct (GType object_type);
VALA_EXTERN WingpanelWidgetsPanel* wingpanel_widgets_panel_new (WingpanelServicesPopoverManager* popover_manager);
VALA_EXTERN WingpanelWidgetsPanel* wingpanel_widgets_panel_construct (GType object_type,
                                                          WingpanelServicesPopoverManager* popover_manager);
static void wingpanel_panel_window_on_realize (WingpanelPanelWindow* self);
static void _wingpanel_panel_window_on_realize_gtk_widget_realize (GtkWidget* _sender,
                                                            gpointer self);
static void __lambda17_ (WingpanelPanelWindow* self);
VALA_EXTERN void wingpanel_widgets_panel_cycle (WingpanelWidgetsPanel* self,
                                    gboolean forward);
static void ___lambda17__g_simple_action_activate (GSimpleAction* _sender,
                                            GVariant* parameter,
                                            gpointer self);
static void __lambda18_ (WingpanelPanelWindow* self);
static void ___lambda18__g_simple_action_activate (GSimpleAction* _sender,
                                            GVariant* parameter,
                                            gpointer self);
static void __lambda19_ (WingpanelPanelWindow* self);
VALA_EXTERN gboolean wingpanel_services_popover_manager_get_indicator_open (WingpanelServicesPopoverManager* self);
VALA_EXTERN GType wingpanel_services_background_manager_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WingpanelServicesBackgroundManager, g_object_unref)
VALA_EXTERN WingpanelServicesBackgroundManager* wingpanel_services_background_manager_get_default (void);
VALA_EXTERN void wingpanel_services_background_manager_restore_window (WingpanelServicesBackgroundManager* self);
VALA_EXTERN void wingpanel_services_background_manager_remember_window (WingpanelServicesBackgroundManager* self);
static void ___lambda19__g_object_notify (GObject* _sender,
                                   GParamSpec* pspec,
                                   gpointer self);
static void wingpanel_panel_window_update_panel_dimensions (WingpanelPanelWindow* self);
static void _wingpanel_panel_window_update_panel_dimensions_g_object_notify (GObject* _sender,
                                                                      GParamSpec* pspec,
                                                                      gpointer self);
static void wingpanel_panel_window_on_compute_size (WingpanelPanelWindow* self,
                                             GdkToplevelSize* top_level_size);
static void _wingpanel_panel_window_on_compute_size_gdk_toplevel_compute_size (GdkToplevel* _sender,
                                                                        GdkToplevelSize* size,
                                                                        gpointer self);
VALA_EXTERN void wingpanel_services_background_manager_initialize (gint panel_height);
static void wingpanel_panel_window_init_wl (WingpanelPanelWindow* self);
VALA_EXTERN gboolean wingpanel_services_display_config_is_logical_layout (void);
VALA_EXTERN void wingpanel_panel_window_toggle_indicator (WingpanelPanelWindow* self,
                                              const gchar* name);
VALA_EXTERN void wingpanel_services_popover_manager_toggle_popover_visible (WingpanelServicesPopoverManager* self,
                                                                const gchar* code_name);
VALA_EXTERN void wingpanel_panel_window_registry_handle_global (WingpanelPanelWindow* self,
                                                    struct wl_registry* wl_registry,
                                                    guint32 name,
                                                    const gchar* interface,
                                                    guint32 version);
static void _wingpanel_panel_window_update_panel_dimensions_gsource_once_func (gpointer self);
static void _wingpanel_panel_window_registry_handle_global_wl_registrylistenerglobal (void* data,
                                                                               struct wl_registry* wl_registry,
                                                                               guint32 name,
                                                                               const gchar* interface,
                                                                               guint32 version);
VALA_EXTERN GType wingpanel_services_background_state_get_type (void) G_GNUC_CONST ;
static void wingpanel_panel_window_update_background (WingpanelPanelWindow* self,
                                               WingpanelServicesBackgroundState state,
                                               guint animation_duration);
static GObject * wingpanel_panel_window_constructor (GType type,
                                              guint n_construct_properties,
                                              GObjectConstructParam * construct_properties);
static void _wingpanel_panel_window_update_background_wingpanel_services_background_manager_background_state_changed (WingpanelServicesBackgroundManager* _sender,
                                                                                                               WingpanelServicesBackgroundState state,
                                                                                                               guint animation_duration,
                                                                                                               gpointer self);
static void wingpanel_panel_window_finalize (GObject * obj);
static GType wingpanel_panel_window_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

static inline gpointer
wingpanel_panel_window_get_instance_private (WingpanelPanelWindow* self)
{
	return G_STRUCT_MEMBER_P (self, WingpanelPanelWindow_private_offset);
}

static void
_wingpanel_panel_window_on_realize_gtk_widget_realize (GtkWidget* _sender,
                                                       gpointer self)
{
	wingpanel_panel_window_on_realize ((WingpanelPanelWindow*) self);
}

static void
__lambda17_ (WingpanelPanelWindow* self)
{
	WingpanelWidgetsPanel* _tmp0_;
	_tmp0_ = self->priv->panel;
	wingpanel_widgets_panel_cycle (_tmp0_, TRUE);
}

static void
___lambda17__g_simple_action_activate (GSimpleAction* _sender,
                                       GVariant* parameter,
                                       gpointer self)
{
	__lambda17_ ((WingpanelPanelWindow*) self);
}

static void
__lambda18_ (WingpanelPanelWindow* self)
{
	WingpanelWidgetsPanel* _tmp0_;
	_tmp0_ = self->priv->panel;
	wingpanel_widgets_panel_cycle (_tmp0_, FALSE);
}

static void
___lambda18__g_simple_action_activate (GSimpleAction* _sender,
                                       GVariant* parameter,
                                       gpointer self)
{
	__lambda18_ ((WingpanelPanelWindow*) self);
}

static void
__lambda19_ (WingpanelPanelWindow* self)
{
	WingpanelServicesPopoverManager* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	_tmp0_ = self->popover_manager;
	_tmp1_ = wingpanel_services_popover_manager_get_indicator_open (_tmp0_);
	_tmp2_ = _tmp1_;
	if (!_tmp2_) {
		WingpanelServicesBackgroundManager* _tmp3_;
		WingpanelServicesBackgroundManager* _tmp4_;
		_tmp3_ = wingpanel_services_background_manager_get_default ();
		_tmp4_ = _tmp3_;
		wingpanel_services_background_manager_restore_window (_tmp4_);
		_g_object_unref0 (_tmp4_);
		return;
	} else {
		WingpanelServicesBackgroundManager* _tmp5_;
		WingpanelServicesBackgroundManager* _tmp6_;
		_tmp5_ = wingpanel_services_background_manager_get_default ();
		_tmp6_ = _tmp5_;
		wingpanel_services_background_manager_remember_window (_tmp6_);
		_g_object_unref0 (_tmp6_);
	}
}

static void
___lambda19__g_object_notify (GObject* _sender,
                              GParamSpec* pspec,
                              gpointer self)
{
	__lambda19_ ((WingpanelPanelWindow*) self);
}

static void
_wingpanel_panel_window_update_panel_dimensions_g_object_notify (GObject* _sender,
                                                                 GParamSpec* pspec,
                                                                 gpointer self)
{
	wingpanel_panel_window_update_panel_dimensions ((WingpanelPanelWindow*) self);
}

WingpanelPanelWindow*
wingpanel_panel_window_construct (GType object_type,
                                  GtkApplication* application)
{
	WingpanelPanelWindow * self = NULL;
	WingpanelServicesPopoverManager* _tmp0_;
	WingpanelServicesPopoverManager* _tmp1_;
	WingpanelWidgetsPanel* _tmp2_;
	WingpanelWidgetsPanel* _tmp3_;
	GSimpleAction* cycle_action = NULL;
	GSimpleAction* _tmp4_;
	GSimpleAction* cycle_back_action = NULL;
	GSimpleAction* _tmp5_;
	gchar* _tmp6_;
	gchar** _tmp7_;
	gchar** _tmp8_;
	gint _tmp8__length1;
	gchar* _tmp9_;
	gchar** _tmp10_;
	gchar** _tmp11_;
	gint _tmp11__length1;
	WingpanelWidgetsPanel* _tmp12_;
	WingpanelServicesPopoverManager* _tmp13_;
	g_return_val_if_fail (application != NULL, NULL);
	self = (WingpanelPanelWindow*) g_object_new (object_type, "application", application, "decorated", FALSE, "resizable", FALSE, "vexpand", FALSE, NULL);
	_tmp0_ = wingpanel_services_popover_manager_new ();
	_g_object_unref0 (self->popover_manager);
	self->popover_manager = _tmp0_;
	_tmp1_ = self->popover_manager;
	_tmp2_ = wingpanel_widgets_panel_new (_tmp1_);
	g_object_ref_sink (_tmp2_);
	_g_object_unref0 (self->priv->panel);
	self->priv->panel = _tmp2_;
	_tmp3_ = self->priv->panel;
	g_signal_connect_object ((GtkWidget*) _tmp3_, "realize", (GCallback) _wingpanel_panel_window_on_realize_gtk_widget_realize, self, 0);
	_tmp4_ = g_simple_action_new ("cycle", NULL);
	cycle_action = _tmp4_;
	g_signal_connect_object (cycle_action, "activate", (GCallback) ___lambda17__g_simple_action_activate, self, 0);
	_tmp5_ = g_simple_action_new ("cycle-back", NULL);
	cycle_back_action = _tmp5_;
	g_signal_connect_object (cycle_back_action, "activate", (GCallback) ___lambda18__g_simple_action_activate, self, 0);
	g_action_map_add_action ((GActionMap*) application, (GAction*) cycle_action);
	g_action_map_add_action ((GActionMap*) application, (GAction*) cycle_back_action);
	_tmp6_ = g_strdup ("<Control>Tab");
	_tmp7_ = g_new0 (gchar*, 1 + 1);
	_tmp7_[0] = _tmp6_;
	_tmp8_ = _tmp7_;
	_tmp8__length1 = 1;
	gtk_application_set_accels_for_action (application, "app.cycle", _tmp8_);
	_tmp8_ = (_vala_array_free (_tmp8_, _tmp8__length1, (GDestroyNotify) g_free), NULL);
	_tmp9_ = g_strdup ("<Control><Shift>Tab");
	_tmp10_ = g_new0 (gchar*, 1 + 1);
	_tmp10_[0] = _tmp9_;
	_tmp11_ = _tmp10_;
	_tmp11__length1 = 1;
	gtk_application_set_accels_for_action (application, "app.cycle-back", _tmp11_);
	_tmp11_ = (_vala_array_free (_tmp11_, _tmp11__length1, (GDestroyNotify) g_free), NULL);
	_tmp12_ = self->priv->panel;
	gtk_window_set_child ((GtkWindow*) self, (GtkWidget*) _tmp12_);
	gtk_widget_remove_css_class ((GtkWidget*) self, GRANITE_STYLE_CLASS_BACKGROUND);
	_tmp13_ = self->popover_manager;
	g_signal_connect_object ((GObject*) _tmp13_, "notify::indicator-open", (GCallback) ___lambda19__g_object_notify, self, 0);
	g_signal_connect_object ((GObject*) self, "notify::scale-factor", (GCallback) _wingpanel_panel_window_update_panel_dimensions_g_object_notify, self, 0);
	_g_object_unref0 (cycle_back_action);
	_g_object_unref0 (cycle_action);
	return self;
}

WingpanelPanelWindow*
wingpanel_panel_window_new (GtkApplication* application)
{
	return wingpanel_panel_window_construct (WINGPANEL_TYPE_PANEL_WINDOW, application);
}

static void
_wingpanel_panel_window_on_compute_size_gdk_toplevel_compute_size (GdkToplevel* _sender,
                                                                   GdkToplevelSize* size,
                                                                   gpointer self)
{
	wingpanel_panel_window_on_compute_size ((WingpanelPanelWindow*) self, size);
}

static void
wingpanel_panel_window_on_realize (WingpanelPanelWindow* self)
{
	GdkSurface* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = gtk_native_get_surface ((GtkNative*) self);
	g_signal_connect_object (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, gdk_toplevel_get_type (), GdkToplevel), "compute-size", (GCallback) _wingpanel_panel_window_on_compute_size_gdk_toplevel_compute_size, self, 0);
	wingpanel_panel_window_update_panel_dimensions (self);
	wingpanel_services_background_manager_initialize (self->priv->panel_height);
	wingpanel_panel_window_init_wl (self);
}

static void
wingpanel_panel_window_on_compute_size (WingpanelPanelWindow* self,
                                        GdkToplevelSize* top_level_size)
{
	gint _tmp0_;
	gint _tmp1_;
	WingpanelWidgetsPanel* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (top_level_size != NULL);
	g_object_get ((GtkWidget*) self, "width-request", &_tmp0_, NULL);
	_tmp1_ = _tmp0_;
	_tmp2_ = self->priv->panel;
	gdk_toplevel_size_set_size (top_level_size, _tmp1_, gtk_widget_get_height ((GtkWidget*) _tmp2_) + 5);
	gdk_toplevel_size_set_shadow_width (top_level_size, 0, 0, 0, 5);
}

static void
wingpanel_panel_window_update_panel_dimensions (WingpanelPanelWindow* self)
{
	WingpanelWidgetsPanel* _tmp0_;
	GdkRectangle monitor_dimensions = {0};
	GdkDisplay* _tmp1_;
	GdkSurface* _tmp2_;
	GdkMonitor* _tmp3_;
	GdkRectangle _tmp4_ = {0};
	GdkRectangle _tmp5_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->panel;
	self->priv->panel_height = gtk_widget_get_height ((GtkWidget*) _tmp0_);
	_tmp1_ = gtk_root_get_display ((GtkRoot*) self);
	_tmp2_ = gtk_native_get_surface ((GtkNative*) self);
	_tmp3_ = gdk_display_get_monitor_at_surface (_tmp1_, _tmp2_);
	gdk_monitor_get_geometry (_tmp3_, &_tmp4_);
	monitor_dimensions = _tmp4_;
	if (!wingpanel_services_display_config_is_logical_layout ()) {
		monitor_dimensions.width = monitor_dimensions.width / gtk_widget_get_scale_factor ((GtkWidget*) self);
		monitor_dimensions.height = monitor_dimensions.height / gtk_widget_get_scale_factor ((GtkWidget*) self);
		monitor_dimensions.x = monitor_dimensions.x / gtk_widget_get_scale_factor ((GtkWidget*) self);
		monitor_dimensions.y = monitor_dimensions.y / gtk_widget_get_scale_factor ((GtkWidget*) self);
	}
	_tmp5_ = monitor_dimensions;
	gtk_widget_set_size_request ((GtkWidget*) self, _tmp5_.width, -1);
}

void
wingpanel_panel_window_toggle_indicator (WingpanelPanelWindow* self,
                                         const gchar* name)
{
	WingpanelServicesPopoverManager* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (name != NULL);
	_tmp0_ = self->popover_manager;
	wingpanel_services_popover_manager_toggle_popover_visible (_tmp0_, name);
}

static void
_wingpanel_panel_window_update_panel_dimensions_gsource_once_func (gpointer self)
{
	wingpanel_panel_window_update_panel_dimensions ((WingpanelPanelWindow*) self);
	g_object_unref (self);
}

void
wingpanel_panel_window_registry_handle_global (WingpanelPanelWindow* self,
                                               struct wl_registry* wl_registry,
                                               guint32 name,
                                               const gchar* interface,
                                               guint32 version)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (wl_registry != NULL);
	g_return_if_fail (interface != NULL);
	if (g_strcmp0 (interface, "io_elementary_pantheon_shell_v1") == 0) {
		gpointer _tmp0_;
		GdkSurface* window = NULL;
		GdkSurface* _tmp1_;
		GdkSurface* _tmp2_;
		_tmp0_ = wl_registry_bind (wl_registry, name, &io_elementary_pantheon_shell_v1_interface, MIN (version, (guint32) 1));
		_wl_proxy_destroy0 (self->priv->desktop_shell);
		self->priv->desktop_shell = (struct io_elementary_pantheon_shell_v1*) _tmp0_;
		_tmp1_ = gtk_native_get_surface ((GtkNative*) self);
		window = _tmp1_;
		_tmp2_ = window;
		if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp2_, gdk_wayland_surface_get_type ())) {
			struct wl_surface* wl_surface = NULL;
			GdkSurface* _tmp3_;
			struct wl_surface* _tmp4_;
			struct io_elementary_pantheon_shell_v1* _tmp5_;
			struct wl_surface* _tmp6_;
			struct io_elementary_pantheon_panel_v1* _tmp7_;
			struct io_elementary_pantheon_panel_v1* _tmp8_;
			struct io_elementary_pantheon_panel_v1* _tmp9_;
			_tmp3_ = window;
			_tmp4_ = gdk_wayland_surface_get_wl_surface (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, gdk_wayland_surface_get_type (), GdkWaylandSurface));
			wl_surface = _tmp4_;
			_tmp5_ = self->priv->desktop_shell;
			_tmp6_ = wl_surface;
			_tmp7_ = io_elementary_pantheon_shell_v1_get_panel (_tmp5_, _tmp6_);
			_wl_proxy_destroy0 (self->priv->desktop_panel);
			self->priv->desktop_panel = _tmp7_;
			_tmp8_ = self->priv->desktop_panel;
			io_elementary_pantheon_panel_v1_set_anchor (_tmp8_, IO_ELEMENTARY_PANTHEON_PANEL_V1_ANCHOR_TOP);
			_tmp9_ = self->priv->desktop_panel;
			io_elementary_pantheon_panel_v1_set_hide_mode (_tmp9_, IO_ELEMENTARY_PANTHEON_PANEL_V1_HIDE_MODE_NEVER);
			g_idle_add_once (_wingpanel_panel_window_update_panel_dimensions_gsource_once_func, g_object_ref (self));
		}
	}
}

static void
_wingpanel_panel_window_registry_handle_global_wl_registrylistenerglobal (void* data,
                                                                          struct wl_registry* wl_registry,
                                                                          guint32 name,
                                                                          const gchar* interface,
                                                                          guint32 version)
{
	wingpanel_panel_window_registry_handle_global (data, wl_registry, name, interface, version);
}

static void
wingpanel_panel_window_init_wl (WingpanelPanelWindow* self)
{
	GdkDisplay* display = NULL;
	GdkDisplay* _tmp0_;
	struct wl_display* wl_display = NULL;
	GdkDisplay* _tmp1_;
	struct wl_display* _tmp2_;
	struct wl_registry* wl_registry = NULL;
	struct wl_display* _tmp3_;
	struct wl_registry* _tmp4_;
	struct wl_registry* _tmp5_;
	struct wl_registry_listener _tmp6_;
	struct wl_display* _tmp7_;
	g_return_if_fail (self != NULL);
	wingpanel_panel_window_registry_listener.global = _wingpanel_panel_window_registry_handle_global_wl_registrylistenerglobal;
	_tmp0_ = gdk_display_get_default ();
	display = _tmp0_;
	_tmp1_ = display;
	_tmp2_ = gdk_wayland_display_get_wl_display (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gdk_wayland_display_get_type (), GdkWaylandDisplay));
	wl_display = _tmp2_;
	_tmp3_ = wl_display;
	_tmp4_ = wl_display_get_registry (_tmp3_);
	wl_registry = _tmp4_;
	_tmp5_ = wl_registry;
	_tmp6_ = wingpanel_panel_window_registry_listener;
	wl_registry_add_listener (_tmp5_, &_tmp6_, self);
	_tmp7_ = wl_display;
	if (wl_display_roundtrip (_tmp7_) < 0) {
		_wl_registry_destroy0 (wl_registry);
		return;
	}
	_wl_registry_destroy0 (wl_registry);
}

static void
wingpanel_panel_window_update_background (WingpanelPanelWindow* self,
                                          WingpanelServicesBackgroundState state,
                                          guint animation_duration)
{
	GtkCssProvider* _tmp0_;
	gchar* css = NULL;
	gchar* _tmp4_;
	GtkCssProvider* _tmp5_;
	const gchar* _tmp6_;
	struct io_elementary_pantheon_panel_v1* _tmp29_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->style_provider;
	if (_tmp0_ == NULL) {
		GtkCssProvider* _tmp1_;
		GdkDisplay* _tmp2_;
		GtkCssProvider* _tmp3_;
		_tmp1_ = gtk_css_provider_new ();
		_g_object_unref0 (self->priv->style_provider);
		self->priv->style_provider = _tmp1_;
		_tmp2_ = gdk_display_get_default ();
		_tmp3_ = self->priv->style_provider;
		gtk_style_context_add_provider_for_display (_tmp2_, (GtkStyleProvider*) _tmp3_, (guint) GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
	}
	_tmp4_ = g_strdup_printf ("\n" \
"            panel {\n" \
"                transition: all %ums cubic-bezier(0.4, 0, 0.2, 1);\n" \
"            }\n" \
"        ", animation_duration);
	css = _tmp4_;
	_tmp5_ = self->priv->style_provider;
	_tmp6_ = css;
	gtk_css_provider_load_from_string (_tmp5_, _tmp6_);
	switch (state) {
		case WINGPANEL_SERVICES_BACKGROUND_STATE_DARK:
		{
			WingpanelWidgetsPanel* _tmp7_;
			gchar* _tmp8_;
			gchar** _tmp9_;
			gchar** _tmp10_;
			gint _tmp10__length1;
			_tmp7_ = self->priv->panel;
			_tmp8_ = g_strdup ("color-light");
			_tmp9_ = g_new0 (gchar*, 1 + 1);
			_tmp9_[0] = _tmp8_;
			_tmp10_ = _tmp9_;
			_tmp10__length1 = 1;
			gtk_widget_set_css_classes ((GtkWidget*) _tmp7_, _tmp10_);
			_tmp10_ = (_vala_array_free (_tmp10_, _tmp10__length1, (GDestroyNotify) g_free), NULL);
			break;
		}
		case WINGPANEL_SERVICES_BACKGROUND_STATE_LIGHT:
		{
			WingpanelWidgetsPanel* _tmp11_;
			gchar* _tmp12_;
			gchar** _tmp13_;
			gchar** _tmp14_;
			gint _tmp14__length1;
			_tmp11_ = self->priv->panel;
			_tmp12_ = g_strdup ("color-dark");
			_tmp13_ = g_new0 (gchar*, 1 + 1);
			_tmp13_[0] = _tmp12_;
			_tmp14_ = _tmp13_;
			_tmp14__length1 = 1;
			gtk_widget_set_css_classes ((GtkWidget*) _tmp11_, _tmp14_);
			_tmp14_ = (_vala_array_free (_tmp14_, _tmp14__length1, (GDestroyNotify) g_free), NULL);
			break;
		}
		case WINGPANEL_SERVICES_BACKGROUND_STATE_MAXIMIZED:
		{
			WingpanelWidgetsPanel* _tmp15_;
			gchar* _tmp16_;
			gchar** _tmp17_;
			gchar** _tmp18_;
			gint _tmp18__length1;
			_tmp15_ = self->priv->panel;
			_tmp16_ = g_strdup ("maximized");
			_tmp17_ = g_new0 (gchar*, 1 + 1);
			_tmp17_[0] = _tmp16_;
			_tmp18_ = _tmp17_;
			_tmp18__length1 = 1;
			gtk_widget_set_css_classes ((GtkWidget*) _tmp15_, _tmp18_);
			_tmp18_ = (_vala_array_free (_tmp18_, _tmp18__length1, (GDestroyNotify) g_free), NULL);
			break;
		}
		case WINGPANEL_SERVICES_BACKGROUND_STATE_TRANSLUCENT_DARK:
		{
			WingpanelWidgetsPanel* _tmp19_;
			gchar* _tmp20_;
			gchar* _tmp21_;
			gchar** _tmp22_;
			gchar** _tmp23_;
			gint _tmp23__length1;
			_tmp19_ = self->priv->panel;
			_tmp20_ = g_strdup ("color-light");
			_tmp21_ = g_strdup ("translucent");
			_tmp22_ = g_new0 (gchar*, 2 + 1);
			_tmp22_[0] = _tmp20_;
			_tmp22_[1] = _tmp21_;
			_tmp23_ = _tmp22_;
			_tmp23__length1 = 2;
			gtk_widget_set_css_classes ((GtkWidget*) _tmp19_, _tmp23_);
			_tmp23_ = (_vala_array_free (_tmp23_, _tmp23__length1, (GDestroyNotify) g_free), NULL);
			break;
		}
		case WINGPANEL_SERVICES_BACKGROUND_STATE_TRANSLUCENT_LIGHT:
		{
			WingpanelWidgetsPanel* _tmp24_;
			gchar* _tmp25_;
			gchar* _tmp26_;
			gchar** _tmp27_;
			gchar** _tmp28_;
			gint _tmp28__length1;
			_tmp24_ = self->priv->panel;
			_tmp25_ = g_strdup ("color-dark");
			_tmp26_ = g_strdup ("translucent");
			_tmp27_ = g_new0 (gchar*, 2 + 1);
			_tmp27_[0] = _tmp25_;
			_tmp27_[1] = _tmp26_;
			_tmp28_ = _tmp27_;
			_tmp28__length1 = 2;
			gtk_widget_set_css_classes ((GtkWidget*) _tmp24_, _tmp28_);
			_tmp28_ = (_vala_array_free (_tmp28_, _tmp28__length1, (GDestroyNotify) g_free), NULL);
			break;
		}
		default:
		break;
	}
	_tmp29_ = self->priv->desktop_panel;
	if (_tmp29_ == NULL) {
		_g_free0 (css);
		return;
	}
	switch (state) {
		case WINGPANEL_SERVICES_BACKGROUND_STATE_DARK:
		case WINGPANEL_SERVICES_BACKGROUND_STATE_LIGHT:
		case WINGPANEL_SERVICES_BACKGROUND_STATE_MAXIMIZED:
		{
			struct io_elementary_pantheon_panel_v1* _tmp30_;
			_tmp30_ = self->priv->desktop_panel;
			io_elementary_pantheon_panel_v1_remove_blur (_tmp30_);
			break;
		}
		case WINGPANEL_SERVICES_BACKGROUND_STATE_TRANSLUCENT_DARK:
		case WINGPANEL_SERVICES_BACKGROUND_STATE_TRANSLUCENT_LIGHT:
		{
			struct io_elementary_pantheon_panel_v1* _tmp31_;
			_tmp31_ = self->priv->desktop_panel;
			io_elementary_pantheon_panel_v1_add_blur (_tmp31_, (guint) 0, (guint) 0, (guint) 0, (guint) 4, (guint) 0);
			break;
		}
		default:
		break;
	}
	_g_free0 (css);
}

static void
_wingpanel_panel_window_update_background_wingpanel_services_background_manager_background_state_changed (WingpanelServicesBackgroundManager* _sender,
                                                                                                          WingpanelServicesBackgroundState state,
                                                                                                          guint animation_duration,
                                                                                                          gpointer self)
{
	wingpanel_panel_window_update_background ((WingpanelPanelWindow*) self, state, animation_duration);
}

static GObject *
wingpanel_panel_window_constructor (GType type,
                                    guint n_construct_properties,
                                    GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	WingpanelPanelWindow * self;
	WingpanelServicesBackgroundManager* _tmp0_;
	WingpanelServicesBackgroundManager* _tmp1_;
	parent_class = G_OBJECT_CLASS (wingpanel_panel_window_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, WINGPANEL_TYPE_PANEL_WINDOW, WingpanelPanelWindow);
	_tmp0_ = wingpanel_services_background_manager_get_default ();
	_tmp1_ = _tmp0_;
	g_signal_connect_object (_tmp1_, "background-state-changed", (GCallback) _wingpanel_panel_window_update_background_wingpanel_services_background_manager_background_state_changed, self, 0);
	_g_object_unref0 (_tmp1_);
	return obj;
}

static void
wingpanel_panel_window_class_init (WingpanelPanelWindowClass * klass,
                                   gpointer klass_data)
{
	wingpanel_panel_window_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &WingpanelPanelWindow_private_offset);
	G_OBJECT_CLASS (klass)->constructor = wingpanel_panel_window_constructor;
	G_OBJECT_CLASS (klass)->finalize = wingpanel_panel_window_finalize;
}

static void
wingpanel_panel_window_instance_init (WingpanelPanelWindow * self,
                                      gpointer klass)
{
	self->priv = wingpanel_panel_window_get_instance_private (self);
	self->priv->style_provider = NULL;
}

static void
wingpanel_panel_window_finalize (GObject * obj)
{
	WingpanelPanelWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, WINGPANEL_TYPE_PANEL_WINDOW, WingpanelPanelWindow);
	_g_object_unref0 (self->popover_manager);
	_g_object_unref0 (self->priv->panel);
	_wl_proxy_destroy0 (self->priv->desktop_shell);
	_wl_proxy_destroy0 (self->priv->desktop_panel);
	_g_object_unref0 (self->priv->style_provider);
	G_OBJECT_CLASS (wingpanel_panel_window_parent_class)->finalize (obj);
}

static GType
wingpanel_panel_window_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (WingpanelPanelWindowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) wingpanel_panel_window_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (WingpanelPanelWindow), 0, (GInstanceInitFunc) wingpanel_panel_window_instance_init, NULL };
	GType wingpanel_panel_window_type_id;
	wingpanel_panel_window_type_id = g_type_register_static (gtk_window_get_type (), "WingpanelPanelWindow", &g_define_type_info, 0);
	WingpanelPanelWindow_private_offset = g_type_add_instance_private (wingpanel_panel_window_type_id, sizeof (WingpanelPanelWindowPrivate));
	return wingpanel_panel_window_type_id;
}

GType
wingpanel_panel_window_get_type (void)
{
	static volatile gsize wingpanel_panel_window_type_id__once = 0;
	if (g_once_init_enter (&wingpanel_panel_window_type_id__once)) {
		GType wingpanel_panel_window_type_id;
		wingpanel_panel_window_type_id = wingpanel_panel_window_get_type_once ();
		g_once_init_leave (&wingpanel_panel_window_type_id__once, wingpanel_panel_window_type_id);
	}
	return wingpanel_panel_window_type_id__once;
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

