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

/*
 * SPDX-License-Identifier: LGPL-3.0-or-later
 * SPDX-FileCopyrightText: 2011-2025 elementary, Inc. (https://elementary.io)
 */

#include <adwaita.h>
#include <glib-object.h>
#include <granite-7.h>
#include <gtk/gtk.h>
#include <glib.h>
#include <gio/gio.h>
#include <vte/vte.h>
#include <stdlib.h>
#include <string.h>
#include <gee.h>
#include <glib/gi18n-lib.h>
#include <pango/pango.h>
#include <gdk/gdk.h>
#include <float.h>
#include <math.h>

#define TERMINAL_MAIN_WINDOW_ACTION_PREFIX "win."
#define TERMINAL_MAIN_WINDOW_ACTION_CLOSE_TAB "action-close-tab"
#define TERMINAL_MAIN_WINDOW_ACTION_CLOSE_TABS_TO_RIGHT "action_close_tabs_to_right"
#define TERMINAL_MAIN_WINDOW_ACTION_CLOSE_OTHER_TABS "action_close_other_tabs"
#define TERMINAL_MAIN_WINDOW_ACTION_FULLSCREEN "action-fullscreen"
#define TERMINAL_MAIN_WINDOW_ACTION_NEW_TAB "action-term_widgetnew-tab"
#define TERMINAL_MAIN_WINDOW_ACTION_NEW_TAB_AT "action-new-tab-at"
#define TERMINAL_MAIN_WINDOW_ACTION_TAB_ACTIVE_SHELL "action-tab_active_shell"
#define TERMINAL_MAIN_WINDOW_ACTION_TAB_RELOAD "action-tab_reload"
#define TERMINAL_MAIN_WINDOW_ACTION_RESTORE_CLOSED_TAB "action-restore-closed-tab"
#define TERMINAL_MAIN_WINDOW_ACTION_DUPLICATE_TAB "action-duplicate-tab"
#define TERMINAL_MAIN_WINDOW_ACTION_NEXT_TAB "action-next-tab"
#define TERMINAL_MAIN_WINDOW_ACTION_PREVIOUS_TAB "action-previous-tab"
#define TERMINAL_MAIN_WINDOW_ACTION_MOVE_TAB_RIGHT "action-move-tab-right"
#define TERMINAL_MAIN_WINDOW_ACTION_MOVE_TAB_LEFT "action-move-tab-left"
#define TERMINAL_MAIN_WINDOW_ACTION_MOVE_TAB_TO_NEW_WINDOW "action-move-tab-to-new-window"
#define TERMINAL_MAIN_WINDOW_ACTION_SEARCH "action-search"
#define TERMINAL_MAIN_WINDOW_ACTION_SEARCH_NEXT "action-search-next"
#define TERMINAL_MAIN_WINDOW_ACTION_SEARCH_PREVIOUS "action-search-previous"
#define TERMINAL_TERMINAL_WIDGET_MIN_SCALE 0.25
#define TERMINAL_TERMINAL_WIDGET_MAX_SCALE 4.0
#define TERMINAL_TERMINAL_WIDGET_DEFAULT_LABEL _ ("Terminal")
#define TERMINAL_APPLICATION_MINIMUM_WIDTH 600
#define TERMINAL_APPLICATION_MINIMUM_HEIGHT 400
#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 TERMINAL_TYPE_MAIN_WINDOW (terminal_main_window_get_type ())
#define TERMINAL_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TERMINAL_TYPE_MAIN_WINDOW, TerminalMainWindow))
#define TERMINAL_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TERMINAL_TYPE_MAIN_WINDOW, TerminalMainWindowClass))
#define TERMINAL_IS_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TERMINAL_TYPE_MAIN_WINDOW))
#define TERMINAL_IS_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TERMINAL_TYPE_MAIN_WINDOW))
#define TERMINAL_MAIN_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TERMINAL_TYPE_MAIN_WINDOW, TerminalMainWindowClass))

typedef struct _TerminalMainWindow TerminalMainWindow;
typedef struct _TerminalMainWindowClass TerminalMainWindowClass;
typedef struct _TerminalMainWindowPrivate TerminalMainWindowPrivate;

#define TERMINAL_WIDGETS_TYPE_SEARCH_TOOLBAR (terminal_widgets_search_toolbar_get_type ())
#define TERMINAL_WIDGETS_SEARCH_TOOLBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TERMINAL_WIDGETS_TYPE_SEARCH_TOOLBAR, TerminalWidgetsSearchToolbar))
#define TERMINAL_WIDGETS_SEARCH_TOOLBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TERMINAL_WIDGETS_TYPE_SEARCH_TOOLBAR, TerminalWidgetsSearchToolbarClass))
#define TERMINAL_WIDGETS_IS_SEARCH_TOOLBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TERMINAL_WIDGETS_TYPE_SEARCH_TOOLBAR))
#define TERMINAL_WIDGETS_IS_SEARCH_TOOLBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TERMINAL_WIDGETS_TYPE_SEARCH_TOOLBAR))
#define TERMINAL_WIDGETS_SEARCH_TOOLBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TERMINAL_WIDGETS_TYPE_SEARCH_TOOLBAR, TerminalWidgetsSearchToolbarClass))

typedef struct _TerminalWidgetsSearchToolbar TerminalWidgetsSearchToolbar;
typedef struct _TerminalWidgetsSearchToolbarClass TerminalWidgetsSearchToolbarClass;

#define TERMINAL_DIALOGS_TYPE_COLOR_PREFERENCES (terminal_dialogs_color_preferences_get_type ())
#define TERMINAL_DIALOGS_COLOR_PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TERMINAL_DIALOGS_TYPE_COLOR_PREFERENCES, TerminalDialogsColorPreferences))
#define TERMINAL_DIALOGS_COLOR_PREFERENCES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TERMINAL_DIALOGS_TYPE_COLOR_PREFERENCES, TerminalDialogsColorPreferencesClass))
#define TERMINAL_DIALOGS_IS_COLOR_PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TERMINAL_DIALOGS_TYPE_COLOR_PREFERENCES))
#define TERMINAL_DIALOGS_IS_COLOR_PREFERENCES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TERMINAL_DIALOGS_TYPE_COLOR_PREFERENCES))
#define TERMINAL_DIALOGS_COLOR_PREFERENCES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TERMINAL_DIALOGS_TYPE_COLOR_PREFERENCES, TerminalDialogsColorPreferencesClass))

typedef struct _TerminalDialogsColorPreferences TerminalDialogsColorPreferences;
typedef struct _TerminalDialogsColorPreferencesClass TerminalDialogsColorPreferencesClass;

#define TERMINAL_TYPE_APPLICATION (terminal_application_get_type ())
#define TERMINAL_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TERMINAL_TYPE_APPLICATION, TerminalApplication))
#define TERMINAL_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TERMINAL_TYPE_APPLICATION, TerminalApplicationClass))
#define TERMINAL_IS_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TERMINAL_TYPE_APPLICATION))
#define TERMINAL_IS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TERMINAL_TYPE_APPLICATION))
#define TERMINAL_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TERMINAL_TYPE_APPLICATION, TerminalApplicationClass))

typedef struct _TerminalApplication TerminalApplication;
typedef struct _TerminalApplicationClass TerminalApplicationClass;

#define TERMINAL_TYPE_TERMINAL_VIEW (terminal_terminal_view_get_type ())
#define TERMINAL_TERMINAL_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TERMINAL_TYPE_TERMINAL_VIEW, TerminalTerminalView))
#define TERMINAL_TERMINAL_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TERMINAL_TYPE_TERMINAL_VIEW, TerminalTerminalViewClass))
#define TERMINAL_IS_TERMINAL_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TERMINAL_TYPE_TERMINAL_VIEW))
#define TERMINAL_IS_TERMINAL_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TERMINAL_TYPE_TERMINAL_VIEW))
#define TERMINAL_TERMINAL_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TERMINAL_TYPE_TERMINAL_VIEW, TerminalTerminalViewClass))

typedef struct _TerminalTerminalView TerminalTerminalView;
typedef struct _TerminalTerminalViewClass TerminalTerminalViewClass;

#define TERMINAL_TYPE_TERMINAL_WIDGET (terminal_terminal_widget_get_type ())
#define TERMINAL_TERMINAL_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TERMINAL_TYPE_TERMINAL_WIDGET, TerminalTerminalWidget))
#define TERMINAL_TERMINAL_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TERMINAL_TYPE_TERMINAL_WIDGET, TerminalTerminalWidgetClass))
#define TERMINAL_IS_TERMINAL_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TERMINAL_TYPE_TERMINAL_WIDGET))
#define TERMINAL_IS_TERMINAL_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TERMINAL_TYPE_TERMINAL_WIDGET))
#define TERMINAL_TERMINAL_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TERMINAL_TYPE_TERMINAL_WIDGET, TerminalTerminalWidgetClass))

typedef struct _TerminalTerminalWidget TerminalTerminalWidget;
typedef struct _TerminalTerminalWidgetClass TerminalTerminalWidgetClass;
enum  {
	TERMINAL_MAIN_WINDOW_0_PROPERTY,
	TERMINAL_MAIN_WINDOW_RECREATE_TABS_PROPERTY,
	TERMINAL_MAIN_WINDOW_APP_PROPERTY,
	TERMINAL_MAIN_WINDOW_ACTIONS_PROPERTY,
	TERMINAL_MAIN_WINDOW_NOTEBOOK_PROPERTY,
	TERMINAL_MAIN_WINDOW_CURRENT_TERMINAL_PROPERTY,
	TERMINAL_MAIN_WINDOW_NUM_PROPERTIES
};
static GParamSpec* terminal_main_window_properties[TERMINAL_MAIN_WINDOW_NUM_PROPERTIES];
typedef void (*GSimpleActionActivateCallback) (GSimpleAction* action, GVariant* parameter, gpointer user_data);
typedef void (*GSimpleActionChangeStateCallback) (GSimpleAction* action, GVariant* value, gpointer user_data);
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

#define TERMINAL_TYPE_SETTINGS_POPOVER (terminal_settings_popover_get_type ())
#define TERMINAL_SETTINGS_POPOVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TERMINAL_TYPE_SETTINGS_POPOVER, TerminalSettingsPopover))
#define TERMINAL_SETTINGS_POPOVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TERMINAL_TYPE_SETTINGS_POPOVER, TerminalSettingsPopoverClass))
#define TERMINAL_IS_SETTINGS_POPOVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TERMINAL_TYPE_SETTINGS_POPOVER))
#define TERMINAL_IS_SETTINGS_POPOVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TERMINAL_TYPE_SETTINGS_POPOVER))
#define TERMINAL_SETTINGS_POPOVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TERMINAL_TYPE_SETTINGS_POPOVER, TerminalSettingsPopoverClass))

typedef struct _TerminalSettingsPopover TerminalSettingsPopover;
typedef struct _TerminalSettingsPopoverClass TerminalSettingsPopoverClass;
typedef void (*TerminalTerminalWidgetConfirmedActionCallback) (gboolean confirmed, gpointer user_data);
typedef struct _Block13Data Block13Data;
typedef struct _TerminalTerminalWidgetPrivate TerminalTerminalWidgetPrivate;
typedef enum  {
	TERMINAL_TERMINAL_WIDGET_TAB_STATE_NONE,
	TERMINAL_TERMINAL_WIDGET_TAB_STATE_WORKING,
	TERMINAL_TERMINAL_WIDGET_TAB_STATE_COMPLETED,
	TERMINAL_TERMINAL_WIDGET_TAB_STATE_ERROR,
	TERMINAL_TERMINAL_WIDGET_TAB_STATE_ATTENTION
} TerminalTerminalWidgetTabState;

#define TERMINAL_TERMINAL_WIDGET_TYPE_TAB_STATE (terminal_terminal_widget_tab_state_get_type ())
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _TerminalMainWindow {
	AdwWindow parent_instance;
	TerminalMainWindowPrivate * priv;
};

struct _TerminalMainWindowClass {
	AdwWindowClass parent_class;
};

struct _TerminalMainWindowPrivate {
	AdwHeaderBar* header;
	TerminalWidgetsSearchToolbar* search_toolbar;
	GtkButton* unfullscreen_button;
	GtkLabel* title_label;
	GtkStack* title_stack;
	GtkToggleButton* search_button;
	TerminalDialogsColorPreferences* color_preferences_dialog;
	guint focus_timeout;
	gboolean _recreate_tabs;
	TerminalApplication* _app;
	GSimpleActionGroup* _actions;
	TerminalTerminalView* _notebook;
	TerminalTerminalWidget* _current_terminal;
	AdwTabPage* tab_to_close;
	TerminalTerminalWidget* term_to_close;
	gboolean close_immediately;
};

struct _Block13Data {
	int _ref_count_;
	TerminalMainWindow* self;
	TerminalTerminalWidget* term;
};

struct _TerminalTerminalWidget {
	VteTerminal parent_instance;
	TerminalTerminalWidgetPrivate * priv;
	gchar* terminal_id;
	AdwTabPage* tab;
};

struct _TerminalTerminalWidgetClass {
	VteTerminalClass parent_class;
};

static gint TerminalMainWindow_private_offset;
static gpointer terminal_main_window_parent_class = NULL;
static GeeMultiMap* terminal_main_window_action_accelerators;
static GeeMultiMap* terminal_main_window_action_accelerators = NULL;
VALA_EXTERN GSettings* terminal_application_saved_state;
VALA_EXTERN GSettings* terminal_application_settings;

VALA_EXTERN GType terminal_main_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TerminalMainWindow, g_object_unref)
VALA_EXTERN GType terminal_widgets_search_toolbar_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TerminalWidgetsSearchToolbar, g_object_unref)
VALA_EXTERN GType terminal_dialogs_color_preferences_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TerminalDialogsColorPreferences, g_object_unref)
VALA_EXTERN GType terminal_application_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TerminalApplication, g_object_unref)
VALA_EXTERN GType terminal_terminal_view_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TerminalTerminalView, g_object_unref)
VALA_EXTERN GType terminal_terminal_widget_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TerminalTerminalWidget, g_object_unref)
static void terminal_main_window_action_close_tab (TerminalMainWindow* self);
static void _terminal_main_window_action_close_tab_gsimple_action_activate_callback (GSimpleAction* action,
                                                                              GVariant* parameter,
                                                                              gpointer self);
static void terminal_main_window_action_close_tabs_to_right (TerminalMainWindow* self);
static void _terminal_main_window_action_close_tabs_to_right_gsimple_action_activate_callback (GSimpleAction* action,
                                                                                        GVariant* parameter,
                                                                                        gpointer self);
static void terminal_main_window_action_close_other_tabs (TerminalMainWindow* self);
static void _terminal_main_window_action_close_other_tabs_gsimple_action_activate_callback (GSimpleAction* action,
                                                                                     GVariant* parameter,
                                                                                     gpointer self);
static void terminal_main_window_action_fullscreen (TerminalMainWindow* self);
static void _terminal_main_window_action_fullscreen_gsimple_action_activate_callback (GSimpleAction* action,
                                                                               GVariant* parameter,
                                                                               gpointer self);
static void terminal_main_window_action_new_tab (TerminalMainWindow* self);
static void _terminal_main_window_action_new_tab_gsimple_action_activate_callback (GSimpleAction* action,
                                                                            GVariant* parameter,
                                                                            gpointer self);
static void terminal_main_window_action_new_tab_at (TerminalMainWindow* self,
                                             GSimpleAction* action,
                                             GVariant* param);
static void _terminal_main_window_action_new_tab_at_gsimple_action_activate_callback (GSimpleAction* action,
                                                                               GVariant* parameter,
                                                                               gpointer self);
static void terminal_main_window_action_tab_reload (TerminalMainWindow* self);
static void _terminal_main_window_action_tab_reload_gsimple_action_activate_callback (GSimpleAction* action,
                                                                               GVariant* parameter,
                                                                               gpointer self);
static void terminal_main_window_action_tab_active_shell (TerminalMainWindow* self,
                                                   GSimpleAction* action,
                                                   GVariant* param);
static void _terminal_main_window_action_tab_active_shell_gsimple_action_activate_callback (GSimpleAction* action,
                                                                                     GVariant* parameter,
                                                                                     gpointer self);
static void terminal_main_window_action_restore_closed_tab (TerminalMainWindow* self,
                                                     GSimpleAction* action,
                                                     GVariant* param);
static void _terminal_main_window_action_restore_closed_tab_gsimple_action_activate_callback (GSimpleAction* action,
                                                                                       GVariant* parameter,
                                                                                       gpointer self);
static void terminal_main_window_action_duplicate_tab (TerminalMainWindow* self);
static void _terminal_main_window_action_duplicate_tab_gsimple_action_activate_callback (GSimpleAction* action,
                                                                                  GVariant* parameter,
                                                                                  gpointer self);
static void terminal_main_window_action_next_tab (TerminalMainWindow* self);
static void _terminal_main_window_action_next_tab_gsimple_action_activate_callback (GSimpleAction* action,
                                                                             GVariant* parameter,
                                                                             gpointer self);
static void terminal_main_window_action_previous_tab (TerminalMainWindow* self);
static void _terminal_main_window_action_previous_tab_gsimple_action_activate_callback (GSimpleAction* action,
                                                                                 GVariant* parameter,
                                                                                 gpointer self);
static void terminal_main_window_action_move_tab_right (TerminalMainWindow* self);
static void _terminal_main_window_action_move_tab_right_gsimple_action_activate_callback (GSimpleAction* action,
                                                                                   GVariant* parameter,
                                                                                   gpointer self);
static void terminal_main_window_action_move_tab_left (TerminalMainWindow* self);
static void _terminal_main_window_action_move_tab_left_gsimple_action_activate_callback (GSimpleAction* action,
                                                                                  GVariant* parameter,
                                                                                  gpointer self);
static void terminal_main_window_action_move_tab_to_new_window (TerminalMainWindow* self);
static void _terminal_main_window_action_move_tab_to_new_window_gsimple_action_activate_callback (GSimpleAction* action,
                                                                                           GVariant* parameter,
                                                                                           gpointer self);
static void terminal_main_window_action_search (TerminalMainWindow* self);
static void _terminal_main_window_action_search_gsimple_action_activate_callback (GSimpleAction* action,
                                                                           GVariant* parameter,
                                                                           gpointer self);
static void terminal_main_window_action_search_change_state (TerminalMainWindow* self,
                                                      GSimpleAction* search_action,
                                                      GVariant* value);
static void _terminal_main_window_action_search_change_state_gsimple_action_change_state_callback (GSimpleAction* action,
                                                                                            GVariant* value,
                                                                                            gpointer self);
static void terminal_main_window_action_search_next (TerminalMainWindow* self);
static void _terminal_main_window_action_search_next_gsimple_action_activate_callback (GSimpleAction* action,
                                                                                GVariant* parameter,
                                                                                gpointer self);
static void terminal_main_window_action_search_previous (TerminalMainWindow* self);
static void _terminal_main_window_action_search_previous_gsimple_action_activate_callback (GSimpleAction* action,
                                                                                    GVariant* parameter,
                                                                                    gpointer self);
VALA_EXTERN TerminalMainWindow* terminal_main_window_new (TerminalApplication* app,
                                              gboolean recreate_tabs);
VALA_EXTERN TerminalMainWindow* terminal_main_window_construct (GType object_type,
                                                    TerminalApplication* app,
                                                    gboolean recreate_tabs);
VALA_EXTERN void terminal_main_window_add_tab_with_working_directory (TerminalMainWindow* self,
                                                          const gchar* directory,
                                                          const gchar* command,
                                                          gboolean create_new_tab);
VALA_EXTERN TerminalTerminalView* terminal_main_window_get_notebook (TerminalMainWindow* self);
VALA_EXTERN gint terminal_terminal_view_get_n_pages (TerminalTerminalView* self);
VALA_EXTERN TerminalTerminalWidget* terminal_terminal_view_add_new_tab (TerminalTerminalView* self,
                                                            const gchar* location,
                                                            const gchar* program,
                                                            gint pos);
VALA_EXTERN AdwTabView* terminal_terminal_view_get_tab_view (TerminalTerminalView* self);
static TerminalTerminalWidget* terminal_main_window_get_term_widget (AdwTabPage* tab);
VALA_EXTERN gchar* terminal_terminal_widget_get_shell_location (TerminalTerminalWidget* self);
VALA_EXTERN void terminal_terminal_view_set_selected_page (TerminalTerminalView* self,
                                               AdwTabPage* value);
static void terminal_main_window_setup_ui (TerminalMainWindow* self);
VALA_EXTERN TerminalSettingsPopover* terminal_settings_popover_new (void);
VALA_EXTERN TerminalSettingsPopover* terminal_settings_popover_construct (GType object_type);
VALA_EXTERN GType terminal_settings_popover_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TerminalSettingsPopover, g_object_unref)
VALA_EXTERN TerminalWidgetsSearchToolbar* terminal_widgets_search_toolbar_new (TerminalMainWindow* window);
VALA_EXTERN TerminalWidgetsSearchToolbar* terminal_widgets_search_toolbar_construct (GType object_type,
                                                                         TerminalMainWindow* window);
VALA_EXTERN TerminalTerminalView* terminal_terminal_view_new (TerminalMainWindow* window);
VALA_EXTERN TerminalTerminalView* terminal_terminal_view_construct (GType object_type,
                                                        TerminalMainWindow* window);
static void terminal_main_window_set_notebook (TerminalMainWindow* self,
                                        TerminalTerminalView* value);
static void terminal_main_window_on_tab_added (TerminalMainWindow* self,
                                        AdwTabPage* tab,
                                        gint pos);
static void _terminal_main_window_on_tab_added_adw_tab_view_page_attached (AdwTabView* _sender,
                                                                    AdwTabPage* page,
                                                                    gint position,
                                                                    gpointer self);
static void terminal_main_window_on_tab_removed (TerminalMainWindow* self,
                                          AdwTabPage* tab);
static void _terminal_main_window_on_tab_removed_adw_tab_view_page_detached (AdwTabView* _sender,
                                                                      AdwTabPage* page,
                                                                      gint position,
                                                                      gpointer self);
static void terminal_main_window_on_tab_reordered (TerminalMainWindow* self,
                                            AdwTabPage* tab,
                                            gint new_pos);
static void _terminal_main_window_on_tab_reordered_adw_tab_view_page_reordered (AdwTabView* _sender,
                                                                         AdwTabPage* page,
                                                                         gint position,
                                                                         gpointer self);
static AdwTabView* terminal_main_window_on_create_window_request (TerminalMainWindow* self);
static AdwTabView* _terminal_main_window_on_create_window_request_adw_tab_view_create_window (AdwTabView* _sender,
                                                                                       gpointer self);
static gboolean __lambda31_ (TerminalMainWindow* self,
                      AdwTabPage* tab);
VALA_EXTERN void terminal_terminal_widget_confirm_kill_fg_process (TerminalTerminalWidget* self,
                                                       const gchar* primary_text,
                                                       const gchar* button_label,
                                                       TerminalTerminalWidgetConfirmedActionCallback cb,
                                                       gpointer cb_target);
static void ___lambda32_ (TerminalMainWindow* self,
                   gboolean confirmed);
