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

/* topbar.vala
 *
 * Copyright (C) Red Hat, Inc
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Author: Felipe Borges <felipeborges@gnome.org>
 *
 */

#include <gtk/gtk.h>
#include <glib-object.h>
#include <handy.h>
#include <gio/gio.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <gdk/gdk.h>
#include <glib/gi18n-lib.h>

#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 CONNECTIONS_TYPE_TOPBAR (connections_topbar_get_type ())
#define CONNECTIONS_TOPBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONNECTIONS_TYPE_TOPBAR, ConnectionsTopbar))
#define CONNECTIONS_TOPBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONNECTIONS_TYPE_TOPBAR, ConnectionsTopbarClass))
#define CONNECTIONS_IS_TOPBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONNECTIONS_TYPE_TOPBAR))
#define CONNECTIONS_IS_TOPBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONNECTIONS_TYPE_TOPBAR))
#define CONNECTIONS_TOPBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONNECTIONS_TYPE_TOPBAR, ConnectionsTopbarClass))

typedef struct _ConnectionsTopbar ConnectionsTopbar;
typedef struct _ConnectionsTopbarClass ConnectionsTopbarClass;
typedef struct _ConnectionsTopbarPrivate ConnectionsTopbarPrivate;

#define CONNECTIONS_TYPE_ASSISTANT (connections_assistant_get_type ())
#define CONNECTIONS_ASSISTANT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONNECTIONS_TYPE_ASSISTANT, ConnectionsAssistant))
#define CONNECTIONS_ASSISTANT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONNECTIONS_TYPE_ASSISTANT, ConnectionsAssistantClass))
#define CONNECTIONS_IS_ASSISTANT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONNECTIONS_TYPE_ASSISTANT))
#define CONNECTIONS_IS_ASSISTANT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONNECTIONS_TYPE_ASSISTANT))
#define CONNECTIONS_ASSISTANT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONNECTIONS_TYPE_ASSISTANT, ConnectionsAssistantClass))

typedef struct _ConnectionsAssistant ConnectionsAssistant;
typedef struct _ConnectionsAssistantClass ConnectionsAssistantClass;

#define CONNECTIONS_TYPE_CONNECTION (connections_connection_get_type ())
#define CONNECTIONS_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONNECTIONS_TYPE_CONNECTION, ConnectionsConnection))
#define CONNECTIONS_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONNECTIONS_TYPE_CONNECTION, ConnectionsConnectionClass))
#define CONNECTIONS_IS_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONNECTIONS_TYPE_CONNECTION))
#define CONNECTIONS_IS_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONNECTIONS_TYPE_CONNECTION))
#define CONNECTIONS_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONNECTIONS_TYPE_CONNECTION, ConnectionsConnectionClass))

typedef struct _ConnectionsConnection ConnectionsConnection;
typedef struct _ConnectionsConnectionClass ConnectionsConnectionClass;
enum  {
	CONNECTIONS_TOPBAR_0_PROPERTY,
	CONNECTIONS_TOPBAR_NUM_PROPERTIES
};
static GParamSpec* connections_topbar_properties[CONNECTIONS_TOPBAR_NUM_PROPERTIES];

#define CONNECTIONS_TYPE_APPLICATION (connections_application_get_type ())
#define CONNECTIONS_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONNECTIONS_TYPE_APPLICATION, ConnectionsApplication))
#define CONNECTIONS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONNECTIONS_TYPE_APPLICATION, ConnectionsApplicationClass))
#define CONNECTIONS_IS_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONNECTIONS_TYPE_APPLICATION))
#define CONNECTIONS_IS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONNECTIONS_TYPE_APPLICATION))
#define CONNECTIONS_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONNECTIONS_TYPE_APPLICATION, ConnectionsApplicationClass))

typedef struct _ConnectionsApplication ConnectionsApplication;
typedef struct _ConnectionsApplicationClass ConnectionsApplicationClass;

#define CONNECTIONS_TYPE_WINDOW (connections_window_get_type ())
#define CONNECTIONS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONNECTIONS_TYPE_WINDOW, ConnectionsWindow))
#define CONNECTIONS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONNECTIONS_TYPE_WINDOW, ConnectionsWindowClass))
#define CONNECTIONS_IS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONNECTIONS_TYPE_WINDOW))
#define CONNECTIONS_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONNECTIONS_TYPE_WINDOW))
#define CONNECTIONS_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONNECTIONS_TYPE_WINDOW, ConnectionsWindowClass))

