Update of /cvsroot/gtkpod/gtkpod/src
In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv11349/src

Modified Files:
        main.c misc_confirm.c prefs.c prefs.h prefs_window.c 
Log Message:

Got rid of old prefs infrastructure. :)
Also added prefs functions for handling double/float keys.


Index: main.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/main.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- main.c      12 Jun 2006 02:44:00 -0000      1.56
+++ main.c      26 Jun 2006 23:58:17 -0000      1.57
@@ -121,10 +121,9 @@
   
   gtkpod_window = gtkpod_xml_get_widget (main_window_xml, "gtkpod");
   
-       init_prefs(argc, argv); 
-  if (!read_prefs_old (gtkpod_window, argc, argv)) return 0;
+  init_prefs(argc, argv); 
   
-       display_create ();
+  display_create ();
 
   gtk_widget_show (gtkpod_window);
 

Index: misc_confirm.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/misc_confirm.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- misc_confirm.c      24 Jun 2006 12:37:46 -0000      1.40
+++ misc_confirm.c      26 Jun 2006 23:58:17 -0000      1.41
@@ -866,7 +866,6 @@
        server_shutdown (); /* stop accepting requests for playcount updates */
 
        cleanup_prefs();
-       write_prefs();
 
 /* FIXME: release memory in a clean way */
 #if 0

Index: prefs.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/prefs.c,v
retrieving revision 1.266
retrieving revision 1.267
diff -u -d -r1.266 -r1.267
--- prefs.c     25 Jun 2006 23:29:08 -0000      1.266
+++ prefs.c     26 Jun 2006 23:58:17 -0000      1.267
@@ -145,7 +145,13 @@
     PATH_NUM
 } PathType;
 
-
+/* enum for reading of options */
+enum {
+  GP_HELP,
+  GP_PLAYCOUNT,
+  GP_MOUNT,
+  GP_AUTO,
+};
 
 /* Set default prefrences */
 static void set_default_preferences()
@@ -263,6 +269,7 @@
     prefs_set_int("toolbar_style", GTK_TOOLBAR_BOTH);
     prefs_set_int("block_display", FALSE);
     prefs_set_int("md5", TRUE);
+    prefs_set_string("export_template", "%o;%a - %t.mp3;%t.wav");
 
     /* Set last browsed directory */
     dir = g_get_current_dir();
@@ -328,21 +335,22 @@
   locale_fprintf(fp, _("  --auto:       same as '-a'.\n"));
 }
 
-/* Not quite ready to use this--disable for now */
-#if 0
 /* Parse commandline based options */
-static gboolean read_commandline(int argc, char *argv[])
+static void read_commandline(int argc, char *argv[])
 {
     int option; /* Code returned by getopt */
        
     /* The options data structure. The format is standard getopt. */
     struct option const options[] =
        {
-           {"h",           no_argument,                                NULL, 
GP_HELP},
-           {"help",        no_argument,                                NULL, 
GP_HELP},
-           {"m",           required_argument,  NULL, GP_MOUNT},
-           {"mountpoint",  required_argument,  NULL, GP_MOUNT},
-           {0, 0, 0, 0}
+           { "h",           no_argument,       NULL, GP_HELP },
+           { "help",        no_argument,       NULL, GP_HELP },
+           { "p",           required_argument,       NULL, GP_PLAYCOUNT },
+           { "m",           required_argument, NULL, GP_MOUNT },
+           { "mountpoint",  required_argument, NULL, GP_MOUNT },
+           { "a",           no_argument,       NULL, GP_AUTO },
+           { "auto",        no_argument,       NULL, GP_AUTO },
+           { 0, 0, 0, 0 }
        };
        
     /* Handle commandline options */
@@ -353,23 +361,25 @@
        case GP_HELP:
            usage(stdout);
            exit(0);
-           return FALSE;
+           break;
+       case GP_PLAYCOUNT:
+           client_playcount(optarg);
+           exit(0);
            break;
        case GP_MOUNT:
            prefs_set_string("initial_mountpoint", optarg);
-           return TRUE;
+           break;
+       case GP_AUTO:
+           prefs_set_int("autoimport_commandline", TRUE);
            break;
        default:
            locale_fprintf(stderr, "Unknown option: %s\n", argv[optind]);
            usage(stderr);
            exit(1);
-           return FALSE;
            break;
        };
     }
