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

#include <libxfce4windowing/libxfce4windowing.h>
#include <gio/gio.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <gobject/gvaluecollector.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 NEW_WALL_PAPER_SWITCHER_TYPE_WATCH_APPLET (new_wall_paper_switcher_watch_applet_get_type ())
#define NEW_WALL_PAPER_SWITCHER_WATCH_APPLET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NEW_WALL_PAPER_SWITCHER_TYPE_WATCH_APPLET, NewWallPaperSwitcherWatchApplet))
#define NEW_WALL_PAPER_SWITCHER_WATCH_APPLET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NEW_WALL_PAPER_SWITCHER_TYPE_WATCH_APPLET, NewWallPaperSwitcherWatchAppletClass))
#define NEW_WALL_PAPER_SWITCHER_IS_WATCH_APPLET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NEW_WALL_PAPER_SWITCHER_TYPE_WATCH_APPLET))
#define NEW_WALL_PAPER_SWITCHER_IS_WATCH_APPLET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NEW_WALL_PAPER_SWITCHER_TYPE_WATCH_APPLET))
#define NEW_WALL_PAPER_SWITCHER_WATCH_APPLET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NEW_WALL_PAPER_SWITCHER_TYPE_WATCH_APPLET, NewWallPaperSwitcherWatchAppletClass))

typedef struct _NewWallPaperSwitcherWatchApplet NewWallPaperSwitcherWatchApplet;
typedef struct _NewWallPaperSwitcherWatchAppletClass NewWallPaperSwitcherWatchAppletClass;
typedef struct _NewWallPaperSwitcherWatchAppletPrivate NewWallPaperSwitcherWatchAppletPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block1Data Block1Data;
#define _new_wall_paper_switcher_watch_applet_unref0(var) ((var == NULL) ? NULL : (var = (new_wall_paper_switcher_watch_applet_unref (var), NULL)))
typedef struct _NewWallPaperSwitcherParamSpecWatchApplet NewWallPaperSwitcherParamSpecWatchApplet;
typedef struct _Block2Data Block2Data;
typedef struct _Block3Data Block3Data;

struct _NewWallPaperSwitcherWatchApplet {
	GTypeInstance parent_instance;
	volatile int ref_count;
	NewWallPaperSwitcherWatchAppletPrivate * priv;
};

struct _NewWallPaperSwitcherWatchAppletClass {
	GTypeClass parent_class;
	void (*finalize) (NewWallPaperSwitcherWatchApplet *self);
};

struct _NewWallPaperSwitcherWatchAppletPrivate {
	GSettings* panel_settings;
	GSettings* currpanelsubject_settings;
	gchar* path;
};

struct _Block1Data {
	int _ref_count_;
	NewWallPaperSwitcherWatchApplet* self;
	gchar** applets;
	gint applets_length1;
	gint _applets_size_;
	gchar* uuid;
};

struct _NewWallPaperSwitcherParamSpecWatchApplet {
	GParamSpec parent_instance;
};

struct _Block2Data {
	int _ref_count_;
	gchar* uuid;
	GSettings* widgetsettings;
};

struct _Block3Data {
	int _ref_count_;
	GSettings* settings;
	gchar* our_uuid;
};

VALA_EXTERN XfwScreen* new_wall_paper_switcher_xfw_scr;
XfwScreen* new_wall_paper_switcher_xfw_scr = NULL;
VALA_EXTERN GSettings* new_wall_paper_switcher_wallsettings;
GSettings* new_wall_paper_switcher_wallsettings = NULL;
VALA_EXTERN GSettings* new_wall_paper_switcher_switchersettings;
GSettings* new_wall_paper_switcher_switchersettings = NULL;
VALA_EXTERN GSettings* new_wall_paper_switcher_animationsettings;
GSettings* new_wall_paper_switcher_animationsettings = NULL;
VALA_EXTERN gint new_wall_paper_switcher_curr_wsindex;
gint new_wall_paper_switcher_curr_wsindex = 0;
VALA_EXTERN gchar** new_wall_paper_switcher_curr_wallist;
VALA_EXTERN gint new_wall_paper_switcher_curr_wallist_length1;
gchar** new_wall_paper_switcher_curr_wallist = NULL;
gint new_wall_paper_switcher_curr_wallist_length1 = 0;
static gint _new_wall_paper_switcher_curr_wallist_size_ = 0;
VALA_EXTERN gboolean new_wall_paper_switcher_runsornot;
gboolean new_wall_paper_switcher_runsornot = FALSE;
static gint NewWallPaperSwitcherWatchApplet_private_offset;
static gpointer new_wall_paper_switcher_watch_applet_parent_class = NULL;

VALA_EXTERN gpointer new_wall_paper_switcher_watch_applet_ref (gpointer instance);
VALA_EXTERN void new_wall_paper_switcher_watch_applet_unref (gpointer instance);
VALA_EXTERN GParamSpec* new_wall_paper_switcher_param_spec_watch_applet (const gchar* name,
                                                             const gchar* nick,
                                                             const gchar* blurb,
                                                             GType object_type,
                                                             GParamFlags flags);
VALA_EXTERN void new_wall_paper_switcher_value_set_watch_applet (GValue* value,
                                                     gpointer v_object);
VALA_EXTERN void new_wall_paper_switcher_value_take_watch_applet (GValue* value,
                                                      gpointer v_object);
