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

/* -*- Mode: Vala; indent-tabs-mode: nil; tab-width: 2 -*-
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 * SPDX-FileCopyrightText: Michael Terry
 */

#include <adwaita.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include "deja.h"
#include <gio/gio.h>
#include <glib.h>
#include <stdlib.h>
#include <string.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
#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_SNAPSHOTS_PAGE (snapshots_page_get_type ())
#define SNAPSHOTS_PAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SNAPSHOTS_PAGE, SnapshotsPage))
#define SNAPSHOTS_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SNAPSHOTS_PAGE, SnapshotsPageClass))
#define IS_SNAPSHOTS_PAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SNAPSHOTS_PAGE))
#define IS_SNAPSHOTS_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SNAPSHOTS_PAGE))
#define SNAPSHOTS_PAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SNAPSHOTS_PAGE, SnapshotsPageClass))

typedef struct _SnapshotsPage SnapshotsPage;
typedef struct _SnapshotsPageClass SnapshotsPageClass;
typedef struct _SnapshotsPagePrivate SnapshotsPagePrivate;

#define TYPE_OPERATION_STATUS_PAGE (operation_status_page_get_type ())
#define OPERATION_STATUS_PAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_OPERATION_STATUS_PAGE, OperationStatusPage))
#define OPERATION_STATUS_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_OPERATION_STATUS_PAGE, OperationStatusPageClass))
#define IS_OPERATION_STATUS_PAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_OPERATION_STATUS_PAGE))
#define IS_OPERATION_STATUS_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_OPERATION_STATUS_PAGE))
#define OPERATION_STATUS_PAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_OPERATION_STATUS_PAGE, OperationStatusPageClass))

typedef struct _OperationStatusPage OperationStatusPage;
typedef struct _OperationStatusPageClass OperationStatusPageClass;
enum  {
	SNAPSHOTS_PAGE_0_PROPERTY,
	SNAPSHOTS_PAGE_NUM_PROPERTIES
};
static GParamSpec* snapshots_page_properties[SNAPSHOTS_PAGE_NUM_PROPERTIES];
#define _deja_dup_operation_state_unref0(var) ((var == NULL) ? NULL : (var = (deja_dup_operation_state_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define TYPE_OPERATION_LAUNCHER (operation_launcher_get_type ())
#define OPERATION_LAUNCHER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_OPERATION_LAUNCHER, OperationLauncher))
#define OPERATION_LAUNCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_OPERATION_LAUNCHER, OperationLauncherClass))
#define IS_OPERATION_LAUNCHER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_OPERATION_LAUNCHER))
#define IS_OPERATION_LAUNCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_OPERATION_LAUNCHER))
#define OPERATION_LAUNCHER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_OPERATION_LAUNCHER, OperationLauncherClass))

typedef struct _OperationLauncher OperationLauncher;
typedef struct _OperationLauncherClass OperationLauncherClass;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _SnapshotsPageMountData SnapshotsPageMountData;
enum  {
	SNAPSHOTS_PAGE_BROWSE_SIGNAL,
	SNAPSHOTS_PAGE_NUM_SIGNALS
};
static guint snapshots_page_signals[SNAPSHOTS_PAGE_NUM_SIGNALS] = {0};

struct _SnapshotsPage {
	AdwNavigationPage parent_instance;
	SnapshotsPagePrivate * priv;
};

struct _SnapshotsPageClass {
	AdwNavigationPageClass parent_class;
};

struct _SnapshotsPagePrivate {
	GtkStack* stack;
	GtkListBox* list_view;
	OperationStatusPage* status_page;
	GtkProgressBar* progress;
	GWeakRef operation;
	DejaDupOperationState* saved_state;
	GCancellable* cancel_mount;
};

