/* symbols_view.c generated by valac 0.21.2.9-2b15d, the Vala compiler
 * generated from symbols_view.vala, do not modify */

/*
 * This file is part of LaTeXila.
 *
 * Copyright © 2012 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/>.
 *
 * Author: Sébastien Wilmet
 */

#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <pango/pango.h>
#include <stdlib.h>
#include <string.h>
#include <gtksourceview/gtksource.h>


#define TYPE_SYMBOLS_VIEW (symbols_view_get_type ())
#define SYMBOLS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SYMBOLS_VIEW, SymbolsView))
#define SYMBOLS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SYMBOLS_VIEW, SymbolsViewClass))
#define IS_SYMBOLS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SYMBOLS_VIEW))
#define IS_SYMBOLS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SYMBOLS_VIEW))
#define SYMBOLS_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SYMBOLS_VIEW, SymbolsViewClass))

typedef struct _SymbolsView SymbolsView;
typedef struct _SymbolsViewClass SymbolsViewClass;
typedef struct _SymbolsViewPrivate SymbolsViewPrivate;

#define TYPE_MAIN_WINDOW (main_window_get_type ())
#define MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MAIN_WINDOW, MainWindow))
#define MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MAIN_WINDOW, MainWindowClass))
#define IS_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MAIN_WINDOW))
#define IS_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MAIN_WINDOW))
#define MAIN_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MAIN_WINDOW, MainWindowClass))

typedef struct _MainWindow MainWindow;
typedef struct _MainWindowClass MainWindowClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block31Data Block31Data;

#define TYPE_SYMBOLS (symbols_get_type ())
#define SYMBOLS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SYMBOLS, Symbols))
#define SYMBOLS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SYMBOLS, SymbolsClass))
#define IS_SYMBOLS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SYMBOLS))
#define IS_SYMBOLS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SYMBOLS))
#define SYMBOLS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SYMBOLS, SymbolsClass))

typedef struct _Symbols Symbols;
typedef struct _SymbolsClass SymbolsClass;

#define TYPE_SYMBOLS_CATEGORY_COLUMN (symbols_category_column_get_type ())

#define TYPE_SYMBOLS_CATEGORY_TYPE (symbols_category_type_get_type ())

#define TYPE_SYMBOL_COLUMN (symbol_column_get_type ())

#define TYPE_DOCUMENT_TAB (document_tab_get_type ())
#define DOCUMENT_TAB(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DOCUMENT_TAB, DocumentTab))
#define DOCUMENT_TAB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DOCUMENT_TAB, DocumentTabClass))
#define IS_DOCUMENT_TAB(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DOCUMENT_TAB))
#define IS_DOCUMENT_TAB_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DOCUMENT_TAB))
#define DOCUMENT_TAB_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DOCUMENT_TAB, DocumentTabClass))

typedef struct _DocumentTab DocumentTab;
typedef struct _DocumentTabClass DocumentTabClass;

#define TYPE_DOCUMENT (document_get_type ())
#define DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DOCUMENT, Document))
#define DOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DOCUMENT, DocumentClass))
#define IS_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DOCUMENT))
#define IS_DOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DOCUMENT))
#define DOCUMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DOCUMENT, DocumentClass))

typedef struct _Document Document;
typedef struct _DocumentClass DocumentClass;
#define _g_free0(var) (var = (g_free (var), NULL))

#define TYPE_DOCUMENT_VIEW (document_view_get_type ())
#define DOCUMENT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DOCUMENT_VIEW, DocumentView))
#define DOCUMENT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DOCUMENT_VIEW, DocumentViewClass))
#define IS_DOCUMENT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DOCUMENT_VIEW))
#define IS_DOCUMENT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DOCUMENT_VIEW))
#define DOCUMENT_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DOCUMENT_VIEW, DocumentViewClass))

typedef struct _DocumentView DocumentView;
typedef struct _DocumentViewClass DocumentViewClass;