VALA_EXTERN gpointer new_wall_paper_switcher_value_get_watch_applet (const GValue* value);
VALA_EXTERN GType new_wall_paper_switcher_watch_applet_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (NewWallPaperSwitcherWatchApplet, new_wall_paper_switcher_watch_applet_unref)
static gboolean new_wall_paper_switcher_watch_applet_find_applet (NewWallPaperSwitcherWatchApplet* self,
                                                           const gchar* uuid,
                                                           gchar** applets,
                                                           gint applets_length1);
VALA_EXTERN NewWallPaperSwitcherWatchApplet* new_wall_paper_switcher_watch_applet_new (const gchar* uuid);
VALA_EXTERN NewWallPaperSwitcherWatchApplet* new_wall_paper_switcher_watch_applet_construct (GType object_type,
                                                                                 const gchar* uuid);
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (void * _userdata_);
static void _____lambda4_ (Block1Data* _data1_);
static void ______lambda4__g_settings_changed (GSettings* _sender,
                                        const gchar* key,
                                        gpointer self);
static void new_wall_paper_switcher_watch_applet_finalize (NewWallPaperSwitcherWatchApplet * obj);
static GType new_wall_paper_switcher_watch_applet_get_type_once (void);
static void new_wall_paper_switcher_main (gchar** args,
                                   gint args_length1);
static Block2Data* block2_data_ref (Block2Data* _data2_);
static void block2_data_unref (void * _userdata_);
VALA_EXTERN void new_wall_paper_switcher_update_workspace (void);
static void _new_wall_paper_switcher_update_workspace_libxfce4windowing_workspace_group_active_workspace_changed (XfwWorkspaceGroup* _sender,
                                                                                                           XfwWorkspace* previously_active_workspace,
                                                                                                           gpointer self);
static void __lambda6_ (void);
static void ___lambda6__libxfce4windowing_workspace_manager_workspace_created (XfwWorkspaceManager* _sender,
                                                                        XfwWorkspace* workspace,
                                                                        gpointer self);
static void __lambda7_ (void);
static void ___lambda7__libxfce4windowing_workspace_manager_workspace_destroyed (XfwWorkspaceManager* _sender,
                                                                          XfwWorkspace* workspace,
                                                                          gpointer self);
VALA_EXTERN void new_wall_paper_switcher_update_wallpaperlist (void);
static void _new_wall_paper_switcher_update_wallpaperlist_g_settings_changed (GSettings* _sender,
                                                                       const gchar* key,
                                                                       gpointer self);
static void __lambda8_ (void);
static void ___lambda8__g_settings_changed (GSettings* _sender,
                                     const gchar* key,
                                     gpointer self);
static gboolean __lambda9_ (Block2Data* _data2_);
VALA_EXTERN void new_wall_paper_switcher_watch_widget (GSettings* settings,
                                           const gchar* our_uuid);
static gboolean ___lambda9__gsource_func (gpointer self);
static Block3Data* block3_data_ref (Block3Data* _data3_);
static void block3_data_unref (void * _userdata_);
static void __lambda10_ (Block3Data* _data3_);
static void ___lambda10__g_settings_changed (GSettings* _sender,
                                      const gchar* key,
                                      gpointer self);
static void _vala_array_add1 (gchar** * array,
                       gint* length,
                       gint* size,
                       gchar* value);
static gboolean ____lambda5_ (void);
static gboolean _____lambda5__gsource_func (gpointer self);
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 gssize _vala_array_length (gpointer array);

static inline gpointer
new_wall_paper_switcher_watch_applet_get_instance_private (NewWallPaperSwitcherWatchApplet* self)
{
	return G_STRUCT_MEMBER_P (self, NewWallPaperSwitcherWatchApplet_private_offset);
}

static gboolean
new_wall_paper_switcher_watch_applet_find_applet (NewWallPaperSwitcherWatchApplet* self,
                                                  const gchar* uuid,
                                                  gchar** applets,
                                                  gint applets_length1)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (uuid != NULL, FALSE);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				const gchar* _tmp2_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				if (!(i < applets_length1)) {
					break;
				}
				_tmp2_ = applets[i];
				if (g_strcmp0 (_tmp2_, uuid) == 0) {
					result = TRUE;
					return result;
				}
			}
		}
	}
	result = FALSE;
	return result;
}

static Block1Data*
block1_data_ref (Block1Data* _data1_)
{
	g_atomic_int_inc (&_data1_->_ref_count_);
	return _data1_;
}

