/* PanelWindow.c generated by valac 0.56.3, 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 <glib.h>
#include <gdk/gdk.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>
#include <cairo-gobject.h>

#define WINGPANEL_WIDGETS_STYLE_CLASS_PANEL "panel"
#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 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_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;

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

struct _WingpanelPanelWindowClass {
	GtkWindowClass parent_class;
};

struct _WingpanelPanelWindowPrivate {
	WingpanelWidgetsPanel* panel;
	gint monitor_number;
	gint monitor_width;
	gint monitor_height;
	gint monitor_x;
	gint monitor_y;
	gint panel_height;
	gboolean expanded;
	gint panel_displacement;
};

static gint WingpanelPanelWindow_private_offset;
static gpointer wingpanel_panel_window_parent_class = NULL;

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);
static void wingpanel_panel_window_update_panel_dimensions (WingpanelPanelWindow* self);
static void _wingpanel_panel_window_update_panel_dimensions_gdk_screen_size_changed (GdkScreen* _sender,
                                                                              gpointer self);
static void _wingpanel_panel_window_update_panel_dimensions_gdk_screen_monitors_changed (GdkScreen* _sender,
                                                                                  gpointer self);
static void wingpanel_panel_window_update_visual (WingpanelPanelWindow* self);
static void _wingpanel_panel_window_update_visual_gtk_widget_screen_changed (GtkWidget* _sender,
                                                                      GdkScreen* previous_screen,
                                                                      gpointer self);
VALA_EXTERN WingpanelServicesPopoverManager* wingpanel_services_popover_manager_new (WingpanelPanelWindow* owner);
VALA_EXTERN WingpanelServicesPopoverManager* wingpanel_services_popover_manager_construct (GType object_type,
                                                                               WingpanelPanelWindow* owner);
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 __lambda22_ (WingpanelPanelWindow* self);
VALA_EXTERN void wingpanel_widgets_panel_cycle (WingpanelWidgetsPanel* self,
                                    gboolean forward);
static void ___lambda22__g_simple_action_activate (GSimpleAction* _sender,
                                            GVariant* parameter,
                                            gpointer self);
static void __lambda23_ (WingpanelPanelWindow* self);
static void ___lambda23__g_simple_action_activate (GSimpleAction* _sender,
                                            GVariant* parameter,
                                            gpointer self);
static gboolean wingpanel_panel_window_animation_step (WingpanelPanelWindow* self);
VALA_EXTERN void wingpanel_services_background_manager_initialize (gint monitor,
                                                       gint panel_height);
static gboolean _wingpanel_panel_window_animation_step_gsource_func (gpointer self);
VALA_EXTERN gboolean wingpanel_utils_is_wayland (void);
VALA_EXTERN GType wingpanel_widgets_indicator_entry_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WingpanelWidgetsIndicatorEntry, g_object_unref)
VALA_EXTERN WingpanelWidgetsIndicatorEntry* wingpanel_services_popover_manager_get_current_indicator (WingpanelServicesPopoverManager* self);
static void wingpanel_panel_window_update_struts (WingpanelPanelWindow* self);
VALA_EXTERN void wingpanel_panel_window_set_expanded (WingpanelPanelWindow* self,
                                          gboolean expand);
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_remember_window (WingpanelServicesBackgroundManager* self);
VALA_EXTERN void wingpanel_services_background_manager_restore_window (WingpanelServicesBackgroundManager* 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 gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

static void
_wingpanel_panel_window_update_panel_dimensions_gdk_screen_size_changed (GdkScreen* _sender,
                                                                         gpointer self)
{
	wingpanel_panel_window_update_panel_dimensions ((WingpanelPanelWindow*) self);
}

static void
_wingpanel_panel_window_update_panel_dimensions_gdk_screen_monitors_changed (GdkScreen* _sender,
                                                                             gpointer self)
{
	wingpanel_panel_window_update_panel_dimensions ((WingpanelPanelWindow*) self);
}

static void
_wingpanel_panel_window_update_visual_gtk_widget_screen_changed (GtkWidget* _sender,
                                                                 GdkScreen* previous_screen,
                                                                 gpointer self)
{
	wingpanel_panel_window_update_visual ((WingpanelPanelWindow*) self);
}

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

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

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

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

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

WingpanelPanelWindow*
wingpanel_panel_window_construct (GType object_type,
                                  GtkApplication* application)
{
	WingpanelPanelWindow * self = NULL;
	GdkScreen* _tmp0_;
	GdkScreen* _tmp1_;
	GtkCssProvider* panel_provider = NULL;
	GtkCssProvider* _tmp2_;
	GtkStyleContext* style_context = NULL;
	GtkStyleContext* _tmp3_;
	GtkStyleContext* _tmp4_;
	GtkCssProvider* app_provider = NULL;
	GtkCssProvider* _tmp5_;
	GdkScreen* _tmp6_;
	GdkScreen* _tmp7_;
	GdkScreen* _tmp8_;
	GdkScreen* _tmp9_;
	GdkScreen* _tmp10_;
	WingpanelServicesPopoverManager* _tmp11_;
	WingpanelServicesPopoverManager* _tmp12_;
	WingpanelWidgetsPanel* _tmp13_;
	WingpanelWidgetsPanel* _tmp14_;
	GSimpleAction* cycle_action = NULL;
	GSimpleAction* _tmp15_;
	GSimpleAction* cycle_back_action = NULL;
	GSimpleAction* _tmp16_;
	gchar* _tmp17_;
	gchar** _tmp18_;
	gchar** _tmp19_;
	gint _tmp19__length1;
	gchar* _tmp20_;
	gchar** _tmp21_;
	gchar** _tmp22_;
	gint _tmp22__length1;
	WingpanelWidgetsPanel* _tmp23_;
	g_return_val_if_fail (application != NULL, NULL);
	self = (WingpanelPanelWindow*) g_object_new (object_type, "application", application, "app-paintable", TRUE, "decorated", FALSE, "resizable", FALSE, "skip-pager-hint", TRUE, "skip-taskbar-hint", TRUE, "type-hint", GDK_WINDOW_TYPE_HINT_DOCK, "vexpand", FALSE, NULL);
	_tmp0_ = gtk_window_get_screen ((GtkWindow*) self);
	_tmp1_ = _tmp0_;
	self->priv->monitor_number = gdk_screen_get_primary_monitor (_tmp1_);
	_tmp2_ = gtk_css_provider_new ();
	panel_provider = _tmp2_;
	gtk_css_provider_load_from_resource (panel_provider, "io/elementary/wingpanel/panel.css");
	_tmp3_ = gtk_widget_get_style_context ((GtkWidget*) self);
	_tmp4_ = _g_object_ref0 (_tmp3_);
	style_context = _tmp4_;
	gtk_style_context_add_class (style_context, WINGPANEL_WIDGETS_STYLE_CLASS_PANEL);
	gtk_style_context_add_provider (style_context, (GtkStyleProvider*) panel_provider, (guint) GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
	_tmp5_ = gtk_css_provider_new ();
	app_provider = _tmp5_;
	gtk_css_provider_load_from_resource (app_provider, "io/elementary/wingpanel/application.css");
	_tmp6_ = gdk_screen_get_default ();
	gtk_style_context_add_provider_for_screen (_tmp6_, (GtkStyleProvider*) app_provider, (guint) GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
	_tmp7_ = gtk_window_get_screen ((GtkWindow*) self);
	_tmp8_ = _tmp7_;
	g_signal_connect_object (_tmp8_, "size-changed", (GCallback) _wingpanel_panel_window_update_panel_dimensions_gdk_screen_size_changed, self, 0);
	_tmp9_ = gtk_window_get_screen ((GtkWindow*) self);
	_tmp10_ = _tmp9_;
	g_signal_connect_object (_tmp10_, "monitors-changed", (GCallback) _wingpanel_panel_window_update_panel_dimensions_gdk_screen_monitors_changed, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "screen-changed", (GCallback) _wingpanel_panel_window_update_visual_gtk_widget_screen_changed, self, 0);
	wingpanel_panel_window_update_visual (self);
	_tmp11_ = wingpanel_services_popover_manager_new (self);
	_g_object_unref0 (self->popover_manager);
	self->popover_manager = _tmp11_;
	_tmp12_ = self->popover_manager;
	_tmp13_ = wingpanel_widgets_panel_new (_tmp12_);
	g_object_ref_sink (_tmp13_);
	_g_object_unref0 (self->priv->panel);
	self->priv->panel = _tmp13_;
	_tmp14_ = self->priv->panel;
	g_signal_connect_object ((GtkWidget*) _tmp14_, "realize", (GCallback) _wingpanel_panel_window_on_realize_gtk_widget_realize, self, 0);
	_tmp15_ = g_simple_action_new ("cycle", NULL);
	cycle_action = _tmp15_;
	g_signal_connect_object (cycle_action, "activate", (GCallback) ___lambda22__g_simple_action_activate, self, 0);
	_tmp16_ = g_simple_action_new ("cycle-back", NULL);
	cycle_back_action = _tmp16_;
	g_signal_connect_object (cycle_back_action, "activate", (GCallback) ___lambda23__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);
	_tmp17_ = g_strdup ("<Control>Tab");
	_tmp18_ = g_new0 (gchar*, 1 + 1);
	_tmp18_[0] = _tmp17_;
	_tmp19_ = _tmp18_;
	_tmp19__length1 = 1;
	gtk_application_set_accels_for_action (application, "app.cycle", _tmp19_);
	_tmp19_ = (_vala_array_free (_tmp19_, _tmp19__length1, (GDestroyNotify) g_free), NULL);
	_tmp20_ = g_strdup ("<Control><Shift>Tab");
	_tmp21_ = g_new0 (gchar*, 1 + 1);
	_tmp21_[0] = _tmp20_;
	_tmp22_ = _tmp21_;
	_tmp22__length1 = 1;
	gtk_application_set_accels_for_action (application, "app.cycle-back", _tmp22_);
	_tmp22_ = (_vala_array_free (_tmp22_, _tmp22__length1, (GDestroyNotify) g_free), NULL);
	_tmp23_ = self->priv->panel;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp23_);
	_g_object_unref0 (cycle_back_action);
	_g_object_unref0 (cycle_action);
	_g_object_unref0 (app_provider);
	_g_object_unref0 (style_context);
	_g_object_unref0 (panel_provider);
	return self;
}

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

static gboolean
wingpanel_panel_window_animation_step (WingpanelPanelWindow* self)
{
	gint _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	if (self->priv->panel_displacement <= (self->priv->panel_height * -1)) {
		result = FALSE;
		return result;
	}
	_tmp0_ = self->priv->panel_displacement;
	self->priv->panel_displacement = _tmp0_ - 1;
	wingpanel_panel_window_update_panel_dimensions (self);
	result = TRUE;
	return result;
}

static gboolean
_wingpanel_panel_window_animation_step_gsource_func (gpointer self)
{
	gboolean result;
	result = wingpanel_panel_window_animation_step ((WingpanelPanelWindow*) self);
	return result;
}

static void
wingpanel_panel_window_on_realize (WingpanelPanelWindow* self)
{
	g_return_if_fail (self != NULL);
	wingpanel_panel_window_update_panel_dimensions (self);
	wingpanel_services_background_manager_initialize (self->priv->monitor_number, self->priv->panel_height);
	g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) (300 / self->priv->panel_height), _wingpanel_panel_window_animation_step_gsource_func, g_object_ref (self), g_object_unref);
}

static void
wingpanel_panel_window_update_panel_dimensions (WingpanelPanelWindow* self)
{
	WingpanelWidgetsPanel* _tmp0_;
	GdkScreen* _tmp1_;
	GdkScreen* _tmp2_;
	GdkRectangle monitor_dimensions = {0};
	GdkRectangle _tmp9_;
	GdkRectangle _tmp10_;
	gint _tmp11_ = 0;
	WingpanelServicesPopoverManager* _tmp12_;
	WingpanelWidgetsIndicatorEntry* _tmp13_;
	WingpanelWidgetsIndicatorEntry* _tmp14_;
	GdkRectangle _tmp15_;
	GdkRectangle _tmp16_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->panel;
	self->priv->panel_height = gtk_widget_get_allocated_height ((GtkWidget*) _tmp0_);
	_tmp1_ = gtk_window_get_screen ((GtkWindow*) self);
	_tmp2_ = _tmp1_;
	self->priv->monitor_number = gdk_screen_get_primary_monitor (_tmp2_);
	if (wingpanel_utils_is_wayland ()) {
		GdkDisplay* _tmp3_;
		GdkMonitor* _tmp4_;
		GdkRectangle _tmp5_ = {0};
		_tmp3_ = gtk_widget_get_display ((GtkWidget*) self);
		_tmp4_ = gdk_display_get_monitor (_tmp3_, 0);
		gdk_monitor_get_geometry (_tmp4_, &_tmp5_);
		monitor_dimensions = _tmp5_;
	} else {
		GdkDisplay* _tmp6_;
		GdkMonitor* _tmp7_;
		GdkRectangle _tmp8_ = {0};
		_tmp6_ = gtk_widget_get_display ((GtkWidget*) self);
		_tmp7_ = gdk_display_get_primary_monitor (_tmp6_);
		gdk_monitor_get_geometry (_tmp7_, &_tmp8_);
		monitor_dimensions = _tmp8_;
	}
	_tmp9_ = monitor_dimensions;
	self->priv->monitor_width = _tmp9_.width;
	_tmp10_ = monitor_dimensions;
	self->priv->monitor_height = _tmp10_.height;
	_tmp12_ = self->popover_manager;
	_tmp13_ = wingpanel_services_popover_manager_get_current_indicator (_tmp12_);
	_tmp14_ = _tmp13_;
	if (_tmp14_ != NULL) {
		_tmp11_ = self->priv->monitor_height;
	} else {
		_tmp11_ = -1;
	}
	gtk_widget_set_size_request ((GtkWidget*) self, self->priv->monitor_width, _tmp11_);
	_tmp15_ = monitor_dimensions;
	self->priv->monitor_x = _tmp15_.x;
	_tmp16_ = monitor_dimensions;
	self->priv->monitor_y = _tmp16_.y;
	gtk_window_move ((GtkWindow*) self, self->priv->monitor_x, self->priv->monitor_y - (self->priv->panel_height + self->priv->panel_displacement));
	wingpanel_panel_window_update_struts (self);
}

static void
wingpanel_panel_window_update_visual (WingpanelPanelWindow* self)
{
	GdkVisual* visual = NULL;
	GdkScreen* _tmp0_;
	GdkScreen* _tmp1_;
	GdkVisual* _tmp2_;
	GdkVisual* _tmp3_;
	GdkVisual* _tmp4_;
	g_return_if_fail (self != NULL);
	_tmp0_ = gtk_window_get_screen ((GtkWindow*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = gdk_screen_get_rgba_visual (_tmp1_);
	_tmp3_ = _g_object_ref0 (_tmp2_);
	visual = _tmp3_;
	_tmp4_ = visual;
	if (_tmp4_ == NULL) {
		g_warning ("PanelWindow.vala:133: Compositing not available, things will Look Bad " \
"(TM)");
	} else {
		GdkVisual* _tmp5_;
		_tmp5_ = visual;
		gtk_widget_set_visual ((GtkWidget*) self, _tmp5_);
	}
	_g_object_unref0 (visual);
}

static void
wingpanel_panel_window_update_struts (WingpanelPanelWindow* self)
{
	gboolean _tmp0_ = FALSE;
	GdkDisplay* display = NULL;
	GdkDisplay* _tmp2_;
	GdkDisplay* _tmp3_;
	gint n_monitors = 0;
	GdkDisplay* _tmp4_;
	gint screen_width = 0;
	gboolean no_monitor_left = FALSE;
	gboolean no_monitor_right = FALSE;
	gboolean no_monitor_above = FALSE;
	glong struts[12] = {0};
	glong _tmp24_[12] = {0};
	gint scale_factor = 0;
	GdkWindow* _tmp25_;
	g_return_if_fail (self != NULL);
	if (!gtk_widget_get_realized ((GtkWidget*) self)) {
		_tmp0_ = TRUE;
	} else {
		WingpanelWidgetsPanel* _tmp1_;
		_tmp1_ = self->priv->panel;
		_tmp0_ = _tmp1_ == NULL;
	}
	if (_tmp0_) {
		return;
	}
	_tmp2_ = gtk_widget_get_display ((GtkWidget*) self);
	_tmp3_ = _g_object_ref0 (_tmp2_);
	display = _tmp3_;
	_tmp4_ = display;
	n_monitors = gdk_display_get_n_monitors (_tmp4_);
	screen_width = 0;
	no_monitor_left = TRUE;
	no_monitor_right = TRUE;
	no_monitor_above = TRUE;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp5_ = FALSE;
			_tmp5_ = TRUE;
			while (TRUE) {
				GdkRectangle rect = {0};
				GdkDisplay* _tmp7_;
				GdkMonitor* _tmp8_;
				GdkRectangle _tmp9_ = {0};
				GdkRectangle _tmp10_;
				GdkRectangle _tmp11_;
				gboolean is_left = FALSE;
				GdkRectangle _tmp12_;
				GdkRectangle _tmp13_;
				gboolean is_right = FALSE;
				GdkRectangle _tmp14_;
				gboolean is_above = FALSE;
				GdkRectangle _tmp15_;
				GdkRectangle _tmp16_;
				gboolean is_below = FALSE;
				GdkRectangle _tmp17_;
				gboolean _tmp18_ = FALSE;
				gboolean _tmp19_ = FALSE;
				gboolean _tmp20_ = FALSE;
				gboolean _tmp21_ = FALSE;
				gboolean _tmp22_ = FALSE;
				gboolean _tmp23_ = FALSE;
				if (!_tmp5_) {
					gint _tmp6_;
					_tmp6_ = i;
					i = _tmp6_ + 1;
				}
				_tmp5_ = FALSE;
				if (!(i < n_monitors)) {
					break;
				}
				_tmp7_ = display;
				_tmp8_ = gdk_display_get_monitor (_tmp7_, i);
				gdk_monitor_get_geometry (_tmp8_, &_tmp9_);
				rect = _tmp9_;
				_tmp10_ = rect;
				_tmp11_ = rect;
				screen_width = MAX (screen_width, _tmp10_.x + _tmp11_.width);
				if (i == self->priv->monitor_number) {
					continue;
				}
				_tmp12_ = rect;
				_tmp13_ = rect;
				is_left = (_tmp12_.x + _tmp13_.width) <= self->priv->monitor_x;
				_tmp14_ = rect;
				is_right = _tmp14_.x >= (self->priv->monitor_x + self->priv->monitor_width);
				_tmp15_ = rect;
				_tmp16_ = rect;
				is_above = (_tmp15_.y + _tmp16_.height) <= self->priv->monitor_y;
				_tmp17_ = rect;
				is_below = _tmp17_.y >= (self->priv->monitor_y + self->priv->panel_height);
				if (!is_left) {
					_tmp19_ = TRUE;
				} else {
					_tmp19_ = is_above;
				}
				if (_tmp19_) {
					_tmp18_ = TRUE;
				} else {
					_tmp18_ = is_below;
				}
				no_monitor_left &= _tmp18_;
				if (!is_right) {
					_tmp21_ = TRUE;
				} else {
					_tmp21_ = is_above;
				}
				if (_tmp21_) {
					_tmp20_ = TRUE;
				} else {
					_tmp20_ = is_below;
				}
				no_monitor_right &= _tmp20_;
				if (!is_above) {
					_tmp23_ = TRUE;
				} else {
					_tmp23_ = is_left;
				}
				if (_tmp23_) {
					_tmp22_ = TRUE;
				} else {
					_tmp22_ = is_right;
				}
				no_monitor_above &= _tmp22_;
			}
		}
	}
	_tmp24_[0] = (glong) 0;
	memcpy (struts, _tmp24_, 12 * sizeof (glong));
	scale_factor = gtk_widget_get_scale_factor ((GtkWidget*) self);
	if (no_monitor_left) {
		struts[0] = (glong) ((self->priv->monitor_x + self->priv->monitor_width) * scale_factor);
		struts[4] = (glong) (self->priv->monitor_y * scale_factor);
		struts[5] = (glong) (((self->priv->monitor_y - self->priv->panel_displacement) * scale_factor) - 1);
	} else {
		if (no_monitor_right) {
			struts[1] = (glong) ((screen_width - self->priv->monitor_x) * scale_factor);
			struts[6] = (glong) (self->priv->monitor_y * scale_factor);
			struts[7] = (glong) (((self->priv->monitor_y - self->priv->panel_displacement) * scale_factor) - 1);
		} else {
			if (no_monitor_above) {
				struts[2] = (glong) ((self->priv->monitor_y - self->priv->panel_displacement) * scale_factor);
				struts[8] = (glong) (self->priv->monitor_x * scale_factor);
				struts[9] = (glong) (((self->priv->monitor_x + self->priv->monitor_width) * scale_factor) - 1);
			} else {
				g_warning ("PanelWindow.vala:191: Unable to set struts, because Wingpanel is not a" \
"t the edge of the Gdk.Screen area.");
			}
		}
	}
	_tmp25_ = gtk_widget_get_window ((GtkWidget*) self);
	gdk_property_change (_tmp25_, gdk_atom_intern ("_NET_WM_STRUT_PARTIAL", FALSE), gdk_atom_intern ("CARDINAL", FALSE), 32, GDK_PROP_MODE_REPLACE, (const guchar*) ((guint8*) struts), 12);
	_g_object_unref0 (display);
}

void
wingpanel_panel_window_set_expanded (WingpanelPanelWindow* self,
                                     gboolean expand)
{
	gboolean _tmp0_ = FALSE;
	g_return_if_fail (self != NULL);
	if (expand) {
		_tmp0_ = !self->priv->expanded;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		WingpanelServicesBackgroundManager* _tmp1_;
		WingpanelServicesBackgroundManager* _tmp2_;
		_tmp1_ = wingpanel_services_background_manager_get_default ();
		_tmp2_ = _tmp1_;
		wingpanel_services_background_manager_remember_window (_tmp2_);
		_g_object_unref0 (_tmp2_);
		self->priv->expanded = TRUE;
		gtk_widget_set_size_request ((GtkWidget*) self, self->priv->monitor_width, self->priv->monitor_height);
	} else {
		if (!expand) {
			WingpanelServicesBackgroundManager* _tmp3_;
			WingpanelServicesBackgroundManager* _tmp4_;
			gint _tmp5_ = 0;
			gint _tmp6_ = 0;
			_tmp3_ = wingpanel_services_background_manager_get_default ();
			_tmp4_ = _tmp3_;
			wingpanel_services_background_manager_restore_window (_tmp4_);
			_g_object_unref0 (_tmp4_);
			self->priv->expanded = FALSE;
			if (self->priv->expanded) {
				_tmp5_ = self->priv->monitor_height;
			} else {
				_tmp5_ = -1;
			}
			gtk_widget_set_size_request ((GtkWidget*) self, self->priv->monitor_width, _tmp5_);
			if (self->priv->expanded) {
				_tmp6_ = self->priv->monitor_height;
			} else {
				_tmp6_ = 1;
			}
			gtk_window_resize ((GtkWindow*) self, self->priv->monitor_width, _tmp6_);
		}
	}
}

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)->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->expanded = FALSE;
}

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