struct _SnapshotsPageMountData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	SnapshotsPage* self;
	gchar* tag;
	GtkListBox* _tmp0_;
	guint pulse_id;
	gchar* error_msg;
	gchar* dir;
	DejaDupMountManager* _tmp1_;
	DejaDupMountManager* _tmp2_;
	DejaDupOperationState* _tmp3_;
	GCancellable* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	const gchar* _tmp7_;
	GtkFileLauncher* launcher;
	const gchar* _tmp8_;
	GFile* _tmp9_;
	GFile* _tmp10_;
	GtkFileLauncher* _tmp11_;
	GtkFileLauncher* _tmp12_;
	GtkFileLauncher* _tmp13_;
	GtkRoot* _tmp14_;
	GtkRoot* _tmp15_;
	GCancellable* _tmp16_;
	GError* e;
	GError* _tmp17_;
	const gchar* _tmp18_;
	gchar* _tmp19_;
	GError* _vala1_e;
	GError* _tmp20_;
	const gchar* _tmp21_;
	gchar* _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_;
	GtkProgressBar* _tmp25_;
	GtkListBox* _tmp26_;
	const gchar* _tmp27_;
	const gchar* _tmp28_;
	DejaDupOperationState* _tmp29_;
	const gchar* _tmp30_;
	GError* _inner_error0_;
};

static gint SnapshotsPage_private_offset;
static gpointer snapshots_page_parent_class = NULL;

VALA_EXTERN GType snapshots_page_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SnapshotsPage, g_object_unref)
VALA_EXTERN GType operation_status_page_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (OperationStatusPage, g_object_unref)
VALA_EXTERN void snapshots_page_scan (SnapshotsPage* self,
                          DejaDupBackend* backend);
VALA_EXTERN GType operation_launcher_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (OperationLauncher, g_object_unref)
VALA_EXTERN OperationLauncher* operation_launcher_get_instance (void);
VALA_EXTERN DejaDupOperationStatus* operation_launcher_create_list_snapshots (OperationLauncher* self,
                                                                  DejaDupBackend* backend,
                                                                  GError** error);
static void snapshots_page_handle_collection_dates (SnapshotsPage* self,
                                             DejaDupOperation* op,
                                             GList* dates);
static void _snapshots_page_handle_collection_dates_deja_dup_operation_status_collection_dates (DejaDupOperationStatus* _sender,
                                                                                         GList* dates,
                                                                                         gpointer self);
VALA_EXTERN void operation_status_page_connect_to_operation (OperationStatusPage* self,
                                                 DejaDupOperation* operation);
VALA_EXTERN void operation_status_page_set_error_state (OperationStatusPage* self,
                                            const gchar* message);
static void snapshots_page_handle_hidden (SnapshotsPage* self);
static void _snapshots_page_handle_hidden_adw_navigation_page_hidden (AdwNavigationPage* _sender,
                                                               gpointer self);
static gint __lambda16_ (DejaDupSnapshotInfo* a,
                  DejaDupSnapshotInfo* b);
static gint ___lambda16__gcompare_func (gconstpointer a,
                                 gconstpointer b);
static void __lambda17_ (SnapshotsPage* self,
                  DejaDupSnapshotInfo* info);
static GtkWidget* snapshots_page_make_row (SnapshotsPage* self,
                                    const gchar* title,
                                    const gchar* desc,
                                    const gchar* tag);
static void ___lambda17__gfunc (gconstpointer data,
                         gpointer self);
static void _g_free_gdestroy_notify (void* data);
static void snapshots_page_mount_data_free (gpointer _data);
static void snapshots_page_mount (SnapshotsPage* self,
                           const gchar* tag,
                           GAsyncReadyCallback _callback_,
                           gpointer _user_data_);
static void snapshots_page_mount_finish (SnapshotsPage* self,
                                  GAsyncResult* _res_);
static gboolean snapshots_page_mount_co (SnapshotsPageMountData* _data_);
static gboolean __lambda18_ (SnapshotsPage* self);
static gboolean ___lambda18__gsource_func (gpointer self);
static void snapshots_page_mount_ready (GObject* source_object,
                                 GAsyncResult* _res_,
                                 gpointer _user_data_);
VALA_EXTERN void error_dialog_create (GtkWidget* parent,
                          const gchar* msg1,
                          const gchar* msg2);
static void snapshots_page_row_activated (SnapshotsPage* self,
                                   GtkListBoxRow* row);
static void _snapshots_page_row_activated_gtk_list_box_row_activated (GtkListBox* _sender,
                                                               GtkListBoxRow* row,
                                                               gpointer self);
