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

/*
 * This file is part of budgie-desktop
 *
 * Copyright Budgie Desktop Developers
 *
 * 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 2 of the License, or
 * (at your option) any later version.
 */

#include "placesindicator.h"
#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib.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

enum  {
	PLACES_SECTION_0_PROPERTY,
	PLACES_SECTION_NUM_PROPERTIES
};
static GParamSpec* places_section_properties[PLACES_SECTION_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _PlacesSectionPrivate {
	GtkLabel* alternative_header;
	GtkBox* header_box;
	GtkListBox* listbox;
	GtkRevealer* revealer;
	GtkImage* toggle_image;
};

static gint PlacesSection_private_offset;
static gpointer places_section_parent_class = NULL;
static GType places_section_type_id = 0;

static void places_section_toggle_revealer (PlacesSection* self);
static void _places_section_toggle_revealer_gtk_button_clicked (GtkButton* _sender,
                                                         gpointer self);
static void places_section_expand_revealer (PlacesSection* self,
                                     gboolean animate);
static void places_section_finalize (GObject * obj);

static inline gpointer
places_section_get_instance_private (PlacesSection* self)
{
	return G_STRUCT_MEMBER_P (self, PlacesSection_private_offset);
}

static void
_places_section_toggle_revealer_gtk_button_clicked (GtkButton* _sender,
                                                    gpointer self)
{
	places_section_toggle_revealer ((PlacesSection*) self);
}

PlacesSection*
places_section_construct (GType object_type)
{
	PlacesSection * self = NULL;
	GtkLabel* _tmp0_;
	GtkLabel* _tmp1_;
	GtkLabel* _tmp2_;
	GtkLabel* _tmp3_;
	GtkLabel* _tmp4_;
	GtkStyleContext* _tmp5_;
	GtkLabel* _tmp6_;
	GtkStyleContext* _tmp7_;
	GtkBox* _tmp8_;
	GtkBox* _tmp9_;
	GtkStyleContext* _tmp10_;
	GtkButton* header_button = NULL;
	GtkButton* _tmp11_;
	GtkBox* _tmp12_;
	GtkBox* header_content_box = NULL;
	GtkBox* _tmp13_;
	GtkImage* header_icon = NULL;
	GtkImage* _tmp14_;
	GtkLabel* header_label = NULL;
	GtkLabel* _tmp15_;
	GtkImage* _tmp16_;
	GtkImage* _tmp17_;
	GtkRevealer* _tmp18_;
	GtkListBox* _tmp19_;
	GtkListBox* _tmp20_;
	GtkStyleContext* _tmp21_;
	GtkListBox* _tmp22_;
	GtkRevealer* _tmp23_;
	GtkListBox* _tmp24_;
	GtkLabel* _tmp25_;
	GtkBox* _tmp26_;
	GtkRevealer* _tmp27_;
	self = (PlacesSection*) g_object_new (object_type, "orientation", GTK_ORIENTATION_VERTICAL, "spacing", 0, NULL);
	_tmp0_ = (GtkLabel*) gtk_label_new (_ ("Places"));
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->alternative_header);
	self->priv->alternative_header = _tmp0_;
	_tmp1_ = self->priv->alternative_header;
	gtk_widget_set_no_show_all ((GtkWidget*) _tmp1_, TRUE);
	_tmp2_ = self->priv->alternative_header;
	gtk_widget_set_visible ((GtkWidget*) _tmp2_, FALSE);
	_tmp3_ = self->priv->alternative_header;
	gtk_widget_set_halign ((GtkWidget*) _tmp3_, GTK_ALIGN_START);
	_tmp4_ = self->priv->alternative_header;
	_tmp5_ = gtk_widget_get_style_context ((GtkWidget*) _tmp4_);
	gtk_style_context_add_class (_tmp5_, "dim-label");
	_tmp6_ = self->priv->alternative_header;
	_tmp7_ = gtk_widget_get_style_context ((GtkWidget*) _tmp6_);
	gtk_style_context_add_class (_tmp7_, "alternative-label");
	_tmp8_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	g_object_ref_sink (_tmp8_);
	_g_object_unref0 (self->priv->header_box);
	self->priv->header_box = _tmp8_;
	_tmp9_ = self->priv->header_box;
	_tmp10_ = gtk_widget_get_style_context ((GtkWidget*) _tmp9_);
	gtk_style_context_add_class (_tmp10_, "places-section-header");
	_tmp11_ = (GtkButton*) gtk_button_new ();
	g_object_ref_sink (_tmp11_);
	header_button = _tmp11_;
	gtk_button_set_relief (header_button, GTK_RELIEF_NONE);
	gtk_widget_set_can_focus ((GtkWidget*) header_button, FALSE);
	_tmp12_ = self->priv->header_box;
	gtk_box_pack_start (_tmp12_, (GtkWidget*) header_button, TRUE, TRUE, (guint) 0);
	_tmp13_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
	g_object_ref_sink (_tmp13_);
	header_content_box = _tmp13_;
	gtk_container_add ((GtkContainer*) header_button, (GtkWidget*) header_content_box);
	_tmp14_ = (GtkImage*) gtk_image_new_from_icon_name ("folder-symbolic", (GtkIconSize) GTK_ICON_SIZE_MENU);
	g_object_ref_sink (_tmp14_);
	header_icon = _tmp14_;
	gtk_widget_set_margin_start ((GtkWidget*) header_icon, 3);
	gtk_box_pack_start (header_content_box, (GtkWidget*) header_icon, FALSE, FALSE, (guint) 0);
	_tmp15_ = (GtkLabel*) gtk_label_new (_ ("Places"));
	g_object_ref_sink (_tmp15_);
	header_label = _tmp15_;
	gtk_widget_set_halign ((GtkWidget*) header_label, GTK_ALIGN_START);
	gtk_box_pack_start (header_content_box, (GtkWidget*) header_label, TRUE, TRUE, (guint) 0);
	_tmp16_ = (GtkImage*) gtk_image_new_from_icon_name ("pan-down-symbolic", (GtkIconSize) GTK_ICON_SIZE_MENU);
	g_object_ref_sink (_tmp16_);
	_g_object_unref0 (self->priv->toggle_image);
	self->priv->toggle_image = _tmp16_;
	_tmp17_ = self->priv->toggle_image;
	gtk_box_pack_start (header_content_box, (GtkWidget*) _tmp17_, FALSE, FALSE, (guint) 0);
	_tmp18_ = (GtkRevealer*) gtk_revealer_new ();
	g_object_ref_sink (_tmp18_);
	_g_object_unref0 (self->priv->revealer);
	self->priv->revealer = _tmp18_;
	_tmp19_ = (GtkListBox*) gtk_list_box_new ();
	g_object_ref_sink (_tmp19_);
	_g_object_unref0 (self->priv->listbox);
	self->priv->listbox = _tmp19_;
	_tmp20_ = self->priv->listbox;
	_tmp21_ = gtk_widget_get_style_context ((GtkWidget*) _tmp20_);
	gtk_style_context_add_class (_tmp21_, "places-list");
	_tmp22_ = self->priv->listbox;
	gtk_list_box_set_selection_mode (_tmp22_, GTK_SELECTION_NONE);
	_tmp23_ = self->priv->revealer;
	_tmp24_ = self->priv->listbox;
	gtk_container_add ((GtkContainer*) _tmp23_, (GtkWidget*) _tmp24_);
	g_signal_connect_object (header_button, "clicked", (GCallback) _places_section_toggle_revealer_gtk_button_clicked, self, 0);
	_tmp25_ = self->priv->alternative_header;
	gtk_box_pack_start ((GtkBox*) self, (GtkWidget*) _tmp25_, FALSE, FALSE, (guint) 0);
	_tmp26_ = self->priv->header_box;
	gtk_box_pack_start ((GtkBox*) self, (GtkWidget*) _tmp26_, FALSE, FALSE, (guint) 0);
	_tmp27_ = self->priv->revealer;
	gtk_box_pack_start ((GtkBox*) self, (GtkWidget*) _tmp27_, FALSE, FALSE, (guint) 0);
	gtk_widget_show_all ((GtkWidget*) self);
	_g_object_unref0 (header_label);
	_g_object_unref0 (header_icon);
	_g_object_unref0 (header_content_box);
	_g_object_unref0 (header_button);
	return self;
}

