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

/*
 * This file is part of budgie-desktop
 *
 * Copyright Budgie Desktop Developers
 *
 * 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.
 */

#include <glib.h>
#include <gtk/gtk.h>
#include <locale.h>
#include <glib/gi18n-lib.h>
#include <budgie-config.h>
#include <stdio.h>
#include <glib-object.h>
#include "budgie-private.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 _g_option_context_free0(var) ((var == NULL) ? NULL : (var = (g_option_context_free (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef enum  {
	BUDGIE_RESET_FLAGS_NONE = 0,
	BUDGIE_RESET_FLAGS_PANEL = 1 << 0,
	BUDGIE_RESET_FLAGS_RAVEN = 1 << 1
} BudgieResetFlags;

#define BUDGIE_TYPE_RESET_FLAGS (budgie_reset_flags_get_type ())

#define BUDGIE_TYPE_PANEL_MANAGER (budgie_panel_manager_get_type ())
#define BUDGIE_PANEL_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BUDGIE_TYPE_PANEL_MANAGER, BudgiePanelManager))
#define BUDGIE_PANEL_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BUDGIE_TYPE_PANEL_MANAGER, BudgiePanelManagerClass))
#define BUDGIE_IS_PANEL_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BUDGIE_TYPE_PANEL_MANAGER))
#define BUDGIE_IS_PANEL_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BUDGIE_TYPE_PANEL_MANAGER))
#define BUDGIE_PANEL_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BUDGIE_TYPE_PANEL_MANAGER, BudgiePanelManagerClass))

typedef struct _BudgiePanelManager BudgiePanelManager;
typedef struct _BudgiePanelManagerClass BudgiePanelManagerClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

VALA_EXTERN gboolean replace;
gboolean replace = FALSE;
VALA_EXTERN gboolean reset_panel;
gboolean reset_panel = FALSE;
VALA_EXTERN gboolean reset_raven;
gboolean reset_raven = FALSE;

static gint _vala_main (gchar** args,
                 gint args_length1);
VALA_EXTERN GType budgie_reset_flags_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType budgie_panel_manager_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BudgiePanelManager, g_object_unref)
VALA_EXTERN BudgiePanelManager* budgie_panel_manager_new (BudgieResetFlags reset_flags);
VALA_EXTERN BudgiePanelManager* budgie_panel_manager_construct (GType object_type,
                                                    BudgieResetFlags reset_flags);
VALA_EXTERN void budgie_panel_manager_serve (BudgiePanelManager* self,
                                 gboolean replace);

const GOptionEntry options[4] = {{"replace", (gchar) 0, (gint) 0, G_OPTION_ARG_NONE, &replace, "Replace currently running panel"}, {"reset", (gchar) 0, (gint) 0, G_OPTION_ARG_NONE, &reset_panel, "Reset the panel configuration"}, {"reset-raven", (gchar) 0, (gint) 0, G_OPTION_ARG_NONE, &reset_raven, "Reset the Raven widget configuration"}, {NULL}};

static gint
_vala_main (gchar** args,
            gint args_length1)
{
	GOptionContext* ctx = NULL;
	GOptionContext* _tmp0_;
	GOptionContext* _tmp1_;
	GOptionContext* _tmp2_;
	GOptionContext* _tmp3_;
	GOptionGroup* _tmp4_;
	BudgieResetFlags reset_flags = 0U;
	BudgiePanelManager* manager = NULL;
	BudgiePanelManager* _tmp10_;
	BudgiePanelManager* _tmp11_;
	GError* _inner_error0_ = NULL;
	gint result;
	gtk_init ((gint*) (&args_length1), &args);
	setlocale (LC_ALL, "");
	bindtextdomain (BUDGIE_GETTEXT_PACKAGE, BUDGIE_LOCALEDIR);
	bind_textdomain_codeset (BUDGIE_GETTEXT_PACKAGE, "UTF-8");
	textdomain (BUDGIE_GETTEXT_PACKAGE);
	_tmp0_ = g_option_context_new ("- Budgie Panel");
	_g_option_context_free0 (ctx);
	ctx = _tmp0_;
	_tmp1_ = ctx;
	g_option_context_set_help_enabled (_tmp1_, TRUE);
	_tmp2_ = ctx;
	g_option_context_add_main_entries (_tmp2_, options, NULL);
	_tmp3_ = ctx;
	_tmp4_ = gtk_get_option_group (FALSE);
	g_option_context_add_group (_tmp3_, _tmp4_);
	{
		GOptionContext* _tmp5_;
		_tmp5_ = ctx;
		g_option_context_parse (_tmp5_, (gint*) (&args_length1), &args, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		FILE* _tmp6_;
		GError* _tmp7_;
		const gchar* _tmp8_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp6_ = stderr;
		_tmp7_ = e;
		_tmp8_ = _tmp7_->message;
		fprintf (_tmp6_, "Error: %s\n", _tmp8_);
		result = 0;
		_g_error_free0 (e);
		_g_option_context_free0 (ctx);
		return result;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint _tmp9_ = -1;
		_g_option_context_free0 (ctx);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return _tmp9_;
	}
	reset_flags = BUDGIE_RESET_FLAGS_NONE;
	if (reset_panel) {
		reset_flags |= BUDGIE_RESET_FLAGS_PANEL;
	}
	if (reset_raven) {
		reset_flags |= BUDGIE_RESET_FLAGS_RAVEN;
	}
	_tmp10_ = budgie_panel_manager_new (reset_flags);
	manager = _tmp10_;
	_tmp11_ = manager;
	budgie_panel_manager_serve (_tmp11_, replace);
	gtk_main ();
	result = 0;
	_g_object_unref0 (manager);
	_g_option_context_free0 (ctx);
	return result;
}

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