typedef struct _ConnectionsWindow ConnectionsWindow;
typedef struct _ConnectionsWindowClass ConnectionsWindowClass;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _ConnectionsTopbar {
	GtkStack parent_instance;
	ConnectionsTopbarPrivate * priv;
	GtkButton* search_button;
	ConnectionsAssistant* assistant;
};

struct _ConnectionsTopbarClass {
	GtkStackClass parent_class;
};

struct _ConnectionsTopbarPrivate {
	HdyHeaderBar* collection_toolbar;
	GtkHeaderBar* display_toolbar;
	ConnectionsConnection* connection;
};

static gint ConnectionsTopbar_private_offset;
static gpointer connections_topbar_parent_class = NULL;
VALA_EXTERN ConnectionsApplication* connections_application_application;

VALA_EXTERN GType connections_topbar_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ConnectionsTopbar, g_object_unref)
VALA_EXTERN GType connections_assistant_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ConnectionsAssistant, g_object_unref)
VALA_EXTERN GType connections_connection_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ConnectionsConnection, g_object_unref)
static void connections_topbar_take_screenshot_activated (ConnectionsTopbar* self);
static void _connections_topbar_take_screenshot_activated_gsimple_action_activate_callback (GSimpleAction* action,
                                                                                     GVariant* parameter,
                                                                                     gpointer self);
static void connections_topbar_fullscreen_activated (ConnectionsTopbar* self);
static void _connections_topbar_fullscreen_activated_gsimple_action_activate_callback (GSimpleAction* action,
                                                                                GVariant* parameter,
                                                                                gpointer self);
static void connections_topbar_properties_activated (ConnectionsTopbar* self);
static void _connections_topbar_properties_activated_gsimple_action_activate_callback (GSimpleAction* action,
                                                                                GVariant* parameter,
                                                                                gpointer self);
static void connections_topbar_ctrl_alt_backspace_activated (ConnectionsTopbar* self);
static void _connections_topbar_ctrl_alt_backspace_activated_gsimple_action_activate_callback (GSimpleAction* action,
                                                                                        GVariant* parameter,
                                                                                        gpointer self);
static void connections_topbar_ctrl_alt_del_activated (ConnectionsTopbar* self);
static void _connections_topbar_ctrl_alt_del_activated_gsimple_action_activate_callback (GSimpleAction* action,
                                                                                  GVariant* parameter,
                                                                                  gpointer self);
static void connections_topbar_ctrl_alt_fn_activated (ConnectionsTopbar* self,
                                               GSimpleAction* action);
static void _connections_topbar_ctrl_alt_fn_activated_gsimple_action_activate_callback (GSimpleAction* action,
                                                                                 GVariant* parameter,
                                                                                 gpointer self);
VALA_EXTERN GType connections_application_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ConnectionsApplication, g_object_unref)
VALA_EXTERN GType connections_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ConnectionsWindow, g_object_unref)
VALA_EXTERN ConnectionsWindow* connections_application_get_main_window (ConnectionsApplication* self);
VALA_EXTERN void connections_window_show_preferences_window (ConnectionsWindow* self,
                                                 ConnectionsConnection* connection);
VALA_EXTERN void connections_connection_take_screenshot (ConnectionsConnection* self,
                                             GAsyncReadyCallback _callback_,
                                             gpointer _user_data_);
VALA_EXTERN void connections_connection_take_screenshot_finish (ConnectionsConnection* self,
                                                    GAsyncResult* _res_);
VALA_EXTERN gboolean connections_window_get_fullscreened (ConnectionsWindow* self);
VALA_EXTERN void connections_window_set_fullscreened (ConnectionsWindow* self,
                                          gboolean value);
static void connections_topbar_back_button_clicked (ConnectionsTopbar* self);
VALA_EXTERN void connections_window_show_collection_view (ConnectionsWindow* self);
static void _connections_topbar_back_button_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                 gpointer self);
VALA_EXTERN void connections_topbar_disconnect_button_clicked (ConnectionsTopbar* self);
VALA_EXTERN void connections_connection_disconnect_it (ConnectionsConnection* self);
static void _connections_topbar_disconnect_button_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                       gpointer self);
VALA_EXTERN void connections_topbar_show_collection_view (ConnectionsTopbar* self);
VALA_EXTERN void connections_topbar_show_display_view (ConnectionsTopbar* self,
                                           ConnectionsConnection* connection);