-    return TRUE;       
 }
-#endif
 
 /* Read options from environment variables */
 static void read_environment()
@@ -508,7 +518,7 @@
 /* Gets a string that contains ~/.gtkpod/ If the folder doesn't exist,
  * create it. Free the string when you are done with it.
  * If the folder wasn't found, and couldn't be created, return NULL */
-gchar *get_config_dir()
+gchar *prefs_get_cfgdir()
 {
     gchar *folder;  /* Folder path */
        
@@ -527,8 +537,6 @@
     return folder;
 }
 
-/* Disable this until the transition is done */
-#if 0
 /* Read preferences from a file */
 static void read_prefs_from_file(FILE *fp)
 {
@@ -581,7 +589,6 @@
        }
     }
 }
-#endif
 
 /* Write prefs to file */
 static void write_prefs_to_file(FILE *fp)
@@ -594,18 +601,15 @@
  * preferences in the user home folder. */
 static void load_prefs()
 {
-#if 0
     gchar *filename; /* Config path to open */
     gchar *config_dir;  /* Directory where config is (usually ~/.gtkpod) */
     FILE *fp;
-#endif
        
     /* Start by initializing the prefs to their default values */
     set_default_preferences();
        
-#if 0
     /* and then override those values with those found in the home folder. */
-    config_dir = get_config_dir();
+    config_dir = prefs_get_cfgdir();
        
     if (config_dir)
     {
@@ -626,7 +630,6 @@
                
        g_free(config_dir);
     }
-#endif
        
     /* Finally, initialize variable-length lists. Do this after everything else
      * so that list defaults don't hang out in the table after prefs have been
@@ -642,7 +645,7 @@
     FILE *fp;  /* File pointer */
        
     /* Open $HOME/.gtkpod/prefs, and write prefs */
-    config_dir = get_config_dir();
+    config_dir = prefs_get_cfgdir();
        
     if (config_dir)
     {
@@ -654,10 +657,6 @@
 
            if (fp)
            {
-               /* remove fprintf() once the old prefs
-                  system is completely gone. */
-               fprintf(fp, "version=%s\n", VERSION);
-
                write_prefs_to_file(fp);
                fclose(fp);
            }
@@ -699,23 +698,14 @@
 static void cleanup_keys()
 {
     gchar *buf;
+    gchar *sp = NULL;
     gint int_buf;
     gint i;
     gint x, y, p;  /* Window position */
     float version=0;
 
-    /* get version */
-    if (prefs_get_string_value ("version", &buf))
-    {
-       version = g_ascii_strtod (buf, NULL);
-       g_free (buf);
-    }
-    else
-    {
-       /* version must only be set to VERSION if no prefs file was
-          found --> elsewhere */
-       g_return_if_reached ();
-    }
+    /* Get version */
+    version = prefs_get_double("version");
 
     /* rename mountpoint to initial_mountpoint */
     if (prefs_get_string_value("mountpoint", &buf))
@@ -870,6 +860,14 @@
     prefs_set_string("mp3gain_path", NULL);
     prefs_set_string("statusbar_timeout", NULL);
     prefs_set_string("offline", NULL);
+    prefs_set_string("time_format", NULL);
+    prefs_set_string("id3_all", NULL);
+    prefs_set_string("pm_autostore", NULL);
+    prefs_set_string("backups", NULL);
+    prefs_set_string("save_sorted_order", NULL);
+    prefs_set_string("fix_path", NULL);
+    prefs_set_string("write_gaintag", NULL);
+
 
     /* sp_created_cond renamed to sp_added_cond */
     for (i = 0; i < SORT_TAB_MAX; i++)
@@ -983,6 +981,52 @@
        prefs_set_string("sm_sort_", NULL);
     }
 
+    /* filename_format renamed to export_template */
+    if (prefs_get_string_value("filename_format", &buf))
+    {
+       prefs_set_string("export_template", buf);
+       g_free(buf);
+       prefs_set_string("filename_format", NULL);
+    }
+
+    /* This string was a wrong autoconvert--just ignore it */
+    buf = prefs_get_string("export_template");
+    
+    if (strcmp(buf, "%a - %a/%T - %T.mp3") == 0)
+       prefs_set_string("export_template", NULL);
+
+    /* We changed the meaning of the %x in export_template */
+    if (version < 0.72)
+    {
+       /* changed the meaning of the %x in export_template */
+       if (sp) while (*sp)
+       {
+           if (sp[0] == '%')
+           {
+               switch (sp[1]) {
+               case 'A':
+                   sp[1] = 'a';
+                   break;
+               case 'd':
+                   sp[1] = 'A';
+                   break;
+               case 'n':
+                   sp[1] = 't';
+                   break;
+               case 't':
+                   sp[1] = 'T';
+                   break;
+               default:
+                   break;
+               }
+           }
+       }
+    }
+
+    /* For versions < 0.91, remove all itdb keys */
+    if (version < 0.91)
+       prefs_flush_subkey("itdb_");
+   
     prefs_set_string ("version", VERSION);
 }
 
@@ -1005,20 +1049,15 @@
        
     /* Load preferences */
     load_prefs();
+
+    /* Clean up old prefs keys */
+    cleanup_keys();
        
     /* Read environment variables */
     read_environment(); 
        
-#if 0
     /* Read commandline arguments */
-    read_commandline(argc, argv);
-#endif
-  
-    /* Leave this here--will work when transition is complete */
-#if 0
-    /* Clean up old prefs keys */
-    cleanup_keys();
-#endif
+    read_commandline(argc, argv);  
 }
 
 /* Save prefs data to a file, and then delete the hash table */
