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

/*
 * Copyright (c) 2026 focus-timer contributors
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include "ft_core.h"
#include "ft_plugin_sni.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

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

VALA_EXTERN gint sni_capabilities_get_env (const gchar* name);
VALA_EXTERN gboolean sni_capabilities_have_icon_theme (void);
VALA_EXTERN gboolean sni_capabilities_have_passive_status (void);
VALA_EXTERN gboolean sni_capabilities_have_attention_status (void);
VALA_EXTERN gboolean sni_capabilities_have_activation (void);
VALA_EXTERN gboolean sni_capabilities_have_tooltips (void);
VALA_EXTERN gboolean sni_capabilities_have_menu_icons (void);
VALA_EXTERN gboolean sni_capabilities_have_toggles (void);

gint
sni_capabilities_get_env (const gchar* name)
{
	const gchar* _tmp0_ = NULL;
	const gchar* _tmp1_;
	gchar* _tmp2_ = NULL;
	const gchar* _tmp4_;
	GQuark _tmp6_ = 0U;
	static GQuark _tmp5_label0 = 0;
	static GQuark _tmp5_label1 = 0;
	static GQuark _tmp5_label2 = 0;
	static GQuark _tmp5_label3 = 0;
	gint result;
	g_return_val_if_fail (name != NULL, -1);
	_tmp1_ = g_getenv (name);
	_tmp0_ = _tmp1_;
	_tmp2_ = NULL;
	if (_tmp0_ != NULL) {
		gchar* _tmp3_;
		_tmp3_ = g_ascii_strdown (_tmp0_, (gssize) -1);
		_g_free0 (_tmp2_);
		_tmp2_ = _tmp3_;
	}
	_tmp4_ = _tmp2_;
	_tmp6_ = (NULL == _tmp4_) ? 0 : g_quark_from_string (_tmp4_);
	if ((_tmp6_ == ((0 != _tmp5_label0) ? _tmp5_label0 : (_tmp5_label0 = g_quark_from_static_string ("1")))) || (_tmp6_ == ((0 != _tmp5_label1) ? _tmp5_label1 : (_tmp5_label1 = g_quark_from_static_string ("true"))))) {
		switch (0) {
			default:
			{
				result = 1;
				_g_free0 (_tmp2_);
				return result;
			}
		}
	} else if ((_tmp6_ == ((0 != _tmp5_label2) ? _tmp5_label2 : (_tmp5_label2 = g_quark_from_static_string ("0")))) || (_tmp6_ == ((0 != _tmp5_label3) ? _tmp5_label3 : (_tmp5_label3 = g_quark_from_static_string ("false"))))) {
		switch (0) {
			default:
			{
				result = 0;
				_g_free0 (_tmp2_);
				return result;
			}
		}
	} else {
		switch (0) {
			default:
			{
				result = -1;
				_g_free0 (_tmp2_);
				return result;
			}
		}
	}
}

/**
     * Whether the host supports icon themes. Without it, we only can display app icon.
     */
