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

Modified Files:
        charset.c file.c prefs.c prefs.h prefs_window.c 
Log Message:
Reversed patch from 6/20 -- will be redone.


Index: charset.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/charset.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- charset.c   20 Jun 2006 23:25:31 -0000      1.25
+++ charset.c   22 Jun 2006 14:29:23 -0000      1.26
@@ -154,7 +154,7 @@
     static GList *charsets = NULL; /* list with choices -- takes a while to
                                     * initialize, so we only do it once */
     
-    current_charset = prefs_get_string("charset");
+    current_charset = prefs_get_charset ();
     if ((current_charset == NULL) || (strlen (current_charset) == 0))
     {
        description = g_strdup (_("System Charset"));
@@ -163,7 +163,6 @@
     {
        description = charset_to_description (current_charset);
     }
-    g_free(current_charset);
     if (charsets == NULL)
     { /* set up list with charsets */
        FILE *fp;
@@ -303,16 +302,12 @@
  * feature. So far only Japanese Auto Detecion is implemented */
 static const gchar *charset_check_auto (const gchar *str)
 {
-    gchar *charset;
+    const gchar *charset;
 
     if (str == NULL) return NULL; /* sanity */
-    charset = prefs_get_string("charset");
+    charset = prefs_get_charset ();
     if (charset && (strcmp (charset, GTKPOD_JAPAN_AUTOMATIC) == 0))
-    {
-       g_free(charset);
-       return (charset_check_k_code ((gchar *)str));
-    }
-    g_free(charset);
+       return (charset_check_k_code (str));
     return NULL;
 }
 
@@ -335,31 +330,23 @@
 /* Must free the returned string yourself */
 gchar *charset_to_utf8 (const gchar *str)
 {
-    gchar *charset;  /* From prefs */
-    const gchar *locale_charset; /* Used if prefs doesn't have a charset */
-    gchar *ret;
+    const gchar *charset;
 
     if (str == NULL) return NULL;  /* sanity */
-    charset = (gchar *)charset_check_auto ((gchar *)str);
+    charset = charset_check_auto (str);
     if (charset)
     {
        auto_charset = charset;
     }
     else
     {
-       charset = prefs_get_string("charset");
+       charset = prefs_get_charset ();
        if (!charset || !strlen (charset))
        {    /* use standard locale charset */
-           g_free(charset);
-           g_get_charset (&locale_charset);
-           ret = charset_to_charset ((gchar *)locale_charset, "UTF-8", str);
-           g_free(charset);
-           return ret;
+           g_get_charset (&charset);
        }
     }
-    ret = charset_to_charset ((gchar *)charset, "UTF-8", str);
-    g_free(charset);
-    return ret;
+    return charset_to_charset ((gchar *)charset, "UTF-8", str);
 }
 
 
@@ -369,23 +356,15 @@
 /* Must free the returned string yourself */
 gchar *charset_from_utf8 (const gchar *str)
 {
-    gchar *charset;
-    const gchar *locale_charset;
-    gchar *ret;
+    const gchar *charset;
 
     if (str == NULL) return NULL;  /* sanity */
-    charset = prefs_get_string("charset");
+    charset = prefs_get_charset ();
     if (!charset || !strlen (charset))
-    {   
-       /* use standard locale charset */
-       g_free(charset);
-       g_get_charset (&locale_charset);
-       ret = charset_to_charset ("UTF-8", (gchar *)locale_charset, str);
-       return ret;
+    {    /* use standard locale charset */
+       g_get_charset (&charset);
     }
-    ret = charset_to_charset ("UTF-8", (gchar *)charset, str);
-    g_free(charset);
-    return ret;
+    return charset_to_charset ("UTF-8", (gchar *)charset, str);
 }
 
 /* Convert "str" from utf8 to the charset specified in @s->charset. If
@@ -394,9 +373,7 @@
 /* Must free the returned string yourself */
 gchar *charset_track_charset_from_utf8 (Track *s, const gchar *str)
 {
-    gchar *charset;
-    const gchar *locale_charset;
-    gchar *ret;
+    const gchar *charset = NULL;
     ExtraTrackData *etd;
 
     g_return_val_if_fail (s, NULL);
@@ -407,18 +384,13 @@
     etd = s->userdata;
 
     if (etd->charset && strlen (etd->charset))
-          charset = g_strdup( etd->charset);
-    else   charset = prefs_get_string("charset");
+          charset = etd->charset;
+    else   charset = prefs_get_charset ();
     if (!charset || !strlen (charset))
     {    /* use standard locale charset */
-       g_free(charset);
-       g_get_charset (&locale_charset);
-       ret = charset_to_charset ("UTF-8", (gchar *)locale_charset, str);
-       return ret;     
+       g_get_charset (&charset);
     }
-    ret = charset_to_charset ("UTF-8", (gchar *)charset, str);
-    g_free(charset);
-    return ret;
+    return charset_to_charset ("UTF-8", (gchar *)charset, str);
 }
 
 /* Convert "str" from "from_charset" to "to_charset", trying to skip

Index: file.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/file.c,v
retrieving revision 1.177
retrieving revision 1.178
diff -u -d -r1.177 -r1.178
--- file.c      20 Jun 2006 23:25:31 -0000      1.177
+++ file.c      22 Jun 2006 14:29:23 -0000      1.178
@@ -717,8 +717,7 @@
 /* update the track->charset info with the currently used charset */
 void update_charset_info (Track *track)
 {
-    gchar *charset = prefs_get_string("charset");
-    const gchar *locale_charset;
+    const gchar *charset = prefs_get_charset ();
     ExtraTrackData *etr;
 
     g_return_if_fail (track);
@@ -726,24 +725,14 @@
     g_return_if_fail (etr);
 
     C_FREE (etr->charset);
-    /* If we can get a charset from prefs, use that one.
-     * Otherwise, use the system locale charset. */
-    /* only set charset if it's not GTKPOD_JAPAN_AUTOMATIC */
     if (!charset || !strlen (charset))
-    { 
-       g_free(charset);
-       g_get_charset (&locale_charset);
-
-       if (locale_charset && 
-           (strcmp (locale_charset, GTKPOD_JAPAN_AUTOMATIC) != 0))
-       {
-           etr->charset = g_strdup (locale_charset);
-       }
+    {    /* use standard locale charset */
+       g_get_charset (&charset);
     }
-    else
+    /* only set charset if it's not GTKPOD_JAPAN_AUTOMATIC */
+    if (charset && (strcmp (charset, GTKPOD_JAPAN_AUTOMATIC) != 0))
     {
-       if (strcmp(charset, GTKPOD_JAPAN_AUTOMATIC) != 0)
-           etr->charset = charset;
+       etr->charset = g_strdup (charset);
     }
 }
 
@@ -1521,8 +1510,12 @@
 
     if (!prefs_get_int("update_charset") && charset_set)
     {   /* we should use the initial charset for the update */
-       prefs_charset = prefs_get_string("charset");
-       prefs_set_string("charset", etr->charset);
+       if (prefs_get_charset ())
+       {   /* remember the charset originally set */
+           prefs_charset = g_strdup (prefs_get_charset ());
+       }
+       /* use the charset used when first importing the track */
+       prefs_set_charset (etr->charset);
     }
 
     trackpath = get_file_name_from_source (track, SOURCE_PREFER_LOCAL);
@@ -1621,11 +1614,10 @@
 
     if (!prefs_get_int("update_charset") && charset_set)
     {   /* reset charset */
-       prefs_set_string("charset", prefs_charset);
+       prefs_set_charset (prefs_charset);
     }
 
     g_free (trackpath);
-    g_free(prefs_charset);
 
     while (widgets_blocked && gtk_events_pending ())  gtk_main_iteration ();
 }
@@ -1907,9 +1899,12 @@
     else               track_charset_set = FALSE;
     if (!prefs_get_int("write_charset") && track_charset_set)
     {   /* we should use the initial charset for the update */
+       if (prefs_get_charset ())
+       {   /* remember the charset originally set */
+           prefs_charset = g_strdup (prefs_get_charset ());
+       }
        /* use the charset used when first importing the track */
-       prefs_charset = prefs_get_string("charset");
-       prefs_set_string("charset", etr->charset);
+       prefs_set_charset (etr->charset);
     }
     else
     {   /* we should update the track->charset information */
@@ -1952,7 +1947,7 @@
 
     if (!prefs_get_int("write_charset") && track_charset_set)
     {   /* reset charset */
-       prefs_set_string("charset", prefs_charset);
+       prefs_set_charset (prefs_charset);
     }
     g_free (prefs_charset);
     return TRUE;

Index: prefs.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/prefs.c,v
retrieving revision 1.258
retrieving revision 1.259
diff -u -d -r1.258 -r1.259
--- prefs.c     21 Jun 2006 08:38:39 -0000      1.258
+++ prefs.c     22 Jun 2006 14:29:24 -0000      1.259
@@ -150,8 +150,6 @@
 static void set_default_preferences()
 {
     int i; 
-    gchar curdir[PATH_MAX]; /* These are for the current directory */
-    gchar *dir;
   
     prefs_set_int("update_existing", FALSE);
     prefs_set_int("id3_write", FALSE);
@@ -262,19 +260,6 @@
     prefs_set_int("display_toolbar", TRUE);
     prefs_set_int("toolbar_style", GTK_TOOLBAR_BOTH);
     prefs_set_int("block_display", FALSE);
-    prefs_set_string("charset", "");
-    prefs_set_int("statusbar_timeout", STATUSBAR_TIMEOUT);
-    prefs_set_int("md5", TRUE);
-
-    /* Set last directory browsed */
-    if (getcwd(curdir, PATH_MAX))
-       prefs_set_string("last_dir_browsed", curdir);
-    else
-    {
-       dir = convert_filename("~/");
-       prefs_set_string("last_dir_browsed", dir);
-       g_free(dir);
-    }
 
     /* Set sorting prefs */
     prefs_set_int("case_sensitive", FALSE);
@@ -1026,9 +1011,6 @@
   
   /* Update default sizes */
   display_update_default_sizes();
-
-  /* Don't save statusbar_timeout */
-  prefs_set_string("statusbar_timeout", NULL);
 }
 
 /* Initialize the prefs table and read configuration */
@@ -1867,11 +1849,29 @@
 struct cfg *cfg_new(void)
 {
     struct cfg *mycfg = NULL;
+    gchar curdir[PATH_MAX];
+    gchar *cfgdir;
+
+    cfgdir = prefs_get_cfgdir ();
 
     mycfg = g_malloc0 (sizeof (struct cfg));
+    if(getcwd(curdir, PATH_MAX))
+    {
+       prefs_set_string ("last_dir_browsed", curdir);
+    }
+    else
+    {
+       gchar *dir = convert_filename ("~/");
+       prefs_set_string ("last_dir_browsed", dir);
+       g_free (dir);
+    }
 
+    mycfg->charset = NULL;    
+    mycfg->md5tracks = TRUE;
     mycfg->offline = FALSE;
 
+    g_free (cfgdir);
+
     return(mycfg);
 }
 
@@ -1975,10 +1975,18 @@
                  prefs_set_string (EXPORT_FILES_TPL, arg);
              }
          }
+         else if(g_ascii_strcasecmp (line, "charset") == 0)
+         {
+               if(strlen (arg))      prefs_set_charset(arg);
+         }
          else if(g_ascii_strcasecmp (line, "id3_all") == 0)
          {
              /* obsoleted since 0.71 */
          }
+         else if(g_ascii_strcasecmp (line, "md5") == 0)
+         {
+             prefs_set_md5tracks((gboolean)atoi(arg));
+         }
          else if(g_ascii_strcasecmp (line, "offline") == 0)
          {
              prefs_set_offline((gboolean)atoi(arg));
@@ -1991,10 +1999,23 @@
          {
              /* removed with version after 0.82-CVS */
          }
+         else if(g_ascii_strcasecmp (line, "dir_browse") == 0)
+         {
+             prefs_set_string ("last_dir_browsed", arg);
+         }
+         else if(g_ascii_strcasecmp (line, "dir_export") == 0)
+         {
+             prefs_set_string (EXPORT_FILES_PATH, arg);
+         }
          else if(g_ascii_strcasecmp (line, "save_sorted_order") == 0)
          {
              /* ignore option -- has been deleted with 0.53 */
          }
+         else if(g_ascii_strcasecmp (line, "export_check_existing") == 0)
+         {
+             prefs_set_int (EXPORT_FILES_CHECK_EXISTING,
+                                  atoi (arg));
+         }
          else if(g_ascii_strcasecmp (line, "fix_path") == 0)
          {
              /* ignore -- wie always fix the export path (replace
@@ -2004,6 +2025,15 @@
          {
              /* ignore -- not used any more */
          }
+         else if(g_ascii_strcasecmp (line, "concal_autosync") == 0)
+         {
+             prefs_set_int ("itdb_0_concal_autosync", atoi(arg));
+         }
+         else if(g_ascii_strcasecmp (line, "special_export_charset") == 0)
+         {
+             prefs_set_int (EXPORT_FILES_SPECIAL_CHARSET,
+                                  atoi (arg));
+         }
          else
          {   /* All leftover options will be stored into the prefs
                 setting hash (generic options -- should have had this
@@ -2143,6 +2173,14 @@
     if(!fp)
        fp = stderr;
 
+
+    if (cfg->charset)
+    {
+       fprintf(fp, "charset=%s\n", cfg->charset);
+    } else {
+       fprintf(fp, "charset=\n");
+    }
+    fprintf(fp, "md5=%d\n",prefs_get_md5tracks ());
     fprintf(fp, "offline=%d\n",prefs_get_offline());
 }
 
@@ -2185,6 +2223,7 @@
 {
     if(c)
     {
+      g_free (c->charset);
       g_free (c);
     }
 }
@@ -2196,11 +2235,67 @@
   info_update_totals_view_space ();
 }
 
+/* If the status of md5 hash flag changes, free or re-init the md5
+   hash table */
+void prefs_set_md5tracks (gboolean active)
+{
+    struct itdbs_head *itdbs_head;
+
+    g_return_if_fail (gtkpod_window);
+    itdbs_head = g_object_get_data (G_OBJECT (gtkpod_window),
+                                   "itdbs_head");
+/*    g_return_if_fail (itdbs_head);*/
+    /* gets called before itdbs are set up -> fail silently */
+    if (!itdbs_head)
+    {
+       cfg->md5tracks = active;
+       return;
+    }
+
+    if (cfg->md5tracks && !active)
+    { /* md5 checksums have been turned off */
+       cfg->md5tracks = FALSE;
+       gp_md5_free_hash ();
+    }
+    if (!cfg->md5tracks && active)
+    { /* md5 checksums have been turned on */
+       cfg->md5tracks = TRUE; /* must be set before calling
+                                 gp_md5_hash_tracks() */
+       gp_md5_hash_tracks ();
+       /* display duplicates */
+       gp_duplicate_remove (NULL, NULL);
+    }
+}
+
+gboolean prefs_get_md5tracks(void)
+{
+    return cfg->md5tracks;
+}
+
 gboolean prefs_get_offline(void)
 {
   return cfg->offline;
 }
 
+void prefs_set_charset (gchar *charset)
+{
+    prefs_cfg_set_charset (cfg, charset);
+}
+
+void prefs_cfg_set_charset (struct cfg *cfgd, gchar *charset)
+{
+    C_FREE (cfgd->charset);
+    if (charset && strlen (charset))
+       cfgd->charset = g_strdup (charset);
+/*     printf ("set_charset: '%s'\n", charset);         */
+}
+
+gchar *prefs_get_charset (void)
+{
+    return cfg->charset;
+/*     printf ("get_charset: '%s'\n", cfg->charset); */
+}
+
 struct cfg *clone_prefs(void)
 {
     struct cfg *result = NULL;
@@ -2208,6 +2303,7 @@
     if(cfg)
     {
        result = g_memdup (cfg, sizeof (struct cfg));
+       result->charset = g_strdup(cfg->charset);
     }
     return(result);
 }
@@ -2238,5 +2334,17 @@
   return cfgdir;
 }
 
+/* A value of "0" will set the default defined in misc.c */
+void prefs_set_statusbar_timeout (guint32 val)
+{
+    if (val == 0)  val = STATUSBAR_TIMEOUT;
+    cfg->statusbar_timeout = val;
+    gtkpod_statusbar_reset_timeout ();
+}
+
+guint32 prefs_get_statusbar_timeout (void)
+{
+    return cfg->statusbar_timeout;
+}
 
 

Index: prefs.h
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/prefs.h,v
retrieving revision 1.183
retrieving revision 1.184
diff -u -d -r1.183 -r1.184
--- prefs.h     21 Jun 2006 04:50:09 -0000      1.183
+++ prefs.h     22 Jun 2006 14:29:24 -0000      1.184
@@ -59,8 +59,11 @@
 
 struct cfg
 {
+  gchar    *charset;        /* CHARSET to use with file operations */
+  gboolean md5tracks;      /* don't allow track duplication on your ipod */
   
   gboolean offline;       /* are we working offline, i.e. without iPod? */
+  guint32 statusbar_timeout;    /* timeout for statusbar messages */
   float version;                /* version of gtkpod writing the cfg file */
 };
 
@@ -199,6 +202,14 @@
 gboolean read_prefs_old (GtkWidget *gtkpod, int argc, char *argv[]);
 
 void prefs_set_offline(gboolean active);
+void prefs_set_md5tracks(gboolean active);
+void prefs_set_charset (gchar *charset);
+void prefs_cfg_set_charset (struct cfg *cfg, gchar *charset);
+void prefs_set_statusbar_timeout (guint32 val);
+
 gboolean prefs_get_offline(void);
+gchar * prefs_get_charset (void);
+gboolean prefs_get_md5tracks(void);
+guint32 prefs_get_statusbar_timeout (void);
 
 #endif

Index: prefs_window.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/prefs_window.c,v
retrieving revision 1.176
retrieving revision 1.177
diff -u -d -r1.176 -r1.177
--- prefs_window.c      21 Jun 2006 04:50:09 -0000      1.176
+++ prefs_window.c      22 Jun 2006 14:29:24 -0000      1.177
@@ -34,7 +34,6 @@
 #include "display_itdb.h"
 #include "info.h"
 #include "fileselection.h"
-#include "md5.h"
 #include "misc.h"
 #include "misc_track.h"
 #include "prefs.h"
@@ -375,7 +374,7 @@
     
     w = gtkpod_xml_get_widget (prefs_window_xml, "cfg_md5tracks");
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
-                                prefs_get_int("md5"));
+                                tmpcfg->md5tracks);
 
     w = gtkpod_xml_get_widget (prefs_window_xml, "cfg_update_existing");
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
@@ -384,7 +383,7 @@
     w = gtkpod_xml_get_widget (prefs_window_xml, "cfg_show_duplicates");
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
                                 prefs_get_int("show_duplicates"));
