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

/* actions-popover.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 <gio/gio.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <stdlib.h>
#include <string.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define CONNECTIONS_TYPE_ACTIONS_POPOVER (connections_actions_popover_get_type ())
#define CONNECTIONS_ACTIONS_POPOVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONNECTIONS_TYPE_ACTIONS_POPOVER, ConnectionsActionsPopover))
#define CONNECTIONS_ACTIONS_POPOVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONNECTIONS_TYPE_ACTIONS_POPOVER, ConnectionsActionsPopoverClass))
#define CONNECTIONS_IS_ACTIONS_POPOVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONNECTIONS_TYPE_ACTIONS_POPOVER))
#define CONNECTIONS_IS_ACTIONS_POPOVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONNECTIONS_TYPE_ACTIONS_POPOVER))
#define CONNECTIONS_ACTIONS_POPOVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONNECTIONS_TYPE_ACTIONS_POPOVER, ConnectionsActionsPopoverClass))

typedef struct _ConnectionsActionsPopover ConnectionsActionsPopover;
typedef struct _ConnectionsActionsPopoverClass ConnectionsActionsPopoverClass;
typedef struct _ConnectionsActionsPopoverPrivate ConnectionsActionsPopoverPrivate;

#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_ACTIONS_POPOVER_0_PROPERTY,
	CONNECTIONS_ACTIONS_POPOVER_NUM_PROPERTIES
};
static GParamSpec* connections_actions_popover_properties[CONNECTIONS_ACTIONS_POPOVER_NUM_PROPERTIES];
typedef void (*GSimpleActionActivateCallback) (GSimpleAction* action, GVariant* parameter, gpointer user_data);
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

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

struct _ConnectionsActionsPopover {
	GtkPopover parent_instance;
	ConnectionsActionsPopoverPrivate * priv;
};

struct _ConnectionsActionsPopoverClass {
	GtkPopoverClass parent_class;
};

struct _ConnectionsActionsPopoverPrivate {
	GSimpleActionGroup* action_group;
	ConnectionsConnection* connection;
};

static gint ConnectionsActionsPopover_private_offset;
static gpointer connections_actions_popover_parent_class = NULL;
VALA_EXTERN ConnectionsApplication* connections_application_application;

VALA_EXTERN GType connections_actions_popover_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ConnectionsActionsPopover, 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_actions_popover_delete_activated (ConnectionsActionsPopover* self);
static void _connections_actions_popover_delete_activated_gsimple_action_activate_callback (GSimpleAction* action,
                                                                                     GVariant* parameter,
                                                                                     gpointer self);
static void connections_actions_popover_properties_activated (ConnectionsActionsPopover* self);
static void _connections_actions_popover_properties_activated_gsimple_action_activate_callback (GSimpleAction* action,
                                                                                         GVariant* parameter,
                                                                                         gpointer self);
VALA_EXTERN void connections_actions_popover_update_for_item (ConnectionsActionsPopover* self,
                                                  ConnectionsConnection* connection);
VALA_EXTERN gchar* connections_connection_get_uri (ConnectionsConnection* self);
VALA_EXTERN GType connections_application_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ConnectionsApplication, g_object_unref)
VALA_EXTERN void connections_application_remove_connection (ConnectionsApplication* self,
                                                ConnectionsConnection* connection);
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 ConnectionsActionsPopover* connections_actions_popover_new (void);
VALA_EXTERN ConnectionsActionsPopover* connections_actions_popover_construct (GType object_type);
static GObject * connections_actions_popover_constructor (GType type,
                                                   guint n_construct_properties,
                                                   GObjectConstructParam * construct_properties);
static void connections_actions_popover_finalize (GObject * obj);
static GType connections_actions_popover_get_type_once (void);

static const GActionEntry CONNECTIONS_ACTIONS_POPOVER_action_entries[2] = {{"delete", _connections_actions_popover_delete_activated_gsimple_action_activate_callback}, {"properties", _connections_actions_popover_properties_activated_gsimple_action_activate_callback}};

static inline gpointer
connections_actions_popover_get_instance_private (ConnectionsActionsPopover* self)
{
	return G_STRUCT_MEMBER_P (self, ConnectionsActionsPopover_private_offset);
}

static void
_connections_actions_popover_delete_activated_gsimple_action_activate_callback (GSimpleAction* action,
                                                                                GVariant* parameter,
                                                                                gpointer self)
{
	connections_actions_popover_delete_activated ((ConnectionsActionsPopover*) self);
}

static void
_connections_actions_popover_properties_activated_gsimple_action_activate_callback (GSimpleAction* action,
                                                                                    GVariant* parameter,
                                                                                    gpointer self)
{
	connections_actions_popover_properties_activated ((ConnectionsActionsPopover*) self);
}

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

void
connections_actions_popover_update_for_item (ConnectionsActionsPopover* self,
                                             ConnectionsConnection* connection)
{
	ConnectionsConnection* _tmp0_;
	GMenu* menu = NULL;
	GMenu* _tmp1_;
	GSimpleAction* action = NULL;
	GSimpleActionGroup* _tmp2_;
	GAction* _tmp3_;
	GSimpleAction* _tmp4_;
	GSimpleAction* _tmp5_;
	GSimpleActionGroup* _tmp6_;
	GAction* _tmp7_;
	GSimpleAction* _tmp8_;
	GSimpleAction* _tmp9_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (connection != NULL);
	_tmp0_ = _g_object_ref0 (connection);
	_g_object_unref0 (self->priv->connection);
	self->priv->connection = _tmp0_;
	_tmp1_ = g_menu_new ();
	menu = _tmp1_;
	_tmp2_ = self->priv->action_group;
	_tmp3_ = g_action_map_lookup_action ((GActionMap*) _tmp2_, "delete");
	_tmp4_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp3_, g_simple_action_get_type ()) ? ((GSimpleAction*) _tmp3_) : NULL);
	action = _tmp4_;
	g_menu_append (menu, _ ("Delete"), "connection.delete");
	_tmp5_ = action;
	g_simple_action_set_enabled (_tmp5_, TRUE);
	_tmp6_ = self->priv->action_group;
	_tmp7_ = g_action_map_lookup_action ((GActionMap*) _tmp6_, "properties");
	_tmp8_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp7_, g_simple_action_get_type ()) ? ((GSimpleAction*) _tmp7_) : NULL);
	_g_object_unref0 (action);
	action = _tmp8_;
	g_menu_append (menu, _ ("Properties"), "connection.properties");
	_tmp9_ = action;
	g_simple_action_set_enabled (_tmp9_, TRUE);
	gtk_popover_bind_model ((GtkPopover*) self, (GMenuModel*) menu, NULL);
	_g_object_unref0 (action);
	_g_object_unref0 (menu);
}

static void
connections_actions_popover_delete_activated (ConnectionsActionsPopover* self)
{
	ConnectionsConnection* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	ConnectionsApplication* _tmp4_;
	ConnectionsConnection* _tmp5_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->connection;
	_tmp1_ = connections_connection_get_uri (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _tmp2_;
	g_debug ("actions-popover.vala:55: Deleting %s", _tmp3_);
	_g_free0 (_tmp3_);
	_tmp4_ = connections_application_application;
	_tmp5_ = self->priv->connection;
	connections_application_remove_connection (_tmp4_, _tmp5_);
}

static void
connections_actions_popover_properties_activated (ConnectionsActionsPopover* self)
{
	ConnectionsConnection* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	ConnectionsApplication* _tmp4_;
	ConnectionsWindow* _tmp5_;
	ConnectionsWindow* _tmp6_;
	ConnectionsConnection* _tmp7_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->connection;
	_tmp1_ = connections_connection_get_uri (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _tmp2_;
	g_debug ("actions-popover.vala:61: Launch properties for %s", _tmp3_);
	_g_free0 (_tmp3_);
	_tmp4_ = connections_application_application;
	_tmp5_ = connections_application_get_main_window (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = self->priv->connection;
	connections_window_show_preferences_window (_tmp6_, _tmp7_);
}

ConnectionsActionsPopover*
connections_actions_popover_construct (GType object_type)
{
	ConnectionsActionsPopover * self = NULL;
	self = (ConnectionsActionsPopover*) g_object_new (object_type, NULL);
	return self;
}

ConnectionsActionsPopover*
connections_actions_popover_new (void)
{
	return connections_actions_popover_construct (CONNECTIONS_TYPE_ACTIONS_POPOVER);
}

static GObject *
connections_actions_popover_constructor (GType type,
                                         guint n_construct_properties,
                                         GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	ConnectionsActionsPopover * self;
	GSimpleActionGroup* _tmp0_;
	GSimpleActionGroup* _tmp1_;
	GSimpleActionGroup* _tmp2_;
	parent_class = G_OBJECT_CLASS (connections_actions_popover_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CONNECTIONS_TYPE_ACTIONS_POPOVER, ConnectionsActionsPopover);
	_tmp0_ = g_simple_action_group_new ();
	_g_object_unref0 (self->priv->action_group);
	self->priv->action_group = _tmp0_;
	_tmp1_ = self->priv->action_group;
	g_action_map_add_action_entries ((GActionMap*) _tmp1_, CONNECTIONS_ACTIONS_POPOVER_action_entries, (gint) G_N_ELEMENTS (CONNECTIONS_ACTIONS_POPOVER_action_entries), self);
	_tmp2_ = self->priv->action_group;
	gtk_widget_insert_action_group ((GtkWidget*) self, "connection", (GActionGroup*) _tmp2_);
	return obj;
}

static void
connections_actions_popover_class_init (ConnectionsActionsPopoverClass * klass,
                                        gpointer klass_data)
{
	connections_actions_popover_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ConnectionsActionsPopover_private_offset);
	G_OBJECT_CLASS (klass)->constructor = connections_actions_popover_constructor;
	G_OBJECT_CLASS (klass)->finalize = connections_actions_popover_finalize;
}

static void
connections_actions_popover_instance_init (ConnectionsActionsPopover * self,
                                           gpointer klass)
{
	self->priv = connections_actions_popover_get_instance_private (self);
}

static void
connections_actions_popover_finalize (GObject * obj)
{
	ConnectionsActionsPopover * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CONNECTIONS_TYPE_ACTIONS_POPOVER, ConnectionsActionsPopover);
	_g_object_unref0 (self->priv->action_group);
	_g_object_unref0 (self->priv->connection);
	G_OBJECT_CLASS (connections_actions_popover_parent_class)->finalize (obj);
}

static GType
connections_actions_popover_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ConnectionsActionsPopoverClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) connections_actions_popover_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ConnectionsActionsPopover), 0, (GInstanceInitFunc) connections_actions_popover_instance_init, NULL };
	GType connections_actions_popover_type_id;
	connections_actions_popover_type_id = g_type_register_static (gtk_popover_get_type (), "ConnectionsActionsPopover", &g_define_type_info, 0);
	ConnectionsActionsPopover_private_offset = g_type_add_instance_private (connections_actions_popover_type_id, sizeof (ConnectionsActionsPopoverPrivate));
	return connections_actions_popover_type_id;
}

GType
connections_actions_popover_get_type (void)
{
	static volatile gsize connections_actions_popover_type_id__once = 0;
	if (g_once_init_enter (&connections_actions_popover_type_id__once)) {
		GType connections_actions_popover_type_id;
		connections_actions_popover_type_id = connections_actions_popover_get_type_once ();
		g_once_init_leave (&connections_actions_popover_type_id__once, connections_actions_popover_type_id);
	}
	return connections_actions_popover_type_id__once;
}

