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

Modified Files:
        Makefile.am display_itdb.c display_itdb.h file_convert.c 
        file_itunesdb.c misc.c misc.h misc_input.c prefs.c prefs.h 
        prefs_window.c tools.c 
Added Files:
        autodetection.c autodetection.h 
Log Message:
        * INSTALL
          configure.in
          src/Makefile.am
          src/autodetection.c (new)
          src/autodetection.h (new)
          src/display_itdb.h
          src/file_convert.c
          src/file_itunesdb.c
          src/misc.c
          src/misc.h
          src/misc_input.c
          src/tools.c:

          Autodetection and auto-loading of iPods. This loads iPods
          automatically on start-up when they are connected or later
          when they are mounted. Uses gnome-vfs for detection of
          mounted volumes and HAL for determining if the mounted
          volume is an iPod. Works fine without HAL, and compiles fine
          without gnome-vfs, but without autodection facility.

          iPod repositories are added automatically when necessary and
          removed when ejecting an iPod. Preferences referring to an
          iPod are saved into the iTunes directory (gtkpod.prefs).


          gtkpod.glade
          src/prefs_windows.c:
          src/prefs.c
          - removed old auto-import functionality. Auto-import is no
            longer supported without gnome-vfs. Code to support
            automounting on KDE should be easy to add -- please
            contribute.
          

          src/prefs.c
          src/prefs.h:
          - new code to save/load temporary preferences to an
            aribtrary file (temp_prefs_load/save(), used by
            load/save_ipod_prefs() in misc.c).
          - new code to create a subset of keys from the prefs
            structure.



--- NEW FILE: autodetection.c ---
/*
|  Copyright (C) 2007 Jorg Schuler <jcsjcs at users.sourceforge.net>
|  Part of the gtkpod project.
|
|  URL: http://gtkpod.sourceforge.net/
|  URL: http://www.gtkpod.org
|
|  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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|  iTunes and iPod are trademarks of Apple
|
|  This product is not supported/written/published by Apple!
|
|  $Id: autodetection.c,v 1.1 2007/05/11 15:41:53 jcsjcs Exp $
*/


#include "autodetection.h"
#include "config.h"
#include "misc.h"
#include "prefs.h"
#include <stdio.h>
#include <string.h>



#ifdef HAVE_GNOME_VFS
#include <libgnomevfs/gnome-vfs.h>
#endif
#ifdef HAVE_HAL
#include <libhal.h>
#include <dbus/dbus.h>
#endif

#define DEBUG_AUTO
#ifdef DEBUG_AUTO
#   define _TO_STR(x) #x
#   define TO_STR(x) _TO_STR(x)
#   define debug(...) do { fprintf(stderr,  __FILE__ ":" TO_STR(__LINE__) ":" 
__VA_ARGS__); } while(0)
#else
#   define debug(...)
#endif



/* Find out if an itdb uses the mountpoint @mountpoint and return that
   itdb */
static iTunesDB *ad_find_repository_with_mountpoint (const gchar *mountpoint)
{
    GList *gl;
    gchar *mp;
    gint lenmp;
    iTunesDB *result = NULL;
    struct itdbs_head *itdbs;

    g_return_val_if_fail (mountpoint, NULL);

    itdbs = gp_get_itdbs_head (gtkpod_window);
    g_return_val_if_fail (itdbs, NULL);

    /* eliminate trailing dir separators ('/') */
    mp = g_strdup (mountpoint);
    lenmp = strlen (mountpoint);
    if ((lenmp > 0) && (mp[lenmp-1] == G_DIR_SEPARATOR))
    {
        mp[lenmp-1] = 0;
    }

    for (gl=itdbs->itdbs; gl; gl=gl->next)
    {
        iTunesDB *itdb = gl->data;
        g_return_val_if_fail (itdb, NULL);

        if (itdb->usertype & GP_ITDB_TYPE_IPOD)
        {
            gchar *imp = get_itdb_prefs_string (itdb, KEY_MOUNTPOINT);
            if (imp)
            {
                gint comp;
                gint lenimp = strlen (imp);

                /* eliminate trailing dir separators ('/') */
                if ((lenimp > 0) && (imp[lenimp-1] == G_DIR_SEPARATOR))
                {
                    imp[lenmp-1] = 0;
                }

                comp = strcmp (mp, imp);

                g_free (imp);

                if (comp == 0)
                {
                    result = itdb;
                    break;
                }
            }
        }
    }

    g_free (mp);

    return result;
}




#ifdef HAVE_GNOME_VFS
typedef struct _AutoDetect AutoDetect;

static gboolean ad_timeout_cb (gpointer data);


struct _AutoDetect
{
    GMutex *mutex;              /* shared lock */
    GList *new_ipod_uris;       /* list of new mounts */
    guint timeout_id;
};    

static AutoDetect *autodetect;


#ifdef HAVE_HAL
/* from rb-ipod-source.c (rhythmbox ipod plugin) */
static gboolean
hal_udi_is_ipod (const char *udi)
{
        LibHalContext *ctx;
        DBusConnection *conn;
        char *parent_udi;
        char *parent_name;
        gboolean result;
        DBusError error;
        gboolean inited = FALSE;

        result = FALSE;
        dbus_error_init (&error);

        conn = NULL;
        parent_udi = NULL;
        parent_name = NULL;

        ctx = libhal_ctx_new ();
        if (ctx == NULL) {
                /* FIXME: should we return an error somehow so that we can
                 * fall back to a check for iTunesDB presence instead ?
                 */
                debug ("cannot connect to HAL");
                goto end;
        }
        conn = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
        if (conn == NULL || dbus_error_is_set (&error))
                goto end;

        libhal_ctx_set_dbus_connection (ctx, conn);
        if (!libhal_ctx_init (ctx, &error) || dbus_error_is_set (&error))
                goto end;

        inited = TRUE;
        parent_udi = libhal_device_get_property_string (ctx, udi,
                        "info.parent", &error);
        if (parent_udi == NULL || dbus_error_is_set (&error))
                goto end;

        parent_name = libhal_device_get_property_string (ctx, parent_udi,
                        "storage.model", &error);
        if (parent_name == NULL || dbus_error_is_set (&error))
                goto end;

        if (strcmp (parent_name, "iPod") == 0)
                result = TRUE;

end:
        g_free (parent_udi);
        g_free (parent_name);

        if (dbus_error_is_set (&error)) {
                debug ("Error: %s\n", error.message);
                dbus_error_free (&error);
                dbus_error_init (&error);
        }

        if (ctx) {
                if (inited)
                        libhal_ctx_shutdown (ctx, &error);
                libhal_ctx_free(ctx);
        }

        dbus_error_free (&error);

        return result;
}
#endif