@@ -1214,9 +1253,6 @@
     temp_prefs_destroy (sub_data.temp_prefs);
 }
 
-
-
-
 /* Functions for non-numbered pref keys */
 
 /* Set a string value with the given key, or remove key if @value is
@@ -1259,6 +1295,17 @@
     }
 }
 
+void prefs_set_double(const gchar *key, gdouble value)
+{
+    gchar *strvalue; /* String value converted from integer */
+
+    if (prefs_table)
+    {
+       strvalue = g_strdup_printf("%f", value);
+       g_hash_table_insert(prefs_table, g_strdup(key), strvalue);
+    }
+}
+
 /* Get a string value associated with a key. Free returned string. */
 gchar *prefs_get_string(const gchar *key)
 {      
@@ -1370,6 +1417,43 @@
     return FALSE;
 }
 
+gdouble prefs_get_double(const gchar *key)
+{
+    gchar *string;  /* Key value string */
+    gdouble value;  /* Retunred value */
+       
+    value = 0;
+
+    if (prefs_table)
+    {
+       string = g_hash_table_lookup(prefs_table, key);
+
+       if (string)
+           value = g_ascii_strtod(string, NULL);
+    }
+       
+    return value;
+}
+
+gboolean prefs_get_double_value(const gchar *key, gdouble *value)
+{
+    gchar *string;  /* String value from prefs table */
+       
+    if (prefs_table)
+    {
+       string = g_hash_table_lookup(prefs_table, key);
+               
+       if (string)
+       {
+           if (value)
+               *value = g_ascii_strtod(string, NULL);
+                       
+           return TRUE;
+       }
+    }
+    return FALSE;
+}
+
 /* Functions for numbered pref keys */
 
 /* Set a string value with the given key */
@@ -1408,6 +1492,18 @@
     g_free(full_key);
 }
 
+/* Set a key to a gdouble value */
+void prefs_set_double_index(const gchar *key, guint index,
+                            gdouble value)
+{
+    gchar *full_key; /* Complete numbered key */
+       
+    full_key = create_full_key(key, index);
+    prefs_set_double(full_key, value);
+       
+    g_free(full_key);
+}
+
 /* Get a string value associated with a key. Free returned string. */
 gchar *prefs_get_string_index(const gchar *key, const guint index)
 {      
@@ -1486,7 +1582,32 @@
     gboolean ret; /* Return value */
        
     full_key = create_full_key(key, index);
-    ret = prefs_get_int64_value(key, value);
+    ret = prefs_get_int64_value(full_key, value);
+       
+    g_free(full_key);
+    return ret;
+}
+
+gdouble prefs_get_double_index(const gchar *key, guint index)
+{
+    gchar *full_key; /* Complete numbered key */
+    gdouble value; /* Return value */
+       
+    full_key = create_full_key(key, index);
+    value = prefs_get_double(full_key);
+       
+    g_free(full_key);
+    return value;
+}
+
+gboolean prefs_get_double_value_index(const gchar *key, guint index,
+                                     gdouble *value)
+{
+    gchar *full_key; /* Complete numbered key */
+    gboolean ret; /* Return value */
+       
+    full_key = create_full_key(key, index);
+    ret = prefs_get_double_value(full_key, value);
        
     g_free(full_key);
     return ret;
@@ -1541,6 +1662,18 @@
     g_tree_insert(temp_prefs->tree, g_strdup(key), strvalue);
 }
 
