/* rdp-preferences-window.c generated by valac 0.56.19, the Vala compiler
 * generated from rdp-preferences-window.vala, do not modify */

/* rdp-preferences-window.vala
 *
 * Copyright (C) Red Hat, Inc
 *
 * 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 3 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, see <http://www.gnu.org/licenses/>.
 *
 * Author: Felipe Borges <felipeborges@gnome.org>
 *
 */

#include <handy.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.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 CONNECTIONS_TYPE_PREFERENCES_WINDOW (connections_preferences_window_get_type ())
#define CONNECTIONS_PREFERENCES_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONNECTIONS_TYPE_PREFERENCES_WINDOW, ConnectionsPreferencesWindow))
#define CONNECTIONS_PREFERENCES_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONNECTIONS_TYPE_PREFERENCES_WINDOW, ConnectionsPreferencesWindowClass))
#define CONNECTIONS_IS_PREFERENCES_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONNECTIONS_TYPE_PREFERENCES_WINDOW))
#define CONNECTIONS_IS_PREFERENCES_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONNECTIONS_TYPE_PREFERENCES_WINDOW))
#define CONNECTIONS_PREFERENCES_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONNECTIONS_TYPE_PREFERENCES_WINDOW, ConnectionsPreferencesWindowClass))

typedef struct _ConnectionsPreferencesWindow ConnectionsPreferencesWindow;
typedef struct _ConnectionsPreferencesWindowClass ConnectionsPreferencesWindowClass;
typedef struct _ConnectionsPreferencesWindowPrivate ConnectionsPreferencesWindowPrivate;

#define CONNECTIONS_TYPE_CONNECTION (connections_connection_get_type ())
#define CONNECTIONS_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONNECTIONS_TYPE_CONNECTION, ConnectionsConnection))
#define CONNECTIONS_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONNECTIONS_TYPE_CONNECTION, ConnectionsConnectionClass))
#define CONNECTIONS_IS_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONNECTIONS_TYPE_CONNECTION))
#define CONNECTIONS_IS_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONNECTIONS_TYPE_CONNECTION))
#define CONNECTIONS_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONNECTIONS_TYPE_CONNECTION, ConnectionsConnectionClass))

typedef struct _ConnectionsConnection ConnectionsConnection;
typedef struct _ConnectionsConnectionClass ConnectionsConnectionClass;

#define CONNECTIONS_TYPE_RDP_PREFERENCES_WINDOW (connections_rdp_preferences_window_get_type ())
#define CONNECTIONS_RDP_PREFERENCES_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONNECTIONS_TYPE_RDP_PREFERENCES_WINDOW, ConnectionsRdpPreferencesWindow))
#define CONNECTIONS_RDP_PREFERENCES_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONNECTIONS_TYPE_RDP_PREFERENCES_WINDOW, ConnectionsRdpPreferencesWindowClass))
#define CONNECTIONS_IS_RDP_PREFERENCES_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONNECTIONS_TYPE_RDP_PREFERENCES_WINDOW))
#define CONNECTIONS_IS_RDP_PREFERENCES_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONNECTIONS_TYPE_RDP_PREFERENCES_WINDOW))
#define CONNECTIONS_RDP_PREFERENCES_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONNECTIONS_TYPE_RDP_PREFERENCES_WINDOW, ConnectionsRdpPreferencesWindowClass))

typedef struct _ConnectionsRdpPreferencesWindow ConnectionsRdpPreferencesWindow;
typedef struct _ConnectionsRdpPreferencesWindowClass ConnectionsRdpPreferencesWindowClass;
typedef struct _ConnectionsRdpPreferencesWindowPrivate ConnectionsRdpPreferencesWindowPrivate;
enum  {
	CONNECTIONS_RDP_PREFERENCES_WINDOW_0_PROPERTY,
	CONNECTIONS_RDP_PREFERENCES_WINDOW_NUM_PROPERTIES
};
static GParamSpec* connections_rdp_preferences_window_properties[CONNECTIONS_RDP_PREFERENCES_WINDOW_NUM_PROPERTIES];

#define CONNECTIONS_TYPE_RDP_CONNECTION (connections_rdp_connection_get_type ())
#define CONNECTIONS_RDP_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONNECTIONS_TYPE_RDP_CONNECTION, ConnectionsRdpConnection))
#define CONNECTIONS_RDP_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONNECTIONS_TYPE_RDP_CONNECTION, ConnectionsRdpConnectionClass))
#define CONNECTIONS_IS_RDP_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONNECTIONS_TYPE_RDP_CONNECTION))
#define CONNECTIONS_IS_RDP_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONNECTIONS_TYPE_RDP_CONNECTION))
#define CONNECTIONS_RDP_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONNECTIONS_TYPE_RDP_CONNECTION, ConnectionsRdpConnectionClass))

