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

/* Copyright 2016 Software Freedom Conservancy Inc.
 * Copyright 2017 Jens Georg <mail@jensge.org>
 *
 * This software is licensed under the GNU LGPL (version 2.1 or later).
 * See the COPYING file in this distribution.
 */

#include <gtk/gtk.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <gee.h>
#include <gdk/gdk.h>
#include <float.h>
#include <math.h>
#include <glib/gi18n-lib.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gobject/gvaluecollector.h>

#define RESOURCES_DIR_PATTERN_URI_SYSWIDE "help:shotwell/other-files"
#define RESOURCES_DEFAULT_ICON_SCALE 24
#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#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 TYPE_PREFERENCES_DIALOG (preferences_dialog_get_type ())
#define PREFERENCES_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PREFERENCES_DIALOG, PreferencesDialog))
#define PREFERENCES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PREFERENCES_DIALOG, PreferencesDialogClass))
#define IS_PREFERENCES_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PREFERENCES_DIALOG))
#define IS_PREFERENCES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PREFERENCES_DIALOG))
#define PREFERENCES_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PREFERENCES_DIALOG, PreferencesDialogClass))

typedef struct _PreferencesDialog PreferencesDialog;
typedef struct _PreferencesDialogClass PreferencesDialogClass;
typedef struct _PreferencesDialogPrivate PreferencesDialogPrivate;

#define TYPE_SORTED_LIST (sorted_list_get_type ())
#define SORTED_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SORTED_LIST, SortedList))
#define SORTED_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SORTED_LIST, SortedListClass))
#define IS_SORTED_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SORTED_LIST))
#define IS_SORTED_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SORTED_LIST))
#define SORTED_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SORTED_LIST, SortedListClass))

typedef struct _SortedList SortedList;
typedef struct _SortedListClass SortedListClass;

#define PREFERENCES_DIALOG_TYPE_PATH_FORMAT (preferences_dialog_path_format_get_type ())
#define PREFERENCES_DIALOG_PATH_FORMAT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PREFERENCES_DIALOG_TYPE_PATH_FORMAT, PreferencesDialogPathFormat))
#define PREFERENCES_DIALOG_PATH_FORMAT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PREFERENCES_DIALOG_TYPE_PATH_FORMAT, PreferencesDialogPathFormatClass))
#define PREFERENCES_DIALOG_IS_PATH_FORMAT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PREFERENCES_DIALOG_TYPE_PATH_FORMAT))
#define PREFERENCES_DIALOG_IS_PATH_FORMAT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PREFERENCES_DIALOG_TYPE_PATH_FORMAT))
#define PREFERENCES_DIALOG_PATH_FORMAT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PREFERENCES_DIALOG_TYPE_PATH_FORMAT, PreferencesDialogPathFormatClass))

typedef struct _PreferencesDialogPathFormat PreferencesDialogPathFormat;
typedef struct _PreferencesDialogPathFormatClass PreferencesDialogPathFormatClass;

#define PLUGINS_TYPE_MANIFEST_WIDGET_MEDIATOR (plugins_manifest_widget_mediator_get_type ())
#define PLUGINS_MANIFEST_WIDGET_MEDIATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PLUGINS_TYPE_MANIFEST_WIDGET_MEDIATOR, PluginsManifestWidgetMediator))
#define PLUGINS_MANIFEST_WIDGET_MEDIATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PLUGINS_TYPE_MANIFEST_WIDGET_MEDIATOR, PluginsManifestWidgetMediatorClass))
#define PLUGINS_IS_MANIFEST_WIDGET_MEDIATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PLUGINS_TYPE_MANIFEST_WIDGET_MEDIATOR))
#define PLUGINS_IS_MANIFEST_WIDGET_MEDIATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PLUGINS_TYPE_MANIFEST_WIDGET_MEDIATOR))
#define PLUGINS_MANIFEST_WIDGET_MEDIATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PLUGINS_TYPE_MANIFEST_WIDGET_MEDIATOR, PluginsManifestWidgetMediatorClass))

typedef struct _PluginsManifestWidgetMediator PluginsManifestWidgetMediator;
typedef struct _PluginsManifestWidgetMediatorClass PluginsManifestWidgetMediatorClass;
enum  {
	PREFERENCES_DIALOG_0_PROPERTY,
	PREFERENCES_DIALOG_NUM_PROPERTIES
};
static GParamSpec* preferences_dialog_properties[PREFERENCES_DIALOG_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))

#define TYPE_PAGE_WINDOW (page_window_get_type ())
#define PAGE_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PAGE_WINDOW, PageWindow))
#define PAGE_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PAGE_WINDOW, PageWindowClass))
#define IS_PAGE_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PAGE_WINDOW))
#define IS_PAGE_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PAGE_WINDOW))
#define PAGE_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PAGE_WINDOW, PageWindowClass))

typedef struct _PageWindow PageWindow;
typedef struct _PageWindowClass PageWindowClass;

#define TYPE_APP_WINDOW (app_window_get_type ())
#define APP_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_APP_WINDOW, AppWindow))
#define APP_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_APP_WINDOW, AppWindowClass))
#define IS_APP_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_APP_WINDOW))
#define IS_APP_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_APP_WINDOW))
#define APP_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_APP_WINDOW, AppWindowClass))

typedef struct _AppWindow AppWindow;
typedef struct _AppWindowClass AppWindowClass;

#define TYPE_CONFIGURATION_FACADE (configuration_facade_get_type ())
#define CONFIGURATION_FACADE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CONFIGURATION_FACADE, ConfigurationFacade))
#define CONFIGURATION_FACADE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CONFIGURATION_FACADE, ConfigurationFacadeClass))
#define IS_CONFIGURATION_FACADE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CONFIGURATION_FACADE))
#define IS_CONFIGURATION_FACADE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CONFIGURATION_FACADE))
#define CONFIGURATION_FACADE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CONFIGURATION_FACADE, ConfigurationFacadeClass))

typedef struct _ConfigurationFacade ConfigurationFacade;
typedef struct _ConfigurationFacadeClass ConfigurationFacadeClass;

#define CONFIG_TYPE_FACADE (config_facade_get_type ())
#define CONFIG_FACADE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONFIG_TYPE_FACADE, ConfigFacade))
#define CONFIG_FACADE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONFIG_TYPE_FACADE, ConfigFacadeClass))
#define CONFIG_IS_FACADE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONFIG_TYPE_FACADE))
#define CONFIG_IS_FACADE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONFIG_TYPE_FACADE))
#define CONFIG_FACADE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONFIG_TYPE_FACADE, ConfigFacadeClass))

typedef struct _ConfigFacade ConfigFacade;
typedef struct _ConfigFacadeClass ConfigFacadeClass;

#define SHOTWELL_TYPE_PROFILE_BROWSER (shotwell_profile_browser_get_type ())
#define SHOTWELL_PROFILE_BROWSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SHOTWELL_TYPE_PROFILE_BROWSER, ShotwellProfileBrowser))
#define SHOTWELL_PROFILE_BROWSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SHOTWELL_TYPE_PROFILE_BROWSER, ShotwellProfileBrowserClass))
#define SHOTWELL_IS_PROFILE_BROWSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SHOTWELL_TYPE_PROFILE_BROWSER))
#define SHOTWELL_IS_PROFILE_BROWSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SHOTWELL_TYPE_PROFILE_BROWSER))
#define SHOTWELL_PROFILE_BROWSER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SHOTWELL_TYPE_PROFILE_BROWSER, ShotwellProfileBrowserClass))

typedef struct _ShotwellProfileBrowser ShotwellProfileBrowser;
typedef struct _ShotwellProfileBrowserClass ShotwellProfileBrowserClass;
typedef enum  {
	RAW_DEVELOPER_SHOTWELL = 0,
	RAW_DEVELOPER_CAMERA,
	RAW_DEVELOPER_EMBEDDED
} RawDeveloper;

#define TYPE_RAW_DEVELOPER (raw_developer_get_type ())
typedef enum  {
	PHOTO_FILE_FORMAT_JFIF,
	PHOTO_FILE_FORMAT_RAW,
	PHOTO_FILE_FORMAT_PNG,
	PHOTO_FILE_FORMAT_TIFF,
	PHOTO_FILE_FORMAT_BMP,
	PHOTO_FILE_FORMAT_GIF,
	PHOTO_FILE_FORMAT_WEBP,
	PHOTO_FILE_FORMAT_AVIF,
	PHOTO_FILE_FORMAT_HEIF,
	PHOTO_FILE_FORMAT_JPEGXL,
	PHOTO_FILE_FORMAT_UNKNOWN
} PhotoFileFormat;

#define TYPE_PHOTO_FILE_FORMAT (photo_file_format_get_type ())
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _PreferencesDialogPathFormatPrivate PreferencesDialogPathFormatPrivate;
#define _preferences_dialog_path_format_unref0(var) ((var == NULL) ? NULL : (var = (preferences_dialog_path_format_unref (var), NULL)))
typedef struct _PreferencesDialogParamSpecPathFormat PreferencesDialogParamSpecPathFormat;
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _PreferencesDialog {
	GtkDialog parent_instance;
	PreferencesDialogPrivate * priv;
};

struct _PreferencesDialogClass {
	GtkDialogClass parent_class;
};

struct _PreferencesDialogPrivate {
	GtkSwitch* switch_dark;
	GtkComboBox* photo_editor_combo;
	GtkComboBox* raw_editor_combo;
	SortedList* external_raw_apps;
	SortedList* external_photo_apps;
	GtkFileChooserButton* library_dir_button;
	GtkComboBoxText* dir_pattern_combo;
	GtkEntry* dir_pattern_entry;
	GtkLabel* dir_pattern_example;
	gboolean allow_closing;
	gchar* lib_dir;
	GeeArrayList* path_formats;
	GDateTime* example_date;
	GtkCheckButton* lowercase;
	PluginsManifestWidgetMediator* plugins_mediator;
	GtkComboBoxText* default_raw_developer_combo;
	GtkCheckButton* autoimport;
	GtkCheckButton* write_metadata;
	GtkLabel* pattern_help;
	GtkStack* preferences_stack;
	GtkRadioButton* transparent_checker_radio;
	GtkRadioButton* transparent_solid_radio;
	GtkColorButton* transparent_solid_color;
	GtkRadioButton* transparent_none_radio;
};

struct _PreferencesDialogPathFormat {
	GTypeInstance parent_instance;
	volatile int ref_count;
	PreferencesDialogPathFormatPrivate * priv;
	gchar* name;
	gchar* pattern;
};

struct _PreferencesDialogPathFormatClass {
	GTypeClass parent_class;
	void (*finalize) (PreferencesDialogPathFormat *self);
};

struct _PreferencesDialogParamSpecPathFormat {
	GParamSpec parent_instance;
};

static gint PreferencesDialog_private_offset;
static gpointer preferences_dialog_parent_class = NULL;
static PreferencesDialog* preferences_dialog_preferences_dialog;
static PreferencesDialog* preferences_dialog_preferences_dialog = NULL;
static gpointer preferences_dialog_path_format_parent_class = NULL;

VALA_EXTERN GType preferences_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PreferencesDialog, g_object_unref)
VALA_EXTERN GType sorted_list_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SortedList, g_object_unref)
static gpointer preferences_dialog_path_format_ref (gpointer instance);
static void preferences_dialog_path_format_unref (gpointer instance);
static GParamSpec* preferences_dialog_param_spec_path_format (const gchar* name,
                                                       const gchar* nick,
                                                       const gchar* blurb,
                                                       GType object_type,
                                                       GParamFlags flags) G_GNUC_UNUSED ;
static void preferences_dialog_value_set_path_format (GValue* value,
                                               gpointer v_object) G_GNUC_UNUSED ;
static void preferences_dialog_value_take_path_format (GValue* value,
                                                gpointer v_object) G_GNUC_UNUSED ;