VALA_EXTERN gchar* connections_connection_get_visible_name (ConnectionsConnection* self);
VALA_EXTERN void connections_topbar_set_title (ConnectionsTopbar* self,
                                   const gchar* title);
static void connections_topbar_send_keys (ConnectionsTopbar* self,
                                   guint* keyvals,
                                   gint keyvals_length1);
VALA_EXTERN void connections_connection_send_keys (ConnectionsConnection* self,
                                       guint* keys,
                                       gint keys_length1);
VALA_EXTERN ConnectionsTopbar* connections_topbar_new (void);
VALA_EXTERN ConnectionsTopbar* connections_topbar_construct (GType object_type);
static GObject * connections_topbar_constructor (GType type,
                                          guint n_construct_properties,
                                          GObjectConstructParam * construct_properties);
static void connections_topbar_finalize (GObject * obj);
static GType connections_topbar_get_type_once (void);

static const GActionEntry CONNECTIONS_TOPBAR_action_entries[3] = {{"take_screenshot", _connections_topbar_take_screenshot_activated_gsimple_action_activate_callback}, {"fullscreen", _connections_topbar_fullscreen_activated_gsimple_action_activate_callback}, {"properties", _connections_topbar_properties_activated_gsimple_action_activate_callback}};
static const GActionEntry CONNECTIONS_TOPBAR_key_input_action_entries[6] = {{"ctrl+alt+backspace", _connections_topbar_ctrl_alt_backspace_activated_gsimple_action_activate_callback}, {"ctrl+alt+del", _connections_topbar_ctrl_alt_del_activated_gsimple_action_activate_callback}, {"ctrl+alt+f1", _connections_topbar_ctrl_alt_fn_activated_gsimple_action_activate_callback}, {"ctrl+alt+f2", _connections_topbar_ctrl_alt_fn_activated_gsimple_action_activate_callback}, {"ctrl+alt+f3", _connections_topbar_ctrl_alt_fn_activated_gsimple_action_activate_callback}, {"ctrl+alt+f7", _connections_topbar_ctrl_alt_fn_activated_gsimple_action_activate_callback}};

static inline gpointer
connections_topbar_get_instance_private (ConnectionsTopbar* self)
{
	return G_STRUCT_MEMBER_P (self, ConnectionsTopbar_private_offset);
}

static void
_connections_topbar_take_screenshot_activated_gsimple_action_activate_callback (GSimpleAction* action,
                                                                                GVariant* parameter,
                                                                                gpointer self)
{
	connections_topbar_take_screenshot_activated ((ConnectionsTopbar*) self);
}

static void
_connections_topbar_fullscreen_activated_gsimple_action_activate_callback (GSimpleAction* action,
                                                                           GVariant* parameter,
                                                                           gpointer self)
{
	connections_topbar_fullscreen_activated ((ConnectionsTopbar*) self);
}

static void
_connections_topbar_properties_activated_gsimple_action_activate_callback (GSimpleAction* action,
                                                                           GVariant* parameter,
                                                                           gpointer self)
{
	connections_topbar_properties_activated ((ConnectionsTopbar*) self);
}

static void
_connections_topbar_ctrl_alt_backspace_activated_gsimple_action_activate_callback (GSimpleAction* action,
                                                                                   GVariant* parameter,
                                                                                   gpointer self)
{
	connections_topbar_ctrl_alt_backspace_activated ((ConnectionsTopbar*) self);
}

static void
_connections_topbar_ctrl_alt_del_activated_gsimple_action_activate_callback (GSimpleAction* action,
                                                                             GVariant* parameter,
                                                                             gpointer self)
{
	connections_topbar_ctrl_alt_del_activated ((ConnectionsTopbar*) self);
}

static void
_connections_topbar_ctrl_alt_fn_activated_gsimple_action_activate_callback (GSimpleAction* action,
                                                                            GVariant* parameter,
                                                                            gpointer self)
{
	connections_topbar_ctrl_alt_fn_activated ((ConnectionsTopbar*) self, action);
}