/* adapted from rb-ipod-source.c (rhythmbox ipod plugin) */
static gchar *ad_get_itunes_dir (GnomeVFSVolume *volume)
{
    gchar *mount_point_uri;
    gchar *result = NULL;

    mount_point_uri = gnome_vfs_volume_get_activation_uri (volume);
    if (mount_point_uri)
    {
        gchar *mount_point;
        mount_point = g_filename_from_uri (mount_point_uri, NULL, NULL);
        if (mount_point)
        {
            result = itdb_get_itunes_dir (mount_point);
            g_free (mount_point);
        }
        g_free (mount_point_uri);
    }
    return result;
}


/* adapted from rb-ipod-source.c (rhythmbox ipod plugin) */
static gboolean ad_volume_has_ipod_dir (GnomeVFSVolume *volume)
{
    gchar *itunes_dir;
    gboolean result = FALSE;

    itunes_dir = ad_get_itunes_dir (volume);

    if (itunes_dir)
    {
        result = g_file_test (itunes_dir, G_FILE_TEST_EXISTS);
    }

    g_free (itunes_dir);

    return result;
}

/* adapted from rb-ipod-source.c (rhythmbox ipod plugin) */
static gboolean ad_volume_is_ipod (GnomeVFSVolume *volume)
{
#ifdef HAVE_HAL
    gchar *udi;
#endif
    if (gnome_vfs_volume_get_volume_type (volume) != 
GNOME_VFS_VOLUME_TYPE_MOUNTPOINT)
    {
        return FALSE;
    }

#ifdef HAVE_HAL
    udi = gnome_vfs_volume_get_hal_udi (volume);
    if (udi != NULL)
    {
        gboolean result;

        result = hal_udi_is_ipod (udi);
        g_free (udi);
        if (result == FALSE)
        {
            return FALSE;
        }
    }
#endif

    return ad_volume_has_ipod_dir (volume);
}



static void ad_volume_mounted_cb (GnomeVFSVolumeMonitor *vfsvolumemonitor,
                                  GnomeVFSVolume *volume,
                                  AutoDetect *ad)
{
    g_return_if_fail (volume && ad);

    if (ad_volume_is_ipod (volume))
    {
        gchar *uri;

        uri = gnome_vfs_volume_get_activation_uri (volume);

        debug ("mounted iPod: '%s'\n", uri);

        g_mutex_lock (ad->mutex);
        ad->new_ipod_uris = g_list_prepend (ad->new_ipod_uris, uri);
        g_mutex_unlock (ad->mutex);
    }
}


void autodetection_init ()
{
    if (autodetect == NULL)
    {
        GList *volumes, *gl;

        if (!gnome_vfs_init ())
        {
            gtkpod_warning (_("Could not initialize GnomeVFS\n"));
            g_return_if_reached ();
        }

        autodetect = g_new0 (AutoDetect, 1);
        autodetect->mutex = g_mutex_new ();

        /* Check if an iPod is already mounted and add it to the list */
        volumes = gnome_vfs_volume_monitor_get_mounted_volumes (
            gnome_vfs_get_volume_monitor ());

        for (gl=volumes; gl; gl=gl->next)
        {
            GnomeVFSVolume *volume = gl->data;
            g_return_if_fail (volume);
            ad_volume_mounted_cb (NULL, volume, autodetect);
            gnome_vfs_volume_unref (volume);
        }
        g_list_free (volumes);

        g_signal_connect (G_OBJECT (gnome_vfs_get_volume_monitor ()),
                          "volume-mounted",
                          G_CALLBACK (ad_volume_mounted_cb),
                          autodetect);

        /* start timeout function for the monitor */
        autodetect->timeout_id = g_timeout_add (100,   /* every 100 ms */
                                                ad_timeout_cb,
                                                autodetect);
    }
}


