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

#include <glib-object.h>
#include <gtk/gtk.h>
#include <glib.h>
#include <adwaita.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <gdk/gdk.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <float.h>
#include <math.h>
#include <json-glib/json-glib.h>
#include <pango/pango.h>
#include <gobject/gvaluecollector.h>

#define DC_GALLERY_DIALOG_CELL_MIN 76
#define DC_GALLERY_DIALOG_CELL_MAX 512
#define DC_GALLERY_DIALOG_FETCH_CHUNK 50
#define DC_GALLERY_DIALOG_ZOOM_COLUMNS_MAX 12
#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 DC_TYPE_GALLERY_CELL (dc_gallery_cell_get_type ())
#define DC_GALLERY_CELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_GALLERY_CELL, DcGalleryCell))
#define DC_IS_GALLERY_CELL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_GALLERY_CELL))
#define DC_GALLERY_CELL_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), DC_TYPE_GALLERY_CELL, DcGalleryCellIface))

typedef struct _DcGalleryCell DcGalleryCell;
typedef struct _DcGalleryCellIface DcGalleryCellIface;

#define DC_TYPE_MESSAGE (dc_message_get_type ())
#define DC_MESSAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_MESSAGE, DcMessage))
#define DC_MESSAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_MESSAGE, DcMessageClass))
#define DC_IS_MESSAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_MESSAGE))
#define DC_IS_MESSAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_MESSAGE))
#define DC_MESSAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_MESSAGE, DcMessageClass))

typedef struct _DcMessage DcMessage;
typedef struct _DcMessageClass DcMessageClass;

#define DC_TYPE_GALLERY_DIALOG (dc_gallery_dialog_get_type ())
#define DC_GALLERY_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_GALLERY_DIALOG, DcGalleryDialog))
#define DC_GALLERY_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_GALLERY_DIALOG, DcGalleryDialogClass))
#define DC_IS_GALLERY_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_GALLERY_DIALOG))
#define DC_IS_GALLERY_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_GALLERY_DIALOG))
#define DC_GALLERY_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_GALLERY_DIALOG, DcGalleryDialogClass))

typedef struct _DcGalleryDialog DcGalleryDialog;
typedef struct _DcGalleryDialogClass DcGalleryDialogClass;
typedef struct _DcGalleryDialogPrivate DcGalleryDialogPrivate;

#define DC_TYPE_WINDOW (dc_window_get_type ())
#define DC_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_WINDOW, DcWindow))
#define DC_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_WINDOW, DcWindowClass))
#define DC_IS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_WINDOW))
#define DC_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_WINDOW))
#define DC_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_WINDOW, DcWindowClass))

typedef struct _DcWindow DcWindow;
typedef struct _DcWindowClass DcWindowClass;

#define DC_TYPE_RPC_CLIENT (dc_rpc_client_get_type ())
#define DC_RPC_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_RPC_CLIENT, DcRpcClient))
#define DC_RPC_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_RPC_CLIENT, DcRpcClientClass))
#define DC_IS_RPC_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_RPC_CLIENT))
#define DC_IS_RPC_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_RPC_CLIENT))
#define DC_RPC_CLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_RPC_CLIENT, DcRpcClientClass))

typedef struct _DcRpcClient DcRpcClient;
typedef struct _DcRpcClientClass DcRpcClientClass;

#define DC_TYPE_IMAGE_VIEWER (dc_image_viewer_get_type ())
#define DC_IMAGE_VIEWER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_IMAGE_VIEWER, DcImageViewer))
#define DC_IMAGE_VIEWER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_IMAGE_VIEWER, DcImageViewerClass))
#define DC_IS_IMAGE_VIEWER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_IMAGE_VIEWER))
#define DC_IS_IMAGE_VIEWER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_IMAGE_VIEWER))
#define DC_IMAGE_VIEWER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_IMAGE_VIEWER, DcImageViewerClass))

typedef struct _DcImageViewer DcImageViewer;
typedef struct _DcImageViewerClass DcImageViewerClass;

#define DC_TYPE_VIDEO_PLAYER (dc_video_player_get_type ())
#define DC_VIDEO_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_VIDEO_PLAYER, DcVideoPlayer))
#define DC_VIDEO_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_VIDEO_PLAYER, DcVideoPlayerClass))
#define DC_IS_VIDEO_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_VIDEO_PLAYER))
#define DC_IS_VIDEO_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_VIDEO_PLAYER))
#define DC_VIDEO_PLAYER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_VIDEO_PLAYER, DcVideoPlayerClass))

typedef struct _DcVideoPlayer DcVideoPlayer;
typedef struct _DcVideoPlayerClass DcVideoPlayerClass;

#define DC_GALLERY_DIALOG_TYPE_GALLERY_TAB (dc_gallery_dialog_gallery_tab_get_type ())
#define DC_GALLERY_DIALOG_GALLERY_TAB(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_GALLERY_DIALOG_TYPE_GALLERY_TAB, DcGalleryDialogGalleryTab))
#define DC_GALLERY_DIALOG_GALLERY_TAB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_GALLERY_DIALOG_TYPE_GALLERY_TAB, DcGalleryDialogGalleryTabClass))
#define DC_GALLERY_DIALOG_IS_GALLERY_TAB(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_GALLERY_DIALOG_TYPE_GALLERY_TAB))
#define DC_GALLERY_DIALOG_IS_GALLERY_TAB_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_GALLERY_DIALOG_TYPE_GALLERY_TAB))
#define DC_GALLERY_DIALOG_GALLERY_TAB_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_GALLERY_DIALOG_TYPE_GALLERY_TAB, DcGalleryDialogGalleryTabClass))

typedef struct _DcGalleryDialogGalleryTab DcGalleryDialogGalleryTab;
typedef struct _DcGalleryDialogGalleryTabClass DcGalleryDialogGalleryTabClass;

#define DC_GALLERY_DIALOG_TYPE_THUMB_REQUEST (dc_gallery_dialog_thumb_request_get_type ())
#define DC_GALLERY_DIALOG_THUMB_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_GALLERY_DIALOG_TYPE_THUMB_REQUEST, DcGalleryDialogThumbRequest))
#define DC_GALLERY_DIALOG_THUMB_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_GALLERY_DIALOG_TYPE_THUMB_REQUEST, DcGalleryDialogThumbRequestClass))
#define DC_GALLERY_DIALOG_IS_THUMB_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_GALLERY_DIALOG_TYPE_THUMB_REQUEST))
#define DC_GALLERY_DIALOG_IS_THUMB_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_GALLERY_DIALOG_TYPE_THUMB_REQUEST))
#define DC_GALLERY_DIALOG_THUMB_REQUEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_GALLERY_DIALOG_TYPE_THUMB_REQUEST, DcGalleryDialogThumbRequestClass))

typedef struct _DcGalleryDialogThumbRequest DcGalleryDialogThumbRequest;
typedef struct _DcGalleryDialogThumbRequestClass DcGalleryDialogThumbRequestClass;
enum  {
	DC_GALLERY_DIALOG_0_PROPERTY,
	DC_GALLERY_DIALOG_SELECTION_MODE_PROPERTY,
	DC_GALLERY_DIALOG_NUM_PROPERTIES
};
static GParamSpec* dc_gallery_dialog_properties[DC_GALLERY_DIALOG_NUM_PROPERTIES];
typedef enum  {
	DC_GALLERY_DIALOG_MEDIA_FILTER_ALL,
	DC_GALLERY_DIALOG_MEDIA_FILTER_STICKERS_ONLY,
	DC_GALLERY_DIALOG_MEDIA_FILTER_NO_STICKERS
} DcGalleryDialogMediaFilter;

#define DC_GALLERY_DIALOG_TYPE_MEDIA_FILTER (dc_gallery_dialog_media_filter_get_type ())
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
#define _g_thread_pool_free0(var) ((var == NULL) ? NULL : (var = (g_thread_pool_free (var, FALSE, TRUE), NULL)))
typedef struct _Block103Data Block103Data;
typedef struct _DcGalleryDialogThumbRequestPrivate DcGalleryDialogThumbRequestPrivate;
#define _dc_gallery_dialog_thumb_request_unref0(var) ((var == NULL) ? NULL : (var = (dc_gallery_dialog_thumb_request_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _DcGalleryDialogGalleryTabPrivate DcGalleryDialogGalleryTabPrivate;
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block104Data Block104Data;
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))

#define DC_TYPE_AUDIO_PLAYBACK (dc_audio_playback_get_type ())
#define DC_AUDIO_PLAYBACK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_AUDIO_PLAYBACK, DcAudioPlayback))
#define DC_AUDIO_PLAYBACK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_AUDIO_PLAYBACK, DcAudioPlaybackClass))
#define DC_IS_AUDIO_PLAYBACK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_AUDIO_PLAYBACK))
#define DC_IS_AUDIO_PLAYBACK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_AUDIO_PLAYBACK))
#define DC_AUDIO_PLAYBACK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_AUDIO_PLAYBACK, DcAudioPlaybackClass))

typedef struct _DcAudioPlayback DcAudioPlayback;
typedef struct _DcAudioPlaybackClass DcAudioPlaybackClass;

#define DC_TYPE_CONTACT_PICKER_DIALOG (dc_contact_picker_dialog_get_type ())
#define DC_CONTACT_PICKER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_CONTACT_PICKER_DIALOG, DcContactPickerDialog))
#define DC_CONTACT_PICKER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_CONTACT_PICKER_DIALOG, DcContactPickerDialogClass))
#define DC_IS_CONTACT_PICKER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_CONTACT_PICKER_DIALOG))
#define DC_IS_CONTACT_PICKER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_CONTACT_PICKER_DIALOG))
#define DC_CONTACT_PICKER_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_CONTACT_PICKER_DIALOG, DcContactPickerDialogClass))

typedef struct _DcContactPickerDialog DcContactPickerDialog;
typedef struct _DcContactPickerDialogClass DcContactPickerDialogClass;
typedef enum  {
	DC_DELETE_CHOICE_CANCEL,
	DC_DELETE_CHOICE_FOR_ME,
	DC_DELETE_CHOICE_FOR_EVERYONE
} DcDeleteChoice;

#define DC_TYPE_DELETE_CHOICE (dc_delete_choice_get_type ())
typedef struct _DcGalleryDialogConfirmDeleteIdsData DcGalleryDialogConfirmDeleteIdsData;
#define _json_array_unref0(var) ((var == NULL) ? NULL : (var = (json_array_unref (var), NULL)))
typedef struct _DcGalleryDialogLoadTabData DcGalleryDialogLoadTabData;
typedef struct _Block105Data Block105Data;

#define DC_GALLERY_DIALOG_TYPE_MEDIA_CELL (dc_gallery_dialog_media_cell_get_type ())
#define DC_GALLERY_DIALOG_MEDIA_CELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_GALLERY_DIALOG_TYPE_MEDIA_CELL, DcGalleryDialogMediaCell))
#define DC_GALLERY_DIALOG_MEDIA_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_GALLERY_DIALOG_TYPE_MEDIA_CELL, DcGalleryDialogMediaCellClass))
#define DC_GALLERY_DIALOG_IS_MEDIA_CELL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_GALLERY_DIALOG_TYPE_MEDIA_CELL))
#define DC_GALLERY_DIALOG_IS_MEDIA_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_GALLERY_DIALOG_TYPE_MEDIA_CELL))
#define DC_GALLERY_DIALOG_MEDIA_CELL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_GALLERY_DIALOG_TYPE_MEDIA_CELL, DcGalleryDialogMediaCellClass))

typedef struct _DcGalleryDialogMediaCell DcGalleryDialogMediaCell;
typedef struct _DcGalleryDialogMediaCellClass DcGalleryDialogMediaCellClass;
#define _g_source_unref0(var) ((var == NULL) ? NULL : (var = (g_source_unref (var), NULL)))
typedef struct _DcGalleryDialogLoadThumbData DcGalleryDialogLoadThumbData;
typedef struct _Block106Data Block106Data;

#define DC_GALLERY_DIALOG_TYPE_GALLERY_ROW (dc_gallery_dialog_gallery_row_get_type ())
#define DC_GALLERY_DIALOG_GALLERY_ROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_GALLERY_DIALOG_TYPE_GALLERY_ROW, DcGalleryDialogGalleryRow))
#define DC_GALLERY_DIALOG_GALLERY_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_GALLERY_DIALOG_TYPE_GALLERY_ROW, DcGalleryDialogGalleryRowClass))
#define DC_GALLERY_DIALOG_IS_GALLERY_ROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_GALLERY_DIALOG_TYPE_GALLERY_ROW))
#define DC_GALLERY_DIALOG_IS_GALLERY_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_GALLERY_DIALOG_TYPE_GALLERY_ROW))
#define DC_GALLERY_DIALOG_GALLERY_ROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_GALLERY_DIALOG_TYPE_GALLERY_ROW, DcGalleryDialogGalleryRowClass))

typedef struct _DcGalleryDialogGalleryRow DcGalleryDialogGalleryRow;
typedef struct _DcGalleryDialogGalleryRowClass DcGalleryDialogGalleryRowClass;
typedef struct _Block107Data Block107Data;
typedef struct _Block108Data Block108Data;
typedef struct _Block109Data Block109Data;
typedef struct _Block110Data Block110Data;
typedef struct _Block111Data Block111Data;
typedef struct _Block112Data Block112Data;

#define DC_TYPE_POPOVER_BUTTON (dc_popover_button_get_type ())
#define DC_POPOVER_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_POPOVER_BUTTON, DcPopoverButton))
#define DC_POPOVER_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_POPOVER_BUTTON, DcPopoverButtonClass))
#define DC_IS_POPOVER_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_POPOVER_BUTTON))
#define DC_IS_POPOVER_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_POPOVER_BUTTON))
#define DC_POPOVER_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_POPOVER_BUTTON, DcPopoverButtonClass))

typedef struct _DcPopoverButton DcPopoverButton;
typedef struct _DcPopoverButtonClass DcPopoverButtonClass;
typedef struct _Block113Data Block113Data;
typedef struct _Block114Data Block114Data;
typedef struct _Block115Data Block115Data;
typedef struct _DcGalleryDialogDeleteMessagesUiData DcGalleryDialogDeleteMessagesUiData;
typedef struct _Block116Data Block116Data;
typedef struct _Block117Data Block117Data;
typedef struct _DcGalleryDialogSaveFilesToFolderData DcGalleryDialogSaveFilesToFolderData;
enum  {
	DC_GALLERY_DIALOG_GALLERY_TAB_0_PROPERTY,
	DC_GALLERY_DIALOG_GALLERY_TAB_NUM_PROPERTIES
};
static GParamSpec* dc_gallery_dialog_gallery_tab_properties[DC_GALLERY_DIALOG_GALLERY_TAB_NUM_PROPERTIES];
typedef struct _DcGalleryDialogParamSpecThumbRequest DcGalleryDialogParamSpecThumbRequest;
typedef struct _DcGalleryDialogMediaCellPrivate DcGalleryDialogMediaCellPrivate;
enum  {
	DC_GALLERY_DIALOG_MEDIA_CELL_0_PROPERTY,
	DC_GALLERY_DIALOG_MEDIA_CELL_MSG_PROPERTY,
	DC_GALLERY_DIALOG_MEDIA_CELL_NUM_PROPERTIES
};
static GParamSpec* dc_gallery_dialog_media_cell_properties[DC_GALLERY_DIALOG_MEDIA_CELL_NUM_PROPERTIES];

#define DC_TYPE_SCALED_PREVIEW_FRAME (dc_scaled_preview_frame_get_type ())
#define DC_SCALED_PREVIEW_FRAME(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_SCALED_PREVIEW_FRAME, DcScaledPreviewFrame))
#define DC_SCALED_PREVIEW_FRAME_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_SCALED_PREVIEW_FRAME, DcScaledPreviewFrameClass))
#define DC_IS_SCALED_PREVIEW_FRAME(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_SCALED_PREVIEW_FRAME))
#define DC_IS_SCALED_PREVIEW_FRAME_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_SCALED_PREVIEW_FRAME))
#define DC_SCALED_PREVIEW_FRAME_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_SCALED_PREVIEW_FRAME, DcScaledPreviewFrameClass))

typedef struct _DcScaledPreviewFrame DcScaledPreviewFrame;
typedef struct _DcScaledPreviewFrameClass DcScaledPreviewFrameClass;
typedef struct _Block118Data Block118Data;
typedef struct _DcGalleryDialogGalleryRowPrivate DcGalleryDialogGalleryRowPrivate;
enum  {
	DC_GALLERY_DIALOG_GALLERY_ROW_0_PROPERTY,
	DC_GALLERY_DIALOG_GALLERY_ROW_MSG_PROPERTY,
	DC_GALLERY_DIALOG_GALLERY_ROW_NUM_PROPERTIES
};
static GParamSpec* dc_gallery_dialog_gallery_row_properties[DC_GALLERY_DIALOG_GALLERY_ROW_NUM_PROPERTIES];
typedef struct _Block119Data Block119Data;
typedef struct _Block120Data Block120Data;
enum  {
	DC_GALLERY_DIALOG_SELECTION_CHANGED_SIGNAL,
	DC_GALLERY_DIALOG_NUM_SIGNALS
};
static guint dc_gallery_dialog_signals[DC_GALLERY_DIALOG_NUM_SIGNALS] = {0};

struct _DcGalleryCellIface {
	GTypeInterface parent_iface;
	void (*bind) (DcGalleryCell* self, DcMessage* m);
	void (*unbind) (DcGalleryCell* self);
	DcMessage* (*get_msg) (DcGalleryCell* self);
	void (*set_msg) (DcGalleryCell* self, DcMessage* value);
};

struct _DcGalleryDialog {
	AdwDialog parent_instance;
	DcGalleryDialogPrivate * priv;
	AdwDialog* presenter_dialog;
};

struct _DcGalleryDialogClass {
	AdwDialogClass parent_class;
};

struct _DcGalleryDialogPrivate {
	DcWindow* app_window;
	DcRpcClient* rpc;
	gint chat_id;
	AdwViewStack* view_stack;
	AdwToastOverlay* toasts;
	GtkButton* save_all_btn;
	GtkMenuButton* more_btn;
	GSimpleAction* section_action;
	DcImageViewer* viewer;
	DcVideoPlayer* player;
	GtkBox* switcher_bar;
	GtkBox* selection_bar;
	GtkRevealer* selection_revealer;
	GtkLabel* selection_label;
	GtkButton* forward_sel_btn;
	GtkButton* save_sel_btn;
	GtkButton* delete_sel_btn;
	gboolean _selection_mode;
	GHashTable* selected_ids;
	DcGalleryDialogGalleryTab** tabs;
	gint tabs_length1;
	gint _tabs_size_;
	GtkGridView** media_grids;
	gint media_grids_length1;
	gint _media_grids_size_;
	gboolean is_open;
	GHashTable* thumb_cache;
	GThreadPool* thumb_pool;
	gboolean playback_was_started;
};

struct _Block103Data {
	int _ref_count_;
	DcGalleryDialog* self;
	GtkEventControllerScroll* zoom_ctrl;
};

struct _DcGalleryDialogThumbRequest {
	GTypeInstance parent_instance;
	volatile int ref_count;
	DcGalleryDialogThumbRequestPrivate * priv;
	gchar* path;
	gint size;
	GSource* resume_source;
	GdkTexture* result;
};

struct _DcGalleryDialogThumbRequestClass {
	GTypeClass parent_class;
	void (*finalize) (DcGalleryDialogThumbRequest *self);
};

struct _DcGalleryDialogGalleryTab {
	GObject parent_instance;
	DcGalleryDialogGalleryTabPrivate * priv;
	gchar* key;
	gchar* title;
	gchar* icon_name;
	gchar** types;
	gint types_length1;
	gint _types_size_;
	DcGalleryDialogMediaFilter filter;
	gchar* empty_title;
	gchar* empty_description;
	gchar* kind_plural;
	gboolean overflow;
	GListStore* store;
	GtkStack* stack;
	gboolean load_started;
};

struct _DcGalleryDialogGalleryTabClass {
	GObjectClass parent_class;
};

struct _Block104Data {
	int _ref_count_;
	Block103Data * _data103_;
	DcGalleryDialogGalleryTab* tab;
};

struct _DcGalleryDialogConfirmDeleteIdsData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcGalleryDialog* self;
	gint* ids;
	gint ids_length1;
	gboolean all_outgoing;
	const gchar* _tmp0_;
	gchar* title;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* what;
	gchar* _tmp5_;
	gchar* _tmp6_;
	const gchar* _tmp7_;
	gchar* _tmp8_;
	const gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* body;
	gchar* _tmp11_;
	DcDeleteChoice choice;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	gint* _tmp14_;
	gint _tmp14__length1;
	gint* _tmp15_;
	gint _tmp15__length1;
};

struct _DcGalleryDialogLoadTabData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcGalleryDialog* self;
	DcGalleryDialogGalleryTab* tab;
	gboolean _tmp0_;
	gint* ids;
	gint ids_length1;
	gint _ids_size_;
	const gchar* _tmp1_;
	gint* _tmp2_;
	JsonArray* arr;
	DcRpcClient* _tmp3_;
	DcRpcClient* _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	JsonArray* _tmp7_;
	JsonArray* _tmp8_;
	guint i;
	gboolean _tmp9_;
	guint _tmp10_;
	JsonArray* _tmp11_;
	JsonArray* _tmp12_;
	gint* _tmp13_;
	DcRpcClient* _tmp14_;
	gchar** _tmp15_;
	gint _tmp15__length1;
	gint _tmp16_;
	gint* _tmp17_;
	gint _tmp13__length1;
	gint __tmp13__size_;
	gint* _tmp18_;
	gint _tmp18__length1;
	gint _vala1_i;
	gint j;
	gint* _tmp19_;
	gint _tmp19__length1;
	gboolean _tmp20_;
	gint _tmp21_;
	gint _tmp22_;
	gint t;
	gint* _tmp23_;
	gint _tmp23__length1;
	gint _tmp24_;
	gint* _tmp25_;
	gint _tmp25__length1;
	gint* _tmp26_;
	gint _tmp26__length1;
	gint _tmp27_;
	gint* _tmp28_;
	gint _tmp28__length1;
	gint off;
	gboolean _tmp29_;
	gint* _tmp30_;
	gint _tmp30__length1;
	gint len;
	gint* _tmp31_;
	gint _tmp31__length1;
	DcMessage** msgs;
	DcRpcClient* _tmp32_;
	gint* _tmp33_;
	gint _tmp33__length1;
	gint _tmp34_;
	DcMessage** _tmp35_;
	gint msgs_length1;
	gint _msgs_size_;
	DcMessage** _tmp36_;
	gint _tmp36__length1;
	GListStore* _tmp37_;
	GtkStack* _tmp38_;
	GError* e;
	GError* _tmp39_;
	const gchar* _tmp40_;
	gchar* _tmp41_;
	gchar* _tmp42_;
	GListStore* _tmp43_;
	GtkStack* _tmp44_;
	GError* _inner_error0_;
};

struct _Block105Data {
	int _ref_count_;
	DcGalleryDialog* self;
	gboolean is_video;
	gboolean contain;
	DcGalleryDialogGalleryTab* tab;
};

struct _DcGalleryDialogLoadThumbData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcGalleryDialog* self;
	gchar* path;
	GdkTexture* result;
	GdkTexture* cached;
	GHashTable* _tmp0_;
	gconstpointer _tmp1_;
	GdkTexture* _tmp2_;
	GdkTexture* _tmp3_;
	GThreadPool* _tmp4_;
	DcGalleryDialogThumbRequest* req;
	DcGalleryDialogThumbRequest* _tmp5_;
	DcGalleryDialogThumbRequest* _tmp6_;
	gchar* _tmp7_;
	DcGalleryDialogThumbRequest* _tmp8_;
	DcGalleryDialogThumbRequest* _tmp9_;
	GSource* _tmp10_;
	DcGalleryDialogThumbRequest* _tmp11_;
	GSource* _tmp12_;
	GThreadPool* _tmp13_;
	DcGalleryDialogThumbRequest* _tmp14_;
	DcGalleryDialogThumbRequest* _tmp15_;
	DcGalleryDialogThumbRequest* _tmp16_;
	GdkTexture* _tmp17_;
	GHashTable* _tmp18_;
	gchar* _tmp19_;
	DcGalleryDialogThumbRequest* _tmp20_;
	GdkTexture* _tmp21_;
	GdkTexture* _tmp22_;
	DcGalleryDialogThumbRequest* _tmp23_;
	GdkTexture* _tmp24_;
	GdkTexture* _tmp25_;
	GError* _inner_error0_;
};

struct _Block106Data {
	int _ref_count_;
	DcGalleryDialog* self;
	DcGalleryDialogGalleryTab* tab;
};

struct _Block107Data {
	int _ref_count_;
	DcGalleryDialog* self;
	GtkUriLauncher* launcher;
};

struct _Block108Data {
	int _ref_count_;
	DcGalleryDialog* self;
	GtkFileLauncher* launcher;
};

struct _Block109Data {
	int _ref_count_;
	GtkWidget* widget;
	DcGalleryCell* cell;
	DcGalleryDialog* dialog;
};

struct _Block110Data {
	int _ref_count_;
	DcGalleryDialog* self;
	GtkWidget* view;
};

struct _Block111Data {
	int _ref_count_;
	DcGalleryDialog* self;
	gint msg_id;
	gboolean is_outgoing;
};

struct _Block112Data {
	int _ref_count_;
	Block111Data * _data111_;
	gchar* link0;
};

struct _Block113Data {
	int _ref_count_;
	Block111Data * _data111_;
	gchar* fpath;
	gchar* fname;
};

struct _Block114Data {
	int _ref_count_;
	Block111Data * _data111_;
	gint target_chat;
	AdwDialog* presenter;
};

struct _Block115Data {
	int _ref_count_;
	Block111Data * _data111_;
	gchar* spath;
};

struct _DcGalleryDialogDeleteMessagesUiData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcGalleryDialog* self;
	gint* ids;
	gint ids_length1;
	gboolean for_all;
	DcRpcClient* _tmp0_;
	DcRpcClient* _tmp1_;
	GHashTable* deleted;
	GHashFunc _tmp2_;
	GEqualFunc _tmp3_;
	GHashTable* _tmp4_;
	gint* msg_id_collection;
	gint msg_id_collection_length1;
	gint _msg_id_collection_size_;
	gint msg_id_it;
	gint msg_id;
	GHashTable* _tmp5_;
	GHashTable* _tmp6_;
	DcGalleryDialogGalleryTab** _tmp7_;
	gint _tmp7__length1;
	DcGalleryDialogGalleryTab** tab_collection;
	gint tab_collection_length1;
	gint _tab_collection_size_;
	gint tab_it;
	DcGalleryDialogGalleryTab* _tmp8_;
	DcGalleryDialogGalleryTab* tab;
	gint i;
	DcGalleryDialogGalleryTab* _tmp9_;
	GListStore* _tmp10_;
	gboolean _tmp11_;
	gint _tmp12_;
	DcMessage* m;
	DcGalleryDialogGalleryTab* _tmp13_;
	GListStore* _tmp14_;
	GObject* _tmp15_;
	gboolean _tmp16_;
	DcMessage* _tmp17_;
	GHashTable* _tmp18_;
	DcMessage* _tmp19_;
	gint _tmp20_;
	gint _tmp21_;
	DcGalleryDialogGalleryTab* _tmp22_;
	GListStore* _tmp23_;
	gboolean _tmp24_;
	DcGalleryDialogGalleryTab* _tmp25_;
	DcGalleryDialogGalleryTab* _tmp26_;
	GListStore* _tmp27_;
	DcGalleryDialogGalleryTab* _tmp28_;
	GtkStack* _tmp29_;
	DcWindow* _tmp30_;
	gchar* _tmp31_;
	gchar* _tmp32_;
	gchar* _tmp33_;
	GError* e;
	GError* _tmp34_;
	const gchar* _tmp35_;
	gchar* _tmp36_;
	gchar* _tmp37_;
	gboolean _tmp38_;
	gboolean _tmp39_;
	GHashTable* _tmp40_;
	gboolean _tmp41_;
	GError* _inner_error0_;
};

struct _Block116Data {
	int _ref_count_;
	DcGalleryDialog* self;
	DcMessage** items;
	gint items_length1;
	gint _items_size_;
	gint skipped;
	GtkFileDialog* chooser;
	gboolean exit_selection;
};

struct _Block117Data {
	int _ref_count_;
	DcGalleryDialog* self;
	GCancellable* cancellable;
	gboolean finished;
	gpointer _async_data_;
};

struct _DcGalleryDialogSaveFilesToFolderData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcGalleryDialog* self;
	DcMessage** items;
	gint items_length1;
	gint skipped;
	GFile* folder;
	Block117Data* _data117_;
	GtkProgressBar* progress;
	GtkProgressBar* _tmp0_;
	GtkProgressBar* _tmp1_;
	GtkLabel* file_label;
	GtkLabel* _tmp2_;
	GtkLabel* _tmp3_;
	GtkLabel* _tmp4_;
	GtkLabel* _tmp5_;
	GtkBox* pbox;
	GtkBox* _tmp6_;
	GtkBox* _tmp7_;
	GtkProgressBar* _tmp8_;
	GtkBox* _tmp9_;
	GtkLabel* _tmp10_;
	AdwAlertDialog* alert;
	AdwAlertDialog* _tmp11_;
	AdwAlertDialog* _tmp12_;
	GtkBox* _tmp13_;
	AdwAlertDialog* _tmp14_;
	AdwAlertDialog* _tmp15_;
	GCancellable* _tmp16_;
	AdwAlertDialog* _tmp17_;
	AdwAlertDialog* _tmp18_;
	gint saved;
	gint failed;
	gint i;
	gboolean _tmp19_;
	gint _tmp20_;
	GCancellable* _tmp21_;
	DcMessage* m;
	DcMessage* _tmp22_;
	DcMessage* _tmp23_;
	gchar* name;
	DcMessage* _tmp24_;
	DcMessage* _tmp25_;
	const gchar* _tmp26_;
	const gchar* _tmp27_;
	gchar* _tmp28_;
	gchar* _tmp29_;
	gchar* _tmp30_;
	gchar* _tmp31_;
	GtkProgressBar* _tmp32_;
	GtkProgressBar* _tmp33_;
	gchar* _tmp34_;
	gchar* _tmp35_;
	GtkProgressBar* _tmp36_;
	GtkLabel* _tmp37_;
	const gchar* _tmp38_;
	GFile* src;
	DcMessage* _tmp39_;
	const gchar* _tmp40_;
	const gchar* _tmp41_;
	GFile* _tmp42_;
	GFile* dest;
	const gchar* _tmp43_;
	GFile* _tmp44_;
	GFile* _tmp45_;
	GFile* _tmp46_;
	GCancellable* _tmp47_;
	gint _tmp48_;
	GError* e;
	GError* _tmp49_;
	gint _tmp50_;
	AdwAlertDialog* _tmp51_;
	gchar* summary;
	GCancellable* _tmp52_;
	const gchar* _tmp53_;
	gchar* _tmp54_;
	const gchar* _tmp55_;
	gchar* _tmp56_;
	const gchar* _tmp57_;
	gchar* _tmp58_;
	gchar* _tmp59_;
	gchar* _tmp60_;
	const gchar* _tmp61_;
	gchar* _tmp62_;
	gchar* _tmp63_;
	gchar* _tmp64_;
	const gchar* _tmp65_;
	GError* _inner_error0_;
};

struct _DcGalleryDialogParamSpecThumbRequest {
	GParamSpec parent_instance;
};

struct _DcGalleryDialogMediaCell {
	GtkBox parent_instance;
	DcGalleryDialogMediaCellPrivate * priv;
};

struct _DcGalleryDialogMediaCellClass {
	GtkBoxClass parent_class;
};

struct _DcGalleryDialogMediaCellPrivate {
	DcMessage* _msg;
	DcGalleryDialog* dialog;
	gboolean is_video;
	GtkPicture* picture;
	GtkImage* placeholder;
	GtkBox* play_badge;
	GtkCheckButton* check;
	gint generation;
};

struct _Block118Data {
	int _ref_count_;
	DcGalleryDialogMediaCell* self;
	gint gen;
};

struct _DcGalleryDialogGalleryRow {
	GtkBox parent_instance;
	DcGalleryDialogGalleryRowPrivate * priv;
};

struct _DcGalleryDialogGalleryRowClass {
	GtkBoxClass parent_class;
};

struct _DcGalleryDialogGalleryRowPrivate {
	DcMessage* _msg;
	DcGalleryDialog* dialog;
	gchar* tab_key;
	GtkCheckButton* check;
	GtkImage* icon;
	GtkLabel* title_label;
	GtkLabel* subtitle_label;
	GtkButton* play_btn;
	GtkPicture* thumb;
	gint generation;
	gulong playing_handler;
	gulong current_handler;
};

struct _Block119Data {
	int _ref_count_;
	DcGalleryDialogGalleryRow* self;
	DcGalleryDialog* dialog;
};

struct _Block120Data {
	int _ref_count_;
	DcGalleryDialogGalleryRow* self;
	gint gen;
};

static gint DcGalleryDialog_private_offset;
static gpointer dc_gallery_dialog_parent_class = NULL;
static gint dc_gallery_dialog_zoom_columns;
static gint dc_gallery_dialog_zoom_columns = DC_GALLERY_DIALOG_ZOOM_COLUMNS_MAX;
static gpointer dc_gallery_dialog_gallery_tab_parent_class = NULL;
static gpointer dc_gallery_dialog_thumb_request_parent_class = NULL;
static gint DcGalleryDialogMediaCell_private_offset;
static gpointer dc_gallery_dialog_media_cell_parent_class = NULL;
static DcGalleryCellIface * dc_gallery_dialog_media_cell_dc_gallery_cell_parent_iface = NULL;
static gint DcGalleryDialogGalleryRow_private_offset;
static gpointer dc_gallery_dialog_gallery_row_parent_class = NULL;
static DcGalleryCellIface * dc_gallery_dialog_gallery_row_dc_gallery_cell_parent_iface = NULL;

VALA_EXTERN GType dc_message_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcMessage, g_object_unref)
VALA_EXTERN GType dc_gallery_cell_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcGalleryCell, g_object_unref)
VALA_EXTERN void dc_gallery_cell_bind (DcGalleryCell* self,
                           DcMessage* m);
VALA_EXTERN void dc_gallery_cell_unbind (DcGalleryCell* self);
VALA_EXTERN DcMessage* dc_gallery_cell_get_msg (DcGalleryCell* self);
VALA_EXTERN void dc_gallery_cell_set_msg (DcGalleryCell* self,
                              DcMessage* value);
static GType dc_gallery_cell_get_type_once (void);
VALA_EXTERN GType dc_gallery_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcGalleryDialog, g_object_unref)
VALA_EXTERN GType dc_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcWindow, g_object_unref)
VALA_EXTERN GType dc_rpc_client_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcRpcClient, g_object_unref)
VALA_EXTERN GType dc_image_viewer_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcImageViewer, g_object_unref)
VALA_EXTERN GType dc_video_player_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcVideoPlayer, g_object_unref)
static GType dc_gallery_dialog_gallery_tab_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcGalleryDialogGalleryTab, g_object_unref)
static gpointer dc_gallery_dialog_thumb_request_ref (gpointer instance);
static void dc_gallery_dialog_thumb_request_unref (gpointer instance);
static GParamSpec* dc_gallery_dialog_param_spec_thumb_request (const gchar* name,
                                                        const gchar* nick,
                                                        const gchar* blurb,
                                                        GType object_type,
                                                        GParamFlags flags) G_GNUC_UNUSED ;
static void dc_gallery_dialog_value_set_thumb_request (GValue* value,
                                                gpointer v_object) G_GNUC_UNUSED ;
static void dc_gallery_dialog_value_take_thumb_request (GValue* value,
                                                 gpointer v_object) G_GNUC_UNUSED ;
static gpointer dc_gallery_dialog_value_get_thumb_request (const GValue* value) G_GNUC_UNUSED ;
static GType dc_gallery_dialog_thumb_request_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcGalleryDialogThumbRequest, dc_gallery_dialog_thumb_request_unref)
static GType dc_gallery_dialog_media_filter_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
static void _g_free0_ (gpointer var);
static void _g_object_unref0_ (gpointer var);
VALA_EXTERN DcGalleryDialog* dc_gallery_dialog_new (DcWindow* window,
                                        DcRpcClient* rpc,
                                        gint chat_id,
                                        const gchar* chat_name);
VALA_EXTERN DcGalleryDialog* dc_gallery_dialog_construct (GType object_type,
                                              DcWindow* window,
                                              DcRpcClient* rpc,
                                              gint chat_id,
                                              const gchar* chat_name);
static Block103Data* block103_data_ref (Block103Data* _data103_);
static void block103_data_unref (void * _userdata_);
static void ___lambda203_ (DcGalleryDialog* self,
                    DcGalleryDialogThumbRequest* req);
VALA_EXTERN GdkPixbuf* dc_scaled_frame_from_file (const gchar* path,
                                      gint max_px,
                                      GError** error);
VALA_EXTERN GdkTexture* dc_texture_from_pixbuf (GdkPixbuf* pixbuf);
static void ____lambda203__gfunc (gpointer data,
                           gpointer self);
static DcGalleryDialogGalleryTab* dc_gallery_dialog_gallery_tab_new (void);
static DcGalleryDialogGalleryTab* dc_gallery_dialog_gallery_tab_construct (GType object_type);
static Block104Data* block104_data_ref (Block104Data* _data104_);
static void block104_data_unref (void * _userdata_);
static void dc_gallery_dialog_build_tab_page (DcGalleryDialog* self,
                                       DcGalleryDialogGalleryTab* tab);
static void ____lambda232_ (Block104Data* _data104_);
static void dc_gallery_dialog_update_tab_badge (DcGalleryDialog* self,
                                         DcGalleryDialogGalleryTab* tab);
static void dc_gallery_dialog_update_save_all_button (DcGalleryDialog* self);
static void _____lambda232__g_list_model_items_changed (GListModel* _sender,
                                                 guint position,
                                                 guint removed,
                                                 guint added,
                                                 gpointer self);
static void __lambda233_ (DcGalleryDialog* self);
static void dc_gallery_dialog_on_save_all_clicked (DcGalleryDialog* self);
static void ___lambda233__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static void __lambda236_ (DcGalleryDialog* self,
                   GVariant* param);
static void ___lambda236__g_simple_action_activate (GSimpleAction* _sender,
                                             GVariant* parameter,
                                             gpointer self);
static void __lambda237_ (DcGalleryDialog* self);
static void dc_gallery_dialog_exit_selection_mode (DcGalleryDialog* self);
static void ___lambda237__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static void __lambda238_ (DcGalleryDialog* self);
static void dc_gallery_dialog_forward_selection (DcGalleryDialog* self);
static void ___lambda238__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static void __lambda241_ (DcGalleryDialog* self);
static void dc_gallery_dialog_save_selection (DcGalleryDialog* self);
static void ___lambda241__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static void __lambda242_ (DcGalleryDialog* self);
static void dc_gallery_dialog_delete_selection (DcGalleryDialog* self);
static void ___lambda242__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static void __lambda243_ (DcGalleryDialog* self);
static void ___lambda243__g_object_notify (GObject* _sender,
                                    GParamSpec* pspec,
                                    gpointer self);
VALA_EXTERN DcImageViewer* dc_image_viewer_new (void);
VALA_EXTERN DcImageViewer* dc_image_viewer_construct (GType object_type);
VALA_EXTERN void dc_image_viewer_set_window (DcImageViewer* self,
                                 DcWindow* w);
VALA_EXTERN DcVideoPlayer* dc_video_player_new (void);
VALA_EXTERN DcVideoPlayer* dc_video_player_construct (GType object_type);
VALA_EXTERN void dc_video_player_set_window (DcVideoPlayer* self,
                                 DcWindow* w);
VALA_EXTERN GtkWidget* dc_image_viewer_get_widget (DcImageViewer* self);
VALA_EXTERN GtkWidget* dc_video_player_get_widget (DcVideoPlayer* self);
static gboolean __lambda244_ (DcGalleryDialog* self,
                       guint kv,
                       guint code,
                       GdkModifierType state);
VALA_EXTERN gboolean dc_image_viewer_get_visible (DcImageViewer* self);
VALA_EXTERN gboolean dc_image_viewer_handle_key (DcImageViewer* self,
                                     guint keyval);
VALA_EXTERN gboolean dc_video_player_get_visible (DcVideoPlayer* self);
VALA_EXTERN gboolean dc_video_player_handle_key (DcVideoPlayer* self,
                                     guint keyval);
static gboolean ___lambda244__gtk_event_controller_key_key_pressed (GtkEventControllerKey* _sender,
                                                             guint keyval,
                                                             guint keycode,
                                                             GdkModifierType state,
                                                             gpointer self);
static gboolean __lambda245_ (Block103Data* _data103_,
                       gdouble dx,
                       gdouble dy);
VALA_EXTERN gboolean dc_platform_has_primary_modifier (GdkModifierType state);
static void dc_gallery_dialog_adjust_thumb_zoom (DcGalleryDialog* self,
                                          gint direction);
static gboolean ___lambda245__gtk_event_controller_scroll_scroll (GtkEventControllerScroll* _sender,
                                                           gdouble dx,
                                                           gdouble dy,
                                                           gpointer self);
static void __lambda246_ (DcGalleryDialog* self);
static void dc_gallery_dialog_update_can_close (DcGalleryDialog* self);
static void ___lambda246__g_object_notify (GObject* _sender,
                                    GParamSpec* pspec,
                                    gpointer self);
static void __lambda247_ (DcGalleryDialog* self);
static void ___lambda247__g_object_notify (GObject* _sender,
                                    GParamSpec* pspec,
                                    gpointer self);
static void __lambda248_ (DcGalleryDialog* self);
VALA_EXTERN void dc_image_viewer_hide (DcImageViewer* self);
VALA_EXTERN void dc_video_player_hide (DcVideoPlayer* self);
VALA_EXTERN gboolean dc_gallery_dialog_get_selection_mode (DcGalleryDialog* self);
static void ___lambda248__adw_dialog_close_attempt (AdwDialog* _sender,
                                             gpointer self);
static void __lambda249_ (DcGalleryDialog* self);
VALA_EXTERN GType dc_audio_playback_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcAudioPlayback, g_object_unref)
VALA_EXTERN DcAudioPlayback* dc_audio_playback_shared (void);
VALA_EXTERN gint dc_audio_playback_get_current_message_id (DcAudioPlayback* self);
VALA_EXTERN void dc_audio_playback_stop (DcAudioPlayback* self);
static void ___lambda249__adw_dialog_closed (AdwDialog* _sender,
                                      gpointer self);
static void __lambda250_ (DcGalleryDialog* self);
static DcGalleryDialogGalleryTab* dc_gallery_dialog_current_tab (DcGalleryDialog* self);
static void dc_gallery_dialog_load_tab (DcGalleryDialog* self,
                                 DcGalleryDialogGalleryTab* tab,
                                 GAsyncReadyCallback _callback_,
                                 gpointer _user_data_);
static void dc_gallery_dialog_load_tab_finish (DcGalleryDialog* self,
                                        GAsyncResult* _res_);
static void dc_gallery_dialog_sync_more_button (DcGalleryDialog* self);
static void ___lambda250__g_object_notify (GObject* _sender,
                                    GParamSpec* pspec,
                                    gpointer self);
static DcGalleryDialogGalleryTab* dc_gallery_dialog_find_tab (DcGalleryDialog* self,
                                                       const gchar* key);
VALA_EXTERN gboolean dc_gallery_dialog_is_selected (DcGalleryDialog* self,
                                        gint msg_id);
static void dc_gallery_dialog_enter_selection_mode (DcGalleryDialog* self,
                                             gint msg_id);
static void dc_gallery_dialog_set_selection_mode (DcGalleryDialog* self,
                                           gboolean value);
static void dc_gallery_dialog_update_selection_ui (DcGalleryDialog* self);
static void dc_gallery_dialog_toggle_selected (DcGalleryDialog* self,
                                        DcMessage* m);
VALA_EXTERN gint dc_message_get_id (DcMessage* self);
static DcMessage** dc_gallery_dialog_selected_messages (DcGalleryDialog* self,
                                                 gint* result_length1);
static void _vala_array_add62 (DcMessage** * array,
                        gint* length,
                        gint* size,
                        DcMessage* value);
static void _vala_array_add63 (gint* * array,
                        gint* length,
                        gint* size,
                        gint value);
VALA_EXTERN GType dc_contact_picker_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcContactPickerDialog, g_object_unref)
VALA_EXTERN DcContactPickerDialog* dc_message_actions_forward_with_picker (DcWindow* window,
                                                               DcRpcClient* rpc,
                                                               gint* msg_ids,
                                                               gint msg_ids_length1);
static void __lambda239_ (DcGalleryDialog* self,
                   gint chat_id);
static void ___lambda239__dc_contact_picker_dialog_chat_picked (DcContactPickerDialog* _sender,
                                                         gint chat_id,
                                                         gpointer self);
static void __lambda240_ (DcGalleryDialog* self,
                   gint contact_id,
                   const gchar* email);
static void ___lambda240__dc_contact_picker_dialog_contact_picked (DcContactPickerDialog* _sender,
                                                            gint contact_id,
                                                            const gchar* email,
                                                            gpointer self);
static void dc_gallery_dialog_choose_folder_then_save (DcGalleryDialog* self,
                                                DcMessage** msgs,
                                                gint msgs_length1,
                                                gboolean exit_selection);
static void _vala_array_add64 (gint* * array,
                        gint* length,
                        gint* size,
                        gint value);
VALA_EXTERN gboolean dc_message_get_is_outgoing (DcMessage* self);
static void dc_gallery_dialog_confirm_delete_ids (DcGalleryDialog* self,
                                           gint* ids,
                                           gint ids_length1,
                                           gboolean all_outgoing,
                                           GAsyncReadyCallback _callback_,
                                           gpointer _user_data_);
static void dc_gallery_dialog_confirm_delete_ids_finish (DcGalleryDialog* self,
                                                  GAsyncResult* _res_);
static gint* _vala_array_dup24 (gint* self,
                         gssize length);
static void dc_gallery_dialog_confirm_delete_ids_data_free (gpointer _data);
static gboolean dc_gallery_dialog_confirm_delete_ids_co (DcGalleryDialogConfirmDeleteIdsData* _data_);
VALA_EXTERN GType dc_delete_choice_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void dc_confirm_delete_options (GtkWidget* parent,
                                const gchar* title,
                                const gchar* body,
                                gboolean allow_delete_for_everyone,
                                GAsyncReadyCallback _callback_,
                                gpointer _user_data_);
VALA_EXTERN DcDeleteChoice dc_confirm_delete_options_finish (GAsyncResult* _res_);
static void dc_gallery_dialog_confirm_delete_ids_ready (GObject* source_object,
                                                 GAsyncResult* _res_,
                                                 gpointer _user_data_);
static void dc_gallery_dialog_delete_messages_ui (DcGalleryDialog* self,
                                           gint* ids,
                                           gint ids_length1,
                                           gboolean for_all,
                                           GAsyncReadyCallback _callback_,
                                           gpointer _user_data_);
static void dc_gallery_dialog_delete_messages_ui_finish (DcGalleryDialog* self,
                                                  GAsyncResult* _res_);
static gint* _vala_array_dup25 (gint* self,
                         gssize length);
static gint* _vala_array_dup26 (gint* self,
                         gssize length);
static GtkGridView* dc_gallery_dialog_build_media_grid (DcGalleryDialog* self,
                                                 DcGalleryDialogGalleryTab* tab);
static GtkListView* dc_gallery_dialog_build_row_list (DcGalleryDialog* self,
                                               DcGalleryDialogGalleryTab* tab);
static void dc_gallery_dialog_load_tab_data_free (gpointer _data);
static gboolean dc_gallery_dialog_load_tab_co (DcGalleryDialogLoadTabData* _data_);
VALA_EXTERN void dc_rpc_client_get_message_ids_for (DcRpcClient* self,
                                        gint acct_id,
                                        gint chat_id,
                                        gboolean info_only,
                                        GAsyncReadyCallback _callback_,
                                        gpointer _user_data_);
VALA_EXTERN JsonArray* dc_rpc_client_get_message_ids_for_finish (DcRpcClient* self,
                                                     GAsyncResult* _res_,
                                                     GError** error);
VALA_EXTERN gint dc_rpc_client_get_account_id (DcRpcClient* self);
static void dc_gallery_dialog_load_tab_ready (GObject* source_object,
                                       GAsyncResult* _res_,
                                       gpointer _user_data_);
static void _vala_array_add65 (gint* * array,
                        gint* length,
                        gint* size,
                        gint value);
VALA_EXTERN void dc_rpc_client_get_chat_media (DcRpcClient* self,
                                   gint chat_id,
                                   gchar** types,
                                   gint types_length1,
                                   GAsyncReadyCallback _callback_,
                                   gpointer _user_data_);
VALA_EXTERN gint* dc_rpc_client_get_chat_media_finish (DcRpcClient* self,
                                           GAsyncResult* _res_,
                                           gint* result_length1,
                                           GError** error);
VALA_EXTERN void dc_rpc_client_get_parsed_messages (DcRpcClient* self,
                                        gint* msg_ids,
                                        gint msg_ids_length1,
                                        GAsyncReadyCallback _callback_,
                                        gpointer _user_data_);
VALA_EXTERN DcMessage** dc_rpc_client_get_parsed_messages_finish (DcRpcClient* self,
                                                      GAsyncResult* _res_,
                                                      gint* result_length1,
                                                      GError** error);
static void dc_gallery_dialog_append_messages (DcGalleryDialog* self,
                                        DcGalleryDialogGalleryTab* tab,
                                        DcMessage** msgs,
                                        gint msgs_length1);
static void dc_gallery_dialog_toast (DcGalleryDialog* self,
                              const gchar* text);
VALA_EXTERN gboolean dc_message_get_is_info (DcMessage* self);
VALA_EXTERN const gchar* dc_message_get_text (DcMessage* self);
VALA_EXTERN gchar** dc_link_cleaner_find_urls (const gchar* text,
                                   gint* result_length1);
static void _vala_array_add66 (GObject** * array,
                        gint* length,
                        gint* size,
                        GObject* value);
VALA_EXTERN gboolean dc_message_get_has_file (DcMessage* self);
VALA_EXTERN gboolean dc_message_is_sticker_file (DcMessage* self);
static void _vala_array_add67 (GObject** * array,
                        gint* length,
                        gint* size,
                        GObject* value);
static GtkSignalListItemFactory* dc_gallery_dialog_make_cell_factory (void);
static void __lambda204_ (GObject* obj);
static void ___lambda204__gtk_signal_list_item_factory_bind (GtkSignalListItemFactory* _sender,
                                                      GObject* object,
                                                      gpointer self);
static void __lambda205_ (GObject* obj);
static void ___lambda205__gtk_signal_list_item_factory_unbind (GtkSignalListItemFactory* _sender,
                                                        GObject* object,
                                                        gpointer self);
static Block105Data* block105_data_ref (Block105Data* _data105_);
static void block105_data_unref (void * _userdata_);
static void __lambda206_ (Block105Data* _data105_,
                   GObject* obj);
static DcGalleryDialogMediaCell* dc_gallery_dialog_media_cell_new (DcGalleryDialog* dialog,
                                                            gboolean is_video,
                                                            gboolean contain);
static DcGalleryDialogMediaCell* dc_gallery_dialog_media_cell_construct (GType object_type,
                                                                  DcGalleryDialog* dialog,
                                                                  gboolean is_video,
                                                                  gboolean contain);
static GType dc_gallery_dialog_media_cell_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcGalleryDialogMediaCell, g_object_unref)
static void ___lambda206__gtk_signal_list_item_factory_setup (GtkSignalListItemFactory* _sender,
                                                       GObject* object,
                                                       gpointer self);
static void _vala_array_add68 (GtkGridView** * array,
                        gint* length,
                        gint* size,
                        GtkGridView* value);
static void __lambda222_ (Block105Data* _data105_,
                   guint pos);
static void dc_gallery_dialog_on_media_activated (DcGalleryDialog* self,
                                           DcGalleryDialogGalleryTab* tab,
                                           guint pos);
static void ___lambda222__gtk_grid_view_activate (GtkGridView* _sender,
                                           guint position,
                                           gpointer self);
static void dc_gallery_dialog_install_menu_key (DcGalleryDialog* self,
                                         GtkWidget* view);
static void dc_gallery_dialog_load_thumb_data_free (gpointer _data);
static void dc_gallery_dialog_load_thumb (DcGalleryDialog* self,
                                   const gchar* path,
                                   GAsyncReadyCallback _callback_,
                                   gpointer _user_data_);
static GdkTexture* dc_gallery_dialog_load_thumb_finish (DcGalleryDialog* self,
                                                 GAsyncResult* _res_);
static gboolean dc_gallery_dialog_load_thumb_co (DcGalleryDialogLoadThumbData* _data_);
static DcGalleryDialogThumbRequest* dc_gallery_dialog_thumb_request_new (void);
static DcGalleryDialogThumbRequest* dc_gallery_dialog_thumb_request_construct (GType object_type);
static gboolean _dc_gallery_dialog_load_thumb_co_gsource_func (gpointer self);
static gboolean dc_gallery_dialog_ensure_local_file (DcGalleryDialog* self,
                                              DcMessage* m);
VALA_EXTERN gboolean dc_message_get_has_local_file (DcMessage* self);
VALA_EXTERN gboolean dc_message_is_video_sticker_file (DcMessage* self);
VALA_EXTERN void dc_video_player_show (DcVideoPlayer* self,
                           const gchar* path,
                           const gchar* name);
VALA_EXTERN const gchar* dc_message_get_file_path (DcMessage* self);
VALA_EXTERN const gchar* dc_message_get_file_name (DcMessage* self);
static void _vala_array_add69 (gchar** * array,
                        gint* length,
                        gint* size,
                        gchar* value);
VALA_EXTERN void dc_image_viewer_show_list (DcImageViewer* self,
                                gchar** image_paths,
                                gint image_paths_length1,
                                gint start_index);
static Block106Data* block106_data_ref (Block106Data* _data106_);
static void block106_data_unref (void * _userdata_);
static void __lambda224_ (Block106Data* _data106_,
                   GObject* obj);
static DcGalleryDialogGalleryRow* dc_gallery_dialog_gallery_row_new (DcGalleryDialog* dialog,
                                                              const gchar* tab_key);
static DcGalleryDialogGalleryRow* dc_gallery_dialog_gallery_row_construct (GType object_type,
                                                                    DcGalleryDialog* dialog,
                                                                    const gchar* tab_key);
static GType dc_gallery_dialog_gallery_row_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcGalleryDialogGalleryRow, g_object_unref)
static void ___lambda224__gtk_signal_list_item_factory_setup (GtkSignalListItemFactory* _sender,
                                                       GObject* object,
                                                       gpointer self);
static void __lambda230_ (Block106Data* _data106_,
                   guint pos);
static void dc_gallery_dialog_on_row_activated (DcGalleryDialog* self,
                                         DcGalleryDialogGalleryTab* tab,
                                         DcMessage* m);
static void ___lambda230__gtk_list_view_activate (GtkListView* _sender,
                                           guint position,
                                           gpointer self);
static void dc_gallery_dialog_toggle_audio (DcGalleryDialog* self,
                                     DcMessage* m);
static void dc_gallery_dialog_open_file (DcGalleryDialog* self,
                                  DcMessage* m);
VALA_EXTERN void dc_window_prompt_webxdc_app (DcWindow* self,
                                  GtkWidget* parent,
                                  DcRpcClient* app_rpc,
                                  DcMessage* msg,
                                  GAsyncReadyCallback _callback_,
                                  gpointer _user_data_);
VALA_EXTERN void dc_window_prompt_webxdc_app_finish (DcWindow* self,
                                         GAsyncResult* _res_);
static void dc_gallery_dialog_open_link (DcGalleryDialog* self,
                                  const gchar* url);
static Block107Data* block107_data_ref (Block107Data* _data107_);
static void block107_data_unref (void * _userdata_);
static void __lambda209_ (Block107Data* _data107_,
                   GObject* o,
                   GAsyncResult* res);
VALA_EXTERN gboolean dc_is_dialog_dismissal (GError* _error_);
static void ___lambda209__gasync_ready_callback (GObject* source_object,
                                          GAsyncResult* res,
                                          gpointer self);
VALA_EXTERN void dc_audio_playback_toggle (DcAudioPlayback* self);
VALA_EXTERN void dc_audio_playback_play_message (DcAudioPlayback* self,
                                     DcMessage* msg,
                                     gint account_id);
static Block108Data* block108_data_ref (Block108Data* _data108_);
static void block108_data_unref (void * _userdata_);
static void __lambda231_ (Block108Data* _data108_,
                   GObject* o,
                   GAsyncResult* res);
static void ___lambda231__gasync_ready_callback (GObject* source_object,
                                          GAsyncResult* res,
                                          gpointer self);
static void dc_gallery_dialog_add_context_menu_gestures (DcGalleryCell* cell,
                                                  DcGalleryDialog* dialog);
static Block109Data* block109_data_ref (Block109Data* _data109_);
static void block109_data_unref (void * _userdata_);
static void __lambda207_ (Block109Data* _data109_,
                   gint n,
                   gdouble x,
                   gdouble y);
static void dc_gallery_dialog_show_item_menu (DcGalleryDialog* self,
                                       GtkWidget* parent,
                                       DcMessage* m,
                                       gdouble x,
                                       gdouble y);
static void ___lambda207__gtk_gesture_click_pressed (GtkGestureClick* _sender,
                                              gint n_press,
                                              gdouble x,
                                              gdouble y,
                                              gpointer self);
static void __lambda219_ (Block109Data* _data109_,
                   gdouble x,
                   gdouble y);
static void ___lambda219__gtk_gesture_long_press_pressed (GtkGestureLongPress* _sender,
                                                   gdouble x,
                                                   gdouble y,
                                                   gpointer self);
static Block110Data* block110_data_ref (Block110Data* _data110_);
static void block110_data_unref (void * _userdata_);
static gboolean __lambda223_ (Block110Data* _data110_,
                       guint kv,
                       guint code,
                       GdkModifierType state);
static gboolean ___lambda223__gtk_event_controller_key_key_pressed (GtkEventControllerKey* _sender,
                                                             guint keyval,
                                                             guint keycode,
                                                             GdkModifierType state,
                                                             gpointer self);
static Block111Data* block111_data_ref (Block111Data* _data111_);
static void block111_data_unref (void * _userdata_);
VALA_EXTERN GtkPopover* dc_popover_menu (GtkWidget* parent,
                             gdouble x,
                             gdouble y,
                             GtkBox** vbox);
static Block112Data* block112_data_ref (Block112Data* _data112_);
static void block112_data_unref (void * _userdata_);
VALA_EXTERN GType dc_popover_button_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcPopoverButton, g_object_unref)
VALA_EXTERN DcPopoverButton* dc_popover_button_new (GtkPopover* popover,
                                        const gchar* label,
                                        gboolean destructive,
                                        gboolean hexpand);
VALA_EXTERN DcPopoverButton* dc_popover_button_construct (GType object_type,
                                              GtkPopover* popover,
                                              const gchar* label,
                                              gboolean destructive,
                                              gboolean hexpand);
static void ____lambda208_ (Block112Data* _data112_);
static void _____lambda208__dc_popover_button_selected (DcPopoverButton* _sender,
                                                 gpointer self);
static void ____lambda210_ (Block112Data* _data112_);
static void _____lambda210__dc_popover_button_selected (DcPopoverButton* _sender,
                                                 gpointer self);
static Block113Data* block113_data_ref (Block113Data* _data113_);
static void block113_data_unref (void * _userdata_);
static void ___lambda211_ (Block113Data* _data113_);
VALA_EXTERN void dc_window_save_attachment (DcWindow* self,
                                const gchar* src_path,
                                const gchar* name,
                                GAsyncReadyCallback _callback_,
                                gpointer _user_data_);
VALA_EXTERN void dc_window_save_attachment_finish (DcWindow* self,
                                       GAsyncResult* _res_);
static void ____lambda211__dc_popover_button_selected (DcPopoverButton* _sender,
                                                gpointer self);
static void __lambda212_ (Block111Data* _data111_);
static void ___lambda212__dc_popover_button_selected (DcPopoverButton* _sender,
                                               gpointer self);
static void __lambda213_ (Block111Data* _data111_);
static void ___lambda213__dc_popover_button_selected (DcPopoverButton* _sender,
                                               gpointer self);
static void __lambda214_ (Block111Data* _data111_);
static Block114Data* block114_data_ref (Block114Data* _data114_);
static void block114_data_unref (void * _userdata_);
static void __lambda215_ (Block114Data* _data114_);
static void ___lambda216_ (Block114Data* _data114_);
VALA_EXTERN void dc_window_open_conversation_message (DcWindow* self,
                                          gint chat_id,
                                          gint msg_id);
static void ____lambda216__adw_dialog_closed (AdwDialog* _sender,
                                       gpointer self);
static void ___lambda215__adw_dialog_closed (AdwDialog* _sender,
                                      gpointer self);
static void ___lambda214__dc_popover_button_selected (DcPopoverButton* _sender,
                                               gpointer self);
static Block115Data* block115_data_ref (Block115Data* _data115_);
static void block115_data_unref (void * _userdata_);
static void ___lambda217_ (Block115Data* _data115_);
VALA_EXTERN void dc_sticker_manager_dialog_prompt_add_sticker (DcWindow* window,
                                                   const gchar* file_path);
static void ____lambda217__dc_popover_button_selected (DcPopoverButton* _sender,
                                                gpointer self);
static void __lambda218_ (Block111Data* _data111_);
static void ___lambda218__dc_popover_button_selected (DcPopoverButton* _sender,
                                               gpointer self);
static void dc_gallery_dialog_delete_messages_ui_data_free (gpointer _data);
static gboolean dc_gallery_dialog_delete_messages_ui_co (DcGalleryDialogDeleteMessagesUiData* _data_);
VALA_EXTERN void dc_rpc_client_delete_messages_for_all (DcRpcClient* self,
                                            gint* msg_ids,
                                            gint msg_ids_length1,
                                            GAsyncReadyCallback _callback_,
                                            gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_delete_messages_for_all_finish (DcRpcClient* self,
                                                   GAsyncResult* _res_,
                                                   GError** error);
static void dc_gallery_dialog_delete_messages_ui_ready (GObject* source_object,
                                                 GAsyncResult* _res_,
                                                 gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_delete_messages (DcRpcClient* self,
                                    gint* msg_ids,
                                    gint msg_ids_length1,
                                    GAsyncReadyCallback _callback_,
                                    gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_delete_messages_finish (DcRpcClient* self,
                                           GAsyncResult* _res_,
                                           GError** error);
VALA_EXTERN void dc_window_request_chat_messages_reload (DcWindow* self,
                                             gint chat_id);
static void _vala_array_add70 (DcMessage** * array,
                        gint* length,
                        gint* size,
                        DcMessage* value);
static DcMessage** _vala_array_dup27 (DcMessage** self,
                               gssize length);
static Block116Data* block116_data_ref (Block116Data* _data116_);
static void block116_data_unref (void * _userdata_);
static void _vala_array_add71 (DcMessage** * array,
                        gint* length,
                        gint* size,
                        DcMessage* value);
static void __lambda234_ (Block116Data* _data116_,
                   GObject* o,
                   GAsyncResult* res);
static void dc_gallery_dialog_save_files_to_folder (DcGalleryDialog* self,
                                             DcMessage** items,
                                             gint items_length1,
                                             gint skipped,
                                             GFile* folder,
                                             GAsyncReadyCallback _callback_,
                                             gpointer _user_data_);
static void dc_gallery_dialog_save_files_to_folder_finish (DcGalleryDialog* self,
                                                    GAsyncResult* _res_);
static DcMessage** _vala_array_dup28 (DcMessage** self,
                               gssize length);
static void ___lambda234__gasync_ready_callback (GObject* source_object,
                                          GAsyncResult* res,
                                          gpointer self);
static void dc_gallery_dialog_save_files_to_folder_data_free (gpointer _data);
static gboolean dc_gallery_dialog_save_files_to_folder_co (DcGalleryDialogSaveFilesToFolderData* _data_);
static Block117Data* block117_data_ref (Block117Data* _data117_);
static void block117_data_unref (void * _userdata_);
static void __lambda235_ (Block117Data* _data117_,
                   const gchar* r);
static void ___lambda235__adw_alert_dialog_response (AdwAlertDialog* _sender,
                                              const gchar* response,
                                              gpointer self);
VALA_EXTERN gchar* dc_message_display_file_name (DcMessage* self,
                                     const gchar* fallback);
VALA_EXTERN GFile* dc_save_folder_unique_destination (GFile* folder,
                                          const gchar* name);
static void dc_gallery_dialog_save_files_to_folder_ready (GObject* source_object,
                                                   GAsyncResult* _res_,
                                                   gpointer _user_data_);
static void dc_gallery_dialog_gallery_tab_finalize (GObject * obj);
static GType dc_gallery_dialog_gallery_tab_get_type_once (void);
static void dc_gallery_dialog_thumb_request_finalize (DcGalleryDialogThumbRequest * obj);
static GType dc_gallery_dialog_thumb_request_get_type_once (void);
VALA_EXTERN GType dc_scaled_preview_frame_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcScaledPreviewFrame, g_object_unref)
VALA_EXTERN DcScaledPreviewFrame* dc_scaled_preview_frame_new (gint natural_width,
                                                   gint natural_height,
                                                   const gchar* css_class);
VALA_EXTERN DcScaledPreviewFrame* dc_scaled_preview_frame_construct (GType object_type,
                                                         gint natural_width,
                                                         gint natural_height,
                                                         const gchar* css_class);
VALA_EXTERN void dc_scaled_preview_frame_set_child (DcScaledPreviewFrame* self,
                                        GtkWidget* value);
static void __lambda220_ (DcGalleryDialogMediaCell* self);
static void dc_gallery_dialog_media_cell_update_selection_visuals (DcGalleryDialogMediaCell* self);
static void ___lambda220__dc_gallery_dialog_selection_changed (DcGalleryDialog* _sender,
                                                        gpointer self);
static void dc_gallery_dialog_media_cell_real_bind (DcGalleryCell* base,
                                             DcMessage* m);
static Block118Data* block118_data_ref (Block118Data* _data118_);
static void block118_data_unref (void * _userdata_);
static void __lambda221_ (Block118Data* _data118_,
                   GObject* o,
                   GAsyncResult* res);
static void ___lambda221__gasync_ready_callback (GObject* source_object,
                                          GAsyncResult* res,
                                          gpointer self);
static void dc_gallery_dialog_media_cell_real_unbind (DcGalleryCell* base);
static void dc_gallery_dialog_media_cell_finalize (GObject * obj);
static GType dc_gallery_dialog_media_cell_get_type_once (void);
static void _vala_dc_gallery_dialog_media_cell_get_property (GObject * object,
                                                      guint property_id,
                                                      GValue * value,
                                                      GParamSpec * pspec);
static void _vala_dc_gallery_dialog_media_cell_set_property (GObject * object,
                                                      guint property_id,
                                                      const GValue * value,
                                                      GParamSpec * pspec);
static Block119Data* block119_data_ref (Block119Data* _data119_);
static void block119_data_unref (void * _userdata_);
static void ___lambda225_ (Block119Data* _data119_);
static void ____lambda225__gtk_button_clicked (GtkButton* _sender,
                                        gpointer self);
static void __lambda226_ (DcGalleryDialogGalleryRow* self);
static void dc_gallery_dialog_gallery_row_update_selection_visuals (DcGalleryDialogGalleryRow* self);
static void ___lambda226__dc_gallery_dialog_selection_changed (DcGalleryDialog* _sender,
                                                        gpointer self);
static void dc_gallery_dialog_gallery_row_real_bind (DcGalleryCell* base,
                                              DcMessage* m);
VALA_EXTERN const gchar* dc_message_get_override_sender_name (DcMessage* self);
VALA_EXTERN const gchar* dc_message_get_sender_name (DcMessage* self);
VALA_EXTERN gchar* dc_format_date_time (gint64 ts);
VALA_EXTERN gint64 dc_message_get_timestamp (DcMessage* self);
VALA_EXTERN const gchar* dc_message_get_view_type (DcMessage* self);
static void ___lambda227_ (DcGalleryDialogGalleryRow* self);
static void dc_gallery_dialog_gallery_row_update_play_icon (DcGalleryDialogGalleryRow* self);
static void ____lambda227__g_object_notify (GObject* _sender,
                                     GParamSpec* pspec,
                                     gpointer self);
static void ___lambda228_ (DcGalleryDialogGalleryRow* self);
static void ____lambda228__g_object_notify (GObject* _sender,
                                     GParamSpec* pspec,
                                     gpointer self);
static gchar* dc_gallery_dialog_gallery_row_app_display_name (DcMessage* m);
VALA_EXTERN gboolean dc_message_is_image_file (DcMessage* self);
static Block120Data* block120_data_ref (Block120Data* _data120_);
static void block120_data_unref (void * _userdata_);
static void ____lambda229_ (Block120Data* _data120_,
                     GObject* o,
                     GAsyncResult* res);
static void _____lambda229__gasync_ready_callback (GObject* source_object,
                                            GAsyncResult* res,
                                            gpointer self);
static GIcon* dc_gallery_dialog_gallery_row_file_type_icon (DcMessage* m);
VALA_EXTERN gint dc_message_get_file_bytes (DcMessage* self);
static void dc_gallery_dialog_gallery_row_real_unbind (DcGalleryCell* base);
VALA_EXTERN gboolean dc_audio_playback_get_playing (DcAudioPlayback* self);
VALA_EXTERN const gchar* dc_message_get_file_mime (DcMessage* self);
static void dc_gallery_dialog_gallery_row_finalize (GObject * obj);
static GType dc_gallery_dialog_gallery_row_get_type_once (void);
static void _vala_dc_gallery_dialog_gallery_row_get_property (GObject * object,
                                                       guint property_id,
                                                       GValue * value,
                                                       GParamSpec * pspec);
static void _vala_dc_gallery_dialog_gallery_row_set_property (GObject * object,
                                                       guint property_id,
                                                       const GValue * value,
                                                       GParamSpec * pspec);
static void dc_gallery_dialog_finalize (GObject * obj);
static GType dc_gallery_dialog_get_type_once (void);
static void _vala_dc_gallery_dialog_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec);
static void _vala_dc_gallery_dialog_set_property (GObject * object,
                                           guint property_id,
                                           const GValue * value,
                                           GParamSpec * pspec);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

void
dc_gallery_cell_bind (DcGalleryCell* self,
                      DcMessage* m)
{
	DcGalleryCellIface* _iface_;
	g_return_if_fail (self != NULL);
	_iface_ = DC_GALLERY_CELL_GET_INTERFACE (self);
	if (_iface_->bind) {
		_iface_->bind (self, m);
	}
}

void
dc_gallery_cell_unbind (DcGalleryCell* self)
{
	DcGalleryCellIface* _iface_;
	g_return_if_fail (self != NULL);
	_iface_ = DC_GALLERY_CELL_GET_INTERFACE (self);
	if (_iface_->unbind) {
		_iface_->unbind (self);
	}
}

DcMessage*
dc_gallery_cell_get_msg (DcGalleryCell* self)
{
	DcGalleryCellIface* _iface_;
	g_return_val_if_fail (self != NULL, NULL);
	_iface_ = DC_GALLERY_CELL_GET_INTERFACE (self);
	if (_iface_->get_msg) {
		return _iface_->get_msg (self);
	}
	return NULL;
}

void
dc_gallery_cell_set_msg (DcGalleryCell* self,
                         DcMessage* value)
{
	DcGalleryCellIface* _iface_;
	g_return_if_fail (self != NULL);
	_iface_ = DC_GALLERY_CELL_GET_INTERFACE (self);
	if (_iface_->set_msg) {
		_iface_->set_msg (self, value);
	}
}

static void
dc_gallery_cell_default_init (DcGalleryCellIface * iface,
                              gpointer iface_data)
{
	g_object_interface_install_property (iface, g_param_spec_object ("msg", "msg", "msg", DC_TYPE_MESSAGE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

/** Implemented by both gallery cell flavours (grid thumbnails and
        list rows) so GalleryDialog drives them through a single list
        item factory (see GalleryDialog.make_cell_factory). */
static GType
dc_gallery_cell_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DcGalleryCellIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_gallery_cell_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
	GType dc_gallery_cell_type_id;
	dc_gallery_cell_type_id = g_type_register_static (G_TYPE_INTERFACE, "DcGalleryCell", &g_define_type_info, 0);
	g_type_interface_add_prerequisite (dc_gallery_cell_type_id, gtk_widget_get_type ());
	return dc_gallery_cell_type_id;
}

GType
dc_gallery_cell_get_type (void)
{
	static volatile gsize dc_gallery_cell_type_id__once = 0;
	if (g_once_init_enter (&dc_gallery_cell_type_id__once)) {
		GType dc_gallery_cell_type_id;
		dc_gallery_cell_type_id = dc_gallery_cell_get_type_once ();
		g_once_init_leave (&dc_gallery_cell_type_id__once, dc_gallery_cell_type_id);
	}
	return dc_gallery_cell_type_id__once;
}

static inline gpointer
dc_gallery_dialog_get_instance_private (DcGalleryDialog* self)
{
	return G_STRUCT_MEMBER_P (self, DcGalleryDialog_private_offset);
}

static GType
dc_gallery_dialog_media_filter_get_type_once (void)
{
	static const GEnumValue values[] = {{DC_GALLERY_DIALOG_MEDIA_FILTER_ALL, "DC_GALLERY_DIALOG_MEDIA_FILTER_ALL", "all"}, {DC_GALLERY_DIALOG_MEDIA_FILTER_STICKERS_ONLY, "DC_GALLERY_DIALOG_MEDIA_FILTER_STICKERS_ONLY", "stickers-only"}, {DC_GALLERY_DIALOG_MEDIA_FILTER_NO_STICKERS, "DC_GALLERY_DIALOG_MEDIA_FILTER_NO_STICKERS", "no-stickers"}, {0, NULL, NULL}};
	GType dc_gallery_dialog_media_filter_type_id;
	dc_gallery_dialog_media_filter_type_id = g_enum_register_static ("DcGalleryDialogMediaFilter", values);
	return dc_gallery_dialog_media_filter_type_id;
}

static GType
dc_gallery_dialog_media_filter_get_type (void)
{
	static volatile gsize dc_gallery_dialog_media_filter_type_id__once = 0;
	if (g_once_init_enter (&dc_gallery_dialog_media_filter_type_id__once)) {
		GType dc_gallery_dialog_media_filter_type_id;
		dc_gallery_dialog_media_filter_type_id = dc_gallery_dialog_media_filter_get_type_once ();
		g_once_init_leave (&dc_gallery_dialog_media_filter_type_id__once, dc_gallery_dialog_media_filter_type_id);
	}
	return dc_gallery_dialog_media_filter_type_id__once;
}

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

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

static Block103Data*
block103_data_ref (Block103Data* _data103_)
{
	g_atomic_int_inc (&_data103_->_ref_count_);
	return _data103_;
}

static void
block103_data_unref (void * _userdata_)
{
	Block103Data* _data103_;
	_data103_ = (Block103Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data103_->_ref_count_)) {
		DcGalleryDialog* self;
		self = _data103_->self;
		_g_object_unref0 (_data103_->zoom_ctrl);
		_g_object_unref0 (self);
		g_slice_free (Block103Data, _data103_);
	}
}

static void
___lambda203_ (DcGalleryDialog* self,
               DcGalleryDialogThumbRequest* req)
{
	GSource* _tmp4_;
	GMainContext* _tmp5_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (req != NULL);
	{
		GdkPixbuf* _tmp0_ = NULL;
		const gchar* _tmp1_;
		GdkPixbuf* _tmp2_;
		GdkTexture* _tmp3_;
		_tmp1_ = req->path;
		_tmp2_ = dc_scaled_frame_from_file (_tmp1_, req->size, &_inner_error0_);
		_tmp0_ = _tmp2_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp3_ = dc_texture_from_pixbuf (_tmp0_);
		_g_object_unref0 (req->result);
		req->result = _tmp3_;
		_g_object_unref0 (_tmp0_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_dc_gallery_dialog_thumb_request_unref0 (req);
		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;
	}
	_tmp4_ = req->resume_source;
	_tmp5_ = g_main_context_default ();
	g_source_attach (_tmp4_, _tmp5_);
	_dc_gallery_dialog_thumb_request_unref0 (req);
}

static void
____lambda203__gfunc (gpointer data,
                      gpointer self)
{
	___lambda203_ ((DcGalleryDialog*) self, (DcGalleryDialogThumbRequest*) data);
}

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

static Block104Data*
block104_data_ref (Block104Data* _data104_)
{
	g_atomic_int_inc (&_data104_->_ref_count_);
	return _data104_;
}

static void
block104_data_unref (void * _userdata_)
{
	Block104Data* _data104_;
	_data104_ = (Block104Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data104_->_ref_count_)) {
		DcGalleryDialog* self;
		self = _data104_->_data103_->self;
		_g_object_unref0 (_data104_->tab);
		block103_data_unref (_data104_->_data103_);
		_data104_->_data103_ = NULL;
		g_slice_free (Block104Data, _data104_);
	}
}

static void
____lambda232_ (Block104Data* _data104_)
{
	Block103Data* _data103_;
	DcGalleryDialog* self;
	DcGalleryDialogGalleryTab* _tmp0_;
	AdwViewStack* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	DcGalleryDialogGalleryTab* _tmp4_;
	const gchar* _tmp5_;
	_data103_ = _data104_->_data103_;
	self = _data103_->self;
	_tmp0_ = _data104_->tab;
	dc_gallery_dialog_update_tab_badge (self, _tmp0_);
	_tmp1_ = self->priv->view_stack;
	_tmp2_ = adw_view_stack_get_visible_child_name (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = _data104_->tab;
	_tmp5_ = _tmp4_->key;
	if (g_strcmp0 (_tmp3_, _tmp5_) == 0) {
		dc_gallery_dialog_update_save_all_button (self);
	}
}

static void
_____lambda232__g_list_model_items_changed (GListModel* _sender,
                                            guint position,
                                            guint removed,
                                            guint added,
                                            gpointer self)
{
	____lambda232_ (self);
}

static void
__lambda233_ (DcGalleryDialog* self)
{
	dc_gallery_dialog_on_save_all_clicked (self);
}

static void
___lambda233__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda233_ ((DcGalleryDialog*) self);
}

static void
__lambda236_ (DcGalleryDialog* self,
              GVariant* param)
{
	AdwViewStack* _tmp0_;
	const gchar* _tmp1_;
	_tmp0_ = self->priv->view_stack;
	_tmp1_ = g_variant_get_string (param, NULL);
	adw_view_stack_set_visible_child_name (_tmp0_, _tmp1_);
}

static void
___lambda236__g_simple_action_activate (GSimpleAction* _sender,
                                        GVariant* parameter,
                                        gpointer self)
{
	__lambda236_ ((DcGalleryDialog*) self, parameter);
}

static void
__lambda237_ (DcGalleryDialog* self)
{
	dc_gallery_dialog_exit_selection_mode (self);
}

static void
___lambda237__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda237_ ((DcGalleryDialog*) self);
}

static void
__lambda238_ (DcGalleryDialog* self)
{
	dc_gallery_dialog_forward_selection (self);
}

static void
___lambda238__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda238_ ((DcGalleryDialog*) self);
}

static void
__lambda241_ (DcGalleryDialog* self)
{
	dc_gallery_dialog_save_selection (self);
}

static void
___lambda241__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda241_ ((DcGalleryDialog*) self);
}

static void
__lambda242_ (DcGalleryDialog* self)
{
	dc_gallery_dialog_delete_selection (self);
}

static void
___lambda242__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda242_ ((DcGalleryDialog*) self);
}

static void
__lambda243_ (DcGalleryDialog* self)
{
	gboolean _tmp0_ = FALSE;
	GtkRevealer* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	_tmp1_ = self->priv->selection_revealer;
	_tmp2_ = gtk_revealer_get_reveal_child (_tmp1_);
	_tmp3_ = _tmp2_;
	if (!_tmp3_) {
		GtkRevealer* _tmp4_;
		gboolean _tmp5_;
		gboolean _tmp6_;
		_tmp4_ = self->priv->selection_revealer;
		_tmp5_ = gtk_revealer_get_child_revealed (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp0_ = !_tmp6_;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		GtkBox* _tmp7_;
		_tmp7_ = self->priv->selection_bar;
		gtk_widget_set_visible ((GtkWidget*) _tmp7_, FALSE);
	}
}

static void
___lambda243__g_object_notify (GObject* _sender,
                               GParamSpec* pspec,
                               gpointer self)
{
	__lambda243_ ((DcGalleryDialog*) self);
}

static gboolean
__lambda244_ (DcGalleryDialog* self,
              guint kv,
              guint code,
              GdkModifierType state)
{
	DcImageViewer* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	DcVideoPlayer* _tmp4_;
	gboolean _tmp5_;
	gboolean _tmp6_;
	gboolean result;
	_tmp0_ = self->priv->viewer;
	_tmp1_ = dc_image_viewer_get_visible (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_) {
		DcImageViewer* _tmp3_;
		_tmp3_ = self->priv->viewer;
		result = dc_image_viewer_handle_key (_tmp3_, kv);
		return result;
	}
	_tmp4_ = self->priv->player;
	_tmp5_ = dc_video_player_get_visible (_tmp4_);
	_tmp6_ = _tmp5_;
	if (_tmp6_) {
		DcVideoPlayer* _tmp7_;
		_tmp7_ = self->priv->player;
		result = dc_video_player_handle_key (_tmp7_, kv);
		return result;
	}
	result = FALSE;
	return result;
}

static gboolean
___lambda244__gtk_event_controller_key_key_pressed (GtkEventControllerKey* _sender,
                                                    guint keyval,
                                                    guint keycode,
                                                    GdkModifierType state,
                                                    gpointer self)
{
	gboolean result;
	result = __lambda244_ ((DcGalleryDialog*) self, keyval, keycode, state);
	return result;
}

static gboolean
__lambda245_ (Block103Data* _data103_,
              gdouble dx,
              gdouble dy)
{
	DcGalleryDialog* self;
	gint _tmp0_ = 0;
	gboolean result;
	self = _data103_->self;
	if (!dc_platform_has_primary_modifier (gtk_event_controller_get_current_event_state ((GtkEventController*) _data103_->zoom_ctrl))) {
		result = FALSE;
		return result;
	}
	if (dy == ((gdouble) 0)) {
		result = FALSE;
		return result;
	}
	if (dy < ((gdouble) 0)) {
		_tmp0_ = 1;
	} else {
		_tmp0_ = -1;
	}
	dc_gallery_dialog_adjust_thumb_zoom (self, _tmp0_);
	result = TRUE;
	return result;
}

static gboolean
___lambda245__gtk_event_controller_scroll_scroll (GtkEventControllerScroll* _sender,
                                                  gdouble dx,
                                                  gdouble dy,
                                                  gpointer self)
{
	gboolean result;
	result = __lambda245_ (self, dx, dy);
	return result;
}

static void
__lambda246_ (DcGalleryDialog* self)
{
	dc_gallery_dialog_update_can_close (self);
}

static void
___lambda246__g_object_notify (GObject* _sender,
                               GParamSpec* pspec,
                               gpointer self)
{
	__lambda246_ ((DcGalleryDialog*) self);
}

static void
__lambda247_ (DcGalleryDialog* self)
{
	dc_gallery_dialog_update_can_close (self);
}

static void
___lambda247__g_object_notify (GObject* _sender,
                               GParamSpec* pspec,
                               gpointer self)
{
	__lambda247_ ((DcGalleryDialog*) self);
}

static void
__lambda248_ (DcGalleryDialog* self)
{
	DcImageViewer* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	_tmp0_ = self->priv->viewer;
	_tmp1_ = dc_image_viewer_get_visible (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_) {
		DcImageViewer* _tmp3_;
		_tmp3_ = self->priv->viewer;
		dc_image_viewer_hide (_tmp3_);
	} else {
		DcVideoPlayer* _tmp4_;
		gboolean _tmp5_;
		gboolean _tmp6_;
		_tmp4_ = self->priv->player;
		_tmp5_ = dc_video_player_get_visible (_tmp4_);
		_tmp6_ = _tmp5_;
		if (_tmp6_) {
			DcVideoPlayer* _tmp7_;
			_tmp7_ = self->priv->player;
			dc_video_player_hide (_tmp7_);
		} else {
			gboolean _tmp8_;
			_tmp8_ = self->priv->_selection_mode;
			if (_tmp8_) {
				dc_gallery_dialog_exit_selection_mode (self);
			} else {
				adw_dialog_force_close ((AdwDialog*) self);
			}
		}
	}
}

static void
___lambda248__adw_dialog_close_attempt (AdwDialog* _sender,
                                        gpointer self)
{
	__lambda248_ ((DcGalleryDialog*) self);
}

static void
__lambda249_ (DcGalleryDialog* self)
{
	DcAudioPlayback* playback = NULL;
	DcAudioPlayback* _tmp0_;
	gboolean _tmp1_ = FALSE;
	self->priv->is_open = FALSE;
	_tmp0_ = dc_audio_playback_shared ();
	playback = _tmp0_;
	if (self->priv->playback_was_started) {
		DcAudioPlayback* _tmp2_;
		gint _tmp3_;
		gint _tmp4_;
		_tmp2_ = playback;
		_tmp3_ = dc_audio_playback_get_current_message_id (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp1_ = _tmp4_ > 0;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		DcAudioPlayback* _tmp5_;
		_tmp5_ = playback;
		dc_audio_playback_stop (_tmp5_);
	}
	_g_object_unref0 (playback);
}

static void
___lambda249__adw_dialog_closed (AdwDialog* _sender,
                                 gpointer self)
{
	__lambda249_ ((DcGalleryDialog*) self);
}

static void
__lambda250_ (DcGalleryDialog* self)
{
	DcGalleryDialogGalleryTab* tab = NULL;
	DcGalleryDialogGalleryTab* _tmp0_;
	DcGalleryDialogGalleryTab* _tmp1_;
	_tmp0_ = dc_gallery_dialog_current_tab (self);
	tab = _tmp0_;
	_tmp1_ = tab;
	if (_tmp1_ != NULL) {
		DcGalleryDialogGalleryTab* _tmp2_;
		_tmp2_ = tab;
		dc_gallery_dialog_load_tab (self, _tmp2_, NULL, NULL);
	}
	dc_gallery_dialog_update_save_all_button (self);
	dc_gallery_dialog_sync_more_button (self);
	_g_object_unref0 (tab);
}

static void
___lambda250__g_object_notify (GObject* _sender,
                               GParamSpec* pspec,
                               gpointer self)
{
	__lambda250_ ((DcGalleryDialog*) self);
}

DcGalleryDialog*
dc_gallery_dialog_construct (GType object_type,
                             DcWindow* window,
                             DcRpcClient* rpc,
                             gint chat_id,
                             const gchar* chat_name)
{
	DcGalleryDialog * self = NULL;
	Block103Data* _data103_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar** _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	DcGalleryDialogGalleryTab* _tmp14_ = NULL;
	gchar* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	gchar* _tmp20_;
	gchar** _tmp21_;
	gchar* _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_;
	DcGalleryDialogGalleryTab* _tmp25_ = NULL;
	gchar* _tmp26_;
	gchar* _tmp27_;
	gchar* _tmp28_;
	gchar* _tmp29_;
	gchar** _tmp30_;
	gchar* _tmp31_;
	gchar* _tmp32_;
	gchar* _tmp33_;
	DcGalleryDialogGalleryTab* _tmp34_ = NULL;
	gchar* _tmp35_;
	gchar* _tmp36_;
	gchar* _tmp37_;
	gchar* _tmp38_;
	gchar* _tmp39_;
	gchar** _tmp40_;
	gchar* _tmp41_;
	gchar* _tmp42_;
	gchar* _tmp43_;
	DcGalleryDialogGalleryTab* _tmp44_ = NULL;
	gchar* _tmp45_;
	gchar* _tmp46_;
	gchar* _tmp47_;
	gchar* _tmp48_;
	gchar** _tmp49_;
	gchar* _tmp50_;
	gchar* _tmp51_;
	gchar* _tmp52_;
	DcGalleryDialogGalleryTab* _tmp53_ = NULL;
	gchar* _tmp54_;
	gchar* _tmp55_;
	gchar* _tmp56_;
	gchar** _tmp57_;
	gchar* _tmp58_;
	gchar* _tmp59_;
	gchar* _tmp60_;
	DcGalleryDialogGalleryTab* _tmp61_ = NULL;
	gchar* _tmp62_;
	gchar* _tmp63_;
	gchar* _tmp64_;
	gchar* _tmp65_;
	gchar** _tmp66_;
	gchar* _tmp67_;
	gchar* _tmp68_;
	gchar* _tmp69_;
	DcGalleryDialogGalleryTab* _tmp70_ = NULL;
	DcGalleryDialogGalleryTab** _tmp71_;
	AdwViewStack* _tmp72_;
	DcGalleryDialogGalleryTab** _tmp73_;
	gint _tmp73__length1;
	AdwHeaderBar* header = NULL;
	AdwHeaderBar* _tmp90_;
	const gchar* _tmp91_ = NULL;
	AdwHeaderBar* _tmp92_;
	AdwWindowTitle* _tmp93_;
	AdwWindowTitle* _tmp94_;
	GtkButton* _tmp95_;
	GtkButton* _tmp96_;
	GtkButton* _tmp97_;
	AdwHeaderBar* _tmp98_;
	GtkButton* _tmp99_;
	AdwViewSwitcher* switcher = NULL;
	AdwViewSwitcher* _tmp100_;
	AdwViewSwitcher* _tmp101_;
	AdwViewStack* _tmp102_;
	AdwViewSwitcher* _tmp103_;
	GMenu* more_menu = NULL;
	GMenu* _tmp104_;
	DcGalleryDialogGalleryTab** _tmp105_;
	gint _tmp105__length1;
	const GVariantType* _tmp119_;
	GVariant* _tmp120_;
	GVariant* _tmp121_;
	GSimpleAction* _tmp122_;
	GSimpleAction* _tmp123_;
	GSimpleActionGroup* gallery_actions = NULL;
	GSimpleActionGroup* _tmp124_;
	GSimpleAction* _tmp125_;
	GtkImage* more_icon = NULL;
	GtkImage* _tmp126_;
	GtkLabel* more_label = NULL;
	GtkLabel* _tmp127_;
	GtkBox* more_box = NULL;
	GtkBox* _tmp128_;
	GtkMenuButton* _tmp129_;
	GtkMenuButton* _tmp130_;
	GtkMenuButton* _tmp131_;
	GMenu* _tmp132_;
	GtkMenuButton* _tmp133_;
	GtkMenuButton* _tmp134_;
	GtkMenuButton* _tmp135_;
	GtkBox* _tmp136_;
	GtkBox* _tmp137_;
	GtkBox* _tmp138_;
	GtkBox* _tmp139_;
	AdwViewSwitcher* _tmp140_;
	GtkBox* _tmp141_;
	GtkMenuButton* _tmp142_;
	GtkButton* cancel_selection = NULL;
	GtkButton* _tmp143_;
	GtkLabel* _tmp144_;
	GtkCenterBox* selection_top = NULL;
	GtkCenterBox* _tmp145_;
	GtkLabel* _tmp146_;
	GtkButton* _tmp147_;
	GtkButton* _tmp148_;
	GtkButton* _tmp149_;
	GtkButton* _tmp150_;
	GtkButton* _tmp151_;
	GtkButton* _tmp152_;
	GtkButton* _tmp153_;
	GtkButton* _tmp154_;
	GtkBox* selection_actions = NULL;
	GtkBox* _tmp155_;
	GtkButton* _tmp156_;
	GtkButton* _tmp157_;
	GtkButton* _tmp158_;
	GtkBox* _tmp159_;
	GtkBox* _tmp160_;
	GtkBox* _tmp161_;
	GtkBox* _tmp162_;
	GtkBox* _tmp163_;
	GtkRevealer* _tmp164_;
	GtkRevealer* _tmp165_;
	GtkRevealer* _tmp166_;
	GtkBox* _tmp167_;
	GtkRevealer* _tmp168_;
	AdwToolbarView* toolbar_view = NULL;
	AdwToolbarView* _tmp169_;
	AdwHeaderBar* _tmp170_;
	GtkBox* _tmp171_;
	GtkRevealer* _tmp172_;
	AdwViewStack* _tmp173_;
	DcImageViewer* _tmp174_;
	DcImageViewer* _tmp175_;
	DcVideoPlayer* _tmp176_;
	DcVideoPlayer* _tmp177_;
	GtkOverlay* media_overlay = NULL;
	GtkOverlay* _tmp178_;
	DcImageViewer* _tmp179_;
	GtkWidget* _tmp180_;
	GtkWidget* _tmp181_;
	DcVideoPlayer* _tmp182_;
	GtkWidget* _tmp183_;
	GtkWidget* _tmp184_;
	AdwToastOverlay* _tmp185_;
	AdwToastOverlay* _tmp186_;
	AdwToastOverlay* _tmp187_;
	GtkEventControllerKey* kc = NULL;
	GtkEventControllerKey* _tmp188_;
	GtkEventController* _tmp189_;
	GtkEventControllerScroll* _tmp190_;
	GtkEventController* _tmp191_;
	DcImageViewer* _tmp192_;
	GtkWidget* _tmp193_;
	GtkWidget* _tmp194_;
	DcVideoPlayer* _tmp195_;
	GtkWidget* _tmp196_;
	GtkWidget* _tmp197_;
	AdwViewStack* _tmp198_;
	AdwViewStack* _tmp199_;
	DcGalleryDialogGalleryTab* _tmp200_;
	DcGalleryDialogGalleryTab* _tmp201_;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (window != NULL, NULL);
	g_return_val_if_fail (rpc != NULL, NULL);
	_data103_ = g_slice_new0 (Block103Data);
	_data103_->_ref_count_ = 1;
	self = (DcGalleryDialog*) g_object_new (object_type, NULL);
	_data103_->self = g_object_ref (self);
	self->priv->app_window = window;
	self->priv->rpc = rpc;
	self->priv->chat_id = chat_id;
	adw_dialog_set_title ((AdwDialog*) self, "Apps and Media");
	adw_dialog_set_content_width ((AdwDialog*) self, 860);
	adw_dialog_set_content_height ((AdwDialog*) self, 600);
	g_object_set ((GtkWidget*) self, "width-request", 280, NULL);
	g_object_set ((GtkWidget*) self, "height-request", 200, NULL);
	{
		GThreadPool* _tmp0_ = NULL;
		GThreadPool* _tmp1_;
		GThreadPool* _tmp2_;
		_tmp1_ = g_thread_pool_new (____lambda203__gfunc, self, 2, FALSE, &_inner_error0_);
		_tmp0_ = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp2_ = _tmp0_;
		_tmp0_ = NULL;
		_g_thread_pool_free0 (self->priv->thumb_pool);
		self->priv->thumb_pool = _tmp2_;
		_g_thread_pool_free0 (_tmp0_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp3_;
		const gchar* _tmp4_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp3_ = e;
		_tmp4_ = _tmp3_->message;
		g_warning ("gallery_dialog.vala:136: gallery thumb pool: %s", _tmp4_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		block103_data_unref (_data103_);
		_data103_ = 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 NULL;
	}
	_tmp5_ = g_strdup ("images");
	_tmp6_ = g_strdup ("Images");
	_tmp7_ = g_strdup ("image-x-generic-symbolic");
	_tmp8_ = g_strdup ("Gif");
	_tmp9_ = g_strdup ("Image");
	_tmp10_ = g_new0 (gchar*, 2 + 1);
	_tmp10_[0] = _tmp8_;
	_tmp10_[1] = _tmp9_;
	_tmp11_ = g_strdup ("No Images");
	_tmp12_ = g_strdup ("Images shared in this chat will appear here");
	_tmp13_ = g_strdup ("images");
	_tmp14_ = dc_gallery_dialog_gallery_tab_new ();
	_g_free0 (_tmp14_->key);
	_tmp14_->key = _tmp5_;
	_g_free0 (_tmp14_->title);
	_tmp14_->title = _tmp6_;
	_g_free0 (_tmp14_->icon_name);
	_tmp14_->icon_name = _tmp7_;
	_tmp14_->types = (_vala_array_free (_tmp14_->types, _tmp14_->types_length1, (GDestroyNotify) g_free), NULL);
	_tmp14_->types = _tmp10_;
	_tmp14_->types_length1 = 2;
	_tmp14_->_types_size_ = _tmp14_->types_length1;
	_tmp14_->filter = DC_GALLERY_DIALOG_MEDIA_FILTER_NO_STICKERS;
	_g_free0 (_tmp14_->empty_title);
	_tmp14_->empty_title = _tmp11_;
	_g_free0 (_tmp14_->empty_description);
	_tmp14_->empty_description = _tmp12_;
	_g_free0 (_tmp14_->kind_plural);
	_tmp14_->kind_plural = _tmp13_;
	_tmp15_ = g_strdup ("stickers");
	_tmp16_ = g_strdup ("Stickers");
	_tmp17_ = g_strdup ("sticker-symbolic");
	_tmp18_ = g_strdup ("Sticker");
	_tmp19_ = g_strdup ("Gif");
	_tmp20_ = g_strdup ("Image");
	_tmp21_ = g_new0 (gchar*, 3 + 1);
	_tmp21_[0] = _tmp18_;
	_tmp21_[1] = _tmp19_;
	_tmp21_[2] = _tmp20_;
	_tmp22_ = g_strdup ("No Stickers");
	_tmp23_ = g_strdup ("Stickers shared in this chat will appear here");
	_tmp24_ = g_strdup ("stickers");
	_tmp25_ = dc_gallery_dialog_gallery_tab_new ();
	_g_free0 (_tmp25_->key);
	_tmp25_->key = _tmp15_;
	_g_free0 (_tmp25_->title);
	_tmp25_->title = _tmp16_;
	_g_free0 (_tmp25_->icon_name);
	_tmp25_->icon_name = _tmp17_;
	_tmp25_->types = (_vala_array_free (_tmp25_->types, _tmp25_->types_length1, (GDestroyNotify) g_free), NULL);
	_tmp25_->types = _tmp21_;
	_tmp25_->types_length1 = 3;
	_tmp25_->_types_size_ = _tmp25_->types_length1;
	_tmp25_->filter = DC_GALLERY_DIALOG_MEDIA_FILTER_STICKERS_ONLY;
	_g_free0 (_tmp25_->empty_title);
	_tmp25_->empty_title = _tmp22_;
	_g_free0 (_tmp25_->empty_description);
	_tmp25_->empty_description = _tmp23_;
	_g_free0 (_tmp25_->kind_plural);
	_tmp25_->kind_plural = _tmp24_;
	_tmp25_->overflow = TRUE;
	_tmp26_ = g_strdup ("video");
	_tmp27_ = g_strdup ("Video");
	_tmp28_ = g_strdup ("video-x-generic-symbolic");
	_tmp29_ = g_strdup ("Video");
	_tmp30_ = g_new0 (gchar*, 1 + 1);
	_tmp30_[0] = _tmp29_;
	_tmp31_ = g_strdup ("No Videos");
	_tmp32_ = g_strdup ("Videos shared in this chat will appear here");
	_tmp33_ = g_strdup ("videos");
	_tmp34_ = dc_gallery_dialog_gallery_tab_new ();
	_g_free0 (_tmp34_->key);
	_tmp34_->key = _tmp26_;
	_g_free0 (_tmp34_->title);
	_tmp34_->title = _tmp27_;
	_g_free0 (_tmp34_->icon_name);
	_tmp34_->icon_name = _tmp28_;
	_tmp34_->types = (_vala_array_free (_tmp34_->types, _tmp34_->types_length1, (GDestroyNotify) g_free), NULL);
	_tmp34_->types = _tmp30_;
	_tmp34_->types_length1 = 1;
	_tmp34_->_types_size_ = _tmp34_->types_length1;
	_g_free0 (_tmp34_->empty_title);
	_tmp34_->empty_title = _tmp31_;
	_g_free0 (_tmp34_->empty_description);
	_tmp34_->empty_description = _tmp32_;
	_g_free0 (_tmp34_->kind_plural);
	_tmp34_->kind_plural = _tmp33_;
	_tmp35_ = g_strdup ("audio");
	_tmp36_ = g_strdup ("Audio");
	_tmp37_ = g_strdup ("audio-x-generic-symbolic");
	_tmp38_ = g_strdup ("Audio");
	_tmp39_ = g_strdup ("Voice");
	_tmp40_ = g_new0 (gchar*, 2 + 1);
	_tmp40_[0] = _tmp38_;
	_tmp40_[1] = _tmp39_;
	_tmp41_ = g_strdup ("No Audio");
	_tmp42_ = g_strdup ("Audio files and voice messages will appear here");
	_tmp43_ = g_strdup ("audio files");
	_tmp44_ = dc_gallery_dialog_gallery_tab_new ();
	_g_free0 (_tmp44_->key);
	_tmp44_->key = _tmp35_;
	_g_free0 (_tmp44_->title);
	_tmp44_->title = _tmp36_;
	_g_free0 (_tmp44_->icon_name);
	_tmp44_->icon_name = _tmp37_;
	_tmp44_->types = (_vala_array_free (_tmp44_->types, _tmp44_->types_length1, (GDestroyNotify) g_free), NULL);
	_tmp44_->types = _tmp40_;
	_tmp44_->types_length1 = 2;
	_tmp44_->_types_size_ = _tmp44_->types_length1;
	_g_free0 (_tmp44_->empty_title);
	_tmp44_->empty_title = _tmp41_;
	_g_free0 (_tmp44_->empty_description);
	_tmp44_->empty_description = _tmp42_;
	_g_free0 (_tmp44_->kind_plural);
	_tmp44_->kind_plural = _tmp43_;
	_tmp45_ = g_strdup ("files");
	_tmp46_ = g_strdup ("Files");
	_tmp47_ = g_strdup ("text-x-generic-symbolic");
	_tmp48_ = g_strdup ("File");
	_tmp49_ = g_new0 (gchar*, 1 + 1);
	_tmp49_[0] = _tmp48_;
	_tmp50_ = g_strdup ("No Files");
	_tmp51_ = g_strdup ("Documents and other files shared in this chat will appear here");
	_tmp52_ = g_strdup ("files");
	_tmp53_ = dc_gallery_dialog_gallery_tab_new ();
	_g_free0 (_tmp53_->key);
	_tmp53_->key = _tmp45_;
	_g_free0 (_tmp53_->title);
	_tmp53_->title = _tmp46_;
	_g_free0 (_tmp53_->icon_name);
	_tmp53_->icon_name = _tmp47_;
	_tmp53_->types = (_vala_array_free (_tmp53_->types, _tmp53_->types_length1, (GDestroyNotify) g_free), NULL);
	_tmp53_->types = _tmp49_;
	_tmp53_->types_length1 = 1;
	_tmp53_->_types_size_ = _tmp53_->types_length1;
	_g_free0 (_tmp53_->empty_title);
	_tmp53_->empty_title = _tmp50_;
	_g_free0 (_tmp53_->empty_description);
	_tmp53_->empty_description = _tmp51_;
	_g_free0 (_tmp53_->kind_plural);
	_tmp53_->kind_plural = _tmp52_;
	_tmp53_->overflow = TRUE;
	_tmp54_ = g_strdup ("links");
	_tmp55_ = g_strdup ("Links");
	_tmp56_ = g_strdup ("web-browser-symbolic");
	_tmp57_ = g_new0 (gchar*, 0 + 1);
	_tmp58_ = g_strdup ("No Links");
	_tmp59_ = g_strdup ("Links shared in this chat will appear here");
	_tmp60_ = g_strdup ("links");
	_tmp61_ = dc_gallery_dialog_gallery_tab_new ();
	_g_free0 (_tmp61_->key);
	_tmp61_->key = _tmp54_;
	_g_free0 (_tmp61_->title);
	_tmp61_->title = _tmp55_;
	_g_free0 (_tmp61_->icon_name);
	_tmp61_->icon_name = _tmp56_;
	_tmp61_->types = (_vala_array_free (_tmp61_->types, _tmp61_->types_length1, (GDestroyNotify) g_free), NULL);
	_tmp61_->types = _tmp57_;
	_tmp61_->types_length1 = 0;
	_tmp61_->_types_size_ = _tmp61_->types_length1;
	_g_free0 (_tmp61_->empty_title);
	_tmp61_->empty_title = _tmp58_;
	_g_free0 (_tmp61_->empty_description);
	_tmp61_->empty_description = _tmp59_;
	_g_free0 (_tmp61_->kind_plural);
	_tmp61_->kind_plural = _tmp60_;
	_tmp61_->overflow = TRUE;
	_tmp62_ = g_strdup ("apps");
	_tmp63_ = g_strdup ("Apps");
	_tmp64_ = g_strdup ("application-x-executable-symbolic");
	_tmp65_ = g_strdup ("Webxdc");
	_tmp66_ = g_new0 (gchar*, 1 + 1);
	_tmp66_[0] = _tmp65_;
	_tmp67_ = g_strdup ("No Apps");
	_tmp68_ = g_strdup ("Delta Chat apps shared in this chat will appear here");
	_tmp69_ = g_strdup ("apps");
	_tmp70_ = dc_gallery_dialog_gallery_tab_new ();
	_g_free0 (_tmp70_->key);
	_tmp70_->key = _tmp62_;
	_g_free0 (_tmp70_->title);
	_tmp70_->title = _tmp63_;
	_g_free0 (_tmp70_->icon_name);
	_tmp70_->icon_name = _tmp64_;
	_tmp70_->types = (_vala_array_free (_tmp70_->types, _tmp70_->types_length1, (GDestroyNotify) g_free), NULL);
	_tmp70_->types = _tmp66_;
	_tmp70_->types_length1 = 1;
	_tmp70_->_types_size_ = _tmp70_->types_length1;
	_g_free0 (_tmp70_->empty_title);
	_tmp70_->empty_title = _tmp67_;
	_g_free0 (_tmp70_->empty_description);
	_tmp70_->empty_description = _tmp68_;
	_g_free0 (_tmp70_->kind_plural);
	_tmp70_->kind_plural = _tmp69_;
	_tmp70_->overflow = TRUE;
	_tmp71_ = g_new0 (DcGalleryDialogGalleryTab*, 7 + 1);
	_tmp71_[0] = _tmp14_;
	_tmp71_[1] = _tmp25_;
	_tmp71_[2] = _tmp34_;
	_tmp71_[3] = _tmp44_;
	_tmp71_[4] = _tmp53_;
	_tmp71_[5] = _tmp61_;
	_tmp71_[6] = _tmp70_;
	self->priv->tabs = (_vala_array_free (self->priv->tabs, self->priv->tabs_length1, (GDestroyNotify) g_object_unref), NULL);
	self->priv->tabs = _tmp71_;
	self->priv->tabs_length1 = 7;
	self->priv->_tabs_size_ = self->priv->tabs_length1;
	_tmp72_ = (AdwViewStack*) adw_view_stack_new ();
	g_object_ref_sink (_tmp72_);
	_g_object_unref0 (self->priv->view_stack);
	self->priv->view_stack = _tmp72_;
	_tmp73_ = self->priv->tabs;
	_tmp73__length1 = self->priv->tabs_length1;
	{
		DcGalleryDialogGalleryTab** tab_collection = NULL;
		gint tab_collection_length1 = 0;
		gint _tab_collection_size_ = 0;
		gint tab_it = 0;
		tab_collection = _tmp73_;
		tab_collection_length1 = _tmp73__length1;
		for (tab_it = 0; tab_it < tab_collection_length1; tab_it = tab_it + 1) {
			DcGalleryDialogGalleryTab* _tmp74_;
			DcGalleryDialogGalleryTab* tab = NULL;
			_tmp74_ = _g_object_ref0 (tab_collection[tab_it]);
			tab = _tmp74_;
			{
				Block104Data* _data104_;
				DcGalleryDialogGalleryTab* _tmp75_;
				AdwViewStackPage* page = NULL;
				AdwViewStack* _tmp76_;
				DcGalleryDialogGalleryTab* _tmp77_;
				GtkStack* _tmp78_;
				DcGalleryDialogGalleryTab* _tmp79_;
				const gchar* _tmp80_;
				DcGalleryDialogGalleryTab* _tmp81_;
				const gchar* _tmp82_;
				AdwViewStackPage* _tmp83_;
				AdwViewStackPage* _tmp84_;
				AdwViewStackPage* _tmp85_;
				DcGalleryDialogGalleryTab* _tmp86_;
				const gchar* _tmp87_;
				DcGalleryDialogGalleryTab* _tmp88_;
				GListStore* _tmp89_;
				_data104_ = g_slice_new0 (Block104Data);
				_data104_->_ref_count_ = 1;
				_data104_->_data103_ = block103_data_ref (_data103_);
				_data104_->tab = tab;
				_tmp75_ = _data104_->tab;
				dc_gallery_dialog_build_tab_page (self, _tmp75_);
				_tmp76_ = self->priv->view_stack;
				_tmp77_ = _data104_->tab;
				_tmp78_ = _tmp77_->stack;
				_tmp79_ = _data104_->tab;
				_tmp80_ = _tmp79_->key;
				_tmp81_ = _data104_->tab;
				_tmp82_ = _tmp81_->title;
				_tmp83_ = adw_view_stack_add_titled (_tmp76_, (GtkWidget*) _tmp78_, _tmp80_, _tmp82_);
				_tmp84_ = _g_object_ref0 (_tmp83_);
				page = _tmp84_;
				_tmp85_ = page;
				_tmp86_ = _data104_->tab;
				_tmp87_ = _tmp86_->icon_name;
				adw_view_stack_page_set_icon_name (_tmp85_, _tmp87_);
				_tmp88_ = _data104_->tab;
				_tmp89_ = _tmp88_->store;
				g_signal_connect_data ((GListModel*) _tmp89_, "items-changed", (GCallback) _____lambda232__g_list_model_items_changed, block104_data_ref (_data104_), (GClosureNotify) block104_data_unref, 0);
				_g_object_unref0 (page);
				block104_data_unref (_data104_);
				_data104_ = NULL;
			}
		}
	}
	_tmp90_ = (AdwHeaderBar*) adw_header_bar_new ();
	g_object_ref_sink (_tmp90_);
	header = _tmp90_;
	_tmp91_ = chat_name;
	if (_tmp91_ == NULL) {
		_tmp91_ = "";
	}
	_tmp92_ = header;
	_tmp93_ = (AdwWindowTitle*) adw_window_title_new ("Apps and Media", _tmp91_);
	g_object_ref_sink (_tmp93_);
	_tmp94_ = _tmp93_;
	adw_header_bar_set_title_widget (_tmp92_, (GtkWidget*) _tmp94_);
	_g_object_unref0 (_tmp94_);
	_tmp95_ = (GtkButton*) gtk_button_new_from_icon_name ("document-save-symbolic");
	g_object_ref_sink (_tmp95_);
	_g_object_unref0 (self->priv->save_all_btn);
	self->priv->save_all_btn = _tmp95_;
	_tmp96_ = self->priv->save_all_btn;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp96_, FALSE);
	_tmp97_ = self->priv->save_all_btn;
	g_signal_connect_object (_tmp97_, "clicked", (GCallback) ___lambda233__gtk_button_clicked, self, 0);
	_tmp98_ = header;
	_tmp99_ = self->priv->save_all_btn;
	adw_header_bar_pack_start (_tmp98_, (GtkWidget*) _tmp99_);
	_tmp100_ = (AdwViewSwitcher*) adw_view_switcher_new ();
	g_object_ref_sink (_tmp100_);
	switcher = _tmp100_;
	_tmp101_ = switcher;
	_tmp102_ = self->priv->view_stack;
	adw_view_switcher_set_stack (_tmp101_, _tmp102_);
	_tmp103_ = switcher;
	adw_view_switcher_set_policy (_tmp103_, ADW_VIEW_SWITCHER_POLICY_NARROW);
	_tmp104_ = g_menu_new ();
	more_menu = _tmp104_;
	_tmp105_ = self->priv->tabs;
	_tmp105__length1 = self->priv->tabs_length1;
	{
		DcGalleryDialogGalleryTab** tab_collection = NULL;
		gint tab_collection_length1 = 0;
		gint _tab_collection_size_ = 0;
		gint tab_it = 0;
		tab_collection = _tmp105_;
		tab_collection_length1 = _tmp105__length1;
		for (tab_it = 0; tab_it < tab_collection_length1; tab_it = tab_it + 1) {
			DcGalleryDialogGalleryTab* _tmp106_;
			DcGalleryDialogGalleryTab* tab = NULL;
			_tmp106_ = _g_object_ref0 (tab_collection[tab_it]);
			tab = _tmp106_;
			{
				DcGalleryDialogGalleryTab* _tmp107_;
				AdwViewStack* _tmp108_;
				DcGalleryDialogGalleryTab* _tmp109_;
				GtkStack* _tmp110_;
				AdwViewStackPage* _tmp111_;
				GMenu* _tmp112_;
				DcGalleryDialogGalleryTab* _tmp113_;
				const gchar* _tmp114_;
				DcGalleryDialogGalleryTab* _tmp115_;
				const gchar* _tmp116_;
				gchar* _tmp117_;
				gchar* _tmp118_;
				_tmp107_ = tab;
				if (!_tmp107_->overflow) {
					_g_object_unref0 (tab);
					continue;
				}
				_tmp108_ = self->priv->view_stack;
				_tmp109_ = tab;
				_tmp110_ = _tmp109_->stack;
				_tmp111_ = adw_view_stack_get_page (_tmp108_, (GtkWidget*) _tmp110_);
				adw_view_stack_page_set_visible (_tmp111_, FALSE);
				_tmp112_ = more_menu;
				_tmp113_ = tab;
				_tmp114_ = _tmp113_->title;
				_tmp115_ = tab;
				_tmp116_ = _tmp115_->key;
				_tmp117_ = g_strdup_printf ("gallery.section('%s')", _tmp116_);
				_tmp118_ = _tmp117_;
				g_menu_append (_tmp112_, _tmp114_, _tmp118_);
				_g_free0 (_tmp118_);
				_g_object_unref0 (tab);
			}
		}
	}
	_tmp119_ = G_VARIANT_TYPE_STRING;
	_tmp120_ = g_variant_new_string ("images");
	g_variant_ref_sink (_tmp120_);
	_tmp121_ = _tmp120_;
	_tmp122_ = g_simple_action_new_stateful ("section", _tmp119_, _tmp121_);
	_g_object_unref0 (self->priv->section_action);
	self->priv->section_action = _tmp122_;
	_g_variant_unref0 (_tmp121_);
	_tmp123_ = self->priv->section_action;
	g_signal_connect_object (_tmp123_, "activate", (GCallback) ___lambda236__g_simple_action_activate, self, 0);
	_tmp124_ = g_simple_action_group_new ();
	gallery_actions = _tmp124_;
	_tmp125_ = self->priv->section_action;
	g_action_map_add_action ((GActionMap*) gallery_actions, (GAction*) _tmp125_);
	gtk_widget_insert_action_group ((GtkWidget*) self, "gallery", (GActionGroup*) gallery_actions);
	_tmp126_ = (GtkImage*) gtk_image_new_from_icon_name ("view-more-symbolic");
	g_object_ref_sink (_tmp126_);
	more_icon = _tmp126_;
	_tmp127_ = (GtkLabel*) gtk_label_new ("More");
	g_object_ref_sink (_tmp127_);
	more_label = _tmp127_;
	gtk_widget_add_css_class ((GtkWidget*) more_label, "caption");
	_tmp128_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
	g_object_ref_sink (_tmp128_);
	more_box = _tmp128_;
	gtk_widget_set_valign ((GtkWidget*) more_box, GTK_ALIGN_CENTER);
	gtk_box_append (more_box, (GtkWidget*) more_icon);
	gtk_box_append (more_box, (GtkWidget*) more_label);
	_tmp129_ = (GtkMenuButton*) gtk_menu_button_new ();
	g_object_ref_sink (_tmp129_);
	_g_object_unref0 (self->priv->more_btn);
	self->priv->more_btn = _tmp129_;
	_tmp130_ = self->priv->more_btn;
	gtk_menu_button_set_child (_tmp130_, (GtkWidget*) more_box);
	_tmp131_ = self->priv->more_btn;
	_tmp132_ = more_menu;
	gtk_menu_button_set_menu_model (_tmp131_, (GMenuModel*) _tmp132_);
	_tmp133_ = self->priv->more_btn;
	gtk_menu_button_set_direction (_tmp133_, GTK_ARROW_UP);
	_tmp134_ = self->priv->more_btn;
	gtk_widget_add_css_class ((GtkWidget*) _tmp134_, "flat");
	_tmp135_ = self->priv->more_btn;
	gtk_widget_add_css_class ((GtkWidget*) _tmp135_, "gallery-more");
	_tmp136_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	g_object_ref_sink (_tmp136_);
	_g_object_unref0 (self->priv->switcher_bar);
	self->priv->switcher_bar = _tmp136_;
	_tmp137_ = self->priv->switcher_bar;
	gtk_widget_set_halign ((GtkWidget*) _tmp137_, GTK_ALIGN_CENTER);
	_tmp138_ = self->priv->switcher_bar;
	gtk_widget_add_css_class ((GtkWidget*) _tmp138_, "gallery-tabs");
	_tmp139_ = self->priv->switcher_bar;
	_tmp140_ = switcher;
	gtk_box_append (_tmp139_, (GtkWidget*) _tmp140_);
	_tmp141_ = self->priv->switcher_bar;
	_tmp142_ = self->priv->more_btn;
	gtk_box_append (_tmp141_, (GtkWidget*) _tmp142_);
	_tmp143_ = (GtkButton*) gtk_button_new_with_label ("Cancel");
	g_object_ref_sink (_tmp143_);
	cancel_selection = _tmp143_;
	g_signal_connect_object (cancel_selection, "clicked", (GCallback) ___lambda237__gtk_button_clicked, self, 0);
	_tmp144_ = (GtkLabel*) gtk_label_new ("");
	g_object_ref_sink (_tmp144_);
	_g_object_unref0 (self->priv->selection_label);
	self->priv->selection_label = _tmp144_;
	_tmp145_ = (GtkCenterBox*) gtk_center_box_new ();
	g_object_ref_sink (_tmp145_);
	selection_top = _tmp145_;
	gtk_center_box_set_start_widget (selection_top, (GtkWidget*) cancel_selection);
	_tmp146_ = self->priv->selection_label;
	gtk_center_box_set_center_widget (selection_top, (GtkWidget*) _tmp146_);
	_tmp147_ = (GtkButton*) gtk_button_new_with_label ("Forward…");
	g_object_ref_sink (_tmp147_);
	_g_object_unref0 (self->priv->forward_sel_btn);
	self->priv->forward_sel_btn = _tmp147_;
	_tmp148_ = self->priv->forward_sel_btn;
	gtk_widget_add_css_class ((GtkWidget*) _tmp148_, "suggested-action");
	_tmp149_ = self->priv->forward_sel_btn;
	g_signal_connect_object (_tmp149_, "clicked", (GCallback) ___lambda238__gtk_button_clicked, self, 0);
	_tmp150_ = (GtkButton*) gtk_button_new_with_label ("Save…");
	g_object_ref_sink (_tmp150_);
	_g_object_unref0 (self->priv->save_sel_btn);
	self->priv->save_sel_btn = _tmp150_;
	_tmp151_ = self->priv->save_sel_btn;
	g_signal_connect_object (_tmp151_, "clicked", (GCallback) ___lambda241__gtk_button_clicked, self, 0);
	_tmp152_ = (GtkButton*) gtk_button_new_with_label ("Delete…");
	g_object_ref_sink (_tmp152_);
	_g_object_unref0 (self->priv->delete_sel_btn);
	self->priv->delete_sel_btn = _tmp152_;
	_tmp153_ = self->priv->delete_sel_btn;
	gtk_widget_add_css_class ((GtkWidget*) _tmp153_, "destructive-action");
	_tmp154_ = self->priv->delete_sel_btn;
	g_signal_connect_object (_tmp154_, "clicked", (GCallback) ___lambda242__gtk_button_clicked, self, 0);
	_tmp155_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	g_object_ref_sink (_tmp155_);
	selection_actions = _tmp155_;
	gtk_box_set_homogeneous (selection_actions, TRUE);
	_tmp156_ = self->priv->delete_sel_btn;
	gtk_box_append (selection_actions, (GtkWidget*) _tmp156_);
	_tmp157_ = self->priv->save_sel_btn;
	gtk_box_append (selection_actions, (GtkWidget*) _tmp157_);
	_tmp158_ = self->priv->forward_sel_btn;
	gtk_box_append (selection_actions, (GtkWidget*) _tmp158_);
	_tmp159_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
	g_object_ref_sink (_tmp159_);
	_g_object_unref0 (self->priv->selection_bar);
	self->priv->selection_bar = _tmp159_;
	_tmp160_ = self->priv->selection_bar;
	gtk_widget_add_css_class ((GtkWidget*) _tmp160_, "toolbar");
	_tmp161_ = self->priv->selection_bar;
	gtk_box_append (_tmp161_, (GtkWidget*) selection_top);
	_tmp162_ = self->priv->selection_bar;
	gtk_box_append (_tmp162_, (GtkWidget*) selection_actions);
	_tmp163_ = self->priv->selection_bar;
	gtk_widget_set_visible ((GtkWidget*) _tmp163_, FALSE);
	_tmp164_ = (GtkRevealer*) gtk_revealer_new ();
	g_object_ref_sink (_tmp164_);
	_g_object_unref0 (self->priv->selection_revealer);
	self->priv->selection_revealer = _tmp164_;
	_tmp165_ = self->priv->selection_revealer;
	gtk_revealer_set_transition_type (_tmp165_, GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP);
	_tmp166_ = self->priv->selection_revealer;
	_tmp167_ = self->priv->selection_bar;
	gtk_revealer_set_child (_tmp166_, (GtkWidget*) _tmp167_);
	_tmp168_ = self->priv->selection_revealer;
	g_signal_connect_object ((GObject*) _tmp168_, "notify::child-revealed", (GCallback) ___lambda243__g_object_notify, self, 0);
	_tmp169_ = (AdwToolbarView*) adw_toolbar_view_new ();
	g_object_ref_sink (_tmp169_);
	toolbar_view = _tmp169_;
	_tmp170_ = header;
	adw_toolbar_view_add_top_bar (toolbar_view, (GtkWidget*) _tmp170_);
	_tmp171_ = self->priv->switcher_bar;
	adw_toolbar_view_add_bottom_bar (toolbar_view, (GtkWidget*) _tmp171_);
	_tmp172_ = self->priv->selection_revealer;
	adw_toolbar_view_add_bottom_bar (toolbar_view, (GtkWidget*) _tmp172_);
	_tmp173_ = self->priv->view_stack;
	adw_toolbar_view_set_content (toolbar_view, (GtkWidget*) _tmp173_);
	_tmp174_ = dc_image_viewer_new ();
	_g_object_unref0 (self->priv->viewer);
	self->priv->viewer = _tmp174_;
	_tmp175_ = self->priv->viewer;
	dc_image_viewer_set_window (_tmp175_, window);
	_tmp176_ = dc_video_player_new ();
	_g_object_unref0 (self->priv->player);
	self->priv->player = _tmp176_;
	_tmp177_ = self->priv->player;
	dc_video_player_set_window (_tmp177_, window);
	_tmp178_ = (GtkOverlay*) gtk_overlay_new ();
	g_object_ref_sink (_tmp178_);
	media_overlay = _tmp178_;
	gtk_overlay_set_child (media_overlay, (GtkWidget*) toolbar_view);
	_tmp179_ = self->priv->viewer;
	_tmp180_ = dc_image_viewer_get_widget (_tmp179_);
	_tmp181_ = _tmp180_;
	gtk_overlay_add_overlay (media_overlay, _tmp181_);
	_tmp182_ = self->priv->player;
	_tmp183_ = dc_video_player_get_widget (_tmp182_);
	_tmp184_ = _tmp183_;
	gtk_overlay_add_overlay (media_overlay, _tmp184_);
	_tmp185_ = (AdwToastOverlay*) adw_toast_overlay_new ();
	g_object_ref_sink (_tmp185_);
	_g_object_unref0 (self->priv->toasts);
	self->priv->toasts = _tmp185_;
	_tmp186_ = self->priv->toasts;
	adw_toast_overlay_set_child (_tmp186_, (GtkWidget*) media_overlay);
	_tmp187_ = self->priv->toasts;
	adw_dialog_set_child ((AdwDialog*) self, (GtkWidget*) _tmp187_);
	_tmp188_ = (GtkEventControllerKey*) gtk_event_controller_key_new ();
	kc = _tmp188_;
	gtk_event_controller_set_propagation_phase ((GtkEventController*) kc, GTK_PHASE_CAPTURE);
	g_signal_connect_object (kc, "key-pressed", (GCallback) ___lambda244__gtk_event_controller_key_key_pressed, self, 0);
	_tmp189_ = _g_object_ref0 ((GtkEventController*) kc);
	gtk_widget_add_controller (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), _tmp189_);
	_tmp190_ = (GtkEventControllerScroll*) gtk_event_controller_scroll_new (GTK_EVENT_CONTROLLER_SCROLL_VERTICAL | GTK_EVENT_CONTROLLER_SCROLL_DISCRETE);
	_data103_->zoom_ctrl = _tmp190_;
	gtk_event_controller_set_propagation_phase ((GtkEventController*) _data103_->zoom_ctrl, GTK_PHASE_CAPTURE);
	g_signal_connect_data (_data103_->zoom_ctrl, "scroll", (GCallback) ___lambda245__gtk_event_controller_scroll_scroll, block103_data_ref (_data103_), (GClosureNotify) block103_data_unref, 0);
	_tmp191_ = _g_object_ref0 ((GtkEventController*) _data103_->zoom_ctrl);
	gtk_widget_add_controller (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), _tmp191_);
	_tmp192_ = self->priv->viewer;
	_tmp193_ = dc_image_viewer_get_widget (_tmp192_);
	_tmp194_ = _tmp193_;
	g_signal_connect_object ((GObject*) _tmp194_, "notify::visible", (GCallback) ___lambda246__g_object_notify, self, 0);
	_tmp195_ = self->priv->player;
	_tmp196_ = dc_video_player_get_widget (_tmp195_);
	_tmp197_ = _tmp196_;
	g_signal_connect_object ((GObject*) _tmp197_, "notify::visible", (GCallback) ___lambda247__g_object_notify, self, 0);
	g_signal_connect_object ((AdwDialog*) self, "close-attempt", (GCallback) ___lambda248__adw_dialog_close_attempt, self, 0);
	g_signal_connect_object ((AdwDialog*) self, "closed", (GCallback) ___lambda249__adw_dialog_closed, self, 0);
	_tmp198_ = self->priv->view_stack;
	g_signal_connect_object ((GObject*) _tmp198_, "notify::visible-child-name", (GCallback) ___lambda250__g_object_notify, self, 0);
	_tmp199_ = self->priv->view_stack;
	adw_view_stack_set_visible_child_name (_tmp199_, "images");
	dc_gallery_dialog_update_save_all_button (self);
	dc_gallery_dialog_sync_more_button (self);
	_tmp200_ = dc_gallery_dialog_find_tab (self, "images");
	_tmp201_ = _tmp200_;
	dc_gallery_dialog_load_tab (self, _tmp201_, NULL, NULL);
	_g_object_unref0 (_tmp201_);
	_g_object_unref0 (kc);
	_g_object_unref0 (media_overlay);
	_g_object_unref0 (toolbar_view);
	_g_object_unref0 (selection_actions);
	_g_object_unref0 (selection_top);
	_g_object_unref0 (cancel_selection);
	_g_object_unref0 (more_box);
	_g_object_unref0 (more_label);
	_g_object_unref0 (more_icon);
	_g_object_unref0 (gallery_actions);
	_g_object_unref0 (more_menu);
	_g_object_unref0 (switcher);
	_g_object_unref0 (header);
	block103_data_unref (_data103_);
	_data103_ = NULL;
	return self;
}

DcGalleryDialog*
dc_gallery_dialog_new (DcWindow* window,
                       DcRpcClient* rpc,
                       gint chat_id,
                       const gchar* chat_name)
{
	return dc_gallery_dialog_construct (DC_TYPE_GALLERY_DIALOG, window, rpc, chat_id, chat_name);
}

static void
dc_gallery_dialog_sync_more_button (DcGalleryDialog* self)
{
	const gchar* _tmp0_ = NULL;
	AdwViewStack* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar* key = NULL;
	gchar* _tmp4_;
	GSimpleAction* _tmp5_;
	const gchar* _tmp6_;
	GVariant* _tmp7_;
	GVariant* _tmp8_;
	DcGalleryDialogGalleryTab* tab = NULL;
	const gchar* _tmp9_;
	DcGalleryDialogGalleryTab* _tmp10_;
	gboolean _tmp11_ = FALSE;
	DcGalleryDialogGalleryTab* _tmp12_;
	g_return_if_fail (self != NULL);
	_tmp1_ = self->priv->view_stack;
	_tmp2_ = adw_view_stack_get_visible_child_name (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp0_ = _tmp3_;
	if (_tmp0_ == NULL) {
		_tmp0_ = "";
	}
	_tmp4_ = g_strdup (_tmp0_);
	key = _tmp4_;
	_tmp5_ = self->priv->section_action;
	_tmp6_ = key;
	_tmp7_ = g_variant_new_string (_tmp6_);
	g_variant_ref_sink (_tmp7_);
	_tmp8_ = _tmp7_;
	g_simple_action_set_state (_tmp5_, _tmp8_);
	_g_variant_unref0 (_tmp8_);
	_tmp9_ = key;
	_tmp10_ = dc_gallery_dialog_find_tab (self, _tmp9_);
	tab = _tmp10_;
	_tmp12_ = tab;
	if (_tmp12_ != NULL) {
		DcGalleryDialogGalleryTab* _tmp13_;
		_tmp13_ = tab;
		_tmp11_ = _tmp13_->overflow;
	} else {
		_tmp11_ = FALSE;
	}
	if (_tmp11_) {
		GtkMenuButton* _tmp14_;
		_tmp14_ = self->priv->more_btn;
		gtk_widget_add_css_class ((GtkWidget*) _tmp14_, "gallery-more-active");
	} else {
		GtkMenuButton* _tmp15_;
		_tmp15_ = self->priv->more_btn;
		gtk_widget_remove_css_class ((GtkWidget*) _tmp15_, "gallery-more-active");
	}
	_g_object_unref0 (tab);
	_g_free0 (key);
}

static void
dc_gallery_dialog_update_can_close (DcGalleryDialog* self)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	DcImageViewer* _tmp2_;
	gboolean _tmp3_;
	gboolean _tmp4_;
	g_return_if_fail (self != NULL);
	_tmp2_ = self->priv->viewer;
	_tmp3_ = dc_image_viewer_get_visible (_tmp2_);
	_tmp4_ = _tmp3_;
	if (!_tmp4_) {
		DcVideoPlayer* _tmp5_;
		gboolean _tmp6_;
		gboolean _tmp7_;
		_tmp5_ = self->priv->player;
		_tmp6_ = dc_video_player_get_visible (_tmp5_);
		_tmp7_ = _tmp6_;
		_tmp1_ = !_tmp7_;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		gboolean _tmp8_;
		_tmp8_ = self->priv->_selection_mode;
		_tmp0_ = !_tmp8_;
	} else {
		_tmp0_ = FALSE;
	}
	adw_dialog_set_can_close ((AdwDialog*) self, _tmp0_);
}

gboolean
dc_gallery_dialog_is_selected (DcGalleryDialog* self,
                               gint msg_id)
{
	GHashTable* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->selected_ids;
	result = g_hash_table_contains (_tmp0_, (gpointer) ((gintptr) msg_id));
	return result;
}

static void
dc_gallery_dialog_enter_selection_mode (DcGalleryDialog* self,
                                        gint msg_id)
{
	GHashTable* _tmp0_;
	g_return_if_fail (self != NULL);
	dc_gallery_dialog_set_selection_mode (self, TRUE);
	_tmp0_ = self->priv->selected_ids;
	g_hash_table_replace (_tmp0_, (gpointer) ((gintptr) msg_id), (gpointer) ((gintptr) TRUE));
	dc_gallery_dialog_update_selection_ui (self);
}

static void
dc_gallery_dialog_exit_selection_mode (DcGalleryDialog* self)
{
	gboolean _tmp0_;
	GHashTable* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_selection_mode;
	if (!_tmp0_) {
		return;
	}
	dc_gallery_dialog_set_selection_mode (self, FALSE);
	_tmp1_ = self->priv->selected_ids;
	g_hash_table_remove_all (_tmp1_);
	dc_gallery_dialog_update_selection_ui (self);
}

static void
dc_gallery_dialog_toggle_selected (DcGalleryDialog* self,
                                   DcMessage* m)
{
	GHashTable* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (m != NULL);
	_tmp0_ = self->priv->selected_ids;
	_tmp1_ = dc_message_get_id (m);
	_tmp2_ = _tmp1_;
	if (g_hash_table_contains (_tmp0_, (gpointer) ((gintptr) _tmp2_))) {
		GHashTable* _tmp3_;
		gint _tmp4_;
		gint _tmp5_;
		_tmp3_ = self->priv->selected_ids;
		_tmp4_ = dc_message_get_id (m);
		_tmp5_ = _tmp4_;
		g_hash_table_remove (_tmp3_, (gpointer) ((gintptr) _tmp5_));
	} else {
		GHashTable* _tmp6_;
		gint _tmp7_;
		gint _tmp8_;
		_tmp6_ = self->priv->selected_ids;
		_tmp7_ = dc_message_get_id (m);
		_tmp8_ = _tmp7_;
		g_hash_table_replace (_tmp6_, (gpointer) ((gintptr) _tmp8_), (gpointer) ((gintptr) TRUE));
	}
	dc_gallery_dialog_update_selection_ui (self);
}

static void
dc_gallery_dialog_update_selection_ui (DcGalleryDialog* self)
{
	guint count = 0U;
	GHashTable* _tmp0_;
	gboolean _tmp1_;
	GtkBox* _tmp3_;
	gboolean _tmp4_;
	GtkRevealer* _tmp5_;
	gboolean _tmp6_;
	GtkLabel* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	GtkButton* _tmp10_;
	GtkButton* _tmp11_;
	GtkButton* _tmp12_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->selected_ids;
	count = g_hash_table_size (_tmp0_);
	_tmp1_ = self->priv->_selection_mode;
	if (_tmp1_) {
		GtkBox* _tmp2_;
		_tmp2_ = self->priv->selection_bar;
		gtk_widget_set_visible ((GtkWidget*) _tmp2_, TRUE);
	}
	_tmp3_ = self->priv->switcher_bar;
	_tmp4_ = self->priv->_selection_mode;
	gtk_widget_set_visible ((GtkWidget*) _tmp3_, !_tmp4_);
	_tmp5_ = self->priv->selection_revealer;
	_tmp6_ = self->priv->_selection_mode;
	gtk_revealer_set_reveal_child (_tmp5_, _tmp6_);
	_tmp7_ = self->priv->selection_label;
	_tmp8_ = g_strdup_printf ("%u selected", count);
	_tmp9_ = _tmp8_;
	gtk_label_set_label (_tmp7_, _tmp9_);
	_g_free0 (_tmp9_);
	_tmp10_ = self->priv->forward_sel_btn;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp10_, count > ((guint) 0));
	_tmp11_ = self->priv->save_sel_btn;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp11_, count > ((guint) 0));
	_tmp12_ = self->priv->delete_sel_btn;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp12_, count > ((guint) 0));
	dc_gallery_dialog_update_can_close (self);
	g_signal_emit (self, dc_gallery_dialog_signals[DC_GALLERY_DIALOG_SELECTION_CHANGED_SIGNAL], 0);
}

/** Selected messages in per-tab store order (newest first), so bulk
            actions keep a stable, predictable ordering. */
static void
_vala_array_add62 (DcMessage** * array,
                   gint* length,
                   gint* size,
                   DcMessage* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (DcMessage*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static DcMessage**
dc_gallery_dialog_selected_messages (DcGalleryDialog* self,
                                     gint* result_length1)
{
	DcMessage** _result_ = NULL;
	DcMessage** _tmp0_;
	gint _result__length1;
	gint __result__size_;
	DcGalleryDialogGalleryTab** _tmp1_;
	gint _tmp1__length1;
	DcMessage** _tmp18_;
	gint _tmp18__length1;
	DcMessage** result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_new0 (DcMessage*, 0 + 1);
	_result_ = _tmp0_;
	_result__length1 = 0;
	__result__size_ = _result__length1;
	_tmp1_ = self->priv->tabs;
	_tmp1__length1 = self->priv->tabs_length1;
	{
		DcGalleryDialogGalleryTab** tab_collection = NULL;
		gint tab_collection_length1 = 0;
		gint _tab_collection_size_ = 0;
		gint tab_it = 0;
		tab_collection = _tmp1_;
		tab_collection_length1 = _tmp1__length1;
		for (tab_it = 0; tab_it < tab_collection_length1; tab_it = tab_it + 1) {
			DcGalleryDialogGalleryTab* _tmp2_;
			DcGalleryDialogGalleryTab* tab = NULL;
			_tmp2_ = _g_object_ref0 (tab_collection[tab_it]);
			tab = _tmp2_;
			{
				{
					guint i = 0U;
					i = (guint) 0;
					{
						gboolean _tmp3_ = FALSE;
						_tmp3_ = TRUE;
						while (TRUE) {
							DcGalleryDialogGalleryTab* _tmp5_;
							GListStore* _tmp6_;
							DcMessage* m = NULL;
							DcGalleryDialogGalleryTab* _tmp7_;
							GListStore* _tmp8_;
							GObject* _tmp9_;
							gboolean _tmp10_ = FALSE;
							DcMessage* _tmp11_;
							if (!_tmp3_) {
								guint _tmp4_;
								_tmp4_ = i;
								i = _tmp4_ + 1;
							}
							_tmp3_ = FALSE;
							_tmp5_ = tab;
							_tmp6_ = _tmp5_->store;
							if (!(i < g_list_model_get_n_items ((GListModel*) _tmp6_))) {
								break;
							}
							_tmp7_ = tab;
							_tmp8_ = _tmp7_->store;
							_tmp9_ = g_list_model_get_item ((GListModel*) _tmp8_, i);
							m = G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, DC_TYPE_MESSAGE, DcMessage);
							_tmp11_ = m;
							if (_tmp11_ != NULL) {
								GHashTable* _tmp12_;
								DcMessage* _tmp13_;
								gint _tmp14_;
								gint _tmp15_;
								_tmp12_ = self->priv->selected_ids;
								_tmp13_ = m;
								_tmp14_ = dc_message_get_id (_tmp13_);
								_tmp15_ = _tmp14_;
								_tmp10_ = g_hash_table_contains (_tmp12_, (gpointer) ((gintptr) _tmp15_));
							} else {
								_tmp10_ = FALSE;
							}
							if (_tmp10_) {
								DcMessage* _tmp16_;
								DcMessage* _tmp17_;
								_tmp16_ = m;
								_tmp17_ = _g_object_ref0 (_tmp16_);
								_vala_array_add62 (&_result_, &_result__length1, &__result__size_, _tmp17_);
							}
							_g_object_unref0 (m);
						}
					}
				}
				_g_object_unref0 (tab);
			}
		}
	}
	_tmp18_ = _result_;
	_tmp18__length1 = _result__length1;
	if (result_length1) {
		*result_length1 = _tmp18__length1;
	}
	result = _tmp18_;
	return result;
}

static void
_vala_array_add63 (gint* * array,
                   gint* length,
                   gint* size,
                   gint value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gint, *array, *size);
	}
	(*array)[(*length)++] = value;
}

static void
__lambda239_ (DcGalleryDialog* self,
              gint chat_id)
{
	dc_gallery_dialog_exit_selection_mode (self);
}

static void
___lambda239__dc_contact_picker_dialog_chat_picked (DcContactPickerDialog* _sender,
                                                    gint chat_id,
                                                    gpointer self)
{
	__lambda239_ ((DcGalleryDialog*) self, chat_id);
}

static void
__lambda240_ (DcGalleryDialog* self,
              gint contact_id,
              const gchar* email)
{
	g_return_if_fail (email != NULL);
	dc_gallery_dialog_exit_selection_mode (self);
}

static void
___lambda240__dc_contact_picker_dialog_contact_picked (DcContactPickerDialog* _sender,
                                                       gint contact_id,
                                                       const gchar* email,
                                                       gpointer self)
{
	__lambda240_ ((DcGalleryDialog*) self, contact_id, email);
}

static void
dc_gallery_dialog_forward_selection (DcGalleryDialog* self)
{
	DcMessage** msgs = NULL;
	gint _tmp0_ = 0;
	DcMessage** _tmp1_;
	gint msgs_length1;
	gint _msgs_size_;
	DcMessage** _tmp2_;
	gint _tmp2__length1;
	gint* ids = NULL;
	gint* _tmp3_;
	gint ids_length1;
	gint _ids_size_;
	DcMessage** _tmp4_;
	gint _tmp4__length1;
	DcContactPickerDialog* picker = NULL;
	DcWindow* _tmp9_;
	DcRpcClient* _tmp10_;
	gint* _tmp11_;
	gint _tmp11__length1;
	DcContactPickerDialog* _tmp12_;
	DcContactPickerDialog* _tmp13_;
	DcContactPickerDialog* _tmp14_;
	DcContactPickerDialog* _tmp15_;
	g_return_if_fail (self != NULL);
	_tmp1_ = dc_gallery_dialog_selected_messages (self, &_tmp0_);
	msgs = _tmp1_;
	msgs_length1 = _tmp0_;
	_msgs_size_ = msgs_length1;
	_tmp2_ = msgs;
	_tmp2__length1 = msgs_length1;
	if (_tmp2__length1 == 0) {
		msgs = (_vala_array_free (msgs, msgs_length1, (GDestroyNotify) g_object_unref), NULL);
		return;
	}
	_tmp3_ = g_new0 (gint, 0);
	ids = _tmp3_;
	ids_length1 = 0;
	_ids_size_ = ids_length1;
	_tmp4_ = msgs;
	_tmp4__length1 = msgs_length1;
	{
		DcMessage** m_collection = NULL;
		gint m_collection_length1 = 0;
		gint _m_collection_size_ = 0;
		gint m_it = 0;
		m_collection = _tmp4_;
		m_collection_length1 = _tmp4__length1;
		for (m_it = 0; m_it < m_collection_length1; m_it = m_it + 1) {
			DcMessage* _tmp5_;
			DcMessage* m = NULL;
			_tmp5_ = _g_object_ref0 (m_collection[m_it]);
			m = _tmp5_;
			{
				DcMessage* _tmp6_;
				gint _tmp7_;
				gint _tmp8_;
				_tmp6_ = m;
				_tmp7_ = dc_message_get_id (_tmp6_);
				_tmp8_ = _tmp7_;
				_vala_array_add63 (&ids, &ids_length1, &_ids_size_, _tmp8_);
				_g_object_unref0 (m);
			}
		}
	}
	_tmp9_ = self->priv->app_window;
	_tmp10_ = self->priv->rpc;
	_tmp11_ = ids;
	_tmp11__length1 = ids_length1;
	_tmp12_ = dc_message_actions_forward_with_picker (_tmp9_, _tmp10_, _tmp11_, (gint) _tmp11__length1);
	picker = _tmp12_;
	_tmp13_ = picker;
	if (_tmp13_ == NULL) {
		_g_object_unref0 (picker);
		ids = (g_free (ids), NULL);
		msgs = (_vala_array_free (msgs, msgs_length1, (GDestroyNotify) g_object_unref), NULL);
		return;
	}
	_tmp14_ = picker;
	g_signal_connect_object (_tmp14_, "chat-picked", (GCallback) ___lambda239__dc_contact_picker_dialog_chat_picked, self, 0);
	_tmp15_ = picker;
	g_signal_connect_object (_tmp15_, "contact-picked", (GCallback) ___lambda240__dc_contact_picker_dialog_contact_picked, self, 0);
	_g_object_unref0 (picker);
	ids = (g_free (ids), NULL);
	msgs = (_vala_array_free (msgs, msgs_length1, (GDestroyNotify) g_object_unref), NULL);
}

static void
dc_gallery_dialog_save_selection (DcGalleryDialog* self)
{
	gint _tmp0_ = 0;
	DcMessage** _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp1_ = dc_gallery_dialog_selected_messages (self, &_tmp0_);
	dc_gallery_dialog_choose_folder_then_save (self, _tmp1_, (gint) _tmp0_, TRUE);
}

static void
_vala_array_add64 (gint* * array,
                   gint* length,
                   gint* size,
                   gint value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gint, *array, *size);
	}
	(*array)[(*length)++] = value;
}

static gint*
_vala_array_dup24 (gint* self,
                   gssize length)
{
	if (length > 0) {
		return _vala_memdup2 (self, length * sizeof (gint));
	}
	return NULL;
}

static void
dc_gallery_dialog_delete_selection (DcGalleryDialog* self)
{
	DcMessage** msgs = NULL;
	gint _tmp0_ = 0;
	DcMessage** _tmp1_;
	gint msgs_length1;
	gint _msgs_size_;
	DcMessage** _tmp2_;
	gint _tmp2__length1;
	gint* ids = NULL;
	gint* _tmp3_;
	gint ids_length1;
	gint _ids_size_;
	gboolean all_outgoing = FALSE;
	DcMessage** _tmp4_;
	gint _tmp4__length1;
	gint* _tmp12_;
	gint _tmp12__length1;
	gint* _tmp13_;
	gint _tmp13__length1;
	g_return_if_fail (self != NULL);
	_tmp1_ = dc_gallery_dialog_selected_messages (self, &_tmp0_);
	msgs = _tmp1_;
	msgs_length1 = _tmp0_;
	_msgs_size_ = msgs_length1;
	_tmp2_ = msgs;
	_tmp2__length1 = msgs_length1;
	if (_tmp2__length1 == 0) {
		msgs = (_vala_array_free (msgs, msgs_length1, (GDestroyNotify) g_object_unref), NULL);
		return;
	}
	_tmp3_ = g_new0 (gint, 0);
	ids = _tmp3_;
	ids_length1 = 0;
	_ids_size_ = ids_length1;
	all_outgoing = TRUE;
	_tmp4_ = msgs;
	_tmp4__length1 = msgs_length1;
	{
		DcMessage** m_collection = NULL;
		gint m_collection_length1 = 0;
		gint _m_collection_size_ = 0;
		gint m_it = 0;
		m_collection = _tmp4_;
		m_collection_length1 = _tmp4__length1;
		for (m_it = 0; m_it < m_collection_length1; m_it = m_it + 1) {
			DcMessage* _tmp5_;
			DcMessage* m = NULL;
			_tmp5_ = _g_object_ref0 (m_collection[m_it]);
			m = _tmp5_;
			{
				DcMessage* _tmp6_;
				gint _tmp7_;
				gint _tmp8_;
				DcMessage* _tmp9_;
				gboolean _tmp10_;
				gboolean _tmp11_;
				_tmp6_ = m;
				_tmp7_ = dc_message_get_id (_tmp6_);
				_tmp8_ = _tmp7_;
				_vala_array_add64 (&ids, &ids_length1, &_ids_size_, _tmp8_);
				_tmp9_ = m;
				_tmp10_ = dc_message_get_is_outgoing (_tmp9_);
				_tmp11_ = _tmp10_;
				if (!_tmp11_) {
					all_outgoing = FALSE;
				}
				_g_object_unref0 (m);
			}
		}
	}
	_tmp12_ = ids;
	_tmp12__length1 = ids_length1;
	_tmp13_ = (_tmp12_ != NULL) ? _vala_array_dup24 (_tmp12_, _tmp12__length1) : _tmp12_;
	_tmp13__length1 = _tmp12__length1;
	dc_gallery_dialog_confirm_delete_ids (self, _tmp13_, (gint) _tmp13__length1, all_outgoing, NULL, NULL);
	ids = (g_free (ids), NULL);
	msgs = (_vala_array_free (msgs, msgs_length1, (GDestroyNotify) g_object_unref), NULL);
}

static void
dc_gallery_dialog_confirm_delete_ids_data_free (gpointer _data)
{
	DcGalleryDialogConfirmDeleteIdsData* _data_;
	_data_ = _data;
	_data_->ids = (g_free (_data_->ids), NULL);
	_g_object_unref0 (_data_->self);
	g_slice_free (DcGalleryDialogConfirmDeleteIdsData, _data_);
}

static void
dc_gallery_dialog_confirm_delete_ids (DcGalleryDialog* self,
                                      gint* ids,
                                      gint ids_length1,
                                      gboolean all_outgoing,
                                      GAsyncReadyCallback _callback_,
                                      gpointer _user_data_)
{
	DcGalleryDialogConfirmDeleteIdsData* _data_;
	DcGalleryDialog* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcGalleryDialogConfirmDeleteIdsData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_gallery_dialog_confirm_delete_ids_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->ids = (g_free (_data_->ids), NULL);
	_data_->ids = ids;
	_data_->ids_length1 = ids_length1;
	_data_->all_outgoing = all_outgoing;
	dc_gallery_dialog_confirm_delete_ids_co (_data_);
}

static void
dc_gallery_dialog_confirm_delete_ids_finish (DcGalleryDialog* self,
                                             GAsyncResult* _res_)
{
	DcGalleryDialogConfirmDeleteIdsData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

/** Confirmation shared by the selection bar and the item context
            menu. Only fully-outgoing selections offer Delete for Everyone. */
static void
dc_gallery_dialog_confirm_delete_ids_ready (GObject* source_object,
                                            GAsyncResult* _res_,
                                            gpointer _user_data_)
{
	DcGalleryDialogConfirmDeleteIdsData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_gallery_dialog_confirm_delete_ids_co (_data_);
}

static gint*
_vala_array_dup25 (gint* self,
                   gssize length)
{
	if (length > 0) {
		return _vala_memdup2 (self, length * sizeof (gint));
	}
	return NULL;
}

static gint*
_vala_array_dup26 (gint* self,
                   gssize length)
{
	if (length > 0) {
		return _vala_memdup2 (self, length * sizeof (gint));
	}
	return NULL;
}

static gboolean
dc_gallery_dialog_confirm_delete_ids_co (DcGalleryDialogConfirmDeleteIdsData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	if (_data_->ids_length1 == 1) {
		_data_->_tmp0_ = "Delete Message?";
	} else {
		_data_->_tmp0_ = "Delete Messages?";
	}
	_data_->_tmp1_ = g_strdup (_data_->_tmp0_);
	_data_->title = _data_->_tmp1_;
	if (_data_->ids_length1 == 1) {
		_data_->_tmp3_ = g_strdup ("this message");
		_g_free0 (_data_->_tmp2_);
		_data_->_tmp2_ = _data_->_tmp3_;
	} else {
		_data_->_tmp4_ = g_strdup_printf ("these %d messages", _data_->ids_length1);
		_g_free0 (_data_->_tmp2_);
		_data_->_tmp2_ = _data_->_tmp4_;
	}
	_data_->_tmp5_ = _data_->_tmp2_;
	_data_->_tmp2_ = NULL;
	_data_->what = _data_->_tmp5_;
	if (_data_->all_outgoing) {
		_data_->_tmp7_ = _data_->what;
		_data_->_tmp8_ = g_strdup_printf ("Delete %s from your device only, or from all participants? This cannot" \
" be undone.", _data_->_tmp7_);
		_g_free0 (_data_->_tmp6_);
		_data_->_tmp6_ = _data_->_tmp8_;
	} else {
		_data_->_tmp9_ = _data_->what;
		_data_->_tmp10_ = g_strdup_printf ("Delete %s from your device? This cannot be undone.", _data_->_tmp9_);
		_g_free0 (_data_->_tmp6_);
		_data_->_tmp6_ = _data_->_tmp10_;
	}
	_data_->_tmp11_ = _data_->_tmp6_;
	_data_->_tmp6_ = NULL;
	_data_->body = _data_->_tmp11_;
	_data_->_tmp12_ = _data_->title;
	_data_->_tmp13_ = _data_->body;
	_data_->_state_ = 1;
	dc_confirm_delete_options ((GtkWidget*) _data_->self, _data_->_tmp12_, _data_->_tmp13_, _data_->all_outgoing, dc_gallery_dialog_confirm_delete_ids_ready, _data_);
	return FALSE;
	_state_1:
	_data_->choice = dc_confirm_delete_options_finish (_data_->_res_);
	if (_data_->choice == DC_DELETE_CHOICE_FOR_ME) {
		_data_->_tmp14_ = (_data_->ids != NULL) ? _vala_array_dup25 (_data_->ids, _data_->ids_length1) : _data_->ids;
		_data_->_tmp14__length1 = _data_->ids_length1;
		dc_gallery_dialog_delete_messages_ui (_data_->self, _data_->_tmp14_, (gint) _data_->_tmp14__length1, FALSE, NULL, NULL);
	} else {
		if (_data_->choice == DC_DELETE_CHOICE_FOR_EVERYONE) {
			_data_->_tmp15_ = (_data_->ids != NULL) ? _vala_array_dup26 (_data_->ids, _data_->ids_length1) : _data_->ids;
			_data_->_tmp15__length1 = _data_->ids_length1;
			dc_gallery_dialog_delete_messages_ui (_data_->self, _data_->_tmp15_, (gint) _data_->_tmp15__length1, TRUE, NULL, NULL);
		}
	}
	_g_free0 (_data_->body);
	_g_free0 (_data_->_tmp6_);
	_g_free0 (_data_->what);
	_g_free0 (_data_->_tmp2_);
	_g_free0 (_data_->title);
	_data_->ids = (g_free (_data_->ids), 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
dc_gallery_dialog_build_tab_page (DcGalleryDialog* self,
                                  DcGalleryDialogGalleryTab* tab)
{
	GtkStack* _tmp0_;
	GtkStack* _tmp1_;
	GtkSpinner* spinner = NULL;
	GtkSpinner* _tmp2_;
	GtkSpinner* _tmp3_;
	GtkSpinner* _tmp4_;
	GtkSpinner* _tmp5_;
	GtkSpinner* _tmp6_;
	GtkSpinner* _tmp7_;
	GtkStack* _tmp8_;
	GtkSpinner* _tmp9_;
	AdwStatusPage* empty = NULL;
	AdwStatusPage* _tmp10_;
	AdwStatusPage* _tmp11_;
	const gchar* _tmp12_;
	AdwStatusPage* _tmp13_;
	const gchar* _tmp14_;
	AdwStatusPage* _tmp15_;
	const gchar* _tmp16_;
	AdwStatusPage* _tmp17_;
	GtkStack* _tmp18_;
	AdwStatusPage* _tmp19_;
	GtkScrolledWindow* scroll = NULL;
	GtkScrolledWindow* _tmp20_;
	GtkScrolledWindow* _tmp21_;
	GtkScrolledWindow* _tmp22_;
	GtkScrolledWindow* _tmp23_;
	gboolean _tmp24_ = FALSE;
	gboolean _tmp25_ = FALSE;
	const gchar* _tmp26_;
	GtkStack* _tmp35_;
	GtkScrolledWindow* _tmp36_;
	GtkStack* _tmp37_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (tab != NULL);
	_tmp0_ = (GtkStack*) gtk_stack_new ();
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (tab->stack);
	tab->stack = _tmp0_;
	_tmp1_ = tab->stack;
	gtk_stack_set_transition_type (_tmp1_, GTK_STACK_TRANSITION_TYPE_CROSSFADE);
	_tmp2_ = (GtkSpinner*) gtk_spinner_new ();
	g_object_ref_sink (_tmp2_);
	spinner = _tmp2_;
	_tmp3_ = spinner;
	gtk_spinner_set_spinning (_tmp3_, TRUE);
	_tmp4_ = spinner;
	g_object_set ((GtkWidget*) _tmp4_, "width-request", 32, NULL);
	_tmp5_ = spinner;
	g_object_set ((GtkWidget*) _tmp5_, "height-request", 32, NULL);
	_tmp6_ = spinner;
	gtk_widget_set_halign ((GtkWidget*) _tmp6_, GTK_ALIGN_CENTER);
	_tmp7_ = spinner;
	gtk_widget_set_valign ((GtkWidget*) _tmp7_, GTK_ALIGN_CENTER);
	_tmp8_ = tab->stack;
	_tmp9_ = spinner;
	gtk_stack_add_named (_tmp8_, (GtkWidget*) _tmp9_, "loading");
	_tmp10_ = (AdwStatusPage*) adw_status_page_new ();
	g_object_ref_sink (_tmp10_);
	empty = _tmp10_;
	_tmp11_ = empty;
	_tmp12_ = tab->icon_name;
	adw_status_page_set_icon_name (_tmp11_, _tmp12_);
	_tmp13_ = empty;
	_tmp14_ = tab->empty_title;
	adw_status_page_set_title (_tmp13_, _tmp14_);
	_tmp15_ = empty;
	_tmp16_ = tab->empty_description;
	adw_status_page_set_description (_tmp15_, _tmp16_);
	_tmp17_ = empty;
	gtk_widget_add_css_class ((GtkWidget*) _tmp17_, "compact");
	_tmp18_ = tab->stack;
	_tmp19_ = empty;
	gtk_stack_add_named (_tmp18_, (GtkWidget*) _tmp19_, "empty");
	_tmp20_ = (GtkScrolledWindow*) gtk_scrolled_window_new ();
	g_object_ref_sink (_tmp20_);
	scroll = _tmp20_;
	_tmp21_ = scroll;
	g_object_set (_tmp21_, "hscrollbar-policy", GTK_POLICY_NEVER, NULL);
	_tmp22_ = scroll;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp22_, TRUE);
	_tmp23_ = scroll;
	gtk_widget_set_vexpand ((GtkWidget*) _tmp23_, TRUE);
	_tmp26_ = tab->key;
	if (g_strcmp0 (_tmp26_, "images") == 0) {
		_tmp25_ = TRUE;
	} else {
		const gchar* _tmp27_;
		_tmp27_ = tab->key;
		_tmp25_ = g_strcmp0 (_tmp27_, "stickers") == 0;
	}
	if (_tmp25_) {
		_tmp24_ = TRUE;
	} else {
		const gchar* _tmp28_;
		_tmp28_ = tab->key;
		_tmp24_ = g_strcmp0 (_tmp28_, "video") == 0;
	}
	if (_tmp24_) {
		GtkScrolledWindow* _tmp29_;
		GtkGridView* _tmp30_;
		GtkGridView* _tmp31_;
		_tmp29_ = scroll;
		_tmp30_ = dc_gallery_dialog_build_media_grid (self, tab);
		_tmp31_ = _tmp30_;
		gtk_scrolled_window_set_child (_tmp29_, (GtkWidget*) _tmp31_);
		_g_object_unref0 (_tmp31_);
	} else {
		GtkScrolledWindow* _tmp32_;
		GtkListView* _tmp33_;
		GtkListView* _tmp34_;
		_tmp32_ = scroll;
		_tmp33_ = dc_gallery_dialog_build_row_list (self, tab);
		_tmp34_ = _tmp33_;
		gtk_scrolled_window_set_child (_tmp32_, (GtkWidget*) _tmp34_);
		_g_object_unref0 (_tmp34_);
	}
	_tmp35_ = tab->stack;
	_tmp36_ = scroll;
	gtk_stack_add_named (_tmp35_, (GtkWidget*) _tmp36_, "content");
	_tmp37_ = tab->stack;
	gtk_stack_set_visible_child_name (_tmp37_, "loading");
	_g_object_unref0 (scroll);
	_g_object_unref0 (empty);
	_g_object_unref0 (spinner);
}

static DcGalleryDialogGalleryTab*
dc_gallery_dialog_find_tab (DcGalleryDialog* self,
                            const gchar* key)
{
	DcGalleryDialogGalleryTab** _tmp0_;
	gint _tmp0__length1;
	DcGalleryDialogGalleryTab* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (key != NULL, NULL);
	_tmp0_ = self->priv->tabs;
	_tmp0__length1 = self->priv->tabs_length1;
	{
		DcGalleryDialogGalleryTab** tab_collection = NULL;
		gint tab_collection_length1 = 0;
		gint _tab_collection_size_ = 0;
		gint tab_it = 0;
		tab_collection = _tmp0_;
		tab_collection_length1 = _tmp0__length1;
		for (tab_it = 0; tab_it < tab_collection_length1; tab_it = tab_it + 1) {
			DcGalleryDialogGalleryTab* _tmp1_;
			DcGalleryDialogGalleryTab* tab = NULL;
			_tmp1_ = _g_object_ref0 (tab_collection[tab_it]);
			tab = _tmp1_;
			{
				DcGalleryDialogGalleryTab* _tmp2_;
				const gchar* _tmp3_;
				_tmp2_ = tab;
				_tmp3_ = _tmp2_->key;
				if (g_strcmp0 (_tmp3_, key) == 0) {
					result = tab;
					return result;
				}
				_g_object_unref0 (tab);
			}
		}
	}
	result = NULL;
	return result;
}

static DcGalleryDialogGalleryTab*
dc_gallery_dialog_current_tab (DcGalleryDialog* self)
{
	gchar* key = NULL;
	AdwViewStack* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	DcGalleryDialogGalleryTab* _tmp4_ = NULL;
	const gchar* _tmp5_;
	DcGalleryDialogGalleryTab* _tmp8_;
	DcGalleryDialogGalleryTab* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->view_stack;
	_tmp1_ = adw_view_stack_get_visible_child_name (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strdup (_tmp2_);
	key = _tmp3_;
	_tmp5_ = key;
	if (_tmp5_ != NULL) {
		const gchar* _tmp6_;
		DcGalleryDialogGalleryTab* _tmp7_;
		_tmp6_ = key;
		_tmp7_ = dc_gallery_dialog_find_tab (self, _tmp6_);
		_g_object_unref0 (_tmp4_);
		_tmp4_ = _tmp7_;
	} else {
		_g_object_unref0 (_tmp4_);
		_tmp4_ = NULL;
	}
	_tmp8_ = _tmp4_;
	_tmp4_ = NULL;
	result = _tmp8_;
	_g_object_unref0 (_tmp4_);
	_g_free0 (key);
	return result;
}

static void
dc_gallery_dialog_update_tab_badge (DcGalleryDialog* self,
                                    DcGalleryDialogGalleryTab* tab)
{
	AdwViewStack* _tmp0_;
	GtkStack* _tmp1_;
	AdwViewStackPage* _tmp2_;
	GListStore* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (tab != NULL);
	_tmp0_ = self->priv->view_stack;
	_tmp1_ = tab->stack;
	_tmp2_ = adw_view_stack_get_page (_tmp0_, (GtkWidget*) _tmp1_);
	_tmp3_ = tab->store;
	adw_view_stack_page_set_badge_number (_tmp2_, g_list_model_get_n_items ((GListModel*) _tmp3_));
}

static void
dc_gallery_dialog_load_tab_data_free (gpointer _data)
{
	DcGalleryDialogLoadTabData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->tab);
	_g_object_unref0 (_data_->self);
	g_slice_free (DcGalleryDialogLoadTabData, _data_);
}

static void
dc_gallery_dialog_load_tab (DcGalleryDialog* self,
                            DcGalleryDialogGalleryTab* tab,
                            GAsyncReadyCallback _callback_,
                            gpointer _user_data_)
{
	DcGalleryDialogLoadTabData* _data_;
	DcGalleryDialog* _tmp0_;
	DcGalleryDialogGalleryTab* _tmp1_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcGalleryDialogLoadTabData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_gallery_dialog_load_tab_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (tab);
	_g_object_unref0 (_data_->tab);
	_data_->tab = _tmp1_;
	dc_gallery_dialog_load_tab_co (_data_);
}

static void
dc_gallery_dialog_load_tab_finish (DcGalleryDialog* self,
                                   GAsyncResult* _res_)
{
	DcGalleryDialogLoadTabData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_gallery_dialog_load_tab_ready (GObject* source_object,
                                  GAsyncResult* _res_,
                                  gpointer _user_data_)
{
	DcGalleryDialogLoadTabData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_gallery_dialog_load_tab_co (_data_);
}

static void
_vala_array_add65 (gint* * array,
                   gint* length,
                   gint* size,
                   gint value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gint, *array, *size);
	}
	(*array)[(*length)++] = value;
}

static gboolean
dc_gallery_dialog_load_tab_co (DcGalleryDialogLoadTabData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		case 3:
		goto _state_3;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	if (_data_->tab == NULL) {
		_data_->_tmp0_ = TRUE;
	} else {
		_data_->_tmp0_ = _data_->tab->load_started;
	}
	if (_data_->_tmp0_) {
		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_->tab->load_started = TRUE;
	{
		_data_->ids_length1 = 0;
		_data_->_ids_size_ = 0;
		_data_->_tmp1_ = _data_->tab->key;
		if (g_strcmp0 (_data_->_tmp1_, "links") == 0) {
			_data_->_tmp2_ = g_new0 (gint, 0);
			_data_->ids = (g_free (_data_->ids), NULL);
			_data_->ids = _data_->_tmp2_;
			_data_->ids_length1 = 0;
			_data_->_ids_size_ = _data_->ids_length1;
			_data_->_tmp3_ = _data_->self->priv->rpc;
			_data_->_tmp4_ = _data_->self->priv->rpc;
			_data_->_tmp5_ = dc_rpc_client_get_account_id (_data_->_tmp4_);
			_data_->_tmp6_ = _data_->_tmp5_;
			_data_->_state_ = 1;
			dc_rpc_client_get_message_ids_for (_data_->_tmp3_, _data_->_tmp6_, _data_->self->priv->chat_id, FALSE, dc_gallery_dialog_load_tab_ready, _data_);
			return FALSE;
			_state_1:
			_data_->_tmp7_ = dc_rpc_client_get_message_ids_for_finish (_data_->_tmp3_, _data_->_res_, &_data_->_inner_error0_);
			_data_->arr = _data_->_tmp7_;
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				_data_->ids = (g_free (_data_->ids), NULL);
				goto __catch0_g_error;
			}
			_data_->_tmp8_ = _data_->arr;
			if (_data_->_tmp8_ != NULL) {
				{
					_data_->i = (guint) 0;
					{
						_data_->_tmp9_ = TRUE;
						while (TRUE) {
							if (!_data_->_tmp9_) {
								_data_->_tmp10_ = _data_->i;
								_data_->i = _data_->_tmp10_ + 1;
							}
							_data_->_tmp9_ = FALSE;
							_data_->_tmp11_ = _data_->arr;
							if (!(_data_->i < json_array_get_length (_data_->_tmp11_))) {
								break;
							}
							_data_->_tmp12_ = _data_->arr;
							_vala_array_add65 (&_data_->ids, &_data_->ids_length1, &_data_->_ids_size_, (gint) json_array_get_int_element (_data_->_tmp12_, _data_->i));
						}
					}
				}
			}
			_json_array_unref0 (_data_->arr);
		} else {
			_data_->_tmp14_ = _data_->self->priv->rpc;
			_data_->_tmp15_ = _data_->tab->types;
			_data_->_tmp15__length1 = _data_->tab->types_length1;
			_data_->_tmp16_ = 0;
			_data_->_state_ = 2;
			dc_rpc_client_get_chat_media (_data_->_tmp14_, _data_->self->priv->chat_id, _data_->_tmp15_, (gint) _data_->_tmp15__length1, dc_gallery_dialog_load_tab_ready, _data_);
			return FALSE;
			_state_2:
			_data_->_tmp17_ = dc_rpc_client_get_chat_media_finish (_data_->_tmp14_, _data_->_res_, &_data_->_tmp16_, &_data_->_inner_error0_);
			_data_->_tmp13_ = _data_->_tmp17_;
			_data_->_tmp13__length1 = _data_->_tmp16_;
			_data_->__tmp13__size_ = _data_->_tmp13__length1;
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				_data_->ids = (g_free (_data_->ids), NULL);
				goto __catch0_g_error;
			}
			_data_->_tmp18_ = _data_->_tmp13_;
			_data_->_tmp18__length1 = _data_->_tmp13__length1;
			_data_->_tmp13_ = NULL;
			_data_->_tmp13__length1 = 0;
			_data_->ids = (g_free (_data_->ids), NULL);
			_data_->ids = _data_->_tmp18_;
			_data_->ids_length1 = _data_->_tmp18__length1;
			_data_->_ids_size_ = _data_->ids_length1;
			_data_->_tmp13_ = (g_free (_data_->_tmp13_), NULL);
		}
		if (!_data_->self->priv->is_open) {
			_data_->ids = (g_free (_data_->ids), 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_->_vala1_i = 0;
			_data_->_tmp19_ = _data_->ids;
			_data_->_tmp19__length1 = _data_->ids_length1;
			_data_->j = _data_->_tmp19__length1 - 1;
			{
				_data_->_tmp20_ = TRUE;
				while (TRUE) {
					if (!_data_->_tmp20_) {
						_data_->_tmp21_ = _data_->_vala1_i;
						_data_->_vala1_i = _data_->_tmp21_ + 1;
						_data_->_tmp22_ = _data_->j;
						_data_->j = _data_->_tmp22_ - 1;
					}
					_data_->_tmp20_ = FALSE;
					if (!(_data_->_vala1_i < _data_->j)) {
						break;
					}
					_data_->_tmp23_ = _data_->ids;
					_data_->_tmp23__length1 = _data_->ids_length1;
					_data_->_tmp24_ = _data_->_tmp23_[_data_->_vala1_i];
					_data_->t = _data_->_tmp24_;
					_data_->_tmp25_ = _data_->ids;
					_data_->_tmp25__length1 = _data_->ids_length1;
					_data_->_tmp26_ = _data_->ids;
					_data_->_tmp26__length1 = _data_->ids_length1;
					_data_->_tmp27_ = _data_->_tmp26_[_data_->j];
					_data_->_tmp25_[_data_->_vala1_i] = _data_->_tmp27_;
					_data_->_tmp28_ = _data_->ids;
					_data_->_tmp28__length1 = _data_->ids_length1;
					_data_->_tmp28_[_data_->j] = _data_->t;
				}
			}
		}
		{
			_data_->off = 0;
			{
				_data_->_tmp29_ = TRUE;
				while (TRUE) {
					if (!_data_->_tmp29_) {
						_data_->off += DC_GALLERY_DIALOG_FETCH_CHUNK;
					}
					_data_->_tmp29_ = FALSE;
					_data_->_tmp30_ = _data_->ids;
					_data_->_tmp30__length1 = _data_->ids_length1;
					if (!(_data_->off < _data_->_tmp30__length1)) {
						break;
					}
					_data_->_tmp31_ = _data_->ids;
					_data_->_tmp31__length1 = _data_->ids_length1;
					_data_->len = MIN (DC_GALLERY_DIALOG_FETCH_CHUNK, _data_->_tmp31__length1 - _data_->off);
					_data_->_tmp32_ = _data_->self->priv->rpc;
					_data_->_tmp33_ = _data_->ids;
					_data_->_tmp33__length1 = _data_->ids_length1;
					_data_->_tmp34_ = 0;
					_data_->_state_ = 3;
					dc_rpc_client_get_parsed_messages (_data_->_tmp32_, _data_->_tmp33_ + _data_->off, (gint) ((_data_->off + _data_->len) - _data_->off), dc_gallery_dialog_load_tab_ready, _data_);
					return FALSE;
					_state_3:
					_data_->_tmp35_ = dc_rpc_client_get_parsed_messages_finish (_data_->_tmp32_, _data_->_res_, &_data_->_tmp34_, &_data_->_inner_error0_);
					_data_->msgs = _data_->_tmp35_;
					_data_->msgs_length1 = _data_->_tmp34_;
					_data_->_msgs_size_ = _data_->msgs_length1;
					if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
						_data_->ids = (g_free (_data_->ids), NULL);
						goto __catch0_g_error;
					}
					if (!_data_->self->priv->is_open) {
						_data_->msgs = (_vala_array_free (_data_->msgs, _data_->msgs_length1, (GDestroyNotify) g_object_unref), NULL);
						_data_->ids = (g_free (_data_->ids), 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_->_tmp36_ = _data_->msgs;
					_data_->_tmp36__length1 = _data_->msgs_length1;
					dc_gallery_dialog_append_messages (_data_->self, _data_->tab, _data_->_tmp36_, (gint) _data_->_tmp36__length1);
					_data_->_tmp37_ = _data_->tab->store;
					if (g_list_model_get_n_items ((GListModel*) _data_->_tmp37_) > ((guint) 0)) {
						_data_->_tmp38_ = _data_->tab->stack;
						gtk_stack_set_visible_child_name (_data_->_tmp38_, "content");
					}
					_data_->msgs = (_vala_array_free (_data_->msgs, _data_->msgs_length1, (GDestroyNotify) g_object_unref), NULL);
				}
			}
		}
		_data_->ids = (g_free (_data_->ids), NULL);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		if (!_data_->self->priv->is_open) {
			_g_error_free0 (_data_->e);
			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_->_tmp39_ = _data_->e;
		_data_->_tmp40_ = _data_->_tmp39_->message;
		_data_->_tmp41_ = g_strconcat ("Could not load media: ", _data_->_tmp40_, NULL);
		_data_->_tmp42_ = _data_->_tmp41_;
		dc_gallery_dialog_toast (_data_->self, _data_->_tmp42_);
		_g_free0 (_data_->_tmp42_);
		_g_error_free0 (_data_->e);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		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;
	}
	_data_->_tmp43_ = _data_->tab->store;
	if (g_list_model_get_n_items ((GListModel*) _data_->_tmp43_) == ((guint) 0)) {
		_data_->_tmp44_ = _data_->tab->stack;
		gtk_stack_set_visible_child_name (_data_->_tmp44_, "empty");
	}
	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 gint
string_index_of (const gchar* self,
                 const gchar* needle,
                 gint start_index)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	g_return_val_if_fail (needle != NULL, -1);
	_tmp0_ = strstr (((gchar*) self) + start_index, (gchar*) needle);
	_result_ = _tmp0_;
	_tmp1_ = _result_;
	if (_tmp1_ != NULL) {
		gchar* _tmp2_;
		_tmp2_ = _result_;
		result = (gint) (_tmp2_ - ((gchar*) self));
		return result;
	} else {
		result = -1;
		return result;
	}
}

static void
_vala_array_add66 (GObject** * array,
                   gint* length,
                   gint* size,
                   GObject* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (GObject*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add67 (GObject** * array,
                   gint* length,
                   gint* size,
                   GObject* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (GObject*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
dc_gallery_dialog_append_messages (DcGalleryDialog* self,
                                   DcGalleryDialogGalleryTab* tab,
                                   DcMessage** msgs,
                                   gint msgs_length1)
{
	GObject** batch = NULL;
	GObject** _tmp0_;
	gint batch_length1;
	gint _batch_size_;
	GObject** _tmp28_;
	gint _tmp28__length1;
	g_return_if_fail (self != NULL);
	g_return_if_fail (tab != NULL);
	_tmp0_ = g_new0 (GObject*, 0 + 1);
	batch = _tmp0_;
	batch_length1 = 0;
	_batch_size_ = batch_length1;
	{
		DcMessage** msg_collection = NULL;
		gint msg_collection_length1 = 0;
		gint _msg_collection_size_ = 0;
		gint msg_it = 0;
		msg_collection = msgs;
		msg_collection_length1 = msgs_length1;
		for (msg_it = 0; msg_it < msg_collection_length1; msg_it = msg_it + 1) {
			DcMessage* _tmp1_;
			DcMessage* msg = NULL;
			_tmp1_ = _g_object_ref0 (msg_collection[msg_it]);
			msg = _tmp1_;
			{
				const gchar* _tmp2_;
				DcMessage* _tmp19_;
				gboolean _tmp20_;
				gboolean _tmp21_;
				gboolean _tmp22_ = FALSE;
				gboolean _tmp24_ = FALSE;
				DcMessage* _tmp26_;
				GObject* _tmp27_;
				_tmp2_ = tab->key;
				if (g_strcmp0 (_tmp2_, "links") == 0) {
					DcMessage* _tmp3_;
					gboolean _tmp4_;
					gboolean _tmp5_;
					const gchar* _tmp6_ = NULL;
					DcMessage* _tmp7_;
					const gchar* _tmp8_;
					const gchar* _tmp9_;
					gchar* t = NULL;
					gchar* _tmp10_;
					gboolean _tmp11_ = FALSE;
					const gchar* _tmp12_;
					DcMessage* _tmp17_;
					GObject* _tmp18_;
					_tmp3_ = msg;
					_tmp4_ = dc_message_get_is_info (_tmp3_);
					_tmp5_ = _tmp4_;
					if (_tmp5_) {
						_g_object_unref0 (msg);
						continue;
					}
					_tmp7_ = msg;
					_tmp8_ = dc_message_get_text (_tmp7_);
					_tmp9_ = _tmp8_;
					_tmp6_ = _tmp9_;
					if (_tmp6_ == NULL) {
						_tmp6_ = "";
					}
					_tmp10_ = g_strdup (_tmp6_);
					t = _tmp10_;
					_tmp12_ = t;
					if (string_index_of (_tmp12_, "://", 0) < 0) {
						_tmp11_ = TRUE;
					} else {
						const gchar* _tmp13_;
						gint _tmp14_ = 0;
						gchar** _tmp15_;
						gchar** _tmp16_;
						gint _tmp16__length1;
						_tmp13_ = t;
						_tmp15_ = dc_link_cleaner_find_urls (_tmp13_, &_tmp14_);
						_tmp16_ = _tmp15_;
						_tmp16__length1 = _tmp14_;
						_tmp11_ = _tmp14_ == 0;
						_tmp16_ = (_vala_array_free (_tmp16_, _tmp16__length1, (GDestroyNotify) g_free), NULL);
					}
					if (_tmp11_) {
						_g_free0 (t);
						_g_object_unref0 (msg);
						continue;
					}
					_tmp17_ = msg;
					_tmp18_ = _g_object_ref0 ((GObject*) _tmp17_);
					_vala_array_add66 (&batch, &batch_length1, &_batch_size_, _tmp18_);
					_g_free0 (t);
					_g_object_unref0 (msg);
					continue;
				}
				_tmp19_ = msg;
				_tmp20_ = dc_message_get_has_file (_tmp19_);
				_tmp21_ = _tmp20_;
				if (!_tmp21_) {
					_g_object_unref0 (msg);
					continue;
				}
				if (tab->filter == DC_GALLERY_DIALOG_MEDIA_FILTER_STICKERS_ONLY) {
					DcMessage* _tmp23_;
					_tmp23_ = msg;
					_tmp22_ = !dc_message_is_sticker_file (_tmp23_);
				} else {
					_tmp22_ = FALSE;
				}
				if (_tmp22_) {
					_g_object_unref0 (msg);
					continue;
				}
				if (tab->filter == DC_GALLERY_DIALOG_MEDIA_FILTER_NO_STICKERS) {
					DcMessage* _tmp25_;
					_tmp25_ = msg;
					_tmp24_ = dc_message_is_sticker_file (_tmp25_);
				} else {
					_tmp24_ = FALSE;
				}
				if (_tmp24_) {
					_g_object_unref0 (msg);
					continue;
				}
				_tmp26_ = msg;
				_tmp27_ = _g_object_ref0 ((GObject*) _tmp26_);
				_vala_array_add67 (&batch, &batch_length1, &_batch_size_, _tmp27_);
				_g_object_unref0 (msg);
			}
		}
	}
	_tmp28_ = batch;
	_tmp28__length1 = batch_length1;
	if (_tmp28__length1 > 0) {
		GListStore* _tmp29_;
		GListStore* _tmp30_;
		GObject** _tmp31_;
		gint _tmp31__length1;
		_tmp29_ = tab->store;
		_tmp30_ = tab->store;
		_tmp31_ = batch;
		_tmp31__length1 = batch_length1;
		g_list_store_splice (_tmp29_, g_list_model_get_n_items ((GListModel*) _tmp30_), (guint) 0, _tmp31_, (guint) _tmp31__length1);
	}
	batch = (_vala_array_free (batch, batch_length1, (GDestroyNotify) g_object_unref), NULL);
}

static void
dc_gallery_dialog_adjust_thumb_zoom (DcGalleryDialog* self,
                                     gint direction)
{
	gint avail = 0;
	AdwViewStack* _tmp0_;
	gboolean _tmp1_ = FALSE;
	gint min_cols = 0;
	GtkGridView** _tmp3_;
	gint _tmp3__length1;
	GtkGridView* _tmp4_;
	guint _tmp5_;
	guint _tmp6_;
	gint minw = 0;
	gint nat = 0;
	gint mb = 0;
	gint nb = 0;
	GtkGridView** _tmp7_;
	gint _tmp7__length1;
	GtkGridView* _tmp8_;
	gint _tmp9_ = 0;
	gint _tmp10_ = 0;
	gint _tmp11_ = 0;
	gint _tmp12_ = 0;
	gint overhead = 0;
	gint fit = 0;
	gint cols = 0;
	GtkGridView** _tmp13_;
	gint _tmp13__length1;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->view_stack;
	avail = gtk_widget_get_width ((GtkWidget*) _tmp0_);
	if (avail <= 0) {
		_tmp1_ = TRUE;
	} else {
		GtkGridView** _tmp2_;
		gint _tmp2__length1;
		_tmp2_ = self->priv->media_grids;
		_tmp2__length1 = self->priv->media_grids_length1;
		_tmp1_ = _tmp2__length1 == 0;
	}
	if (_tmp1_) {
		return;
	}
	_tmp3_ = self->priv->media_grids;
	_tmp3__length1 = self->priv->media_grids_length1;
	_tmp4_ = _tmp3_[0];
	_tmp5_ = gtk_grid_view_get_min_columns (_tmp4_);
	_tmp6_ = _tmp5_;
	min_cols = MAX (1, (gint) _tmp6_);
	_tmp7_ = self->priv->media_grids;
	_tmp7__length1 = self->priv->media_grids_length1;
	_tmp8_ = _tmp7_[0];
	gtk_widget_measure ((GtkWidget*) _tmp8_, GTK_ORIENTATION_HORIZONTAL, -1, &_tmp9_, &_tmp10_, &_tmp11_, &_tmp12_);
	minw = _tmp9_;
	nat = _tmp10_;
	mb = _tmp11_;
	nb = _tmp12_;
	overhead = MAX (0, minw - (min_cols * DC_GALLERY_DIALOG_CELL_MIN));
	fit = MAX (min_cols, (avail - overhead) / DC_GALLERY_DIALOG_CELL_MIN);
	cols = MIN (dc_gallery_dialog_zoom_columns, fit);
	cols = CLAMP (cols - direction, min_cols, DC_GALLERY_DIALOG_ZOOM_COLUMNS_MAX);
	if (cols == dc_gallery_dialog_zoom_columns) {
		return;
	}
	dc_gallery_dialog_zoom_columns = cols;
	_tmp13_ = self->priv->media_grids;
	_tmp13__length1 = self->priv->media_grids_length1;
	{
		GtkGridView** g_collection = NULL;
		gint g_collection_length1 = 0;
		gint _g_collection_size_ = 0;
		gint g_it = 0;
		g_collection = _tmp13_;
		g_collection_length1 = _tmp13__length1;
		for (g_it = 0; g_it < g_collection_length1; g_it = g_it + 1) {
			GtkGridView* _tmp14_;
			GtkGridView* g = NULL;
			_tmp14_ = _g_object_ref0 (g_collection[g_it]);
			g = _tmp14_;
			{
				GtkGridView* _tmp15_;
				_tmp15_ = g;
				gtk_grid_view_set_max_columns (_tmp15_, (guint) cols);
				_g_object_unref0 (g);
			}
		}
	}
}

static void
__lambda204_ (GObject* obj)
{
	GtkListItem* item = NULL;
	GtkListItem* _tmp0_;
	GtkWidget* _tmp1_;
	GtkWidget* _tmp2_;
	GObject* _tmp3_;
	GObject* _tmp4_;
	g_return_if_fail (obj != NULL);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (obj, gtk_list_item_get_type (), GtkListItem));
	item = _tmp0_;
	_tmp1_ = gtk_list_item_get_child (item);
	_tmp2_ = _tmp1_;
	_tmp3_ = gtk_list_item_get_item (item);
	_tmp4_ = _tmp3_;
	dc_gallery_cell_bind (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, DC_TYPE_GALLERY_CELL, DcGalleryCell), G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, DC_TYPE_MESSAGE, DcMessage));
	_g_object_unref0 (item);
}

static void
___lambda204__gtk_signal_list_item_factory_bind (GtkSignalListItemFactory* _sender,
                                                 GObject* object,
                                                 gpointer self)
{
	__lambda204_ (object);
}

static void
__lambda205_ (GObject* obj)
{
	GtkListItem* item = NULL;
	GtkListItem* _tmp0_;
	GtkWidget* _tmp1_;
	GtkWidget* _tmp2_;
	g_return_if_fail (obj != NULL);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (obj, gtk_list_item_get_type (), GtkListItem));
	item = _tmp0_;
	_tmp1_ = gtk_list_item_get_child (item);
	_tmp2_ = _tmp1_;
	dc_gallery_cell_unbind (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, DC_TYPE_GALLERY_CELL, DcGalleryCell));
	_g_object_unref0 (item);
}

static void
___lambda205__gtk_signal_list_item_factory_unbind (GtkSignalListItemFactory* _sender,
                                                   GObject* object,
                                                   gpointer self)
{
	__lambda205_ (object);
}

static GtkSignalListItemFactory*
dc_gallery_dialog_make_cell_factory (void)
{
	GtkSignalListItemFactory* factory = NULL;
	GtkSignalListItemFactory* _tmp0_;
	GtkSignalListItemFactory* result;
	_tmp0_ = (GtkSignalListItemFactory*) gtk_signal_list_item_factory_new ();
	factory = _tmp0_;
	g_signal_connect (factory, "bind", (GCallback) ___lambda204__gtk_signal_list_item_factory_bind, NULL);
	g_signal_connect (factory, "unbind", (GCallback) ___lambda205__gtk_signal_list_item_factory_unbind, NULL);
	result = factory;
	return result;
}

static Block105Data*
block105_data_ref (Block105Data* _data105_)
{
	g_atomic_int_inc (&_data105_->_ref_count_);
	return _data105_;
}

static void
block105_data_unref (void * _userdata_)
{
	Block105Data* _data105_;
	_data105_ = (Block105Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data105_->_ref_count_)) {
		DcGalleryDialog* self;
		self = _data105_->self;
		_g_object_unref0 (_data105_->tab);
		_g_object_unref0 (self);
		g_slice_free (Block105Data, _data105_);
	}
}

static void
__lambda206_ (Block105Data* _data105_,
              GObject* obj)
{
	DcGalleryDialog* self;
	DcGalleryDialogMediaCell* _tmp0_;
	DcGalleryDialogMediaCell* _tmp1_;
	self = _data105_->self;
	g_return_if_fail (obj != NULL);
	_tmp0_ = dc_gallery_dialog_media_cell_new (self, _data105_->is_video, _data105_->contain);
	g_object_ref_sink (_tmp0_);
	_tmp1_ = _tmp0_;
	gtk_list_item_set_child (G_TYPE_CHECK_INSTANCE_CAST (obj, gtk_list_item_get_type (), GtkListItem), (GtkWidget*) _tmp1_);
	_g_object_unref0 (_tmp1_);
}

static void
___lambda206__gtk_signal_list_item_factory_setup (GtkSignalListItemFactory* _sender,
                                                  GObject* object,
                                                  gpointer self)
{
	__lambda206_ (self, object);
}

static void
_vala_array_add68 (GtkGridView** * array,
                   gint* length,
                   gint* size,
                   GtkGridView* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (GtkGridView*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
__lambda222_ (Block105Data* _data105_,
              guint pos)
{
	DcGalleryDialog* self;
	self = _data105_->self;
	dc_gallery_dialog_on_media_activated (self, _data105_->tab, pos);
}

static void
___lambda222__gtk_grid_view_activate (GtkGridView* _sender,
                                      guint position,
                                      gpointer self)
{
	__lambda222_ (self, position);
}

static GtkGridView*
dc_gallery_dialog_build_media_grid (DcGalleryDialog* self,
                                    DcGalleryDialogGalleryTab* tab)
{
	Block105Data* _data105_;
	DcGalleryDialogGalleryTab* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	GtkSignalListItemFactory* factory = NULL;
	GtkSignalListItemFactory* _tmp3_;
	GtkGridView* grid = NULL;
	GListStore* _tmp4_;
	GListModel* _tmp5_;
	GtkNoSelection* _tmp6_;
	GtkListItemFactory* _tmp7_;
	GtkGridView* _tmp8_;
	GtkGridView* _tmp9_;
	GtkGridView* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (tab != NULL, NULL);
	_data105_ = g_slice_new0 (Block105Data);
	_data105_->_ref_count_ = 1;
	_data105_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (tab);
	_g_object_unref0 (_data105_->tab);
	_data105_->tab = _tmp0_;
	_tmp1_ = _data105_->tab->key;
	_data105_->is_video = g_strcmp0 (_tmp1_, "video") == 0;
	_tmp2_ = _data105_->tab->key;
	_data105_->contain = g_strcmp0 (_tmp2_, "stickers") == 0;
	_tmp3_ = dc_gallery_dialog_make_cell_factory ();
	factory = _tmp3_;
	g_signal_connect_data (factory, "setup", (GCallback) ___lambda206__gtk_signal_list_item_factory_setup, block105_data_ref (_data105_), (GClosureNotify) block105_data_unref, 0);
	_tmp4_ = _data105_->tab->store;
	_tmp5_ = _g_object_ref0 ((GListModel*) _tmp4_);
	_tmp6_ = gtk_no_selection_new (_tmp5_);
	_tmp7_ = _g_object_ref0 ((GtkListItemFactory*) factory);
	_tmp8_ = (GtkGridView*) gtk_grid_view_new ((GtkSelectionModel*) _tmp6_, _tmp7_);
	g_object_ref_sink (_tmp8_);
	grid = _tmp8_;
	gtk_grid_view_set_single_click_activate (grid, TRUE);
	gtk_grid_view_set_min_columns (grid, (guint) 1);
	gtk_grid_view_set_max_columns (grid, (guint) dc_gallery_dialog_zoom_columns);
	gtk_widget_add_css_class ((GtkWidget*) grid, "gallery-grid");
	_tmp9_ = _g_object_ref0 (grid);
	_vala_array_add68 (&self->priv->media_grids, &self->priv->media_grids_length1, &self->priv->_media_grids_size_, _tmp9_);
	g_signal_connect_data (grid, "activate", (GCallback) ___lambda222__gtk_grid_view_activate, block105_data_ref (_data105_), (GClosureNotify) block105_data_unref, 0);
	dc_gallery_dialog_install_menu_key (self, (GtkWidget*) grid);
	result = grid;
	_g_object_unref0 (factory);
	block105_data_unref (_data105_);
	_data105_ = NULL;
	return result;
}

static void
dc_gallery_dialog_load_thumb_data_free (gpointer _data)
{
	DcGalleryDialogLoadThumbData* _data_;
	_data_ = _data;
	_g_free0 (_data_->path);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (DcGalleryDialogLoadThumbData, _data_);
}

static void
dc_gallery_dialog_load_thumb (DcGalleryDialog* self,
                              const gchar* path,
                              GAsyncReadyCallback _callback_,
                              gpointer _user_data_)
{
	DcGalleryDialogLoadThumbData* _data_;
	DcGalleryDialog* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (path != NULL);
	_data_ = g_slice_new0 (DcGalleryDialogLoadThumbData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_gallery_dialog_load_thumb_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = g_strdup (path);
	_g_free0 (_data_->path);
	_data_->path = _tmp1_;
	dc_gallery_dialog_load_thumb_co (_data_);
}

static GdkTexture*
dc_gallery_dialog_load_thumb_finish (DcGalleryDialog* self,
                                     GAsyncResult* _res_)
{
	GdkTexture* result;
	DcGalleryDialogLoadThumbData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static gboolean
_dc_gallery_dialog_load_thumb_co_gsource_func (gpointer self)
{
	gboolean result;
	result = dc_gallery_dialog_load_thumb_co (self);
	return result;
}

static gpointer
_dc_gallery_dialog_thumb_request_ref0 (gpointer self)
{
	return self ? dc_gallery_dialog_thumb_request_ref (self) : NULL;
}

static gboolean
dc_gallery_dialog_load_thumb_co (DcGalleryDialogLoadThumbData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->thumb_cache;
	_data_->_tmp1_ = g_hash_table_lookup (_data_->_tmp0_, _data_->path);
	_data_->_tmp2_ = _g_object_ref0 ((GdkTexture*) _data_->_tmp1_);
	_data_->cached = _data_->_tmp2_;
	_data_->_tmp3_ = _data_->cached;
	if (_data_->_tmp3_ != NULL) {
		_data_->result = _data_->cached;
		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_->_tmp4_ = _data_->self->priv->thumb_pool;
	if (_data_->_tmp4_ == NULL) {
		_data_->result = NULL;
		_g_object_unref0 (_data_->cached);
		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_->_tmp5_ = dc_gallery_dialog_thumb_request_new ();
	_data_->req = _data_->_tmp5_;
	_data_->_tmp6_ = _data_->req;
	_data_->_tmp7_ = g_strdup (_data_->path);
	_g_free0 (_data_->_tmp6_->path);
	_data_->_tmp6_->path = _data_->_tmp7_;
	_data_->_tmp8_ = _data_->req;
	_data_->_tmp8_->size = DC_GALLERY_DIALOG_CELL_MIN * 2;
	_data_->_tmp9_ = _data_->req;
	_data_->_tmp10_ = g_idle_source_new ();
	_g_source_unref0 (_data_->_tmp9_->resume_source);
	_data_->_tmp9_->resume_source = _data_->_tmp10_;
	_data_->_tmp11_ = _data_->req;
	_data_->_tmp12_ = _data_->_tmp11_->resume_source;
	g_source_set_callback (_data_->_tmp12_, _dc_gallery_dialog_load_thumb_co_gsource_func, _data_, NULL);
	{
		_data_->_tmp13_ = _data_->self->priv->thumb_pool;
		_data_->_tmp14_ = _data_->req;
		_data_->_tmp15_ = _dc_gallery_dialog_thumb_request_ref0 (_data_->_tmp14_);
		g_thread_pool_push (_data_->_tmp13_, _data_->_tmp15_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_data_->_inner_error0_);
		_data_->result = NULL;
		_dc_gallery_dialog_thumb_request_unref0 (_data_->req);
		_g_object_unref0 (_data_->cached);
		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;
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_dc_gallery_dialog_thumb_request_unref0 (_data_->req);
		_g_object_unref0 (_data_->cached);
		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;
	}
	_data_->_state_ = 1;
	return FALSE;
	_state_1:
	;
	_data_->_tmp16_ = _data_->req;
	_data_->_tmp17_ = _data_->_tmp16_->result;
	if (_data_->_tmp17_ != NULL) {
		_data_->_tmp18_ = _data_->self->priv->thumb_cache;
		_data_->_tmp19_ = g_strdup (_data_->path);
		_data_->_tmp20_ = _data_->req;
		_data_->_tmp21_ = _data_->_tmp20_->result;
		_data_->_tmp22_ = _g_object_ref0 (_data_->_tmp21_);
		g_hash_table_insert (_data_->_tmp18_, _data_->_tmp19_, _data_->_tmp22_);
	}
	_data_->_tmp23_ = _data_->req;
	_data_->_tmp24_ = _data_->_tmp23_->result;
	_data_->_tmp25_ = _g_object_ref0 (_data_->_tmp24_);
	_data_->result = _data_->_tmp25_;
	_dc_gallery_dialog_thumb_request_unref0 (_data_->req);
	_g_object_unref0 (_data_->cached);
	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;
}

/** False (with a toast) when the attachment is not downloaded. */
static gboolean
dc_gallery_dialog_ensure_local_file (DcGalleryDialog* self,
                                     DcMessage* m)
{
	gboolean _tmp0_;
	gboolean _tmp1_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (m != NULL, FALSE);
	_tmp0_ = dc_message_get_has_local_file (m);
	_tmp1_ = _tmp0_;
	if (_tmp1_) {
		result = TRUE;
		return result;
	}
	dc_gallery_dialog_toast (self, "File not available");
	result = FALSE;
	return result;
}

static void
_vala_array_add69 (gchar** * array,
                   gint* length,
                   gint* size,
                   gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
dc_gallery_dialog_on_media_activated (DcGalleryDialog* self,
                                      DcGalleryDialogGalleryTab* tab,
                                      guint pos)
{
	DcMessage* m = NULL;
	GListStore* _tmp0_;
	GObject* _tmp1_;
	DcMessage* _tmp2_;
	gboolean _tmp3_;
	DcMessage* _tmp5_;
	gboolean _tmp6_ = FALSE;
	const gchar* _tmp7_;
	gchar** paths = NULL;
	gchar** _tmp16_;
	gint paths_length1;
	gint _paths_size_;
	gint start = 0;
	DcImageViewer* _tmp40_;
	gchar** _tmp41_;
	gint _tmp41__length1;
	g_return_if_fail (self != NULL);
	g_return_if_fail (tab != NULL);
	_tmp0_ = tab->store;
	_tmp1_ = g_list_model_get_item ((GListModel*) _tmp0_, pos);
	m = G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, DC_TYPE_MESSAGE, DcMessage);
	_tmp2_ = m;
	if (_tmp2_ == NULL) {
		_g_object_unref0 (m);
		return;
	}
	_tmp3_ = self->priv->_selection_mode;
	if (_tmp3_) {
		DcMessage* _tmp4_;
		_tmp4_ = m;
		dc_gallery_dialog_toggle_selected (self, _tmp4_);
		_g_object_unref0 (m);
		return;
	}
	_tmp5_ = m;
	if (!dc_gallery_dialog_ensure_local_file (self, _tmp5_)) {
		_g_object_unref0 (m);
		return;
	}
	_tmp7_ = tab->key;
	if (g_strcmp0 (_tmp7_, "video") == 0) {
		_tmp6_ = TRUE;
	} else {
		DcMessage* _tmp8_;
		_tmp8_ = m;
		_tmp6_ = dc_message_is_video_sticker_file (_tmp8_);
	}
	if (_tmp6_) {
		DcVideoPlayer* _tmp9_;
		DcMessage* _tmp10_;
		const gchar* _tmp11_;
		const gchar* _tmp12_;
		DcMessage* _tmp13_;
		const gchar* _tmp14_;
		const gchar* _tmp15_;
		_tmp9_ = self->priv->player;
		_tmp10_ = m;
		_tmp11_ = dc_message_get_file_path (_tmp10_);
		_tmp12_ = _tmp11_;
		_tmp13_ = m;
		_tmp14_ = dc_message_get_file_name (_tmp13_);
		_tmp15_ = _tmp14_;
		dc_video_player_show (_tmp9_, _tmp12_, _tmp15_);
		_g_object_unref0 (m);
		return;
	}
	_tmp16_ = g_new0 (gchar*, 0 + 1);
	paths = _tmp16_;
	paths_length1 = 0;
	_paths_size_ = paths_length1;
	start = 0;
	{
		guint i = 0U;
		i = (guint) 0;
		{
			gboolean _tmp17_ = FALSE;
			_tmp17_ = TRUE;
			while (TRUE) {
				GListStore* _tmp19_;
				DcMessage* it = NULL;
				GListStore* _tmp20_;
				GObject* _tmp21_;
				gboolean _tmp22_ = FALSE;
				gboolean _tmp23_ = FALSE;
				DcMessage* _tmp24_;
				DcMessage* _tmp29_;
				gint _tmp30_;
				gint _tmp31_;
				DcMessage* _tmp32_;
				gint _tmp33_;
				gint _tmp34_;
				DcMessage* _tmp36_;
				const gchar* _tmp37_;
				const gchar* _tmp38_;
				gchar* _tmp39_;
				if (!_tmp17_) {
					guint _tmp18_;
					_tmp18_ = i;
					i = _tmp18_ + 1;
				}
				_tmp17_ = FALSE;
				_tmp19_ = tab->store;
				if (!(i < g_list_model_get_n_items ((GListModel*) _tmp19_))) {
					break;
				}
				_tmp20_ = tab->store;
				_tmp21_ = g_list_model_get_item ((GListModel*) _tmp20_, i);
				it = G_TYPE_CHECK_INSTANCE_CAST (_tmp21_, DC_TYPE_MESSAGE, DcMessage);
				_tmp24_ = it;
				if (_tmp24_ == NULL) {
					_tmp23_ = TRUE;
				} else {
					DcMessage* _tmp25_;
					gboolean _tmp26_;
					gboolean _tmp27_;
					_tmp25_ = it;
					_tmp26_ = dc_message_get_has_local_file (_tmp25_);
					_tmp27_ = _tmp26_;
					_tmp23_ = !_tmp27_;
				}
				if (_tmp23_) {
					_tmp22_ = TRUE;
				} else {
					DcMessage* _tmp28_;
					_tmp28_ = it;
					_tmp22_ = dc_message_is_video_sticker_file (_tmp28_);
				}
				if (_tmp22_) {
					_g_object_unref0 (it);
					continue;
				}
				_tmp29_ = it;
				_tmp30_ = dc_message_get_id (_tmp29_);
				_tmp31_ = _tmp30_;
				_tmp32_ = m;
				_tmp33_ = dc_message_get_id (_tmp32_);
				_tmp34_ = _tmp33_;
				if (_tmp31_ == _tmp34_) {
					gchar** _tmp35_;
					gint _tmp35__length1;
					_tmp35_ = paths;
					_tmp35__length1 = paths_length1;
					start = _tmp35__length1;
				}
				_tmp36_ = it;
				_tmp37_ = dc_message_get_file_path (_tmp36_);
				_tmp38_ = _tmp37_;
				_tmp39_ = g_strdup (_tmp38_);
				_vala_array_add69 (&paths, &paths_length1, &_paths_size_, _tmp39_);
				_g_object_unref0 (it);
			}
		}
	}
	_tmp40_ = self->priv->viewer;
	_tmp41_ = paths;
	_tmp41__length1 = paths_length1;
	dc_image_viewer_show_list (_tmp40_, _tmp41_, (gint) _tmp41__length1, start);
	paths = (_vala_array_free (paths, paths_length1, (GDestroyNotify) g_free), NULL);
	_g_object_unref0 (m);
}

static Block106Data*
block106_data_ref (Block106Data* _data106_)
{
	g_atomic_int_inc (&_data106_->_ref_count_);
	return _data106_;
}

static void
block106_data_unref (void * _userdata_)
{
	Block106Data* _data106_;
	_data106_ = (Block106Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data106_->_ref_count_)) {
		DcGalleryDialog* self;
		self = _data106_->self;
		_g_object_unref0 (_data106_->tab);
		_g_object_unref0 (self);
		g_slice_free (Block106Data, _data106_);
	}
}

static void
__lambda224_ (Block106Data* _data106_,
              GObject* obj)
{
	DcGalleryDialog* self;
	const gchar* _tmp0_;
	DcGalleryDialogGalleryRow* _tmp1_;
	DcGalleryDialogGalleryRow* _tmp2_;
	self = _data106_->self;
	g_return_if_fail (obj != NULL);
	_tmp0_ = _data106_->tab->key;
	_tmp1_ = dc_gallery_dialog_gallery_row_new (self, _tmp0_);
	g_object_ref_sink (_tmp1_);
	_tmp2_ = _tmp1_;
	gtk_list_item_set_child (G_TYPE_CHECK_INSTANCE_CAST (obj, gtk_list_item_get_type (), GtkListItem), (GtkWidget*) _tmp2_);
	_g_object_unref0 (_tmp2_);
}

static void
___lambda224__gtk_signal_list_item_factory_setup (GtkSignalListItemFactory* _sender,
                                                  GObject* object,
                                                  gpointer self)
{
	__lambda224_ (self, object);
}

static void
__lambda230_ (Block106Data* _data106_,
              guint pos)
{
	DcGalleryDialog* self;
	DcMessage* m = NULL;
	GListStore* _tmp0_;
	GObject* _tmp1_;
	DcMessage* _tmp2_;
	self = _data106_->self;
	_tmp0_ = _data106_->tab->store;
	_tmp1_ = g_list_model_get_item ((GListModel*) _tmp0_, pos);
	m = G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, DC_TYPE_MESSAGE, DcMessage);
	_tmp2_ = m;
	if (_tmp2_ != NULL) {
		DcMessage* _tmp3_;
		_tmp3_ = m;
		dc_gallery_dialog_on_row_activated (self, _data106_->tab, _tmp3_);
	}
	_g_object_unref0 (m);
}

static void
___lambda230__gtk_list_view_activate (GtkListView* _sender,
                                      guint position,
                                      gpointer self)
{
	__lambda230_ (self, position);
}

static GtkListView*
dc_gallery_dialog_build_row_list (DcGalleryDialog* self,
                                  DcGalleryDialogGalleryTab* tab)
{
	Block106Data* _data106_;
	DcGalleryDialogGalleryTab* _tmp0_;
	GtkSignalListItemFactory* factory = NULL;
	GtkSignalListItemFactory* _tmp1_;
	GtkListView* list = NULL;
	GListStore* _tmp2_;
	GListModel* _tmp3_;
	GtkNoSelection* _tmp4_;
	GtkListItemFactory* _tmp5_;
	GtkListView* _tmp6_;
	GtkListView* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (tab != NULL, NULL);
	_data106_ = g_slice_new0 (Block106Data);
	_data106_->_ref_count_ = 1;
	_data106_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (tab);
	_g_object_unref0 (_data106_->tab);
	_data106_->tab = _tmp0_;
	_tmp1_ = dc_gallery_dialog_make_cell_factory ();
	factory = _tmp1_;
	g_signal_connect_data (factory, "setup", (GCallback) ___lambda224__gtk_signal_list_item_factory_setup, block106_data_ref (_data106_), (GClosureNotify) block106_data_unref, 0);
	_tmp2_ = _data106_->tab->store;
	_tmp3_ = _g_object_ref0 ((GListModel*) _tmp2_);
	_tmp4_ = gtk_no_selection_new (_tmp3_);
	_tmp5_ = _g_object_ref0 ((GtkListItemFactory*) factory);
	_tmp6_ = (GtkListView*) gtk_list_view_new ((GtkSelectionModel*) _tmp4_, _tmp5_);
	g_object_ref_sink (_tmp6_);
	list = _tmp6_;
	gtk_list_view_set_single_click_activate (list, TRUE);
	gtk_widget_add_css_class ((GtkWidget*) list, "gallery-list");
	g_signal_connect_data (list, "activate", (GCallback) ___lambda230__gtk_list_view_activate, block106_data_ref (_data106_), (GClosureNotify) block106_data_unref, 0);
	dc_gallery_dialog_install_menu_key (self, (GtkWidget*) list);
	result = list;
	_g_object_unref0 (factory);
	block106_data_unref (_data106_);
	_data106_ = NULL;
	return result;
}

static void
dc_gallery_dialog_on_row_activated (DcGalleryDialog* self,
                                    DcGalleryDialogGalleryTab* tab,
                                    DcMessage* m)
{
	gboolean _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	GQuark _tmp4_ = 0U;
	static GQuark _tmp3_label0 = 0;
	static GQuark _tmp3_label1 = 0;
	static GQuark _tmp3_label2 = 0;
	static GQuark _tmp3_label3 = 0;
	g_return_if_fail (self != NULL);
	g_return_if_fail (tab != NULL);
	g_return_if_fail (m != NULL);
	_tmp0_ = self->priv->_selection_mode;
	if (_tmp0_) {
		dc_gallery_dialog_toggle_selected (self, m);
		return;
	}
	_tmp1_ = tab->key;
	_tmp2_ = _tmp1_;
	_tmp4_ = (NULL == _tmp2_) ? 0 : g_quark_from_string (_tmp2_);
	if (_tmp4_ == ((0 != _tmp3_label0) ? _tmp3_label0 : (_tmp3_label0 = g_quark_from_static_string ("audio")))) {
		switch (0) {
			default:
			{
				dc_gallery_dialog_toggle_audio (self, m);
				break;
			}
		}
	} else if (_tmp4_ == ((0 != _tmp3_label1) ? _tmp3_label1 : (_tmp3_label1 = g_quark_from_static_string ("files")))) {
		switch (0) {
			default:
			{
				dc_gallery_dialog_open_file (self, m);
				break;
			}
		}
	} else if (_tmp4_ == ((0 != _tmp3_label2) ? _tmp3_label2 : (_tmp3_label2 = g_quark_from_static_string ("apps")))) {
		switch (0) {
			default:
			{
				DcWindow* _tmp5_;
				DcRpcClient* _tmp6_;
				_tmp5_ = self->priv->app_window;
				_tmp6_ = self->priv->rpc;
				dc_window_prompt_webxdc_app (_tmp5_, (GtkWidget*) self, _tmp6_, m, NULL, NULL);
				break;
			}
		}
	} else if (_tmp4_ == ((0 != _tmp3_label3) ? _tmp3_label3 : (_tmp3_label3 = g_quark_from_static_string ("links")))) {
		switch (0) {
			default:
			{
				const gchar* _tmp7_ = NULL;
				const gchar* _tmp8_;
				const gchar* _tmp9_;
				gchar** links = NULL;
				gint _tmp10_ = 0;
				gchar** _tmp11_;
				gint links_length1;
				gint _links_size_;
				gchar** _tmp12_;
				gint _tmp12__length1;
				_tmp8_ = dc_message_get_text (m);
				_tmp9_ = _tmp8_;
				_tmp7_ = _tmp9_;
				if (_tmp7_ == NULL) {
					_tmp7_ = "";
				}
				_tmp11_ = dc_link_cleaner_find_urls (_tmp7_, &_tmp10_);
				links = _tmp11_;
				links_length1 = _tmp10_;
				_links_size_ = links_length1;
				_tmp12_ = links;
				_tmp12__length1 = links_length1;
				if (_tmp12__length1 > 0) {
					gchar** _tmp13_;
					gint _tmp13__length1;
					const gchar* _tmp14_;
					_tmp13_ = links;
					_tmp13__length1 = links_length1;
					_tmp14_ = _tmp13_[0];
					dc_gallery_dialog_open_link (self, _tmp14_);
				}
				links = (_vala_array_free (links, links_length1, (GDestroyNotify) g_free), NULL);
				break;
			}
		}
	}
}

static Block107Data*
block107_data_ref (Block107Data* _data107_)
{
	g_atomic_int_inc (&_data107_->_ref_count_);
	return _data107_;
}

static void
block107_data_unref (void * _userdata_)
{
	Block107Data* _data107_;
	_data107_ = (Block107Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data107_->_ref_count_)) {
		DcGalleryDialog* self;
		self = _data107_->self;
		_g_object_unref0 (_data107_->launcher);
		_g_object_unref0 (self);
		g_slice_free (Block107Data, _data107_);
	}
}

static void
__lambda209_ (Block107Data* _data107_,
              GObject* o,
              GAsyncResult* res)
{
	DcGalleryDialog* self;
	GError* _inner_error0_ = NULL;
	self = _data107_->self;
	g_return_if_fail (res != NULL);
	{
		gtk_uri_launcher_launch_finish (_data107_->launcher, res, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp0_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp0_ = e;
		if (!dc_is_dialog_dismissal (_tmp0_)) {
			GError* _tmp1_;
			const gchar* _tmp2_;
			gchar* _tmp3_;
			gchar* _tmp4_;
			_tmp1_ = e;
			_tmp2_ = _tmp1_->message;
			_tmp3_ = g_strconcat ("Could not open link: ", _tmp2_, NULL);
			_tmp4_ = _tmp3_;
			dc_gallery_dialog_toast (self, _tmp4_);
			_g_free0 (_tmp4_);
		}
		_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;
	}
}

static void
___lambda209__gasync_ready_callback (GObject* source_object,
                                     GAsyncResult* res,
                                     gpointer self)
{
	__lambda209_ (self, source_object, res);
	block107_data_unref (self);
}

static void
dc_gallery_dialog_open_link (DcGalleryDialog* self,
                             const gchar* url)
{
	Block107Data* _data107_;
	GtkUriLauncher* _tmp0_;
	DcWindow* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (url != NULL);
	_data107_ = g_slice_new0 (Block107Data);
	_data107_->_ref_count_ = 1;
	_data107_->self = g_object_ref (self);
	_tmp0_ = gtk_uri_launcher_new (url);
	_data107_->launcher = _tmp0_;
	_tmp1_ = self->priv->app_window;
	gtk_uri_launcher_launch (_data107_->launcher, (GtkWindow*) _tmp1_, NULL, ___lambda209__gasync_ready_callback, block107_data_ref (_data107_));
	block107_data_unref (_data107_);
	_data107_ = NULL;
}

static void
dc_gallery_dialog_toggle_audio (DcGalleryDialog* self,
                                DcMessage* m)
{
	DcAudioPlayback* playback = NULL;
	DcAudioPlayback* _tmp0_;
	DcAudioPlayback* _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (m != NULL);
	if (!dc_gallery_dialog_ensure_local_file (self, m)) {
		return;
	}
	_tmp0_ = dc_audio_playback_shared ();
	playback = _tmp0_;
	_tmp1_ = playback;
	_tmp2_ = dc_audio_playback_get_current_message_id (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = dc_message_get_id (m);
	_tmp5_ = _tmp4_;
	if (_tmp3_ == _tmp5_) {
		DcAudioPlayback* _tmp6_;
		_tmp6_ = playback;
		dc_audio_playback_toggle (_tmp6_);
	} else {
		DcAudioPlayback* _tmp7_;
		DcRpcClient* _tmp8_;
		gint _tmp9_;
		gint _tmp10_;
		_tmp7_ = playback;
		_tmp8_ = self->priv->rpc;
		_tmp9_ = dc_rpc_client_get_account_id (_tmp8_);
		_tmp10_ = _tmp9_;
		dc_audio_playback_play_message (_tmp7_, m, _tmp10_);
		self->priv->playback_was_started = TRUE;
	}
	_g_object_unref0 (playback);
}

static Block108Data*
block108_data_ref (Block108Data* _data108_)
{
	g_atomic_int_inc (&_data108_->_ref_count_);
	return _data108_;
}

static void
block108_data_unref (void * _userdata_)
{
	Block108Data* _data108_;
	_data108_ = (Block108Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data108_->_ref_count_)) {
		DcGalleryDialog* self;
		self = _data108_->self;
		_g_object_unref0 (_data108_->launcher);
		_g_object_unref0 (self);
		g_slice_free (Block108Data, _data108_);
	}
}

static void
__lambda231_ (Block108Data* _data108_,
              GObject* o,
              GAsyncResult* res)
{
	DcGalleryDialog* self;
	GError* _inner_error0_ = NULL;
	self = _data108_->self;
	g_return_if_fail (res != NULL);
	{
		GtkFileLauncher* _tmp0_;
		_tmp0_ = _data108_->launcher;
		gtk_file_launcher_launch_finish (_tmp0_, res, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp1_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp1_ = e;
		if (!dc_is_dialog_dismissal (_tmp1_)) {
			GError* _tmp2_;
			const gchar* _tmp3_;
			gchar* _tmp4_;
			gchar* _tmp5_;
			_tmp2_ = e;
			_tmp3_ = _tmp2_->message;
			_tmp4_ = g_strconcat ("Could not open file: ", _tmp3_, NULL);
			_tmp5_ = _tmp4_;
			dc_gallery_dialog_toast (self, _tmp5_);
			_g_free0 (_tmp5_);
		}
		_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;
	}
}

static void
___lambda231__gasync_ready_callback (GObject* source_object,
                                     GAsyncResult* res,
                                     gpointer self)
{
	__lambda231_ (self, source_object, res);
	block108_data_unref (self);
}

static void
dc_gallery_dialog_open_file (DcGalleryDialog* self,
                             DcMessage* m)
{
	Block108Data* _data108_;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	GFile* _tmp2_;
	GFile* _tmp3_;
	GtkFileLauncher* _tmp4_;
	GtkFileLauncher* _tmp5_;
	GtkFileLauncher* _tmp6_;
	DcWindow* _tmp7_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (m != NULL);
	_data108_ = g_slice_new0 (Block108Data);
	_data108_->_ref_count_ = 1;
	_data108_->self = g_object_ref (self);
	if (!dc_gallery_dialog_ensure_local_file (self, m)) {
		block108_data_unref (_data108_);
		_data108_ = NULL;
		return;
	}
	_tmp0_ = dc_message_get_file_path (m);
	_tmp1_ = _tmp0_;
	_tmp2_ = g_file_new_for_path (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = gtk_file_launcher_new (_tmp3_);
	_tmp5_ = _tmp4_;
	_g_object_unref0 (_tmp3_);
	_data108_->launcher = _tmp5_;
	_tmp6_ = _data108_->launcher;
	_tmp7_ = self->priv->app_window;
	gtk_file_launcher_launch (_tmp6_, (GtkWindow*) _tmp7_, NULL, ___lambda231__gasync_ready_callback, block108_data_ref (_data108_));
	block108_data_unref (_data108_);
	_data108_ = NULL;
}

/** Right click and touch long-press open the item context menu.
            The message is read at event time because cells are recycled
            and rebound to different messages. */
static Block109Data*
block109_data_ref (Block109Data* _data109_)
{
	g_atomic_int_inc (&_data109_->_ref_count_);
	return _data109_;
}

static void
block109_data_unref (void * _userdata_)
{
	Block109Data* _data109_;
	_data109_ = (Block109Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data109_->_ref_count_)) {
		_g_object_unref0 (_data109_->widget);
		_g_object_unref0 (_data109_->cell);
		_g_object_unref0 (_data109_->dialog);
		g_slice_free (Block109Data, _data109_);
	}
}

static void
__lambda207_ (Block109Data* _data109_,
              gint n,
              gdouble x,
              gdouble y)
{
	DcMessage* _tmp0_;
	DcMessage* _tmp1_;
	_tmp0_ = dc_gallery_cell_get_msg (_data109_->cell);
	_tmp1_ = _tmp0_;
	if (_tmp1_ != NULL) {
		DcMessage* _tmp2_;
		DcMessage* _tmp3_;
		_tmp2_ = dc_gallery_cell_get_msg (_data109_->cell);
		_tmp3_ = _tmp2_;
		dc_gallery_dialog_show_item_menu (_data109_->dialog, _data109_->widget, _tmp3_, x, y);
	}
}

static void
___lambda207__gtk_gesture_click_pressed (GtkGestureClick* _sender,
                                         gint n_press,
                                         gdouble x,
                                         gdouble y,
                                         gpointer self)
{
	__lambda207_ (self, n_press, x, y);
}

static void
__lambda219_ (Block109Data* _data109_,
              gdouble x,
              gdouble y)
{
	DcMessage* _tmp0_;
	DcMessage* _tmp1_;
	_tmp0_ = dc_gallery_cell_get_msg (_data109_->cell);
	_tmp1_ = _tmp0_;
	if (_tmp1_ != NULL) {
		DcMessage* _tmp2_;
		DcMessage* _tmp3_;
		_tmp2_ = dc_gallery_cell_get_msg (_data109_->cell);
		_tmp3_ = _tmp2_;
		dc_gallery_dialog_show_item_menu (_data109_->dialog, _data109_->widget, _tmp3_, x, y);
	}
}

static void
___lambda219__gtk_gesture_long_press_pressed (GtkGestureLongPress* _sender,
                                              gdouble x,
                                              gdouble y,
                                              gpointer self)
{
	__lambda219_ (self, x, y);
}

static void
dc_gallery_dialog_add_context_menu_gestures (DcGalleryCell* cell,
                                             DcGalleryDialog* dialog)
{
	Block109Data* _data109_;
	DcGalleryCell* _tmp0_;
	DcGalleryDialog* _tmp1_;
	GtkWidget* _tmp2_;
	GtkGestureClick* right_click = NULL;
	GtkGestureClick* _tmp3_;
	GtkEventController* _tmp4_;
	GtkGestureLongPress* long_press = NULL;
	GtkGestureLongPress* _tmp5_;
	GtkEventController* _tmp6_;
	g_return_if_fail (cell != NULL);
	g_return_if_fail (dialog != NULL);
	_data109_ = g_slice_new0 (Block109Data);
	_data109_->_ref_count_ = 1;
	_tmp0_ = _g_object_ref0 (cell);
	_g_object_unref0 (_data109_->cell);
	_data109_->cell = _tmp0_;
	_tmp1_ = _g_object_ref0 (dialog);
	_g_object_unref0 (_data109_->dialog);
	_data109_->dialog = _tmp1_;
	_tmp2_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_data109_->cell, gtk_widget_get_type (), GtkWidget));
	_data109_->widget = _tmp2_;
	_tmp3_ = (GtkGestureClick*) gtk_gesture_click_new ();
	right_click = _tmp3_;
	gtk_gesture_single_set_button ((GtkGestureSingle*) right_click, (guint) 3);
	g_signal_connect_data (right_click, "pressed", (GCallback) ___lambda207__gtk_gesture_click_pressed, block109_data_ref (_data109_), (GClosureNotify) block109_data_unref, 0);
	_tmp4_ = _g_object_ref0 ((GtkEventController*) right_click);
	gtk_widget_add_controller (_data109_->widget, _tmp4_);
	_tmp5_ = (GtkGestureLongPress*) gtk_gesture_long_press_new ();
	long_press = _tmp5_;
	gtk_gesture_single_set_touch_only ((GtkGestureSingle*) long_press, TRUE);
	g_signal_connect_data (long_press, "pressed", (GCallback) ___lambda219__gtk_gesture_long_press_pressed, block109_data_ref (_data109_), (GClosureNotify) block109_data_unref, 0);
	_tmp6_ = _g_object_ref0 ((GtkEventController*) long_press);
	gtk_widget_add_controller (_data109_->widget, _tmp6_);
	_g_object_unref0 (long_press);
	_g_object_unref0 (right_click);
	block109_data_unref (_data109_);
	_data109_ = NULL;
}

/** Menu / Shift+F10 on a grid or list opens the context menu for
            the focused cell. The controller sits on the view because the
            focusable widget is GTK's internal list item, not our cell. */
static Block110Data*
block110_data_ref (Block110Data* _data110_)
{
	g_atomic_int_inc (&_data110_->_ref_count_);
	return _data110_;
}

static void
block110_data_unref (void * _userdata_)
{
	Block110Data* _data110_;
	_data110_ = (Block110Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data110_->_ref_count_)) {
		DcGalleryDialog* self;
		self = _data110_->self;
		_g_object_unref0 (_data110_->view);
		_g_object_unref0 (self);
		g_slice_free (Block110Data, _data110_);
	}
}

static gboolean
__lambda223_ (Block110Data* _data110_,
              guint kv,
              guint code,
              GdkModifierType state)
{
	DcGalleryDialog* self;
	gboolean _tmp0_ = FALSE;
	gboolean menu_key = FALSE;
	GtkWidget* item = NULL;
	GtkWidget* _tmp2_;
	GtkWidget* _tmp3_;
	DcGalleryCell* _tmp4_ = NULL;
	GtkWidget* _tmp5_;
	DcGalleryCell* cell = NULL;
	DcGalleryCell* _tmp8_;
	gboolean _tmp9_ = FALSE;
	DcGalleryCell* _tmp10_;
	GtkWidget* widget = NULL;
	DcGalleryCell* _tmp14_;
	GtkWidget* _tmp15_;
	GtkWidget* _tmp16_;
	DcGalleryCell* _tmp17_;
	DcMessage* _tmp18_;
	DcMessage* _tmp19_;
	GtkWidget* _tmp20_;
	GtkWidget* _tmp21_;
	gboolean result;
	self = _data110_->self;
	if (kv == GDK_KEY_Menu) {
		_tmp0_ = TRUE;
	} else {
		gboolean _tmp1_ = FALSE;
		if (kv == GDK_KEY_F10) {
			_tmp1_ = (state & GDK_SHIFT_MASK) != 0;
		} else {
			_tmp1_ = FALSE;
		}
		_tmp0_ = _tmp1_;
	}
	menu_key = _tmp0_;
	if (!menu_key) {
		result = FALSE;
		return result;
	}
	_tmp2_ = gtk_widget_get_focus_child (_data110_->view);
	_tmp3_ = _g_object_ref0 (_tmp2_);
	item = _tmp3_;
	_tmp5_ = item;
	if (_tmp5_ != NULL) {
		GtkWidget* _tmp6_;
		GtkWidget* _tmp7_;
		_tmp6_ = item;
		_tmp7_ = gtk_widget_get_first_child (_tmp6_);
		_tmp4_ = DC_IS_GALLERY_CELL (_tmp7_) ? ((DcGalleryCell*) _tmp7_) : NULL;
	} else {
		_tmp4_ = NULL;
	}
	_tmp8_ = _g_object_ref0 (_tmp4_);
	cell = _tmp8_;
	_tmp10_ = cell;
	if (_tmp10_ == NULL) {
		_tmp9_ = TRUE;
	} else {
		DcGalleryCell* _tmp11_;
		DcMessage* _tmp12_;
		DcMessage* _tmp13_;
		_tmp11_ = cell;
		_tmp12_ = dc_gallery_cell_get_msg (_tmp11_);
		_tmp13_ = _tmp12_;
		_tmp9_ = _tmp13_ == NULL;
	}
	if (_tmp9_) {
		result = FALSE;
		_g_object_unref0 (cell);
		_g_object_unref0 (item);
		return result;
	}
	_tmp14_ = cell;
	_tmp15_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp14_, gtk_widget_get_type (), GtkWidget));
	widget = _tmp15_;
	_tmp16_ = widget;
	_tmp17_ = cell;
	_tmp18_ = dc_gallery_cell_get_msg (_tmp17_);
	_tmp19_ = _tmp18_;
	_tmp20_ = widget;
	_tmp21_ = widget;
	dc_gallery_dialog_show_item_menu (self, _tmp16_, _tmp19_, gtk_widget_get_width (_tmp20_) / 2.0, gtk_widget_get_height (_tmp21_) / 2.0);
	result = TRUE;
	_g_object_unref0 (widget);
	_g_object_unref0 (cell);
	_g_object_unref0 (item);
	return result;
}

static gboolean
___lambda223__gtk_event_controller_key_key_pressed (GtkEventControllerKey* _sender,
                                                    guint keyval,
                                                    guint keycode,
                                                    GdkModifierType state,
                                                    gpointer self)
{
	gboolean result;
	result = __lambda223_ (self, keyval, keycode, state);
	return result;
}

static void
dc_gallery_dialog_install_menu_key (DcGalleryDialog* self,
                                    GtkWidget* view)
{
	Block110Data* _data110_;
	GtkWidget* _tmp0_;
	GtkEventControllerKey* keys = NULL;
	GtkEventControllerKey* _tmp1_;
	GtkEventController* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (view != NULL);
	_data110_ = g_slice_new0 (Block110Data);
	_data110_->_ref_count_ = 1;
	_data110_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (view);
	_g_object_unref0 (_data110_->view);
	_data110_->view = _tmp0_;
	_tmp1_ = (GtkEventControllerKey*) gtk_event_controller_key_new ();
	keys = _tmp1_;
	g_signal_connect_data (keys, "key-pressed", (GCallback) ___lambda223__gtk_event_controller_key_key_pressed, block110_data_ref (_data110_), (GClosureNotify) block110_data_unref, 0);
	_tmp2_ = _g_object_ref0 ((GtkEventController*) keys);
	gtk_widget_add_controller (_data110_->view, _tmp2_);
	_g_object_unref0 (keys);
	block110_data_unref (_data110_);
	_data110_ = NULL;
}

static Block111Data*
block111_data_ref (Block111Data* _data111_)
{
	g_atomic_int_inc (&_data111_->_ref_count_);
	return _data111_;
}

static void
block111_data_unref (void * _userdata_)
{
	Block111Data* _data111_;
	_data111_ = (Block111Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data111_->_ref_count_)) {
		DcGalleryDialog* self;
		self = _data111_->self;
		_g_object_unref0 (self);
		g_slice_free (Block111Data, _data111_);
	}
}

static Block112Data*
block112_data_ref (Block112Data* _data112_)
{
	g_atomic_int_inc (&_data112_->_ref_count_);
	return _data112_;
}

static void
block112_data_unref (void * _userdata_)
{
	Block112Data* _data112_;
	_data112_ = (Block112Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data112_->_ref_count_)) {
		DcGalleryDialog* self;
		self = _data112_->_data111_->self;
		_g_free0 (_data112_->link0);
		block111_data_unref (_data112_->_data111_);
		_data112_->_data111_ = NULL;
		g_slice_free (Block112Data, _data112_);
	}
}

static void
____lambda208_ (Block112Data* _data112_)
{
	Block111Data* _data111_;
	DcGalleryDialog* self;
	const gchar* _tmp0_;
	_data111_ = _data112_->_data111_;
	self = _data111_->self;
	_tmp0_ = _data112_->link0;
	dc_gallery_dialog_open_link (self, _tmp0_);
}

static void
_____lambda208__dc_popover_button_selected (DcPopoverButton* _sender,
                                            gpointer self)
{
	____lambda208_ (self);
}

static void
____lambda210_ (Block112Data* _data112_)
{
	Block111Data* _data111_;
	DcGalleryDialog* self;
	GdkClipboard* _tmp0_;
	const gchar* _tmp1_;
	_data111_ = _data112_->_data111_;
	self = _data111_->self;
	_tmp0_ = gtk_widget_get_clipboard ((GtkWidget*) self);
	_tmp1_ = _data112_->link0;
	gdk_clipboard_set_text (_tmp0_, _tmp1_);
	dc_gallery_dialog_toast (self, "Link copied");
}

static void
_____lambda210__dc_popover_button_selected (DcPopoverButton* _sender,
                                            gpointer self)
{
	____lambda210_ (self);
}

static Block113Data*
block113_data_ref (Block113Data* _data113_)
{
	g_atomic_int_inc (&_data113_->_ref_count_);
	return _data113_;
}

static void
block113_data_unref (void * _userdata_)
{
	Block113Data* _data113_;
	_data113_ = (Block113Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data113_->_ref_count_)) {
		DcGalleryDialog* self;
		self = _data113_->_data111_->self;
		_g_free0 (_data113_->fname);
		_g_free0 (_data113_->fpath);
		block111_data_unref (_data113_->_data111_);
		_data113_->_data111_ = NULL;
		g_slice_free (Block113Data, _data113_);
	}
}

static void
___lambda211_ (Block113Data* _data113_)
{
	Block111Data* _data111_;
	DcGalleryDialog* self;
	DcWindow* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	_data111_ = _data113_->_data111_;
	self = _data111_->self;
	_tmp0_ = self->priv->app_window;
	_tmp1_ = _data113_->fpath;
	_tmp2_ = _data113_->fname;
	dc_window_save_attachment (_tmp0_, _tmp1_, _tmp2_, NULL, NULL);
}

static void
____lambda211__dc_popover_button_selected (DcPopoverButton* _sender,
                                           gpointer self)
{
	___lambda211_ (self);
}

static void
__lambda212_ (Block111Data* _data111_)
{
	DcGalleryDialog* self;
	DcWindow* _tmp0_;
	DcRpcClient* _tmp1_;
	gint* _tmp2_;
	gint* _tmp3_;
	gint _tmp3__length1;
	DcContactPickerDialog* _tmp4_;
	DcContactPickerDialog* _tmp5_;
	self = _data111_->self;
	_tmp0_ = self->priv->app_window;
	_tmp1_ = self->priv->rpc;
	_tmp2_ = g_new0 (gint, 1);
	_tmp2_[0] = _data111_->msg_id;
	_tmp3_ = _tmp2_;
	_tmp3__length1 = 1;
	_tmp4_ = dc_message_actions_forward_with_picker (_tmp0_, _tmp1_, _tmp3_, (gint) 1);
	_tmp5_ = _tmp4_;
	_g_object_unref0 (_tmp5_);
	_tmp3_ = (g_free (_tmp3_), NULL);
}

static void
___lambda212__dc_popover_button_selected (DcPopoverButton* _sender,
                                          gpointer self)
{
	__lambda212_ (self);
}

static void
__lambda213_ (Block111Data* _data111_)
{
	DcGalleryDialog* self;
	self = _data111_->self;
	dc_gallery_dialog_enter_selection_mode (self, _data111_->msg_id);
}

static void
___lambda213__dc_popover_button_selected (DcPopoverButton* _sender,
                                          gpointer self)
{
	__lambda213_ (self);
}

static Block114Data*
block114_data_ref (Block114Data* _data114_)
{
	g_atomic_int_inc (&_data114_->_ref_count_);
	return _data114_;
}

static void
block114_data_unref (void * _userdata_)
{
	Block114Data* _data114_;
	_data114_ = (Block114Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data114_->_ref_count_)) {
		DcGalleryDialog* self;
		self = _data114_->_data111_->self;
		_g_object_unref0 (_data114_->presenter);
		block111_data_unref (_data114_->_data111_);
		_data114_->_data111_ = NULL;
		g_slice_free (Block114Data, _data114_);
	}
}

static void
___lambda216_ (Block114Data* _data114_)
{
	Block111Data* _data111_;
	DcGalleryDialog* self;
	DcWindow* _tmp0_;
	_data111_ = _data114_->_data111_;
	self = _data111_->self;
	_tmp0_ = self->priv->app_window;
	dc_window_open_conversation_message (_tmp0_, _data114_->target_chat, _data111_->msg_id);
}

static void
____lambda216__adw_dialog_closed (AdwDialog* _sender,
                                  gpointer self)
{
	___lambda216_ (self);
}

static void
__lambda215_ (Block114Data* _data114_)
{
	Block111Data* _data111_;
	DcGalleryDialog* self;
	_data111_ = _data114_->_data111_;
	self = _data111_->self;
	if (_data114_->presenter != NULL) {
		g_signal_connect_data (_data114_->presenter, "closed", (GCallback) ____lambda216__adw_dialog_closed, block114_data_ref (_data114_), (GClosureNotify) block114_data_unref, 0);
		adw_dialog_close (_data114_->presenter);
	} else {
		DcWindow* _tmp0_;
		_tmp0_ = self->priv->app_window;
		dc_window_open_conversation_message (_tmp0_, _data114_->target_chat, _data111_->msg_id);
	}
}

static void
___lambda215__adw_dialog_closed (AdwDialog* _sender,
                                 gpointer self)
{
	__lambda215_ (self);
}

static void
__lambda214_ (Block111Data* _data111_)
{
	DcGalleryDialog* self;
	Block114Data* _data114_;
	AdwDialog* _tmp0_;
	AdwDialog* _tmp1_;
	self = _data111_->self;
	_data114_ = g_slice_new0 (Block114Data);
	_data114_->_ref_count_ = 1;
	_data114_->_data111_ = block111_data_ref (_data111_);
	_data114_->target_chat = self->priv->chat_id;
	_tmp0_ = self->presenter_dialog;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_data114_->presenter = _tmp1_;
	g_signal_connect_data ((AdwDialog*) self, "closed", (GCallback) ___lambda215__adw_dialog_closed, block114_data_ref (_data114_), (GClosureNotify) block114_data_unref, 0);
	adw_dialog_close ((AdwDialog*) self);
	block114_data_unref (_data114_);
	_data114_ = NULL;
}

static void
___lambda214__dc_popover_button_selected (DcPopoverButton* _sender,
                                          gpointer self)
{
	__lambda214_ (self);
}

static Block115Data*
block115_data_ref (Block115Data* _data115_)
{
	g_atomic_int_inc (&_data115_->_ref_count_);
	return _data115_;
}

static void
block115_data_unref (void * _userdata_)
{
	Block115Data* _data115_;
	_data115_ = (Block115Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data115_->_ref_count_)) {
		DcGalleryDialog* self;
		self = _data115_->_data111_->self;
		_g_free0 (_data115_->spath);
		block111_data_unref (_data115_->_data111_);
		_data115_->_data111_ = NULL;
		g_slice_free (Block115Data, _data115_);
	}
}

static void
___lambda217_ (Block115Data* _data115_)
{
	Block111Data* _data111_;
	DcGalleryDialog* self;
	DcWindow* _tmp0_;
	const gchar* _tmp1_;
	_data111_ = _data115_->_data111_;
	self = _data111_->self;
	_tmp0_ = self->priv->app_window;
	_tmp1_ = _data115_->spath;
	dc_sticker_manager_dialog_prompt_add_sticker (_tmp0_, _tmp1_);
}

static void
____lambda217__dc_popover_button_selected (DcPopoverButton* _sender,
                                           gpointer self)
{
	___lambda217_ (self);
}

static void
__lambda218_ (Block111Data* _data111_)
{
	DcGalleryDialog* self;
	gint* _tmp0_;
	self = _data111_->self;
	_tmp0_ = g_new0 (gint, 1);
	_tmp0_[0] = _data111_->msg_id;
	dc_gallery_dialog_confirm_delete_ids (self, _tmp0_, (gint) 1, _data111_->is_outgoing, NULL, NULL);
}

static void
___lambda218__dc_popover_button_selected (DcPopoverButton* _sender,
                                          gpointer self)
{
	__lambda218_ (self);
}

static void
dc_gallery_dialog_show_item_menu (DcGalleryDialog* self,
                                  GtkWidget* parent,
                                  DcMessage* m,
                                  gdouble x,
                                  gdouble y)
{
	Block111Data* _data111_;
	GtkBox* vbox = NULL;
	GtkPopover* popover = NULL;
	GtkBox* _tmp0_ = NULL;
	GtkPopover* _tmp1_;
	DcGalleryDialogGalleryTab* cur = NULL;
	DcGalleryDialogGalleryTab* _tmp2_;
	gboolean _tmp3_ = FALSE;
	DcGalleryDialogGalleryTab* _tmp4_;
	gboolean _tmp26_;
	gboolean _tmp27_;
	gint _tmp39_;
	gint _tmp40_;
	DcPopoverButton* forward_btn = NULL;
	GtkPopover* _tmp41_;
	DcPopoverButton* _tmp42_;
	DcPopoverButton* _tmp43_;
	GtkBox* _tmp44_;
	DcPopoverButton* _tmp45_;
	DcPopoverButton* select_btn = NULL;
	GtkPopover* _tmp46_;
	DcPopoverButton* _tmp47_;
	DcPopoverButton* _tmp48_;
	GtkBox* _tmp49_;
	DcPopoverButton* _tmp50_;
	DcPopoverButton* view_btn = NULL;
	GtkPopover* _tmp51_;
	DcPopoverButton* _tmp52_;
	DcPopoverButton* _tmp53_;
	GtkBox* _tmp54_;
	DcPopoverButton* _tmp55_;
	gboolean _tmp56_ = FALSE;
	GtkBox* _tmp67_;
	GtkSeparator* _tmp68_;
	GtkSeparator* _tmp69_;
	gboolean _tmp70_;
	gboolean _tmp71_;
	DcPopoverButton* delete_btn = NULL;
	GtkPopover* _tmp72_;
	DcPopoverButton* _tmp73_;
	GtkBox* _tmp74_;
	GtkPopover* _tmp75_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (parent != NULL);
	g_return_if_fail (m != NULL);
	_data111_ = g_slice_new0 (Block111Data);
	_data111_->_ref_count_ = 1;
	_data111_->self = g_object_ref (self);
	_tmp1_ = dc_popover_menu (parent, x, y, &_tmp0_);
	_g_object_unref0 (vbox);
	vbox = _tmp0_;
	popover = _tmp1_;
	_tmp2_ = dc_gallery_dialog_current_tab (self);
	cur = _tmp2_;
	_tmp4_ = cur;
	if (_tmp4_ != NULL) {
		DcGalleryDialogGalleryTab* _tmp5_;
		const gchar* _tmp6_;
		_tmp5_ = cur;
		_tmp6_ = _tmp5_->key;
		_tmp3_ = g_strcmp0 (_tmp6_, "links") == 0;
	} else {
		_tmp3_ = FALSE;
	}
	if (_tmp3_) {
		const gchar* _tmp7_ = NULL;
		const gchar* _tmp8_;
		const gchar* _tmp9_;
		gchar** links = NULL;
		gint _tmp10_ = 0;
		gchar** _tmp11_;
		gint links_length1;
		gint _links_size_;
		gchar** _tmp12_;
		gint _tmp12__length1;
		_tmp8_ = dc_message_get_text (m);
		_tmp9_ = _tmp8_;
		_tmp7_ = _tmp9_;
		if (_tmp7_ == NULL) {
			_tmp7_ = "";
		}
		_tmp11_ = dc_link_cleaner_find_urls (_tmp7_, &_tmp10_);
		links = _tmp11_;
		links_length1 = _tmp10_;
		_links_size_ = links_length1;
		_tmp12_ = links;
		_tmp12__length1 = links_length1;
		if (_tmp12__length1 > 0) {
			Block112Data* _data112_;
			gchar** _tmp13_;
			gint _tmp13__length1;
			const gchar* _tmp14_;
			gchar* _tmp15_;
			DcPopoverButton* open_btn = NULL;
			GtkPopover* _tmp16_;
			DcPopoverButton* _tmp17_;
			DcPopoverButton* _tmp18_;
			GtkBox* _tmp19_;
			DcPopoverButton* _tmp20_;
			DcPopoverButton* copy_btn = NULL;
			GtkPopover* _tmp21_;
			DcPopoverButton* _tmp22_;
			DcPopoverButton* _tmp23_;
			GtkBox* _tmp24_;
			DcPopoverButton* _tmp25_;
			_data112_ = g_slice_new0 (Block112Data);
			_data112_->_ref_count_ = 1;
			_data112_->_data111_ = block111_data_ref (_data111_);
			_tmp13_ = links;
			_tmp13__length1 = links_length1;
			_tmp14_ = _tmp13_[0];
			_tmp15_ = g_strdup (_tmp14_);
			_data112_->link0 = _tmp15_;
			_tmp16_ = popover;
			_tmp17_ = dc_popover_button_new (_tmp16_, "Open Link", FALSE, FALSE);
			g_object_ref_sink (_tmp17_);
			open_btn = _tmp17_;
			_tmp18_ = open_btn;
			g_signal_connect_data (_tmp18_, "selected", (GCallback) _____lambda208__dc_popover_button_selected, block112_data_ref (_data112_), (GClosureNotify) block112_data_unref, 0);
			_tmp19_ = vbox;
			_tmp20_ = open_btn;
			gtk_box_append (_tmp19_, (GtkWidget*) _tmp20_);
			_tmp21_ = popover;
			_tmp22_ = dc_popover_button_new (_tmp21_, "Copy Link", FALSE, FALSE);
			g_object_ref_sink (_tmp22_);
			copy_btn = _tmp22_;
			_tmp23_ = copy_btn;
			g_signal_connect_data (_tmp23_, "selected", (GCallback) _____lambda210__dc_popover_button_selected, block112_data_ref (_data112_), (GClosureNotify) block112_data_unref, 0);
			_tmp24_ = vbox;
			_tmp25_ = copy_btn;
			gtk_box_append (_tmp24_, (GtkWidget*) _tmp25_);
			_g_object_unref0 (copy_btn);
			_g_object_unref0 (open_btn);
			block112_data_unref (_data112_);
			_data112_ = NULL;
		}
		links = (_vala_array_free (links, links_length1, (GDestroyNotify) g_free), NULL);
	}
	_tmp26_ = dc_message_get_has_local_file (m);
	_tmp27_ = _tmp26_;
	if (_tmp27_) {
		Block113Data* _data113_;
		const gchar* _tmp28_;
		const gchar* _tmp29_;
		gchar* _tmp30_;
		const gchar* _tmp31_;
		const gchar* _tmp32_;
		gchar* _tmp33_;
		DcPopoverButton* save_btn = NULL;
		GtkPopover* _tmp34_;
		DcPopoverButton* _tmp35_;
		DcPopoverButton* _tmp36_;
		GtkBox* _tmp37_;
		DcPopoverButton* _tmp38_;
		_data113_ = g_slice_new0 (Block113Data);
		_data113_->_ref_count_ = 1;
		_data113_->_data111_ = block111_data_ref (_data111_);
		_tmp28_ = dc_message_get_file_path (m);
		_tmp29_ = _tmp28_;
		_tmp30_ = g_strdup (_tmp29_);
		_data113_->fpath = _tmp30_;
		_tmp31_ = dc_message_get_file_name (m);
		_tmp32_ = _tmp31_;
		_tmp33_ = g_strdup (_tmp32_);
		_data113_->fname = _tmp33_;
		_tmp34_ = popover;
		_tmp35_ = dc_popover_button_new (_tmp34_, "Save As…", FALSE, FALSE);
		g_object_ref_sink (_tmp35_);
		save_btn = _tmp35_;
		_tmp36_ = save_btn;
		g_signal_connect_data (_tmp36_, "selected", (GCallback) ____lambda211__dc_popover_button_selected, block113_data_ref (_data113_), (GClosureNotify) block113_data_unref, 0);
		_tmp37_ = vbox;
		_tmp38_ = save_btn;
		gtk_box_append (_tmp37_, (GtkWidget*) _tmp38_);
		_g_object_unref0 (save_btn);
		block113_data_unref (_data113_);
		_data113_ = NULL;
	}
	_tmp39_ = dc_message_get_id (m);
	_tmp40_ = _tmp39_;
	_data111_->msg_id = _tmp40_;
	_tmp41_ = popover;
	_tmp42_ = dc_popover_button_new (_tmp41_, "Forward…", FALSE, FALSE);
	g_object_ref_sink (_tmp42_);
	forward_btn = _tmp42_;
	_tmp43_ = forward_btn;
	g_signal_connect_data (_tmp43_, "selected", (GCallback) ___lambda212__dc_popover_button_selected, block111_data_ref (_data111_), (GClosureNotify) block111_data_unref, 0);
	_tmp44_ = vbox;
	_tmp45_ = forward_btn;
	gtk_box_append (_tmp44_, (GtkWidget*) _tmp45_);
	_tmp46_ = popover;
	_tmp47_ = dc_popover_button_new (_tmp46_, "Select…", FALSE, FALSE);
	g_object_ref_sink (_tmp47_);
	select_btn = _tmp47_;
	_tmp48_ = select_btn;
	g_signal_connect_data (_tmp48_, "selected", (GCallback) ___lambda213__dc_popover_button_selected, block111_data_ref (_data111_), (GClosureNotify) block111_data_unref, 0);
	_tmp49_ = vbox;
	_tmp50_ = select_btn;
	gtk_box_append (_tmp49_, (GtkWidget*) _tmp50_);
	_tmp51_ = popover;
	_tmp52_ = dc_popover_button_new (_tmp51_, "View in Conversation", FALSE, FALSE);
	g_object_ref_sink (_tmp52_);
	view_btn = _tmp52_;
	_tmp53_ = view_btn;
	g_signal_connect_data (_tmp53_, "selected", (GCallback) ___lambda214__dc_popover_button_selected, block111_data_ref (_data111_), (GClosureNotify) block111_data_unref, 0);
	_tmp54_ = vbox;
	_tmp55_ = view_btn;
	gtk_box_append (_tmp54_, (GtkWidget*) _tmp55_);
	if (dc_message_is_sticker_file (m)) {
		gboolean _tmp57_;
		gboolean _tmp58_;
		_tmp57_ = dc_message_get_has_local_file (m);
		_tmp58_ = _tmp57_;
		_tmp56_ = _tmp58_;
	} else {
		_tmp56_ = FALSE;
	}
	if (_tmp56_) {
		Block115Data* _data115_;
		const gchar* _tmp59_;
		const gchar* _tmp60_;
		gchar* _tmp61_;
		DcPopoverButton* sticker_btn = NULL;
		GtkPopover* _tmp62_;
		DcPopoverButton* _tmp63_;
		DcPopoverButton* _tmp64_;
		GtkBox* _tmp65_;
		DcPopoverButton* _tmp66_;
		_data115_ = g_slice_new0 (Block115Data);
		_data115_->_ref_count_ = 1;
		_data115_->_data111_ = block111_data_ref (_data111_);
		_tmp59_ = dc_message_get_file_path (m);
		_tmp60_ = _tmp59_;
		_tmp61_ = g_strdup (_tmp60_);
		_data115_->spath = _tmp61_;
		_tmp62_ = popover;
		_tmp63_ = dc_popover_button_new (_tmp62_, "Add Sticker…", FALSE, FALSE);
		g_object_ref_sink (_tmp63_);
		sticker_btn = _tmp63_;
		_tmp64_ = sticker_btn;
		g_signal_connect_data (_tmp64_, "selected", (GCallback) ____lambda217__dc_popover_button_selected, block115_data_ref (_data115_), (GClosureNotify) block115_data_unref, 0);
		_tmp65_ = vbox;
		_tmp66_ = sticker_btn;
		gtk_box_append (_tmp65_, (GtkWidget*) _tmp66_);
		_g_object_unref0 (sticker_btn);
		block115_data_unref (_data115_);
		_data115_ = NULL;
	}
	_tmp67_ = vbox;
	_tmp68_ = (GtkSeparator*) gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
	g_object_ref_sink (_tmp68_);
	_tmp69_ = _tmp68_;
	gtk_box_append (_tmp67_, (GtkWidget*) _tmp69_);
	_g_object_unref0 (_tmp69_);
	_tmp70_ = dc_message_get_is_outgoing (m);
	_tmp71_ = _tmp70_;
	_data111_->is_outgoing = _tmp71_;
	_tmp72_ = popover;
	_tmp73_ = dc_popover_button_new (_tmp72_, "Delete…", TRUE, FALSE);
	g_object_ref_sink (_tmp73_);
	delete_btn = _tmp73_;
	g_signal_connect_data (delete_btn, "selected", (GCallback) ___lambda218__dc_popover_button_selected, block111_data_ref (_data111_), (GClosureNotify) block111_data_unref, 0);
	_tmp74_ = vbox;
	gtk_box_append (_tmp74_, (GtkWidget*) delete_btn);
	_tmp75_ = popover;
	gtk_popover_popup (_tmp75_);
	_g_object_unref0 (delete_btn);
	_g_object_unref0 (view_btn);
	_g_object_unref0 (select_btn);
	_g_object_unref0 (forward_btn);
	_g_object_unref0 (cur);
	_g_object_unref0 (popover);
	_g_object_unref0 (vbox);
	block111_data_unref (_data111_);
	_data111_ = NULL;
}

static void
dc_gallery_dialog_delete_messages_ui_data_free (gpointer _data)
{
	DcGalleryDialogDeleteMessagesUiData* _data_;
	_data_ = _data;
	_data_->ids = (g_free (_data_->ids), NULL);
	_g_object_unref0 (_data_->self);
	g_slice_free (DcGalleryDialogDeleteMessagesUiData, _data_);
}

static void
dc_gallery_dialog_delete_messages_ui (DcGalleryDialog* self,
                                      gint* ids,
                                      gint ids_length1,
                                      gboolean for_all,
                                      GAsyncReadyCallback _callback_,
                                      gpointer _user_data_)
{
	DcGalleryDialogDeleteMessagesUiData* _data_;
	DcGalleryDialog* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcGalleryDialogDeleteMessagesUiData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_gallery_dialog_delete_messages_ui_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->ids = (g_free (_data_->ids), NULL);
	_data_->ids = ids;
	_data_->ids_length1 = ids_length1;
	_data_->for_all = for_all;
	dc_gallery_dialog_delete_messages_ui_co (_data_);
}

static void
dc_gallery_dialog_delete_messages_ui_finish (DcGalleryDialog* self,
                                             GAsyncResult* _res_)
{
	DcGalleryDialogDeleteMessagesUiData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_gallery_dialog_delete_messages_ui_ready (GObject* source_object,
                                            GAsyncResult* _res_,
                                            gpointer _user_data_)
{
	DcGalleryDialogDeleteMessagesUiData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_gallery_dialog_delete_messages_ui_co (_data_);
}

static gboolean
dc_gallery_dialog_delete_messages_ui_co (DcGalleryDialogDeleteMessagesUiData* _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:
	{
		if (_data_->for_all) {
			_data_->_tmp0_ = _data_->self->priv->rpc;
			_data_->_state_ = 1;
			dc_rpc_client_delete_messages_for_all (_data_->_tmp0_, _data_->ids, (gint) _data_->ids_length1, dc_gallery_dialog_delete_messages_ui_ready, _data_);
			return FALSE;
			_state_1:
			dc_rpc_client_delete_messages_for_all_finish (_data_->_tmp0_, _data_->_res_, &_data_->_inner_error0_);
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
		} else {
			_data_->_tmp1_ = _data_->self->priv->rpc;
			_data_->_state_ = 2;
			dc_rpc_client_delete_messages (_data_->_tmp1_, _data_->ids, (gint) _data_->ids_length1, dc_gallery_dialog_delete_messages_ui_ready, _data_);
			return FALSE;
			_state_2:
			dc_rpc_client_delete_messages_finish (_data_->_tmp1_, _data_->_res_, &_data_->_inner_error0_);
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
		}
		_data_->_tmp2_ = g_direct_hash;
		_data_->_tmp3_ = g_direct_equal;
		_data_->_tmp4_ = g_hash_table_new_full (_data_->_tmp2_, _data_->_tmp3_, NULL, NULL);
		_data_->deleted = _data_->_tmp4_;
		{
			_data_->msg_id_collection_length1 = 0;
			_data_->_msg_id_collection_size_ = 0;
			_data_->msg_id_collection = _data_->ids;
			_data_->msg_id_collection_length1 = _data_->ids_length1;
			for (_data_->msg_id_it = 0; _data_->msg_id_it < _data_->msg_id_collection_length1; _data_->msg_id_it = _data_->msg_id_it + 1) {
				_data_->msg_id = _data_->msg_id_collection[_data_->msg_id_it];
				{
					_data_->_tmp5_ = _data_->deleted;
					g_hash_table_replace (_data_->_tmp5_, (gpointer) ((gintptr) _data_->msg_id), (gpointer) ((gintptr) TRUE));
					_data_->_tmp6_ = _data_->self->priv->selected_ids;
					g_hash_table_remove (_data_->_tmp6_, (gpointer) ((gintptr) _data_->msg_id));
				}
			}
		}
		_data_->_tmp7_ = _data_->self->priv->tabs;
		_data_->_tmp7__length1 = _data_->self->priv->tabs_length1;
		{
			_data_->tab_collection_length1 = 0;
			_data_->_tab_collection_size_ = 0;
			_data_->tab_collection = _data_->_tmp7_;
			_data_->tab_collection_length1 = _data_->_tmp7__length1;
			for (_data_->tab_it = 0; _data_->tab_it < _data_->tab_collection_length1; _data_->tab_it = _data_->tab_it + 1) {
				_data_->_tmp8_ = _g_object_ref0 (_data_->tab_collection[_data_->tab_it]);
				_data_->tab = _data_->_tmp8_;
				{
					{
						_data_->_tmp9_ = _data_->tab;
						_data_->_tmp10_ = _data_->_tmp9_->store;
						_data_->i = ((gint) g_list_model_get_n_items ((GListModel*) _data_->_tmp10_)) - 1;
						{
							_data_->_tmp11_ = TRUE;
							while (TRUE) {
								if (!_data_->_tmp11_) {
									_data_->_tmp12_ = _data_->i;
									_data_->i = _data_->_tmp12_ - 1;
								}
								_data_->_tmp11_ = FALSE;
								if (!(_data_->i >= 0)) {
									break;
								}
								_data_->_tmp13_ = _data_->tab;
								_data_->_tmp14_ = _data_->_tmp13_->store;
								_data_->_tmp15_ = g_list_model_get_item ((GListModel*) _data_->_tmp14_, (guint) _data_->i);
								_data_->m = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp15_, DC_TYPE_MESSAGE, DcMessage);
								_data_->_tmp17_ = _data_->m;
								if (_data_->_tmp17_ != NULL) {
									_data_->_tmp18_ = _data_->deleted;
									_data_->_tmp19_ = _data_->m;
									_data_->_tmp20_ = dc_message_get_id (_data_->_tmp19_);
									_data_->_tmp21_ = _data_->_tmp20_;
									_data_->_tmp16_ = g_hash_table_contains (_data_->_tmp18_, (gpointer) ((gintptr) _data_->_tmp21_));
								} else {
									_data_->_tmp16_ = FALSE;
								}
								if (_data_->_tmp16_) {
									_data_->_tmp22_ = _data_->tab;
									_data_->_tmp23_ = _data_->_tmp22_->store;
									g_list_store_remove (_data_->_tmp23_, (guint) _data_->i);
								}
								_g_object_unref0 (_data_->m);
							}
						}
					}
					_data_->_tmp25_ = _data_->tab;
					if (_data_->_tmp25_->load_started) {
						_data_->_tmp26_ = _data_->tab;
						_data_->_tmp27_ = _data_->_tmp26_->store;
						_data_->_tmp24_ = g_list_model_get_n_items ((GListModel*) _data_->_tmp27_) == ((guint) 0);
					} else {
						_data_->_tmp24_ = FALSE;
					}
					if (_data_->_tmp24_) {
						_data_->_tmp28_ = _data_->tab;
						_data_->_tmp29_ = _data_->_tmp28_->stack;
						gtk_stack_set_visible_child_name (_data_->_tmp29_, "empty");
					}
					_g_object_unref0 (_data_->tab);
				}
			}
		}
		_data_->_tmp30_ = _data_->self->priv->app_window;
		dc_window_request_chat_messages_reload (_data_->_tmp30_, _data_->self->priv->chat_id);
		if (_data_->ids_length1 == 1) {
			_data_->_tmp32_ = g_strdup ("Message deleted");
			_g_free0 (_data_->_tmp31_);
			_data_->_tmp31_ = _data_->_tmp32_;
		} else {
			_data_->_tmp33_ = g_strdup_printf ("%d messages deleted", _data_->ids_length1);
			_g_free0 (_data_->_tmp31_);
			_data_->_tmp31_ = _data_->_tmp33_;
		}
		dc_gallery_dialog_toast (_data_->self, _data_->_tmp31_);
		_g_free0 (_data_->_tmp31_);
		_g_hash_table_unref0 (_data_->deleted);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp34_ = _data_->e;
		_data_->_tmp35_ = _data_->_tmp34_->message;
		_data_->_tmp36_ = g_strconcat ("Delete failed: ", _data_->_tmp35_, NULL);
		_data_->_tmp37_ = _data_->_tmp36_;
		dc_gallery_dialog_toast (_data_->self, _data_->_tmp37_);
		_g_free0 (_data_->_tmp37_);
		_g_error_free0 (_data_->e);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_data_->ids = (g_free (_data_->ids), NULL);
		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;
	}
	_data_->_tmp39_ = _data_->self->priv->_selection_mode;
	if (_data_->_tmp39_) {
		_data_->_tmp40_ = _data_->self->priv->selected_ids;
		_data_->_tmp38_ = g_hash_table_size (_data_->_tmp40_) == ((guint) 0);
	} else {
		_data_->_tmp38_ = FALSE;
	}
	if (_data_->_tmp38_) {
		dc_gallery_dialog_exit_selection_mode (_data_->self);
	} else {
		_data_->_tmp41_ = _data_->self->priv->_selection_mode;
		if (_data_->_tmp41_) {
			dc_gallery_dialog_update_selection_ui (_data_->self);
		}
	}
	_data_->ids = (g_free (_data_->ids), 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
dc_gallery_dialog_update_save_all_button (DcGalleryDialog* self)
{
	DcGalleryDialogGalleryTab* tab = NULL;
	DcGalleryDialogGalleryTab* _tmp0_;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	DcGalleryDialogGalleryTab* _tmp3_;
	gboolean has_items = FALSE;
	GtkButton* _tmp8_;
	gchar* _tmp9_ = NULL;
	DcGalleryDialogGalleryTab* _tmp10_;
	GtkButton* _tmp15_;
	g_return_if_fail (self != NULL);
	_tmp0_ = dc_gallery_dialog_current_tab (self);
	tab = _tmp0_;
	_tmp3_ = tab;
	if (_tmp3_ != NULL) {
		DcGalleryDialogGalleryTab* _tmp4_;
		const gchar* _tmp5_;
		_tmp4_ = tab;
		_tmp5_ = _tmp4_->key;
		_tmp2_ = g_strcmp0 (_tmp5_, "links") != 0;
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		DcGalleryDialogGalleryTab* _tmp6_;
		GListStore* _tmp7_;
		_tmp6_ = tab;
		_tmp7_ = _tmp6_->store;
		_tmp1_ = g_list_model_get_n_items ((GListModel*) _tmp7_) > ((guint) 0);
	} else {
		_tmp1_ = FALSE;
	}
	has_items = _tmp1_;
	_tmp8_ = self->priv->save_all_btn;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp8_, has_items);
	_tmp10_ = tab;
	if (_tmp10_ != NULL) {
		DcGalleryDialogGalleryTab* _tmp11_;
		const gchar* _tmp12_;
		gchar* _tmp13_;
		_tmp11_ = tab;
		_tmp12_ = _tmp11_->kind_plural;
		_tmp13_ = g_strdup_printf ("Save all %s to a folder…", _tmp12_);
		_g_free0 (_tmp9_);
		_tmp9_ = _tmp13_;
	} else {
		gchar* _tmp14_;
		_tmp14_ = g_strdup ("Save all to a folder…");
		_g_free0 (_tmp9_);
		_tmp9_ = _tmp14_;
	}
	_tmp15_ = self->priv->save_all_btn;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp15_, _tmp9_);
	_g_free0 (_tmp9_);
	_g_object_unref0 (tab);
}

static void
_vala_array_add70 (DcMessage** * array,
                   gint* length,
                   gint* size,
                   DcMessage* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (DcMessage*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static DcMessage**
_vala_array_dup27 (DcMessage** self,
                   gssize length)
{
	if (length >= 0) {
		DcMessage** result;
		gssize i;
		result = g_new0 (DcMessage*, length + 1);
		for (i = 0; i < length; i++) {
			DcMessage* _tmp0_;
			_tmp0_ = _g_object_ref0 (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

static void
dc_gallery_dialog_on_save_all_clicked (DcGalleryDialog* self)
{
	DcGalleryDialogGalleryTab* tab = NULL;
	DcGalleryDialogGalleryTab* _tmp0_;
	DcGalleryDialogGalleryTab* _tmp1_;
	DcMessage** msgs = NULL;
	DcMessage** _tmp2_;
	gint msgs_length1;
	gint _msgs_size_;
	DcMessage** _tmp13_;
	gint _tmp13__length1;
	DcMessage** _tmp14_;
	gint _tmp14__length1;
	g_return_if_fail (self != NULL);
	_tmp0_ = dc_gallery_dialog_current_tab (self);
	tab = _tmp0_;
	_tmp1_ = tab;
	if (_tmp1_ == NULL) {
		_g_object_unref0 (tab);
		return;
	}
	_tmp2_ = g_new0 (DcMessage*, 0 + 1);
	msgs = _tmp2_;
	msgs_length1 = 0;
	_msgs_size_ = msgs_length1;
	{
		guint i = 0U;
		i = (guint) 0;
		{
			gboolean _tmp3_ = FALSE;
			_tmp3_ = TRUE;
			while (TRUE) {
				DcGalleryDialogGalleryTab* _tmp5_;
				GListStore* _tmp6_;
				DcMessage* m = NULL;
				DcGalleryDialogGalleryTab* _tmp7_;
				GListStore* _tmp8_;
				GObject* _tmp9_;
				DcMessage* _tmp10_;
				if (!_tmp3_) {
					guint _tmp4_;
					_tmp4_ = i;
					i = _tmp4_ + 1;
				}
				_tmp3_ = FALSE;
				_tmp5_ = tab;
				_tmp6_ = _tmp5_->store;
				if (!(i < g_list_model_get_n_items ((GListModel*) _tmp6_))) {
					break;
				}
				_tmp7_ = tab;
				_tmp8_ = _tmp7_->store;
				_tmp9_ = g_list_model_get_item ((GListModel*) _tmp8_, i);
				m = G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, DC_TYPE_MESSAGE, DcMessage);
				_tmp10_ = m;
				if (_tmp10_ != NULL) {
					DcMessage* _tmp11_;
					DcMessage* _tmp12_;
					_tmp11_ = m;
					_tmp12_ = _g_object_ref0 (_tmp11_);
					_vala_array_add70 (&msgs, &msgs_length1, &_msgs_size_, _tmp12_);
				}
				_g_object_unref0 (m);
			}
		}
	}
	_tmp13_ = msgs;
	_tmp13__length1 = msgs_length1;
	_tmp14_ = (_tmp13_ != NULL) ? _vala_array_dup27 (_tmp13_, _tmp13__length1) : _tmp13_;
	_tmp14__length1 = _tmp13__length1;
	dc_gallery_dialog_choose_folder_then_save (self, _tmp14_, (gint) _tmp14__length1, FALSE);
	msgs = (_vala_array_free (msgs, msgs_length1, (GDestroyNotify) g_object_unref), NULL);
	_g_object_unref0 (tab);
}

/** Shared by "save all" and the selection bar's "Save…"; items
            without a downloaded file are only counted as skipped.
            exit_selection runs only when a folder was actually chosen. */
static Block116Data*
block116_data_ref (Block116Data* _data116_)
{
	g_atomic_int_inc (&_data116_->_ref_count_);
	return _data116_;
}

static void
block116_data_unref (void * _userdata_)
{
	Block116Data* _data116_;
	_data116_ = (Block116Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data116_->_ref_count_)) {
		DcGalleryDialog* self;
		self = _data116_->self;
		_g_object_unref0 (_data116_->chooser);
		_data116_->items = (_vala_array_free (_data116_->items, _data116_->items_length1, (GDestroyNotify) g_object_unref), NULL);
		_g_object_unref0 (self);
		g_slice_free (Block116Data, _data116_);
	}
}

static void
_vala_array_add71 (DcMessage** * array,
                   gint* length,
                   gint* size,
                   DcMessage* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (DcMessage*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static DcMessage**
_vala_array_dup28 (DcMessage** self,
                   gssize length)
{
	if (length >= 0) {
		DcMessage** result;
		gssize i;
		result = g_new0 (DcMessage*, length + 1);
		for (i = 0; i < length; i++) {
			DcMessage* _tmp0_;
			_tmp0_ = _g_object_ref0 (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

static void
__lambda234_ (Block116Data* _data116_,
              GObject* o,
              GAsyncResult* res)
{
	DcGalleryDialog* self;
	GError* _inner_error0_ = NULL;
	self = _data116_->self;
	g_return_if_fail (res != NULL);
	{
		GFile* folder = NULL;
		GtkFileDialog* _tmp0_;
		GFile* _tmp1_;
		GFile* _tmp2_;
		DcMessage** _tmp3_;
		gint _tmp3__length1;
		DcMessage** _tmp4_;
		gint _tmp4__length1;
		GFile* _tmp5_;
		_tmp0_ = _data116_->chooser;
		_tmp1_ = gtk_file_dialog_select_folder_finish (_tmp0_, res, &_inner_error0_);
		folder = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp2_ = folder;
		if (_tmp2_ == NULL) {
			_g_object_unref0 (folder);
			return;
		}
		if (_data116_->exit_selection) {
			dc_gallery_dialog_exit_selection_mode (self);
		}
		_tmp3_ = _data116_->items;
		_tmp3__length1 = _data116_->items_length1;
		_tmp4_ = (_tmp3_ != NULL) ? _vala_array_dup28 (_tmp3_, _tmp3__length1) : _tmp3_;
		_tmp4__length1 = _tmp3__length1;
		_tmp5_ = folder;
		dc_gallery_dialog_save_files_to_folder (self, _tmp4_, (gint) _tmp4__length1, _data116_->skipped, _tmp5_, NULL, NULL);
		_g_object_unref0 (folder);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp6_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp6_ = e;
		if (!dc_is_dialog_dismissal (_tmp6_)) {
			GError* _tmp7_;
			const gchar* _tmp8_;
			gchar* _tmp9_;
			gchar* _tmp10_;
			_tmp7_ = e;
			_tmp8_ = _tmp7_->message;
			_tmp9_ = g_strconcat ("Folder selection failed: ", _tmp8_, NULL);
			_tmp10_ = _tmp9_;
			dc_gallery_dialog_toast (self, _tmp10_);
			_g_free0 (_tmp10_);
		}
		_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;
	}
}

static void
___lambda234__gasync_ready_callback (GObject* source_object,
                                     GAsyncResult* res,
                                     gpointer self)
{
	__lambda234_ (self, source_object, res);
	block116_data_unref (self);
}

static void
dc_gallery_dialog_choose_folder_then_save (DcGalleryDialog* self,
                                           DcMessage** msgs,
                                           gint msgs_length1,
                                           gboolean exit_selection)
{
	Block116Data* _data116_;
	DcMessage** _tmp0_;
	DcMessage** _tmp8_;
	gint _tmp8__length1;
	GtkFileDialog* _tmp9_;
	GtkFileDialog* _tmp10_;
	GtkFileDialog* _tmp11_;
	DcWindow* _tmp12_;
	g_return_if_fail (self != NULL);
	_data116_ = g_slice_new0 (Block116Data);
	_data116_->_ref_count_ = 1;
	_data116_->self = g_object_ref (self);
	_data116_->exit_selection = exit_selection;
	_tmp0_ = g_new0 (DcMessage*, 0 + 1);
	_data116_->items = _tmp0_;
	_data116_->items_length1 = 0;
	_data116_->_items_size_ = _data116_->items_length1;
	_data116_->skipped = 0;
	{
		DcMessage** m_collection = NULL;
		gint m_collection_length1 = 0;
		gint _m_collection_size_ = 0;
		gint m_it = 0;
		m_collection = msgs;
		m_collection_length1 = msgs_length1;
		for (m_it = 0; m_it < m_collection_length1; m_it = m_it + 1) {
			DcMessage* _tmp1_;
			DcMessage* m = NULL;
			_tmp1_ = _g_object_ref0 (m_collection[m_it]);
			m = _tmp1_;
			{
				DcMessage* _tmp2_;
				gboolean _tmp3_;
				gboolean _tmp4_;
				_tmp2_ = m;
				_tmp3_ = dc_message_get_has_local_file (_tmp2_);
				_tmp4_ = _tmp3_;
				if (_tmp4_) {
					DcMessage* _tmp5_;
					DcMessage* _tmp6_;
					_tmp5_ = m;
					_tmp6_ = _g_object_ref0 (_tmp5_);
					_vala_array_add71 (&_data116_->items, &_data116_->items_length1, &_data116_->_items_size_, _tmp6_);
				} else {
					gint _tmp7_;
					_tmp7_ = _data116_->skipped;
					_data116_->skipped = _tmp7_ + 1;
				}
				_g_object_unref0 (m);
			}
		}
	}
	_tmp8_ = _data116_->items;
	_tmp8__length1 = _data116_->items_length1;
	if (_tmp8__length1 == 0) {
		dc_gallery_dialog_toast (self, "No downloaded files to save");
		block116_data_unref (_data116_);
		_data116_ = NULL;
		msgs = (_vala_array_free (msgs, msgs_length1, (GDestroyNotify) g_object_unref), NULL);
		return;
	}
	_tmp9_ = gtk_file_dialog_new ();
	_data116_->chooser = _tmp9_;
	_tmp10_ = _data116_->chooser;
	gtk_file_dialog_set_title (_tmp10_, "Select Folder");
	_tmp11_ = _data116_->chooser;
	_tmp12_ = self->priv->app_window;
	gtk_file_dialog_select_folder (_tmp11_, (GtkWindow*) _tmp12_, NULL, ___lambda234__gasync_ready_callback, block116_data_ref (_data116_));
	msgs = (_vala_array_free (msgs, msgs_length1, (GDestroyNotify) g_object_unref), NULL);
	block116_data_unref (_data116_);
	_data116_ = NULL;
}

static void
dc_gallery_dialog_save_files_to_folder_data_free (gpointer _data)
{
	DcGalleryDialogSaveFilesToFolderData* _data_;
	_data_ = _data;
	_data_->items = (_vala_array_free (_data_->items, _data_->items_length1, (GDestroyNotify) g_object_unref), NULL);
	_g_object_unref0 (_data_->folder);
	_g_object_unref0 (_data_->self);
	g_slice_free (DcGalleryDialogSaveFilesToFolderData, _data_);
}

static void
dc_gallery_dialog_save_files_to_folder (DcGalleryDialog* self,
                                        DcMessage** items,
                                        gint items_length1,
                                        gint skipped,
                                        GFile* folder,
                                        GAsyncReadyCallback _callback_,
                                        gpointer _user_data_)
{
	DcGalleryDialogSaveFilesToFolderData* _data_;
	DcGalleryDialog* _tmp0_;
	GFile* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (folder != NULL);
	_data_ = g_slice_new0 (DcGalleryDialogSaveFilesToFolderData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_gallery_dialog_save_files_to_folder_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->items = (_vala_array_free (_data_->items, _data_->items_length1, (GDestroyNotify) g_object_unref), NULL);
	_data_->items = items;
	_data_->items_length1 = items_length1;
	_data_->skipped = skipped;
	_tmp1_ = _g_object_ref0 (folder);
	_g_object_unref0 (_data_->folder);
	_data_->folder = _tmp1_;
	dc_gallery_dialog_save_files_to_folder_co (_data_);
}

static void
dc_gallery_dialog_save_files_to_folder_finish (DcGalleryDialog* self,
                                               GAsyncResult* _res_)
{
	DcGalleryDialogSaveFilesToFolderData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static Block117Data*
block117_data_ref (Block117Data* _data117_)
{
	g_atomic_int_inc (&_data117_->_ref_count_);
	return _data117_;
}

static void
block117_data_unref (void * _userdata_)
{
	Block117Data* _data117_;
	_data117_ = (Block117Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data117_->_ref_count_)) {
		DcGalleryDialog* self;
		self = _data117_->self;
		_g_object_unref0 (_data117_->cancellable);
		_g_object_unref0 (self);
		g_slice_free (Block117Data, _data117_);
	}
}

static void
__lambda235_ (Block117Data* _data117_,
              const gchar* r)
{
	DcGalleryDialog* self;
	self = _data117_->self;
	g_return_if_fail (r != NULL);
	if (!_data117_->finished) {
		GCancellable* _tmp0_;
		_tmp0_ = _data117_->cancellable;
		g_cancellable_cancel (_tmp0_);
	}
}

static void
___lambda235__adw_alert_dialog_response (AdwAlertDialog* _sender,
                                         const gchar* response,
                                         gpointer self)
{
	__lambda235_ (self, response);
}

static void
dc_gallery_dialog_save_files_to_folder_ready (GObject* source_object,
                                              GAsyncResult* _res_,
                                              gpointer _user_data_)
{
	DcGalleryDialogSaveFilesToFolderData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_gallery_dialog_save_files_to_folder_co (_data_);
}

static gboolean
dc_gallery_dialog_save_files_to_folder_co (DcGalleryDialogSaveFilesToFolderData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_data117_ = g_slice_new0 (Block117Data);
	_data_->_data117_->_ref_count_ = 1;
	_data_->_data117_->self = g_object_ref (_data_->self);
	_data_->_data117_->_async_data_ = _data_;
	_data_->_tmp0_ = (GtkProgressBar*) gtk_progress_bar_new ();
	g_object_ref_sink (_data_->_tmp0_);
	_data_->progress = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->progress;
	gtk_widget_set_hexpand ((GtkWidget*) _data_->_tmp1_, TRUE);
	_data_->_tmp2_ = (GtkLabel*) gtk_label_new ("");
	g_object_ref_sink (_data_->_tmp2_);
	_data_->file_label = _data_->_tmp2_;
	_data_->_tmp3_ = _data_->file_label;
	gtk_label_set_ellipsize (_data_->_tmp3_, PANGO_ELLIPSIZE_MIDDLE);
	_data_->_tmp4_ = _data_->file_label;
	gtk_widget_add_css_class ((GtkWidget*) _data_->_tmp4_, "dim-label");
	_data_->_tmp5_ = _data_->file_label;
	gtk_widget_add_css_class ((GtkWidget*) _data_->_tmp5_, "caption");
	_data_->_tmp6_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
	g_object_ref_sink (_data_->_tmp6_);
	_data_->pbox = _data_->_tmp6_;
	_data_->_tmp7_ = _data_->pbox;
	_data_->_tmp8_ = _data_->progress;
	gtk_box_append (_data_->_tmp7_, (GtkWidget*) _data_->_tmp8_);
	_data_->_tmp9_ = _data_->pbox;
	_data_->_tmp10_ = _data_->file_label;
	gtk_box_append (_data_->_tmp9_, (GtkWidget*) _data_->_tmp10_);
	_data_->_tmp11_ = (AdwAlertDialog*) adw_alert_dialog_new ("Saving Files", NULL);
	g_object_ref_sink (_data_->_tmp11_);
	_data_->alert = _data_->_tmp11_;
	_data_->_tmp12_ = _data_->alert;
	_data_->_tmp13_ = _data_->pbox;
	adw_alert_dialog_set_extra_child (_data_->_tmp12_, (GtkWidget*) _data_->_tmp13_);
	_data_->_tmp14_ = _data_->alert;
	adw_alert_dialog_add_response (_data_->_tmp14_, "cancel", "Cancel");
	_data_->_tmp15_ = _data_->alert;
	adw_alert_dialog_set_close_response (_data_->_tmp15_, "cancel");
	_data_->_tmp16_ = g_cancellable_new ();
	_data_->_data117_->cancellable = _data_->_tmp16_;
	_data_->_data117_->finished = FALSE;
	_data_->_tmp17_ = _data_->alert;
	g_signal_connect_data (_data_->_tmp17_, "response", (GCallback) ___lambda235__adw_alert_dialog_response, block117_data_ref (_data_->_data117_), (GClosureNotify) block117_data_unref, 0);
	_data_->_tmp18_ = _data_->alert;
	adw_dialog_present ((AdwDialog*) _data_->_tmp18_, (GtkWidget*) _data_->self);
	_data_->saved = 0;
	_data_->failed = 0;
	{
		_data_->i = 0;
		{
			_data_->_tmp19_ = TRUE;
			while (TRUE) {
				if (!_data_->_tmp19_) {
					_data_->_tmp20_ = _data_->i;
					_data_->i = _data_->_tmp20_ + 1;
				}
				_data_->_tmp19_ = FALSE;
				if (!(_data_->i < _data_->items_length1)) {
					break;
				}
				_data_->_tmp21_ = _data_->_data117_->cancellable;
				if (g_cancellable_is_cancelled (_data_->_tmp21_)) {
					break;
				}
				_data_->_tmp22_ = _data_->items[_data_->i];
				_data_->_tmp23_ = _g_object_ref0 (_data_->_tmp22_);
				_data_->m = _data_->_tmp23_;
				_data_->_tmp24_ = _data_->m;
				_data_->_tmp25_ = _data_->m;
				_data_->_tmp26_ = dc_message_get_file_path (_data_->_tmp25_);
				_data_->_tmp27_ = _data_->_tmp26_;
				_data_->_tmp28_ = g_path_get_basename (_data_->_tmp27_);
				_data_->_tmp29_ = _data_->_tmp28_;
				_data_->_tmp30_ = dc_message_display_file_name (_data_->_tmp24_, _data_->_tmp29_);
				_data_->_tmp31_ = _data_->_tmp30_;
				_g_free0 (_data_->_tmp29_);
				_data_->name = _data_->_tmp31_;
				_data_->_tmp32_ = _data_->progress;
				gtk_progress_bar_set_fraction (_data_->_tmp32_, ((gdouble) _data_->i) / _data_->items_length1);
				_data_->_tmp33_ = _data_->progress;
				_data_->_tmp34_ = g_strdup_printf ("%d of %d", _data_->i + 1, _data_->items_length1);
				_data_->_tmp35_ = _data_->_tmp34_;
				gtk_progress_bar_set_text (_data_->_tmp33_, _data_->_tmp35_);
				_g_free0 (_data_->_tmp35_);
				_data_->_tmp36_ = _data_->progress;
				gtk_progress_bar_set_show_text (_data_->_tmp36_, TRUE);
				_data_->_tmp37_ = _data_->file_label;
				_data_->_tmp38_ = _data_->name;
				gtk_label_set_label (_data_->_tmp37_, _data_->_tmp38_);
				{
					_data_->_tmp39_ = _data_->m;
					_data_->_tmp40_ = dc_message_get_file_path (_data_->_tmp39_);
					_data_->_tmp41_ = _data_->_tmp40_;
					_data_->_tmp42_ = g_file_new_for_path (_data_->_tmp41_);
					_data_->src = _data_->_tmp42_;
					_data_->_tmp43_ = _data_->name;
					_data_->_tmp44_ = dc_save_folder_unique_destination (_data_->folder, _data_->_tmp43_);
					_data_->dest = _data_->_tmp44_;
					_data_->_tmp45_ = _data_->src;
					_data_->_tmp46_ = _data_->dest;
					_data_->_tmp47_ = _data_->_data117_->cancellable;
					_data_->_state_ = 1;
					g_file_copy_async (_data_->_tmp45_, _data_->_tmp46_, G_FILE_COPY_NONE, G_PRIORITY_DEFAULT, _data_->_tmp47_, NULL, NULL, dc_gallery_dialog_save_files_to_folder_ready, _data_);
					return FALSE;
					_state_1:
					g_file_copy_finish (_data_->_tmp45_, _data_->_res_, &_data_->_inner_error0_);
					if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
						_g_object_unref0 (_data_->dest);
						_g_object_unref0 (_data_->src);
						goto __catch0_g_error;
					}
					_data_->_tmp48_ = _data_->saved;
					_data_->saved = _data_->_tmp48_ + 1;
					_g_object_unref0 (_data_->dest);
					_g_object_unref0 (_data_->src);
				}
				goto __finally0;
				__catch0_g_error:
				{
					_data_->e = _data_->_inner_error0_;
					_data_->_inner_error0_ = NULL;
					_data_->_tmp49_ = _data_->e;
					if (g_error_matches (_data_->_tmp49_, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
						_g_error_free0 (_data_->e);
						_g_free0 (_data_->name);
						_g_object_unref0 (_data_->m);
						break;
					}
					_data_->_tmp50_ = _data_->failed;
					_data_->failed = _data_->_tmp50_ + 1;
					_g_error_free0 (_data_->e);
				}
				__finally0:
				if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
					_g_free0 (_data_->name);
					_g_object_unref0 (_data_->m);
					_g_object_unref0 (_data_->alert);
					_g_object_unref0 (_data_->pbox);
					_g_object_unref0 (_data_->file_label);
					_g_object_unref0 (_data_->progress);
					block117_data_unref (_data_->_data117_);
					_data_->_data117_ = NULL;
					_data_->items = (_vala_array_free (_data_->items, _data_->items_length1, (GDestroyNotify) g_object_unref), NULL);
					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_free0 (_data_->name);
				_g_object_unref0 (_data_->m);
			}
		}
	}
	_data_->_data117_->finished = TRUE;
	_data_->_tmp51_ = _data_->alert;
	adw_dialog_force_close ((AdwDialog*) _data_->_tmp51_);
	if (!_data_->self->priv->is_open) {
		_g_object_unref0 (_data_->alert);
		_g_object_unref0 (_data_->pbox);
		_g_object_unref0 (_data_->file_label);
		_g_object_unref0 (_data_->progress);
		block117_data_unref (_data_->_data117_);
		_data_->_data117_ = NULL;
		_data_->items = (_vala_array_free (_data_->items, _data_->items_length1, (GDestroyNotify) g_object_unref), 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_->_tmp52_ = _data_->_data117_->cancellable;
	if (g_cancellable_is_cancelled (_data_->_tmp52_)) {
		if (_data_->saved == 1) {
			_data_->_tmp53_ = "";
		} else {
			_data_->_tmp53_ = "s";
		}
		_data_->_tmp54_ = g_strdup_printf ("Saving cancelled — %d file%s saved", _data_->saved, _data_->_tmp53_);
		_g_free0 (_data_->summary);
		_data_->summary = _data_->_tmp54_;
	} else {
		if (_data_->saved == 1) {
			_data_->_tmp55_ = "";
		} else {
			_data_->_tmp55_ = "s";
		}
		_data_->_tmp56_ = g_strdup_printf ("Saved %d file%s", _data_->saved, _data_->_tmp55_);
		_g_free0 (_data_->summary);
		_data_->summary = _data_->_tmp56_;
		if (_data_->failed > 0) {
			_data_->_tmp57_ = _data_->summary;
			_data_->_tmp58_ = g_strdup_printf (", %d failed", _data_->failed);
			_data_->_tmp59_ = _data_->_tmp58_;
			_data_->_tmp60_ = g_strconcat (_data_->_tmp57_, _data_->_tmp59_, NULL);
			_g_free0 (_data_->summary);
			_data_->summary = _data_->_tmp60_;
			_g_free0 (_data_->_tmp59_);
		}
		if (_data_->skipped > 0) {
			_data_->_tmp61_ = _data_->summary;
			_data_->_tmp62_ = g_strdup_printf (", %d not downloaded", _data_->skipped);
			_data_->_tmp63_ = _data_->_tmp62_;
			_data_->_tmp64_ = g_strconcat (_data_->_tmp61_, _data_->_tmp63_, NULL);
			_g_free0 (_data_->summary);
			_data_->summary = _data_->_tmp64_;
			_g_free0 (_data_->_tmp63_);
		}
	}
	_data_->_tmp65_ = _data_->summary;
	dc_gallery_dialog_toast (_data_->self, _data_->_tmp65_);
	_g_free0 (_data_->summary);
	_g_object_unref0 (_data_->alert);
	_g_object_unref0 (_data_->pbox);
	_g_object_unref0 (_data_->file_label);
	_g_object_unref0 (_data_->progress);
	_data_->items = (_vala_array_free (_data_->items, _data_->items_length1, (GDestroyNotify) g_object_unref), NULL);
	block117_data_unref (_data_->_data117_);
	_data_->_data117_ = 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
dc_gallery_dialog_toast (DcGalleryDialog* self,
                         const gchar* text)
{
	AdwToastOverlay* _tmp0_;
	AdwToast* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (text != NULL);
	_tmp0_ = self->priv->toasts;
	_tmp1_ = adw_toast_new (text);
	adw_toast_overlay_add_toast (_tmp0_, _tmp1_);
}

gboolean
dc_gallery_dialog_get_selection_mode (DcGalleryDialog* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_selection_mode;
	return result;
}

static void
dc_gallery_dialog_set_selection_mode (DcGalleryDialog* self,
                                      gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = dc_gallery_dialog_get_selection_mode (self);
	if (old_value != value) {
		self->priv->_selection_mode = value;
		g_object_notify_by_pspec ((GObject *) self, dc_gallery_dialog_properties[DC_GALLERY_DIALOG_SELECTION_MODE_PROPERTY]);
	}
}

static DcGalleryDialogGalleryTab*
dc_gallery_dialog_gallery_tab_construct (GType object_type)
{
	DcGalleryDialogGalleryTab * self = NULL;
	self = (DcGalleryDialogGalleryTab*) g_object_new (object_type, NULL);
	return self;
}

static DcGalleryDialogGalleryTab*
dc_gallery_dialog_gallery_tab_new (void)
{
	return dc_gallery_dialog_gallery_tab_construct (DC_GALLERY_DIALOG_TYPE_GALLERY_TAB);
}

static void
dc_gallery_dialog_gallery_tab_class_init (DcGalleryDialogGalleryTabClass * klass,
                                          gpointer klass_data)
{
	dc_gallery_dialog_gallery_tab_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = dc_gallery_dialog_gallery_tab_finalize;
}

static void
dc_gallery_dialog_gallery_tab_instance_init (DcGalleryDialogGalleryTab * self,
                                             gpointer klass)
{
	GListStore* _tmp0_;
	_tmp0_ = g_list_store_new (DC_TYPE_MESSAGE);
	self->store = _tmp0_;
	self->load_started = FALSE;
}

static void
dc_gallery_dialog_gallery_tab_finalize (GObject * obj)
{
	DcGalleryDialogGalleryTab * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_GALLERY_DIALOG_TYPE_GALLERY_TAB, DcGalleryDialogGalleryTab);
	_g_free0 (self->key);
	_g_free0 (self->title);
	_g_free0 (self->icon_name);
	self->types = (_vala_array_free (self->types, self->types_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (self->empty_title);
	_g_free0 (self->empty_description);
	_g_free0 (self->kind_plural);
	_g_object_unref0 (self->store);
	_g_object_unref0 (self->stack);
	G_OBJECT_CLASS (dc_gallery_dialog_gallery_tab_parent_class)->finalize (obj);
}

static GType
dc_gallery_dialog_gallery_tab_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DcGalleryDialogGalleryTabClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_gallery_dialog_gallery_tab_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcGalleryDialogGalleryTab), 0, (GInstanceInitFunc) dc_gallery_dialog_gallery_tab_instance_init, NULL };
	GType dc_gallery_dialog_gallery_tab_type_id;
	dc_gallery_dialog_gallery_tab_type_id = g_type_register_static (G_TYPE_OBJECT, "DcGalleryDialogGalleryTab", &g_define_type_info, 0);
	return dc_gallery_dialog_gallery_tab_type_id;
}

static GType
dc_gallery_dialog_gallery_tab_get_type (void)
{
	static volatile gsize dc_gallery_dialog_gallery_tab_type_id__once = 0;
	if (g_once_init_enter (&dc_gallery_dialog_gallery_tab_type_id__once)) {
		GType dc_gallery_dialog_gallery_tab_type_id;
		dc_gallery_dialog_gallery_tab_type_id = dc_gallery_dialog_gallery_tab_get_type_once ();
		g_once_init_leave (&dc_gallery_dialog_gallery_tab_type_id__once, dc_gallery_dialog_gallery_tab_type_id);
	}
	return dc_gallery_dialog_gallery_tab_type_id__once;
}

static DcGalleryDialogThumbRequest*
dc_gallery_dialog_thumb_request_construct (GType object_type)
{
	DcGalleryDialogThumbRequest* self = NULL;
	self = (DcGalleryDialogThumbRequest*) g_type_create_instance (object_type);
	return self;
}

static DcGalleryDialogThumbRequest*
dc_gallery_dialog_thumb_request_new (void)
{
	return dc_gallery_dialog_thumb_request_construct (DC_GALLERY_DIALOG_TYPE_THUMB_REQUEST);
}

static void
dc_gallery_dialog_value_thumb_request_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
dc_gallery_dialog_value_thumb_request_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		dc_gallery_dialog_thumb_request_unref (value->data[0].v_pointer);
	}
}

static void
dc_gallery_dialog_value_thumb_request_copy_value (const GValue* src_value,
                                                  GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = dc_gallery_dialog_thumb_request_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
dc_gallery_dialog_value_thumb_request_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
dc_gallery_dialog_value_thumb_request_collect_value (GValue* value,
                                                     guint n_collect_values,
                                                     GTypeCValue* collect_values,
                                                     guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		DcGalleryDialogThumbRequest * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = dc_gallery_dialog_thumb_request_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
dc_gallery_dialog_value_thumb_request_lcopy_value (const GValue* value,
                                                   guint n_collect_values,
                                                   GTypeCValue* collect_values,
                                                   guint collect_flags)
{
	DcGalleryDialogThumbRequest ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = dc_gallery_dialog_thumb_request_ref (value->data[0].v_pointer);
	}
	return NULL;
}

static GParamSpec*
dc_gallery_dialog_param_spec_thumb_request (const gchar* name,
                                            const gchar* nick,
                                            const gchar* blurb,
                                            GType object_type,
                                            GParamFlags flags)
{
	DcGalleryDialogParamSpecThumbRequest* spec;
	g_return_val_if_fail (g_type_is_a (object_type, DC_GALLERY_DIALOG_TYPE_THUMB_REQUEST), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

static gpointer
dc_gallery_dialog_value_get_thumb_request (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DC_GALLERY_DIALOG_TYPE_THUMB_REQUEST), NULL);
	return value->data[0].v_pointer;
}

static void
dc_gallery_dialog_value_set_thumb_request (GValue* value,
                                           gpointer v_object)
{
	DcGalleryDialogThumbRequest * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DC_GALLERY_DIALOG_TYPE_THUMB_REQUEST));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, DC_GALLERY_DIALOG_TYPE_THUMB_REQUEST));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		dc_gallery_dialog_thumb_request_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		dc_gallery_dialog_thumb_request_unref (old);
	}
}

static void
dc_gallery_dialog_value_take_thumb_request (GValue* value,
                                            gpointer v_object)
{
	DcGalleryDialogThumbRequest * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DC_GALLERY_DIALOG_TYPE_THUMB_REQUEST));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, DC_GALLERY_DIALOG_TYPE_THUMB_REQUEST));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		dc_gallery_dialog_thumb_request_unref (old);
	}
}

static void
dc_gallery_dialog_thumb_request_class_init (DcGalleryDialogThumbRequestClass * klass,
                                            gpointer klass_data)
{
	dc_gallery_dialog_thumb_request_parent_class = g_type_class_peek_parent (klass);
	((DcGalleryDialogThumbRequestClass *) klass)->finalize = dc_gallery_dialog_thumb_request_finalize;
}

static void
dc_gallery_dialog_thumb_request_instance_init (DcGalleryDialogThumbRequest * self,
                                               gpointer klass)
{
	self->result = NULL;
	self->ref_count = 1;
}

static void
dc_gallery_dialog_thumb_request_finalize (DcGalleryDialogThumbRequest * obj)
{
	DcGalleryDialogThumbRequest * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_GALLERY_DIALOG_TYPE_THUMB_REQUEST, DcGalleryDialogThumbRequest);
	g_signal_handlers_destroy (self);
	_g_free0 (self->path);
	_g_source_unref0 (self->resume_source);
	_g_object_unref0 (self->result);
}

static GType
dc_gallery_dialog_thumb_request_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { dc_gallery_dialog_value_thumb_request_init, dc_gallery_dialog_value_thumb_request_free_value, dc_gallery_dialog_value_thumb_request_copy_value, dc_gallery_dialog_value_thumb_request_peek_pointer, "p", dc_gallery_dialog_value_thumb_request_collect_value, "p", dc_gallery_dialog_value_thumb_request_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (DcGalleryDialogThumbRequestClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_gallery_dialog_thumb_request_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcGalleryDialogThumbRequest), 0, (GInstanceInitFunc) dc_gallery_dialog_thumb_request_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType dc_gallery_dialog_thumb_request_type_id;
	dc_gallery_dialog_thumb_request_type_id = g_type_register_fundamental (g_type_fundamental_next (), "DcGalleryDialogThumbRequest", &g_define_type_info, &g_define_type_fundamental_info, 0);
	return dc_gallery_dialog_thumb_request_type_id;
}

static GType
dc_gallery_dialog_thumb_request_get_type (void)
{
	static volatile gsize dc_gallery_dialog_thumb_request_type_id__once = 0;
	if (g_once_init_enter (&dc_gallery_dialog_thumb_request_type_id__once)) {
		GType dc_gallery_dialog_thumb_request_type_id;
		dc_gallery_dialog_thumb_request_type_id = dc_gallery_dialog_thumb_request_get_type_once ();
		g_once_init_leave (&dc_gallery_dialog_thumb_request_type_id__once, dc_gallery_dialog_thumb_request_type_id);
	}
	return dc_gallery_dialog_thumb_request_type_id__once;
}

static gpointer
dc_gallery_dialog_thumb_request_ref (gpointer instance)
{
	DcGalleryDialogThumbRequest * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

static void
dc_gallery_dialog_thumb_request_unref (gpointer instance)
{
	DcGalleryDialogThumbRequest * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		DC_GALLERY_DIALOG_THUMB_REQUEST_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static inline gpointer
dc_gallery_dialog_media_cell_get_instance_private (DcGalleryDialogMediaCell* self)
{
	return G_STRUCT_MEMBER_P (self, DcGalleryDialogMediaCell_private_offset);
}

static void
__lambda220_ (DcGalleryDialogMediaCell* self)
{
	dc_gallery_dialog_media_cell_update_selection_visuals (self);
}

static void
___lambda220__dc_gallery_dialog_selection_changed (DcGalleryDialog* _sender,
                                                   gpointer self)
{
	__lambda220_ ((DcGalleryDialogMediaCell*) self);
}

static DcGalleryDialogMediaCell*
dc_gallery_dialog_media_cell_construct (GType object_type,
                                        DcGalleryDialog* dialog,
                                        gboolean is_video,
                                        gboolean contain)
{
	DcGalleryDialogMediaCell * self = NULL;
	GtkPicture* _tmp0_;
	GtkContentFit _tmp1_ = 0;
	GtkPicture* _tmp2_;
	GtkPicture* _tmp3_;
	GtkPicture* _tmp4_;
	GtkPicture* _tmp5_;
	GtkOverlay* overlay = NULL;
	GtkOverlay* _tmp6_;
	GtkOverlay* _tmp7_;
	GtkPicture* _tmp8_;
	const gchar* _tmp9_ = NULL;
	GtkImage* _tmp10_;
	GtkImage* _tmp11_;
	GtkImage* _tmp12_;
	GtkImage* _tmp13_;
	GtkImage* _tmp14_;
	GtkOverlay* _tmp15_;
	GtkImage* _tmp16_;
	GtkCheckButton* _tmp29_;
	GtkCheckButton* _tmp30_;
	GtkCheckButton* _tmp31_;
	GtkCheckButton* _tmp32_;
	GtkCheckButton* _tmp33_;
	GtkCheckButton* _tmp34_;
	GtkCheckButton* _tmp35_;
	GtkCheckButton* _tmp36_;
	GtkOverlay* _tmp37_;
	GtkCheckButton* _tmp38_;
	DcScaledPreviewFrame* frame = NULL;
	DcScaledPreviewFrame* _tmp39_;
	DcScaledPreviewFrame* _tmp40_;
	DcScaledPreviewFrame* _tmp42_;
	GtkOverlay* _tmp43_;
	DcScaledPreviewFrame* _tmp44_;
	g_return_val_if_fail (dialog != NULL, NULL);
	self = (DcGalleryDialogMediaCell*) g_object_new (object_type, "orientation", GTK_ORIENTATION_VERTICAL, "spacing", 0, NULL);
	self->priv->dialog = dialog;
	self->priv->is_video = is_video;
	_tmp0_ = (GtkPicture*) gtk_picture_new ();
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->picture);
	self->priv->picture = _tmp0_;
	if (contain) {
		_tmp1_ = GTK_CONTENT_FIT_CONTAIN;
	} else {
		_tmp1_ = GTK_CONTENT_FIT_COVER;
	}
	_tmp2_ = self->priv->picture;
	gtk_picture_set_content_fit (_tmp2_, _tmp1_);
	_tmp3_ = self->priv->picture;
	gtk_picture_set_can_shrink (_tmp3_, TRUE);
	_tmp4_ = self->priv->picture;
	gtk_widget_set_halign ((GtkWidget*) _tmp4_, GTK_ALIGN_FILL);
	_tmp5_ = self->priv->picture;
	gtk_widget_set_valign ((GtkWidget*) _tmp5_, GTK_ALIGN_FILL);
	_tmp6_ = (GtkOverlay*) gtk_overlay_new ();
	g_object_ref_sink (_tmp6_);
	overlay = _tmp6_;
	_tmp7_ = overlay;
	_tmp8_ = self->priv->picture;
	gtk_overlay_set_child (_tmp7_, (GtkWidget*) _tmp8_);
	if (is_video) {
		_tmp9_ = "video-x-generic-symbolic";
	} else {
		_tmp9_ = "image-x-generic-symbolic";
	}
	_tmp10_ = (GtkImage*) gtk_image_new_from_icon_name (_tmp9_);
	g_object_ref_sink (_tmp10_);
	_g_object_unref0 (self->priv->placeholder);
	self->priv->placeholder = _tmp10_;
	_tmp11_ = self->priv->placeholder;
	gtk_image_set_pixel_size (_tmp11_, 28);
	_tmp12_ = self->priv->placeholder;
	gtk_widget_set_halign ((GtkWidget*) _tmp12_, GTK_ALIGN_CENTER);
	_tmp13_ = self->priv->placeholder;
	gtk_widget_set_valign ((GtkWidget*) _tmp13_, GTK_ALIGN_CENTER);
	_tmp14_ = self->priv->placeholder;
	gtk_widget_add_css_class ((GtkWidget*) _tmp14_, "dim-label");
	_tmp15_ = overlay;
	_tmp16_ = self->priv->placeholder;
	gtk_overlay_add_overlay (_tmp15_, (GtkWidget*) _tmp16_);
	if (is_video) {
		GtkBox* _tmp17_;
		GtkBox* _tmp18_;
		GtkBox* _tmp19_;
		GtkBox* _tmp20_;
		GtkBox* _tmp21_;
		GtkImage* play = NULL;
		GtkImage* _tmp22_;
		GtkImage* _tmp23_;
		GtkBox* _tmp24_;
		GtkImage* _tmp25_;
		GtkBox* _tmp26_;
		GtkOverlay* _tmp27_;
		GtkBox* _tmp28_;
		_tmp17_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
		g_object_ref_sink (_tmp17_);
		_g_object_unref0 (self->priv->play_badge);
		self->priv->play_badge = _tmp17_;
		_tmp18_ = self->priv->play_badge;
		gtk_widget_add_css_class ((GtkWidget*) _tmp18_, "message-video-play");
		_tmp19_ = self->priv->play_badge;
		gtk_widget_set_halign ((GtkWidget*) _tmp19_, GTK_ALIGN_CENTER);
		_tmp20_ = self->priv->play_badge;
		gtk_widget_set_valign ((GtkWidget*) _tmp20_, GTK_ALIGN_CENTER);
		_tmp21_ = self->priv->play_badge;
		gtk_widget_set_can_target ((GtkWidget*) _tmp21_, FALSE);
		_tmp22_ = (GtkImage*) gtk_image_new_from_icon_name ("media-playback-start-symbolic");
		g_object_ref_sink (_tmp22_);
		play = _tmp22_;
		_tmp23_ = play;
		gtk_image_set_pixel_size (_tmp23_, 18);
		_tmp24_ = self->priv->play_badge;
		_tmp25_ = play;
		gtk_box_append (_tmp24_, (GtkWidget*) _tmp25_);
		_tmp26_ = self->priv->play_badge;
		gtk_widget_set_visible ((GtkWidget*) _tmp26_, FALSE);
		_tmp27_ = overlay;
		_tmp28_ = self->priv->play_badge;
		gtk_overlay_add_overlay (_tmp27_, (GtkWidget*) _tmp28_);
		_g_object_unref0 (play);
	}
	_tmp29_ = (GtkCheckButton*) gtk_check_button_new ();
	g_object_ref_sink (_tmp29_);
	_g_object_unref0 (self->priv->check);
	self->priv->check = _tmp29_;
	_tmp30_ = self->priv->check;
	gtk_widget_add_css_class ((GtkWidget*) _tmp30_, "selection-mode");
	_tmp31_ = self->priv->check;
	gtk_widget_set_can_target ((GtkWidget*) _tmp31_, FALSE);
	_tmp32_ = self->priv->check;
	gtk_widget_set_halign ((GtkWidget*) _tmp32_, GTK_ALIGN_END);
	_tmp33_ = self->priv->check;
	gtk_widget_set_valign ((GtkWidget*) _tmp33_, GTK_ALIGN_START);
	_tmp34_ = self->priv->check;
	gtk_widget_set_margin_top ((GtkWidget*) _tmp34_, 6);
	_tmp35_ = self->priv->check;
	gtk_widget_set_margin_end ((GtkWidget*) _tmp35_, 6);
	_tmp36_ = self->priv->check;
	gtk_widget_set_visible ((GtkWidget*) _tmp36_, FALSE);
	_tmp37_ = overlay;
	_tmp38_ = self->priv->check;
	gtk_overlay_add_overlay (_tmp37_, (GtkWidget*) _tmp38_);
	_tmp39_ = dc_scaled_preview_frame_new (DC_GALLERY_DIALOG_CELL_MAX, DC_GALLERY_DIALOG_CELL_MAX, "gallery-thumb");
	g_object_ref_sink (_tmp39_);
	frame = _tmp39_;
	_tmp40_ = frame;
	gtk_widget_set_size_request ((GtkWidget*) _tmp40_, DC_GALLERY_DIALOG_CELL_MIN, -1);
	if (contain) {
		DcScaledPreviewFrame* _tmp41_;
		_tmp41_ = frame;
		gtk_widget_add_css_class ((GtkWidget*) _tmp41_, "gallery-thumb-checker");
	}
	_tmp42_ = frame;
	_tmp43_ = overlay;
	dc_scaled_preview_frame_set_child (_tmp42_, (GtkWidget*) _tmp43_);
	_tmp44_ = frame;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp44_);
	dc_gallery_dialog_add_context_menu_gestures ((DcGalleryCell*) self, dialog);
	g_signal_connect_object (dialog, "selection-changed", (GCallback) ___lambda220__dc_gallery_dialog_selection_changed, self, 0);
	_g_object_unref0 (frame);
	_g_object_unref0 (overlay);
	return self;
}

static DcGalleryDialogMediaCell*
dc_gallery_dialog_media_cell_new (DcGalleryDialog* dialog,
                                  gboolean is_video,
                                  gboolean contain)
{
	return dc_gallery_dialog_media_cell_construct (DC_GALLERY_DIALOG_TYPE_MEDIA_CELL, dialog, is_video, contain);
}

static Block118Data*
block118_data_ref (Block118Data* _data118_)
{
	g_atomic_int_inc (&_data118_->_ref_count_);
	return _data118_;
}

static void
block118_data_unref (void * _userdata_)
{
	Block118Data* _data118_;
	_data118_ = (Block118Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data118_->_ref_count_)) {
		DcGalleryDialogMediaCell* self;
		self = _data118_->self;
		_g_object_unref0 (self);
		g_slice_free (Block118Data, _data118_);
	}
}

static void
__lambda221_ (Block118Data* _data118_,
              GObject* o,
              GAsyncResult* res)
{
	DcGalleryDialogMediaCell* self;
	GdkTexture* tex = NULL;
	DcGalleryDialog* _tmp0_;
	GdkTexture* _tmp1_;
	gboolean _tmp2_ = FALSE;
	GtkPicture* _tmp4_;
	GdkTexture* _tmp5_;
	GtkImage* _tmp6_;
	self = _data118_->self;
	g_return_if_fail (res != NULL);
	_tmp0_ = self->priv->dialog;
	_tmp1_ = dc_gallery_dialog_load_thumb_finish (_tmp0_, res);
	tex = _tmp1_;
	if (_data118_->gen != self->priv->generation) {
		_tmp2_ = TRUE;
	} else {
		GdkTexture* _tmp3_;
		_tmp3_ = tex;
		_tmp2_ = _tmp3_ == NULL;
	}
	if (_tmp2_) {
		_g_object_unref0 (tex);
		return;
	}
	_tmp4_ = self->priv->picture;
	_tmp5_ = tex;
	gtk_picture_set_paintable (_tmp4_, (GdkPaintable*) _tmp5_);
	_tmp6_ = self->priv->placeholder;
	gtk_widget_set_visible ((GtkWidget*) _tmp6_, FALSE);
	_g_object_unref0 (tex);
}

static void
___lambda221__gasync_ready_callback (GObject* source_object,
                                     GAsyncResult* res,
                                     gpointer self)
{
	__lambda221_ (self, source_object, res);
	block118_data_unref (self);
}

static void
dc_gallery_dialog_media_cell_real_bind (DcGalleryCell* base,
                                        DcMessage* m)
{
	DcGalleryDialogMediaCell * self;
	Block118Data* _data118_;
	gint _tmp0_;
	GtkPicture* _tmp1_;
	GtkImage* _tmp2_;
	GtkBox* _tmp3_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gboolean _tmp7_;
	gboolean _tmp8_;
	const gchar* _tmp10_ = NULL;
	GtkImage* _tmp11_;
	gboolean _tmp12_ = FALSE;
	DcGalleryDialog* _tmp22_;
	const gchar* _tmp23_;
	const gchar* _tmp24_;
	self = (DcGalleryDialogMediaCell*) base;
	g_return_if_fail (m != NULL);
	_data118_ = g_slice_new0 (Block118Data);
	_data118_->_ref_count_ = 1;
	_data118_->self = g_object_ref (self);
	dc_gallery_cell_set_msg ((DcGalleryCell*) self, m);
	_tmp0_ = self->priv->generation;
	self->priv->generation = _tmp0_ + 1;
	_tmp1_ = self->priv->picture;
	gtk_picture_set_paintable (_tmp1_, NULL);
	_tmp2_ = self->priv->placeholder;
	gtk_widget_set_visible ((GtkWidget*) _tmp2_, TRUE);
	_tmp3_ = self->priv->play_badge;
	if (_tmp3_ != NULL) {
		GtkBox* _tmp4_;
		_tmp4_ = self->priv->play_badge;
		gtk_widget_set_visible ((GtkWidget*) _tmp4_, FALSE);
	}
	_tmp5_ = dc_message_display_file_name (m, "file");
	_tmp6_ = _tmp5_;
	gtk_widget_set_tooltip_text ((GtkWidget*) self, _tmp6_);
	_g_free0 (_tmp6_);
	dc_gallery_dialog_media_cell_update_selection_visuals (self);
	_tmp7_ = dc_message_get_has_local_file (m);
	_tmp8_ = _tmp7_;
	if (!_tmp8_) {
		GtkImage* _tmp9_;
		_tmp9_ = self->priv->placeholder;
		g_object_set (_tmp9_, "icon-name", "image-missing-symbolic", NULL);
		block118_data_unref (_data118_);
		_data118_ = NULL;
		return;
	}
	if (self->priv->is_video) {
		_tmp10_ = "video-x-generic-symbolic";
	} else {
		_tmp10_ = "image-x-generic-symbolic";
	}
	_tmp11_ = self->priv->placeholder;
	g_object_set (_tmp11_, "icon-name", _tmp10_, NULL);
	if (self->priv->is_video) {
		_tmp12_ = TRUE;
	} else {
		_tmp12_ = dc_message_is_video_sticker_file (m);
	}
	if (_tmp12_) {
		GtkMediaFile* media = NULL;
		const gchar* _tmp13_;
		const gchar* _tmp14_;
		GtkMediaFile* _tmp15_;
		GtkMediaFile* _tmp16_;
		GtkPicture* _tmp17_;
		GtkMediaFile* _tmp18_;
		GtkImage* _tmp19_;
		GtkBox* _tmp20_;
		_tmp13_ = dc_message_get_file_path (m);
		_tmp14_ = _tmp13_;
		_tmp15_ = (GtkMediaFile*) gtk_media_file_new_for_filename (_tmp14_);
		media = _tmp15_;
		_tmp16_ = media;
		gtk_media_stream_pause ((GtkMediaStream*) _tmp16_);
		_tmp17_ = self->priv->picture;
		_tmp18_ = media;
		gtk_picture_set_paintable (_tmp17_, (GdkPaintable*) _tmp18_);
		_tmp19_ = self->priv->placeholder;
		gtk_widget_set_visible ((GtkWidget*) _tmp19_, FALSE);
		_tmp20_ = self->priv->play_badge;
		if (_tmp20_ != NULL) {
			GtkBox* _tmp21_;
			_tmp21_ = self->priv->play_badge;
			gtk_widget_set_visible ((GtkWidget*) _tmp21_, TRUE);
		}
		_g_object_unref0 (media);
		block118_data_unref (_data118_);
		_data118_ = NULL;
		return;
	}
	_data118_->gen = self->priv->generation;
	_tmp22_ = self->priv->dialog;
	_tmp23_ = dc_message_get_file_path (m);
	_tmp24_ = _tmp23_;
	dc_gallery_dialog_load_thumb (_tmp22_, _tmp24_, ___lambda221__gasync_ready_callback, block118_data_ref (_data118_));
	block118_data_unref (_data118_);
	_data118_ = NULL;
}

static void
dc_gallery_dialog_media_cell_real_unbind (DcGalleryCell* base)
{
	DcGalleryDialogMediaCell * self;
	gint _tmp0_;
	GtkPicture* _tmp1_;
	self = (DcGalleryDialogMediaCell*) base;
	dc_gallery_cell_set_msg ((DcGalleryCell*) self, NULL);
	_tmp0_ = self->priv->generation;
	self->priv->generation = _tmp0_ + 1;
	_tmp1_ = self->priv->picture;
	gtk_picture_set_paintable (_tmp1_, NULL);
}

static void
dc_gallery_dialog_media_cell_update_selection_visuals (DcGalleryDialogMediaCell* self)
{
	GtkCheckButton* _tmp0_;
	DcGalleryDialog* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	gboolean _tmp4_ = FALSE;
	DcMessage* _tmp5_;
	DcMessage* _tmp6_;
	GtkCheckButton* _tmp12_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->check;
	_tmp1_ = self->priv->dialog;
	_tmp2_ = dc_gallery_dialog_get_selection_mode (_tmp1_);
	_tmp3_ = _tmp2_;
	gtk_widget_set_visible ((GtkWidget*) _tmp0_, _tmp3_);
	_tmp5_ = dc_gallery_cell_get_msg ((DcGalleryCell*) self);
	_tmp6_ = _tmp5_;
	if (_tmp6_ != NULL) {
		DcGalleryDialog* _tmp7_;
		DcMessage* _tmp8_;
		DcMessage* _tmp9_;
		gint _tmp10_;
		gint _tmp11_;
		_tmp7_ = self->priv->dialog;
		_tmp8_ = dc_gallery_cell_get_msg ((DcGalleryCell*) self);
		_tmp9_ = _tmp8_;
		_tmp10_ = dc_message_get_id (_tmp9_);
		_tmp11_ = _tmp10_;
		_tmp4_ = dc_gallery_dialog_is_selected (_tmp7_, _tmp11_);
	} else {
		_tmp4_ = FALSE;
	}
	_tmp12_ = self->priv->check;
	gtk_check_button_set_active (_tmp12_, _tmp4_);
}

static DcMessage*
dc_gallery_dialog_media_cell_real_get_msg (DcGalleryCell* base)
{
	DcMessage* result;
	DcGalleryDialogMediaCell* self;
	DcMessage* _tmp0_;
	self = (DcGalleryDialogMediaCell*) base;
	_tmp0_ = self->priv->_msg;
	result = _tmp0_;
	return result;
}

static void
dc_gallery_dialog_media_cell_real_set_msg (DcGalleryCell* base,
                                           DcMessage* value)
{
	DcGalleryDialogMediaCell* self;
	DcMessage* old_value;
	self = (DcGalleryDialogMediaCell*) base;
	old_value = dc_gallery_dialog_media_cell_real_get_msg (base);
	if (old_value != value) {
		DcMessage* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_msg);
		self->priv->_msg = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, dc_gallery_dialog_media_cell_properties[DC_GALLERY_DIALOG_MEDIA_CELL_MSG_PROPERTY]);
	}
}

static void
dc_gallery_dialog_media_cell_class_init (DcGalleryDialogMediaCellClass * klass,
                                         gpointer klass_data)
{
	dc_gallery_dialog_media_cell_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DcGalleryDialogMediaCell_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_dc_gallery_dialog_media_cell_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_dc_gallery_dialog_media_cell_set_property;
	G_OBJECT_CLASS (klass)->finalize = dc_gallery_dialog_media_cell_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DC_GALLERY_DIALOG_MEDIA_CELL_MSG_PROPERTY, dc_gallery_dialog_media_cell_properties[DC_GALLERY_DIALOG_MEDIA_CELL_MSG_PROPERTY] = g_param_spec_object ("msg", "msg", "msg", DC_TYPE_MESSAGE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
dc_gallery_dialog_media_cell_dc_gallery_cell_interface_init (DcGalleryCellIface * iface,
                                                             gpointer iface_data)
{
	dc_gallery_dialog_media_cell_dc_gallery_cell_parent_iface = g_type_interface_peek_parent (iface);
	iface->bind = (void (*) (DcGalleryCell*, DcMessage*)) dc_gallery_dialog_media_cell_real_bind;
	iface->unbind = (void (*) (DcGalleryCell*)) dc_gallery_dialog_media_cell_real_unbind;
	iface->get_msg = dc_gallery_dialog_media_cell_real_get_msg;
	iface->set_msg = dc_gallery_dialog_media_cell_real_set_msg;
}

static void
dc_gallery_dialog_media_cell_instance_init (DcGalleryDialogMediaCell * self,
                                            gpointer klass)
{
	self->priv = dc_gallery_dialog_media_cell_get_instance_private (self);
	self->priv->play_badge = NULL;
	self->priv->generation = 0;
}

static void
dc_gallery_dialog_media_cell_finalize (GObject * obj)
{
	DcGalleryDialogMediaCell * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_GALLERY_DIALOG_TYPE_MEDIA_CELL, DcGalleryDialogMediaCell);
	_g_object_unref0 (self->priv->_msg);
	_g_object_unref0 (self->priv->picture);
	_g_object_unref0 (self->priv->placeholder);
	_g_object_unref0 (self->priv->play_badge);
	_g_object_unref0 (self->priv->check);
	G_OBJECT_CLASS (dc_gallery_dialog_media_cell_parent_class)->finalize (obj);
}

static GType
dc_gallery_dialog_media_cell_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DcGalleryDialogMediaCellClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_gallery_dialog_media_cell_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcGalleryDialogMediaCell), 0, (GInstanceInitFunc) dc_gallery_dialog_media_cell_instance_init, NULL };
	static const GInterfaceInfo dc_gallery_cell_info = { (GInterfaceInitFunc) dc_gallery_dialog_media_cell_dc_gallery_cell_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType dc_gallery_dialog_media_cell_type_id;
	dc_gallery_dialog_media_cell_type_id = g_type_register_static (gtk_box_get_type (), "DcGalleryDialogMediaCell", &g_define_type_info, 0);
	g_type_add_interface_static (dc_gallery_dialog_media_cell_type_id, DC_TYPE_GALLERY_CELL, &dc_gallery_cell_info);
	DcGalleryDialogMediaCell_private_offset = g_type_add_instance_private (dc_gallery_dialog_media_cell_type_id, sizeof (DcGalleryDialogMediaCellPrivate));
	return dc_gallery_dialog_media_cell_type_id;
}

static GType
dc_gallery_dialog_media_cell_get_type (void)
{
	static volatile gsize dc_gallery_dialog_media_cell_type_id__once = 0;
	if (g_once_init_enter (&dc_gallery_dialog_media_cell_type_id__once)) {
		GType dc_gallery_dialog_media_cell_type_id;
		dc_gallery_dialog_media_cell_type_id = dc_gallery_dialog_media_cell_get_type_once ();
		g_once_init_leave (&dc_gallery_dialog_media_cell_type_id__once, dc_gallery_dialog_media_cell_type_id);
	}
	return dc_gallery_dialog_media_cell_type_id__once;
}

static void
_vala_dc_gallery_dialog_media_cell_get_property (GObject * object,
                                                 guint property_id,
                                                 GValue * value,
                                                 GParamSpec * pspec)
{
	DcGalleryDialogMediaCell * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DC_GALLERY_DIALOG_TYPE_MEDIA_CELL, DcGalleryDialogMediaCell);
	switch (property_id) {
		case DC_GALLERY_DIALOG_MEDIA_CELL_MSG_PROPERTY:
		g_value_set_object (value, dc_gallery_cell_get_msg ((DcGalleryCell*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_dc_gallery_dialog_media_cell_set_property (GObject * object,
                                                 guint property_id,
                                                 const GValue * value,
                                                 GParamSpec * pspec)
{
	DcGalleryDialogMediaCell * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DC_GALLERY_DIALOG_TYPE_MEDIA_CELL, DcGalleryDialogMediaCell);
	switch (property_id) {
		case DC_GALLERY_DIALOG_MEDIA_CELL_MSG_PROPERTY:
		dc_gallery_cell_set_msg ((DcGalleryCell*) self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
dc_gallery_dialog_gallery_row_get_instance_private (DcGalleryDialogGalleryRow* self)
{
	return G_STRUCT_MEMBER_P (self, DcGalleryDialogGalleryRow_private_offset);
}

static Block119Data*
block119_data_ref (Block119Data* _data119_)
{
	g_atomic_int_inc (&_data119_->_ref_count_);
	return _data119_;
}

static void
block119_data_unref (void * _userdata_)
{
	Block119Data* _data119_;
	_data119_ = (Block119Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data119_->_ref_count_)) {
		DcGalleryDialogGalleryRow* self;
		self = _data119_->self;
		_g_object_unref0 (_data119_->dialog);
		_g_object_unref0 (self);
		g_slice_free (Block119Data, _data119_);
	}
}

static void
___lambda225_ (Block119Data* _data119_)
{
	DcGalleryDialogGalleryRow* self;
	DcMessage* _tmp0_;
	DcMessage* _tmp1_;
	self = _data119_->self;
	_tmp0_ = dc_gallery_cell_get_msg ((DcGalleryCell*) self);
	_tmp1_ = _tmp0_;
	if (_tmp1_ != NULL) {
		DcMessage* _tmp2_;
		DcMessage* _tmp3_;
		_tmp2_ = dc_gallery_cell_get_msg ((DcGalleryCell*) self);
		_tmp3_ = _tmp2_;
		dc_gallery_dialog_toggle_audio (_data119_->dialog, _tmp3_);
	}
}

static void
____lambda225__gtk_button_clicked (GtkButton* _sender,
                                   gpointer self)
{
	___lambda225_ (self);
}

static void
__lambda226_ (DcGalleryDialogGalleryRow* self)
{
	dc_gallery_dialog_gallery_row_update_selection_visuals (self);
}

static void
___lambda226__dc_gallery_dialog_selection_changed (DcGalleryDialog* _sender,
                                                   gpointer self)
{
	__lambda226_ ((DcGalleryDialogGalleryRow*) self);
}

static DcGalleryDialogGalleryRow*
dc_gallery_dialog_gallery_row_construct (GType object_type,
                                         DcGalleryDialog* dialog,
                                         const gchar* tab_key)
{
	DcGalleryDialogGalleryRow * self = NULL;
	Block119Data* _data119_;
	DcGalleryDialog* _tmp0_;
	gchar* _tmp1_;
	GtkCheckButton* _tmp2_;
	GtkCheckButton* _tmp3_;
	GtkCheckButton* _tmp4_;
	GtkCheckButton* _tmp5_;
	GtkCheckButton* _tmp6_;
	GtkImage* _tmp7_;
	GtkImage* _tmp8_;
	GtkImage* _tmp9_;
	GtkBox* text_box = NULL;
	GtkBox* _tmp10_;
	GtkBox* _tmp11_;
	GtkBox* _tmp12_;
	GtkLabel* _tmp13_;
	GtkLabel* _tmp14_;
	GtkLabel* _tmp15_;
	GtkBox* _tmp16_;
	GtkLabel* _tmp17_;
	GtkLabel* _tmp18_;
	GtkLabel* _tmp19_;
	GtkLabel* _tmp20_;
	GtkLabel* _tmp21_;
	GtkLabel* _tmp22_;
	GtkBox* _tmp23_;
	GtkLabel* _tmp24_;
	GtkBox* _tmp25_;
	g_return_val_if_fail (dialog != NULL, NULL);
	g_return_val_if_fail (tab_key != NULL, NULL);
	_data119_ = g_slice_new0 (Block119Data);
	_data119_->_ref_count_ = 1;
	_tmp0_ = _g_object_ref0 (dialog);
	_g_object_unref0 (_data119_->dialog);
	_data119_->dialog = _tmp0_;
	self = (DcGalleryDialogGalleryRow*) g_object_new (object_type, "orientation", GTK_ORIENTATION_HORIZONTAL, "spacing", 12, NULL);
	_data119_->self = g_object_ref (self);
	self->priv->dialog = _data119_->dialog;
	_tmp1_ = g_strdup (tab_key);
	_g_free0 (self->priv->tab_key);
	self->priv->tab_key = _tmp1_;
	gtk_widget_add_css_class ((GtkWidget*) self, "gallery-row");
	gtk_widget_set_margin_start ((GtkWidget*) self, 12);
	gtk_widget_set_margin_end ((GtkWidget*) self, 12);
	gtk_widget_set_margin_top ((GtkWidget*) self, 8);
	gtk_widget_set_margin_bottom ((GtkWidget*) self, 8);
	_tmp2_ = (GtkCheckButton*) gtk_check_button_new ();
	g_object_ref_sink (_tmp2_);
	_g_object_unref0 (self->priv->check);
	self->priv->check = _tmp2_;
	_tmp3_ = self->priv->check;
	gtk_widget_set_valign ((GtkWidget*) _tmp3_, GTK_ALIGN_CENTER);
	_tmp4_ = self->priv->check;
	gtk_widget_set_can_target ((GtkWidget*) _tmp4_, FALSE);
	_tmp5_ = self->priv->check;
	gtk_widget_set_visible ((GtkWidget*) _tmp5_, FALSE);
	_tmp6_ = self->priv->check;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp6_);
	_tmp7_ = (GtkImage*) gtk_image_new ();
	g_object_ref_sink (_tmp7_);
	_g_object_unref0 (self->priv->icon);
	self->priv->icon = _tmp7_;
	_tmp8_ = self->priv->icon;
	gtk_image_set_pixel_size (_tmp8_, 24);
	_tmp9_ = self->priv->icon;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp9_);
	_tmp10_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
	g_object_ref_sink (_tmp10_);
	text_box = _tmp10_;
	_tmp11_ = text_box;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp11_, TRUE);
	_tmp12_ = text_box;
	gtk_widget_set_valign ((GtkWidget*) _tmp12_, GTK_ALIGN_CENTER);
	_tmp13_ = (GtkLabel*) gtk_label_new ("");
	g_object_ref_sink (_tmp13_);
	_g_object_unref0 (self->priv->title_label);
	self->priv->title_label = _tmp13_;
	_tmp14_ = self->priv->title_label;
	gtk_label_set_xalign (_tmp14_, (gfloat) 0);
	_tmp15_ = self->priv->title_label;
	gtk_label_set_ellipsize (_tmp15_, PANGO_ELLIPSIZE_MIDDLE);
	_tmp16_ = text_box;
	_tmp17_ = self->priv->title_label;
	gtk_box_append (_tmp16_, (GtkWidget*) _tmp17_);
	_tmp18_ = (GtkLabel*) gtk_label_new ("");
	g_object_ref_sink (_tmp18_);
	_g_object_unref0 (self->priv->subtitle_label);
	self->priv->subtitle_label = _tmp18_;
	_tmp19_ = self->priv->subtitle_label;
	gtk_label_set_xalign (_tmp19_, (gfloat) 0);
	_tmp20_ = self->priv->subtitle_label;
	gtk_label_set_ellipsize (_tmp20_, PANGO_ELLIPSIZE_END);
	_tmp21_ = self->priv->subtitle_label;
	gtk_widget_add_css_class ((GtkWidget*) _tmp21_, "dim-label");
	_tmp22_ = self->priv->subtitle_label;
	gtk_widget_add_css_class ((GtkWidget*) _tmp22_, "caption");
	_tmp23_ = text_box;
	_tmp24_ = self->priv->subtitle_label;
	gtk_box_append (_tmp23_, (GtkWidget*) _tmp24_);
	_tmp25_ = text_box;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp25_);
	if (g_strcmp0 (tab_key, "links") == 0) {
		GtkPicture* _tmp26_;
		GtkPicture* _tmp27_;
		GtkPicture* _tmp28_;
		GtkPicture* _tmp29_;
		GtkPicture* _tmp30_;
		GtkPicture* _tmp31_;
		GtkPicture* _tmp32_;
		GtkPicture* _tmp33_;
		GtkPicture* _tmp34_;
		_tmp26_ = (GtkPicture*) gtk_picture_new ();
		g_object_ref_sink (_tmp26_);
		_g_object_unref0 (self->priv->thumb);
		self->priv->thumb = _tmp26_;
		_tmp27_ = self->priv->thumb;
		gtk_picture_set_content_fit (_tmp27_, GTK_CONTENT_FIT_COVER);
		_tmp28_ = self->priv->thumb;
		gtk_widget_set_size_request ((GtkWidget*) _tmp28_, 48, 48);
		_tmp29_ = self->priv->thumb;
		gtk_widget_set_overflow ((GtkWidget*) _tmp29_, GTK_OVERFLOW_HIDDEN);
		_tmp30_ = self->priv->thumb;
		gtk_widget_add_css_class ((GtkWidget*) _tmp30_, "gallery-thumb");
		_tmp31_ = self->priv->thumb;
		gtk_widget_set_halign ((GtkWidget*) _tmp31_, GTK_ALIGN_END);
		_tmp32_ = self->priv->thumb;
		gtk_widget_set_valign ((GtkWidget*) _tmp32_, GTK_ALIGN_CENTER);
		_tmp33_ = self->priv->thumb;
		gtk_widget_set_visible ((GtkWidget*) _tmp33_, FALSE);
		_tmp34_ = self->priv->thumb;
		gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp34_);
	}
	if (g_strcmp0 (tab_key, "audio") == 0) {
		GtkButton* _tmp35_;
		GtkButton* _tmp36_;
		GtkButton* _tmp37_;
		GtkButton* _tmp38_;
		GtkButton* _tmp39_;
		GtkButton* _tmp40_;
		GtkButton* _tmp41_;
		_tmp35_ = (GtkButton*) gtk_button_new_from_icon_name ("media-playback-start-symbolic");
		g_object_ref_sink (_tmp35_);
		_g_object_unref0 (self->priv->play_btn);
		self->priv->play_btn = _tmp35_;
		_tmp36_ = self->priv->play_btn;
		gtk_widget_add_css_class ((GtkWidget*) _tmp36_, "circular");
		_tmp37_ = self->priv->play_btn;
		gtk_widget_add_css_class ((GtkWidget*) _tmp37_, "flat");
		_tmp38_ = self->priv->play_btn;
		gtk_widget_set_valign ((GtkWidget*) _tmp38_, GTK_ALIGN_CENTER);
		_tmp39_ = self->priv->play_btn;
		gtk_widget_set_tooltip_text ((GtkWidget*) _tmp39_, "Play");
		_tmp40_ = self->priv->play_btn;
		g_signal_connect_data (_tmp40_, "clicked", (GCallback) ____lambda225__gtk_button_clicked, block119_data_ref (_data119_), (GClosureNotify) block119_data_unref, 0);
		_tmp41_ = self->priv->play_btn;
		gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp41_);
	}
	dc_gallery_dialog_add_context_menu_gestures ((DcGalleryCell*) self, _data119_->dialog);
	g_signal_connect_object (_data119_->dialog, "selection-changed", (GCallback) ___lambda226__dc_gallery_dialog_selection_changed, self, 0);
	_g_object_unref0 (text_box);
	block119_data_unref (_data119_);
	_data119_ = NULL;
	return self;
}

static DcGalleryDialogGalleryRow*
dc_gallery_dialog_gallery_row_new (DcGalleryDialog* dialog,
                                   const gchar* tab_key)
{
	return dc_gallery_dialog_gallery_row_construct (DC_GALLERY_DIALOG_TYPE_GALLERY_ROW, dialog, tab_key);
}

static void
___lambda227_ (DcGalleryDialogGalleryRow* self)
{
	dc_gallery_dialog_gallery_row_update_play_icon (self);
}

static void
____lambda227__g_object_notify (GObject* _sender,
                                GParamSpec* pspec,
                                gpointer self)
{
	___lambda227_ ((DcGalleryDialogGalleryRow*) self);
}

static void
___lambda228_ (DcGalleryDialogGalleryRow* self)
{
	dc_gallery_dialog_gallery_row_update_play_icon (self);
}

static void
____lambda228__g_object_notify (GObject* _sender,
                                GParamSpec* pspec,
                                gpointer self)
{
	___lambda228_ ((DcGalleryDialogGalleryRow*) self);
}

static Block120Data*
block120_data_ref (Block120Data* _data120_)
{
	g_atomic_int_inc (&_data120_->_ref_count_);
	return _data120_;
}

static void
block120_data_unref (void * _userdata_)
{
	Block120Data* _data120_;
	_data120_ = (Block120Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data120_->_ref_count_)) {
		DcGalleryDialogGalleryRow* self;
		self = _data120_->self;
		_g_object_unref0 (self);
		g_slice_free (Block120Data, _data120_);
	}
}

static void
____lambda229_ (Block120Data* _data120_,
                GObject* o,
                GAsyncResult* res)
{
	DcGalleryDialogGalleryRow* self;
	GdkTexture* tex = NULL;
	DcGalleryDialog* _tmp0_;
	GdkTexture* _tmp1_;
	gboolean _tmp2_ = FALSE;
	GtkPicture* _tmp4_;
	GdkTexture* _tmp5_;
	self = _data120_->self;
	g_return_if_fail (res != NULL);
	_tmp0_ = self->priv->dialog;
	_tmp1_ = dc_gallery_dialog_load_thumb_finish (_tmp0_, res);
	tex = _tmp1_;
	if (_data120_->gen != self->priv->generation) {
		_tmp2_ = TRUE;
	} else {
		GdkTexture* _tmp3_;
		_tmp3_ = tex;
		_tmp2_ = _tmp3_ == NULL;
	}
	if (_tmp2_) {
		_g_object_unref0 (tex);
		return;
	}
	_tmp4_ = self->priv->thumb;
	_tmp5_ = tex;
	gtk_picture_set_paintable (_tmp4_, (GdkPaintable*) _tmp5_);
	_g_object_unref0 (tex);
}

static void
_____lambda229__gasync_ready_callback (GObject* source_object,
                                       GAsyncResult* res,
                                       gpointer self)
{
	____lambda229_ (self, source_object, res);
	block120_data_unref (self);
}

static void
dc_gallery_dialog_gallery_row_real_bind (DcGalleryCell* base,
                                         DcMessage* m)
{
	DcGalleryDialogGalleryRow * self;
	gint _tmp0_;
	const gchar* _tmp1_ = NULL;
	gboolean _tmp2_;
	gboolean _tmp3_;
	gchar* sender = NULL;
	gchar* _tmp10_;
	gchar* when = NULL;
	gint64 _tmp11_;
	gint64 _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_ = NULL;
	const gchar* _tmp15_;
	gint _tmp16_;
	gint _tmp17_;
	gchar* meta = NULL;
	gchar* _tmp23_;
	const gchar* _tmp24_;
	const gchar* _tmp25_;
	GQuark _tmp27_ = 0U;
	static GQuark _tmp26_label0 = 0;
	static GQuark _tmp26_label1 = 0;
	static GQuark _tmp26_label2 = 0;
	self = (DcGalleryDialogGalleryRow*) base;
	g_return_if_fail (m != NULL);
	dc_gallery_cell_set_msg ((DcGalleryCell*) self, m);
	_tmp0_ = self->priv->generation;
	self->priv->generation = _tmp0_ + 1;
	dc_gallery_dialog_gallery_row_update_selection_visuals (self);
	_tmp2_ = dc_message_get_is_outgoing (m);
	_tmp3_ = _tmp2_;
	if (_tmp3_) {
		_tmp1_ = "You";
	} else {
		const gchar* _tmp4_ = NULL;
		const gchar* _tmp5_;
		const gchar* _tmp6_;
		_tmp5_ = dc_message_get_override_sender_name (m);
		_tmp6_ = _tmp5_;
		_tmp4_ = _tmp6_;
		if (_tmp4_ == NULL) {
			const gchar* _tmp7_ = NULL;
			const gchar* _tmp8_;
			const gchar* _tmp9_;
			_tmp8_ = dc_message_get_sender_name (m);
			_tmp9_ = _tmp8_;
			_tmp7_ = _tmp9_;
			if (_tmp7_ == NULL) {
				_tmp7_ = "";
			}
			_tmp4_ = _tmp7_;
		}
		_tmp1_ = _tmp4_;
	}
	_tmp10_ = g_strdup (_tmp1_);
	sender = _tmp10_;
	_tmp11_ = dc_message_get_timestamp (m);
	_tmp12_ = _tmp11_;
	_tmp13_ = dc_format_date_time (_tmp12_);
	when = _tmp13_;
	_tmp15_ = sender;
	_tmp16_ = strlen (_tmp15_);
	_tmp17_ = _tmp16_;
	if (_tmp17_ > 0) {
		const gchar* _tmp18_;
		const gchar* _tmp19_;
		gchar* _tmp20_;
		_tmp18_ = sender;
		_tmp19_ = when;
		_tmp20_ = g_strdup_printf ("%s · %s", _tmp18_, _tmp19_);
		_g_free0 (_tmp14_);
		_tmp14_ = _tmp20_;
	} else {
		const gchar* _tmp21_;
		gchar* _tmp22_;
		_tmp21_ = when;
		_tmp22_ = g_strdup (_tmp21_);
		_g_free0 (_tmp14_);
		_tmp14_ = _tmp22_;
	}
	_tmp23_ = _tmp14_;
	_tmp14_ = NULL;
	meta = _tmp23_;
	_tmp24_ = self->priv->tab_key;
	_tmp25_ = _tmp24_;
	_tmp27_ = (NULL == _tmp25_) ? 0 : g_quark_from_string (_tmp25_);
	if (_tmp27_ == ((0 != _tmp26_label0) ? _tmp26_label0 : (_tmp26_label0 = g_quark_from_static_string ("audio")))) {
		switch (0) {
			default:
			{
				gboolean _tmp28_ = FALSE;
				const gchar* _tmp29_;
				const gchar* _tmp30_;
				gboolean voice = FALSE;
				const gchar* _tmp35_ = NULL;
				GtkImage* _tmp36_;
				gchar* _tmp37_ = NULL;
				GtkLabel* _tmp40_;
				GtkLabel* _tmp41_;
				const gchar* _tmp42_;
				DcAudioPlayback* playback = NULL;
				DcAudioPlayback* _tmp43_;
				DcAudioPlayback* _tmp44_;
				gulong _tmp45_;
				DcAudioPlayback* _tmp46_;
				gulong _tmp47_;
				GtkButton* _tmp48_;
				gboolean _tmp49_;
				gboolean _tmp50_;
				_tmp29_ = dc_message_get_view_type (m);
				_tmp30_ = _tmp29_;
				if (_tmp30_ != NULL) {
					const gchar* _tmp31_;
					const gchar* _tmp32_;
					gchar* _tmp33_;
					gchar* _tmp34_;
					_tmp31_ = dc_message_get_view_type (m);
					_tmp32_ = _tmp31_;
					_tmp33_ = g_utf8_strdown (_tmp32_, (gssize) -1);
					_tmp34_ = _tmp33_;
					_tmp28_ = g_strcmp0 (_tmp34_, "voice") == 0;
					_g_free0 (_tmp34_);
				} else {
					_tmp28_ = FALSE;
				}
				voice = _tmp28_;
				if (voice) {
					_tmp35_ = "audio-input-microphone-symbolic";
				} else {
					_tmp35_ = "audio-x-generic-symbolic";
				}
				_tmp36_ = self->priv->icon;
				g_object_set (_tmp36_, "icon-name", _tmp35_, NULL);
				if (voice) {
					gchar* _tmp38_;
					_tmp38_ = g_strdup ("Voice message");
					_g_free0 (_tmp37_);
					_tmp37_ = _tmp38_;
				} else {
					gchar* _tmp39_;
					_tmp39_ = dc_message_display_file_name (m, "Audio");
					_g_free0 (_tmp37_);
					_tmp37_ = _tmp39_;
				}
				_tmp40_ = self->priv->title_label;
				gtk_label_set_label (_tmp40_, _tmp37_);
				_tmp41_ = self->priv->subtitle_label;
				_tmp42_ = meta;
				gtk_label_set_label (_tmp41_, _tmp42_);
				_tmp43_ = dc_audio_playback_shared ();
				playback = _tmp43_;
				_tmp44_ = playback;
				_tmp45_ = g_signal_connect_object ((GObject*) _tmp44_, "notify::playing", (GCallback) ____lambda227__g_object_notify, self, 0);
				self->priv->playing_handler = _tmp45_;
				_tmp46_ = playback;
				_tmp47_ = g_signal_connect_object ((GObject*) _tmp46_, "notify::current-message-id", (GCallback) ____lambda228__g_object_notify, self, 0);
				self->priv->current_handler = _tmp47_;
				dc_gallery_dialog_gallery_row_update_play_icon (self);
				_tmp48_ = self->priv->play_btn;
				_tmp49_ = dc_message_get_has_local_file (m);
				_tmp50_ = _tmp49_;
				gtk_widget_set_sensitive ((GtkWidget*) _tmp48_, _tmp50_);
				_g_object_unref0 (playback);
				_g_free0 (_tmp37_);
				break;
			}
		}
	} else if (_tmp27_ == ((0 != _tmp26_label1) ? _tmp26_label1 : (_tmp26_label1 = g_quark_from_static_string ("apps")))) {
		switch (0) {
			default:
			{
				GtkImage* _tmp51_;
				GtkLabel* _tmp52_;
				gchar* _tmp53_;
				gchar* _tmp54_;
				GtkLabel* _tmp55_;
				const gchar* _tmp56_;
				_tmp51_ = self->priv->icon;
				g_object_set (_tmp51_, "icon-name", "application-x-executable-symbolic", NULL);
				_tmp52_ = self->priv->title_label;
				_tmp53_ = dc_gallery_dialog_gallery_row_app_display_name (m);
				_tmp54_ = _tmp53_;
				gtk_label_set_label (_tmp52_, _tmp54_);
				_g_free0 (_tmp54_);
				_tmp55_ = self->priv->subtitle_label;
				_tmp56_ = meta;
				gtk_label_set_label (_tmp55_, _tmp56_);
				break;
			}
		}
	} else if (_tmp27_ == ((0 != _tmp26_label2) ? _tmp26_label2 : (_tmp26_label2 = g_quark_from_static_string ("links")))) {
		switch (0) {
			default:
			{
				const gchar* _tmp57_ = NULL;
				const gchar* _tmp58_;
				const gchar* _tmp59_;
				gchar** links = NULL;
				gint _tmp60_ = 0;
				gchar** _tmp61_;
				gint links_length1;
				gint _links_size_;
				const gchar* _tmp62_ = NULL;
				gchar** _tmp63_;
				gint _tmp63__length1;
				gchar* link = NULL;
				gchar* _tmp66_;
				gchar* _tmp67_ = NULL;
				gchar** _tmp68_;
				gint _tmp68__length1;
				GtkLabel* _tmp74_;
				const gchar* _tmp75_;
				GtkLabel* _tmp76_;
				const gchar* _tmp77_;
				GtkImage* _tmp78_;
				gboolean _tmp79_ = FALSE;
				gboolean _tmp80_;
				gboolean _tmp81_;
				gboolean has_pic = FALSE;
				GtkPicture* _tmp82_;
				GtkPicture* _tmp83_;
				_tmp58_ = dc_message_get_text (m);
				_tmp59_ = _tmp58_;
				_tmp57_ = _tmp59_;
				if (_tmp57_ == NULL) {
					_tmp57_ = "";
				}
				_tmp61_ = dc_link_cleaner_find_urls (_tmp57_, &_tmp60_);
				links = _tmp61_;
				links_length1 = _tmp60_;
				_links_size_ = links_length1;
				_tmp63_ = links;
				_tmp63__length1 = links_length1;
				if (_tmp63__length1 > 0) {
					gchar** _tmp64_;
					gint _tmp64__length1;
					const gchar* _tmp65_;
					_tmp64_ = links;
					_tmp64__length1 = links_length1;
					_tmp65_ = _tmp64_[0];
					_tmp62_ = _tmp65_;
				} else {
					_tmp62_ = "";
				}
				_tmp66_ = g_strdup (_tmp62_);
				link = _tmp66_;
				_tmp68_ = links;
				_tmp68__length1 = links_length1;
				if (_tmp68__length1 > 1) {
					const gchar* _tmp69_;
					gchar** _tmp70_;
					gint _tmp70__length1;
					gchar* _tmp71_;
					_tmp69_ = link;
					_tmp70_ = links;
					_tmp70__length1 = links_length1;
					_tmp71_ = g_strdup_printf ("%s (+%d more)", _tmp69_, _tmp70__length1 - 1);
					_g_free0 (_tmp67_);
					_tmp67_ = _tmp71_;
				} else {
					const gchar* _tmp72_;
					gchar* _tmp73_;
					_tmp72_ = link;
					_tmp73_ = g_strdup (_tmp72_);
					_g_free0 (_tmp67_);
					_tmp67_ = _tmp73_;
				}
				_tmp74_ = self->priv->title_label;
				gtk_label_set_label (_tmp74_, _tmp67_);
				_tmp75_ = link;
				gtk_widget_set_tooltip_text ((GtkWidget*) self, _tmp75_);
				_tmp76_ = self->priv->subtitle_label;
				_tmp77_ = meta;
				gtk_label_set_label (_tmp76_, _tmp77_);
				_tmp78_ = self->priv->icon;
				g_object_set (_tmp78_, "icon-name", "web-browser-symbolic", NULL);
				_tmp80_ = dc_message_get_has_local_file (m);
				_tmp81_ = _tmp80_;
				if (_tmp81_) {
					_tmp79_ = dc_message_is_image_file (m);
				} else {
					_tmp79_ = FALSE;
				}
				has_pic = _tmp79_;
				_tmp82_ = self->priv->thumb;
				gtk_widget_set_visible ((GtkWidget*) _tmp82_, has_pic);
				_tmp83_ = self->priv->thumb;
				gtk_picture_set_paintable (_tmp83_, NULL);
				if (has_pic) {
					Block120Data* _data120_;
					DcGalleryDialog* _tmp84_;
					const gchar* _tmp85_;
					const gchar* _tmp86_;
					_data120_ = g_slice_new0 (Block120Data);
					_data120_->_ref_count_ = 1;
					_data120_->self = g_object_ref (self);
					_data120_->gen = self->priv->generation;
					_tmp84_ = self->priv->dialog;
					_tmp85_ = dc_message_get_file_path (m);
					_tmp86_ = _tmp85_;
					dc_gallery_dialog_load_thumb (_tmp84_, _tmp86_, _____lambda229__gasync_ready_callback, block120_data_ref (_data120_));
					block120_data_unref (_data120_);
					_data120_ = NULL;
				}
				_g_free0 (_tmp67_);
				_g_free0 (link);
				links = (_vala_array_free (links, links_length1, (GDestroyNotify) g_free), NULL);
				break;
			}
		}
	} else {
		switch (0) {
			default:
			{
				GtkImage* _tmp87_;
				GIcon* _tmp88_;
				GIcon* _tmp89_;
				GtkLabel* _tmp90_;
				gchar* _tmp91_;
				gchar* _tmp92_;
				gchar* _tmp93_ = NULL;
				gint _tmp94_;
				gint _tmp95_;
				GtkLabel* _tmp104_;
				_tmp87_ = self->priv->icon;
				_tmp88_ = dc_gallery_dialog_gallery_row_file_type_icon (m);
				_tmp89_ = _tmp88_;
				g_object_set (_tmp87_, "gicon", _tmp89_, NULL);
				_g_object_unref0 (_tmp89_);
				_tmp90_ = self->priv->title_label;
				_tmp91_ = dc_message_display_file_name (m, "file");
				_tmp92_ = _tmp91_;
				gtk_label_set_label (_tmp90_, _tmp92_);
				_g_free0 (_tmp92_);
				_tmp94_ = dc_message_get_file_bytes (m);
				_tmp95_ = _tmp94_;
				if (_tmp95_ > 0) {
					gint _tmp96_;
					gint _tmp97_;
					gchar* _tmp98_;
					gchar* _tmp99_;
					const gchar* _tmp100_;
					gchar* _tmp101_;
					_tmp96_ = dc_message_get_file_bytes (m);
					_tmp97_ = _tmp96_;
					_tmp98_ = g_format_size_full ((guint64) _tmp97_, G_FORMAT_SIZE_DEFAULT);
					_tmp99_ = _tmp98_;
					_tmp100_ = meta;
					_tmp101_ = g_strdup_printf ("%s · %s", _tmp99_, _tmp100_);
					_g_free0 (_tmp93_);
					_tmp93_ = _tmp101_;
					_g_free0 (_tmp99_);
				} else {
					const gchar* _tmp102_;
					gchar* _tmp103_;
					_tmp102_ = meta;
					_tmp103_ = g_strdup (_tmp102_);
					_g_free0 (_tmp93_);
					_tmp93_ = _tmp103_;
				}
				_tmp104_ = self->priv->subtitle_label;
				gtk_label_set_label (_tmp104_, _tmp93_);
				_g_free0 (_tmp93_);
				break;
			}
		}
	}
	_g_free0 (meta);
	_g_free0 (_tmp14_);
	_g_free0 (when);
	_g_free0 (sender);
}

static void
dc_gallery_dialog_gallery_row_real_unbind (DcGalleryCell* base)
{
	DcGalleryDialogGalleryRow * self;
	gint _tmp0_;
	GtkPicture* _tmp1_;
	DcAudioPlayback* playback = NULL;
	DcAudioPlayback* _tmp3_;
	self = (DcGalleryDialogGalleryRow*) base;
	_tmp0_ = self->priv->generation;
	self->priv->generation = _tmp0_ + 1;
	_tmp1_ = self->priv->thumb;
	if (_tmp1_ != NULL) {
		GtkPicture* _tmp2_;
		_tmp2_ = self->priv->thumb;
		gtk_picture_set_paintable (_tmp2_, NULL);
	}
	_tmp3_ = dc_audio_playback_shared ();
	playback = _tmp3_;
	if (self->priv->playing_handler != ((gulong) 0)) {
		DcAudioPlayback* _tmp4_;
		_tmp4_ = playback;
		g_signal_handler_disconnect ((GObject*) _tmp4_, self->priv->playing_handler);
		self->priv->playing_handler = (gulong) 0;
	}
	if (self->priv->current_handler != ((gulong) 0)) {
		DcAudioPlayback* _tmp5_;
		_tmp5_ = playback;
		g_signal_handler_disconnect ((GObject*) _tmp5_, self->priv->current_handler);
		self->priv->current_handler = (gulong) 0;
	}
	dc_gallery_cell_set_msg ((DcGalleryCell*) self, NULL);
	_g_object_unref0 (playback);
}

static void
dc_gallery_dialog_gallery_row_update_selection_visuals (DcGalleryDialogGalleryRow* self)
{
	GtkCheckButton* _tmp0_;
	DcGalleryDialog* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	gboolean _tmp4_ = FALSE;
	DcMessage* _tmp5_;
	DcMessage* _tmp6_;
	GtkCheckButton* _tmp12_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->check;
	_tmp1_ = self->priv->dialog;
	_tmp2_ = dc_gallery_dialog_get_selection_mode (_tmp1_);
	_tmp3_ = _tmp2_;
	gtk_widget_set_visible ((GtkWidget*) _tmp0_, _tmp3_);
	_tmp5_ = dc_gallery_cell_get_msg ((DcGalleryCell*) self);
	_tmp6_ = _tmp5_;
	if (_tmp6_ != NULL) {
		DcGalleryDialog* _tmp7_;
		DcMessage* _tmp8_;
		DcMessage* _tmp9_;
		gint _tmp10_;
		gint _tmp11_;
		_tmp7_ = self->priv->dialog;
		_tmp8_ = dc_gallery_cell_get_msg ((DcGalleryCell*) self);
		_tmp9_ = _tmp8_;
		_tmp10_ = dc_message_get_id (_tmp9_);
		_tmp11_ = _tmp10_;
		_tmp4_ = dc_gallery_dialog_is_selected (_tmp7_, _tmp11_);
	} else {
		_tmp4_ = FALSE;
	}
	_tmp12_ = self->priv->check;
	gtk_check_button_set_active (_tmp12_, _tmp4_);
}

static void
dc_gallery_dialog_gallery_row_update_play_icon (DcGalleryDialogGalleryRow* self)
{
	gboolean _tmp0_ = FALSE;
	GtkButton* _tmp1_;
	DcAudioPlayback* playback = NULL;
	DcAudioPlayback* _tmp4_;
	gboolean _tmp5_ = FALSE;
	DcAudioPlayback* _tmp6_;
	gint _tmp7_;
	gint _tmp8_;
	DcMessage* _tmp9_;
	DcMessage* _tmp10_;
	gint _tmp11_;
	gint _tmp12_;
	gboolean this_playing = FALSE;
	const gchar* _tmp16_ = NULL;
	GtkButton* _tmp17_;
	const gchar* _tmp18_ = NULL;
	GtkButton* _tmp19_;
	g_return_if_fail (self != NULL);
	_tmp1_ = self->priv->play_btn;
	if (_tmp1_ == NULL) {
		_tmp0_ = TRUE;
	} else {
		DcMessage* _tmp2_;
		DcMessage* _tmp3_;
		_tmp2_ = dc_gallery_cell_get_msg ((DcGalleryCell*) self);
		_tmp3_ = _tmp2_;
		_tmp0_ = _tmp3_ == NULL;
	}
	if (_tmp0_) {
		return;
	}
	_tmp4_ = dc_audio_playback_shared ();
	playback = _tmp4_;
	_tmp6_ = playback;
	_tmp7_ = dc_audio_playback_get_current_message_id (_tmp6_);
	_tmp8_ = _tmp7_;
	_tmp9_ = dc_gallery_cell_get_msg ((DcGalleryCell*) self);
	_tmp10_ = _tmp9_;
	_tmp11_ = dc_message_get_id (_tmp10_);
	_tmp12_ = _tmp11_;
	if (_tmp8_ == _tmp12_) {
		DcAudioPlayback* _tmp13_;
		gboolean _tmp14_;
		gboolean _tmp15_;
		_tmp13_ = playback;
		_tmp14_ = dc_audio_playback_get_playing (_tmp13_);
		_tmp15_ = _tmp14_;
		_tmp5_ = _tmp15_;
	} else {
		_tmp5_ = FALSE;
	}
	this_playing = _tmp5_;
	if (this_playing) {
		_tmp16_ = "media-playback-pause-symbolic";
	} else {
		_tmp16_ = "media-playback-start-symbolic";
	}
	_tmp17_ = self->priv->play_btn;
	gtk_button_set_icon_name (_tmp17_, _tmp16_);
	if (this_playing) {
		_tmp18_ = "Pause";
	} else {
		_tmp18_ = "Play";
	}
	_tmp19_ = self->priv->play_btn;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp19_, _tmp18_);
	_g_object_unref0 (playback);
}

static GIcon*
dc_gallery_dialog_gallery_row_file_type_icon (DcMessage* m)
{
	const gchar* _tmp0_ = NULL;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* mime = NULL;
	gchar* _tmp3_;
	gboolean _tmp4_ = FALSE;
	const gchar* _tmp5_;
	gint _tmp6_;
	gint _tmp7_;
	const gchar* _tmp14_;
	gint _tmp15_;
	gint _tmp16_;
	GThemedIcon* _tmp19_;
	GIcon* result;
	g_return_val_if_fail (m != NULL, NULL);
	_tmp1_ = dc_message_get_file_mime (m);
	_tmp2_ = _tmp1_;
	_tmp0_ = _tmp2_;
	if (_tmp0_ == NULL) {
		_tmp0_ = "";
	}
	_tmp3_ = g_strdup (_tmp0_);
	mime = _tmp3_;
	_tmp5_ = mime;
	_tmp6_ = strlen (_tmp5_);
	_tmp7_ = _tmp6_;
	if (_tmp7_ == 0) {
		const gchar* _tmp8_;
		const gchar* _tmp9_;
		_tmp8_ = dc_message_get_file_name (m);
		_tmp9_ = _tmp8_;
		_tmp4_ = _tmp9_ != NULL;
	} else {
		_tmp4_ = FALSE;
	}
	if (_tmp4_) {
		gboolean uncertain = FALSE;
		const gchar* _tmp10_;
		const gchar* _tmp11_;
		gboolean _tmp12_ = FALSE;
		gchar* _tmp13_;
		_tmp10_ = dc_message_get_file_name (m);
		_tmp11_ = _tmp10_;
		_tmp13_ = g_content_type_guess (_tmp11_, NULL, (gsize) 0, &_tmp12_);
		uncertain = _tmp12_;
		_g_free0 (mime);
		mime = _tmp13_;
	}
	_tmp14_ = mime;
	_tmp15_ = strlen (_tmp14_);
	_tmp16_ = _tmp15_;
	if (_tmp16_ > 0) {
		const gchar* _tmp17_;
		GIcon* _tmp18_;
		_tmp17_ = mime;
		_tmp18_ = g_content_type_get_icon (_tmp17_);
		result = _tmp18_;
		_g_free0 (mime);
		return result;
	}
	_tmp19_ = (GThemedIcon*) g_themed_icon_new ("text-x-generic-symbolic");
	result = (GIcon*) _tmp19_;
	_g_free0 (mime);
	return result;
}

static gchar*
string_slice (const gchar* self,
              glong start,
              glong end)
{
	glong string_length = 0L;
	gint _tmp0_;
	gint _tmp1_;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gchar* _tmp4_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	string_length = (glong) _tmp1_;
	if (start < ((glong) 0)) {
		start = string_length + start;
	}
	if (end < ((glong) 0)) {
		end = string_length + end;
	}
	if (start >= ((glong) 0)) {
		_tmp2_ = start <= string_length;
	} else {
		_tmp2_ = FALSE;
	}
	g_return_val_if_fail (_tmp2_, NULL);
	if (end >= ((glong) 0)) {
		_tmp3_ = end <= string_length;
	} else {
		_tmp3_ = FALSE;
	}
	g_return_val_if_fail (_tmp3_, NULL);
	g_return_val_if_fail (start <= end, NULL);
	_tmp4_ = g_strndup (((gchar*) self) + start, (gsize) (end - start));
	result = _tmp4_;
	return result;
}

static gchar*
dc_gallery_dialog_gallery_row_app_display_name (DcMessage* m)
{
	gchar* name = NULL;
	gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gboolean _tmp4_;
	gchar* result;
	g_return_val_if_fail (m != NULL, NULL);
	_tmp0_ = dc_message_display_file_name (m, "App");
	name = _tmp0_;
	_tmp1_ = name;
	_tmp2_ = g_utf8_strdown (_tmp1_, (gssize) -1);
	_tmp3_ = _tmp2_;
	_tmp4_ = g_str_has_suffix (_tmp3_, ".xdc");
	_g_free0 (_tmp3_);
	if (_tmp4_) {
		const gchar* _tmp5_;
		const gchar* _tmp6_;
		gint _tmp7_;
		gint _tmp8_;
		gchar* _tmp9_;
		_tmp5_ = name;
		_tmp6_ = name;
		_tmp7_ = strlen (_tmp6_);
		_tmp8_ = _tmp7_;
		_tmp9_ = string_slice (_tmp5_, (glong) 0, (glong) (_tmp8_ - 4));
		_g_free0 (name);
		name = _tmp9_;
	}
	result = name;
	return result;
}

static DcMessage*
dc_gallery_dialog_gallery_row_real_get_msg (DcGalleryCell* base)
{
	DcMessage* result;
	DcGalleryDialogGalleryRow* self;
	DcMessage* _tmp0_;
	self = (DcGalleryDialogGalleryRow*) base;
	_tmp0_ = self->priv->_msg;
	result = _tmp0_;
	return result;
}

static void
dc_gallery_dialog_gallery_row_real_set_msg (DcGalleryCell* base,
                                            DcMessage* value)
{
	DcGalleryDialogGalleryRow* self;
	DcMessage* old_value;
	self = (DcGalleryDialogGalleryRow*) base;
	old_value = dc_gallery_dialog_gallery_row_real_get_msg (base);
	if (old_value != value) {
		DcMessage* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_msg);
		self->priv->_msg = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, dc_gallery_dialog_gallery_row_properties[DC_GALLERY_DIALOG_GALLERY_ROW_MSG_PROPERTY]);
	}
}

static void
dc_gallery_dialog_gallery_row_class_init (DcGalleryDialogGalleryRowClass * klass,
                                          gpointer klass_data)
{
	dc_gallery_dialog_gallery_row_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DcGalleryDialogGalleryRow_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_dc_gallery_dialog_gallery_row_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_dc_gallery_dialog_gallery_row_set_property;
	G_OBJECT_CLASS (klass)->finalize = dc_gallery_dialog_gallery_row_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DC_GALLERY_DIALOG_GALLERY_ROW_MSG_PROPERTY, dc_gallery_dialog_gallery_row_properties[DC_GALLERY_DIALOG_GALLERY_ROW_MSG_PROPERTY] = g_param_spec_object ("msg", "msg", "msg", DC_TYPE_MESSAGE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
dc_gallery_dialog_gallery_row_dc_gallery_cell_interface_init (DcGalleryCellIface * iface,
                                                              gpointer iface_data)
{
	dc_gallery_dialog_gallery_row_dc_gallery_cell_parent_iface = g_type_interface_peek_parent (iface);
	iface->bind = (void (*) (DcGalleryCell*, DcMessage*)) dc_gallery_dialog_gallery_row_real_bind;
	iface->unbind = (void (*) (DcGalleryCell*)) dc_gallery_dialog_gallery_row_real_unbind;
	iface->get_msg = dc_gallery_dialog_gallery_row_real_get_msg;
	iface->set_msg = dc_gallery_dialog_gallery_row_real_set_msg;
}

static void
dc_gallery_dialog_gallery_row_instance_init (DcGalleryDialogGalleryRow * self,
                                             gpointer klass)
{
	self->priv = dc_gallery_dialog_gallery_row_get_instance_private (self);
	self->priv->play_btn = NULL;
	self->priv->thumb = NULL;
	self->priv->generation = 0;
	self->priv->playing_handler = (gulong) 0;
	self->priv->current_handler = (gulong) 0;
}

static void
dc_gallery_dialog_gallery_row_finalize (GObject * obj)
{
	DcGalleryDialogGalleryRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_GALLERY_DIALOG_TYPE_GALLERY_ROW, DcGalleryDialogGalleryRow);
	_g_object_unref0 (self->priv->_msg);
	_g_free0 (self->priv->tab_key);
	_g_object_unref0 (self->priv->check);
	_g_object_unref0 (self->priv->icon);
	_g_object_unref0 (self->priv->title_label);
	_g_object_unref0 (self->priv->subtitle_label);
	_g_object_unref0 (self->priv->play_btn);
	_g_object_unref0 (self->priv->thumb);
	G_OBJECT_CLASS (dc_gallery_dialog_gallery_row_parent_class)->finalize (obj);
}

static GType
dc_gallery_dialog_gallery_row_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DcGalleryDialogGalleryRowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_gallery_dialog_gallery_row_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcGalleryDialogGalleryRow), 0, (GInstanceInitFunc) dc_gallery_dialog_gallery_row_instance_init, NULL };
	static const GInterfaceInfo dc_gallery_cell_info = { (GInterfaceInitFunc) dc_gallery_dialog_gallery_row_dc_gallery_cell_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType dc_gallery_dialog_gallery_row_type_id;
	dc_gallery_dialog_gallery_row_type_id = g_type_register_static (gtk_box_get_type (), "DcGalleryDialogGalleryRow", &g_define_type_info, 0);
	g_type_add_interface_static (dc_gallery_dialog_gallery_row_type_id, DC_TYPE_GALLERY_CELL, &dc_gallery_cell_info);
	DcGalleryDialogGalleryRow_private_offset = g_type_add_instance_private (dc_gallery_dialog_gallery_row_type_id, sizeof (DcGalleryDialogGalleryRowPrivate));
	return dc_gallery_dialog_gallery_row_type_id;
}

static GType
dc_gallery_dialog_gallery_row_get_type (void)
{
	static volatile gsize dc_gallery_dialog_gallery_row_type_id__once = 0;
	if (g_once_init_enter (&dc_gallery_dialog_gallery_row_type_id__once)) {
		GType dc_gallery_dialog_gallery_row_type_id;
		dc_gallery_dialog_gallery_row_type_id = dc_gallery_dialog_gallery_row_get_type_once ();
		g_once_init_leave (&dc_gallery_dialog_gallery_row_type_id__once, dc_gallery_dialog_gallery_row_type_id);
	}
	return dc_gallery_dialog_gallery_row_type_id__once;
}

static void
_vala_dc_gallery_dialog_gallery_row_get_property (GObject * object,
                                                  guint property_id,
                                                  GValue * value,
                                                  GParamSpec * pspec)
{
	DcGalleryDialogGalleryRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DC_GALLERY_DIALOG_TYPE_GALLERY_ROW, DcGalleryDialogGalleryRow);
	switch (property_id) {
		case DC_GALLERY_DIALOG_GALLERY_ROW_MSG_PROPERTY:
		g_value_set_object (value, dc_gallery_cell_get_msg ((DcGalleryCell*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_dc_gallery_dialog_gallery_row_set_property (GObject * object,
                                                  guint property_id,
                                                  const GValue * value,
                                                  GParamSpec * pspec)
{
	DcGalleryDialogGalleryRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DC_GALLERY_DIALOG_TYPE_GALLERY_ROW, DcGalleryDialogGalleryRow);
	switch (property_id) {
		case DC_GALLERY_DIALOG_GALLERY_ROW_MSG_PROPERTY:
		dc_gallery_cell_set_msg ((DcGalleryCell*) self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
dc_gallery_dialog_class_init (DcGalleryDialogClass * klass,
                              gpointer klass_data)
{
	dc_gallery_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DcGalleryDialog_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_dc_gallery_dialog_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_dc_gallery_dialog_set_property;
	G_OBJECT_CLASS (klass)->finalize = dc_gallery_dialog_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DC_GALLERY_DIALOG_SELECTION_MODE_PROPERTY, dc_gallery_dialog_properties[DC_GALLERY_DIALOG_SELECTION_MODE_PROPERTY] = g_param_spec_boolean ("selection-mode", "selection-mode", "selection-mode", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	dc_gallery_dialog_signals[DC_GALLERY_DIALOG_SELECTION_CHANGED_SIGNAL] = g_signal_new ("selection-changed", DC_TYPE_GALLERY_DIALOG, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
dc_gallery_dialog_instance_init (DcGalleryDialog * self,
                                 gpointer klass)
{
	GHashFunc _tmp0_;
	GEqualFunc _tmp1_;
	GHashTable* _tmp2_;
	DcGalleryDialogGalleryTab** _tmp3_;
	GtkGridView** _tmp4_;
	GHashFunc _tmp5_;
	GEqualFunc _tmp6_;
	GHashTable* _tmp7_;
	self->priv = dc_gallery_dialog_get_instance_private (self);
	self->presenter_dialog = NULL;
	self->priv->_selection_mode = FALSE;
	_tmp0_ = g_direct_hash;
	_tmp1_ = g_direct_equal;
	_tmp2_ = g_hash_table_new_full (_tmp0_, _tmp1_, NULL, NULL);
	self->priv->selected_ids = _tmp2_;
	_tmp3_ = g_new0 (DcGalleryDialogGalleryTab*, 0 + 1);
	self->priv->tabs = _tmp3_;
	self->priv->tabs_length1 = 0;
	self->priv->_tabs_size_ = self->priv->tabs_length1;
	_tmp4_ = g_new0 (GtkGridView*, 0 + 1);
	self->priv->media_grids = _tmp4_;
	self->priv->media_grids_length1 = 0;
	self->priv->_media_grids_size_ = self->priv->media_grids_length1;
	self->priv->is_open = TRUE;
	_tmp5_ = g_str_hash;
	_tmp6_ = g_str_equal;
	_tmp7_ = g_hash_table_new_full (_tmp5_, _tmp6_, _g_free0_, _g_object_unref0_);
	self->priv->thumb_cache = _tmp7_;
	self->priv->thumb_pool = NULL;
	self->priv->playback_was_started = FALSE;
}

static void
dc_gallery_dialog_finalize (GObject * obj)
{
	DcGalleryDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_TYPE_GALLERY_DIALOG, DcGalleryDialog);
	_g_object_unref0 (self->priv->view_stack);
	_g_object_unref0 (self->priv->toasts);
	_g_object_unref0 (self->priv->save_all_btn);
	_g_object_unref0 (self->priv->more_btn);
	_g_object_unref0 (self->priv->section_action);
	_g_object_unref0 (self->priv->viewer);
	_g_object_unref0 (self->priv->player);
	_g_object_unref0 (self->priv->switcher_bar);
	_g_object_unref0 (self->priv->selection_bar);
	_g_object_unref0 (self->priv->selection_revealer);
	_g_object_unref0 (self->priv->selection_label);
	_g_object_unref0 (self->priv->forward_sel_btn);
	_g_object_unref0 (self->priv->save_sel_btn);
	_g_object_unref0 (self->priv->delete_sel_btn);
	_g_hash_table_unref0 (self->priv->selected_ids);
	self->priv->tabs = (_vala_array_free (self->priv->tabs, self->priv->tabs_length1, (GDestroyNotify) g_object_unref), NULL);
	self->priv->media_grids = (_vala_array_free (self->priv->media_grids, self->priv->media_grids_length1, (GDestroyNotify) g_object_unref), NULL);
	_g_hash_table_unref0 (self->priv->thumb_cache);
	_g_thread_pool_free0 (self->priv->thumb_pool);
	G_OBJECT_CLASS (dc_gallery_dialog_parent_class)->finalize (obj);
}

/**
     * Per-chat media overview mirroring the official Delta Chat gallery:
     * tabs for Apps, Images, Video, Audio and Files. Message ids come from
     * the get_chat_media JSON-RPC call — a metadata-only database query,
     * so nothing is downloaded to build the lists. Core returns the ids
     * oldest first; we display newest first like the official client.
     *
     * Images and videos open in the same fullscreen viewers used by the
     * conversation (ImageViewer / VideoPlayer), overlaid on the dialog.
     */
static GType
dc_gallery_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DcGalleryDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_gallery_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcGalleryDialog), 0, (GInstanceInitFunc) dc_gallery_dialog_instance_init, NULL };
	GType dc_gallery_dialog_type_id;
	dc_gallery_dialog_type_id = g_type_register_static (adw_dialog_get_type (), "DcGalleryDialog", &g_define_type_info, 0);
	DcGalleryDialog_private_offset = g_type_add_instance_private (dc_gallery_dialog_type_id, sizeof (DcGalleryDialogPrivate));
	return dc_gallery_dialog_type_id;
}

GType
dc_gallery_dialog_get_type (void)
{
	static volatile gsize dc_gallery_dialog_type_id__once = 0;
	if (g_once_init_enter (&dc_gallery_dialog_type_id__once)) {
		GType dc_gallery_dialog_type_id;
		dc_gallery_dialog_type_id = dc_gallery_dialog_get_type_once ();
		g_once_init_leave (&dc_gallery_dialog_type_id__once, dc_gallery_dialog_type_id);
	}
	return dc_gallery_dialog_type_id__once;
}

static void
_vala_dc_gallery_dialog_get_property (GObject * object,
                                      guint property_id,
                                      GValue * value,
                                      GParamSpec * pspec)
{
	DcGalleryDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DC_TYPE_GALLERY_DIALOG, DcGalleryDialog);
	switch (property_id) {
		case DC_GALLERY_DIALOG_SELECTION_MODE_PROPERTY:
		g_value_set_boolean (value, dc_gallery_dialog_get_selection_mode (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_dc_gallery_dialog_set_property (GObject * object,
                                      guint property_id,
                                      const GValue * value,
                                      GParamSpec * pspec)
{
	DcGalleryDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DC_TYPE_GALLERY_DIALOG, DcGalleryDialog);
	switch (property_id) {
		case DC_GALLERY_DIALOG_SELECTION_MODE_PROPERTY:
		dc_gallery_dialog_set_selection_mode (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

