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

#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <platform.h>
#include <gtk/gtk.h>
#include <gdk/gdk.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

typedef void (*DcPlatformRawMacosFileDropCallback) (const gchar* path, void* user_data);
#define _g_free0(var) (var = (g_free (var), NULL))

VALA_EXTERN gchar* dc_platform_get_executable_path (void);
VALA_EXTERN gchar* dc_platform_get_executable_dir (void);
VALA_EXTERN gboolean dc_platform_is_macos (void);
VALA_EXTERN void dc_platform_setup_macos_bundle_environment (void);
VALA_EXTERN void dc_platform_install_macos_file_drop_handler (GtkWidget* widget,
                                                  DcPlatformRawMacosFileDropCallback callback,
                                                  void* user_data);
VALA_EXTERN GdkModifierType dc_platform_primary_modifier_mask (void);
VALA_EXTERN gboolean dc_platform_has_primary_modifier (GdkModifierType state);
VALA_EXTERN gchar* dc_platform_primary_accelerator_prefix (void);
VALA_EXTERN gchar* dc_platform_primary_shortcut_text (const gchar* key);

gchar*
dc_platform_get_executable_path (void)
{
	gchar* _tmp0_;
	gchar* result;
	_tmp0_ = parla_get_executable_path ();
	result = _tmp0_;
	return result;
}

gchar*
dc_platform_get_executable_dir (void)
{
	gchar* exe_path = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_ = NULL;
	const gchar* _tmp2_;
	gchar* _tmp5_;
	gchar* result;
	_tmp0_ = dc_platform_get_executable_path ();
	exe_path = _tmp0_;
	_tmp2_ = exe_path;
	if (_tmp2_ != NULL) {
		const gchar* _tmp3_;
		gchar* _tmp4_;
		_tmp3_ = exe_path;
		_tmp4_ = g_path_get_dirname (_tmp3_);
		_g_free0 (_tmp1_);
		_tmp1_ = _tmp4_;
	} else {
		_g_free0 (_tmp1_);
		_tmp1_ = NULL;
	}
	_tmp5_ = _tmp1_;
	_tmp1_ = NULL;
	result = _tmp5_;
	_g_free0 (_tmp1_);
	_g_free0 (exe_path);
	return result;
}

gboolean
dc_platform_is_macos (void)
{
	gboolean result;
	result = parla_platform_is_macos ();
	return result;
}

void
dc_platform_setup_macos_bundle_environment (void)
{
	parla_setup_macos_bundle_environment ();
}

void
dc_platform_install_macos_file_drop_handler (GtkWidget* widget,
                                             DcPlatformRawMacosFileDropCallback callback,
                                             void* user_data)
{
	g_return_if_fail (widget != NULL);
	if (!dc_platform_is_macos ()) {
		return;
	}
	parla_macos_install_file_drop_handler (widget, callback, user_data);
}

GdkModifierType
dc_platform_primary_modifier_mask (void)
{
	GdkModifierType _tmp0_ = 0U;
	GdkModifierType result;
	if (dc_platform_is_macos ()) {
		_tmp0_ = GDK_META_MASK;
	} else {
		_tmp0_ = GDK_CONTROL_MASK;
	}
	result = _tmp0_;
	return result;
}

gboolean
dc_platform_has_primary_modifier (GdkModifierType state)
{
	gboolean result;
	result = (state & dc_platform_primary_modifier_mask ()) != 0;
	return result;
}

gchar*
dc_platform_primary_accelerator_prefix (void)
{
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_;
	gchar* result;
	if (dc_platform_is_macos ()) {
		_tmp0_ = "<Meta>";
	} else {
		_tmp0_ = "<Control>";
	}
	_tmp1_ = g_strdup (_tmp0_);
	result = _tmp1_;
	return result;
}

gchar*
dc_platform_primary_shortcut_text (const gchar* key)
{
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_;
	gchar* result;
	g_return_val_if_fail (key != NULL, NULL);
	if (dc_platform_is_macos ()) {
		_tmp0_ = "Command";
	} else {
		_tmp0_ = "Ctrl";
	}
	_tmp1_ = g_strdup_printf ("%s+%s", _tmp0_, key);
	result = _tmp1_;
	return result;
}