#define TYPE_MOST_USED_SYMBOLS (most_used_symbols_get_type ())
#define MOST_USED_SYMBOLS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MOST_USED_SYMBOLS, MostUsedSymbols))
#define MOST_USED_SYMBOLS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MOST_USED_SYMBOLS, MostUsedSymbolsClass))
#define IS_MOST_USED_SYMBOLS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MOST_USED_SYMBOLS))
#define IS_MOST_USED_SYMBOLS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MOST_USED_SYMBOLS))
#define MOST_USED_SYMBOLS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MOST_USED_SYMBOLS, MostUsedSymbolsClass))

typedef struct _MostUsedSymbols MostUsedSymbols;
typedef struct _MostUsedSymbolsClass MostUsedSymbolsClass;
#define _gtk_tree_path_free0(var) ((var == NULL) ? NULL : (var = (gtk_tree_path_free (var), NULL)))
#define __g_list_free__gtk_tree_path_free0_0(var) ((var == NULL) ? NULL : (var = (_g_list_free__gtk_tree_path_free0_ (var), NULL)))

struct _SymbolsView {
	GtkGrid parent_instance;
	SymbolsViewPrivate * priv;
};

struct _SymbolsViewClass {
	GtkGridClass parent_class;
};

struct _SymbolsViewPrivate {
	MainWindow* _main_window;
	GtkComboBox* _combo_box;
	GtkIconView* _symbol_view;
	GtkButton* _clear_button;
};

struct _Block31Data {
	int _ref_count_;
	SymbolsView * self;
	GtkTreeModel* categories_model;
};

typedef enum  {
	SYMBOLS_CATEGORY_COLUMN_TYPE,
	SYMBOLS_CATEGORY_COLUMN_ICON,
	SYMBOLS_CATEGORY_COLUMN_NAME,
	SYMBOLS_CATEGORY_COLUMN_SYMBOLS_STORE,
	SYMBOLS_CATEGORY_COLUMN_N_COLUMNS
} SymbolsCategoryColumn;

typedef enum  {
	SYMBOLS_CATEGORY_TYPE_NORMAL,
	SYMBOLS_CATEGORY_TYPE_MOST_USED
} SymbolsCategoryType;

typedef enum  {
	SYMBOL_COLUMN_PIXBUF,
	SYMBOL_COLUMN_COMMAND,
	SYMBOL_COLUMN_TOOLTIP,
	SYMBOL_COLUMN_ID,
	SYMBOL_COLUMN_N_COLUMNS
} SymbolColumn;


static gpointer symbols_view_parent_class = NULL;

GType symbols_view_get_type (void) G_GNUC_CONST;
GType main_window_get_type (void) G_GNUC_CONST;
#define SYMBOLS_VIEW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_SYMBOLS_VIEW, SymbolsViewPrivate))
enum  {
	SYMBOLS_VIEW_DUMMY_PROPERTY
};
SymbolsView* symbols_view_new (MainWindow* main_window);
SymbolsView* symbols_view_construct (GType object_type, MainWindow* main_window);
static void symbols_view_create_combo_box (SymbolsView* self);
static void symbols_view_create_icon_view (SymbolsView* self);
static void symbols_view_create_clear_button (SymbolsView* self);
GtkScrolledWindow* utils_add_scrollbar (GtkWidget* child);
static Block31Data* block31_data_ref (Block31Data* _data31_);
static void block31_data_unref (void * _userdata_);
GType symbols_get_type (void) G_GNUC_CONST;
Symbols* symbols_get_default (void);
GtkTreeModel* symbols_get_categories_model (Symbols* self);
GType symbols_category_column_get_type (void) G_GNUC_CONST;
static void __lambda114_ (Block31Data* _data31_);
GType symbols_category_type_get_type (void) G_GNUC_CONST;
static void ___lambda114__gtk_combo_box_changed (GtkComboBox* _sender, gpointer self);
GType symbol_column_get_type (void) G_GNUC_CONST;
static void __lambda115_ (SymbolsView* self);
GType document_tab_get_type (void) G_GNUC_CONST;
DocumentTab* main_window_get_active_tab (MainWindow* self);
GType document_get_type (void) G_GNUC_CONST;
Document* main_window_get_active_document (MainWindow* self);
GType document_view_get_type (void) G_GNUC_CONST;
DocumentView* main_window_get_active_view (MainWindow* self);
GType most_used_symbols_get_type (void) G_GNUC_CONST;
MostUsedSymbols* most_used_symbols_get_default (void);
void most_used_symbols_increment_symbol (MostUsedSymbols* self, const gchar* id);
static void _gtk_tree_path_free0_ (gpointer var);
static void _g_list_free__gtk_tree_path_free0_ (GList* self);
static void ___lambda115__gtk_icon_view_selection_changed (GtkIconView* _sender, gpointer self);
static void __lambda116_ (SymbolsView* self);
void most_used_symbols_clear (MostUsedSymbols* self);
static void ___lambda116__gtk_button_clicked (GtkButton* _sender, gpointer self);
static void symbols_view_finalize (GObject* obj);


