/* BrowserPage.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from BrowserPage.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 <gio/gio.h>
#include "deja.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_BROWSER_PAGE (browser_page_get_type ())
#define BROWSER_PAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_BROWSER_PAGE, BrowserPage))
#define BROWSER_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_BROWSER_PAGE, BrowserPageClass))
#define IS_BROWSER_PAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_BROWSER_PAGE))
#define IS_BROWSER_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_BROWSER_PAGE))
#define BROWSER_PAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_BROWSER_PAGE, BrowserPageClass))

typedef struct _BrowserPage BrowserPage;
typedef struct _BrowserPageClass BrowserPageClass;
typedef struct _BrowserPagePrivate BrowserPagePrivate;

#define TYPE_RESTORE_TOOLBAR_VIEW (restore_toolbar_view_get_type ())
#define RESTORE_TOOLBAR_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_RESTORE_TOOLBAR_VIEW, RestoreToolbarView))
#define RESTORE_TOOLBAR_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_RESTORE_TOOLBAR_VIEW, RestoreToolbarViewClass))
#define IS_RESTORE_TOOLBAR_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_RESTORE_TOOLBAR_VIEW))
#define IS_RESTORE_TOOLBAR_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_RESTORE_TOOLBAR_VIEW))
#define RESTORE_TOOLBAR_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_RESTORE_TOOLBAR_VIEW, RestoreToolbarViewClass))

typedef struct _RestoreToolbarView RestoreToolbarView;
typedef struct _RestoreToolbarViewClass RestoreToolbarViewClass;

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

#define TYPE_BROWSER (browser_get_type ())
#define BROWSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_BROWSER, Browser))
#define BROWSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_BROWSER, BrowserClass))
#define IS_BROWSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_BROWSER))
#define IS_BROWSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_BROWSER))
#define BROWSER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_BROWSER, BrowserClass))

typedef struct _Browser Browser;
typedef struct _BrowserClass BrowserClass;
enum  {
	BROWSER_PAGE_0_PROPERTY,
	BROWSER_PAGE_WINDOW_PROPERTY,
	BROWSER_PAGE_NUM_PROPERTIES
};
static GParamSpec* browser_page_properties[BROWSER_PAGE_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)))
#define _deja_dup_operation_state_unref0(var) ((var == NULL) ? NULL : (var = (deja_dup_operation_state_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 TYPE_ACTION_DIALOG (action_dialog_get_type ())
#define ACTION_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ACTION_DIALOG, ActionDialog))
#define ACTION_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_ACTION_DIALOG, ActionDialogClass))
#define IS_ACTION_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ACTION_DIALOG))
#define IS_ACTION_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_ACTION_DIALOG))
#define ACTION_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_ACTION_DIALOG, ActionDialogClass))

typedef struct _ActionDialog ActionDialog;
typedef struct _ActionDialogClass ActionDialogClass;

#define TYPE_RESTORE_TARGET_DIALOG (restore_target_dialog_get_type ())
#define RESTORE_TARGET_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_RESTORE_TARGET_DIALOG, RestoreTargetDialog))
#define RESTORE_TARGET_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_RESTORE_TARGET_DIALOG, RestoreTargetDialogClass))
#define IS_RESTORE_TARGET_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_RESTORE_TARGET_DIALOG))
#define IS_RESTORE_TARGET_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_RESTORE_TARGET_DIALOG))
#define RESTORE_TARGET_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_RESTORE_TARGET_DIALOG, RestoreTargetDialogClass))

typedef struct _RestoreTargetDialog RestoreTargetDialog;
typedef struct _RestoreTargetDialogClass RestoreTargetDialogClass;
typedef struct _Block3Data Block3Data;
typedef struct _BrowserPageStartRestoreAsyncData BrowserPageStartRestoreAsyncData;

struct _BrowserPage {
	AdwNavigationPage parent_instance;
	BrowserPagePrivate * priv;
};

struct _BrowserPageClass {
	AdwNavigationPageClass parent_class;
};

struct _BrowserPagePrivate {
	GtkWindow* _window;
	RestoreToolbarView* restore_view;
	GtkStack* stack;
	OperationStatusPage* status_page;
	Browser* browser;
	GSimpleActionGroup* action_group;
	GWeakRef operation;
	DejaDupOperationState* saved_state;
};

struct _Block3Data {
	int _ref_count_;
	BrowserPage* self;
	GList* files;
	RestoreTargetDialog* dlg;
	gpointer _async_data_;
};

struct _BrowserPageStartRestoreAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	BrowserPage* self;
	Block3Data* _data3_;
	Browser* _tmp0_;
	GList* _tmp1_;
	GList* _tmp2_;
	Browser* _tmp3_;
	DejaDupFileTree* _tmp4_;
	DejaDupFileTree* _tmp5_;
	GList* _tmp6_;
	RestoreTargetDialog* _tmp7_;
	RestoreTargetDialog* _tmp8_;
	RestoreTargetDialog* _tmp9_;
	RestoreTargetDialog* _tmp10_;
};

static gint BrowserPage_private_offset;
static gpointer browser_page_parent_class = NULL;

VALA_EXTERN GType browser_page_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BrowserPage, g_object_unref)
VALA_EXTERN GType restore_toolbar_view_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (RestoreToolbarView, 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 GType browser_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Browser, g_object_unref)
static void browser_page_select_all (BrowserPage* self);
static void _browser_page_select_all_gsimple_action_activate_callback (GSimpleAction* action,
                                                                GVariant* parameter,
                                                                gpointer self);
static void browser_page_go_up (BrowserPage* self);
static void _browser_page_go_up_gsimple_action_activate_callback (GSimpleAction* action,
                                                           GVariant* parameter,
                                                           gpointer self);
static void browser_page_activate_search (BrowserPage* self);
static void _browser_page_activate_search_gsimple_action_activate_callback (GSimpleAction* action,
                                                                     GVariant* parameter,
                                                                     gpointer self);
VALA_EXTERN void browser_page_scan (BrowserPage* self,
                        const gchar* tag,
                        DejaDupOperationState* state);
VALA_EXTERN const gchar* browser_get_tag (Browser* self);
VALA_EXTERN void browser_clear_tree (Browser* self);
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 DejaDupOperationFiles* operation_launcher_create_list_files (OperationLauncher* self,
                                                             const gchar* tag,
                                                             DejaDupOperationState* state,
                                                             GError** error);
static void browser_page_handle_listed_current_files (BrowserPage* self,
                                               DejaDupOperationFiles* op,
                                               DejaDupFileTree* tree);
static void _browser_page_handle_listed_current_files_deja_dup_operation_files_listed_current_files (DejaDupOperationFiles* _sender,
                                                                                              DejaDupFileTree* tree,
                                                                                              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);
VALA_EXTERN void browser_select_all (Browser* self);
VALA_EXTERN void browser_go_up (Browser* self);
VALA_EXTERN void restore_toolbar_view_activate_search (RestoreToolbarView* self);
VALA_EXTERN void browser_set_tree (Browser* self,
                       const gchar* tag,
                       DejaDupFileTree* tree);
static void browser_page_start_restore (BrowserPage* self);
static void browser_page_start_restore_async (BrowserPage* self,
                                       GAsyncReadyCallback _callback_,
                                       gpointer _user_data_);
static void browser_page_start_restore_finish (BrowserPage* self,
                                        GAsyncResult* _res_);
static void _browser_page_start_restore_restore_toolbar_view_restore (RestoreToolbarView* _sender,
                                                               gpointer self);
static void browser_page_start_restore_async_data_free (gpointer _data);
static gboolean browser_page_start_restore_async_co (BrowserPageStartRestoreAsyncData* _data_);
VALA_EXTERN GType action_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ActionDialog, g_object_unref)
VALA_EXTERN GType restore_target_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (RestoreTargetDialog, g_object_unref)
static Block3Data* block3_data_ref (Block3Data* _data3_);
static void _g_object_unref0_ (gpointer var);
static inline void _g_list_free__g_object_unref0_ (GList* self);
static void block3_data_unref (void * _userdata_);
VALA_EXTERN GList* browser_get_selected_files (Browser* self);
VALA_EXTERN DejaDupFileTree* browser_get_tree (Browser* self);
VALA_EXTERN RestoreTargetDialog* restore_target_dialog_new (DejaDupFileTree* tree,
                                                GList* restore_files);
VALA_EXTERN RestoreTargetDialog* restore_target_dialog_construct (GType object_type,
                                                      DejaDupFileTree* tree,
                                                      GList* restore_files);
static void __lambda20_ (Block3Data* _data3_);
VALA_EXTERN void operation_launcher_start_restore (OperationLauncher* self,
                                       DejaDupOperationState* state,
                                       const gchar* restore_location,
                                       DejaDupFileTree* tree,
                                       const gchar* tag,
                                       GList* files);
VALA_EXTERN const gchar* restore_target_dialog_get_restore_location (RestoreTargetDialog* self);
static void ___lambda20__action_dialog_accepted (ActionDialog* _sender,
                                          gpointer self);
static void browser_page_handle_showing (BrowserPage* self);
VALA_EXTERN GtkWindow* browser_page_get_window (BrowserPage* self);
static void _browser_page_handle_showing_adw_navigation_page_showing (AdwNavigationPage* _sender,
                                                               gpointer self);
static void browser_page_handle_hidden (BrowserPage* self);
static void _browser_page_handle_hidden_adw_navigation_page_hidden (AdwNavigationPage* _sender,
                                                             gpointer self);
static gchar* browser_page_calculate_title (BrowserPage* self,
                                     const gchar* folder_name,
                                     const gchar* search_filter);
VALA_EXTERN BrowserPage* browser_page_new (void);
VALA_EXTERN BrowserPage* browser_page_construct (GType object_type);
VALA_EXTERN void browser_page_set_window (BrowserPage* self,
                              GtkWindow* value);
static GObject * browser_page_constructor (GType type,
                                    guint n_construct_properties,
                                    GObjectConstructParam * construct_properties);
static void browser_page_finalize (GObject * obj);
static GType browser_page_get_type_once (void);
static void _vala_browser_page_get_property (GObject * object,
                                      guint property_id,
                                      GValue * value,
                                      GParamSpec * pspec);
static void _vala_browser_page_set_property (GObject * object,
                                      guint property_id,
                                      const GValue * value,
                                      GParamSpec * pspec);

static const GActionEntry BROWSER_PAGE_ACTIONS[3] = {{"select-all", _browser_page_select_all_gsimple_action_activate_callback}, {"go-up", _browser_page_go_up_gsimple_action_activate_callback}, {"search", _browser_page_activate_search_gsimple_action_activate_callback}};

static inline gpointer
browser_page_get_instance_private (BrowserPage* self)
{
	return G_STRUCT_MEMBER_P (self, BrowserPage_private_offset);
}

static void
_browser_page_select_all_gsimple_action_activate_callback (GSimpleAction* action,
                                                           GVariant* parameter,
                                                           gpointer self)
{
	browser_page_select_all ((BrowserPage*) self);
}

static void
_browser_page_go_up_gsimple_action_activate_callback (GSimpleAction* action,
                                                      GVariant* parameter,
                                                      gpointer self)
{
	browser_page_go_up ((BrowserPage*) self);
}

static void
_browser_page_activate_search_gsimple_action_activate_callback (GSimpleAction* action,
                                                                GVariant* parameter,
                                                                gpointer self)
{
	browser_page_activate_search ((BrowserPage*) self);
}

static gpointer
_deja_dup_operation_state_ref0 (gpointer self)
{
	return self ? deja_dup_operation_state_ref (self) : NULL;
}

static void
_browser_page_handle_listed_current_files_deja_dup_operation_files_listed_current_files (DejaDupOperationFiles* _sender,
                                                                                         DejaDupFileTree* tree,
                                                                                         gpointer self)
{
	browser_page_handle_listed_current_files ((BrowserPage*) self, _sender, tree);
}

void
browser_page_scan (BrowserPage* self,
                   const gchar* tag,
                   DejaDupOperationState* state)
{
	gboolean _tmp0_ = FALSE;
	DejaDupOperationState* _tmp5_;
	Browser* _tmp6_;
	GtkStack* _tmp19_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (tag != NULL);
	if (g_strcmp0 (tag, "") != 0) {
		Browser* _tmp1_;
		const gchar* _tmp2_;
		const gchar* _tmp3_;
		_tmp1_ = self->priv->browser;
		_tmp2_ = browser_get_tag (_tmp1_);
		_tmp3_ = _tmp2_;
		_tmp0_ = g_strcmp0 (_tmp3_, tag) == 0;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		GtkStack* _tmp4_;
		_tmp4_ = self->priv->stack;
		gtk_stack_set_visible_child_name (_tmp4_, "browser");
		return;
	}
	_tmp5_ = _deja_dup_operation_state_ref0 (state);
	_deja_dup_operation_state_unref0 (self->priv->saved_state);
	self->priv->saved_state = _tmp5_;
	_tmp6_ = self->priv->browser;
	browser_clear_tree (_tmp6_);
	{
		DejaDupOperationFiles* op = NULL;
		OperationLauncher* _tmp7_;
		OperationLauncher* _tmp8_;
		DejaDupOperationFiles* _tmp9_;
		DejaDupOperationFiles* _tmp10_;
		DejaDupOperationFiles* _tmp11_;
		DejaDupOperationFiles* _tmp12_;
		OperationStatusPage* _tmp13_;
		DejaDupOperationFiles* _tmp14_;
		DejaDupOperationFiles* _tmp15_;
		_tmp7_ = operation_launcher_get_instance ();
		_tmp8_ = _tmp7_;
		_tmp9_ = operation_launcher_create_list_files (_tmp8_, tag, state, &_inner_error0_);
		_tmp10_ = _tmp9_;
		_g_object_unref0 (_tmp8_);
		op = _tmp10_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp11_ = op;
		g_weak_ref_set (&self->priv->operation, (GObject*) _tmp11_);
		_tmp12_ = op;
		g_signal_connect_object (_tmp12_, "listed-current-files", (GCallback) _browser_page_handle_listed_current_files_deja_dup_operation_files_listed_current_files, self, 0);
		_tmp13_ = self->priv->status_page;
		_tmp14_ = op;
		operation_status_page_connect_to_operation (_tmp13_, (DejaDupOperation*) _tmp14_);
		_tmp15_ = op;
		deja_dup_operation_start ((DejaDupOperation*) _tmp15_, NULL, NULL);
		_g_object_unref0 (op);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		OperationStatusPage* _tmp16_;
		GError* _tmp17_;
		const gchar* _tmp18_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp16_ = self->priv->status_page;
		_tmp17_ = e;
		_tmp18_ = _tmp17_->message;
		operation_status_page_set_error_state (_tmp16_, _tmp18_);
		_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;
	}
	_tmp19_ = self->priv->stack;
	gtk_stack_set_visible_child_name (_tmp19_, "operation");
}

static void
browser_page_select_all (BrowserPage* self)
{
	Browser* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->browser;
	browser_select_all (_tmp0_);
}

static void
browser_page_go_up (BrowserPage* self)
{
	Browser* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->browser;
	browser_go_up (_tmp0_);
}

static void
browser_page_activate_search (BrowserPage* self)
{
	RestoreToolbarView* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->restore_view;
	restore_toolbar_view_activate_search (_tmp0_);
}

static void
browser_page_handle_listed_current_files (BrowserPage* self,
                                          DejaDupOperationFiles* op,
                                          DejaDupFileTree* tree)
{
	Browser* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	DejaDupOperationState* _tmp3_;
	GtkStack* _tmp4_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (op != NULL);
	g_return_if_fail (tree != NULL);
	_tmp0_ = self->priv->browser;
	_tmp1_ = deja_dup_operation_files_get_tag (op);
	_tmp2_ = _tmp1_;
	browser_set_tree (_tmp0_, _tmp2_, tree);
	_tmp3_ = deja_dup_operation_get_state ((DejaDupOperation*) op);
	_deja_dup_operation_state_unref0 (self->priv->saved_state);
	self->priv->saved_state = _tmp3_;
	_tmp4_ = self->priv->stack;
	gtk_stack_set_visible_child_name (_tmp4_, "browser");
}

static void
browser_page_start_restore (BrowserPage* self)
{
	g_return_if_fail (self != NULL);
	browser_page_start_restore_async (self, NULL, NULL);
}

static void
_browser_page_start_restore_restore_toolbar_view_restore (RestoreToolbarView* _sender,
                                                          gpointer self)
{
	browser_page_start_restore ((BrowserPage*) self);
}

static void
browser_page_start_restore_async_data_free (gpointer _data)
{
	BrowserPageStartRestoreAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (BrowserPageStartRestoreAsyncData, _data_);
}

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

static void
browser_page_start_restore_async (BrowserPage* self,
                                  GAsyncReadyCallback _callback_,
                                  gpointer _user_data_)
{
	BrowserPageStartRestoreAsyncData* _data_;
	BrowserPage* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (BrowserPageStartRestoreAsyncData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, browser_page_start_restore_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	browser_page_start_restore_async_co (_data_);
}

static void
browser_page_start_restore_finish (BrowserPage* self,
                                   GAsyncResult* _res_)
{
	BrowserPageStartRestoreAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static Block3Data*
block3_data_ref (Block3Data* _data3_)
{
	g_atomic_int_inc (&_data3_->_ref_count_);
	return _data3_;
}

static void
_g_object_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
}

static inline void
_g_list_free__g_object_unref0_ (GList* self)
{
	g_list_free_full (self, (GDestroyNotify) _g_object_unref0_);
}

static void
block3_data_unref (void * _userdata_)
{
	Block3Data* _data3_;
	_data3_ = (Block3Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data3_->_ref_count_)) {
		BrowserPage* self;
		self = _data3_->self;
		_g_object_unref0 (_data3_->dlg);
		(_data3_->files == NULL) ? NULL : (_data3_->files = (_g_list_free__g_object_unref0_ (_data3_->files), NULL));
		_g_object_unref0 (self);
		g_slice_free (Block3Data, _data3_);
	}
}

static void
__lambda20_ (Block3Data* _data3_)
{
	BrowserPage* self;
	OperationLauncher* _tmp0_;
	OperationLauncher* _tmp1_;
	DejaDupOperationState* _tmp2_;
	RestoreTargetDialog* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	Browser* _tmp6_;
	DejaDupFileTree* _tmp7_;
	DejaDupFileTree* _tmp8_;
	Browser* _tmp9_;
	const gchar* _tmp10_;
	const gchar* _tmp11_;
	GList* _tmp12_;
	self = _data3_->self;
	_tmp0_ = operation_launcher_get_instance ();
	_tmp1_ = _tmp0_;
	_tmp2_ = self->priv->saved_state;
	_tmp3_ = _data3_->dlg;
	_tmp4_ = restore_target_dialog_get_restore_location (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = self->priv->browser;
	_tmp7_ = browser_get_tree (_tmp6_);
	_tmp8_ = _tmp7_;
	_tmp9_ = self->priv->browser;
	_tmp10_ = browser_get_tag (_tmp9_);
	_tmp11_ = _tmp10_;
	_tmp12_ = _data3_->files;
	operation_launcher_start_restore (_tmp1_, _tmp2_, _tmp5_, _tmp8_, _tmp11_, _tmp12_);
	_g_object_unref0 (_tmp8_);
	_g_object_unref0 (_tmp1_);
}

static void
___lambda20__action_dialog_accepted (ActionDialog* _sender,
                                     gpointer self)
{
	__lambda20_ (self);
}

static gboolean
browser_page_start_restore_async_co (BrowserPageStartRestoreAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_data3_ = g_slice_new0 (Block3Data);
	_data_->_data3_->_ref_count_ = 1;
	_data_->_data3_->self = g_object_ref (_data_->self);
	_data_->_data3_->_async_data_ = _data_;
	_data_->_tmp0_ = _data_->self->priv->browser;
	_data_->_tmp1_ = browser_get_selected_files (_data_->_tmp0_);
	_data_->_data3_->files = _data_->_tmp1_;
	_data_->_tmp2_ = _data_->_data3_->files;
	if (_data_->_tmp2_ == NULL) {
		block3_data_unref (_data_->_data3_);
		_data_->_data3_ = NULL;
		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;
	}
	_data_->_tmp3_ = _data_->self->priv->browser;
	_data_->_tmp4_ = browser_get_tree (_data_->_tmp3_);
	_data_->_tmp5_ = _data_->_tmp4_;
	_data_->_tmp6_ = _data_->_data3_->files;
	_data_->_tmp7_ = restore_target_dialog_new (_data_->_tmp5_, _data_->_tmp6_);
	g_object_ref_sink (_data_->_tmp7_);
	_data_->_tmp8_ = _data_->_tmp7_;
	_g_object_unref0 (_data_->_tmp5_);
	_data_->_data3_->dlg = _data_->_tmp8_;
	_data_->_tmp9_ = _data_->_data3_->dlg;
	g_signal_connect_data ((ActionDialog*) _data_->_tmp9_, "accepted", (GCallback) ___lambda20__action_dialog_accepted, block3_data_ref (_data_->_data3_), (GClosureNotify) block3_data_unref, 0);
	_data_->_tmp10_ = _data_->_data3_->dlg;
	adw_dialog_present ((AdwDialog*) _data_->_tmp10_, (GtkWidget*) _data_->self);
	block3_data_unref (_data_->_data3_);
	_data_->_data3_ = NULL;
	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
browser_page_handle_showing (BrowserPage* self)
{
	GtkWindow* _tmp0_;
	GSimpleActionGroup* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_window;
	_tmp1_ = self->priv->action_group;
	gtk_widget_insert_action_group ((GtkWidget*) _tmp0_, "restore", (GActionGroup*) _tmp1_);
}

static void
_browser_page_handle_showing_adw_navigation_page_showing (AdwNavigationPage* _sender,
                                                          gpointer self)
{
	browser_page_handle_showing ((BrowserPage*) self);
}

static void
browser_page_handle_hidden (BrowserPage* self)
{
	GtkWindow* _tmp0_;
	DejaDupOperation* op = NULL;
	GObject* _tmp1_;
	DejaDupOperation* _tmp2_;
	DejaDupOperation* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_window;
	gtk_widget_insert_action_group ((GtkWidget*) _tmp0_, "restore", NULL);
	_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
_browser_page_handle_hidden_adw_navigation_page_hidden (AdwNavigationPage* _sender,
                                                        gpointer self)
{
	browser_page_handle_hidden ((BrowserPage*) self);
}

static gchar*
browser_page_calculate_title (BrowserPage* self,
                              const gchar* folder_name,
                              const gchar* search_filter)
{
	gboolean _tmp0_ = FALSE;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	if (search_filter != NULL) {
		_tmp0_ = g_strcmp0 (search_filter, "") != 0;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		gchar* _tmp1_;
		_tmp1_ = g_strdup (C_ ("noun", "Search"));
		result = _tmp1_;
		return result;
	} else {
		gboolean _tmp2_ = FALSE;
		if (folder_name != NULL) {
			_tmp2_ = g_strcmp0 (folder_name, "") != 0;
		} else {
			_tmp2_ = FALSE;
		}
		if (_tmp2_) {
			gchar* _tmp3_;
			_tmp3_ = g_strdup (folder_name);
			result = _tmp3_;
			return result;
		} else {
			gchar* _tmp4_;
			_tmp4_ = g_strdup (_ ("Files"));
			result = _tmp4_;
			return result;
		}
	}
}

BrowserPage*
browser_page_construct (GType object_type)
{
	BrowserPage * self = NULL;
	self = (BrowserPage*) g_object_new (object_type, NULL);
	return self;
}

BrowserPage*
browser_page_new (void)
{
	return browser_page_construct (TYPE_BROWSER_PAGE);
}

GtkWindow*
browser_page_get_window (BrowserPage* self)
{
	GtkWindow* result;
	GtkWindow* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_window;
	result = _tmp0_;
	return result;
}

void
browser_page_set_window (BrowserPage* self,
                         GtkWindow* value)
{
	GtkWindow* old_value;
	g_return_if_fail (self != NULL);
	old_value = browser_page_get_window (self);
	if (old_value != value) {
		GtkWindow* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_window);
		self->priv->_window = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, browser_page_properties[BROWSER_PAGE_WINDOW_PROPERTY]);
	}
}

static GObject *
browser_page_constructor (GType type,
                          guint n_construct_properties,
                          GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	BrowserPage * self;
	GSimpleActionGroup* _tmp0_;
	GSimpleActionGroup* _tmp1_;
	GAction* go_up_action = NULL;
	GSimpleActionGroup* _tmp2_;
	GAction* _tmp3_;
	GAction* _tmp4_;
	Browser* _tmp5_;
	GAction* _tmp6_;
	GAction* select_all_action = NULL;
	GSimpleActionGroup* _tmp7_;
	GAction* _tmp8_;
	GAction* _tmp9_;
	Browser* _tmp10_;
	GAction* _tmp11_;
	parent_class = G_OBJECT_CLASS (browser_page_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_BROWSER_PAGE, BrowserPage);
	_tmp0_ = g_simple_action_group_new ();
	_g_object_unref0 (self->priv->action_group);
	self->priv->action_group = _tmp0_;
	_tmp1_ = self->priv->action_group;
	g_action_map_add_action_entries ((GActionMap*) _tmp1_, BROWSER_PAGE_ACTIONS, (gint) G_N_ELEMENTS (BROWSER_PAGE_ACTIONS), self);
	_tmp2_ = self->priv->action_group;
	_tmp3_ = g_action_map_lookup_action ((GActionMap*) _tmp2_, "go-up");
	_tmp4_ = _g_object_ref0 (_tmp3_);
	go_up_action = _tmp4_;
	_tmp5_ = self->priv->browser;
	_tmp6_ = go_up_action;
	g_object_bind_property_with_closures ((GObject*) _tmp5_, "can-go-up", (GObject*) _tmp6_, "enabled", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp7_ = self->priv->action_group;
	_tmp8_ = g_action_map_lookup_action ((GActionMap*) _tmp7_, "select-all");
	_tmp9_ = _g_object_ref0 (_tmp8_);
	select_all_action = _tmp9_;
	_tmp10_ = self->priv->browser;
	_tmp11_ = select_all_action;
	g_object_bind_property_with_closures ((GObject*) _tmp10_, "has-content", (GObject*) _tmp11_, "enabled", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_g_object_unref0 (select_all_action);
	_g_object_unref0 (go_up_action);
	return obj;
}

static void
browser_page_class_init (BrowserPageClass * klass,
                         gpointer klass_data)
{
	browser_page_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &BrowserPage_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_browser_page_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_browser_page_set_property;
	G_OBJECT_CLASS (klass)->constructor = browser_page_constructor;
	G_OBJECT_CLASS (klass)->finalize = browser_page_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), BROWSER_PAGE_WINDOW_PROPERTY, browser_page_properties[BROWSER_PAGE_WINDOW_PROPERTY] = g_param_spec_object ("window", "window", "window", gtk_window_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/DejaDup/BrowserPage.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "restore_view", FALSE, BrowserPage_private_offset + G_STRUCT_OFFSET (BrowserPagePrivate, restore_view));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "stack", FALSE, BrowserPage_private_offset + G_STRUCT_OFFSET (BrowserPagePrivate, stack));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "status_page", FALSE, BrowserPage_private_offset + G_STRUCT_OFFSET (BrowserPagePrivate, status_page));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "browser", FALSE, BrowserPage_private_offset + G_STRUCT_OFFSET (BrowserPagePrivate, browser));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "start_restore", G_CALLBACK(_browser_page_start_restore_restore_toolbar_view_restore));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "handle_showing", G_CALLBACK(_browser_page_handle_showing_adw_navigation_page_showing));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "handle_hidden", G_CALLBACK(_browser_page_handle_hidden_adw_navigation_page_hidden));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "calculate_title", G_CALLBACK(browser_page_calculate_title));
}

static void
browser_page_instance_init (BrowserPage * self,
                            gpointer klass)
{
	self->priv = browser_page_get_instance_private (self);
	g_type_ensure (TYPE_RESTORE_TOOLBAR_VIEW);
	g_type_ensure (TYPE_OPERATION_STATUS_PAGE);
	g_type_ensure (TYPE_BROWSER);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
browser_page_finalize (GObject * obj)
{
	BrowserPage * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_BROWSER_PAGE, BrowserPage);
	_g_object_unref0 (self->priv->_window);
	_g_object_unref0 (self->priv->action_group);
	g_weak_ref_clear (&self->priv->operation);
	_deja_dup_operation_state_unref0 (self->priv->saved_state);
	G_OBJECT_CLASS (browser_page_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
browser_page_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BrowserPageClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) browser_page_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BrowserPage), 0, (GInstanceInitFunc) browser_page_instance_init, NULL };
	GType browser_page_type_id;
	browser_page_type_id = g_type_register_static (adw_navigation_page_get_type (), "BrowserPage", &g_define_type_info, 0);
	BrowserPage_private_offset = g_type_add_instance_private (browser_page_type_id, sizeof (BrowserPagePrivate));
	return browser_page_type_id;
}

GType
browser_page_get_type (void)
{
	static gsize browser_page_type_id__once = 0;
	if (g_once_init_enter (&browser_page_type_id__once)) {
		GType browser_page_type_id;
		browser_page_type_id = browser_page_get_type_once ();
		g_once_init_leave (&browser_page_type_id__once, browser_page_type_id);
	}
	return browser_page_type_id__once;
}

static void
_vala_browser_page_get_property (GObject * object,
                                 guint property_id,
                                 GValue * value,
                                 GParamSpec * pspec)
{
	BrowserPage * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_BROWSER_PAGE, BrowserPage);
	switch (property_id) {
		case BROWSER_PAGE_WINDOW_PROPERTY:
		g_value_set_object (value, browser_page_get_window (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_browser_page_set_property (GObject * object,
                                 guint property_id,
                                 const GValue * value,
                                 GParamSpec * pspec)
{
	BrowserPage * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_BROWSER_PAGE, BrowserPage);
	switch (property_id) {
		case BROWSER_PAGE_WINDOW_PROPERTY:
		browser_page_set_window (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