+void temp_prefs_set_double(TempPrefs *temp_prefs, const gchar *key,
+                          gdouble value)
+{
+    gchar *strvalue; /* String value converted from int64 */
+       
+    g_return_if_fail (temp_prefs && temp_prefs->tree);
+    g_return_if_fail (key);
+
+    strvalue = g_strdup_printf("%fu", value);
+    g_tree_insert(temp_prefs->tree, g_strdup(key), strvalue);
+}
+
 /* Get a string value associated with a key. Free returned string. */
 gchar *temp_prefs_get_string(TempPrefs *temp_prefs, const gchar *key)
 {      
@@ -1616,6 +1749,48 @@
        return FALSE;
 }
 
+gdouble temp_prefs_get_double(TempPrefs *temp_prefs,
+                             const gchar *key)
+{
+    gchar *string; /* Hash value string */
+    gdouble value;  /* Retunred value */
+       
+    g_return_val_if_fail (temp_prefs && temp_prefs->tree, 0);
+    g_return_val_if_fail (key, 0);
+
+    value = 0.0f;
+       
+    string = g_tree_lookup (temp_prefs->tree, key);
+               
+    if (string)
+       value = g_ascii_strtod(string, NULL);
+
+    return value;    
+}
+
+gboolean temp_prefs_get_double_value(TempPrefs *temp_prefs,
+                                   const gchar *key, gdouble *value)
+{
+    gchar *string;  /* String value from prefs table */
+       
+    g_return_val_if_fail (temp_prefs && temp_prefs->tree, FALSE);
+    g_return_val_if_fail (key, FALSE);
+
+    string = g_tree_lookup (temp_prefs->tree, key);
+
+    if (value)
+    {
+       if (string)
+           *value = g_ascii_strtod(string, NULL);
+       else
+           *value = 0;
+    }
+
+    if (string)
+       return TRUE;
+    else
+       return FALSE;
+}
 
 /* Functions for numbered pref keys */
 
@@ -1832,364 +2007,3 @@
     
     return list;
 }