static gboolean ad_timeout_cb (gpointer data)
{
    AutoDetect *ad = data;
    g_return_val_if_fail (ad, FALSE);


    /* Don't interfere with a blocked display -- try again later */
    if (!widgets_blocked)
    {
        gdk_threads_enter ();
        block_widgets ();
        g_mutex_lock (ad->mutex);
        while (ad->new_ipod_uris)
        {
            iTunesDB *itdb, *loaded_itdb = NULL;
            gchar *mountpoint;
            struct itdbs_head *itdbs;
            GList *gl = ad->new_ipod_uris;
            gchar *mount_uri = gl->data;

            ad->new_ipod_uris = g_list_delete_link (ad->new_ipod_uris, gl);

            g_mutex_unlock (ad->mutex);

            g_return_val_if_fail (mount_uri, (gdk_threads_leave(), 
release_widgets(), TRUE));

            mountpoint = g_filename_from_uri (mount_uri, NULL, NULL);
            g_free (mount_uri);
            debug ("Mounted iPod at '%s'\n", mountpoint);

            itdb = ad_find_repository_with_mountpoint (mountpoint);

            itdbs = gp_get_itdbs_head (gtkpod_window);
            g_return_val_if_fail (itdbs, (gdk_threads_leave(), 
release_widgets(), TRUE));

            if (itdb)
            {
                ExtraiTunesDBData *eitdb = itdb->userdata;
                g_return_val_if_fail (eitdb,(gdk_threads_leave(), 
release_widgets(), TRUE));

                debug ("...used by itdb %p\n", itdb);

                if (!eitdb->itdb_imported)
                {
                    loaded_itdb = gp_load_ipod (itdb);
                    loaded_itdb->usertype |= GP_ITDB_TYPE_AUTOMATIC;
                    set_itdb_prefs_int (loaded_itdb, "type", 
loaded_itdb->usertype);
                }
                else
                {
                    gtkpod_warning (_("Newly mounted iPod at '%s' appearss to 
be already loaded!\n\n"));
                }
                debug ("...OK (used)\n");
            }
            else
            {   /* Set up new itdb (which we'll add to the end of the list) */
                iTunesDB *new_itdb;
                gint index = g_list_length (itdbs->itdbs);
                debug ("...not used by any itdb.\n");
                set_itdb_index_prefs_string (index,
                                             KEY_MOUNTPOINT, mountpoint);
                set_itdb_index_prefs_string (index,
                                             "name", _("New iPod"));
                set_itdb_index_prefs_int (index,
                                          "type", GP_ITDB_TYPE_IPOD |
                                                  GP_ITDB_TYPE_AUTOMATIC);
                new_itdb = setup_itdb_n (index);
                g_return_val_if_fail (new_itdb,
                                      (gdk_threads_leave(), release_widgets(), 
TRUE));
                /* add to display */
                gp_itdb_add (new_itdb, -1);
                /* load prefs from iPod */
                loaded_itdb = gp_load_ipod (new_itdb);
                if (!loaded_itdb)
                {   /* remove itdb and all associated keys again */
                    remove_itdb_prefs (itdb);
                    gp_itdb_remove (new_itdb);
                    gp_itdb_free (new_itdb);
                }
                debug ("...OK (new)\n");
            }

            g_free (mountpoint);

            g_mutex_lock (ad->mutex);
        }
        g_mutex_unlock (ad->mutex);
        release_widgets ();
        gdk_threads_leave();
    }

    return TRUE;
}

#else
/* No GNOME_VFS support */

void autodetection_init ()
{
}
#endif

--- NEW FILE: autodetection.h ---
/*
|  Copyright (C) 2007 Jorg Schuler <jcsjcs at users.sourceforge.net>
|  Part of the gtkpod project.
|
|  URL: http://gtkpod.sourceforge.net/
|  URL: http://www.gtkpod.org
|
|  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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|  iTunes and iPod are trademarks of Apple
|
|  This product is not supported/written/published by Apple!
|
|  $Id: autodetection.h,v 1.1 2007/05/11 15:41:53 jcsjcs Exp $
*/

#ifndef AUTODETECTION_H
#include "config.h"
void autodetection_init ();

#endif

Index: Makefile.am
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/Makefile.am,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- Makefile.am 27 Apr 2007 15:50:44 -0000      1.64
+++ Makefile.am 11 May 2007 15:41:50 -0000      1.65
@@ -27,6 +27,7 @@
 
 
 gtkpod_SOURCES = \
+    autodetection.c autodetection.h \
     charset.c charset.h \
     clientserver.c clientserver.h \
     confirmation.c confirmation.h \

Index: display_itdb.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/display_itdb.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- display_itdb.c      6 May 2007 14:16:15 -0000       1.67
+++ display_itdb.c      11 May 2007 15:41:53 -0000      1.68
@@ -839,32 +839,37 @@
     {
        /* databases have not been set up previously -- take care of
           this */
-       gchar *mountpoint, *filename;
-
-       /* iPod database */
-       mountpoint = prefs_get_string ("initial_mountpoint");
-       filename = g_build_filename (cfgdir, "iTunesDB", NULL);
-       prefs_set_int ("itdb_0_type", GP_ITDB_TYPE_IPOD);
-       prefs_set_string ("itdb_0_name", _("iPod"));
-       prefs_set_string ("itdb_0_filename", filename);
-       prefs_set_string ("itdb_0_mountpoint", mountpoint);
-       g_free (mountpoint);
-       g_free (filename);
+#ifndef HAVE_GNOME_VFS
+       gchar *mountpoint;
+#endif
+       gchar *filename;
 
        /* Local database */
        filename = g_build_filename (cfgdir, "local_0.itdb", NULL);
-       prefs_set_int ("itdb_1_type", GP_ITDB_TYPE_LOCAL);
-       prefs_set_string ("itdb_1_name", _("Local"));
-       prefs_set_string ("itdb_1_filename", filename);
+       prefs_set_int ("itdb_0_type", GP_ITDB_TYPE_LOCAL);
+       prefs_set_string ("itdb_0_name", _("Local"));
+       prefs_set_string ("itdb_0_filename", filename);
        g_free (filename);
 
        /* Podcasts database */
        filename = g_build_filename (cfgdir, "podcasts.itdb", NULL);
-       prefs_set_int ("itdb_2_type",
+       prefs_set_int ("itdb_1_type",
                       GP_ITDB_TYPE_PODCASTS|GP_ITDB_TYPE_LOCAL);
-       prefs_set_string ("itdb_2_name", _("Podcasts"));
+       prefs_set_string ("itdb_1_name", _("Podcasts"));
+       prefs_set_string ("itdb_1_filename", filename);
+       g_free (filename);
+
+#ifndef HAVE_GNOME_VFS
+       /* iPod database -- only set up if autodetection is not active */
+       mountpoint = prefs_get_string ("initial_mountpoint");
+       filename = g_build_filename (cfgdir, "iTunesDB", NULL);
+       prefs_set_int ("itdb_2_type", GP_ITDB_TYPE_IPOD);
+       prefs_set_string ("itdb_2_name", _("iPod"));
        prefs_set_string ("itdb_2_filename", filename);
+       prefs_set_string ("itdb_2_mountpoint", mountpoint);
+       g_free (mountpoint);
        g_free (filename);
+#endif
     }
 
 

Index: display_itdb.h
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/display_itdb.h,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- display_itdb.h      6 May 2007 14:16:15 -0000       1.43
+++ display_itdb.h      11 May 2007 15:41:53 -0000      1.44
@@ -90,8 +90,9 @@
 typedef enum
 {
     GP_ITDB_TYPE_LOCAL = 1<<0,    /* local browsing, normal music */
-    GP_ITDB_TYPE_IPOD  = 1<<1,    /* iPod */
-    GP_ITDB_TYPE_PODCASTS = 1<<2, /* local browsing, podcasts */
+    GP_ITDB_TYPE_IPOD  = 1<<1,    /* iPod                         */
+    GP_ITDB_TYPE_PODCASTS = 1<<2, /* local browsing, podcasts     */
+    GP_ITDB_TYPE_AUTOMATIC = 1<<3,/* repository was automounted   */
 } GpItdbType;
 
 /* Delete actions */

Index: file_convert.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/file_convert.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- file_convert.c      6 May 2007 14:16:17 -0000       1.8
+++ file_convert.c      11 May 2007 15:41:53 -0000      1.9
@@ -1712,11 +1712,13 @@
 
 /*     debug ("conversion_scheduler enter\n"); */
 
+    gdk_threads_enter();
     g_mutex_lock (conv->mutex);
 
     result = conversion_scheduler_unlocked (conv);
 
     g_mutex_unlock (conv->mutex);
+    gdk_threads_leave();
 
 /*    debug ("conversion_scheduler exit\n");*/
 

Index: file_itunesdb.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/file_itunesdb.c,v
retrieving revision 1.121
retrieving revision 1.122
diff -u -d -r1.121 -r1.122
--- file_itunesdb.c     6 May 2007 14:16:17 -0000       1.121
+++ file_itunesdb.c     11 May 2007 15:41:53 -0000      1.122
@@ -848,6 +848,9 @@
     mountpoint = get_itdb_prefs_string (itdb, KEY_MOUNTPOINT);
     call_script ("gtkpod.load", mountpoint, NULL);
 
+    /* read preferences keys from the iPod if available */
+    load_ipod_prefs (itdb, mountpoint);
+
     itdb_device_set_mountpoint (itdb->device, mountpoint);
 
     itunesdb = itdb_get_itunesdb_path (mountpoint);
@@ -969,25 +972,38 @@
     {
        gint index;
        gchar *mountpoint;
-       iTunesDB *new_itdb;
 
        mountpoint = get_itdb_prefs_string (itdb, KEY_MOUNTPOINT);
+
+       /* save prefs relevant for this iPod to the iPod */
+       save_ipod_prefs (itdb, mountpoint);
+
        call_script ("gtkpod.eject", mountpoint, FALSE);
        g_free (mountpoint);
 
        index = get_itdb_index (itdb);
-       new_itdb = setup_itdb_n (index);
-       if (new_itdb)
-       {
-           ExtraiTunesDBData *new_eitdb;
 
-           new_eitdb = new_itdb->userdata;
-           g_return_val_if_fail (new_eitdb, TRUE);
+       if (itdb->usertype & GP_ITDB_TYPE_AUTOMATIC)
+       {   /* remove itdb from display */
+           remove_itdb_prefs (itdb);
+           gp_itdb_remove (itdb);
+           gp_itdb_free (itdb);
+       }
+       else
+       {   /* switch to an empty itdb */
+           iTunesDB *new_itdb = setup_itdb_n (index);
+           if (new_itdb)
+           {
+               ExtraiTunesDBData *new_eitdb;
 
-           gp_replace_itdb (itdb, new_itdb);
+               new_eitdb = new_itdb->userdata;
+               g_return_val_if_fail (new_eitdb, TRUE);
 
-           new_eitdb->ipod_ejected = TRUE;
-       }
+               gp_replace_itdb (itdb, new_itdb);
+
+               new_eitdb->ipod_ejected = TRUE;
+           }
+       }
        return TRUE;
     }
     return FALSE;

Index: misc.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/misc.c,v
retrieving revision 1.221
retrieving revision 1.222
diff -u -d -r1.221 -r1.222
--- misc.c      23 Apr 2007 15:33:31 -0000      1.221
+++ misc.c      11 May 2007 15:41:53 -0000      1.222
@@ -38,6 +38,7 @@
 #include <sys/stat.h>
 #include <sys/wait.h>
 #include <unistd.h>
+#include "autodetection.h"
 #include "charset.h"
 #include "clientserver.h"
 #include "file_convert.h"
@@ -1404,7 +1405,51 @@
 }
 
 
-  gchar    *ipod_mount;     /* mount point of iPod */
+guint32 guiToDB(gint gui)
+{
+  guint32 db = 0;
+  switch (gui)
+    {
+    case 0: db = 0x00000000; break;
+    case 1: db = 0x00000001; break;
+    case 2: db = 0x00000002; break;
+    case 3: db = 0x00000004; break;
+    case 4: db = 0x00000006; break;
+    case 5: db = 0x00000008; break;
+    case 6: db = 0x00000020; break;
+    case 7: db = 0x00000040; break;
+    case 8: db = 0x00000060; break;
+    default:
+      /* This is an error */
+      g_warning ("Programming error: GUI is not in sync with Media Types.\n");
+      db = 0;
+    };
+
+  return db;
+}
+
+gint dbToGUI(guint32 db)
+{
+  gint gui = 0;
+  switch (db)
+    {
+    case 0x00000000: gui = 0; break;
+    case 0x00000001: gui = 1; break;
+    case 0x00000002: gui = 2; break;
+    case 0x00000004: gui = 3; break;
+    case 0x00000006: gui = 4; break;
+    case 0x00000008: gui = 5; break;
+    case 0x00000020: gui = 6; break;
+    case 0x00000040: gui = 7; break;
+    case 0x00000060: gui = 8; break;
+    default:
+      /* Warning */
+      g_warning ("Unknown media type found: %#.8x\n", db);
+      gui = 0;
+    };
+  return gui;
+}
+
 /* ------------------------------------------------------------
  *
  *        Helper functions for pref keys
@@ -1651,61 +1696,179 @@
     g_free (key);
 }
 
-/* retrieve offline mode from itdb (convenience function) */
-gboolean get_offline (iTunesDB *itdb)
+/**
+ * Helper function to remove all prefs strings for itdb @index and
+ * move all subsequent itdb strings forward. You can call this even
+ * after your have removed the itdb from itdbs_head.
+ * 
+ **/
+static void remove_itdb_index_prefs (gint index)
 {
-    ExtraiTunesDBData *eitdb;
+    struct itdbs_head *itdbs_head;
+    gchar *subkey;
+    gint i, n;
 
-    g_return_val_if_fail (itdb, FALSE);
-    eitdb = itdb->userdata;
-    g_return_val_if_fail (eitdb, FALSE);
+    itdbs_head = gp_get_itdbs_head (gtkpod_window);
+    g_return_if_fail (itdbs_head);
 
-    return eitdb->offline;
+    n = g_list_length (itdbs_head->itdbs);
+    subkey = get_itdb_prefs_key (index, "");
+    prefs_flush_subkey (subkey);
+    g_free (subkey);
+    
+    for (i=index; i<=n; ++i)
+    {
+       gchar *from_key = get_itdb_prefs_key (i+1, "");
+       gchar *to_key = get_itdb_prefs_key (i, "");
+       prefs_rename_subkey (from_key, to_key);
+       g_free (from_key);
+       g_free (to_key);
+    }
 }
 
-guint32 guiToDB(gint gui)
+
+/**
+ * Helper function to remove all prefs strings for @itdb and move all
+ * subsequent itdb strings forward. Call this before removing the itdb
+ * from itdbs_head.
+ * 
+ **/
+void remove_itdb_prefs (iTunesDB *itdb)
 {
-  guint32 db = 0;
-  switch (gui)
+    g_return_if_fail (itdb);
+
+    remove_itdb_index_prefs (get_itdb_index (itdb));
+}
+
+/* Save all itdb_<index>_* keys to the iPod
+ * (<ControlDir>/gtkpod.prefs).
+ *
+ * Return value: TRUE on succes, FALSE on error
+ */
+gboolean save_ipod_index_prefs (gint index, const gchar *mountpoint)
+{
+    TempPrefs *temp_prefs;
+    gboolean result = FALSE;
+    gchar *subkey, *dir;
+
+    g_return_val_if_fail (mountpoint, FALSE);
+
+    /* isolate all 'itdb_<index>_*' keys */
+    subkey = get_itdb_prefs_key (index, "");
+    temp_prefs = prefs_create_subset (subkey);
+
+    /* rename to 'itdb_*' */
+    temp_prefs_rename_subkey (temp_prefs, subkey, "itdb_");
+
+    /* remove some keys */
+    temp_prefs_remove_key (temp_prefs, "itdb_mountpoint");
+    temp_prefs_remove_key (temp_prefs, "itdb_name");
+    temp_prefs_remove_key (temp_prefs, "itdb_type");
+
+    /* build filename path */
+    dir = itdb_get_itunes_dir (mountpoint);
+    if (dir)
     {
-    case 0: db = 0x00000000; break;
-    case 1: db = 0x00000001; break;
-    case 2: db = 0x00000002; break;
-    case 3: db = 0x00000004; break;
-    case 4: db = 0x00000006; break;
-    case 5: db = 0x00000008; break;
-    case 6: db = 0x00000020; break;
-    case 7: db = 0x00000040; break;
-    case 8: db = 0x00000060; break;
-    default:
-      /* This is an error */
-      g_warning ("Programming error: GUI is not in sync with Media Types.\n");
-      db = 0;
-    };
+       GError *error = NULL;
+       gchar *path = g_build_filename (dir, "gtkpod.prefs", NULL);
+       result = temp_prefs_save (temp_prefs, path, &error);
+       if (result == FALSE)
+       {
+           gtkpod_warning (_("Writing preferences file '%s' failed (%s).\n\n"),
+                           path,
+                           error? error->message:_("unspecified error"));
+           g_error_free (error);
+       }
+       g_free (path);
+       g_free (dir);
+    }
+    else
+    {
+       gtkpod_warning (_("Writing preferences to the iPod (%s) failed: could 
not get path to Control Directory.\n\n"),
+                       mountpoint);
+    }
 
-  return db;
+    temp_prefs_destroy (temp_prefs);
+    g_free (subkey);
+
+    return result;
 }
 
-gint dbToGUI(guint32 db)
+
+
+/* Save all itdb_<index>_* keys to the iPod
+ * (<ControlDir>/gtkpod.prefs).
+ *
+ * Return value: TRUE on succes, FALSE on error
+ */
+gboolean save_ipod_prefs (iTunesDB *itdb, const gchar *mountpoint)
 {
-  gint gui = 0;
-  switch (db)
+    g_return_val_if_fail (itdb && mountpoint, FALSE);
+    return save_ipod_index_prefs (get_itdb_index (itdb), mountpoint);
+}
+
+
+/* Load preferences file from the iPod and merge them into the general
+ * prefs system.
+ */
+static void load_ipod_index_prefs (gint index, const gchar *mountpoint)
+{
+    gchar *dir;
+
+    g_return_if_fail (mountpoint);
+
+    /* build filename path */
+    dir = itdb_get_itunes_dir (mountpoint);
+    if (dir)
     {
-    case 0x00000000: gui = 0; break;
-    case 0x00000001: gui = 1; break;
-    case 0x00000002: gui = 2; break;
-    case 0x00000004: gui = 3; break;
-    case 0x00000006: gui = 4; break;
-    case 0x00000008: gui = 5; break;
-    case 0x00000020: gui = 6; break;
-    case 0x00000040: gui = 7; break;
-    case 0x00000060: gui = 8; break;
-    default:
-      /* Warning */
-      g_warning ("Unknown media type found: %#.8x\n", db);
-      gui = 0;
-    };
-  return gui;
+       TempPrefs *temp_prefs;
+       GError *error = NULL;
+       gchar *path = g_build_filename (dir, "gtkpod.prefs", NULL);
+       temp_prefs = temp_prefs_load (path, &error);
+       if (temp_prefs)
+       {
+           gchar *subkey;
+           subkey = get_itdb_prefs_key (index, "");
+           /* rename 'itdb_*' to 'itdb_<index>_*' */
+           temp_prefs_rename_subkey (temp_prefs, "itdb_", subkey);
+           /* merge with real prefs */
+           temp_prefs_apply (temp_prefs);
+           /* destroy temp prefs */
+           temp_prefs_destroy (temp_prefs);
+       }
+       else
+       {
+           /* we ignore errors -- no need to be concerned about them */
+           g_error_free (error);
+       }
+       g_free (dir);
+    }
+}
+
+
+
+/* Load preferences file from the iPod and merge them into the general
+ * prefs system.
+ */
+void load_ipod_prefs (iTunesDB *itdb, const gchar *mountpoint)
+{
+    g_return_if_fail (mountpoint);
+    load_ipod_index_prefs (get_itdb_index (itdb), mountpoint);
+}
+
+
+
+
+/* retrieve offline mode from itdb (convenience function) */
+gboolean get_offline (iTunesDB *itdb)
+{
+    ExtraiTunesDBData *eitdb;
+
+    g_return_val_if_fail (itdb, FALSE);
+    eitdb = itdb->userdata;
+    g_return_val_if_fail (eitdb, FALSE);
+
+    return eitdb->offline;
 }
 
 /* ----------------------------------------------------------------
@@ -1786,7 +1949,7 @@
     file_convert_init ();
 
     display_create ();
-       
+
     gtk_widget_show (gtkpod_window);
 
     init_data (gtkpod_window);   /* setup base data, importing all local
@@ -1795,9 +1958,8 @@
     /* stuff to be done before starting gtkpod */
     call_script ("gtkpod.in", NULL);
 
-    if(prefs_get_int("autoimport") || prefs_get_int("autoimport_commandline"))
-       gp_load_ipods ();
-
+    autodetection_init ();
+       
     server_setup ();   /* start server to accept playcount updates */
 }
 