static void
block1_data_unref (void * _userdata_)
{
	Block1Data* _data1_;
	_data1_ = (Block1Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
		NewWallPaperSwitcherWatchApplet* self;
		self = _data1_->self;
		_data1_->applets = (_vala_array_free (_data1_->applets, _data1_->applets_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (_data1_->uuid);
		_new_wall_paper_switcher_watch_applet_unref0 (self);
		g_slice_free (Block1Data, _data1_);
	}
}

static void
_____lambda4_ (Block1Data* _data1_)
{
	NewWallPaperSwitcherWatchApplet* self;
	GSettings* _tmp0_;
	gchar** _tmp1_;
	gchar** _tmp2_;
	gchar** _tmp3_;
	gint _tmp3__length1;
	self = _data1_->self;
	_tmp0_ = self->priv->currpanelsubject_settings;
	_tmp2_ = _tmp1_ = g_settings_get_strv (_tmp0_, "applets");
	_data1_->applets = (_vala_array_free (_data1_->applets, _data1_->applets_length1, (GDestroyNotify) g_free), NULL);
	_data1_->applets = _tmp2_;
	_data1_->applets_length1 = _vala_array_length (_tmp1_);
	_data1_->_applets_size_ = _data1_->applets_length1;
	_tmp3_ = _data1_->applets;
	_tmp3__length1 = _data1_->applets_length1;
	if (!new_wall_paper_switcher_watch_applet_find_applet (self, _data1_->uuid, _tmp3_, (gint) _tmp3__length1)) {
		gtk_main_quit ();
	}
}

static void
______lambda4__g_settings_changed (GSettings* _sender,
                                   const gchar* key,
                                   gpointer self)
{
	_____lambda4_ (self);
}

NewWallPaperSwitcherWatchApplet*
new_wall_paper_switcher_watch_applet_construct (GType object_type,
                                                const gchar* uuid)
{
	NewWallPaperSwitcherWatchApplet* self = NULL;
	Block1Data* _data1_;
	gchar* _tmp0_;
	const gchar* _tmp1_;
	GSettings* _tmp2_;
	gchar** allpanels_list = NULL;
	GSettings* _tmp3_;
	gchar** _tmp4_;
	gchar** _tmp5_;
	gint allpanels_list_length1;
	gint _allpanels_list_size_;
	gchar** _tmp6_;
	gint _tmp6__length1;
	g_return_val_if_fail (uuid != NULL, NULL);
	self = (NewWallPaperSwitcherWatchApplet*) g_type_create_instance (object_type);
	_data1_ = g_slice_new0 (Block1Data);
	_data1_->_ref_count_ = 1;
	_data1_->self = new_wall_paper_switcher_watch_applet_ref (self);
	_tmp0_ = g_strdup (uuid);
	_g_free0 (_data1_->uuid);
	_data1_->uuid = _tmp0_;
	_tmp1_ = self->priv->path;
	_tmp2_ = g_settings_new (_tmp1_);
	_g_object_unref0 (self->priv->panel_settings);
	self->priv->panel_settings = _tmp2_;
	_tmp3_ = self->priv->panel_settings;
	_tmp5_ = _tmp4_ = g_settings_get_strv (_tmp3_, "panels");
	allpanels_list = _tmp5_;
	allpanels_list_length1 = _vala_array_length (_tmp4_);
	_allpanels_list_size_ = allpanels_list_length1;
	_tmp6_ = allpanels_list;
	_tmp6__length1 = allpanels_list_length1;
	{
		gchar** p_collection = NULL;
		gint p_collection_length1 = 0;
		gint _p_collection_size_ = 0;
		gint p_it = 0;
		p_collection = _tmp6_;
		p_collection_length1 = _tmp6__length1;
		for (p_it = 0; p_it < p_collection_length1; p_it = p_it + 1) {
			gchar* _tmp7_;
			gchar* p = NULL;
			_tmp7_ = g_strdup (p_collection[p_it]);
			p = _tmp7_;
			{
				gchar* panelpath = NULL;
				const gchar* _tmp8_;
				gchar* _tmp9_;
				const gchar* _tmp10_;
				gchar* _tmp11_;
				gchar* _tmp12_;
				const gchar* _tmp13_;
				GSettings* _tmp14_;
				GSettings* _tmp15_;
				gchar** _tmp16_;
				gchar** _tmp17_;
				gchar** _tmp18_;
				gint _tmp18__length1;
				_tmp8_ = p;
				_tmp9_ = g_strconcat ("/com/solus-project/budgie-panel/panels/", "{", _tmp8_, "}/", NULL);
				panelpath = _tmp9_;
				_tmp10_ = self->priv->path;
				_tmp11_ = g_strconcat (_tmp10_, ".panel", NULL);
				_tmp12_ = _tmp11_;
				_tmp13_ = panelpath;
				_tmp14_ = g_settings_new_with_path (_tmp12_, _tmp13_);
				_g_object_unref0 (self->priv->currpanelsubject_settings);
				self->priv->currpanelsubject_settings = _tmp14_;
				_g_free0 (_tmp12_);
				_tmp15_ = self->priv->currpanelsubject_settings;
				_tmp17_ = _tmp16_ = g_settings_get_strv (_tmp15_, "applets");
				_data1_->applets = (_vala_array_free (_data1_->applets, _data1_->applets_length1, (GDestroyNotify) g_free), NULL);
				_data1_->applets = _tmp17_;
				_data1_->applets_length1 = _vala_array_length (_tmp16_);
				_data1_->_applets_size_ = _data1_->applets_length1;
				_tmp18_ = _data1_->applets;
				_tmp18__length1 = _data1_->applets_length1;
				if (new_wall_paper_switcher_watch_applet_find_applet (self, _data1_->uuid, _tmp18_, (gint) _tmp18__length1)) {
					GSettings* _tmp19_;
					_tmp19_ = self->priv->currpanelsubject_settings;
					g_signal_connect_data (_tmp19_, "changed::applets", (GCallback) ______lambda4__g_settings_changed, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0);
					_g_free0 (panelpath);
					_g_free0 (p);
					break;
				}
				_g_free0 (panelpath);
				_g_free0 (p);
			}
		}
	}
	allpanels_list = (_vala_array_free (allpanels_list, allpanels_list_length1, (GDestroyNotify) g_free), NULL);
	block1_data_unref (_data1_);
	_data1_ = NULL;
	return self;
}

NewWallPaperSwitcherWatchApplet*
new_wall_paper_switcher_watch_applet_new (const gchar* uuid)
{
	return new_wall_paper_switcher_watch_applet_construct (NEW_WALL_PAPER_SWITCHER_TYPE_WATCH_APPLET, uuid);
}

static void
new_wall_paper_switcher_value_watch_applet_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
new_wall_paper_switcher_value_watch_applet_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		new_wall_paper_switcher_watch_applet_unref (value->data[0].v_pointer);
	}
}