SymbolsView* symbols_view_construct (GType object_type, MainWindow* main_window) {
	SymbolsView * self = NULL;
	MainWindow* _tmp0_ = NULL;
	GtkComboBox* _tmp1_ = NULL;
	GtkScrolledWindow* sw = NULL;
	GtkIconView* _tmp2_ = NULL;
	GtkScrolledWindow* _tmp3_ = NULL;
	GtkButton* _tmp4_ = NULL;
	GtkComboBox* _tmp5_ = NULL;
	g_return_val_if_fail (main_window != NULL, NULL);
	self = (SymbolsView*) g_object_new (object_type, NULL);
	_tmp0_ = main_window;
	self->priv->_main_window = _tmp0_;
	symbols_view_create_combo_box (self);
	symbols_view_create_icon_view (self);
	symbols_view_create_clear_button (self);
	gtk_orientable_set_orientation ((GtkOrientable*) self, GTK_ORIENTATION_VERTICAL);
	gtk_grid_set_row_spacing ((GtkGrid*) self, (guint) 3);
	_tmp1_ = self->priv->_combo_box;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp1_);
	_tmp2_ = self->priv->_symbol_view;
	_tmp3_ = utils_add_scrollbar ((GtkWidget*) _tmp2_);
	sw = _tmp3_;
	gtk_scrolled_window_set_shadow_type (sw, GTK_SHADOW_IN);
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) sw);
	_tmp4_ = self->priv->_clear_button;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp4_);
	gtk_widget_show_all ((GtkWidget*) self);
	_tmp5_ = self->priv->_combo_box;
	gtk_combo_box_set_active (_tmp5_, 0);
	_g_object_unref0 (sw);
	return self;
}


SymbolsView* symbols_view_new (MainWindow* main_window) {
	return symbols_view_construct (TYPE_SYMBOLS_VIEW, main_window);
}


static Block31Data* block31_data_ref (Block31Data* _data31_) {
	g_atomic_int_inc (&_data31_->_ref_count_);
	return _data31_;
}


static void block31_data_unref (void * _userdata_) {
	Block31Data* _data31_;
	_data31_ = (Block31Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data31_->_ref_count_)) {
		SymbolsView * self;
		self = _data31_->self;
		_g_object_unref0 (_data31_->categories_model);
		_g_object_unref0 (self);
		g_slice_free (Block31Data, _data31_);
	}
}


