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

Modified Files:
        file_itunesdb.c misc.c prefs.c prefs.h repository.c 
Log Message:
        * src/repository.c
          src/prefs.c
          src/prefs.h: added temp_prefs_remove_key()

          src/repository.c: use temp_prefs_remove_key() to remove keys.

          src/file_itunesdb.c: fix assertions related to get_offline()
          introduced yesterday.

        * src/repository.c: only print debug messages about keys
          added/removed if LOCAL_DEBUG is defined



Index: file_itunesdb.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/file_itunesdb.c,v
retrieving revision 1.98
retrieving revision 1.99
diff -u -d -r1.98 -r1.99
--- file_itunesdb.c     24 Jun 2006 15:39:22 -0000      1.98
+++ file_itunesdb.c     25 Jun 2006 16:08:22 -0000      1.99
@@ -1,4 +1,4 @@
-/* Time-stamp: <2006-06-25 00:25:34 jcs>
+/* Time-stamp: <2006-06-25 15:57:03 jcs>
 |
 |  Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users sourceforge net>
 |  Part of the gtkpod project.
@@ -400,14 +400,21 @@
     iTunesDB *itdb = NULL;
     GError *error = NULL;
     gint32 total, num;
+    gboolean offline;
+
 
     g_return_val_if_fail (!(type & GP_ITDB_TYPE_LOCAL) || name_loc, NULL);
     g_return_val_if_fail (!(type & GP_ITDB_TYPE_IPOD) || 
                          (mp && name_off), NULL);
     g_return_val_if_fail (cfgdir, NULL);
 
+    if (old_itdb)
+       offline = get_offline (old_itdb);
+    else
+       offline = FALSE;
+
     block_widgets ();
-    if (get_offline(old_itdb) || (type & GP_ITDB_TYPE_LOCAL))
+    if (offline || (type & GP_ITDB_TYPE_LOCAL))
     { /* offline or local database - requires extended info */
        gchar *name_ext;
        gchar *name_db;
@@ -542,11 +549,13 @@
     eitdb = itdb->userdata;
     g_return_val_if_fail (eitdb, (release_widgets(), NULL));
 
