/* notifications-revealer.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from notifications-revealer.vala, do not modify */

/*
  This file is part of GNOME Taquin

  GNOME Taquin 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.

  GNOME Taquin 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 GNOME Taquin.  If not, see <https://www.gnu.org/licenses/>.
*/

#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.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 TYPE_ADAPTATIVE_WIDGET (adaptative_widget_get_type ())
#define ADAPTATIVE_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ADAPTATIVE_WIDGET, AdaptativeWidget))
#define IS_ADAPTATIVE_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ADAPTATIVE_WIDGET))
#define ADAPTATIVE_WIDGET_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TYPE_ADAPTATIVE_WIDGET, AdaptativeWidgetIface))

typedef struct _AdaptativeWidget AdaptativeWidget;
typedef struct _AdaptativeWidgetIface AdaptativeWidgetIface;
typedef enum  {
	ADAPTATIVE_WIDGET_WINDOW_SIZE_START_SIZE,
	ADAPTATIVE_WIDGET_WINDOW_SIZE_USUAL_SIZE,
	ADAPTATIVE_WIDGET_WINDOW_SIZE_QUITE_THIN,
	ADAPTATIVE_WIDGET_WINDOW_SIZE_PHONE_VERT,
	ADAPTATIVE_WIDGET_WINDOW_SIZE_PHONE_HZTL,
	ADAPTATIVE_WIDGET_WINDOW_SIZE_PHONE_BOTH,
	ADAPTATIVE_WIDGET_WINDOW_SIZE_EXTRA_THIN,
	ADAPTATIVE_WIDGET_WINDOW_SIZE_EXTRA_FLAT
} AdaptativeWidgetWindowSize;

#define ADAPTATIVE_WIDGET_TYPE_WINDOW_SIZE (adaptative_widget_window_size_get_type ())

#define TYPE_NOTIFICATIONS_REVEALER (notifications_revealer_get_type ())
#define NOTIFICATIONS_REVEALER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_NOTIFICATIONS_REVEALER, NotificationsRevealer))
#define NOTIFICATIONS_REVEALER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_NOTIFICATIONS_REVEALER, NotificationsRevealerClass))
#define IS_NOTIFICATIONS_REVEALER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_NOTIFICATIONS_REVEALER))
#define IS_NOTIFICATIONS_REVEALER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_NOTIFICATIONS_REVEALER))
#define NOTIFICATIONS_REVEALER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_NOTIFICATIONS_REVEALER, NotificationsRevealerClass))

typedef struct _NotificationsRevealer NotificationsRevealer;
typedef struct _NotificationsRevealerClass NotificationsRevealerClass;
typedef struct _NotificationsRevealerPrivate NotificationsRevealerPrivate;
enum  {
	NOTIFICATIONS_REVEALER_0_PROPERTY,
	NOTIFICATIONS_REVEALER_NUM_PROPERTIES
};
static GParamSpec* notifications_revealer_properties[NOTIFICATIONS_REVEALER_NUM_PROPERTIES];
typedef void (*GSimpleActionActivateCallback) (GSimpleAction* action, GVariant* parameter, gpointer user_data);
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _AdaptativeWidgetIface {
	GTypeInterface parent_iface;
	void (*set_window_size) (AdaptativeWidget* self, AdaptativeWidgetWindowSize new_size);
};

struct _NotificationsRevealer {
	GtkRevealer parent_instance;
	NotificationsRevealerPrivate * priv;
};

struct _NotificationsRevealerClass {
	GtkRevealerClass parent_class;
};

struct _NotificationsRevealerPrivate {
	GtkLabel* notification_label;
	gboolean is_thin;
};

static gint NotificationsRevealer_private_offset;
static gpointer notifications_revealer_parent_class = NULL;
static AdaptativeWidgetIface * notifications_revealer_adaptative_widget_parent_iface = NULL;

VALA_EXTERN GType adaptative_widget_window_size_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType adaptative_widget_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (AdaptativeWidget, g_object_unref)
VALA_EXTERN GType notifications_revealer_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (NotificationsRevealer, g_object_unref)
VALA_EXTERN void notifications_revealer_hide_notification (NotificationsRevealer* self);
static void _notifications_revealer_hide_notification_gsimple_action_activate_callback (GSimpleAction* action,
                                                                                 GVariant* parameter,
                                                                                 gpointer self);
VALA_EXTERN void notifications_revealer_show_notification (NotificationsRevealer* self,
                                               const gchar* notification);
static void notifications_revealer_real_set_window_size (AdaptativeWidget* base,
                                                  AdaptativeWidgetWindowSize new_size);
VALA_EXTERN gboolean adaptative_widget_window_size_is_quite_thin (AdaptativeWidgetWindowSize window_size);
static void notifications_revealer_install_action_entries (NotificationsRevealer* self);
VALA_EXTERN NotificationsRevealer* notifications_revealer_new (void);
VALA_EXTERN NotificationsRevealer* notifications_revealer_construct (GType object_type);
static GObject * notifications_revealer_constructor (GType type,
                                              guint n_construct_properties,
                                              GObjectConstructParam * construct_properties);
VALA_EXTERN void adaptative_widget_set_window_size (AdaptativeWidget* self,
                                        AdaptativeWidgetWindowSize new_size);
static void notifications_revealer_finalize (GObject * obj);
static GType notifications_revealer_get_type_once (void);

static const GActionEntry NOTIFICATIONS_REVEALER_action_entries[1] = {{"hide", _notifications_revealer_hide_notification_gsimple_action_activate_callback}};

static inline gpointer
notifications_revealer_get_instance_private (NotificationsRevealer* self)
{
	return G_STRUCT_MEMBER_P (self, NotificationsRevealer_private_offset);
}