Index: misc.h
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/misc.h,v
retrieving revision 1.126
retrieving revision 1.127
diff -u -d -r1.126 -r1.127
--- misc.h      23 Apr 2007 15:33:31 -0000      1.126
+++ misc.h      11 May 2007 15:41:53 -0000      1.127
@@ -259,6 +259,10 @@
 void set_itdb_prefs_int (iTunesDB *itdb, const gchar *subkey, gint value);
 void set_itdb_index_prefs_int (gint index,
                               const gchar *subkey, gint value);
+void remove_itdb_prefs (iTunesDB *itdb);
+void load_ipod_prefs (iTunesDB *itdb, const gchar *mountpoint);
+gboolean save_ipod_prefs (iTunesDB *itdb, const gchar *mountpoint);
+
 gboolean get_offline (iTunesDB *itdb);
 
 guint32 guiToDB(gint gui);

Index: misc_input.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/misc_input.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- misc_input.c        7 Jun 2006 05:03:43 -0000       1.14
+++ misc_input.c        11 May 2007 15:41:53 -0000      1.15
@@ -1,4 +1,4 @@
-/* Time-stamp: <2006-05-20 23:23:44 jcs>
+/* Time-stamp: <2007-05-10 00:39:18 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.286
retrieving revision 1.287
diff -u -d -r1.286 -r1.287
--- prefs.c     11 May 2007 11:45:52 -0000      1.286
+++ prefs.c     11 May 2007 15:41:53 -0000      1.287
@@ -93,6 +93,13 @@
 /* End-of-list marker for variable-length lists */
 #define LIST_END_MARKER "----++++----"
 
