/*************************************************************************************************************
* This file contains statusbar function to change lines counts
* 2012/8 by Dlxko
* Version 3.0
**************************************************************************************************************/
#include "Statusbar.h"

// Local static variables
static gint rows_count;
static GtkTextIter textview_iter;

// Function to update statusbar text after counting its lines
void function_update_statusbar(GtkTextBuffer *input_textview_buffer, GtkStatusbar  *input_statusbar_widget)
{
	// Create pointers to memory
	gchar *statusbar_text;
	gchar *lines_count_text;

	// Remove previous message
	gtk_statusbar_pop(input_statusbar_widget, 0);

	// Get iter at the end of buffer
	gtk_text_buffer_get_end_iter(input_textview_buffer, &textview_iter);

	// Get line namber at the iter position
	rows_count = gtk_text_iter_get_line(&textview_iter);

	// Get the new text with line count
	lines_count_text = g_strdup_printf("%d", rows_count);
	statusbar_text = g_strconcat (LANG_STATUSBAR_TEXT_1, lines_count_text, LANG_STATUSBAR_TEXT_2, NULL);

	// Insert new text
	gtk_statusbar_push(input_statusbar_widget, 0, statusbar_text);

	// Free statusbar and lines count text
	g_free(statusbar_text);
	g_free(lines_count_text);
}