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

#include <gtk/gtk.h>
#include <glib-object.h>
#include "libdino.h"
#include <gee.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include "dino_i18n.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 DINO_UI_CHAT_INPUT_TYPE_VIEW (dino_ui_chat_input_view_get_type ())
#define DINO_UI_CHAT_INPUT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DINO_UI_CHAT_INPUT_TYPE_VIEW, DinoUiChatInputView))
#define DINO_UI_CHAT_INPUT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DINO_UI_CHAT_INPUT_TYPE_VIEW, DinoUiChatInputViewClass))
#define DINO_UI_CHAT_INPUT_IS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DINO_UI_CHAT_INPUT_TYPE_VIEW))
#define DINO_UI_CHAT_INPUT_IS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DINO_UI_CHAT_INPUT_TYPE_VIEW))
#define DINO_UI_CHAT_INPUT_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DINO_UI_CHAT_INPUT_TYPE_VIEW, DinoUiChatInputViewClass))

typedef struct _DinoUiChatInputView DinoUiChatInputView;
typedef struct _DinoUiChatInputViewClass DinoUiChatInputViewClass;
typedef struct _DinoUiChatInputViewPrivate DinoUiChatInputViewPrivate;

#define DINO_UI_TYPE_CHAT_TEXT_VIEW (dino_ui_chat_text_view_get_type ())
#define DINO_UI_CHAT_TEXT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DINO_UI_TYPE_CHAT_TEXT_VIEW, DinoUiChatTextView))
#define DINO_UI_CHAT_TEXT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DINO_UI_TYPE_CHAT_TEXT_VIEW, DinoUiChatTextViewClass))
#define DINO_UI_IS_CHAT_TEXT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DINO_UI_TYPE_CHAT_TEXT_VIEW))
#define DINO_UI_IS_CHAT_TEXT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DINO_UI_TYPE_CHAT_TEXT_VIEW))
#define DINO_UI_CHAT_TEXT_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DINO_UI_TYPE_CHAT_TEXT_VIEW, DinoUiChatTextViewClass))

typedef struct _DinoUiChatTextView DinoUiChatTextView;
typedef struct _DinoUiChatTextViewClass DinoUiChatTextViewClass;

#define DINO_UI_TYPE_ENCRYPTION_BUTTON (dino_ui_encryption_button_get_type ())
#define DINO_UI_ENCRYPTION_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DINO_UI_TYPE_ENCRYPTION_BUTTON, DinoUiEncryptionButton))
#define DINO_UI_ENCRYPTION_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DINO_UI_TYPE_ENCRYPTION_BUTTON, DinoUiEncryptionButtonClass))
#define DINO_UI_IS_ENCRYPTION_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DINO_UI_TYPE_ENCRYPTION_BUTTON))
#define DINO_UI_IS_ENCRYPTION_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DINO_UI_TYPE_ENCRYPTION_BUTTON))
#define DINO_UI_ENCRYPTION_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DINO_UI_TYPE_ENCRYPTION_BUTTON, DinoUiEncryptionButtonClass))

