/* PreferencesDialog.c generated by valac 0.54.3, the Vala compiler
 * generated from PreferencesDialog.vala, do not modify */

/*
 *  Copyright (C) 2009-2010 Michael J. Chudobiak.
 *
 *  This file is part of moserial.
 *
 *  moserial 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.
 *
 *  moserial 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 moserial.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <glib-object.h>
#include <gtk/gtk.h>
#include <glib.h>
#include <config.h>
#include <glib/gi18n-lib.h>
#include <float.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <gdk/gdk.h>

#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define MOSERIAL_TYPE_PREFERENCES_DIALOG (moserial_preferences_dialog_get_type ())
#define MOSERIAL_PREFERENCES_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MOSERIAL_TYPE_PREFERENCES_DIALOG, moserialPreferencesDialog))
#define MOSERIAL_PREFERENCES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MOSERIAL_TYPE_PREFERENCES_DIALOG, moserialPreferencesDialogClass))
#define MOSERIAL_IS_PREFERENCES_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MOSERIAL_TYPE_PREFERENCES_DIALOG))
#define MOSERIAL_IS_PREFERENCES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MOSERIAL_TYPE_PREFERENCES_DIALOG))
#define MOSERIAL_PREFERENCES_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MOSERIAL_TYPE_PREFERENCES_DIALOG, moserialPreferencesDialogClass))

typedef struct _moserialPreferencesDialog moserialPreferencesDialog;
typedef struct _moserialPreferencesDialogClass moserialPreferencesDialogClass;
typedef struct _moserialPreferencesDialogPrivate moserialPreferencesDialogPrivate;
enum  {
	MOSERIAL_PREFERENCES_DIALOG_0_PROPERTY,
	MOSERIAL_PREFERENCES_DIALOG_NUM_PROPERTIES
};
static GParamSpec* moserial_preferences_dialog_properties[MOSERIAL_PREFERENCES_DIALOG_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef enum  {
	MOSERIAL_SERIAL_STREAM_RECORDER_DIRECTION_INCOMING,
	MOSERIAL_SERIAL_STREAM_RECORDER_DIRECTION_OUTGOING,
	MOSERIAL_SERIAL_STREAM_RECORDER_DIRECTION_BOTH
} moserialSerialStreamRecorderDirection;

#define MOSERIAL_SERIAL_STREAM_RECORDER_TYPE_DIRECTION (moserial_serial_stream_recorder_direction_get_type ())
#define _g_free0(var) (var = (g_free (var), NULL))

#define TYPE_PREFERENCES (preferences_get_type ())
#define PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PREFERENCES, Preferences))
#define PREFERENCES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PREFERENCES, PreferencesClass))
#define IS_PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PREFERENCES))
#define IS_PREFERENCES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PREFERENCES))
#define PREFERENCES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PREFERENCES, PreferencesClass))

typedef struct _Preferences Preferences;
typedef struct _PreferencesClass PreferencesClass;
enum  {
	MOSERIAL_PREFERENCES_DIALOG_UPDATE_PREFERENCES_SIGNAL,
	MOSERIAL_PREFERENCES_DIALOG_NUM_SIGNALS
};
static guint moserial_preferences_dialog_signals[MOSERIAL_PREFERENCES_DIALOG_NUM_SIGNALS] = {0};

struct _moserialPreferencesDialog {
	GObject parent_instance;
	moserialPreferencesDialogPrivate * priv;
};

struct _moserialPreferencesDialogClass {
	GObjectClass parent_class;
};

struct _moserialPreferencesDialogPrivate {
	GtkDialog* dialog;
	GtkButton* cancelButton;
	GtkButton* okButton;
	GtkCheckButton* systemFont;
	GtkFontButton* fontButton;
	GtkColorButton* fontColorButton;
	GtkColorButton* backgroundColorButton;
	GtkColorButton* highlightColorButton;
	GtkCheckButton* recordLaunch;
	GtkCheckButton* enableTimeout;
	GtkSpinButton* timeout;
	GtkCheckButton* recordAutoName;
	GtkComboBox* recordAutoDirection;
	GtkEntry* recordAutoExtension;
	GtkWidget* recordAutoFolder;
};

static gint moserialPreferencesDialog_private_offset;
static gpointer moserial_preferences_dialog_parent_class = NULL;

VALA_EXTERN GType moserial_preferences_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (moserialPreferencesDialog, g_object_unref)
VALA_EXTERN moserialPreferencesDialog* moserial_preferences_dialog_new (GtkWindow* parent);
VALA_EXTERN moserialPreferencesDialog* moserial_preferences_dialog_construct (GType object_type,
                                                                  GtkWindow* parent);
VALA_EXTERN void moserial_preferences_dialog_recordAutoToggled (moserialPreferencesDialog* self,
                                                    GtkToggleButton* button);
static void _moserial_preferences_dialog_recordAutoToggled_gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                                                               gpointer self);
VALA_EXTERN void mo_utils_populateComboBox (GtkComboBox* Combo,
                                gchar** val_array,
                                gint val_array_length1,
                                gboolean render_cell);
VALA_EXTERN GType moserial_serial_stream_recorder_direction_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void moserial_preferences_dialog_systemFontToggled (moserialPreferencesDialog* self,
                                                    GtkToggleButton* button);
static void _moserial_preferences_dialog_systemFontToggled_gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                                                               gpointer self);
VALA_EXTERN void moserial_preferences_dialog_enableTimeoutToggled (moserialPreferencesDialog* self,
                                                       GtkToggleButton* button);
static void _moserial_preferences_dialog_enableTimeoutToggled_gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                                                                  gpointer self);
VALA_EXTERN void moserial_preferences_dialog_ok (moserialPreferencesDialog* self,
                                     GtkButton* button);
static void _moserial_preferences_dialog_ok_gtk_button_clicked (GtkButton* _sender,
                                                         gpointer self);
VALA_EXTERN void moserial_preferences_dialog_cancel (moserialPreferencesDialog* self,
                                         GtkButton* button);
static void _moserial_preferences_dialog_cancel_gtk_button_clicked (GtkButton* _sender,
                                                             gpointer self);
VALA_EXTERN gboolean moserial_preferences_dialog_hide (moserialPreferencesDialog* self);
static gboolean _moserial_preferences_dialog_hide_gtk_widget_delete_event (GtkWidget* _sender,
                                                                    GdkEventAny* event,
                                                                    gpointer self);
VALA_EXTERN GType preferences_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Preferences, g_object_unref)
VALA_EXTERN Preferences* preferences_new (gboolean useSystemMonospaceFont,
                              const gchar* font,
                              const gchar* fontColor,
                              const gchar* backgroundColor,
                              const gchar* highlightColor,
                              gboolean recordLaunch,
                              gboolean enableTimeout,
                              gint timeout,
                              gboolean recordAutoName,
                              gint recordAutoDirection,
                              const gchar* recordAutoExtension,
                              const gchar* recordAutoFolder);
VALA_EXTERN Preferences* preferences_construct (GType object_type,
                                    gboolean useSystemMonospaceFont,
                                    const gchar* font,
                                    const gchar* fontColor,
                                    const gchar* backgroundColor,
                                    const gchar* highlightColor,
                                    gboolean recordLaunch,
                                    gboolean enableTimeout,
                                    gint timeout,
                                    gboolean recordAutoName,
                                    gint recordAutoDirection,
                                    const gchar* recordAutoExtension,
                                    const gchar* recordAutoFolder);
VALA_EXTERN void moserial_preferences_dialog_show (moserialPreferencesDialog* self,
                                       Preferences* preferences,
                                       gboolean recording);
VALA_EXTERN gboolean preferences_get_useSystemMonospaceFont (Preferences* self);
VALA_EXTERN const gchar* preferences_get_font (Preferences* self);
VALA_EXTERN void preferences_getGdkRGBA (const gchar* color,
                             GdkRGBA* result);
VALA_EXTERN const gchar* preferences_get_fontColor (Preferences* self);
VALA_EXTERN const gchar* preferences_get_backgroundColor (Preferences* self);
VALA_EXTERN const gchar* preferences_get_highlightColor (Preferences* self);
VALA_EXTERN gboolean preferences_get_recordLaunch (Preferences* self);
VALA_EXTERN gboolean preferences_get_enableTimeout (Preferences* self);
VALA_EXTERN gint preferences_get_timeout (Preferences* self);
VALA_EXTERN gboolean preferences_get_recordAutoName (Preferences* self);
VALA_EXTERN gint preferences_get_recordAutoDirection (Preferences* self);
VALA_EXTERN const gchar* preferences_get_recordAutoExtension (Preferences* self);
VALA_EXTERN const gchar* preferences_get_recordAutoFolder (Preferences* self);
static void moserial_preferences_dialog_finalize (GObject * obj);
static GType moserial_preferences_dialog_get_type_once (void);

VALA_EXTERN const gchar* MOSERIAL_SERIAL_STREAM_RECORDER_DirectionStrings[3];

static inline gpointer
moserial_preferences_dialog_get_instance_private (moserialPreferencesDialog* self)
{
	return G_STRUCT_MEMBER_P (self, moserialPreferencesDialog_private_offset);
}

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

static void
_moserial_preferences_dialog_recordAutoToggled_gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                                                          gpointer self)
{
	moserial_preferences_dialog_recordAutoToggled ((moserialPreferencesDialog*) self, _sender);
}

static void
_moserial_preferences_dialog_systemFontToggled_gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                                                          gpointer self)
{
	moserial_preferences_dialog_systemFontToggled ((moserialPreferencesDialog*) self, _sender);
}

static void
_moserial_preferences_dialog_enableTimeoutToggled_gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                                                             gpointer self)
{
	moserial_preferences_dialog_enableTimeoutToggled ((moserialPreferencesDialog*) self, _sender);
}

static void
_moserial_preferences_dialog_ok_gtk_button_clicked (GtkButton* _sender,
                                                    gpointer self)
{
	moserial_preferences_dialog_ok ((moserialPreferencesDialog*) self, _sender);
}

static void
_moserial_preferences_dialog_cancel_gtk_button_clicked (GtkButton* _sender,
                                                        gpointer self)
{
	moserial_preferences_dialog_cancel ((moserialPreferencesDialog*) self, _sender);
}

static gboolean
_moserial_preferences_dialog_hide_gtk_widget_delete_event (GtkWidget* _sender,
                                                           GdkEventAny* event,
                                                           gpointer self)
{
	gboolean result;
	result = moserial_preferences_dialog_hide ((moserialPreferencesDialog*) self);
	return result;
}

moserialPreferencesDialog*
moserial_preferences_dialog_construct (GType object_type,
                                       GtkWindow* parent)
{
	moserialPreferencesDialog * self = NULL;
	GtkBuilder* builder = NULL;
	GtkBuilder* _tmp0_;
	GObject* _tmp1_;
	GtkDialog* _tmp2_;
	GtkDialog* _tmp3_;
	GObject* _tmp4_;
	GtkButton* _tmp5_;
	GObject* _tmp6_;
	GtkButton* _tmp7_;
	GObject* _tmp8_;
	GtkCheckButton* _tmp9_;
	GObject* _tmp10_;
	GtkFontButton* _tmp11_;
	GObject* _tmp12_;
	GtkColorButton* _tmp13_;
	GObject* _tmp14_;
	GtkColorButton* _tmp15_;
	GObject* _tmp16_;
	GtkColorButton* _tmp17_;
	GObject* _tmp18_;
	GtkCheckButton* _tmp19_;
	GtkCheckButton* _tmp20_;
	GObject* _tmp21_;
	GtkCheckButton* _tmp22_;
	GtkCheckButton* _tmp23_;
	GObject* _tmp24_;
	GtkSpinButton* _tmp25_;
	GtkSpinButton* _tmp26_;
	GtkAdjustment* _tmp27_;
	GtkAdjustment* _tmp28_;
	GtkSpinButton* _tmp29_;
	GtkAdjustment* _tmp30_;
	GtkAdjustment* _tmp31_;
	GtkSpinButton* _tmp32_;
	GtkAdjustment* _tmp33_;
	GtkAdjustment* _tmp34_;
	GtkSpinButton* _tmp35_;
	GtkAdjustment* _tmp36_;
	GtkAdjustment* _tmp37_;
	GObject* _tmp38_;
	GtkCheckButton* _tmp39_;
	GtkCheckButton* _tmp40_;
	GObject* _tmp41_;
	GtkComboBox* _tmp42_;
	GtkComboBox* _tmp43_;
	GtkComboBox* _tmp44_;
	GObject* _tmp45_;
	GtkEntry* _tmp46_;
	GObject* _tmp47_;
	GtkWidget* _tmp48_;
	GtkCheckButton* _tmp49_;
	GtkCheckButton* _tmp50_;
	GtkButton* _tmp51_;
	GtkButton* _tmp52_;
	GtkDialog* _tmp53_;
	g_return_val_if_fail (parent != NULL, NULL);
	self = (moserialPreferencesDialog*) g_object_new (object_type, NULL);
	_tmp0_ = gtk_builder_new_from_resource (UIROOT "preferences.ui");
	builder = _tmp0_;
	_tmp1_ = gtk_builder_get_object (builder, "preferences_dialog");
	_tmp2_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_dialog_get_type (), GtkDialog));
	_g_object_unref0 (self->priv->dialog);
	self->priv->dialog = _tmp2_;
	_tmp3_ = self->priv->dialog;
	gtk_window_set_transient_for ((GtkWindow*) _tmp3_, parent);
	_tmp4_ = gtk_builder_get_object (builder, "preferences_ok");
	_tmp5_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, gtk_button_get_type (), GtkButton));
	_g_object_unref0 (self->priv->okButton);
	self->priv->okButton = _tmp5_;
	_tmp6_ = gtk_builder_get_object (builder, "preferences_cancel");
	_tmp7_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, gtk_button_get_type (), GtkButton));
	_g_object_unref0 (self->priv->cancelButton);
	self->priv->cancelButton = _tmp7_;
	_tmp8_ = gtk_builder_get_object (builder, "preferences_use_system_font");
	_tmp9_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, gtk_check_button_get_type (), GtkCheckButton));
	_g_object_unref0 (self->priv->systemFont);
	self->priv->systemFont = _tmp9_;
	_tmp10_ = gtk_builder_get_object (builder, "preferences_font_button");
	_tmp11_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, gtk_font_button_get_type (), GtkFontButton));
	_g_object_unref0 (self->priv->fontButton);
	self->priv->fontButton = _tmp11_;
	_tmp12_ = gtk_builder_get_object (builder, "preferences_font_color_button");
	_tmp13_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, gtk_color_button_get_type (), GtkColorButton));
	_g_object_unref0 (self->priv->fontColorButton);
	self->priv->fontColorButton = _tmp13_;
	_tmp14_ = gtk_builder_get_object (builder, "preferences_background_color_button");
	_tmp15_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp14_, gtk_color_button_get_type (), GtkColorButton));
	_g_object_unref0 (self->priv->backgroundColorButton);
	self->priv->backgroundColorButton = _tmp15_;
	_tmp16_ = gtk_builder_get_object (builder, "preferences_highlight_color_button");
	_tmp17_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp16_, gtk_color_button_get_type (), GtkColorButton));
	_g_object_unref0 (self->priv->highlightColorButton);
	self->priv->highlightColorButton = _tmp17_;
	_tmp18_ = gtk_builder_get_object (builder, "preferences_record_launch");
	_tmp19_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp18_, gtk_check_button_get_type (), GtkCheckButton));
	_g_object_unref0 (self->priv->recordLaunch);
	self->priv->recordLaunch = _tmp19_;
	_tmp20_ = self->priv->recordLaunch;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp20_, _ ("If this option is enabled, a recorded file will be opened immediately " \
"after it is saved, using the default application for the file type. Th" \
"e default application is defined by the desktop environment."));
	_tmp21_ = gtk_builder_get_object (builder, "preferences_record_enable_timeout");
	_tmp22_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp21_, gtk_check_button_get_type (), GtkCheckButton));
	_g_object_unref0 (self->priv->enableTimeout);
	self->priv->enableTimeout = _tmp22_;
	_tmp23_ = self->priv->enableTimeout;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp23_, _ ("If this option is enabled, recording will be automatically stopped aft" \
"er an adjustable period of inactivity after receiving some data. Moser" \
"ial will wait indefinitely to record the first data byte before activa" \
"ting the inactivity timer."));
	_tmp24_ = gtk_builder_get_object (builder, "preferences_record_timeout");
	_tmp25_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp24_, gtk_spin_button_get_type (), GtkSpinButton));
	_g_object_unref0 (self->priv->timeout);
	self->priv->timeout = _tmp25_;
	_tmp26_ = self->priv->timeout;
	_tmp27_ = gtk_spin_button_get_adjustment (_tmp26_);
	_tmp28_ = _tmp27_;
	gtk_adjustment_set_lower (_tmp28_, (gdouble) 0);
	_tmp29_ = self->priv->timeout;
	_tmp30_ = gtk_spin_button_get_adjustment (_tmp29_);
	_tmp31_ = _tmp30_;
	gtk_adjustment_set_upper (_tmp31_, (gdouble) 600);
	_tmp32_ = self->priv->timeout;
	_tmp33_ = gtk_spin_button_get_adjustment (_tmp32_);
	_tmp34_ = _tmp33_;
	gtk_adjustment_set_step_increment (_tmp34_, (gdouble) 1);
	_tmp35_ = self->priv->timeout;
	_tmp36_ = gtk_spin_button_get_adjustment (_tmp35_);
	_tmp37_ = _tmp36_;
	gtk_adjustment_set_page_increment (_tmp37_, (gdouble) 60);
	_tmp38_ = gtk_builder_get_object (builder, "preferences_record_auto_name");
	_tmp39_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp38_, gtk_check_button_get_type (), GtkCheckButton));
	_g_object_unref0 (self->priv->recordAutoName);
	self->priv->recordAutoName = _tmp39_;
	_tmp40_ = self->priv->recordAutoName;
	g_signal_connect_object ((GtkToggleButton*) _tmp40_, "toggled", (GCallback) _moserial_preferences_dialog_recordAutoToggled_gtk_toggle_button_toggled, self, 0);
	_tmp41_ = gtk_builder_get_object (builder, "preferences_record_auto_direction");
	_tmp42_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp41_, gtk_combo_box_get_type (), GtkComboBox));
	_g_object_unref0 (self->priv->recordAutoDirection);
	self->priv->recordAutoDirection = _tmp42_;
	_tmp43_ = self->priv->recordAutoDirection;
	mo_utils_populateComboBox (_tmp43_, MOSERIAL_SERIAL_STREAM_RECORDER_DirectionStrings, (gint) G_N_ELEMENTS (MOSERIAL_SERIAL_STREAM_RECORDER_DirectionStrings), TRUE);
	_tmp44_ = self->priv->recordAutoDirection;
	gtk_combo_box_set_active (_tmp44_, (gint) MOSERIAL_SERIAL_STREAM_RECORDER_DIRECTION_INCOMING);
	_tmp45_ = gtk_builder_get_object (builder, "preferences_record_auto_extension");
	_tmp46_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp45_, gtk_entry_get_type (), GtkEntry));
	_g_object_unref0 (self->priv->recordAutoExtension);
	self->priv->recordAutoExtension = _tmp46_;
	_tmp47_ = gtk_builder_get_object (builder, "preferences_record_auto_folder");
	_tmp48_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp47_, gtk_widget_get_type (), GtkWidget));
	_g_object_unref0 (self->priv->recordAutoFolder);
	self->priv->recordAutoFolder = _tmp48_;
	_tmp49_ = self->priv->systemFont;
	g_signal_connect_object ((GtkToggleButton*) _tmp49_, "toggled", (GCallback) _moserial_preferences_dialog_systemFontToggled_gtk_toggle_button_toggled, self, 0);
	_tmp50_ = self->priv->enableTimeout;
	g_signal_connect_object ((GtkToggleButton*) _tmp50_, "toggled", (GCallback) _moserial_preferences_dialog_enableTimeoutToggled_gtk_toggle_button_toggled, self, 0);
	_tmp51_ = self->priv->okButton;
	g_signal_connect_object (_tmp51_, "clicked", (GCallback) _moserial_preferences_dialog_ok_gtk_button_clicked, self, 0);
	_tmp52_ = self->priv->cancelButton;
	g_signal_connect_object (_tmp52_, "clicked", (GCallback) _moserial_preferences_dialog_cancel_gtk_button_clicked, self, 0);
	_tmp53_ = self->priv->dialog;
	g_signal_connect_object ((GtkWidget*) _tmp53_, "delete-event", (GCallback) _moserial_preferences_dialog_hide_gtk_widget_delete_event, self, 0);
	_g_object_unref0 (builder);
	return self;
}

moserialPreferencesDialog*
moserial_preferences_dialog_new (GtkWindow* parent)
{
	return moserial_preferences_dialog_construct (MOSERIAL_TYPE_PREFERENCES_DIALOG, parent);
}

void
moserial_preferences_dialog_ok (moserialPreferencesDialog* self,
                                GtkButton* button)
{
	gboolean pSystemFont = FALSE;
	gchar* pFont = NULL;
	gchar* pFontColor = NULL;
	gchar* pBackgroundColor = NULL;
	gchar* pHighlightColor = NULL;
	gboolean pRecordLaunch = FALSE;
	gboolean pEnableTimeout = FALSE;
	gint pTimeout = 0;
	gboolean pRecordAutoName = FALSE;
	gint pRecordAutoDirection = 0;
	gchar* pRecordAutoExtension = NULL;
	gchar* pRecordAutoFolder = NULL;
	GtkCheckButton* _tmp0_;
	GtkFontButton* _tmp1_;
	gchar* _tmp2_;
	GdkRGBA c = {0};
	GtkColorButton* _tmp3_;
	GdkRGBA _tmp4_ = {0};
	gchar* _tmp5_;
	GtkColorButton* _tmp6_;
	GdkRGBA _tmp7_ = {0};
	gchar* _tmp8_;
	GtkColorButton* _tmp9_;
	GdkRGBA _tmp10_ = {0};
	gchar* _tmp11_;
	GtkCheckButton* _tmp12_;
	GtkCheckButton* _tmp13_;
	GtkSpinButton* _tmp14_;
	GtkCheckButton* _tmp15_;
	GtkComboBox* _tmp16_;
	GtkEntry* _tmp17_;
	const gchar* _tmp18_;
	gchar* _tmp19_;
	GtkWidget* _tmp20_;
	gchar* _tmp21_;
	Preferences* preferences = NULL;
	const gchar* _tmp22_;
	const gchar* _tmp23_;
	const gchar* _tmp24_;
	const gchar* _tmp25_;
	Preferences* _tmp26_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (button != NULL);
	moserial_preferences_dialog_hide (self);
	_tmp0_ = self->priv->systemFont;
	if (gtk_toggle_button_get_active ((GtkToggleButton*) _tmp0_)) {
		pSystemFont = TRUE;
	} else {
		pSystemFont = FALSE;
	}
	_tmp1_ = self->priv->fontButton;
	_tmp2_ = gtk_font_chooser_get_font ((GtkFontChooser*) _tmp1_);
	_g_free0 (pFont);
	pFont = _tmp2_;
	memset (&c, 0, sizeof (GdkRGBA));
	_tmp3_ = self->priv->fontColorButton;
	gtk_color_chooser_get_rgba ((GtkColorChooser*) _tmp3_, &_tmp4_);
	c = _tmp4_;
	_tmp5_ = gdk_rgba_to_string (&c);
	_g_free0 (pFontColor);
	pFontColor = _tmp5_;
	_tmp6_ = self->priv->backgroundColorButton;
	gtk_color_chooser_get_rgba ((GtkColorChooser*) _tmp6_, &_tmp7_);
	c = _tmp7_;
	_tmp8_ = gdk_rgba_to_string (&c);
	_g_free0 (pBackgroundColor);
	pBackgroundColor = _tmp8_;
	_tmp9_ = self->priv->highlightColorButton;
	gtk_color_chooser_get_rgba ((GtkColorChooser*) _tmp9_, &_tmp10_);
	c = _tmp10_;
	_tmp11_ = gdk_rgba_to_string (&c);
	_g_free0 (pHighlightColor);
	pHighlightColor = _tmp11_;
	_tmp12_ = self->priv->recordLaunch;
	if (gtk_toggle_button_get_active ((GtkToggleButton*) _tmp12_)) {
		pRecordLaunch = TRUE;
	} else {
		pRecordLaunch = FALSE;
	}
	_tmp13_ = self->priv->enableTimeout;
	if (gtk_toggle_button_get_active ((GtkToggleButton*) _tmp13_)) {
		pEnableTimeout = TRUE;
	} else {
		pEnableTimeout = FALSE;
	}
	_tmp14_ = self->priv->timeout;
	pTimeout = (gint) gtk_spin_button_get_value (_tmp14_);
	_tmp15_ = self->priv->recordAutoName;
	if (gtk_toggle_button_get_active ((GtkToggleButton*) _tmp15_)) {
		pRecordAutoName = TRUE;
	} else {
		pRecordAutoName = FALSE;
	}
	_tmp16_ = self->priv->recordAutoDirection;
	pRecordAutoDirection = gtk_combo_box_get_active (_tmp16_);
	_tmp17_ = self->priv->recordAutoExtension;
	_tmp18_ = gtk_entry_get_text (_tmp17_);
	_tmp19_ = g_strdup (_tmp18_);
	_g_free0 (pRecordAutoExtension);
	pRecordAutoExtension = _tmp19_;
	_tmp20_ = self->priv->recordAutoFolder;
	_tmp21_ = gtk_file_chooser_get_filename (G_TYPE_CHECK_INSTANCE_CAST (_tmp20_, gtk_file_chooser_get_type (), GtkFileChooser));
	_g_free0 (pRecordAutoFolder);
	pRecordAutoFolder = _tmp21_;
	_tmp22_ = pFont;
	_tmp23_ = pFontColor;
	_tmp24_ = pBackgroundColor;
	_tmp25_ = pHighlightColor;
	_tmp26_ = preferences_new (pSystemFont, _tmp22_, _tmp23_, _tmp24_, _tmp25_, pRecordLaunch, pEnableTimeout, pTimeout, pRecordAutoName, pRecordAutoDirection, pRecordAutoExtension, pRecordAutoFolder);
	preferences = _tmp26_;
	g_signal_emit (self, moserial_preferences_dialog_signals[MOSERIAL_PREFERENCES_DIALOG_UPDATE_PREFERENCES_SIGNAL], 0, preferences);
	_g_object_unref0 (preferences);
	_g_free0 (pRecordAutoFolder);
	_g_free0 (pRecordAutoExtension);
	_g_free0 (pHighlightColor);
	_g_free0 (pBackgroundColor);
	_g_free0 (pFontColor);
	_g_free0 (pFont);
}

void
moserial_preferences_dialog_show (moserialPreferencesDialog* self,
                                  Preferences* preferences,
                                  gboolean recording)
{
	gboolean _tmp0_;
	gboolean _tmp1_;
	GtkFontButton* _tmp6_;
	const gchar* _tmp7_;
	const gchar* _tmp8_;
	GtkColorButton* _tmp9_;
	const gchar* _tmp10_;
	const gchar* _tmp11_;
	GdkRGBA _tmp12_ = {0};
	GtkColorButton* _tmp13_;
	const gchar* _tmp14_;
	const gchar* _tmp15_;
	GdkRGBA _tmp16_ = {0};
	GtkColorButton* _tmp17_;
	const gchar* _tmp18_;
	const gchar* _tmp19_;
	GdkRGBA _tmp20_ = {0};
	gboolean _tmp21_;
	gboolean _tmp22_;
	gboolean _tmp25_;
	gboolean _tmp26_;
	GtkSpinButton* _tmp34_;
	gint _tmp35_;
	gint _tmp36_;
	GtkCheckButton* _tmp37_;
	gboolean _tmp38_;
	gboolean _tmp39_;
	GtkComboBox* _tmp40_;
	gint _tmp41_;
	gint _tmp42_;
	GtkEntry* _tmp43_;
	const gchar* _tmp44_;
	const gchar* _tmp45_;
	GtkWidget* _tmp46_;
	const gchar* _tmp47_;
	const gchar* _tmp48_;
	GtkDialog* _tmp49_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (preferences != NULL);
	_tmp0_ = preferences_get_useSystemMonospaceFont (preferences);
	_tmp1_ = _tmp0_;
	if (_tmp1_) {
		GtkFontButton* _tmp2_;
		GtkCheckButton* _tmp3_;
		_tmp2_ = self->priv->fontButton;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp2_, FALSE);
		_tmp3_ = self->priv->systemFont;
		gtk_toggle_button_set_active ((GtkToggleButton*) _tmp3_, TRUE);
	} else {
		GtkFontButton* _tmp4_;
		GtkCheckButton* _tmp5_;
		_tmp4_ = self->priv->fontButton;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp4_, TRUE);
		_tmp5_ = self->priv->systemFont;
		gtk_toggle_button_set_active ((GtkToggleButton*) _tmp5_, FALSE);
	}
	_tmp6_ = self->priv->fontButton;
	_tmp7_ = preferences_get_font (preferences);
	_tmp8_ = _tmp7_;
	gtk_font_chooser_set_font ((GtkFontChooser*) _tmp6_, _tmp8_);
	_tmp9_ = self->priv->fontColorButton;
	_tmp10_ = preferences_get_fontColor (preferences);
	_tmp11_ = _tmp10_;
	preferences_getGdkRGBA (_tmp11_, &_tmp12_);
	gtk_color_chooser_set_rgba ((GtkColorChooser*) _tmp9_, &_tmp12_);
	_tmp13_ = self->priv->backgroundColorButton;
	_tmp14_ = preferences_get_backgroundColor (preferences);
	_tmp15_ = _tmp14_;
	preferences_getGdkRGBA (_tmp15_, &_tmp16_);
	gtk_color_chooser_set_rgba ((GtkColorChooser*) _tmp13_, &_tmp16_);
	_tmp17_ = self->priv->highlightColorButton;
	_tmp18_ = preferences_get_highlightColor (preferences);
	_tmp19_ = _tmp18_;
	preferences_getGdkRGBA (_tmp19_, &_tmp20_);
	gtk_color_chooser_set_rgba ((GtkColorChooser*) _tmp17_, &_tmp20_);
	_tmp21_ = preferences_get_recordLaunch (preferences);
	_tmp22_ = _tmp21_;
	if (_tmp22_) {
		GtkCheckButton* _tmp23_;
		_tmp23_ = self->priv->recordLaunch;
		gtk_toggle_button_set_active ((GtkToggleButton*) _tmp23_, TRUE);
	} else {
		GtkCheckButton* _tmp24_;
		_tmp24_ = self->priv->recordLaunch;
		gtk_toggle_button_set_active ((GtkToggleButton*) _tmp24_, FALSE);
	}
	_tmp25_ = preferences_get_enableTimeout (preferences);
	_tmp26_ = _tmp25_;
	if (_tmp26_) {
		GtkCheckButton* _tmp27_;
		GtkSpinButton* _tmp28_;
		_tmp27_ = self->priv->enableTimeout;
		gtk_toggle_button_set_active ((GtkToggleButton*) _tmp27_, TRUE);
		_tmp28_ = self->priv->timeout;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp28_, TRUE);
	} else {
		GtkCheckButton* _tmp29_;
		GtkSpinButton* _tmp30_;
		_tmp29_ = self->priv->enableTimeout;
		gtk_toggle_button_set_active ((GtkToggleButton*) _tmp29_, FALSE);
		_tmp30_ = self->priv->timeout;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp30_, FALSE);
	}
	if (recording) {
		GtkCheckButton* _tmp31_;
		GtkSpinButton* _tmp32_;
		_tmp31_ = self->priv->enableTimeout;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp31_, FALSE);
		_tmp32_ = self->priv->timeout;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp32_, FALSE);
	} else {
		GtkCheckButton* _tmp33_;
		_tmp33_ = self->priv->enableTimeout;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp33_, TRUE);
	}
	_tmp34_ = self->priv->timeout;
	_tmp35_ = preferences_get_timeout (preferences);
	_tmp36_ = _tmp35_;
	gtk_spin_button_set_value (_tmp34_, (gdouble) _tmp36_);
	_tmp37_ = self->priv->recordAutoName;
	_tmp38_ = preferences_get_recordAutoName (preferences);
	_tmp39_ = _tmp38_;
	gtk_toggle_button_set_active ((GtkToggleButton*) _tmp37_, _tmp39_);
	_tmp40_ = self->priv->recordAutoDirection;
	_tmp41_ = preferences_get_recordAutoDirection (preferences);
	_tmp42_ = _tmp41_;
	gtk_combo_box_set_active (_tmp40_, _tmp42_);
	_tmp43_ = self->priv->recordAutoExtension;
	_tmp44_ = preferences_get_recordAutoExtension (preferences);
	_tmp45_ = _tmp44_;
	gtk_entry_set_text (_tmp43_, _tmp45_);
	_tmp46_ = self->priv->recordAutoFolder;
	_tmp47_ = preferences_get_recordAutoFolder (preferences);
	_tmp48_ = _tmp47_;
	gtk_file_chooser_set_current_folder (G_TYPE_CHECK_INSTANCE_CAST (_tmp46_, gtk_file_chooser_get_type (), GtkFileChooser), _tmp48_);
	_tmp49_ = self->priv->dialog;
	gtk_widget_show_all ((GtkWidget*) _tmp49_);
}

void
moserial_preferences_dialog_cancel (moserialPreferencesDialog* self,
                                    GtkButton* button)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (button != NULL);
	moserial_preferences_dialog_hide (self);
}

gboolean
moserial_preferences_dialog_hide (moserialPreferencesDialog* self)
{
	GtkDialog* _tmp0_;
	gboolean result = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->dialog;
	gtk_widget_hide ((GtkWidget*) _tmp0_);
	result = TRUE;
	return result;
}

void
moserial_preferences_dialog_systemFontToggled (moserialPreferencesDialog* self,
                                               GtkToggleButton* button)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (button != NULL);
	if (gtk_toggle_button_get_active (button)) {
		GtkFontButton* _tmp0_;
		_tmp0_ = self->priv->fontButton;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp0_, FALSE);
	} else {
		GtkFontButton* _tmp1_;
		_tmp1_ = self->priv->fontButton;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp1_, TRUE);
	}
}

void
moserial_preferences_dialog_enableTimeoutToggled (moserialPreferencesDialog* self,
                                                  GtkToggleButton* button)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (button != NULL);
	if (gtk_toggle_button_get_active (button)) {
		GtkSpinButton* _tmp0_;
		_tmp0_ = self->priv->timeout;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp0_, TRUE);
	} else {
		GtkSpinButton* _tmp1_;
		_tmp1_ = self->priv->timeout;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp1_, FALSE);
	}
}

void
moserial_preferences_dialog_recordAutoToggled (moserialPreferencesDialog* self,
                                               GtkToggleButton* button)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (button != NULL);
	if (gtk_toggle_button_get_active (button)) {
		GtkEntry* _tmp0_;
		GtkComboBox* _tmp1_;
		GtkWidget* _tmp2_;
		_tmp0_ = self->priv->recordAutoExtension;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp0_, TRUE);
		_tmp1_ = self->priv->recordAutoDirection;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp1_, TRUE);
		_tmp2_ = self->priv->recordAutoFolder;
		gtk_widget_set_sensitive (_tmp2_, TRUE);
	} else {
		GtkEntry* _tmp3_;
		GtkComboBox* _tmp4_;
		GtkWidget* _tmp5_;
		_tmp3_ = self->priv->recordAutoExtension;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp3_, FALSE);
		_tmp4_ = self->priv->recordAutoDirection;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp4_, FALSE);
		_tmp5_ = self->priv->recordAutoFolder;
		gtk_widget_set_sensitive (_tmp5_, FALSE);
	}
}

static void
moserial_preferences_dialog_class_init (moserialPreferencesDialogClass * klass,
                                        gpointer klass_data)
{
	moserial_preferences_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &moserialPreferencesDialog_private_offset);
	G_OBJECT_CLASS (klass)->finalize = moserial_preferences_dialog_finalize;
	moserial_preferences_dialog_signals[MOSERIAL_PREFERENCES_DIALOG_UPDATE_PREFERENCES_SIGNAL] = g_signal_new ("update-preferences", MOSERIAL_TYPE_PREFERENCES_DIALOG, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, TYPE_PREFERENCES);
}

static void
moserial_preferences_dialog_instance_init (moserialPreferencesDialog * self,
                                           gpointer klass)
{
	self->priv = moserial_preferences_dialog_get_instance_private (self);
}

static void
moserial_preferences_dialog_finalize (GObject * obj)
{
	moserialPreferencesDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, MOSERIAL_TYPE_PREFERENCES_DIALOG, moserialPreferencesDialog);
	_g_object_unref0 (self->priv->dialog);
	_g_object_unref0 (self->priv->cancelButton);
	_g_object_unref0 (self->priv->okButton);
	_g_object_unref0 (self->priv->systemFont);
	_g_object_unref0 (self->priv->fontButton);
	_g_object_unref0 (self->priv->fontColorButton);
	_g_object_unref0 (self->priv->backgroundColorButton);
	_g_object_unref0 (self->priv->highlightColorButton);
	_g_object_unref0 (self->priv->recordLaunch);
	_g_object_unref0 (self->priv->enableTimeout);
	_g_object_unref0 (self->priv->timeout);
	_g_object_unref0 (self->priv->recordAutoName);
	_g_object_unref0 (self->priv->recordAutoDirection);
	_g_object_unref0 (self->priv->recordAutoExtension);
	_g_object_unref0 (self->priv->recordAutoFolder);
	G_OBJECT_CLASS (moserial_preferences_dialog_parent_class)->finalize (obj);
}

static GType
moserial_preferences_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (moserialPreferencesDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) moserial_preferences_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (moserialPreferencesDialog), 0, (GInstanceInitFunc) moserial_preferences_dialog_instance_init, NULL };
	GType moserial_preferences_dialog_type_id;
	moserial_preferences_dialog_type_id = g_type_register_static (G_TYPE_OBJECT, "moserialPreferencesDialog", &g_define_type_info, 0);
	moserialPreferencesDialog_private_offset = g_type_add_instance_private (moserial_preferences_dialog_type_id, sizeof (moserialPreferencesDialogPrivate));
	return moserial_preferences_dialog_type_id;
}

GType
moserial_preferences_dialog_get_type (void)
{
	static volatile gsize moserial_preferences_dialog_type_id__volatile = 0;
	if (g_once_init_enter (&moserial_preferences_dialog_type_id__volatile)) {
		GType moserial_preferences_dialog_type_id;
		moserial_preferences_dialog_type_id = moserial_preferences_dialog_get_type_once ();
		g_once_init_leave (&moserial_preferences_dialog_type_id__volatile, moserial_preferences_dialog_type_id);
	}
	return moserial_preferences_dialog_type_id__volatile;
}