+struct temp_prefs_save
+{
+    GIOChannel *gio;
+    GError **error;
+    gboolean success;
+};
+
 struct sub_data
 {
     TempPrefs *temp_prefs;
@@ -131,7 +138,6 @@
   GP_HELP,
   GP_PLAYCOUNT,
   GP_MOUNT,
-  GP_AUTO,
   GP_PRINT_HASH,
 };
 
@@ -265,7 +271,6 @@
     prefs_set_int("size_file_dialog_details.x", 320);
     prefs_set_int("size_file_dialog_details.y", 140);
 
-    prefs_set_int("autoimport", FALSE);
     prefs_set_int("readtags", TRUE);
     prefs_set_int("write_extended_info", TRUE);
     prefs_set_int("parsetags", FALSE);
@@ -372,8 +377,6 @@
            { "hash",        required_argument, NULL, GP_PRINT_HASH },
            { "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 }
        };
        
@@ -397,9 +400,6 @@
        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);
@@ -508,7 +508,7 @@
 
 /* Add key/value to temp_prefs if it matches subkey -- called by
  * prefs_create_subset() and temp_prefs_create_subset() */
-gboolean get_subset (gpointer key, gpointer value, gpointer user_data)
+static gboolean get_subset (gpointer key, gpointer value, gpointer user_data)
 {
     struct sub_data *sub_data = user_data;
 
@@ -565,55 +565,65 @@
     return folder;
 }
 