VALA_EXTERN void terminal_terminal_widget_kill_fg (TerminalTerminalWidget* self);
static void terminal_main_window_terminate_and_disconnect (TerminalMainWindow* self,
                                                    TerminalTerminalWidget* term,
                                                    gboolean make_restorable_required);
static void ____lambda32__terminal_terminal_widget_confirmed_action_callback (gboolean confirmed,
                                                                       gpointer self);
static gboolean ___lambda31__adw_tab_view_close_page (AdwTabView* _sender,
                                               AdwTabPage* page,
                                               gpointer self);
static void __lambda33_ (TerminalMainWindow* self);
static Block13Data* block13_data_ref (Block13Data* _data13_);
static void block13_data_unref (void * _userdata_);
static void terminal_main_window_set_current_terminal (TerminalMainWindow* self,
                                                TerminalTerminalWidget* value);
static gboolean __lambda34_ (Block13Data* _data13_);
static void terminal_main_window_set_title_label (TerminalMainWindow* self);
static gboolean ___lambda34__gsource_func (gpointer self);
VALA_EXTERN GType terminal_terminal_widget_tab_state_get_type (void) G_GNUC_CONST ;
VALA_EXTERN TerminalTerminalWidgetTabState terminal_terminal_widget_get_tab_state (TerminalTerminalWidget* self);
VALA_EXTERN void terminal_terminal_widget_set_tab_state (TerminalTerminalWidget* self,
                                             TerminalTerminalWidgetTabState value);
static void ___lambda33__g_object_notify (GObject* _sender,
                                   GParamSpec* pspec,
                                   gpointer self);
VALA_EXTERN AdwTabBar* terminal_terminal_view_get_tab_bar (TerminalTerminalView* self);
static void __lambda35_ (TerminalMainWindow* self);
VALA_EXTERN TerminalDialogsColorPreferences* terminal_dialogs_color_preferences_new (GtkWindow* parent);
VALA_EXTERN TerminalDialogsColorPreferences* terminal_dialogs_color_preferences_construct (GType object_type,
                                                                               GtkWindow* parent);
static void ___lambda35__terminal_settings_popover_show_theme_editor (TerminalSettingsPopover* _sender,
                                                               gpointer self);
static gboolean terminal_main_window_key_pressed (TerminalMainWindow* self,
                                           guint keyval,
                                           guint keycode,
                                           GdkModifierType modifiers);
VALA_EXTERN GSimpleActionGroup* terminal_main_window_get_actions (TerminalMainWindow* self);
static GVariant* _variant_new3 (gboolean value);
VALA_EXTERN void terminal_widgets_search_toolbar_previous_search (TerminalWidgetsSearchToolbar* self);
VALA_EXTERN void terminal_widgets_search_toolbar_next_search (TerminalWidgetsSearchToolbar* self);
VALA_EXTERN void terminal_main_window_save_opened_terminals (TerminalMainWindow* self,
                                                 gboolean save_tabs,
                                                 gboolean save_zooms);
static void terminal_main_window_connect_terminal_signals (TerminalMainWindow* self,
                                                    TerminalTerminalWidget* terminal_widget);
static void terminal_main_window_check_for_tabs_with_same_name (TerminalMainWindow* self);
static TerminalMainWindow* terminal_main_window_present_new_empty_window (TerminalMainWindow* self);
static void terminal_main_window_open_tabs (TerminalMainWindow* self);
static void _vala_array_add1 (gchar** * array,
                       gint* length,
                       gint* size,
                       gchar* value);
static void _vala_array_add2 (gdouble* * array,
                       gint* length,
                       gint* size,
                       gdouble value);
static void _vala_array_add3 (gdouble* * array,
                       gint* length,
                       gint* size,
                       gdouble value);
static void _vala_array_add4 (gdouble* * array,
                       gint* length,
                       gint* size,
                       gdouble value);
static void _vala_array_add5 (gchar** * array,
                       gint* length,
                       gint* size,
                       gchar* value);
static void _vala_array_add6 (gdouble* * array,
                       gint* length,
                       gint* size,
                       gdouble value);
static void terminal_main_window_on_terminal_child_exited (TerminalMainWindow* self,
                                                    VteTerminal* term,
                                                    gint status);
static void _terminal_main_window_on_terminal_child_exited_vte_terminal_child_exited (VteTerminal* _sender,
                                                                               gint status,
                                                                               gpointer self);
static void terminal_main_window_on_terminal_cwd_changed (TerminalMainWindow* self);
static void _terminal_main_window_on_terminal_cwd_changed_terminal_terminal_widget_cwd_changed (TerminalTerminalWidget* _sender,
                                                                                         gpointer self);
static void _terminal_main_window_set_title_label_terminal_terminal_widget_foreground_process_changed (TerminalTerminalWidget* _sender,
                                                                                                const gchar* cmdline,
                                                                                                gpointer self);
static void _terminal_main_window_set_title_label_vte_terminal_window_title_changed (VteTerminal* _sender,
                                                                              gpointer self);
VALA_EXTERN gboolean terminal_terminal_widget_get_killed (TerminalTerminalWidget* self);
VALA_EXTERN const gchar* terminal_terminal_widget_get_program_string (TerminalTerminalWidget* self);
VALA_EXTERN void terminal_terminal_widget_set_program_string (TerminalTerminalWidget* self,
                                                  const gchar* value);
VALA_EXTERN void terminal_terminal_widget_active_shell (TerminalTerminalWidget* self,
                                            const gchar* dir);
VALA_EXTERN const gchar* terminal_terminal_widget_get_current_working_directory (TerminalTerminalWidget* self);
VALA_EXTERN TerminalTerminalWidget* terminal_main_window_get_current_terminal (TerminalMainWindow* self);
static gboolean terminal_main_window_on_delete_event (TerminalMainWindow* self);
VALA_EXTERN gboolean terminal_terminal_widget_has_foreground_process (TerminalTerminalWidget* self);
static void ______lambda36_ (TerminalMainWindow* self,
                      gboolean confirmed);
static void terminal_main_window_terminate_all (TerminalMainWindow* self);
static void _______lambda36__terminal_terminal_widget_confirmed_action_callback (gboolean confirmed,
                                                                          gpointer self);
VALA_EXTERN void terminal_terminal_widget_term_ps (TerminalTerminalWidget* self);
VALA_EXTERN void terminal_terminal_view_make_restorable (TerminalTerminalView* self,
                                             const gchar* path);
VALA_EXTERN void terminal_terminal_view_close_tab (TerminalTerminalView* self);
VALA_EXTERN void terminal_terminal_view_close_tabs_to_right (TerminalTerminalView* self);
VALA_EXTERN void terminal_terminal_view_close_other_tabs (TerminalTerminalView* self);
VALA_EXTERN void terminal_terminal_view_after_tab_restored (TerminalTerminalView* self,
                                                const gchar* path);
VALA_EXTERN void terminal_terminal_widget_change_directory (TerminalTerminalWidget* self,
                                                const gchar* path);
VALA_EXTERN AdwTabPage* terminal_terminal_view_get_tab_menu_target (TerminalTerminalView* self);
VALA_EXTERN void terminal_terminal_widget_reload (TerminalTerminalWidget* self);
VALA_EXTERN void terminal_terminal_view_cycle_tabs (TerminalTerminalView* self,
                                        AdwNavigationDirection direction);
VALA_EXTERN AdwTabPage* terminal_terminal_view_get_selected_page (TerminalTerminalView* self);
VALA_EXTERN void terminal_terminal_view_transfer_tab_to_window (TerminalTerminalView* self,
                                                    TerminalMainWindow* window);
VALA_EXTERN void terminal_widgets_search_toolbar_clear (TerminalWidgetsSearchToolbar* self);
VALA_EXTERN TerminalApplication* terminal_main_window_get_app (TerminalMainWindow* self);
static GVariant* _variant_new4 (gboolean value);
VALA_EXTERN TerminalTerminalWidget* terminal_main_window_get_terminal (TerminalMainWindow* self,
                                                           const gchar* terminal_id);
VALA_EXTERN AdwTabPage* terminal_main_window_get_page (TerminalMainWindow* self,
                                           const gchar* terminal_id);
static gchar* terminal_main_window_disambiguate_label (const gchar* path,
                                                const gchar* conflict_path);
VALA_EXTERN gboolean terminal_application_get_is_testing (TerminalApplication* self);
static void _vala_array_add7 (gchar** * array,
                       gint* length,
                       gint* size,
                       gchar* value);
static void _vala_array_add8 (gchar** * array,
                       gint* length,
                       gint* size,
                       gchar* value);
VALA_EXTERN gchar* terminal_utils_get_parent_path_from_path (const gchar* path);
VALA_EXTERN GSimpleAction* terminal_main_window_get_simple_action (TerminalMainWindow* self,
                                                       const gchar* action);
VALA_EXTERN gboolean terminal_main_window_get_recreate_tabs (TerminalMainWindow* self);
static void terminal_main_window_set_recreate_tabs (TerminalMainWindow* self,
                                             gboolean value);
static void terminal_main_window_set_app (TerminalMainWindow* self,
                                   TerminalApplication* value);
static void terminal_main_window_set_actions (TerminalMainWindow* self,
                                       GSimpleActionGroup* value);
static GObject * terminal_main_window_constructor (GType type,
                                            guint n_construct_properties,
                                            GObjectConstructParam * construct_properties);
static void _vala_array_add9 (gchar** * array,
                       gint* length,
                       gint* size,
                       gchar* value);
static gboolean _terminal_main_window_key_pressed_gtk_event_controller_key_key_pressed (GtkEventControllerKey* _sender,
                                                                                 guint keyval,
                                                                                 guint keycode,
                                                                                 GdkModifierType state,
                                                                                 gpointer self);
static void _terminal_main_window___lambda37_ (TerminalMainWindow* self);
static gboolean ___lambda38_ (TerminalMainWindow* self);
static gboolean ____lambda38__gsource_func (gpointer self);
static void __terminal_main_window___lambda37__gtk_event_controller_focus_enter (GtkEventControllerFocus* _sender,
                                                                          gpointer self);
static gboolean _terminal_main_window_on_delete_event_gtk_window_close_request (GtkWindow* _sender,
                                                                         gpointer self);
static void terminal_main_window_finalize (GObject * obj);
static GType terminal_main_window_get_type_once (void);
static void _vala_terminal_main_window_get_property (GObject * object,
                                              guint property_id,
                                              GValue * value,
                                              GParamSpec * pspec);
static void _vala_terminal_main_window_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 gssize _vala_array_length (gpointer array);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static const GActionEntry TERMINAL_MAIN_WINDOW_ACTION_ENTRIES[18] = {{TERMINAL_MAIN_WINDOW_ACTION_CLOSE_TAB, _terminal_main_window_action_close_tab_gsimple_action_activate_callback}, {TERMINAL_MAIN_WINDOW_ACTION_CLOSE_TABS_TO_RIGHT, _terminal_main_window_action_close_tabs_to_right_gsimple_action_activate_callback}, {TERMINAL_MAIN_WINDOW_ACTION_CLOSE_OTHER_TABS, _terminal_main_window_action_close_other_tabs_gsimple_action_activate_callback}, {TERMINAL_MAIN_WINDOW_ACTION_FULLSCREEN, _terminal_main_window_action_fullscreen_gsimple_action_activate_callback}, {TERMINAL_MAIN_WINDOW_ACTION_NEW_TAB, _terminal_main_window_action_new_tab_gsimple_action_activate_callback}, {TERMINAL_MAIN_WINDOW_ACTION_NEW_TAB_AT, _terminal_main_window_action_new_tab_at_gsimple_action_activate_callback, "s"}, {TERMINAL_MAIN_WINDOW_ACTION_TAB_RELOAD, _terminal_main_window_action_tab_reload_gsimple_action_activate_callback}, {TERMINAL_MAIN_WINDOW_ACTION_TAB_ACTIVE_SHELL, _terminal_main_window_action_tab_active_shell_gsimple_action_activate_callback, "s"}, {TERMINAL_MAIN_WINDOW_ACTION_RESTORE_CLOSED_TAB, _terminal_main_window_action_restore_closed_tab_gsimple_action_activate_callback, "s"}, {TERMINAL_MAIN_WINDOW_ACTION_DUPLICATE_TAB, _terminal_main_window_action_duplicate_tab_gsimple_action_activate_callback}, {TERMINAL_MAIN_WINDOW_ACTION_NEXT_TAB, _terminal_main_window_action_next_tab_gsimple_action_activate_callback}, {TERMINAL_MAIN_WINDOW_ACTION_PREVIOUS_TAB, _terminal_main_window_action_previous_tab_gsimple_action_activate_callback}, {TERMINAL_MAIN_WINDOW_ACTION_MOVE_TAB_RIGHT, _terminal_main_window_action_move_tab_right_gsimple_action_activate_callback}, {TERMINAL_MAIN_WINDOW_ACTION_MOVE_TAB_LEFT, _terminal_main_window_action_move_tab_left_gsimple_action_activate_callback}, {TERMINAL_MAIN_WINDOW_ACTION_MOVE_TAB_TO_NEW_WINDOW, _terminal_main_window_action_move_tab_to_new_window_gsimple_action_activate_callback}, {TERMINAL_MAIN_WINDOW_ACTION_SEARCH, _terminal_main_window_action_search_gsimple_action_activate_callback, NULL, "false", _terminal_main_window_action_search_change_state_gsimple_action_change_state_callback}, {TERMINAL_MAIN_WINDOW_ACTION_SEARCH_NEXT, _terminal_main_window_action_search_next_gsimple_action_activate_callback}, {TERMINAL_MAIN_WINDOW_ACTION_SEARCH_PREVIOUS, _terminal_main_window_action_search_previous_gsimple_action_activate_callback}};

static inline gpointer
terminal_main_window_get_instance_private (TerminalMainWindow* self)
{
	return G_STRUCT_MEMBER_P (self, TerminalMainWindow_private_offset);
}

static void
_terminal_main_window_action_close_tab_gsimple_action_activate_callback (GSimpleAction* action,
                                                                         GVariant* parameter,
                                                                         gpointer self)
{
	terminal_main_window_action_close_tab ((TerminalMainWindow*) self);
}

static void
_terminal_main_window_action_close_tabs_to_right_gsimple_action_activate_callback (GSimpleAction* action,
                                                                                   GVariant* parameter,
                                                                                   gpointer self)
{
	terminal_main_window_action_close_tabs_to_right ((TerminalMainWindow*) self);
}

static void
_terminal_main_window_action_close_other_tabs_gsimple_action_activate_callback (GSimpleAction* action,
                                                                                GVariant* parameter,
                                                                                gpointer self)
{
	terminal_main_window_action_close_other_tabs ((TerminalMainWindow*) self);
}

static void
_terminal_main_window_action_fullscreen_gsimple_action_activate_callback (GSimpleAction* action,
                                                                          GVariant* parameter,
                                                                          gpointer self)
{
	terminal_main_window_action_fullscreen ((TerminalMainWindow*) self);
}

static void
_terminal_main_window_action_new_tab_gsimple_action_activate_callback (GSimpleAction* action,
                                                                       GVariant* parameter,
                                                                       gpointer self)
{
	terminal_main_window_action_new_tab ((TerminalMainWindow*) self);
}

static void
_terminal_main_window_action_new_tab_at_gsimple_action_activate_callback (GSimpleAction* action,
                                                                          GVariant* parameter,
                                                                          gpointer self)
{
	terminal_main_window_action_new_tab_at ((TerminalMainWindow*) self, action, parameter);
}

static void
_terminal_main_window_action_tab_reload_gsimple_action_activate_callback (GSimpleAction* action,
                                                                          GVariant* parameter,
                                                                          gpointer self)
{
	terminal_main_window_action_tab_reload ((TerminalMainWindow*) self);
}

static void
_terminal_main_window_action_tab_active_shell_gsimple_action_activate_callback (GSimpleAction* action,
                                                                                GVariant* parameter,
                                                                                gpointer self)
{
	terminal_main_window_action_tab_active_shell ((TerminalMainWindow*) self, action, parameter);
}

static void
_terminal_main_window_action_restore_closed_tab_gsimple_action_activate_callback (GSimpleAction* action,
                                                                                  GVariant* parameter,
                                                                                  gpointer self)
{
	terminal_main_window_action_restore_closed_tab ((TerminalMainWindow*) self, action, parameter);
}

static void
_terminal_main_window_action_duplicate_tab_gsimple_action_activate_callback (GSimpleAction* action,
                                                                             GVariant* parameter,
                                                                             gpointer self)
{
	terminal_main_window_action_duplicate_tab ((TerminalMainWindow*) self);
}

static void
_terminal_main_window_action_next_tab_gsimple_action_activate_callback (GSimpleAction* action,
                                                                        GVariant* parameter,
                                                                        gpointer self)
{
	terminal_main_window_action_next_tab ((TerminalMainWindow*) self);
}

static void
_terminal_main_window_action_previous_tab_gsimple_action_activate_callback (GSimpleAction* action,
                                                                            GVariant* parameter,
                                                                            gpointer self)
{
	terminal_main_window_action_previous_tab ((TerminalMainWindow*) self);
}

static void
_terminal_main_window_action_move_tab_right_gsimple_action_activate_callback (GSimpleAction* action,
                                                                              GVariant* parameter,
                                                                              gpointer self)
{
	terminal_main_window_action_move_tab_right ((TerminalMainWindow*) self);
}

static void
_terminal_main_window_action_move_tab_left_gsimple_action_activate_callback (GSimpleAction* action,
                                                                             GVariant* parameter,
                                                                             gpointer self)
{
	terminal_main_window_action_move_tab_left ((TerminalMainWindow*) self);
}

static void
_terminal_main_window_action_move_tab_to_new_window_gsimple_action_activate_callback (GSimpleAction* action,
                                                                                      GVariant* parameter,
                                                                                      gpointer self)
{
	terminal_main_window_action_move_tab_to_new_window ((TerminalMainWindow*) self);
}

static void
_terminal_main_window_action_search_gsimple_action_activate_callback (GSimpleAction* action,
                                                                      GVariant* parameter,
                                                                      gpointer self)
{
	terminal_main_window_action_search ((TerminalMainWindow*) self);
}

static void
_terminal_main_window_action_search_change_state_gsimple_action_change_state_callback (GSimpleAction* action,
                                                                                       GVariant* value,
                                                                                       gpointer self)
{
	terminal_main_window_action_search_change_state ((TerminalMainWindow*) self, action, value);
}

static void
_terminal_main_window_action_search_next_gsimple_action_activate_callback (GSimpleAction* action,
                                                                           GVariant* parameter,
                                                                           gpointer self)
{
	terminal_main_window_action_search_next ((TerminalMainWindow*) self);
}

static void
_terminal_main_window_action_search_previous_gsimple_action_activate_callback (GSimpleAction* action,
                                                                               GVariant* parameter,
                                                                               gpointer self)
{
	terminal_main_window_action_search_previous ((TerminalMainWindow*) self);
}

TerminalMainWindow*
terminal_main_window_construct (GType object_type,
                                TerminalApplication* app,
                                gboolean recreate_tabs)
{
	TerminalMainWindow * self = NULL;
	g_return_val_if_fail (app != NULL, NULL);
	self = (TerminalMainWindow*) g_object_new (object_type, "app", app, "recreate-tabs", recreate_tabs, NULL);
	return self;
}

TerminalMainWindow*
terminal_main_window_new (TerminalApplication* app,
                          gboolean recreate_tabs)
{
	return terminal_main_window_construct (TERMINAL_TYPE_MAIN_WINDOW, app, recreate_tabs);
}

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

void
terminal_main_window_add_tab_with_working_directory (TerminalMainWindow* self,
                                                     const gchar* directory,
                                                     const gchar* command,
                                                     gboolean create_new_tab)
{
	gchar* location = NULL;
	gchar* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	gboolean _tmp12_ = FALSE;
	gint _tmp13_;
	gint _tmp14_;
	TerminalTerminalView* _tmp39_;
	const gchar* _tmp40_;
	TerminalTerminalWidget* _tmp41_;
	TerminalTerminalWidget* _tmp42_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (directory != NULL);
	g_return_if_fail (command != NULL);
	_tmp0_ = g_strdup ("");
	location = _tmp0_;
	_tmp1_ = strlen (directory);
	_tmp2_ = _tmp1_;
	if (_tmp2_ == 0) {
		gboolean _tmp3_ = FALSE;
		gboolean _tmp4_ = FALSE;
		TerminalTerminalView* _tmp5_;
		gint _tmp6_;
		gint _tmp7_;
		_tmp5_ = self->priv->_notebook;
		_tmp6_ = terminal_terminal_view_get_n_pages (_tmp5_);
		_tmp7_ = _tmp6_;
		if (_tmp7_ == 0) {
			_tmp4_ = TRUE;
		} else {
			_tmp4_ = command != NULL;
		}
		if (_tmp4_) {
			_tmp3_ = TRUE;
		} else {
			_tmp3_ = create_new_tab;
		}
		if (_tmp3_) {
			TerminalTerminalView* _tmp8_;
			TerminalTerminalWidget* _tmp9_;
			TerminalTerminalWidget* _tmp10_;
			_tmp8_ = self->priv->_notebook;
			_tmp9_ = terminal_terminal_view_add_new_tab (_tmp8_, "", command, -1);
			_tmp10_ = _tmp9_;
			_g_object_unref0 (_tmp10_);
		}
		_g_free0 (location);
		return;
	} else {
		gchar* _tmp11_;
		_tmp11_ = g_strdup (directory);
		_g_free0 (location);
		location = _tmp11_;
	}
	_tmp13_ = strlen (command);
	_tmp14_ = _tmp13_;
	if (_tmp14_ == 0) {
		_tmp12_ = !create_new_tab;
	} else {
		_tmp12_ = FALSE;
	}
	if (_tmp12_) {
		GFile* file = NULL;
		const gchar* _tmp15_;
		GFile* _tmp16_;
		_tmp15_ = location;
		_tmp16_ = g_file_new_for_commandline_arg (_tmp15_);
		file = _tmp16_;
		{
			gint pos = 0;
			pos = 0;
			{
				gboolean _tmp17_ = FALSE;
				_tmp17_ = TRUE;
				while (TRUE) {
					TerminalTerminalView* _tmp19_;
					gint _tmp20_;
					gint _tmp21_;
					AdwTabPage* tab = NULL;
					TerminalTerminalView* _tmp22_;
					AdwTabView* _tmp23_;
					AdwTabView* _tmp24_;
					AdwTabPage* _tmp25_;
					AdwTabPage* _tmp26_;
					TerminalTerminalWidget* terminal_widget = NULL;
					AdwTabPage* _tmp27_;
					TerminalTerminalWidget* _tmp28_;
					TerminalTerminalWidget* _tmp29_;
					gchar* tab_path = NULL;
					TerminalTerminalWidget* _tmp30_;
					gchar* _tmp31_;
					GFile* _tmp32_;
					const gchar* _tmp33_;
					GFile* _tmp34_;
					GFile* _tmp35_;
					gboolean _tmp36_;
					if (!_tmp17_) {
						gint _tmp18_;
						_tmp18_ = pos;
						pos = _tmp18_ + 1;
					}
					_tmp17_ = FALSE;
					_tmp19_ = self->priv->_notebook;
					_tmp20_ = terminal_terminal_view_get_n_pages (_tmp19_);
					_tmp21_ = _tmp20_;
					if (!(pos < _tmp21_)) {
						break;
					}
					_tmp22_ = self->priv->_notebook;
					_tmp23_ = terminal_terminal_view_get_tab_view (_tmp22_);
					_tmp24_ = _tmp23_;
					_tmp25_ = adw_tab_view_get_nth_page (_tmp24_, pos);
					_tmp26_ = _g_object_ref0 (_tmp25_);
					tab = _tmp26_;
					_tmp27_ = tab;
					_tmp28_ = terminal_main_window_get_term_widget (_tmp27_);
					_tmp29_ = _g_object_ref0 (_tmp28_);
					terminal_widget = _tmp29_;
					_tmp30_ = terminal_widget;
					_tmp31_ = terminal_terminal_widget_get_shell_location (_tmp30_);
					tab_path = _tmp31_;
					_tmp32_ = file;
					_tmp33_ = tab_path;
					_tmp34_ = g_file_new_for_path (_tmp33_);
					_tmp35_ = _tmp34_;
					_tmp36_ = g_file_equal (_tmp32_, _tmp35_);
					_g_object_unref0 (_tmp35_);
					if (_tmp36_) {
						TerminalTerminalView* _tmp37_;
						AdwTabPage* _tmp38_;
						_tmp37_ = self->priv->_notebook;
						_tmp38_ = tab;
						terminal_terminal_view_set_selected_page (_tmp37_, _tmp38_);
						_g_free0 (tab_path);
						_g_object_unref0 (terminal_widget);
						_g_object_unref0 (tab);
						_g_object_unref0 (file);
						_g_free0 (location);
						return;
					}
					_g_free0 (tab_path);
					_g_object_unref0 (terminal_widget);
					_g_object_unref0 (tab);
				}
			}
		}
		_g_object_unref0 (file);
	}
	_tmp39_ = self->priv->_notebook;
	_tmp40_ = location;
	_tmp41_ = terminal_terminal_view_add_new_tab (_tmp39_, _tmp40_, command, -1);
	_tmp42_ = _tmp41_;
	_g_object_unref0 (_tmp42_);
	_g_free0 (location);
}