typedef struct _DinoUiEncryptionButton DinoUiEncryptionButton;
typedef struct _DinoUiEncryptionButtonClass DinoUiEncryptionButtonClass;
enum  {
	DINO_UI_CHAT_INPUT_VIEW_0_PROPERTY,
	DINO_UI_CHAT_INPUT_VIEW_TEXT_PROPERTY,
	DINO_UI_CHAT_INPUT_VIEW_NUM_PROPERTIES
};
static GParamSpec* dino_ui_chat_input_view_properties[DINO_UI_CHAT_INPUT_VIEW_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _dino_ui_encryption_button_unref0(var) ((var == NULL) ? NULL : (var = (dino_ui_encryption_button_unref (var), NULL)))
typedef struct _DinoUiChatTextViewPrivate DinoUiChatTextViewPrivate;
#define _g_free0(var) (var = (g_free (var), NULL))

struct _DinoUiChatInputView {
	GtkBox parent_instance;
	DinoUiChatInputViewPrivate * priv;
	GtkFrame* frame;
	GtkBox* quote_box;
	DinoUiChatTextView* chat_text_view;
	GtkButton* file_button;
	GtkMenuButton* emoji_button;
	GtkMenuButton* encryption_button;
	GtkSeparator* file_separator;
	GtkLabel* chat_input_status;
	DinoUiEncryptionButton* encryption_widget;
};

struct _DinoUiChatInputViewClass {
	GtkBoxClass parent_class;
};

struct _DinoUiChatInputViewPrivate {
	DinoStreamInteractor* stream_interactor;
	DinoEntitiesConversation* conversation;
	GeeHashMap* entry_cache;
};

struct _DinoUiChatTextView {
	GtkBox parent_instance;
	DinoUiChatTextViewPrivate * priv;
	GtkScrolledWindow* scrolled_window;
	GtkTextView* text_view;
};

struct _DinoUiChatTextViewClass {
	GtkBoxClass parent_class;
};

static gint DinoUiChatInputView_private_offset;
static gpointer dino_ui_chat_input_view_parent_class = NULL;

VALA_EXTERN GType dino_ui_chat_input_view_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DinoUiChatInputView, g_object_unref)
VALA_EXTERN GType dino_ui_chat_text_view_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DinoUiChatTextView, g_object_unref)
VALA_EXTERN gpointer dino_ui_encryption_button_ref (gpointer instance);
VALA_EXTERN void dino_ui_encryption_button_unref (gpointer instance);
VALA_EXTERN GParamSpec* dino_ui_param_spec_encryption_button (const gchar* name,
                                                  const gchar* nick,
                                                  const gchar* blurb,
                                                  GType object_type,
                                                  GParamFlags flags);
VALA_EXTERN void dino_ui_value_set_encryption_button (GValue* value,
                                          gpointer v_object);
VALA_EXTERN void dino_ui_value_take_encryption_button (GValue* value,
                                           gpointer v_object);
VALA_EXTERN gpointer dino_ui_value_get_encryption_button (const GValue* value);
VALA_EXTERN GType dino_ui_encryption_button_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DinoUiEncryptionButton, dino_ui_encryption_button_unref)
static guint _dino_entities_conversation_hash_func_gee_hash_data_func (gconstpointer v,
                                                                gpointer self);
static gboolean _dino_entities_conversation_equals_func_gee_equal_data_func (gconstpointer a,
                                                                      gconstpointer b,
                                                                      gpointer self);
VALA_EXTERN DinoUiChatInputView* dino_ui_chat_input_view_init (DinoUiChatInputView* self,
                                                   DinoStreamInteractor* stream_interactor);
VALA_EXTERN DinoUiEncryptionButton* dino_ui_encryption_button_new (DinoStreamInteractor* stream_interactor,
                                                       GtkMenuButton* menu_button);
VALA_EXTERN DinoUiEncryptionButton* dino_ui_encryption_button_construct (GType object_type,
                                                             DinoStreamInteractor* stream_interactor,
                                                             GtkMenuButton* menu_button);
static void __lambda9_ (DinoUiChatInputView* self,
                 const gchar* emoji);
static void ___lambda9__gtk_emoji_chooser_emoji_picked (GtkEmojiChooser* _sender,
                                                 const gchar* text,
                                                 gpointer self);
VALA_EXTERN void dino_ui_chat_input_view_do_focus (DinoUiChatInputView* self);
static void _dino_ui_chat_input_view_do_focus_gtk_popover_closed (GtkPopover* _sender,
                                                           gpointer self);
VALA_EXTERN gchar* dino_ui_util_string_if_tooltips_active (const gchar* s);
VALA_EXTERN GtkCssProvider* dino_ui_util_force_css (GtkWidget* widget,
                                        const gchar* css);
VALA_EXTERN void dino_ui_chat_input_view_set_file_upload_active (DinoUiChatInputView* self,
                                                     gboolean active);
VALA_EXTERN void dino_ui_chat_input_view_initialize_for_conversation (DinoUiChatInputView* self,
                                                          DinoEntitiesConversation* conversation);
VALA_EXTERN void dino_ui_chat_input_view_set_input_state (DinoUiChatInputView* self,
                                              DinoPluginsInputFieldStatusMessageType message_type);
VALA_EXTERN void dino_ui_chat_input_view_highlight_state_description (DinoUiChatInputView* self);
static gboolean __lambda10_ (DinoUiChatInputView* self);
static gboolean ___lambda10__gsource_func (gpointer self);
VALA_EXTERN void dino_ui_chat_input_view_set_quoted_message (DinoUiChatInputView* self,
                                                 GtkWidget* quote_widget);