static gpointer preferences_dialog_value_get_path_format (const GValue* value) G_GNUC_UNUSED ;
static GType preferences_dialog_path_format_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PreferencesDialogPathFormat, preferences_dialog_path_format_unref)
VALA_EXTERN GType plugins_manifest_widget_mediator_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PluginsManifestWidgetMediator, g_object_unref)
VALA_EXTERN PluginsManifestWidgetMediator* plugins_manifest_widget_mediator_new (void);
VALA_EXTERN PluginsManifestWidgetMediator* plugins_manifest_widget_mediator_construct (GType object_type);
static PreferencesDialog* preferences_dialog_new (void);
static PreferencesDialog* preferences_dialog_construct (GType object_type);
VALA_EXTERN gint resources_use_header_bar (void);
VALA_EXTERN GType page_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PageWindow, g_object_unref)
VALA_EXTERN GType app_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (AppWindow, g_object_unref)
VALA_EXTERN AppWindow* app_window_get_instance (void);
static gboolean preferences_dialog_on_delete (PreferencesDialog* self);
static gboolean _preferences_dialog_on_delete_gtk_widget_delete_event (GtkWidget* _sender,
                                                                GdkEventAny* event,
                                                                gpointer self);
static void preferences_dialog_on_close (PreferencesDialog* self);
static void _preferences_dialog_on_close_gtk_dialog_response (GtkDialog* _sender,
                                                       gint response_id,
                                                       gpointer self);
static void preferences_dialog_on_radio_changed (PreferencesDialog* self);
static void _preferences_dialog_on_radio_changed_gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                                                     gpointer self);
VALA_EXTERN GType configuration_facade_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ConfigurationFacade, g_object_unref)
VALA_EXTERN GType config_facade_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ConfigFacade, g_object_unref)
VALA_EXTERN ConfigFacade* config_facade_get_instance (void);
VALA_EXTERN gchar* configuration_facade_get_transparent_background_color (ConfigurationFacade* self);
static void preferences_dialog_on_color_changed (PreferencesDialog* self);
static void _preferences_dialog_on_color_changed_gtk_color_button_color_set (GtkColorButton* _sender,
                                                                      gpointer self);
VALA_EXTERN gchar* configuration_facade_get_transparent_background_type (ConfigurationFacade* self);
VALA_EXTERN gchar* resources_get_help_path (void);
static gboolean preferences_dialog_on_local_pattern_help (PreferencesDialog* self,
                                                   const gchar* ignore);
static gboolean _preferences_dialog_on_local_pattern_help_gtk_label_activate_link (GtkLabel* _sender,
                                                                            const gchar* uri,
                                                                            gpointer self);
static void preferences_dialog_add_to_dir_formats (PreferencesDialog* self,
                                            const gchar* name,
                                            const gchar* pattern);
static void preferences_dialog_on_dir_pattern_combo_changed (PreferencesDialog* self);
static void _preferences_dialog_on_dir_pattern_combo_changed_gtk_combo_box_changed (GtkComboBox* _sender,
                                                                             gpointer self);
static void preferences_dialog_on_dir_pattern_entry_changed (PreferencesDialog* self);
static void _preferences_dialog_on_dir_pattern_entry_changed_gtk_editable_changed (GtkEditable* _sender,
                                                                            gpointer self);
static void preferences_dialog_on_lowercase_toggled (PreferencesDialog* self);
static void _preferences_dialog_on_lowercase_toggled_gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                                                         gpointer self);
VALA_EXTERN ShotwellProfileBrowser* shotwell_profile_browser_new (void);
VALA_EXTERN ShotwellProfileBrowser* shotwell_profile_browser_construct (GType object_type);
VALA_EXTERN GType shotwell_profile_browser_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ShotwellProfileBrowser, g_object_unref)
VALA_EXTERN void preferences_dialog_populate_preference_options (PreferencesDialog* self);
static void preferences_dialog_on_photo_editor_changed (PreferencesDialog* self);
static void _preferences_dialog_on_photo_editor_changed_gtk_combo_box_changed (GtkComboBox* _sender,
                                                                        gpointer self);
static void preferences_dialog_on_raw_editor_changed (PreferencesDialog* self);
static void _preferences_dialog_on_raw_editor_changed_gtk_combo_box_changed (GtkComboBox* _sender,
                                                                      gpointer self);
VALA_EXTERN gboolean configuration_facade_get_auto_import_from_library (ConfigurationFacade* self);
VALA_EXTERN gboolean configuration_facade_get_commit_metadata_to_masters (ConfigurationFacade* self);
VALA_EXTERN GType raw_developer_get_type (void) G_GNUC_CONST ;
VALA_EXTERN gchar* raw_developer_get_label (RawDeveloper self);
static void preferences_dialog_set_raw_developer_combo (PreferencesDialog* self,
                                                 RawDeveloper d);
VALA_EXTERN RawDeveloper configuration_facade_get_default_raw_developer (ConfigurationFacade* self);
static void preferences_dialog_on_default_raw_developer_changed (PreferencesDialog* self);
static void _preferences_dialog_on_default_raw_developer_changed_gtk_combo_box_changed (GtkComboBox* _sender,
                                                                                 gpointer self);
static void preferences_dialog_on_theme_variant_changed (PreferencesDialog* self,
                                                  GObject* o,
                                                  GParamSpec* ps);
static void _preferences_dialog_on_theme_variant_changed_g_object_notify (GObject* _sender,
                                                                   GParamSpec* pspec,
                                                                   gpointer self);
static void preferences_dialog_populate_app_combo_box (PreferencesDialog* self,
                                                GtkComboBox* combo_box,
                                                gchar** mime_types,
                                                gint mime_types_length1,
                                                const gchar* current_app_executable,
                                                SortedList** external_apps);
VALA_EXTERN gchar** photo_file_format_get_editable_mime_types (gint* result_length1);
VALA_EXTERN gchar* configuration_facade_get_external_photo_app (ConfigurationFacade* self);
VALA_EXTERN GType photo_file_format_get_type (void) G_GNUC_CONST ;
VALA_EXTERN gchar** photo_file_format_get_mime_types (PhotoFileFormat self,
                                          gint* result_length1);
VALA_EXTERN gchar* configuration_facade_get_external_raw_app (ConfigurationFacade* self);
static void preferences_dialog_setup_dir_pattern (PreferencesDialog* self,
                                           GtkComboBox* combo_box,
                                           GtkEntry* entry);
VALA_EXTERN gboolean configuration_facade_get_use_lowercase_filenames (ConfigurationFacade* self);
VALA_EXTERN void configuration_facade_set_gtk_theme_variant (ConfigurationFacade* self,
                                                 gboolean dark);
VALA_EXTERN void configuration_facade_set_transparent_background_type (ConfigurationFacade* self,
                                                           const gchar* type);
VALA_EXTERN void configuration_facade_set_transparent_background_color (ConfigurationFacade* self,
                                                            const gchar* color_name);
VALA_EXTERN void resources_launch_help (GtkWindow* window,
                            const gchar* anchor,
                            GError** error);
VALA_EXTERN SortedList* desktop_integration_get_apps_for_mime_types (gchar** mime_types,
                                                         gint mime_types_length1);
VALA_EXTERN GdkPixbuf* scale_pixbuf (GdkPixbuf* pixbuf,
                         gint scale,
                         GdkInterpType interp,
                         gboolean scale_up);
VALA_EXTERN gint sorted_list_index_of (SortedList* self,
                           gconstpointer search);
VALA_EXTERN gchar* configuration_facade_get_directory_pattern (ConfigurationFacade* self);
VALA_EXTERN gchar* configuration_facade_get_directory_pattern_custom (ConfigurationFacade* self);
VALA_EXTERN gboolean is_string_empty (const gchar* s);
VALA_EXTERN void preferences_dialog_show_preferences (void);
VALA_EXTERN GFile* app_dirs_get_import_dir (void);
static void preferences_dialog_commit_on_close (PreferencesDialog* self);
VALA_EXTERN void configuration_facade_set_auto_import_from_library (ConfigurationFacade* self,
                                                        gboolean auto_import);
VALA_EXTERN void configuration_facade_set_commit_metadata_to_masters (ConfigurationFacade* self,
                                                          gboolean commit_metadata);
VALA_EXTERN void app_dirs_set_import_dir (const gchar* path);
VALA_EXTERN void configuration_facade_set_directory_pattern_custom (ConfigurationFacade* self,
                                                        const gchar* s);
VALA_EXTERN void configuration_facade_set_directory_pattern (ConfigurationFacade* self,
                                                 const gchar* s);
static gboolean preferences_dialog_get_allow_closing (PreferencesDialog* self);
static void preferences_dialog_set_allow_closing (PreferencesDialog* self,
                                           gboolean allow);
VALA_EXTERN gpointer sorted_list_get_at (SortedList* self,
                             gint index);
VALA_EXTERN void configuration_facade_set_external_photo_app (ConfigurationFacade* self,
                                                  const gchar* external_photo_app);
VALA_EXTERN gchar* desktop_integration_get_app_open_command (GAppInfo* app_info);
VALA_EXTERN void configuration_facade_set_external_raw_app (ConfigurationFacade* self,
                                                const gchar* external_raw_app);
static RawDeveloper preferences_dialog_raw_developer_from_combo (PreferencesDialog* self);
VALA_EXTERN void configuration_facade_set_default_raw_developer (ConfigurationFacade* self,
                                                     RawDeveloper d);
static void preferences_dialog_on_current_folder_changed (PreferencesDialog* self);
static gboolean preferences_dialog_real_map_event (GtkWidget* base,
                                            GdkEventAny* event);
static void _preferences_dialog_on_current_folder_changed_gtk_file_chooser_current_folder_changed (GtkFileChooser* _sender,
                                                                                            gpointer self);
static PreferencesDialogPathFormat* preferences_dialog_path_format_new (const gchar* name,
                                                                 const gchar* pattern);
static PreferencesDialogPathFormat* preferences_dialog_path_format_construct (GType object_type,
                                                                       const gchar* name,
                                                                       const gchar* pattern);
VALA_EXTERN void configuration_facade_set_use_lowercase_filenames (ConfigurationFacade* self,
                                                       gboolean b);
static void preferences_dialog_path_format_finalize (PreferencesDialogPathFormat * obj);
static GType preferences_dialog_path_format_get_type_once (void);
static void preferences_dialog_finalize (GObject * obj);
static GType preferences_dialog_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static gssize _vala_array_length (gpointer array);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
preferences_dialog_get_instance_private (PreferencesDialog* self)
{
	return G_STRUCT_MEMBER_P (self, PreferencesDialog_private_offset);
}

static gboolean
_preferences_dialog_on_delete_gtk_widget_delete_event (GtkWidget* _sender,
                                                       GdkEventAny* event,
                                                       gpointer self)
{
	gboolean result;
	result = preferences_dialog_on_delete ((PreferencesDialog*) self);
	return result;
}

static void
_preferences_dialog_on_close_gtk_dialog_response (GtkDialog* _sender,
                                                  gint response_id,
                                                  gpointer self)
{
	preferences_dialog_on_close ((PreferencesDialog*) self);
}

static void
_preferences_dialog_on_radio_changed_gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                                                gpointer self)
{
	preferences_dialog_on_radio_changed ((PreferencesDialog*) self);
}

static void
_preferences_dialog_on_color_changed_gtk_color_button_color_set (GtkColorButton* _sender,
                                                                 gpointer self)
{
	preferences_dialog_on_color_changed ((PreferencesDialog*) self);
}

static gboolean
_preferences_dialog_on_local_pattern_help_gtk_label_activate_link (GtkLabel* _sender,
                                                                   const gchar* uri,
                                                                   gpointer self)
{
	gboolean result;
	result = preferences_dialog_on_local_pattern_help ((PreferencesDialog*) self, uri);
	return result;
}

static void
_preferences_dialog_on_dir_pattern_combo_changed_gtk_combo_box_changed (GtkComboBox* _sender,
                                                                        gpointer self)
{
	preferences_dialog_on_dir_pattern_combo_changed ((PreferencesDialog*) self);
}

static void
_preferences_dialog_on_dir_pattern_entry_changed_gtk_editable_changed (GtkEditable* _sender,
                                                                       gpointer self)
{
	preferences_dialog_on_dir_pattern_entry_changed ((PreferencesDialog*) self);
}

static void
_preferences_dialog_on_lowercase_toggled_gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                                                    gpointer self)
{
	preferences_dialog_on_lowercase_toggled ((PreferencesDialog*) self);
}

static void
_preferences_dialog_on_photo_editor_changed_gtk_combo_box_changed (GtkComboBox* _sender,
                                                                   gpointer self)
{
	preferences_dialog_on_photo_editor_changed ((PreferencesDialog*) self);
}