static void
_terminal_main_window_on_tab_added_adw_tab_view_page_attached (AdwTabView* _sender,
                                                               AdwTabPage* page,
                                                               gint position,
                                                               gpointer self)
{
	terminal_main_window_on_tab_added ((TerminalMainWindow*) self, page, position);
}

static void
_terminal_main_window_on_tab_removed_adw_tab_view_page_detached (AdwTabView* _sender,
                                                                 AdwTabPage* page,
                                                                 gint position,
                                                                 gpointer self)
{
	terminal_main_window_on_tab_removed ((TerminalMainWindow*) self, page);
}

static void
_terminal_main_window_on_tab_reordered_adw_tab_view_page_reordered (AdwTabView* _sender,
                                                                    AdwTabPage* page,
                                                                    gint position,
                                                                    gpointer self)
{
	terminal_main_window_on_tab_reordered ((TerminalMainWindow*) self, page, position);
}

static AdwTabView*
_terminal_main_window_on_create_window_request_adw_tab_view_create_window (AdwTabView* _sender,
                                                                           gpointer self)
{
	AdwTabView* result;
	result = terminal_main_window_on_create_window_request ((TerminalMainWindow*) self);
	return result;
}

static void
___lambda32_ (TerminalMainWindow* self,
              gboolean confirmed)
{
	TerminalTerminalView* _tmp2_;
	AdwTabView* _tmp3_;
	AdwTabView* _tmp4_;
	AdwTabPage* _tmp5_;
	if (confirmed) {
		TerminalTerminalWidget* _tmp0_;
		TerminalTerminalWidget* _tmp1_;
		_tmp0_ = self->priv->term_to_close;
		terminal_terminal_widget_kill_fg (_tmp0_);
		_tmp1_ = self->priv->term_to_close;
		terminal_main_window_terminate_and_disconnect (self, _tmp1_, TRUE);
	}
	_tmp2_ = self->priv->_notebook;
	_tmp3_ = terminal_terminal_view_get_tab_view (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = self->priv->tab_to_close;
	adw_tab_view_close_page_finish (_tmp4_, _tmp5_, confirmed);
}

static void
____lambda32__terminal_terminal_widget_confirmed_action_callback (gboolean confirmed,
                                                                  gpointer self)
{
	___lambda32_ ((TerminalMainWindow*) self, confirmed);
}

static gboolean
__lambda31_ (TerminalMainWindow* self,
             AdwTabPage* tab)
{
	TerminalTerminalWidget* _tmp0_;
	TerminalTerminalWidget* _tmp1_;
	TerminalTerminalWidget* _tmp2_;
	gboolean result;
	g_return_val_if_fail (tab != NULL, FALSE);
	_tmp0_ = terminal_main_window_get_term_widget (tab);
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->term_to_close);
	self->priv->term_to_close = _tmp1_;
	_tmp2_ = self->priv->term_to_close;
	if (_tmp2_ != NULL) {
		AdwTabPage* _tmp3_;
		TerminalTerminalWidget* _tmp4_;
		_tmp3_ = _g_object_ref0 (tab);
		_g_object_unref0 (self->priv->tab_to_close);
		self->priv->tab_to_close = _tmp3_;
		_tmp4_ = self->priv->term_to_close;
		terminal_terminal_widget_confirm_kill_fg_process (_tmp4_, _ ("Are you sure you want to close this tab?"), _ ("Close tab"), ____lambda32__terminal_terminal_widget_confirmed_action_callback, self);
	}
	result = GDK_EVENT_STOP;
	return result;
}

static gboolean
___lambda31__adw_tab_view_close_page (AdwTabView* _sender,
                                      AdwTabPage* page,
                                      gpointer self)
{
	gboolean result;
	result = __lambda31_ ((TerminalMainWindow*) self, page);
	return result;
}

static Block13Data*
block13_data_ref (Block13Data* _data13_)
{
	g_atomic_int_inc (&_data13_->_ref_count_);
	return _data13_;
}

static void
block13_data_unref (void * _userdata_)
{
	Block13Data* _data13_;
	_data13_ = (Block13Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data13_->_ref_count_)) {
		TerminalMainWindow* self;
		self = _data13_->self;
		_g_object_unref0 (_data13_->term);
		_g_object_unref0 (self);
		g_slice_free (Block13Data, _data13_);
	}
}

static gboolean
__lambda34_ (Block13Data* _data13_)
{
	TerminalMainWindow* self;
	TerminalTerminalWidget* _tmp0_;
	gboolean result;
	self = _data13_->self;
	terminal_main_window_set_title_label (self);
	_tmp0_ = _data13_->term;
	gtk_widget_grab_focus ((GtkWidget*) _tmp0_);
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
___lambda34__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda34_ (self);
	return result;
}

static void
__lambda33_ (TerminalMainWindow* self)
{
	Block13Data* _data13_;
	TerminalTerminalView* _tmp0_;
	AdwTabView* _tmp1_;
	AdwTabView* _tmp2_;
	AdwTabPage* _tmp3_;
	AdwTabPage* _tmp4_;
	TerminalTerminalWidget* _tmp5_;
	TerminalTerminalWidget* _tmp6_;
	TerminalTerminalWidget* _tmp7_;
	TerminalTerminalWidget* _tmp8_;
	TerminalTerminalWidget* _tmp9_;
	AdwTabPage* _tmp10_;
	TerminalTerminalWidget* _tmp11_;
	TerminalTerminalWidgetTabState _tmp12_;
	TerminalTerminalWidgetTabState _tmp13_;
	_data13_ = g_slice_new0 (Block13Data);
	_data13_->_ref_count_ = 1;
	_data13_->self = g_object_ref (self);
	_tmp0_ = self->priv->_notebook;
	_tmp1_ = terminal_terminal_view_get_tab_view (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = adw_tab_view_get_selected_page (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = terminal_main_window_get_term_widget (_tmp4_);
	_tmp6_ = _g_object_ref0 (_tmp5_);
	_data13_->term = _tmp6_;
	_tmp7_ = _data13_->term;
	terminal_main_window_set_current_terminal (self, _tmp7_);
	_tmp8_ = _data13_->term;
	if (_tmp8_ == NULL) {
		block13_data_unref (_data13_);
		_data13_ = NULL;
		return;
	}
	g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, ___lambda34__gsource_func, block13_data_ref (_data13_), block13_data_unref);
	_tmp9_ = _data13_->term;
	_tmp10_ = _tmp9_->tab;
	if (_tmp10_ == NULL) {
		block13_data_unref (_data13_);
		_data13_ = NULL;
		return;
	}
	_tmp11_ = _data13_->term;
	_tmp12_ = terminal_terminal_widget_get_tab_state (_tmp11_);
	_tmp13_ = _tmp12_;
	if (_tmp13_ != TERMINAL_TERMINAL_WIDGET_TAB_STATE_WORKING) {
		TerminalTerminalWidget* _tmp14_;
		_tmp14_ = _data13_->term;
		terminal_terminal_widget_set_tab_state (_tmp14_, TERMINAL_TERMINAL_WIDGET_TAB_STATE_NONE);
	}
	block13_data_unref (_data13_);
	_data13_ = NULL;
}

static void
___lambda33__g_object_notify (GObject* _sender,
                              GParamSpec* pspec,
                              gpointer self)
{
	__lambda33_ ((TerminalMainWindow*) self);
}

static void
__lambda35_ (TerminalMainWindow* self)
{
	TerminalDialogsColorPreferences* _tmp0_;
	TerminalDialogsColorPreferences* _tmp2_;
	_tmp0_ = self->priv->color_preferences_dialog;
	if (_tmp0_ == NULL) {
		TerminalDialogsColorPreferences* _tmp1_;
		_tmp1_ = terminal_dialogs_color_preferences_new ((GtkWindow*) self);
		g_object_ref_sink (_tmp1_);
		_g_object_unref0 (self->priv->color_preferences_dialog);
		self->priv->color_preferences_dialog = _tmp1_;
	}
	_tmp2_ = self->priv->color_preferences_dialog;
	gtk_window_present ((GtkWindow*) _tmp2_);
}

static void
___lambda35__terminal_settings_popover_show_theme_editor (TerminalSettingsPopover* _sender,
                                                          gpointer self)
{
	__lambda35_ ((TerminalMainWindow*) self);
}

static void
terminal_main_window_setup_ui (TerminalMainWindow* self)
{
	gchar* _tmp0_;
	GtkButton* _tmp1_ = NULL;
	GtkButton* _tmp2_;
	GeeMultiMap* _tmp3_;
	GeeCollection* _tmp4_;
	GeeCollection* _tmp5_;
	gint _tmp6_ = 0;
	gpointer* _tmp7_;
	gchar** _tmp8_;
	gint _tmp8__length1;
	gchar* _tmp9_;
	gchar* _tmp10_;
	GtkButton* _tmp11_;
	GtkButton* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	gchar** _tmp16_;
	gchar** _tmp17_;
	gint _tmp17__length1;
	gchar* _tmp18_;
	GtkToggleButton* _tmp19_ = NULL;
	GtkButton* new_tab_button = NULL;
	gchar* _tmp20_;
	gchar* _tmp21_;
	gchar** _tmp22_;
	gchar** _tmp23_;
	gint _tmp23__length1;
	gchar* _tmp24_;
	GtkButton* _tmp25_ = NULL;
	GtkButton* _tmp26_;
	GtkRevealer* new_tab_revealer = NULL;
	GtkWidget* _tmp27_;
	GtkRevealer* _tmp28_ = NULL;
	GtkMenuButton* menu_button = NULL;
	gchar* _tmp29_;
	TerminalSettingsPopover* _tmp30_;
	gchar* _tmp31_;
	GtkMenuButton* _tmp32_ = NULL;
	TerminalWidgetsSearchToolbar* _tmp33_;
	const gchar* _tmp34_;
	const gchar* _tmp35_;
	GtkLabel* _tmp36_ = NULL;
	GtkLabel* _tmp37_;
	GtkStack* _tmp38_ = NULL;
	GtkStack* _tmp39_;
	GtkLabel* _tmp40_;
	GtkStack* _tmp41_;
	TerminalWidgetsSearchToolbar* _tmp42_;
	GtkStack* _tmp43_;
	GtkLabel* _tmp44_;
	GtkStack* _tmp45_;
	GtkWidget* _tmp46_;
	AdwHeaderBar* _tmp47_ = NULL;
	AdwHeaderBar* _tmp48_;
	GtkButton* _tmp49_;
	AdwHeaderBar* _tmp50_;
	AdwHeaderBar* _tmp51_;
	GtkToggleButton* _tmp52_;
	AdwHeaderBar* _tmp53_;
	AdwHeaderBar* _tmp54_;
	TerminalTerminalView* _tmp55_;
	TerminalTerminalView* _tmp56_;
	TerminalTerminalView* _tmp57_;
	AdwTabView* _tmp58_;
	AdwTabView* _tmp59_;
	TerminalTerminalView* _tmp60_;
	AdwTabView* _tmp61_;
	AdwTabView* _tmp62_;
	TerminalTerminalView* _tmp63_;
	AdwTabView* _tmp64_;
	AdwTabView* _tmp65_;
	TerminalTerminalView* _tmp66_;
	AdwTabView* _tmp67_;
	AdwTabView* _tmp68_;
	TerminalTerminalView* _tmp69_;
	AdwTabView* _tmp70_;
	AdwTabView* _tmp71_;
	TerminalTerminalView* _tmp72_;
	AdwTabView* _tmp73_;
	AdwTabView* _tmp74_;
	TerminalTerminalView* _tmp75_;
	AdwTabBar* _tmp76_;
	AdwTabBar* _tmp77_;
	AdwToolbarView* box = NULL;
	TerminalTerminalView* _tmp78_;
	GtkWidget* _tmp79_;
	AdwToolbarView* _tmp80_ = NULL;
	AdwHeaderBar* _tmp81_;
	TerminalTerminalView* _tmp82_;
	AdwTabBar* _tmp83_;
	AdwTabBar* _tmp84_;
	GtkLabel* _tmp85_;
	TerminalSettingsPopover* menu_popover = NULL;
	GtkPopover* _tmp86_;
	GtkPopover* _tmp87_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup (TERMINAL_MAIN_WINDOW_ACTION_PREFIX TERMINAL_MAIN_WINDOW_ACTION_FULLSCREEN);
	_tmp1_ = (GtkButton*) gtk_button_new_from_icon_name ("view-restore-symbolic");
	gtk_actionable_set_action_name ((GtkActionable*) _tmp1_, _tmp0_);
	_g_free0 (_tmp0_);
	gtk_widget_set_can_focus ((GtkWidget*) _tmp1_, FALSE);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp1_, 12);
	gtk_widget_set_visible ((GtkWidget*) _tmp1_, FALSE);
	g_object_ref_sink (_tmp1_);
	_g_object_unref0 (self->priv->unfullscreen_button);
	self->priv->unfullscreen_button = _tmp1_;
	_tmp2_ = self->priv->unfullscreen_button;
	_tmp3_ = terminal_main_window_action_accelerators;
	_tmp4_ = gee_multi_map_get (_tmp3_, TERMINAL_MAIN_WINDOW_ACTION_FULLSCREEN);
	_tmp5_ = _tmp4_;
	_tmp7_ = gee_collection_to_array (_tmp5_, &_tmp6_);
	_tmp8_ = _tmp7_;
	_tmp8__length1 = _tmp6_;
	_tmp9_ = granite_markup_accel_tooltip (_tmp8_, (gint) _tmp6_, _ ("Exit FullScreen"));
	_tmp10_ = _tmp9_;
	gtk_widget_set_tooltip_markup ((GtkWidget*) _tmp2_, _tmp10_);
	_g_free0 (_tmp10_);
	_tmp8_ = (_vala_array_free (_tmp8_, _tmp8__length1, (GDestroyNotify) g_free), NULL);
	_g_object_unref0 (_tmp5_);
	_tmp11_ = self->priv->unfullscreen_button;
	gtk_widget_remove_css_class ((GtkWidget*) _tmp11_, "image-button");
	_tmp12_ = self->priv->unfullscreen_button;
	gtk_widget_add_css_class ((GtkWidget*) _tmp12_, "titlebutton");
	_tmp13_ = g_strdup (TERMINAL_MAIN_WINDOW_ACTION_PREFIX TERMINAL_MAIN_WINDOW_ACTION_SEARCH);
	_tmp14_ = g_strdup ("edit-find-symbolic");
	_tmp15_ = g_strdup ("<Ctrl><Shift>f");
	_tmp16_ = g_new0 (gchar*, 1 + 1);
	_tmp16_[0] = _tmp15_;
	_tmp17_ = _tmp16_;
	_tmp17__length1 = 1;
	_tmp18_ = granite_markup_accel_tooltip (_tmp17_, (gint) 1, _ ("Find…"));
	_tmp19_ = (GtkToggleButton*) gtk_toggle_button_new ();
	gtk_actionable_set_action_name ((GtkActionable*) _tmp19_, _tmp13_);
	_g_free0 (_tmp13_);
	gtk_button_set_icon_name ((GtkButton*) _tmp19_, _tmp14_);
	_g_free0 (_tmp14_);
	gtk_widget_set_valign ((GtkWidget*) _tmp19_, GTK_ALIGN_CENTER);
	gtk_widget_set_tooltip_markup ((GtkWidget*) _tmp19_, _tmp18_);
	_g_free0 (_tmp18_);
	g_object_ref_sink (_tmp19_);
	_g_object_unref0 (self->priv->search_button);
	self->priv->search_button = _tmp19_;
	_tmp17_ = (_vala_array_free (_tmp17_, _tmp17__length1, (GDestroyNotify) g_free), NULL);
	_tmp20_ = g_strdup (TERMINAL_MAIN_WINDOW_ACTION_PREFIX TERMINAL_MAIN_WINDOW_ACTION_NEW_TAB);
	_tmp21_ = g_strdup ("<Ctrl><Shift>t");
	_tmp22_ = g_new0 (gchar*, 1 + 1);
	_tmp22_[0] = _tmp21_;
	_tmp23_ = _tmp22_;
	_tmp23__length1 = 1;
	_tmp24_ = granite_markup_accel_tooltip (_tmp23_, (gint) 1, _ ("New Tab…"));
	_tmp25_ = (GtkButton*) gtk_button_new_from_icon_name ("list-add-symbolic");
	gtk_widget_set_valign ((GtkWidget*) _tmp25_, GTK_ALIGN_CENTER);
	gtk_actionable_set_action_name ((GtkActionable*) _tmp25_, _tmp20_);
	_g_free0 (_tmp20_);
	gtk_widget_set_tooltip_markup ((GtkWidget*) _tmp25_, _tmp24_);
	_g_free0 (_tmp24_);
	g_object_ref_sink (_tmp25_);
	_tmp26_ = _tmp25_;
	_tmp23_ = (_vala_array_free (_tmp23_, _tmp23__length1, (GDestroyNotify) g_free), NULL);
	new_tab_button = _tmp26_;
	_tmp27_ = _g_object_ref0 ((GtkWidget*) new_tab_button);
	_tmp28_ = (GtkRevealer*) gtk_revealer_new ();
	gtk_revealer_set_child (_tmp28_, _tmp27_);
	_g_object_unref0 (_tmp27_);
	gtk_revealer_set_transition_type (_tmp28_, GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT);
	g_object_ref_sink (_tmp28_);
	new_tab_revealer = _tmp28_;
	_tmp29_ = g_strdup ("open-menu-symbolic");
	_tmp30_ = terminal_settings_popover_new ();
	g_object_ref_sink (_tmp30_);
	_tmp31_ = g_strdup (_ ("Settings"));
	_tmp32_ = (GtkMenuButton*) gtk_menu_button_new ();
	gtk_widget_set_can_focus ((GtkWidget*) _tmp32_, FALSE);
	gtk_menu_button_set_icon_name (_tmp32_, _tmp29_);
	_g_free0 (_tmp29_);
	gtk_menu_button_set_popover (_tmp32_, (GtkPopover*) _tmp30_);
	_g_object_unref0 (_tmp30_);
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp32_, _tmp31_);
	_g_free0 (_tmp31_);
	gtk_widget_set_valign ((GtkWidget*) _tmp32_, GTK_ALIGN_CENTER);
	g_object_ref_sink (_tmp32_);
	menu_button = _tmp32_;
	_tmp33_ = terminal_widgets_search_toolbar_new (self);
	g_object_ref_sink (_tmp33_);
	_g_object_unref0 (self->priv->search_toolbar);
	self->priv->search_toolbar = _tmp33_;
	_tmp34_ = gtk_window_get_title ((GtkWindow*) self);
	_tmp35_ = _tmp34_;
	_tmp36_ = (GtkLabel*) gtk_label_new (_tmp35_);
	gtk_label_set_wrap (_tmp36_, FALSE);
	gtk_label_set_single_line_mode (_tmp36_, TRUE);
	gtk_label_set_ellipsize (_tmp36_, PANGO_ELLIPSIZE_END);
	g_object_ref_sink (_tmp36_);
	_g_object_unref0 (self->priv->title_label);
	self->priv->title_label = _tmp36_;
	_tmp37_ = self->priv->title_label;
	gtk_widget_add_css_class ((GtkWidget*) _tmp37_, GRANITE_STYLE_CLASS_TITLE_LABEL);
	_tmp38_ = (GtkStack*) gtk_stack_new ();
	gtk_stack_set_transition_type (_tmp38_, GTK_STACK_TRANSITION_TYPE_SLIDE_UP_DOWN);
	gtk_stack_set_hhomogeneous (_tmp38_, FALSE);
	g_object_ref_sink (_tmp38_);
	_g_object_unref0 (self->priv->title_stack);
	self->priv->title_stack = _tmp38_;
	_tmp39_ = self->priv->title_stack;
	_tmp40_ = self->priv->title_label;
	gtk_stack_add_child (_tmp39_, (GtkWidget*) _tmp40_);
	_tmp41_ = self->priv->title_stack;
	_tmp42_ = self->priv->search_toolbar;
	gtk_stack_add_child (_tmp41_, (GtkWidget*) _tmp42_);
	_tmp43_ = self->priv->title_stack;
	_tmp44_ = self->priv->title_label;
	gtk_stack_set_visible_child (_tmp43_, (GtkWidget*) _tmp44_);
	_tmp45_ = self->priv->title_stack;
	_tmp46_ = _g_object_ref0 ((GtkWidget*) _tmp45_);
	_tmp47_ = (AdwHeaderBar*) adw_header_bar_new ();
	adw_header_bar_set_title_widget (_tmp47_, _tmp46_);
	_g_object_unref0 (_tmp46_);
	adw_header_bar_set_centering_policy (_tmp47_, ADW_CENTERING_POLICY_STRICT);
	g_object_ref_sink (_tmp47_);
	_g_object_unref0 (self->priv->header);
	self->priv->header = _tmp47_;
	_tmp48_ = self->priv->header;
	_tmp49_ = self->priv->unfullscreen_button;
	adw_header_bar_pack_end (_tmp48_, (GtkWidget*) _tmp49_);
	_tmp50_ = self->priv->header;
	adw_header_bar_pack_end (_tmp50_, (GtkWidget*) menu_button);
	_tmp51_ = self->priv->header;
	_tmp52_ = self->priv->search_button;
	adw_header_bar_pack_end (_tmp51_, (GtkWidget*) _tmp52_);
	_tmp53_ = self->priv->header;
	adw_header_bar_pack_end (_tmp53_, (GtkWidget*) new_tab_revealer);
	_tmp54_ = self->priv->header;
	gtk_widget_add_css_class ((GtkWidget*) _tmp54_, "default-decoration");
	_tmp55_ = terminal_terminal_view_new (self);
	g_object_ref_sink (_tmp55_);
	_tmp56_ = _tmp55_;
	terminal_main_window_set_notebook (self, _tmp56_);
	_g_object_unref0 (_tmp56_);
	_tmp57_ = self->priv->_notebook;
	_tmp58_ = terminal_terminal_view_get_tab_view (_tmp57_);
	_tmp59_ = _tmp58_;
	g_signal_connect_object (_tmp59_, "page-attached", (GCallback) _terminal_main_window_on_tab_added_adw_tab_view_page_attached, self, 0);
	_tmp60_ = self->priv->_notebook;
	_tmp61_ = terminal_terminal_view_get_tab_view (_tmp60_);
	_tmp62_ = _tmp61_;
	g_signal_connect_object (_tmp62_, "page-detached", (GCallback) _terminal_main_window_on_tab_removed_adw_tab_view_page_detached, self, 0);
	_tmp63_ = self->priv->_notebook;
	_tmp64_ = terminal_terminal_view_get_tab_view (_tmp63_);
	_tmp65_ = _tmp64_;
	g_signal_connect_object (_tmp65_, "page-reordered", (GCallback) _terminal_main_window_on_tab_reordered_adw_tab_view_page_reordered, self, 0);
	_tmp66_ = self->priv->_notebook;
	_tmp67_ = terminal_terminal_view_get_tab_view (_tmp66_);
	_tmp68_ = _tmp67_;
	g_signal_connect_object (_tmp68_, "create-window", (GCallback) _terminal_main_window_on_create_window_request_adw_tab_view_create_window, self, 0);
	_tmp69_ = self->priv->_notebook;
	_tmp70_ = terminal_terminal_view_get_tab_view (_tmp69_);
	_tmp71_ = _tmp70_;
	g_signal_connect_object (_tmp71_, "close-page", (GCallback) ___lambda31__adw_tab_view_close_page, self, 0);
	_tmp72_ = self->priv->_notebook;
	_tmp73_ = terminal_terminal_view_get_tab_view (_tmp72_);
	_tmp74_ = _tmp73_;
	g_signal_connect_object ((GObject*) _tmp74_, "notify::selected-page", (GCallback) ___lambda33__g_object_notify, self, 0);
	_tmp75_ = self->priv->_notebook;
	_tmp76_ = terminal_terminal_view_get_tab_bar (_tmp75_);
	_tmp77_ = _tmp76_;
	g_object_bind_property_with_closures ((GObject*) _tmp77_, "tabs-revealed", (GObject*) new_tab_revealer, "reveal-child", G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp78_ = self->priv->_notebook;
	_tmp79_ = _g_object_ref0 ((GtkWidget*) _tmp78_);
	_tmp80_ = (AdwToolbarView*) adw_toolbar_view_new ();
	adw_toolbar_view_set_content (_tmp80_, _tmp79_);
	_g_object_unref0 (_tmp79_);
	adw_toolbar_view_set_top_bar_style (_tmp80_, ADW_TOOLBAR_RAISED_BORDER);
	g_object_ref_sink (_tmp80_);
	box = _tmp80_;
	_tmp81_ = self->priv->header;
	adw_toolbar_view_add_top_bar (box, (GtkWidget*) _tmp81_);
	_tmp82_ = self->priv->_notebook;
	_tmp83_ = terminal_terminal_view_get_tab_bar (_tmp82_);
	_tmp84_ = _tmp83_;
	adw_toolbar_view_add_top_bar (box, (GtkWidget*) _tmp84_);
	adw_window_set_content ((AdwWindow*) self, (GtkWidget*) box);
	gtk_widget_add_css_class ((GtkWidget*) self, "terminal-window");
	_tmp85_ = self->priv->title_label;
	g_object_bind_property_with_closures ((GObject*) self, "title", (GObject*) _tmp85_, "label", G_BINDING_DEFAULT, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp86_ = gtk_menu_button_get_popover (menu_button);
	_tmp87_ = _tmp86_;
	menu_popover = G_TYPE_CHECK_INSTANCE_CAST (_tmp87_, TERMINAL_TYPE_SETTINGS_POPOVER, TerminalSettingsPopover);
	g_signal_connect_object (menu_popover, "show-theme-editor", (GCallback) ___lambda35__terminal_settings_popover_show_theme_editor, self, 0);
	g_object_bind_property_with_closures ((GObject*) self, "current-terminal", (GObject*) menu_popover, "terminal", G_BINDING_DEFAULT, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_g_object_unref0 (box);
	_g_object_unref0 (menu_button);
	_g_object_unref0 (new_tab_revealer);
	_g_object_unref0 (new_tab_button);
}

static GVariant*
_variant_new3 (gboolean value)
{
	return g_variant_ref_sink (g_variant_new_boolean (value));
}

static gboolean
terminal_main_window_key_pressed (TerminalMainWindow* self,
                                  guint keyval,
                                  guint keycode,
                                  GdkModifierType modifiers)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	switch (keyval) {
		case GDK_KEY_Escape:
		{
			GtkWidget* _tmp0_;
			GtkWidget* _tmp1_;
			GtkWidget* _tmp2_;
			TerminalWidgetsSearchToolbar* _tmp3_;
			gboolean _tmp4_;
			g_object_get ((GtkWindow*) self, "focus-widget", &_tmp0_, NULL);
			_tmp1_ = _tmp0_;
			_tmp2_ = _tmp1_;
			_tmp3_ = self->priv->search_toolbar;
			_tmp4_ = gtk_widget_is_ancestor (_tmp2_, (GtkWidget*) _tmp3_);
			_g_object_unref0 (_tmp2_);
			if (_tmp4_) {
				GSimpleActionGroup* _tmp5_;
				GAction* _tmp6_;
				GVariant* _tmp7_;
				_tmp5_ = self->priv->_actions;
				_tmp6_ = g_action_map_lookup_action ((GActionMap*) _tmp5_, TERMINAL_MAIN_WINDOW_ACTION_SEARCH);
				_tmp7_ = _variant_new3 (FALSE);
				g_action_change_state (_tmp6_, _tmp7_);
				_g_variant_unref0 (_tmp7_);
				result = GDK_EVENT_STOP;
				return result;
			}
			break;
		}
		case GDK_KEY_Return:
		{
			GtkWidget* _tmp8_;
			GtkWidget* _tmp9_;
			GtkWidget* _tmp10_;
			TerminalWidgetsSearchToolbar* _tmp11_;
			gboolean _tmp12_;
			g_object_get ((GtkWindow*) self, "focus-widget", &_tmp8_, NULL);
			_tmp9_ = _tmp8_;
			_tmp10_ = _tmp9_;
			_tmp11_ = self->priv->search_toolbar;
			_tmp12_ = gtk_widget_is_ancestor (_tmp10_, (GtkWidget*) _tmp11_);
			_g_object_unref0 (_tmp10_);
			if (_tmp12_) {
				if ((modifiers & GDK_SHIFT_MASK) == GDK_SHIFT_MASK) {
					TerminalWidgetsSearchToolbar* _tmp13_;
					_tmp13_ = self->priv->search_toolbar;
					terminal_widgets_search_toolbar_previous_search (_tmp13_);
				} else {
					TerminalWidgetsSearchToolbar* _tmp14_;
					_tmp14_ = self->priv->search_toolbar;
					terminal_widgets_search_toolbar_next_search (_tmp14_);
				}
				result = GDK_EVENT_STOP;
				return result;
			}
			break;
		}
		default:
		break;
	}
	result = GDK_EVENT_PROPAGATE;
	return result;
}

static void
terminal_main_window_on_tab_added (TerminalMainWindow* self,
                                   AdwTabPage* tab,
                                   gint pos)
{
	TerminalTerminalWidget* term = NULL;
	TerminalTerminalWidget* _tmp0_;
	TerminalTerminalWidget* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (tab != NULL);
	_tmp0_ = terminal_main_window_get_term_widget (tab);
	_tmp1_ = _g_object_ref0 (_tmp0_);
	term = _tmp1_;
	terminal_main_window_save_opened_terminals (self, TRUE, TRUE);
	terminal_main_window_connect_terminal_signals (self, term);
	_g_object_unref0 (term);
}

static void
terminal_main_window_on_tab_removed (TerminalMainWindow* self,
                                     AdwTabPage* tab)
{
	TerminalTerminalView* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (tab != NULL);
	_tmp0_ = self->priv->_notebook;
	_tmp1_ = terminal_terminal_view_get_n_pages (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_ == 0) {
		terminal_main_window_save_opened_terminals (self, TRUE, TRUE);
		gtk_window_destroy ((GtkWindow*) self);
	} else {
		terminal_main_window_check_for_tabs_with_same_name (self);
		terminal_main_window_save_opened_terminals (self, TRUE, TRUE);
	}
}

static void
terminal_main_window_on_tab_reordered (TerminalMainWindow* self,
                                       AdwTabPage* tab,
                                       gint new_pos)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (tab != NULL);
	terminal_main_window_save_opened_terminals (self, TRUE, TRUE);
}

