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

#include "pantheon-files-core.h"
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <glib-object.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

enum  {
	FILES_SINGLE_LINE_EDITABLE_LABEL_0_PROPERTY,
	FILES_SINGLE_LINE_EDITABLE_LABEL_NUM_PROPERTIES
};
static GParamSpec* files_single_line_editable_label_properties[FILES_SINGLE_LINE_EDITABLE_LABEL_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _FilesSingleLineEditableLabelPrivate {
	gint select_start;
	gint select_end;
};

static gint FilesSingleLineEditableLabel_private_offset;
static gpointer files_single_line_editable_label_parent_class = NULL;

static void files_single_line_editable_label_real_set_text (FilesAbstractEditableLabel* base,
                                                     const gchar* text);
static void files_single_line_editable_label_real_set_justify (FilesAbstractEditableLabel* base,
                                                        GtkJustification jtype);
static gchar* files_single_line_editable_label_real_get_text (FilesAbstractEditableLabel* base);
static gboolean files_single_line_editable_label_real_on_key_press_event (FilesAbstractEditableLabel* base,
                                                                   guint keyval,
                                                                   guint keycode,
                                                                   GdkModifierType state);
static void files_single_line_editable_label_real_select_region (FilesAbstractEditableLabel* base,
                                                          gint start_pos,
                                                          gint end_pos);
static void files_single_line_editable_label_real_do_delete_text (FilesAbstractEditableLabel* base,
                                                           gint start_pos,
                                                           gint end_pos);
static void files_single_line_editable_label_real_do_insert_text (FilesAbstractEditableLabel* base,
                                                           const gchar* new_text,
                                                           gint new_text_length,
                                                           gint* position);
static gchar* files_single_line_editable_label_real_get_chars (FilesAbstractEditableLabel* base,
                                                        gint start_pos,
                                                        gint end_pos);
static gint files_single_line_editable_label_real_get_position (FilesAbstractEditableLabel* base);
static gboolean files_single_line_editable_label_real_get_selection_bounds (FilesAbstractEditableLabel* base,
                                                                     gint* start_pos,
                                                                     gint* end_pos);
static void files_single_line_editable_label_real_set_position (FilesAbstractEditableLabel* base,
                                                         gint position);
static void files_single_line_editable_label_real_set_size_request (FilesAbstractEditableLabel* base,
                                                             gint width,
                                                             gint height);
static void files_single_line_editable_label_real_start_editing (FilesAbstractEditableLabel* base,
                                                          GdkEvent* event);
static GObject * files_single_line_editable_label_constructor (GType type,
                                                        guint n_construct_properties,
                                                        GObjectConstructParam * construct_properties);
static void files_single_line_editable_label_finalize (GObject * obj);
static GType files_single_line_editable_label_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
files_single_line_editable_label_get_instance_private (FilesSingleLineEditableLabel* self)
{
	return G_STRUCT_MEMBER_P (self, FilesSingleLineEditableLabel_private_offset);
}

static void
files_single_line_editable_label_real_set_text (FilesAbstractEditableLabel* base,
                                                const gchar* text)
{
	FilesSingleLineEditableLabel * self;
	GtkEntry* _tmp0_;
	gchar* _tmp1_;
	self = (FilesSingleLineEditableLabel*) base;
	g_return_if_fail (text != NULL);
	_tmp0_ = self->textview;
	gtk_entry_set_text (_tmp0_, text);
	_tmp1_ = g_strdup (text);
	_g_free0 (((FilesAbstractEditableLabel*) self)->original_name);
	((FilesAbstractEditableLabel*) self)->original_name = _tmp1_;
}

static void
files_single_line_editable_label_real_set_justify (FilesAbstractEditableLabel* base,
                                                   GtkJustification jtype)
{
	FilesSingleLineEditableLabel * self;
	self = (FilesSingleLineEditableLabel*) base;
	switch (jtype) {
		case GTK_JUSTIFY_LEFT:
		{
			GtkEntry* _tmp0_;
			_tmp0_ = self->textview;
			gtk_entry_set_alignment (_tmp0_, 0.0f);
			break;
		}
		case GTK_JUSTIFY_CENTER:
		{
			GtkEntry* _tmp1_;
			_tmp1_ = self->textview;
			gtk_entry_set_alignment (_tmp1_, 0.5f);
			break;
		}
		case GTK_JUSTIFY_RIGHT:
		{
			GtkEntry* _tmp2_;
			_tmp2_ = self->textview;
			gtk_entry_set_alignment (_tmp2_, 1.0f);
			break;
		}
		default:
		{
			GtkEntry* _tmp3_;
			_tmp3_ = self->textview;
			gtk_entry_set_alignment (_tmp3_, 0.5f);
			break;
		}
	}
}

static gchar*
files_single_line_editable_label_real_get_text (FilesAbstractEditableLabel* base)
{
	FilesSingleLineEditableLabel * self;
	GtkEntry* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* result;
	self = (FilesSingleLineEditableLabel*) base;
	_tmp0_ = self->textview;
	_tmp1_ = gtk_entry_get_text (_tmp0_);
	_tmp2_ = g_strdup (_tmp1_);
	result = _tmp2_;
	return result;
}

static gboolean
files_single_line_editable_label_real_on_key_press_event (FilesAbstractEditableLabel* base,
                                                          guint keyval,
                                                          guint keycode,
                                                          GdkModifierType state)
{
	FilesSingleLineEditableLabel * self;
	gboolean result;
	self = (FilesSingleLineEditableLabel*) base;
	switch (keyval) {
		case GDK_KEY_Up:
		case GDK_KEY_Down:
		{
			files_abstract_editable_label_end_editing ((FilesAbstractEditableLabel*) self, TRUE);
			result = TRUE;
			return result;
		}
		default:
		{
			break;
		}
	}
	result = FILES_ABSTRACT_EDITABLE_LABEL_CLASS (files_single_line_editable_label_parent_class)->on_key_press_event (G_TYPE_CHECK_INSTANCE_CAST (self, FILES_TYPE_ABSTRACT_EDITABLE_LABEL, FilesAbstractEditableLabel), keyval, keycode, state);
	return result;
}

/** Gtk.Editable interface */
static void
files_single_line_editable_label_real_select_region (FilesAbstractEditableLabel* base,
                                                     gint start_pos,
                                                     gint end_pos)
{
	FilesSingleLineEditableLabel * self;
	self = (FilesSingleLineEditableLabel*) base;
	self->priv->select_start = start_pos;
	self->priv->select_end = end_pos;
}

static void
files_single_line_editable_label_real_do_delete_text (FilesAbstractEditableLabel* base,
                                                      gint start_pos,
                                                      gint end_pos)
{
	FilesSingleLineEditableLabel * self;
	GtkEntry* _tmp0_;
	self = (FilesSingleLineEditableLabel*) base;
	_tmp0_ = self->textview;
	g_signal_emit_by_name ((GtkEditable*) _tmp0_, "delete-text", start_pos, end_pos);
}

static void
files_single_line_editable_label_real_do_insert_text (FilesAbstractEditableLabel* base,
                                                      const gchar* new_text,
                                                      gint new_text_length,
                                                      gint* position)
{
	FilesSingleLineEditableLabel * self;
	GtkEntry* _tmp0_;
	self = (FilesSingleLineEditableLabel*) base;
	g_return_if_fail (new_text != NULL);
	_tmp0_ = self->textview;
	g_signal_emit_by_name ((GtkEditable*) _tmp0_, "insert-text", new_text, new_text_length, position);
}

static gchar*
files_single_line_editable_label_real_get_chars (FilesAbstractEditableLabel* base,
                                                 gint start_pos,
                                                 gint end_pos)
{
	FilesSingleLineEditableLabel * self;
	GtkEntry* _tmp0_;
	gchar* _tmp1_;
	gchar* result;
	self = (FilesSingleLineEditableLabel*) base;
	_tmp0_ = self->textview;
	_tmp1_ = gtk_editable_get_chars ((GtkEditable*) _tmp0_, start_pos, end_pos);
	result = _tmp1_;
	return result;
}

static gint
files_single_line_editable_label_real_get_position (FilesAbstractEditableLabel* base)
{
	FilesSingleLineEditableLabel * self;
	GtkEntry* _tmp0_;
	gint result;
	self = (FilesSingleLineEditableLabel*) base;
	_tmp0_ = self->textview;
	result = gtk_editable_get_position ((GtkEditable*) _tmp0_);
	return result;
}

static gboolean
files_single_line_editable_label_real_get_selection_bounds (FilesAbstractEditableLabel* base,
                                                            gint* start_pos,
                                                            gint* end_pos)
{
	FilesSingleLineEditableLabel * self;
	gint _vala_start_pos = 0;
	gint _vala_end_pos = 0;
	gint start = 0;
	gint end = 0;
	gboolean _result_ = FALSE;
	GtkEntry* _tmp0_;
	gint _tmp1_ = 0;
	gint _tmp2_ = 0;
	gboolean _tmp3_;
	gboolean result;
	self = (FilesSingleLineEditableLabel*) base;
	_tmp0_ = self->textview;
	_tmp3_ = gtk_editable_get_selection_bounds ((GtkEditable*) _tmp0_, &_tmp1_, &_tmp2_);
	start = _tmp1_;
	end = _tmp2_;
	_result_ = _tmp3_;
	_vala_start_pos = start;
	_vala_end_pos = end;
	result = _result_;
	if (start_pos) {
		*start_pos = _vala_start_pos;
	}
	if (end_pos) {
		*end_pos = _vala_end_pos;
	}
	return result;
}

static void
files_single_line_editable_label_real_set_position (FilesAbstractEditableLabel* base,
                                                    gint position)
{
	FilesSingleLineEditableLabel * self;
	GtkEntry* _tmp0_;
	self = (FilesSingleLineEditableLabel*) base;
	_tmp0_ = self->textview;
	gtk_editable_set_position ((GtkEditable*) _tmp0_, position);
}

static void
files_single_line_editable_label_real_set_size_request (FilesAbstractEditableLabel* base,
                                                        gint width,
                                                        gint height)
{
	FilesSingleLineEditableLabel * self;
	GtkEntry* _tmp0_;
	self = (FilesSingleLineEditableLabel*) base;
	_tmp0_ = self->textview;
	gtk_widget_set_size_request ((GtkWidget*) _tmp0_, width, height);
}

static void
files_single_line_editable_label_real_start_editing (FilesAbstractEditableLabel* base,
                                                     GdkEvent* event)
{
	FilesSingleLineEditableLabel * self;
	GtkEntry* _tmp0_;
	GtkEntry* _tmp1_;
	self = (FilesSingleLineEditableLabel*) base;
	_tmp0_ = self->textview;
	gtk_widget_grab_focus ((GtkWidget*) _tmp0_);
	_tmp1_ = self->textview;
	gtk_editable_select_region ((GtkEditable*) _tmp1_, self->priv->select_start, self->priv->select_end);
}

FilesSingleLineEditableLabel*
files_single_line_editable_label_construct (GType object_type)
{
	FilesSingleLineEditableLabel * self = NULL;
	self = (FilesSingleLineEditableLabel*) files_abstract_editable_label_construct (object_type);
	return self;
}

FilesSingleLineEditableLabel*
files_single_line_editable_label_new (void)
{
	return files_single_line_editable_label_construct (FILES_TYPE_SINGLE_LINE_EDITABLE_LABEL);
}

static GObject *
files_single_line_editable_label_constructor (GType type,
                                              guint n_construct_properties,
                                              GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	FilesSingleLineEditableLabel * self;
	GtkEntry* _tmp0_;
	GtkEntry* _tmp1_;
	GtkEntry* _tmp2_;
	parent_class = G_OBJECT_CLASS (files_single_line_editable_label_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FILES_TYPE_SINGLE_LINE_EDITABLE_LABEL, FilesSingleLineEditableLabel);
	_tmp0_ = (GtkEntry*) gtk_entry_new ();
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->textview);
	self->textview = _tmp0_;
	_tmp1_ = self->textview;
	files_abstract_editable_label_connect_editable_widget ((FilesAbstractEditableLabel*) self, (GtkWidget*) _tmp1_);
	_tmp2_ = self->textview;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp2_);
	return obj;
}