VALA_EXTERN SnapshotsPage* snapshots_page_new (void);
VALA_EXTERN SnapshotsPage* snapshots_page_construct (GType object_type);
static void g_cclosure_user_marshal_VOID__DEJA_DUP_OPERATION_STATE_STRING (GClosure * closure,
                                                                    GValue * return_value,
                                                                    guint n_param_values,
                                                                    const GValue * param_values,
                                                                    gpointer invocation_hint,
                                                                    gpointer marshal_data);
static GObject * snapshots_page_constructor (GType type,
                                      guint n_construct_properties,
                                      GObjectConstructParam * construct_properties);
static void snapshots_page_finalize (GObject * obj);
static GType snapshots_page_get_type_once (void);

static inline gpointer
snapshots_page_get_instance_private (SnapshotsPage* self)
{
	return G_STRUCT_MEMBER_P (self, SnapshotsPage_private_offset);
}

static void
_snapshots_page_handle_collection_dates_deja_dup_operation_status_collection_dates (DejaDupOperationStatus* _sender,
                                                                                    GList* dates,
                                                                                    gpointer self)
{
	snapshots_page_handle_collection_dates ((SnapshotsPage*) self, _sender, dates);
}

void
snapshots_page_scan (SnapshotsPage* self,
                     DejaDupBackend* backend)
{
	GCancellable* _tmp8_;
	GtkStack* _tmp9_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	_deja_dup_operation_state_unref0 (self->priv->saved_state);
	self->priv->saved_state = NULL;
	{
		DejaDupOperationStatus* op = NULL;
		OperationLauncher* _tmp0_;
		OperationLauncher* _tmp1_;
		DejaDupOperationStatus* _tmp2_;
		DejaDupOperationStatus* _tmp3_;
		OperationStatusPage* _tmp4_;
		_tmp0_ = operation_launcher_get_instance ();
		_tmp1_ = _tmp0_;
		_tmp2_ = operation_launcher_create_list_snapshots (_tmp1_, backend, &_inner_error0_);
		_tmp3_ = _tmp2_;
		_g_object_unref0 (_tmp1_);
		op = _tmp3_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		g_weak_ref_set (&self->priv->operation, (GObject*) op);
		g_signal_connect_object (op, "collection-dates", (GCallback) _snapshots_page_handle_collection_dates_deja_dup_operation_status_collection_dates, self, 0);
		_tmp4_ = self->priv->status_page;
		operation_status_page_connect_to_operation (_tmp4_, (DejaDupOperation*) op);
		deja_dup_operation_start ((DejaDupOperation*) op, NULL, NULL);
		_g_object_unref0 (op);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		OperationStatusPage* _tmp5_;
		GError* _tmp6_;
		const gchar* _tmp7_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp5_ = self->priv->status_page;
		_tmp6_ = e;
		_tmp7_ = _tmp6_->message;
		operation_status_page_set_error_state (_tmp5_, _tmp7_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		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;
	}
	_tmp8_ = self->priv->cancel_mount;
	g_cancellable_reset (_tmp8_);
	_tmp9_ = self->priv->stack;
	gtk_stack_set_visible_child_name (_tmp9_, "operation");
}

static void
snapshots_page_handle_hidden (SnapshotsPage* self)
{
	GCancellable* _tmp0_;
	DejaDupOperation* op = NULL;
	GObject* _tmp1_;
	DejaDupOperation* _tmp2_;
	DejaDupOperation* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->cancel_mount;
	g_cancellable_cancel (_tmp0_);
	_tmp1_ = g_weak_ref_get (&self->priv->operation);
	_tmp2_ = G_TYPE_CHECK_INSTANCE_TYPE (_tmp1_, DEJA_DUP_TYPE_OPERATION) ? ((DejaDupOperation*) _tmp1_) : NULL;
	if (_tmp2_ == NULL) {
		_g_object_unref0 (_tmp1_);
	}
	op = _tmp2_;
	_tmp3_ = op;
	if (_tmp3_ != NULL) {
		DejaDupOperation* _tmp4_;
		_tmp4_ = op;
		deja_dup_operation_stop (_tmp4_);
	}
	g_weak_ref_set (&self->priv->operation, NULL);
	_g_object_unref0 (op);
}

static void
_snapshots_page_handle_hidden_adw_navigation_page_hidden (AdwNavigationPage* _sender,
                                                          gpointer self)
{
	snapshots_page_handle_hidden ((SnapshotsPage*) self);
}

static gint
__lambda16_ (DejaDupSnapshotInfo* a,
             DejaDupSnapshotInfo* b)
{
	GDateTime* _tmp0_;
	GDateTime* _tmp1_;
	gint result;
	g_return_val_if_fail (a != NULL, 0);
	g_return_val_if_fail (b != NULL, 0);
	_tmp0_ = a->time;
	_tmp1_ = b->time;
	result = g_date_time_compare (_tmp0_, _tmp1_);
	return result;
}

static gint
___lambda16__gcompare_func (gconstpointer a,
                            gconstpointer b)
{
	gint result;
	result = __lambda16_ ((DejaDupSnapshotInfo*) a, (DejaDupSnapshotInfo*) b);
	return result;
}

static void
__lambda17_ (SnapshotsPage* self,
             DejaDupSnapshotInfo* info)
{
	GDateTime* _tmp0_;
	GDateTime* _tmp1_;
	gchar* user_str = NULL;
	GDateTime* _tmp2_;
	gchar* _tmp3_;
	GtkListBox* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	GtkWidget* _tmp7_;
	GtkWidget* _tmp8_;
	g_return_if_fail (info != NULL);
	_tmp0_ = info->time;
	_tmp1_ = g_date_time_to_local (_tmp0_);
	_g_date_time_unref0 (info->time);
	info->time = _tmp1_;
	_tmp2_ = info->time;
	_tmp3_ = g_date_time_format (_tmp2_, "%c");
	user_str = _tmp3_;
	_tmp4_ = self->priv->list_view;
	_tmp5_ = info->external_description;
	_tmp6_ = info->tag;
	_tmp7_ = snapshots_page_make_row (self, user_str, _tmp5_, _tmp6_);
	_tmp8_ = _tmp7_;
	gtk_list_box_prepend (_tmp4_, _tmp8_);
	_g_object_unref0 (_tmp8_);
	_g_free0 (user_str);
}

static void
___lambda17__gfunc (gconstpointer data,
                    gpointer self)
{
	__lambda17_ ((SnapshotsPage*) self, (DejaDupSnapshotInfo*) data);
}

static void
snapshots_page_handle_collection_dates (SnapshotsPage* self,
                                        DejaDupOperation* op,
                                        GList* dates)
{
	DejaDupOperationState* _tmp0_;
	GtkListBox* _tmp2_;
	GtkStack* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (op != NULL);
	_tmp0_ = deja_dup_operation_get_state (op);
	_deja_dup_operation_state_unref0 (self->priv->saved_state);
	self->priv->saved_state = _tmp0_;
	if (g_list_length (dates) == ((guint) 0)) {
		GtkStack* _tmp1_;
		_tmp1_ = self->priv->stack;
		gtk_stack_set_visible_child_name (_tmp1_, "no-snapshots");
		return;
	}
	dates = g_list_sort (dates, ___lambda16__gcompare_func);
	_tmp2_ = self->priv->list_view;
	gtk_list_box_remove_all (_tmp2_);
	g_list_foreach (dates, ___lambda17__gfunc, self);
	_tmp3_ = self->priv->stack;
	gtk_stack_set_visible_child_name (_tmp3_, "list");
}

static void
_g_free_gdestroy_notify (void* data)
{
	g_free (data);
}

static GtkWidget*
snapshots_page_make_row (SnapshotsPage* self,
                         const gchar* title,
                         const gchar* desc,
                         const gchar* tag)
{
	AdwActionRow* row = NULL;
	AdwActionRow* _tmp0_;
	AdwActionRow* _tmp1_;
	AdwActionRow* _tmp2_;
	AdwActionRow* _tmp3_;
	gchar* icon_name = NULL;
	gchar* _tmp4_;
	DejaDupOperationState* _tmp5_;
	DejaDupToolPlugin* _tmp6_;
	AdwActionRow* _tmp8_;
	const gchar* _tmp9_;
	GtkImage* _tmp10_;
	GtkImage* _tmp11_;
	AdwActionRow* _tmp12_;
	gchar* _tmp13_;
	GtkWidget* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (title != NULL, NULL);
	g_return_val_if_fail (tag != NULL, NULL);
	_tmp0_ = (AdwActionRow*) adw_action_row_new ();
	g_object_ref_sink (_tmp0_);
	row = _tmp0_;
	_tmp1_ = row;
	gtk_list_box_row_set_activatable ((GtkListBoxRow*) _tmp1_, TRUE);
	_tmp2_ = row;
	adw_preferences_row_set_title ((AdwPreferencesRow*) _tmp2_, title);
	_tmp3_ = row;
	adw_action_row_set_subtitle (_tmp3_, desc);
	_tmp4_ = g_strdup ("go-next-symbolic");
	icon_name = _tmp4_;
	_tmp5_ = self->priv->saved_state;
	_tmp6_ = _tmp5_->tool;
	if (deja_dup_tool_plugin_supports_mount (_tmp6_)) {
		gchar* _tmp7_;
		_tmp7_ = g_strdup ("external-link-symbolic");
		_g_free0 (icon_name);
		icon_name = _tmp7_;
	}
	_tmp8_ = row;
	_tmp9_ = icon_name;
	_tmp10_ = (GtkImage*) gtk_image_new_from_icon_name (_tmp9_);
	g_object_ref_sink (_tmp10_);
	_tmp11_ = _tmp10_;
	adw_action_row_add_suffix (_tmp8_, (GtkWidget*) _tmp11_);
	_g_object_unref0 (_tmp11_);
	_tmp12_ = row;
	_tmp13_ = g_strdup (tag);
	g_object_set_data_full ((GObject*) _tmp12_, "tag", _tmp13_, _g_free_gdestroy_notify);
	result = (GtkWidget*) row;
	_g_free0 (icon_name);
	return result;
}

static void
snapshots_page_mount_data_free (gpointer _data)
{
	SnapshotsPageMountData* _data_;
	_data_ = _data;
	_g_free0 (_data_->tag);
	_g_object_unref0 (_data_->self);
	g_slice_free (SnapshotsPageMountData, _data_);
}

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

static void
snapshots_page_mount (SnapshotsPage* self,
                      const gchar* tag,
                      GAsyncReadyCallback _callback_,
                      gpointer _user_data_)
{
	SnapshotsPageMountData* _data_;
	SnapshotsPage* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (tag != NULL);
	_data_ = g_slice_new0 (SnapshotsPageMountData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, snapshots_page_mount_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = g_strdup (tag);
	_g_free0 (_data_->tag);
	_data_->tag = _tmp1_;
	snapshots_page_mount_co (_data_);
}

static void
snapshots_page_mount_finish (SnapshotsPage* self,
                             GAsyncResult* _res_)
{
	SnapshotsPageMountData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static gboolean
__lambda18_ (SnapshotsPage* self)
{
	GtkProgressBar* _tmp0_;
	GtkProgressBar* _tmp1_;
	gboolean result;
	_tmp0_ = self->priv->progress;
	gtk_widget_set_visible ((GtkWidget*) _tmp0_, TRUE);
	_tmp1_ = self->priv->progress;
	gtk_progress_bar_pulse (_tmp1_);
	result = G_SOURCE_CONTINUE;
	return result;
}

static gboolean
___lambda18__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda18_ ((SnapshotsPage*) self);
	return result;
}

static void
snapshots_page_mount_ready (GObject* source_object,
                            GAsyncResult* _res_,
                            gpointer _user_data_)
{
	SnapshotsPageMountData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	snapshots_page_mount_co (_data_);
}

static gboolean
string_contains (const gchar* self,
                 const gchar* needle)
{
	gchar* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (needle != NULL, FALSE);
	_tmp0_ = strstr ((gchar*) self, (gchar*) needle);
	result = _tmp0_ != NULL;
	return result;
}

static gboolean
snapshots_page_mount_co (SnapshotsPageMountData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->list_view;
	gtk_widget_set_sensitive ((GtkWidget*) _data_->_tmp0_, FALSE);
	_data_->pulse_id = g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 250, ___lambda18__gsource_func, g_object_ref (_data_->self), g_object_unref);
	_data_->error_msg = NULL;
	{
		_data_->_tmp1_ = deja_dup_mount_manager_get_instance ();
		_data_->_tmp2_ = _data_->_tmp1_;
		_data_->_tmp3_ = _data_->self->priv->saved_state;
		_data_->_tmp4_ = _data_->self->priv->cancel_mount;
		_data_->_state_ = 1;
		deja_dup_mount_manager_mount (_data_->_tmp2_, _data_->_tmp3_, _data_->tag, _data_->_tmp4_, snapshots_page_mount_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp5_ = deja_dup_mount_manager_mount_finish (_data_->_tmp2_, _data_->_res_, &_data_->_inner_error0_);
		_data_->_tmp6_ = _data_->_tmp5_;
		_g_object_unref0 (_data_->_tmp2_);
		_data_->dir = _data_->_tmp6_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			if (g_error_matches (_data_->_inner_error0_, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
				goto __catch0_g_io_error_cancelled;
			}
			if (_data_->_inner_error0_->domain == DEJA_DUP_MOUNT_ERROR) {
				goto __catch0_deja_dup_mount_error;
			}
			goto __catch0_g_error;
		}
		_data_->_tmp7_ = _data_->dir;
		if (_data_->_tmp7_ != NULL) {
			_data_->_tmp8_ = _data_->dir;
			_data_->_tmp9_ = g_file_new_for_path (_data_->_tmp8_);
			_data_->_tmp10_ = _data_->_tmp9_;
			_data_->_tmp11_ = gtk_file_launcher_new (_data_->_tmp10_);
			_data_->_tmp12_ = _data_->_tmp11_;
			_g_object_unref0 (_data_->_tmp10_);
			_data_->launcher = _data_->_tmp12_;
			_data_->_tmp13_ = _data_->launcher;
			_data_->_tmp14_ = gtk_widget_get_root ((GtkWidget*) _data_->self);
			_data_->_tmp15_ = _data_->_tmp14_;
			_data_->_tmp16_ = _data_->self->priv->cancel_mount;
			_data_->_state_ = 2;
			gtk_file_launcher_launch (_data_->_tmp13_, G_TYPE_CHECK_INSTANCE_TYPE (_data_->_tmp15_, gtk_window_get_type ()) ? ((GtkWindow*) _data_->_tmp15_) : NULL, _data_->_tmp16_, snapshots_page_mount_ready, _data_);
			return FALSE;
			_state_2:
			gtk_file_launcher_launch_finish (_data_->_tmp13_, _data_->_res_, &_data_->_inner_error0_);
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				_g_object_unref0 (_data_->launcher);
				_g_free0 (_data_->dir);
				if (g_error_matches (_data_->_inner_error0_, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
					goto __catch0_g_io_error_cancelled;
				}
				if (_data_->_inner_error0_->domain == DEJA_DUP_MOUNT_ERROR) {
					goto __catch0_deja_dup_mount_error;
				}
				goto __catch0_g_error;
			}
			_g_object_unref0 (_data_->launcher);
		}
		_g_free0 (_data_->dir);
	}
	goto __finally0;
	__catch0_g_io_error_cancelled:
	{
		g_clear_error (&_data_->_inner_error0_);
	}
	goto __finally0;
	__catch0_deja_dup_mount_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp17_ = _data_->e;
		_data_->_tmp18_ = _data_->_tmp17_->message;
		_data_->_tmp19_ = g_strdup (_data_->_tmp18_);
		_g_free0 (_data_->error_msg);
		_data_->error_msg = _data_->_tmp19_;
		_g_error_free0 (_data_->e);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->_vala1_e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp20_ = _data_->_vala1_e;
		_data_->_tmp21_ = _data_->_tmp20_->message;
		_data_->_tmp22_ = g_strconcat (_data_->_tmp21_, "\n\n", NULL);
		_data_->_tmp23_ = _data_->_tmp22_;
		_data_->_tmp24_ = g_strconcat (_data_->_tmp23_, _ ("Try closing any open file manager windows and trying again."), NULL);
		_g_free0 (_data_->error_msg);
		_data_->error_msg = _data_->_tmp24_;
		_g_free0 (_data_->_tmp23_);
		_g_error_free0 (_data_->_vala1_e);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_g_free0 (_data_->error_msg);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	g_source_remove (_data_->pulse_id);
	_data_->_tmp25_ = _data_->self->priv->progress;
	gtk_widget_set_visible ((GtkWidget*) _data_->_tmp25_, FALSE);
	_data_->_tmp26_ = _data_->self->priv->list_view;
	gtk_widget_set_sensitive ((GtkWidget*) _data_->_tmp26_, TRUE);
	_data_->_tmp27_ = _data_->error_msg;
	if (_data_->_tmp27_ != NULL) {
		_data_->_tmp28_ = _data_->error_msg;
		if (string_contains (_data_->_tmp28_, "is not a socket, can't send fuse fd")) {
			_data_->_tmp29_ = _data_->self->priv->saved_state;
			g_signal_emit (_data_->self, snapshots_page_signals[SNAPSHOTS_PAGE_BROWSE_SIGNAL], 0, _data_->_tmp29_, _data_->tag);
		} else {
			_data_->_tmp30_ = _data_->error_msg;
			error_dialog_create ((GtkWidget*) _data_->self, _ ("Failed to Open Backup"), _data_->_tmp30_);
		}
	}
	_g_free0 (_data_->error_msg);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
snapshots_page_row_activated (SnapshotsPage* self,
                              GtkListBoxRow* row)
{
	gchar* tag = NULL;
	gconstpointer _tmp0_;
	gchar* _tmp1_;
	DejaDupOperationState* _tmp2_;
	DejaDupToolPlugin* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (row != NULL);
	_tmp0_ = g_object_get_data ((GObject*) row, "tag");
	_tmp1_ = g_strdup ((const gchar*) _tmp0_);
	tag = _tmp1_;
	_tmp2_ = self->priv->saved_state;
	_tmp3_ = _tmp2_->tool;
	if (deja_dup_tool_plugin_supports_mount (_tmp3_)) {
		const gchar* _tmp4_;
		_tmp4_ = tag;
		snapshots_page_mount (self, _tmp4_, NULL, NULL);
	} else {
		DejaDupOperationState* _tmp5_;
		const gchar* _tmp6_;
		_tmp5_ = self->priv->saved_state;
		_tmp6_ = tag;
		g_signal_emit (self, snapshots_page_signals[SNAPSHOTS_PAGE_BROWSE_SIGNAL], 0, _tmp5_, _tmp6_);
	}
	_g_free0 (tag);
}

static void
_snapshots_page_row_activated_gtk_list_box_row_activated (GtkListBox* _sender,
                                                          GtkListBoxRow* row,
                                                          gpointer self)
{
	snapshots_page_row_activated ((SnapshotsPage*) self, row);
}

SnapshotsPage*
snapshots_page_construct (GType object_type)
{
	SnapshotsPage * self = NULL;
	self = (SnapshotsPage*) g_object_new (object_type, NULL);
	return self;
}

SnapshotsPage*
snapshots_page_new (void)
{
	return snapshots_page_construct (TYPE_SNAPSHOTS_PAGE);
}

static void
g_cclosure_user_marshal_VOID__DEJA_DUP_OPERATION_STATE_STRING (GClosure * closure,
                                                               GValue * return_value,
                                                               guint n_param_values,
                                                               const GValue * param_values,
                                                               gpointer invocation_hint,
                                                               gpointer marshal_data)
{
	typedef void (*GMarshalFunc_VOID__DEJA_DUP_OPERATION_STATE_STRING) (gpointer data1, gpointer arg_1, const char* arg_2, gpointer data2);
	register GMarshalFunc_VOID__DEJA_DUP_OPERATION_STATE_STRING callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 3);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__DEJA_DUP_OPERATION_STATE_STRING) (marshal_data ? marshal_data : cc->callback);
	callback (data1, deja_dup_operation_value_get_state (param_values + 1), g_value_get_string (param_values + 2), data2);
}

static GObject *
snapshots_page_constructor (GType type,
                            guint n_construct_properties,
                            GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	SnapshotsPage * self;
	DejaDupOperationWatcher* op_watcher = NULL;
	DejaDupOperationWatcher* _tmp0_;
	DejaDupOperationWatcher* _tmp1_;
	GtkListBox* _tmp2_;
	GCancellable* _tmp3_;
	parent_class = G_OBJECT_CLASS (snapshots_page_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_SNAPSHOTS_PAGE, SnapshotsPage);
	_tmp0_ = deja_dup_operation_watcher_get_instance ();
	op_watcher = _tmp0_;
	_tmp1_ = op_watcher;
	_tmp2_ = self->priv->list_view;
	g_object_bind_property_with_closures ((GObject*) _tmp1_, "active", (GObject*) _tmp2_, "sensitive", G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp3_ = g_cancellable_new ();
	_g_object_unref0 (self->priv->cancel_mount);
	self->priv->cancel_mount = _tmp3_;
	_g_object_unref0 (op_watcher);
	return obj;
}

static void
snapshots_page_class_init (SnapshotsPageClass * klass,
                           gpointer klass_data)
{
	snapshots_page_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &SnapshotsPage_private_offset);
	G_OBJECT_CLASS (klass)->constructor = snapshots_page_constructor;
	G_OBJECT_CLASS (klass)->finalize = snapshots_page_finalize;
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/DejaDup/SnapshotsPage.ui");
	snapshots_page_signals[SNAPSHOTS_PAGE_BROWSE_SIGNAL] = g_signal_new ("browse", TYPE_SNAPSHOTS_PAGE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__DEJA_DUP_OPERATION_STATE_STRING, G_TYPE_NONE, 2, DEJA_DUP_OPERATION_TYPE_STATE, G_TYPE_STRING);
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "stack", FALSE, SnapshotsPage_private_offset + G_STRUCT_OFFSET (SnapshotsPagePrivate, stack));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "list_view", FALSE, SnapshotsPage_private_offset + G_STRUCT_OFFSET (SnapshotsPagePrivate, list_view));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "status_page", FALSE, SnapshotsPage_private_offset + G_STRUCT_OFFSET (SnapshotsPagePrivate, status_page));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "progress", FALSE, SnapshotsPage_private_offset + G_STRUCT_OFFSET (SnapshotsPagePrivate, progress));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "handle_hidden", G_CALLBACK(_snapshots_page_handle_hidden_adw_navigation_page_hidden));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "row_activated", G_CALLBACK(_snapshots_page_row_activated_gtk_list_box_row_activated));
}