static AdwTabView*
terminal_main_window_on_create_window_request (TerminalMainWindow* self)
{
	TerminalMainWindow* _tmp0_;
	TerminalMainWindow* _tmp1_;
	TerminalTerminalView* _tmp2_;
	AdwTabView* _tmp3_;
	AdwTabView* _tmp4_;
	AdwTabView* _tmp5_;
	AdwTabView* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = terminal_main_window_present_new_empty_window (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_->priv->_notebook;
	_tmp3_ = terminal_terminal_view_get_tab_view (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = _tmp4_;
	_g_object_unref0 (_tmp1_);
	result = _tmp5_;
	return result;
}

static void
_vala_array_add1 (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
_vala_array_add2 (gdouble* * array,
                  gint* length,
                  gint* size,
                  gdouble value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gdouble, *array, *size);
	}
	(*array)[(*length)++] = value;
}

static gdouble
double_parse (const gchar* str)
{
	gdouble result;
	g_return_val_if_fail (str != NULL, -1.0);
	result = g_ascii_strtod (str, NULL);
	return result;
}

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

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

static void
_vala_array_add5 (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
_vala_array_add6 (gdouble* * array,
                  gint* length,
                  gint* size,
                  gdouble value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gdouble, *array, *size);
	}
	(*array)[(*length)++] = value;
}

static void
terminal_main_window_open_tabs (TerminalMainWindow* self)
{
	gchar** tabs = NULL;
	gchar** _tmp0_;
	gint tabs_length1;
	gint _tabs_size_;
	gdouble* zooms = NULL;
	gdouble* _tmp1_;
	gint zooms_length1;
	gint _zooms_size_;
	gint focus = 0;
	gdouble default_zoom = 0.0;
	GSettings* _tmp2_;
	gboolean _tmp3_ = FALSE;
	gdouble* _tmp19_;
	gint _tmp19__length1;
	gchar** _tmp20_;
	gint _tmp20__length1;
	gint null_dirs = 0;
	gchar** _tmp34_;
	gint _tmp34__length1;
	TerminalTerminalView* _tmp35_;
	gint _tmp36_;
	gint _tmp37_;
	gint index = 0;
	gchar** _tmp38_;
	gint _tmp38__length1;
	TerminalTerminalView* _tmp49_;
	TerminalTerminalView* _tmp50_;
	AdwTabView* _tmp51_;
	AdwTabView* _tmp52_;
	TerminalTerminalView* _tmp53_;
	gint _tmp54_;
	gint _tmp55_;
	AdwTabPage* _tmp56_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_new0 (gchar*, 0 + 1);
	tabs = _tmp0_;
	tabs_length1 = 0;
	_tabs_size_ = tabs_length1;
	_tmp1_ = g_new0 (gdouble, 0);
	zooms = _tmp1_;
	zooms_length1 = 0;
	_zooms_size_ = zooms_length1;
	focus = 0;
	_tmp2_ = terminal_application_saved_state;
	default_zoom = g_settings_get_double (_tmp2_, "zoom");
	if (granite_services_system_history_is_enabled ()) {
		GSettings* _tmp4_;
		_tmp4_ = terminal_application_settings;
		_tmp3_ = g_settings_get_boolean (_tmp4_, "remember-tabs");
	} else {
		_tmp3_ = FALSE;
	}
	if (_tmp3_) {
		GSettings* _tmp5_;
		gchar** _tmp6_;
		gchar** _tmp7_;
		gint n_tabs = 0;
		gchar** _tmp8_;
		gint _tmp8__length1;
		GSettings* _tmp17_;
		_tmp5_ = terminal_application_saved_state;
		_tmp7_ = _tmp6_ = g_settings_get_strv (_tmp5_, "tabs");
		tabs = (_vala_array_free (tabs, tabs_length1, (GDestroyNotify) g_free), NULL);
		tabs = _tmp7_;
		tabs_length1 = _vala_array_length (_tmp6_);
		_tabs_size_ = tabs_length1;
		_tmp8_ = tabs;
		_tmp8__length1 = tabs_length1;
		n_tabs = _tmp8__length1;
		if (n_tabs == 0) {
			const gchar* _tmp9_;
			gchar* _tmp10_;
			_tmp9_ = g_get_home_dir ();
			_tmp10_ = g_strdup (_tmp9_);
			_vala_array_add1 (&tabs, &tabs_length1, &_tabs_size_, _tmp10_);
			_vala_array_add2 (&zooms, &zooms_length1, &_zooms_size_, default_zoom);
		} else {
			GSettings* _tmp11_;
			gchar** _tmp12_;
			gchar** _tmp13_;
			_tmp11_ = terminal_application_saved_state;
			_tmp13_ = _tmp12_ = g_settings_get_strv (_tmp11_, "tab-zooms");
			{
				gchar** zoom_s_collection = NULL;
				gint zoom_s_collection_length1 = 0;
				gint _zoom_s_collection_size_ = 0;
				gint zoom_s_it = 0;
				zoom_s_collection = _tmp13_;
				zoom_s_collection_length1 = _vala_array_length (_tmp12_);
				for (zoom_s_it = 0; zoom_s_it < zoom_s_collection_length1; zoom_s_it = zoom_s_it + 1) {
					const gchar* zoom_s = NULL;
					zoom_s = zoom_s_collection[zoom_s_it];
					{
						gdouble* _tmp14_;
						gint _tmp14__length1;
						_tmp14_ = zooms;
						_tmp14__length1 = zooms_length1;
						if (_tmp14__length1 < n_tabs) {
							const gchar* _tmp15_;
							_tmp15_ = zoom_s;
							_vala_array_add3 (&zooms, &zooms_length1, &_zooms_size_, double_parse (_tmp15_));
						} else {
							break;
						}
					}
				}
				zoom_s_collection = (_vala_array_free (zoom_s_collection, zoom_s_collection_length1, (GDestroyNotify) g_free), NULL);
			}
			while (TRUE) {
				gdouble* _tmp16_;
				gint _tmp16__length1;
				_tmp16_ = zooms;
				_tmp16__length1 = zooms_length1;
				if (!(_tmp16__length1 < n_tabs)) {
					break;
				}
				_vala_array_add4 (&zooms, &zooms_length1, &_zooms_size_, default_zoom);
			}
		}
		_tmp17_ = terminal_application_saved_state;
		focus = g_settings_get_int (_tmp17_, "focused-tab");
	} else {
		gchar* _tmp18_;
		_tmp18_ = g_get_current_dir ();
		_vala_array_add5 (&tabs, &tabs_length1, &_tabs_size_, _tmp18_);
		_vala_array_add6 (&zooms, &zooms_length1, &_zooms_size_, default_zoom);
	}
	_tmp19_ = zooms;
	_tmp19__length1 = zooms_length1;
	_tmp20_ = tabs;
	_tmp20__length1 = tabs_length1;
	_vala_assert (_tmp19__length1 == _tmp20__length1, "zooms.length == tabs.length");
	null_dirs = 0;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp21_ = FALSE;
			_tmp21_ = TRUE;
			while (TRUE) {
				gchar** _tmp23_;
				gint _tmp23__length1;
				GFile* file = NULL;
				gchar** _tmp24_;
				gint _tmp24__length1;
				const gchar* _tmp25_;
				GFile* _tmp26_;
				GFile* _tmp27_;
				gchar** _tmp31_;
				gint _tmp31__length1;
				if (!_tmp21_) {
					gint _tmp22_;
					_tmp22_ = i;
					i = _tmp22_ + 1;
				}
				_tmp21_ = FALSE;
				_tmp23_ = tabs;
				_tmp23__length1 = tabs_length1;
				if (!(i < _tmp23__length1)) {
					break;
				}
				_tmp24_ = tabs;
				_tmp24__length1 = tabs_length1;
				_tmp25_ = _tmp24_[i];
				_tmp26_ = g_file_new_for_path (_tmp25_);
				file = _tmp26_;
				_tmp27_ = file;
				if (!g_file_query_exists (_tmp27_, NULL)) {
					gint _tmp28_;
					gchar** _tmp29_;
					gint _tmp29__length1;
					gchar* _tmp30_;
					_tmp28_ = null_dirs;
					null_dirs = _tmp28_ + 1;
					_tmp29_ = tabs;
					_tmp29__length1 = tabs_length1;
					_tmp30_ = g_strdup ("");
					_g_free0 (_tmp29_[i]);
					_tmp29_[i] = _tmp30_;
				}
				_tmp31_ = tabs;
				_tmp31__length1 = tabs_length1;
				if (null_dirs == _tmp31__length1) {
					gchar** _tmp32_;
					gint _tmp32__length1;
					gchar* _tmp33_;
					_tmp32_ = tabs;
					_tmp32__length1 = tabs_length1;
					_tmp33_ = g_get_current_dir ();
					_g_free0 (_tmp32_[0]);
					_tmp32_[0] = _tmp33_;
				}
				_g_object_unref0 (file);
			}
		}
	}
	_tmp34_ = tabs;
	_tmp34__length1 = tabs_length1;
	focus = CLAMP (focus, 0, _tmp34__length1 - 1);
	_tmp35_ = self->priv->_notebook;
	_tmp36_ = terminal_terminal_view_get_n_pages (_tmp35_);
	_tmp37_ = _tmp36_;
	focus += _tmp37_;
	index = 0;
	_tmp38_ = tabs;
	_tmp38__length1 = tabs_length1;
	{
		gchar** loc_collection = NULL;
		gint loc_collection_length1 = 0;
		gint _loc_collection_size_ = 0;
		gint loc_it = 0;
		loc_collection = _tmp38_;
		loc_collection_length1 = _tmp38__length1;
		for (loc_it = 0; loc_it < loc_collection_length1; loc_it = loc_it + 1) {
			gchar* _tmp39_;
			gchar* loc = NULL;
			_tmp39_ = g_strdup (loc_collection[loc_it]);
			loc = _tmp39_;
			{
				const gchar* _tmp40_;
				gint _tmp48_;
				_tmp40_ = loc;
				if (g_strcmp0 (_tmp40_, "") == 0) {
					gint _tmp41_;
					_tmp41_ = focus;
					focus = _tmp41_ - 1;
				} else {
					TerminalTerminalWidget* term = NULL;
					TerminalTerminalView* _tmp42_;
					const gchar* _tmp43_;
					TerminalTerminalWidget* _tmp44_;
					TerminalTerminalWidget* _tmp45_;
					gdouble* _tmp46_;
					gint _tmp46__length1;
					gdouble _tmp47_;
					_tmp42_ = self->priv->_notebook;
					_tmp43_ = loc;
					_tmp44_ = terminal_terminal_view_add_new_tab (_tmp42_, _tmp43_, "", -1);
					term = _tmp44_;
					_tmp45_ = term;
					_tmp46_ = zooms;
					_tmp46__length1 = zooms_length1;
					_tmp47_ = _tmp46_[index];
					vte_terminal_set_font_scale ((VteTerminal*) _tmp45_, CLAMP (_tmp47_, TERMINAL_TERMINAL_WIDGET_MIN_SCALE, TERMINAL_TERMINAL_WIDGET_MAX_SCALE));
					_g_object_unref0 (term);
				}
				_tmp48_ = index;
				index = _tmp48_ + 1;
				_g_free0 (loc);
			}
		}
	}
	_tmp49_ = self->priv->_notebook;
	_tmp50_ = self->priv->_notebook;
	_tmp51_ = terminal_terminal_view_get_tab_view (_tmp50_);
	_tmp52_ = _tmp51_;
	_tmp53_ = self->priv->_notebook;
	_tmp54_ = terminal_terminal_view_get_n_pages (_tmp53_);
	_tmp55_ = _tmp54_;
	_tmp56_ = adw_tab_view_get_nth_page (_tmp52_, CLAMP (focus, 0, _tmp55_ - 1));
	terminal_terminal_view_set_selected_page (_tmp49_, _tmp56_);
	zooms = (g_free (zooms), NULL);
	tabs = (_vala_array_free (tabs, tabs_length1, (GDestroyNotify) g_free), NULL);
}

static void
_terminal_main_window_on_terminal_child_exited_vte_terminal_child_exited (VteTerminal* _sender,
                                                                          gint status,
                                                                          gpointer self)
{
	terminal_main_window_on_terminal_child_exited ((TerminalMainWindow*) self, _sender, status);
}

static void
_terminal_main_window_on_terminal_cwd_changed_terminal_terminal_widget_cwd_changed (TerminalTerminalWidget* _sender,
                                                                                    gpointer self)
{
	terminal_main_window_on_terminal_cwd_changed ((TerminalMainWindow*) self);
}

static void
_terminal_main_window_set_title_label_terminal_terminal_widget_foreground_process_changed (TerminalTerminalWidget* _sender,
                                                                                           const gchar* cmdline,
                                                                                           gpointer self)
{
	terminal_main_window_set_title_label ((TerminalMainWindow*) self);
}

static void
_terminal_main_window_set_title_label_vte_terminal_window_title_changed (VteTerminal* _sender,
                                                                         gpointer self)
{
	terminal_main_window_set_title_label ((TerminalMainWindow*) self);
}

static void
terminal_main_window_connect_terminal_signals (TerminalMainWindow* self,
                                               TerminalTerminalWidget* terminal_widget)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (terminal_widget != NULL);
	g_signal_connect_object ((VteTerminal*) terminal_widget, "child-exited", (GCallback) _terminal_main_window_on_terminal_child_exited_vte_terminal_child_exited, self, 0);
	g_signal_connect_object (terminal_widget, "cwd-changed", (GCallback) _terminal_main_window_on_terminal_cwd_changed_terminal_terminal_widget_cwd_changed, self, 0);
	g_signal_connect_object (terminal_widget, "foreground-process-changed", (GCallback) _terminal_main_window_set_title_label_terminal_terminal_widget_foreground_process_changed, self, 0);
	g_signal_connect_object ((VteTerminal*) terminal_widget, "window-title-changed", (GCallback) _terminal_main_window_set_title_label_vte_terminal_window_title_changed, self, 0);
}