gboolean
sni_capabilities_have_icon_theme (void)
{
	gint env_value = 0;
	gchar* _tmp0_;
	gchar* _tmp1_;
	GQuark _tmp3_ = 0U;
	static GQuark _tmp2_label0 = 0;
	static GQuark _tmp2_label1 = 0;
	static GQuark _tmp2_label2 = 0;
	static GQuark _tmp2_label3 = 0;
	static GQuark _tmp2_label4 = 0;
	static GQuark _tmp2_label5 = 0;
	gboolean result;
	env_value = sni_capabilities_get_env ("SNI_HAVE_ICON_THEME");
	if (env_value >= 0) {
		result = (gboolean) env_value;
		return result;
	}
	_tmp0_ = ft_get_desktop_name ();
	_tmp1_ = _tmp0_;
	_tmp3_ = (NULL == _tmp1_) ? 0 : g_quark_from_string (_tmp1_);
	g_free (_tmp1_);
	if (_tmp3_ == ((0 != _tmp2_label0) ? _tmp2_label0 : (_tmp2_label0 = g_quark_from_static_string ("gnome")))) {
		switch (0) {
			default:
			{
				result = TRUE;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label1) ? _tmp2_label1 : (_tmp2_label1 = g_quark_from_static_string ("kde")))) {
		switch (0) {
			default:
			{
				result = TRUE;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label2) ? _tmp2_label2 : (_tmp2_label2 = g_quark_from_static_string ("cinnamon")))) {
		switch (0) {
			default:
			{
				result = FALSE;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label3) ? _tmp2_label3 : (_tmp2_label3 = g_quark_from_static_string ("xfce")))) {
		switch (0) {
			default:
			{
				result = TRUE;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label4) ? _tmp2_label4 : (_tmp2_label4 = g_quark_from_static_string ("lxqt")))) {
		switch (0) {
			default:
			{
				result = TRUE;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label5) ? _tmp2_label5 : (_tmp2_label5 = g_quark_from_static_string ("cosmic")))) {
		switch (0) {
			default:
			{
				result = FALSE;
				return result;
			}
		}
	} else {
		switch (0) {
			default:
			{
				result = FALSE;
				return result;
			}
		}
	}
}

/**
     * Whether the host supports PASSIVE status (when the timer stopped),
     * and the tray icon remain visible - just with lower priority.
     */
gboolean
sni_capabilities_have_passive_status (void)
{
	gint env_value = 0;
	gchar* _tmp0_;
	gchar* _tmp1_;
	GQuark _tmp3_ = 0U;
	static GQuark _tmp2_label0 = 0;
	static GQuark _tmp2_label1 = 0;
	static GQuark _tmp2_label2 = 0;
	static GQuark _tmp2_label3 = 0;
	static GQuark _tmp2_label4 = 0;
	static GQuark _tmp2_label5 = 0;
	gboolean result;
	env_value = sni_capabilities_get_env ("SNI_HAVE_PASSIVE_STATUS");
	if (env_value >= 0) {
		result = (gboolean) env_value;
		return result;
	}
	_tmp0_ = ft_get_desktop_name ();
	_tmp1_ = _tmp0_;
	_tmp3_ = (NULL == _tmp1_) ? 0 : g_quark_from_string (_tmp1_);
	g_free (_tmp1_);
	if (_tmp3_ == ((0 != _tmp2_label0) ? _tmp2_label0 : (_tmp2_label0 = g_quark_from_static_string ("gnome")))) {
		switch (0) {
			default:
			{
				result = FALSE;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label1) ? _tmp2_label1 : (_tmp2_label1 = g_quark_from_static_string ("kde")))) {
		switch (0) {
			default:
			{
				result = TRUE;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label2) ? _tmp2_label2 : (_tmp2_label2 = g_quark_from_static_string ("cinnamon")))) {
		switch (0) {
			default:
			{
				result = FALSE;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label3) ? _tmp2_label3 : (_tmp2_label3 = g_quark_from_static_string ("xfce")))) {
		switch (0) {
			default:
			{
				result = FALSE;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label4) ? _tmp2_label4 : (_tmp2_label4 = g_quark_from_static_string ("lxqt")))) {
		switch (0) {
			default:
			{
				result = FALSE;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label5) ? _tmp2_label5 : (_tmp2_label5 = g_quark_from_static_string ("cosmic")))) {
		switch (0) {
			default:
			{
				result = FALSE;
				return result;
			}
		}
	} else {
		switch (0) {
			default:
			{
				result = FALSE;
				return result;
			}
		}
	}
}

/**
     * Whether the host makes the icon blinking in NEEDS_ATTENTION status (when the timer is
     * paused or finished).
     */