VALA_EXTERN void dino_ui_chat_input_view_unset_quoted_message (DinoUiChatInputView* self);
VALA_EXTERN DinoUiChatInputView* dino_ui_chat_input_view_new (void);
VALA_EXTERN DinoUiChatInputView* dino_ui_chat_input_view_construct (GType object_type);
VALA_EXTERN gchar* dino_ui_chat_input_view_get_text (DinoUiChatInputView* self);
VALA_EXTERN void dino_ui_chat_input_view_set_text (DinoUiChatInputView* self,
                                       const gchar* value);
static void dino_ui_chat_input_view_finalize (GObject * obj);
static GType dino_ui_chat_input_view_get_type_once (void);
static void _vala_dino_ui_chat_input_view_get_property (GObject * object,
                                                 guint property_id,
                                                 GValue * value,
                                                 GParamSpec * pspec);
static void _vala_dino_ui_chat_input_view_set_property (GObject * object,
                                                 guint property_id,
                                                 const GValue * value,
                                                 GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
dino_ui_chat_input_view_get_instance_private (DinoUiChatInputView* self)
{
	return G_STRUCT_MEMBER_P (self, DinoUiChatInputView_private_offset);
}

static guint
_dino_entities_conversation_hash_func_gee_hash_data_func (gconstpointer v,
                                                          gpointer self)
{
	guint result;
	result = dino_entities_conversation_hash_func ((DinoEntitiesConversation*) v);
	return result;
}

static gboolean
_dino_entities_conversation_equals_func_gee_equal_data_func (gconstpointer a,
                                                             gconstpointer b,
                                                             gpointer self)
{
	gboolean result;
	result = dino_entities_conversation_equals_func ((DinoEntitiesConversation*) a, (DinoEntitiesConversation*) b);
	return result;
}

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

static guint8*
string_get_data (const gchar* self,
                 gint* result_length1)
{
	guint8* result;
	guint8* res = NULL;
	gint res_length1;
	gint _res_size_;
	gint _tmp0_;
	gint _tmp1_;
	guint8* _tmp2_;
	gint _tmp2__length1;
	g_return_val_if_fail (self != NULL, NULL);
	res = (guint8*) self;
	res_length1 = -1;
	_res_size_ = res_length1;
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	res_length1 = (gint) _tmp1_;
	_tmp2_ = res;
	_tmp2__length1 = res_length1;
	if (result_length1) {
		*result_length1 = _tmp2__length1;
	}
	result = _tmp2_;
	return result;
}

static void
__lambda9_ (DinoUiChatInputView* self,
            const gchar* emoji)
{
	DinoUiChatTextView* _tmp0_;
	GtkTextView* _tmp1_;
	GtkTextBuffer* _tmp2_;
	GtkTextBuffer* _tmp3_;
	guint8* _tmp4_;
	gint _tmp4__length1;
	gint _tmp5_ = 0;
	guint8* _tmp6_;
	gint _tmp6__length1;
	g_return_if_fail (emoji != NULL);
	_tmp0_ = self->chat_text_view;
	_tmp1_ = _tmp0_->text_view;
	_tmp2_ = gtk_text_view_get_buffer (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = string_get_data (emoji, &_tmp5_);
	_tmp4__length1 = _tmp5_;
	_tmp6_ = _tmp4_;
	_tmp6__length1 = _tmp4__length1;
	gtk_text_buffer_insert_at_cursor (_tmp3_, emoji, _tmp6__length1);
}

static void
___lambda9__gtk_emoji_chooser_emoji_picked (GtkEmojiChooser* _sender,
                                            const gchar* text,
                                            gpointer self)
{
	__lambda9_ ((DinoUiChatInputView*) self, text);
}

static void
_dino_ui_chat_input_view_do_focus_gtk_popover_closed (GtkPopover* _sender,
                                                      gpointer self)
{
	dino_ui_chat_input_view_do_focus ((DinoUiChatInputView*) self);
}

DinoUiChatInputView*
dino_ui_chat_input_view_init (DinoUiChatInputView* self,
                              DinoStreamInteractor* stream_interactor)
{
	DinoStreamInteractor* _tmp0_;
	GtkMenuButton* _tmp1_;
	DinoUiEncryptionButton* _tmp2_;
	GtkEmojiChooser* chooser = NULL;
	GtkEmojiChooser* _tmp3_;
	GtkMenuButton* _tmp4_;
	GtkButton* _tmp5_;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	GtkFrame* _tmp9_;
	GtkCssProvider* _tmp10_;
	GtkCssProvider* _tmp11_;
	DinoUiChatInputView* _tmp12_;
	DinoUiChatInputView* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (stream_interactor != NULL, NULL);
	_tmp0_ = _g_object_ref0 (stream_interactor);
	_g_object_unref0 (self->priv->stream_interactor);
	self->priv->stream_interactor = _tmp0_;
	_tmp1_ = self->encryption_button;
	_tmp2_ = dino_ui_encryption_button_new (stream_interactor, _tmp1_);
	_dino_ui_encryption_button_unref0 (self->encryption_widget);
	self->encryption_widget = _tmp2_;
	_tmp3_ = (GtkEmojiChooser*) gtk_emoji_chooser_new ();
	g_object_ref_sink (_tmp3_);
	chooser = _tmp3_;
	g_signal_connect_object (chooser, "emoji-picked", (GCallback) ___lambda9__gtk_emoji_chooser_emoji_picked, self, 0);
	g_signal_connect_object ((GtkPopover*) chooser, "closed", (GCallback) _dino_ui_chat_input_view_do_focus_gtk_popover_closed, self, 0);
	_tmp4_ = self->emoji_button;
	gtk_menu_button_set_popover (_tmp4_, (GtkPopover*) chooser);
	_tmp5_ = self->file_button;
	_tmp6_ = dino_gettext ("Send a file");
	_tmp7_ = dino_ui_util_string_if_tooltips_active (_tmp6_);
	_tmp8_ = _tmp7_;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp5_, _tmp8_);
	_g_free0 (_tmp8_);
	_tmp9_ = self->frame;
	_tmp10_ = dino_ui_util_force_css ((GtkWidget*) _tmp9_, "* { border-radius: 3px; }");
	_tmp11_ = _tmp10_;
	_g_object_unref0 (_tmp11_);
	_tmp12_ = _g_object_ref0 (self);
	result = _tmp12_;
	_g_object_unref0 (chooser);
	return result;
}

void
dino_ui_chat_input_view_set_file_upload_active (DinoUiChatInputView* self,
                                                gboolean active)
{
	GtkButton* _tmp0_;
	GtkSeparator* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->file_button;
	gtk_widget_set_visible ((GtkWidget*) _tmp0_, active);
	_tmp1_ = self->file_separator;
	gtk_widget_set_visible ((GtkWidget*) _tmp1_, active);
}

void
dino_ui_chat_input_view_initialize_for_conversation (DinoUiChatInputView* self,
                                                     DinoEntitiesConversation* conversation)
{
	DinoEntitiesConversation* _tmp0_;
	DinoEntitiesConversation* _tmp10_;
	DinoUiChatTextView* _tmp11_;
	GtkTextView* _tmp12_;
	GtkTextBuffer* _tmp13_;
	GtkTextBuffer* _tmp14_;
	GeeHashMap* _tmp15_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (conversation != NULL);
	_tmp0_ = self->priv->conversation;
	if (_tmp0_ != NULL) {
		GeeHashMap* _tmp1_;
		DinoEntitiesConversation* _tmp2_;
		DinoUiChatTextView* _tmp3_;
		GtkTextView* _tmp4_;
		GtkTextBuffer* _tmp5_;
		GtkTextBuffer* _tmp6_;
		gchar* _tmp7_;
		gchar* _tmp8_;
		gchar* _tmp9_;
		_tmp1_ = self->priv->entry_cache;
		_tmp2_ = self->priv->conversation;
		_tmp3_ = self->chat_text_view;
		_tmp4_ = _tmp3_->text_view;
		_tmp5_ = gtk_text_view_get_buffer (_tmp4_);
		_tmp6_ = _tmp5_;
		g_object_get (_tmp6_, "text", &_tmp7_, NULL);
		_tmp8_ = _tmp7_;
		_tmp9_ = _tmp8_;
		gee_abstract_map_set ((GeeAbstractMap*) _tmp1_, _tmp2_, _tmp9_);
		_g_free0 (_tmp9_);
	}
	_tmp10_ = _g_object_ref0 (conversation);
	_g_object_unref0 (self->priv->conversation);
	self->priv->conversation = _tmp10_;
	_tmp11_ = self->chat_text_view;
	_tmp12_ = _tmp11_->text_view;
	_tmp13_ = gtk_text_view_get_buffer (_tmp12_);
	_tmp14_ = _tmp13_;
	g_object_set (_tmp14_, "text", "", NULL);
	_tmp15_ = self->priv->entry_cache;
	if (gee_abstract_map_has_key ((GeeAbstractMap*) _tmp15_, conversation)) {
		DinoUiChatTextView* _tmp16_;
		GtkTextView* _tmp17_;
		GtkTextBuffer* _tmp18_;
		GtkTextBuffer* _tmp19_;
		GeeHashMap* _tmp20_;
		gpointer _tmp21_;
		gchar* _tmp22_;
		_tmp16_ = self->chat_text_view;
		_tmp17_ = _tmp16_->text_view;
		_tmp18_ = gtk_text_view_get_buffer (_tmp17_);
		_tmp19_ = _tmp18_;
		_tmp20_ = self->priv->entry_cache;
		_tmp21_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp20_, conversation);
		_tmp22_ = (gchar*) _tmp21_;
		g_object_set (_tmp19_, "text", _tmp22_, NULL);
		_g_free0 (_tmp22_);
	}
	dino_ui_chat_input_view_do_focus (self);
}