-    if (!prefs_get_int("md5")) gtk_widget_set_sensitive (w, FALSE);
+    if (!tmpcfg->md5tracks) gtk_widget_set_sensitive (w, FALSE);
 
     w = gtkpod_xml_get_widget (prefs_window_xml, "cfg_show_updated");
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
@@ -683,34 +682,28 @@
 static void
 prefs_window_set(void)
 {
-    gboolean md5active;
-
-    if (temp_prefs)
-    {
-       /* Update the display if we changed the number of sort tabs */
-       if (temp_prefs_get_int_value(temp_prefs, "sort_tab_num", NULL))
-           st_show_visible();
-
-        /* Free/re-initialize the md5 tabe if the setting was changed */
-       if (temp_prefs_get_int_value(temp_prefs, "md5", &md5active))
-           setup_md5(md5active);
-    }
-           
+   if (temp_prefs)
+   {
+     /* Update the display if we changed the number of sort tabs */
+     if (temp_prefs_get_int_value(temp_prefs, "sort_tab_num", NULL))
+      st_show_visible();
+   }
   
-    /* Need this in case user reordered column order (we don't
-     * catch the reorder signal) */
-    tm_store_col_order ();
+   if (tmpcfg)
+    {
+       /* Need this in case user reordered column order (we don't
+        * catch the reorder signal) */
+       tm_store_col_order ();
+       prefs_set_charset(tmpcfg->charset);
 
-    /* update columns if user reordered them */
-    tm_show_preferred_columns();
-   
-    /* update sort tab display */
-    st_show_visible();
-   
-    /* update tooltip/toolbar displays */
-    display_show_hide_tooltips();
-    display_show_hide_toolbar();
+       /* this call well automatically destroy/setup the md5 hash table */
+       prefs_set_md5tracks(tmpcfg->md5tracks);
+       tm_show_preferred_columns();
+       st_show_visible();
+       display_show_hide_tooltips();
+       display_show_hide_toolbar();
        
+    }
 }
 
 
@@ -940,7 +933,7 @@
     gboolean val = gtk_toggle_button_get_active(togglebutton);
     GtkWidget *w = gtkpod_xml_get_widget (prefs_window_xml, 
"cfg_show_duplicates");
 
-    temp_prefs_set_int(temp_prefs, "md5", val);
+    tmpcfg->md5tracks = val;
     if(w)      gtk_widget_set_sensitive (w, val);
 }
 
@@ -1081,7 +1074,7 @@
 
     descr = gtk_editable_get_chars (editable, 0, -1);
     charset = charset_from_description (descr);
-    temp_prefs_set_string(temp_prefs, "charset", charset);
+    prefs_cfg_set_charset (tmpcfg, charset);
     g_free (descr);
     g_free (charset);
 }


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