typedef struct _ConnectionsRdpConnection ConnectionsRdpConnection;
typedef struct _ConnectionsRdpConnectionClass ConnectionsRdpConnectionClass;
#define _g_free0(var) (var = (g_free (var), NULL))

struct _ConnectionsPreferencesWindow {
	HdyPreferencesWindow parent_instance;
	ConnectionsPreferencesWindowPrivate * priv;
	ConnectionsConnection* connection;
};

struct _ConnectionsPreferencesWindowClass {
	HdyPreferencesWindowClass parent_class;
};

struct _ConnectionsRdpPreferencesWindow {
	ConnectionsPreferencesWindow parent_instance;
	ConnectionsRdpPreferencesWindowPrivate * priv;
};

struct _ConnectionsRdpPreferencesWindowClass {
	ConnectionsPreferencesWindowClass parent_class;
};

struct _ConnectionsRdpPreferencesWindowPrivate {
	GtkEntry* connection_name_entry;
	GtkLabel* host_address_label;
	GtkComboBoxText* scale_mode_combo;
};

static gint ConnectionsRdpPreferencesWindow_private_offset;
static gpointer connections_rdp_preferences_window_parent_class = NULL;

VALA_EXTERN GType connections_preferences_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ConnectionsPreferencesWindow, g_object_unref)
VALA_EXTERN GType connections_connection_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ConnectionsConnection, g_object_unref)
VALA_EXTERN GType connections_rdp_preferences_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ConnectionsRdpPreferencesWindow, g_object_unref)
VALA_EXTERN ConnectionsRdpPreferencesWindow* connections_rdp_preferences_window_new (ConnectionsConnection* connection);
VALA_EXTERN ConnectionsRdpPreferencesWindow* connections_rdp_preferences_window_construct (GType object_type,
                                                                               ConnectionsConnection* connection);
VALA_EXTERN ConnectionsPreferencesWindow* connections_preferences_window_new (void);
VALA_EXTERN ConnectionsPreferencesWindow* connections_preferences_window_construct (GType object_type);
static void connections_rdp_preferences_window_update_scale_mode_combo (ConnectionsRdpPreferencesWindow* self);
VALA_EXTERN void connections_preferences_window_bind_widget_property (ConnectionsPreferencesWindow* self,
                                                          GtkWidget* widget,
                                                          const gchar* widget_property,
                                                          const gchar* connection_property);
static void _connections_rdp_preferences_window_update_scale_mode_combo_g_object_notify (GObject* _sender,
                                                                                  GParamSpec* pspec,
                                                                                  gpointer self);
VALA_EXTERN GType connections_rdp_connection_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ConnectionsRdpConnection, g_object_unref)
VALA_EXTERN gboolean connections_rdp_connection_get_resize_supported (ConnectionsRdpConnection* self);
VALA_EXTERN const gchar* connections_rdp_connection_get_scale_mode (ConnectionsRdpConnection* self);
static gboolean connections_rdp_preferences_window_combo_contains_item (ConnectionsRdpPreferencesWindow* self,
                                                                 GtkComboBoxText* combo_box,
                                                                 const gchar* item_id);
static void connections_rdp_preferences_window_finalize (GObject * obj);
static GType connections_rdp_preferences_window_get_type_once (void);

static inline gpointer
connections_rdp_preferences_window_get_instance_private (ConnectionsRdpPreferencesWindow* self)
{
	return G_STRUCT_MEMBER_P (self, ConnectionsRdpPreferencesWindow_private_offset);
}

static void
_connections_rdp_preferences_window_update_scale_mode_combo_g_object_notify (GObject* _sender,
                                                                             GParamSpec* pspec,
                                                                             gpointer self)
{
	connections_rdp_preferences_window_update_scale_mode_combo ((ConnectionsRdpPreferencesWindow*) self);
}