gboolean
sni_capabilities_have_attention_status (void)
{
	gint env_value = 0;
	gchar* _tmp0_;
	gchar* _tmp1_;
	GQuark _tmp3_ = 0U;
	static GQuark _tmp2_label0 = 0;
	static GQuark _tmp2_label1 = 0;
	static GQuark _tmp2_label2 = 0;
	static GQuark _tmp2_label3 = 0;
	static GQuark _tmp2_label4 = 0;
	static GQuark _tmp2_label5 = 0;
	gboolean result;
	env_value = sni_capabilities_get_env ("SNI_HAVE_ATTENTION_STATUS");
	if (env_value >= 0) {
		result = (gboolean) env_value;
		return result;
	}
	_tmp0_ = ft_get_desktop_name ();
	_tmp1_ = _tmp0_;
	_tmp3_ = (NULL == _tmp1_) ? 0 : g_quark_from_string (_tmp1_);
	g_free (_tmp1_);
	if (_tmp3_ == ((0 != _tmp2_label0) ? _tmp2_label0 : (_tmp2_label0 = g_quark_from_static_string ("gnome")))) {
		switch (0) {
			default:
			{
				result = FALSE;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label1) ? _tmp2_label1 : (_tmp2_label1 = g_quark_from_static_string ("kde")))) {
		switch (0) {
			default:
			{
				result = TRUE;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label2) ? _tmp2_label2 : (_tmp2_label2 = g_quark_from_static_string ("cinnamon")))) {
		switch (0) {
			default:
			{
				result = FALSE;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label3) ? _tmp2_label3 : (_tmp2_label3 = g_quark_from_static_string ("xfce")))) {
		switch (0) {
			default:
			{
				result = FALSE;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label4) ? _tmp2_label4 : (_tmp2_label4 = g_quark_from_static_string ("lxqt")))) {
		switch (0) {
			default:
			{
				result = FALSE;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label5) ? _tmp2_label5 : (_tmp2_label5 = g_quark_from_static_string ("cosmic")))) {
		switch (0) {
			default:
			{
				result = FALSE;
				return result;
			}
		}
	} else {
		switch (0) {
			default:
			{
				result = FALSE;
				return result;
			}
		}
	}
}

/**
     * Whether the host prefers activation (clicking the icon brings the app to focus)
     * over displaying the context menu.
     */
gboolean
sni_capabilities_have_activation (void)
{
	gint env_value = 0;
	gchar* _tmp0_;
	gchar* _tmp1_;
	GQuark _tmp3_ = 0U;
	static GQuark _tmp2_label0 = 0;
	static GQuark _tmp2_label1 = 0;
	static GQuark _tmp2_label2 = 0;
	static GQuark _tmp2_label3 = 0;
	static GQuark _tmp2_label4 = 0;
	static GQuark _tmp2_label5 = 0;
	gboolean result;
	env_value = sni_capabilities_get_env ("SNI_HAVE_ACTIVATION");
	if (env_value >= 0) {
		result = (gboolean) env_value;
		return result;
	}
	_tmp0_ = ft_get_desktop_name ();
	_tmp1_ = _tmp0_;
	_tmp3_ = (NULL == _tmp1_) ? 0 : g_quark_from_string (_tmp1_);
	g_free (_tmp1_);
	if (_tmp3_ == ((0 != _tmp2_label0) ? _tmp2_label0 : (_tmp2_label0 = g_quark_from_static_string ("gnome")))) {
		switch (0) {
			default:
			{
				result = FALSE;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label1) ? _tmp2_label1 : (_tmp2_label1 = g_quark_from_static_string ("kde")))) {
		switch (0) {
			default:
			{
				result = TRUE;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label2) ? _tmp2_label2 : (_tmp2_label2 = g_quark_from_static_string ("cinnamon")))) {
		switch (0) {
			default:
			{
				result = TRUE;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label3) ? _tmp2_label3 : (_tmp2_label3 = g_quark_from_static_string ("xfce")))) {
		switch (0) {
			default:
			{
				result = TRUE;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label4) ? _tmp2_label4 : (_tmp2_label4 = g_quark_from_static_string ("lxqt")))) {
		switch (0) {
			default:
			{
				result = TRUE;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label5) ? _tmp2_label5 : (_tmp2_label5 = g_quark_from_static_string ("cosmic")))) {
		switch (0) {
			default:
			{
				result = FALSE;
				return result;
			}
		}
	} else {
		switch (0) {
			default:
			{
				result = TRUE;
				return result;
			}
		}
	}
}