static void
_preferences_dialog_on_raw_editor_changed_gtk_combo_box_changed (GtkComboBox* _sender,
                                                                 gpointer self)
{
	preferences_dialog_on_raw_editor_changed ((PreferencesDialog*) self);
}

static void
_preferences_dialog_on_default_raw_developer_changed_gtk_combo_box_changed (GtkComboBox* _sender,
                                                                            gpointer self)
{
	preferences_dialog_on_default_raw_developer_changed ((PreferencesDialog*) self);
}

static void
_preferences_dialog_on_theme_variant_changed_g_object_notify (GObject* _sender,
                                                              GParamSpec* pspec,
                                                              gpointer self)
{
	preferences_dialog_on_theme_variant_changed ((PreferencesDialog*) self, _sender, pspec);
}

static PreferencesDialog*
preferences_dialog_construct (GType object_type)
{
	PreferencesDialog * self = NULL;
	AppWindow* _tmp0_;
	AppWindow* _tmp1_;
	GdkWindow* _tmp2_;
	AppWindow* _tmp3_;
	AppWindow* _tmp4_;
	GtkRadioButton* _tmp5_;
	GtkRadioButton* _tmp6_;
	GtkRadioButton* _tmp7_;
	GtkRadioButton* _tmp8_;
	GtkColorButton* _tmp9_;
	GdkRGBA color = {0};
	ConfigFacade* _tmp10_;
	ConfigFacade* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	GtkColorButton* _tmp14_;
	GdkRGBA _tmp15_;
	GtkColorButton* _tmp16_;
	ConfigFacade* _tmp17_;
	ConfigFacade* _tmp18_;
	gchar* _tmp19_;
	gchar* _tmp20_;
	gchar* _tmp21_;
	GQuark _tmp23_ = 0U;
	static GQuark _tmp22_label0 = 0;
	static GQuark _tmp22_label1 = 0;
	gchar* help_path = NULL;
	gchar* _tmp27_;
	const gchar* _tmp28_;
	gchar* _tmp36_;
	gchar* _tmp37_;
	gchar* _tmp38_;
	gchar* _tmp39_;
	gchar* _tmp40_;
	gchar* _tmp41_;
	GtkComboBoxText* _tmp42_;
	GtkEntry* _tmp43_;
	GtkCheckButton* _tmp44_;
	GtkStack* _tmp45_;
	GtkWidget* _tmp46_;
	PluginsManifestWidgetMediator* _tmp47_;
	GtkStack* _tmp48_;
	GtkWidget* _tmp49_;
	ShotwellProfileBrowser* _tmp50_;
	ShotwellProfileBrowser* _tmp51_;
	GtkComboBox* _tmp52_;
	GtkComboBox* _tmp53_;
	GtkCheckButton* _tmp54_;
	ConfigFacade* _tmp55_;
	ConfigFacade* _tmp56_;
	GtkCheckButton* _tmp57_;
	ConfigFacade* _tmp58_;
	ConfigFacade* _tmp59_;
	GtkComboBoxText* _tmp60_;
	gchar* _tmp61_;
	gchar* _tmp62_;
	GtkComboBoxText* _tmp63_;
	gchar* _tmp64_;
	gchar* _tmp65_;
	ConfigFacade* _tmp66_;
	ConfigFacade* _tmp67_;
	GtkComboBoxText* _tmp68_;
	GtkSwitch* _tmp69_;
	GtkSettings* _tmp70_;
	gboolean _tmp71_;
	gboolean _tmp72_;
	GtkSwitch* _tmp73_;
	self = (PreferencesDialog*) g_object_new (object_type, "use-header-bar", resources_use_header_bar (), NULL);
	_tmp0_ = app_window_get_instance ();
	_tmp1_ = _tmp0_;
	_tmp2_ = gtk_widget_get_parent_window (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_widget_get_type (), GtkWidget));
	gtk_widget_set_parent_window (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), _tmp2_);
	_g_object_unref0 (_tmp1_);
	_tmp3_ = app_window_get_instance ();
	_tmp4_ = _tmp3_;
	gtk_window_set_transient_for (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_window_get_type (), GtkWindow), G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, gtk_window_get_type (), GtkWindow));
	_g_object_unref0 (_tmp4_);
	g_signal_connect_object (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), "delete-event", (GCallback) _preferences_dialog_on_delete_gtk_widget_delete_event, self, 0);
	g_signal_connect_object (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_dialog_get_type (), GtkDialog), "response", (GCallback) _preferences_dialog_on_close_gtk_dialog_response, self, 0);
	_tmp5_ = self->priv->transparent_checker_radio;
	g_signal_connect_object (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, gtk_toggle_button_get_type (), GtkToggleButton), "toggled", (GCallback) _preferences_dialog_on_radio_changed_gtk_toggle_button_toggled, self, 0);
	_tmp6_ = self->priv->transparent_solid_radio;
	g_signal_connect_object (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, gtk_toggle_button_get_type (), GtkToggleButton), "toggled", (GCallback) _preferences_dialog_on_radio_changed_gtk_toggle_button_toggled, self, 0);
	_tmp7_ = self->priv->transparent_none_radio;
	g_signal_connect_object (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, gtk_toggle_button_get_type (), GtkToggleButton), "toggled", (GCallback) _preferences_dialog_on_radio_changed_gtk_toggle_button_toggled, self, 0);
	_tmp8_ = self->priv->transparent_solid_radio;
	_tmp9_ = self->priv->transparent_solid_color;
	g_object_bind_property_with_closures (G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, G_TYPE_OBJECT, GObject), "active", G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, G_TYPE_OBJECT, GObject), "sensitive", G_BINDING_DEFAULT, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	memset (&color, 0, sizeof (GdkRGBA));
	_tmp10_ = config_facade_get_instance ();
	_tmp11_ = _tmp10_;
	_tmp12_ = configuration_facade_get_transparent_background_color (G_TYPE_CHECK_INSTANCE_CAST (_tmp11_, TYPE_CONFIGURATION_FACADE, ConfigurationFacade));
	_tmp13_ = _tmp12_;
	gdk_rgba_parse (&color, _tmp13_);
	_g_free0 (_tmp13_);
	_g_object_unref0 (_tmp11_);
	_tmp14_ = self->priv->transparent_solid_color;
	_tmp15_ = color;
	gtk_color_chooser_set_rgba (G_TYPE_CHECK_INSTANCE_CAST (_tmp14_, gtk_color_chooser_get_type (), GtkColorChooser), &_tmp15_);
	_tmp16_ = self->priv->transparent_solid_color;
	g_signal_connect_object (_tmp16_, "color-set", (GCallback) _preferences_dialog_on_color_changed_gtk_color_button_color_set, self, 0);
	_tmp17_ = config_facade_get_instance ();
	_tmp18_ = _tmp17_;
	_tmp19_ = configuration_facade_get_transparent_background_type (G_TYPE_CHECK_INSTANCE_CAST (_tmp18_, TYPE_CONFIGURATION_FACADE, ConfigurationFacade));
	_tmp20_ = _tmp19_;
	_g_object_unref0 (_tmp18_);
	_tmp21_ = _tmp20_;
	_tmp23_ = (NULL == _tmp21_) ? 0 : g_quark_from_string (_tmp21_);
	g_free (_tmp21_);
	if (_tmp23_ == ((0 != _tmp22_label0) ? _tmp22_label0 : (_tmp22_label0 = g_quark_from_static_string ("checkered")))) {
		switch (0) {
			default:
			{
				GtkRadioButton* _tmp24_;
				_tmp24_ = self->priv->transparent_checker_radio;
				gtk_toggle_button_set_active (G_TYPE_CHECK_INSTANCE_CAST (_tmp24_, gtk_toggle_button_get_type (), GtkToggleButton), TRUE);
				break;
			}
		}
	} else if (_tmp23_ == ((0 != _tmp22_label1) ? _tmp22_label1 : (_tmp22_label1 = g_quark_from_static_string ("solid")))) {
		switch (0) {
			default:
			{
				GtkRadioButton* _tmp25_;
				_tmp25_ = self->priv->transparent_solid_radio;
				gtk_toggle_button_set_active (G_TYPE_CHECK_INSTANCE_CAST (_tmp25_, gtk_toggle_button_get_type (), GtkToggleButton), TRUE);
				break;
			}
		}
	} else {
		switch (0) {
			default:
			{
				GtkRadioButton* _tmp26_;
				_tmp26_ = self->priv->transparent_none_radio;
				gtk_toggle_button_set_active (G_TYPE_CHECK_INSTANCE_CAST (_tmp26_, gtk_toggle_button_get_type (), GtkToggleButton), TRUE);
				break;
			}
		}
	}
	_tmp27_ = resources_get_help_path ();
	help_path = _tmp27_;
	_tmp28_ = help_path;
	if (_tmp28_ == NULL) {
		GtkLabel* _tmp29_;
		gchar* _tmp30_;
		gchar* _tmp31_;
		_tmp29_ = self->priv->pattern_help;
		_tmp30_ = g_strdup_printf ("<a href=\"%s\">%s</a>", RESOURCES_DIR_PATTERN_URI_SYSWIDE, _ ("(Help)"));
		_tmp31_ = _tmp30_;
		gtk_label_set_markup (_tmp29_, _tmp31_);
		_g_free0 (_tmp31_);
	} else {
		GtkLabel* _tmp32_;
		gchar* _tmp33_;
		gchar* _tmp34_;
		GtkLabel* _tmp35_;
		_tmp32_ = self->priv->pattern_help;
		_tmp33_ = g_strdup_printf ("<a href=\"dummy:\">%s</a>", _ ("(Help)"));
		_tmp34_ = _tmp33_;
		gtk_label_set_markup (_tmp32_, _tmp34_);
		_g_free0 (_tmp34_);
		_tmp35_ = self->priv->pattern_help;
		g_signal_connect_object (_tmp35_, "activate-link", (GCallback) _preferences_dialog_on_local_pattern_help_gtk_label_activate_link, self, 0);
	}
	_tmp36_ = g_strdup_printf (_ ("Year%sMonth%sDay"), G_DIR_SEPARATOR_S, G_DIR_SEPARATOR_S);
	_tmp37_ = _tmp36_;
	preferences_dialog_add_to_dir_formats (self, _tmp37_, "%Y" G_DIR_SEPARATOR_S "%m" G_DIR_SEPARATOR_S "%d");
	_g_free0 (_tmp37_);
	_tmp38_ = g_strdup_printf (_ ("Year%sMonth"), G_DIR_SEPARATOR_S);
	_tmp39_ = _tmp38_;
	preferences_dialog_add_to_dir_formats (self, _tmp39_, "%Y" G_DIR_SEPARATOR_S "%m");
	_g_free0 (_tmp39_);
	_tmp40_ = g_strdup_printf (_ ("Year%sMonth-Day"), G_DIR_SEPARATOR_S);
	_tmp41_ = _tmp40_;
	preferences_dialog_add_to_dir_formats (self, _tmp41_, "%Y" G_DIR_SEPARATOR_S "%m-%d");
	_g_free0 (_tmp41_);
	preferences_dialog_add_to_dir_formats (self, _ ("Year-Month-Day"), "%Y-%m-%d");
	preferences_dialog_add_to_dir_formats (self, _ ("Custom"), NULL);
	_tmp42_ = self->priv->dir_pattern_combo;
	g_signal_connect_object (G_TYPE_CHECK_INSTANCE_CAST (_tmp42_, gtk_combo_box_get_type (), GtkComboBox), "changed", (GCallback) _preferences_dialog_on_dir_pattern_combo_changed_gtk_combo_box_changed, self, 0);
	_tmp43_ = self->priv->dir_pattern_entry;
	g_signal_connect_object (G_TYPE_CHECK_INSTANCE_CAST (_tmp43_, gtk_editable_get_type (), GtkEditable), "changed", (GCallback) _preferences_dialog_on_dir_pattern_entry_changed_gtk_editable_changed, self, 0);
	_tmp44_ = self->priv->lowercase;
	g_signal_connect_object (G_TYPE_CHECK_INSTANCE_CAST (_tmp44_, gtk_toggle_button_get_type (), GtkToggleButton), "toggled", (GCallback) _preferences_dialog_on_lowercase_toggled_gtk_toggle_button_toggled, self, 0);
	_tmp45_ = self->priv->preferences_stack;
	_tmp46_ = gtk_stack_get_child_by_name (_tmp45_, "plugins");
	_tmp47_ = self->priv->plugins_mediator;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (G_TYPE_CHECK_INSTANCE_CAST (_tmp46_, gtk_box_get_type (), GtkBox), gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp47_, gtk_widget_get_type (), GtkWidget));
	_tmp48_ = self->priv->preferences_stack;
	_tmp49_ = gtk_stack_get_child_by_name (_tmp48_, "profiles");
	_tmp50_ = shotwell_profile_browser_new ();
	g_object_ref_sink (_tmp50_);
	_tmp51_ = _tmp50_;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (G_TYPE_CHECK_INSTANCE_CAST (_tmp49_, gtk_box_get_type (), GtkBox), gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp51_, gtk_widget_get_type (), GtkWidget));
	_g_object_unref0 (_tmp51_);
	preferences_dialog_populate_preference_options (self);
	_tmp52_ = self->priv->photo_editor_combo;
	g_signal_connect_object (_tmp52_, "changed", (GCallback) _preferences_dialog_on_photo_editor_changed_gtk_combo_box_changed, self, 0);
	_tmp53_ = self->priv->raw_editor_combo;
	g_signal_connect_object (_tmp53_, "changed", (GCallback) _preferences_dialog_on_raw_editor_changed_gtk_combo_box_changed, self, 0);
	_tmp54_ = self->priv->autoimport;
	_tmp55_ = config_facade_get_instance ();
	_tmp56_ = _tmp55_;
	gtk_toggle_button_set_active (G_TYPE_CHECK_INSTANCE_CAST (_tmp54_, gtk_toggle_button_get_type (), GtkToggleButton), configuration_facade_get_auto_import_from_library (G_TYPE_CHECK_INSTANCE_CAST (_tmp56_, TYPE_CONFIGURATION_FACADE, ConfigurationFacade)));
	_g_object_unref0 (_tmp56_);
	_tmp57_ = self->priv->write_metadata;
	_tmp58_ = config_facade_get_instance ();
	_tmp59_ = _tmp58_;
	gtk_toggle_button_set_active (G_TYPE_CHECK_INSTANCE_CAST (_tmp57_, gtk_toggle_button_get_type (), GtkToggleButton), configuration_facade_get_commit_metadata_to_masters (G_TYPE_CHECK_INSTANCE_CAST (_tmp59_, TYPE_CONFIGURATION_FACADE, ConfigurationFacade)));
	_g_object_unref0 (_tmp59_);
	_tmp60_ = self->priv->default_raw_developer_combo;
	_tmp61_ = raw_developer_get_label (RAW_DEVELOPER_CAMERA);
	_tmp62_ = _tmp61_;
	gtk_combo_box_text_append_text (_tmp60_, _tmp62_);
	_g_free0 (_tmp62_);
	_tmp63_ = self->priv->default_raw_developer_combo;
	_tmp64_ = raw_developer_get_label (RAW_DEVELOPER_SHOTWELL);
	_tmp65_ = _tmp64_;
	gtk_combo_box_text_append_text (_tmp63_, _tmp65_);
	_g_free0 (_tmp65_);
	_tmp66_ = config_facade_get_instance ();
	_tmp67_ = _tmp66_;
	preferences_dialog_set_raw_developer_combo (self, configuration_facade_get_default_raw_developer (G_TYPE_CHECK_INSTANCE_CAST (_tmp67_, TYPE_CONFIGURATION_FACADE, ConfigurationFacade)));
	_g_object_unref0 (_tmp67_);
	_tmp68_ = self->priv->default_raw_developer_combo;
	g_signal_connect_object (G_TYPE_CHECK_INSTANCE_CAST (_tmp68_, gtk_combo_box_get_type (), GtkComboBox), "changed", (GCallback) _preferences_dialog_on_default_raw_developer_changed_gtk_combo_box_changed, self, 0);
	_tmp69_ = self->priv->switch_dark;
	_tmp70_ = gtk_settings_get_default ();
	g_object_get (_tmp70_, "gtk-application-prefer-dark-theme", &_tmp71_, NULL);
	_tmp72_ = _tmp71_;
	gtk_switch_set_active (_tmp69_, _tmp72_);
	_tmp73_ = self->priv->switch_dark;
	g_signal_connect_object (G_TYPE_CHECK_INSTANCE_CAST (_tmp73_, G_TYPE_OBJECT, GObject), "notify::active", (GCallback) _preferences_dialog_on_theme_variant_changed_g_object_notify, self, 0);
	_g_free0 (help_path);
	return self;
}