+
+/* get @key and @value from a string like "key=value" */
+static gboolean read_prefs_get_key_value (const gchar *buf,
+                                         gchar **key, gchar **value)
+{
+    size_t len;  /* string length */
+    const gchar *buf_start; /* Pointer to where actual useful data starts in 
line */
+
+    g_return_val_if_fail (buf && key && value, FALSE);
+
+    /* Strip out any comments (lines that begin with ; or #) */
+    if ((buf[0] == ';') || (buf[0] == '#')) 
+       return FALSE;
+
+    /* Find the key and value, and look for malformed lines */
+    buf_start = strchr (buf, '=');
+
+    if ((!buf_start) || (buf_start == buf))
+    {
+       printf("Parse error reading prefs: %s", buf);
+       return FALSE;
+    }
+
+    /* Find the key name */
+    *key = g_strndup (buf, (buf_start - buf));
+
+    /* Strip whitespace */
+    g_strstrip (*key);
+
+    /* Find the value string */
+    *value = strdup (buf_start+1);
+
+    /* remove newline */
+    len = strlen (*value);
+    if ((len > 0) && ((*value)[len - 1] == 0x0a))
+       (*value)[len - 1] = 0;
+
+    /* Strip whitespace */
+    g_strstrip (*value);
+
+    return TRUE;
+}
+
+
 /* Read preferences from a file */
 static void read_prefs_from_file(FILE *fp)
 {
     gchar buf[PATH_MAX];  /* Buffer that contains one line */
-    gchar *buf_start; /* Pointer to where actual useful data starts in line */
     gchar *key;  /* Pref value key */
     gchar *value; /* Pref value */
-    size_t len;  /* string length */
-       
-    if (fp)
+
+
+    g_return_if_fail (prefs_table && fp);
+
+    while (fgets(buf, PATH_MAX, fp))
     {
-       while (fgets(buf, PATH_MAX, fp))
+       if (read_prefs_get_key_value (buf, &key, &value))
        {
-           /* Strip out any comments (lines that begin with ; or #) */
-           if ((buf[0] == ';') || (buf[0] == '#')) 
-               continue;
-                       
-           /* Find the key and value, and look for malformed lines */
-           value = strchr(buf, '=');
-                       
-           if ((!value) || (value == buf))
-               printf("Parse error reading prefs: %s", buf);
-                       
-           /* Strip off whitespace */
-           buf_start = buf;
-                       
-           while (g_ascii_isspace(*buf_start))
-               buf_start++;
-                       
-           /* Find the key name */
-           key = g_strndup(buf, (value - buf_start));
-           value++;
-                       
-           /* remove newline */
-           len = strlen(value);
-                       
-           if ((len > 0) && (value[len - 1] == 0x0a))
-               value[len - 1] = 0;
-                       
-           /* Strip whitespace off the key value */
-           while (g_ascii_isspace(*value))
-               value++;
-                       
-           /* Finally, load each key/value pair into the pref hash table */
-           if (prefs_table)
-           {
-               g_hash_table_insert(prefs_table, (gpointer)key, 
-                                   (gpointer)g_strdup(value));
-           }
+           g_hash_table_insert (prefs_table, key, value);
        }
     }
 }