-
-/* config struct */
-static struct cfg *cfg = NULL;
-
-/* enum for reading of options */
-enum {
-  GP_HELP,
-  GP_PLAYCOUNT,
-  GP_MOUNT,
-  GP_AUTO,
-};
-
-
-struct cfg *cfg_new(void)
-{
-    struct cfg *mycfg = NULL;
-
-    mycfg = g_malloc0 (sizeof (struct cfg));
-
-
-    return(mycfg);
-}
-
-
-/* Compare strlen(@arg) chars of @arg with @line. Return strlen (@arg)
-   in @off if @off != NULL */
-static gint arg_comp (const gchar *line, const gchar *arg, gint *off)
-{
-    if (arg && line)
-    {
-       gint len = strlen (arg);
-       if (off) *off = len;
-       return g_ascii_strncasecmp (line, arg, len);
-    }
-    else
-    {
-       if (*off)   *off = 0;
-       return 0;
-    }
-}
-
-
-
-static void
-read_prefs_from_file_desc(FILE *fp)
-{
-    gchar buf[PATH_MAX];
-    gchar *line, *arg, *bufp;
-    gint len;
-
-    /* set ignore fields (ignore above words for artist) */
-    bufp = g_strdup_printf ("sort_ign_field_%d", T_ARTIST);
-    prefs_set_int (bufp, 1);
-    g_free (bufp);
-
-    if(fp)
-    {
-      while (fgets (buf, PATH_MAX, fp))
-       {
-         /* allow comments */
-         if ((buf[0] == ';') || (buf[0] == '#')) continue;
-         arg = strchr (buf, '=');
-         if (!arg || (arg == buf))
-           {
-             gtkpod_warning (_("Error while reading prefs: %s\n"), buf);
-             continue;
-           }
-         /* skip whitespace */
-         bufp = buf;
-         while (g_ascii_isspace(*bufp)) ++bufp;
-         line = g_strndup (buf, arg-bufp);
-         ++arg;
-         len = strlen (arg); /* remove newline */
-         if((len>0) && (arg[len-1] == 0x0a))  arg[len-1] = 0;
-         /* skip whitespace */
-         while (g_ascii_isspace(*arg)) ++arg;
-         if(g_ascii_strcasecmp (line, "version") == 0)
-         {
-             cfg->version = g_ascii_strtod (arg, NULL);
-             prefs_set_string ("version", arg);
-         }
-         else if(g_ascii_strcasecmp (line, "time_format") == 0)
-         {
-             /* removed in 0.87 */
-         }
-         else if((g_ascii_strcasecmp (line, "filename_format") == 0) ||
-                 (g_ascii_strcasecmp (line, "export_template") == 0))
-         {  /* changed to "export_template" in 0.73CVS */
-             /* this "funky" string was the result of a wrong
-                autoconvert -- just ignore it */
-             if (strcmp (arg, "%a - %a/%T - %T.mp3") != 0)
-             {
-                 if (cfg->version < 0.72)
-                 {
-                     /* changed the meaning of the %x in export_template */
-                     gchar *sp = arg;
-                     if (sp) while (*sp)
-                     {
-                         if (sp[0] == '%')
-                         {
-                             switch (sp[1]) {
-                             case 'A':
-                                 sp[1] = 'a';
-                                 break;
-                             case 'd':
-                                 sp[1] = 'A';
-                                 break;
-                             case 'n':
-                                 sp[1] = 't';
-                                 break;
-                             case 't':
-                                 sp[1] = 'T';
-                                 break;
-                             default:
-                                 break;
-                             }
-                         }
-                         ++sp;
-                     }
-                 }
-                 prefs_set_string (EXPORT_FILES_TPL, arg);
-             }
-         }
-         else if(g_ascii_strcasecmp (line, "id3_all") == 0)
-         {
-             /* obsoleted since 0.71 */
-         }
-         else if(g_ascii_strcasecmp (line, "pm_autostore") == 0)
-         {
-             /* ignore */
-         }
-         else if(g_ascii_strcasecmp (line, "backups") == 0)
-         {
-             /* removed with version after 0.82-CVS */
-         }
-         else if(g_ascii_strcasecmp (line, "save_sorted_order") == 0)
-         {
-             /* ignore option -- has been deleted with 0.53 */
-         }
-         else if(g_ascii_strcasecmp (line, "fix_path") == 0)
-         {
-             /* ignore -- wie always fix the export path (replace
-              * non-compatible chars) */
-         }
-         else if(g_ascii_strcasecmp (line, "write_gaintag") == 0)
-         {
-             /* ignore -- not used any more */
-         }
-         else
-         {   /* All leftover options will be stored into the prefs
-                setting hash (generic options -- should have had this
-                idea much sooner... */
-             gboolean skip = FALSE;
-             if (cfg->version < 0.91)
-             {
-                 if(arg_comp (line, "itdb_", NULL) == 0)
-                 {   /* set incorrectly in 0.90 -- delete */
-                     skip = TRUE;
-                 }
-             }
-             if (!skip)
-                 prefs_set_string (line, arg);
-         }
-         g_free(line);
-       }
-    }
-}
-
-
-/* we first read from /etc/gtkpod/prefs and then overwrite the
-   settings with ~/.gtkpod/prefs */
-void
-read_prefs_defaults(void)
-{
-  gchar *cfgdir = NULL;
-  gchar *filename;
-  FILE *fp = NULL;
-  gboolean have_prefs = FALSE;
-
-  cfgdir = prefs_get_cfgdir ();
-
-  filename = g_build_filename (cfgdir, "prefs", NULL);
-  if(g_file_test(filename, G_FILE_TEST_EXISTS))
-  {
-      if((fp = fopen(filename, "r")))
-      {
-         read_prefs_from_file_desc(fp);
-         fclose(fp);
-    cleanup_keys();
-         have_prefs = TRUE; /* read prefs */
-      }
-      else
-      {
-         gtkpod_warning(_("Unable to open config file '%s' for reading\n"), 
filename);
-         }
-  }
-  g_free (filename);
-
-  if (!have_prefs)
-  {
-      filename = g_build_filename ("/etc", "gtkpod", "prefs", NULL);
-
-      if (g_file_test (filename, G_FILE_TEST_EXISTS))
-      {
-         if((fp = fopen(filename, "r")))
-         {
-             read_prefs_from_file_desc(fp);
-             fclose(fp);
-             have_prefs = TRUE; /* read prefs */
-         }
-      }
-      g_free (filename);
-  }
-  g_free (cfgdir);
-  /* set version of the prefs file to "current" if none was read */
-  if (!have_prefs)
-  {
-      cfg->version = g_ascii_strtod (VERSION, NULL);
-      prefs_set_string ("version", VERSION);
-  }
-}
-
-/* Read Preferences and initialise the cfg-struct */
-/* Return value: FALSE if "-p" argument was given -> stop program */
-gboolean read_prefs_old (GtkWidget *gtkpod, int argc, char *argv[])
-{
-  int opt;
-  int option_index;
-  gboolean result = TRUE;
-  struct option const options[] =
-    {
-      { "h",           no_argument,    NULL, GP_HELP },
-      { "help",        no_argument,    NULL, GP_HELP },
-      { "p",           required_argument,       NULL, GP_PLAYCOUNT },
-      { "m",           required_argument,      NULL, GP_MOUNT },
-      { "mountpoint",  required_argument,      NULL, GP_MOUNT },
-      { "a",           no_argument,    NULL, GP_AUTO },
-      { "auto",        no_argument,    NULL, GP_AUTO },
-      { 0, 0, 0, 0 }
-    };
-               
-  if (cfg != NULL) discard_prefs ();
-
-  cfg = cfg_new();
-  read_prefs_defaults();
-
-  while((opt=getopt_long_only(argc, argv, "", options, &option_index)) != -1) {
-    switch(opt)
-      {
-      case GP_HELP:
-         usage(stdout);
-         exit(0);
-         break;
-      case GP_PLAYCOUNT:
-         client_playcount (optarg);
-         result = FALSE;
-         break;
-      case GP_MOUNT:
-         prefs_set_string ("initial_mountpoint", optarg);
-         break;
-      case GP_AUTO:
-         prefs_set_int("autoimport_commandline", TRUE);
-         break;
-      default:
-         locale_fprintf(stderr, _("Unknown option: %s\n"), argv[optind]);
-         usage(stderr);
-         exit(1);
-      }
-  }
-
-  return result;
-}
-
-static void
-write_prefs_to_file_desc(FILE *fp)
-{
-
-    if(!fp)
-       fp = stderr;
-
-}
-
-
-void
-write_prefs (void)
-{
-    gchar *filename;
-    gchar *cfgdir;
-    FILE *fp = NULL;
-
-    cfgdir = prefs_get_cfgdir ();
-
-    filename = g_build_filename (cfgdir, "prefs", NULL);
-    if((fp = fopen(filename, "a")))
-    {
-       write_prefs_to_file_desc(fp);
-       fclose(fp);
-    }
-    else
-    {
-       gtkpod_warning (_("Unable to open '%s' for writing\n"),
-                       filename);
-    }
-
-    g_free (filename);
-    g_free (cfgdir);
-}
-
-
-
-/* Free all memory including the cfg-struct itself. */
-void discard_prefs ()
-{
-    cfg_free(cfg);
-    cfg = NULL;
-}
-
-void cfg_free(struct cfg *c)
-{
-    if(c)
-    {
-      g_free (c);
-    }
-}
-
-struct cfg *clone_prefs(void)
-{
-    struct cfg *result = NULL;
-
-    if(cfg)
-    {
-       result = g_memdup (cfg, sizeof (struct cfg));
-    }
-    return(result);
-}
-
-/* Returns "$HOME/.gtkpod" and tries to create it if it does not
-   exist. */
-gchar *prefs_get_cfgdir (void)
-{
-  G_CONST_RETURN gchar *str;
-  gchar *cfgdir=NULL;
-
-  if((str = g_get_home_dir ()))
-  {
-      cfgdir = g_build_filename (str, ".gtkpod", NULL);
-      if(!g_file_test(cfgdir, G_FILE_TEST_IS_DIR))
-      {
-         if(mkdir(cfgdir, 0777) == -1)
-         {
-             /* if this error occurs before we have initialized config
-                and display we crash --> resort to fprintf() */
-             if (cfg)
-                 gtkpod_warning(_("Unable to 'mkdir %s'\n"), cfgdir);
-             else
-                 fprintf(stderr, _("Unable to 'mkdir %s'\n"), cfgdir);
-         }
-      }
-  }
-  return cfgdir;
-}