static PreferencesDialog*
preferences_dialog_new (void)
{
	return preferences_dialog_construct (TYPE_PREFERENCES_DIALOG);
}

void
preferences_dialog_populate_preference_options (PreferencesDialog* self)
{
	GtkComboBox* _tmp0_;
	gint _tmp1_ = 0;
	gchar** _tmp2_;
	gchar** _tmp3_;
	gint _tmp3__length1;
	ConfigFacade* _tmp4_;
	ConfigFacade* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	SortedList* _tmp8_ = NULL;
	GtkComboBox* _tmp9_;
	gint _tmp10_ = 0;
	gchar** _tmp11_;
	gchar** _tmp12_;
	gint _tmp12__length1;
	ConfigFacade* _tmp13_;
	ConfigFacade* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	SortedList* _tmp17_ = NULL;
	GtkComboBoxText* _tmp18_;
	GtkEntry* _tmp19_;
	GtkCheckButton* _tmp20_;
	ConfigFacade* _tmp21_;
	ConfigFacade* _tmp22_;
	g_return_if_fail (IS_PREFERENCES_DIALOG (self));
	_tmp0_ = self->priv->photo_editor_combo;
	_tmp2_ = photo_file_format_get_editable_mime_types (&_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp3__length1 = _tmp1_;
	_tmp4_ = config_facade_get_instance ();
	_tmp5_ = _tmp4_;
	_tmp6_ = configuration_facade_get_external_photo_app (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, TYPE_CONFIGURATION_FACADE, ConfigurationFacade));
	_tmp7_ = _tmp6_;
	preferences_dialog_populate_app_combo_box (self, _tmp0_, _tmp3_, (gint) _tmp1_, _tmp7_, &_tmp8_);
	_g_object_unref0 (self->priv->external_photo_apps);
	self->priv->external_photo_apps = _tmp8_;
	_g_free0 (_tmp7_);
	_g_object_unref0 (_tmp5_);
	_tmp3_ = (_vala_array_free (_tmp3_, _tmp3__length1, (GDestroyNotify) g_free), NULL);
	_tmp9_ = self->priv->raw_editor_combo;
	_tmp11_ = photo_file_format_get_mime_types (PHOTO_FILE_FORMAT_RAW, &_tmp10_);
	_tmp12_ = _tmp11_;
	_tmp12__length1 = _tmp10_;
	_tmp13_ = config_facade_get_instance ();
	_tmp14_ = _tmp13_;
	_tmp15_ = configuration_facade_get_external_raw_app (G_TYPE_CHECK_INSTANCE_CAST (_tmp14_, TYPE_CONFIGURATION_FACADE, ConfigurationFacade));
	_tmp16_ = _tmp15_;
	preferences_dialog_populate_app_combo_box (self, _tmp9_, _tmp12_, (gint) _tmp10_, _tmp16_, &_tmp17_);
	_g_object_unref0 (self->priv->external_raw_apps);
	self->priv->external_raw_apps = _tmp17_;
	_g_free0 (_tmp16_);
	_g_object_unref0 (_tmp14_);
	_tmp12_ = (_vala_array_free (_tmp12_, _tmp12__length1, (GDestroyNotify) g_free), NULL);
	_tmp18_ = self->priv->dir_pattern_combo;
	_tmp19_ = self->priv->dir_pattern_entry;
	preferences_dialog_setup_dir_pattern (self, G_TYPE_CHECK_INSTANCE_CAST (_tmp18_, gtk_combo_box_get_type (), GtkComboBox), _tmp19_);
	_tmp20_ = self->priv->lowercase;
	_tmp21_ = config_facade_get_instance ();
	_tmp22_ = _tmp21_;
	gtk_toggle_button_set_active (G_TYPE_CHECK_INSTANCE_CAST (_tmp20_, gtk_toggle_button_get_type (), GtkToggleButton), configuration_facade_get_use_lowercase_filenames (G_TYPE_CHECK_INSTANCE_CAST (_tmp22_, TYPE_CONFIGURATION_FACADE, ConfigurationFacade)));
	_g_object_unref0 (_tmp22_);
}

static void
preferences_dialog_on_theme_variant_changed (PreferencesDialog* self,
                                             GObject* o,
                                             GParamSpec* ps)
{
	ConfigFacade* config = NULL;
	ConfigFacade* _tmp0_;
	GtkSwitch* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	GtkSettings* _tmp4_;
	GtkSwitch* _tmp5_;
	gboolean _tmp6_;
	gboolean _tmp7_;
	g_return_if_fail (IS_PREFERENCES_DIALOG (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (o, G_TYPE_OBJECT));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (ps, G_TYPE_PARAM));
	_tmp0_ = config_facade_get_instance ();
	config = _tmp0_;
	_tmp1_ = self->priv->switch_dark;
	_tmp2_ = gtk_switch_get_active (_tmp1_);
	_tmp3_ = _tmp2_;
	configuration_facade_set_gtk_theme_variant (G_TYPE_CHECK_INSTANCE_CAST (config, TYPE_CONFIGURATION_FACADE, ConfigurationFacade), _tmp3_);
	_tmp4_ = gtk_settings_get_default ();
	_tmp5_ = self->priv->switch_dark;
	_tmp6_ = gtk_switch_get_active (_tmp5_);
	_tmp7_ = _tmp6_;
	g_object_set (_tmp4_, "gtk-application-prefer-dark-theme", _tmp7_, NULL);
	_g_object_unref0 (config);
}

static void
preferences_dialog_on_radio_changed (PreferencesDialog* self)
{
	ConfigFacade* config = NULL;
	ConfigFacade* _tmp0_;
	GtkRadioButton* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	g_return_if_fail (IS_PREFERENCES_DIALOG (self));
	_tmp0_ = config_facade_get_instance ();
	config = _tmp0_;
	_tmp1_ = self->priv->transparent_checker_radio;
	_tmp2_ = gtk_toggle_button_get_active (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_toggle_button_get_type (), GtkToggleButton));
	_tmp3_ = _tmp2_;
	if (_tmp3_) {
		ConfigFacade* _tmp4_;
		_tmp4_ = config;
		configuration_facade_set_transparent_background_type (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, TYPE_CONFIGURATION_FACADE, ConfigurationFacade), "checkered");
	} else {
		GtkRadioButton* _tmp5_;
		gboolean _tmp6_;
		gboolean _tmp7_;
		_tmp5_ = self->priv->transparent_solid_radio;
		_tmp6_ = gtk_toggle_button_get_active (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, gtk_toggle_button_get_type (), GtkToggleButton));
		_tmp7_ = _tmp6_;
		if (_tmp7_) {
			ConfigFacade* _tmp8_;
			_tmp8_ = config;
			configuration_facade_set_transparent_background_type (G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, TYPE_CONFIGURATION_FACADE, ConfigurationFacade), "solid");
		} else {
			ConfigFacade* _tmp9_;
			_tmp9_ = config;
			configuration_facade_set_transparent_background_type (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, TYPE_CONFIGURATION_FACADE, ConfigurationFacade), "none");
		}
	}
	_g_object_unref0 (config);
}

static void
preferences_dialog_on_color_changed (PreferencesDialog* self)
{
	gchar* color = NULL;
	GtkColorButton* _tmp0_;
	GdkRGBA _tmp1_ = {0};
	GdkRGBA _tmp2_;
	gchar* _tmp3_;
	ConfigFacade* _tmp4_;
	ConfigFacade* _tmp5_;
	g_return_if_fail (IS_PREFERENCES_DIALOG (self));
	_tmp0_ = self->priv->transparent_solid_color;
	gtk_color_chooser_get_rgba (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, gtk_color_chooser_get_type (), GtkColorChooser), &_tmp1_);
	_tmp2_ = _tmp1_;
	_tmp3_ = gdk_rgba_to_string (&_tmp2_);
	color = _tmp3_;
	_tmp4_ = config_facade_get_instance ();
	_tmp5_ = _tmp4_;
	configuration_facade_set_transparent_background_color (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, TYPE_CONFIGURATION_FACADE, ConfigurationFacade), color);
	_g_object_unref0 (_tmp5_);
	_g_free0 (color);
}