@@ -705,6 +715,98 @@
     }
 }
 
+
+static gboolean temp_prefs_save_fe (gchar *key, gchar *value,
+                                   struct temp_prefs_save *tps)
+{
+    gchar *buf;
+    GIOStatus status;
+
+    buf=g_strdup_printf ("%s=%s\n", key, value);
+    status = g_io_channel_write_chars (tps->gio, buf, -1, NULL, tps->error);
+    g_free (buf);
+    if (status != G_IO_STATUS_NORMAL)
+    {
+       tps->success = FALSE;
+       return TRUE;  /* stop traversal */
+    }
+    return FALSE;
+}
+
+
+/* Save @temp_prefs to @filename in the same manner as prefs_save is
+ * saving to ~/.gtkpod/prefs. @error: location where to store
+ * information about errors or NULL.
+ * 
+ * Return value: TRUE on success, FALSE if an error occured, in which
+ * case @error will be set accordingly.
+ */
+gboolean temp_prefs_save (TempPrefs *temp_prefs,
+                         const gchar *filename,
+                         GError **error)
+{
+    GIOChannel *gio;
+    struct temp_prefs_save tps;
+
+    g_return_val_if_fail (temp_prefs && filename, FALSE);
+
+    gio = g_io_channel_new_file (filename, "w", error);
+    tps.gio = gio;
+    tps.error = error;
+    tps.success = TRUE;
+    if (gio)
+    {
+       g_tree_foreach (temp_prefs->tree, (GTraverseFunc)temp_prefs_save_fe, 
&tps);
+       g_io_channel_unref (gio);
+    }
+
+    return tps.success;
+}
+
+
+TempPrefs *temp_prefs_load (const gchar *filename, GError **error)
+{
+    GIOChannel *gio;
+    TempPrefs *temp_prefs = NULL;
+
+    g_return_val_if_fail (filename, NULL);
+
+    gio = g_io_channel_new_file (filename, "r", error);
+    if (gio)
+    {
+       GIOStatus status;
+
+       temp_prefs = temp_prefs_create ();
+
+       do
+       {
+           gchar *line;
+
+           status = g_io_channel_read_line (gio, &line, NULL, NULL, error);
+           if (status == G_IO_STATUS_NORMAL)
+           {
+               gchar *key, *value;
+               if (read_prefs_get_key_value (line, &key, &value))
+               {
+                   temp_prefs_set_string (temp_prefs, key, value);
+               }
+               g_free (line);
+           }
+       } while (status == G_IO_STATUS_NORMAL);
+
+       g_io_channel_unref (gio);
+
+       if (status != G_IO_STATUS_EOF)
+       {
+           temp_prefs_destroy (temp_prefs);
+           temp_prefs = NULL;
+       }
+    }
+
+    return temp_prefs;
+}
+
+
 /* Removes already existing list keys from the prefs table */
 static void wipe_list(const gchar *key)
 {
@@ -935,6 +1037,8 @@
     prefs_set_string("size_file_dialog.y", NULL);
     prefs_set_string("size_file_dialog_details.x", NULL);
     prefs_set_string("size_file_dialog_details.y", NULL);
+    prefs_set_string("autoimport", NULL);
+    prefs_set_string("auto_import", NULL);
 
     /* sp_created_cond renamed to sp_added_cond */
     for (i = 0; i < SORT_TAB_MAX; i++)
@@ -1006,13 +1110,6 @@
        prefs_set_string("size_info.y", NULL);
     }
     
