#include <dbus/dbus-glib.h>
#define MAX_FIELDS 50
+#define CONFIG_GENERAL_GROUP "General"
+#define CONFIG_SEEN_CREDITS_KEY "seen_credits"
+#define CONFIG_DIRECTORY "/home/user/.config/belltower"
+#define CONFIG_FILENAME CONFIG_DIRECTORY "/belltower.ini"
GtkWidget *window;
LocationGPSDevice *device;
GKeyFile *static_content;
+GKeyFile *config;
typedef enum {
/** stop scanning the database */
gtk_widget_destroy (GTK_WIDGET (note));
}
+/**
+ * Loads the content of the static and dynamic data files.
+ * Possibly puts up a warning if we can't load the static file.
+ */
+static void
+load_config (void)
+{
+ static_content = g_key_file_new ();
+
+ if (!g_key_file_load_from_file (static_content,
+ "/usr/share/belltower/static.ini",
+ G_KEY_FILE_NONE,
+ NULL))
+ {
+ show_message ("Could not load static content. Attempting to continue.");
+ }
+
+ config = g_key_file_new ();
+ /* it doesn't matter if this fails */
+ g_key_file_load_from_file (config,
+ CONFIG_FILENAME,
+ G_KEY_FILE_KEEP_COMMENTS,
+ NULL);
+}
+
+/**
+ * Saves the dynamic data file to disk.
+ * Puts up a message if there was any error.
+ */
+static void
+save_config (void)
+{
+ gchar *data;
+
+ g_mkdir_with_parents (CONFIG_DIRECTORY, 0700);
+
+ data = g_key_file_to_data (config, NULL, NULL);
+
+ if (!g_file_set_contents (CONFIG_FILENAME,
+ data,
+ -1,
+ NULL))
+ {
+ show_message ("Could not write config file.");
+ }
+
+ g_free (data);
+}
+
static gint
distance_to_tower (tower *details)
{
}
/**
- * Loads the content of the static data file. Possibly puts
- * up a warning if we can't load it.
- */
-static void
-load_static_content (void)
-{
- static_content = g_key_file_new ();
-
- if (!g_key_file_load_from_file (static_content,
- "/usr/share/belltower/static.ini",
- G_KEY_FILE_NONE,
- NULL))
- {
- show_message ("Could not load static content. Attempting to continue.");
- }
-}
-
-/**
* Displays a web page.
* (Perhaps this should be merged with show_browser().)
*
gboolean from_button = (source!=NULL);
GtkWidget *dialog, *label, *button;
+ if (!from_button &&
+ g_key_file_get_boolean (config,
+ CONFIG_GENERAL_GROUP,
+ CONFIG_SEEN_CREDITS_KEY,
+ NULL))
+ {
+ return;
+ }
+
+
dialog = gtk_dialog_new_with_buttons ("Credits",
GTK_WINDOW (window),
GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
TRUE, TRUE, 0);
gtk_widget_show_all (GTK_WIDGET (dialog));
+
+ g_key_file_set_boolean (config,
+ CONFIG_GENERAL_GROUP,
+ CONFIG_SEEN_CREDITS_KEY,
+ TRUE);
+ save_config ();
}
int
gtk_container_add (GTK_CONTAINER (window), hbox);
gtk_widget_show_all (GTK_WIDGET (window));
- load_static_content ();
+ load_config ();
show_credits (NULL, NULL);
gtk_main ();