static void
terminal_main_window_on_terminal_child_exited (TerminalMainWindow* self,
                                               VteTerminal* term,
                                               gint status)
{
	TerminalTerminalWidget* tw = NULL;
	TerminalTerminalWidget* _tmp0_;
	TerminalTerminalWidget* _tmp1_;
	AdwTabPage* _tmp2_;
	GtkWidget* _tmp3_;
	GtkWidget* _tmp4_;
	TerminalTerminalWidget* _tmp5_;
	GtkWidget* _tmp6_;
	GtkWidget* _tmp7_;
	TerminalTerminalWidget* _tmp8_;
	gboolean _tmp9_;
	gboolean _tmp10_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (term != NULL);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (term, TERMINAL_TYPE_TERMINAL_WIDGET, TerminalTerminalWidget));
	tw = _tmp0_;
	_tmp1_ = tw;
	_tmp2_ = _tmp1_->tab;
	_tmp3_ = adw_tab_page_get_child (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = tw;
	_tmp6_ = gtk_widget_get_parent ((GtkWidget*) _tmp5_);
	_tmp7_ = _tmp6_;
	if (_tmp4_ != _tmp7_) {
		_g_object_unref0 (tw);
		return;
	}
	_tmp8_ = tw;
	_tmp9_ = terminal_terminal_widget_get_killed (_tmp8_);
	_tmp10_ = _tmp9_;
	if (!_tmp10_) {
		TerminalTerminalWidget* _tmp11_;
		const gchar* _tmp12_;
		const gchar* _tmp13_;
		gint _tmp14_;
		gint _tmp15_;
		_tmp11_ = tw;
		_tmp12_ = terminal_terminal_widget_get_program_string (_tmp11_);
		_tmp13_ = _tmp12_;
		_tmp14_ = strlen (_tmp13_);
		_tmp15_ = _tmp14_;
		if (_tmp15_ > 0) {
			TerminalTerminalWidget* _tmp16_;
			TerminalTerminalWidget* _tmp17_;
			TerminalTerminalWidget* _tmp18_;
			const gchar* _tmp19_;
			const gchar* _tmp20_;
			_tmp16_ = tw;
			terminal_terminal_widget_set_program_string (_tmp16_, "");
			_tmp17_ = tw;
			_tmp18_ = tw;
			_tmp19_ = terminal_terminal_widget_get_current_working_directory (_tmp18_);
			_tmp20_ = _tmp19_;
			terminal_terminal_widget_active_shell (_tmp17_, _tmp20_);
			terminal_main_window_check_for_tabs_with_same_name (self);
		} else {
			TerminalTerminalWidget* _tmp21_;
			AdwTabPage* _tmp22_;
			_tmp21_ = tw;
			_tmp22_ = _tmp21_->tab;
			if (_tmp22_ != NULL) {
				TerminalTerminalView* _tmp23_;
				AdwTabView* _tmp24_;
				AdwTabView* _tmp25_;
				TerminalTerminalWidget* _tmp26_;
				AdwTabPage* _tmp27_;
				_tmp23_ = self->priv->_notebook;
				_tmp24_ = terminal_terminal_view_get_tab_view (_tmp23_);
				_tmp25_ = _tmp24_;
				_tmp26_ = tw;
				_tmp27_ = _tmp26_->tab;
				adw_tab_view_close_page (_tmp25_, _tmp27_);
			}
			_g_object_unref0 (tw);
			return;
		}
	}
	_g_object_unref0 (tw);
}

static void
terminal_main_window_set_title_label (TerminalMainWindow* self)
{
	TerminalTerminalWidget* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_current_terminal;
	_tmp1_ = vte_terminal_get_window_title ((VteTerminal*) _tmp0_);
	_tmp2_ = _tmp1_;
	if (g_strcmp0 (_tmp2_, "") != 0) {
		TerminalTerminalWidget* _tmp3_;
		const gchar* _tmp4_;
		const gchar* _tmp5_;
		_tmp3_ = self->priv->_current_terminal;
		_tmp4_ = vte_terminal_get_window_title ((VteTerminal*) _tmp3_);
		_tmp5_ = _tmp4_;
		gtk_window_set_title ((GtkWindow*) self, _tmp5_);
	} else {
		TerminalTerminalWidget* _tmp6_;
		const gchar* _tmp7_;
		const gchar* _tmp8_;
		_tmp6_ = self->priv->_current_terminal;
		_tmp7_ = terminal_terminal_widget_get_current_working_directory (_tmp6_);
		_tmp8_ = _tmp7_;
		if (g_strcmp0 (_tmp8_, "") != 0) {
			TerminalTerminalWidget* _tmp9_;
			const gchar* _tmp10_;
			const gchar* _tmp11_;
			_tmp9_ = self->priv->_current_terminal;
			_tmp10_ = terminal_terminal_widget_get_current_working_directory (_tmp9_);
			_tmp11_ = _tmp10_;
			gtk_window_set_title ((GtkWindow*) self, _tmp11_);
		} else {
			gtk_window_set_title ((GtkWindow*) self, TERMINAL_TERMINAL_WIDGET_DEFAULT_LABEL);
		}
	}
}

static void
______lambda36_ (TerminalMainWindow* self,
                 gboolean confirmed)
{
	if (confirmed) {
		terminal_main_window_terminate_all (self);
		self->priv->close_immediately = TRUE;
		gtk_window_close ((GtkWindow*) self);
	}
}

static void
_______lambda36__terminal_terminal_widget_confirmed_action_callback (gboolean confirmed,
                                                                     gpointer self)
{
	______lambda36_ ((TerminalMainWindow*) self, confirmed);
}

static gboolean
terminal_main_window_on_delete_event (TerminalMainWindow* self)
{
	TerminalTerminalView* _tmp0_;
	AdwTabView* _tmp1_;
	AdwTabView* _tmp2_;
	guint _tmp3_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	if (self->priv->close_immediately) {
		result = GDK_EVENT_PROPAGATE;
		return result;
	}
	_tmp0_ = self->priv->_notebook;
	_tmp1_ = terminal_terminal_view_get_tab_view (_tmp0_);
	_tmp2_ = _tmp1_;
	g_signal_parse_name ("page-detached", adw_tab_view_get_type (), &_tmp3_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_tmp2_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp3_, 0, NULL, (GCallback) _terminal_main_window_on_tab_removed_adw_tab_view_page_detached, self);
	terminal_main_window_save_opened_terminals (self, TRUE, TRUE);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp4_ = FALSE;
			_tmp4_ = TRUE;
			while (TRUE) {
				TerminalTerminalView* _tmp6_;
				gint _tmp7_;
				gint _tmp8_;
				TerminalTerminalWidget* term = NULL;
				TerminalTerminalView* _tmp9_;
				AdwTabView* _tmp10_;
				AdwTabView* _tmp11_;
				AdwTabPage* _tmp12_;
				TerminalTerminalWidget* _tmp13_;
				TerminalTerminalWidget* _tmp14_;
				TerminalTerminalWidget* _tmp15_;
				if (!_tmp4_) {
					gint _tmp5_;
					_tmp5_ = i;
					i = _tmp5_ + 1;
				}
				_tmp4_ = FALSE;
				_tmp6_ = self->priv->_notebook;
				_tmp7_ = terminal_terminal_view_get_n_pages (_tmp6_);
				_tmp8_ = _tmp7_;
				if (!(i < _tmp8_)) {
					break;
				}
				_tmp9_ = self->priv->_notebook;
				_tmp10_ = terminal_terminal_view_get_tab_view (_tmp9_);
				_tmp11_ = _tmp10_;
				_tmp12_ = adw_tab_view_get_nth_page (_tmp11_, i);
				_tmp13_ = terminal_main_window_get_term_widget (_tmp12_);
				_tmp14_ = _g_object_ref0 (_tmp13_);
				term = _tmp14_;
				_tmp15_ = term;
				if (terminal_terminal_widget_has_foreground_process (_tmp15_)) {
					TerminalTerminalWidget* _tmp16_;
					_tmp16_ = term;
					terminal_terminal_widget_confirm_kill_fg_process (_tmp16_, _ ("Are you sure you want to close all foreground processes before closing" \
" the window?"), _ ("Close window"), _______lambda36__terminal_terminal_widget_confirmed_action_callback, self);
					result = GDK_EVENT_STOP;
					_g_object_unref0 (term);
					return result;
				}
				_g_object_unref0 (term);
			}
		}
	}
	terminal_main_window_terminate_all (self);
	result = GDK_EVENT_PROPAGATE;
	return result;
}

static void
terminal_main_window_terminate_all (TerminalMainWindow* self)
{
	g_return_if_fail (self != NULL);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				TerminalTerminalView* _tmp2_;
				gint _tmp3_;
				gint _tmp4_;
				TerminalTerminalWidget* term = NULL;
				TerminalTerminalView* _tmp5_;
				AdwTabView* _tmp6_;
				AdwTabView* _tmp7_;
				AdwTabPage* _tmp8_;
				TerminalTerminalWidget* _tmp9_;
				TerminalTerminalWidget* _tmp10_;
				TerminalTerminalWidget* _tmp11_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = self->priv->_notebook;
				_tmp3_ = terminal_terminal_view_get_n_pages (_tmp2_);
				_tmp4_ = _tmp3_;
				if (!(i < _tmp4_)) {
					break;
				}
				_tmp5_ = self->priv->_notebook;
				_tmp6_ = terminal_terminal_view_get_tab_view (_tmp5_);
				_tmp7_ = _tmp6_;
				_tmp8_ = adw_tab_view_get_nth_page (_tmp7_, i);
				_tmp9_ = terminal_main_window_get_term_widget (_tmp8_);
				_tmp10_ = _g_object_ref0 (_tmp9_);
				term = _tmp10_;
				_tmp11_ = term;
				terminal_main_window_terminate_and_disconnect (self, _tmp11_, FALSE);
				_g_object_unref0 (term);
			}
		}
	}
}

static void
terminal_main_window_terminate_and_disconnect (TerminalMainWindow* self,
                                               TerminalTerminalWidget* term,
                                               gboolean make_restorable_required)
{
	gboolean _tmp0_ = FALSE;
	g_return_if_fail (self != NULL);
	g_return_if_fail (term != NULL);
	terminal_terminal_widget_term_ps (term);
	if (make_restorable_required) {
		GSettings* _tmp1_;
		_tmp1_ = terminal_application_settings;
		_tmp0_ = g_settings_get_boolean (_tmp1_, "save-exited-tabs");
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		TerminalTerminalView* _tmp2_;
		const gchar* _tmp3_;
		const gchar* _tmp4_;
		_tmp2_ = self->priv->_notebook;
		_tmp3_ = terminal_terminal_widget_get_current_working_directory (term);
		_tmp4_ = _tmp3_;
		terminal_terminal_view_make_restorable (_tmp2_, _tmp4_);
	}
}

static void
terminal_main_window_action_close_tab (TerminalMainWindow* self)
{
	TerminalTerminalView* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_notebook;
	terminal_terminal_view_close_tab (_tmp0_);
}

static void
terminal_main_window_action_close_tabs_to_right (TerminalMainWindow* self)
{
	TerminalTerminalView* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_notebook;
	terminal_terminal_view_close_tabs_to_right (_tmp0_);
}

static void
terminal_main_window_action_close_other_tabs (TerminalMainWindow* self)
{
	TerminalTerminalView* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_notebook;
	terminal_terminal_view_close_other_tabs (_tmp0_);
}

static void
terminal_main_window_action_restore_closed_tab (TerminalMainWindow* self,
                                                GSimpleAction* action,
                                                GVariant* param)
{
	TerminalTerminalView* _tmp0_;
	const gchar* _tmp1_;
	TerminalTerminalWidget* _tmp2_;
	TerminalTerminalWidget* _tmp3_;
	TerminalTerminalView* _tmp4_;
	const gchar* _tmp5_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (action != NULL);
	_tmp0_ = self->priv->_notebook;
	_tmp1_ = g_variant_get_string (param, NULL);
	_tmp2_ = terminal_terminal_view_add_new_tab (_tmp0_, _tmp1_, "", -1);
	_tmp3_ = _tmp2_;
	_g_object_unref0 (_tmp3_);
	_tmp4_ = self->priv->_notebook;
	_tmp5_ = g_variant_get_string (param, NULL);
	terminal_terminal_view_after_tab_restored (_tmp4_, _tmp5_);
}

static void
terminal_main_window_action_new_tab (TerminalMainWindow* self)
{
	TerminalTerminalWidget* _tmp0_;
	GSettings* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_current_terminal;
	_vala_return_if_fail (_tmp0_ != NULL, "current_terminal != null");
	_tmp1_ = terminal_application_settings;
	if (g_settings_get_boolean (_tmp1_, "follow-last-tab")) {
		TerminalTerminalView* _tmp2_;
		TerminalTerminalWidget* _tmp3_;
		gchar* _tmp4_;
		gchar* _tmp5_;
		TerminalTerminalWidget* _tmp6_;
		TerminalTerminalWidget* _tmp7_;
		_tmp2_ = self->priv->_notebook;
		_tmp3_ = self->priv->_current_terminal;
		_tmp4_ = terminal_terminal_widget_get_shell_location (_tmp3_);
		_tmp5_ = _tmp4_;
		_tmp6_ = terminal_terminal_view_add_new_tab (_tmp2_, _tmp5_, "", -1);
		_tmp7_ = _tmp6_;
		_g_object_unref0 (_tmp7_);
		_g_free0 (_tmp5_);
	} else {
		TerminalTerminalView* _tmp8_;
		const gchar* _tmp9_;
		TerminalTerminalWidget* _tmp10_;
		TerminalTerminalWidget* _tmp11_;
		_tmp8_ = self->priv->_notebook;
		_tmp9_ = g_get_home_dir ();
		_tmp10_ = terminal_terminal_view_add_new_tab (_tmp8_, _tmp9_, "", -1);
		_tmp11_ = _tmp10_;
		_g_object_unref0 (_tmp11_);
	}
}

static void
terminal_main_window_action_new_tab_at (TerminalMainWindow* self,
                                        GSimpleAction* action,
                                        GVariant* param)
{
	const GVariantType* _tmp0_;
	TerminalTerminalView* _tmp1_;
	const gchar* _tmp2_;
	TerminalTerminalWidget* _tmp3_;
	TerminalTerminalWidget* _tmp4_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (action != NULL);
	_vala_return_if_fail (param != NULL, "param != null");
	_tmp0_ = G_VARIANT_TYPE_STRING;
	_vala_return_if_fail (g_variant_is_of_type (param, _tmp0_), "param.is_of_type (VariantType.STRING)");
	_tmp1_ = self->priv->_notebook;
	_tmp2_ = g_variant_get_string (param, NULL);
	_tmp3_ = terminal_terminal_view_add_new_tab (_tmp1_, _tmp2_, "", -1);
	_tmp4_ = _tmp3_;
	_g_object_unref0 (_tmp4_);
}

static void
terminal_main_window_action_tab_active_shell (TerminalMainWindow* self,
                                              GSimpleAction* action,
                                              GVariant* param)
{
	gchar* path = NULL;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	TerminalTerminalWidget* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (action != NULL);
	_tmp0_ = g_variant_get_string (param, NULL);
	_tmp1_ = g_strdup (_tmp0_);
	path = _tmp1_;
	_tmp2_ = self->priv->_current_terminal;
	terminal_terminal_widget_change_directory (_tmp2_, path);
	_g_free0 (path);
}

