/* custom_statusbar.c generated by valac 0.18.0.1-c1117, the Vala compiler
 * generated from custom_statusbar.vala, do not modify */

/*
 * This file is part of LaTeXila.
 *
 * Copyright © 2010-2011 Sébastien Wilmet
 *
 * LaTeXila 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.
 *
 * LaTeXila 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 LaTeXila.  If not, see <http://www.gnu.org/licenses/>.
 */

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


#define TYPE_CUSTOM_STATUSBAR (custom_statusbar_get_type ())
#define CUSTOM_STATUSBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CUSTOM_STATUSBAR, CustomStatusbar))
#define CUSTOM_STATUSBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CUSTOM_STATUSBAR, CustomStatusbarClass))
#define IS_CUSTOM_STATUSBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CUSTOM_STATUSBAR))
#define IS_CUSTOM_STATUSBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CUSTOM_STATUSBAR))
#define CUSTOM_STATUSBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CUSTOM_STATUSBAR, CustomStatusbarClass))

typedef struct _CustomStatusbar CustomStatusbar;
typedef struct _CustomStatusbarClass CustomStatusbarClass;
typedef struct _CustomStatusbarPrivate CustomStatusbarPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _CustomStatusbar {
	GtkStatusbar parent_instance;
	CustomStatusbarPrivate * priv;
};

struct _CustomStatusbarClass {
	GtkStatusbarClass parent_class;
};

struct _CustomStatusbarPrivate {
	GtkStatusbar* cursor_position;
};


static gpointer custom_statusbar_parent_class = NULL;

GType custom_statusbar_get_type (void) G_GNUC_CONST;
#define CUSTOM_STATUSBAR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_CUSTOM_STATUSBAR, CustomStatusbarPrivate))
enum  {
	CUSTOM_STATUSBAR_DUMMY_PROPERTY
};
CustomStatusbar* custom_statusbar_new (void);
CustomStatusbar* custom_statusbar_construct (GType object_type);
void custom_statusbar_set_cursor_position (CustomStatusbar* self, gint line, gint col);
static void custom_statusbar_finalize (GObject* obj);


CustomStatusbar* custom_statusbar_construct (GType object_type) {
	CustomStatusbar * self = NULL;
	GtkStatusbar* _tmp0_;
	GtkStatusbar* _tmp1_;
	GtkStatusbar* _tmp2_;
	self = (CustomStatusbar*) g_object_new (object_type, NULL);
	_tmp0_ = (GtkStatusbar*) gtk_statusbar_new ();
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->cursor_position);
	self->priv->cursor_position = _tmp0_;
	_tmp1_ = self->priv->cursor_position;
	gtk_widget_set_size_request ((GtkWidget*) _tmp1_, 150, -1);
	_tmp2_ = self->priv->cursor_position;
	gtk_box_pack_end ((GtkBox*) self, (GtkWidget*) _tmp2_, FALSE, TRUE, (guint) 0);
	return self;
}


CustomStatusbar* custom_statusbar_new (void) {
	return custom_statusbar_construct (TYPE_CUSTOM_STATUSBAR);
}


void custom_statusbar_set_cursor_position (CustomStatusbar* self, gint line, gint col) {
	GtkStatusbar* _tmp0_;
	gboolean _tmp1_ = FALSE;
	gint _tmp2_;
	gboolean _tmp4_;
	GtkStatusbar* _tmp5_;
	const gchar* _tmp6_ = NULL;
	gint _tmp7_;
	gint _tmp8_;
	gchar* _tmp9_ = NULL;
	gchar* _tmp10_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->cursor_position;
	gtk_statusbar_pop (_tmp0_, (guint) 0);
	_tmp2_ = line;
	if (_tmp2_ == (-1)) {
		gint _tmp3_;
		_tmp3_ = col;
		_tmp1_ = _tmp3_ == (-1);
	} else {
		_tmp1_ = FALSE;
	}
	_tmp4_ = _tmp1_;
	if (_tmp4_) {
		return;
	}
	_tmp5_ = self->priv->cursor_position;
	_tmp6_ = _ ("Ln %d, Col %d");
	_tmp7_ = line;
	_tmp8_ = col;
	_tmp9_ = g_strdup_printf (_tmp6_, _tmp7_, _tmp8_);
	_tmp10_ = _tmp9_;
	gtk_statusbar_push (_tmp5_, (guint) 0, _tmp10_);
	_g_free0 (_tmp10_);
}


static void custom_statusbar_class_init (CustomStatusbarClass * klass) {
	custom_statusbar_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (CustomStatusbarPrivate));
	G_OBJECT_CLASS (klass)->finalize = custom_statusbar_finalize;
}


static void custom_statusbar_instance_init (CustomStatusbar * self) {
	self->priv = CUSTOM_STATUSBAR_GET_PRIVATE (self);
}


static void custom_statusbar_finalize (GObject* obj) {
	CustomStatusbar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_CUSTOM_STATUSBAR, CustomStatusbar);
	_g_object_unref0 (self->priv->cursor_position);
	G_OBJECT_CLASS (custom_statusbar_parent_class)->finalize (obj);
}


GType custom_statusbar_get_type (void) {
	static volatile gsize custom_statusbar_type_id__volatile = 0;
	if (g_once_init_enter (&custom_statusbar_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (CustomStatusbarClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) custom_statusbar_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (CustomStatusbar), 0, (GInstanceInitFunc) custom_statusbar_instance_init, NULL };
		GType custom_statusbar_type_id;
		custom_statusbar_type_id = g_type_register_static (GTK_TYPE_STATUSBAR, "CustomStatusbar", &g_define_type_info, 0);
		g_once_init_leave (&custom_statusbar_type_id__volatile, custom_statusbar_type_id);
	}
	return custom_statusbar_type_id__volatile;
}



