/* main-panel-plugin.c generated by valac 0.56.18, the Vala compiler
 * generated from main-panel-plugin.vala, do not modify */

/*
 *  Notes - panel plugin for Xfce Desktop Environment
 *  Copyright (C) 2009-2010  Mike Massonnet <mmassonnet@xfce.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 2 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, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

#include "notes.h"
#include <gtk/gtk.h>
#include "libnotes.h"
#include <libxfce4panel/libxfce4panel.h>
#include <glib-object.h>
#include <libxfce4util/libxfce4util.h>
#include <xfce-revision.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.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

enum  {
	NOTES_PLUGIN_0_PROPERTY,
	NOTES_PLUGIN_NUM_PROPERTIES
};
static GParamSpec* notes_plugin_properties[NOTES_PLUGIN_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _NotesPluginPrivate {
	GtkButton* button;
	GtkImage* image;
	XnpApplication* application;
};

static gint NotesPlugin_private_offset;
static gpointer notes_plugin_parent_class = NULL;
static GType notes_plugin_type_id = 0;

static void notes_plugin_real_construct (XfcePanelPlugin* base);
static void __lambda4_ (NotesPlugin* self);
static void ___lambda4__gtk_button_clicked (GtkButton* _sender,
                                     gpointer self);
static gboolean __lambda5_ (NotesPlugin* self,
                     XfcePanelPlugin* p,
                     gint size);
static gboolean ___lambda5__xfce_panel_plugin_size_changed (XfcePanelPlugin* _sender,
                                                     gint size,
                                                     gpointer self);
static void __lambda6_ (NotesPlugin* self);
static void ___lambda6__xfce_panel_plugin_save (XfcePanelPlugin* _sender,
                                         gpointer self);
static void __lambda7_ (NotesPlugin* self);
static void ___lambda7__xfce_panel_plugin_free_data (XfcePanelPlugin* _sender,
                                              gpointer self);
static void __lambda8_ (NotesPlugin* self);
static void ___lambda8__xfce_panel_plugin_configure_plugin (XfcePanelPlugin* _sender,
                                                     gpointer self);
static void __lambda9_ (NotesPlugin* self);
static void ___lambda9__xfce_panel_plugin_about (XfcePanelPlugin* _sender,
                                          gpointer self);
static void notes_plugin_finalize (GObject * obj);

static inline gpointer
notes_plugin_get_instance_private (NotesPlugin* self)
{
	return G_STRUCT_MEMBER_P (self, NotesPlugin_private_offset);
}

NotesPlugin*
notes_plugin_construct (GType object_type)
{
	NotesPlugin * self = NULL;
	self = (NotesPlugin*) g_object_new (object_type, NULL);
	return self;
}

NotesPlugin*
notes_plugin_new (void)
{
	return notes_plugin_construct (TYPE_NOTES_PLUGIN);
}

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

static void
__lambda4_ (NotesPlugin* self)
{
	XnpApplication* _tmp0_;
	_tmp0_ = self->priv->application;
	xnp_application_show_hide_notes (_tmp0_);
}

static void
___lambda4__gtk_button_clicked (GtkButton* _sender,
                                gpointer self)
{
	__lambda4_ ((NotesPlugin*) self);
}

static gboolean
__lambda5_ (NotesPlugin* self,
            XfcePanelPlugin* p,
            gint size)
{
	guint _tmp0_;
	guint _tmp1_;
	GtkButton* _tmp2_;
	gint icon_size = 0;
	GtkImage* _tmp3_;
	gboolean result;
	g_return_val_if_fail (p != NULL, FALSE);
	_tmp0_ = xfce_panel_plugin_get_nrows ((XfcePanelPlugin*) self);
	_tmp1_ = _tmp0_;
	size = size / ((gint) _tmp1_);
	_tmp2_ = self->priv->button;
	gtk_widget_set_size_request ((GtkWidget*) _tmp2_, size, size);
	icon_size = xfce_panel_plugin_get_icon_size (p);
	_tmp3_ = self->priv->image;
	gtk_image_set_pixel_size (_tmp3_, icon_size);
	result = TRUE;
	return result;
}

static gboolean
___lambda5__xfce_panel_plugin_size_changed (XfcePanelPlugin* _sender,
                                            gint size,
                                            gpointer self)
{
	gboolean result;
	result = __lambda5_ ((NotesPlugin*) self, _sender, size);
	return result;
}

static void
__lambda6_ (NotesPlugin* self)
{
	XnpApplication* _tmp0_;
	_tmp0_ = self->priv->application;
	xnp_application_save_windows_configuration (_tmp0_);
}

static void
___lambda6__xfce_panel_plugin_save (XfcePanelPlugin* _sender,
                                    gpointer self)
{
	__lambda6_ ((NotesPlugin*) self);
}

static void
__lambda7_ (NotesPlugin* self)
{
	XnpApplication* _tmp0_;
	_tmp0_ = self->priv->application;
	xnp_application_save_notes (_tmp0_);
}

static void
___lambda7__xfce_panel_plugin_free_data (XfcePanelPlugin* _sender,
                                         gpointer self)
{
	__lambda7_ ((NotesPlugin*) self);
}

static void
__lambda8_ (NotesPlugin* self)
{
	XnpApplication* _tmp0_;
	_tmp0_ = self->priv->application;
	xnp_application_open_settings_dialog (_tmp0_);
}

static void
___lambda8__xfce_panel_plugin_configure_plugin (XfcePanelPlugin* _sender,
                                                gpointer self)
{
	__lambda8_ ((NotesPlugin*) self);
}

static void
__lambda9_ (NotesPlugin* self)
{
	XnpApplication* _tmp0_;
	_tmp0_ = self->priv->application;
	xnp_application_open_about_dialog (_tmp0_);
}

static void
___lambda9__xfce_panel_plugin_about (XfcePanelPlugin* _sender,
                                     gpointer self)
{
	__lambda9_ ((NotesPlugin*) self);
}

static void
notes_plugin_real_construct (XfcePanelPlugin* base)
{
	NotesPlugin * self;
	gchar* _tmp0_;
	gchar* _tmp1_;
	XnpApplication* _tmp2_;
	GtkWidget* _tmp3_;
	GtkButton* _tmp4_;
	GtkImage* _tmp5_;
	GtkButton* _tmp6_;
	GtkImage* _tmp7_;
	GtkButton* _tmp8_;
	GtkButton* _tmp9_;
	GtkButton* _tmp10_;
	GtkButton* _tmp11_;
	GtkMenuItem* mi = NULL;
	GtkMenuItem* _tmp12_;
	GtkMenu* menu = NULL;
	XnpApplication* _tmp13_;
	GtkMenu* _tmp14_;
	self = (NotesPlugin*) base;
	xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
	_tmp0_ = xfce_panel_plugin_save_location ((XfcePanelPlugin*) self, TRUE);
	_tmp1_ = _tmp0_;
	_tmp2_ = xnp_application_new (_tmp1_);
	_g_object_unref0 (self->priv->application);
	self->priv->application = _tmp2_;
	_g_free0 (_tmp1_);
	_tmp3_ = xfce_panel_create_button ();
	_tmp4_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, gtk_button_get_type (), GtkButton));
	_g_object_unref0 (self->priv->button);
	self->priv->button = _tmp4_;
	_tmp5_ = (GtkImage*) gtk_image_new_from_icon_name ("org.xfce.panel.notes", (GtkIconSize) GTK_ICON_SIZE_BUTTON);
	g_object_ref_sink (_tmp5_);
	_g_object_unref0 (self->priv->image);
	self->priv->image = _tmp5_;
	_tmp6_ = self->priv->button;
	_tmp7_ = self->priv->image;
	gtk_container_add ((GtkContainer*) _tmp6_, (GtkWidget*) _tmp7_);
	_tmp8_ = self->priv->button;
	g_signal_connect_object (_tmp8_, "clicked", (GCallback) ___lambda4__gtk_button_clicked, self, 0);
	_tmp9_ = self->priv->button;
	gtk_widget_show_all ((GtkWidget*) _tmp9_);
	xfce_panel_plugin_set_small ((XfcePanelPlugin*) self, TRUE);
	_tmp10_ = self->priv->button;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp10_);
	_tmp11_ = self->priv->button;
	xfce_panel_plugin_add_action_widget ((XfcePanelPlugin*) self, (GtkWidget*) _tmp11_);
	gtk_widget_set_tooltip_text ((GtkWidget*) self, _ ("Notes"));
	xfce_panel_plugin_menu_show_configure ((XfcePanelPlugin*) self);
	xfce_panel_plugin_menu_show_about ((XfcePanelPlugin*) self);
	_tmp12_ = (GtkMenuItem*) gtk_menu_item_new_with_mnemonic (_ ("_Groups"));
	g_object_ref_sink (_tmp12_);
	mi = _tmp12_;
	_tmp13_ = self->priv->application;
	_tmp14_ = xnp_application_context_menu (_tmp13_);
	menu = _tmp14_;
	gtk_menu_item_set_submenu (mi, menu);
	gtk_widget_show_all ((GtkWidget*) mi);
	xfce_panel_plugin_menu_insert_item ((XfcePanelPlugin*) self, mi);
	g_signal_connect_object ((XfcePanelPlugin*) self, "size-changed", (GCallback) ___lambda5__xfce_panel_plugin_size_changed, self, 0);
	g_signal_connect_object ((XfcePanelPlugin*) self, "save", (GCallback) ___lambda6__xfce_panel_plugin_save, self, 0);
	g_signal_connect_object ((XfcePanelPlugin*) self, "free-data", (GCallback) ___lambda7__xfce_panel_plugin_free_data, self, 0);
	g_signal_connect_object ((XfcePanelPlugin*) self, "configure-plugin", (GCallback) ___lambda8__xfce_panel_plugin_configure_plugin, self, 0);
	g_signal_connect_object ((XfcePanelPlugin*) self, "about", (GCallback) ___lambda9__xfce_panel_plugin_about, self, 0);
	_g_object_unref0 (menu);
	_g_object_unref0 (mi);
}

static void
notes_plugin_class_init (NotesPluginClass * klass,
                         gpointer klass_data)
{
	notes_plugin_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &NotesPlugin_private_offset);
	((XfcePanelPluginClass *) klass)->construct = (void (*) (XfcePanelPlugin*)) notes_plugin_real_construct;
	G_OBJECT_CLASS (klass)->finalize = notes_plugin_finalize;
}

static void
notes_plugin_instance_init (NotesPlugin * self,
                            gpointer klass)
{
	self->priv = notes_plugin_get_instance_private (self);
}

static void
notes_plugin_finalize (GObject * obj)
{
	NotesPlugin * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_NOTES_PLUGIN, NotesPlugin);
	_g_object_unref0 (self->priv->button);
	_g_object_unref0 (self->priv->image);
	_g_object_unref0 (self->priv->application);
	G_OBJECT_CLASS (notes_plugin_parent_class)->finalize (obj);
}

GType
notes_plugin_get_type (void)
{
	return notes_plugin_type_id;
}

GType
notes_plugin_register_type (GTypeModule * module)
{
	static const GTypeInfo g_define_type_info = { sizeof (NotesPluginClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) notes_plugin_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (NotesPlugin), 0, (GInstanceInitFunc) notes_plugin_instance_init, NULL };
	notes_plugin_type_id = g_type_module_register_type (module, xfce_panel_plugin_get_type (), "NotesPlugin", &g_define_type_info, 0);
	NotesPlugin_private_offset = sizeof (NotesPluginPrivate);
	return notes_plugin_type_id;
}

GType
xfce_panel_module_init (GTypeModule* module)
{
	GType result;
	g_return_val_if_fail (module != NULL, 0UL);
	notes_plugin_register_type (module);
	result = TYPE_NOTES_PLUGIN;
	return result;
}