static void
connections_topbar_properties_activated (ConnectionsTopbar* self)
{
	ConnectionsApplication* _tmp0_;
	ConnectionsWindow* _tmp1_;
	ConnectionsWindow* _tmp2_;
	ConnectionsConnection* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = connections_application_application;
	_tmp1_ = connections_application_get_main_window (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = self->priv->connection;
	connections_window_show_preferences_window (_tmp2_, _tmp3_);
}

static void
connections_topbar_take_screenshot_activated (ConnectionsTopbar* self)
{
	ConnectionsConnection* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->connection;
	if (_tmp0_ != NULL) {
		ConnectionsConnection* _tmp1_;
		_tmp1_ = self->priv->connection;
		connections_connection_take_screenshot (_tmp1_, NULL, NULL);
	}
}

static void
connections_topbar_fullscreen_activated (ConnectionsTopbar* self)
{
	ConnectionsApplication* _tmp0_;
	ConnectionsWindow* _tmp1_;
	ConnectionsWindow* _tmp2_;
	ConnectionsApplication* _tmp3_;
	ConnectionsWindow* _tmp4_;
	ConnectionsWindow* _tmp5_;
	gboolean _tmp6_;
	gboolean _tmp7_;
	g_return_if_fail (self != NULL);
	_tmp0_ = connections_application_application;
	_tmp1_ = connections_application_get_main_window (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = connections_application_application;
	_tmp4_ = connections_application_get_main_window (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = connections_window_get_fullscreened (_tmp5_);
	_tmp7_ = _tmp6_;
	connections_window_set_fullscreened (_tmp2_, !_tmp7_);
}

static void
connections_topbar_back_button_clicked (ConnectionsTopbar* self)
{
	ConnectionsApplication* _tmp0_;
	ConnectionsWindow* _tmp1_;
	ConnectionsWindow* _tmp2_;
	HdyHeaderBar* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = connections_application_application;
	_tmp1_ = connections_application_get_main_window (_tmp0_);
	_tmp2_ = _tmp1_;
	connections_window_show_collection_view (_tmp2_);
	_tmp3_ = self->priv->collection_toolbar;
	gtk_stack_set_visible_child ((GtkStack*) self, (GtkWidget*) _tmp3_);
}

static void
_connections_topbar_back_button_clicked_gtk_button_clicked (GtkButton* _sender,
                                                            gpointer self)
{
	connections_topbar_back_button_clicked ((ConnectionsTopbar*) self);
}

void
connections_topbar_disconnect_button_clicked (ConnectionsTopbar* self)
{
	ConnectionsConnection* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->connection;
	connections_connection_disconnect_it (_tmp0_);
	connections_topbar_back_button_clicked (self);
}

static void
_connections_topbar_disconnect_button_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                  gpointer self)
{
	connections_topbar_disconnect_button_clicked ((ConnectionsTopbar*) self);
}

void
connections_topbar_show_collection_view (ConnectionsTopbar* self)
{
	HdyHeaderBar* _tmp0_;
	g_return_if_fail (self != NULL);
	self->priv->connection = NULL;
	_tmp0_ = self->priv->collection_toolbar;
	gtk_stack_set_visible_child ((GtkStack*) self, (GtkWidget*) _tmp0_);
}

void
connections_topbar_show_display_view (ConnectionsTopbar* self,
                                      ConnectionsConnection* connection)
{
	GtkHeaderBar* _tmp0_;
	GtkHeaderBar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (connection != NULL);
	self->priv->connection = connection;
	_tmp0_ = self->priv->display_toolbar;
	gtk_stack_set_visible_child ((GtkStack*) self, (GtkWidget*) _tmp0_);
	_tmp1_ = self->priv->display_toolbar;
	_tmp2_ = connections_connection_get_visible_name (connection);
	_tmp3_ = _tmp2_;
	gtk_header_bar_set_title (_tmp1_, _tmp3_);
	_g_free0 (_tmp3_);
}

void
connections_topbar_set_title (ConnectionsTopbar* self,
                              const gchar* title)
{
	HdyHeaderBar* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (title != NULL);
	_tmp0_ = self->priv->collection_toolbar;
	hdy_header_bar_set_title (_tmp0_, title);
}

static void
connections_topbar_ctrl_alt_backspace_activated (ConnectionsTopbar* self)
{
	guint* keyvals = NULL;
	guint* _tmp0_;
	gint keyvals_length1;
	gint _keyvals_size_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_new0 (guint, 3);
	_tmp0_[0] = GDK_KEY_Control_L;
	_tmp0_[1] = GDK_KEY_Alt_L;
	_tmp0_[2] = GDK_KEY_BackSpace;
	keyvals = _tmp0_;
	keyvals_length1 = 3;
	_keyvals_size_ = keyvals_length1;
	connections_topbar_send_keys (self, keyvals, (gint) keyvals_length1);
	keyvals = (g_free (keyvals), NULL);
}

static void
connections_topbar_ctrl_alt_del_activated (ConnectionsTopbar* self)
{
	guint* keyvals = NULL;
	guint* _tmp0_;
	gint keyvals_length1;
	gint _keyvals_size_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_new0 (guint, 3);
	_tmp0_[0] = GDK_KEY_Control_L;
	_tmp0_[1] = GDK_KEY_Alt_L;
	_tmp0_[2] = GDK_KEY_Delete;
	keyvals = _tmp0_;
	keyvals_length1 = 3;
	_keyvals_size_ = keyvals_length1;
	connections_topbar_send_keys (self, keyvals, (gint) keyvals_length1);
	keyvals = (g_free (keyvals), NULL);
}

static gchar
string_get (const gchar* self,
            glong index)
{
	gchar _tmp0_;
	gchar result;
	g_return_val_if_fail (self != NULL, '\0');
	_tmp0_ = ((gchar*) self)[index];
	result = _tmp0_;
	return result;
}

static void
connections_topbar_ctrl_alt_fn_activated (ConnectionsTopbar* self,
                                          GSimpleAction* action)
{
	guint* keyvals = NULL;
	guint* _tmp0_;
	gint keyvals_length1;
	gint _keyvals_size_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	guint* _tmp29_;
	gint _tmp29__length1;
	g_return_if_fail (self != NULL);
	g_return_if_fail (action != NULL);
	_tmp0_ = g_new0 (guint, 3);
	_tmp0_[0] = GDK_KEY_Control_L;
	_tmp0_[1] = GDK_KEY_Alt_L;
	_tmp0_[2] = (guint) 0;
	keyvals = _tmp0_;
	keyvals_length1 = 3;
	_keyvals_size_ = keyvals_length1;
	_tmp1_ = g_action_get_name ((GAction*) action);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_action_get_name ((GAction*) action);
	_tmp4_ = _tmp3_;
	_tmp5_ = strlen (_tmp4_);
	_tmp6_ = _tmp5_;
	if (string_get (_tmp2_, (glong) (_tmp6_ - 1)) == '1') {
		guint* _tmp7_;
		gint _tmp7__length1;
		_tmp7_ = keyvals;
		_tmp7__length1 = keyvals_length1;
		_tmp7_[2] = GDK_KEY_F1;
	} else {
		const gchar* _tmp8_;
		const gchar* _tmp9_;
		const gchar* _tmp10_;
		const gchar* _tmp11_;
		gint _tmp12_;
		gint _tmp13_;
		_tmp8_ = g_action_get_name ((GAction*) action);
		_tmp9_ = _tmp8_;
		_tmp10_ = g_action_get_name ((GAction*) action);
		_tmp11_ = _tmp10_;
		_tmp12_ = strlen (_tmp11_);
		_tmp13_ = _tmp12_;
		if (string_get (_tmp9_, (glong) (_tmp13_ - 1)) == '2') {
			guint* _tmp14_;
			gint _tmp14__length1;
			_tmp14_ = keyvals;
			_tmp14__length1 = keyvals_length1;
			_tmp14_[2] = GDK_KEY_F2;
		} else {
			const gchar* _tmp15_;
			const gchar* _tmp16_;
			const gchar* _tmp17_;
			const gchar* _tmp18_;
			gint _tmp19_;
			gint _tmp20_;
			_tmp15_ = g_action_get_name ((GAction*) action);
			_tmp16_ = _tmp15_;
			_tmp17_ = g_action_get_name ((GAction*) action);
			_tmp18_ = _tmp17_;
			_tmp19_ = strlen (_tmp18_);
			_tmp20_ = _tmp19_;
			if (string_get (_tmp16_, (glong) (_tmp20_ - 1)) == '3') {
				guint* _tmp21_;
				gint _tmp21__length1;
				_tmp21_ = keyvals;
				_tmp21__length1 = keyvals_length1;
				_tmp21_[3] = GDK_KEY_F3;
			} else {
				const gchar* _tmp22_;
				const gchar* _tmp23_;
				const gchar* _tmp24_;
				const gchar* _tmp25_;
				gint _tmp26_;
				gint _tmp27_;
				_tmp22_ = g_action_get_name ((GAction*) action);
				_tmp23_ = _tmp22_;
				_tmp24_ = g_action_get_name ((GAction*) action);
				_tmp25_ = _tmp24_;
				_tmp26_ = strlen (_tmp25_);
				_tmp27_ = _tmp26_;
				if (string_get (_tmp23_, (glong) (_tmp27_ - 1)) == '7') {
					guint* _tmp28_;
					gint _tmp28__length1;
					_tmp28_ = keyvals;
					_tmp28__length1 = keyvals_length1;
					_tmp28_[2] = GDK_KEY_F7;
				} else {
					g_warn_if_reached ();
					keyvals = (g_free (keyvals), NULL);
					return;
				}
			}
		}
	}
	_tmp29_ = keyvals;
	_tmp29__length1 = keyvals_length1;
	connections_topbar_send_keys (self, _tmp29_, (gint) _tmp29__length1);
	keyvals = (g_free (keyvals), NULL);
}

static void
connections_topbar_send_keys (ConnectionsTopbar* self,
                              guint* keyvals,
                              gint keyvals_length1)
{
	ConnectionsConnection* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->connection;
	connections_connection_send_keys (_tmp0_, keyvals, (gint) keyvals_length1);
}

ConnectionsTopbar*
connections_topbar_construct (GType object_type)
{
	ConnectionsTopbar * self = NULL;
	self = (ConnectionsTopbar*) g_object_new (object_type, NULL);
	return self;
}

ConnectionsTopbar*
connections_topbar_new (void)
{
	return connections_topbar_construct (CONNECTIONS_TYPE_TOPBAR);
}

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

static GObject *
connections_topbar_constructor (GType type,
                                guint n_construct_properties,
                                GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	ConnectionsTopbar * self;
	GSimpleActionGroup* action_group = NULL;
	GSimpleActionGroup* _tmp0_;
	GSimpleActionGroup* _tmp1_;
	GSimpleActionGroup* _tmp2_;
	GMenu* menu = NULL;
	GMenu* _tmp3_;
	GMenu* section = NULL;
	GMenu* _tmp4_;
	GMenu* _tmp5_;
	GSimpleAction* action = NULL;
	GSimpleActionGroup* _tmp6_;
	GAction* _tmp7_;
	GSimpleAction* _tmp8_;
	GSimpleAction* _tmp9_;
	GMenu* _tmp10_;
	GSimpleActionGroup* _tmp11_;
	GAction* _tmp12_;
	GSimpleAction* _tmp13_;
	GSimpleAction* _tmp14_;
	GMenu* _tmp15_;
	GSimpleActionGroup* _tmp16_;
	GAction* _tmp17_;
	GSimpleAction* _tmp18_;
	GSimpleAction* _tmp19_;
	GSimpleActionGroup* key_input_action_group = NULL;
	GSimpleActionGroup* _tmp20_;
	GSimpleActionGroup* _tmp21_;
	GSimpleActionGroup* _tmp22_;
	parent_class = G_OBJECT_CLASS (connections_topbar_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CONNECTIONS_TYPE_TOPBAR, ConnectionsTopbar);
	_tmp0_ = g_simple_action_group_new ();
	action_group = _tmp0_;
	_tmp1_ = action_group;
	g_action_map_add_action_entries ((GActionMap*) _tmp1_, CONNECTIONS_TOPBAR_action_entries, (gint) G_N_ELEMENTS (CONNECTIONS_TOPBAR_action_entries), self);
	_tmp2_ = action_group;
	gtk_widget_insert_action_group ((GtkWidget*) self, "display", (GActionGroup*) _tmp2_);
	_tmp3_ = g_menu_new ();
	menu = _tmp3_;
	_tmp4_ = g_menu_new ();
	section = _tmp4_;
	_tmp5_ = section;
	g_menu_append (_tmp5_, _ ("Take Screenshot"), "display.take_screenshot");
	_tmp6_ = action_group;
	_tmp7_ = g_action_map_lookup_action ((GActionMap*) _tmp6_, "take_screenshot");
	_tmp8_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp7_, g_simple_action_get_type ()) ? ((GSimpleAction*) _tmp7_) : NULL);
	action = _tmp8_;
	_tmp9_ = action;
	g_simple_action_set_enabled (_tmp9_, TRUE);
	_tmp10_ = section;
	g_menu_append (_tmp10_, _ ("Fullscreen"), "display.fullscreen");
	_tmp11_ = action_group;
	_tmp12_ = g_action_map_lookup_action ((GActionMap*) _tmp11_, "fullscreen");
	_tmp13_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp12_, g_simple_action_get_type ()) ? ((GSimpleAction*) _tmp12_) : NULL);
	_g_object_unref0 (action);
	action = _tmp13_;
	_tmp14_ = action;
	g_simple_action_set_enabled (_tmp14_, TRUE);
	_tmp15_ = section;
	g_menu_append (_tmp15_, _ ("Properties"), "display.properties");
	_tmp16_ = action_group;
	_tmp17_ = g_action_map_lookup_action ((GActionMap*) _tmp16_, "properties");
	_tmp18_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp17_, g_simple_action_get_type ()) ? ((GSimpleAction*) _tmp17_) : NULL);
	_g_object_unref0 (action);
	action = _tmp18_;
	_tmp19_ = action;
	g_simple_action_set_enabled (_tmp19_, TRUE);
	_tmp20_ = g_simple_action_group_new ();
	key_input_action_group = _tmp20_;
	_tmp21_ = key_input_action_group;
	g_action_map_add_action_entries ((GActionMap*) _tmp21_, CONNECTIONS_TOPBAR_key_input_action_entries, (gint) G_N_ELEMENTS (CONNECTIONS_TOPBAR_key_input_action_entries), self);
	_tmp22_ = key_input_action_group;
	gtk_widget_insert_action_group ((GtkWidget*) self, "key", (GActionGroup*) _tmp22_);
	_g_object_unref0 (key_input_action_group);
	_g_object_unref0 (action);
	_g_object_unref0 (section);
	_g_object_unref0 (menu);
	_g_object_unref0 (action_group);
	return obj;
}