Index: prefs.h
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/prefs.h,v
retrieving revision 1.190
retrieving revision 1.191
diff -u -d -r1.190 -r1.191
--- prefs.h     25 Jun 2006 23:29:08 -0000      1.190
+++ prefs.h     26 Jun 2006 23:58:17 -0000      1.191
@@ -56,13 +56,6 @@
 extern const gchar *KEY_SYNCMODE;
 extern const gchar *KEY_MANUAL_SYNCDIR;
 
-
-struct cfg
-{
-  float version;            /* version of gtkpod writing the cfg file */
-};
-
-
 /* New prefs backend. Will replace the stuff above */
 
 /* 
@@ -95,6 +88,7 @@
 void prefs_set_string(const gchar *key, const gchar *value);
 void prefs_set_int(const gchar *key, const gint value);
 void prefs_set_int64(const gchar *key, const gint64 value);
+void prefs_set_double(const gchar *key, gdouble value);
 
 /* The index parameter is used for numbered preference keys.
  * (i.e. pref0, pref1, etc) */
@@ -104,6 +98,8 @@
                         const gint value);
 void prefs_set_int64_index(const gchar *key, guint index,
                           const gint64 value);
+void prefs_set_double_index(const gchar *key, guint index,
+                           gdouble value);
 
 /* Functions that get prefrence values */
 gchar *prefs_get_string(const gchar *key);
