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

/*
* Copyright (c) 2011 Marlin Developers (http://launchpad.net/marlin)
* Copyright (c) 2015-2018 elementary LLC <https://elementary.io>
*
* 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, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1335 USA.
*
* Authored by: ammonkey <am.monkeyd@gmail.com>
*/

#include <granite.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <stdlib.h>
#include <string.h>
#include "pantheon-files-core.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 FILES_VIEW_TYPE_ABSTRACT_PROPERTIES_DIALOG (files_view_abstract_properties_dialog_get_type ())
#define FILES_VIEW_ABSTRACT_PROPERTIES_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FILES_VIEW_TYPE_ABSTRACT_PROPERTIES_DIALOG, FilesViewAbstractPropertiesDialog))
#define FILES_VIEW_ABSTRACT_PROPERTIES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FILES_VIEW_TYPE_ABSTRACT_PROPERTIES_DIALOG, FilesViewAbstractPropertiesDialogClass))
#define FILES_VIEW_IS_ABSTRACT_PROPERTIES_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FILES_VIEW_TYPE_ABSTRACT_PROPERTIES_DIALOG))
#define FILES_VIEW_IS_ABSTRACT_PROPERTIES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FILES_VIEW_TYPE_ABSTRACT_PROPERTIES_DIALOG))
#define FILES_VIEW_ABSTRACT_PROPERTIES_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FILES_VIEW_TYPE_ABSTRACT_PROPERTIES_DIALOG, FilesViewAbstractPropertiesDialogClass))

typedef struct _FilesViewAbstractPropertiesDialog FilesViewAbstractPropertiesDialog;
typedef struct _FilesViewAbstractPropertiesDialogClass FilesViewAbstractPropertiesDialogClass;
typedef struct _FilesViewAbstractPropertiesDialogPrivate FilesViewAbstractPropertiesDialogPrivate;

#define FILES_VIEW_TYPE_VOLUME_PROPERTIES_WINDOW (files_view_volume_properties_window_get_type ())
#define FILES_VIEW_VOLUME_PROPERTIES_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FILES_VIEW_TYPE_VOLUME_PROPERTIES_WINDOW, FilesViewVolumePropertiesWindow))
#define FILES_VIEW_VOLUME_PROPERTIES_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FILES_VIEW_TYPE_VOLUME_PROPERTIES_WINDOW, FilesViewVolumePropertiesWindowClass))
#define FILES_VIEW_IS_VOLUME_PROPERTIES_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FILES_VIEW_TYPE_VOLUME_PROPERTIES_WINDOW))
#define FILES_VIEW_IS_VOLUME_PROPERTIES_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FILES_VIEW_TYPE_VOLUME_PROPERTIES_WINDOW))
#define FILES_VIEW_VOLUME_PROPERTIES_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FILES_VIEW_TYPE_VOLUME_PROPERTIES_WINDOW, FilesViewVolumePropertiesWindowClass))

typedef struct _FilesViewVolumePropertiesWindow FilesViewVolumePropertiesWindow;
typedef struct _FilesViewVolumePropertiesWindowClass FilesViewVolumePropertiesWindowClass;
typedef struct _FilesViewVolumePropertiesWindowPrivate FilesViewVolumePropertiesWindowPrivate;
enum  {
	FILES_VIEW_VOLUME_PROPERTIES_WINDOW_0_PROPERTY,
	FILES_VIEW_VOLUME_PROPERTIES_WINDOW_NUM_PROPERTIES
};
static GParamSpec* files_view_volume_properties_window_properties[FILES_VIEW_VOLUME_PROPERTIES_WINDOW_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))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _FilesViewAbstractPropertiesDialog {
	GraniteDialog parent_instance;
	FilesViewAbstractPropertiesDialogPrivate * priv;
	GtkGrid* info_grid;
	GtkGrid* layout;
	GtkStack* stack;
	GtkWidget* header_title;
};