static void
connections_topbar_class_init (ConnectionsTopbarClass * klass,
                               gpointer klass_data)
{
	connections_topbar_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ConnectionsTopbar_private_offset);
	G_OBJECT_CLASS (klass)->constructor = connections_topbar_constructor;
	G_OBJECT_CLASS (klass)->finalize = connections_topbar_finalize;
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/Connections/ui/topbar.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "collection_toolbar", FALSE, ConnectionsTopbar_private_offset + G_STRUCT_OFFSET (ConnectionsTopbarPrivate, collection_toolbar));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "search_button", FALSE, G_STRUCT_OFFSET (ConnectionsTopbar, search_button));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "display_toolbar", FALSE, ConnectionsTopbar_private_offset + G_STRUCT_OFFSET (ConnectionsTopbarPrivate, display_toolbar));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "assistant", FALSE, G_STRUCT_OFFSET (ConnectionsTopbar, assistant));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "back_button_clicked", G_CALLBACK(_connections_topbar_back_button_clicked_gtk_button_clicked));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "disconnect_button_clicked", G_CALLBACK(_connections_topbar_disconnect_button_clicked_gtk_button_clicked));
}

static void
connections_topbar_instance_init (ConnectionsTopbar * self,
                                  gpointer klass)
{
	self->priv = connections_topbar_get_instance_private (self);
	g_type_ensure (CONNECTIONS_TYPE_ASSISTANT);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
connections_topbar_finalize (GObject * obj)
{
	ConnectionsTopbar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CONNECTIONS_TYPE_TOPBAR, ConnectionsTopbar);
	G_OBJECT_CLASS (connections_topbar_parent_class)->finalize (obj);
}

static GType
connections_topbar_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ConnectionsTopbarClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) connections_topbar_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ConnectionsTopbar), 0, (GInstanceInitFunc) connections_topbar_instance_init, NULL };
	GType connections_topbar_type_id;
	connections_topbar_type_id = g_type_register_static (gtk_stack_get_type (), "ConnectionsTopbar", &g_define_type_info, 0);
	ConnectionsTopbar_private_offset = g_type_add_instance_private (connections_topbar_type_id, sizeof (ConnectionsTopbarPrivate));
	return connections_topbar_type_id;
}

GType
connections_topbar_get_type (void)
{
	static volatile gsize connections_topbar_type_id__once = 0;
	if (g_once_init_enter (&connections_topbar_type_id__once)) {
		GType connections_topbar_type_id;
		connections_topbar_type_id = connections_topbar_get_type_once ();
		g_once_init_leave (&connections_topbar_type_id__once, connections_topbar_type_id);
	}
	return connections_topbar_type_id__once;
}