static void
new_wall_paper_switcher_value_watch_applet_copy_value (const GValue* src_value,
                                                       GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = new_wall_paper_switcher_watch_applet_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
new_wall_paper_switcher_value_watch_applet_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
new_wall_paper_switcher_value_watch_applet_collect_value (GValue* value,
                                                          guint n_collect_values,
                                                          GTypeCValue* collect_values,
                                                          guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		NewWallPaperSwitcherWatchApplet * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = new_wall_paper_switcher_watch_applet_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
new_wall_paper_switcher_value_watch_applet_lcopy_value (const GValue* value,
                                                        guint n_collect_values,
                                                        GTypeCValue* collect_values,
                                                        guint collect_flags)
{
	NewWallPaperSwitcherWatchApplet ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = new_wall_paper_switcher_watch_applet_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
new_wall_paper_switcher_param_spec_watch_applet (const gchar* name,
                                                 const gchar* nick,
                                                 const gchar* blurb,
                                                 GType object_type,
                                                 GParamFlags flags)
{
	NewWallPaperSwitcherParamSpecWatchApplet* spec;
	g_return_val_if_fail (g_type_is_a (object_type, NEW_WALL_PAPER_SWITCHER_TYPE_WATCH_APPLET), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

gpointer
new_wall_paper_switcher_value_get_watch_applet (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, NEW_WALL_PAPER_SWITCHER_TYPE_WATCH_APPLET), NULL);
	return value->data[0].v_pointer;
}

void
new_wall_paper_switcher_value_set_watch_applet (GValue* value,
                                                gpointer v_object)
{
	NewWallPaperSwitcherWatchApplet * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, NEW_WALL_PAPER_SWITCHER_TYPE_WATCH_APPLET));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, NEW_WALL_PAPER_SWITCHER_TYPE_WATCH_APPLET));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		new_wall_paper_switcher_watch_applet_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		new_wall_paper_switcher_watch_applet_unref (old);
	}
}

void
new_wall_paper_switcher_value_take_watch_applet (GValue* value,
                                                 gpointer v_object)
{
	NewWallPaperSwitcherWatchApplet * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, NEW_WALL_PAPER_SWITCHER_TYPE_WATCH_APPLET));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, NEW_WALL_PAPER_SWITCHER_TYPE_WATCH_APPLET));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		new_wall_paper_switcher_watch_applet_unref (old);
	}
}

static void
new_wall_paper_switcher_watch_applet_class_init (NewWallPaperSwitcherWatchAppletClass * klass,
                                                 gpointer klass_data)
{
	new_wall_paper_switcher_watch_applet_parent_class = g_type_class_peek_parent (klass);
	((NewWallPaperSwitcherWatchAppletClass *) klass)->finalize = new_wall_paper_switcher_watch_applet_finalize;
	g_type_class_adjust_private_offset (klass, &NewWallPaperSwitcherWatchApplet_private_offset);
}

static void
new_wall_paper_switcher_watch_applet_instance_init (NewWallPaperSwitcherWatchApplet * self,
                                                    gpointer klass)
{
	gchar* _tmp0_;
	self->priv = new_wall_paper_switcher_watch_applet_get_instance_private (self);
	_tmp0_ = g_strdup ("com.solus-project.budgie-panel");
	self->priv->path = _tmp0_;
	self->ref_count = 1;
}

static void
new_wall_paper_switcher_watch_applet_finalize (NewWallPaperSwitcherWatchApplet * obj)
{
	NewWallPaperSwitcherWatchApplet * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, NEW_WALL_PAPER_SWITCHER_TYPE_WATCH_APPLET, NewWallPaperSwitcherWatchApplet);
	g_signal_handlers_destroy (self);
	_g_object_unref0 (self->priv->panel_settings);
	_g_object_unref0 (self->priv->currpanelsubject_settings);
	_g_free0 (self->priv->path);
}

static GType
new_wall_paper_switcher_watch_applet_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { new_wall_paper_switcher_value_watch_applet_init, new_wall_paper_switcher_value_watch_applet_free_value, new_wall_paper_switcher_value_watch_applet_copy_value, new_wall_paper_switcher_value_watch_applet_peek_pointer, "p", new_wall_paper_switcher_value_watch_applet_collect_value, "p", new_wall_paper_switcher_value_watch_applet_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (NewWallPaperSwitcherWatchAppletClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) new_wall_paper_switcher_watch_applet_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (NewWallPaperSwitcherWatchApplet), 0, (GInstanceInitFunc) new_wall_paper_switcher_watch_applet_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType new_wall_paper_switcher_watch_applet_type_id;
	new_wall_paper_switcher_watch_applet_type_id = g_type_register_fundamental (g_type_fundamental_next (), "NewWallPaperSwitcherWatchApplet", &g_define_type_info, &g_define_type_fundamental_info, 0);
	NewWallPaperSwitcherWatchApplet_private_offset = g_type_add_instance_private (new_wall_paper_switcher_watch_applet_type_id, sizeof (NewWallPaperSwitcherWatchAppletPrivate));
	return new_wall_paper_switcher_watch_applet_type_id;
}

