--- /dev/null
+#include "debug.h"
+#include "tilda-config.h"
+
+GHashTable *config_defaults;
+GKeyFile *config_userprefs;
+
+/*
+ * TODO:
+ *
+ * Add some capability to version the config file. Maybe a [meta] section.
+ *
+ * Make it possible to get the version number without firing up the config system
+ * as a whole. Or maybe just add the migration here, in this file, upon startup.
+ *
+ * The whole idea of this is that each of the objects that accesses the config
+ * system implements their own lookup engine.
+ */
+
+/*
+ * The main idea behind this configuration system is that each of the objects
+ * that accesses the config system implements their own lookup scheme. Since
+ * both TildaWindow and TildaTerminal need to lookup things different ways,
+ * I thought this would be the most logical solution.
+ */
+
+/**
+ * This function adds all of the defaults to the defaults hashtable.
+ * It just uses their names, since there are currently no conflicts
+ * in the properties of TildaWindow and TildaTerminal. If conflicts
+ * become a problem in the future, prefix them with "w-" and "t-",
+ * for example. Then fix up all callers. :) */
+static void
+tilda_config_setup_defaults ()
+{
+ /* NOTE: All properties must be specified as strings. This sucks, but it really
+ * is easiest to keep it this way. We can then implement custom functions to
+ * change the values as we need them. */
+
+ /* Window properties */
+ g_hash_table_insert (config_defaults, "key", NULL);
+ g_hash_table_insert (config_defaults, "height", "300");
+ g_hash_table_insert (config_defaults, "width", "600");
+ g_hash_table_insert (config_defaults, "x-position", "0");
+ g_hash_table_insert (config_defaults, "y-position", "0");
+ g_hash_table_insert (config_defaults, "tab-position", "top");
+ g_hash_table_insert (config_defaults, "animation-orientation", "top");
+ g_hash_table_insert (config_defaults, "animation-delay", "15000");
+ g_hash_table_insert (config_defaults, "keep-above", "true");
+ g_hash_table_insert (config_defaults, "skip-taskbar-hint", "true");
+ g_hash_table_insert (config_defaults, "stick", "true");
+ g_hash_table_insert (config_defaults, "hidden-at-start", "false");
+ g_hash_table_insert (config_defaults, "centered-horizontally", "false");
+ g_hash_table_insert (config_defaults, "centered-vertically", "false");
+
+ /* Terminal Properties */
+ g_hash_table_insert (config_defaults, "background-image", NULL);
+ g_hash_table_insert (config_defaults, "shell", NULL);
+ g_hash_table_insert (config_defaults, "font", "Bitstream Vera Sans Mono 12");
+ g_hash_table_insert (config_defaults, "title", "Tilda");
+ g_hash_table_insert (config_defaults, "working-directory", NULL);
+ g_hash_table_insert (config_defaults, "web-browser", "firefox");
+ g_hash_table_insert (config_defaults, "scrollback-lines", "1000");
+ g_hash_table_insert (config_defaults, "transparency-percent", "0");
+ g_hash_table_insert (config_defaults, "backspace-binding", "vte-erase-auto");
+ g_hash_table_insert (config_defaults, "delete-binding", "vte-erase-auto");
+ g_hash_table_insert (config_defaults, "dynamic-title", "after-initial");
+ g_hash_table_insert (config_defaults, "exit-action", "exit");
+ g_hash_table_insert (config_defaults, "scrollbar-position", "right");
+#if 0
+ /* These don't have properties yet! */
+ g_hash_table_insert (config_defaults, "background-color", "0;0;0");
+ g_hash_table_insert (config_defaults, "foreground-color", "255;255;255");
+#endif
+ g_hash_table_insert (config_defaults, "scroll-background", "false");
+ g_hash_table_insert (config_defaults, "scroll-on-output", "false");
+ g_hash_table_insert (config_defaults, "scroll-on-keystroke", "true");
+ g_hash_table_insert (config_defaults, "antialiased", "true");
+ g_hash_table_insert (config_defaults, "allow-bold-text", "true");
+ g_hash_table_insert (config_defaults, "cursor-blinks", "true");
+ g_hash_table_insert (config_defaults, "audible-bell", "false");
+ g_hash_table_insert (config_defaults, "visible-bell", "true");
+ g_hash_table_insert (config_defaults, "double-buffered", "true");
+ g_hash_table_insert (config_defaults, "mouse-autohide", "true");
+}
+
+gboolean
+tilda_config_init (const gchar *filename)
+{
+ /* Create the hashtable */
+ config_defaults = g_hash_table_new (g_str_hash, g_str_equal);
+
+ /* Fill it with the default values */
+ tilda_config_setup_defaults ();
+
+ /* If we have no file to read from, then we are just using the defaults,
+ * and are done. */
+ if (filename == NULL)
+ {
+ config_userprefs = NULL;
+ return TRUE;
+ }
+
+ /* Create the key file */
+ config_userprefs = g_key_file_new ();
+
+ /* TODO: load from a file! */
+ return TRUE;
+}
+
+/**
+ * Since we DO NOT allow writing to the configuration file from a Tilda
+ * process (only from the wizard), this does nothing more than free the
+ * defaults hashtable, and free the opened keyfile.
+ */
+gboolean
+tilda_config_free ()
+{
+ g_hash_table_destroy (config_defaults);
+ g_key_file_free (config_userprefs);
+
+ config_defaults = NULL;
+ config_userprefs = NULL;
+
+ return TRUE;
+}
+
+/* vim: set ts=4 sts=4 sw=4 noet tw=112: */