-    /* auto_import reanmed to autoimport */
-    if (prefs_get_int_value("auto_import", &int_buf))
-    {
-       prefs_set_int("autoimport", int_buf);
-       prefs_set_string("auto_import", NULL);
-    }
-
     /* not_played_song renamed to not_played_track */
     if (prefs_get_int_value("not_played_song", &int_buf))
     {
@@ -1146,7 +1243,7 @@
 
 /* Create the temp prefs tree */
 /* Free the returned structure with delete_temp_prefs() */
-TempPrefs *temp_prefs_create()
+TempPrefs *temp_prefs_create ()
 {
     TempPrefs *temp_prefs;  /* Retunred temp prefs structure */
 
@@ -1159,7 +1256,7 @@
 }
 
 /* Delete temp prefs */
-void temp_prefs_destroy(TempPrefs *temp_prefs)
+void temp_prefs_destroy (TempPrefs *temp_prefs)
 {
     g_return_if_fail (temp_prefs);
     g_return_if_fail (temp_prefs->tree);
@@ -1169,7 +1266,7 @@
 }
 
 /* Copy key data from the temp prefs tree to the hash table */
-static gboolean copy_key(gpointer key, gpointer value, gpointer user_data)
+static gboolean copy_key (gpointer key, gpointer value, gpointer user_data)
 {
     prefs_set_string(key, value);
        
@@ -1177,7 +1274,7 @@
 }
 
 /* Copy the data from the temp prefs tree to the permanent prefs table */
-void temp_prefs_apply(TempPrefs *temp_prefs)
+void temp_prefs_apply (TempPrefs *temp_prefs)
 {
     g_return_if_fail (temp_prefs);
     g_return_if_fail (temp_prefs->tree);
@@ -1188,7 +1285,7 @@
 
 /* Create a temp_prefs tree containing a subset of keys in the
    permanent prefs table (those starting with @subkey */
-static TempPrefs *prefs_create_subset (const gchar *subkey)
+static TempPrefs *prefs_create_subset_unlocked (const gchar *subkey)
 {
     struct sub_data sub_data;
 
@@ -1202,6 +1299,21 @@
     return sub_data.temp_prefs;
 }
 
+/* Create a temp_prefs tree containing a subset of keys in the
+   permanent prefs table (those starting with @subkey */
+TempPrefs *prefs_create_subset (const gchar *subkey)
+{
+    TempPrefs *temp_prefs;
+
+    lock_prefs_table ();
+
+    temp_prefs = prefs_create_subset_unlocked (subkey);
+
+    unlock_prefs_table ();
+
+    return temp_prefs;
+}
+
 
 /* Create a temp_prefs tree containing a subset of keys in the
    permanent prefs table (those starting with @subkey */
@@ -1224,7 +1336,7 @@
 
 /* Remove all keys in the temp prefs tree from the permanent prefs
    table */
-void temp_prefs_flush(TempPrefs *temp_prefs)
+void temp_prefs_flush (TempPrefs *temp_prefs)
 {
     g_return_if_fail (temp_prefs);
     g_return_if_fail (temp_prefs->tree);
@@ -1299,7 +1411,7 @@
        g_return_if_reached ();
     }
 
-    sub_data.temp_prefs = prefs_create_subset (subkey_old);
+    sub_data.temp_prefs = prefs_create_subset_unlocked (subkey_old);
     sub_data.temp_prefs_orig = NULL;
 
     if (temp_prefs_size (sub_data.temp_prefs) > 0)
@@ -1775,7 +1887,7 @@
  * 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, 
+void temp_prefs_set_string (TempPrefs *temp_prefs, const gchar *key, 
                           const gchar *value)
 {
     g_return_if_fail (temp_prefs && temp_prefs->tree);

Index: prefs.h
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/prefs.h,v
retrieving revision 1.197
retrieving revision 1.198
diff -u -d -r1.197 -r1.198
--- prefs.h     15 Apr 2007 11:31:40 -0000      1.197
+++ prefs.h     11 May 2007 15:41:53 -0000      1.198
@@ -128,6 +128,7 @@
 gboolean prefs_get_double_value_index(const gchar *key, guint index,
                                      gdouble *value);
 /* Special functions */
+TempPrefs *prefs_create_subset (const gchar *subkey);
 void prefs_flush_subkey (const gchar *subkey);
 void prefs_rename_subkey (const gchar *subkey_old, const gchar *subkey_new);
 void temp_prefs_rename_subkey (TempPrefs *temp_prefs,
@@ -140,6 +141,10 @@
  * Temp prefs functions
  */
 TempPrefs *temp_prefs_create (void);
+TempPrefs *temp_prefs_load (const gchar *filename, GError **error);
+gboolean temp_prefs_save (TempPrefs *temp_prefs,
+                         const gchar *filename,
+                         GError **error);
 TempPrefs *temp_prefs_create_subset (TempPrefs *temp_prefs,
                                     const gchar *subkey);
 void temp_prefs_destroy (TempPrefs *temp_prefs);

Index: prefs_window.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/prefs_window.c,v
retrieving revision 1.199
retrieving revision 1.200
diff -u -d -r1.199 -r1.200
--- prefs_window.c      6 May 2007 14:16:17 -0000       1.199
+++ prefs_window.c      11 May 2007 15:41:53 -0000      1.200
@@ -518,10 +518,6 @@
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
                                 prefs_get_int("delete_database"));
 
-    w = gtkpod_xml_get_widget (prefs_window_xml,  "cfg_autoimport");
-    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
-                                prefs_get_int("autoimport"));
-
 #if 0
     /* last.fm -- disabled, we'll hide the prefs window */
     int x = prefs_get_int("lastfm_active");
@@ -1199,14 +1195,6 @@
 
 
 void
-on_cfg_autoimport_toggled              (GtkToggleButton *togglebutton,
-                                       gpointer         user_data)
-{
-    temp_prefs_set_int(temp_prefs, "autoimport",
-                      gtk_toggle_button_get_active(togglebutton));
-}
-
-void
 on_charset_combo_entry_changed          (GtkEditable     *editable,
                                        gpointer         user_data)
 {

Index: tools.c
===================================================================
RCS file: /cvsroot/gtkpod/gtkpod/src/tools.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- tools.c     18 Jan 2007 16:54:07 -0000      1.51
+++ tools.c     11 May 2007 15:41:53 -0000      1.52
@@ -1,4 +1,4 @@
-/* Time-stamp: <2007-01-19 01:52:28 jcs>
+/* Time-stamp: <2007-05-09 22:23:27 jcs>
 |
 |  Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users sourceforge net>
 |  Part of the gtkpod project.
@@ -562,7 +562,7 @@
 
     if (!itdb) return;
 
-    ipod_mount = get_itdb_prefs_string (itdb, "mountpoint");
+    ipod_mount = get_itdb_prefs_string (itdb, KEY_MOUNTPOINT);
 
     if (!ipod_mount) ipod_mount = g_strdup ("");
 


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2

Reply via email to