GType
new_wall_paper_switcher_watch_applet_get_type (void)
{
	static volatile gsize new_wall_paper_switcher_watch_applet_type_id__once = 0;
	if (g_once_init_enter (&new_wall_paper_switcher_watch_applet_type_id__once)) {
		GType new_wall_paper_switcher_watch_applet_type_id;
		new_wall_paper_switcher_watch_applet_type_id = new_wall_paper_switcher_watch_applet_get_type_once ();
		g_once_init_leave (&new_wall_paper_switcher_watch_applet_type_id__once, new_wall_paper_switcher_watch_applet_type_id);
	}
	return new_wall_paper_switcher_watch_applet_type_id__once;
}

gpointer
new_wall_paper_switcher_watch_applet_ref (gpointer instance)
{
	NewWallPaperSwitcherWatchApplet * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

void
new_wall_paper_switcher_watch_applet_unref (gpointer instance)
{
	NewWallPaperSwitcherWatchApplet * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		NEW_WALL_PAPER_SWITCHER_WATCH_APPLET_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static Block2Data*
block2_data_ref (Block2Data* _data2_)
{
	g_atomic_int_inc (&_data2_->_ref_count_);
	return _data2_;
}

static void
block2_data_unref (void * _userdata_)
{
	Block2Data* _data2_;
	_data2_ = (Block2Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data2_->_ref_count_)) {
		_g_object_unref0 (_data2_->widgetsettings);
		_g_free0 (_data2_->uuid);
		g_slice_free (Block2Data, _data2_);
	}
}

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

static void
_new_wall_paper_switcher_update_workspace_libxfce4windowing_workspace_group_active_workspace_changed (XfwWorkspaceGroup* _sender,
                                                                                                      XfwWorkspace* previously_active_workspace,
                                                                                                      gpointer self)
{
	new_wall_paper_switcher_update_workspace ();
}

static void
__lambda6_ (void)
{
	new_wall_paper_switcher_update_workspace ();
}

static void
___lambda6__libxfce4windowing_workspace_manager_workspace_created (XfwWorkspaceManager* _sender,
                                                                   XfwWorkspace* workspace,
                                                                   gpointer self)
{
	__lambda6_ ();
}

static void
__lambda7_ (void)
{
	new_wall_paper_switcher_update_workspace ();
}

static void
___lambda7__libxfce4windowing_workspace_manager_workspace_destroyed (XfwWorkspaceManager* _sender,
                                                                     XfwWorkspace* workspace,
                                                                     gpointer self)
{
	__lambda7_ ();
}

static void
_new_wall_paper_switcher_update_wallpaperlist_g_settings_changed (GSettings* _sender,
                                                                  const gchar* key,
                                                                  gpointer self)
{
	new_wall_paper_switcher_update_wallpaperlist ();
}

static void
__lambda8_ (void)
{
	GSettings* _tmp0_;
	_tmp0_ = new_wall_paper_switcher_switchersettings;
	new_wall_paper_switcher_runsornot = g_settings_get_boolean (_tmp0_, "runwswitcher");
}

static void
___lambda8__g_settings_changed (GSettings* _sender,
                                const gchar* key,
                                gpointer self)
{
	__lambda8_ ();
}

static gboolean
__lambda9_ (Block2Data* _data2_)
{
	GSettings* _tmp0_;
	const gchar* _tmp1_;
	gboolean result;
	_tmp0_ = _data2_->widgetsettings;
	_tmp1_ = _data2_->uuid;
	new_wall_paper_switcher_watch_widget (_tmp0_, _tmp1_);
	result = FALSE;
	return result;
}

static gboolean
___lambda9__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda9_ (self);
	return result;
}