@@ -112,6 +108,8 @@
 gboolean prefs_get_int_value(const gchar *key, gint *value);
 gint64 prefs_get_int64(const gchar *key);
 gboolean prefs_get_int64_value(const gchar *key, gint64 *value);
+gdouble prefs_get_double(const gchar *key);
+gboolean prefs_get_double_value(const gchar *key, gdouble *value);
 
 /* Numbered prefs functions */
 gchar *prefs_get_string_index(const gchar *key, const guint index);
@@ -123,7 +121,10 @@
 gint64 prefs_get_int64_index(const gchar *key, const guint index);
 gboolean prefs_get_int64_value_index(const gchar *key,
                                     const guint index, gint64 *value);
-
+gdouble prefs_get_double_index(const gchar *key,
+                              guint index);
+gboolean prefs_get_double_value_index(const gchar *key, guint index,
+                                     gdouble *value);
 /* Special functions */
 void prefs_flush_subkey (const gchar *subkey);
 void prefs_rename_subkey (const gchar *subkey_old, const gchar *subkey_new);
@@ -155,6 +156,8 @@
                        const gint value);
 void temp_prefs_set_int64(TempPrefs *temp_prefs, const gchar *key,
                          const gint64 value);
+void temp_prefs_set_double(TempPrefs *temp_prefs, const gchar *key,
+                          gdouble value);
 
 /*
  * Functions that retrieve various types of info from the temp prefs tree.
@@ -165,7 +168,9 @@
 gint temp_prefs_get_int(TempPrefs *temp_prefs, const gchar *key);
 gboolean temp_prefs_get_int_value(TempPrefs *temp_prefs,
                                  const gchar *key, gint *value);
-
+gdouble temp_prefs_get_double(TempPrefs *temp_prefs, const gchar *key);
+gboolean temp_prefs_get_double_value(TempPrefs *temp_prefs, const gchar *key,
+                                   gdouble *value);
 
 /* Numbered prefrences functions */
 void temp_prefs_set_string_index(TempPrefs *temp_prefs, const gchar *key,
@@ -174,6 +179,8 @@
                              const guint index, const gint value);
 void temp_prefs_set_int64_index(TempPrefs *temp_prefs, const gchar *key,
                                const guint index, const gint64 value);