void
dino_ui_chat_input_view_set_input_state (DinoUiChatInputView* self,
                                         DinoPluginsInputFieldStatusMessageType message_type)
{
	g_return_if_fail (self != NULL);
	switch (message_type) {
		case DINO_PLUGINS_INPUT_FIELD_STATUS_MESSAGE_TYPE_NONE:
		{
			gtk_widget_remove_css_class ((GtkWidget*) self, "dino-input-warning");
			gtk_widget_remove_css_class ((GtkWidget*) self, "dino-input-error");
			break;
		}
		case DINO_PLUGINS_INPUT_FIELD_STATUS_MESSAGE_TYPE_INFO:
		{
			gtk_widget_remove_css_class ((GtkWidget*) self, "dino-input-warning");
			gtk_widget_remove_css_class ((GtkWidget*) self, "dino-input-error");
			break;
		}
		case DINO_PLUGINS_INPUT_FIELD_STATUS_MESSAGE_TYPE_WARNING:
		{
			gtk_widget_add_css_class ((GtkWidget*) self, "dino-input-warning");
			gtk_widget_remove_css_class ((GtkWidget*) self, "dino-input-error");
			break;
		}
		case DINO_PLUGINS_INPUT_FIELD_STATUS_MESSAGE_TYPE_ERROR:
		{
			gtk_widget_remove_css_class ((GtkWidget*) self, "dino-input-warning");
			gtk_widget_add_css_class ((GtkWidget*) self, "dino-input-error");
			break;
		}
		default:
		break;
	}
}