static gboolean
preferences_dialog_on_local_pattern_help (PreferencesDialog* self,
                                          const gchar* ignore)
{
	GError* _inner_error0_ = NULL;
	gboolean result;
	g_return_val_if_fail (IS_PREFERENCES_DIALOG (self), FALSE);
	g_return_val_if_fail (ignore != NULL, FALSE);
	{
		AppWindow* _tmp0_;
		AppWindow* _tmp1_;
		_tmp0_ = app_window_get_instance ();
		_tmp1_ = _tmp0_;
		resources_launch_help (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_window_get_type (), GtkWindow), "other-files.page", &_inner_error0_);
		_g_object_unref0 (_tmp1_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp2_;
		const gchar* _tmp3_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp2_ = e;
		_tmp3_ = _tmp2_->message;
		g_message ("Preferences.vala:192: Unable to launch help: %s", _tmp3_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp4_ = FALSE;
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return _tmp4_;
	}
	result = TRUE;
	return result;
}

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

static void
preferences_dialog_populate_app_combo_box (PreferencesDialog* self,
                                           GtkComboBox* combo_box,
                                           gchar** mime_types,
                                           gint mime_types_length1,
                                           const gchar* current_app_executable,
                                           SortedList** external_apps)
{
	SortedList* _vala_external_apps = NULL;
	SortedList* _tmp0_;
	SortedList* _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	GtkCellRendererPixbuf* pixbuf_renderer = NULL;
	GtkCellRendererPixbuf* _tmp4_;
	GtkCellRendererText* text_renderer = NULL;
	GtkCellRendererText* _tmp5_;
	GtkCellRendererPixbuf* _tmp6_;
	GtkCellRendererText* _tmp7_;
	GtkCellRendererPixbuf* _tmp8_;
	GtkCellRendererText* _tmp9_;
	GtkListStore* combo_store = NULL;
	GtkListStore* _tmp10_;
	GtkTreeIter iter = {0};
	gint current_app = 0;
	GtkListStore* _tmp57_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (IS_PREFERENCES_DIALOG (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (combo_box, gtk_combo_box_get_type ()));
	g_return_if_fail (current_app_executable != NULL);
	_vala_assert (mime_types_length1 != 0, "mime_types.length != 0");
	_tmp0_ = desktop_integration_get_apps_for_mime_types (mime_types, (gint) mime_types_length1);
	_g_object_unref0 (_vala_external_apps);
	_vala_external_apps = _tmp0_;
	_tmp1_ = _vala_external_apps;
	_tmp2_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEE_TYPE_COLLECTION, GeeCollection));
	_tmp3_ = _tmp2_;
	if (_tmp3_ == 0) {
		if (external_apps) {
			*external_apps = _vala_external_apps;
		} else {
			_g_object_unref0 (_vala_external_apps);
		}
		return;
	}
	_tmp4_ = (GtkCellRendererPixbuf*) gtk_cell_renderer_pixbuf_new ();
	g_object_ref_sink (_tmp4_);
	pixbuf_renderer = _tmp4_;
	_tmp5_ = (GtkCellRendererText*) gtk_cell_renderer_text_new ();
	g_object_ref_sink (_tmp5_);
	text_renderer = _tmp5_;
	gtk_cell_layout_clear (G_TYPE_CHECK_INSTANCE_CAST (combo_box, gtk_cell_layout_get_type (), GtkCellLayout));
	_tmp6_ = pixbuf_renderer;
	gtk_cell_layout_pack_start (G_TYPE_CHECK_INSTANCE_CAST (combo_box, gtk_cell_layout_get_type (), GtkCellLayout), G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, gtk_cell_renderer_get_type (), GtkCellRenderer), FALSE);
	_tmp7_ = text_renderer;
	gtk_cell_layout_pack_start (G_TYPE_CHECK_INSTANCE_CAST (combo_box, gtk_cell_layout_get_type (), GtkCellLayout), G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, gtk_cell_renderer_get_type (), GtkCellRenderer), FALSE);
	_tmp8_ = pixbuf_renderer;
	gtk_cell_layout_add_attribute (G_TYPE_CHECK_INSTANCE_CAST (combo_box, gtk_cell_layout_get_type (), GtkCellLayout), G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, gtk_cell_renderer_get_type (), GtkCellRenderer), "pixbuf", 0);
	_tmp9_ = text_renderer;
	gtk_cell_layout_add_attribute (G_TYPE_CHECK_INSTANCE_CAST (combo_box, gtk_cell_layout_get_type (), GtkCellLayout), G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, gtk_cell_renderer_get_type (), GtkCellRenderer), "text", 1);
	_tmp10_ = gtk_list_store_new (2, gdk_pixbuf_get_type (), G_TYPE_STRING, -1);
	combo_store = _tmp10_;
	current_app = -1;
	{
		GeeIterator* _app_it = NULL;
		SortedList* _tmp11_;
		GeeIterator* _tmp12_;
		_tmp11_ = _vala_external_apps;
		_tmp12_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp11_, GEE_TYPE_ITERABLE, GeeIterable));
		_app_it = _tmp12_;
		while (TRUE) {
			GeeIterator* _tmp13_;
			GAppInfo* app = NULL;
			GeeIterator* _tmp14_;
			gpointer _tmp15_;
			GtkListStore* _tmp16_;
			GtkTreeIter _tmp17_ = {0};
			GIcon* app_icon = NULL;
			GAppInfo* _tmp18_;
			GIcon* _tmp19_;
			GIcon* _tmp20_;
			GtkListStore* _tmp48_;
			GtkTreeIter _tmp49_;
			GAppInfo* _tmp50_;
			const gchar* _tmp51_;
			GValue _tmp52_ = {0};
			GAppInfo* _tmp53_;
			const gchar* _tmp54_;
			_tmp13_ = _app_it;
			if (!gee_iterator_next (_tmp13_)) {
				break;
			}
			_tmp14_ = _app_it;
			_tmp15_ = gee_iterator_get (_tmp14_);
			app = (GAppInfo*) _tmp15_;
			_tmp16_ = combo_store;
			gtk_list_store_append (_tmp16_, &_tmp17_);
			iter = _tmp17_;
			_tmp18_ = app;
			_tmp19_ = g_app_info_get_icon (_tmp18_);
			_tmp20_ = _g_object_ref0 (_tmp19_);
			app_icon = _tmp20_;
			{
				GIcon* _tmp21_;
				_tmp21_ = app_icon;
				if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp21_, g_file_icon_get_type ())) {
					GdkPixbuf* _tmp22_ = NULL;
					GIcon* _tmp23_;
					GFile* _tmp24_;
					gchar* _tmp25_;
					gchar* _tmp26_;
					GdkPixbuf* _tmp27_;
					GdkPixbuf* _tmp28_;
					GtkListStore* _tmp29_;
					GtkTreeIter _tmp30_;
					GdkPixbuf* _tmp31_;
					GValue _tmp32_ = {0};
					_tmp23_ = app_icon;
					_tmp24_ = g_file_icon_get_file (G_TYPE_CHECK_INSTANCE_CAST (_tmp23_, g_file_icon_get_type (), GFileIcon));
					_tmp25_ = g_file_get_path (_tmp24_);
					_tmp26_ = _tmp25_;
					_tmp27_ = gdk_pixbuf_new_from_file (_tmp26_, &_inner_error0_);
					_tmp28_ = _tmp27_;
					_g_free0 (_tmp26_);
					_tmp22_ = _tmp28_;
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						goto __catch0_g_error;
					}
					_tmp29_ = combo_store;
					_tmp30_ = iter;
					_tmp31_ = scale_pixbuf (_tmp22_, RESOURCES_DEFAULT_ICON_SCALE, GDK_INTERP_BILINEAR, FALSE);
					g_value_init (&_tmp32_, gdk_pixbuf_get_type ());
					g_value_take_object (&_tmp32_, _tmp31_);
					gtk_list_store_set_value (_tmp29_, &_tmp30_, 0, &_tmp32_);
					G_IS_VALUE (&_tmp32_) ? (g_value_unset (&_tmp32_), NULL) : NULL;
					_g_object_unref0 (_tmp22_);
				} else {
					GIcon* _tmp33_;
					_tmp33_ = app_icon;
					if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp33_, g_themed_icon_get_type ())) {
						GdkPixbuf* icon_pixbuf = NULL;
						GtkIconTheme* _tmp34_;
						GIcon* _tmp35_;
						gchar** _tmp36_;
						gchar** _tmp37_;
						const gchar* _tmp38_;
						GdkPixbuf* _tmp39_;
						GtkListStore* _tmp40_;
						GtkTreeIter _tmp41_;
						GdkPixbuf* _tmp42_;
						GValue _tmp43_ = {0};
						_tmp34_ = gtk_icon_theme_get_default ();
						_tmp35_ = app_icon;
						_tmp37_ = _tmp36_ = g_themed_icon_get_names (G_TYPE_CHECK_INSTANCE_CAST (_tmp35_, g_themed_icon_get_type (), GThemedIcon));
						_tmp38_ = _tmp37_[0];
						_tmp39_ = gtk_icon_theme_load_icon (_tmp34_, _tmp38_, RESOURCES_DEFAULT_ICON_SCALE, GTK_ICON_LOOKUP_FORCE_SIZE, &_inner_error0_);
						icon_pixbuf = _tmp39_;
						if (G_UNLIKELY (_inner_error0_ != NULL)) {
							goto __catch0_g_error;
						}
						_tmp40_ = combo_store;
						_tmp41_ = iter;
						_tmp42_ = icon_pixbuf;
						g_value_init (&_tmp43_, gdk_pixbuf_get_type ());
						g_value_set_object (&_tmp43_, _tmp42_);
						gtk_list_store_set_value (_tmp40_, &_tmp41_, 0, &_tmp43_);
						G_IS_VALUE (&_tmp43_) ? (g_value_unset (&_tmp43_), NULL) : NULL;
						_g_object_unref0 (icon_pixbuf);
					}
				}
			}
			goto __finally0;
			__catch0_g_error:
			{
				GError* _error_ = NULL;
				GError* _tmp44_;
				const gchar* _tmp45_;
				gchar* _tmp46_;
				gchar* _tmp47_;
				_error_ = _inner_error0_;
				_inner_error0_ = NULL;
				_tmp44_ = _error_;
				_tmp45_ = _tmp44_->message;
				_tmp46_ = g_strconcat ("Error loading icon pixbuf: ", _tmp45_, NULL);
				_tmp47_ = _tmp46_;
				g_warning ("Preferences.vala:238: %s", _tmp47_);
				_g_free0 (_tmp47_);
				_g_error_free0 (_error_);
			}
			__finally0:
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_g_object_unref0 (app_icon);
				_g_object_unref0 (app);
				_g_object_unref0 (_app_it);
				_g_object_unref0 (combo_store);
				_g_object_unref0 (text_renderer);
				_g_object_unref0 (pixbuf_renderer);
				_g_object_unref0 (_vala_external_apps);
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
				g_clear_error (&_inner_error0_);
				return;
			}
			_tmp48_ = combo_store;
			_tmp49_ = iter;
			_tmp50_ = app;
			_tmp51_ = g_app_info_get_name (_tmp50_);
			g_value_init (&_tmp52_, G_TYPE_STRING);
			g_value_set_string (&_tmp52_, _tmp51_);
			gtk_list_store_set_value (_tmp48_, &_tmp49_, 1, &_tmp52_);
			G_IS_VALUE (&_tmp52_) ? (g_value_unset (&_tmp52_), NULL) : NULL;
			_tmp53_ = app;
			_tmp54_ = g_app_info_get_commandline (_tmp53_);
			if (g_strcmp0 (_tmp54_, current_app_executable) == 0) {
				SortedList* _tmp55_;
				GAppInfo* _tmp56_;
				_tmp55_ = _vala_external_apps;
				_tmp56_ = app;
				current_app = sorted_list_index_of (_tmp55_, _tmp56_);
			}
			_g_object_unref0 (app_icon);
			_g_object_unref0 (app);
		}
		_g_object_unref0 (_app_it);
	}
	_tmp57_ = combo_store;
	gtk_combo_box_set_model (combo_box, G_TYPE_CHECK_INSTANCE_CAST (_tmp57_, gtk_tree_model_get_type (), GtkTreeModel));
	if (current_app != -1) {
		gtk_combo_box_set_active (combo_box, current_app);
	}
	_g_object_unref0 (combo_store);
	_g_object_unref0 (text_renderer);
	_g_object_unref0 (pixbuf_renderer);
	if (external_apps) {
		*external_apps = _vala_external_apps;
	} else {
		_g_object_unref0 (_vala_external_apps);
	}
}