struct _FilesViewAbstractPropertiesDialogClass {
	GraniteDialogClass parent_class;
};

struct _FilesViewVolumePropertiesWindow {
	FilesViewAbstractPropertiesDialog parent_instance;
	FilesViewVolumePropertiesWindowPrivate * priv;
};

struct _FilesViewVolumePropertiesWindowClass {
	FilesViewAbstractPropertiesDialogClass parent_class;
};

static gpointer files_view_volume_properties_window_parent_class = NULL;

VALA_EXTERN GType files_view_abstract_properties_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FilesViewAbstractPropertiesDialog, g_object_unref)
VALA_EXTERN GType files_view_volume_properties_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FilesViewVolumePropertiesWindow, g_object_unref)
VALA_EXTERN FilesViewVolumePropertiesWindow* files_view_volume_properties_window_new (GMount* mount,
                                                                          GtkWindow* parent);
VALA_EXTERN FilesViewVolumePropertiesWindow* files_view_volume_properties_window_construct (GType object_type,
                                                                                GMount* mount,
                                                                                GtkWindow* parent);
VALA_EXTERN FilesViewAbstractPropertiesDialog* files_view_abstract_properties_dialog_construct (GType object_type,
                                                                                    const gchar* _title,
                                                                                    GtkWindow* parent);
VALA_EXTERN void files_view_abstract_properties_dialog_overlay_emblems (FilesViewAbstractPropertiesDialog* self,
                                                            GtkImage* file_icon,
                                                            GList* emblems_list);
static void _g_free0_ (gpointer var);
static inline void _g_list_free__g_free0_ (GList* self);
VALA_EXTERN void files_view_abstract_properties_dialog_create_header_title (FilesViewAbstractPropertiesDialog* self);
VALA_EXTERN GtkLabel* files_make_key_label (const gchar* label);
VALA_EXTERN GtkLabel* files_make_value_label (const gchar* label);
VALA_EXTERN void files_view_abstract_properties_dialog_create_storage_bar (FilesViewAbstractPropertiesDialog* self,
                                                               GFileInfo* file_info,
                                                               gint line);
static GType files_view_volume_properties_window_get_type_once (void);

static void
_g_free0_ (gpointer var)
{
	var = (g_free (var), NULL);
}

static inline void
_g_list_free__g_free0_ (GList* self)
{
	g_list_free_full (self, (GDestroyNotify) _g_free0_);
}