static void
new_wall_paper_switcher_main (gchar** args,
                              gint args_length1)
{
	Block2Data* _data2_;
	const gchar* _tmp0_ = NULL;
	gchar* _tmp2_;
	const gchar* _tmp3_;
	GSettings* _tmp4_;
	XfwScreen* _tmp5_;
	XfwWorkspaceManager* workspace_manager = NULL;
	XfwScreen* _tmp6_;
	XfwWorkspaceManager* _tmp7_;
	XfwWorkspaceManager* _tmp8_;
	XfwWorkspaceGroup* group = NULL;
	XfwWorkspaceManager* _tmp9_;
	GList* _tmp10_;
	gconstpointer _tmp11_;
	XfwWorkspaceGroup* _tmp12_;
	XfwWorkspaceGroup* _tmp13_;
	XfwWorkspaceManager* _tmp14_;
	XfwWorkspaceManager* _tmp15_;
	GSettings* _tmp16_;
	GSettings* _tmp17_;
	GSettings* _tmp18_;
	GSettings* _tmp19_;
	GSettings* _tmp20_;
	GSettings* _tmp21_;
	_data2_ = g_slice_new0 (Block2Data);
	_data2_->_ref_count_ = 1;
	gtk_init ((gint*) (&args_length1), &args);
	if (args_length1 > 1) {
		const gchar* _tmp1_;
		_tmp1_ = args[1];
		_tmp0_ = _tmp1_;
	} else {
		_tmp0_ = "";
	}
	_tmp2_ = g_strdup (_tmp0_);
	_data2_->uuid = _tmp2_;
	_tmp3_ = _data2_->uuid;
	if (g_strcmp0 (_tmp3_, "") == 0) {
		block2_data_unref (_data2_);
		_data2_ = NULL;
		return;
	}
	_tmp4_ = g_settings_new ("org.ubuntubudgie.plugins.budgie-wswitcher");
	_g_object_unref0 (new_wall_paper_switcher_switchersettings);
	new_wall_paper_switcher_switchersettings = _tmp4_;
	_tmp5_ = xfw_screen_get_default ();
	_g_object_unref0 (new_wall_paper_switcher_xfw_scr);
	new_wall_paper_switcher_xfw_scr = _tmp5_;
	_tmp6_ = new_wall_paper_switcher_xfw_scr;
	_tmp7_ = xfw_screen_get_workspace_manager (_tmp6_);
	_tmp8_ = _g_object_ref0 (_tmp7_);
	workspace_manager = _tmp8_;
	_tmp9_ = workspace_manager;
	_tmp10_ = xfw_workspace_manager_list_workspace_groups (_tmp9_);
	_tmp11_ = g_list_nth_data (_tmp10_, (guint) 0);
	_tmp12_ = _g_object_ref0 ((XfwWorkspaceGroup*) _tmp11_);
	group = _tmp12_;
	_tmp13_ = group;
	g_signal_connect (_tmp13_, "active-workspace-changed", (GCallback) _new_wall_paper_switcher_update_workspace_libxfce4windowing_workspace_group_active_workspace_changed, NULL);
	_tmp14_ = workspace_manager;
	g_signal_connect (_tmp14_, "workspace-created", (GCallback) ___lambda6__libxfce4windowing_workspace_manager_workspace_created, NULL);
	_tmp15_ = workspace_manager;
	g_signal_connect (_tmp15_, "workspace-destroyed", (GCallback) ___lambda7__libxfce4windowing_workspace_manager_workspace_destroyed, NULL);
	_tmp16_ = g_settings_new ("org.gnome.desktop.background");
	_g_object_unref0 (new_wall_paper_switcher_wallsettings);
	new_wall_paper_switcher_wallsettings = _tmp16_;
	_tmp17_ = new_wall_paper_switcher_wallsettings;
	g_signal_connect (_tmp17_, "changed::picture-uri", (GCallback) _new_wall_paper_switcher_update_wallpaperlist_g_settings_changed, NULL);
	_tmp18_ = g_settings_new ("org.gnome.desktop.interface");
	_g_object_unref0 (new_wall_paper_switcher_animationsettings);
	new_wall_paper_switcher_animationsettings = _tmp18_;
	_tmp19_ = new_wall_paper_switcher_switchersettings;
	new_wall_paper_switcher_runsornot = g_settings_get_boolean (_tmp19_, "runwswitcher");
	_tmp20_ = new_wall_paper_switcher_switchersettings;
	g_signal_connect (_tmp20_, "changed::runwswitcher", (GCallback) ___lambda8__g_settings_changed, NULL);
	_tmp21_ = g_settings_new ("org.buddiesofbudgie.budgie-desktop.raven.widgets");
	_data2_->widgetsettings = _tmp21_;
	g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, ___lambda9__gsource_func, block2_data_ref (_data2_), block2_data_unref);
	new_wall_paper_switcher_update_workspace ();
	new_wall_paper_switcher_update_wallpaperlist ();
	gtk_main ();
	_g_object_unref0 (group);
	_g_object_unref0 (workspace_manager);
	block2_data_unref (_data2_);
	_data2_ = NULL;
}

int
main (int argc,
      char ** argv)
{
	new_wall_paper_switcher_main (argv, argc);
	return 0;
}

static Block3Data*
block3_data_ref (Block3Data* _data3_)
{
	g_atomic_int_inc (&_data3_->_ref_count_);
	return _data3_;
}

static void
block3_data_unref (void * _userdata_)
{
	Block3Data* _data3_;
	_data3_ = (Block3Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data3_->_ref_count_)) {
		_g_object_unref0 (_data3_->settings);
		_g_free0 (_data3_->our_uuid);
		g_slice_free (Block3Data, _data3_);
	}
}