static void
terminal_main_window_action_tab_reload (TerminalMainWindow* self)
{
	TerminalTerminalWidget* term = NULL;
	AdwTabPage* target = NULL;
	TerminalTerminalView* _tmp0_;
	AdwTabPage* _tmp1_;
	AdwTabPage* _tmp2_;
	AdwTabPage* _tmp3_;
	AdwTabPage* _tmp4_;
	TerminalTerminalWidget* _tmp15_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_notebook;
	_tmp1_ = terminal_terminal_view_get_tab_menu_target (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	target = _tmp3_;
	_tmp4_ = target;
	if (_tmp4_ != NULL) {
		AdwTabPage* _tmp5_;
		TerminalTerminalWidget* _tmp6_;
		TerminalTerminalWidget* _tmp7_;
		_tmp5_ = target;
		_tmp6_ = terminal_main_window_get_term_widget (_tmp5_);
		_tmp7_ = _g_object_ref0 (_tmp6_);
		_g_object_unref0 (term);
		term = _tmp7_;
	} else {
		TerminalTerminalView* _tmp8_;
		AdwTabView* _tmp9_;
		AdwTabView* _tmp10_;
		AdwTabPage* _tmp11_;
		AdwTabPage* _tmp12_;
		TerminalTerminalWidget* _tmp13_;
		TerminalTerminalWidget* _tmp14_;
		_tmp8_ = self->priv->_notebook;
		_tmp9_ = terminal_terminal_view_get_tab_view (_tmp8_);
		_tmp10_ = _tmp9_;
		_tmp11_ = adw_tab_view_get_selected_page (_tmp10_);
		_tmp12_ = _tmp11_;
		_tmp13_ = terminal_main_window_get_term_widget (_tmp12_);
		_tmp14_ = _g_object_ref0 (_tmp13_);
		_g_object_unref0 (term);
		term = _tmp14_;
	}
	_tmp15_ = term;
	if (_tmp15_ != NULL) {
		TerminalTerminalWidget* _tmp16_;
		_tmp16_ = term;
		terminal_terminal_widget_reload (_tmp16_);
	}
	_g_object_unref0 (target);
	_g_object_unref0 (term);
}

static void
terminal_main_window_action_duplicate_tab (TerminalMainWindow* self)
{
	TerminalTerminalWidget* _tmp0_;
	TerminalTerminalWidget* _tmp1_ = NULL;
	TerminalTerminalView* _tmp2_;
	AdwTabPage* _tmp3_;
	AdwTabPage* _tmp4_;
	TerminalTerminalWidget* term = NULL;
	TerminalTerminalWidget* _tmp10_;
	gint _tmp11_ = 0;
	TerminalTerminalView* _tmp12_;
	AdwTabPage* _tmp13_;
	AdwTabPage* _tmp14_;
	gint pos = 0;
	TerminalTerminalView* _tmp24_;
	TerminalTerminalWidget* _tmp25_;
	gchar* _tmp26_;
	gchar* _tmp27_;
	TerminalTerminalWidget* _tmp28_;
	TerminalTerminalWidget* _tmp29_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_current_terminal;
	_vala_return_if_fail (_tmp0_ != NULL, "current_terminal != null");
	_tmp2_ = self->priv->_notebook;
	_tmp3_ = terminal_terminal_view_get_tab_menu_target (_tmp2_);
	_tmp4_ = _tmp3_;
	if (_tmp4_ != NULL) {
		TerminalTerminalView* _tmp5_;
		AdwTabPage* _tmp6_;
		AdwTabPage* _tmp7_;
		TerminalTerminalWidget* _tmp8_;
		_tmp5_ = self->priv->_notebook;
		_tmp6_ = terminal_terminal_view_get_tab_menu_target (_tmp5_);
		_tmp7_ = _tmp6_;
		_tmp8_ = terminal_main_window_get_term_widget (_tmp7_);
		_tmp1_ = _tmp8_;
	} else {
		TerminalTerminalWidget* _tmp9_;
		_tmp9_ = self->priv->_current_terminal;
		_tmp1_ = _tmp9_;
	}
	_tmp10_ = _g_object_ref0 (_tmp1_);
	term = _tmp10_;
	_tmp12_ = self->priv->_notebook;
	_tmp13_ = terminal_terminal_view_get_tab_menu_target (_tmp12_);
	_tmp14_ = _tmp13_;
	if (_tmp14_ != NULL) {
		TerminalTerminalView* _tmp15_;
		AdwTabView* _tmp16_;
		AdwTabView* _tmp17_;
		TerminalTerminalView* _tmp18_;
		AdwTabPage* _tmp19_;
		AdwTabPage* _tmp20_;
		_tmp15_ = self->priv->_notebook;
		_tmp16_ = terminal_terminal_view_get_tab_view (_tmp15_);
		_tmp17_ = _tmp16_;
		_tmp18_ = self->priv->_notebook;
		_tmp19_ = terminal_terminal_view_get_tab_menu_target (_tmp18_);
		_tmp20_ = _tmp19_;
		_tmp11_ = adw_tab_view_get_page_position (_tmp17_, _tmp20_) + 1;
	} else {
		TerminalTerminalView* _tmp21_;
		gint _tmp22_;
		gint _tmp23_;
		_tmp21_ = self->priv->_notebook;
		_tmp22_ = terminal_terminal_view_get_n_pages (_tmp21_);
		_tmp23_ = _tmp22_;
		_tmp11_ = _tmp23_;
	}
	pos = _tmp11_;
	_tmp24_ = self->priv->_notebook;
	_tmp25_ = term;
	_tmp26_ = terminal_terminal_widget_get_shell_location (_tmp25_);
	_tmp27_ = _tmp26_;
	_tmp28_ = terminal_terminal_view_add_new_tab (_tmp24_, _tmp27_, "", pos);
	_tmp29_ = _tmp28_;
	_g_object_unref0 (_tmp29_);
	_g_free0 (_tmp27_);
	_g_object_unref0 (term);
}

static void
terminal_main_window_action_next_tab (TerminalMainWindow* self)
{
	TerminalTerminalView* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_notebook;
	terminal_terminal_view_cycle_tabs (_tmp0_, ADW_NAVIGATION_DIRECTION_FORWARD);
}

static void
terminal_main_window_action_previous_tab (TerminalMainWindow* self)
{
	TerminalTerminalView* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_notebook;
	terminal_terminal_view_cycle_tabs (_tmp0_, ADW_NAVIGATION_DIRECTION_BACK);
}

static void
terminal_main_window_action_move_tab_right (TerminalMainWindow* self)
{
	TerminalTerminalView* _tmp0_;
	AdwTabView* _tmp1_;
	AdwTabView* _tmp2_;
	TerminalTerminalView* _tmp3_;
	AdwTabPage* _tmp4_;
	AdwTabPage* _tmp5_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_notebook;
	_tmp1_ = terminal_terminal_view_get_tab_view (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = self->priv->_notebook;
	_tmp4_ = terminal_terminal_view_get_selected_page (_tmp3_);
	_tmp5_ = _tmp4_;
	adw_tab_view_reorder_forward (_tmp2_, _tmp5_);
}

static void
terminal_main_window_action_move_tab_left (TerminalMainWindow* self)
{
	TerminalTerminalView* _tmp0_;
	AdwTabView* _tmp1_;
	AdwTabView* _tmp2_;
	TerminalTerminalView* _tmp3_;
	AdwTabPage* _tmp4_;
	AdwTabPage* _tmp5_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_notebook;
	_tmp1_ = terminal_terminal_view_get_tab_view (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = self->priv->_notebook;
	_tmp4_ = terminal_terminal_view_get_selected_page (_tmp3_);
	_tmp5_ = _tmp4_;
	adw_tab_view_reorder_backward (_tmp2_, _tmp5_);
}

static void
terminal_main_window_action_move_tab_to_new_window (TerminalMainWindow* self)
{
	TerminalTerminalView* _tmp0_;
	TerminalMainWindow* _tmp1_;
	TerminalMainWindow* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_notebook;
	_tmp1_ = terminal_main_window_present_new_empty_window (self);
	_tmp2_ = _tmp1_;
	terminal_terminal_view_transfer_tab_to_window (_tmp0_, _tmp2_);
	_g_object_unref0 (_tmp2_);
}

static void
terminal_main_window_action_search_change_state (TerminalMainWindow* self,
                                                 GSimpleAction* search_action,
                                                 GVariant* value)
{
	const GVariantType* _tmp0_;
	TerminalTerminalWidget* _tmp1_;
	GVariant* _tmp2_;
	GVariant* _tmp3_;
	GVariant* _tmp4_;
	gboolean _tmp5_;
	gchar** next_accels = NULL;
	gchar** _tmp34_;
	gint next_accels_length1;
	gint _next_accels_size_;
	GeeMultiMap* _tmp35_;
	GeeCollection* _tmp36_;
	GeeCollection* _tmp37_;
	gboolean _tmp38_;
	gboolean _tmp39_;
	gboolean _tmp40_;
	gchar** prev_accels = NULL;
	gchar** _tmp46_;
	gint prev_accels_length1;
	gint _prev_accels_size_;
	GeeMultiMap* _tmp47_;
	GeeCollection* _tmp48_;
	GeeCollection* _tmp49_;
	gboolean _tmp50_;
	gboolean _tmp51_;
	gboolean _tmp52_;
	TerminalApplication* _tmp58_;
	gchar** _tmp59_;
	gint _tmp59__length1;
	TerminalApplication* _tmp60_;
	gchar** _tmp61_;
	gint _tmp61__length1;
	g_return_if_fail (self != NULL);
	g_return_if_fail (search_action != NULL);
	g_return_if_fail (value != NULL);
	_tmp0_ = G_VARIANT_TYPE_BOOLEAN;
	_vala_return_if_fail (g_variant_is_of_type (value, _tmp0_), "value.is_of_type (VariantType.BOOLEAN)");
	_tmp1_ = self->priv->_current_terminal;
	_vala_return_if_fail (_tmp1_ != NULL, "current_terminal != null");
	g_simple_action_set_state (search_action, value);
	_tmp2_ = g_action_get_state ((GAction*) search_action);
	_tmp3_ = _tmp2_;
	_tmp4_ = _tmp3_;
	_tmp5_ = g_variant_get_boolean (_tmp4_);
	_g_variant_unref0 (_tmp4_);
	if (_tmp5_) {
		GtkToggleButton* _tmp6_;
		GtkStack* _tmp7_;
		TerminalWidgetsSearchToolbar* _tmp8_;
		GeeMultiMap* _tmp9_;
		GeeMultiMap* _tmp10_;
		GeeMultiMap* _tmp11_;
		GeeMultiMap* _tmp12_;
		GtkToggleButton* _tmp13_;
		gchar* _tmp14_;
		gchar* _tmp15_;
		gchar** _tmp16_;
		gchar** _tmp17_;
		gint _tmp17__length1;
		gchar* _tmp18_;
		gchar* _tmp19_;
		TerminalWidgetsSearchToolbar* _tmp20_;
		_tmp6_ = self->priv->search_button;
		gtk_toggle_button_set_active (_tmp6_, TRUE);
		_tmp7_ = self->priv->title_stack;
		_tmp8_ = self->priv->search_toolbar;
		gtk_stack_set_visible_child (_tmp7_, (GtkWidget*) _tmp8_);
		_tmp9_ = terminal_main_window_action_accelerators;
		gee_multi_map_set (_tmp9_, TERMINAL_MAIN_WINDOW_ACTION_SEARCH_NEXT, "<Control>g");
		_tmp10_ = terminal_main_window_action_accelerators;
		gee_multi_map_set (_tmp10_, TERMINAL_MAIN_WINDOW_ACTION_SEARCH_NEXT, "<Control>Down");
		_tmp11_ = terminal_main_window_action_accelerators;
		gee_multi_map_set (_tmp11_, TERMINAL_MAIN_WINDOW_ACTION_SEARCH_PREVIOUS, "<Control><Shift>g");
		_tmp12_ = terminal_main_window_action_accelerators;
		gee_multi_map_set (_tmp12_, TERMINAL_MAIN_WINDOW_ACTION_SEARCH_PREVIOUS, "<Control>Up");
		_tmp13_ = self->priv->search_button;
		_tmp14_ = g_strdup ("Escape");
		_tmp15_ = g_strdup ("<Ctrl><Shift>f");
		_tmp16_ = g_new0 (gchar*, 2 + 1);
		_tmp16_[0] = _tmp14_;
		_tmp16_[1] = _tmp15_;
		_tmp17_ = _tmp16_;
		_tmp17__length1 = 2;
		_tmp18_ = granite_markup_accel_tooltip (_tmp17_, (gint) 2, _ ("Hide find bar"));
		_tmp19_ = _tmp18_;
		gtk_widget_set_tooltip_markup ((GtkWidget*) _tmp13_, _tmp19_);
		_g_free0 (_tmp19_);
		_tmp17_ = (_vala_array_free (_tmp17_, _tmp17__length1, (GDestroyNotify) g_free), NULL);
		_tmp20_ = self->priv->search_toolbar;
		gtk_widget_grab_focus ((GtkWidget*) _tmp20_);
	} else {
		GtkToggleButton* _tmp21_;
		GtkStack* _tmp22_;
		GtkLabel* _tmp23_;
		GeeMultiMap* _tmp24_;
		GeeMultiMap* _tmp25_;
		GtkToggleButton* _tmp26_;
		gchar* _tmp27_;
		gchar** _tmp28_;
		gchar** _tmp29_;
		gint _tmp29__length1;
		gchar* _tmp30_;
		gchar* _tmp31_;
		TerminalWidgetsSearchToolbar* _tmp32_;
		TerminalTerminalWidget* _tmp33_;
		_tmp21_ = self->priv->search_button;
		gtk_toggle_button_set_active (_tmp21_, FALSE);
		_tmp22_ = self->priv->title_stack;
		_tmp23_ = self->priv->title_label;
		gtk_stack_set_visible_child (_tmp22_, (GtkWidget*) _tmp23_);
		_tmp24_ = terminal_main_window_action_accelerators;
		gee_multi_map_remove_all (_tmp24_, TERMINAL_MAIN_WINDOW_ACTION_SEARCH_NEXT);
		_tmp25_ = terminal_main_window_action_accelerators;
		gee_multi_map_remove_all (_tmp25_, TERMINAL_MAIN_WINDOW_ACTION_SEARCH_PREVIOUS);
		_tmp26_ = self->priv->search_button;
		_tmp27_ = g_strdup ("<Ctrl><Shift>f");
		_tmp28_ = g_new0 (gchar*, 1 + 1);
		_tmp28_[0] = _tmp27_;
		_tmp29_ = _tmp28_;
		_tmp29__length1 = 1;
		_tmp30_ = granite_markup_accel_tooltip (_tmp29_, (gint) 1, _ ("Find…"));
		_tmp31_ = _tmp30_;
		gtk_widget_set_tooltip_markup ((GtkWidget*) _tmp26_, _tmp31_);
		_g_free0 (_tmp31_);
		_tmp29_ = (_vala_array_free (_tmp29_, _tmp29__length1, (GDestroyNotify) g_free), NULL);
		_tmp32_ = self->priv->search_toolbar;
		terminal_widgets_search_toolbar_clear (_tmp32_);
		_tmp33_ = self->priv->_current_terminal;
		gtk_widget_grab_focus ((GtkWidget*) _tmp33_);
	}
	_tmp34_ = g_new0 (gchar*, 0 + 1);
	next_accels = _tmp34_;
	next_accels_length1 = 0;
	_next_accels_size_ = next_accels_length1;
	_tmp35_ = terminal_main_window_action_accelerators;
	_tmp36_ = gee_multi_map_get (_tmp35_, TERMINAL_MAIN_WINDOW_ACTION_SEARCH_NEXT);
	_tmp37_ = _tmp36_;
	_tmp38_ = gee_collection_get_is_empty (_tmp37_);
	_tmp39_ = _tmp38_;
	_tmp40_ = !_tmp39_;
	_g_object_unref0 (_tmp37_);
	if (_tmp40_) {
		GeeMultiMap* _tmp41_;
		GeeCollection* _tmp42_;
		GeeCollection* _tmp43_;
		gint _tmp44_ = 0;
		gpointer* _tmp45_;
		_tmp41_ = terminal_main_window_action_accelerators;
		_tmp42_ = gee_multi_map_get (_tmp41_, TERMINAL_MAIN_WINDOW_ACTION_SEARCH_NEXT);
		_tmp43_ = _tmp42_;
		_tmp45_ = gee_collection_to_array (_tmp43_, &_tmp44_);
		next_accels = (_vala_array_free (next_accels, next_accels_length1, (GDestroyNotify) g_free), NULL);
		next_accels = _tmp45_;
		next_accels_length1 = _tmp44_;
		_next_accels_size_ = next_accels_length1;
		_g_object_unref0 (_tmp43_);
	}
	_tmp46_ = g_new0 (gchar*, 0 + 1);
	prev_accels = _tmp46_;
	prev_accels_length1 = 0;
	_prev_accels_size_ = prev_accels_length1;
	_tmp47_ = terminal_main_window_action_accelerators;
	_tmp48_ = gee_multi_map_get (_tmp47_, TERMINAL_MAIN_WINDOW_ACTION_SEARCH_NEXT);
	_tmp49_ = _tmp48_;
	_tmp50_ = gee_collection_get_is_empty (_tmp49_);
	_tmp51_ = _tmp50_;
	_tmp52_ = !_tmp51_;
	_g_object_unref0 (_tmp49_);
	if (_tmp52_) {
		GeeMultiMap* _tmp53_;
		GeeCollection* _tmp54_;
		GeeCollection* _tmp55_;
		gint _tmp56_ = 0;
		gpointer* _tmp57_;
		_tmp53_ = terminal_main_window_action_accelerators;
		_tmp54_ = gee_multi_map_get (_tmp53_, TERMINAL_MAIN_WINDOW_ACTION_SEARCH_PREVIOUS);
		_tmp55_ = _tmp54_;
		_tmp57_ = gee_collection_to_array (_tmp55_, &_tmp56_);
		prev_accels = (_vala_array_free (prev_accels, prev_accels_length1, (GDestroyNotify) g_free), NULL);
		prev_accels = _tmp57_;
		prev_accels_length1 = _tmp56_;
		_prev_accels_size_ = prev_accels_length1;
		_g_object_unref0 (_tmp55_);
	}
	_tmp58_ = self->priv->_app;
	_tmp59_ = next_accels;
	_tmp59__length1 = next_accels_length1;
	gtk_application_set_accels_for_action ((GtkApplication*) _tmp58_, TERMINAL_MAIN_WINDOW_ACTION_PREFIX TERMINAL_MAIN_WINDOW_ACTION_SEARCH_NEXT, _tmp59_);
	_tmp60_ = self->priv->_app;
	_tmp61_ = prev_accels;
	_tmp61__length1 = prev_accels_length1;
	gtk_application_set_accels_for_action ((GtkApplication*) _tmp60_, TERMINAL_MAIN_WINDOW_ACTION_PREFIX TERMINAL_MAIN_WINDOW_ACTION_SEARCH_PREVIOUS, _tmp61_);
	prev_accels = (_vala_array_free (prev_accels, prev_accels_length1, (GDestroyNotify) g_free), NULL);
	next_accels = (_vala_array_free (next_accels, next_accels_length1, (GDestroyNotify) g_free), NULL);
}

static GVariant*
_variant_new4 (gboolean value)
{
	return g_variant_ref_sink (g_variant_new_boolean (value));
}

static void
terminal_main_window_action_search (TerminalMainWindow* self)
{
	GSimpleAction* search_action = NULL;
	GSimpleActionGroup* _tmp0_;
	GAction* _tmp1_;
	GVariant* _tmp2_;
	GVariant* _tmp3_;
	GVariant* _tmp4_;
	GVariant* _tmp5_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_actions;
	_tmp1_ = g_action_map_lookup_action ((GActionMap*) _tmp0_, TERMINAL_MAIN_WINDOW_ACTION_SEARCH);
	search_action = G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, g_simple_action_get_type (), GSimpleAction);
	_tmp2_ = g_action_get_state ((GAction*) search_action);
	_tmp3_ = _tmp2_;
	_tmp4_ = _tmp3_;
	_tmp5_ = _variant_new4 (!g_variant_get_boolean (_tmp4_));
	g_signal_emit_by_name (search_action, "change-state", _tmp5_);
	_g_variant_unref0 (_tmp5_);
	_g_variant_unref0 (_tmp4_);
}

static void
terminal_main_window_action_search_next (TerminalMainWindow* self)
{
	GSimpleActionGroup* _tmp0_;
	GAction* _tmp1_;
	GVariant* _tmp2_;
	GVariant* _tmp3_;
	GVariant* _tmp4_;
	gboolean _tmp5_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_actions;
	_tmp1_ = g_action_map_lookup_action ((GActionMap*) _tmp0_, TERMINAL_MAIN_WINDOW_ACTION_SEARCH);
	_tmp2_ = g_action_get_state (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = _tmp3_;
	_tmp5_ = g_variant_get_boolean (_tmp4_);
	_g_variant_unref0 (_tmp4_);
	if (_tmp5_) {
		TerminalWidgetsSearchToolbar* _tmp6_;
		_tmp6_ = self->priv->search_toolbar;
		terminal_widgets_search_toolbar_next_search (_tmp6_);
	}
}

static void
terminal_main_window_action_search_previous (TerminalMainWindow* self)
{
	GSimpleActionGroup* _tmp0_;
	GAction* _tmp1_;
	GVariant* _tmp2_;
	GVariant* _tmp3_;
	GVariant* _tmp4_;
	gboolean _tmp5_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_actions;
	_tmp1_ = g_action_map_lookup_action ((GActionMap*) _tmp0_, TERMINAL_MAIN_WINDOW_ACTION_SEARCH);
	_tmp2_ = g_action_get_state (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = _tmp3_;
	_tmp5_ = g_variant_get_boolean (_tmp4_);
	_g_variant_unref0 (_tmp4_);
	if (_tmp5_) {
		TerminalWidgetsSearchToolbar* _tmp6_;
		_tmp6_ = self->priv->search_toolbar;
		terminal_widgets_search_toolbar_previous_search (_tmp6_);
	}
}

static void
terminal_main_window_action_fullscreen (TerminalMainWindow* self)
{
	g_return_if_fail (self != NULL);
	if (gtk_window_is_fullscreen ((GtkWindow*) self)) {
		AdwHeaderBar* _tmp0_;
		GtkButton* _tmp1_;
		_tmp0_ = self->priv->header;
		adw_header_bar_set_decoration_layout (_tmp0_, NULL);
		_tmp1_ = self->priv->unfullscreen_button;
		gtk_widget_set_visible ((GtkWidget*) _tmp1_, FALSE);
		gtk_window_unfullscreen ((GtkWindow*) self);
	} else {
		AdwHeaderBar* _tmp2_;
		GtkButton* _tmp3_;
		_tmp2_ = self->priv->header;
		adw_header_bar_set_decoration_layout (_tmp2_, "close:");
		_tmp3_ = self->priv->unfullscreen_button;
		gtk_widget_set_visible ((GtkWidget*) _tmp3_, TRUE);
		gtk_window_fullscreen ((GtkWindow*) self);
	}
}

static TerminalTerminalWidget*
terminal_main_window_get_term_widget (AdwTabPage* tab)
{
	GtkScrolledWindow* tab_child = NULL;
	GtkWidget* _tmp0_;
	GtkWidget* _tmp1_;
	GtkScrolledWindow* _tmp2_;
	TerminalTerminalWidget* term = NULL;
	GtkScrolledWindow* _tmp3_;
	GtkWidget* _tmp4_;
	GtkWidget* _tmp5_;
	TerminalTerminalWidget* _tmp6_;
	TerminalTerminalWidget* result;
	if (tab == NULL) {
		result = NULL;
		return result;
	}
	_tmp0_ = adw_tab_page_get_child (tab);
	_tmp1_ = _tmp0_;
	_tmp2_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_scrolled_window_get_type (), GtkScrolledWindow));
	tab_child = _tmp2_;
	_tmp3_ = tab_child;
	_tmp4_ = gtk_scrolled_window_get_child (_tmp3_);
	_tmp5_ = _tmp4_;
	term = G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, TERMINAL_TYPE_TERMINAL_WIDGET, TerminalTerminalWidget);
	_tmp6_ = term;
	result = _tmp6_;
	_g_object_unref0 (tab_child);
	return result;
}

TerminalTerminalWidget*
terminal_main_window_get_terminal (TerminalMainWindow* self,
                                   const gchar* terminal_id)
{
	TerminalTerminalWidget* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (terminal_id != NULL, NULL);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				TerminalTerminalView* _tmp2_;
				gint _tmp3_;
				gint _tmp4_;
				TerminalTerminalWidget* term = NULL;
				TerminalTerminalView* _tmp5_;
				AdwTabView* _tmp6_;
				AdwTabView* _tmp7_;
				AdwTabPage* _tmp8_;
				TerminalTerminalWidget* _tmp9_;
				TerminalTerminalWidget* _tmp10_;
				const gchar* _tmp11_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = self->priv->_notebook;
				_tmp3_ = terminal_terminal_view_get_n_pages (_tmp2_);
				_tmp4_ = _tmp3_;
				if (!(i < _tmp4_)) {
					break;
				}
				_tmp5_ = self->priv->_notebook;
				_tmp6_ = terminal_terminal_view_get_tab_view (_tmp5_);
				_tmp7_ = _tmp6_;
				_tmp8_ = adw_tab_view_get_nth_page (_tmp7_, i);
				_tmp9_ = terminal_main_window_get_term_widget (_tmp8_);
				term = _tmp9_;
				_tmp10_ = term;
				_tmp11_ = _tmp10_->terminal_id;
				if (g_strcmp0 (_tmp11_, terminal_id) == 0) {
					TerminalTerminalWidget* _tmp12_;
					_tmp12_ = term;
					result = _tmp12_;
					return result;
				}
			}
		}
	}
	result = NULL;
	return result;
}

AdwTabPage*
terminal_main_window_get_page (TerminalMainWindow* self,
                               const gchar* terminal_id)
{
	AdwTabPage* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (terminal_id != NULL, NULL);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				TerminalTerminalView* _tmp2_;
				gint _tmp3_;
				gint _tmp4_;
				AdwTabPage* page = NULL;
				TerminalTerminalView* _tmp5_;
				AdwTabView* _tmp6_;
				AdwTabView* _tmp7_;
				AdwTabPage* _tmp8_;
				TerminalTerminalWidget* terminal_widget = NULL;
				AdwTabPage* _tmp9_;
				TerminalTerminalWidget* _tmp10_;
				TerminalTerminalWidget* _tmp11_;
				const gchar* _tmp12_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = self->priv->_notebook;
				_tmp3_ = terminal_terminal_view_get_n_pages (_tmp2_);
				_tmp4_ = _tmp3_;
				if (!(i < _tmp4_)) {
					break;
				}
				_tmp5_ = self->priv->_notebook;
				_tmp6_ = terminal_terminal_view_get_tab_view (_tmp5_);
				_tmp7_ = _tmp6_;
				_tmp8_ = adw_tab_view_get_nth_page (_tmp7_, i);
				page = _tmp8_;
				_tmp9_ = page;
				_tmp10_ = terminal_main_window_get_term_widget (_tmp9_);
				terminal_widget = _tmp10_;
				_tmp11_ = terminal_widget;
				_tmp12_ = _tmp11_->terminal_id;
				if (g_strcmp0 (_tmp12_, terminal_id) == 0) {
					AdwTabPage* _tmp13_;
					_tmp13_ = page;
					result = _tmp13_;
					return result;
				}
			}
		}
	}
	result = NULL;
	return result;
}