PlacesSection*
places_section_new (void)
{
	return places_section_construct (TYPE_PLACES_SECTION);
}

static void
places_section_toggle_revealer (PlacesSection* self)
{
	GtkRevealer* _tmp0_;
	GtkRevealer* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->revealer;
	gtk_revealer_set_transition_type (_tmp0_, GTK_REVEALER_TRANSITION_TYPE_NONE);
	_tmp1_ = self->priv->revealer;
	_tmp2_ = gtk_revealer_get_child_revealed (_tmp1_);
	_tmp3_ = _tmp2_;
	if (!_tmp3_) {
		places_section_expand_revealer (self, TRUE);
	} else {
		places_section_contract_revealer (self, TRUE);
	}
}

static void
places_section_expand_revealer (PlacesSection* self,
                                gboolean animate)
{
	GtkRevealer* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->revealer;
	if (!gtk_revealer_get_child_revealed (_tmp0_)) {
		GtkRevealer* _tmp2_;
		GtkImage* _tmp3_;
		if (animate) {
			GtkRevealer* _tmp1_;
			_tmp1_ = self->priv->revealer;
			gtk_revealer_set_transition_type (_tmp1_, GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP);
		}
		_tmp2_ = self->priv->revealer;
		gtk_revealer_set_reveal_child (_tmp2_, TRUE);
		_tmp3_ = self->priv->toggle_image;
		gtk_image_set_from_icon_name (_tmp3_, "pan-up-symbolic", (GtkIconSize) GTK_ICON_SIZE_MENU);
	}
}

