/* MainWindow.c generated by valac 0.56.18-dirty, 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 <handy.h>
#include <glib-object.h>
#include <pango/pango.h>
#include <gtk/gtk.h>
#include <granite.h>
#include <gio/gio.h>
#include <glib.h>
#include <vte/vte.h>
#include <gdk/gdk.h>
#include <stdlib.h>
#include <string.h>
#include <gee.h>
#include <glib/gi18n-lib.h>
#include <cairo-gobject.h>
#include <float.h>
#include <math.h>

#define TERMINAL_MAIN_WINDOW_NORMAL 0
#define TERMINAL_MAIN_WINDOW_MAXIMIZED 1
#define TERMINAL_MAIN_WINDOW_FULLSCREEN 2
#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_ACCEL "<Control><Shift>f"
#define TERMINAL_MAIN_WINDOW_ACTION_SEARCH_NEXT "action-search-next"
#define TERMINAL_MAIN_WINDOW_ACTION_SEARCH_PREVIOUS "action-search-previous"
#define TERMINAL_MAIN_WINDOW_ACTION_OPEN_IN_BROWSER "action-open-in-browser"
#define TERMINAL_MAIN_WINDOW_ACTION_OPEN_IN_BROWSER_ACCEL "<Control><Shift>e"
#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_TERMINAL_WIDGET_ACTION_COPY "term.copy"
#define TERMINAL_TERMINAL_WIDGET_ACTION_COPY_OUTPUT "term.copy-output"
#define TERMINAL_TERMINAL_WIDGET_ACTION_CLEAR_SCREEN "term.clear-screen"
#define TERMINAL_TERMINAL_WIDGET_ACTION_RESET "term.reset"
#define TERMINAL_TERMINAL_WIDGET_ACTION_PASTE "term.paste"
#define TERMINAL_TERMINAL_WIDGET_ACTION_SELECT_ALL "term.select-all"
#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_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_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_WIDGETS_TYPE_ZOOM_OVERLAY (terminal_widgets_zoom_overlay_get_type ())
#define TERMINAL_WIDGETS_ZOOM_OVERLAY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TERMINAL_WIDGETS_TYPE_ZOOM_OVERLAY, TerminalWidgetsZoomOverlay))
#define TERMINAL_WIDGETS_ZOOM_OVERLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TERMINAL_WIDGETS_TYPE_ZOOM_OVERLAY, TerminalWidgetsZoomOverlayClass))
#define TERMINAL_WIDGETS_IS_ZOOM_OVERLAY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TERMINAL_WIDGETS_TYPE_ZOOM_OVERLAY))
#define TERMINAL_WIDGETS_IS_ZOOM_OVERLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TERMINAL_WIDGETS_TYPE_ZOOM_OVERLAY))
#define TERMINAL_WIDGETS_ZOOM_OVERLAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TERMINAL_WIDGETS_TYPE_ZOOM_OVERLAY, TerminalWidgetsZoomOverlayClass))

typedef struct _TerminalWidgetsZoomOverlay TerminalWidgetsZoomOverlay;
typedef struct _TerminalWidgetsZoomOverlayClass TerminalWidgetsZoomOverlayClass;

#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_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_NOTEBOOK_PROPERTY,
	TERMINAL_MAIN_WINDOW_FOCUS_RESTORED_TABS_PROPERTY,
	TERMINAL_MAIN_WINDOW_RECREATE_TABS_PROPERTY,
	TERMINAL_MAIN_WINDOW_CONTEXT_MENU_MODEL_PROPERTY,
	TERMINAL_MAIN_WINDOW_APP_PROPERTY,
	TERMINAL_MAIN_WINDOW_ACTIONS_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);
#define __vala_PangoFontDescription_free0(var) ((var == NULL) ? NULL : (var = (_vala_PangoFontDescription_free (var), NULL)))
#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 struct _Block8Data Block8Data;
typedef struct _TerminalTerminalWidgetPrivate TerminalTerminalWidgetPrivate;
typedef struct _TerminalWidgetsSearchToolbarPrivate TerminalWidgetsSearchToolbarPrivate;
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _Block9Data Block9Data;
#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 {
	HdyWindow parent_instance;
	TerminalMainWindowPrivate * priv;
};

struct _TerminalMainWindowClass {
	HdyWindowClass parent_class;
};

struct _TerminalMainWindowPrivate {
	PangoFontDescription* term_font;
	HdyHeaderBar* header;
	TerminalTerminalView* _notebook;
	GtkClipboard* clipboard;
	GtkClipboard* primary_selection;
	TerminalWidgetsSearchToolbar* search_toolbar;
	GtkButton* unfullscreen_button;
	GtkLabel* title_label;
	GtkStack* title_stack;
	GtkToggleButton* search_button;
	TerminalWidgetsZoomOverlay* zoom_overlay;
	TerminalDialogsColorPreferences* color_preferences_dialog;
	GMenuItem* open_in_browser_menuitem;
	GtkEventControllerKey* key_controller;
	guint timer_window_state_change;
	guint focus_timeout;
	gboolean _focus_restored_tabs;
	gboolean _recreate_tabs;
	GMenu* _context_menu_model;
	TerminalApplication* _app;
	GSimpleActionGroup* _actions;
	TerminalTerminalWidget* _current_terminal;
};

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

struct _TerminalTerminalWidget {
	VteTerminal parent_instance;
	TerminalTerminalWidgetPrivate * priv;
	gchar* terminal_id;
	HdyTabPage* tab;
	gchar* link_uri;
	gint default_size;
	gboolean last_key_was_return;
};

struct _TerminalTerminalWidgetClass {
	VteTerminalClass parent_class;
};

struct _TerminalWidgetsSearchToolbar {
	GtkBox parent_instance;
	TerminalWidgetsSearchToolbarPrivate * priv;
	GtkSearchEntry* search_entry;
};

struct _TerminalWidgetsSearchToolbarClass {
	GtkBoxClass parent_class;
};

struct _Block9Data {
	int _ref_count_;
	TerminalMainWindow* self;
	gchar* text;
};

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_settings;
VALA_EXTERN GSettings* terminal_application_saved_state;
VALA_EXTERN GSettings* terminal_application_settings_sys;

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_terminal_view_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TerminalTerminalView, 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_widgets_zoom_overlay_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TerminalWidgetsZoomOverlay, 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_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_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);
static void terminal_main_window_action_open_in_browser (TerminalMainWindow* self);
static void _terminal_main_window_action_open_in_browser_gsimple_action_activate_callback (GSimpleAction* action,
                                                                                    GVariant* parameter,
                                                                                    gpointer self);
static void _vala_PangoFontDescription_free (PangoFontDescription* 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);
static TerminalTerminalWidget* terminal_main_window_new_tab (TerminalMainWindow* self,
                                                      const gchar* location,
                                                      const gchar* program,
                                                      gboolean focus,
                                                      gint pos);
VALA_EXTERN HdyTabView* terminal_terminal_view_get_tab_view (TerminalTerminalView* self);
static TerminalTerminalWidget* terminal_main_window_get_term_widget (TerminalMainWindow* self,
                                                              HdyTabPage* tab);
VALA_EXTERN gchar* terminal_terminal_widget_get_shell_location (TerminalTerminalWidget* self);
VALA_EXTERN void terminal_terminal_view_set_selected_page (TerminalTerminalView* self,
                                               HdyTabPage* 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,
                                        HdyTabPage* tab,
                                        gint pos);
static void _terminal_main_window_on_tab_added_hdy_tab_view_page_attached (HdyTabView* _sender,
                                                                    HdyTabPage* page,
                                                                    gint position,
                                                                    gpointer self);
static void terminal_main_window_on_tab_removed (TerminalMainWindow* self,
                                          HdyTabPage* tab);
static void _terminal_main_window_on_tab_removed_hdy_tab_view_page_detached (HdyTabView* _sender,
                                                                      HdyTabPage* page,
                                                                      gint position,
                                                                      gpointer self);
static void terminal_main_window_on_tab_reordered (TerminalMainWindow* self,
                                            HdyTabPage* tab,
                                            gint new_pos);
static void _terminal_main_window_on_tab_reordered_hdy_tab_view_page_reordered (HdyTabView* _sender,
                                                                         HdyTabPage* page,
                                                                         gint position,
                                                                         gpointer self);
static HdyTabView* terminal_main_window_on_create_window_request (TerminalMainWindow* self);
static HdyTabView* _terminal_main_window_on_create_window_request_hdy_tab_view_create_window (HdyTabView* _sender,
                                                                                       gpointer self);
static gboolean __lambda23_ (TerminalMainWindow* self,
                      HdyTabPage* tab);
VALA_EXTERN gboolean terminal_terminal_widget_confirm_kill_fg_process (TerminalTerminalWidget* self,
                                                           const gchar* primary_text,
                                                           const gchar* button_label);
VALA_EXTERN gboolean terminal_terminal_widget_get_child_has_exited (TerminalTerminalWidget* 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 const gchar* terminal_terminal_widget_get_current_working_directory (TerminalTerminalWidget* self);
static void terminal_main_window_disconnect_terminal_signals (TerminalMainWindow* self,
                                                       TerminalTerminalWidget* terminal_widget);
VALA_EXTERN void terminal_terminal_widget_prepare_to_close (TerminalTerminalWidget* self);
static gboolean ___lambda23__hdy_tab_view_close_page (HdyTabView* _sender,
                                               HdyTabPage* page,
                                               gpointer self);
static void __lambda24_ (TerminalMainWindow* self);
static Block8Data* block8_data_ref (Block8Data* _data8_);
static void block8_data_unref (void * _userdata_);
static void terminal_main_window_set_current_terminal (TerminalMainWindow* self,
                                                TerminalTerminalWidget* value);
VALA_EXTERN void terminal_widgets_zoom_overlay_hide_zoom_level (TerminalWidgetsZoomOverlay* self);
static gboolean __lambda25_ (Block8Data* _data8_);
static gboolean ___lambda25__gsource_func (gpointer self);
static void ___lambda24__g_object_notify (GObject* _sender,
                                   GParamSpec* pspec,
                                   gpointer self);
VALA_EXTERN HdyTabBar* terminal_terminal_view_get_tab_bar (TerminalTerminalView* self);
VALA_EXTERN TerminalWidgetsZoomOverlay* terminal_widgets_zoom_overlay_new (GtkOverlay* overlay);
VALA_EXTERN TerminalWidgetsZoomOverlay* terminal_widgets_zoom_overlay_construct (GType object_type,
                                                                     GtkOverlay* overlay);
static void __lambda26_ (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 __lambda27_ (TerminalMainWindow* self);
static void ___lambda27__gtk_widget_destroy (GtkWidget* _sender,
                                      gpointer self);
static void ___lambda26__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 void terminal_widgets_search_toolbar_previous_search (TerminalWidgetsSearchToolbar* self);
VALA_EXTERN void terminal_widgets_search_toolbar_next_search (TerminalWidgetsSearchToolbar* self);
static void terminal_main_window_restore_saved_state (TerminalMainWindow* self);
static void terminal_main_window_set_is_fullscreen (TerminalMainWindow* self,
                                             gboolean value);
VALA_EXTERN void terminal_terminal_widget_set_main_window (TerminalTerminalWidget* self,
                                               TerminalMainWindow* value);
static 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);
VALA_EXTERN TerminalApplication* terminal_main_window_get_app (TerminalMainWindow* self);
VALA_EXTERN void terminal_main_window_update_context_menu (TerminalMainWindow* self);
VALA_EXTERN TerminalTerminalWidget* terminal_main_window_get_current_terminal (TerminalMainWindow* self);
static gchar* terminal_main_window_get_current_selection_link_or_pwd (TerminalMainWindow* self);
static void terminal_main_window_update_menu_label (TerminalMainWindow* self,
                                             const gchar* uri);
static GAppInfo* terminal_main_window_get_default_app_for_uri (TerminalMainWindow* self,
                                                        const gchar* uri);
VALA_EXTERN GMenu* terminal_main_window_get_context_menu_model (TerminalMainWindow* self);
VALA_EXTERN GSimpleAction* terminal_main_window_get_simple_action (TerminalMainWindow* self,
                                                       const gchar* action);
static gboolean terminal_main_window_real_configure_event (GtkWidget* base,
                                                    GdkEventConfigure* event);
static gboolean __lambda28_ (TerminalMainWindow* self);
static gboolean ___lambda28__gsource_func (gpointer self);
static void terminal_main_window_open_tabs (TerminalMainWindow* self);
static void _vala_array_add4 (gchar** * array,
                       gint* length,
                       gint* size,
                       gchar* value);
static void _vala_array_add5 (gdouble* * array,
                       gint* length,
                       gint* size,
                       gdouble value);
static void _vala_array_add6 (gdouble* * array,
                       gint* length,
                       gint* size,
                       gdouble value);
static void _vala_array_add7 (gdouble* * array,
                       gint* length,
                       gint* size,
                       gdouble value);
static void _vala_array_add8 (gchar** * array,
                       gint* length,
                       gint* size,
                       gchar* value);
static void _vala_array_add9 (gdouble* * array,
                       gint* length,
                       gint* size,
                       gdouble value);
VALA_EXTERN gboolean terminal_main_window_get_focus_restored_tabs (TerminalMainWindow* self);
VALA_EXTERN TerminalTerminalWidget* terminal_terminal_widget_new (TerminalMainWindow* parent_window);
VALA_EXTERN TerminalTerminalWidget* terminal_terminal_widget_construct (GType object_type,
                                                            TerminalMainWindow* parent_window);
static HdyTabPage* terminal_main_window_append_tab (TerminalMainWindow* self,
                                             const gchar* label,
                                             GIcon* icon,
                                             TerminalTerminalWidget* term,
                                             gint pos);
VALA_EXTERN void terminal_terminal_widget_active_shell (TerminalTerminalWidget* self,
                                            const gchar* dir);
VALA_EXTERN void terminal_terminal_widget_run_program (TerminalTerminalWidget* self,
                                           const gchar* _program_string,
                                           const gchar* working_directory);
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_font_scale_changed (TerminalMainWindow* self);
static void _terminal_main_window_on_terminal_font_scale_changed_g_object_notify (GObject* _sender,
                                                                           GParamSpec* pspec,
                                                                           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_on_terminal_program_changed (TerminalMainWindow* self,
                                                       TerminalTerminalWidget* src,
                                                       const gchar* cmdline);
static void _terminal_main_window_on_terminal_program_changed_terminal_terminal_widget_foreground_process_changed (TerminalTerminalWidget* _sender,
                                                                                                            const gchar* cmdline,
                                                                                                            gpointer self);
static void terminal_main_window_on_terminal_window_title_changed (TerminalMainWindow* self);
static void _terminal_main_window_on_terminal_window_title_changed_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_widgets_zoom_overlay_show_zoom_level (TerminalWidgetsZoomOverlay* self,
                                                    gdouble zoom_level);
static void terminal_main_window_update_font (TerminalMainWindow* self);
VALA_EXTERN gboolean terminal_main_window_on_delete_event (TerminalMainWindow* self);
static void _g_object_unref0_ (gpointer var);
static inline void _g_list_free__g_object_unref0_ (GList* self);
static void __lambda16_ (TerminalMainWindow* self,
                  GObject* obj,
                  GAsyncResult* res);
static void ___lambda16__gasync_ready_callback (GObject* source_object,
                                         GAsyncResult* res,
                                         gpointer self);
static Block9Data* block9_data_ref (Block9Data* _data9_);
static void block9_data_unref (void * _userdata_);
static void ____lambda15_ (Block9Data* _data9_,
                    GtkClipboard* clipboard,
                    const gchar* uri);
static void _____lambda15__gtk_clipboard_text_received_func (GtkClipboard* clipboard,
                                                      const gchar* text,
                                                      gpointer self);
VALA_EXTERN gchar* terminal_utils_sanitize_path (const gchar* _path,
                                     const gchar* shell_location,
                                     gboolean add_file_scheme);
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_widget_change_directory (TerminalTerminalWidget* self,
                                                const gchar* path);
VALA_EXTERN HdyTabPage* 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,
                                        HdyNavigationDirection direction);
VALA_EXTERN HdyTabPage* terminal_terminal_view_get_selected_page (TerminalTerminalView* self);
VALA_EXTERN void terminal_terminal_view_transfer_tab_to_new_window (TerminalTerminalView* self);
VALA_EXTERN GSimpleActionGroup* terminal_main_window_get_actions (TerminalMainWindow* self);
static GVariant* _variant_new3 (gboolean value);
VALA_EXTERN void terminal_widgets_search_toolbar_clear (TerminalWidgetsSearchToolbar* self);
static gboolean terminal_main_window_get_is_fullscreen (TerminalMainWindow* self);
VALA_EXTERN TerminalTerminalWidget* terminal_main_window_get_terminal (TerminalMainWindow* self,
                                                           const gchar* id);
VALA_EXTERN void terminal_main_window_set_active_terminal_tab (TerminalMainWindow* self,
                                                   HdyTabPage* tab);
VALA_EXTERN void terminal_terminal_widget_set_tab_label (TerminalTerminalWidget* self,
                                             const gchar* value);
static gchar* terminal_main_window_disambiguate_label (TerminalMainWindow* self,
                                                const gchar* path,
                                                const gchar* conflict_path);
VALA_EXTERN gboolean terminal_application_get_is_testing (TerminalApplication* self);
static void _vala_array_add10 (gchar** * array,
                        gint* length,
                        gint* size,
                        gchar* value);
static void _vala_array_add11 (gchar** * array,
                        gint* length,
                        gint* size,
                        gchar* value);
VALA_EXTERN gchar* terminal_utils_get_parent_path_from_path (const gchar* path);
static void terminal_main_window_set_focus_restored_tabs (TerminalMainWindow* self,
                                                   gboolean value);
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_context_menu_model (TerminalMainWindow* self,
                                                  GMenu* 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_add12 (gchar** * array,
                        gint* length,
                        gint* size,
                        gchar* value);
static GVariant* _variant_new4 (const gchar* value);
static GVariant* _variant_new5 (const 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___lambda29_ (TerminalMainWindow* self);
static gboolean ___lambda30_ (TerminalMainWindow* self);
static gboolean ____lambda30__gsource_func (gpointer self);
static void __terminal_main_window___lambda29__gtk_event_controller_key_focus_in (GtkEventControllerKey* _sender,
                                                                           gpointer self);
static void _terminal_main_window_update_font_g_settings_changed (GSettings* _sender,
                                                           const gchar* key,
                                                           gpointer self);
static gboolean _terminal_main_window_on_delete_event_gtk_widget_delete_event (GtkWidget* _sender,
                                                                        GdkEventAny* event,
                                                                        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[19] = {{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_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}, {TERMINAL_MAIN_WINDOW_ACTION_OPEN_IN_BROWSER, _terminal_main_window_action_open_in_browser_gsimple_action_activate_callback}};
VALA_EXTERN const gchar* TERMINAL_TERMINAL_WIDGET_ACCELS_COPY[2];
VALA_EXTERN const gchar* TERMINAL_TERMINAL_WIDGET_ACCELS_COPY_OUTPUT[2];
VALA_EXTERN const gchar* TERMINAL_TERMINAL_WIDGET_ACCELS_CLEAR_SCREEN[2];
VALA_EXTERN const gchar* TERMINAL_TERMINAL_WIDGET_ACCELS_RESET[2];
VALA_EXTERN const gchar* TERMINAL_TERMINAL_WIDGET_ACCELS_PASTE[2];
VALA_EXTERN const gchar* TERMINAL_TERMINAL_WIDGET_ACCELS_SELECT_ALL[2];

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

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

static void
_vala_PangoFontDescription_free (PangoFontDescription* self)
{
	g_boxed_free (pango_font_description_get_type (), 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 _tmp14_ = FALSE;
	gint _tmp15_;
	gint _tmp16_;
	const gchar* _tmp41_;
	TerminalTerminalView* _tmp42_;
	gint _tmp43_;
	gint _tmp44_;
	TerminalTerminalWidget* _tmp45_;
	TerminalTerminalWidget* _tmp46_;
	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_;
			gint _tmp9_;
			gint _tmp10_;
			TerminalTerminalWidget* _tmp11_;
			TerminalTerminalWidget* _tmp12_;
			_tmp8_ = self->priv->_notebook;
			_tmp9_ = terminal_terminal_view_get_n_pages (_tmp8_);
			_tmp10_ = _tmp9_;
			_tmp11_ = terminal_main_window_new_tab (self, "", command, TRUE, _tmp10_);
			_tmp12_ = _tmp11_;
			_g_object_unref0 (_tmp12_);
		}
		_g_free0 (location);
		return;
	} else {
		gchar* _tmp13_;
		_tmp13_ = g_strdup (directory);
		_g_free0 (location);
		location = _tmp13_;
	}
	_tmp15_ = strlen (command);
	_tmp16_ = _tmp15_;
	if (_tmp16_ == 0) {
		_tmp14_ = !create_new_tab;
	} else {
		_tmp14_ = FALSE;
	}
	if (_tmp14_) {
		GFile* file = NULL;
		const gchar* _tmp17_;
		GFile* _tmp18_;
		_tmp17_ = location;
		_tmp18_ = g_file_new_for_commandline_arg (_tmp17_);
		file = _tmp18_;
		{
			gint pos = 0;
			pos = 0;
			{
				gboolean _tmp19_ = FALSE;
				_tmp19_ = TRUE;
				while (TRUE) {
					TerminalTerminalView* _tmp21_;
					gint _tmp22_;
					gint _tmp23_;
					HdyTabPage* tab = NULL;
					TerminalTerminalView* _tmp24_;
					HdyTabView* _tmp25_;
					HdyTabView* _tmp26_;
					HdyTabPage* _tmp27_;
					HdyTabPage* _tmp28_;
					TerminalTerminalWidget* terminal_widget = NULL;
					HdyTabPage* _tmp29_;
					TerminalTerminalWidget* _tmp30_;
					TerminalTerminalWidget* _tmp31_;
					gchar* tab_path = NULL;
					TerminalTerminalWidget* _tmp32_;
					gchar* _tmp33_;
					GFile* _tmp34_;
					const gchar* _tmp35_;
					GFile* _tmp36_;
					GFile* _tmp37_;
					gboolean _tmp38_;
					if (!_tmp19_) {
						gint _tmp20_;
						_tmp20_ = pos;
						pos = _tmp20_ + 1;
					}
					_tmp19_ = FALSE;
					_tmp21_ = self->priv->_notebook;
					_tmp22_ = terminal_terminal_view_get_n_pages (_tmp21_);
					_tmp23_ = _tmp22_;
					if (!(pos < _tmp23_)) {
						break;
					}
					_tmp24_ = self->priv->_notebook;
					_tmp25_ = terminal_terminal_view_get_tab_view (_tmp24_);
					_tmp26_ = _tmp25_;
					_tmp27_ = hdy_tab_view_get_nth_page (_tmp26_, pos);
					_tmp28_ = _g_object_ref0 (_tmp27_);
					tab = _tmp28_;
					_tmp29_ = tab;
					_tmp30_ = terminal_main_window_get_term_widget (self, _tmp29_);
					_tmp31_ = _g_object_ref0 (_tmp30_);
					terminal_widget = _tmp31_;
					_tmp32_ = terminal_widget;
					_tmp33_ = terminal_terminal_widget_get_shell_location (_tmp32_);
					tab_path = _tmp33_;
					_tmp34_ = file;
					_tmp35_ = tab_path;
					_tmp36_ = g_file_new_for_path (_tmp35_);
					_tmp37_ = _tmp36_;
					_tmp38_ = g_file_equal (_tmp34_, _tmp37_);
					_g_object_unref0 (_tmp37_);
					if (_tmp38_) {
						TerminalTerminalView* _tmp39_;
						HdyTabPage* _tmp40_;
						_tmp39_ = self->priv->_notebook;
						_tmp40_ = tab;
						terminal_terminal_view_set_selected_page (_tmp39_, _tmp40_);
						_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);
	}
	_tmp41_ = location;
	_tmp42_ = self->priv->_notebook;
	_tmp43_ = terminal_terminal_view_get_n_pages (_tmp42_);
	_tmp44_ = _tmp43_;
	_tmp45_ = terminal_main_window_new_tab (self, _tmp41_, command, TRUE, _tmp44_);
	_tmp46_ = _tmp45_;
	_g_object_unref0 (_tmp46_);
	_g_free0 (location);
}

static void
_terminal_main_window_on_tab_added_hdy_tab_view_page_attached (HdyTabView* _sender,
                                                               HdyTabPage* page,
                                                               gint position,
                                                               gpointer self)
{
	terminal_main_window_on_tab_added ((TerminalMainWindow*) self, page, position);
}

static void
_terminal_main_window_on_tab_removed_hdy_tab_view_page_detached (HdyTabView* _sender,
                                                                 HdyTabPage* page,
                                                                 gint position,
                                                                 gpointer self)
{
	terminal_main_window_on_tab_removed ((TerminalMainWindow*) self, page);
}

static void
_terminal_main_window_on_tab_reordered_hdy_tab_view_page_reordered (HdyTabView* _sender,
                                                                    HdyTabPage* page,
                                                                    gint position,
                                                                    gpointer self)
{
	terminal_main_window_on_tab_reordered ((TerminalMainWindow*) self, page, position);
}

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

static gboolean
__lambda23_ (TerminalMainWindow* self,
             HdyTabPage* tab)
{
	TerminalTerminalWidget* term = NULL;
	TerminalTerminalWidget* _tmp0_;
	TerminalTerminalWidget* _tmp1_;
	gboolean confirmed = FALSE;
	TerminalTerminalWidget* _tmp2_;
	gboolean _tmp4_ = FALSE;
	TerminalTerminalView* _tmp17_;
	HdyTabView* _tmp18_;
	HdyTabView* _tmp19_;
	gboolean result;
	g_return_val_if_fail (tab != NULL, FALSE);
	_tmp0_ = terminal_main_window_get_term_widget (self, tab);
	_tmp1_ = _g_object_ref0 (_tmp0_);
	term = _tmp1_;
	confirmed = FALSE;
	_tmp2_ = term;
	if (_tmp2_ == NULL) {
		confirmed = TRUE;
	} else {
		TerminalTerminalWidget* _tmp3_;
		_tmp3_ = term;
		confirmed = terminal_terminal_widget_confirm_kill_fg_process (_tmp3_, _ ("Are you sure you want to close this tab?"), _ ("Close Tab"));
	}
	if (confirmed) {
		TerminalTerminalWidget* _tmp5_;
		_tmp5_ = term;
		_tmp4_ = _tmp5_ != NULL;
	} else {
		_tmp4_ = FALSE;
	}
	if (_tmp4_) {
		TerminalTerminalWidget* _tmp6_;
		gboolean _tmp7_;
		gboolean _tmp8_;
		GSettings* _tmp10_;
		TerminalTerminalWidget* _tmp15_;
		TerminalTerminalWidget* _tmp16_;
		_tmp6_ = term;
		_tmp7_ = terminal_terminal_widget_get_child_has_exited (_tmp6_);
		_tmp8_ = _tmp7_;
		if (!_tmp8_) {
			TerminalTerminalWidget* _tmp9_;
			_tmp9_ = term;
			terminal_terminal_widget_term_ps (_tmp9_);
		}
		_tmp10_ = terminal_application_settings;
		if (g_settings_get_boolean (_tmp10_, "save-exited-tabs")) {
			TerminalTerminalView* _tmp11_;
			TerminalTerminalWidget* _tmp12_;
			const gchar* _tmp13_;
			const gchar* _tmp14_;
			_tmp11_ = self->priv->_notebook;
			_tmp12_ = term;
			_tmp13_ = terminal_terminal_widget_get_current_working_directory (_tmp12_);
			_tmp14_ = _tmp13_;
			terminal_terminal_view_make_restorable (_tmp11_, _tmp14_);
		}
		_tmp15_ = term;
		terminal_main_window_disconnect_terminal_signals (self, _tmp15_);
		_tmp16_ = term;
		terminal_terminal_widget_prepare_to_close (_tmp16_);
	}
	_tmp17_ = self->priv->_notebook;
	_tmp18_ = terminal_terminal_view_get_tab_view (_tmp17_);
	_tmp19_ = _tmp18_;
	hdy_tab_view_close_page_finish (_tmp19_, tab, confirmed);
	result = GDK_EVENT_STOP;
	_g_object_unref0 (term);
	return result;
}

static gboolean
___lambda23__hdy_tab_view_close_page (HdyTabView* _sender,
                                      HdyTabPage* page,
                                      gpointer self)
{
	gboolean result;
	result = __lambda23_ ((TerminalMainWindow*) self, page);
	return result;
}

static Block8Data*
block8_data_ref (Block8Data* _data8_)
{
	g_atomic_int_inc (&_data8_->_ref_count_);
	return _data8_;
}

static void
block8_data_unref (void * _userdata_)
{
	Block8Data* _data8_;
	_data8_ = (Block8Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data8_->_ref_count_)) {
		TerminalMainWindow* self;
		self = _data8_->self;
		_g_object_unref0 (_data8_->term);
		_g_object_unref0 (self);
		g_slice_free (Block8Data, _data8_);
	}
}

static gboolean
__lambda25_ (Block8Data* _data8_)
{
	TerminalMainWindow* self;
	TerminalTerminalWidget* _tmp0_;
	gboolean result;
	self = _data8_->self;
	_tmp0_ = _data8_->term;
	gtk_widget_grab_focus ((GtkWidget*) _tmp0_);
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
___lambda25__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda25_ (self);
	return result;
}

static void
__lambda24_ (TerminalMainWindow* self)
{
	Block8Data* _data8_;
	TerminalTerminalView* _tmp0_;
	HdyTabView* _tmp1_;
	HdyTabView* _tmp2_;
	HdyTabPage* _tmp3_;
	HdyTabPage* _tmp4_;
	TerminalTerminalWidget* _tmp5_;
	TerminalTerminalWidget* _tmp6_;
	TerminalTerminalWidget* _tmp7_;
	TerminalWidgetsZoomOverlay* _tmp8_;
	TerminalTerminalWidget* _tmp9_;
	const gchar* _tmp10_ = NULL;
	TerminalTerminalWidget* _tmp11_;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	TerminalTerminalWidget* _tmp20_;
	HdyTabPage* _tmp21_;
	TerminalTerminalWidget* _tmp22_;
	HdyTabPage* _tmp23_;
	_data8_ = g_slice_new0 (Block8Data);
	_data8_->_ref_count_ = 1;
	_data8_->self = g_object_ref (self);
	_tmp0_ = self->priv->_notebook;
	_tmp1_ = terminal_terminal_view_get_tab_view (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = hdy_tab_view_get_selected_page (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = terminal_main_window_get_term_widget (self, _tmp4_);
	_tmp6_ = _g_object_ref0 (_tmp5_);
	_data8_->term = _tmp6_;
	_tmp7_ = _data8_->term;
	terminal_main_window_set_current_terminal (self, _tmp7_);
	_tmp8_ = self->priv->zoom_overlay;
	terminal_widgets_zoom_overlay_hide_zoom_level (_tmp8_);
	_tmp9_ = _data8_->term;
	if (_tmp9_ == NULL) {
		block8_data_unref (_data8_);
		_data8_ = NULL;
		return;
	}
	_tmp11_ = _data8_->term;
	_tmp12_ = vte_terminal_get_window_title ((VteTerminal*) _tmp11_);
	_tmp13_ = _tmp12_;
	if (g_strcmp0 (_tmp13_, "") != 0) {
		TerminalTerminalWidget* _tmp14_;
		const gchar* _tmp15_;
		const gchar* _tmp16_;
		_tmp14_ = _data8_->term;
		_tmp15_ = vte_terminal_get_window_title ((VteTerminal*) _tmp14_);
		_tmp16_ = _tmp15_;
		_tmp10_ = _tmp16_;
	} else {
		TerminalTerminalWidget* _tmp17_;
		const gchar* _tmp18_;
		const gchar* _tmp19_;
		_tmp17_ = _data8_->term;
		_tmp18_ = terminal_terminal_widget_get_current_working_directory (_tmp17_);
		_tmp19_ = _tmp18_;
		_tmp10_ = _tmp19_;
	}
	gtk_window_set_title ((GtkWindow*) self, _tmp10_);
	g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, ___lambda25__gsource_func, block8_data_ref (_data8_), block8_data_unref);
	_tmp20_ = _data8_->term;
	_tmp21_ = _tmp20_->tab;
	if (_tmp21_ == NULL) {
		block8_data_unref (_data8_);
		_data8_ = NULL;
		return;
	}
	_tmp22_ = _data8_->term;
	_tmp23_ = _tmp22_->tab;
	hdy_tab_page_set_icon (_tmp23_, NULL);
	block8_data_unref (_data8_);
	_data8_ = NULL;
}

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

static void
__lambda27_ (TerminalMainWindow* self)
{
	_g_object_unref0 (self->priv->color_preferences_dialog);
	self->priv->color_preferences_dialog = NULL;
}

static void
___lambda27__gtk_widget_destroy (GtkWidget* _sender,
                                 gpointer self)
{
	__lambda27_ ((TerminalMainWindow*) self);
}

static void
__lambda26_ (TerminalMainWindow* self)
{
	TerminalDialogsColorPreferences* _tmp0_;
	TerminalDialogsColorPreferences* _tmp2_;
	TerminalDialogsColorPreferences* _tmp3_;
	_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;
	g_signal_connect_object ((GtkWidget*) _tmp2_, "destroy", (GCallback) ___lambda27__gtk_widget_destroy, self, 0);
	_tmp3_ = self->priv->color_preferences_dialog;
	gtk_window_present ((GtkWindow*) _tmp3_);
}

static void
___lambda26__terminal_settings_popover_show_theme_editor (TerminalSettingsPopover* _sender,
                                                          gpointer self)
{
	__lambda26_ ((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_;
	GtkStyleContext* _tmp12_;
	GtkButton* _tmp13_;
	GtkStyleContext* _tmp14_;
	gchar* _tmp15_;
	GtkImage* _tmp16_;
	gchar* _tmp17_;
	gchar** _tmp18_;
	gchar** _tmp19_;
	gint _tmp19__length1;
	gchar* _tmp20_;
	GtkToggleButton* _tmp21_ = NULL;
	GtkButton* new_tab_button = NULL;
	gchar* _tmp22_;
	gchar* _tmp23_;
	gchar** _tmp24_;
	gchar** _tmp25_;
	gint _tmp25__length1;
	gchar* _tmp26_;
	GtkButton* _tmp27_ = NULL;
	GtkButton* _tmp28_;
	GtkRevealer* new_tab_revealer = NULL;
	GtkWidget* _tmp29_;
	GtkRevealer* _tmp30_ = NULL;
	GtkMenuButton* menu_button = NULL;
	GtkImage* _tmp31_;
	TerminalSettingsPopover* _tmp32_;
	gchar* _tmp33_;
	GtkMenuButton* _tmp34_ = NULL;
	TerminalWidgetsSearchToolbar* _tmp35_;
	const gchar* _tmp36_;
	const gchar* _tmp37_;
	GtkLabel* _tmp38_ = NULL;
	GtkLabel* _tmp39_;
	GtkStyleContext* _tmp40_;
	GtkStack* _tmp41_ = NULL;
	GtkStack* _tmp42_;
	GtkLabel* _tmp43_;
	GtkStack* _tmp44_;
	TerminalWidgetsSearchToolbar* _tmp45_;
	GtkStack* _tmp46_;
	GtkStack* _tmp47_;
	GtkLabel* _tmp48_;
	HdyHeaderBar* _tmp49_ = NULL;
	HdyHeaderBar* _tmp50_;
	GtkButton* _tmp51_;
	HdyHeaderBar* _tmp52_;
	HdyHeaderBar* _tmp53_;
	GtkToggleButton* _tmp54_;
	HdyHeaderBar* _tmp55_;
	HdyHeaderBar* _tmp56_;
	GtkStack* _tmp57_;
	HdyHeaderBar* _tmp58_;
	GtkStyleContext* _tmp59_;
	TerminalTerminalView* _tmp60_;
	TerminalTerminalView* _tmp61_;
	TerminalTerminalView* _tmp62_;
	HdyTabView* _tmp63_;
	HdyTabView* _tmp64_;
	TerminalTerminalView* _tmp65_;
	HdyTabView* _tmp66_;
	HdyTabView* _tmp67_;
	TerminalTerminalView* _tmp68_;
	HdyTabView* _tmp69_;
	HdyTabView* _tmp70_;
	TerminalTerminalView* _tmp71_;
	HdyTabView* _tmp72_;
	HdyTabView* _tmp73_;
	TerminalTerminalView* _tmp74_;
	HdyTabView* _tmp75_;
	HdyTabView* _tmp76_;
	TerminalTerminalView* _tmp77_;
	HdyTabView* _tmp78_;
	HdyTabView* _tmp79_;
	TerminalTerminalView* _tmp80_;
	HdyTabBar* _tmp81_;
	HdyTabBar* _tmp82_;
	GtkOverlay* overlay = NULL;
	TerminalTerminalView* _tmp83_;
	GtkWidget* _tmp84_;
	GtkOverlay* _tmp85_ = NULL;
	TerminalWidgetsZoomOverlay* _tmp86_;
	GtkBox* box = NULL;
	GtkBox* _tmp87_;
	HdyHeaderBar* _tmp88_;
	GtkStyleContext* _tmp89_;
	GtkLabel* _tmp90_;
	TerminalSettingsPopover* menu_popover = NULL;
	GtkPopover* _tmp91_;
	GtkPopover* _tmp92_;
	HdyHeaderBar* _tmp93_;
	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", (GtkIconSize) GTK_ICON_SIZE_BUTTON);
	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_no_show_all ((GtkWidget*) _tmp1_, TRUE);
	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;
	_tmp12_ = gtk_widget_get_style_context ((GtkWidget*) _tmp11_);
	gtk_style_context_remove_class (_tmp12_, "image-button");
	_tmp13_ = self->priv->unfullscreen_button;
	_tmp14_ = gtk_widget_get_style_context ((GtkWidget*) _tmp13_);
	gtk_style_context_add_class (_tmp14_, "titlebutton");
	_tmp15_ = g_strdup (TERMINAL_MAIN_WINDOW_ACTION_PREFIX TERMINAL_MAIN_WINDOW_ACTION_SEARCH);
	_tmp16_ = (GtkImage*) gtk_image_new_from_icon_name ("edit-find-symbolic", (GtkIconSize) GTK_ICON_SIZE_SMALL_TOOLBAR);
	g_object_ref_sink (_tmp16_);
	_tmp17_ = g_strdup ("<Ctrl><Shift>f");
	_tmp18_ = g_new0 (gchar*, 1 + 1);
	_tmp18_[0] = _tmp17_;
	_tmp19_ = _tmp18_;
	_tmp19__length1 = 1;
	_tmp20_ = granite_markup_accel_tooltip (_tmp19_, (gint) 1, _ ("Find…"));
	_tmp21_ = (GtkToggleButton*) gtk_toggle_button_new ();
	gtk_actionable_set_action_name ((GtkActionable*) _tmp21_, _tmp15_);
	_g_free0 (_tmp15_);
	gtk_button_set_image ((GtkButton*) _tmp21_, (GtkWidget*) _tmp16_);
	_g_object_unref0 (_tmp16_);
	gtk_widget_set_valign ((GtkWidget*) _tmp21_, GTK_ALIGN_CENTER);
	gtk_widget_set_tooltip_markup ((GtkWidget*) _tmp21_, _tmp20_);
	_g_free0 (_tmp20_);
	g_object_ref_sink (_tmp21_);
	_g_object_unref0 (self->priv->search_button);
	self->priv->search_button = _tmp21_;
	_tmp19_ = (_vala_array_free (_tmp19_, _tmp19__length1, (GDestroyNotify) g_free), NULL);
	_tmp22_ = g_strdup (TERMINAL_MAIN_WINDOW_ACTION_PREFIX TERMINAL_MAIN_WINDOW_ACTION_NEW_TAB);
	_tmp23_ = g_strdup ("<Ctrl><Shift>t");
	_tmp24_ = g_new0 (gchar*, 1 + 1);
	_tmp24_[0] = _tmp23_;
	_tmp25_ = _tmp24_;
	_tmp25__length1 = 1;
	_tmp26_ = granite_markup_accel_tooltip (_tmp25_, (gint) 1, _ ("New Tab…"));
	_tmp27_ = (GtkButton*) gtk_button_new_from_icon_name ("list-add-symbolic", (GtkIconSize) GTK_ICON_SIZE_BUTTON);
	gtk_widget_set_valign ((GtkWidget*) _tmp27_, GTK_ALIGN_CENTER);
	gtk_actionable_set_action_name ((GtkActionable*) _tmp27_, _tmp22_);
	_g_free0 (_tmp22_);
	gtk_widget_set_tooltip_markup ((GtkWidget*) _tmp27_, _tmp26_);
	_g_free0 (_tmp26_);
	g_object_ref_sink (_tmp27_);
	_tmp28_ = _tmp27_;
	_tmp25_ = (_vala_array_free (_tmp25_, _tmp25__length1, (GDestroyNotify) g_free), NULL);
	new_tab_button = _tmp28_;
	_tmp29_ = _g_object_ref0 ((GtkWidget*) new_tab_button);
	_tmp30_ = (GtkRevealer*) gtk_revealer_new ();
	g_object_set ((GtkContainer*) _tmp30_, "child", _tmp29_, NULL);
	_g_object_unref0 (_tmp29_);
	gtk_revealer_set_transition_type (_tmp30_, GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT);
	g_object_ref_sink (_tmp30_);
	new_tab_revealer = _tmp30_;
	_tmp31_ = (GtkImage*) gtk_image_new_from_icon_name ("open-menu-symbolic", (GtkIconSize) GTK_ICON_SIZE_SMALL_TOOLBAR);
	g_object_ref_sink (_tmp31_);
	_tmp32_ = terminal_settings_popover_new ();
	g_object_ref_sink (_tmp32_);
	_tmp33_ = g_strdup (_ ("Settings"));
	_tmp34_ = (GtkMenuButton*) gtk_menu_button_new ();
	gtk_widget_set_can_focus ((GtkWidget*) _tmp34_, FALSE);
	gtk_button_set_image ((GtkButton*) _tmp34_, (GtkWidget*) _tmp31_);
	_g_object_unref0 (_tmp31_);
	gtk_menu_button_set_popover (_tmp34_, (GtkPopover*) _tmp32_);
	_g_object_unref0 (_tmp32_);
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp34_, _tmp33_);
	_g_free0 (_tmp33_);
	gtk_widget_set_valign ((GtkWidget*) _tmp34_, GTK_ALIGN_CENTER);
	g_object_ref_sink (_tmp34_);
	menu_button = _tmp34_;
	_tmp35_ = terminal_widgets_search_toolbar_new (self);
	g_object_ref_sink (_tmp35_);
	_g_object_unref0 (self->priv->search_toolbar);
	self->priv->search_toolbar = _tmp35_;
	_tmp36_ = gtk_window_get_title ((GtkWindow*) self);
	_tmp37_ = _tmp36_;
	_tmp38_ = (GtkLabel*) gtk_label_new (_tmp37_);
	g_object_set (_tmp38_, "wrap", FALSE, NULL);
	gtk_label_set_single_line_mode (_tmp38_, TRUE);
	gtk_label_set_ellipsize (_tmp38_, PANGO_ELLIPSIZE_END);
	g_object_ref_sink (_tmp38_);
	_g_object_unref0 (self->priv->title_label);
	self->priv->title_label = _tmp38_;
	_tmp39_ = self->priv->title_label;
	_tmp40_ = gtk_widget_get_style_context ((GtkWidget*) _tmp39_);
	gtk_style_context_add_class (_tmp40_, GTK_STYLE_CLASS_TITLE);
	_tmp41_ = (GtkStack*) gtk_stack_new ();
	gtk_stack_set_transition_type (_tmp41_, GTK_STACK_TRANSITION_TYPE_SLIDE_UP_DOWN);
	gtk_stack_set_hhomogeneous (_tmp41_, FALSE);
	g_object_ref_sink (_tmp41_);
	_g_object_unref0 (self->priv->title_stack);
	self->priv->title_stack = _tmp41_;
	_tmp42_ = self->priv->title_stack;
	_tmp43_ = self->priv->title_label;
	gtk_container_add ((GtkContainer*) _tmp42_, (GtkWidget*) _tmp43_);
	_tmp44_ = self->priv->title_stack;
	_tmp45_ = self->priv->search_toolbar;
	gtk_container_add ((GtkContainer*) _tmp44_, (GtkWidget*) _tmp45_);
	_tmp46_ = self->priv->title_stack;
	gtk_widget_show_all ((GtkWidget*) _tmp46_);
	_tmp47_ = self->priv->title_stack;
	_tmp48_ = self->priv->title_label;
	gtk_stack_set_visible_child (_tmp47_, (GtkWidget*) _tmp48_);
	_tmp49_ = (HdyHeaderBar*) hdy_header_bar_new ();
	hdy_header_bar_set_centering_policy (_tmp49_, HDY_CENTERING_POLICY_STRICT);
	hdy_header_bar_set_show_close_button (_tmp49_, TRUE);
	hdy_header_bar_set_has_subtitle (_tmp49_, FALSE);
	g_object_ref_sink (_tmp49_);
	_g_object_unref0 (self->priv->header);
	self->priv->header = _tmp49_;
	_tmp50_ = self->priv->header;
	_tmp51_ = self->priv->unfullscreen_button;
	hdy_header_bar_pack_end (_tmp50_, (GtkWidget*) _tmp51_);
	_tmp52_ = self->priv->header;
	hdy_header_bar_pack_end (_tmp52_, (GtkWidget*) menu_button);
	_tmp53_ = self->priv->header;
	_tmp54_ = self->priv->search_button;
	hdy_header_bar_pack_end (_tmp53_, (GtkWidget*) _tmp54_);
	_tmp55_ = self->priv->header;
	hdy_header_bar_pack_end (_tmp55_, (GtkWidget*) new_tab_revealer);
	_tmp56_ = self->priv->header;
	_tmp57_ = self->priv->title_stack;
	hdy_header_bar_set_custom_title (_tmp56_, (GtkWidget*) _tmp57_);
	_tmp58_ = self->priv->header;
	_tmp59_ = gtk_widget_get_style_context ((GtkWidget*) _tmp58_);
	gtk_style_context_add_class (_tmp59_, "default-decoration");
	_tmp60_ = terminal_terminal_view_new (self);
	g_object_ref_sink (_tmp60_);
	_tmp61_ = _tmp60_;
	terminal_main_window_set_notebook (self, _tmp61_);
	_g_object_unref0 (_tmp61_);
	_tmp62_ = self->priv->_notebook;
	_tmp63_ = terminal_terminal_view_get_tab_view (_tmp62_);
	_tmp64_ = _tmp63_;
	g_signal_connect_object (_tmp64_, "page-attached", (GCallback) _terminal_main_window_on_tab_added_hdy_tab_view_page_attached, self, 0);
	_tmp65_ = self->priv->_notebook;
	_tmp66_ = terminal_terminal_view_get_tab_view (_tmp65_);
	_tmp67_ = _tmp66_;
	g_signal_connect_object (_tmp67_, "page-detached", (GCallback) _terminal_main_window_on_tab_removed_hdy_tab_view_page_detached, self, 0);
	_tmp68_ = self->priv->_notebook;
	_tmp69_ = terminal_terminal_view_get_tab_view (_tmp68_);
	_tmp70_ = _tmp69_;
	g_signal_connect_object (_tmp70_, "page-reordered", (GCallback) _terminal_main_window_on_tab_reordered_hdy_tab_view_page_reordered, self, 0);
	_tmp71_ = self->priv->_notebook;
	_tmp72_ = terminal_terminal_view_get_tab_view (_tmp71_);
	_tmp73_ = _tmp72_;
	g_signal_connect_object (_tmp73_, "create-window", (GCallback) _terminal_main_window_on_create_window_request_hdy_tab_view_create_window, self, 0);
	_tmp74_ = self->priv->_notebook;
	_tmp75_ = terminal_terminal_view_get_tab_view (_tmp74_);
	_tmp76_ = _tmp75_;
	g_signal_connect_object (_tmp76_, "close-page", (GCallback) ___lambda23__hdy_tab_view_close_page, self, 0);
	_tmp77_ = self->priv->_notebook;
	_tmp78_ = terminal_terminal_view_get_tab_view (_tmp77_);
	_tmp79_ = _tmp78_;
	g_signal_connect_object ((GObject*) _tmp79_, "notify::selected-page", (GCallback) ___lambda24__g_object_notify, self, 0);
	_tmp80_ = self->priv->_notebook;
	_tmp81_ = terminal_terminal_view_get_tab_bar (_tmp80_);
	_tmp82_ = _tmp81_;
	g_object_bind_property_with_closures ((GObject*) _tmp82_, "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)));
	_tmp83_ = self->priv->_notebook;
	_tmp84_ = _g_object_ref0 ((GtkWidget*) _tmp83_);
	_tmp85_ = (GtkOverlay*) gtk_overlay_new ();
	g_object_set ((GtkContainer*) _tmp85_, "child", _tmp84_, NULL);
	_g_object_unref0 (_tmp84_);
	g_object_ref_sink (_tmp85_);
	overlay = _tmp85_;
	_tmp86_ = terminal_widgets_zoom_overlay_new (overlay);
	g_object_ref_sink (_tmp86_);
	_g_object_unref0 (self->priv->zoom_overlay);
	self->priv->zoom_overlay = _tmp86_;
	_tmp87_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp87_);
	box = _tmp87_;
	_tmp88_ = self->priv->header;
	gtk_container_add ((GtkContainer*) box, (GtkWidget*) _tmp88_);
	gtk_container_add ((GtkContainer*) box, (GtkWidget*) overlay);
	g_object_set ((GtkContainer*) self, "child", (GtkWidget*) box, NULL);
	_tmp89_ = gtk_widget_get_style_context ((GtkWidget*) self);
	gtk_style_context_add_class (_tmp89_, "terminal-window");
	_tmp90_ = self->priv->title_label;
	g_object_bind_property_with_closures ((GObject*) self, "title", (GObject*) _tmp90_, "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)));
	_tmp91_ = gtk_menu_button_get_popover (menu_button);
	_tmp92_ = _tmp91_;
	menu_popover = G_TYPE_CHECK_INSTANCE_CAST (_tmp92_, TERMINAL_TYPE_SETTINGS_POPOVER, TerminalSettingsPopover);
	g_signal_connect_object (menu_popover, "show-theme-editor", (GCallback) ___lambda26__terminal_settings_popover_show_theme_editor, self, 0);
	_tmp93_ = self->priv->header;
	g_object_bind_property_with_closures ((GObject*) self, "title", (GObject*) _tmp93_, "title", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	g_object_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 (overlay);
	_g_object_unref0 (menu_button);
	_g_object_unref0 (new_tab_revealer);
	_g_object_unref0 (new_tab_button);
}

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:
		{
			TerminalWidgetsSearchToolbar* _tmp0_;
			GtkSearchEntry* _tmp1_;
			gboolean _tmp2_;
			gboolean _tmp3_;
			_tmp0_ = self->priv->search_toolbar;
			_tmp1_ = _tmp0_->search_entry;
			g_object_get ((GtkWidget*) _tmp1_, "has-focus", &_tmp2_, NULL);
			_tmp3_ = _tmp2_;
			if (_tmp3_) {
				GtkToggleButton* _tmp4_;
				GtkToggleButton* _tmp5_;
				gboolean _tmp6_;
				gboolean _tmp7_;
				_tmp4_ = self->priv->search_button;
				_tmp5_ = self->priv->search_button;
				_tmp6_ = gtk_toggle_button_get_active (_tmp5_);
				_tmp7_ = _tmp6_;
				gtk_toggle_button_set_active (_tmp4_, !_tmp7_);
				result = TRUE;
				return result;
			}
			break;
		}
		case GDK_KEY_Return:
		{
			TerminalWidgetsSearchToolbar* _tmp8_;
			GtkSearchEntry* _tmp9_;
			gboolean _tmp10_;
			gboolean _tmp11_;
			_tmp8_ = self->priv->search_toolbar;
			_tmp9_ = _tmp8_->search_entry;
			g_object_get ((GtkWidget*) _tmp9_, "has-focus", &_tmp10_, NULL);
			_tmp11_ = _tmp10_;
			if (_tmp11_) {
				if ((modifiers & GDK_SHIFT_MASK) == GDK_SHIFT_MASK) {
					TerminalWidgetsSearchToolbar* _tmp12_;
					_tmp12_ = self->priv->search_toolbar;
					terminal_widgets_search_toolbar_previous_search (_tmp12_);
				} else {
					TerminalWidgetsSearchToolbar* _tmp13_;
					_tmp13_ = self->priv->search_toolbar;
					terminal_widgets_search_toolbar_next_search (_tmp13_);
				}
				result = TRUE;
				return result;
			}
			break;
		}
		case GDK_KEY_1:
		case GDK_KEY_2:
		case GDK_KEY_3:
		case GDK_KEY_4:
		case GDK_KEY_5:
		case GDK_KEY_6:
		case GDK_KEY_7:
		case GDK_KEY_8:
		{
			gboolean _tmp14_ = FALSE;
			gboolean _tmp15_ = FALSE;
			if ((modifiers & GDK_MOD1_MASK) == GDK_MOD1_MASK) {
				GSettings* _tmp16_;
				_tmp16_ = terminal_application_settings;
				_tmp15_ = g_settings_get_boolean (_tmp16_, "alt-changes-tab");
			} else {
				_tmp15_ = FALSE;
			}
			if (_tmp15_) {
				TerminalTerminalView* _tmp17_;
				gint _tmp18_;
				gint _tmp19_;
				_tmp17_ = self->priv->_notebook;
				_tmp18_ = terminal_terminal_view_get_n_pages (_tmp17_);
				_tmp19_ = _tmp18_;
				_tmp14_ = _tmp19_ > 1;
			} else {
				_tmp14_ = FALSE;
			}
			if (_tmp14_) {
				guint tab_index = 0U;
				TerminalTerminalView* _tmp20_;
				gint _tmp21_;
				gint _tmp22_;
				TerminalTerminalView* _tmp23_;
				TerminalTerminalView* _tmp24_;
				HdyTabView* _tmp25_;
				HdyTabView* _tmp26_;
				HdyTabPage* _tmp27_;
				tab_index = keyval - 49;
				_tmp20_ = self->priv->_notebook;
				_tmp21_ = terminal_terminal_view_get_n_pages (_tmp20_);
				_tmp22_ = _tmp21_;
				if (tab_index > ((guint) (_tmp22_ - 1))) {
					result = FALSE;
					return result;
				}
				_tmp23_ = self->priv->_notebook;
				_tmp24_ = self->priv->_notebook;
				_tmp25_ = terminal_terminal_view_get_tab_view (_tmp24_);
				_tmp26_ = _tmp25_;
				_tmp27_ = hdy_tab_view_get_nth_page (_tmp26_, (gint) tab_index);
				terminal_terminal_view_set_selected_page (_tmp23_, _tmp27_);
				result = TRUE;
				return result;
			}
			break;
		}
		case GDK_KEY_9:
		{
			gboolean _tmp28_ = FALSE;
			gboolean _tmp29_ = FALSE;
			if ((modifiers & GDK_MOD1_MASK) == GDK_MOD1_MASK) {
				GSettings* _tmp30_;
				_tmp30_ = terminal_application_settings;
				_tmp29_ = g_settings_get_boolean (_tmp30_, "alt-changes-tab");
			} else {
				_tmp29_ = FALSE;
			}
			if (_tmp29_) {
				TerminalTerminalView* _tmp31_;
				gint _tmp32_;
				gint _tmp33_;
				_tmp31_ = self->priv->_notebook;
				_tmp32_ = terminal_terminal_view_get_n_pages (_tmp31_);
				_tmp33_ = _tmp32_;
				_tmp28_ = _tmp33_ > 1;
			} else {
				_tmp28_ = FALSE;
			}
			if (_tmp28_) {
				TerminalTerminalView* _tmp34_;
				TerminalTerminalView* _tmp35_;
				HdyTabView* _tmp36_;
				HdyTabView* _tmp37_;
				TerminalTerminalView* _tmp38_;
				gint _tmp39_;
				gint _tmp40_;
				HdyTabPage* _tmp41_;
				_tmp34_ = self->priv->_notebook;
				_tmp35_ = self->priv->_notebook;
				_tmp36_ = terminal_terminal_view_get_tab_view (_tmp35_);
				_tmp37_ = _tmp36_;
				_tmp38_ = self->priv->_notebook;
				_tmp39_ = terminal_terminal_view_get_n_pages (_tmp38_);
				_tmp40_ = _tmp39_;
				_tmp41_ = hdy_tab_view_get_nth_page (_tmp37_, _tmp40_ - 1);
				terminal_terminal_view_set_selected_page (_tmp34_, _tmp41_);
				result = TRUE;
				return result;
			}
			break;
		}
		default:
		{
			break;
		}
	}
	result = FALSE;
	return result;
}

static void
terminal_main_window_restore_saved_state (TerminalMainWindow* self)
{
	GdkRectangle rect = {0};
	GSettings* _tmp0_;
	gint _tmp1_ = 0;
	gint _tmp2_ = 0;
	GdkRectangle _tmp3_;
	GdkRectangle _tmp4_;
	gint window_state = 0;
	GSettings* _tmp5_;
	g_return_if_fail (self != NULL);
	memset (&rect, 0, sizeof (GdkRectangle));
	_tmp0_ = terminal_application_saved_state;
	g_settings_get (_tmp0_, "window-size", "(ii)", &_tmp1_, &_tmp2_);
	rect.width = _tmp1_;
	rect.height = _tmp2_;
	_tmp3_ = rect;
	g_object_set ((GtkWindow*) self, "default-width", _tmp3_.width, NULL);
	_tmp4_ = rect;
	g_object_set ((GtkWindow*) self, "default-height", _tmp4_.height, NULL);
	_tmp5_ = terminal_application_saved_state;
	window_state = g_settings_get_enum (_tmp5_, "window-state");
	if (window_state == TERMINAL_MAIN_WINDOW_MAXIMIZED) {
		gtk_window_maximize ((GtkWindow*) self);
	} else {
		if (window_state == TERMINAL_MAIN_WINDOW_FULLSCREEN) {
			terminal_main_window_set_is_fullscreen (self, TRUE);
		}
	}
}

static void
terminal_main_window_on_tab_added (TerminalMainWindow* self,
                                   HdyTabPage* 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 (self, tab);
	_tmp1_ = _g_object_ref0 (_tmp0_);
	term = _tmp1_;
	terminal_terminal_widget_set_main_window (term, self);
	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,
                                     HdyTabPage* tab)
{
	TerminalTerminalView* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	TerminalTerminalWidget* _tmp3_;
	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_widget_destroy ((GtkWidget*) self);
	} else {
		terminal_main_window_check_for_tabs_with_same_name (self);
		terminal_main_window_save_opened_terminals (self, TRUE, TRUE);
	}
	_tmp3_ = terminal_main_window_get_term_widget (self, tab);
	terminal_main_window_disconnect_terminal_signals (self, _tmp3_);
}

static void
terminal_main_window_on_tab_reordered (TerminalMainWindow* self,
                                       HdyTabPage* 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 HdyTabView*
terminal_main_window_on_create_window_request (TerminalMainWindow* self)
{
	TerminalMainWindow* new_window = NULL;
	TerminalApplication* _tmp0_;
	TerminalMainWindow* _tmp1_;
	TerminalTerminalView* _tmp2_;
	HdyTabView* _tmp3_;
	HdyTabView* _tmp4_;
	HdyTabView* 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_ = new_window->priv->_notebook;
	_tmp3_ = terminal_terminal_view_get_tab_view (_tmp2_);
	_tmp4_ = _tmp3_;
	result = _tmp4_;
	_g_object_unref0 (new_window);
	return result;
}

void
terminal_main_window_update_context_menu (TerminalMainWindow* self)
{
	TerminalTerminalWidget* _tmp0_;
	gchar* uri = NULL;
	gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_current_terminal;
	_vala_return_if_fail (_tmp0_ != NULL, "current_terminal != null");
	_tmp1_ = terminal_main_window_get_current_selection_link_or_pwd (self);
	uri = _tmp1_;
	terminal_main_window_update_menu_label (self, uri);
	_g_free0 (uri);
}

static void
terminal_main_window_update_menu_label (TerminalMainWindow* self,
                                        const gchar* uri)
{
	GAppInfo* appinfo = NULL;
	GAppInfo* _tmp0_;
	GMenu* _tmp1_;
	GSimpleAction* _tmp2_;
	GSimpleAction* _tmp3_;
	GAppInfo* _tmp4_;
	const gchar* _tmp5_ = NULL;
	GAppInfo* _tmp6_;
	gchar* new_name = NULL;
	gchar* _tmp9_;
	GMenuItem* _tmp10_;
	GVariant* _tmp11_;
	GVariant* _tmp12_;
	GMenu* _tmp13_;
	GMenuItem* _tmp14_;
	g_return_if_fail (self != NULL);
	_tmp0_ = terminal_main_window_get_default_app_for_uri (self, uri);
	appinfo = _tmp0_;
	_tmp1_ = self->priv->_context_menu_model;
	g_menu_remove (_tmp1_, 0);
	_tmp2_ = terminal_main_window_get_simple_action (self, TERMINAL_MAIN_WINDOW_ACTION_OPEN_IN_BROWSER);
	_tmp3_ = _tmp2_;
	_tmp4_ = appinfo;
	g_simple_action_set_enabled (_tmp3_, _tmp4_ != NULL);
	_g_object_unref0 (_tmp3_);
	_tmp6_ = appinfo;
	if (_tmp6_ != NULL) {
		GAppInfo* _tmp7_;
		const gchar* _tmp8_;
		_tmp7_ = appinfo;
		_tmp8_ = g_app_info_get_display_name (_tmp7_);
		_tmp5_ = _tmp8_;
	} else {
		_tmp5_ = _ ("Default application");
	}
	_tmp9_ = g_strdup_printf (_ ("Show in %s"), _tmp5_);
	new_name = _tmp9_;
	_tmp10_ = self->priv->open_in_browser_menuitem;
	_tmp11_ = g_variant_new ("s", new_name, NULL);
	g_variant_ref_sink (_tmp11_);
	_tmp12_ = _tmp11_;
	g_menu_item_set_attribute_value (_tmp10_, "label", _tmp12_);
	_g_variant_unref0 (_tmp12_);
	_tmp13_ = self->priv->_context_menu_model;
	_tmp14_ = self->priv->open_in_browser_menuitem;
	g_menu_prepend_item (_tmp13_, _tmp14_);
	_g_free0 (new_name);
	_g_object_unref0 (appinfo);
}

static GAppInfo*
terminal_main_window_get_default_app_for_uri (TerminalMainWindow* self,
                                              const gchar* uri)
{
	GAppInfo* appinfo = NULL;
	gchar* scheme = NULL;
	gchar* _tmp0_;
	const gchar* _tmp1_;
	GAppInfo* _tmp4_;
	GError* _inner_error0_ = NULL;
	GAppInfo* result;
	g_return_val_if_fail (self != NULL, NULL);
	if (uri == NULL) {
		result = NULL;
		return result;
	}
	appinfo = NULL;
	_tmp0_ = g_uri_parse_scheme (uri);
	scheme = _tmp0_;
	_tmp1_ = scheme;
	if (_tmp1_ != NULL) {
		const gchar* _tmp2_;
		GAppInfo* _tmp3_;
		_tmp2_ = scheme;
		_tmp3_ = g_app_info_get_default_for_uri_scheme (_tmp2_);
		_g_object_unref0 (appinfo);
		appinfo = _tmp3_;
	}
	_tmp4_ = appinfo;
	if (_tmp4_ == NULL) {
		gboolean uncertain = FALSE;
		gchar* ctype = NULL;
		gboolean _tmp5_ = FALSE;
		gchar* _tmp6_;
		GAppInfo* _tmp9_;
		_tmp6_ = g_content_type_guess (uri, NULL, (gsize) 0, &_tmp5_);
		uncertain = _tmp5_;
		ctype = _tmp6_;
		if (!uncertain) {
			const gchar* _tmp7_;
			GAppInfo* _tmp8_;
			_tmp7_ = ctype;
			_tmp8_ = g_app_info_get_default_for_type (_tmp7_, TRUE);
			_g_object_unref0 (appinfo);
			appinfo = _tmp8_;
		}
		_tmp9_ = appinfo;
		if (_tmp9_ == NULL) {
			GFile* file = NULL;
			GFile* _tmp10_;
			_tmp10_ = g_file_new_for_commandline_arg (uri);
			file = _tmp10_;
			{
				GFileInfo* info = NULL;
				GFile* _tmp11_;
				GFileInfo* _tmp12_;
				GFileInfo* _tmp13_;
				_tmp11_ = file;
				_tmp12_ = g_file_query_info (_tmp11_, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL, &_inner_error0_);
				info = _tmp12_;
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					goto __catch0_g_error;
				}
				_tmp13_ = info;
				if (g_file_info_has_attribute (_tmp13_, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE)) {
					GFileInfo* _tmp14_;
					const gchar* _tmp15_;
					GAppInfo* _tmp16_;
					_tmp14_ = info;
					_tmp15_ = g_file_info_get_attribute_string (_tmp14_, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE);
					_tmp16_ = g_app_info_get_default_for_type (_tmp15_, TRUE);
					_g_object_unref0 (appinfo);
					appinfo = _tmp16_;
				}
				_g_object_unref0 (info);
			}
			goto __finally0;
			__catch0_g_error:
			{
				GError* e = NULL;
				GError* _tmp17_;
				const gchar* _tmp18_;
				e = _inner_error0_;
				_inner_error0_ = NULL;
				_tmp17_ = e;
				_tmp18_ = _tmp17_->message;
				g_warning ("MainWindow.vala:620: Could not get file info %s", _tmp18_);
				_g_error_free0 (e);
			}
			__finally0:
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_g_object_unref0 (file);
				_g_free0 (ctype);
				_g_free0 (scheme);
				_g_object_unref0 (appinfo);
				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;
			}
			_g_object_unref0 (file);
		}
		_g_free0 (ctype);
	}
	result = appinfo;
	_g_free0 (scheme);
	return result;
}

static gboolean
__lambda28_ (TerminalMainWindow* self)
{
	GdkWindow* _tmp0_;
	GdkWindow* _tmp1_;
	gboolean result;
	self->priv->timer_window_state_change = (guint) 0;
	_tmp0_ = gtk_widget_get_window ((GtkWidget*) self);
	if (_tmp0_ == NULL) {
		result = FALSE;
		return result;
	}
	_tmp1_ = gtk_widget_get_window ((GtkWidget*) self);
	if ((gdk_window_get_state (_tmp1_) & GDK_WINDOW_STATE_FULLSCREEN) != 0) {
		GSettings* _tmp2_;
		_tmp2_ = terminal_application_saved_state;
		g_settings_set_enum (_tmp2_, "window-state", TERMINAL_MAIN_WINDOW_FULLSCREEN);
	} else {
		gboolean _tmp3_;
		gboolean _tmp4_;
		g_object_get ((GtkWindow*) self, "is-maximized", &_tmp3_, NULL);
		_tmp4_ = _tmp3_;
		if (_tmp4_) {
			GSettings* _tmp5_;
			_tmp5_ = terminal_application_saved_state;
			g_settings_set_enum (_tmp5_, "window-state", TERMINAL_MAIN_WINDOW_MAXIMIZED);
		} else {
			GSettings* _tmp6_;
			GdkRectangle rect = {0};
			gint _tmp7_ = 0;
			gint _tmp8_ = 0;
			GSettings* _tmp9_;
			GdkRectangle _tmp10_;
			GdkRectangle _tmp11_;
			_tmp6_ = terminal_application_saved_state;
			g_settings_set_enum (_tmp6_, "window-state", TERMINAL_MAIN_WINDOW_NORMAL);
			memset (&rect, 0, sizeof (GdkRectangle));
			gtk_window_get_size ((GtkWindow*) self, &_tmp7_, &_tmp8_);
			rect.width = _tmp7_;
			rect.height = _tmp8_;
			_tmp9_ = terminal_application_saved_state;
			_tmp10_ = rect;
			_tmp11_ = rect;
			g_settings_set (_tmp9_, "window-size", "(ii)", _tmp10_.width, _tmp11_.height);
		}
	}
	result = FALSE;
	return result;
}

static gboolean
___lambda28__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda28_ ((TerminalMainWindow*) self);
	return result;
}

static gboolean
terminal_main_window_real_configure_event (GtkWidget* base,
                                           GdkEventConfigure* event)
{
	TerminalMainWindow * self;
	gboolean result;
	self = (TerminalMainWindow*) base;
	g_return_val_if_fail (event != NULL, FALSE);
	if (self->priv->timer_window_state_change > ((guint) 0)) {
		g_source_remove (self->priv->timer_window_state_change);
	}
	self->priv->timer_window_state_change = g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 400, ___lambda28__gsource_func, g_object_ref (self), g_object_unref);
	result = GTK_WIDGET_CLASS (terminal_main_window_parent_class)->configure_event ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (self, hdy_window_get_type (), HdyWindow), event);
	return result;
}

static void
_vala_array_add4 (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_add5 (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, 0.0);
	result = g_ascii_strtod (str, NULL);
	return result;
}

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
_vala_array_add7 (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_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;
}

static void
_vala_array_add9 (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;
	gboolean _tmp51_;
	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_add4 (&tabs, &tabs_length1, &_tabs_size_, _tmp10_);
			_vala_array_add5 (&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 zoom = 0.0;
						const gchar* _tmp14_;
						gdouble* _tmp15_;
						gint _tmp15__length1;
						_tmp14_ = zoom_s;
						zoom = double_parse (_tmp14_);
						_tmp15_ = zooms;
						_tmp15__length1 = zooms_length1;
						if (_tmp15__length1 < n_tabs) {
							_vala_array_add6 (&zooms, &zooms_length1, &_zooms_size_, zoom);
						} 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_add7 (&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_add8 (&tabs, &tabs_length1, &_tabs_size_, _tmp18_);
		_vala_array_add9 (&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) == FALSE) {
					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 _tmp50_;
				_tmp40_ = loc;
				if (g_strcmp0 (_tmp40_, "") == 0) {
					gint _tmp41_;
					_tmp41_ = focus;
					focus = _tmp41_ - 1;
				} else {
					TerminalTerminalWidget* term = NULL;
					const gchar* _tmp42_;
					TerminalTerminalView* _tmp43_;
					gint _tmp44_;
					gint _tmp45_;
					TerminalTerminalWidget* _tmp46_;
					TerminalTerminalWidget* _tmp47_;
					gdouble* _tmp48_;
					gint _tmp48__length1;
					gdouble _tmp49_;
					_tmp42_ = loc;
					_tmp43_ = self->priv->_notebook;
					_tmp44_ = terminal_terminal_view_get_n_pages (_tmp43_);
					_tmp45_ = _tmp44_;
					_tmp46_ = terminal_main_window_new_tab (self, _tmp42_, "", FALSE, _tmp45_);
					term = _tmp46_;
					_tmp47_ = term;
					_tmp48_ = zooms;
					_tmp48__length1 = zooms_length1;
					_tmp49_ = _tmp48_[index];
					vte_terminal_set_font_scale ((VteTerminal*) _tmp47_, CLAMP (_tmp49_, TERMINAL_TERMINAL_WIDGET_MIN_SCALE, TERMINAL_TERMINAL_WIDGET_MAX_SCALE));
					_g_object_unref0 (term);
				}
				_tmp50_ = index;
				index = _tmp50_ + 1;
				_g_free0 (loc);
			}
		}
	}
	_tmp51_ = self->priv->_focus_restored_tabs;
	if (_tmp51_) {
		HdyTabPage* tab = NULL;
		TerminalTerminalView* _tmp52_;
		HdyTabView* _tmp53_;
		HdyTabView* _tmp54_;
		TerminalTerminalView* _tmp55_;
		gint _tmp56_;
		gint _tmp57_;
		HdyTabPage* _tmp58_;
		HdyTabPage* _tmp59_;
		TerminalTerminalView* _tmp60_;
		HdyTabPage* _tmp61_;
		_tmp52_ = self->priv->_notebook;
		_tmp53_ = terminal_terminal_view_get_tab_view (_tmp52_);
		_tmp54_ = _tmp53_;
		_tmp55_ = self->priv->_notebook;
		_tmp56_ = terminal_terminal_view_get_n_pages (_tmp55_);
		_tmp57_ = _tmp56_;
		_tmp58_ = hdy_tab_view_get_nth_page (_tmp54_, CLAMP (focus, 0, _tmp57_ - 1));
		_tmp59_ = _g_object_ref0 (_tmp58_);
		tab = _tmp59_;
		_tmp60_ = self->priv->_notebook;
		_tmp61_ = tab;
		terminal_terminal_view_set_selected_page (_tmp60_, _tmp61_);
		_g_object_unref0 (tab);
	}
	zooms = (g_free (zooms), NULL);
	tabs = (_vala_array_free (tabs, tabs_length1, (GDestroyNotify) g_free), NULL);
}

static TerminalTerminalWidget*
terminal_main_window_new_tab (TerminalMainWindow* self,
                              const gchar* location,
                              const gchar* program,
                              gboolean focus,
                              gint pos)
{
	TerminalTerminalWidget* terminal_widget = NULL;
	GSettings* _tmp0_;
	TerminalTerminalWidget* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	HdyTabPage* tab = NULL;
	TerminalTerminalWidget* _tmp5_;
	HdyTabPage* _tmp6_;
	TerminalTerminalWidget* _tmp7_;
	PangoFontDescription* _tmp8_;
	TerminalTerminalWidget* _tmp9_;
	gint _tmp18_;
	gint _tmp19_;
	TerminalTerminalWidget* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (location != NULL, NULL);
	g_return_val_if_fail (program != NULL, NULL);
	_tmp0_ = terminal_application_settings;
	_tmp1_ = terminal_terminal_widget_new (self);
	vte_terminal_set_scrollback_lines ((VteTerminal*) _tmp1_, (guint) g_settings_get_int (_tmp0_, "scrollback-lines"));
	gtk_widget_set_hexpand ((GtkWidget*) _tmp1_, TRUE);
	gtk_widget_set_vexpand ((GtkWidget*) _tmp1_, TRUE);
	g_object_ref_sink (_tmp1_);
	terminal_widget = _tmp1_;
	if (location != NULL) {
		gchar* _tmp3_;
		_tmp3_ = g_path_get_basename (location);
		_g_free0 (_tmp2_);
		_tmp2_ = _tmp3_;
	} else {
		gchar* _tmp4_;
		_tmp4_ = g_strdup (TERMINAL_TERMINAL_WIDGET_DEFAULT_LABEL);
		_g_free0 (_tmp2_);
		_tmp2_ = _tmp4_;
	}
	_tmp5_ = terminal_widget;
	_tmp6_ = terminal_main_window_append_tab (self, _tmp2_, NULL, _tmp5_, pos);
	tab = _tmp6_;
	_tmp7_ = terminal_widget;
	_tmp8_ = self->priv->term_font;
	vte_terminal_set_font ((VteTerminal*) _tmp7_, _tmp8_);
	_tmp9_ = self->priv->_current_terminal;
	if (_tmp9_ != NULL) {
		TerminalTerminalWidget* _tmp10_;
		TerminalTerminalWidget* _tmp11_;
		gdouble _tmp12_;
		gdouble _tmp13_;
		_tmp10_ = terminal_widget;
		_tmp11_ = self->priv->_current_terminal;
		_tmp12_ = vte_terminal_get_font_scale ((VteTerminal*) _tmp11_);
		_tmp13_ = _tmp12_;
		vte_terminal_set_font_scale ((VteTerminal*) _tmp10_, _tmp13_);
	} else {
		TerminalTerminalWidget* _tmp14_;
		GSettings* _tmp15_;
		_tmp14_ = terminal_widget;
		_tmp15_ = terminal_application_saved_state;
		vte_terminal_set_font_scale ((VteTerminal*) _tmp14_, g_settings_get_double (_tmp15_, "zoom"));
	}
	if (focus) {
		TerminalTerminalView* _tmp16_;
		HdyTabPage* _tmp17_;
		_tmp16_ = self->priv->_notebook;
		_tmp17_ = tab;
		terminal_terminal_view_set_selected_page (_tmp16_, _tmp17_);
	}
	_tmp18_ = strlen (program);
	_tmp19_ = _tmp18_;
	if (_tmp19_ == 0) {
		if (g_strcmp0 (location, "") == 0) {
			TerminalTerminalWidget* _tmp20_;
			gchar* _tmp21_;
			gchar* _tmp22_;
			_tmp20_ = terminal_widget;
			_tmp21_ = g_get_current_dir ();
			_tmp22_ = _tmp21_;
			terminal_terminal_widget_active_shell (_tmp20_, _tmp22_);
			_g_free0 (_tmp22_);
		} else {
			TerminalTerminalWidget* _tmp23_;
			_tmp23_ = terminal_widget;
			terminal_terminal_widget_active_shell (_tmp23_, location);
		}
	} else {
		TerminalTerminalWidget* _tmp24_;
		_tmp24_ = terminal_widget;
		terminal_terminal_widget_run_program (_tmp24_, program, location);
	}
	terminal_main_window_save_opened_terminals (self, TRUE, TRUE);
	result = terminal_widget;
	_g_object_unref0 (tab);
	_g_free0 (_tmp2_);
	return result;
}

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_font_scale_changed_g_object_notify (GObject* _sender,
                                                                      GParamSpec* pspec,
                                                                      gpointer self)
{
	terminal_main_window_on_terminal_font_scale_changed ((TerminalMainWindow*) self);
}

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_on_terminal_program_changed_terminal_terminal_widget_foreground_process_changed (TerminalTerminalWidget* _sender,
                                                                                                       const gchar* cmdline,
                                                                                                       gpointer self)
{
	terminal_main_window_on_terminal_program_changed ((TerminalMainWindow*) self, _sender, cmdline);
}

static void
_terminal_main_window_on_terminal_window_title_changed_vte_terminal_window_title_changed (VteTerminal* _sender,
                                                                                          gpointer self)
{
	terminal_main_window_on_terminal_window_title_changed ((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 ((GObject*) terminal_widget, "notify::font-scale", (GCallback) _terminal_main_window_on_terminal_font_scale_changed_g_object_notify, 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_on_terminal_program_changed_terminal_terminal_widget_foreground_process_changed, self, 0);
	g_signal_connect_object ((VteTerminal*) terminal_widget, "window-title-changed", (GCallback) _terminal_main_window_on_terminal_window_title_changed_vte_terminal_window_title_changed, self, 0);
}

static void
terminal_main_window_disconnect_terminal_signals (TerminalMainWindow* self,
                                                  TerminalTerminalWidget* terminal_widget)
{
	guint _tmp0_;
	guint _tmp1_;
	GQuark _tmp2_;
	guint _tmp3_;
	guint _tmp4_;
	guint _tmp5_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (terminal_widget != NULL);
	g_signal_parse_name ("child-exited", vte_terminal_get_type (), &_tmp0_, NULL, FALSE);
	g_signal_handlers_disconnect_matched ((VteTerminal*) terminal_widget, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp0_, 0, NULL, (GCallback) _terminal_main_window_on_terminal_child_exited_vte_terminal_child_exited, self);
	g_signal_parse_name ("notify::font-scale", G_TYPE_OBJECT, &_tmp1_, &_tmp2_, TRUE);
	g_signal_handlers_disconnect_matched ((GObject*) terminal_widget, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DETAIL | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp1_, _tmp2_, NULL, (GCallback) _terminal_main_window_on_terminal_font_scale_changed_g_object_notify, self);
	g_signal_parse_name ("cwd-changed", TERMINAL_TYPE_TERMINAL_WIDGET, &_tmp3_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (terminal_widget, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp3_, 0, NULL, (GCallback) _terminal_main_window_on_terminal_cwd_changed_terminal_terminal_widget_cwd_changed, self);
	g_signal_parse_name ("foreground-process-changed", TERMINAL_TYPE_TERMINAL_WIDGET, &_tmp4_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (terminal_widget, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp4_, 0, NULL, (GCallback) _terminal_main_window_on_terminal_program_changed_terminal_terminal_widget_foreground_process_changed, self);
	g_signal_parse_name ("window-title-changed", vte_terminal_get_type (), &_tmp5_, NULL, FALSE);
	g_signal_handlers_disconnect_matched ((VteTerminal*) terminal_widget, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp5_, 0, NULL, (GCallback) _terminal_main_window_on_terminal_window_title_changed_vte_terminal_window_title_changed, self);
}

static void
terminal_main_window_on_terminal_child_exited (TerminalMainWindow* self,
                                               VteTerminal* term,
                                               gint status)
{
	TerminalTerminalWidget* tw = NULL;
	TerminalTerminalWidget* _tmp0_;
	TerminalTerminalWidget* _tmp1_;
	HdyTabPage* _tmp2_;
	GtkWidget* _tmp3_;
	GtkWidget* _tmp4_;
	TerminalTerminalWidget* _tmp5_;
	GtkContainer* _tmp6_;
	GtkContainer* _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_ = hdy_tab_page_get_child (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = tw;
	_tmp6_ = gtk_widget_get_parent ((GtkWidget*) _tmp5_);
	_tmp7_ = _tmp6_;
	if (_tmp4_ != G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, gtk_widget_get_type (), GtkWidget)) {
		_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_;
			HdyTabPage* _tmp22_;
			_tmp21_ = tw;
			_tmp22_ = _tmp21_->tab;
			if (_tmp22_ != NULL) {
				TerminalTerminalView* _tmp23_;
				HdyTabView* _tmp24_;
				HdyTabView* _tmp25_;
				TerminalTerminalWidget* _tmp26_;
				HdyTabPage* _tmp27_;
				_tmp23_ = self->priv->_notebook;
				_tmp24_ = terminal_terminal_view_get_tab_view (_tmp23_);
				_tmp25_ = _tmp24_;
				_tmp26_ = tw;
				_tmp27_ = _tmp26_->tab;
				hdy_tab_view_close_page (_tmp25_, _tmp27_);
			}
			_g_object_unref0 (tw);
			return;
		}
	}
	_g_object_unref0 (tw);
}

static void
terminal_main_window_on_terminal_font_scale_changed (TerminalMainWindow* self)
{
	TerminalWidgetsZoomOverlay* _tmp0_;
	TerminalTerminalWidget* _tmp1_;
	gdouble _tmp2_;
	gdouble _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->zoom_overlay;
	_tmp1_ = self->priv->_current_terminal;
	_tmp2_ = vte_terminal_get_font_scale ((VteTerminal*) _tmp1_);
	_tmp3_ = _tmp2_;
	terminal_widgets_zoom_overlay_show_zoom_level (_tmp0_, _tmp3_);
	terminal_main_window_save_opened_terminals (self, FALSE, TRUE);
}

static void
terminal_main_window_on_terminal_window_title_changed (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_;
	gtk_window_set_title ((GtkWindow*) self, _tmp2_);
}

static HdyTabPage*
terminal_main_window_append_tab (TerminalMainWindow* self,
                                 const gchar* label,
                                 GIcon* icon,
                                 TerminalTerminalWidget* term,
                                 gint pos)
{
	GtkScrolledWindow* sw = NULL;
	GtkAdjustment* _tmp0_;
	GtkAdjustment* _tmp1_;
	GtkWidget* _tmp2_;
	GtkScrolledWindow* _tmp3_ = NULL;
	HdyTabPage* tab = NULL;
	TerminalTerminalView* _tmp4_;
	HdyTabView* _tmp5_;
	HdyTabView* _tmp6_;
	HdyTabPage* _tmp7_;
	HdyTabPage* _tmp8_;
	const gchar* _tmp9_;
	const gchar* _tmp10_;
	GtkWidget* _tmp11_;
	GtkWidget* _tmp12_;
	HdyTabPage* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (label != NULL, NULL);
	g_return_val_if_fail (term != NULL, NULL);
	_tmp0_ = gtk_scrollable_get_vadjustment ((GtkScrollable*) term);
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_tmp2_ = _g_object_ref0 ((GtkWidget*) term);
	_tmp3_ = (GtkScrolledWindow*) gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_vadjustment (_tmp3_, _tmp1_);
	_g_object_unref0 (_tmp1_);
	g_object_set ((GtkContainer*) _tmp3_, "child", _tmp2_, NULL);
	_g_object_unref0 (_tmp2_);
	g_object_ref_sink (_tmp3_);
	sw = _tmp3_;
	_tmp4_ = self->priv->_notebook;
	_tmp5_ = terminal_terminal_view_get_tab_view (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = hdy_tab_view_insert (_tmp6_, (GtkWidget*) sw, pos);
	_tmp8_ = _g_object_ref0 (_tmp7_);
	tab = _tmp8_;
	hdy_tab_page_set_title (tab, label);
	_tmp9_ = terminal_terminal_widget_get_current_working_directory (term);
	_tmp10_ = _tmp9_;
	hdy_tab_page_set_tooltip (tab, _tmp10_);
	hdy_tab_page_set_icon (tab, icon);
	term->tab = tab;
	_tmp11_ = hdy_tab_page_get_child (tab);
	_tmp12_ = _tmp11_;
	gtk_widget_show_all (_tmp12_);
	result = tab;
	_g_object_unref0 (sw);
	return result;
}

static void
terminal_main_window_update_font (TerminalMainWindow* self)
{
	gchar* app_font_name = NULL;
	GSettings* _tmp0_;
	gchar* _tmp1_;
	gchar* sys_font_name = NULL;
	GSettings* _tmp2_;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	g_return_if_fail (self != NULL);
	_tmp0_ = terminal_application_settings;
	_tmp1_ = g_settings_get_string (_tmp0_, "font");
	app_font_name = _tmp1_;
	_tmp2_ = terminal_application_settings_sys;
	_tmp3_ = g_settings_get_string (_tmp2_, "monospace-font-name");
	sys_font_name = _tmp3_;
	_tmp4_ = app_font_name;
	if (g_strcmp0 (_tmp4_, "") != 0) {
		const gchar* _tmp5_;
		PangoFontDescription* _tmp6_;
		_tmp5_ = app_font_name;
		_tmp6_ = pango_font_description_from_string (_tmp5_);
		__vala_PangoFontDescription_free0 (self->priv->term_font);
		self->priv->term_font = _tmp6_;
	} else {
		const gchar* _tmp7_;
		PangoFontDescription* _tmp8_;
		_tmp7_ = sys_font_name;
		_tmp8_ = pango_font_description_from_string (_tmp7_);
		__vala_PangoFontDescription_free0 (self->priv->term_font);
		self->priv->term_font = _tmp8_;
	}
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp9_ = FALSE;
			_tmp9_ = TRUE;
			while (TRUE) {
				TerminalTerminalView* _tmp11_;
				gint _tmp12_;
				gint _tmp13_;
				TerminalTerminalWidget* term = NULL;
				TerminalTerminalView* _tmp14_;
				HdyTabView* _tmp15_;
				HdyTabView* _tmp16_;
				HdyTabPage* _tmp17_;
				TerminalTerminalWidget* _tmp18_;
				TerminalTerminalWidget* _tmp19_;
				TerminalTerminalWidget* _tmp20_;
				PangoFontDescription* _tmp21_;
				if (!_tmp9_) {
					gint _tmp10_;
					_tmp10_ = i;
					i = _tmp10_ + 1;
				}
				_tmp9_ = FALSE;
				_tmp11_ = self->priv->_notebook;
				_tmp12_ = terminal_terminal_view_get_n_pages (_tmp11_);
				_tmp13_ = _tmp12_;
				if (!(i < _tmp13_)) {
					break;
				}
				_tmp14_ = self->priv->_notebook;
				_tmp15_ = terminal_terminal_view_get_tab_view (_tmp14_);
				_tmp16_ = _tmp15_;
				_tmp17_ = hdy_tab_view_get_nth_page (_tmp16_, i);
				_tmp18_ = terminal_main_window_get_term_widget (self, _tmp17_);
				_tmp19_ = _g_object_ref0 (_tmp18_);
				term = _tmp19_;
				_tmp20_ = term;
				_tmp21_ = self->priv->term_font;
				vte_terminal_set_font ((VteTerminal*) _tmp20_, _tmp21_);
				_g_object_unref0 (term);
			}
		}
	}
	_g_free0 (sys_font_name);
	_g_free0 (app_font_name);
}

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

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

gboolean
terminal_main_window_on_delete_event (TerminalMainWindow* self)
{
	TerminalTerminalView* _tmp0_;
	HdyTabView* _tmp1_;
	HdyTabView* _tmp2_;
	guint _tmp3_;
	GList* tabs_to_terminate = NULL;
	GList* _tmp18_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->_notebook;
	_tmp1_ = terminal_terminal_view_get_tab_view (_tmp0_);
	_tmp2_ = _tmp1_;
	g_signal_parse_name ("page-detached", hdy_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_hdy_tab_view_page_detached, self);
	terminal_main_window_save_opened_terminals (self, TRUE, TRUE);
	tabs_to_terminate = NULL;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp4_ = FALSE;
			_tmp4_ = TRUE;
			while (TRUE) {
				TerminalTerminalView* _tmp6_;
				gint _tmp7_;
				gint _tmp8_;
				TerminalTerminalWidget* term = NULL;
				TerminalTerminalView* _tmp9_;
				HdyTabView* _tmp10_;
				HdyTabView* _tmp11_;
				HdyTabPage* _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_ = hdy_tab_view_get_nth_page (_tmp11_, i);
				_tmp13_ = terminal_main_window_get_term_widget (self, _tmp12_);
				_tmp14_ = _g_object_ref0 (_tmp13_);
				term = _tmp14_;
				_tmp15_ = term;
				if (terminal_terminal_widget_confirm_kill_fg_process (_tmp15_, _ ("Are you sure you want to quit Terminal?"), _ ("Quit Terminal"))) {
					TerminalTerminalWidget* _tmp16_;
					TerminalTerminalWidget* _tmp17_;
					_tmp16_ = term;
					_tmp17_ = _g_object_ref0 (_tmp16_);
					tabs_to_terminate = g_list_append (tabs_to_terminate, _tmp17_);
				} else {
					result = TRUE;
					_g_object_unref0 (term);
					(tabs_to_terminate == NULL) ? NULL : (tabs_to_terminate = (_g_list_free__g_object_unref0_ (tabs_to_terminate), NULL));
					return result;
				}
				_g_object_unref0 (term);
			}
		}
	}
	_tmp18_ = tabs_to_terminate;
	{
		GList* t_collection = NULL;
		GList* t_it = NULL;
		t_collection = _tmp18_;
		for (t_it = t_collection; t_it != NULL; t_it = t_it->next) {
			TerminalTerminalWidget* _tmp19_;
			TerminalTerminalWidget* t = NULL;
			_tmp19_ = _g_object_ref0 ((TerminalTerminalWidget*) t_it->data);
			t = _tmp19_;
			{
				TerminalTerminalWidget* _tmp20_;
				_tmp20_ = t;
				terminal_terminal_widget_term_ps (_tmp20_);
				_g_object_unref0 (t);
			}
		}
	}
	result = FALSE;
	(tabs_to_terminate == NULL) ? NULL : (tabs_to_terminate = (_g_list_free__g_object_unref0_ (tabs_to_terminate), NULL));
	return result;
}

static void
__lambda16_ (TerminalMainWindow* self,
             GObject* obj,
             GAsyncResult* res)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (res != NULL);
	{
		g_app_info_launch_default_for_uri_finish (res, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp0_;
		const gchar* _tmp1_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp0_ = e;
		_tmp1_ = _tmp0_->message;
		g_warning ("MainWindow.vala:914: Launcher failed with error %s", _tmp1_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
}

static void
___lambda16__gasync_ready_callback (GObject* source_object,
                                    GAsyncResult* res,
                                    gpointer self)
{
	__lambda16_ ((TerminalMainWindow*) self, source_object, res);
	g_object_unref (self);
}

static void
terminal_main_window_action_open_in_browser (TerminalMainWindow* self)
{
	TerminalTerminalWidget* _tmp0_;
	gchar* uri = NULL;
	gchar* _tmp1_;
	GdkAppLaunchContext* context = NULL;
	GdkDisplay* _tmp2_;
	GdkAppLaunchContext* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_current_terminal;
	_vala_return_if_fail (_tmp0_ != NULL, "current_terminal != null");
	_tmp1_ = terminal_main_window_get_current_selection_link_or_pwd (self);
	uri = _tmp1_;
	_tmp2_ = gdk_display_get_default ();
	_tmp3_ = gdk_display_get_app_launch_context (_tmp2_);
	context = _tmp3_;
	g_app_info_launch_default_for_uri_async (uri, (GAppLaunchContext*) context, NULL, ___lambda16__gasync_ready_callback, g_object_ref (self));
	_g_object_unref0 (context);
	_g_free0 (uri);
}

static Block9Data*
block9_data_ref (Block9Data* _data9_)
{
	g_atomic_int_inc (&_data9_->_ref_count_);
	return _data9_;
}

static void
block9_data_unref (void * _userdata_)
{
	Block9Data* _data9_;
	_data9_ = (Block9Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data9_->_ref_count_)) {
		TerminalMainWindow* self;
		self = _data9_->self;
		_g_free0 (_data9_->text);
		_g_object_unref0 (self);
		g_slice_free (Block9Data, _data9_);
	}
}

static void
____lambda15_ (Block9Data* _data9_,
               GtkClipboard* clipboard,
               const gchar* uri)
{
	TerminalMainWindow* self;
	gchar* _tmp0_;
	self = _data9_->self;
	g_return_if_fail (clipboard != NULL);
	_tmp0_ = g_strdup (uri);
	_g_free0 (_data9_->text);
	_data9_->text = _tmp0_;
}

static void
_____lambda15__gtk_clipboard_text_received_func (GtkClipboard* clipboard,
                                                 const gchar* text,
                                                 gpointer self)
{
	____lambda15_ (self, clipboard, text);
	block9_data_unref (self);
}

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

static gchar*
terminal_main_window_get_current_selection_link_or_pwd (TerminalMainWindow* self)
{
	TerminalTerminalWidget* _tmp0_;
	gchar* link_uri = NULL;
	TerminalTerminalWidget* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_current_terminal;
	_vala_return_val_if_fail (_tmp0_ != NULL, "current_terminal != null", NULL);
	_tmp1_ = self->priv->_current_terminal;
	_tmp2_ = _tmp1_->link_uri;
	_tmp3_ = g_strdup (_tmp2_);
	link_uri = _tmp3_;
	_tmp4_ = link_uri;
	if (_tmp4_ == NULL) {
		Block9Data* _data9_;
		TerminalTerminalWidget* _tmp5_;
		const gchar* _tmp8_;
		const gchar* _tmp11_;
		TerminalTerminalWidget* _tmp12_;
		gchar* _tmp13_;
		gchar* _tmp14_;
		gchar* _tmp15_;
		gchar* _tmp16_;
		_data9_ = g_slice_new0 (Block9Data);
		_data9_->_ref_count_ = 1;
		_data9_->self = g_object_ref (self);
		_data9_->text = NULL;
		_tmp5_ = self->priv->_current_terminal;
		if (vte_terminal_get_has_selection ((VteTerminal*) _tmp5_)) {
			TerminalTerminalWidget* _tmp6_;
			GtkClipboard* _tmp7_;
			_tmp6_ = self->priv->_current_terminal;
			vte_terminal_copy_primary ((VteTerminal*) _tmp6_);
			_tmp7_ = self->priv->primary_selection;
			gtk_clipboard_request_text (_tmp7_, _____lambda15__gtk_clipboard_text_received_func, block9_data_ref (_data9_));
		}
		_tmp8_ = _data9_->text;
		if (_tmp8_ == NULL) {
			TerminalTerminalWidget* _tmp9_;
			gchar* _tmp10_;
			_tmp9_ = self->priv->_current_terminal;
			_tmp10_ = terminal_terminal_widget_get_shell_location (_tmp9_);
			_g_free0 (_data9_->text);
			_data9_->text = _tmp10_;
		}
		_tmp11_ = _data9_->text;
		_tmp12_ = self->priv->_current_terminal;
		_tmp13_ = terminal_terminal_widget_get_shell_location (_tmp12_);
		_tmp14_ = _tmp13_;
		_tmp15_ = terminal_utils_sanitize_path (_tmp11_, _tmp14_, TRUE);
		_tmp16_ = _tmp15_;
		_g_free0 (_tmp14_);
		result = _tmp16_;
		block9_data_unref (_data9_);
		_data9_ = NULL;
		_g_free0 (link_uri);
		return result;
	} else {
		const gchar* _tmp17_;
		_tmp17_ = link_uri;
		if (!string_contains (_tmp17_, "://")) {
			const gchar* _tmp18_;
			gchar* _tmp19_;
			_tmp18_ = link_uri;
			_tmp19_ = g_strconcat ("http://", _tmp18_, NULL);
			_g_free0 (link_uri);
			link_uri = _tmp19_;
		}
		result = link_uri;
		return result;
	}
}

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)
{
	const gchar* _tmp0_;
	TerminalTerminalView* _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	TerminalTerminalWidget* _tmp4_;
	TerminalTerminalWidget* _tmp5_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (action != NULL);
	_tmp0_ = g_variant_get_string (param, NULL);
	_tmp1_ = self->priv->_notebook;
	_tmp2_ = terminal_terminal_view_get_n_pages (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = terminal_main_window_new_tab (self, _tmp0_, "", TRUE, _tmp3_);
	_tmp5_ = _tmp4_;
	_g_object_unref0 (_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")) {
		TerminalTerminalWidget* _tmp2_;
		gchar* _tmp3_;
		gchar* _tmp4_;
		TerminalTerminalView* _tmp5_;
		gint _tmp6_;
		gint _tmp7_;
		TerminalTerminalWidget* _tmp8_;
		TerminalTerminalWidget* _tmp9_;
		_tmp2_ = self->priv->_current_terminal;
		_tmp3_ = terminal_terminal_widget_get_shell_location (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp5_ = self->priv->_notebook;
		_tmp6_ = terminal_terminal_view_get_n_pages (_tmp5_);
		_tmp7_ = _tmp6_;
		_tmp8_ = terminal_main_window_new_tab (self, _tmp4_, "", TRUE, _tmp7_);
		_tmp9_ = _tmp8_;
		_g_object_unref0 (_tmp9_);
		_g_free0 (_tmp4_);
	} else {
		const gchar* _tmp10_;
		TerminalTerminalView* _tmp11_;
		gint _tmp12_;
		gint _tmp13_;
		TerminalTerminalWidget* _tmp14_;
		TerminalTerminalWidget* _tmp15_;
		_tmp10_ = g_get_home_dir ();
		_tmp11_ = self->priv->_notebook;
		_tmp12_ = terminal_terminal_view_get_n_pages (_tmp11_);
		_tmp13_ = _tmp12_;
		_tmp14_ = terminal_main_window_new_tab (self, _tmp10_, "", TRUE, _tmp13_);
		_tmp15_ = _tmp14_;
		_g_object_unref0 (_tmp15_);
	}
}

static void
terminal_main_window_action_new_tab_at (TerminalMainWindow* self,
                                        GSimpleAction* action,
                                        GVariant* param)
{
	gchar* uri = NULL;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	TerminalTerminalView* _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	TerminalTerminalWidget* _tmp5_;
	TerminalTerminalWidget* _tmp6_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (action != NULL);
	_tmp0_ = g_variant_get_string (param, NULL);
	_tmp1_ = g_strdup (_tmp0_);
	uri = _tmp1_;
	_tmp2_ = self->priv->_notebook;
	_tmp3_ = terminal_terminal_view_get_n_pages (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = terminal_main_window_new_tab (self, uri, "", TRUE, _tmp4_);
	_tmp6_ = _tmp5_;
	_g_object_unref0 (_tmp6_);
	_g_free0 (uri);
}

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;
	HdyTabPage* target = NULL;
	TerminalTerminalView* _tmp0_;
	HdyTabPage* _tmp1_;
	HdyTabPage* _tmp2_;
	HdyTabPage* _tmp3_;
	HdyTabPage* _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) {
		HdyTabPage* _tmp5_;
		TerminalTerminalWidget* _tmp6_;
		TerminalTerminalWidget* _tmp7_;
		_tmp5_ = target;
		_tmp6_ = terminal_main_window_get_term_widget (self, _tmp5_);
		_tmp7_ = _g_object_ref0 (_tmp6_);
		_g_object_unref0 (term);
		term = _tmp7_;
	} else {
		TerminalTerminalView* _tmp8_;
		HdyTabView* _tmp9_;
		HdyTabView* _tmp10_;
		HdyTabPage* _tmp11_;
		HdyTabPage* _tmp12_;
		TerminalTerminalWidget* _tmp13_;
		TerminalTerminalWidget* _tmp14_;
		_tmp8_ = self->priv->_notebook;
		_tmp9_ = terminal_terminal_view_get_tab_view (_tmp8_);
		_tmp10_ = _tmp9_;
		_tmp11_ = hdy_tab_view_get_selected_page (_tmp10_);
		_tmp12_ = _tmp11_;
		_tmp13_ = terminal_main_window_get_term_widget (self, _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_;
	HdyTabPage* _tmp3_;
	HdyTabPage* _tmp4_;
	TerminalTerminalWidget* term = NULL;
	TerminalTerminalWidget* _tmp10_;
	gint _tmp11_ = 0;
	TerminalTerminalView* _tmp12_;
	HdyTabPage* _tmp13_;
	HdyTabPage* _tmp14_;
	gint pos = 0;
	TerminalTerminalWidget* _tmp24_;
	gchar* _tmp25_;
	gchar* _tmp26_;
	TerminalTerminalWidget* _tmp27_;
	TerminalTerminalWidget* _tmp28_;
	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_;
		HdyTabPage* _tmp6_;
		HdyTabPage* _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 (self, _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_;
		HdyTabView* _tmp16_;
		HdyTabView* _tmp17_;
		TerminalTerminalView* _tmp18_;
		HdyTabPage* _tmp19_;
		HdyTabPage* _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_ = hdy_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_ = term;
	_tmp25_ = terminal_terminal_widget_get_shell_location (_tmp24_);
	_tmp26_ = _tmp25_;
	_tmp27_ = terminal_main_window_new_tab (self, _tmp26_, "", TRUE, pos);
	_tmp28_ = _tmp27_;
	_g_object_unref0 (_tmp28_);
	_g_free0 (_tmp26_);
	_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_, HDY_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_, HDY_NAVIGATION_DIRECTION_BACK);
}

static void
terminal_main_window_action_move_tab_right (TerminalMainWindow* self)
{
	TerminalTerminalView* _tmp0_;
	HdyTabView* _tmp1_;
	HdyTabView* _tmp2_;
	TerminalTerminalView* _tmp3_;
	HdyTabPage* _tmp4_;
	HdyTabPage* _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_;
	hdy_tab_view_reorder_forward (_tmp2_, _tmp5_);
}

static void
terminal_main_window_action_move_tab_left (TerminalMainWindow* self)
{
	TerminalTerminalView* _tmp0_;
	HdyTabView* _tmp1_;
	HdyTabView* _tmp2_;
	TerminalTerminalView* _tmp3_;
	HdyTabPage* _tmp4_;
	HdyTabPage* _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_;
	hdy_tab_view_reorder_backward (_tmp2_, _tmp5_);
}

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

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

static void
terminal_main_window_action_search (TerminalMainWindow* self)
{
	TerminalTerminalWidget* _tmp0_;
	GSimpleAction* search_action = NULL;
	GSimpleActionGroup* _tmp1_;
	GAction* _tmp2_;
	GSimpleAction* _tmp3_;
	gboolean search_state = FALSE;
	GSimpleAction* _tmp4_;
	GVariant* _tmp5_;
	GVariant* _tmp6_;
	gboolean _tmp7_;
	GSimpleAction* _tmp8_;
	GVariant* _tmp9_;
	GtkToggleButton* _tmp10_;
	gboolean _tmp11_;
	gboolean _tmp12_;
	gchar** next_accels = NULL;
	gchar** _tmp39_;
	gint next_accels_length1;
	gint _next_accels_size_;
	GeeMultiMap* _tmp40_;
	GeeCollection* _tmp41_;
	GeeCollection* _tmp42_;
	gboolean _tmp43_;
	gboolean _tmp44_;
	gboolean _tmp45_;
	gchar** prev_accels = NULL;
	gchar** _tmp51_;
	gint prev_accels_length1;
	gint _prev_accels_size_;
	GeeMultiMap* _tmp52_;
	GeeCollection* _tmp53_;
	GeeCollection* _tmp54_;
	gboolean _tmp55_;
	gboolean _tmp56_;
	gboolean _tmp57_;
	TerminalApplication* _tmp63_;
	gchar** _tmp64_;
	gint _tmp64__length1;
	TerminalApplication* _tmp65_;
	gchar** _tmp66_;
	gint _tmp66__length1;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_current_terminal;
	_vala_return_if_fail (_tmp0_ != NULL, "current_terminal != null");
	_tmp1_ = self->priv->_actions;
	_tmp2_ = g_action_map_lookup_action ((GActionMap*) _tmp1_, TERMINAL_MAIN_WINDOW_ACTION_SEARCH);
	_tmp3_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, g_simple_action_get_type (), GSimpleAction));
	search_action = _tmp3_;
	_tmp4_ = search_action;
	_tmp5_ = g_action_get_state ((GAction*) _tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = g_variant_get_boolean (_tmp6_);
	_g_variant_unref0 (_tmp6_);
	search_state = _tmp7_;
	_tmp8_ = search_action;
	_tmp9_ = _variant_new3 (!search_state);
	g_simple_action_set_state (_tmp8_, _tmp9_);
	_g_variant_unref0 (_tmp9_);
	_tmp10_ = self->priv->search_button;
	_tmp11_ = gtk_toggle_button_get_active (_tmp10_);
	_tmp12_ = _tmp11_;
	if (_tmp12_) {
		GtkStack* _tmp13_;
		TerminalWidgetsSearchToolbar* _tmp14_;
		GeeMultiMap* _tmp15_;
		GeeMultiMap* _tmp16_;
		GeeMultiMap* _tmp17_;
		GeeMultiMap* _tmp18_;
		GtkToggleButton* _tmp19_;
		gchar* _tmp20_;
		gchar* _tmp21_;
		gchar** _tmp22_;
		gchar** _tmp23_;
		gint _tmp23__length1;
		gchar* _tmp24_;
		gchar* _tmp25_;
		TerminalWidgetsSearchToolbar* _tmp26_;
		_tmp13_ = self->priv->title_stack;
		_tmp14_ = self->priv->search_toolbar;
		gtk_stack_set_visible_child (_tmp13_, (GtkWidget*) _tmp14_);
		_tmp15_ = terminal_main_window_action_accelerators;
		gee_multi_map_set (_tmp15_, TERMINAL_MAIN_WINDOW_ACTION_SEARCH_NEXT, "<Control>g");
		_tmp16_ = terminal_main_window_action_accelerators;
		gee_multi_map_set (_tmp16_, TERMINAL_MAIN_WINDOW_ACTION_SEARCH_NEXT, "<Control>Down");
		_tmp17_ = terminal_main_window_action_accelerators;
		gee_multi_map_set (_tmp17_, TERMINAL_MAIN_WINDOW_ACTION_SEARCH_PREVIOUS, "<Control><Shift>g");
		_tmp18_ = terminal_main_window_action_accelerators;
		gee_multi_map_set (_tmp18_, TERMINAL_MAIN_WINDOW_ACTION_SEARCH_PREVIOUS, "<Control>Up");
		_tmp19_ = self->priv->search_button;
		_tmp20_ = g_strdup ("Escape");
		_tmp21_ = g_strdup ("<Ctrl><Shift>f");
		_tmp22_ = g_new0 (gchar*, 2 + 1);
		_tmp22_[0] = _tmp20_;
		_tmp22_[1] = _tmp21_;
		_tmp23_ = _tmp22_;
		_tmp23__length1 = 2;
		_tmp24_ = granite_markup_accel_tooltip (_tmp23_, (gint) 2, _ ("Hide find bar"));
		_tmp25_ = _tmp24_;
		gtk_widget_set_tooltip_markup ((GtkWidget*) _tmp19_, _tmp25_);
		_g_free0 (_tmp25_);
		_tmp23_ = (_vala_array_free (_tmp23_, _tmp23__length1, (GDestroyNotify) g_free), NULL);
		_tmp26_ = self->priv->search_toolbar;
		gtk_widget_grab_focus ((GtkWidget*) _tmp26_);
	} else {
		GtkStack* _tmp27_;
		GtkLabel* _tmp28_;
		GeeMultiMap* _tmp29_;
		GeeMultiMap* _tmp30_;
		GtkToggleButton* _tmp31_;
		gchar* _tmp32_;
		gchar** _tmp33_;
		gchar** _tmp34_;
		gint _tmp34__length1;
		gchar* _tmp35_;
		gchar* _tmp36_;
		TerminalWidgetsSearchToolbar* _tmp37_;
		TerminalTerminalWidget* _tmp38_;
		_tmp27_ = self->priv->title_stack;
		_tmp28_ = self->priv->title_label;
		gtk_stack_set_visible_child (_tmp27_, (GtkWidget*) _tmp28_);
		_tmp29_ = terminal_main_window_action_accelerators;
		gee_multi_map_remove_all (_tmp29_, TERMINAL_MAIN_WINDOW_ACTION_SEARCH_NEXT);
		_tmp30_ = terminal_main_window_action_accelerators;
		gee_multi_map_remove_all (_tmp30_, TERMINAL_MAIN_WINDOW_ACTION_SEARCH_PREVIOUS);
		_tmp31_ = self->priv->search_button;
		_tmp32_ = g_strdup ("<Ctrl><Shift>f");
		_tmp33_ = g_new0 (gchar*, 1 + 1);
		_tmp33_[0] = _tmp32_;
		_tmp34_ = _tmp33_;
		_tmp34__length1 = 1;
		_tmp35_ = granite_markup_accel_tooltip (_tmp34_, (gint) 1, _ ("Find…"));
		_tmp36_ = _tmp35_;
		gtk_widget_set_tooltip_markup ((GtkWidget*) _tmp31_, _tmp36_);
		_g_free0 (_tmp36_);
		_tmp34_ = (_vala_array_free (_tmp34_, _tmp34__length1, (GDestroyNotify) g_free), NULL);
		_tmp37_ = self->priv->search_toolbar;
		terminal_widgets_search_toolbar_clear (_tmp37_);
		_tmp38_ = self->priv->_current_terminal;
		gtk_widget_grab_focus ((GtkWidget*) _tmp38_);
	}
	_tmp39_ = g_new0 (gchar*, 0 + 1);
	next_accels = _tmp39_;
	next_accels_length1 = 0;
	_next_accels_size_ = next_accels_length1;
	_tmp40_ = terminal_main_window_action_accelerators;
	_tmp41_ = gee_multi_map_get (_tmp40_, TERMINAL_MAIN_WINDOW_ACTION_SEARCH_NEXT);
	_tmp42_ = _tmp41_;
	_tmp43_ = gee_collection_get_is_empty (_tmp42_);
	_tmp44_ = _tmp43_;
	_tmp45_ = !_tmp44_;
	_g_object_unref0 (_tmp42_);
	if (_tmp45_) {
		GeeMultiMap* _tmp46_;
		GeeCollection* _tmp47_;
		GeeCollection* _tmp48_;
		gint _tmp49_ = 0;
		gpointer* _tmp50_;
		_tmp46_ = terminal_main_window_action_accelerators;
		_tmp47_ = gee_multi_map_get (_tmp46_, TERMINAL_MAIN_WINDOW_ACTION_SEARCH_NEXT);
		_tmp48_ = _tmp47_;
		_tmp50_ = gee_collection_to_array (_tmp48_, &_tmp49_);
		next_accels = (_vala_array_free (next_accels, next_accels_length1, (GDestroyNotify) g_free), NULL);
		next_accels = _tmp50_;
		next_accels_length1 = _tmp49_;
		_next_accels_size_ = next_accels_length1;
		_g_object_unref0 (_tmp48_);
	}
	_tmp51_ = g_new0 (gchar*, 0 + 1);
	prev_accels = _tmp51_;
	prev_accels_length1 = 0;
	_prev_accels_size_ = prev_accels_length1;
	_tmp52_ = terminal_main_window_action_accelerators;
	_tmp53_ = gee_multi_map_get (_tmp52_, TERMINAL_MAIN_WINDOW_ACTION_SEARCH_NEXT);
	_tmp54_ = _tmp53_;
	_tmp55_ = gee_collection_get_is_empty (_tmp54_);
	_tmp56_ = _tmp55_;
	_tmp57_ = !_tmp56_;
	_g_object_unref0 (_tmp54_);
	if (_tmp57_) {
		GeeMultiMap* _tmp58_;
		GeeCollection* _tmp59_;
		GeeCollection* _tmp60_;
		gint _tmp61_ = 0;
		gpointer* _tmp62_;
		_tmp58_ = terminal_main_window_action_accelerators;
		_tmp59_ = gee_multi_map_get (_tmp58_, TERMINAL_MAIN_WINDOW_ACTION_SEARCH_PREVIOUS);
		_tmp60_ = _tmp59_;
		_tmp62_ = gee_collection_to_array (_tmp60_, &_tmp61_);
		prev_accels = (_vala_array_free (prev_accels, prev_accels_length1, (GDestroyNotify) g_free), NULL);
		prev_accels = _tmp62_;
		prev_accels_length1 = _tmp61_;
		_prev_accels_size_ = prev_accels_length1;
		_g_object_unref0 (_tmp60_);
	}
	_tmp63_ = self->priv->_app;
	_tmp64_ = next_accels;
	_tmp64__length1 = next_accels_length1;
	gtk_application_set_accels_for_action ((GtkApplication*) _tmp63_, TERMINAL_MAIN_WINDOW_ACTION_PREFIX TERMINAL_MAIN_WINDOW_ACTION_SEARCH_NEXT, _tmp64_);
	_tmp65_ = self->priv->_app;
	_tmp66_ = prev_accels;
	_tmp66__length1 = prev_accels_length1;
	gtk_application_set_accels_for_action ((GtkApplication*) _tmp65_, TERMINAL_MAIN_WINDOW_ACTION_PREFIX TERMINAL_MAIN_WINDOW_ACTION_SEARCH_PREVIOUS, _tmp66_);
	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);
	_g_object_unref0 (search_action);
}

static void
terminal_main_window_action_search_next (TerminalMainWindow* self)
{
	GtkToggleButton* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->search_button;
	_tmp1_ = gtk_toggle_button_get_active (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_) {
		TerminalWidgetsSearchToolbar* _tmp3_;
		_tmp3_ = self->priv->search_toolbar;
		terminal_widgets_search_toolbar_next_search (_tmp3_);
	}
}

static void
terminal_main_window_action_search_previous (TerminalMainWindow* self)
{
	GtkToggleButton* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->search_button;
	_tmp1_ = gtk_toggle_button_get_active (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_) {
		TerminalWidgetsSearchToolbar* _tmp3_;
		_tmp3_ = self->priv->search_toolbar;
		terminal_widgets_search_toolbar_previous_search (_tmp3_);
	}
}

static void
terminal_main_window_action_fullscreen (TerminalMainWindow* self)
{
	gboolean _tmp0_;
	gboolean _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = terminal_main_window_get_is_fullscreen (self);
	_tmp1_ = _tmp0_;
	terminal_main_window_set_is_fullscreen (self, !_tmp1_);
}

static TerminalTerminalWidget*
terminal_main_window_get_term_widget (TerminalMainWindow* self,
                                      HdyTabPage* tab)
{
	GtkScrolledWindow* tab_child = NULL;
	GtkWidget* _tmp0_;
	GtkWidget* _tmp1_;
	GtkScrolledWindow* _tmp2_;
	TerminalTerminalWidget* term = NULL;
	GtkScrolledWindow* _tmp3_;
	GtkWidget* _tmp4_;
	TerminalTerminalWidget* _tmp5_;
	TerminalTerminalWidget* result;
	g_return_val_if_fail (self != NULL, NULL);
	if (tab == NULL) {
		result = NULL;
		return result;
	}
	_tmp0_ = hdy_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_bin_get_child ((GtkBin*) _tmp3_);
	term = G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, TERMINAL_TYPE_TERMINAL_WIDGET, TerminalTerminalWidget);
	_tmp5_ = term;
	result = _tmp5_;
	_g_object_unref0 (tab_child);
	return result;
}

TerminalTerminalWidget*
terminal_main_window_get_terminal (TerminalMainWindow* self,
                                   const gchar* id)
{
	TerminalTerminalWidget* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (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_;
				HdyTabView* _tmp6_;
				HdyTabView* _tmp7_;
				HdyTabPage* _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_ = hdy_tab_view_get_nth_page (_tmp7_, i);
				_tmp9_ = terminal_main_window_get_term_widget (self, _tmp8_);
				term = _tmp9_;
				_tmp10_ = term;
				_tmp11_ = _tmp10_->terminal_id;
				if (g_strcmp0 (_tmp11_, id) == 0) {
					TerminalTerminalWidget* _tmp12_;
					_tmp12_ = term;
					result = _tmp12_;
					return result;
				}
			}
		}
	}
	result = NULL;
	return result;
}

void
terminal_main_window_set_active_terminal_tab (TerminalMainWindow* self,
                                              HdyTabPage* tab)
{
	TerminalTerminalView* _tmp0_;
	HdyTabView* _tmp1_;
	HdyTabView* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (tab != NULL);
	_tmp0_ = self->priv->_notebook;
	_tmp1_ = terminal_terminal_view_get_tab_view (_tmp0_);
	_tmp2_ = _tmp1_;
	hdy_tab_view_set_selected_page (_tmp2_, tab);
}

/** 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_;
			HdyTabView* _tmp7_;
			HdyTabView* _tmp8_;
			HdyTabPage* _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_ = hdy_tab_view_get_nth_page (_tmp8_, i);
			_tmp10_ = terminal_main_window_get_term_widget (self, _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_;
				TerminalTerminalWidget* _tmp16_;
				const gchar* _tmp17_;
				const gchar* _tmp18_;
				_tmp15_ = term;
				_tmp16_ = term;
				_tmp17_ = terminal_terminal_widget_get_program_string (_tmp16_);
				_tmp18_ = _tmp17_;
				terminal_terminal_widget_set_tab_label (_tmp15_, _tmp18_);
				_g_free0 (term_label);
				_g_free0 (term_path);
				_g_object_unref0 (term);
				continue;
			} else {
				TerminalTerminalWidget* _tmp19_;
				const gchar* _tmp20_;
				const gchar* _tmp21_;
				gchar* _tmp22_;
				const gchar* _tmp23_;
				gchar* _tmp24_;
				gboolean _tmp25_ = FALSE;
				const gchar* _tmp26_;
				_tmp19_ = term;
				_tmp20_ = terminal_terminal_widget_get_current_working_directory (_tmp19_);
				_tmp21_ = _tmp20_;
				_tmp22_ = g_strdup (_tmp21_);
				_g_free0 (term_path);
				term_path = _tmp22_;
				_tmp23_ = term_path;
				_tmp24_ = g_path_get_basename (_tmp23_);
				_g_free0 (term_label);
				term_label = _tmp24_;
				_tmp26_ = term_label;
				if (g_strcmp0 (_tmp26_, "") == 0) {
					_tmp25_ = TRUE;
				} else {
					const gchar* _tmp27_;
					_tmp27_ = term_label;
					_tmp25_ = g_strcmp0 (_tmp27_, "/") == 0;
				}
				if (_tmp25_) {
					TerminalTerminalWidget* _tmp28_;
					_tmp28_ = term;
					terminal_terminal_widget_set_tab_label (_tmp28_, TERMINAL_TERMINAL_WIDGET_DEFAULT_LABEL);
					_g_free0 (term_label);
					_g_free0 (term_path);
					_g_object_unref0 (term);
					continue;
				} else {
					TerminalTerminalWidget* _tmp29_;
					const gchar* _tmp30_;
					_tmp29_ = term;
					_tmp30_ = term_label;
					terminal_terminal_widget_set_tab_label (_tmp29_, _tmp30_);
				}
			}
			{
				gboolean _tmp31_ = FALSE;
				j = 0;
				_tmp31_ = TRUE;
				while (TRUE) {
					TerminalTerminalView* _tmp33_;
					gint _tmp34_;
					gint _tmp35_;
					TerminalTerminalWidget* term2 = NULL;
					TerminalTerminalView* _tmp36_;
					HdyTabView* _tmp37_;
					HdyTabView* _tmp38_;
					HdyTabPage* _tmp39_;
					TerminalTerminalWidget* _tmp40_;
					TerminalTerminalWidget* _tmp41_;
					gchar* term2_path = NULL;
					TerminalTerminalWidget* _tmp42_;
					const gchar* _tmp43_;
					const gchar* _tmp44_;
					gchar* _tmp45_;
					gchar* term2_name = NULL;
					const gchar* _tmp46_;
					gchar* _tmp47_;
					gboolean _tmp48_ = FALSE;
					gboolean _tmp49_ = FALSE;
					TerminalTerminalWidget* _tmp50_;
					const gchar* _tmp51_;
					TerminalTerminalWidget* _tmp52_;
					const gchar* _tmp53_;
					if (!_tmp31_) {
						gint _tmp32_;
						_tmp32_ = j;
						j = _tmp32_ + 1;
					}
					_tmp31_ = FALSE;
					_tmp33_ = self->priv->_notebook;
					_tmp34_ = terminal_terminal_view_get_n_pages (_tmp33_);
					_tmp35_ = _tmp34_;
					if (!(j < _tmp35_)) {
						break;
					}
					_tmp36_ = self->priv->_notebook;
					_tmp37_ = terminal_terminal_view_get_tab_view (_tmp36_);
					_tmp38_ = _tmp37_;
					_tmp39_ = hdy_tab_view_get_nth_page (_tmp38_, j);
					_tmp40_ = terminal_main_window_get_term_widget (self, _tmp39_);
					_tmp41_ = _g_object_ref0 (_tmp40_);
					term2 = _tmp41_;
					_tmp42_ = term2;
					_tmp43_ = terminal_terminal_widget_get_current_working_directory (_tmp42_);
					_tmp44_ = _tmp43_;
					_tmp45_ = g_strdup (_tmp44_);
					term2_path = _tmp45_;
					_tmp46_ = term2_path;
					_tmp47_ = g_path_get_basename (_tmp46_);
					term2_name = _tmp47_;
					_tmp50_ = term2;
					_tmp51_ = _tmp50_->terminal_id;
					_tmp52_ = term;
					_tmp53_ = _tmp52_->terminal_id;
					if (g_strcmp0 (_tmp51_, _tmp53_) != 0) {
						const gchar* _tmp54_;
						const gchar* _tmp55_;
						_tmp54_ = term2_name;
						_tmp55_ = term_label;
						_tmp49_ = g_strcmp0 (_tmp54_, _tmp55_) == 0;
					} else {
						_tmp49_ = FALSE;
					}
					if (_tmp49_) {
						const gchar* _tmp56_;
						const gchar* _tmp57_;
						_tmp56_ = term2_path;
						_tmp57_ = term_path;
						_tmp48_ = g_strcmp0 (_tmp56_, _tmp57_) != 0;
					} else {
						_tmp48_ = FALSE;
					}
					if (_tmp48_) {
						TerminalTerminalWidget* _tmp58_;
						const gchar* _tmp59_;
						const gchar* _tmp60_;
						gchar* _tmp61_;
						gchar* _tmp62_;
						TerminalTerminalWidget* _tmp63_;
						const gchar* _tmp64_;
						const gchar* _tmp65_;
						gchar* _tmp66_;
						gchar* _tmp67_;
						_tmp58_ = term2;
						_tmp59_ = term2_path;
						_tmp60_ = term_path;
						_tmp61_ = terminal_main_window_disambiguate_label (self, _tmp59_, _tmp60_);
						_tmp62_ = _tmp61_;
						terminal_terminal_widget_set_tab_label (_tmp58_, _tmp62_);
						_g_free0 (_tmp62_);
						_tmp63_ = term;
						_tmp64_ = term_path;
						_tmp65_ = term2_path;
						_tmp66_ = terminal_main_window_disambiguate_label (self, _tmp64_, _tmp65_);
						_tmp67_ = _tmp66_;
						terminal_terminal_widget_set_tab_label (_tmp63_, _tmp67_);
						_g_free0 (_tmp67_);
					}
					_g_free0 (term2_name);
					_g_free0 (term2_path);
					_g_object_unref0 (term2);
				}
			}
			_g_free0 (term_label);
			_g_free0 (term_path);
			_g_object_unref0 (term);
		}
	}
	return;
}

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

static void
terminal_main_window_on_terminal_program_changed (TerminalMainWindow* self,
                                                  TerminalTerminalWidget* src,
                                                  const gchar* cmdline)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (src != NULL);
	g_return_if_fail (cmdline != NULL);
	terminal_terminal_widget_set_program_string (src, cmdline);
	terminal_main_window_check_for_tabs_with_same_name (self);
}

static void
_vala_array_add10 (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_add11 (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
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_;
					HdyTabView* _tmp19_;
					HdyTabView* _tmp20_;
					HdyTabPage* _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_ = hdy_tab_view_get_nth_page (_tmp20_, i);
					_tmp22_ = terminal_main_window_get_term_widget (self, _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_add10 (&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_add11 (&zooms, &zooms_length1, &_zooms_size_, _tmp35_);
							}
						}
						_g_free0 (location);
					}
					_g_object_unref0 (term);
				}
			}
		}
		if (save_tabs) {
			TerminalTerminalView* _tmp37_;
			HdyTabPage* _tmp38_;
			HdyTabPage* _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_;
			HdyTabView* _tmp41_;
			HdyTabView* _tmp42_;
			TerminalTerminalView* _tmp43_;
			HdyTabPage* _tmp44_;
			HdyTabPage* _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 = hdy_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 (TerminalMainWindow* self,
                                         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 (self != NULL, NULL);
	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;
}

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

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

static gboolean
terminal_main_window_get_is_fullscreen (TerminalMainWindow* self)
{
	gboolean result;
	GtkButton* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->unfullscreen_button;
	_tmp1_ = gtk_widget_get_visible ((GtkWidget*) _tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

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

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

static void
terminal_main_window_set_focus_restored_tabs (TerminalMainWindow* self,
                                              gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = terminal_main_window_get_focus_restored_tabs (self);
	if (old_value != value) {
		self->priv->_focus_restored_tabs = value;
		g_object_notify_by_pspec ((GObject *) self, terminal_main_window_properties[TERMINAL_MAIN_WINDOW_FOCUS_RESTORED_TABS_PROPERTY]);
	}
}

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

GMenu*
terminal_main_window_get_context_menu_model (TerminalMainWindow* self)
{
	GMenu* result;
	GMenu* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_context_menu_model;
	result = _tmp0_;
	return result;
}

static void
terminal_main_window_set_context_menu_model (TerminalMainWindow* self,
                                             GMenu* value)
{
	GMenu* old_value;
	g_return_if_fail (self != NULL);
	old_value = terminal_main_window_get_context_menu_model (self);
	if (old_value != value) {
		GMenu* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_context_menu_model);
		self->priv->_context_menu_model = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, terminal_main_window_properties[TERMINAL_MAIN_WINDOW_CONTEXT_MENU_MODEL_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]);
	}
}

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_add12 (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 GVariant*
_variant_new4 (const gchar* value)
{
	return g_variant_ref_sink (g_variant_new_string (value));
}

static GVariant*
_variant_new5 (const gchar* value)
{
	return g_variant_ref_sink (g_variant_new_string (value));
}

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
___lambda30_ (TerminalMainWindow* self)
{
	gboolean result;
	self->priv->focus_timeout = (guint) 0;
	terminal_main_window_save_opened_terminals (self, TRUE, TRUE);
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
____lambda30__gsource_func (gpointer self)
{
	gboolean result;
	result = ___lambda30_ ((TerminalMainWindow*) self);
	return result;
}

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

static void
__terminal_main_window___lambda29__gtk_event_controller_key_focus_in (GtkEventControllerKey* _sender,
                                                                      gpointer self)
{
	_terminal_main_window___lambda29_ ((TerminalMainWindow*) self);
}

static void
_terminal_main_window_update_font_g_settings_changed (GSettings* _sender,
                                                      const gchar* key,
                                                      gpointer self)
{
	terminal_main_window_update_font ((TerminalMainWindow*) self);
}

static gboolean
_terminal_main_window_on_delete_event_gtk_widget_delete_event (GtkWidget* _sender,
                                                               GdkEventAny* event,
                                                               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_;
	GtkClipboard* _tmp25_;
	GtkClipboard* _tmp26_;
	GtkClipboard* _tmp27_;
	GtkClipboard* _tmp28_;
	GMenuItem* _tmp29_;
	GMenuItem* _tmp30_;
	GVariant* _tmp31_;
	GMenuItem* search_menuitem = NULL;
	GMenuItem* _tmp32_;
	GMenuItem* _tmp33_;
	GVariant* _tmp34_;
	GMenuItem* copy_menuitem = NULL;
	GMenuItem* _tmp35_;
	GMenuItem* _tmp36_;
	const gchar* _tmp37_;
	GVariant* _tmp38_;
	GVariant* _tmp39_;
	GMenuItem* copy_last_output_menuitem = NULL;
	GMenuItem* _tmp40_;
	GMenuItem* _tmp41_;
	const gchar* _tmp42_;
	GVariant* _tmp43_;
	GVariant* _tmp44_;
	GMenuItem* clear_screen_menuitem = NULL;
	GMenuItem* _tmp45_;
	GMenuItem* _tmp46_;
	const gchar* _tmp47_;
	GVariant* _tmp48_;
	GVariant* _tmp49_;
	GMenuItem* reset_menuitem = NULL;
	GMenuItem* _tmp50_;
	GMenuItem* _tmp51_;
	const gchar* _tmp52_;
	GVariant* _tmp53_;
	GVariant* _tmp54_;
	GMenuItem* paste_menuitem = NULL;
	GMenuItem* _tmp55_;
	GMenuItem* _tmp56_;
	const gchar* _tmp57_;
	GVariant* _tmp58_;
	GVariant* _tmp59_;
	GMenuItem* select_all_menuitem = NULL;
	GMenuItem* _tmp60_;
	GMenuItem* _tmp61_;
	const gchar* _tmp62_;
	GVariant* _tmp63_;
	GVariant* _tmp64_;
	GMenu* terminal_action_section = NULL;
	GMenu* _tmp65_;
	GMenu* _tmp66_;
	GMenuItem* _tmp67_;
	GMenu* _tmp68_;
	GMenuItem* _tmp69_;
	GMenu* _tmp70_;
	GMenuItem* _tmp71_;
	GMenu* _tmp72_;
	GMenuItem* _tmp73_;
	GMenu* terminal_clear_reset_section = NULL;
	GMenu* _tmp74_;
	GMenu* _tmp75_;
	GMenuItem* _tmp76_;
	GMenu* _tmp77_;
	GMenuItem* _tmp78_;
	GMenu* search_section = NULL;
	GMenu* _tmp79_;
	GMenu* _tmp80_;
	GMenuItem* _tmp81_;
	GMenu* _tmp82_;
	GMenu* _tmp83_;
	GMenu* _tmp84_;
	GMenuItem* _tmp85_;
	GMenu* _tmp86_;
	GMenu* _tmp87_;
	GMenu* _tmp88_;
	GMenu* _tmp89_;
	GMenu* _tmp90_;
	GMenu* _tmp91_;
	GtkEventControllerKey* _tmp92_ = NULL;
	GtkEventControllerKey* _tmp93_;
	GtkEventControllerKey* _tmp94_;
	GSettings* _tmp95_;
	GSettings* _tmp96_;
	gboolean _tmp97_;
	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_add12 (&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);
	_tmp25_ = gtk_clipboard_get (gdk_atom_intern ("CLIPBOARD", FALSE));
	_tmp26_ = _g_object_ref0 (_tmp25_);
	_g_object_unref0 (self->priv->clipboard);
	self->priv->clipboard = _tmp26_;
	_tmp27_ = gtk_clipboard_get (gdk_atom_intern ("PRIMARY", FALSE));
	_tmp28_ = _g_object_ref0 (_tmp27_);
	_g_object_unref0 (self->priv->primary_selection);
	self->priv->primary_selection = _tmp28_;
	_tmp29_ = g_menu_item_new ("", TERMINAL_MAIN_WINDOW_ACTION_PREFIX TERMINAL_MAIN_WINDOW_ACTION_OPEN_IN_BROWSER);
	_g_object_unref0 (self->priv->open_in_browser_menuitem);
	self->priv->open_in_browser_menuitem = _tmp29_;
	_tmp30_ = self->priv->open_in_browser_menuitem;
	_tmp31_ = _variant_new4 (TERMINAL_MAIN_WINDOW_ACTION_OPEN_IN_BROWSER_ACCEL);
	g_menu_item_set_attribute_value (_tmp30_, "accel", _tmp31_);
	_g_variant_unref0 (_tmp31_);
	_tmp32_ = g_menu_item_new (_ ("Show Search Bar"), TERMINAL_MAIN_WINDOW_ACTION_PREFIX TERMINAL_MAIN_WINDOW_ACTION_SEARCH);
	search_menuitem = _tmp32_;
	_tmp33_ = search_menuitem;
	_tmp34_ = _variant_new5 (TERMINAL_MAIN_WINDOW_ACTION_SEARCH_ACCEL);
	g_menu_item_set_attribute_value (_tmp33_, "accel", _tmp34_);
	_g_variant_unref0 (_tmp34_);
	_tmp35_ = g_menu_item_new (_ ("Copy"), TERMINAL_TERMINAL_WIDGET_ACTION_COPY);
	copy_menuitem = _tmp35_;
	_tmp36_ = copy_menuitem;
	_tmp37_ = TERMINAL_TERMINAL_WIDGET_ACCELS_COPY[0];
	_tmp38_ = g_variant_new ("s", _tmp37_, NULL);
	g_variant_ref_sink (_tmp38_);
	_tmp39_ = _tmp38_;
	g_menu_item_set_attribute_value (_tmp36_, "accel", _tmp39_);
	_g_variant_unref0 (_tmp39_);
	_tmp40_ = g_menu_item_new (_ ("Copy Last Output"), TERMINAL_TERMINAL_WIDGET_ACTION_COPY_OUTPUT);
	copy_last_output_menuitem = _tmp40_;
	_tmp41_ = copy_last_output_menuitem;
	_tmp42_ = TERMINAL_TERMINAL_WIDGET_ACCELS_COPY_OUTPUT[0];
	_tmp43_ = g_variant_new ("s", _tmp42_, NULL);
	g_variant_ref_sink (_tmp43_);
	_tmp44_ = _tmp43_;
	g_menu_item_set_attribute_value (_tmp41_, "accel", _tmp44_);
	_g_variant_unref0 (_tmp44_);
	_tmp45_ = g_menu_item_new (_ ("Clear Screen"), TERMINAL_TERMINAL_WIDGET_ACTION_CLEAR_SCREEN);
	clear_screen_menuitem = _tmp45_;
	_tmp46_ = clear_screen_menuitem;
	_tmp47_ = TERMINAL_TERMINAL_WIDGET_ACCELS_CLEAR_SCREEN[0];
	_tmp48_ = g_variant_new ("s", _tmp47_, NULL);
	g_variant_ref_sink (_tmp48_);
	_tmp49_ = _tmp48_;
	g_menu_item_set_attribute_value (_tmp46_, "accel", _tmp49_);
	_g_variant_unref0 (_tmp49_);
	_tmp50_ = g_menu_item_new (_ ("Reset"), TERMINAL_TERMINAL_WIDGET_ACTION_RESET);
	reset_menuitem = _tmp50_;
	_tmp51_ = reset_menuitem;
	_tmp52_ = TERMINAL_TERMINAL_WIDGET_ACCELS_RESET[0];
	_tmp53_ = g_variant_new ("s", _tmp52_, NULL);
	g_variant_ref_sink (_tmp53_);
	_tmp54_ = _tmp53_;
	g_menu_item_set_attribute_value (_tmp51_, "accel", _tmp54_);
	_g_variant_unref0 (_tmp54_);
	_tmp55_ = g_menu_item_new (_ ("Paste"), TERMINAL_TERMINAL_WIDGET_ACTION_PASTE);
	paste_menuitem = _tmp55_;
	_tmp56_ = paste_menuitem;
	_tmp57_ = TERMINAL_TERMINAL_WIDGET_ACCELS_PASTE[0];
	_tmp58_ = g_variant_new ("s", _tmp57_, NULL);
	g_variant_ref_sink (_tmp58_);
	_tmp59_ = _tmp58_;
	g_menu_item_set_attribute_value (_tmp56_, "accel", _tmp59_);
	_g_variant_unref0 (_tmp59_);
	_tmp60_ = g_menu_item_new (_ ("Select All"), TERMINAL_TERMINAL_WIDGET_ACTION_SELECT_ALL);
	select_all_menuitem = _tmp60_;
	_tmp61_ = select_all_menuitem;
	_tmp62_ = TERMINAL_TERMINAL_WIDGET_ACCELS_SELECT_ALL[0];
	_tmp63_ = g_variant_new ("s", _tmp62_, NULL);
	g_variant_ref_sink (_tmp63_);
	_tmp64_ = _tmp63_;
	g_menu_item_set_attribute_value (_tmp61_, "accel", _tmp64_);
	_g_variant_unref0 (_tmp64_);
	_tmp65_ = g_menu_new ();
	terminal_action_section = _tmp65_;
	_tmp66_ = terminal_action_section;
	_tmp67_ = copy_menuitem;
	g_menu_append_item (_tmp66_, _tmp67_);
	_tmp68_ = terminal_action_section;
	_tmp69_ = copy_last_output_menuitem;
	g_menu_append_item (_tmp68_, _tmp69_);
	_tmp70_ = terminal_action_section;
	_tmp71_ = paste_menuitem;
	g_menu_append_item (_tmp70_, _tmp71_);
	_tmp72_ = terminal_action_section;
	_tmp73_ = select_all_menuitem;
	g_menu_append_item (_tmp72_, _tmp73_);
	_tmp74_ = g_menu_new ();
	terminal_clear_reset_section = _tmp74_;
	_tmp75_ = terminal_clear_reset_section;
	_tmp76_ = clear_screen_menuitem;
	g_menu_append_item (_tmp75_, _tmp76_);
	_tmp77_ = terminal_clear_reset_section;
	_tmp78_ = reset_menuitem;
	g_menu_append_item (_tmp77_, _tmp78_);
	_tmp79_ = g_menu_new ();
	search_section = _tmp79_;
	_tmp80_ = search_section;
	_tmp81_ = search_menuitem;
	g_menu_append_item (_tmp80_, _tmp81_);
	_tmp82_ = g_menu_new ();
	_tmp83_ = _tmp82_;
	terminal_main_window_set_context_menu_model (self, _tmp83_);
	_g_object_unref0 (_tmp83_);
	_tmp84_ = self->priv->_context_menu_model;
	_tmp85_ = self->priv->open_in_browser_menuitem;
	g_menu_append_item (_tmp84_, _tmp85_);
	_tmp86_ = self->priv->_context_menu_model;
	_tmp87_ = terminal_action_section;
	g_menu_append_section (_tmp86_, NULL, (GMenuModel*) _tmp87_);
	_tmp88_ = self->priv->_context_menu_model;
	_tmp89_ = search_section;
	g_menu_append_section (_tmp88_, NULL, (GMenuModel*) _tmp89_);
	_tmp90_ = self->priv->_context_menu_model;
	_tmp91_ = terminal_clear_reset_section;
	g_menu_append_section (_tmp90_, NULL, (GMenuModel*) _tmp91_);
	terminal_main_window_setup_ui (self);
	_tmp92_ = (GtkEventControllerKey*) gtk_event_controller_key_new ((GtkWidget*) self);
	gtk_event_controller_set_propagation_phase ((GtkEventController*) _tmp92_, GTK_PHASE_TARGET);
	_g_object_unref0 (self->priv->key_controller);
	self->priv->key_controller = _tmp92_;
	_tmp93_ = self->priv->key_controller;
	g_signal_connect_object (_tmp93_, "key-pressed", (GCallback) _terminal_main_window_key_pressed_gtk_event_controller_key_key_pressed, self, 0);
	_tmp94_ = self->priv->key_controller;
	g_signal_connect_object (_tmp94_, "focus-in", (GCallback) __terminal_main_window___lambda29__gtk_event_controller_key_focus_in, self, 0);
	terminal_main_window_update_font (self);
	_tmp95_ = terminal_application_settings_sys;
	g_signal_connect_object (_tmp95_, "changed::monospace-font-name", (GCallback) _terminal_main_window_update_font_g_settings_changed, self, 0);
	_tmp96_ = terminal_application_settings;
	g_signal_connect_object (_tmp96_, "changed::font", (GCallback) _terminal_main_window_update_font_g_settings_changed, self, 0);
	gtk_widget_set_size_request ((GtkWidget*) self, TERMINAL_APPLICATION_MINIMUM_WIDTH, TERMINAL_APPLICATION_MINIMUM_HEIGHT);
	terminal_main_window_restore_saved_state (self);
	gtk_widget_show_all ((GtkWidget*) self);
	_tmp97_ = self->priv->_recreate_tabs;
	if (_tmp97_) {
		terminal_main_window_open_tabs (self);
	}
	g_signal_connect_object ((GtkWidget*) self, "delete-event", (GCallback) _terminal_main_window_on_delete_event_gtk_widget_delete_event, self, 0);
	_g_object_unref0 (search_section);
	_g_object_unref0 (terminal_clear_reset_section);
	_g_object_unref0 (terminal_action_section);
	_g_object_unref0 (select_all_menuitem);
	_g_object_unref0 (paste_menuitem);
	_g_object_unref0 (reset_menuitem);
	_g_object_unref0 (clear_screen_menuitem);
	_g_object_unref0 (copy_last_output_menuitem);
	_g_object_unref0 (copy_menuitem);
	_g_object_unref0 (search_menuitem);
	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_;
	GeeMultiMap* _tmp13_;
	terminal_main_window_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &TerminalMainWindow_private_offset);
	((GtkWidgetClass *) klass)->configure_event = (gboolean (*) (GtkWidget*, GdkEventConfigure*)) terminal_main_window_real_configure_event;
	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_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_FOCUS_RESTORED_TABS_PROPERTY, terminal_main_window_properties[TERMINAL_MAIN_WINDOW_FOCUS_RESTORED_TABS_PROPERTY] = g_param_spec_boolean ("focus-restored-tabs", "focus-restored-tabs", "focus-restored-tabs", TRUE, 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_RECREATE_TABS_PROPERTY, terminal_main_window_properties[TERMINAL_MAIN_WINDOW_RECREATE_TABS_PROPERTY] = g_param_spec_boolean ("recreate-tabs", "recreate-tabs", "recreate-tabs", TRUE, 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_CONTEXT_MENU_MODEL_PROPERTY, terminal_main_window_properties[TERMINAL_MAIN_WINDOW_CONTEXT_MENU_MODEL_PROPERTY] = g_param_spec_object ("context-menu-model", "context-menu-model", "context-menu-model", g_menu_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	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_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, TERMINAL_MAIN_WINDOW_ACTION_SEARCH_ACCEL);
	_tmp13_ = terminal_main_window_action_accelerators;
	gee_multi_map_set (_tmp13_, TERMINAL_MAIN_WINDOW_ACTION_OPEN_IN_BROWSER, TERMINAL_MAIN_WINDOW_ACTION_OPEN_IN_BROWSER_ACCEL);
}

static void
terminal_main_window_instance_init (TerminalMainWindow * self,
                                    gpointer klass)
{
	self->priv = terminal_main_window_get_instance_private (self);
	self->priv->timer_window_state_change = (guint) 0;
	self->priv->focus_timeout = (guint) 0;
	self->priv->_focus_restored_tabs = TRUE;
	self->priv->_recreate_tabs = TRUE;
	self->priv->_current_terminal = NULL;
}

static void
terminal_main_window_finalize (GObject * obj)
{
	TerminalMainWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TERMINAL_TYPE_MAIN_WINDOW, TerminalMainWindow);
	__vala_PangoFontDescription_free0 (self->priv->term_font);
	_g_object_unref0 (self->priv->header);
	_g_object_unref0 (self->priv->_notebook);
	_g_object_unref0 (self->priv->clipboard);
	_g_object_unref0 (self->priv->primary_selection);
	_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->zoom_overlay);
	_g_object_unref0 (self->priv->color_preferences_dialog);
	_g_object_unref0 (self->priv->open_in_browser_menuitem);
	_g_object_unref0 (self->priv->key_controller);
	_g_object_unref0 (self->priv->_context_menu_model);
	_g_object_unref0 (self->priv->_app);
	_g_object_unref0 (self->priv->_actions);
	_g_object_unref0 (self->priv->_current_terminal);
	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 (hdy_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_NOTEBOOK_PROPERTY:
		g_value_set_object (value, terminal_main_window_get_notebook (self));
		break;
		case TERMINAL_MAIN_WINDOW_FOCUS_RESTORED_TABS_PROPERTY:
		g_value_set_boolean (value, terminal_main_window_get_focus_restored_tabs (self));
		break;
		case TERMINAL_MAIN_WINDOW_RECREATE_TABS_PROPERTY:
		g_value_set_boolean (value, terminal_main_window_get_recreate_tabs (self));
		break;
		case TERMINAL_MAIN_WINDOW_CONTEXT_MENU_MODEL_PROPERTY:
		g_value_set_object (value, terminal_main_window_get_context_menu_model (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_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_NOTEBOOK_PROPERTY:
		terminal_main_window_set_notebook (self, g_value_get_object (value));
		break;
		case TERMINAL_MAIN_WINDOW_FOCUS_RESTORED_TABS_PROPERTY:
		terminal_main_window_set_focus_restored_tabs (self, g_value_get_boolean (value));
		break;
		case TERMINAL_MAIN_WINDOW_RECREATE_TABS_PROPERTY:
		terminal_main_window_set_recreate_tabs (self, g_value_get_boolean (value));
		break;
		case TERMINAL_MAIN_WINDOW_CONTEXT_MENU_MODEL_PROPERTY:
		terminal_main_window_set_context_menu_model (self, g_value_get_object (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_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;
}