/** Compare every tab label with every other and resolve ambiguities **/
static void
terminal_main_window_check_for_tabs_with_same_name (TerminalMainWindow* self)
{
	TerminalTerminalWidget* _tmp0_;
	gint i = 0;
	gint j = 0;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_current_terminal;
	_vala_return_if_fail (_tmp0_ != NULL, "current_terminal != null");
	i = 0;
	j = 0;
	{
		gboolean _tmp1_ = FALSE;
		i = 0;
		_tmp1_ = TRUE;
		while (TRUE) {
			TerminalTerminalView* _tmp3_;
			gint _tmp4_;
			gint _tmp5_;
			TerminalTerminalWidget* term = NULL;
			TerminalTerminalView* _tmp6_;
			AdwTabView* _tmp7_;
			AdwTabView* _tmp8_;
			AdwTabPage* _tmp9_;
			TerminalTerminalWidget* _tmp10_;
			TerminalTerminalWidget* _tmp11_;
			gchar* term_path = NULL;
			gchar* term_label = NULL;
			TerminalTerminalWidget* _tmp12_;
			const gchar* _tmp13_;
			const gchar* _tmp14_;
			if (!_tmp1_) {
				gint _tmp2_;
				_tmp2_ = i;
				i = _tmp2_ + 1;
			}
			_tmp1_ = FALSE;
			_tmp3_ = self->priv->_notebook;
			_tmp4_ = terminal_terminal_view_get_n_pages (_tmp3_);
			_tmp5_ = _tmp4_;
			if (!(i < _tmp5_)) {
				break;
			}
			_tmp6_ = self->priv->_notebook;
			_tmp7_ = terminal_terminal_view_get_tab_view (_tmp6_);
			_tmp8_ = _tmp7_;
			_tmp9_ = adw_tab_view_get_nth_page (_tmp8_, i);
			_tmp10_ = terminal_main_window_get_term_widget (_tmp9_);
			_tmp11_ = _g_object_ref0 (_tmp10_);
			term = _tmp11_;
			_tmp12_ = term;
			_tmp13_ = terminal_terminal_widget_get_program_string (_tmp12_);
			_tmp14_ = _tmp13_;
			if (g_strcmp0 (_tmp14_, "") != 0) {
				TerminalTerminalWidget* _tmp15_;
				AdwTabPage* _tmp16_;
				TerminalTerminalWidget* _tmp17_;
				const gchar* _tmp18_;
				const gchar* _tmp19_;
				_tmp15_ = term;
				_tmp16_ = _tmp15_->tab;
				_tmp17_ = term;
				_tmp18_ = terminal_terminal_widget_get_program_string (_tmp17_);
				_tmp19_ = _tmp18_;
				adw_tab_page_set_title (_tmp16_, _tmp19_);
				_g_free0 (term_label);
				_g_free0 (term_path);
				_g_object_unref0 (term);
				continue;
			} else {
				TerminalTerminalWidget* _tmp20_;
				const gchar* _tmp21_;
				const gchar* _tmp22_;
				gchar* _tmp23_;
				const gchar* _tmp24_;
				gchar* _tmp25_;
				gboolean _tmp26_ = FALSE;
				const gchar* _tmp27_;
				_tmp20_ = term;
				_tmp21_ = terminal_terminal_widget_get_current_working_directory (_tmp20_);
				_tmp22_ = _tmp21_;
				_tmp23_ = g_strdup (_tmp22_);
				_g_free0 (term_path);
				term_path = _tmp23_;
				_tmp24_ = term_path;
				_tmp25_ = g_path_get_basename (_tmp24_);
				_g_free0 (term_label);
				term_label = _tmp25_;
				_tmp27_ = term_label;
				if (g_strcmp0 (_tmp27_, "") == 0) {
					_tmp26_ = TRUE;
				} else {
					const gchar* _tmp28_;
					_tmp28_ = term_label;
					_tmp26_ = g_strcmp0 (_tmp28_, "/") == 0;
				}
				if (_tmp26_) {
					TerminalTerminalWidget* _tmp29_;
					AdwTabPage* _tmp30_;
					_tmp29_ = term;
					_tmp30_ = _tmp29_->tab;
					adw_tab_page_set_title (_tmp30_, TERMINAL_TERMINAL_WIDGET_DEFAULT_LABEL);
					_g_free0 (term_label);
					_g_free0 (term_path);
					_g_object_unref0 (term);
					continue;
				} else {
					TerminalTerminalWidget* _tmp31_;
					AdwTabPage* _tmp32_;
					const gchar* _tmp33_;
					_tmp31_ = term;
					_tmp32_ = _tmp31_->tab;
					_tmp33_ = term_label;
					adw_tab_page_set_title (_tmp32_, _tmp33_);
				}
			}
			{
				gboolean _tmp34_ = FALSE;
				j = 0;
				_tmp34_ = TRUE;
				while (TRUE) {
					TerminalTerminalView* _tmp36_;
					gint _tmp37_;
					gint _tmp38_;
					TerminalTerminalWidget* term2 = NULL;
					TerminalTerminalView* _tmp39_;
					AdwTabView* _tmp40_;
					AdwTabView* _tmp41_;
					AdwTabPage* _tmp42_;
					TerminalTerminalWidget* _tmp43_;
					TerminalTerminalWidget* _tmp44_;
					gchar* term2_path = NULL;
					TerminalTerminalWidget* _tmp45_;
					const gchar* _tmp46_;
					const gchar* _tmp47_;
					gchar* _tmp48_;
					gchar* term2_name = NULL;
					const gchar* _tmp49_;
					gchar* _tmp50_;
					gboolean _tmp51_ = FALSE;
					gboolean _tmp52_ = FALSE;
					TerminalTerminalWidget* _tmp53_;
					const gchar* _tmp54_;
					TerminalTerminalWidget* _tmp55_;
					const gchar* _tmp56_;
					if (!_tmp34_) {
						gint _tmp35_;
						_tmp35_ = j;
						j = _tmp35_ + 1;
					}
					_tmp34_ = FALSE;
					_tmp36_ = self->priv->_notebook;
					_tmp37_ = terminal_terminal_view_get_n_pages (_tmp36_);
					_tmp38_ = _tmp37_;
					if (!(j < _tmp38_)) {
						break;
					}
					_tmp39_ = self->priv->_notebook;
					_tmp40_ = terminal_terminal_view_get_tab_view (_tmp39_);
					_tmp41_ = _tmp40_;
					_tmp42_ = adw_tab_view_get_nth_page (_tmp41_, j);
					_tmp43_ = terminal_main_window_get_term_widget (_tmp42_);
					_tmp44_ = _g_object_ref0 (_tmp43_);
					term2 = _tmp44_;
					_tmp45_ = term2;
					_tmp46_ = terminal_terminal_widget_get_current_working_directory (_tmp45_);
					_tmp47_ = _tmp46_;
					_tmp48_ = g_strdup (_tmp47_);
					term2_path = _tmp48_;
					_tmp49_ = term2_path;
					_tmp50_ = g_path_get_basename (_tmp49_);
					term2_name = _tmp50_;
					_tmp53_ = term2;
					_tmp54_ = _tmp53_->terminal_id;
					_tmp55_ = term;
					_tmp56_ = _tmp55_->terminal_id;
					if (g_strcmp0 (_tmp54_, _tmp56_) != 0) {
						const gchar* _tmp57_;
						const gchar* _tmp58_;
						_tmp57_ = term2_name;
						_tmp58_ = term_label;
						_tmp52_ = g_strcmp0 (_tmp57_, _tmp58_) == 0;
					} else {
						_tmp52_ = FALSE;
					}
					if (_tmp52_) {
						const gchar* _tmp59_;
						const gchar* _tmp60_;
						_tmp59_ = term2_path;
						_tmp60_ = term_path;
						_tmp51_ = g_strcmp0 (_tmp59_, _tmp60_) != 0;
					} else {
						_tmp51_ = FALSE;
					}
					if (_tmp51_) {
						TerminalTerminalWidget* _tmp61_;
						AdwTabPage* _tmp62_;
						const gchar* _tmp63_;
						const gchar* _tmp64_;
						gchar* _tmp65_;
						gchar* _tmp66_;
						TerminalTerminalWidget* _tmp67_;
						AdwTabPage* _tmp68_;
						const gchar* _tmp69_;
						const gchar* _tmp70_;
						gchar* _tmp71_;
						gchar* _tmp72_;
						_tmp61_ = term2;
						_tmp62_ = _tmp61_->tab;
						_tmp63_ = term2_path;
						_tmp64_ = term_path;
						_tmp65_ = terminal_main_window_disambiguate_label (_tmp63_, _tmp64_);
						_tmp66_ = _tmp65_;
						adw_tab_page_set_title (_tmp62_, _tmp66_);
						_g_free0 (_tmp66_);
						_tmp67_ = term;
						_tmp68_ = _tmp67_->tab;
						_tmp69_ = term_path;
						_tmp70_ = term2_path;
						_tmp71_ = terminal_main_window_disambiguate_label (_tmp69_, _tmp70_);
						_tmp72_ = _tmp71_;
						adw_tab_page_set_title (_tmp68_, _tmp72_);
						_g_free0 (_tmp72_);
					}
					_g_free0 (term2_name);
					_g_free0 (term2_path);
					_g_object_unref0 (term2);
				}
			}
			_g_free0 (term_label);
			_g_free0 (term_path);
			_g_object_unref0 (term);
		}
	}
}

static void
terminal_main_window_on_terminal_cwd_changed (TerminalMainWindow* self)
{
	g_return_if_fail (self != NULL);
	terminal_main_window_check_for_tabs_with_same_name (self);
	terminal_main_window_save_opened_terminals (self, TRUE, FALSE);
	terminal_main_window_set_title_label (self);
}

static void
_vala_array_add7 (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 gchar*
double_to_string (gdouble self)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gint _tmp1__length1;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* result;
	_tmp0_ = g_new0 (gchar, G_ASCII_DTOSTR_BUF_SIZE);
	_tmp1_ = _tmp0_;
	_tmp1__length1 = G_ASCII_DTOSTR_BUF_SIZE;
	_tmp2_ = g_ascii_dtostr (_tmp1_, (gint) G_ASCII_DTOSTR_BUF_SIZE, self);
	_tmp3_ = g_strdup (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp1_ = (g_free (_tmp1_), NULL);
	result = _tmp4_;
	return result;
}

static void
_vala_array_add8 (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;
}

void
terminal_main_window_save_opened_terminals (TerminalMainWindow* self,
                                            gboolean save_tabs,
                                            gboolean save_zooms)
{
	gchar** zooms = NULL;
	gchar** _tmp0_;
	gint zooms_length1;
	gint _zooms_size_;
	gchar** opened_tabs = NULL;
	gchar** _tmp1_;
	gint opened_tabs_length1;
	gint _opened_tabs_size_;
	gint focused_tab = 0;
	TerminalApplication* _tmp2_;
	gboolean _tmp3_;
	gboolean _tmp4_;
	gboolean _tmp5_ = FALSE;
	gboolean _tmp11_ = FALSE;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_new0 (gchar*, 0 + 1);
	zooms = _tmp0_;
	zooms_length1 = 0;
	_zooms_size_ = zooms_length1;
	_tmp1_ = g_new0 (gchar*, 0 + 1);
	opened_tabs = _tmp1_;
	opened_tabs_length1 = 0;
	_opened_tabs_size_ = opened_tabs_length1;
	focused_tab = 0;
	_tmp2_ = self->priv->_app;
	_tmp3_ = terminal_application_get_is_testing (_tmp2_);
	_tmp4_ = _tmp3_;
	if (_tmp4_) {
		opened_tabs = (_vala_array_free (opened_tabs, opened_tabs_length1, (GDestroyNotify) g_free), NULL);
		zooms = (_vala_array_free (zooms, zooms_length1, (GDestroyNotify) g_free), NULL);
		return;
	}
	if (save_zooms) {
		TerminalTerminalWidget* _tmp6_;
		_tmp6_ = self->priv->_current_terminal;
		_tmp5_ = _tmp6_ != NULL;
	} else {
		_tmp5_ = FALSE;
	}
	if (_tmp5_) {
		GSettings* _tmp7_;
		TerminalTerminalWidget* _tmp8_;
		gdouble _tmp9_;
		gdouble _tmp10_;
		_tmp7_ = terminal_application_saved_state;
		_tmp8_ = self->priv->_current_terminal;
		_tmp9_ = vte_terminal_get_font_scale ((VteTerminal*) _tmp8_);
		_tmp10_ = _tmp9_;
		g_settings_set_double (_tmp7_, "zoom", _tmp10_);
	}
	if (granite_services_system_history_is_enabled ()) {
		GSettings* _tmp12_;
		_tmp12_ = terminal_application_settings;
		_tmp11_ = g_settings_get_boolean (_tmp12_, "remember-tabs");
	} else {
		_tmp11_ = FALSE;
	}
	if (_tmp11_) {
		gboolean _tmp36_ = FALSE;
		{
			gint i = 0;
			i = 0;
			{
				gboolean _tmp13_ = FALSE;
				_tmp13_ = TRUE;
				while (TRUE) {
					TerminalTerminalView* _tmp15_;
					gint _tmp16_;
					gint _tmp17_;
					TerminalTerminalWidget* term = NULL;
					TerminalTerminalView* _tmp18_;
					AdwTabView* _tmp19_;
					AdwTabView* _tmp20_;
					AdwTabPage* _tmp21_;
					TerminalTerminalWidget* _tmp22_;
					TerminalTerminalWidget* _tmp23_;
					TerminalTerminalWidget* _tmp24_;
					if (!_tmp13_) {
						gint _tmp14_;
						_tmp14_ = i;
						i = _tmp14_ + 1;
					}
					_tmp13_ = FALSE;
					_tmp15_ = self->priv->_notebook;
					_tmp16_ = terminal_terminal_view_get_n_pages (_tmp15_);
					_tmp17_ = _tmp16_;
					if (!(i < _tmp17_)) {
						break;
					}
					_tmp18_ = self->priv->_notebook;
					_tmp19_ = terminal_terminal_view_get_tab_view (_tmp18_);
					_tmp20_ = _tmp19_;
					_tmp21_ = adw_tab_view_get_nth_page (_tmp20_, i);
					_tmp22_ = terminal_main_window_get_term_widget (_tmp21_);
					_tmp23_ = _g_object_ref0 (_tmp22_);
					term = _tmp23_;
					_tmp24_ = term;
					if (_tmp24_ != NULL) {
						gchar* location = NULL;
						TerminalTerminalWidget* _tmp25_;
						gchar* _tmp26_;
						gboolean _tmp27_ = FALSE;
						const gchar* _tmp28_;
						_tmp25_ = term;
						_tmp26_ = terminal_terminal_widget_get_shell_location (_tmp25_);
						location = _tmp26_;
						_tmp28_ = location;
						if (_tmp28_ != NULL) {
							const gchar* _tmp29_;
							_tmp29_ = location;
							_tmp27_ = g_strcmp0 (_tmp29_, "") != 0;
						} else {
							_tmp27_ = FALSE;
						}
						if (_tmp27_) {
							if (save_tabs) {
								const gchar* _tmp30_;
								gchar* _tmp31_;
								_tmp30_ = location;
								_tmp31_ = g_strdup (_tmp30_);
								_vala_array_add7 (&opened_tabs, &opened_tabs_length1, &_opened_tabs_size_, _tmp31_);
							}
							if (save_zooms) {
								TerminalTerminalWidget* _tmp32_;
								gdouble _tmp33_;
								gdouble _tmp34_;
								gchar* _tmp35_;
								_tmp32_ = term;
								_tmp33_ = vte_terminal_get_font_scale ((VteTerminal*) _tmp32_);
								_tmp34_ = _tmp33_;
								_tmp35_ = double_to_string (_tmp34_);
								_vala_array_add8 (&zooms, &zooms_length1, &_zooms_size_, _tmp35_);
							}
						}
						_g_free0 (location);
					}
					_g_object_unref0 (term);
				}
			}
		}
		if (save_tabs) {
			TerminalTerminalView* _tmp37_;
			AdwTabPage* _tmp38_;
			AdwTabPage* _tmp39_;
			_tmp37_ = self->priv->_notebook;
			_tmp38_ = terminal_terminal_view_get_selected_page (_tmp37_);
			_tmp39_ = _tmp38_;
			_tmp36_ = _tmp39_ != NULL;
		} else {
			_tmp36_ = FALSE;
		}
		if (_tmp36_) {
			TerminalTerminalView* _tmp40_;
			AdwTabView* _tmp41_;
			AdwTabView* _tmp42_;
			TerminalTerminalView* _tmp43_;
			AdwTabPage* _tmp44_;
			AdwTabPage* _tmp45_;
			_tmp40_ = self->priv->_notebook;
			_tmp41_ = terminal_terminal_view_get_tab_view (_tmp40_);
			_tmp42_ = _tmp41_;
			_tmp43_ = self->priv->_notebook;
			_tmp44_ = terminal_terminal_view_get_selected_page (_tmp43_);
			_tmp45_ = _tmp44_;
			focused_tab = adw_tab_view_get_page_position (_tmp42_, _tmp45_);
		}
	}
	if (save_tabs) {
		GSettings* _tmp46_;
		gchar** _tmp47_;
		gint _tmp47__length1;
		GSettings* _tmp48_;
		_tmp46_ = terminal_application_saved_state;
		_tmp47_ = opened_tabs;
		_tmp47__length1 = opened_tabs_length1;
		g_settings_set_strv (_tmp46_, "tabs", _tmp47_);
		_tmp48_ = terminal_application_saved_state;
		g_settings_set_int (_tmp48_, "focused-tab", focused_tab);
	}
	if (save_zooms) {
		GSettings* _tmp49_;
		gchar** _tmp50_;
		gint _tmp50__length1;
		_tmp49_ = terminal_application_saved_state;
		_tmp50_ = zooms;
		_tmp50__length1 = zooms_length1;
		g_settings_set_strv (_tmp49_, "tab-zooms", _tmp50_);
	}
	opened_tabs = (_vala_array_free (opened_tabs, opened_tabs_length1, (GDestroyNotify) g_free), NULL);
	zooms = (_vala_array_free (zooms, zooms_length1, (GDestroyNotify) g_free), NULL);
}

/** Return enough of @path to distinguish it from @conflict_path **/
static gchar*
string_replace (const gchar* self,
                const gchar* old,
                const gchar* replacement)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (old != NULL, NULL);
	g_return_val_if_fail (replacement != NULL, NULL);
	if ((*((gchar*) self)) == '\0') {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = (*((gchar*) old)) == '\0';
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = g_strcmp0 (old, replacement) == 0;
	}
	if (_tmp0_) {
		gchar* _tmp2_;
		_tmp2_ = g_strdup (self);
		result = _tmp2_;
		return result;
	}
	{
		GRegex* regex = NULL;
		gchar* _tmp3_;
		gchar* _tmp4_;
		GRegex* _tmp5_;
		GRegex* _tmp6_;
		gchar* _tmp7_ = NULL;
		GRegex* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		_tmp3_ = g_regex_escape_string (old, -1);
		_tmp4_ = _tmp3_;
		_tmp5_ = g_regex_new (_tmp4_, 0, 0, &_inner_error0_);
		_tmp6_ = _tmp5_;
		_g_free0 (_tmp4_);
		regex = _tmp6_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected 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;
		}
		_tmp8_ = regex;
		_tmp9_ = g_regex_replace_literal (_tmp8_, self, (gssize) -1, 0, replacement, 0, &_inner_error0_);
		_tmp7_ = _tmp9_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_regex_unref0 (regex);
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected 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;
		}
		_tmp10_ = _tmp7_;
		_tmp7_ = NULL;
		result = _tmp10_;
		_g_free0 (_tmp7_);
		_g_regex_unref0 (regex);
		return result;
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		g_clear_error (&_inner_error0_);
		g_assert_not_reached ();
	}
	__finally0:
	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;
}

static gchar*
terminal_main_window_disambiguate_label (const gchar* path,
                                         const gchar* conflict_path)
{
	gchar* prefix = NULL;
	gchar* _tmp0_;
	gchar* conflict_prefix = NULL;
	gchar* _tmp1_;
	gchar* temp_path = NULL;
	gchar* _tmp2_;
	gchar* temp_conflict_path = NULL;
	gchar* _tmp3_;
	gchar* basename = NULL;
	gchar* _tmp4_;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gboolean _tmp8_;
	const gchar* _tmp33_;
	const gchar* _tmp34_;
	gchar* _tmp35_;
	gchar* _tmp36_;
	gchar* _tmp37_;
	gchar* _tmp38_;
	gchar* result;
	g_return_val_if_fail (path != NULL, NULL);
	g_return_val_if_fail (conflict_path != NULL, NULL);
	_tmp0_ = g_strdup ("");
	prefix = _tmp0_;
	_tmp1_ = g_strdup ("");
	conflict_prefix = _tmp1_;
	_tmp2_ = g_strdup (path);
	temp_path = _tmp2_;
	_tmp3_ = g_strdup (conflict_path);
	temp_conflict_path = _tmp3_;
	_tmp4_ = g_path_get_basename (path);
	basename = _tmp4_;
	_tmp5_ = basename;
	_tmp6_ = g_path_get_basename (conflict_path);
	_tmp7_ = _tmp6_;
	_tmp8_ = g_strcmp0 (_tmp5_, _tmp7_) != 0;
	_g_free0 (_tmp7_);
	if (_tmp8_) {
		result = basename;
		_g_free0 (temp_conflict_path);
		_g_free0 (temp_path);
		_g_free0 (conflict_prefix);
		_g_free0 (prefix);
		return result;
	}
	while (TRUE) {
		const gchar* _tmp9_;
		const gchar* _tmp10_;
		gchar* parent_temp_path = NULL;
		const gchar* _tmp11_;
		gchar* _tmp12_;
		gchar* parent_temp_confict_path = NULL;
		const gchar* _tmp13_;
		gchar* _tmp14_;
		const gchar* _tmp15_;
		gchar* _tmp16_;
		gchar* _tmp17_;
		gchar* _tmp18_;
		gchar* _tmp19_;
		const gchar* _tmp20_;
		gchar* _tmp21_;
		const gchar* _tmp22_;
		gchar* _tmp23_;
		gchar* _tmp24_;
		gchar* _tmp25_;
		gchar* _tmp26_;
		const gchar* _tmp27_;
		gchar* _tmp28_;
		const gchar* _tmp29_;
		gchar* _tmp30_;
		const gchar* _tmp31_;
		gchar* _tmp32_;
		_tmp9_ = prefix;
		_tmp10_ = conflict_prefix;
		if (!(g_strcmp0 (_tmp9_, _tmp10_) == 0)) {
			break;
		}
		_tmp11_ = temp_path;
		_tmp12_ = terminal_utils_get_parent_path_from_path (_tmp11_);
		parent_temp_path = _tmp12_;
		_tmp13_ = temp_conflict_path;
		_tmp14_ = terminal_utils_get_parent_path_from_path (_tmp13_);
		parent_temp_confict_path = _tmp14_;
		_tmp15_ = parent_temp_path;
		_tmp16_ = g_path_get_basename (_tmp15_);
		_tmp17_ = _tmp16_;
		_tmp18_ = g_strconcat (_tmp17_, G_DIR_SEPARATOR_S, NULL);
		_tmp19_ = _tmp18_;
		_tmp20_ = prefix;
		_tmp21_ = g_strconcat (_tmp19_, _tmp20_, NULL);
		_g_free0 (prefix);
		prefix = _tmp21_;
		_g_free0 (_tmp19_);
		_g_free0 (_tmp17_);
		_tmp22_ = parent_temp_confict_path;
		_tmp23_ = g_path_get_basename (_tmp22_);
		_tmp24_ = _tmp23_;
		_tmp25_ = g_strconcat (_tmp24_, G_DIR_SEPARATOR_S, NULL);
		_tmp26_ = _tmp25_;
		_tmp27_ = conflict_prefix;
		_tmp28_ = g_strconcat (_tmp26_, _tmp27_, NULL);
		_g_free0 (conflict_prefix);
		conflict_prefix = _tmp28_;
		_g_free0 (_tmp26_);
		_g_free0 (_tmp24_);
		_tmp29_ = parent_temp_path;
		_tmp30_ = g_strdup (_tmp29_);
		_g_free0 (temp_path);
		temp_path = _tmp30_;
		_tmp31_ = parent_temp_confict_path;
		_tmp32_ = g_strdup (_tmp31_);
		_g_free0 (temp_conflict_path);
		temp_conflict_path = _tmp32_;
		_g_free0 (parent_temp_confict_path);
		_g_free0 (parent_temp_path);
	}
	_tmp33_ = prefix;
	_tmp34_ = basename;
	_tmp35_ = g_strconcat (_tmp33_, _tmp34_, NULL);
	_tmp36_ = _tmp35_;
	_tmp37_ = string_replace (_tmp36_, "//", "/");
	_tmp38_ = _tmp37_;
	_g_free0 (_tmp36_);
	result = _tmp38_;
	_g_free0 (basename);
	_g_free0 (temp_conflict_path);
	_g_free0 (temp_path);
	_g_free0 (conflict_prefix);
	_g_free0 (prefix);
	return result;
}