static gboolean
__lambda10_ (DinoUiChatInputView* self)
{
	GtkLabel* _tmp0_;
	gboolean result;
	_tmp0_ = self->chat_input_status;
	gtk_widget_remove_css_class ((GtkWidget*) _tmp0_, "input-status-highlight-once");
	result = FALSE;
	return result;
}

static gboolean
___lambda10__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda10_ ((DinoUiChatInputView*) self);
	return result;
}

void
dino_ui_chat_input_view_highlight_state_description (DinoUiChatInputView* self)
{
	GtkLabel* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->chat_input_status;
	gtk_widget_add_css_class ((GtkWidget*) _tmp0_, "input-status-highlight-once");
	g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 500, ___lambda10__gsource_func, g_object_ref (self), g_object_unref);
}

void
dino_ui_chat_input_view_set_quoted_message (DinoUiChatInputView* self,
                                            GtkWidget* quote_widget)
{
	GtkWidget* quote_box_child = NULL;
	GtkBox* _tmp0_;
	GtkWidget* _tmp1_;
	GtkWidget* _tmp2_;
	GtkWidget* _tmp3_;
	GtkBox* _tmp6_;
	GtkBox* _tmp7_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (quote_widget != NULL);
	_tmp0_ = self->quote_box;
	_tmp1_ = gtk_widget_get_first_child ((GtkWidget*) _tmp0_);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	quote_box_child = _tmp2_;
	_tmp3_ = quote_box_child;
	if (_tmp3_ != NULL) {
		GtkBox* _tmp4_;
		GtkWidget* _tmp5_;
		_tmp4_ = self->quote_box;
		_tmp5_ = quote_box_child;
		gtk_box_remove (_tmp4_, _tmp5_);
	}
	_tmp6_ = self->quote_box;
	gtk_box_append (_tmp6_, quote_widget);
	_tmp7_ = self->quote_box;
	gtk_widget_set_visible ((GtkWidget*) _tmp7_, TRUE);
	_g_object_unref0 (quote_box_child);
}

