Cleanup of autoconf files
[emu8051.git] / src / gtk / app-config.c
index 90022f2..3152421 100644 (file)
@@ -3,19 +3,7 @@
  *
  * Copyright (C) 2013 Hugo Villeneuve <hugo@hugovil.com>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ * This file is released under the GPLv2
  */
 
 #if HAVE_CONFIG_H
@@ -53,6 +41,8 @@ app_config_init(void)
        /* UI settings */
        cfg->win_width = 640;
        cfg->win_height = 480;
+       cfg->win_pos_x = 10;
+       cfg->win_pos_y = 10;
        cfg->hpane_pos = 100;
        cfg->vpane_pos = 200;
        cfg->main_pane_pos = 200;
@@ -60,25 +50,25 @@ app_config_init(void)
        /* View menu options */
        cfg->layout = UI_LAYOUT1;
        cfg->view_int_memory = 1;
-       cfg->view_sfr_memory = 1;
        cfg->view_ext_memory = 1;
-       cfg->bits_per_row = 16; /* 8 or 16 */
+       cfg->bytes_per_row = 16; /* 8 or 16 */
 }
 
 static int
-app_config_key_file_get_int(GKeyFile *kf, const char *grp, const char *key, int *value)
+app_config_key_file_get_int(GKeyFile *kf, const char *grp, const char *key,
+                           int *value)
 {
-    char *str = g_key_file_get_value(kf, grp, key, NULL);
+       char *str = g_key_file_get_value(kf, grp, key, NULL);
 
-    log_debug("key: %s", key);
+       log_debug("key: %s", key);
 
-    if (G_LIKELY(str)) {
-           *value = atoi(str);
-           log_debug("  value = %d", *value);
-           g_free(str);
-    }
+       if (G_LIKELY(str)) {
+               *value = atoi(str);
+               log_debug("  value = %d", *value);
+               g_free(str);
+       }
 
-    return str != NULL;
+       return str != NULL;
 }
 
 static void
@@ -91,6 +81,8 @@ app_config_load_from_key_file(GKeyFile *kf)
        /* ui */
        app_config_key_file_get_int(kf, "ui", "win_width",  &cfg->win_width);
        app_config_key_file_get_int(kf, "ui", "win_height", &cfg->win_height);
+       app_config_key_file_get_int(kf, "ui", "win_pos_x",  &cfg->win_pos_x);
+       app_config_key_file_get_int(kf, "ui", "win_pos_y",  &cfg->win_pos_y);
        app_config_key_file_get_int(kf, "ui", "hpane_pos",  &cfg->hpane_pos);
        app_config_key_file_get_int(kf, "ui", "vpane_pos",  &cfg->vpane_pos);
        app_config_key_file_get_int(kf, "ui", "main_pane_pos",
@@ -104,12 +96,10 @@ app_config_load_from_key_file(GKeyFile *kf)
        }
        app_config_key_file_get_int(kf, "view", "int_memory",
                                    &cfg->view_int_memory);
-       app_config_key_file_get_int(kf, "view", "sfr_memory",
-                                   &cfg->view_sfr_memory);
        app_config_key_file_get_int(kf, "view", "ext_memory",
                                    &cfg->view_ext_memory);
-       app_config_key_file_get_int(kf, "view", "bits_per_row",
-                                   &cfg->bits_per_row);
+       app_config_key_file_get_int(kf, "view", "bytes_per_row",
+                                   &cfg->bytes_per_row);
 }
 
 static char *
@@ -117,7 +107,7 @@ app_config_get_dir_path(void)
 {
        char *dir_path;
 
-       dir_path = g_build_filename(g_get_user_config_dir(), PACKAGE,
+       dir_path = g_build_filename(g_get_user_config_dir(), PACKAGE_NAME,
                                    profile_name, NULL);
 
        return dir_path;
@@ -130,7 +120,7 @@ app_config_get_file_path(void)
        char *dir_path;
        char file[MAX_FILENAME_LENGTH];
 
-       sprintf(file, "%s.conf", PACKAGE);
+       sprintf(file, "%s.conf", PACKAGE_NAME);
 
        dir_path = app_config_get_dir_path();
 
@@ -174,10 +164,9 @@ app_config_save(void)
 
        dir_path = app_config_get_dir_path();
 
-       if (g_mkdir_with_parents(dir_path, 0700) != -1)
-       {
+       if (g_mkdir_with_parents(dir_path, 0700) != -1) {
                char *file_path;
-               GStringbuf = g_string_sized_new(1024);
+               GString *buf = g_string_sized_new(1024);
 
                g_string_append(buf, "\n[emulation]\n");
 
@@ -188,6 +177,8 @@ app_config_save(void)
 
                g_string_append_printf(buf, "win_width=%d\n", cfg->win_width);
                g_string_append_printf(buf, "win_height=%d\n", cfg->win_height);
+               g_string_append_printf(buf, "win_pos_x=%d\n", cfg->win_pos_x);
+               g_string_append_printf(buf, "win_pos_y=%d\n", cfg->win_pos_y);
                g_string_append_printf(buf, "hpane_pos=%d\n", cfg->hpane_pos);
                g_string_append_printf(buf, "vpane_pos=%d\n", cfg->vpane_pos);
                g_string_append_printf(buf, "main_pane_pos=%d\n",
@@ -197,12 +188,10 @@ app_config_save(void)
                g_string_append_printf(buf, "layout=%d\n", cfg->layout);
                g_string_append_printf(buf, "int_memory=%d\n",
                                       cfg->view_int_memory);
-               g_string_append_printf(buf, "sfr_memory=%d\n",
-                                      cfg->view_sfr_memory);
                g_string_append_printf(buf, "ext_memory=%d\n",
                                       cfg->view_ext_memory);
-               g_string_append_printf(buf, "bits_per_row=%d\n",
-                                      cfg->bits_per_row);
+               g_string_append_printf(buf, "bytes_per_row=%d\n",
+                                      cfg->bytes_per_row);
 
                file_path = app_config_get_file_path();