ConnectionsRdpPreferencesWindow*
connections_rdp_preferences_window_construct (GType object_type,
                                              ConnectionsConnection* connection)
{
	ConnectionsRdpPreferencesWindow * self = NULL;
	GtkEntry* _tmp0_;
	GtkLabel* _tmp1_;
	GtkComboBoxText* _tmp2_;
	g_return_val_if_fail (connection != NULL, NULL);
	self = (ConnectionsRdpPreferencesWindow*) connections_preferences_window_construct (object_type);
	((ConnectionsPreferencesWindow*) self)->connection = connection;
	connections_rdp_preferences_window_update_scale_mode_combo (self);
	_tmp0_ = self->priv->connection_name_entry;
	connections_preferences_window_bind_widget_property ((ConnectionsPreferencesWindow*) self, (GtkWidget*) _tmp0_, "text", "display_name");
	_tmp1_ = self->priv->host_address_label;
	connections_preferences_window_bind_widget_property ((ConnectionsPreferencesWindow*) self, (GtkWidget*) _tmp1_, "label", "uri");
	_tmp2_ = self->priv->scale_mode_combo;
	connections_preferences_window_bind_widget_property ((ConnectionsPreferencesWindow*) self, (GtkWidget*) _tmp2_, "active_id", "scale-mode");
	g_signal_connect_object ((GObject*) connection, "notify::resize-supported", (GCallback) _connections_rdp_preferences_window_update_scale_mode_combo_g_object_notify, self, 0);
	return self;
}

ConnectionsRdpPreferencesWindow*
connections_rdp_preferences_window_new (ConnectionsConnection* connection)
{
	return connections_rdp_preferences_window_construct (CONNECTIONS_TYPE_RDP_PREFERENCES_WINDOW, connection);
}

static void
connections_rdp_preferences_window_update_scale_mode_combo (ConnectionsRdpPreferencesWindow* self)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	ConnectionsConnection* _tmp2_;
	gboolean _tmp3_;
	gboolean _tmp4_;
	g_return_if_fail (self != NULL);
	_tmp2_ = ((ConnectionsPreferencesWindow*) self)->connection;
	_tmp3_ = connections_rdp_connection_get_resize_supported (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, CONNECTIONS_TYPE_RDP_CONNECTION, ConnectionsRdpConnection));
	_tmp4_ = _tmp3_;
	if (_tmp4_) {
		_tmp1_ = TRUE;
	} else {
		ConnectionsConnection* _tmp5_;
		const gchar* _tmp6_;
		const gchar* _tmp7_;
		_tmp5_ = ((ConnectionsPreferencesWindow*) self)->connection;
		_tmp6_ = connections_rdp_connection_get_scale_mode (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, CONNECTIONS_TYPE_RDP_CONNECTION, ConnectionsRdpConnection));
		_tmp7_ = _tmp6_;
		_tmp1_ = g_strcmp0 (_tmp7_, "resize-desktop") == 0;
	}
	if (_tmp1_) {
		GtkComboBoxText* _tmp8_;
		_tmp8_ = self->priv->scale_mode_combo;
		_tmp0_ = !connections_rdp_preferences_window_combo_contains_item (self, _tmp8_, "resize-desktop");
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		GtkComboBoxText* _tmp9_;
		_tmp9_ = self->priv->scale_mode_combo;
		gtk_combo_box_text_insert (_tmp9_, 0, "resize-desktop", _ ("Resize desktop"));
	}
}

