/* symbols_view.c generated by valac 0.36.5, 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 <tepl/tepl.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.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 _Block33Data Block33Data;

#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 _Block33Data {
	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 Block33Data* block33_data_ref (Block33Data* _data33_);
static void block33_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 __lambda72_ (Block33Data* _data33_);
GType symbols_category_type_get_type (void) G_GNUC_CONST;
static void ___lambda72__gtk_combo_box_changed (GtkComboBox* _sender, gpointer self);
GType symbol_column_get_type (void) G_GNUC_CONST;
static void __lambda73_ (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 ___lambda73__gtk_icon_view_selection_changed (GtkIconView* _sender, gpointer self);
static void __lambda74_ (SymbolsView* self);
void most_used_symbols_clear (MostUsedSymbols* self);
static void ___lambda74__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_;
	GtkScrolledWindow* sw = NULL;
	GtkIconView* _tmp2_;
	GtkScrolledWindow* _tmp3_;
	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 Block33Data* block33_data_ref (Block33Data* _data33_) {
	g_atomic_int_inc (&_data33_->_ref_count_);
	return _data33_;
}


static void block33_data_unref (void * _userdata_) {
	Block33Data* _data33_;
	_data33_ = (Block33Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data33_->_ref_count_)) {
		SymbolsView* self;
		self = _data33_->self;
		_g_object_unref0 (_data33_->categories_model);
		_g_object_unref0 (self);
		g_slice_free (Block33Data, _data33_);
	}
}


static void __lambda72_ (Block33Data* _data33_) {
	SymbolsView* self;
	GtkTreeIter iter = {0};
	GtkTreeIter _tmp0_ = {0};
	GtkComboBox* _tmp1_;
	GtkTreeIter _tmp2_ = {0};
	gboolean _tmp3_;
	GtkListStore* store = NULL;
	SymbolsCategoryType type = 0;
	GtkTreeIter _tmp4_;
	GtkIconView* _tmp5_;
	SymbolsCategoryType _tmp8_;
	self = _data33_->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 (_data33_->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 ___lambda72__gtk_combo_box_changed (GtkComboBox* _sender, gpointer self) {
	__lambda72_ (self);
}


static void symbols_view_create_combo_box (SymbolsView* self) {
	Block33Data* _data33_;
	Symbols* _tmp0_;
	Symbols* _tmp1_;
	GtkTreeModel* _tmp2_;
	GtkTreeModel* _tmp3_;
	GtkComboBox* _tmp4_;
	GtkComboBox* _tmp5_;
	GtkComboBox* _tmp6_;
	GtkCellRendererPixbuf* pixbuf_renderer = NULL;
	GtkCellRendererPixbuf* _tmp7_;
	GtkComboBox* _tmp8_;
	GtkComboBox* _tmp9_;
	GtkCellRendererText* text_renderer = NULL;
	GtkCellRendererText* _tmp10_;
	GtkComboBox* _tmp11_;
	GtkComboBox* _tmp12_;
	GtkComboBox* _tmp13_;
	g_return_if_fail (self != NULL);
	_data33_ = g_slice_new0 (Block33Data);
	_data33_->_ref_count_ = 1;
	_data33_->self = g_object_ref (self);
	_tmp0_ = symbols_get_default ();
	_tmp1_ = _tmp0_;
	_tmp2_ = symbols_get_categories_model (_tmp1_);
	_tmp3_ = _tmp2_;
	_g_object_unref0 (_tmp1_);
	_data33_->categories_model = _tmp3_;
	_tmp4_ = (GtkComboBox*) gtk_combo_box_new_with_model (_data33_->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_ = self->priv->_combo_box;
	gtk_widget_set_margin_end ((GtkWidget*) _tmp6_, 3);
	_tmp7_ = (GtkCellRendererPixbuf*) gtk_cell_renderer_pixbuf_new ();
	g_object_ref_sink (_tmp7_);
	pixbuf_renderer = _tmp7_;
	_tmp8_ = self->priv->_combo_box;
	gtk_cell_layout_pack_start ((GtkCellLayout*) _tmp8_, (GtkCellRenderer*) pixbuf_renderer, FALSE);
	_tmp9_ = self->priv->_combo_box;
	gtk_cell_layout_set_attributes ((GtkCellLayout*) _tmp9_, (GtkCellRenderer*) pixbuf_renderer, "icon-name", SYMBOLS_CATEGORY_COLUMN_ICON, NULL, NULL);
	_tmp10_ = (GtkCellRendererText*) gtk_cell_renderer_text_new ();
	g_object_ref_sink (_tmp10_);
	text_renderer = _tmp10_;
	g_object_set (text_renderer, "ellipsize-set", TRUE, NULL);
	g_object_set (text_renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
	_tmp11_ = self->priv->_combo_box;
	gtk_cell_layout_pack_start ((GtkCellLayout*) _tmp11_, (GtkCellRenderer*) text_renderer, TRUE);
	_tmp12_ = self->priv->_combo_box;
	gtk_cell_layout_set_attributes ((GtkCellLayout*) _tmp12_, (GtkCellRenderer*) text_renderer, "text", SYMBOLS_CATEGORY_COLUMN_NAME, NULL, NULL);
	_tmp13_ = self->priv->_combo_box;
	g_signal_connect_data (_tmp13_, "changed", (GCallback) ___lambda72__gtk_combo_box_changed, block33_data_ref (_data33_), (GClosureNotify) block33_data_unref, 0);
	_g_object_unref0 (text_renderer);
	_g_object_unref0 (pixbuf_renderer);
	block33_data_unref (_data33_);
	_data33_ = 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 __lambda73_ (SymbolsView* self) {
	MainWindow* _tmp0_;
	DocumentTab* _tmp1_;
	DocumentTab* _tmp2_;
	GList* selected_items = NULL;
	GtkIconView* _tmp4_;
	GList* _tmp5_;
	GtkIconView* _tmp6_;
	GtkTreePath* path = NULL;
	GList* _tmp7_;
	gconstpointer _tmp8_;
	GtkTreePath* _tmp9_;
	GtkTreeModel* model = NULL;
	GtkIconView* _tmp10_;
	GtkTreeModel* _tmp11_;
	GtkTreeModel* _tmp12_;
	GtkTreeIter iter = {0};
	GtkTreeIter _tmp13_ = {0};
	gboolean _tmp14_ = FALSE;
	GtkTreePath* _tmp15_;
	_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_;
		_tmp16_ = model;
		_tmp17_ = path;
		_tmp19_ = gtk_tree_model_get_iter (_tmp16_, &_tmp18_, _tmp17_);
		iter = _tmp18_;
		_tmp14_ = _tmp19_;
	} else {
		_tmp14_ = FALSE;
	}
	if (_tmp14_) {
		gchar* latex_command = NULL;
		gchar* id = NULL;
		GtkTreeModel* _tmp20_;
		GtkTreeIter _tmp21_;
		MainWindow* _tmp22_;
		Document* _tmp23_;
		Document* _tmp24_;
		MainWindow* _tmp25_;
		Document* _tmp26_;
		Document* _tmp27_;
		const gchar* _tmp28_;
		const gchar* _tmp29_;
		gchar* _tmp30_;
		gchar* _tmp31_;
		MainWindow* _tmp32_;
		Document* _tmp33_;
		Document* _tmp34_;
		MainWindow* _tmp35_;
		DocumentView* _tmp36_;
		DocumentView* _tmp37_;
		MostUsedSymbols* _tmp38_;
		MostUsedSymbols* _tmp39_;
		const gchar* _tmp40_;
		_tmp20_ = model;
		_tmp21_ = iter;
		gtk_tree_model_get (_tmp20_, &_tmp21_, SYMBOL_COLUMN_COMMAND, &latex_command, SYMBOL_COLUMN_ID, &id, -1);
		_tmp22_ = self->priv->_main_window;
		_tmp23_ = main_window_get_active_document (_tmp22_);
		_tmp24_ = _tmp23_;
		gtk_text_buffer_begin_user_action ((GtkTextBuffer*) _tmp24_);
		_tmp25_ = self->priv->_main_window;
		_tmp26_ = main_window_get_active_document (_tmp25_);
		_tmp27_ = _tmp26_;
		_tmp28_ = latex_command;
		_tmp29_ = string_to_string (_tmp28_);
		_tmp30_ = g_strconcat (_tmp29_, " ", NULL);
		_tmp31_ = _tmp30_;
		gtk_text_buffer_insert_at_cursor ((GtkTextBuffer*) _tmp27_, _tmp31_, -1);
		_g_free0 (_tmp31_);
		_tmp32_ = self->priv->_main_window;
		_tmp33_ = main_window_get_active_document (_tmp32_);
		_tmp34_ = _tmp33_;
		gtk_text_buffer_end_user_action ((GtkTextBuffer*) _tmp34_);
		_tmp35_ = self->priv->_main_window;
		_tmp36_ = main_window_get_active_view (_tmp35_);
		_tmp37_ = _tmp36_;
		gtk_widget_grab_focus ((GtkWidget*) _tmp37_);
		_tmp38_ = most_used_symbols_get_default ();
		_tmp39_ = _tmp38_;
		_tmp40_ = id;
		most_used_symbols_increment_symbol (_tmp39_, _tmp40_);
		_g_object_unref0 (_tmp39_);
		_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 ___lambda73__gtk_icon_view_selection_changed (GtkIconView* _sender, gpointer self) {
	__lambda73_ ((SymbolsView*) 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) ___lambda73__gtk_icon_view_selection_changed, self, 0);
}


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


static void ___lambda74__gtk_button_clicked (GtkButton* _sender, gpointer self) {
	__lambda74_ ((SymbolsView*) self);
}


static void symbols_view_create_clear_button (SymbolsView* self) {
	GtkButton* _tmp0_;
	GtkButton* _tmp1_;
	GtkButton* _tmp2_;
	GtkButton* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = (GtkButton*) gtk_button_new_with_mnemonic (_ ("_Clear"));
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->_clear_button);
	self->priv->_clear_button = _tmp0_;
	_tmp1_ = self->priv->_clear_button;
	gtk_widget_set_margin_end ((GtkWidget*) _tmp1_, 3);
	_tmp2_ = self->priv->_clear_button;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp2_, _ ("Clear most used symbols"));
	_tmp3_ = self->priv->_clear_button;
	g_signal_connect_object (_tmp3_, "clicked", (GCallback) ___lambda74__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_grid_get_type (), "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;
}