static void __lambda114_ (Block31Data* _data31_) {
	SymbolsView * self;
	GtkTreeIter iter = {0};
	GtkTreeIter _tmp0_ = {0};
	GtkComboBox* _tmp1_ = NULL;
	GtkTreeIter _tmp2_ = {0};
	gboolean _tmp3_ = FALSE;
	GtkListStore* store = NULL;
	SymbolsCategoryType type = 0;
	GtkTreeIter _tmp4_ = {0};
	GtkIconView* _tmp5_ = NULL;
	SymbolsCategoryType _tmp8_ = 0;
	self = _data31_->self;
	iter = _tmp0_;
	_tmp1_ = self->priv->_combo_box;
	_tmp3_ = gtk_combo_box_get_active_iter (_tmp1_, &_tmp2_);
	iter = _tmp2_;
	if (!_tmp3_) {
		return;
	}
	_tmp4_ = iter;
	gtk_tree_model_get (_data31_->categories_model, &_tmp4_, SYMBOLS_CATEGORY_COLUMN_SYMBOLS_STORE, &store, SYMBOLS_CATEGORY_COLUMN_TYPE, &type, -1);
	_tmp5_ = self->priv->_symbol_view;
	if (_tmp5_ != NULL) {
		GtkIconView* _tmp6_ = NULL;
		GtkListStore* _tmp7_ = NULL;
		_tmp6_ = self->priv->_symbol_view;
		_tmp7_ = store;
		gtk_icon_view_set_model (_tmp6_, (GtkTreeModel*) _tmp7_);
	}
	_tmp8_ = type;
	if (_tmp8_ == SYMBOLS_CATEGORY_TYPE_MOST_USED) {
		GtkButton* _tmp9_ = NULL;
		_tmp9_ = self->priv->_clear_button;
		gtk_widget_show ((GtkWidget*) _tmp9_);
	} else {
		GtkButton* _tmp10_ = NULL;
		_tmp10_ = self->priv->_clear_button;
		gtk_widget_hide ((GtkWidget*) _tmp10_);
	}
	_g_object_unref0 (store);
}


static void ___lambda114__gtk_combo_box_changed (GtkComboBox* _sender, gpointer self) {
	__lambda114_ (self);
}


static void symbols_view_create_combo_box (SymbolsView* self) {
	Block31Data* _data31_;
	Symbols* _tmp0_ = NULL;
	Symbols* _tmp1_ = NULL;
	GtkTreeModel* _tmp2_ = NULL;
	GtkTreeModel* _tmp3_ = NULL;
	GtkComboBox* _tmp4_ = NULL;
	GtkComboBox* _tmp5_ = NULL;
	GtkCellRendererPixbuf* pixbuf_renderer = NULL;
	GtkCellRendererPixbuf* _tmp6_ = NULL;
	GtkComboBox* _tmp7_ = NULL;
	GtkComboBox* _tmp8_ = NULL;
	GtkCellRendererText* text_renderer = NULL;
	GtkCellRendererText* _tmp9_ = NULL;
	GtkComboBox* _tmp10_ = NULL;
	GtkComboBox* _tmp11_ = NULL;
	GtkComboBox* _tmp12_ = NULL;
	g_return_if_fail (self != NULL);
	_data31_ = g_slice_new0 (Block31Data);
	_data31_->_ref_count_ = 1;
	_data31_->self = g_object_ref (self);
	_tmp0_ = symbols_get_default ();
	_tmp1_ = _tmp0_;
	_tmp2_ = symbols_get_categories_model (_tmp1_);
	_tmp3_ = _tmp2_;
	_g_object_unref0 (_tmp1_);
	_data31_->categories_model = _tmp3_;
	_tmp4_ = (GtkComboBox*) gtk_combo_box_new_with_model (_data31_->categories_model);
	g_object_ref_sink (_tmp4_);
	_g_object_unref0 (self->priv->_combo_box);
	self->priv->_combo_box = _tmp4_;
	_tmp5_ = self->priv->_combo_box;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp5_, TRUE);
	_tmp6_ = (GtkCellRendererPixbuf*) gtk_cell_renderer_pixbuf_new ();
	g_object_ref_sink (_tmp6_);
	pixbuf_renderer = _tmp6_;
	_tmp7_ = self->priv->_combo_box;
	gtk_cell_layout_pack_start ((GtkCellLayout*) _tmp7_, (GtkCellRenderer*) pixbuf_renderer, FALSE);
	_tmp8_ = self->priv->_combo_box;
	gtk_cell_layout_set_attributes ((GtkCellLayout*) _tmp8_, (GtkCellRenderer*) pixbuf_renderer, "stock-id", SYMBOLS_CATEGORY_COLUMN_ICON, NULL, NULL);
	_tmp9_ = (GtkCellRendererText*) gtk_cell_renderer_text_new ();
	g_object_ref_sink (_tmp9_);
	text_renderer = _tmp9_;
	g_object_set (text_renderer, "ellipsize-set", TRUE, NULL);
	g_object_set (text_renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
	_tmp10_ = self->priv->_combo_box;
	gtk_cell_layout_pack_start ((GtkCellLayout*) _tmp10_, (GtkCellRenderer*) text_renderer, TRUE);
	_tmp11_ = self->priv->_combo_box;
	gtk_cell_layout_set_attributes ((GtkCellLayout*) _tmp11_, (GtkCellRenderer*) text_renderer, "text", SYMBOLS_CATEGORY_COLUMN_NAME, NULL, NULL);
	_tmp12_ = self->priv->_combo_box;
	g_signal_connect_data (_tmp12_, "changed", (GCallback) ___lambda114__gtk_combo_box_changed, block31_data_ref (_data31_), (GClosureNotify) block31_data_unref, 0);
	_g_object_unref0 (text_renderer);
	_g_object_unref0 (pixbuf_renderer);
	block31_data_unref (_data31_);
	_data31_ = NULL;
}