static void
files_single_line_editable_label_class_init (FilesSingleLineEditableLabelClass * klass,
                                             gpointer klass_data)
{
	files_single_line_editable_label_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FilesSingleLineEditableLabel_private_offset);
	((FilesAbstractEditableLabelClass *) klass)->set_text = (void (*) (FilesAbstractEditableLabel*, const gchar*)) files_single_line_editable_label_real_set_text;
	((FilesAbstractEditableLabelClass *) klass)->set_justify = (void (*) (FilesAbstractEditableLabel*, GtkJustification)) files_single_line_editable_label_real_set_justify;
	((FilesAbstractEditableLabelClass *) klass)->get_text = (gchar* (*) (FilesAbstractEditableLabel*)) files_single_line_editable_label_real_get_text;
	((FilesAbstractEditableLabelClass *) klass)->on_key_press_event = (gboolean (*) (FilesAbstractEditableLabel*, guint, guint, GdkModifierType)) files_single_line_editable_label_real_on_key_press_event;
	((FilesAbstractEditableLabelClass *) klass)->select_region = (void (*) (FilesAbstractEditableLabel*, gint, gint)) files_single_line_editable_label_real_select_region;
	((FilesAbstractEditableLabelClass *) klass)->do_delete_text = (void (*) (FilesAbstractEditableLabel*, gint, gint)) files_single_line_editable_label_real_do_delete_text;
	((FilesAbstractEditableLabelClass *) klass)->do_insert_text = (void (*) (FilesAbstractEditableLabel*, const gchar*, gint, gint*)) files_single_line_editable_label_real_do_insert_text;
	((FilesAbstractEditableLabelClass *) klass)->get_chars = (gchar* (*) (FilesAbstractEditableLabel*, gint, gint)) files_single_line_editable_label_real_get_chars;
	((FilesAbstractEditableLabelClass *) klass)->get_position = (gint (*) (FilesAbstractEditableLabel*)) files_single_line_editable_label_real_get_position;
	((FilesAbstractEditableLabelClass *) klass)->get_selection_bounds = (gboolean (*) (FilesAbstractEditableLabel*, gint*, gint*)) files_single_line_editable_label_real_get_selection_bounds;
	((FilesAbstractEditableLabelClass *) klass)->set_position = (void (*) (FilesAbstractEditableLabel*, gint)) files_single_line_editable_label_real_set_position;
	((FilesAbstractEditableLabelClass *) klass)->set_size_request = (void (*) (FilesAbstractEditableLabel*, gint, gint)) files_single_line_editable_label_real_set_size_request;
	((FilesAbstractEditableLabelClass *) klass)->start_editing = (void (*) (FilesAbstractEditableLabel*, GdkEvent*)) files_single_line_editable_label_real_start_editing;
	G_OBJECT_CLASS (klass)->constructor = files_single_line_editable_label_constructor;
	G_OBJECT_CLASS (klass)->finalize = files_single_line_editable_label_finalize;
}