+    eitdb->offline = offline;
+
     /* fill in additional info */
     itdb->usertype = type;
     if (type & GP_ITDB_TYPE_IPOD)
     {
-       if (get_offline (itdb))
+       if (offline)
        {
            itdb_set_mountpoint (itdb, mp);
            g_free (itdb->filename);

Index: misc.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/misc.c,v
retrieving revision 1.209
retrieving revision 1.210
diff -u -d -r1.209 -r1.210
--- misc.c      24 Jun 2006 15:39:22 -0000      1.209
+++ misc.c      25 Jun 2006 16:08:22 -0000      1.210
@@ -1,5 +1,5 @@
 /* -*- coding: utf-8; -*-
-|  Time-stamp: <2006-06-25 00:28:34 jcs>
+|  Time-stamp: <2006-06-25 15:20:33 jcs>
 |
 |  Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users sourceforge net>
 |  Part of the gtkpod project.

Index: prefs.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/prefs.c,v
retrieving revision 1.264
retrieving revision 1.265
diff -u -d -r1.264 -r1.265
--- prefs.c     25 Jun 2006 05:56:41 -0000      1.264
+++ prefs.c     25 Jun 2006 16:08:22 -0000      1.265
@@ -1,4 +1,4 @@
-/* Time-stamp: <2006-06-25 01:18:23 jcs>
+/* Time-stamp: <2006-06-25 21:40:01 jcs>
 |
 |  Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users sourceforge net>
 |  Part of the gtkpod project.
@@ -379,14 +379,6 @@
        return NULL;
 }
 
-/* Copy key data from the temp prefs tree to the hash table */
-static gboolean copy_key(gpointer key, gpointer value, gpointer user_data)
-{
-    prefs_set_string(key, value);
-       
-    return FALSE;
-}
-
 /* Remove key present in the temp prefs tree from the hash table */
 static gboolean flush_key (gpointer key, gpointer value, gpointer user_data)
 {
@@ -1057,6 +1049,14 @@
     g_free(temp_prefs);
 }
 
+/* Copy key data from the temp prefs tree to the hash table */
+static gboolean copy_key(gpointer key, gpointer value, gpointer user_data)
+{
+    prefs_set_string(key, value);
+       
+    return FALSE;
+}
+
 /* Copy the data from the temp prefs tree to the permanent prefs table */
 void temp_prefs_apply(TempPrefs *temp_prefs)
 {
@@ -1479,16 +1479,27 @@
     return ret;
 }
 
-/* Add string value with the given key to temp prefs. Remove the key
- * if @value is NULL. */
+/* Add string value with the given key to temp prefs. Note: use
+ * temp_prefs_remove_key() to remove key from the temp prefs. Setting
+ * it to NULL will not remove the key. It will instead remove the key
+ * in the main prefs table when you call temp_prefs_apply(). */
 void temp_prefs_set_string(TempPrefs *temp_prefs, const gchar *key, 
                           const gchar *value)
 {
     g_return_if_fail (temp_prefs && temp_prefs->tree);
     g_return_if_fail (key);
 
-    if (value)
-       g_tree_insert (temp_prefs->tree, g_strdup(key), g_strdup(value));
+    g_tree_insert (temp_prefs->tree, g_strdup(key), g_strdup(value));
+}
+
+/* Add string value with the given key to temp prefs. Remove the key
+ * if @value is NULL. */
+void temp_prefs_remove_key (TempPrefs *temp_prefs, const gchar *key)
+{
+    g_return_if_fail (temp_prefs && temp_prefs->tree);
+    g_return_if_fail (key);
+
+    g_tree_remove (temp_prefs->tree, key);
 }
 
 /* Add an integer value to temp prefs */

Index: prefs.h
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/prefs.h,v
retrieving revision 1.188
retrieving revision 1.189
diff -u -d -r1.188 -r1.189
--- prefs.h     25 Jun 2006 04:16:52 -0000      1.188
+++ prefs.h     25 Jun 2006 16:08:22 -0000      1.189
@@ -1,4 +1,4 @@
-/* Time-stamp: <2006-06-25 01:18:22 jcs>
+/* Time-stamp: <2006-06-25 15:57:02 jcs>
 |
 |  Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users sourceforge net>
 |  Part of the gtkpod project.
@@ -150,6 +150,7 @@
 /*
  * Functions that add various types of info to the temp prefs tree.
  */
+void temp_prefs_remove_key (TempPrefs *temp_prefs, const gchar *key);
 void temp_prefs_set_string(TempPrefs *temp_prefs, const gchar *key,
                           const gchar *value);
 void temp_prefs_set_int(TempPrefs *temp_prefs, const gchar *key,

Index: repository.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/repository.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- repository.c        14 Jun 2006 16:12:10 -0000      1.14
+++ repository.c        25 Jun 2006 16:08:22 -0000      1.15
@@ -1,4 +1,4 @@
-/* Time-stamp: <2006-06-15 00:58:25 jcs>
+/* Time-stamp: <2006-06-25 21:40:01 jcs>
 |
 |  Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users sourceforge net>
 |  Part of the gtkpod project.
@@ -42,10 +42,12 @@
 #include "repository.h"
 #include "syncdir.h"
 
+/* print local debug message */
+#define LOCAL_DEBUG 0
+
 /* List with all repository edit windows (we only allow one, however) */
 static GList *repwins = NULL;
 
-
 struct _RepWin
 {
     GladeXML *xml;           /* XML info                             */
@@ -273,15 +275,19 @@
        (prefs_str && (strcmp (str, prefs_str) != 0)))
     {   /* value has changed with respect to the value stored in the
           prefs */
-printf ("setting '%s' to '%s'\n", key, str);
+#       if LOCAL_DEBUG
+       printf ("setting '%s' to '%s'\n", key, str);
+#       endif
        temp_prefs_set_string (repwin->temp_prefs, key, str);
        result = TRUE;
     }
     else
     {   /* value has not changed -- remove key from temp prefs (in
           case it exists */
-printf ("removing '%s'.\n", key);
-       temp_prefs_set_string (repwin->temp_prefs, key, NULL);
+#       if LOCAL_DEBUG
+       printf ("removing '%s'.\n", key);
+#       endif
+       temp_prefs_remove_key (repwin->temp_prefs, key);
        result = FALSE;
     }
     update_buttons (repwin);
@@ -325,14 +331,18 @@
     if (prefs_val != val)
     {   /* value has changed with respect to the value stored in the
           prefs */
-printf ("setting '%s' to '%d'\n", key, val);
+#       if LOCAL_DEBUG
+       printf ("setting '%s' to '%d'\n", key, val);
+#       endif
        temp_prefs_set_int (repwin->temp_prefs, key, val);
     }
     else
     {   /* value has not changed -- remove key from temp prefs (in
           case it exists */
-printf ("removing '%s'.\n", key);
-       temp_prefs_set_string (repwin->temp_prefs, key, NULL);
+#       if LOCAL_DEBUG
+       printf ("removing '%s'.\n", key);
+#       endif
+       temp_prefs_remove_key (repwin->temp_prefs, key);
     }
     update_buttons (repwin);
     g_free (key);
@@ -477,7 +487,7 @@
     if (keybase == KEY_LIVEUPDATE)
     {
        if (active == repwin->playlist->splpref.liveupdate)
-           temp_prefs_set_string (repwin->extra_prefs, key, NULL);
+           temp_prefs_remove_key (repwin->extra_prefs, key);
        else
            temp_prefs_set_int (repwin->extra_prefs, key, active);
 
@@ -500,7 +510,7 @@
     {   /* Un-delete if necessary */
        gchar *key = get_itdb_prefs_key (repwin->itdb_index, "deleted");
 
-       temp_prefs_set_string (repwin->extra_prefs, key, NULL);
+       temp_prefs_remove_key (repwin->extra_prefs, key);
        g_free (key);
     }
     update_buttons (repwin);
@@ -1013,7 +1023,9 @@
            select_repository (repwin, new_itdb, NULL);
        }
     }
-printf ("index: %d\n", repwin->itdb_index);
+#   if LOCAL_DEBUG
+    printf ("index: %d\n", repwin->itdb_index);
+#   endif
 
     update_buttons (repwin);
 }
@@ -1452,7 +1464,9 @@
     iTunesDB *itdb;
     gint index;
 
-printf ("Repository changed (%p)\n", repwin);
+#   if LOCAL_DEBUG
+    printf ("Repository changed (%p)\n", repwin);
+#   endif
 
     g_return_if_fail (repwin);
 
@@ -1484,7 +1498,9 @@
     GtkTreeIter iter;
     gint index;
 
-printf ("Playlist changed (%p)\n", repwin);
+#   if LOCAL_DEBUG
+    printf ("Playlist changed (%p)\n", repwin);
+#   endif
 
     g_return_if_fail (repwin);
 
@@ -1828,7 +1844,9 @@
        {
            gchar *from_key = get_itdb_prefs_key (i, "");
            gchar *to_key = get_itdb_prefs_key (i+1, "");
-printf ("TP renaming %d to %d\n", i, i+1);
+#           if LOCAL_DEBUG
+           printf ("TP renaming %d to %d\n", i, i+1);
+#           endif
            temp_prefs_rename_subkey (repwin->temp_prefs,
                                      from_key, to_key);
            g_free (from_key);
@@ -2213,7 +2231,9 @@
     {
        gchar *from_key = get_itdb_prefs_key (i, "");
        gchar *to_key = get_itdb_prefs_key (i+1, "");
-printf ("renaming %d to %d\n", i, i+1);
+#       if LOCAL_DEBUG
+       printf ("renaming %d to %d\n", i, i+1);
+#       endif
        prefs_rename_subkey (from_key, to_key);
        g_free (from_key);
        g_free (to_key);


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