static gboolean
connections_rdp_preferences_window_combo_contains_item (ConnectionsRdpPreferencesWindow* self,
                                                        GtkComboBoxText* combo_box,
                                                        const gchar* item_id)
{
	GtkTreeIter iter = {0};
	gchar* mode = NULL;
	GtkComboBoxText* _tmp0_;
	GtkTreeModel* _tmp1_;
	GtkTreeModel* _tmp2_;
	GtkTreeIter _tmp3_ = {0};
	gboolean _tmp4_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (combo_box != NULL, FALSE);
	g_return_val_if_fail (item_id != NULL, FALSE);
	_tmp0_ = self->priv->scale_mode_combo;
	_tmp1_ = gtk_combo_box_get_model ((GtkComboBox*) _tmp0_);
	_tmp2_ = _tmp1_;
	_tmp4_ = gtk_tree_model_get_iter_first (_tmp2_, &_tmp3_);
	iter = _tmp3_;
	if (_tmp4_) {
		GtkComboBoxText* _tmp5_;
		GtkTreeModel* _tmp6_;
		GtkTreeModel* _tmp7_;
		GtkTreeIter _tmp8_;
		gchar* _tmp9_ = NULL;
		const gchar* _tmp10_;
		_tmp5_ = self->priv->scale_mode_combo;
		_tmp6_ = gtk_combo_box_get_model ((GtkComboBox*) _tmp5_);
		_tmp7_ = _tmp6_;
		_tmp8_ = iter;
		gtk_tree_model_get (_tmp7_, &_tmp8_, 1, &_tmp9_, -1);
		_g_free0 (mode);
		mode = _tmp9_;
		_tmp10_ = mode;
		if (g_strcmp0 (_tmp10_, item_id) == 0) {
			result = TRUE;
			_g_free0 (mode);
			return result;
		} else {
			while (TRUE) {
				GtkComboBoxText* _tmp11_;
				GtkTreeModel* _tmp12_;
				GtkTreeModel* _tmp13_;
				gboolean _tmp14_;
				GtkComboBoxText* _tmp15_;
				GtkTreeModel* _tmp16_;
				GtkTreeModel* _tmp17_;
				GtkTreeIter _tmp18_;
				gchar* _tmp19_ = NULL;
				const gchar* _tmp20_;
				_tmp11_ = self->priv->scale_mode_combo;
				_tmp12_ = gtk_combo_box_get_model ((GtkComboBox*) _tmp11_);
				_tmp13_ = _tmp12_;
				_tmp14_ = gtk_tree_model_iter_next (_tmp13_, &iter);
				if (!_tmp14_) {
					break;
				}
				_tmp15_ = self->priv->scale_mode_combo;
				_tmp16_ = gtk_combo_box_get_model ((GtkComboBox*) _tmp15_);
				_tmp17_ = _tmp16_;
				_tmp18_ = iter;
				gtk_tree_model_get (_tmp17_, &_tmp18_, 1, &_tmp19_, -1);
				_g_free0 (mode);
				mode = _tmp19_;
				_tmp20_ = mode;
				if (g_strcmp0 (_tmp20_, item_id) == 0) {
					result = TRUE;
					_g_free0 (mode);
					return result;
				}
			}
		}
	}
	result = FALSE;
	_g_free0 (mode);
	return result;
}

static void
connections_rdp_preferences_window_class_init (ConnectionsRdpPreferencesWindowClass * klass,
                                               gpointer klass_data)
{
	connections_rdp_preferences_window_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ConnectionsRdpPreferencesWindow_private_offset);
	G_OBJECT_CLASS (klass)->finalize = connections_rdp_preferences_window_finalize;
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/Connections/ui/rdp-preferences.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "connection_name_entry", FALSE, ConnectionsRdpPreferencesWindow_private_offset + G_STRUCT_OFFSET (ConnectionsRdpPreferencesWindowPrivate, connection_name_entry));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "host_address_label", FALSE, ConnectionsRdpPreferencesWindow_private_offset + G_STRUCT_OFFSET (ConnectionsRdpPreferencesWindowPrivate, host_address_label));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "scale_mode_combo", FALSE, ConnectionsRdpPreferencesWindow_private_offset + G_STRUCT_OFFSET (ConnectionsRdpPreferencesWindowPrivate, scale_mode_combo));
}

static void
connections_rdp_preferences_window_instance_init (ConnectionsRdpPreferencesWindow * self,
                                                  gpointer klass)
{
	self->priv = connections_rdp_preferences_window_get_instance_private (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
connections_rdp_preferences_window_finalize (GObject * obj)
{
	ConnectionsRdpPreferencesWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CONNECTIONS_TYPE_RDP_PREFERENCES_WINDOW, ConnectionsRdpPreferencesWindow);
	G_OBJECT_CLASS (connections_rdp_preferences_window_parent_class)->finalize (obj);
}

static GType
connections_rdp_preferences_window_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ConnectionsRdpPreferencesWindowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) connections_rdp_preferences_window_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ConnectionsRdpPreferencesWindow), 0, (GInstanceInitFunc) connections_rdp_preferences_window_instance_init, NULL };
	GType connections_rdp_preferences_window_type_id;
	connections_rdp_preferences_window_type_id = g_type_register_static (CONNECTIONS_TYPE_PREFERENCES_WINDOW, "ConnectionsRdpPreferencesWindow", &g_define_type_info, 0);
	ConnectionsRdpPreferencesWindow_private_offset = g_type_add_instance_private (connections_rdp_preferences_window_type_id, sizeof (ConnectionsRdpPreferencesWindowPrivate));
	return connections_rdp_preferences_window_type_id;
}

GType
connections_rdp_preferences_window_get_type (void)
{
	static volatile gsize connections_rdp_preferences_window_type_id__once = 0;
	if (g_once_init_enter (&connections_rdp_preferences_window_type_id__once)) {
		GType connections_rdp_preferences_window_type_id;
		connections_rdp_preferences_window_type_id = connections_rdp_preferences_window_get_type_once ();
		g_once_init_leave (&connections_rdp_preferences_window_type_id__once, connections_rdp_preferences_window_type_id);
	}
	return connections_rdp_preferences_window_type_id__once;
}

