/* tray-gtk.c generated by valac 0.56.17, the Vala compiler
 * generated from tray-gtk.vala, do not modify */

/*
 *  pamac-vala
 *
 *  Copyright (C) 2014-2022 Guillaume Benoit <guillaume@manjaro.org>
 *
 *  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 get of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <gtk/gtk.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <pamac.h>
#include <gio/gio.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 PAMAC_TYPE_TRAY_ICON (pamac_tray_icon_get_type ())
#define PAMAC_TRAY_ICON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PAMAC_TYPE_TRAY_ICON, PamacTrayIcon))
#define PAMAC_TRAY_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PAMAC_TYPE_TRAY_ICON, PamacTrayIconClass))
#define PAMAC_IS_TRAY_ICON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PAMAC_TYPE_TRAY_ICON))
#define PAMAC_IS_TRAY_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PAMAC_TYPE_TRAY_ICON))
#define PAMAC_TRAY_ICON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PAMAC_TYPE_TRAY_ICON, PamacTrayIconClass))

typedef struct _PamacTrayIcon PamacTrayIcon;
typedef struct _PamacTrayIconClass PamacTrayIconClass;
typedef struct _PamacTrayIconPrivate PamacTrayIconPrivate;

#define PAMAC_TYPE_GTK_TRAY_ICON (pamac_gtk_tray_icon_get_type ())
#define PAMAC_GTK_TRAY_ICON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PAMAC_TYPE_GTK_TRAY_ICON, PamacGtkTrayIcon))
#define PAMAC_GTK_TRAY_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PAMAC_TYPE_GTK_TRAY_ICON, PamacGtkTrayIconClass))
#define PAMAC_IS_GTK_TRAY_ICON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PAMAC_TYPE_GTK_TRAY_ICON))
#define PAMAC_IS_GTK_TRAY_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PAMAC_TYPE_GTK_TRAY_ICON))
#define PAMAC_GTK_TRAY_ICON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PAMAC_TYPE_GTK_TRAY_ICON, PamacGtkTrayIconClass))

typedef struct _PamacGtkTrayIcon PamacGtkTrayIcon;
typedef struct _PamacGtkTrayIconClass PamacGtkTrayIconClass;
typedef struct _PamacGtkTrayIconPrivate PamacGtkTrayIconPrivate;
enum  {
	PAMAC_GTK_TRAY_ICON_0_PROPERTY,
	PAMAC_GTK_TRAY_ICON_NUM_PROPERTIES
};
static GParamSpec* pamac_gtk_tray_icon_properties[PAMAC_GTK_TRAY_ICON_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _PamacTrayIcon {
	GtkApplication parent_instance;
	PamacTrayIconPrivate * priv;
	PamacUpdatesChecker* updates_checker;
};

struct _PamacTrayIconClass {
	GtkApplicationClass parent_class;
	void (*init_status_icon) (PamacTrayIcon* self);
	void (*set_tooltip) (PamacTrayIcon* self, const gchar* info);
	void (*set_icon) (PamacTrayIcon* self, const gchar* icon);
	void (*set_icon_visible) (PamacTrayIcon* self, gboolean visible);
};

struct _PamacGtkTrayIcon {
	PamacTrayIcon parent_instance;
	PamacGtkTrayIconPrivate * priv;
};

struct _PamacGtkTrayIconClass {
	PamacTrayIconClass parent_class;
};

struct _PamacGtkTrayIconPrivate {
	GtkStatusIcon* status_icon;
};

static gint PamacGtkTrayIcon_private_offset;
static gpointer pamac_gtk_tray_icon_parent_class = NULL;

VALA_EXTERN GType pamac_tray_icon_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PamacTrayIcon, g_object_unref)
VALA_EXTERN GType pamac_gtk_tray_icon_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PamacGtkTrayIcon, g_object_unref)
VALA_EXTERN void pamac_tray_icon_init_status_icon (PamacTrayIcon* self);
VALA_EXTERN void pamac_tray_icon_set_tooltip (PamacTrayIcon* self,
                                  const gchar* info);
VALA_EXTERN void pamac_tray_icon_set_icon (PamacTrayIcon* self,
                               const gchar* icon);
VALA_EXTERN void pamac_tray_icon_set_icon_visible (PamacTrayIcon* self,
                                       gboolean visible);
static void pamac_gtk_tray_icon_real_init_status_icon (PamacTrayIcon* base);
VALA_EXTERN void pamac_tray_icon_left_clicked (PamacTrayIcon* self);
static void _pamac_tray_icon_left_clicked_gtk_status_icon_activate (GtkStatusIcon* _sender,
                                                             gpointer self);
static void pamac_gtk_tray_icon_menu_popup (PamacGtkTrayIcon* self);
static void _pamac_gtk_tray_icon_menu_popup_gtk_status_icon_popup_menu (GtkStatusIcon* _sender,
                                                                 guint button,
                                                                 guint activate_time,
                                                                 gpointer self);
VALA_EXTERN GtkMenu* pamac_tray_icon_create_menu (PamacTrayIcon* self);
static void pamac_gtk_tray_icon_real_set_tooltip (PamacTrayIcon* base,
                                           const gchar* info);
static void pamac_gtk_tray_icon_real_set_icon (PamacTrayIcon* base,
                                        const gchar* icon);
static void pamac_gtk_tray_icon_real_set_icon_visible (PamacTrayIcon* base,
                                                gboolean visible);
VALA_EXTERN PamacGtkTrayIcon* pamac_gtk_tray_icon_new (void);
VALA_EXTERN PamacGtkTrayIcon* pamac_gtk_tray_icon_construct (GType object_type);
VALA_EXTERN PamacTrayIcon* pamac_tray_icon_construct (GType object_type);
static void pamac_gtk_tray_icon_finalize (GObject * obj);
static GType pamac_gtk_tray_icon_get_type_once (void);
static gint _vala_main (gchar** args,
                 gint args_length1);

static inline gpointer
pamac_gtk_tray_icon_get_instance_private (PamacGtkTrayIcon* self)
{
	return G_STRUCT_MEMBER_P (self, PamacGtkTrayIcon_private_offset);
}

static void
_pamac_tray_icon_left_clicked_gtk_status_icon_activate (GtkStatusIcon* _sender,
                                                        gpointer self)
{
	pamac_tray_icon_left_clicked ((PamacTrayIcon*) self);
}

static void
_pamac_gtk_tray_icon_menu_popup_gtk_status_icon_popup_menu (GtkStatusIcon* _sender,
                                                            guint button,
                                                            guint activate_time,
                                                            gpointer self)
{
	pamac_gtk_tray_icon_menu_popup ((PamacGtkTrayIcon*) self);
}

static void
pamac_gtk_tray_icon_real_init_status_icon (PamacTrayIcon* base)
{
	PamacGtkTrayIcon * self;
	GtkStatusIcon* _tmp0_;
	GtkStatusIcon* _tmp1_;
	GtkStatusIcon* _tmp2_;
	GtkStatusIcon* _tmp3_;
	self = (PamacGtkTrayIcon*) base;
	_tmp0_ = gtk_status_icon_new ();
	_g_object_unref0 (self->priv->status_icon);
	self->priv->status_icon = _tmp0_;
	_tmp1_ = self->priv->status_icon;
	gtk_status_icon_set_visible (_tmp1_, FALSE);
	_tmp2_ = self->priv->status_icon;
	g_signal_connect_object (_tmp2_, "activate", (GCallback) _pamac_tray_icon_left_clicked_gtk_status_icon_activate, (PamacTrayIcon*) self, 0);
	_tmp3_ = self->priv->status_icon;
	g_signal_connect_object (_tmp3_, "popup-menu", (GCallback) _pamac_gtk_tray_icon_menu_popup_gtk_status_icon_popup_menu, self, 0);
}

static void
pamac_gtk_tray_icon_menu_popup (PamacGtkTrayIcon* self)
{
	GtkMenu* menu = NULL;
	GtkMenu* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = pamac_tray_icon_create_menu ((PamacTrayIcon*) self);
	menu = _tmp0_;
	gtk_menu_popup_at_pointer (menu, NULL);
	_g_object_unref0 (menu);
}

static void
pamac_gtk_tray_icon_real_set_tooltip (PamacTrayIcon* base,
                                      const gchar* info)
{
	PamacGtkTrayIcon * self;
	GtkStatusIcon* _tmp0_;
	self = (PamacGtkTrayIcon*) base;
	g_return_if_fail (info != NULL);
	_tmp0_ = self->priv->status_icon;
	gtk_status_icon_set_tooltip_markup (_tmp0_, info);
}

static void
pamac_gtk_tray_icon_real_set_icon (PamacTrayIcon* base,
                                   const gchar* icon)
{
	PamacGtkTrayIcon * self;
	GtkStatusIcon* _tmp0_;
	self = (PamacGtkTrayIcon*) base;
	g_return_if_fail (icon != NULL);
	_tmp0_ = self->priv->status_icon;
	gtk_status_icon_set_from_icon_name (_tmp0_, icon);
}

static void
pamac_gtk_tray_icon_real_set_icon_visible (PamacTrayIcon* base,
                                           gboolean visible)
{
	PamacGtkTrayIcon * self;
	GtkStatusIcon* _tmp0_;
	self = (PamacGtkTrayIcon*) base;
	_tmp0_ = self->priv->status_icon;
	gtk_status_icon_set_visible (_tmp0_, visible);
}

PamacGtkTrayIcon*
pamac_gtk_tray_icon_construct (GType object_type)
{
	PamacGtkTrayIcon * self = NULL;
	self = (PamacGtkTrayIcon*) pamac_tray_icon_construct (object_type);
	return self;
}

PamacGtkTrayIcon*
pamac_gtk_tray_icon_new (void)
{
	return pamac_gtk_tray_icon_construct (PAMAC_TYPE_GTK_TRAY_ICON);
}

static void
pamac_gtk_tray_icon_class_init (PamacGtkTrayIconClass * klass,
                                gpointer klass_data)
{
	pamac_gtk_tray_icon_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &PamacGtkTrayIcon_private_offset);
	((PamacTrayIconClass *) klass)->init_status_icon = (void (*) (PamacTrayIcon*)) pamac_gtk_tray_icon_real_init_status_icon;
	((PamacTrayIconClass *) klass)->set_tooltip = (void (*) (PamacTrayIcon*, const gchar*)) pamac_gtk_tray_icon_real_set_tooltip;
	((PamacTrayIconClass *) klass)->set_icon = (void (*) (PamacTrayIcon*, const gchar*)) pamac_gtk_tray_icon_real_set_icon;
	((PamacTrayIconClass *) klass)->set_icon_visible = (void (*) (PamacTrayIcon*, gboolean)) pamac_gtk_tray_icon_real_set_icon_visible;
	G_OBJECT_CLASS (klass)->finalize = pamac_gtk_tray_icon_finalize;
}

static void
pamac_gtk_tray_icon_instance_init (PamacGtkTrayIcon * self,
                                   gpointer klass)
{
	self->priv = pamac_gtk_tray_icon_get_instance_private (self);
}

static void
pamac_gtk_tray_icon_finalize (GObject * obj)
{
	PamacGtkTrayIcon * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PAMAC_TYPE_GTK_TRAY_ICON, PamacGtkTrayIcon);
	_g_object_unref0 (self->priv->status_icon);
	G_OBJECT_CLASS (pamac_gtk_tray_icon_parent_class)->finalize (obj);
}

static GType
pamac_gtk_tray_icon_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (PamacGtkTrayIconClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) pamac_gtk_tray_icon_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (PamacGtkTrayIcon), 0, (GInstanceInitFunc) pamac_gtk_tray_icon_instance_init, NULL };
	GType pamac_gtk_tray_icon_type_id;
	pamac_gtk_tray_icon_type_id = g_type_register_static (PAMAC_TYPE_TRAY_ICON, "PamacGtkTrayIcon", &g_define_type_info, 0);
	PamacGtkTrayIcon_private_offset = g_type_add_instance_private (pamac_gtk_tray_icon_type_id, sizeof (PamacGtkTrayIconPrivate));
	return pamac_gtk_tray_icon_type_id;
}

GType
pamac_gtk_tray_icon_get_type (void)
{
	static volatile gsize pamac_gtk_tray_icon_type_id__once = 0;
	if (g_once_init_enter (&pamac_gtk_tray_icon_type_id__once)) {
		GType pamac_gtk_tray_icon_type_id;
		pamac_gtk_tray_icon_type_id = pamac_gtk_tray_icon_get_type_once ();
		g_once_init_leave (&pamac_gtk_tray_icon_type_id__once, pamac_gtk_tray_icon_type_id);
	}
	return pamac_gtk_tray_icon_type_id__once;
}

static gint
_vala_main (gchar** args,
            gint args_length1)
{
	PamacGtkTrayIcon* tray_icon = NULL;
	PamacGtkTrayIcon* _tmp0_;
	gint result;
	_tmp0_ = pamac_gtk_tray_icon_new ();
	tray_icon = _tmp0_;
	result = g_application_run ((GApplication*) tray_icon, (gint) args_length1, args);
	_g_object_unref0 (tray_icon);
	return result;
}

int
main (int argc,
      char ** argv)
{
	return _vala_main (argv, argc);
}