static void
preferences_dialog_setup_dir_pattern (PreferencesDialog* self,
                                      GtkComboBox* combo_box,
                                      GtkEntry* entry)
{
	gchar* pattern = NULL;
	ConfigFacade* _tmp0_;
	ConfigFacade* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gboolean found = FALSE;
	const gchar* _tmp4_;
	g_return_if_fail (IS_PREFERENCES_DIALOG (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (combo_box, gtk_combo_box_get_type ()));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (entry, gtk_entry_get_type ()));
	_tmp0_ = config_facade_get_instance ();
	_tmp1_ = _tmp0_;
	_tmp2_ = configuration_facade_get_directory_pattern (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, TYPE_CONFIGURATION_FACADE, ConfigurationFacade));
	_tmp3_ = _tmp2_;
	_g_object_unref0 (_tmp1_);
	pattern = _tmp3_;
	found = FALSE;
	_tmp4_ = pattern;
	if (NULL != _tmp4_) {
		gint i = 0;
		i = 0;
		{
			GeeArrayList* _pf_list = NULL;
			GeeArrayList* _tmp5_;
			gint _pf_size = 0;
			GeeArrayList* _tmp6_;
			gint _tmp7_;
			gint _tmp8_;
			gint _pf_index = 0;
			_tmp5_ = self->priv->path_formats;
			_pf_list = _tmp5_;
			_tmp6_ = _pf_list;
			_tmp7_ = gee_abstract_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection));
			_tmp8_ = _tmp7_;
			_pf_size = _tmp8_;
			_pf_index = -1;
			while (TRUE) {
				gint _tmp9_;
				gint _tmp10_;
				PreferencesDialogPathFormat* pf = NULL;
				GeeArrayList* _tmp11_;
				gpointer _tmp12_;
				PreferencesDialogPathFormat* _tmp13_;
				const gchar* _tmp14_;
				const gchar* _tmp15_;
				gint _tmp16_;
				_pf_index = _pf_index + 1;
				_tmp9_ = _pf_index;
				_tmp10_ = _pf_size;
				if (!(_tmp9_ < _tmp10_)) {
					break;
				}
				_tmp11_ = _pf_list;
				_tmp12_ = gee_abstract_list_get (G_TYPE_CHECK_INSTANCE_CAST (_tmp11_, GEE_TYPE_ABSTRACT_LIST, GeeAbstractList), _pf_index);
				pf = (PreferencesDialogPathFormat*) _tmp12_;
				_tmp13_ = pf;
				_tmp14_ = _tmp13_->pattern;
				_tmp15_ = pattern;
				if (g_strcmp0 (_tmp14_, _tmp15_) == 0) {
					gtk_combo_box_set_active (combo_box, i);
					found = TRUE;
					_preferences_dialog_path_format_unref0 (pf);
					break;
				}
				_tmp16_ = i;
				i = _tmp16_ + 1;
				_preferences_dialog_path_format_unref0 (pf);
			}
		}
	} else {
		gchar* s = NULL;
		ConfigFacade* _tmp17_;
		ConfigFacade* _tmp18_;
		gchar* _tmp19_;
		gchar* _tmp20_;
		const gchar* _tmp21_;
		_tmp17_ = config_facade_get_instance ();
		_tmp18_ = _tmp17_;
		_tmp19_ = configuration_facade_get_directory_pattern_custom (G_TYPE_CHECK_INSTANCE_CAST (_tmp18_, TYPE_CONFIGURATION_FACADE, ConfigurationFacade));
		_tmp20_ = _tmp19_;
		_g_object_unref0 (_tmp18_);
		s = _tmp20_;
		_tmp21_ = s;
		if (!is_string_empty (_tmp21_)) {
			GeeArrayList* _tmp22_;
			gint _tmp23_;
			gint _tmp24_;
			_tmp22_ = self->priv->path_formats;
			_tmp23_ = gee_abstract_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_tmp22_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection));
			_tmp24_ = _tmp23_;
			gtk_combo_box_set_active (combo_box, _tmp24_ - 1);
			found = TRUE;
		}
		_g_free0 (s);
	}
	if (!found) {
		gtk_combo_box_set_active (combo_box, 0);
	}
	preferences_dialog_on_dir_pattern_combo_changed (self);
	_g_free0 (pattern);
}

void
preferences_dialog_show_preferences (void)
{
	PreferencesDialog* _tmp0_;
	PreferencesDialog* _tmp2_;
	PreferencesDialog* _tmp3_;
	PreferencesDialog* _tmp4_;
	GtkFileChooserButton* _tmp5_;
	GFile* _tmp6_;
	GFile* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	PreferencesDialog* _tmp10_;
	_tmp0_ = preferences_dialog_preferences_dialog;
	if (_tmp0_ == NULL) {
		PreferencesDialog* _tmp1_;
		_tmp1_ = preferences_dialog_new ();
		g_object_ref_sink (_tmp1_);
		_g_object_unref0 (preferences_dialog_preferences_dialog);
		preferences_dialog_preferences_dialog = _tmp1_;
	}
	_tmp2_ = preferences_dialog_preferences_dialog;
	preferences_dialog_populate_preference_options (_tmp2_);
	_tmp3_ = preferences_dialog_preferences_dialog;
	gtk_widget_show_all (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, gtk_widget_get_type (), GtkWidget));
	_tmp4_ = preferences_dialog_preferences_dialog;
	_tmp5_ = _tmp4_->priv->library_dir_button;
	_tmp6_ = app_dirs_get_import_dir ();
	_tmp7_ = _tmp6_;
	_tmp8_ = g_file_get_path (_tmp7_);
	_tmp9_ = _tmp8_;
	gtk_file_chooser_set_current_folder (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, gtk_file_chooser_get_type (), GtkFileChooser), _tmp9_);
	_g_free0 (_tmp9_);
	_g_object_unref0 (_tmp7_);
	_tmp10_ = preferences_dialog_preferences_dialog;
	gtk_window_present (G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, gtk_window_get_type (), GtkWindow));
}

static void
preferences_dialog_commit_on_close (PreferencesDialog* self)
{
	ConfigFacade* _tmp0_;
	ConfigFacade* _tmp1_;
	GtkCheckButton* _tmp2_;
	gboolean _tmp3_;
	gboolean _tmp4_;
	ConfigFacade* _tmp5_;
	ConfigFacade* _tmp6_;
	GtkCheckButton* _tmp7_;
	gboolean _tmp8_;
	gboolean _tmp9_;
	const gchar* _tmp10_;
	PreferencesDialogPathFormat* pf = NULL;
	GeeArrayList* _tmp12_;
	GtkComboBoxText* _tmp13_;
	gpointer _tmp14_;
	PreferencesDialogPathFormat* _tmp15_;
	const gchar* _tmp16_;
	g_return_if_fail (IS_PREFERENCES_DIALOG (self));
	_tmp0_ = config_facade_get_instance ();
	_tmp1_ = _tmp0_;
	_tmp2_ = self->priv->autoimport;
	_tmp3_ = gtk_toggle_button_get_active (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, gtk_toggle_button_get_type (), GtkToggleButton));
	_tmp4_ = _tmp3_;
	configuration_facade_set_auto_import_from_library (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, TYPE_CONFIGURATION_FACADE, ConfigurationFacade), _tmp4_);
	_g_object_unref0 (_tmp1_);
	_tmp5_ = config_facade_get_instance ();
	_tmp6_ = _tmp5_;
	_tmp7_ = self->priv->write_metadata;
	_tmp8_ = gtk_toggle_button_get_active (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, gtk_toggle_button_get_type (), GtkToggleButton));
	_tmp9_ = _tmp8_;
	configuration_facade_set_commit_metadata_to_masters (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, TYPE_CONFIGURATION_FACADE, ConfigurationFacade), _tmp9_);
	_g_object_unref0 (_tmp6_);
	_tmp10_ = self->priv->lib_dir;
	if (_tmp10_ != NULL) {
		const gchar* _tmp11_;
		_tmp11_ = self->priv->lib_dir;
		app_dirs_set_import_dir (_tmp11_);
	}
	_tmp12_ = self->priv->path_formats;
	_tmp13_ = self->priv->dir_pattern_combo;
	_tmp14_ = gee_abstract_list_get (G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, GEE_TYPE_ABSTRACT_LIST, GeeAbstractList), gtk_combo_box_get_active (G_TYPE_CHECK_INSTANCE_CAST (_tmp13_, gtk_combo_box_get_type (), GtkComboBox)));
	pf = (PreferencesDialogPathFormat*) _tmp14_;
	_tmp15_ = pf;
	_tmp16_ = _tmp15_->pattern;
	if (NULL == _tmp16_) {
		ConfigFacade* _tmp17_;
		ConfigFacade* _tmp18_;
		GtkEntry* _tmp19_;
		const gchar* _tmp20_;
		const gchar* _tmp21_;
		ConfigFacade* _tmp22_;
		ConfigFacade* _tmp23_;
		_tmp17_ = config_facade_get_instance ();
		_tmp18_ = _tmp17_;
		_tmp19_ = self->priv->dir_pattern_entry;
		_tmp20_ = gtk_entry_get_text (_tmp19_);
		_tmp21_ = _tmp20_;
		configuration_facade_set_directory_pattern_custom (G_TYPE_CHECK_INSTANCE_CAST (_tmp18_, TYPE_CONFIGURATION_FACADE, ConfigurationFacade), _tmp21_);
		_g_object_unref0 (_tmp18_);
		_tmp22_ = config_facade_get_instance ();
		_tmp23_ = _tmp22_;
		configuration_facade_set_directory_pattern (G_TYPE_CHECK_INSTANCE_CAST (_tmp23_, TYPE_CONFIGURATION_FACADE, ConfigurationFacade), NULL);
		_g_object_unref0 (_tmp23_);
	} else {
		ConfigFacade* _tmp24_;
		ConfigFacade* _tmp25_;
		PreferencesDialogPathFormat* _tmp26_;
		const gchar* _tmp27_;
		_tmp24_ = config_facade_get_instance ();
		_tmp25_ = _tmp24_;
		_tmp26_ = pf;
		_tmp27_ = _tmp26_->pattern;
		configuration_facade_set_directory_pattern (G_TYPE_CHECK_INSTANCE_CAST (_tmp25_, TYPE_CONFIGURATION_FACADE, ConfigurationFacade), _tmp27_);
		_g_object_unref0 (_tmp25_);
	}
	_preferences_dialog_path_format_unref0 (pf);
}