static void
__lambda10_ (Block3Data* _data3_)
{
	gchar** all_uuids = NULL;
	gchar** _tmp0_;
	gchar** _tmp1_;
	gint all_uuids_length1;
	gint _all_uuids_size_;
	gchar** _tmp2_;
	gint _tmp2__length1;
	_tmp1_ = _tmp0_ = g_settings_get_strv (_data3_->settings, "uuids");
	all_uuids = _tmp1_;
	all_uuids_length1 = _vala_array_length (_tmp0_);
	_all_uuids_size_ = all_uuids_length1;
	_tmp2_ = all_uuids;
	_tmp2__length1 = all_uuids_length1;
	{
		gchar** uuid_collection = NULL;
		gint uuid_collection_length1 = 0;
		gint _uuid_collection_size_ = 0;
		gint uuid_it = 0;
		uuid_collection = _tmp2_;
		uuid_collection_length1 = _tmp2__length1;
		for (uuid_it = 0; uuid_it < uuid_collection_length1; uuid_it = uuid_it + 1) {
			gchar* _tmp3_;
			gchar* uuid = NULL;
			_tmp3_ = g_strdup (uuid_collection[uuid_it]);
			uuid = _tmp3_;
			{
				const gchar* _tmp4_;
				_tmp4_ = uuid;
				if (g_strcmp0 (_tmp4_, _data3_->our_uuid) == 0) {
					_g_free0 (uuid);
					all_uuids = (_vala_array_free (all_uuids, all_uuids_length1, (GDestroyNotify) g_free), NULL);
					return;
				}
				_g_free0 (uuid);
			}
		}
	}
	gtk_main_quit ();
	all_uuids = (_vala_array_free (all_uuids, all_uuids_length1, (GDestroyNotify) g_free), NULL);
}

static void
___lambda10__g_settings_changed (GSettings* _sender,
                                 const gchar* key,
                                 gpointer self)
{
	__lambda10_ (self);
}

void
new_wall_paper_switcher_watch_widget (GSettings* settings,
                                      const gchar* our_uuid)
{
	Block3Data* _data3_;
	GSettings* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (settings != NULL);
	g_return_if_fail (our_uuid != NULL);
	_data3_ = g_slice_new0 (Block3Data);
	_data3_->_ref_count_ = 1;
	_tmp0_ = _g_object_ref0 (settings);
	_g_object_unref0 (_data3_->settings);
	_data3_->settings = _tmp0_;
	_tmp1_ = g_strdup (our_uuid);
	_g_free0 (_data3_->our_uuid);
	_data3_->our_uuid = _tmp1_;
	g_signal_connect_data (_data3_->settings, "changed::uuids", (GCallback) ___lambda10__g_settings_changed, block3_data_ref (_data3_), (GClosureNotify) block3_data_unref, 0);
	block3_data_unref (_data3_);
	_data3_ = NULL;
}

void
new_wall_paper_switcher_update_wallpaperlist (void)
{
	gchar* new_wall = NULL;
	GSettings* _tmp0_;
	gchar* _tmp1_;
	gchar** _tmp2_;
	gint _tmp2__length1;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	_tmp0_ = new_wall_paper_switcher_wallsettings;
	_tmp1_ = g_settings_get_string (_tmp0_, "picture-uri");
	new_wall = _tmp1_;
	_tmp2_ = new_wall_paper_switcher_curr_wallist;
	_tmp2__length1 = new_wall_paper_switcher_curr_wallist_length1;
	_tmp3_ = _tmp2_[new_wall_paper_switcher_curr_wsindex];
	_tmp4_ = new_wall;
	if (g_strcmp0 (_tmp3_, _tmp4_) != 0) {
		gchar** _tmp5_;
		gint _tmp5__length1;
		const gchar* _tmp6_;
		gchar* _tmp7_;
		GSettings* _tmp8_;
		gchar** _tmp9_;
		gint _tmp9__length1;
		_tmp5_ = new_wall_paper_switcher_curr_wallist;
		_tmp5__length1 = new_wall_paper_switcher_curr_wallist_length1;
		_tmp6_ = new_wall;
		_tmp7_ = g_strdup (_tmp6_);
		_g_free0 (_tmp5_[new_wall_paper_switcher_curr_wsindex]);
		_tmp5_[new_wall_paper_switcher_curr_wsindex] = _tmp7_;
		_tmp8_ = new_wall_paper_switcher_switchersettings;
		_tmp9_ = new_wall_paper_switcher_curr_wallist;
		_tmp9__length1 = new_wall_paper_switcher_curr_wallist_length1;
		g_settings_set_strv (_tmp8_, "wallpapers", _tmp9_);
	}
	_g_free0 (new_wall);
}