static gpointer _gtk_tree_path_copy0 (gpointer self) {
	return self ? gtk_tree_path_copy (self) : NULL;
}


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


static const gchar* string_to_string (const gchar* self) {
	const gchar* result = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}


static void _gtk_tree_path_free0_ (gpointer var) {
	(var == NULL) ? NULL : (var = (gtk_tree_path_free (var), NULL));
}


static void _g_list_free__gtk_tree_path_free0_ (GList* self) {
	g_list_foreach (self, (GFunc) _gtk_tree_path_free0_, NULL);
	g_list_free (self);
}


static void __lambda115_ (SymbolsView* self) {
	MainWindow* _tmp0_ = NULL;
	DocumentTab* _tmp1_ = NULL;
	DocumentTab* _tmp2_ = NULL;
	GList* selected_items = NULL;
	GtkIconView* _tmp4_ = NULL;
	GList* _tmp5_ = NULL;
	GtkIconView* _tmp6_ = NULL;
	GtkTreePath* path = NULL;
	GList* _tmp7_ = NULL;
	gconstpointer _tmp8_ = NULL;
	GtkTreePath* _tmp9_ = NULL;
	GtkTreeModel* model = NULL;
	GtkIconView* _tmp10_ = NULL;
	GtkTreeModel* _tmp11_ = NULL;
	GtkTreeModel* _tmp12_ = NULL;
	GtkTreeIter iter = {0};
	GtkTreeIter _tmp13_ = {0};
	gboolean _tmp14_ = FALSE;
	GtkTreePath* _tmp15_ = NULL;
	gboolean _tmp20_ = FALSE;
	_tmp0_ = self->priv->_main_window;
	_tmp1_ = main_window_get_active_tab (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_ == NULL) {
		GtkIconView* _tmp3_ = NULL;
		_tmp3_ = self->priv->_symbol_view;
		g_signal_emit_by_name (_tmp3_, "unselect-all");
		return;
	}
	_tmp4_ = self->priv->_symbol_view;
	_tmp5_ = gtk_icon_view_get_selected_items (_tmp4_);
	selected_items = _tmp5_;
	_tmp6_ = self->priv->_symbol_view;
	g_signal_emit_by_name (_tmp6_, "unselect-all");
	_tmp7_ = selected_items;
	_tmp8_ = g_list_nth_data (_tmp7_, (guint) 0);
	_tmp9_ = _gtk_tree_path_copy0 ((GtkTreePath*) _tmp8_);
	path = _tmp9_;
	_tmp10_ = self->priv->_symbol_view;
	_tmp11_ = gtk_icon_view_get_model (_tmp10_);
	_tmp12_ = _g_object_ref0 (_tmp11_);
	model = _tmp12_;
	iter = _tmp13_;
	_tmp15_ = path;
	if (_tmp15_ != NULL) {
		GtkTreeModel* _tmp16_ = NULL;
		GtkTreePath* _tmp17_ = NULL;
		GtkTreeIter _tmp18_ = {0};
		gboolean _tmp19_ = FALSE;
		_tmp16_ = model;
		_tmp17_ = path;
		_tmp19_ = gtk_tree_model_get_iter (_tmp16_, &_tmp18_, _tmp17_);
		iter = _tmp18_;
		_tmp14_ = _tmp19_;
	} else {
		_tmp14_ = FALSE;
	}
	_tmp20_ = _tmp14_;
	if (_tmp20_) {
		gchar* latex_command = NULL;
		gchar* id = NULL;
		GtkTreeModel* _tmp21_ = NULL;
		GtkTreeIter _tmp22_ = {0};
		MainWindow* _tmp23_ = NULL;
		Document* _tmp24_ = NULL;
		Document* _tmp25_ = NULL;
		MainWindow* _tmp26_ = NULL;
		Document* _tmp27_ = NULL;
		Document* _tmp28_ = NULL;
		const gchar* _tmp29_ = NULL;
		const gchar* _tmp30_ = NULL;
		gchar* _tmp31_ = NULL;
		gchar* _tmp32_ = NULL;
		MainWindow* _tmp33_ = NULL;
		Document* _tmp34_ = NULL;
		Document* _tmp35_ = NULL;
		MainWindow* _tmp36_ = NULL;
		DocumentView* _tmp37_ = NULL;
		DocumentView* _tmp38_ = NULL;
		MostUsedSymbols* _tmp39_ = NULL;
		MostUsedSymbols* _tmp40_ = NULL;
		const gchar* _tmp41_ = NULL;
		_tmp21_ = model;
		_tmp22_ = iter;
		gtk_tree_model_get (_tmp21_, &_tmp22_, SYMBOL_COLUMN_COMMAND, &latex_command, SYMBOL_COLUMN_ID, &id, -1);
		_tmp23_ = self->priv->_main_window;
		_tmp24_ = main_window_get_active_document (_tmp23_);
		_tmp25_ = _tmp24_;
		gtk_text_buffer_begin_user_action ((GtkTextBuffer*) _tmp25_);
		_tmp26_ = self->priv->_main_window;
		_tmp27_ = main_window_get_active_document (_tmp26_);
		_tmp28_ = _tmp27_;
		_tmp29_ = latex_command;
		_tmp30_ = string_to_string (_tmp29_);
		_tmp31_ = g_strconcat (_tmp30_, " ", NULL);
		_tmp32_ = _tmp31_;
		gtk_text_buffer_insert_at_cursor ((GtkTextBuffer*) _tmp28_, _tmp32_, -1);
		_g_free0 (_tmp32_);
		_tmp33_ = self->priv->_main_window;
		_tmp34_ = main_window_get_active_document (_tmp33_);
		_tmp35_ = _tmp34_;
		gtk_text_buffer_end_user_action ((GtkTextBuffer*) _tmp35_);
		_tmp36_ = self->priv->_main_window;
		_tmp37_ = main_window_get_active_view (_tmp36_);
		_tmp38_ = _tmp37_;
		gtk_widget_grab_focus ((GtkWidget*) _tmp38_);
		_tmp39_ = most_used_symbols_get_default ();
		_tmp40_ = _tmp39_;
		_tmp41_ = id;
		most_used_symbols_increment_symbol (_tmp40_, _tmp41_);
		_g_object_unref0 (_tmp40_);
		_g_free0 (id);
		_g_free0 (latex_command);
	}
	_g_object_unref0 (model);
	_gtk_tree_path_free0 (path);
	__g_list_free__gtk_tree_path_free0_0 (selected_items);
}