static void
snapshots_page_instance_init (SnapshotsPage * self,
                              gpointer klass)
{
	self->priv = snapshots_page_get_instance_private (self);
	g_type_ensure (TYPE_OPERATION_STATUS_PAGE);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
snapshots_page_finalize (GObject * obj)
{
	SnapshotsPage * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_SNAPSHOTS_PAGE, SnapshotsPage);
	g_weak_ref_clear (&self->priv->operation);
	_deja_dup_operation_state_unref0 (self->priv->saved_state);
	_g_object_unref0 (self->priv->cancel_mount);
	G_OBJECT_CLASS (snapshots_page_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
snapshots_page_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (SnapshotsPageClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) snapshots_page_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SnapshotsPage), 0, (GInstanceInitFunc) snapshots_page_instance_init, NULL };
	GType snapshots_page_type_id;
	snapshots_page_type_id = g_type_register_static (adw_navigation_page_get_type (), "SnapshotsPage", &g_define_type_info, 0);
	SnapshotsPage_private_offset = g_type_add_instance_private (snapshots_page_type_id, sizeof (SnapshotsPagePrivate));
	return snapshots_page_type_id;
}

GType
snapshots_page_get_type (void)
{
	static gsize snapshots_page_type_id__once = 0;
	if (g_once_init_enter (&snapshots_page_type_id__once)) {
		GType snapshots_page_type_id;
		snapshots_page_type_id = snapshots_page_get_type_once ();
		g_once_init_leave (&snapshots_page_type_id__once, snapshots_page_type_id);
	}
	return snapshots_page_type_id__once;
}

