/* symbols_view.c generated by valac 0.18.0.1-c1117, 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 _Block34Data Block34Data;

#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 _Block34Data {
	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 Block34Data* block34_data_ref (Block34Data* _data34_);
static void block34_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 __lambda121_ (Block34Data* _data34_);
GType symbols_category_type_get_type (void) G_GNUC_CONST;
static void ___lambda121__gtk_combo_box_changed (GtkComboBox* _sender, gpointer self);
GType symbol_column_get_type (void) G_GNUC_CONST;
static void __lambda122_ (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 ___lambda122__gtk_icon_view_selection_changed (GtkIconView* _sender, gpointer self);
static void __lambda123_ (SymbolsView* self);
void most_used_symbols_clear (MostUsedSymbols* self);
static void ___lambda123__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_;
	GtkComboBox* _tmp1_;
	GtkIconView* _tmp2_;
	GtkScrolledWindow* _tmp3_ = NULL;
	GtkScrolledWindow* sw;
	GtkButton* _tmp4_;
	GtkComboBox* _tmp5_;
	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 Block34Data* block34_data_ref (Block34Data* _data34_) {
	g_atomic_int_inc (&_data34_->_ref_count_);
	return _data34_;
}


static void block34_data_unref (void * _userdata_) {
	Block34Data* _data34_;
	_data34_ = (Block34Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data34_->_ref_count_)) {
		SymbolsView * self;
		self = _data34_->self;
		_g_object_unref0 (_data34_->categories_model);
		_g_object_unref0 (self);
		g_slice_free (Block34Data, _data34_);
	}
}


static void __lambda121_ (Block34Data* _data34_) {
	SymbolsView * self;
	GtkTreeIter _tmp0_ = {0};
	GtkTreeIter iter;
	GtkComboBox* _tmp1_;
	GtkTreeIter _tmp2_ = {0};
	gboolean _tmp3_ = FALSE;
	GtkListStore* store = NULL;
	SymbolsCategoryType type = 0;
	GtkTreeIter _tmp4_;
	GtkIconView* _tmp5_;
	SymbolsCategoryType _tmp8_;
	self = _data34_->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 (_data34_->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_;
		GtkListStore* _tmp7_;
		_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_;
		_tmp9_ = self->priv->_clear_button;
		gtk_widget_show ((GtkWidget*) _tmp9_);
	} else {
		GtkButton* _tmp10_;
		_tmp10_ = self->priv->_clear_button;
		gtk_widget_hide ((GtkWidget*) _tmp10_);
	}
	_g_object_unref0 (store);
}


static void ___lambda121__gtk_combo_box_changed (GtkComboBox* _sender, gpointer self) {
	__lambda121_ (self);
}


static void symbols_view_create_combo_box (SymbolsView* self) {
	Block34Data* _data34_;
	Symbols* _tmp0_ = NULL;
	Symbols* _tmp1_;
	GtkTreeModel* _tmp2_ = NULL;
	GtkTreeModel* _tmp3_;
	GtkComboBox* _tmp4_;
	GtkComboBox* _tmp5_;
	GtkCellRendererPixbuf* _tmp6_;
	GtkCellRendererPixbuf* pixbuf_renderer;
	GtkComboBox* _tmp7_;
	GtkComboBox* _tmp8_;
	GtkCellRendererText* _tmp9_;
	GtkCellRendererText* text_renderer;
	GtkComboBox* _tmp10_;
	GtkComboBox* _tmp11_;
	GtkComboBox* _tmp12_;
	g_return_if_fail (self != NULL);
	_data34_ = g_slice_new0 (Block34Data);
	_data34_->_ref_count_ = 1;
	_data34_->self = g_object_ref (self);
	_tmp0_ = symbols_get_default ();
	_tmp1_ = _tmp0_;
	_tmp2_ = symbols_get_categories_model (_tmp1_);
	_tmp3_ = _tmp2_;
	_g_object_unref0 (_tmp1_);
	_data34_->categories_model = _tmp3_;
	_tmp4_ = (GtkComboBox*) gtk_combo_box_new_with_model (_data34_->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) ___lambda121__gtk_combo_box_changed, block34_data_ref (_data34_), (GClosureNotify) block34_data_unref, 0);
	_g_object_unref0 (text_renderer);
	_g_object_unref0 (pixbuf_renderer);
	block34_data_unref (_data34_);
	_data34_ = 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 __lambda122_ (SymbolsView* self) {
	MainWindow* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentTab* _tmp2_;
	GtkIconView* _tmp4_;
	GList* _tmp5_ = NULL;
	GList* selected_items;
	GtkIconView* _tmp6_;
	GList* _tmp7_;
	gconstpointer _tmp8_ = NULL;
	GtkTreePath* _tmp9_;
	GtkTreePath* path;
	GtkIconView* _tmp10_;
	GtkTreeModel* _tmp11_ = NULL;
	GtkTreeModel* _tmp12_;
	GtkTreeModel* model;
	GtkTreeIter _tmp13_ = {0};
	GtkTreeIter iter;
	gboolean _tmp14_ = FALSE;
	GtkTreePath* _tmp15_;
	gboolean _tmp20_;
	_tmp0_ = self->priv->_main_window;
	_tmp1_ = main_window_get_active_tab (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_ == NULL) {
		GtkIconView* _tmp3_;
		_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_;
		GtkTreePath* _tmp17_;
		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_;
		GtkTreeIter _tmp22_;
		MainWindow* _tmp23_;
		Document* _tmp24_;
		Document* _tmp25_;
		MainWindow* _tmp26_;
		Document* _tmp27_;
		Document* _tmp28_;
		const gchar* _tmp29_;
		const gchar* _tmp30_ = NULL;
		gchar* _tmp31_ = NULL;
		gchar* _tmp32_;
		MainWindow* _tmp33_;
		Document* _tmp34_;
		Document* _tmp35_;
		MainWindow* _tmp36_;
		DocumentView* _tmp37_;
		DocumentView* _tmp38_;
		MostUsedSymbols* _tmp39_ = NULL;
		MostUsedSymbols* _tmp40_;
		const gchar* _tmp41_;
		_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 ___lambda122__gtk_icon_view_selection_changed (GtkIconView* _sender, gpointer self) {
	__lambda122_ (self);
}


static void symbols_view_create_icon_view (SymbolsView* self) {
	GtkIconView* _tmp0_;
	GtkIconView* _tmp1_;
	GtkIconView* _tmp2_;
	GtkIconView* _tmp3_;
	GtkIconView* _tmp4_;
	GtkIconView* _tmp5_;
	GtkIconView* _tmp6_;
	GtkIconView* _tmp7_;
	GtkIconView* _tmp8_;
	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) ___lambda122__gtk_icon_view_selection_changed, self, 0);
}


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


static void ___lambda123__gtk_button_clicked (GtkButton* _sender, gpointer self) {
	__lambda123_ (self);
}


static void symbols_view_create_clear_button (SymbolsView* self) {
	GtkButton* _tmp0_;
	GtkButton* _tmp1_;
	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) ___lambda123__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;
}