static void
_notifications_revealer_hide_notification_gsimple_action_activate_callback (GSimpleAction* action,
                                                                            GVariant* parameter,
                                                                            gpointer self)
{
	notifications_revealer_hide_notification ((NotificationsRevealer*) self);
}

void
notifications_revealer_show_notification (NotificationsRevealer* self,
                                          const gchar* notification)
{
	GtkLabel* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (notification != NULL);
	_tmp0_ = self->priv->notification_label;
	gtk_label_set_text (_tmp0_, notification);
	gtk_revealer_set_reveal_child ((GtkRevealer*) self, TRUE);
}

static void
notifications_revealer_real_set_window_size (AdaptativeWidget* base,
                                             AdaptativeWidgetWindowSize new_size)
{
	NotificationsRevealer * self;
	gboolean _is_thin = FALSE;
	self = (NotificationsRevealer*) base;
	_is_thin = adaptative_widget_window_size_is_quite_thin (new_size);
	if (self->priv->is_thin == _is_thin) {
		return;
	}
	self->priv->is_thin = _is_thin;
	if (_is_thin) {
		gtk_widget_set_hexpand ((GtkWidget*) self, TRUE);
		gtk_widget_set_halign ((GtkWidget*) self, GTK_ALIGN_FILL);
	} else {
		gtk_widget_set_hexpand ((GtkWidget*) self, FALSE);
		gtk_widget_set_halign ((GtkWidget*) self, GTK_ALIGN_CENTER);
	}
}

static void
notifications_revealer_install_action_entries (NotificationsRevealer* self)
{
	GSimpleActionGroup* action_group = NULL;
	GSimpleActionGroup* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_simple_action_group_new ();
	action_group = _tmp0_;
	g_action_map_add_action_entries ((GActionMap*) action_group, NOTIFICATIONS_REVEALER_action_entries, (gint) G_N_ELEMENTS (NOTIFICATIONS_REVEALER_action_entries), self);
	gtk_widget_insert_action_group ((GtkWidget*) self, "notification", (GActionGroup*) action_group);
	_g_object_unref0 (action_group);
}

void
notifications_revealer_hide_notification (NotificationsRevealer* self)
{
	g_return_if_fail (self != NULL);
	gtk_revealer_set_reveal_child ((GtkRevealer*) self, FALSE);
}

NotificationsRevealer*
notifications_revealer_construct (GType object_type)
{
	NotificationsRevealer * self = NULL;
	self = (NotificationsRevealer*) g_object_new (object_type, NULL);
	return self;
}

NotificationsRevealer*
notifications_revealer_new (void)
{
	return notifications_revealer_construct (TYPE_NOTIFICATIONS_REVEALER);
}

static GObject *
notifications_revealer_constructor (GType type,
                                    guint n_construct_properties,
                                    GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	NotificationsRevealer * self;
	parent_class = G_OBJECT_CLASS (notifications_revealer_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_NOTIFICATIONS_REVEALER, NotificationsRevealer);
	notifications_revealer_install_action_entries (self);
	return obj;
}

static void
notifications_revealer_class_init (NotificationsRevealerClass * klass,
                                   gpointer klass_data)
{
	notifications_revealer_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &NotificationsRevealer_private_offset);
	G_OBJECT_CLASS (klass)->constructor = notifications_revealer_constructor;
	G_OBJECT_CLASS (klass)->finalize = notifications_revealer_finalize;
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/Taquin/ui/notifications-revealer.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "notification_label", FALSE, NotificationsRevealer_private_offset + G_STRUCT_OFFSET (NotificationsRevealerPrivate, notification_label));
}

static void
notifications_revealer_adaptative_widget_interface_init (AdaptativeWidgetIface * iface,
                                                         gpointer iface_data)
{
	notifications_revealer_adaptative_widget_parent_iface = g_type_interface_peek_parent (iface);
	iface->set_window_size = (void (*) (AdaptativeWidget*, AdaptativeWidgetWindowSize)) notifications_revealer_real_set_window_size;
}

static void
notifications_revealer_instance_init (NotificationsRevealer * self,
                                      gpointer klass)
{
	self->priv = notifications_revealer_get_instance_private (self);
	self->priv->is_thin = FALSE;
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
notifications_revealer_finalize (GObject * obj)
{
	NotificationsRevealer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_NOTIFICATIONS_REVEALER, NotificationsRevealer);
	G_OBJECT_CLASS (notifications_revealer_parent_class)->finalize (obj);
}

static GType
notifications_revealer_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (NotificationsRevealerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) notifications_revealer_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (NotificationsRevealer), 0, (GInstanceInitFunc) notifications_revealer_instance_init, NULL };
	static const GInterfaceInfo adaptative_widget_info = { (GInterfaceInitFunc) notifications_revealer_adaptative_widget_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType notifications_revealer_type_id;
	notifications_revealer_type_id = g_type_register_static (gtk_revealer_get_type (), "NotificationsRevealer", &g_define_type_info, 0);
	g_type_add_interface_static (notifications_revealer_type_id, TYPE_ADAPTATIVE_WIDGET, &adaptative_widget_info);
	NotificationsRevealer_private_offset = g_type_add_instance_private (notifications_revealer_type_id, sizeof (NotificationsRevealerPrivate));
	return notifications_revealer_type_id;
}

GType
notifications_revealer_get_type (void)
{
	static volatile gsize notifications_revealer_type_id__once = 0;
	if (g_once_init_enter (&notifications_revealer_type_id__once)) {
		GType notifications_revealer_type_id;
		notifications_revealer_type_id = notifications_revealer_get_type_once ();
		g_once_init_leave (&notifications_revealer_type_id__once, notifications_revealer_type_id);
	}
	return notifications_revealer_type_id__once;
}