FilesViewVolumePropertiesWindow*
files_view_volume_properties_window_construct (GType object_type,
                                               GMount* mount,
                                               GtkWindow* parent)
{
	FilesViewVolumePropertiesWindow * self = NULL;
	GFile* mount_root = NULL;
	gchar* mount_name = NULL;
	GIcon* mount_icon = NULL;
	GFileInfo* info = NULL;
	GtkImage* file_icon = NULL;
	GIcon* _tmp12_;
	GtkImage* _tmp13_ = NULL;
	GtkImage* _tmp14_;
	const gchar* _tmp23_;
	GtkLabel* _tmp24_;
	GtkLabel* location_label = NULL;
	GtkLabel* _tmp25_;
	GtkLabel* location_value = NULL;
	GFile* _tmp26_;
	gchar* _tmp27_;
	gchar* _tmp28_;
	gchar* _tmp29_;
	gchar* _tmp30_;
	gchar* _tmp31_;
	gchar* _tmp32_;
	gchar* _tmp33_;
	gchar* _tmp34_;
	GFile* _tmp35_;
	gchar* _tmp36_;
	gchar* _tmp37_;
	gchar* _tmp38_;
	gchar* _tmp39_;
	gchar* _tmp40_;
	gchar* _tmp41_;
	gchar* _tmp42_;
	gchar* _tmp43_;
	GtkLabel* _tmp44_;
	GtkLabel* _tmp45_;
	GtkGrid* _tmp46_;
	GtkLabel* _tmp47_;
	GtkGrid* _tmp48_;
	GtkLabel* _tmp49_;
	GtkLabel* _tmp50_;
	guint64 used_space = 0ULL;
	gboolean _tmp51_ = FALSE;
	GFileInfo* _tmp52_;
	GFileInfo* _tmp64_;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (parent != NULL, NULL);
	self = (FilesViewVolumePropertiesWindow*) files_view_abstract_properties_dialog_construct (object_type, _ ("Disk Properties"), parent);
	if (mount != NULL) {
		GFile* _tmp0_;
		gchar* _tmp1_;
		GIcon* _tmp2_;
		_tmp0_ = g_mount_get_root (mount);
		_g_object_unref0 (mount_root);
		mount_root = _tmp0_;
		_tmp1_ = g_mount_get_name (mount);
		_g_free0 (mount_name);
		mount_name = _tmp1_;
		_tmp2_ = g_mount_get_icon (mount);
		_g_object_unref0 (mount_icon);
		mount_icon = _tmp2_;
	} else {
		GFile* _tmp3_;
		gchar* _tmp4_;
		GThemedIcon* _tmp5_;
		_tmp3_ = g_file_new_for_uri ("file:///");
		_g_object_unref0 (mount_root);
		mount_root = _tmp3_;
		_tmp4_ = g_strdup (_ ("File System"));
		_g_free0 (mount_name);
		mount_name = _tmp4_;
		_tmp5_ = (GThemedIcon*) g_themed_icon_new_with_default_fallbacks (FILES_ICON_FILESYSTEM);
		_g_object_unref0 (mount_icon);
		mount_icon = (GIcon*) _tmp5_;
	}
	info = NULL;
	{
		GFileInfo* _tmp6_ = NULL;
		GFile* _tmp7_;
		GFileInfo* _tmp8_;
		GFileInfo* _tmp9_;
		_tmp7_ = mount_root;
		_tmp8_ = g_file_query_filesystem_info (_tmp7_, "filesystem::*", NULL, &_inner_error0_);
		_tmp6_ = _tmp8_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp9_ = _tmp6_;
		_tmp6_ = NULL;
		_g_object_unref0 (info);
		info = _tmp9_;
		_g_object_unref0 (_tmp6_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp10_;
		const gchar* _tmp11_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp10_ = e;
		_tmp11_ = _tmp10_->message;
		g_warning ("VolumePropertiesWindow.vala:50: error: %s", _tmp11_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (info);
		_g_object_unref0 (mount_icon);
		_g_free0 (mount_name);
		_g_object_unref0 (mount_root);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return NULL;
	}
	_tmp12_ = mount_icon;
	_tmp13_ = (GtkImage*) gtk_image_new_from_gicon (_tmp12_, (GtkIconSize) GTK_ICON_SIZE_DIALOG);
	gtk_image_set_pixel_size (_tmp13_, 48);
	g_object_ref_sink (_tmp13_);
	file_icon = _tmp13_;
	_tmp14_ = file_icon;
	if (_tmp14_ != NULL) {
		GList* emblems_list = NULL;
		gboolean _tmp15_ = FALSE;
		gboolean _tmp16_ = FALSE;
		GFileInfo* _tmp17_;
		GtkImage* _tmp21_;
		GList* _tmp22_;
		emblems_list = NULL;
		_tmp17_ = info;
		if (_tmp17_ != NULL) {
			GFileInfo* _tmp18_;
			_tmp18_ = info;
			_tmp16_ = g_file_info_has_attribute (_tmp18_, G_FILE_ATTRIBUTE_FILESYSTEM_READONLY);
		} else {
			_tmp16_ = FALSE;
		}
		if (_tmp16_) {
			GFileInfo* _tmp19_;
			_tmp19_ = info;
			_tmp15_ = g_file_info_get_attribute_boolean (_tmp19_, G_FILE_ATTRIBUTE_FILESYSTEM_READONLY);
		} else {
			_tmp15_ = FALSE;
		}
		if (_tmp15_) {
			gchar* _tmp20_;
			_tmp20_ = g_strdup ("emblem-readonly");
			emblems_list = g_list_append (emblems_list, _tmp20_);
		}
		_tmp21_ = file_icon;
		_tmp22_ = emblems_list;
		files_view_abstract_properties_dialog_overlay_emblems ((FilesViewAbstractPropertiesDialog*) self, _tmp21_, _tmp22_);
		(emblems_list == NULL) ? NULL : (emblems_list = (_g_list_free__g_free0_ (emblems_list), NULL));
	}
	_tmp23_ = mount_name;
	_tmp24_ = (GtkLabel*) gtk_label_new (_tmp23_);
	g_object_ref_sink (_tmp24_);
	_g_object_unref0 (((FilesViewAbstractPropertiesDialog*) self)->header_title);
	((FilesViewAbstractPropertiesDialog*) self)->header_title = (GtkWidget*) _tmp24_;
	files_view_abstract_properties_dialog_create_header_title ((FilesViewAbstractPropertiesDialog*) self);
	_tmp25_ = files_make_key_label (_ ("Location:"));
	location_label = _tmp25_;
	_tmp26_ = mount_root;
	_tmp27_ = g_file_get_uri (_tmp26_);
	_tmp28_ = _tmp27_;
	_tmp29_ = g_markup_escape_text (_tmp28_, (gssize) -1);
	_tmp30_ = _tmp29_;
	_tmp31_ = g_strconcat ("<a href=\"", _tmp30_, NULL);
	_tmp32_ = _tmp31_;
	_tmp33_ = g_strconcat (_tmp32_, "\">", NULL);
	_tmp34_ = _tmp33_;
	_tmp35_ = mount_root;
	_tmp36_ = g_file_get_parse_name (_tmp35_);
	_tmp37_ = _tmp36_;
	_tmp38_ = g_markup_escape_text (_tmp37_, (gssize) -1);
	_tmp39_ = _tmp38_;
	_tmp40_ = g_strconcat (_tmp34_, _tmp39_, NULL);
	_tmp41_ = _tmp40_;
	_tmp42_ = g_strconcat (_tmp41_, "</a>", NULL);
	_tmp43_ = _tmp42_;
	_tmp44_ = files_make_value_label (_tmp43_);
	_tmp45_ = _tmp44_;
	_g_free0 (_tmp43_);
	_g_free0 (_tmp41_);
	_g_free0 (_tmp39_);
	_g_free0 (_tmp37_);
	_g_free0 (_tmp34_);
	_g_free0 (_tmp32_);
	_g_free0 (_tmp30_);
	_g_free0 (_tmp28_);
	location_value = _tmp45_;
	_tmp46_ = ((FilesViewAbstractPropertiesDialog*) self)->info_grid;
	_tmp47_ = location_label;
	gtk_grid_attach (_tmp46_, (GtkWidget*) _tmp47_, 0, 1, 1, 1);
	_tmp48_ = ((FilesViewAbstractPropertiesDialog*) self)->info_grid;
	_tmp49_ = location_value;
	_tmp50_ = location_label;
	gtk_grid_attach_next_to (_tmp48_, (GtkWidget*) _tmp49_, (GtkWidget*) _tmp50_, GTK_POS_RIGHT, 1, 1);
	used_space = (guint64) 0;
	_tmp52_ = info;
	if (_tmp52_ != NULL) {
		GFileInfo* _tmp53_;
		_tmp53_ = info;
		_tmp51_ = g_file_info_has_attribute (_tmp53_, G_FILE_ATTRIBUTE_FILESYSTEM_TYPE);
	} else {
		_tmp51_ = FALSE;
	}
	if (_tmp51_) {
		GtkLabel* key_label = NULL;
		GtkLabel* _tmp54_;
		GtkLabel* value_label = NULL;
		GFileInfo* _tmp55_;
		const gchar* _tmp56_;
		GtkLabel* _tmp57_;
		GtkGrid* _tmp58_;
		GtkLabel* _tmp59_;
		GtkGrid* _tmp60_;
		GtkLabel* _tmp61_;
		GtkLabel* _tmp62_;
		GFileInfo* _tmp63_;
		_tmp54_ = files_make_key_label (_ ("Format:"));
		key_label = _tmp54_;
		_tmp55_ = info;
		_tmp56_ = g_file_info_get_attribute_string (_tmp55_, G_FILE_ATTRIBUTE_FILESYSTEM_TYPE);
		_tmp57_ = files_make_value_label (_tmp56_);
		value_label = _tmp57_;
		_tmp58_ = ((FilesViewAbstractPropertiesDialog*) self)->info_grid;
		_tmp59_ = key_label;
		gtk_grid_attach (_tmp58_, (GtkWidget*) _tmp59_, 0, 2, 1, 1);
		_tmp60_ = ((FilesViewAbstractPropertiesDialog*) self)->info_grid;
		_tmp61_ = value_label;
		_tmp62_ = key_label;
		gtk_grid_attach_next_to (_tmp60_, (GtkWidget*) _tmp61_, (GtkWidget*) _tmp62_, GTK_POS_RIGHT, 1, 1);
		_tmp63_ = info;
		used_space = g_file_info_get_attribute_uint64 (_tmp63_, G_FILE_ATTRIBUTE_FILESYSTEM_USED);
		_g_object_unref0 (value_label);
		_g_object_unref0 (key_label);
	}
	_tmp64_ = info;
	files_view_abstract_properties_dialog_create_storage_bar ((FilesViewAbstractPropertiesDialog*) self, _tmp64_, 3);
	gtk_widget_show_all ((GtkWidget*) self);
	_g_object_unref0 (location_value);
	_g_object_unref0 (location_label);
	_g_object_unref0 (file_icon);
	_g_object_unref0 (info);
	_g_object_unref0 (mount_icon);
	_g_free0 (mount_name);
	_g_object_unref0 (mount_root);
	return self;
}

FilesViewVolumePropertiesWindow*
files_view_volume_properties_window_new (GMount* mount,
                                         GtkWindow* parent)
{
	return files_view_volume_properties_window_construct (FILES_VIEW_TYPE_VOLUME_PROPERTIES_WINDOW, mount, parent);
}

static void
files_view_volume_properties_window_class_init (FilesViewVolumePropertiesWindowClass * klass,
                                                gpointer klass_data)
{
	files_view_volume_properties_window_parent_class = g_type_class_peek_parent (klass);
}

static void
files_view_volume_properties_window_instance_init (FilesViewVolumePropertiesWindow * self,
                                                   gpointer klass)
{
}

 G_GNUC_NO_INLINE static GType
files_view_volume_properties_window_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FilesViewVolumePropertiesWindowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) files_view_volume_properties_window_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FilesViewVolumePropertiesWindow), 0, (GInstanceInitFunc) files_view_volume_properties_window_instance_init, NULL };
	GType files_view_volume_properties_window_type_id;
	files_view_volume_properties_window_type_id = g_type_register_static (FILES_VIEW_TYPE_ABSTRACT_PROPERTIES_DIALOG, "FilesViewVolumePropertiesWindow", &g_define_type_info, 0);
	return files_view_volume_properties_window_type_id;
}

GType
files_view_volume_properties_window_get_type (void)
{
	static volatile gsize files_view_volume_properties_window_type_id__once = 0;
	if (g_once_init_enter (&files_view_volume_properties_window_type_id__once)) {
		GType files_view_volume_properties_window_type_id;
		files_view_volume_properties_window_type_id = files_view_volume_properties_window_get_type_once ();
		g_once_init_leave (&files_view_volume_properties_window_type_id__once, files_view_volume_properties_window_type_id);
	}
	return files_view_volume_properties_window_type_id__once;
}