static gboolean
preferences_dialog_on_delete (PreferencesDialog* self)
{
	gboolean result;
	g_return_val_if_fail (IS_PREFERENCES_DIALOG (self), FALSE);
	if (!preferences_dialog_get_allow_closing (self)) {
		result = TRUE;
		return result;
	}
	preferences_dialog_commit_on_close (self);
	result = gtk_widget_hide_on_delete (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
	return result;
}

static void
preferences_dialog_on_close (PreferencesDialog* self)
{
	g_return_if_fail (IS_PREFERENCES_DIALOG (self));
	if (!preferences_dialog_get_allow_closing (self)) {
		return;
	}
	gtk_widget_hide (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
	preferences_dialog_commit_on_close (self);
}

static void
preferences_dialog_on_dir_pattern_combo_changed (PreferencesDialog* self)
{
	PreferencesDialogPathFormat* pf = NULL;
	GeeArrayList* _tmp0_;
	GtkComboBoxText* _tmp1_;
	gpointer _tmp2_;
	PreferencesDialogPathFormat* _tmp3_;
	const gchar* _tmp4_;
	g_return_if_fail (IS_PREFERENCES_DIALOG (self));
	_tmp0_ = self->priv->path_formats;
	_tmp1_ = self->priv->dir_pattern_combo;
	_tmp2_ = gee_abstract_list_get (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_ABSTRACT_LIST, GeeAbstractList), gtk_combo_box_get_active (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_combo_box_get_type (), GtkComboBox)));
	pf = (PreferencesDialogPathFormat*) _tmp2_;
	_tmp3_ = pf;
	_tmp4_ = _tmp3_->pattern;
	if (NULL == _tmp4_) {
		gchar* dir_pattern = NULL;
		ConfigFacade* _tmp5_;
		ConfigFacade* _tmp6_;
		gchar* _tmp7_;
		gchar* _tmp8_;
		const gchar* _tmp9_;
		GtkEntry* _tmp11_;
		const gchar* _tmp12_;
		GtkEntry* _tmp13_;
		GtkEntry* _tmp14_;
		_tmp5_ = config_facade_get_instance ();
		_tmp6_ = _tmp5_;
		_tmp7_ = configuration_facade_get_directory_pattern_custom (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, TYPE_CONFIGURATION_FACADE, ConfigurationFacade));
		_tmp8_ = _tmp7_;
		_g_object_unref0 (_tmp6_);
		dir_pattern = _tmp8_;
		_tmp9_ = dir_pattern;
		if (is_string_empty (_tmp9_)) {
			gchar* _tmp10_;
			_tmp10_ = g_strdup ("");
			_g_free0 (dir_pattern);
			dir_pattern = _tmp10_;
		}
		_tmp11_ = self->priv->dir_pattern_entry;
		_tmp12_ = dir_pattern;
		gtk_entry_set_text (_tmp11_, _tmp12_);
		_tmp13_ = self->priv->dir_pattern_entry;
		g_object_set (_tmp13_, "editable", TRUE, NULL);
		_tmp14_ = self->priv->dir_pattern_entry;
		gtk_widget_set_sensitive (G_TYPE_CHECK_INSTANCE_CAST (_tmp14_, gtk_widget_get_type (), GtkWidget), TRUE);
		_g_free0 (dir_pattern);
	} else {
		GtkEntry* _tmp15_;
		PreferencesDialogPathFormat* _tmp16_;
		const gchar* _tmp17_;
		GtkEntry* _tmp18_;
		GtkEntry* _tmp19_;
		_tmp15_ = self->priv->dir_pattern_entry;
		_tmp16_ = pf;
		_tmp17_ = _tmp16_->pattern;
		gtk_entry_set_text (_tmp15_, _tmp17_);
		_tmp18_ = self->priv->dir_pattern_entry;
		g_object_set (_tmp18_, "editable", FALSE, NULL);
		_tmp19_ = self->priv->dir_pattern_entry;
		gtk_widget_set_sensitive (G_TYPE_CHECK_INSTANCE_CAST (_tmp19_, gtk_widget_get_type (), GtkWidget), FALSE);
	}
	_preferences_dialog_path_format_unref0 (pf);
}

static void
preferences_dialog_on_dir_pattern_entry_changed (PreferencesDialog* self)
{
	gchar* example = NULL;
	GDateTime* _tmp0_;
	GtkEntry* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	gboolean _tmp5_ = FALSE;
	const gchar* _tmp6_;
	g_return_if_fail (IS_PREFERENCES_DIALOG (self));
	_tmp0_ = self->priv->example_date;
	_tmp1_ = self->priv->dir_pattern_entry;
	_tmp2_ = gtk_entry_get_text (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = g_date_time_format (_tmp0_, _tmp3_);
	example = _tmp4_;
	_tmp6_ = example;
	if (is_string_empty (_tmp6_)) {
		GtkEntry* _tmp7_;
		const gchar* _tmp8_;
		const gchar* _tmp9_;
		_tmp7_ = self->priv->dir_pattern_entry;
		_tmp8_ = gtk_entry_get_text (_tmp7_);
		_tmp9_ = _tmp8_;
		_tmp5_ = !is_string_empty (_tmp9_);
	} else {
		_tmp5_ = FALSE;
	}
	if (_tmp5_) {
		GtkLabel* _tmp10_;
		GtkEntry* _tmp11_;
		GtkEntry* _tmp12_;
		_tmp10_ = self->priv->dir_pattern_example;
		gtk_label_set_text (_tmp10_, _ ("Invalid pattern"));
		_tmp11_ = self->priv->dir_pattern_entry;
		gtk_entry_set_icon_from_icon_name (_tmp11_, GTK_ENTRY_ICON_SECONDARY, "dialog-error");
		_tmp12_ = self->priv->dir_pattern_entry;
		gtk_entry_set_icon_activatable (_tmp12_, GTK_ENTRY_ICON_SECONDARY, FALSE);
		preferences_dialog_set_allow_closing (self, FALSE);
	} else {
		GtkLabel* _tmp13_;
		const gchar* _tmp14_;
		GtkEntry* _tmp15_;
		_tmp13_ = self->priv->dir_pattern_example;
		_tmp14_ = example;
		gtk_label_set_text (_tmp13_, _tmp14_);
		_tmp15_ = self->priv->dir_pattern_entry;
		gtk_entry_set_icon_from_icon_name (_tmp15_, GTK_ENTRY_ICON_SECONDARY, NULL);
		preferences_dialog_set_allow_closing (self, TRUE);
	}
	_g_free0 (example);
}

static void
preferences_dialog_set_allow_closing (PreferencesDialog* self,
                                      gboolean allow)
{
	g_return_if_fail (IS_PREFERENCES_DIALOG (self));
	gtk_window_set_deletable (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_window_get_type (), GtkWindow), allow);
	self->priv->allow_closing = allow;
}

static gboolean
preferences_dialog_get_allow_closing (PreferencesDialog* self)
{
	gboolean result;
	g_return_val_if_fail (IS_PREFERENCES_DIALOG (self), FALSE);
	result = self->priv->allow_closing;
	return result;
}

static void
preferences_dialog_on_photo_editor_changed (PreferencesDialog* self)
{
	gint _tmp0_ = 0;
	GtkComboBox* _tmp1_;
	SortedList* _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	gint photo_app_choice_index = 0;
	GAppInfo* app = NULL;
	SortedList* _tmp9_;
	gpointer _tmp10_;
	ConfigFacade* _tmp11_;
	ConfigFacade* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	g_return_if_fail (IS_PREFERENCES_DIALOG (self));
	_tmp1_ = self->priv->photo_editor_combo;
	_tmp2_ = self->priv->external_photo_apps;
	_tmp3_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GEE_TYPE_COLLECTION, GeeCollection));
	_tmp4_ = _tmp3_;
	if (gtk_combo_box_get_active (_tmp1_) < _tmp4_) {
		GtkComboBox* _tmp5_;
		_tmp5_ = self->priv->photo_editor_combo;
		_tmp0_ = gtk_combo_box_get_active (_tmp5_);
	} else {
		SortedList* _tmp6_;
		gint _tmp7_;
		gint _tmp8_;
		_tmp6_ = self->priv->external_photo_apps;
		_tmp7_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, GEE_TYPE_COLLECTION, GeeCollection));
		_tmp8_ = _tmp7_;
		_tmp0_ = _tmp8_;
	}
	photo_app_choice_index = _tmp0_;
	_tmp9_ = self->priv->external_photo_apps;
	_tmp10_ = sorted_list_get_at (_tmp9_, photo_app_choice_index);
	app = (GAppInfo*) _tmp10_;
	_tmp11_ = config_facade_get_instance ();
	_tmp12_ = _tmp11_;
	_tmp13_ = desktop_integration_get_app_open_command (app);
	_tmp14_ = _tmp13_;
	configuration_facade_set_external_photo_app (G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, TYPE_CONFIGURATION_FACADE, ConfigurationFacade), _tmp14_);
	_g_free0 (_tmp14_);
	_g_object_unref0 (_tmp12_);
	_tmp15_ = desktop_integration_get_app_open_command (app);
	_tmp16_ = _tmp15_;
	g_debug ("Preferences.vala:382: setting external photo editor to: %s", _tmp16_);
	_g_free0 (_tmp16_);
	_g_object_unref0 (app);
}

static void
preferences_dialog_on_raw_editor_changed (PreferencesDialog* self)
{
	gint _tmp0_ = 0;
	GtkComboBox* _tmp1_;
	SortedList* _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	gint raw_app_choice_index = 0;
	GAppInfo* app = NULL;
	SortedList* _tmp9_;
	gpointer _tmp10_;
	ConfigFacade* _tmp11_;
	ConfigFacade* _tmp12_;
	const gchar* _tmp13_;
	const gchar* _tmp14_;
	g_return_if_fail (IS_PREFERENCES_DIALOG (self));
	_tmp1_ = self->priv->raw_editor_combo;
	_tmp2_ = self->priv->external_raw_apps;
	_tmp3_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GEE_TYPE_COLLECTION, GeeCollection));
	_tmp4_ = _tmp3_;
	if (gtk_combo_box_get_active (_tmp1_) < _tmp4_) {
		GtkComboBox* _tmp5_;
		_tmp5_ = self->priv->raw_editor_combo;
		_tmp0_ = gtk_combo_box_get_active (_tmp5_);
	} else {
		SortedList* _tmp6_;
		gint _tmp7_;
		gint _tmp8_;
		_tmp6_ = self->priv->external_raw_apps;
		_tmp7_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, GEE_TYPE_COLLECTION, GeeCollection));
		_tmp8_ = _tmp7_;
		_tmp0_ = _tmp8_;
	}
	raw_app_choice_index = _tmp0_;
	_tmp9_ = self->priv->external_raw_apps;
	_tmp10_ = sorted_list_get_at (_tmp9_, raw_app_choice_index);
	app = (GAppInfo*) _tmp10_;
	_tmp11_ = config_facade_get_instance ();
	_tmp12_ = _tmp11_;
	_tmp13_ = g_app_info_get_commandline (app);
	configuration_facade_set_external_raw_app (G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, TYPE_CONFIGURATION_FACADE, ConfigurationFacade), _tmp13_);
	_g_object_unref0 (_tmp12_);
	_tmp14_ = g_app_info_get_commandline (app);
	g_debug ("Preferences.vala:393: setting external raw editor to: %s", _tmp14_);
	_g_object_unref0 (app);
}

static RawDeveloper
preferences_dialog_raw_developer_from_combo (PreferencesDialog* self)
{
	GtkComboBoxText* _tmp0_;
	RawDeveloper result;
	g_return_val_if_fail (IS_PREFERENCES_DIALOG (self), 0);
	_tmp0_ = self->priv->default_raw_developer_combo;
	if (gtk_combo_box_get_active (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, gtk_combo_box_get_type (), GtkComboBox)) == 0) {
		result = RAW_DEVELOPER_CAMERA;
		return result;
	}
	result = RAW_DEVELOPER_SHOTWELL;
	return result;
}

static void
preferences_dialog_set_raw_developer_combo (PreferencesDialog* self,
                                            RawDeveloper d)
{
	g_return_if_fail (IS_PREFERENCES_DIALOG (self));
	if (d == RAW_DEVELOPER_CAMERA) {
		GtkComboBoxText* _tmp0_;
		_tmp0_ = self->priv->default_raw_developer_combo;
		gtk_combo_box_set_active (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, gtk_combo_box_get_type (), GtkComboBox), 0);
	} else {
		GtkComboBoxText* _tmp1_;
		_tmp1_ = self->priv->default_raw_developer_combo;
		gtk_combo_box_set_active (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_combo_box_get_type (), GtkComboBox), 1);
	}
}

static void
preferences_dialog_on_default_raw_developer_changed (PreferencesDialog* self)
{
	ConfigFacade* _tmp0_;
	ConfigFacade* _tmp1_;
	g_return_if_fail (IS_PREFERENCES_DIALOG (self));
	_tmp0_ = config_facade_get_instance ();
	_tmp1_ = _tmp0_;
	configuration_facade_set_default_raw_developer (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, TYPE_CONFIGURATION_FACADE, ConfigurationFacade), preferences_dialog_raw_developer_from_combo (self));
	_g_object_unref0 (_tmp1_);
}

static void
preferences_dialog_on_current_folder_changed (PreferencesDialog* self)
{
	GtkFileChooserButton* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (IS_PREFERENCES_DIALOG (self));
	_tmp0_ = self->priv->library_dir_button;
	_tmp1_ = gtk_file_chooser_get_filename (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, gtk_file_chooser_get_type (), GtkFileChooser));
	_g_free0 (self->priv->lib_dir);
	self->priv->lib_dir = _tmp1_;
}