static void ___lambda115__gtk_icon_view_selection_changed (GtkIconView* _sender, gpointer self) {
	__lambda115_ (self);
}


static void symbols_view_create_icon_view (SymbolsView* self) {
	GtkIconView* _tmp0_ = NULL;
	GtkIconView* _tmp1_ = NULL;
	GtkIconView* _tmp2_ = NULL;
	GtkIconView* _tmp3_ = NULL;
	GtkIconView* _tmp4_ = NULL;
	GtkIconView* _tmp5_ = NULL;
	GtkIconView* _tmp6_ = NULL;
	GtkIconView* _tmp7_ = NULL;
	GtkIconView* _tmp8_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = (GtkIconView*) gtk_icon_view_new ();
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->_symbol_view);
	self->priv->_symbol_view = _tmp0_;
	_tmp1_ = self->priv->_symbol_view;
	gtk_icon_view_set_pixbuf_column (_tmp1_, (gint) SYMBOL_COLUMN_PIXBUF);
	_tmp2_ = self->priv->_symbol_view;
	gtk_icon_view_set_tooltip_column (_tmp2_, (gint) SYMBOL_COLUMN_TOOLTIP);
	_tmp3_ = self->priv->_symbol_view;
	gtk_icon_view_set_selection_mode (_tmp3_, GTK_SELECTION_SINGLE);
	_tmp4_ = self->priv->_symbol_view;
	gtk_icon_view_set_spacing (_tmp4_, 0);
	_tmp5_ = self->priv->_symbol_view;
	gtk_icon_view_set_row_spacing (_tmp5_, 0);
	_tmp6_ = self->priv->_symbol_view;
	gtk_icon_view_set_column_spacing (_tmp6_, 0);
	_tmp7_ = self->priv->_symbol_view;
	g_object_set ((GtkWidget*) _tmp7_, "expand", TRUE, NULL);
	_tmp8_ = self->priv->_symbol_view;
	g_signal_connect_object (_tmp8_, "selection-changed", (GCallback) ___lambda115__gtk_icon_view_selection_changed, self, 0);
}