+void temp_prefs_set_double_index(TempPrefs *temp_prefs, const gchar *key,
+                                guint index, gdouble value);
 
 
 /* 
@@ -190,12 +197,4 @@
 GList *get_list_from_buffer(GtkTextBuffer *buffer);
 
 gchar *prefs_get_cfgdir (void);
-void cfg_free(struct cfg *c);
-void write_prefs (void);
-struct cfg* clone_prefs(void);
-gboolean read_prefs_old (GtkWidget *gtkpod, int argc, char *argv[]);
-
-void prefs_set_md5tracks(gboolean active);
-gboolean prefs_get_md5tracks(void);
-
 #endif

Index: prefs_window.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/prefs_window.c,v
retrieving revision 1.180
retrieving revision 1.181
diff -u -d -r1.180 -r1.181
--- prefs_window.c      25 Jun 2006 23:29:08 -0000      1.180
+++ prefs_window.c      26 Jun 2006 23:58:17 -0000      1.181
@@ -47,8 +47,6 @@
 
 static GtkWidget *prefs_window = NULL;
 static GtkWidget *sort_window = NULL;
-static struct cfg *tmpcfg = NULL;
-static struct cfg *origcfg = NULL;
 
 /* New prefs temp handling */
 static TempPrefs *temp_prefs;
@@ -316,20 +314,9 @@
        return;
     }
                
-               /* Initialize temp prefs structures */
-               temp_prefs = temp_prefs_create();
-               temp_lists = temp_lists_create();
-
-    if(!tmpcfg && !origcfg)
-    {
-       tmpcfg = clone_prefs();
-       origcfg = clone_prefs();
-    }
-    else
-    {
-       g_warning ("Programming error: tmpcfg is not NULL!!\n");
-       return;
-    }
+    /* Initialize temp prefs structures */
+    temp_prefs = temp_prefs_create();
+    temp_lists = temp_lists_create();
 
     prefs_window_xml = glade_xml_new (xml_file, "prefs_window", NULL);
     glade_xml_signal_autoconnect (prefs_window_xml);
@@ -726,18 +713,9 @@
 void
 prefs_window_cancel(void)
 {
-    cfg_free (tmpcfg);
-    /* exchange tmpcfg for origcfg */
-    tmpcfg = origcfg;
-    origcfg = NULL;
-
     /* "save" (i.e. reset) original configs */
     prefs_window_set ();
 
-    /* delete cfg struct */
-    cfg_free (tmpcfg);
-    tmpcfg = NULL;
-
     /* save current window size */
     prefs_window_update_default_sizes ();
 
@@ -753,12 +731,6 @@
 {
     gint defx, defy;
     GtkWidget *nb;
-
-    /* delete cfg structs */
-    cfg_free (tmpcfg);
-    tmpcfg = NULL;
-    cfg_free (origcfg);
-    origcfg = NULL;
        
     /* Delete temp prefs structures */
     temp_prefs_destroy(temp_prefs);
@@ -790,19 +762,13 @@
     gint defx, defy;
     GtkWidget *nb;
 
-    /* Committ temp prefs to prefs table */
+    /* Commit temp prefs to prefs table */
     temp_prefs_apply(temp_prefs);
     temp_lists_apply(temp_lists);
   
     /* save current settings */
     prefs_window_set ();
 
-    /* delete cfg structs */
-    cfg_free (tmpcfg);
-    tmpcfg = NULL;
-    cfg_free (origcfg);
-    origcfg = NULL;
-
     /* save current notebook page */
     nb = gtkpod_xml_get_widget (prefs_window_xml, "notebook");
     prefs_set_int("last_prefs_page",gtk_notebook_get_current_page (
@@ -827,7 +793,7 @@
     gint defx, defy;
     GtkWidget *nb;
 
-    /* Committ temp prefs to prefs table */
+    /* Commit temp prefs to prefs table */
     temp_prefs_apply(temp_prefs);
     temp_lists_apply(temp_lists);
   
@@ -1946,9 +1912,6 @@
  */
 void sort_window_cancel (void)
 {
-    /* "save" (i.e. reset) original configs */
-    sort_window_set ();
-
     /* close the window */
     if(sort_window)
        gtk_widget_destroy(sort_window);


Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2

Reply via email to