static void
_preferences_dialog_on_current_folder_changed_gtk_file_chooser_current_folder_changed (GtkFileChooser* _sender,
                                                                                       gpointer self)
{
	preferences_dialog_on_current_folder_changed ((PreferencesDialog*) self);
}

static gboolean
preferences_dialog_real_map_event (GtkWidget* base,
                                   GdkEventAny* event)
{
	PreferencesDialog * self;
	gboolean _result_ = FALSE;
	GtkFileChooserButton* _tmp0_;
	gboolean result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_PREFERENCES_DIALOG, PreferencesDialog);
	g_return_val_if_fail (event != NULL, FALSE);
	_result_ = GTK_WIDGET_CLASS (preferences_dialog_parent_class)->map_event (G_TYPE_CHECK_INSTANCE_CAST (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_dialog_get_type (), GtkDialog), gtk_widget_get_type (), GtkWidget), event);
	_tmp0_ = self->priv->library_dir_button;
	g_signal_connect_object (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, gtk_file_chooser_get_type (), GtkFileChooser), "current-folder-changed", (GCallback) _preferences_dialog_on_current_folder_changed_gtk_file_chooser_current_folder_changed, self, 0);
	result = _result_;
	return result;
}

static void
preferences_dialog_add_to_dir_formats (PreferencesDialog* self,
                                       const gchar* name,
                                       const gchar* pattern)
{
	PreferencesDialogPathFormat* pf = NULL;
	PreferencesDialogPathFormat* _tmp0_;
	GeeArrayList* _tmp1_;
	GtkComboBoxText* _tmp2_;
	g_return_if_fail (IS_PREFERENCES_DIALOG (self));
	g_return_if_fail (name != NULL);
	_tmp0_ = preferences_dialog_path_format_new (name, pattern);
	pf = _tmp0_;
	_tmp1_ = self->priv->path_formats;
	gee_abstract_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection), pf);
	_tmp2_ = self->priv->dir_pattern_combo;
	gtk_combo_box_text_append_text (_tmp2_, name);
	_preferences_dialog_path_format_unref0 (pf);
}

static void
preferences_dialog_on_lowercase_toggled (PreferencesDialog* self)
{
	ConfigFacade* _tmp0_;
	ConfigFacade* _tmp1_;
	GtkCheckButton* _tmp2_;
	g_return_if_fail (IS_PREFERENCES_DIALOG (self));
	_tmp0_ = config_facade_get_instance ();
	_tmp1_ = _tmp0_;
	_tmp2_ = self->priv->lowercase;
	configuration_facade_set_use_lowercase_filenames (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, TYPE_CONFIGURATION_FACADE, ConfigurationFacade), gtk_toggle_button_get_active (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, gtk_toggle_button_get_type (), GtkToggleButton)));
	_g_object_unref0 (_tmp1_);
}

static PreferencesDialogPathFormat*
preferences_dialog_path_format_construct (GType object_type,
                                          const gchar* name,
                                          const gchar* pattern)
{
	PreferencesDialogPathFormat* self = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	g_return_val_if_fail (name != NULL, NULL);
	self = (PreferencesDialogPathFormat*) g_type_create_instance (object_type);
	_tmp0_ = g_strdup (name);
	_g_free0 (self->name);
	self->name = _tmp0_;
	_tmp1_ = g_strdup (pattern);
	_g_free0 (self->pattern);
	self->pattern = _tmp1_;
	return self;
}

static PreferencesDialogPathFormat*
preferences_dialog_path_format_new (const gchar* name,
                                    const gchar* pattern)
{
	return preferences_dialog_path_format_construct (PREFERENCES_DIALOG_TYPE_PATH_FORMAT, name, pattern);
}

static void
preferences_dialog_value_path_format_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
preferences_dialog_value_path_format_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		preferences_dialog_path_format_unref (value->data[0].v_pointer);
	}
}

static void
preferences_dialog_value_path_format_copy_value (const GValue* src_value,
                                                 GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = preferences_dialog_path_format_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
preferences_dialog_value_path_format_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
preferences_dialog_value_path_format_collect_value (GValue* value,
                                                    guint n_collect_values,
                                                    GTypeCValue* collect_values,
                                                    guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		PreferencesDialogPathFormat * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = preferences_dialog_path_format_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
preferences_dialog_value_path_format_lcopy_value (const GValue* value,
                                                  guint n_collect_values,
                                                  GTypeCValue* collect_values,
                                                  guint collect_flags)
{
	PreferencesDialogPathFormat ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = preferences_dialog_path_format_ref (value->data[0].v_pointer);
	}
	return NULL;
}

static GParamSpec*
preferences_dialog_param_spec_path_format (const gchar* name,
                                           const gchar* nick,
                                           const gchar* blurb,
                                           GType object_type,
                                           GParamFlags flags)
{
	PreferencesDialogParamSpecPathFormat* spec;
	g_return_val_if_fail (g_type_is_a (object_type, PREFERENCES_DIALOG_TYPE_PATH_FORMAT), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

static gpointer
preferences_dialog_value_get_path_format (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, PREFERENCES_DIALOG_TYPE_PATH_FORMAT), NULL);
	return value->data[0].v_pointer;
}

static void
preferences_dialog_value_set_path_format (GValue* value,
                                          gpointer v_object)
{
	PreferencesDialogPathFormat * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, PREFERENCES_DIALOG_TYPE_PATH_FORMAT));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, PREFERENCES_DIALOG_TYPE_PATH_FORMAT));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		preferences_dialog_path_format_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		preferences_dialog_path_format_unref (old);
	}
}

static void
preferences_dialog_value_take_path_format (GValue* value,
                                           gpointer v_object)
{
	PreferencesDialogPathFormat * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, PREFERENCES_DIALOG_TYPE_PATH_FORMAT));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, PREFERENCES_DIALOG_TYPE_PATH_FORMAT));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		preferences_dialog_path_format_unref (old);
	}
}

static void
preferences_dialog_path_format_class_init (PreferencesDialogPathFormatClass * klass,
                                           gpointer klass_data)
{
	preferences_dialog_path_format_parent_class = g_type_class_peek_parent (klass);
	((PreferencesDialogPathFormatClass *) klass)->finalize = preferences_dialog_path_format_finalize;
}

static void
preferences_dialog_path_format_instance_init (PreferencesDialogPathFormat * self,
                                              gpointer klass)
{
	self->ref_count = 1;
}

static void
preferences_dialog_path_format_finalize (PreferencesDialogPathFormat * obj)
{
	PreferencesDialogPathFormat * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PREFERENCES_DIALOG_TYPE_PATH_FORMAT, PreferencesDialogPathFormat);
	g_signal_handlers_destroy (self);
	_g_free0 (self->name);
	_g_free0 (self->pattern);
}

static GType
preferences_dialog_path_format_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { preferences_dialog_value_path_format_init, preferences_dialog_value_path_format_free_value, preferences_dialog_value_path_format_copy_value, preferences_dialog_value_path_format_peek_pointer, "p", preferences_dialog_value_path_format_collect_value, "p", preferences_dialog_value_path_format_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (PreferencesDialogPathFormatClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) preferences_dialog_path_format_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (PreferencesDialogPathFormat), 0, (GInstanceInitFunc) preferences_dialog_path_format_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType preferences_dialog_path_format_type_id;
	preferences_dialog_path_format_type_id = g_type_register_fundamental (g_type_fundamental_next (), "PreferencesDialogPathFormat", &g_define_type_info, &g_define_type_fundamental_info, 0);
	return preferences_dialog_path_format_type_id;
}

static GType
preferences_dialog_path_format_get_type (void)
{
	static volatile gsize preferences_dialog_path_format_type_id__once = 0;
	if (g_once_init_enter (&preferences_dialog_path_format_type_id__once)) {
		GType preferences_dialog_path_format_type_id;
		preferences_dialog_path_format_type_id = preferences_dialog_path_format_get_type_once ();
		g_once_init_leave (&preferences_dialog_path_format_type_id__once, preferences_dialog_path_format_type_id);
	}
	return preferences_dialog_path_format_type_id__once;
}

static gpointer
preferences_dialog_path_format_ref (gpointer instance)
{
	PreferencesDialogPathFormat * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

static void
preferences_dialog_path_format_unref (gpointer instance)
{
	PreferencesDialogPathFormat * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		PREFERENCES_DIALOG_PATH_FORMAT_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static void
preferences_dialog_class_init (PreferencesDialogClass * klass,
                               gpointer klass_data)
{
	preferences_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &PreferencesDialog_private_offset);
	((GtkWidgetClass *) klass)->map_event = (gboolean (*) (GtkWidget*, GdkEventAny*)) preferences_dialog_real_map_event;
	G_OBJECT_CLASS (klass)->finalize = preferences_dialog_finalize;
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/Shotwell/ui/preferences_dialog.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "switch_dark", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, switch_dark));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "photo_editor_combo", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, photo_editor_combo));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "raw_editor_combo", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, raw_editor_combo));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "library_dir_button", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, library_dir_button));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "dir_pattern_combo", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, dir_pattern_combo));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "dir_pattern_entry", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, dir_pattern_entry));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "dir_pattern_example", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, dir_pattern_example));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "lowercase", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, lowercase));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "default_raw_developer_combo", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, default_raw_developer_combo));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "autoimport", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, autoimport));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "write_metadata", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, write_metadata));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "pattern_help", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, pattern_help));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "preferences_stack", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, preferences_stack));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "transparent_checker_radio", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, transparent_checker_radio));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "transparent_solid_radio", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, transparent_solid_radio));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "transparent_solid_color", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, transparent_solid_color));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "transparent_none_radio", FALSE, PreferencesDialog_private_offset + G_STRUCT_OFFSET (PreferencesDialogPrivate, transparent_none_radio));
}

static void
preferences_dialog_instance_init (PreferencesDialog * self,
                                  gpointer klass)
{
	GeeArrayList* _tmp0_;
	GDateTime* _tmp1_;
	PluginsManifestWidgetMediator* _tmp2_;
	self->priv = preferences_dialog_get_instance_private (self);
	self->priv->allow_closing = FALSE;
	self->priv->lib_dir = NULL;
	_tmp0_ = gee_array_list_new (PREFERENCES_DIALOG_TYPE_PATH_FORMAT, (GBoxedCopyFunc) preferences_dialog_path_format_ref, (GDestroyNotify) preferences_dialog_path_format_unref, NULL, NULL, NULL);
	self->priv->path_formats = _tmp0_;
	_tmp1_ = g_date_time_new_local (2009, 3, 10, 18, 16, (gdouble) 11);
	self->priv->example_date = _tmp1_;
	_tmp2_ = plugins_manifest_widget_mediator_new ();
	g_object_ref_sink (_tmp2_);
	self->priv->plugins_mediator = _tmp2_;
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
preferences_dialog_finalize (GObject * obj)
{
	PreferencesDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_PREFERENCES_DIALOG, PreferencesDialog);
	_g_object_unref0 (self->priv->external_raw_apps);
	_g_object_unref0 (self->priv->external_photo_apps);
	_g_free0 (self->priv->lib_dir);
	_g_object_unref0 (self->priv->path_formats);
	_g_date_time_unref0 (self->priv->example_date);
	_g_object_unref0 (self->priv->plugins_mediator);
	G_OBJECT_CLASS (preferences_dialog_parent_class)->finalize (obj);
}

static GType
preferences_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (PreferencesDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) preferences_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (PreferencesDialog), 0, (GInstanceInitFunc) preferences_dialog_instance_init, NULL };
	GType preferences_dialog_type_id;
	preferences_dialog_type_id = g_type_register_static (gtk_dialog_get_type (), "PreferencesDialog", &g_define_type_info, 0);
	PreferencesDialog_private_offset = g_type_add_instance_private (preferences_dialog_type_id, sizeof (PreferencesDialogPrivate));
	return preferences_dialog_type_id;
}

GType
preferences_dialog_get_type (void)
{
	static volatile gsize preferences_dialog_type_id__once = 0;
	if (g_once_init_enter (&preferences_dialog_type_id__once)) {
		GType preferences_dialog_type_id;
		preferences_dialog_type_id = preferences_dialog_get_type_once ();
		g_once_init_leave (&preferences_dialog_type_id__once, preferences_dialog_type_id);
	}
	return preferences_dialog_type_id__once;
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