void
dino_ui_chat_input_view_unset_quoted_message (DinoUiChatInputView* self)
{
	GtkWidget* quote_box_child = NULL;
	GtkBox* _tmp0_;
	GtkWidget* _tmp1_;
	GtkWidget* _tmp2_;
	GtkWidget* _tmp3_;
	GtkBox* _tmp6_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->quote_box;
	_tmp1_ = gtk_widget_get_first_child ((GtkWidget*) _tmp0_);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	quote_box_child = _tmp2_;
	_tmp3_ = quote_box_child;
	if (_tmp3_ != NULL) {
		GtkBox* _tmp4_;
		GtkWidget* _tmp5_;
		_tmp4_ = self->quote_box;
		_tmp5_ = quote_box_child;
		gtk_box_remove (_tmp4_, _tmp5_);
	}
	_tmp6_ = self->quote_box;
	gtk_widget_set_visible ((GtkWidget*) _tmp6_, FALSE);
	_g_object_unref0 (quote_box_child);
}

void
dino_ui_chat_input_view_do_focus (DinoUiChatInputView* self)
{
	DinoUiChatTextView* _tmp0_;
	GtkTextView* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->chat_text_view;
	_tmp1_ = _tmp0_->text_view;
	gtk_widget_grab_focus ((GtkWidget*) _tmp1_);
}

DinoUiChatInputView*
dino_ui_chat_input_view_construct (GType object_type)
{
	DinoUiChatInputView * self = NULL;
	self = (DinoUiChatInputView*) g_object_new (object_type, NULL);
	return self;
}

DinoUiChatInputView*
dino_ui_chat_input_view_new (void)
{
	return dino_ui_chat_input_view_construct (DINO_UI_CHAT_INPUT_TYPE_VIEW);
}

gchar*
dino_ui_chat_input_view_get_text (DinoUiChatInputView* self)
{
	gchar* result;
	DinoUiChatTextView* _tmp0_;
	GtkTextView* _tmp1_;
	GtkTextBuffer* _tmp2_;
	GtkTextBuffer* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->chat_text_view;
	_tmp1_ = _tmp0_->text_view;
	_tmp2_ = gtk_text_view_get_buffer (_tmp1_);
	_tmp3_ = _tmp2_;
	g_object_get (_tmp3_, "text", &_tmp4_, NULL);
	_tmp5_ = _tmp4_;
	result = _tmp5_;
	return result;
}

void
dino_ui_chat_input_view_set_text (DinoUiChatInputView* self,
                                  const gchar* value)
{
	DinoUiChatTextView* _tmp0_;
	GtkTextView* _tmp1_;
	GtkTextBuffer* _tmp2_;
	GtkTextBuffer* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->chat_text_view;
	_tmp1_ = _tmp0_->text_view;
	_tmp2_ = gtk_text_view_get_buffer (_tmp1_);
	_tmp3_ = _tmp2_;
	g_object_set (_tmp3_, "text", value, NULL);
	g_object_notify_by_pspec ((GObject *) self, dino_ui_chat_input_view_properties[DINO_UI_CHAT_INPUT_VIEW_TEXT_PROPERTY]);
}