static void
_vala_array_add1 (gchar** * array,
                  gint* length,
                  gint* size,
                  gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static gboolean
____lambda5_ (void)
{
	GSettings* _tmp0_;
	gboolean result;
	_tmp0_ = new_wall_paper_switcher_animationsettings;
	g_settings_set_boolean (_tmp0_, "enable-animations", TRUE);
	result = FALSE;
	return result;
}

static gboolean
_____lambda5__gsource_func (gpointer self)
{
	gboolean result;
	result = ____lambda5_ ();
	return result;
}

void
new_wall_paper_switcher_update_workspace (void)
{
	XfwWorkspaceManager* workspace_manager = NULL;
	XfwScreen* _tmp0_;
	XfwWorkspaceManager* _tmp1_;
	XfwWorkspaceManager* _tmp2_;
	XfwWorkspace* curr_ws = NULL;
	XfwWorkspaceManager* _tmp3_;
	GList* _tmp4_;
	gconstpointer _tmp5_;
	XfwWorkspace* _tmp6_;
	XfwWorkspace* _tmp7_;
	XfwWorkspace* _tmp8_;
	GList* currspaces = NULL;
	XfwWorkspaceManager* _tmp9_;
	GList* _tmp10_;
	gconstpointer _tmp11_;
	GList* _tmp12_;
	GList* _tmp13_;
	XfwWorkspace* _tmp14_;
	GSettings* _tmp15_;
	gchar** _tmp16_;
	gchar** _tmp17_;
	guint n_workspaces = 0U;
	GList* _tmp18_;
	GSettings* _tmp21_;
	gchar** _tmp22_;
	gint _tmp22__length1;
	gchar* new_wall = NULL;
	gchar** _tmp23_;
	gint _tmp23__length1;
	const gchar* _tmp24_;
	gchar* _tmp25_;
	gboolean _tmp26_ = FALSE;
	const gchar* _tmp27_;
	_tmp0_ = new_wall_paper_switcher_xfw_scr;
	_tmp1_ = xfw_screen_get_workspace_manager (_tmp0_);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	workspace_manager = _tmp2_;
	_tmp3_ = workspace_manager;
	_tmp4_ = xfw_workspace_manager_list_workspace_groups (_tmp3_);
	_tmp5_ = g_list_nth_data (_tmp4_, (guint) 0);
	_tmp6_ = xfw_workspace_group_get_active_workspace ((XfwWorkspaceGroup*) _tmp5_);
	_tmp7_ = _g_object_ref0 (_tmp6_);
	curr_ws = _tmp7_;
	_tmp8_ = curr_ws;
	if (_tmp8_ == NULL) {
		_g_object_unref0 (curr_ws);
		_g_object_unref0 (workspace_manager);
		return;
	}
	_tmp9_ = workspace_manager;
	_tmp10_ = xfw_workspace_manager_list_workspace_groups (_tmp9_);
	_tmp11_ = g_list_nth_data (_tmp10_, (guint) 0);
	_tmp12_ = xfw_workspace_group_list_workspaces ((XfwWorkspaceGroup*) _tmp11_);
	currspaces = _tmp12_;
	_tmp13_ = currspaces;
	_tmp14_ = curr_ws;
	new_wall_paper_switcher_curr_wsindex = g_list_index (_tmp13_, _tmp14_);
	_tmp15_ = new_wall_paper_switcher_switchersettings;
	_tmp17_ = _tmp16_ = g_settings_get_strv (_tmp15_, "wallpapers");
	new_wall_paper_switcher_curr_wallist = (_vala_array_free (new_wall_paper_switcher_curr_wallist, new_wall_paper_switcher_curr_wallist_length1, (GDestroyNotify) g_free), NULL);
	new_wall_paper_switcher_curr_wallist = _tmp17_;
	new_wall_paper_switcher_curr_wallist_length1 = _vala_array_length (_tmp16_);
	_new_wall_paper_switcher_curr_wallist_size_ = new_wall_paper_switcher_curr_wallist_length1;
	_tmp18_ = currspaces;
	n_workspaces = g_list_length (_tmp18_);
	while (TRUE) {
		gchar** _tmp19_;
		gint _tmp19__length1;
		gchar* _tmp20_;
		_tmp19_ = new_wall_paper_switcher_curr_wallist;
		_tmp19__length1 = new_wall_paper_switcher_curr_wallist_length1;
		if (!(((guint) _tmp19__length1) < n_workspaces)) {
			break;
		}
		_tmp20_ = g_strdup ("");
		_vala_array_add1 (&new_wall_paper_switcher_curr_wallist, &new_wall_paper_switcher_curr_wallist_length1, &_new_wall_paper_switcher_curr_wallist_size_, _tmp20_);
	}
	_tmp21_ = new_wall_paper_switcher_switchersettings;
	_tmp22_ = new_wall_paper_switcher_curr_wallist;
	_tmp22__length1 = new_wall_paper_switcher_curr_wallist_length1;
	g_settings_set_strv (_tmp21_, "wallpapers", _tmp22_);
	_tmp23_ = new_wall_paper_switcher_curr_wallist;
	_tmp23__length1 = new_wall_paper_switcher_curr_wallist_length1;
	_tmp24_ = _tmp23_[new_wall_paper_switcher_curr_wsindex];
	_tmp25_ = g_strdup (_tmp24_);
	new_wall = _tmp25_;
	_tmp27_ = new_wall;
	if (g_strcmp0 (_tmp27_, "") != 0) {
		_tmp26_ = new_wall_paper_switcher_runsornot;
	} else {
		_tmp26_ = FALSE;
	}
	if (_tmp26_) {
		gboolean save_animation = FALSE;
		GSettings* _tmp28_;
		GSettings* _tmp30_;
		const gchar* _tmp31_;
		_tmp28_ = new_wall_paper_switcher_animationsettings;
		save_animation = g_settings_get_boolean (_tmp28_, "enable-animations");
		if (save_animation) {
			GSettings* _tmp29_;
			_tmp29_ = new_wall_paper_switcher_animationsettings;
			g_settings_set_boolean (_tmp29_, "enable-animations", FALSE);
		}
		_tmp30_ = new_wall_paper_switcher_wallsettings;
		_tmp31_ = new_wall;
		g_settings_set_string (_tmp30_, "picture-uri", _tmp31_);
		if (save_animation) {
			g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 650, _____lambda5__gsource_func, NULL, NULL);
		}
	}
	_g_free0 (new_wall);
	_g_object_unref0 (curr_ws);
	_g_object_unref0 (workspace_manager);
}

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

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