/**
     * Whether the host displays tooltips.
     *
     * It's required for scroll-wheel gesture. Otherwise user would change countdown duration
     * without much of a visual cue.
     */
gboolean
sni_capabilities_have_tooltips (void)
{
	gint env_value = 0;
	gchar* _tmp0_;
	gchar* _tmp1_;
	GQuark _tmp3_ = 0U;
	static GQuark _tmp2_label0 = 0;
	static GQuark _tmp2_label1 = 0;
	static GQuark _tmp2_label2 = 0;
	static GQuark _tmp2_label3 = 0;
	static GQuark _tmp2_label4 = 0;
	static GQuark _tmp2_label5 = 0;
	gboolean result;
	env_value = sni_capabilities_get_env ("SNI_HAVE_TOOLTIPS");
	if (env_value >= 0) {
		result = (gboolean) env_value;
		return result;
	}
	_tmp0_ = ft_get_desktop_name ();
	_tmp1_ = _tmp0_;
	_tmp3_ = (NULL == _tmp1_) ? 0 : g_quark_from_string (_tmp1_);
	g_free (_tmp1_);
	if (_tmp3_ == ((0 != _tmp2_label0) ? _tmp2_label0 : (_tmp2_label0 = g_quark_from_static_string ("gnome")))) {
		switch (0) {
			default:
			{
				result = FALSE;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label1) ? _tmp2_label1 : (_tmp2_label1 = g_quark_from_static_string ("kde")))) {
		switch (0) {
			default:
			{
				result = TRUE;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label2) ? _tmp2_label2 : (_tmp2_label2 = g_quark_from_static_string ("cinnamon")))) {
		switch (0) {
			default:
			{
				result = FALSE;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label3) ? _tmp2_label3 : (_tmp2_label3 = g_quark_from_static_string ("xfce")))) {
		switch (0) {
			default:
			{
				result = FALSE;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label4) ? _tmp2_label4 : (_tmp2_label4 = g_quark_from_static_string ("lxqt")))) {
		switch (0) {
			default:
			{
				result = FALSE;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label5) ? _tmp2_label5 : (_tmp2_label5 = g_quark_from_static_string ("cosmic")))) {
		switch (0) {
			default:
			{
				result = FALSE;
				return result;
			}
		}
	} else {
		switch (0) {
			default:
			{
				result = FALSE;
				return result;
			}
		}
	}
}

/**
     * Whether the desktop prefers having icons in their menus,
     * and the host can handle custom icon themes in the menu.
     */