static void
files_single_line_editable_label_instance_init (FilesSingleLineEditableLabel * self,
                                                gpointer klass)
{
	self->priv = files_single_line_editable_label_get_instance_private (self);
	self->priv->select_start = 0;
	self->priv->select_end = 0;
}

static void
files_single_line_editable_label_finalize (GObject * obj)
{
	FilesSingleLineEditableLabel * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FILES_TYPE_SINGLE_LINE_EDITABLE_LABEL, FilesSingleLineEditableLabel);
	_g_object_unref0 (self->textview);
	G_OBJECT_CLASS (files_single_line_editable_label_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
files_single_line_editable_label_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FilesSingleLineEditableLabelClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) files_single_line_editable_label_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FilesSingleLineEditableLabel), 0, (GInstanceInitFunc) files_single_line_editable_label_instance_init, NULL };
	GType files_single_line_editable_label_type_id;
	files_single_line_editable_label_type_id = g_type_register_static (FILES_TYPE_ABSTRACT_EDITABLE_LABEL, "FilesSingleLineEditableLabel", &g_define_type_info, 0);
	FilesSingleLineEditableLabel_private_offset = g_type_add_instance_private (files_single_line_editable_label_type_id, sizeof (FilesSingleLineEditableLabelPrivate));
	return files_single_line_editable_label_type_id;
}

GType
files_single_line_editable_label_get_type (void)
{
	static volatile gsize files_single_line_editable_label_type_id__once = 0;
	if (g_once_init_enter (&files_single_line_editable_label_type_id__once)) {
		GType files_single_line_editable_label_type_id;
		files_single_line_editable_label_type_id = files_single_line_editable_label_get_type_once ();
		g_once_init_leave (&files_single_line_editable_label_type_id__once, files_single_line_editable_label_type_id);
	}
	return files_single_line_editable_label_type_id__once;
}

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;
}