static void
dino_ui_chat_input_view_class_init (DinoUiChatInputViewClass * klass,
                                    gpointer klass_data)
{
	dino_ui_chat_input_view_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DinoUiChatInputView_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_dino_ui_chat_input_view_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_dino_ui_chat_input_view_set_property;
	G_OBJECT_CLASS (klass)->finalize = dino_ui_chat_input_view_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_UI_CHAT_INPUT_VIEW_TEXT_PROPERTY, dino_ui_chat_input_view_properties[DINO_UI_CHAT_INPUT_VIEW_TEXT_PROPERTY] = g_param_spec_string ("text", "text", "text", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/im/dino/Dino/chat_input.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "frame", FALSE, G_STRUCT_OFFSET (DinoUiChatInputView, frame));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "quote_box", FALSE, G_STRUCT_OFFSET (DinoUiChatInputView, quote_box));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "chat_text_view", FALSE, G_STRUCT_OFFSET (DinoUiChatInputView, chat_text_view));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "file_button", FALSE, G_STRUCT_OFFSET (DinoUiChatInputView, file_button));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "emoji_button", FALSE, G_STRUCT_OFFSET (DinoUiChatInputView, emoji_button));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "encryption_button", FALSE, G_STRUCT_OFFSET (DinoUiChatInputView, encryption_button));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "file_separator", FALSE, G_STRUCT_OFFSET (DinoUiChatInputView, file_separator));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "chat_input_status", FALSE, G_STRUCT_OFFSET (DinoUiChatInputView, chat_input_status));
}

static void
dino_ui_chat_input_view_instance_init (DinoUiChatInputView * self,
                                       gpointer klass)
{
	GeeHashMap* _tmp0_;
	self->priv = dino_ui_chat_input_view_get_instance_private (self);
	_tmp0_ = gee_hash_map_new (DINO_ENTITIES_TYPE_CONVERSATION, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _dino_entities_conversation_hash_func_gee_hash_data_func, NULL, NULL, _dino_entities_conversation_equals_func_gee_equal_data_func, NULL, NULL, NULL, NULL, NULL);
	self->priv->entry_cache = _tmp0_;
	g_type_ensure (DINO_UI_TYPE_CHAT_TEXT_VIEW);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
dino_ui_chat_input_view_finalize (GObject * obj)
{
	DinoUiChatInputView * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_UI_CHAT_INPUT_TYPE_VIEW, DinoUiChatInputView);
	_g_object_unref0 (self->priv->stream_interactor);
	_g_object_unref0 (self->priv->conversation);
	_g_object_unref0 (self->priv->entry_cache);
	_dino_ui_encryption_button_unref0 (self->encryption_widget);
	G_OBJECT_CLASS (dino_ui_chat_input_view_parent_class)->finalize (obj);
}

static GType
dino_ui_chat_input_view_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoUiChatInputViewClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_ui_chat_input_view_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoUiChatInputView), 0, (GInstanceInitFunc) dino_ui_chat_input_view_instance_init, NULL };
	GType dino_ui_chat_input_view_type_id;
	dino_ui_chat_input_view_type_id = g_type_register_static (gtk_box_get_type (), "DinoUiChatInputView", &g_define_type_info, 0);
	DinoUiChatInputView_private_offset = g_type_add_instance_private (dino_ui_chat_input_view_type_id, sizeof (DinoUiChatInputViewPrivate));
	return dino_ui_chat_input_view_type_id;
}

GType
dino_ui_chat_input_view_get_type (void)
{
	static volatile gsize dino_ui_chat_input_view_type_id__once = 0;
	if (g_once_init_enter (&dino_ui_chat_input_view_type_id__once)) {
		GType dino_ui_chat_input_view_type_id;
		dino_ui_chat_input_view_type_id = dino_ui_chat_input_view_get_type_once ();
		g_once_init_leave (&dino_ui_chat_input_view_type_id__once, dino_ui_chat_input_view_type_id);
	}
	return dino_ui_chat_input_view_type_id__once;
}

static void
_vala_dino_ui_chat_input_view_get_property (GObject * object,
                                            guint property_id,
                                            GValue * value,
                                            GParamSpec * pspec)
{
	DinoUiChatInputView * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DINO_UI_CHAT_INPUT_TYPE_VIEW, DinoUiChatInputView);
	switch (property_id) {
		case DINO_UI_CHAT_INPUT_VIEW_TEXT_PROPERTY:
		g_value_take_string (value, dino_ui_chat_input_view_get_text (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_dino_ui_chat_input_view_set_property (GObject * object,
                                            guint property_id,
                                            const GValue * value,
                                            GParamSpec * pspec)
{
	DinoUiChatInputView * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DINO_UI_CHAT_INPUT_TYPE_VIEW, DinoUiChatInputView);
	switch (property_id) {
		case DINO_UI_CHAT_INPUT_VIEW_TEXT_PROPERTY:
		dino_ui_chat_input_view_set_text (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