static void __lambda116_ (SymbolsView* self) {
	MostUsedSymbols* _tmp0_ = NULL;
	MostUsedSymbols* _tmp1_ = NULL;
	_tmp0_ = most_used_symbols_get_default ();
	_tmp1_ = _tmp0_;
	most_used_symbols_clear (_tmp1_);
	_g_object_unref0 (_tmp1_);
}


static void ___lambda116__gtk_button_clicked (GtkButton* _sender, gpointer self) {
	__lambda116_ (self);
}


static void symbols_view_create_clear_button (SymbolsView* self) {
	GtkButton* _tmp0_ = NULL;
	GtkButton* _tmp1_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = (GtkButton*) gtk_button_new_from_stock (GTK_STOCK_CLEAR);
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->_clear_button);
	self->priv->_clear_button = _tmp0_;
	_tmp1_ = self->priv->_clear_button;
	g_signal_connect_object (_tmp1_, "clicked", (GCallback) ___lambda116__gtk_button_clicked, self, 0);
}


static void symbols_view_class_init (SymbolsViewClass * klass) {
	symbols_view_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (SymbolsViewPrivate));
	G_OBJECT_CLASS (klass)->finalize = symbols_view_finalize;
}


static void symbols_view_instance_init (SymbolsView * self) {
	self->priv = SYMBOLS_VIEW_GET_PRIVATE (self);
}


static void symbols_view_finalize (GObject* obj) {
	SymbolsView * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_SYMBOLS_VIEW, SymbolsView);
	_g_object_unref0 (self->priv->_combo_box);
	_g_object_unref0 (self->priv->_symbol_view);
	_g_object_unref0 (self->priv->_clear_button);
	G_OBJECT_CLASS (symbols_view_parent_class)->finalize (obj);
}


GType symbols_view_get_type (void) {
	static volatile gsize symbols_view_type_id__volatile = 0;
	if (g_once_init_enter (&symbols_view_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (SymbolsViewClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) symbols_view_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SymbolsView), 0, (GInstanceInitFunc) symbols_view_instance_init, NULL };
		GType symbols_view_type_id;
		symbols_view_type_id = g_type_register_static (GTK_TYPE_GRID, "SymbolsView", &g_define_type_info, 0);
		g_once_init_leave (&symbols_view_type_id__volatile, symbols_view_type_id);
	}
	return symbols_view_type_id__volatile;
}



