/* custom_statusbar.c generated by valac 0.36.3, 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_;
	GtkStatusbar* _tmp3_;
	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;
	g_object_set ((GtkWidget*) _tmp2_, "margin", 0, NULL);
	_tmp3_ = self->priv->cursor_position;
	gtk_box_pack_end ((GtkBox*) self, (GtkWidget*) _tmp3_, FALSE, TRUE, (guint) 0);
	gtk_widget_set_margin_top ((GtkWidget*) self, 0);
	gtk_widget_set_margin_bottom ((GtkWidget*) self, 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_;
	GtkStatusbar* _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	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;
	}
	if (_tmp1_) {
		return;
	}
	_tmp4_ = self->priv->cursor_position;
	_tmp5_ = line;
	_tmp6_ = col;
	_tmp7_ = g_strdup_printf (_ ("Ln %d, Col %d"), _tmp5_, _tmp6_);
	_tmp8_ = _tmp7_;
	gtk_statusbar_push (_tmp4_, (guint) 0, _tmp8_);
	_g_free0 (_tmp8_);
}


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_statusbar_get_type (), "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;
}