void
places_section_contract_revealer (PlacesSection* self,
                                  gboolean animate)
{
	GtkRevealer* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->revealer;
	if (gtk_revealer_get_child_revealed (_tmp0_)) {
		GtkRevealer* _tmp2_;
		GtkImage* _tmp3_;
		if (animate) {
			GtkRevealer* _tmp1_;
			_tmp1_ = self->priv->revealer;
			gtk_revealer_set_transition_type (_tmp1_, GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP);
		}
		_tmp2_ = self->priv->revealer;
		gtk_revealer_set_reveal_child (_tmp2_, FALSE);
		_tmp3_ = self->priv->toggle_image;
		gtk_image_set_from_icon_name (_tmp3_, "pan-down-symbolic", (GtkIconSize) GTK_ICON_SIZE_MENU);
	}
}

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

void
places_section_clear (PlacesSection* self)
{
	GtkListBox* _tmp0_;
	GList* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->listbox;
	_tmp1_ = gtk_container_get_children ((GtkContainer*) _tmp0_);
	{
		GList* item_collection = NULL;
		GList* item_it = NULL;
		item_collection = _tmp1_;
		for (item_it = item_collection; item_it != NULL; item_it = item_it->next) {
			GtkWidget* _tmp2_;
			GtkWidget* item = NULL;
			_tmp2_ = _g_object_ref0 ((GtkWidget*) item_it->data);
			item = _tmp2_;
			{
				GtkWidget* _tmp3_;
				_tmp3_ = item;
				gtk_widget_destroy (_tmp3_);
				_g_object_unref0 (item);
			}
		}
		(item_collection == NULL) ? NULL : (item_collection = (g_list_free (item_collection), NULL));
	}
}