static TerminalMainWindow*
terminal_main_window_present_new_empty_window (TerminalMainWindow* self)
{
	TerminalMainWindow* new_window = NULL;
	TerminalApplication* _tmp0_;
	TerminalMainWindow* _tmp1_;
	TerminalApplication* _tmp2_;
	GtkWindow* _tmp3_;
	GtkWindow* _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	TerminalApplication* _tmp7_;
	GtkWindow* _tmp8_;
	GtkWindow* _tmp9_;
	gint _tmp10_;
	gint _tmp11_;
	TerminalMainWindow* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_app;
	_tmp1_ = terminal_main_window_new (_tmp0_, FALSE);
	g_object_ref_sink (_tmp1_);
	new_window = _tmp1_;
	_tmp2_ = self->priv->_app;
	_tmp3_ = gtk_application_get_active_window ((GtkApplication*) _tmp2_);
	_tmp4_ = _tmp3_;
	g_object_get ((GtkWidget*) _tmp4_, "width-request", &_tmp5_, NULL);
	_tmp6_ = _tmp5_;
	_tmp7_ = self->priv->_app;
	_tmp8_ = gtk_application_get_active_window ((GtkApplication*) _tmp7_);
	_tmp9_ = _tmp8_;
	g_object_get ((GtkWidget*) _tmp9_, "height-request", &_tmp10_, NULL);
	_tmp11_ = _tmp10_;
	gtk_widget_set_size_request ((GtkWidget*) new_window, _tmp6_, _tmp11_);
	gtk_window_present ((GtkWindow*) new_window);
	result = new_window;
	return result;
}

GSimpleAction*
terminal_main_window_get_simple_action (TerminalMainWindow* self,
                                        const gchar* action)
{
	GSimpleActionGroup* _tmp0_;
	GAction* _tmp1_;
	GSimpleAction* _tmp2_;
	GSimpleAction* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (action != NULL, NULL);
	_tmp0_ = self->priv->_actions;
	_tmp1_ = g_action_map_lookup_action ((GActionMap*) _tmp0_, action);
	_tmp2_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp1_, g_simple_action_get_type ()) ? ((GSimpleAction*) _tmp1_) : NULL);
	result = _tmp2_;
	return result;
}

gboolean
terminal_main_window_get_recreate_tabs (TerminalMainWindow* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_recreate_tabs;
	return result;
}

static void
terminal_main_window_set_recreate_tabs (TerminalMainWindow* self,
                                        gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = terminal_main_window_get_recreate_tabs (self);
	if (old_value != value) {
		self->priv->_recreate_tabs = value;
		g_object_notify_by_pspec ((GObject *) self, terminal_main_window_properties[TERMINAL_MAIN_WINDOW_RECREATE_TABS_PROPERTY]);
	}
}

TerminalApplication*
terminal_main_window_get_app (TerminalMainWindow* self)
{
	TerminalApplication* result;
	TerminalApplication* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_app;
	result = _tmp0_;
	return result;
}

static void
terminal_main_window_set_app (TerminalMainWindow* self,
                              TerminalApplication* value)
{
	TerminalApplication* old_value;
	g_return_if_fail (self != NULL);
	old_value = terminal_main_window_get_app (self);
	if (old_value != value) {
		TerminalApplication* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_app);
		self->priv->_app = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, terminal_main_window_properties[TERMINAL_MAIN_WINDOW_APP_PROPERTY]);
	}
}

GSimpleActionGroup*
terminal_main_window_get_actions (TerminalMainWindow* self)
{
	GSimpleActionGroup* result;
	GSimpleActionGroup* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_actions;
	result = _tmp0_;
	return result;
}

static void
terminal_main_window_set_actions (TerminalMainWindow* self,
                                  GSimpleActionGroup* value)
{
	GSimpleActionGroup* old_value;
	g_return_if_fail (self != NULL);
	old_value = terminal_main_window_get_actions (self);
	if (old_value != value) {
		GSimpleActionGroup* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_actions);
		self->priv->_actions = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, terminal_main_window_properties[TERMINAL_MAIN_WINDOW_ACTIONS_PROPERTY]);
	}
}

TerminalTerminalView*
terminal_main_window_get_notebook (TerminalMainWindow* self)
{
	TerminalTerminalView* result;
	TerminalTerminalView* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_notebook;
	result = _tmp0_;
	return result;
}

static void
terminal_main_window_set_notebook (TerminalMainWindow* self,
                                   TerminalTerminalView* value)
{
	TerminalTerminalView* old_value;
	g_return_if_fail (self != NULL);
	old_value = terminal_main_window_get_notebook (self);
	if (old_value != value) {
		TerminalTerminalView* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_notebook);
		self->priv->_notebook = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, terminal_main_window_properties[TERMINAL_MAIN_WINDOW_NOTEBOOK_PROPERTY]);
	}
}

TerminalTerminalWidget*
terminal_main_window_get_current_terminal (TerminalMainWindow* self)
{
	TerminalTerminalWidget* result;
	TerminalTerminalWidget* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_current_terminal;
	result = _tmp0_;
	return result;
}

static void
terminal_main_window_set_current_terminal (TerminalMainWindow* self,
                                           TerminalTerminalWidget* value)
{
	TerminalTerminalWidget* old_value;
	g_return_if_fail (self != NULL);
	old_value = terminal_main_window_get_current_terminal (self);
	if (old_value != value) {
		TerminalTerminalWidget* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_current_terminal);
		self->priv->_current_terminal = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, terminal_main_window_properties[TERMINAL_MAIN_WINDOW_CURRENT_TERMINAL_PROPERTY]);
	}
}

static void
_vala_array_add9 (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 gboolean
_terminal_main_window_key_pressed_gtk_event_controller_key_key_pressed (GtkEventControllerKey* _sender,
                                                                        guint keyval,
                                                                        guint keycode,
                                                                        GdkModifierType state,
                                                                        gpointer self)
{
	gboolean result;
	result = terminal_main_window_key_pressed ((TerminalMainWindow*) self, keyval, keycode, state);
	return result;
}

static gboolean
___lambda38_ (TerminalMainWindow* self)
{
	TerminalTerminalWidget* _tmp0_;
	gboolean result;
	self->priv->focus_timeout = (guint) 0;
	terminal_main_window_save_opened_terminals (self, TRUE, TRUE);
	_tmp0_ = self->priv->_current_terminal;
	gtk_widget_grab_focus ((GtkWidget*) _tmp0_);
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
____lambda38__gsource_func (gpointer self)
{
	gboolean result;
	result = ___lambda38_ ((TerminalMainWindow*) self);
	return result;
}

static void
_terminal_main_window___lambda37_ (TerminalMainWindow* self)
{
	if (self->priv->focus_timeout == ((guint) 0)) {
		self->priv->focus_timeout = g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 20, ____lambda38__gsource_func, g_object_ref (self), g_object_unref);
	}
}

static void
__terminal_main_window___lambda37__gtk_event_controller_focus_enter (GtkEventControllerFocus* _sender,
                                                                     gpointer self)
{
	_terminal_main_window___lambda37_ ((TerminalMainWindow*) self);
}

static gboolean
_terminal_main_window_on_delete_event_gtk_window_close_request (GtkWindow* _sender,
                                                                gpointer self)
{
	gboolean result;
	result = terminal_main_window_on_delete_event ((TerminalMainWindow*) self);
	return result;
}

static GObject *
terminal_main_window_constructor (GType type,
                                  guint n_construct_properties,
                                  GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	TerminalMainWindow * self;
	GSimpleActionGroup* _tmp0_;
	GSimpleActionGroup* _tmp1_;
	GSimpleActionGroup* _tmp2_;
	GSimpleActionGroup* _tmp3_;
	TerminalApplication* _tmp4_;
	GtkEventControllerKey* key_controller = NULL;
	GtkEventControllerKey* _tmp25_ = NULL;
	GtkEventControllerKey* _tmp26_;
	GtkEventControllerFocus* focus_controller = NULL;
	GtkEventControllerFocus* _tmp27_;
	GtkEventControllerFocus* _tmp28_;
	GtkEventControllerKey* _tmp29_;
	GtkEventController* _tmp30_;
	GtkEventControllerFocus* _tmp31_;
	GtkEventController* _tmp32_;
	gboolean _tmp33_;
	parent_class = G_OBJECT_CLASS (terminal_main_window_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TERMINAL_TYPE_MAIN_WINDOW, TerminalMainWindow);
	_tmp0_ = g_simple_action_group_new ();
	_tmp1_ = _tmp0_;
	terminal_main_window_set_actions (self, _tmp1_);
	_g_object_unref0 (_tmp1_);
	_tmp2_ = self->priv->_actions;
	g_action_map_add_action_entries ((GActionMap*) _tmp2_, TERMINAL_MAIN_WINDOW_ACTION_ENTRIES, (gint) G_N_ELEMENTS (TERMINAL_MAIN_WINDOW_ACTION_ENTRIES), self);
	_tmp3_ = self->priv->_actions;
	gtk_widget_insert_action_group ((GtkWidget*) self, "win", (GActionGroup*) _tmp3_);
	gtk_window_set_icon_name ((GtkWindow*) self, "utilities-terminal");
	_tmp4_ = self->priv->_app;
	gtk_window_set_application ((GtkWindow*) self, (GtkApplication*) _tmp4_);
	{
		GeeIterator* _action_it = NULL;
		GeeMultiMap* _tmp5_;
		GeeSet* _tmp6_;
		GeeSet* _tmp7_;
		GeeIterator* _tmp8_;
		GeeIterator* _tmp9_;
		_tmp5_ = terminal_main_window_action_accelerators;
		_tmp6_ = gee_multi_map_get_keys (_tmp5_);
		_tmp7_ = _tmp6_;
		_tmp8_ = gee_iterable_iterator ((GeeIterable*) _tmp7_);
		_tmp9_ = _tmp8_;
		_g_object_unref0 (_tmp7_);
		_action_it = _tmp9_;
		while (TRUE) {
			GeeIterator* _tmp10_;
			gchar* action = NULL;
			GeeIterator* _tmp11_;
			gpointer _tmp12_;
			gchar** accels_array = NULL;
			GeeMultiMap* _tmp13_;
			const gchar* _tmp14_;
			GeeCollection* _tmp15_;
			GeeCollection* _tmp16_;
			gint _tmp17_ = 0;
			gpointer* _tmp18_;
			gchar** _tmp19_;
			gint _tmp19__length1;
			gint accels_array_length1;
			gint _accels_array_size_;
			TerminalApplication* _tmp20_;
			const gchar* _tmp21_;
			gchar* _tmp22_;
			gchar* _tmp23_;
			gchar** _tmp24_;
			gint _tmp24__length1;
			_tmp10_ = _action_it;
			if (!gee_iterator_next (_tmp10_)) {
				break;
			}
			_tmp11_ = _action_it;
			_tmp12_ = gee_iterator_get (_tmp11_);
			action = (gchar*) _tmp12_;
			_tmp13_ = terminal_main_window_action_accelerators;
			_tmp14_ = action;
			_tmp15_ = gee_multi_map_get (_tmp13_, _tmp14_);
			_tmp16_ = _tmp15_;
			_tmp18_ = gee_collection_to_array (_tmp16_, &_tmp17_);
			_tmp19_ = _tmp18_;
			_tmp19__length1 = _tmp17_;
			_g_object_unref0 (_tmp16_);
			accels_array = _tmp19_;
			accels_array_length1 = _tmp19__length1;
			_accels_array_size_ = accels_array_length1;
			_vala_array_add9 (&accels_array, &accels_array_length1, &_accels_array_size_, NULL);
			_tmp20_ = self->priv->_app;
			_tmp21_ = action;
			_tmp22_ = g_strconcat (TERMINAL_MAIN_WINDOW_ACTION_PREFIX, _tmp21_, NULL);
			_tmp23_ = _tmp22_;
			_tmp24_ = accels_array;
			_tmp24__length1 = accels_array_length1;
			gtk_application_set_accels_for_action ((GtkApplication*) _tmp20_, _tmp23_, _tmp24_);
			_g_free0 (_tmp23_);
			accels_array = (_vala_array_free (accels_array, accels_array_length1, (GDestroyNotify) g_free), NULL);
			_g_free0 (action);
		}
		_g_object_unref0 (_action_it);
	}
	gtk_window_set_title ((GtkWindow*) self, TERMINAL_TERMINAL_WIDGET_DEFAULT_LABEL);
	terminal_main_window_setup_ui (self);
	_tmp25_ = (GtkEventControllerKey*) gtk_event_controller_key_new ();
	gtk_event_controller_set_propagation_phase ((GtkEventController*) _tmp25_, GTK_PHASE_CAPTURE);
	key_controller = _tmp25_;
	_tmp26_ = key_controller;
	g_signal_connect_object (_tmp26_, "key-pressed", (GCallback) _terminal_main_window_key_pressed_gtk_event_controller_key_key_pressed, self, 0);
	_tmp27_ = (GtkEventControllerFocus*) gtk_event_controller_focus_new ();
	focus_controller = _tmp27_;
	_tmp28_ = focus_controller;
	g_signal_connect_object (_tmp28_, "enter", (GCallback) __terminal_main_window___lambda37__gtk_event_controller_focus_enter, self, 0);
	_tmp29_ = key_controller;
	_tmp30_ = _g_object_ref0 ((GtkEventController*) _tmp29_);
	gtk_widget_add_controller (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), _tmp30_);
	_tmp31_ = focus_controller;
	_tmp32_ = _g_object_ref0 ((GtkEventController*) _tmp31_);
	gtk_widget_add_controller (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), _tmp32_);
	gtk_widget_set_size_request ((GtkWidget*) self, TERMINAL_APPLICATION_MINIMUM_WIDTH, TERMINAL_APPLICATION_MINIMUM_HEIGHT);
	_tmp33_ = self->priv->_recreate_tabs;
	if (_tmp33_) {
		terminal_main_window_open_tabs (self);
	}
	g_signal_connect_object ((GtkWindow*) self, "close-request", (GCallback) _terminal_main_window_on_delete_event_gtk_window_close_request, self, 0);
	_g_object_unref0 (focus_controller);
	_g_object_unref0 (key_controller);
	return obj;
}

static void
terminal_main_window_class_init (TerminalMainWindowClass * klass,
                                 gpointer klass_data)
{
	GeeHashMultiMap* _tmp0_;
	GeeMultiMap* _tmp1_;
	GeeMultiMap* _tmp2_;
	GeeMultiMap* _tmp3_;
	GeeMultiMap* _tmp4_;
	GeeMultiMap* _tmp5_;
	GeeMultiMap* _tmp6_;
	GeeMultiMap* _tmp7_;
	GeeMultiMap* _tmp8_;
	GeeMultiMap* _tmp9_;
	GeeMultiMap* _tmp10_;
	GeeMultiMap* _tmp11_;
	GeeMultiMap* _tmp12_;
	terminal_main_window_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &TerminalMainWindow_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_terminal_main_window_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_terminal_main_window_set_property;
	G_OBJECT_CLASS (klass)->constructor = terminal_main_window_constructor;
	G_OBJECT_CLASS (klass)->finalize = terminal_main_window_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), TERMINAL_MAIN_WINDOW_RECREATE_TABS_PROPERTY, terminal_main_window_properties[TERMINAL_MAIN_WINDOW_RECREATE_TABS_PROPERTY] = g_param_spec_boolean ("recreate-tabs", "recreate-tabs", "recreate-tabs", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), TERMINAL_MAIN_WINDOW_APP_PROPERTY, terminal_main_window_properties[TERMINAL_MAIN_WINDOW_APP_PROPERTY] = g_param_spec_object ("app", "app", "app", TERMINAL_TYPE_APPLICATION, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), TERMINAL_MAIN_WINDOW_ACTIONS_PROPERTY, terminal_main_window_properties[TERMINAL_MAIN_WINDOW_ACTIONS_PROPERTY] = g_param_spec_object ("actions", "actions", "actions", g_simple_action_group_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), TERMINAL_MAIN_WINDOW_NOTEBOOK_PROPERTY, terminal_main_window_properties[TERMINAL_MAIN_WINDOW_NOTEBOOK_PROPERTY] = g_param_spec_object ("notebook", "notebook", "notebook", TERMINAL_TYPE_TERMINAL_VIEW, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), TERMINAL_MAIN_WINDOW_CURRENT_TERMINAL_PROPERTY, terminal_main_window_properties[TERMINAL_MAIN_WINDOW_CURRENT_TERMINAL_PROPERTY] = g_param_spec_object ("current-terminal", "current-terminal", "current-terminal", TERMINAL_TYPE_TERMINAL_WIDGET, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	_tmp0_ = gee_hash_multi_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	terminal_main_window_action_accelerators = (GeeMultiMap*) _tmp0_;
	_tmp1_ = terminal_main_window_action_accelerators;
	gee_multi_map_set (_tmp1_, TERMINAL_MAIN_WINDOW_ACTION_CLOSE_TAB, "<Control><Shift>w");
	_tmp2_ = terminal_main_window_action_accelerators;
	gee_multi_map_set (_tmp2_, TERMINAL_MAIN_WINDOW_ACTION_FULLSCREEN, "F11");
	_tmp3_ = terminal_main_window_action_accelerators;
	gee_multi_map_set (_tmp3_, TERMINAL_MAIN_WINDOW_ACTION_NEW_TAB, "<Control><Shift>t");
	_tmp4_ = terminal_main_window_action_accelerators;
	gee_multi_map_set (_tmp4_, TERMINAL_MAIN_WINDOW_ACTION_DUPLICATE_TAB, "<Control><Shift>d");
	_tmp5_ = terminal_main_window_action_accelerators;
	gee_multi_map_set (_tmp5_, TERMINAL_MAIN_WINDOW_ACTION_TAB_RELOAD, "<Control><Shift>r");
	_tmp6_ = terminal_main_window_action_accelerators;
	gee_multi_map_set (_tmp6_, TERMINAL_MAIN_WINDOW_ACTION_NEXT_TAB, "<Control>Tab");
	_tmp7_ = terminal_main_window_action_accelerators;
	gee_multi_map_set (_tmp7_, TERMINAL_MAIN_WINDOW_ACTION_NEXT_TAB, "<Control>Page_Down");
	_tmp8_ = terminal_main_window_action_accelerators;
	gee_multi_map_set (_tmp8_, TERMINAL_MAIN_WINDOW_ACTION_PREVIOUS_TAB, "<Control><Shift>Tab");
	_tmp9_ = terminal_main_window_action_accelerators;
	gee_multi_map_set (_tmp9_, TERMINAL_MAIN_WINDOW_ACTION_PREVIOUS_TAB, "<Control>Page_Up");
	_tmp10_ = terminal_main_window_action_accelerators;
	gee_multi_map_set (_tmp10_, TERMINAL_MAIN_WINDOW_ACTION_MOVE_TAB_RIGHT, "<Control><Alt>Right");
	_tmp11_ = terminal_main_window_action_accelerators;
	gee_multi_map_set (_tmp11_, TERMINAL_MAIN_WINDOW_ACTION_MOVE_TAB_LEFT, "<Control><Alt>Left");
	_tmp12_ = terminal_main_window_action_accelerators;
	gee_multi_map_set (_tmp12_, TERMINAL_MAIN_WINDOW_ACTION_SEARCH, "<Control><Shift>f");
}

static void
terminal_main_window_instance_init (TerminalMainWindow * self,
                                    gpointer klass)
{
	self->priv = terminal_main_window_get_instance_private (self);
	self->priv->focus_timeout = (guint) 0;
	self->priv->_current_terminal = NULL;
	self->priv->tab_to_close = NULL;
	self->priv->term_to_close = NULL;
	self->priv->close_immediately = FALSE;
}

static void
terminal_main_window_finalize (GObject * obj)
{
	TerminalMainWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TERMINAL_TYPE_MAIN_WINDOW, TerminalMainWindow);
	_g_object_unref0 (self->priv->header);
	_g_object_unref0 (self->priv->search_toolbar);
	_g_object_unref0 (self->priv->unfullscreen_button);
	_g_object_unref0 (self->priv->title_label);
	_g_object_unref0 (self->priv->title_stack);
	_g_object_unref0 (self->priv->search_button);
	_g_object_unref0 (self->priv->color_preferences_dialog);
	_g_object_unref0 (self->priv->_app);
	_g_object_unref0 (self->priv->_actions);
	_g_object_unref0 (self->priv->_notebook);
	_g_object_unref0 (self->priv->_current_terminal);
	_g_object_unref0 (self->priv->tab_to_close);
	_g_object_unref0 (self->priv->term_to_close);
	G_OBJECT_CLASS (terminal_main_window_parent_class)->finalize (obj);
}

static GType
terminal_main_window_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (TerminalMainWindowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) terminal_main_window_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TerminalMainWindow), 0, (GInstanceInitFunc) terminal_main_window_instance_init, NULL };
	GType terminal_main_window_type_id;
	terminal_main_window_type_id = g_type_register_static (adw_window_get_type (), "TerminalMainWindow", &g_define_type_info, 0);
	TerminalMainWindow_private_offset = g_type_add_instance_private (terminal_main_window_type_id, sizeof (TerminalMainWindowPrivate));
	return terminal_main_window_type_id;
}

GType
terminal_main_window_get_type (void)
{
	static volatile gsize terminal_main_window_type_id__once = 0;
	if (g_once_init_enter (&terminal_main_window_type_id__once)) {
		GType terminal_main_window_type_id;
		terminal_main_window_type_id = terminal_main_window_get_type_once ();
		g_once_init_leave (&terminal_main_window_type_id__once, terminal_main_window_type_id);
	}
	return terminal_main_window_type_id__once;
}

static void
_vala_terminal_main_window_get_property (GObject * object,
                                         guint property_id,
                                         GValue * value,
                                         GParamSpec * pspec)
{
	TerminalMainWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TERMINAL_TYPE_MAIN_WINDOW, TerminalMainWindow);
	switch (property_id) {
		case TERMINAL_MAIN_WINDOW_RECREATE_TABS_PROPERTY:
		g_value_set_boolean (value, terminal_main_window_get_recreate_tabs (self));
		break;
		case TERMINAL_MAIN_WINDOW_APP_PROPERTY:
		g_value_set_object (value, terminal_main_window_get_app (self));
		break;
		case TERMINAL_MAIN_WINDOW_ACTIONS_PROPERTY:
		g_value_set_object (value, terminal_main_window_get_actions (self));
		break;
		case TERMINAL_MAIN_WINDOW_NOTEBOOK_PROPERTY:
		g_value_set_object (value, terminal_main_window_get_notebook (self));
		break;
		case TERMINAL_MAIN_WINDOW_CURRENT_TERMINAL_PROPERTY:
		g_value_set_object (value, terminal_main_window_get_current_terminal (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_terminal_main_window_set_property (GObject * object,
                                         guint property_id,
                                         const GValue * value,
                                         GParamSpec * pspec)
{
	TerminalMainWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TERMINAL_TYPE_MAIN_WINDOW, TerminalMainWindow);
	switch (property_id) {
		case TERMINAL_MAIN_WINDOW_RECREATE_TABS_PROPERTY:
		terminal_main_window_set_recreate_tabs (self, g_value_get_boolean (value));
		break;
		case TERMINAL_MAIN_WINDOW_APP_PROPERTY:
		terminal_main_window_set_app (self, g_value_get_object (value));
		break;
		case TERMINAL_MAIN_WINDOW_ACTIONS_PROPERTY:
		terminal_main_window_set_actions (self, g_value_get_object (value));
		break;
		case TERMINAL_MAIN_WINDOW_NOTEBOOK_PROPERTY:
		terminal_main_window_set_notebook (self, g_value_get_object (value));
		break;
		case TERMINAL_MAIN_WINDOW_CURRENT_TERMINAL_PROPERTY:
		terminal_main_window_set_current_terminal (self, g_value_get_object (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 gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

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