gboolean
sni_capabilities_have_menu_icons (void)
{
	gint env_value = 0;
	gchar* _tmp0_;
	gchar* _tmp1_;
	GQuark _tmp3_ = 0U;
	static GQuark _tmp2_label0 = 0;
	static GQuark _tmp2_label1 = 0;
	static GQuark _tmp2_label2 = 0;
	static GQuark _tmp2_label3 = 0;
	static GQuark _tmp2_label4 = 0;
	static GQuark _tmp2_label5 = 0;
	gboolean result;
	env_value = sni_capabilities_get_env ("SNI_HAVE_MENU_ICONS");
	if (env_value >= 0) {
		result = (gboolean) env_value;
		return result;
	}
	_tmp0_ = ft_get_desktop_name ();
	_tmp1_ = _tmp0_;
	_tmp3_ = (NULL == _tmp1_) ? 0 : g_quark_from_string (_tmp1_);
	g_free (_tmp1_);
	if (_tmp3_ == ((0 != _tmp2_label0) ? _tmp2_label0 : (_tmp2_label0 = g_quark_from_static_string ("gnome")))) {
		switch (0) {
			default:
			{
				result = FALSE;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label1) ? _tmp2_label1 : (_tmp2_label1 = g_quark_from_static_string ("kde")))) {
		switch (0) {
			default:
			{
				result = TRUE;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label2) ? _tmp2_label2 : (_tmp2_label2 = g_quark_from_static_string ("cinnamon")))) {
		switch (0) {
			default:
			{
				result = FALSE;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label3) ? _tmp2_label3 : (_tmp2_label3 = g_quark_from_static_string ("xfce")))) {
		switch (0) {
			default:
			{
				result = FALSE;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label4) ? _tmp2_label4 : (_tmp2_label4 = g_quark_from_static_string ("lxqt")))) {
		switch (0) {
			default:
			{
				result = FALSE;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label5) ? _tmp2_label5 : (_tmp2_label5 = g_quark_from_static_string ("cosmic")))) {
		switch (0) {
			default:
			{
				result = FALSE;
				return result;
			}
		}
	} else {
		switch (0) {
			default:
			{
				result = FALSE;
				return result;
			}
		}
	}
}

/**
     * Whether the host displays radios right next to the label
     * or does it *break* the menu layout.
     *
     * When `false`, we use custom icons to display radio / checkmark.
     */
gboolean
sni_capabilities_have_toggles (void)
{
	gint env_value = 0;
	gchar* _tmp0_;
	gchar* _tmp1_;
	GQuark _tmp3_ = 0U;
	static GQuark _tmp2_label0 = 0;
	static GQuark _tmp2_label1 = 0;
	static GQuark _tmp2_label2 = 0;
	static GQuark _tmp2_label3 = 0;
	static GQuark _tmp2_label4 = 0;
	static GQuark _tmp2_label5 = 0;
	gboolean result;
	if (!sni_capabilities_have_menu_icons ()) {
		result = TRUE;
		return result;
	}
	env_value = sni_capabilities_get_env ("SNI_HAVE_TOGGLES");
	if (env_value >= 0) {
		result = (gboolean) env_value;
		return result;
	}
	_tmp0_ = ft_get_desktop_name ();
	_tmp1_ = _tmp0_;
	_tmp3_ = (NULL == _tmp1_) ? 0 : g_quark_from_string (_tmp1_);
	g_free (_tmp1_);
	if (_tmp3_ == ((0 != _tmp2_label0) ? _tmp2_label0 : (_tmp2_label0 = g_quark_from_static_string ("gnome")))) {
		switch (0) {
			default:
			{
				result = TRUE;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label1) ? _tmp2_label1 : (_tmp2_label1 = g_quark_from_static_string ("kde")))) {
		switch (0) {
			default:
			{
				result = FALSE;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label2) ? _tmp2_label2 : (_tmp2_label2 = g_quark_from_static_string ("cinnamon")))) {
		switch (0) {
			default:
			{
				result = TRUE;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label3) ? _tmp2_label3 : (_tmp2_label3 = g_quark_from_static_string ("xfce")))) {
		switch (0) {
			default:
			{
				result = TRUE;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label4) ? _tmp2_label4 : (_tmp2_label4 = g_quark_from_static_string ("lxqt")))) {
		switch (0) {
			default:
			{
				result = TRUE;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label5) ? _tmp2_label5 : (_tmp2_label5 = g_quark_from_static_string ("cosmic")))) {
		switch (0) {
			default:
			{
				result = TRUE;
				return result;
			}
		}
	} else {
		switch (0) {
			default:
			{
				result = TRUE;
				return result;
			}
		}
	}
}