void
places_section_add_item (PlacesSection* self,
                         PlaceItem* item)
{
	GtkListBox* _tmp0_;
	GtkContainer* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (item != NULL);
	_tmp0_ = self->priv->listbox;
	gtk_container_add ((GtkContainer*) _tmp0_, (GtkWidget*) item);
	_tmp1_ = gtk_widget_get_parent ((GtkWidget*) item);
	gtk_widget_set_can_focus ((GtkWidget*) _tmp1_, FALSE);
}

void
places_section_reveal (PlacesSection* self,
                       gboolean state)
{
	GtkRevealer* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->revealer;
	gtk_revealer_set_transition_type (_tmp0_, GTK_REVEALER_TRANSITION_TYPE_NONE);
	if (state) {
		places_section_expand_revealer (self, FALSE);
	} else {
		places_section_contract_revealer (self, FALSE);
	}
}

void
places_section_show_alternative_header (PlacesSection* self,
                                        gboolean state)
{
	GtkBox* _tmp0_;
	GtkBox* _tmp1_;
	GtkLabel* _tmp2_;
	GtkLabel* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->header_box;
	gtk_widget_set_no_show_all ((GtkWidget*) _tmp0_, state);
	_tmp1_ = self->priv->header_box;
	gtk_widget_set_visible ((GtkWidget*) _tmp1_, !state);
	_tmp2_ = self->priv->alternative_header;
	gtk_widget_set_no_show_all ((GtkWidget*) _tmp2_, !state);
	_tmp3_ = self->priv->alternative_header;
	gtk_widget_set_visible ((GtkWidget*) _tmp3_, state);
	if (state) {
		GtkListBox* _tmp4_;
		GtkStyleContext* _tmp5_;
		_tmp4_ = self->priv->listbox;
		_tmp5_ = gtk_widget_get_style_context ((GtkWidget*) _tmp4_);
		gtk_style_context_add_class (_tmp5_, "always-expand");
	} else {
		GtkListBox* _tmp6_;
		GtkStyleContext* _tmp7_;
		_tmp6_ = self->priv->listbox;
		_tmp7_ = gtk_widget_get_style_context ((GtkWidget*) _tmp6_);
		gtk_style_context_remove_class (_tmp7_, "always-expand");
	}
}

gboolean
places_section_is_revealed (PlacesSection* self)
{
	GtkRevealer* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->revealer;
	result = gtk_revealer_get_reveal_child (_tmp0_);
	return result;
}

static void
places_section_class_init (PlacesSectionClass * klass,
                           gpointer klass_data)
{
	places_section_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &PlacesSection_private_offset);
	G_OBJECT_CLASS (klass)->finalize = places_section_finalize;
}

static void
places_section_instance_init (PlacesSection * self,
                              gpointer klass)
{
	self->priv = places_section_get_instance_private (self);
}

static void
places_section_finalize (GObject * obj)
{
	PlacesSection * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_PLACES_SECTION, PlacesSection);
	_g_object_unref0 (self->priv->alternative_header);
	_g_object_unref0 (self->priv->header_box);
	_g_object_unref0 (self->priv->listbox);
	_g_object_unref0 (self->priv->revealer);
	_g_object_unref0 (self->priv->toggle_image);
	G_OBJECT_CLASS (places_section_parent_class)->finalize (obj);
}

GType
places_section_get_type (void)
{
	return places_section_type_id;
}

GType
places_section_register_type (GTypeModule * module)
{
	static const GTypeInfo g_define_type_info = { sizeof (PlacesSectionClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) places_section_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (PlacesSection), 0, (GInstanceInitFunc) places_section_instance_init, NULL };
	places_section_type_id = g_type_module_register_type (module, gtk_box_get_type (), "PlacesSection", &g_define_type_info, 0);
	PlacesSection_private_offset = sizeof (PlacesSectionPrivate);
	return places_section_type_id;
}

